From 9097013b3b5669f7f63500a1b34f362d7baeb2b2 Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Mon, 23 Dec 2019 21:42:30 -0500 Subject: [PATCH] Fix #502: add os_radio(RADIO_TX_AT), version is 3.0.99.8 --- doc/RadioDriver.md | 10 ++++++++-- src/lmic/lmic.h | 4 ++-- src/lmic/radio.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/RadioDriver.md b/doc/RadioDriver.md index 60d8533c..1473e613 100644 --- a/doc/RadioDriver.md +++ b/doc/RadioDriver.md @@ -71,6 +71,10 @@ The radio is placed in continuous receive mode. If a frame is received, `LMIC.os This operation is not supported in FSK mode. +### `os_radio(RADIO_TX_AT)` + +This is like `os_radio(RADIO_TX)`, but the transmission is scheduled at `LMIC.txend`. + ## Common parameters ### `LMIC.rps` (IN) @@ -109,9 +113,11 @@ The array of data to be sent. The length of the array to be sent. -### `LMIC.txend` (OUT) +### `LMIC.txend` (IN, OUT) + +For `RADIO_TX_AT`, an input parameter, for the scheduled TX time. -The OS time at which the TX end interrupt was recognized. +For all transmissions, updated to the OS time at which the TX end interrupt was recognized. ## Receive parameters diff --git a/src/lmic/lmic.h b/src/lmic/lmic.h index 564d9aff..f12ffcf1 100644 --- a/src/lmic/lmic.h +++ b/src/lmic/lmic.h @@ -105,7 +105,7 @@ extern "C"{ #define ARDUINO_LMIC_VERSION_CALC(major, minor, patch, local) \ (((major) << 24ul) | ((minor) << 16ul) | ((patch) << 8ul) | ((local) << 0ul)) -#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(3, 0, 99, 7) /* v3.0.99.7 */ +#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(3, 0, 99, 8) /* v3.0.99.8 */ #define ARDUINO_LMIC_VERSION_GET_MAJOR(v) \ (((v) >> 24u) & 0xFFu) @@ -219,7 +219,7 @@ struct bcninfo_t { #endif // !DISABLE_BEACONS // purpose of receive window - lmic_t.rxState -enum { RADIO_RST=0, RADIO_TX=1, RADIO_RX=2, RADIO_RXON=3 }; +enum { RADIO_RST=0, RADIO_TX=1, RADIO_RX=2, RADIO_RXON=3, RADIO_TX_AT=4, }; // Netid values / lmic_t.netid enum { NETID_NONE=(int)~0U, NETID_MASK=(int)0xFFFFFF }; // MAC operation modes (lmic_t.opmode). diff --git a/src/lmic/radio.c b/src/lmic/radio.c index b16a5b2e..de5c567d 100644 --- a/src/lmic/radio.c +++ b/src/lmic/radio.c @@ -781,6 +781,8 @@ static void txfsk () { hal_pin_rxtx(1); // now we actually start the transmission + if (LMIC.txend) + hal_waitUntil(LMIC.txend); // busy wait until exact rx time LMICOS_logEventUint32("+Tx FSK", LMIC.dataLen); opmode(OPMODE_TX); } @@ -826,6 +828,8 @@ static void txlora () { hal_pin_rxtx(1); // now we actually start the transmission + if (LMIC.txend) + hal_waitUntil(LMIC.txend); // busy wait until exact rx time LMICOS_logEventUint32("+Tx LoRa", LMIC.dataLen); opmode(OPMODE_TX); @@ -1350,9 +1354,16 @@ void os_radio (u1_t mode) { case RADIO_TX: // transmit frame now + LMIC.txend = 0; starttx(); // buf=LMIC.frame, len=LMIC.dataLen break; + case RADIO_TX_AT: + if (LMIC.txend == 0) + LMIC.txend = 1; + starttx(); + break; + case RADIO_RX: // receive frame now (exactly at rxtime) startrx(RXMODE_SINGLE); // buf=LMIC.frame, time=LMIC.rxtime, timeout=LMIC.rxsyms