GrumpyOldPizza / ArduinoCore-stm32l0

Arduino Core for STM32L0
125 stars 67 forks source link

LoRaWAN.disableChannel() not working? #5

Closed BoelD closed 6 years ago

BoelD commented 6 years ago

Hi,

I am trying to setup a single channel node, so that I can combine it with a single channel gateway. I am using the Add B-L072Z-LRWAN1 in combination with your (great!) library.

I found LoRaWAN.disableChannel() by snooping into the source coude and figured I could use this to, well, disable channels. So that I end up with a single channel gateway. So my setup now looks like this:

void setup( void ) { LoRaWAN.begin(EU868);

for (unsigned int x = 1; x <=15; x++) {
LoRaWAN.disableChannel(x); } // LoRaWAN.setADR(false); LoRaWAN.setDataRate(0); LoRaWAN.setTxPower(10); LoRaWAN.setSubBand(2); // for TTN LoRaWAN.joinOTAA(appEui, appKey, devEui); }

But... There are still transmissions on other channels than 0 as well, as you can see on the screenshot below.

image

Am I using disableChannel() wrong, or could it be something else is wrong?

Thanks,

David

GrumpyOldPizza commented 6 years ago

Semi-bug.

You set the initial mask. However the JOIN_ACCEPT reply from the gateway will most likely add channel 4/5/6/7/8.

So you need to put the channel disable post the joinOTAA().

On Tue, Apr 17, 2018 at 1:42 PM, David Boelee notifications@github.com wrote:

Hi,

I am trying to setup a single channel node, so that I can combine it with a single channel gateway. I am using the Add B-L072Z-LRWAN1 in combination with your (great!) library.

I found LoRaWAN.disableChannel() by snooping into the source coude and figured I could use this to, well, disable channels. So that I end up with a single channel gateway. So my setup now looks like this:

void setup( void ) { LoRaWAN.begin(EU868);

for (unsigned int x = 1; x <=15; x++) { LoRaWAN.disableChannel(x); } // LoRaWAN.setADR(false); LoRaWAN.setDataRate(0); LoRaWAN.setTxPower(10); LoRaWAN.setSubBand(2); // for TTN LoRaWAN.joinOTAA(appEui, appKey, devEui); }

But... There are still transmissions on other channels than 0 as well, as you can see on the screenshot below.

[image: image] https://user-images.githubusercontent.com/23418587/38892599-fdc84c2a-4287-11e8-8f59-db99e72851a9.png

Am I using disableChannel() wrong, or could it be something else is wrong?

Thanks,

David

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfHdOT6s6NzJS_fguYSINIsprOMocks5tpkWSgaJpZM4TY7eE .

BoelD commented 6 years ago

Ah! That makes sense. Not even a semi-bug, but just how the protocol works. Thanks for your quich answer.

Op di 17 apr. 2018 22:00 schreef Thomas Roell notifications@github.com:

Semi-bug.

You set the initial mask. However the JOIN_ACCEPT reply from the gateway will most likely add channel 4/5/6/7/8.

So you need to put the channel disable post the joinOTAA().

On Tue, Apr 17, 2018 at 1:42 PM, David Boelee notifications@github.com wrote:

Hi,

I am trying to setup a single channel node, so that I can combine it with a single channel gateway. I am using the Add B-L072Z-LRWAN1 in combination with your (great!) library.

I found LoRaWAN.disableChannel() by snooping into the source coude and figured I could use this to, well, disable channels. So that I end up with a single channel gateway. So my setup now looks like this:

void setup( void ) { LoRaWAN.begin(EU868);

for (unsigned int x = 1; x <=15; x++) { LoRaWAN.disableChannel(x); } // LoRaWAN.setADR(false); LoRaWAN.setDataRate(0); LoRaWAN.setTxPower(10); LoRaWAN.setSubBand(2); // for TTN LoRaWAN.joinOTAA(appEui, appKey, devEui); }

But... There are still transmissions on other channels than 0 as well, as you can see on the screenshot below.

[image: image] < https://user-images.githubusercontent.com/23418587/38892599-fdc84c2a-4287-11e8-8f59-db99e72851a9.png

Am I using disableChannel() wrong, or could it be something else is wrong?

Thanks,

David

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5, or mute the thread < https://github.com/notifications/unsubscribe-auth/AG4QfHdOT6s6NzJS_fguYSINIsprOMocks5tpkWSgaJpZM4TY7eE

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-382122787, or mute the thread https://github.com/notifications/unsubscribe-auth/AWVW23sOfgYtnoNe1dpqwosHRch9_fi5ks5tpknIgaJpZM4TY7eE .

GrumpyOldPizza commented 6 years ago

Yeah, too a bit to find out. There is also this issue of enabling/disabling default channels. I had thought that it might enable the default channels behind you back, post OTAA join.

On Tue, Apr 17, 2018 at 2:55 PM, David Boelee notifications@github.com wrote:

Ah! That makes sense. Not even a semi-bug, but just how the protocol works. Thanks for your quich answer.

Op di 17 apr. 2018 22:00 schreef Thomas Roell notifications@github.com:

Semi-bug.

You set the initial mask. However the JOIN_ACCEPT reply from the gateway will most likely add channel 4/5/6/7/8.

So you need to put the channel disable post the joinOTAA().

On Tue, Apr 17, 2018 at 1:42 PM, David Boelee notifications@github.com wrote:

Hi,

I am trying to setup a single channel node, so that I can combine it with a single channel gateway. I am using the Add B-L072Z-LRWAN1 in combination with your (great!) library.

I found LoRaWAN.disableChannel() by snooping into the source coude and figured I could use this to, well, disable channels. So that I end up with a single channel gateway. So my setup now looks like this:

void setup( void ) { LoRaWAN.begin(EU868);

for (unsigned int x = 1; x <=15; x++) { LoRaWAN.disableChannel(x); } // LoRaWAN.setADR(false); LoRaWAN.setDataRate(0); LoRaWAN.setTxPower(10); LoRaWAN.setSubBand(2); // for TTN LoRaWAN.joinOTAA(appEui, appKey, devEui); }

But... There are still transmissions on other channels than 0 as well, as you can see on the screenshot below.

[image: image] < https://user-images.githubusercontent.com/23418587/38892599-fdc84c2a- 4287-11e8-8f59-db99e72851a9.png

Am I using disableChannel() wrong, or could it be something else is wrong?

Thanks,

David

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5, or mute the thread < https://github.com/notifications/unsubscribe-auth/AG4QfHdOT6s6NzJS_ fguYSINIsprOMocks5tpkWSgaJpZM4TY7eE

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore- stm32l0/issues/5#issuecomment-382122787, or mute the thread https://github.com/notifications/unsubscribe-auth/ AWVW23sOfgYtnoNe1dpqwosHRch9_fi5ks5tpknIgaJpZM4TY7eE .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-382142478, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfKuuUg_y6Oj0JChOJc89bgsB2twjks5tplapgaJpZM4TY7eE .

BoelD commented 6 years ago

It does a little bit more than that. I experimented with it today and found out that you have to disable the channels before every package you send. If you don't, channels are activated again along the run. Also, it's a good idea to disable channels before joining, so that no time is wasted sending join messages on channels that aren't listened to by the single channel gateway.

Code below worked reliable for me.

void setup( void )
{
    LoRaWAN.begin(EU868);

    for (unsigned int x = 1; x <=15; x++)
 {  
    LoRaWAN.disableChannel(x);
 }

   // LoRaWAN.setADR(false);
    LoRaWAN.setDataRate(0);
    LoRaWAN.setTxPower(10);
    LoRaWAN.setSubBand(2); // for TTN

    LoRaWAN.joinOTAA(appEui, appKey, devEui);

}

void loop( void )
{
    delay(10000);

    if (!LoRaWAN.busy() && LoRaWAN.joined())
    {
        for (unsigned int x = 1; x <=15; x++)
        {  
        LoRaWAN.disableChannel(x);
        }
        LoRaWAN.beginPacket();
        LoRaWAN.write(0xef);
        LoRaWAN.write(0xbe);
        LoRaWAN.write(0xad);
        LoRaWAN.write(0xde);
        LoRaWAN.endPacket();
    }
}
GrumpyOldPizza commented 6 years ago

Need to trace that throu. Something does not feel right.

There are a bunch of problems with the original LoRaMac-node code. One is the default channels, which you can modify, are not properly restored. So even if you disabled them, the region-default gets restored. But post join (OTAA) that should not matter ...

Well, unless you have ADR enabled, in which case the gateway can re-enable channels.

What should really be done is to disable channels before the join, so that the join can be limited to the channels the gateway supports. If the gateway later says it supports more, then that;s fine

If you want a single channel gateway, then this gateway should not enable channel it does not support.

On Wed, Apr 18, 2018 at 8:14 AM, David Boelee notifications@github.com wrote:

It does a little bit more than that. I experimented with it today and found out that you have to disable the channels before every package you send. If you don't, other channels are activated again. Also, it's a good idea to disable channels before joining, so that no time is wasted sending join messages on channels that aren't listened to by the single channel gateway. It may feel a little bit sketchy to keep disabling channels, but hey, single channel is a bit sketchy anyways. ;)

Code below worked reliable for me.

void setup( void ) { LoRaWAN.begin(EU868);

for (unsigned int x = 1; x <=15; x++)

{ LoRaWAN.disableChannel(x); }

// LoRaWAN.setADR(false); LoRaWAN.setDataRate(0); LoRaWAN.setTxPower(10); LoRaWAN.setSubBand(2); // for TTN

LoRaWAN.joinOTAA(appEui, appKey, devEui);

}

void loop( void ) { delay(10000);

if (!LoRaWAN.busy() && LoRaWAN.joined()) { for (unsigned int x = 1; x <=15; x++) { LoRaWAN.disableChannel(x); } LoRaWAN.beginPacket(); LoRaWAN.write(0xef); LoRaWAN.write(0xbe); LoRaWAN.write(0xad); LoRaWAN.write(0xde); LoRaWAN.endPacket(); }

}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-382401507, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfP_SVXdeRGFwZn23fdNvvZ4mS6iLks5tp0pMgaJpZM4TY7eE .

GrumpyOldPizza commented 6 years ago

Single Channel Gateways are not supported via hackery on the node side. To be region compliant your gateway needs to send it's proper channel mask post joinOTAA(). There is no way to override the gateways channel mask, as every downlink could change that. The modified LoRaMac-node code in use allows ADR without DR/TX_POWER change to change the channel mask if ADR is disabled. Again, the code for that is implemented. If you use joinABP(), then the node needs to enable/disable the proper channels.

nalberto commented 6 years ago

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

GrumpyOldPizza commented 6 years ago

There is no way provided to track which channels are used in which sequence for JOIN.

On Sun, Nov 18, 2018 at 7:44 AM nalberto notifications@github.com wrote:

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439698067, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfAhy8t4_S9bkogaJwJV4wITgttseks5uwXI3gaJpZM4TY7eE .

nalberto commented 6 years ago

So do you practicaly check which frequencies are used when trying to join?

The join process takes sometime a very long time and I suspect it uses channels out of range. Sometimes it just never joins with the same code after resetting.

I have also tried disabling all channels and it still joins on the same frequency 916.8 Australia TTN.

I feel totally blind. I have seen some code using lmic/Arduino that was sending debugging info to serial with join frequencies.

On Mon, Nov 19, 2018, 7:59 PM Thomas Roell <notifications@github.com wrote:

There is no way provided to track which channels are used in which sequence for JOIN.

On Sun, Nov 18, 2018 at 7:44 AM nalberto notifications@github.com wrote:

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub < https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439698067 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AG4QfAhy8t4_S9bkogaJwJV4wITgttseks5uwXI3gaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439869580, or mute the thread https://github.com/notifications/unsubscribe-auth/AEhlGzGnIs8s2HnAwvOHpjhlQpouDK4Hks5uwp0EgaJpZM4TY7eE .

GrumpyOldPizza commented 6 years ago

I think there are 3 different region specifications applicable for Australia. Do you know which one your gateway is using (yes, I know that sounds like a stupid question, but others have run into that where AS923 was used instead of AU915).

Also if it's AU915, did you select the proper subband ?

On Mon, Nov 19, 2018 at 6:05 AM nalberto notifications@github.com wrote:

So do you practicaly check which frequencies are used when trying to join?

The join process takes sometime a very long time and I suspect it uses channels out of range. Sometimes it just never joins with the same code after resetting.

I have also tried disabling all channels and it still joins on the same frequency 916.8 Australia TTN.

I feel totally blind. I have seen some code using lmic/Arduino that was sending debugging info to serial with join frequencies.

On Mon, Nov 19, 2018, 7:59 PM Thomas Roell <notifications@github.com wrote:

There is no way provided to track which channels are used in which sequence for JOIN.

On Sun, Nov 18, 2018 at 7:44 AM nalberto notifications@github.com wrote:

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439698067

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG4QfAhy8t4_S9bkogaJwJV4wITgttseks5uwXI3gaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439869580 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AEhlGzGnIs8s2HnAwvOHpjhlQpouDK4Hks5uwp0EgaJpZM4TY7eE

.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439886179, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfKedqxWNWlWy4jCkvrHIkRXBDcK5ks5uwqyqgaJpZM4TY7eE .

nalberto commented 6 years ago

I use AU915 subband 2 which I understand is the right frequency for TTN Australia. I suspect it ignores the subband when joining and tries the whole set of channels randomly.

On Mon, Nov 19, 2018, 9:13 PM Thomas Roell <notifications@github.com wrote:

I think there are 3 different region specifications applicable for Australia. Do you know which one your gateway is using (yes, I know that sounds like a stupid question, but others have run into that where AS923 was used instead of AU915).

Also if it's AU915, did you select the proper subband ?

On Mon, Nov 19, 2018 at 6:05 AM nalberto notifications@github.com wrote:

So do you practicaly check which frequencies are used when trying to join?

The join process takes sometime a very long time and I suspect it uses channels out of range. Sometimes it just never joins with the same code after resetting.

I have also tried disabling all channels and it still joins on the same frequency 916.8 Australia TTN.

I feel totally blind. I have seen some code using lmic/Arduino that was sending debugging info to serial with join frequencies.

On Mon, Nov 19, 2018, 7:59 PM Thomas Roell <notifications@github.com wrote:

There is no way provided to track which channels are used in which sequence for JOIN.

On Sun, Nov 18, 2018 at 7:44 AM nalberto notifications@github.com wrote:

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439698067

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG4QfAhy8t4_S9bkogaJwJV4wITgttseks5uwXI3gaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439869580

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AEhlGzGnIs8s2HnAwvOHpjhlQpouDK4Hks5uwp0EgaJpZM4TY7eE

.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub < https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439886179 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AG4QfKedqxWNWlWy4jCkvrHIkRXBDcK5ks5uwqyqgaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439888185, or mute the thread https://github.com/notifications/unsubscribe-auth/AEhlG_hhtxI1xA8yXx9oEf1GQwIX3mBJks5uwq56gaJpZM4TY7eE .

GrumpyOldPizza commented 6 years ago

Actually it does not ignore the subband during join. If you don't specifiy a subband it tries all 64+8 channels in a special sequence to touch all subbands as quickly as possible.

But that goes back to the question, if you have a close by gateway, is it really on AU915 ?

On Mon, Nov 19, 2018 at 6:29 AM nalberto notifications@github.com wrote:

I use AU915 subband 2 which I understand is the right frequency for TTN Australia. I suspect it ignores the subband when joining and tries the whole set of channels randomly.

On Mon, Nov 19, 2018, 9:13 PM Thomas Roell <notifications@github.com wrote:

I think there are 3 different region specifications applicable for Australia. Do you know which one your gateway is using (yes, I know that sounds like a stupid question, but others have run into that where AS923 was used instead of AU915).

Also if it's AU915, did you select the proper subband ?

On Mon, Nov 19, 2018 at 6:05 AM nalberto notifications@github.com wrote:

So do you practicaly check which frequencies are used when trying to join?

The join process takes sometime a very long time and I suspect it uses channels out of range. Sometimes it just never joins with the same code after resetting.

I have also tried disabling all channels and it still joins on the same frequency 916.8 Australia TTN.

I feel totally blind. I have seen some code using lmic/Arduino that was sending debugging info to serial with join frequencies.

On Mon, Nov 19, 2018, 7:59 PM Thomas Roell <notifications@github.com wrote:

There is no way provided to track which channels are used in which sequence for JOIN.

On Sun, Nov 18, 2018 at 7:44 AM nalberto notifications@github.com wrote:

How do you show which channel / frequency is being used to try to join the gateway in the serial console? I would want to debug but not sure how to display that?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439698067

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG4QfAhy8t4_S9bkogaJwJV4wITgttseks5uwXI3gaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439869580

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AEhlGzGnIs8s2HnAwvOHpjhlQpouDK4Hks5uwp0EgaJpZM4TY7eE

.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <

https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439886179

, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG4QfKedqxWNWlWy4jCkvrHIkRXBDcK5ks5uwqyqgaJpZM4TY7eE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439888185 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AEhlG_hhtxI1xA8yXx9oEf1GQwIX3mBJks5uwq56gaJpZM4TY7eE

.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/5#issuecomment-439892696, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfNMUwExDJFjjJHwNV7XynaH-sHoKks5uwrIkgaJpZM4TY7eE .

nalberto commented 6 years ago

Yes AU915 and gateway is on my roof. It does join but very inconsistent behavior. Could take 1 min to join on try for 40 min without success on same code and close to gateway.

I cannot use this for low power device as the battery may drain on reset.