Hey there,
I’m trying to code a program capable of adding a bunch of LoRa fake devices to Chirpstack and using these devices to send fake data to Chirpstack.
I succeeded to add devices via the API with my program but I don’t know how to send fake data to Chirpstack via the API.
I tried the api/devices/{device_queue_item}/queue but I don’t see any data in the “Device Data” tab.
Here’s the body of the request :
{
“deviceQueueItem”: {
“confirmed”: true,
“data”: “KBoy”,
“devEUI”: “1111111111111111”,
“fCnt”: 0,
“fPort”: 2
}
}
I also tried to push data via the MQTT Broker but it didn’t succeed neither. Here’s the passed command :
mosquitto_pub -h localhost -p 1883 -t “gateway/dca632ffffa8bc6e/event/up” -m ‘{“confirmed”:true,“data”:“KBoy”,“devEUI”:“1111111111111111”,“fCnt”:0,“fPort”:2}’ -u simulator -P Simulator@MQTT2021
Result :
mai 28 10:02:57 raspberrypi chirpstack-network-server[508]: time=“2021-05-28T10:02:57+02:00” level=error msg=“gateway/mqtt: unmarshal uplink frame error” data_base64=“eyJjb25maXJtZWQ6Ijp0cnVlLCJmUG9ydCI6MiwiZGF0YSI6IktCb3kiLCJkZXZFVUkiOiIxMTExMTExMTExMTExMTExIn0=” error=“unexpected EOF”
Is it actually possible to send data via the API or MQTT?
Thanks in advance.
Regards.
Information :
- Host : Raspberry Pi 4
- Chirpstack network server version : 3.12.3
- Chirpstack application server version : 3.14.0
Hey,
I succeeded to fix the previous error and send data via MQTT using the following JSON file :
{
“phyPayload”: “QDtuDwAAmgACT7ELbo4+LA==”,
“txInfo”: {
“frequency”: 868300000,
“modulation”: “LORA”,
“loRaModulationInfo”: {
“bandwidth”: 125,
“spreadingFactor”: 10,
“codeRate”: “4/5”,
“polarizationInversion”: false
}
},
“rxInfo”: {
“gatewayID”: “3KYy//+ovG4=”,
“time”: “2021-05-28T09:15:59.127823500Z”,
“timeSinceGPSEpoch”: “9223372036.854775807s”,
“rssi”: -57,
“loRaSNR”: 7,
“channel”: 0,
“rfChain”: 1,
“board”: 0,
“antenna”: 0,
“location”: null,
“fineTimestampType”: “NONE”,
“context”: “AAAAAA==”,
“uplinkID”: null
}
}
However the topic gateway/+/event/+ is common with all the other devices. So, I would like to send data data on the topic application/{{ AppID }}/device/{{ DevEUI }}/+.
Howerver, when I tried to send data on this topic, the data is successfully sent to the broker but nothing appears on the Chirpstack side.
I’ve seen that many users tried to send data on this topic but nothing seems to correspond to my problem.
Any idea to solve this problem?
Regards.
When you publish data to that topic, ChirpStack will decode the PHYPayload and based on DevAddr and MIC will associate it to a device.
You might be intereted in: GitHub - brocaar/chirpstack-simulator: Simulator utility for the ChirpStack open-source LoRaWAN Network-Server.. Note that you can also use this code as a library.
I didn’t notice that you have created your own simulator so I tried to do my own simulator in python. 
By curiosity, is it possible to use that topic application/{{ AppID }}/device/{{ DevEUI }}/+?
Thanks for your support @brocaar !
Hi @brocaar
Thanks for your help, I tried your simulator and it works as a charm.
Just for fun I tried to do my own simulator in python but i didn’t succeed to encrypt the FRMPayload.
Based on the official LoRa alliance specs and a python module for AES i tried to use AES-CTR as explained but I don’t understand very well.
https://pycryptodome.readthedocs.io/en/latest/src/cipher/classic.html#ecb-mode
In fact, the pycryptodome documentation does not specify if it use a block size of ceil(len(pld) / 16) as it’s recommended in the LoRa spec. Moreover they don’t use any counter block in the example (which is quite annoying for a cryptographic technic based on counter blocks)…
As it’s not linked to the Chirpstack solution I would understand that you don’t answer to my question but it would be very helpfull if you do it.
Thanks in advance.