Sending data to lora node with mqtt


#1

i wrote a nodejs mqtt client code to publish the data that i want to send to the lora node. the mqtt subscriber is able to display it but the lora node receive nothing.

application/2/node/0004a30b001b5bd8/tx {“reference”:“abcd1234”,“confirmed”:true,“fPort”:11,“data”:“SGVsbG8=”,“object”:{“temperatureSensor”:{“1”:25},“humiditySensor”:{“1”:32}}}

however i found the following message in the log file of lora-app-server

Apr 23 15:58:29 rhf2s001 lora-app-server[722]: time=“2018-04-23T15:58:29Z” level=error msg=“handle data-down payload error: no or invalid codec configured for application” application_id=2 dev_eui=0004a30b001b5bd8 reference=abcd1234

anything i can do to fix the error?


Unable to send downlinks to devices
Issues with MQTT to send data to node
Cannot getting downlink from server to endnode
#2

If you are completing some testing like I did…

Change it to:

application/2/node/0004a30b001b5bd8/tx {“reference”:“abcd1234”,“confirmed”:true,“fPort”:11,“data”:“SGVsbG8=”

You’ll be able to send it without decode script.

Regard.


#3

Yes, this time the error message of handle data-down payload gone after i removed the object but my arduino lora node still didn’t receive the message.

Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="handler/mqtt: data-down payload received" topic=application/2/node/0004a30b001b5bd8/tx
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[[0 4 163 11 0 27 91 216]]" duration=2.445065ms query="select * from device where dev_eui = $1"
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[0004a30b001b5bd8]" duration=4.618461ms query="\n\t\tselect\n\t\t\tns.*\n\t\tfrom\n\t\t\tnetwork_server ns\n\t\tinner join device_profile dp\n\t\t\ton dp.network_server_id = ns.id\n\t\tinner join device d\n\t\t\ton d.device_profile_id = dp.device_profile_id\n\t\twhere\n\t\t\td.dev_eui = $1"
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="finished client unary call" grpc.code=OK grpc.method=GetDevice grpc.service=ns.NetworkServer grpc.time_ms=4.693 span.kind=client system=grpc
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[0004a30b001b5bd8]" duration=4.418355ms query="\n\t\tselect\n\t\t\tns.*\n\t\tfrom\n\t\t\tnetwork_server ns\n\t\tinner join device_profile dp\n\t\t\ton dp.network_server_id = ns.id\n\t\tinner join device d\n\t\t\ton d.device_profile_id = dp.device_profile_id\n\t\twhere\n\t\t\td.dev_eui = $1"
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="finished client unary call" grpc.code=OK grpc.method=GetNextDownlinkFCntForDevEUI grpc.service=ns.NetworkServer grpc.time_ms=11.525 span.kind=client system=grpc
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[[0 4 163 11 0 27 91 216]]" duration=3.126995ms query="\n        select *\n        from device_activation\n        where\n            dev_eui = $1\n        order by\n            created_at desc\n        limit 1"
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[2018-04-24 00:26:01.593189526 +0000 UTC m=+5390.585535276 abcd1234 [0 4 163 11 0 27 91 216] 759]" duration=2.466627ms query="\n\t\tinsert into device_queue_mapping (\n\t\t\tcreated_at,\n\t\t\treference,\n\t\t\tdev_eui,\n\t\t\tf_cnt\n\t\t) values ($1, $2, $3, $4)\n\t\treturning id"
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="device-queue mapping created" dev_eui=0004a30b001b5bd8 f_cnt=759 id=28 reference=abcd1234
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="finished client unary call" grpc.code=OK grpc.method=CreateDeviceQueueItem grpc.service=ns.NetworkServer grpc.time_ms=13.78 span.kind=client system=grpc
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=info msg="downlink device-queue item handled" confirmed=true dev_eui=0004a30b001b5bd8 f_cnt=759 reference=abcd1234
Apr 24 00:26:01 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:01Z" level=debug msg="sql query executed" args="[]" duration=4.167729ms query="\n\t\tselect\n\t\t\tg.*\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval '24 hours' / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
Apr 24 00:26:02 rhf2s001 lora-app-server[725]: time="2018-04-24T00:26:02Z" level=debug msg="sql query executed" args="[]" duration=4.307158ms query="\n\t\tselect\n\t\t\tg.*\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval '24 hours' / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"

anything i should do to further debug down the lora node?


#4

Under Live LoRaWAN frame logs PANEL … can you see the downlink frame… under RX/TX parameters ???
… and what keys do you see under downlink>txInfo ???


#5

no packet receive at all at the panel of live lorawan frame logs of the device

only uplink packets are shown at the panel of the live lorawan frame log of the gateway


#6

Question #1: Can I assume the gateway has transmitted the message i generated when I see the following mqtt message published by the gateway?

application/2/node/0004a30b001b5bd8/tx {"reference":"abcdxx1234","confirmed":true,"fPort":1,"data":"SGVsbG8="}
gateway/b827ebfffe958375/tx {"token":46475,"txInfo":{"mac":"b827ebfffe958375","immediately":false,"timestamp":2458150251,"frequency":922900000,"power":23,"dataRate":{"modulation":"LORA","spreadFactor":7,"bandwidth":125},"codeRate":"4/5","iPol":null,"board":0,"antenna":0},"phyPayload":"oNcZdQeClQEIAQHJi3cD5g8pqkU="}

Question #2: Can I considered the lora node acknowledge the receive of the message transmitted by the gateway with the following mqtt message published?

application/2/node/0004a30b001b5bd8/ack {"applicationID":"2","applicationName":"streetlight","deviceName":"sl_100","devEUI":"0004a30b001b5bd8","reference":"abcdxx1234","acknowledged":false,"fCnt":405}


#7

Question #1: Can I assume the gateway has transmitted the message i generated when I see the following mqtt message published by the gateway?

No, it only indicates that the message was sent to the gateway, not by the gateway. When using the latest packet-forwarder, you will see an gateway/b827ebfffe958375/ack message, this indicates that the message was acknowledged for transmission (which could be in the future).

Question #2: Can I considered the lora node acknowledge the receive of the message transmitted by the gateway with the following mqtt message published?

When you receive a message on application/2/node/0004a30b001b5bd8/ack it means a confirmed downlink message was acknowledged (edit) by the device.


#8

the downlink message was acknowledged by the lora node?


#9

…if it can help…

You could open 4 terminals session…and execute these commands to see your Downlink TX live…

  1. journalctl -u loraserver -f
  2. journalctl -u lora-app-server -f
  3. journalctl -f -n 100 -u lora-gateway-bridge -f
  4. mosquitto_sub -v -t “gateway/+/tx” -u {user} -P {pasword} -h localhost -p 1883
  5. click on your nodered to execute the flow
  6. …fun begin…gather all informations and/or error messages in each terminal

you could also try to get all these info from LOGS… but this is another story…


#10

Hi guys,

I am currently testing some devices on our LoraServer setup. More specifically, I am testing an pulse meter by SensingLabs. The device is working just fine and I can successfully receive messages from it. However I need to reset to 0 the current index of the device and, in order to do so, I have to send a downlink with the following bytes to reset it.

020400000000

Based on what I have read, in order to send this to the device I have to encode it in base64 (AgQAAAAA) and send it via an MQTT client right?

So, I am using MQTT.fx and an I am trying to publish que following message:

{
“reference”: “reset”,
“confirmed”: true,
“fPort”: 2,
“data”: “AgQAAAAA”
}

I checked the users guide of the device and the fPort to downlink is “2" and I have tried both confirmed and unconfirmed downlinks. I can’t even see the downlinks in the frame logs and I am supposed to receive an uplink confirming the reset. Also tried to enable Class-B and Class-C options on device profiles.

Any suggestions?


#11

Hi Kim_Chuan_Lim,
I am trying to create a similar application ( node.js mqtt client application) , hiwerver i have to been facing a lot of problem connecting to the mqtt server. I found out that is was not possible to connect to the mqtt server directly from browser. I would like to know how u solved the problem. DId you create another socket connection to mqtt that servery your application ?


#12

first, make sure your nodejs mqtt client has no problem to subscribe to any topic published by loraserver or lora-app-server before you test the mqtt publish?

i’m using https://www.npmjs.com/package/mqtt and running from console (not browser).


#13

I am facing a issue similar to this topic

I able to send downlink data using the api ( device queue) but the same thing is not possible via mqtt
my mqtt topic:
application/1/device/0102030405060708/tx

here i can see message received

but in lora-app-server or loraserver log nothing is printed and the message is also not added to queue.


#14

this work for me with nodejs

var mqtt = require(‘mqtt’)
var client = mqtt.connect(‘mqtt://localhost’) //change this to your MQTT broker ip address

var pm = JSON.stringify({
“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”: Buffer.from(“Hello”).toString(‘base64’), // base64 encoded data (plaintext, will be encrypted by LoRa Server)
});

client.publish("application/1/device/0102030405060708/tx",pm);

#15

my issue is the I am able to publish the data via mqtt but the lora-app-server logs does not show any thing like mqtt received… the lora-app-server is not responding to any mqtt message with tx
. But it is responding to rx, join, and ack messages.

@brocaar any clue about solving the issue


#16

I able to send downlink data using mqtt. downlink data is coming to live lorawan frame logs, and to my gateway but my mbed Lora node didn’t receive the downlink data.


#17

hi i want to know if you have solved the problem? I want to connect to the mqtt server directly from browser


#18

Hi,
I am getting problem, when I am transmitting downlink from (nodered+MQTT) to the end device is not getting at end device. but when one uplink packet received automatically downlink be received at client(end device). i am not able to find where is the problem?
in my observations

  1. In the automatically send downlink packet phypayload contians ACK: true
    adr:true
    adrAckReq:false
    ack :true
    fPending :false
    classB :false

  2. Downlink packet which is sending by me from nodered + MQTT phypayload contains
    adr:true
    adrAckReq :false
    ack :false
    fPending :false
    classB :false

please suggest me where is the problem(in my Endnode or Server) & tell me answer how can i rectify this problem

Thanks in advance
Regards,
Ashok


#19

Please refer to sending documentation at https://www.loraserver.io/lora-app-server/integrate/data/


#20

Hi Grendy_Eki_Aliandy,
Thanks for your reply,
please tell me where i have to set those payload parameters attached in below screen shot


Thanks in advance.
Regards
Ashok