lorawan.cpp: TTN SF9 RX2 patch

This commit is contained in:
Verkehrsrot 2019-10-06 13:17:35 +02:00
parent b796fd79af
commit 921d377cd2

View File

@ -486,6 +486,19 @@ void lmictask(void *pvParameters) {
LMIC_reset(); // initialize lmic MAC LMIC_reset(); // initialize lmic MAC
LMIC_setLinkCheckMode(0); LMIC_setLinkCheckMode(0);
#if defined(CFG_eu868)
// Note that The Things Network uses the non-standard SF9BW125 data rate for
// RX2 in Europe and switches between RX1 and RX2 based on network congestion.
// Thus, to avoid occasionally join failures, we set datarate to SF9 and
// bypass the LORAWAN spec-compliant RX2 == SF12 setting
LMIC_setDrTxpow(EU868_DR_SF9, KEEP_TXPOW);
#else
// Set the data rate to Spreading Factor 7. This is the fastest supported
// rate for 125 kHz channels, and it minimizes air time and battery power.
// Set the transmission power to 14 dBi (25 mW).
LMIC_setDrTxpow(DR_SF7, 14);
#endif
// This tells LMIC to make the receive windows bigger, in case your clock is // This tells LMIC to make the receive windows bigger, in case your clock is
// faster or slower. This causes the transceiver to be earlier switched on, // faster or slower. This causes the transceiver to be earlier switched on,
// so consuming more power. You may sharpen (reduce) CLOCK_ERROR_PERCENTAGE // so consuming more power. You may sharpen (reduce) CLOCK_ERROR_PERCENTAGE
@ -503,11 +516,6 @@ void lmictask(void *pvParameters) {
LMIC_selectSubBand(1); LMIC_selectSubBand(1);
#endif #endif
// Set the data rate to Spreading Factor 7. This is the fastest supported
// rate for 125 kHz channels, and it minimizes air time and battery power.
// Set the transmission power to 14 dBi (25 mW).
LMIC_setDrTxpow(DR_SF7, 14);
// register a callback for downlink messages. We aren't trying to write // register a callback for downlink messages. We aren't trying to write
// reentrant code, so pUserData is NULL. // reentrant code, so pUserData is NULL.
LMIC_registerRxMessageCb(myRxCallback, NULL); LMIC_registerRxMessageCb(myRxCallback, NULL);