6.5 Primitive Mapping
6.5.1 Request primitives
A oneM2M request primitive is made up of a number of control parameters and (optionally) a content part. All the parameters in these parts are serialized into the payload of an MQTT Publish Packet, using the rules given in clause 8 of oneM2M TS-0004 [3] applied to m2m:requestPrimitive defined in clause 6.4.1 of oneM2M TS-0004 [3].
All the parameters that are present in the primitive shall be serialized, in particular the request shall contain the mandatory parameters such as Operation, To, From, Request Identifier as specified in clause 8.1.2 of oneM2M TS-0001 [2] and 7.1.1.1 of oneM2M TS-0004 [3].

Figure 6.5.1-1: MQTT Request example
An example of an MQTT Request message serialized using JSON is:
{
"op": 1,
"to": "//xxxxx/2345",
"fr": "//xxxxx/99",
"rqi": "A1234",
"ty": 18,
"pc": {
"m2m:sch":{
"rn": "schedule1",
"se": {
"sce": ["* 0-5 2,6,10 * * * *"]
}
}
},
"ot": 20150910T062032
}
- op: short name of Operation parameter specified as m2m:operation in oneM2M TS-0004 [3].
- to: short name of To parameter specified either xs:anyURI [3] or m2m:nhURI [3]. It is an URI of the target resource.
- fr: short name of From parameter which is an ID of the Originator e.g. either the AE or CSE.
- rqi: short name of Request Identifier specified as m2m:requestID [3].
- ty: short name of Resource Type parameter specified as m2m:resourceType [3].
- pc: short name of Content parameter specified in oneM2M TS-0004 [3].
- ot: short name of Originating Timestamp parameter specified as m2m:timestamp [3].
6.5.2 Response primitives
A oneM2M response primitive is serialized using the rules given in clause 8 of oneM2M TS-0004 [3] applied to m2m:responsePrimitive defined in clause 6.4.2 of oneM2M TS-0004 [3].
In particular, each response primitive shall include the Response Status Code parameter to indicate success or failure of the operation and the Request Identifier parameter.

Figure 6.5.2-1: MQTT Response example
An example of an MQTT Response message serialized using JSON is:
{
"rsc": 2000,
"rqi": "A1234",
"pc": {
"m2m:sch": {
"se": {
"sce": ["* 0-5 2,6,10 * * * *"]
}
}
},
"to": "//xxxxx/2345",
"fr": "//xxxxx/99"
}
- rsc: short name of Response Status Code parameter specified as m2m:responseStatusCode in oneM2M TS-0004 [3].
- rqi: short name of Request Identifier specified as m2m:requestID in oneM2M TS-0004 [3].
- pc: short name of Content parameter specified in oneM2M TS-0004 [3].
- to: short name of To parameter specified either xs:anyURI [3] or m2m:nhURI [3]. It is an URI of the target resource.
- fr: short name of From parameter which is an ID of the Originator e.g. either the AE or CSE.
6.5.3 Serialization Format Negotiation
When sending a response primitive over MQTT, the Receiver should use the same serialization that was used in the corresponding request primitive.
6.5.4 Content-type
An MQTT message payload contains a oneM2M request or response primitive which is serialized using the XML, the JSON or the CBOR encoding given in clause 8 of oneM2M TS-0004 [3].
When an MQTT client publishes a message, it shall use a Topic name to indicate the format of the payload included in a PUBLISH message. As defined in clause 8 of oneM2M TS-0004 [3], the payload of request or response message shall include oneM2M primitives serialized using XML, JSON or CBOR.
The Topic name takes this form:
- /oneM2M/req/<originator>/<receiver>/xml or /oneM2M/req/<originator>/<receiver>/json or /oneM2M/req/<originator>/<receiver>/cbor
- /oneM2M/resp/<originator>/<receiver>/xml or /oneM2M/resp/<originator>/<receiver>/json or /oneM2M/resp/<originator>/<receiver>/cbor
In order to receive a PUBLISH message with the Topic name, each MQTT client shall subscribe to the Topic name as follows:
- /oneM2M/req/+/<receiver>/#
- /oneM2M/resp/<originator>/#
In some figures in the present document, topic strings are shown that do not end with /json, /xml or /cbor. However the suffix /json, /xml, or /cbor shall always be used.