Difference between revisions of "IoTGateway/CoAP-like"
From ESS-WIKI
(→IPSO for CoAP-like) |
(→Advantech CoAP-like Packet Structure) |
||
| (34 intermediate revisions by one other user not shown) | |||
| Line 3: | Line 3: | ||
'''<big><big>CoAP-like Packet Format</big></big>'''<br /> | '''<big><big>CoAP-like Packet Format</big></big>'''<br /> | ||
| − | [[File:CoAP-like-PacketFormat.jpg|600x100px]] | + | [[File:CoAP-like-PacketFormat.jpg|600x100px]]<br /> |
| + | |||
| + | '''<big>Header Size: 8 Bytes</big>'''<br /> | ||
| + | '''<big>Payload Size: 0 ~ 70 (Max) Bytes</big>''' <br /><br /> | ||
| + | |||
'''<big><big>CoAP-like Header</big></big>'''<br /> | '''<big><big>CoAP-like Header</big></big>'''<br /> | ||
| Line 45: | Line 49: | ||
*'''Method Not Allowed(4.05): 133''' | *'''Method Not Allowed(4.05): 133''' | ||
*'''Not Implemented(5.01): 161''' | *'''Not Implemented(5.01): 161''' | ||
| + | <br /> | ||
| − | ==IPSO Smart Object ID | + | =IPSO for CoAP-like= |
| + | '''<big>IPSO RESTful API Rule:</big>''' '''<big>/{Object ID}/{Object Instance}/{Resource ID}/</big>''' | ||
| + | |||
| + | |||
| + | |||
| + | '''<big>IPSO Smart Object ID</big>''' | ||
| − | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 73: | Line 82: | ||
| Ultrasonic || 9200 | | Ultrasonic || 9200 | ||
|} | |} | ||
| + | |||
| + | |||
| + | '''<big>IPSO Smart Resource ID</big>''' | ||
| + | |||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! Resource !! Object ID | ||
| + | |- | ||
| + | | DI Status|| 5500 | ||
| + | |- | ||
| + | | DO Status|| 5550 | ||
| + | |- | ||
| + | | Min Range Value|| 5603 | ||
| + | |- | ||
| + | | Max Range Value|| 5604 | ||
| + | |- | ||
| + | | Sensor Value || 5700 | ||
| + | |- | ||
| + | | Sensor Units || 5701 | ||
| + | |- | ||
| + | | X Value || 5702 | ||
| + | |- | ||
| + | | Y Value || 5703 | ||
| + | |- | ||
| + | | Z Value || 5704 | ||
| + | |- | ||
| + | | Compass Direction || 5705 | ||
| + | |} | ||
| + | <br /> | ||
| + | <br /> | ||
| + | |||
| + | =CoAP-like Command= | ||
| + | |||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! URI Resources!! Description | ||
| + | |- | ||
| + | | /dev/info|| Information of Sensor Hub | ||
| + | |- | ||
| + | | /net/info|| Information of Net Communication | ||
| + | |- | ||
| + | | /net/status|| Status of Network | ||
| + | |- | ||
| + | | /sen/info || Information of Sensor | ||
| + | |- | ||
| + | | /sen/status || Status of Sensors | ||
| + | |} | ||
| + | |||
| + | |||
| + | |||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! Commands (Key) !! Value !! Description !! For URI Resources !! Example | ||
| + | |- | ||
| + | | action || list || List detail information || /sen/info, /dev/info, /net/info || GET '''/sen/info?action=list''' | ||
| + | |- | ||
| + | | action || observe || Observe status || /sen/status, /net/status || GET '''/sen/status?action=observe&id=all''' | ||
| + | |- | ||
| + | | action || cancel || Cancel observe || /sen/status, /net/status || GET '''/sen/status?action=cancel&id=all''' | ||
| + | |- | ||
| + | | field || id || List all sensor id || /sen/info || GET '''/sen/info?action=list&field=id''' | ||
| + | |- | ||
| + | | field || health || Network health status || /net/status || GET '''/net/status?field=health''' | ||
| + | |- | ||
| + | | id || all || Get all sensor’s data || /sen/info, /sen/status || GET '''/sen/status?action=observe&id=all''' | ||
| + | |- | ||
| + | | id || 0,1,2,3... || Get one of sensor data || /sen/info, /sen/status || GET '''/sen/status?action=observe&id=0,1''' | ||
| + | |} | ||
| + | <br /><br /> | ||
| + | |||
| + | =CoAP-like Protocols= | ||
| + | ==Get SenHub Info== | ||
| + | ===Get SenHub Device info=== | ||
| + | '''Request''' | ||
| + | GET /dev/info?action=list | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /dev/info?action=list | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub-> GW | ||
| + | TP : Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </dev>;n="Room1", mdl="WISE1020", sw="1.0.01", reset=0 | ||
| + | |||
| + | ===Get SenHub Net info=== | ||
| + | '''Request''' | ||
| + | GET /net/info?action=list | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /net/info?action=list | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP : Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </net>;n="dust", sw="1.0.01" | ||
| + | |||
| + | ==Get Sensor Info== | ||
| + | ===Get Sensor id List=== | ||
| + | '''Request''' | ||
| + | GET /sen/info?action=list&field=id | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/info?action=list&field=id | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP : Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </sen>;0,1,2,3,4,5 | ||
| + | |||
| + | ===Get Detail Info of Sensor=== | ||
| + | '''Request''' | ||
| + | GET /sen/info?action=list&id=0 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/info?action=list&id=0 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </0>;n="Room_Tempature", mdl="mp6050", sid="3303" | ||
| + | |||
| + | ===Get Sensor Properties=== | ||
| + | '''Request''' | ||
| + | GET /sen/info?query=list&sid=3303 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/info?query=list&sid=3303 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </3303>;asm="r", rt="ucum.Cel", type="d", st="ipso", u="Cel" | ||
| + | |||
| + | ===Get Sensor Model=== | ||
| + | '''Request''' | ||
| + | GET /sen/info?query=list&id=0&mdl=mp6050 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/info?query=list&id=0 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: </0>;min="-20", max="100" | ||
| + | |||
| + | ==Get Sensor Value== | ||
| + | ===Observe all sensors' value=== | ||
| + | '''Request''' | ||
| + | GET /sen/status?action=observe&id=all | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/status?action=observe&id=all | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: 0 36.2,1 26.5,2 9000,3 100,4 0, 5 10 20 30 | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | 0 36,1 26.5,2 9100,3 380,4 1, 5 10 20 20 | ||
| + | |||
| + | ===Cancel all sensors' value=== | ||
| + | '''Request''' | ||
| + | GET /sen/status?action=cancel&id=all | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/status?action=cancel&id=all | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub-> GW | ||
| + | TP: Change | ||
| + | Type:2 | ||
| + | Code:68 | ||
| + | PAYLOAD: cancel /sen/status?id=all | ||
| + | |||
| + | ===Observe sensors' value=== | ||
| + | '''Request''' | ||
| + | GET /sen/status?action=observe&id=0,1 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/status?action=observe&id=0,1 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Content | ||
| + | Type:2 | ||
| + | Code:69 | ||
| + | PAYLOAD: 0 36.2, 1 9000 | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | 0 35, 1 9236 | ||
| + | |||
| + | ===Cancel sensors' value=== | ||
| + | '''Request''' | ||
| + | GET /sen/status?action=cancel&id=0,1 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: GET | ||
| + | Type:0 | ||
| + | Code:1 | ||
| + | PAYLOAD: /sen/status?action=cancel&id=0,1 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP: Change | ||
| + | Type:2 | ||
| + | Code:68 | ||
| + | PAYLOAD: cancel /sen/status?id=0,1 | ||
| + | |||
| + | ==Set SenHub Value== | ||
| + | ===Set Device Name=== | ||
| + | ''Request''' | ||
| + | PUT /dev/info?n="Demo 1" | ||
| + | Direction: GW -> SenHub | ||
| + | TP: PUT | ||
| + | Type:0 | ||
| + | Code:3 | ||
| + | PAYLOAD: /dev/info?n="Demo 1" | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP:Change | ||
| + | Type:2 | ||
| + | Code:68 | ||
| + | PAYLOAD: n="Demo1" | ||
| + | |||
| + | ===Reset SenHub=== | ||
| + | '''Request''' | ||
| + | PUT /dev/info?reset=1 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: PUT | ||
| + | Type:0 | ||
| + | Code:3 | ||
| + | PAYLOAD: /dev/info?reset=1 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP:Change | ||
| + | Type:2 | ||
| + | Code:68 | ||
| + | PAYLOAD: reset=1 | ||
| + | |||
| + | ==Set Sensor Value== | ||
| + | ===Set Sensor value by id=== | ||
| + | '''Request''' | ||
| + | PUT /sen/status?id=5&bv=1 | ||
| + | Direction: GW -> SenHub | ||
| + | TP: PUT | ||
| + | Type:0 | ||
| + | Code:3 | ||
| + | PAYLOAD: /sen/status?id=5&bv=1 | ||
| + | |||
| + | '''Response''' | ||
| + | Direction: SenHub -> GW | ||
| + | TP:Change | ||
| + | Type:2 | ||
| + | Code:68 | ||
| + | PAYLOAD: id=5, bv=1 | ||
Latest revision as of 05:06, 11 March 2016
Contents
Advantech CoAP-like Packet Structure
Header Size: 8 Bytes
Payload Size: 0 ~ 70 (Max) Bytes
| Name | Size ( bits ) |
|---|---|
| Ver | 2 |
| Type (T) | 2 |
| TKL: Token Length | 4 |
| Code | 8 |
| Message ID | 16 |
| Length | 32 |
Type (T) : 2-bit unsigned integer Transaction Type field. Indicates if this message is
- Confirmable (0): Some messages require an acknowledgment
- Non-Confirmable (1): Some other messages do not require an acknowledgment
- Acknowledgment (2): An Acknowledgment message acknowledges that a specific Confirmable message (identified by its Transaction ID) arrived
- Reset (3): A Reset message indicates that a specific Confirmable message was received, but some context is missing to properly process it. This condition is usually caused when
- the receiving node has rebooted and has forgotten some state that would be required to interpret the message
Code : : 8-bit unsigned integer
Request
- GET(0.01): 1
- PUT(0.03): 3
Response
- Change(2.04): 68
- Content(2.05): 69
- Bad Request(4.00): 128
- Unauthorized(4.01): 129
- Not Found(4.04): 132
- Method Not Allowed(4.05): 133
- Not Implemented(5.01): 161
IPSO for CoAP-like
IPSO RESTful API Rule: /{Object ID}/{Object Instance}/{Resource ID}/
IPSO Smart Object ID
| Sensor | Object ID |
|---|---|
| Temperature | 3303 |
| Humidity | 3304 |
| Magnetic | 3314 |
| Accelerometer | 3313 |
| Light Sensor | 3301 |
| Digital Output | 3201 |
| Digital Input | 3200 |
| CO2 | 9001 |
| CO | 9002 |
| Ultrasonic | 9200 |
IPSO Smart Resource ID
| Resource | Object ID |
|---|---|
| DI Status | 5500 |
| DO Status | 5550 |
| Min Range Value | 5603 |
| Max Range Value | 5604 |
| Sensor Value | 5700 |
| Sensor Units | 5701 |
| X Value | 5702 |
| Y Value | 5703 |
| Z Value | 5704 |
| Compass Direction | 5705 |
CoAP-like Command
| URI Resources | Description |
|---|---|
| /dev/info | Information of Sensor Hub |
| /net/info | Information of Net Communication |
| /net/status | Status of Network |
| /sen/info | Information of Sensor |
| /sen/status | Status of Sensors |
| Commands (Key) | Value | Description | For URI Resources | Example |
|---|---|---|---|---|
| action | list | List detail information | /sen/info, /dev/info, /net/info | GET /sen/info?action=list |
| action | observe | Observe status | /sen/status, /net/status | GET /sen/status?action=observe&id=all |
| action | cancel | Cancel observe | /sen/status, /net/status | GET /sen/status?action=cancel&id=all |
| field | id | List all sensor id | /sen/info | GET /sen/info?action=list&field=id |
| field | health | Network health status | /net/status | GET /net/status?field=health |
| id | all | Get all sensor’s data | /sen/info, /sen/status | GET /sen/status?action=observe&id=all |
| id | 0,1,2,3... | Get one of sensor data | /sen/info, /sen/status | GET /sen/status?action=observe&id=0,1 |
CoAP-like Protocols
Get SenHub Info
Get SenHub Device info
Request GET /dev/info?action=list Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /dev/info?action=list
Response Direction: SenHub-> GW TP : Content Type:2 Code:69 PAYLOAD: </dev>;n="Room1", mdl="WISE1020", sw="1.0.01", reset=0
Get SenHub Net info
Request GET /net/info?action=list Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /net/info?action=list
Response Direction: SenHub -> GW TP : Content Type:2 Code:69 PAYLOAD: </net>;n="dust", sw="1.0.01"
Get Sensor Info
Get Sensor id List
Request GET /sen/info?action=list&field=id Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/info?action=list&field=id
Response Direction: SenHub -> GW TP : Content Type:2 Code:69 PAYLOAD: </sen>;0,1,2,3,4,5
Get Detail Info of Sensor
Request GET /sen/info?action=list&id=0 Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/info?action=list&id=0
Response Direction: SenHub -> GW TP: Content Type:2 Code:69 PAYLOAD: </0>;n="Room_Tempature", mdl="mp6050", sid="3303"
Get Sensor Properties
Request GET /sen/info?query=list&sid=3303 Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/info?query=list&sid=3303
Response Direction: SenHub -> GW TP: Content Type:2 Code:69 PAYLOAD: </3303>;asm="r", rt="ucum.Cel", type="d", st="ipso", u="Cel"
Get Sensor Model
Request GET /sen/info?query=list&id=0&mdl=mp6050 Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/info?query=list&id=0
Response Direction: SenHub -> GW TP: Content Type:2 Code:69 PAYLOAD: </0>;min="-20", max="100"
Get Sensor Value
Observe all sensors' value
Request GET /sen/status?action=observe&id=all Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/status?action=observe&id=all
Response
Direction: SenHub -> GW
TP: Content
Type:2
Code:69
PAYLOAD: 0 36.2,1 26.5,2 9000,3 100,4 0, 5 10 20 30
.
.
.
0 36,1 26.5,2 9100,3 380,4 1, 5 10 20 20
Cancel all sensors' value
Request GET /sen/status?action=cancel&id=all Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/status?action=cancel&id=all
Response Direction: SenHub-> GW TP: Change Type:2 Code:68 PAYLOAD: cancel /sen/status?id=all
Observe sensors' value
Request GET /sen/status?action=observe&id=0,1 Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/status?action=observe&id=0,1
Response
Direction: SenHub -> GW
TP: Content
Type:2
Code:69
PAYLOAD: 0 36.2, 1 9000
.
.
.
0 35, 1 9236
Cancel sensors' value
Request GET /sen/status?action=cancel&id=0,1 Direction: GW -> SenHub TP: GET Type:0 Code:1 PAYLOAD: /sen/status?action=cancel&id=0,1
Response Direction: SenHub -> GW TP: Change Type:2 Code:68 PAYLOAD: cancel /sen/status?id=0,1
Set SenHub Value
Set Device Name
Request' PUT /dev/info?n="Demo 1" Direction: GW -> SenHub TP: PUT Type:0 Code:3 PAYLOAD: /dev/info?n="Demo 1" Response Direction: SenHub -> GW TP:Change Type:2 Code:68 PAYLOAD: n="Demo1"
Reset SenHub
Request PUT /dev/info?reset=1 Direction: GW -> SenHub TP: PUT Type:0 Code:3 PAYLOAD: /dev/info?reset=1
Response Direction: SenHub -> GW TP:Change Type:2 Code:68 PAYLOAD: reset=1
Set Sensor Value
Set Sensor value by id
Request PUT /sen/status?id=5&bv=1 Direction: GW -> SenHub TP: PUT Type:0 Code:3 PAYLOAD: /sen/status?id=5&bv=1
Response Direction: SenHub -> GW TP:Change Type:2 Code:68 PAYLOAD: id=5, bv=1