Simulate message from the Gateway => Gateway Bridge

First Thank you so much for this awesome utility tool !!!




Second, I’m rather new to lorawan and I struggled few hours with the install of Lora server, loraserver_device_simulator (lds), and their connection (lds local, chirpstack on AWS)

So I would like to share my experience and hopefully help some and probably myself too in few weeks :slight_smile: .

For chirpstack (loraserver) on aws this link helped me:


it uses ansible but your can easily use docker or directly the chirpstack-* binary (I tried these 3 methods, they all work as expected)




LORASERVER DEVICE SIMULATOR INSTALL

Working on a Windows computer I decided to opt for a virtual machine (Ubuntu 19.10 thanks https ://www.osboxes.org/ubuntu/)
I spent quite some hours making it run on virtualbox just to learn that virtualbox does not support openGL 3 (which is mandatory in our case)
turns out that VMware support openGL 3 (which is awesome) so I used it.
Plus VMware is so much faster (on both my computers) than virtualbox
I won’t elaborate too much on Chirpstack and AWS integration (I simply followed chirpstack getting started Debian/Ubuntu on my Ubuntu EC2 instance).

I used quite a few programming languages however Go isn’t part of them, here is how I installed lds

to install go and lds
https ://golang.org/doc/install?download=go1.13.4.linux-amd64.tar.gz

Download the archive
$ cd ~/Downloads
$ tar -C /usr/local -xzf go1.13.4.linux-amd64.tar.gz

add to .bashrc:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

create go and src folder
$ mkdir -p $HOME/go/src

install go-dep
$ sudo apt-get install go-dep
$ sudo apt install build-essential xorg-dev libgl1 libgl1-mesa-dev libgl1-mesa-glx redis-server

clone your git project in src, for example (lorhammer)
$ cd $GOPATH/src
$ git clone https://github.com/iegomez/lds.git
$ cd lds
$ make
you should see the “gui” executable appearing
$ touch conf.toml
copy/paste the conf example from https ://github.com/iegomez/lds (Readme) into your freshly created conf.toml




CHIRSPSTACK SET-TUP
(for newbie like me)

In your favorit browser go to your chirpstack app (on my case my AWS EC2 instance) port 8080
http ://xx.xx.xx.xx:8080/

login then create a network-server, organization (optional) as per the chirpstack’s getting started

Service profile:
add gateway meta-data: checked
Enable network geolocation: unchecked
Device-status request frequency: 0
Minimum allowed data-rate: 0
Maximum allowed data-rate: 5

Device Profile:
give an arbitrary name
LoRaWAN MAC version: 1.0.0
LoRaWAN Regional Parameters revision: A
Max EIRP: 0
Geolocation buffer TTL (seconds): 0
Geolocation minimum buffer size: 5

Gateways
Create
give an arbitrary name and description
generate a Gateway ID (refresh icon)
select the network server you created
no need to fill gateway profile
create gateway

Application
Create
give an arbitrary name and description
select the service profile you created

navigate to application (once more)
click on your application freshly created
on “device” click create
give an arbitrary name and description
generate a device EUI then click on MSB and keep that ID for later (be sure to keep it on MSB format) {1}
select the device profile you created
disable frame counter validation: checked
click create device

device page (you get their by finishing the above instruction by going to application->devices and selecting it)
click on Keys (OTAA)
Generated “Application key” and “Gen Application key” although we won’t need the later (refresh icon)
keep the “application key” for later IN LSB format {2}
click Set Device Keys




LORASERVER DEVICE SIMULATOR CONFIGURATION

Now, back to (in my case) Ubuntu on VMware go to the location of the “gui” executable (loraserver_device_simulator (lds) folder)
gedit conf.toml (gedit, vim, vscode, nano, whatever) to edit the lds configuration file

[mqtt]
server: tcp://theIpOfYourChirpstackServer:1883
user: “”
password: “” (I did not set these on my chirpstack app, will do later)
uplink_topic and down_link topic : leave it as it is

[device]
eui = put the MSB eui of your device that you saved in {1}
adress = “00000000” (can be anything, it does no matter just respect the size (number of 0))
network_session_encription_key=“00000000000000000000000000000000” (can be anything, it does no matter just respect the size (number of 0))
serving_network_session_integrity_key=“00000000000000000000000000000000” (can be anything, it does no matter just respect the size (number of 0))
forwarding_network_session_integrity_key=“00000000000000000000000000000000” (can be anything, it does no matter just respect the size (number of 0))
application_session_key=“00000000000000000000000000000000” (can be anything, it does no matter just respect the size (number of 0))
marshaler=“json”
nwk_key=put the LSB App Key of your device that you saved in {2}
app_key=put the LSB App Key of your device that you saved in {2}
join_eui=“0000000000000000” (can be anything, it does no matter just respect the size (number of 0))
mac_version=0
profile=“OTAA”
joined=false
skip_fcnt_check=true

save and close




TEST

on Chirpstack app (http ://xx.xx.xx.xx:8080/)
navigate to you device
navigate to Lorawan Frames

launch the lds gui application (Ubuntu)
$ ./gui
click on “Connect” MQTT & Gateway section
you should see “connection established” in Output section
click on Join in device section

on Chirpstack app (http ://xx.xx.xx.xx:8080/)
you should see a UPLINK (JoinRequest) and DOWNLINK (JoinAccept) message appearing

on lds gui application (Ubuntu)
click on “send data” in data section

on Chirpstack app (http ://xx.xx.xx.xx:8080/)
got to “activation tab” and verify that you have received the network session key and application session key
got to device data and there you will be able to see the the data you send from lds gui (Ubuntu) by clicking again “send data”.

note:
On LoraServer Device Simulator, if you hit reset device, in order to “reactivate it” you will need to use a different Join EUI.




Et Voilà !

2 Likes

Hi @iegomez, i am using your simulator, thanks for this great tool. I think, the device is joined but when i send some data i get a error:

mar 05 12:23:16 onirem chirpstack-network-server[970]: time=“2020-03-05T12:23:16-05:00” level=info msg=“finished client unary call” ctx_id=f4a36a55-1dce-4642-a959-c8d5e5419a2a grpc.code=OK grpc.ctx_id=29205a7a-c5c7-4ae7-b042-02a80ea2cd19 grpc.duration=15.35368ms grpc.method=HandleError grpc.service=as.ApplicationServerService span.kind=client system=grpc
mar 05 12:23:16 onirem chirpstack-network-server[970]: time=“2020-03-05T12:23:16-05:00” level=error msg=“uplink: processing uplink frame error” ctx_id=f4a36a55-1dce-4642-a959-c8d5e5419a2a error=“get device-session error: invalid MIC”

Hey, sorry, I haven’t used this in a while so I’d suggest searching the forum for get device-session error: invalid MIC for hints.

thank you very much, this tutorial has been very helpful for me. Now its working!

Lds is very helpful Lora tools, it works for me. Thanks @iegomez for sharing !
I made some successful tests with my chirpstack server with MQTT, However I wonder how to communicate through UDP with the chirpstack gateway bridge. Do I need to install somehow extra forwarder (like https://github.com/Lora-net/packet_forwarder) between lds and the chirpstack gateway bridge ?

Thx

Hey, I didn’t do the work for the packet forwarder support and I’m also a bit away from development of the tool. I added the contributor to this functionality as a maintainer, so you may open an issue and ask there directly, I’m sure he’ll be able to help much more than I can right now.