matthijskooijman / arduino-lmic

:warning: This library is deprecated, see the README for alternatives.
704 stars 651 forks source link

OTAA, ADR and LMIC_setLinkCheckMode #284

Open hackdaworld opened 4 years ago

hackdaworld commented 4 years ago

Hi all,

just a quick question concerning ADR and link check validation.

Afaics, ADR is enabled by default since in LMIC_reset(), LMIC.adrEnabled ist set to FCT_ADREN. In the example code (OTAA), link check validation is disabled once the node joined.

    case EV_JOINED:
      Serial.println(F("EV_JOINED"));
      // Disable link check validation (automatically enabled
      // during join, but not supported by TTN at this time).
      LMIC_setLinkCheckMode(0);
      break;
which essentially sets adrAckReq to LINK_CHECK_OFF
void LMIC_setLinkCheckMode (bit_t enabled) {
    LMIC.adrChanged = 0;
    LMIC.adrAckReq = enabled ? LINK_CHECK_INIT : LINK_CHECK_OFF;
}
However, since ADR is enabled and once the network sends MAC commands that result in data rate optimizations, link check validation is enabled again.
    if( LMIC.adrChanged ) {
        if( LMIC.adrAckReq < 0 )
            LMIC.adrAckReq = 0;
        LMIC.adrChanged = 0;
    }
Which makes sense of course since the node just changed its data rate and it needs to validate that the network still receives the uplink frames. To put it in a nutshell, since ADR is enabled by default, disabling link check validation of a node that joins a network supporting/utilizing ADR is useless (but in the same time doesn't harm). Can somebody confirm this? Thanks and all the best, Frank