Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » Posting data object with MQTT(Posting data object with MQTT)
Posting data object with MQTT [message #1783097] Wed, 07 March 2018 21:01 Go to next message
Jairo  Ariza is currently offline Jairo ArizaFriend
Messages: 9
Registered: March 2018
Junior Member
Hello.
In the rest tutorial shows how to post data in the data container http://127.0.0.1:8080/~/in-cse/in-name/MY_SENSOR/DATA using xml content

<m2m:cin xmlns:m2m="http://www.onem2m.org/xml/protocols">
<cnf>message</cnf>
<con>
&lt;obj&gt;
&lt;str name=&quot;appId&quot; val=&quot;MY_SENSOR&quot;/&gt;
&lt;str name=&quot;category&quot; val=&quot;temperature &quot;/&gt;
&lt;int name=&quot;data&quot; val=&quot;27&quot;/&gt;
&lt;int name=&quot;unit&quot; val=&quot;celsius&quot;/&gt;
&lt;/obj&gt;
</con>
</m2m:cin>

or with json

{
"m2m:cin": {"cnf":"message",
"con":"<obj>
<str name=\"appId\" val=\"MY_SENSOR\"/>
<str name=\"category\" val=\"temperature \"/>
<int name=\"data\" val=\"27\"/>
<int name=\"unit\" val=\"Farenheit\"/>
</obj>"
}
}

When I use mqtt to do the same operation with this payload:

payload6="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR/DATA",
"m2m:op" : 1,
"m2m:rqi": 123454,
"m2m:pc": {
"m2m:cin": {"cnf":"message",
"con":"<obj>
<str name=\"appId\" val=\"MY_SENSOR\"/>
<str name=\"category\" val=\"temperature \"/>
<int name=\"data\" val=\"27\"/>
<int name=\"unit\" val=\"Farenheit\"/>
</obj>"
}
},
"m2m:ty": 4}}"""

I get this error:

{
"m2m:rsp" : {
"m2m:rsc" : 4000,
"m2m:pc" : "Invalid content provided in request primitive",
"m2m:to" : "Sensor_MQTT",
"m2m:fr" : "/in-cse"
}
}

But if I sent a simple pc with this payload:

payload6="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR/DATA",
"m2m:op" : 1,
"m2m:rqi": 123454,
"m2m:pc": {
"m2m:cin": {"cnf":"message",
"con":"66 C"
}
},
"m2m:ty": 4}}"""

The instance is successfully created.

how can I successfully create a object data instance with mqtt?

Thank for your help.

Re: Posting data object with MQTT [message #1784106 is a reply to message #1783097] Thu, 22 March 2018 15:38 Go to previous message
Loula Beck is currently offline Loula BeckFriend
Messages: 12
Registered: March 2018
Junior Member
Hi,

Instead of using " in your object try to use '.

[Updated on: Fri, 23 March 2018 07:54]

Report message to a moderator

Previous Topic:OM2M MQTT Response Parameters
Next Topic:Connection between two MN's and one IN
Goto Forum:
  


Current Time: Fri Oct 04 21:23:24 GMT 2024

Powered by FUDForum. Page generated in 0.04191 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top