Simulate message from the Gateway => Gateway Bridge


#21

But I’m still a bit confuse.
So I installed this in my VirtualBox without loraserver and then in my real machine that has loraserver only still waiting for any message?
Another point, I need to install lora gateway bridge in my machine which contains the loraserver?

Thank you for you support! :smiley:


#23

I mean my script, it won’t work as the lorawan package has changed and I haven’t got the time to update it right now. But as I said, you could check that package and try to fix what’s wrong (the errors you got before).

For this to work, your particular deployment doesn’t matter much (i.e., if loraserver/lora-app-server/lora-gateway-bridge are in same or different machines) as long as you have the MQTT broker running and they are all connected to it. The script (if fixed) publishes to the broker.

I’d recommend you give a thorough read to the loraserver architecture and the docs in general.


#25

Hi. Sorry, but not yet.
I’ll try to rewrite it this week and comment here when it’s done.


#26

Firstly, I want to thank you for your support.
I just want to know if I need to change the value that you have in appEUI because the errors that appears me is from the line 322 - 409 and some reason I think it provides from that appEUI that you say in your go file we need to replace, and I don’t know for what I need to replace :thinking:
/*
*
* To test OTAA activation, send a join request.
* Replace appKey, devEUI and appEUI with the correct ones.
*
*/
appKey := [16]byte{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
appEUI := [8]byte{1, 1, 1, 1, 1, 1, 1, 1}
devEUI := [8]byte{2, 2, 2, 2, 2, 2, 2, 2}
this thing is in line 77-85


#27

The problem is bigger than just changing some EUI or removing a legacy one: the program won’t compile as the package lorawan has changed and it depends on it. That’s why it throws error about missing methods and things like that.

I’m pretty sure I’ll be able to rewrite it some time before friday, hope that helps.


How do I can connect MQTT BROKER with NODE RED and show the device data in web browser
#28

Alright, I did a quick fix at work and got it going for an ABP device, LoRaWAN version 1.0.2 and regional parameters B. But it was still a messy script, so later at home I rewrote it to be a package that can be imported.

Sadly, I can’t test that from home, so I’m hoping nothing got messed up in the rewrite. I’ll test it tomorrow at work and fix any issue that I may have missed now. You can check it here, it’s been renamed to show the change: https://github.com/iegomez/loraserver-device-sim

Also, this is the working commit from earlier today when it was still a script: https://github.com/iegomez/loraserver-device-sim/commit/de71f4a14e0cc5266d490239cb6502293bb65b1d

Now, bear in mind that it’s horribly simple right now and just allows to send an Uplink or a JoinRequest, and only for version 1.0.X of LoRaWAN. I’ll be adding some more functionality as I get the time, but hope that helps in the meantime. Take a look at the examples folder for an uplink example program.


#29

teste@teste:~/loraserver-device-sim$ go run lds.go
go run: cannot run non-main package

It gives me this :confused:

Another point and I’m sorry for be so dumb :frowning:
I can send the package and I receive in loraserver this message:

jul 18 09:46:13 diogo loraserver[3971]: time=“2018-07-18T09:46:13+01:00” level=info msg=“backend/gateway: rx packet received”
jul 18 09:46:13 diogo loraserver[3971]: time=“2018-07-18T09:46:13+01:00” level=error msg=“processing rx packet error: get device-session error: device-session does not exist or invalid fcnt or mic” data_base64=“QIMrJgcAAAAByeb1p8PNxYudogA=”


#30

Well yes, lds.go is a package, not a runnable program. On the other hand, uplink_example.go declares the package and function main, so it can be compiled to en executable binary that may run, and imports the package loraserver-device-sim to call the exported functions.

I tested the change today and it’s all working fine here. You probably mixed up the keys, didn’t relax frame counter, selected a different lorawan mac version on device-profile, etc. Here is my device profile :


And here is my device activation:

Note that the first 3 keys are used with lorawan mac version 1.1, so they are all the same and correspond to NwkSKey on version 1.0. Also, on my package the application session key is set in the device as AppSKey. Make sure those are correct.


#31

But where you can find that keys?


#32

You set them. In ABP (activation by personalization) you provide the keys, they are not negotiated by the device and server. So you may press “Generate random key” at the UI and then use those (device address, nwskSKey and AppSKey) when creating a device with my package (remember to leave the same for the 3 keys that come after the device address).


#34

Your lora-app-server is running fine. I don’t know how you configured it, but by default it should expose the UI at localhost:8080. Anyway, I think you need to give a read to the docs before even trying to simulate a device :wink:. I doubt you have a device configured to receive the packets if you haven’t looked at the UI (unless you are doing everything through the API).


#37

I need to click where? In gateway and add it?


#38


#39

Please, read the docs I referenced carefully to get to know the whole loraserver infrastructure. You need to understand those before trying to do more advanced things. It’ll also guide you through the basics, like creating users, organizations, adding gateways, applications, devices, etc.

It is a good amount of information and probably not something to cover in this forum thread, which is getting totally off topic. Also, many of the questions you may have when going through it may already be answered at the forum, so remember to search for them before.

Good luck! :wink:


#40

Hi again,
after your advice I was reading again and more deep the docs.
But I can’t see where I can Generate random key as you said.


#43

jul 19 12:05:00 diogo loraserver[3719]: time=“2018-07-19T12:05:00+01:00” level=info msg=“backend/gateway: rx packet received”
jul 19 12:05:01 diogo loraserver[3719]: time=“2018-07-19T12:05:01+01:00” level=error msg=“processing rx packet error: get device-session error: device-session does not exist or invalid fcnt or mic” data_base64=“QIMrJgcAAAAB0+L0obXqsWqcLNE=”

This is the error message on LoRaServer


#44

The device EUI you entered at lora-app-server doesn’t match the one at the package. Also try to disable the frame counter validation.


#45

This is what I need to write so what I should write in device EUI? I can find in the package…


#46

In the example you have devEUI := [8]byte{0, 0, 0, 0, 0, 0, 0, 2}, which in hex would be 0000000000000002, so the latter is what you need at Device EUI.


#47

jul 19 14:37:33 diogo loraserver[3133]: time=“2018-07-19T14:37:33+01:00” level=info msg=“backend/gateway: rx packet received”
jul 19 14:37:33 diogo loraserver[3133]: time=“2018-07-19T14:37:33+01:00” level=warning msg=“get device-sessions for dev_addr error: object does not exist” dev_addr=07262b83 dev_eui=0102030405060708
jul 19 14:37:33 diogo loraserver[3133]: time=“2018-07-19T14:37:33+01:00” level=error msg=“processing rx packet error: get data-rate error: lorawan/band: data-rate not found” data_base64=“QIMrJgcAAAABzMT1q4KGv6mKagk=”