Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » MQTT: Error in creating container/content instance on MN-CSE/IN-CSE
MQTT: Error in creating container/content instance on MN-CSE/IN-CSE [message #1782043] Fri, 16 February 2018 12:28 Go to next message
Muhammad Kamran is currently offline Muhammad KamranFriend
Messages: 18
Registered: November 2017
Junior Member
Tried to create container/content instance on MN-CSE/IN-CSE over MQTT by following https://wiki.eclipse.org/OM2M/one/MQTT_Binding, but receiving following response.

{
"m2m:rsp" : {
"m2m:rsc" : 4000,
"m2m:pc" : "No Operation provided",
"m2m:fr" : "/MN-CSE7"
}
}


Request Topic: /oneM2M/req/AE_123/in-cse/json

Payload
{
"m2m:rqp" : {
"fr" : "AE_123",
"to" : "/in-cse/in-name/AE_123",
"op" : 1,
"rqi": 123456,
"pc": {
"m2m:cnt" : {
"rn": "cntName"
}
},
"ty": 3
}
}
Re: MQTT: Error in creating container/content instance on MN-CSE/IN-CSE [message #1783098 is a reply to message #1782043] Wed, 07 March 2018 21:39 Go to previous messageGo to next message
Jairo  Ariza is currently offline Jairo ArizaFriend
Messages: 9
Registered: March 2018
Junior Member
Hi with this python code I manage to create app, container and send data via MQTT.

import paho.mqtt.client as mqtt
import time
def on_message(client, userdata, msg):
print("Respuesta del topico: "+str(msg.payload.decode("UTF-8")))

topic="/oneM2M/req/Sensor_MQTT/in-cse/json"
payload_lista=[]
payload1="""{"m2m:rqp": {"m2m:fr": "Sensor_1","m2m:to": "/in-cse","m2m:op": 2,"m2m:rqi": 123456}}"""

payload2="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name",
"m2m:op" : 1,
"m2m:rqi": 123456,
"m2m:pc": {
"m2m:ae": {
"api": "app-sensor",
"rr": "false",
"lbl": ["Type/sensor", "Category/temperature", "Location/home"],
"rn": "MY_SENSOR"}},
"m2m:ty": 2}}"""

payload3="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR",
"m2m:op" : 1,
"m2m:rqi": 123456,
"m2m:pc": {"m2m:cnt": {"rn": "DESCRIPTOR"}},
"m2m:ty": 3}}"""

payload5="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR",
"m2m:op" : 1,
"m2m:rqi": 123456,
"m2m:pc": {"m2m:cnt": {"rn": "DATA"}},
"m2m:ty": 3}}"""

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":"55 C"
}
},
"m2m:ty": 4}}"""

payload_lista.append(payload1)
payload_lista.append(payload2)
payload_lista.append(payload3)
payload_lista.append(payload5)
payload_lista.append(payload6)

for payload in payload_lista:
client = mqtt.Client("OM2M_MQTT")
client.on_message = on_message
client.connect("127.0.0.1", 1883)

client.loop_start()
client.subscribe("/oneM2M/resp/in-cse/Sensor_MQTT/json")
print("prueba del MQTT: "+payload)
print()
client.publish(topic,payload)
time.sleep(1)
client.on_message = on_message
client.loop_stop()

I hope this helps

Regards

[Updated on: Wed, 07 March 2018 21:41]

Report message to a moderator

Re: MQTT: Error in creating container/content instance on MN-CSE/IN-CSE [message #1783122 is a reply to message #1783098] Thu, 08 March 2018 07:07 Go to previous message
Muhammad Kamran is currently offline Muhammad KamranFriend
Messages: 18
Registered: November 2017
Junior Member
Thanks, it helped, replacing key parameters of json solved issue e.g "op" with "m2m:op"
Previous Topic:Test MQTT blinding in OM2M
Next Topic:CORS issue
Goto Forum:
  


Current Time: Mon Sep 24 07:10:36 GMT 2018

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

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

Back to the top