TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
207 stars 96 forks source link

AU915 Data Rates Incorrect #236

Closed ElectronicallyE closed 6 years ago

ElectronicallyE commented 6 years ago

Hello,

I'm currently using a RN2903 in Australia with the SA1.0.3 firmware which supports the 915MHz frequency. After testing numerous factors which could be preventing me from transmitting, I discovered that my serial was giving me:

Sending: mac set ch drrange 8 0 3

Followed by this further down in the serial:

Sending: mac set dr 5
Response is not OK: invalid_param

This from my understanding means that the data rate range is 0-3 for the AU915 frequency and it is trying to set dr 5 which won't work.

Looking in the library and in particular thethingsnetwork.cpp, I found this:

void TheThingsNetwork::configureAU915(uint8_t fsb)
{
  uint8_t ch;
  uint8_t chLow = fsb > 0 ? (fsb - 1) * 8 : 0;
  uint8_t chHigh = fsb > 0 ? chLow + 7 : 71;
  uint8_t ch500 = fsb + 63;
  for (ch = 0; ch < 72; ch++)
  {
    if (ch == ch500 || (ch <= chHigh && ch >= chLow))
    {
      sendChSet(MAC_CHANNEL_STATUS, ch, "on");
      if (ch < 63)
      {
        sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 3");
      }
    }
    else
    {
      sendChSet(MAC_CHANNEL_STATUS, ch, "off");
    }
  }
  sendMacSet(MAC_PWRIDX, TTN_PWRIDX_AU915);
}

From my discussion in the Slack group, AU915 supports DR0 to DR5 (truely DR6). If the "0 3" is replaced to "0 5" in line 675, I thought it may resolve this issue, but am getting the following in my serial output:

Sending: mac set ch status 8 on
Sending: mac set ch drrange 8 0 5
Response is not OK: invalid_param
Sending: mac set ch status 9 on
Sending: mac set ch drrange 9 0 5
Response is not OK: invalid_param
Sending: mac set ch status 10 on
Sending: mac set ch drrange 10 0 5
Response is not OK: invalid_param
Sending: mac set ch status 11 on
Sending: mac set ch drrange 11 0 5
Response is not OK: invalid_param
Sending: mac set ch status 12 on
Sending: mac set ch drrange 12 0 5
Response is not OK: invalid_param
Sending: mac set ch status 13 on
Sending: mac set ch drrange 13 0 5
Response is not OK: invalid_param
Sending: mac set ch status 14 on
Sending: mac set ch drrange 14 0 5
Response is not OK: invalid_param
Sending: mac set ch status 15 on
Sending: mac set ch drrange 15 0 5
Response is not OK: invalid_param

From my understanding now, it's not just as simple as changing the DRRANGE. There must be other things that need to be adjusted, but I am not experienced with the library, so there's little method to my madness.

What I have noticed is in the EU868, instead of: sendChSet(MAC_CHANNEL_DRRANGE, ch, "0 3") It has: sendChSet(MAC_CHANNEL_DRRANGE, 1, "0 6");

It looks like the EU868 has the right DR, however the function is different so I can't simply copy and paste.

sa-wilson commented 6 years ago

Looking at #222 this is an issue with the RN2903 itself. I've brought it up there and we'll have to see what happens.

You should only set the DR range to [0..5] by the way, DR 6 is for the 500 kHz channel (65 in this case).

johanstokking commented 6 years ago

Indeed, the drrange N 0 5 is failing, which is in fact specification; this 1.0.3 module supports LoRaWAN Regional Parameters 1.0.2 rev A, and for AU915 the data rate range is 0-4 (with 4 being 500 KHz). This has changed in 1.0.2 rev B and higher.

This "1.0.3" version does not refer to the LoRaWAN (or Regional Parameters) version, but the RN firmware itself.

So the error is that DR 5 is used for sending, while it doesn't exist. I'm submitting a PR.

johanstokking commented 6 years ago

Released in https://github.com/TheThingsNetwork/arduino-device-lib/releases/tag/v2.5.10. Arduino IDE will update automatically.

ElectronicallyE commented 6 years ago

Thanks Johan. Will test tonight and report back. Appreciate the rapid response from the community and yourself with this matter. 👊

leogaggl commented 6 years ago

Can confirm that with 2.5.10 any reported invalid param errors with DR5 are now gone.

[strangely enough, the TTN Uno's have been working fine on 2.5.7 for weeks]