Device is in lab, near to gateway I manage. I can see uplink message in gateway console but it does not show in application live data.
When I force OTAA on sensor then it start working again, until few restarts later.
End device in application is configured as follow:
Frequency plan: Europe 863-870 MHz (SF9 for RX2 - recommended)
LoRaWAN version LoRaWAN Specification 1.0.2
Regional Parameters version RP001 Regional Parameters 1.0.2 revision B
When I browse message details in gateway console I see that all messages are using (I think) correct frequencies (868.1, 868.3 & 868.5). End device has default Network layer settings. I also use defaults in SX126x-Arduino library.
I have verified that Network Session Key and Application Session Key are persisted correctly (so library uses them) - and since message is seen in gateway console that mean NSK is correct, right?
A joined device in EU868 should use 8 frequencies, not just 3.
There is a whole lot more you need to persist. The frequencies you receive when joining, the frame counters (up and down), spreading factor and transmission power amongst them.
Start by checking the counter values. If they reset messages are considered a replay attack.
There’s a whole pile of missing detail and a few assumptions about what’s going on.
So check out the https://www.thethingsnetwork.org/docs/lorawan/ to cover, for instance, when & where the keys are used - hint, NSK being correct is not a requirement for appearing in the gateway console.
As for missing details, there’s an implication that you are restarting the device with some but not all of the session persisted. What is the device and why is it being restarted?
It’s always useful if you can say what you are trying to achieve, as there may be something in the mix that isn’t a good fit for the implementation.
This will be air quality sensor and it is not battery powered so it has to be able withstand power loss.
Now I know I have to persist much more data and I know how to do it I’ll make change, but I have noticed that after OTAA (when messages are delivered to application) device still sends messages only using 3 default frequencies.
And each message is followed by downlink message to my device so this is probably some MAC command from TTN. I guess I need to ask about that on SX126x library forum.
My question is - can I manually decode MAC command? I guess I should use network session key and raw_payload field?
I’m writing own code (I’m adding LoRaWAN capabilities using this library into mature project which was using only WiFi until now). I have tried SX126x-Arduino library in small project and it was working OK on the same hardware (Heltec module) or I just didn’t notice any glitches.
I have just installed that example project and it is sending data using not only 3 basic frequencies and was adjusting SF according to received MAC commands from TTN. So it looks like library/hardware is OK.
It looks like I need just to do more tests and review implementation in this second project…
Or more likely, don’t touch any of the code in the library folder and just use the API calls it supplies - that way it should carry on working per spec!