So i have implemented the rak811 module for connections with The Things Community Stack.
I recently had an issue with “uplink channel not found”, however I was told the solution was to turn off the other channels not designated for transmitting a join command. This solution worked, however I came across another problem.
I keep getting an error code: “RAK811 response error 99: LoRa join failed”
In my TTS console I spot that the gateway is transmitting a join accept message, however the rak811 module does not receive it…
@carlrowan My initial thought was that the rak811 timed out before it could receive the join accept downlink, however this was not the case as the error is a response error
Given that it is basically the same problem, I’m not sure if it is needed to open another post.
Devices
End-node: RAK811
Gateway: RAK2247
Problem
Using join ABP works just fine, but OTAA won’t work, at least not with TTN v3 console. Though I remember having it working with TTN v2.
Given that I get an error code 82 The LoRa parameters are invalid. I think the answer should be pretty obvius. But I’ve tried setting new devices with no success. Maybe it is because the AppEUI is full of zeros? Not sure, but TTN v3 doesn’t generate one like before.
OK V3.0.0.14.H
Start init RAK811 parameters...
Current work region: AU915
RAK811 init OK!
Start to join LoRaWAN...
Join LoRaWAN success
Start send data...
1.29
OK
Start send data...
1.29
OK
OTAA:
********************************************************
LoRaWAN
********************************************************
OK V3.0.0.14.H
Start init RAK811 parameters...
Current work region: AU915
RAK811 init OK!
Start to join LoRaWAN...
ERROR: 82
Rejoin again after 5s...
ERROR: 82
Full-code
I’m using rak’s example with few changes.
/********************
* This demo is only supported after RUI firmware version 3.0.0.13.X on RAK811
* Master Board Uart Receive buffer size at least 128 bytes.
********************/
#include "RAK811.h"
#define WORK_MODE LoRaWAN // LoRaWAN or LoRaP2P
#define JOIN_MODE ABP // OTAA or ABP
#if JOIN_MODE == OTAA
String DevEui = "0102030405060708"; // -> Changed
String AppEui = "0000000000000000"; // I'm using this one
String AppKey = "01020304050607080901020102030405010"; // -> Changed
#else JOIN_MODE == ABP
String NwkSKey = "01020304050607080901020102030405010"; // -> Changed
String AppSKey = "01020304050607080901020102030405010"; // -> Changed
String DevAddr = "01020304"; // -> Changed
#endif
#define DebugSerial Serial
#define LoRaSerial Serial4
char buffer[60] = {0};
char res[15];
char hi[3] = {'h','i', '\0'};
bool InitLoRaWAN(void);
RAK811 RAKLoRa(LoRaSerial,DebugSerial);
void setup() {
DebugSerial.begin(115200);
while(!DebugSerial)
;
DebugSerial.println(F("********************************************************"));
DebugSerial.println(F("LoRaWAN"));
DebugSerial.println(F("********************************************************"));
LoRaSerial.begin(115200); //set LoRaSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device.
while(LoRaSerial.available())
{
LoRaSerial.read();
}
RAKLoRa.rk_setWorkingMode(0);
// if(!RAKLoRa.rk_setWorkingMode(0)) //set WisNode work_mode to LoRaWAN.
// {
// DebugSerial.println(F("set work_mode failed, please reset module."));
// while(1);
// }
RAKLoRa.rk_getVersion(); //get RAK811 firmware version
DebugSerial.println(RAKLoRa.rk_recvData()); //print version number
DebugSerial.println(F("Start init RAK811 parameters..."));
if (!InitLoRaWAN()) //init LoRaWAN
{
DebugSerial.println(F("Init error,please reset module."));
while(1);
}
DebugSerial.println(F("Start to join LoRaWAN..."));
while(!RAKLoRa.rk_joinLoRaNetwork(60)) //Joining LoRaNetwork timeout 60s
{
DebugSerial.println();
DebugSerial.println(F("Rejoin again after 5s..."));
delay(5000);
}
DebugSerial.println(F("Join LoRaWAN success"));
if(!RAKLoRa.rk_isConfirm(0)) //set LoRa data send package type:0->unconfirm, 1->confirm
{
DebugSerial.println(F("LoRa data send package set error,please reset module."));
while(1);
}
}
void loop() {
DebugSerial.println(F("Start send data..."));
int resistance = (int)((analogRead(A1)+250) * (3.3/1023.0) * 100); //123.45;
itoa(resistance, res, 10);
sprintf(buffer, "%s:%s", hi, res);
DebugSerial.println(resistance/100.);
if (RAKLoRa.rk_sendDataASCII(1, buffer, strlen(buffer)))
{
for (unsigned long start = millis(); millis() - start < 60000L;)
{
String ret = RAKLoRa.rk_recvData();
if(ret != "")
{
DebugSerial.println(ret);
}
}
}
}
bool InitLoRaWAN(void)
{
#if JOIN_MODE == OTAA
if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:OTAA
{
if(RAKLoRa.rk_setRegion(1)) //set region AU915
{
if (RAKLoRa.rk_initOTAA(DevEui, AppEui, AppKey))
{
DebugSerial.println(F("RAK811 init OK!"));
return true;
}
}
}
return false;
#else
if(RAKLoRa.rk_setJoinMode(JOIN_MODE)) //set join_mode:ABP
{
if(RAKLoRa.rk_setRegion(1)) //set region EU868, alterado de 5 para 1
{
if (RAKLoRa.rk_initABP(DevAddr, NwkSKey, AppSKey)) //set ABP mode parameters
{
DebugSerial.println(F("RAK811 init OK!"));
return true;
}
}
}
#endif
}
```
********************************************************
LoRaWAN
********************************************************
OK V3.0.0.14.H
Start init RAK811 parameters...
Current work region: AU915
OTAA: RAK811 init OK!
Start to join LoRaWAN...
ERROR: 82
Rejoin again after 5s...
ERROR: 82
In both of them, the gateway and the device live data show nothing about my messages and I keep getting error 82 The LoRa parameters are invalid.
I’ve changed the AppKey to 100000000000F04C to see what happens… And it worked! Thank you!
Than I changed what @nmcc suggested and it still works. To be sure, I’ve changed the appEUI back to 00 again ant it went to error 82. So we need to set it to something else.
Gateway’s Live Data:
Here we can see the first message that is the OTAA request, then the gateway’s answer, after that we have the payload and a confirmed message i guess, due to the downlink after it.
Over on the TTN forum we’re not overly keen on the all-Zero’s idea either, but we are told it’s a “thing” - even if many MAC implementations object to it.
So TTI are looking at generating EUI’s for Dev & App/Join to cover this - but don’t know on what timescale.
What do you mean with MAC implementations? Like the LoRaWAN stack in the device?
I am actually pushing for us to support the all-zero APPEUI of TTS. But it is not seen as a priority. But if TTI team will create an APPEUI generation like before, then there will be no need to change in our side
Yes, either LoRaMac-node or LMIC - I’ve not really tested the 00’s as I have some proper EUI64’s to use - but reports on the TTN forum indicate a range of issues with the code base not co-operating - mostly with joins.