1

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.

beaver
  • 17,333
  • 2
  • 40
  • 66
santos
  • 31
  • 4

2 Answers2

1

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
beaver
  • 17,333
  • 2
  • 40
  • 66
0

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.

Giorgio Cerruti
  • 896
  • 6
  • 17
  • Thanks for sharing. But, I am thinking for little more help from the M2M API point of view. – santos Dec 29 '16 at 09:15