I have a Multitech Conduit gateway(GW) and a Dragino LoRa mini Dev endnode(EN), and
am trying to implement OTAA and downlink algorithm. I’ve been using ABP algorithm. So
this is my first try for OTAA.
Currently I have a problem. The problem is :
(1)My EN can NOT join the session.
(2)My EN can NOT transmit data.
(3)My application can NOT receive downlink data.
Here are more information about my developing environment.
For (1), I refer to the code ttn-otaa-downlink.ino, which was originally created by Thomas
Telkamp and Matthijs Kooijman, and slightly modified, use some part of the code. Especially
follow onEvent (). After running the code, it shows on the serial monitor “EV_JOINING”, and “EV_JOIN_FAILED”, never shows “EV_TXCOMPLETE”. TTN GW console shows Join Request and Join Accept, but never shows Data. TTN APPL console just shows “Activation”.
For (2), as told above my EN never tells “EV_TXCOMPLETE”.
For (3), I can schedule downlink data from TTN console. I usually send 2 bytes data. When
I tried downlink with ABP session, I could see data reception on TTN APPL console. This time I can see scheduled data, but NOT see received data on TTN APPL console.
case EV_BEACON_FOUND:
Serial.println(F("EV_BEACON_FOUND"));
break;
case EV_BEACON_MISSED:
Serial.println(F("EV_BEACON_MISSED"));
break;
case EV_BEACON_TRACKED:
Serial.println(F("EV_BEACON_TRACKED"));
break;
case EV_JOINING:
Serial.println(F("EV_JOINING"));
break;
case EV_JOINED:
Serial.println(F("EV_JOINED"));
// Disable link check validation (automatically enabled
// during join, but not supported by TTN at this time).
LMIC_setLinkCheckMode(0);
break;
case EV_RFU1:
Serial.println(F("EV_RFU1"));
break;
case EV_JOIN_FAILED:
Serial.println(F("EV_JOIN_FAILED"));
break;
case EV_REJOIN_FAILED:
Serial.println(F("EV_REJOIN_FAILED"));
break;
break;
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if (LMIC.txrxFlags & TXRX_ACK)
Serial.println(F("Received ack"));
// for debug
Serial.println(LMIC.dataLen);
if (LMIC.dataLen)
{
Serial.println(F("Received "));
Serial.println(LMIC.dataLen);
Serial.println(F(" bytes of payload"));
// downlink処理 ****************************
uint8_t data[LMIC.dataLen];
memcpy(&data, &(LMIC.frame + LMIC.dataBeg)[0], LMIC.dataLen);
for(int i = 0; i < LMIC.dataLen; i++)
{
Serial.println(data[i]);
}
// *****************************************
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
break;
case EV_RESET:
Serial.println(F("EV_RESET"));
break;
case EV_RXCOMPLETE:
// data received in ping slot
Serial.println(F("EV_RXCOMPLETE"));
break;
case EV_LINK_DEAD:
Serial.println(F("EV_LINK_DEAD"));
break;
case EV_LINK_ALIVE:
Serial.println(F("EV_LINK_ALIVE"));
break;
default:
Serial.println(F("Unknown event"));
break;
I tried to understand OTAA procedure by checking following web site.
This site tells and depicts the procedure like this :
After reading this explanation I’ve gotten some questions.
How to use Network Session Key and Application Session Key
Currently my end nodes join procedure succeeds, and my application can generate
Network Session Key and Application Session Key. But those seem not to be used
anywhere in my end nodes source code. As a result uplink does NOT happen.
My question is how I can use generated Network Session Key and Application
Session Key, and start uplink process.
Where is Activation
TTN application console shows “Activation”. Where can I see this action in the above
procedure?
First I thought it is #5: Session key generation. But time stamp of the Activation tells it
happens between Join Request and Join Accept. Is this #2: End Device Authentication
Session key generation?
Why can NOT get EV_JOINED
TTN gateway console tells Join Accepted. How come my end node can not get EV_JOINED?
Are those “join” different?
I checked actual numbers onEvent (ev_t ev) function receives in my end node code. When it tells
“unknown event”, the number is 17. In lmic.h event types are defined as follows :
17th event seems to be EV_TXSTART. But in my end node code, onEvent () function, the event is
not defined. It’s strange. My end node codes seems to be wrong!!
Thank you for your reply. I’m not sure the version … It’s 2 years old, and slightly modified by Japanese agent. I’m pretty sure it’s too old. Please tell me the latest ang greatest version.
I tried to implement some files from following library.
onEvent() function seems to treat events correctly. Serial console shows no “Unknown even”. This
is good. But still EV_JOIN_FAILED remains. This is not good.
I realized even if my EN tells “EV_TXSTART”, it does nothing. Currently EN code treat the event like
this :
case EV_TXSTART:
Serial.println(F("EV_TXSTART"));
break;
<Question 1>
So question is what should EN do once it receives “EX_TXSTART”?
And I did another try. I took a look at the following notes.
Problems with downlink and OTAA
Uplink will often work right away, but sometimes downlink (and thus also OTAA) will not work directly. In practice, this is often due to inaccuracies in the receive window timing (see the previous section for details). If you run into problems with OTAA or downlink, it is a good idea to relax the RX mode timings to see if that helps by adding this to your setup somewhere:
LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);
This function is intended to compensate for clock inaccuracy (up to ±10% in this example), but that also works to compensate for inaccuracies due to software delays. The downside of this compensation is a longer receive window, which means a higher battery drain. So if this helps, you might want to try to lower the percentage (i.e. lower the 10 in the above call), often 1% works well already.
And I tried some “relaxation” parameters, like 10, 20 etc. But still EN tells “EV_FAILED”.
<Question 2>
What should I consider if I can use setClockError() function?
This, this every time. Start simple, test ABP uplinks AND downlinks, especially downlinks, because if your device is not able to receive, OTAA joins will never work.
The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.
Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.
The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.
I double-checked all the keys, LSB/MSB first setting. The keys are all correct.
Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.
I can see join request/accept on the TTN gateway console. And I can see activation on TTN application console.