From 66fd1be545d624e5a1c74c1b1c0cc1a8786fc96d Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Mon, 16 Aug 2021 17:17:29 +0200 Subject: [PATCH 1/2] Add getters for RX1 and RX2 windows --- src/MKRWAN.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/MKRWAN.h b/src/MKRWAN.h index 7f1447a..5ee5679 100644 --- a/src/MKRWAN.h +++ b/src/MKRWAN.h @@ -618,6 +618,37 @@ class LoRaModem : public Stream return false; } + /** + * Returns the delay between the end of the Tx and the Rx Window 1 in ms. + * This may get changed automatically based on a network server's preference after joining it. + * This can be used to determine the wait time after a poll() call until data is available. + * Data will be available earliest after the RX1 window has passed. + * E.g. + * modem.poll(); + * delay(modem.getRX1Delay() + 1000); + * */ + long getRX1Delay(){ + sendAT(GF("+RX1DL?")); + if (waitResponse("+OK=") == 1) { + return stream.readStringUntil('\r').toInt(); + } + return -1; + } + + /** + * Returns the delay between the end of the Tx and the Rx Window 2 in ms. + * This may get changed automatically based on a network server's preference after joining it. + * This can be used to determine the wait time after a poll() call until data is available. + * @see getRX1Delay() + * */ + long getRX2Delay(){ + sendAT(GF("+RX2DL?")); + if (waitResponse() == 1) { + return stream.readStringUntil('\r').toInt(); + } + return -1; + } + String version() { sendAT(GF("+DEV?")); if (waitResponse("+OK=") == 1) { From 2e86755246d3673c7c015b095e59cddc2c26699e Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Mon, 16 Aug 2021 17:34:46 +0200 Subject: [PATCH 2/2] Clarify on demodulation time --- src/MKRWAN.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MKRWAN.h b/src/MKRWAN.h index 5ee5679..09a3e38 100644 --- a/src/MKRWAN.h +++ b/src/MKRWAN.h @@ -625,7 +625,9 @@ class LoRaModem : public Stream * Data will be available earliest after the RX1 window has passed. * E.g. * modem.poll(); - * delay(modem.getRX1Delay() + 1000); + * delay(modem.getRX1Delay() + 2000); + * Take into account the time required to demodulate the downlink message. + * At Spreading Factor 12 it can take more than two seconds while at SF7, it will take less than 100 ms. * */ long getRX1Delay(){ sendAT(GF("+RX1DL?"));