Downlink packets with Laird Sentrius RG186 (MQTT forwarder)

Hi,
sorry for my issue.
I’m using a Laird Sentrius RG186 gateway configured with the MQTT forwarder which addresses data towards a MQTT Mosquitto broker installed on a Raspberry Pi.
I’m trying to understand how it works and I managed to see posts on topic gateway/{device-eui}/rx (received from lora nodes) using node-red or MQTTLens app. An example of the received .JSON object is: { topic: “gateway/{device-eui}/rx”, payload: “{“rxInfo”:{“mac”:”{device-eui}…", qos: 0, retain: false, _msgid: “7aa59b96.db1214” }.
Now I want to communicate with nodes and I’m trying to find the .JSON template needed, but I don’t find it.
Can you help me?

There is an page about MQTT integration at MQTT - ChirpStack open-source LoRaWAN<sup>®</sup> Network Server
but you should be carefull because at this topic the payload is yet encrypted and probably you should be using the topic application/+/device/+/rx wich is the output from app Server, there you will have decrypted frmPayload wich is the output from phyPayload. in order to use MQTT gateway topic you should be posting in tx sufix: gateway/{device-eui}/tx but you should only post encrypted data, phyPayload. if you have the gateway properly configured you should be able to monitor server response at this topic.

I.E.:

mosquitto_sub -t 'gateway/+/tx'
{"token":56971,"txInfo":{"mac":"c0ee40ffff293829","immediately":false,"timestamp":833375316,"frequency":923300000,"power":20,"dataRate":{"modulation":"LORA","spreadFactor":10,"bandwidth":500},"codeRate":"4/5","iPol":null,"board":0,"antenna":0},"phyPayload":"YG8+LumnUBMFCGjijAgBAWgeTg=="}

Kind Regards.

1 Like

Thank you for your reply !

Ok, but do I need mandatorily LoRa App Server to communicate with a node or is can I use a .JSON template to communicate without having LoRa Server ad LoRa App Server but using only the LoRa Gateway Bridge pre-installed in Sentrius?

It is not mandatory but you would have to respect all LoRa Alliance LORAWAN specifications. If you have this developed then you are good to go and wont need to install LoRa Server, but if you dont you will probably enjoy al the work that is free and open source developed by Brocaar in the project LoRa Server.

I really appreciate this open source project :slight_smile:
I’d like to understand how to schedule a downlink packet to a LoRa Node by posting on “gateway/+/tx”. Is it possible ? And if it is, how can I do it? What am I supposed to post ?
Sorry for my insistence @brocaar

Is possible and in order to do this you will have to refer to LoRaWAN specifications to build your phyPayload based on desired data and your keys and devEUI.
https://www.lora-alliance.org/resource-hub/lorawantm-specification-v11
also find out how this token works.
good luck

1 Like

@Alexandre_Pelagaggi

Thanks for nice explanation.But still i have one query.

{
    "reference": "abcd1234",                  // reference which will be used on ack or error (this can be a random string)
    "confirmed": true,                        // whether the payload must be sent as confirmed data down or not
    "fPort": 10,                              // FPort to use (must be > 0)
    "data": "...."                            // base64 encoded data (plaintext, will be encrypted by LoRa Server)
    "object": {                               // decoded object (when application coded has been configured)
        "temperatureSensor": {"1": 25},       // when providing the 'object', you can omit 'data'
        "humiditySensor": {"1": 32}
    }
}
  1. How about the above format ,can we use it for downlink testing? or do we need to use the same format that how you are using with tokens and other field?
  2. If so ,whether the token field is mandatory ?
  3. Regarding payload (data encoding) - just converting plain text in to base64 format, is it enough or do we need to use keys to encrypt data?

Please help me to resolve. I couldn’t achieve downlink data,i tried using the following topics:

`application/[applicationID]/node/[devEUI]/tx`
'gateway/+/tx

But none of them i am not getting downlink data.

Thanks in Advance!

Hi !

  1. The format you posted is ok (except for the field "object which is linked to a specific application so I advise to cancel it) and it is not necessary to use the one proposed by Alexandre
    I use the following format and it works:
    "{"reference": "ABCD1234","confirmed": false,"fPort": 4,"data": "AOfZ9iI="}"

  2. No token field mandatory :wink:

  3. LoRaServer and LoRaAppServer manage the encryption and the decryption of the payload so you only have to encode you data in Base64 and put it in the “data” field. Note that you need to create an application and add your device with its AppKey and NtwKey in LoRa AppServer to make it work.

Finally you have to post your payload in the topic application/[applicationID]/node/[devEUI]/tx.

Let me know if you need further help.

lcer

1 Like

@lcer93

Thank you so much for your quick reply :grinning:and very informative.I was struggling to find answer for this question for long time :sweat:

So i will give a try with the above format with your suggested topic and get back to you shortly.

Thanks once again!

Hi @lcer93

Sorry for the edit.
Just now i was checking the log file.When i am sending uplink data itself i am getting the following error.

INFO[0613] backend/gateway: rx packet received
ERRO[0613] processing rx packet error: get device-session error: device-session does not exist or invalid fcnt or mic  data_base64="gOMaASaABAAFMfzd1PqYg9o="

But payload reaches gateway live frame logs page(webui)

I hope if i cleared this error ,my downlink will run smoothly.
Can you please share your thoughts on this error?

Hi @Praveen_Kumar_R,
I think that your error is related to a worng or incomplete configuration of the device on the LoRa App Server webui.
Unfortunately, I don’t know exactly the meaning of the error, but I think that @brocaar can surely help you understanding it.
I’m sorry for not being helpful, but I feel you are very close to the solution !

I put here my downlink packet log from Live LoRaWAN frame logs:

To check your steps in the application and device configuration, I suggest to follow this instructions I found here in the forum:

Setting up an initial application
In order to receive data from a device / node, that device must be associated with an
application. This can be done via the REST interface via some external application, or via
the UI that comes with LoRa App Server.
To access the LoRa App Server web-interface, enter the IP address of your server and the port
as defined in application_server.external_api.bind in your browser specifying the https protocol in your browser’s address bar, example: https://localhost:8080.
This will forward to a login screen. A default administrator account is available at
installation time with the username of admin and a password of admin (it would be wise to
reset the password upon first login).
In order to connect you LoRa App Server instance with the LoRa Server instance, click Network
servers and then Add network-server. As LoRa Server is installed on the same host as LoRa App
Server, use localhost:8000 as network-server name.
After adding the network-server, click on LoRa Server to go back to the home screen. Then
open the Service profiles tab and click Create service-profile to create a service-profile
for the LoRa Server organization. This will also associate the organization with the
network-server instance.
After creating the service-profile, go to the Device profiles tab and click Create
device-profile. Here you can define the device properties and capabilities (e.g. OTAA vs ABP).
After connecting LoRa App Server with the LoRa Server network-server, creating a service- and
device-profile it is time to create your first application and add a device!
Go to the Applications tab and click the CREATE APPLICATION button, and add an application
for your device(s). This only requires an application name and description. Once the
application is created, you can click on the title to get a list of the devices associated
with the application (none at system installation). Click on the CREATE DEVICE button to
create the node (device). The basic fields that are required are the Device name,
Description, Device EUI and the Device-profile. After creating the device, you will be
redirected to a page to enter the AppKey in case of an OTAA device or to activate the device
in case of an ABP device.
Once the device and it application are created, the LoRa Server and LoRa App Server will be
able to handle messaging from the device.

@lcer93

Thank so much for your detailed info.Sorry for late reply. I was out of station for two days.

Sure i will check with the above steps and get back to you.

Before that i want to share my current device profile and app settings for reference.If any mistakes please correct me.

Clarification :

Serving network session integrity key *

I am not sure with this keys, i have just given random generate and i am not using this keys anywhere.
Will it be a problem?

No problem, I was out of office too.
Your configuration appears ok, even if I think you have a different version of LoRa App Server installed (maybe a more recent one).
I post my configuration:




Note that I don’t know if my configuration is perfectly correct since I’m only doing some tests.

Thanks for quick reply.I think if @brocaar if coming in to the picture ,we can get some more details.

@brocaar :

Please help me to resolve this. Please advise me what is wrong with my lora-app-server configuration.

Thanks

finally solved my issue! Thanks for everyone.

Problem is network session key and network session integrity key both should be same.

Thanks,
Praveen

2 Likes