Issue: Can’t get downlink message to node.
Setup:
- Board with Arduino IDE.
- RAK811 Breakout Board for end-node.
- RAK2247 for gateway.
Server: TTN
Details: I’m testing it using the WisNode-Arduino-Library running the Join Network OTAA Example as I want to get the downlink through LoRaWAN not P2P.
As TTN LoRaWAN explanation says: “Downlink messages should be avoided if possible, and if you send downlink, keep the payload small.”, but it should word as I’m sending only 01
or 02
.
My code is the example code added the receive part that reads from the Breakout Board Serial.
Another strange thing that happens is that TTN’s console only sends my downlink when the Node sends data to it, so if I set the node as a receiver only, the data keeps as scheduled
forever on TTNs.
void setup() {
DebugSerial.begin(115200);
while(DebugSerial.available())
{
DebugSerial.read();
}
while(!DebugSerial) delay(10);
Serial.println("RAK811: Join Network OTAA Example");
ATSerial.begin(115200); //set ATSerial baudrate:This baud rate has to be consistent with the baud rate of the WisNode device.
while(ATSerial.available())
{
ATSerial.read();
}
RAKLoRa.rk_setWorkingMode(0);
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);
}
}
bool InitLoRaWAN(void)
{
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;
}
void loop() {
DebugSerial.println(F("Start send data..."));
if (RAKLoRa.rk_sendData(1, buffer))
{
for (unsigned long start = millis(); millis() - start < 5000L;)
{
String ret = RAKLoRa.rk_recvData();
if(ret != NULL)
{
DebugSerial.println(ret);
}
if((ret.indexOf("OK")>0)||(ret.indexOf("ERROR")>0))
{
DebugSerial.println(F("Go to Sleep."));
RAKLoRa.rk_sleep(1); //Set RAK811 enter sleep mode
delay(10000); //delay 10s
RAKLoRa.rk_sleep(0); //Wakeup RAK811 from sleep mode
break;
}
}
}
// recvP2P just reads the serial until /0 and trim it later
DebugSerial.println(F("Start receiving..."));
for (unsigned long start = millis(); millis() - start < 100000L;)
{
String ret2 = RAKLoRa.rk_recvP2PData();
if(ret2 != NULL)
{
DebugSerial.println(ret2);
}
}
}
My gateway service status moments after the scheduled
downlink was delivered.
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: src/jitqueue.c:448:jit_print_queue(): INFO: [jit] queue is empty
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: ### [GPS] ###
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: # GPS sync is disabled
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: ##### END #####
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: JSON up: {"stat":{"time":"2020-10-24 12:05:41 GMT","rxnb":0,"rxok":0,"rxfw":0,"ackr"
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: INFO: Received pkt from mote: 26032F33 (fcnt=1)
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: JSON up: {"rxpk":[{"tmst":1939074315,"chan":1,"rfch":0,"freq":917.000000,"stat":1,"m
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: INFO: [down] PULL_RESP received - token[0:58] :)
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: JSON down: {"txpk":{"imme":false,"tmst":1940074315,"freq":923.9,"rfch":0,"powe":20,"
Oct 24 13:05:43 raspberrypi ttn-gateway[10024]: INFO: == used txlut index:11