Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » Test MQTT blinding in OM2M(Test MQTT blinding in OM2M)
Test MQTT blinding in OM2M [message #1776864] Wed, 22 November 2017 11:14 Go to next message
hieu tran is currently offline hieu tranFriend
Messages: 14
Registered: November 2017
Junior Member
I'm reading docs: https://wiki.eclipse.org/OM2M/one/MQTT_Binding
But having some miss understanding:

1. In step: Start the binding

At first, the binding is not started in the org.eclipse.om2m.site.in-cse product. To start it, one must retrieve the bundleId of the MQTT binding plugin using the ss mqtt and then start it using the command start <bundleId>. Otherwise, it can be set as auto-start into the OM2M product.

I did not find bundleId of mqtt although the project builds done (of course having org.eclipse.om2m :: binding mqtt)

Then, I try to test with other available version at: https://wiki.eclipse.org/OM2M/Download but all the sames

2. How to creat topic req,resp and AE ? Have it avaialble ?
In fisrt line of docs:
The Eclipse OM2M MQTT Binding implements the TS-0010 MQTT Protocol Binding defined by the oneM2M consortium. The document is available on the oneM2M website. The Eclipse Paho library has been used as a MQTT Client for the Eclipse OM2M MQTT Binding.

Do I have to creat an app which plays role as MQTT Client by Paho, then sent message ? Have any way to do that ?
Re: Test MQTT blinding in OM2M [message #1777780 is a reply to message #1776864] Mon, 04 December 2017 15:50 Go to previous messageGo to next message
Dorian Kurzaj is currently offline Dorian KurzajFriend
Messages: 16
Registered: May 2016
Junior Member
1. Start the binding
I don't remember, but probably, by default the MQTT module is not enabled in the product (mn or in) you launch. To do so you can take example on how to activate an IPE here : https://wiki.eclipse.org/OM2M/one/Developer#Add_the_plugin_to_the_OM2M_product.28s.29 You just need to do the same, but for the MQTT binding.

2. How to create topic req,resp and AE ? Have it available ?
You need to have a MQTT broker (it's some king of MQTT server which manages the MQTT message queues). In the OM2M tutorial they advise you to use the Mosquitto broker, but you can use any you want. Then, you need to configure OM2M to use this MQTT broker (as described here : https://wiki.eclipse.org/OM2M/one/MQTT_Binding#Constants), and finally, if you want to communicate to OM2M through MQTT you have to make a program which implements an MQTT client which is going to connect to the same broker, so that OM2M and your program can communicate through the same topics.
Here is a Python MQTT client simulating a thermometer I developed :

from random import randint
import paho.mqtt.client as mqtt
import time

####################################################

def on_message(client, userdata, message):
    print("message received ", str(message.payload.decode("utf-8")))
    print("message topic=", message.topic)
    print("message qos=", message.qos)
    print("message retain flag=", message.retain)

###################################################

mqttc = mqtt.Client()
mqttc.on_message = on_message  # Attach function to callback
mqttc.connect("localhost", 1883, 60)
mqttc.loop_start()
mqttc.subscribe("/oneM2M/resp/mn-cse/THERMOMETER/json", 2)

while 1:
    temperature = randint(-10, 40)

    payload = ("""
            {
                "m2m:rqp": {
                    "fr": "THERMOMETER",
                    "to": "/mn-cse/mn-name/THERMOMETER/DATA",
                    "op": 1,
                    "rqi": 123456,
                    "pc": {
                        "m2m:cin": {
                            "cnf": "message",
                            "con": "%s"
                        }
                    },
                    "ty": 4
                }
            }
            """ % str(temperature))

    print("Send:", payload)

    (result, mid) = mqttc.publish(
        "/oneM2M/req/THERMOMETER/mn-cse/json", payload, 2)
    time.sleep(5)

mqttc.loop_stop()
mqttc.disconnect()


This is a MQTT client using the Paho library to communicate in MQTT to my Mosquitto MQTT broker running in localhost:1883. The goal of this MQTT client is to send data to a previously created device registered in OM2M at the URI : /mn-cse/mn-name/THERMOMETER.

I hope this helps ! :)

Best regards,
Dorian

[Updated on: Thu, 14 December 2017 15:02]

Report message to a moderator

Re: Test MQTT blinding in OM2M [message #1777791 is a reply to message #1777780] Mon, 04 December 2017 16:21 Go to previous messageGo to next message
hieu tran is currently offline hieu tranFriend
Messages: 14
Registered: November 2017
Junior Member
Thanks for your answer. I had run mqtt broker and start mqtt blinding.
However, I don't know what strutures of messsage could be sent.
According Tuturial https://wiki.eclipse.org/OM2M/one/MQTT_Binding,
when i sent a message in req topic, om2m have sent back one message to resp topic. But in fact, when sending message into req topic, the response message has some thing wrong:

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



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


Could you show me the response of your example and guide me step how to creat AE or resgister AE to oneM2M ?

Many thanks,

[Updated on: Mon, 04 December 2017 16:22]

Report message to a moderator

Re: Test MQTT blinding in OM2M [message #1778464 is a reply to message #1777791] Thu, 14 December 2017 14:44 Go to previous messageGo to next message
Dorian Kurzaj is currently offline Dorian KurzajFriend
Messages: 16
Registered: May 2016
Junior Member
I just retried and indeed, I have the same error message as you have, maybe the latest update broke the MQTT binding. Is anyone working with MQTT and having no issue using it like the HTTP binding (REST API)?

And I tried with an XML payload (to see if the error would be the same) on the XML dedicated topics, but I get another error:
[ERROR] - org.eclipse.om2m.datamapping.jaxb.Mapper  
JAXB unmarshalling error!
javax.xml.bind.UnmarshalException
 - with linked exception:
[Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {http://www.onem2m.org/xml/protocols}rqp was not found in the project]
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:980)
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:588)
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:182)
	at org.eclipse.om2m.datamapping.jaxb.Mapper.stringToObj(Mapper.java:181)
	at org.eclipse.om2m.binding.mqtt.MqttRequestHandler.messageArrived(MqttRequestHandler.java:180)
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:354)
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:162)
	at java.lang.Thread.run(Thread.java:748)
Caused by: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {http://www.onem2m.org/xml/protocols}rqp was not found in the project
	at org.eclipse.persistence.exceptions.XMLMarshalException.noDescriptorWithMatchingRootElement(XMLMarshalException.java:148)
	at org.eclipse.persistence.internal.oxm.record.SAXUnmarshallerHandler.startElement(SAXUnmarshallerHandler.java:302)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parseEvent(XMLStreamReaderReader.java:132)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:99)
	at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:86)
	at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:895)
	at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:659)
	at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:585)
	... 6 more
[INFO] - org.eclipse.om2m.binding.mqtt.MqttRequestHandler  
Invalid content provided in MQTT request


Here is the type of payload I sent in MQTT:
<m2m:rqp xmlns:m2m="http://www.onem2m.org/xml/protocols">
    <fr>THERMOMETER</fr>
    <to>/mn-cse/mn-name/THERMOMETER/DATA</to>
    <op>1</op>
    <rqi>123456</rqi>
    <pc>
        <m2m:cin xmlns:m2m="http://www.onem2m.org/xml/protocols">
            <cnf>application/xml</cnf>
            <con>%s</con>
        </m2m:cin>
    </pc>
</m2m:rqp>


Apparently, according to the error stack trace, my use of the tag: <m2m:rqp xmlns:m2m="http://www.onem2m.org/xml/protocols"> is wrong or bugged. Any hint about that too ?

[Updated on: Mon, 18 December 2017 09:11]

Report message to a moderator

Re: Test MQTT blinding in OM2M [message #1783009 is a reply to message #1778464] Tue, 06 March 2018 12:48 Go to previous message
Loula Beck is currently offline Loula BeckFriend
Messages: 12
Registered: March 2018
Junior Member
Hi,

I would like to know if this problem has been fixed ? If not, how did you overcome with this issue ?

Thanks in advance.

[Updated on: Tue, 06 March 2018 14:50]

Report message to a moderator

Previous Topic:NM-CSE registration error
Next Topic:MQTT: Error in creating container/content instance on MN-CSE/IN-CSE
Goto Forum:
  


Current Time: Tue Nov 13 20:19:43 GMT 2018

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

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

Back to the top