lora-mote-emulator
lora-mote-emulator copied to clipboard
device session error
Hi I can see the messages getting to the gateway bridge but i get device-session error: device-session does not exist or invalid fcnt or mic" for when i run this command python main.py app -m helloworld -f 0302
I have my device set up as
Here are my configs i used abp.txt config.txt device.txt
It usually becauses the two fields txch and txdr are not correctly set, therefore the mic may be wrong.
You need to set the frequency and channel index of devices on appserver, and modify the two attributes(self.txch
and self.txdr
) in __init__
function of class Mote
inside motes/mac.py file. This program is still under development (but the abp mode has been successfully tested via loraserver) so you have to modify them inside codes.
Please let me know if there is still be any problem.
Thanks for the response can you send me how you set this up for abp. like the config files you used and how you ran it ?
The problem is caused by the inconsistent config in appserver(the website where you set up your devices) and in emulator. Open the appserver, click application -> device, and set the frequency and channel index (if I'm not mistaken).
I'll send you more details (with figures) during working time tomorrow (Beijing time). :P
@johnjoelanders
Open this appserver, click Device-profiles -> JOIN(OTAA/ABP), fill the RX2 data rate, RX2 channel frequency(the practical frequency used by device) and Factory-present frequency(supported frequencies when leave factory). Then, modify the freq
field of rxpk
data in class Gateway
to be the same with RX2 channel frequency, modify the self.txch
to be the same with the index of RX2 channel frequency in Factory-present frequency(the self.txch
should be 1 if use configs as the figure shows), and modify the self.txdr
to be the same with RX2 data rate.
After these configs, you may be able to receive downlink data.
Hi I have tried what you suggested but still i am not able to get this working
- Make sure the FCnt field is 0 if the emulator sends the uplink data for the first time.
- Make sure the Session keys are matched, especially the Byte Sequence.
- Always send
pull
command to connect the gateway to the bridge before sending any other data.
Hi,
I got same MIC error in ABP with chirpstack server (uplink frame). Even when changing the AppSkey and NwkSKey in LSB/MSB, I got same error again. I got also MIC error with extracting data frame with online Lora packet decoder. I guess it is related to mic computation with NwkSKey. As far as I understand, the only keys needed in ABP are NwkSKey and AppSkey.
Could you confirm which parameters it corresponds in abp.yml file :
nwksenckey = NwkSKey ? appskey = AppSkey ?
Please could you also clarify me what are snwksintkey and fnwksintkey ?
Thx !
abp.yml
deveui: 0ebee4aec9e37047 joineui: 0ebee4aec9e37047 devaddr: 0105fec2 appkey: 0b23933ece6df4023ce7d1814dcf8574 nwkkey: 7541f1245623c9bc98c8612e81d89e3e nwksenckey: 7541f1245623c9bc98c8612e81d89e3e snwksintkey: 7541f1245623c9bc98c8612e81d89e3e fnwksintkey: 7541f1245623c9bc98c8612e81d89e3e appskey: 0b23933ece6df4023ce7d1814dcf8574 fcntup: 0
@starsky35 In LoRaWAN V1.0.2, there are three keys in total, i.e., AppKey
(root key) and two session keys AppSKey
and NwkSKey
. But, all the fields in abp.yml
are defined according to LoRaWAN V1.1. It uses two root keys (AppKey
and NwkKey
) to derive all the four session keys (as well as two keys JSIntKey
and JSEncKey
that are used only for OTAA). SNwkSIntKey
is used to calculate the first two bytes of MIC
field, while FNwkSIntKey
is used to calculate the last two bytes of MIC
field. This is presented in LoRaWAN 1.1 Specification, page 27.
If we use LoRaWAN V1.0, we need to set only two fields,
-
fnwksintkey
equals toNwkSKey
-
appskey
equals toAppSKey
The others, either way.
In your case, the appskey
is not equal to what is shown in the figure. It may cause the error because the package is encrypted before MIC calculation. But there may also some flaws in my code, I'll check it carefully.
Good luck!
@houluy thanks for your reply, you pointed indeed a byte issue in my appskey. However, still got mic issue in chirpstack server after correction in ABP. I'm suspecting now rather a Lorawan version issue because whenever I set --version parameter, seems not taken into account in the code (especially in form_phypld). Even when I force version to 1.1 in chirpstack device profile and leave it as default in emulator (1.1), I got same error.
@starsky35 The version
parameter may have some problems because it is not well tested. Only 1.1 with ChirpStack server is tested.
I'll run a complete test over the whole system to check all the bugs, and update the document in details.
In yuu case, I suggest to try OTAA mode with version 1.1, this may work.
Thanks a lot!