Sample messages from IOT sensors for MQTT communications

429 views Asked by At

There is an M2M Application which wants to talk to the temperature sensors on the field, i.e. send/receive messages using MQTT pub/sub protocol.

I have setup both IOTDM as well as one with eclipse OneM2M using Mosquito. But, I am looking for some sample APIs/commands through which a M2M application can send a message to the MQTT client and vice versa.

Or if any of you could point me to the appropriate call flows that would be helpful.

Any help would be highly appreciated.

2

There are 2 answers

1
Giorgio Cerruti On

For an JS speach i made an app for mesure the soil moisture. I used MQTT for send information from my Arduino to server written in NodeJS. I don't know if you have some skills on JS. You can see the cond on my github repo . I hope this solution can help you.

0
beaver On

Here is a GET MQTT message example:

topic: /oneM2M/req/{{origin}}/{{cse-id}}/json
message: 
{
    "m2m:rqp": {
        "op": "2",
        "to": "{{resource_uri}}",
        "fr": "{{origin}}",
        "rqi": 12345,
        "pc": ""
    }
}
  • {{resource_uri}} is the relative path of a resource existing on the oneM2M server (e.g. /my_cse_base/my_ae)
  • {{origin}} is the origin enabled (by ACP) to retrieve the resource
  • {{cse-id}} is the CSEbase ID

The message received could be similar to:

topic: /oneM2M/resp/{{origin}}/{{cse-id}}/json
message: 
{
    "m2m:rsp": {
        "rsc": 2000,
        "rqi": 12345,
        "pc": {
            "m2m:ae": {
                "pi": "Sy2XMSpbb",
                "ty": 2,
                "ct": "20170706T085259",
                "ri": "r1NX_cOiVZ",
                "rn": "my_ae",
                "lt": "20170706T085259",
                "et": "20270706T085259",
                "acpi": ["/my_cse_base/acp_my_ae"],
                "aei": "my_ae_id",
                "rr": true
            }
        }
    }
}

A POST example:

topic: /oneM2M/req/{{origin}}/{{cse-id}}/json
message: 
{
    "m2m:rqp": {
        "op": "1",
        "to": "{{resource_uri}}",
        "fr": "{{origin}}",
        "rqi": 12345,
        "ty": "4",
        "pc": {
            "m2m:cin": {
                "cnf": "text/plain:0",
                "con": "123",
                "lbl": ["test"]
            }
        }
    }
}
  • {{resource_uri}} is the relative path of a resource existing on the oneM2M server (e.g. /my_cse_base/my_ae)
  • {{origin}} is the origin enabled (by ACP) to create a new resource
  • {{cse-id}} is the CSEbase ID