Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoRa node encounters failure in txfsk() #193

Open
utkarshshah007 opened this issue Aug 20, 2018 · 2 comments
Open

LoRa node encounters failure in txfsk() #193

utkarshshah007 opened this issue Aug 20, 2018 · 2 comments

Comments

@utkarshshah007
Copy link

utkarshshah007 commented Aug 20, 2018

After running for about an hour using a slight modification of ttn-otaa (just sending unheard join requests, the TTN gateway I'm using is disconnected), my LoRa end node hits:

FAILURE /.../Arduino/libraries/IBM_LMIC_framework/src/lmic/radio.c:429

This corresponds to an early assert in the txfsk() method. However, this node should be running in Lora mode, not FSK mode.

I assume this means that getSf(LMIC.rps) == FSK must be true. I've set my downlink datarate to SF9, as suggested in the ttn-otaa example.

Why might my end node be in FSK mode? How do I change this?

@utkarshshah007
Copy link
Author

I was able to discover the source of this issue.

For US-915, the datarate for joining is set in lmic.c as follows:

if( LMIC.datarate != DR_SF8C ) {
        LMIC.txChnl = 64+(LMIC.txChnl&7);
        setDrJoin(DRCHG_SET, DR_SF8C);
    } else {
        LMIC.txChnl = os_getRndU1() & 0x3F;
        s1_t dr = DR_SF7 - ++LMIC.txCnt;
        if( dr < DR_SF10 ) {
            dr = DR_SF10;
            failed = 1; // All DR exhausted - signal failed
        }
        setDrJoin(DRCHG_SET, dr);
    }

When LMIC.txCnt reaches 132, dr becomes -129.
However, dr is an 8-bit signed integer, which means that it’s minimum value is -128. Therefore, it overflows and becomes +127.

utkarshshah007 added a commit to utkarshshah007/arduino-lmic that referenced this issue Sep 1, 2018
This PR provides a solution for matthijskooijman#193

Currently, if there are more than 132 failed Join requests, the datarate will overflow, and the "override to SF10" behavior will fail. This eventually leads to a failure and execution halt. 

This change allows everything to function as intended, until the txCnt increases past 255, at which point it will simply start again from 0 without a failure.
@utkarshshah007
Copy link
Author

Here's a PR that solves this issue: #197

ngraziano pushed a commit to ngraziano/arduino-lmic that referenced this issue Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant