-
Notifications
You must be signed in to change notification settings - Fork 4
4. Device Management Commands
simen edited this page Oct 10, 2016
·
3 revisions
- Read
- Write
- Discover
- Write Attributes
- Execute
- Create (not supported)
- Delete (not supported)
- Observe
- Ping
- Given keys (oid, iid, rid) to alloacte a Resource
- Given keys (oid, iid) to alloacte an Object Instance
- Given a key (oid) to allocate an Object
- REQ: request
- RSP: response
- s2c: Direction is from Server to Client
- c2s: Direction is from Client to Server
-
Command Id:
0
or'read'
-
REQ (s2c):
{ transId, cmdId, oid[, iid[, rid]] }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
205
(Content),400
(BadRequest),404
(NotFound),405
(MethodNotAllowed)
- Possible status:
- Note: none
-
Examples
- Read an Object
// REQ { transId: 10, cmdId: 0, oid: 3303 } // RSP { transId: 10, cmdId: 0, status: 205, data: { '0': { sensorValue: 21, units: 'Cel', minMeaValue: 18, maxMeaValue: 23 }, '1': { sensorValue: 22.6 }, '2': { sensorValue: 24.1 } } }
- Read an Object Instance
// REQ { transId: 11, cmdId: 0, oid: 3303, iid: 0 } // RSP { transId: 11, cmdId: 0, status: 205, data: { sensorValue: 21, units: 'Cel', minMeaValue: 19, maxMeaValue: 32 } }
- Read a Resource
// REQ { transId: 12, cmdId: 0, oid: 3303, iid: 0, rid: 5700 } // RSP { transId: 12, cmdId: 0, status: 205, data: 18 }
- Read an Object
-
Command Id:
1
or'write'
-
REQ (s2c):
{ transId, cmdId, oid, iid, rid, data }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
204
(Changed),400
(BadRequest),404
(NotFound),405
(MethodNotAllowed)
- Possible status:
-
Note: Writing an Object or Object Instance is in vain, will return status
405
back -
Examples
- Write an Object
// REQ { transId: 13, cmdId: 1, oid: 3303, data: { '0': { units: 'F' } } } // RSP { transId: 13, cmdId: 1, status: 405, data: null }
- Write an Object Instance
// REQ { transId: 14, cmdId: 1, oid: 3303, iid: 0, data: { units: 'F' } } // RSP { transId: 14, cmdId: 1, status: 405, data: null }
- Write a Resource
// REQ { transId: 15, cmdId: 1, oid: 3303, iid: 0, rid: 5700, data: 22 } // RSP { transId: 15, cmdId: 1, status: 405, data: '_unwritable_' }
- Write an Object
-
Command Id:
2
or'discover'
-
REQ (s2c):
{ transId, cmdId, oid[, iid[, rid]] }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
205
(Content),400
(BadRequest), and404
(NotFound)
- Possible status:
-
Note: Discovering an Object will return you a list of Resource Ids within
data.resrcList
-
Examples
- Discover an Object
// REQ { transId: 16, cmdId: 2, oid: 3303 } // RSP { transId: 16, cmdId: 2, status: 205, data: { pmin: 1, pmax: 60, cancel: true, resrcList: { '0': [ 5700, 5701, 5601, 5602, 5603, 5604 ], '1': [ 5700 ], '2': [ 5700 ] } } }
- Discover an Object Instance
// REQ { transId: 17, cmdId: 2, oid: 3303, iid: 0 } // RSP { transId: 17, cmdId: 2, status: 205, data: { pmin: 1, pmax: 60, cancel: true } }
- Discover a Resource
// REQ { transId: 18, cmdId: 2, oid: 3303, iid: 0, rid: 5700 } // RSP { transId: 18, cmdId: 2, status: 205, data: { pmin: 5, pmax: 10, stp: 3, cancel: true } }
- Discover an Object
-
Command Id:
3
or'writeAttrs'
-
REQ (s2c):
{ transId, cmdId, oid[, iid[, rid]], data }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
204
(Changed),400
(BadRequest),404
(NotFound), and405
(MethodNotAllowed)
- Possible status:
-
Note:
data
is the attributes to be written. LWMQN doesn't support the observation of an Object, thus writting attributes to an Object is in vain, the Client will still return you the current settings. -
Examples
- Write attributes to an Object
// REQ { transId: 19, cmdId: 3, oid: 3303, data: { pmin: 50, pmax: 600 } } // RSP { transId: 19, cmdId: 3, status: 204, data: { pmin: 1, pmax: 60, cancel: true } // not changed }
- Write attributes to an Object Instance
// REQ { transId: 20, cmdId: 3, oid: 3303, iid: 0, data: { pmin: 50, pmax: 600 } } // RSP { transId: 20, cmdId: 3, status: 204, data: { pmin: 50, pmax: 600, cancel: true } }
- Write attributes to a Resource
// REQ { transId: 21, cmdId: 3, oid: 3303, iid: 0, rid: 5700 data: { pmin: 50, pmax: 600, stp: 10 } } // RSP { transId: 21, cmdId: 3, status: 204, data: { pmin: 50, pmax: 600, stp: 10, cancel: true } }
- Write attributes to an Object
-
Command Id:
4
or'execute'
-
REQ (s2c):
{ transId, cmdId, oid[, iid[, rid]], data }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
204
(Changed),400
(BadRequest),404
(NotFound),405
(MethodNotAllowed),500
(InternalServerError)
- Possible status:
-
Note:
data
, which should be an array, is the arguments apply to the executable Resource. This command only valid for Resources. -
Examples
- Execute upon an Object
// REQ { transId: 22, cmdId: 4, oid: 3303, data: [ 'simen' ] } // RSP { transId: 22, cmdId: 4, status: 405, data: null }
- Execute upon an Object Instance
// REQ { transId: 23, cmdId: 4, oid: 3303, iid: 0, data: [ 'simen' ] } // RSP { transId: 23, cmdId: 4, status: 405, data: null }
- Execute upon an executable Resource
// REQ { transId: 24, cmdId: 4, oid: 3303, iid: 0, rid: 'foo' data: [ 'simen' ] } // RSP { transId: 24, cmdId: 4, status: 204, data: 'hello simen: you are executed. XD' }
- Execute upon an Object
- Not supported
- Not supported
-
Command Id:
5
or'observe'
-
REQ (s2c):
{ transId, cmdId, oid, iid, rid, data }
-
RSP (c2s):
{ transId, cmdId, status, data }
- Possible status:
205
(Content),400
(BadRequest),404
(NotFound), and405
(MethodNotAllowed)
- Possible status:
-
Note:
data
, aceepts an{ option: 1 | 0 }
to control the observation. Setdata.option
to1
will cancel the reporting. Observation upon an Object is not supported -
Examples
- Observe an Object
// REQ { transId: 25, cmdId: 5, oid: 3303, data: { option: 0 } } // RSP { transId: 25, cmdId: 5, status: 405 }
- Observe an Object Instance
// REQ { transId: 26, cmdId: 5, oid: 3303, iid: 0, data: { option: 0 } } // RSP { transId: 26, cmdId: 5, status: 205 }
- Observe a Resource
// REQ { transId: 24, cmdId: 4, oid: 3303, iid: 0, rid: 5700 data: { option: 0 } } // RSP { transId: 26, cmdId: 5, status: 205 }
- Observe an Object
-
Command Id:
7
or'ping'
-
REQ (s2c):
{ transId, cmdId }
-
RSP (c2s):
{ transId, cmdId, status }
- Possible status:
200
(Changed),408
(Timeout)
- Possible status:
- Note: none
-
Examples
- Ping the Client
// REQ { transId: 27, cmdId: 7 } // RSP { transId: 27, cmdId: 7, status: 200 }
- Ping the Client
Overview
- APIs
- Events
- 'ready'
- 'error'
- 'permitJoinin'g
-
'ind'
- devIncoming, devLeaving, devUpdate, devNotify, devChange, devStatus
- 'message'
- APIs
Advanced Topics
Appendix