Subscribing to n device under one application

Hi,
Can we subscribe to multiple devices under one application? If so how the result will be? If the data comes from different devices at a time how mqtt subscribe will taken care?

Yes, for example:

mosquitto_sub -t "application/1234/node/+/rx" -v

Note that + is a wildcard for one level. You can also use #, e… application/1234/# to subscribe to everything under the application/1234/ prefix.

Hi,
Thanks for your reply:grinning::grinning:. I got the clear idea now.

Hi brocaar,
I need to subscribe for 16 devices under one application. I am planning to use the below command
mosquitto_sub -t “application/1234/node/+/rx” -v
but can you please tell me what will be the result of above command if two devices sends data simultaneously.

I believe you should see 2 strings simultaneously. Each string will contain node_ID field which refers to a particular device.

Something like this:
application/14/node/0000000000000001/rx {“applicationID”:“14”,“applicationName”:“dragino_app”,“nodeName”:“dragino_node”,“devEUI”:“0000000000000001”, ETC…}

Mosquitto_sub subscribes to pointed topic and listens it all the time. It is not a one time command. =)

Hi lance ,
Thank you for your reply.
My question is if i subscribe to multiple devices ( mosquitto_sub -t “application/1234/node/+/rx” -v), and two devices sends data simultaneously how the json format will be.

Whether we will get one after the another like below?
{“applicationID”:“14”,“applicationName”:“dragino_app”,“nodeName”:“dragino_node1”,“devEUI”:“0000000000000001”, ETC…}
{“applicationID”:“14”,“applicationName”:“dragino_app”,“nodeName”:“dragino_node2”,“devEUI”:“0000000000000002”, ETC…}

I believe we will. Unfortunately I have no devices to test, but there has to be a mechanic which manages free time slots inside the server to prevent collisions, if that is what are you talking about.

Thank you lance . :grinning:
If someone have tested with two devices please give me the output of mqtt_sub when two devices sends data at a time.

You will get both, one after the other, like this:

{"applicationID":"3","applicationName":"app1","deviceName":"test-node-2","devEUI":"0303030303030303","rxInfo":[{"mac":"b827ebfffee100b5","time":"2017-12-15T10:30:43-03:00","rssi":-57,"loRaSNR":7,"name":"rak831one","latitude":-33.43367,"longitude":-70.61953,"altitude":600}],"txInfo":{"frequency":902300000,"dataRate":{"modulation":"LORA","bandwidth":500,"spreadFactor":8},"adr":false,"codeRate":"4/5"},"fCnt":0,"fPort":1,"data":"ABQA0HOPQM3HxcAE"}

{"applicationID":"3","applicationName":"app1","deviceName":"test-node","devEUI":"0202020202020202","rxInfo":[{"mac":"b827ebfffee100b5","time":"2017-12-15T10:30:43-03:00","rssi":-57,"loRaSNR":7,"name":"rak831one","latitude":-33.43367,"longitude":-70.61953,"altitude":600}],"txInfo":{"frequency":902300000,"dataRate":{"modulation":"LORA","bandwidth":500,"spreadFactor":8},"adr":false,"codeRate":"4/5"},"fCnt":0,"fPort":1,"data":"ABQA0HNkgM3HukAG"}

You can see that they both have the same timestamp. This was tested and confirmed, as you can see in this screenshot, where some modified mqtt messages are received by a javascript client and shown in a map:

So, in summary, don’t worry about two nodes sending at the same time: if your gateway has multiple channels, it will handle them correctly and any of the two will be seen just before the other at the application level.

2 Likes

Thank you very much iegomez :grinning: