EIS RESTfulAPI ESL Solution
RESTful API Path Rule for WSNManage
This document is about EIS RESTful API service of Wireless Sensor Manage (WSNManage). There are two major classes in WSNManage service one is "Connectiviy" another is "SenHub". Connectivity is wireless interfaces information in the EIS IoT Gateway solution. "SenHub" is short of sensor hub.
Connectivity
GET
Path: restapi/esl_mgr/Connectivity
-> All Capability ( without data )
{ "IoTGW": { "Zigbee": { "0000852CF4B7B0E8": { "Info": { "e": [ {"n": "DeviceList","sv": "","asm": "r"}, {"n": "premit-tag-list","sv": "","asm": "rw"}, {"n": "pan-id","v": 1,"asm": "r"}, {"n": "zd-fw-version","v": 1,"asm": "r"}, {"n": "reboot","bv": 0,"asm": "rw"} ], "bn": "Info" }, "bn": "0000852CF4B7B0E8", "ver": 1 }, "bn": "Zigbee" }, "HostGateway": "", "ver": 1, "bn": "IoTGW" } }
Path: rstapi/ESL/Connectivity/IoTGW/Zigbee/0000852CF4B7B0E8/Info
Reply: with latest data value
{ "e": [ {"n": "DeviceList","sv": "0000852CF4BE33BC"}, {"n": "pan-id","v": 6}, {"n": "premit-tag-list","sv": "0000852CF4BE36558"}, {"n": "zd-fw-version","v": 1}, {"n": "reboot","bv": 0} ], "bn": "Info" }
Put
Path: restapi/esl_mgr/Connectivity/IoTGW/Zigbee/0000852CF4B7B0E8/Info/reset
Data:
{"bv":1}
Reply:
Status Code: 200
Data:
{"bv":1}
Device
Get
1.Path: restapi/esl_mgr/Device/AllDeviceList
Reply:
{"n":"AllDeviceList","sv":"xxxxxx,0017000E40000001,xxxxx"}
2. Path: restapi/esl_mgr/Device/<DeviceID>/DevInfo
Reply by Router:
{ "devID":"0022000E40000022", "hostname":"AAA", "sn":"0017000E40000001", "mac":"0017000E40000001", "version":"3.1.23", "type":"IoTGW", "product":"WISE-20xx", "manufacture":"", "status":"1", "commCmd":1, "requestID":30002, "agentID":"0022000E40000022", "handlerName":"general", "sendTS":160081026 }
Reply by Tag ( SenHub )
{ "devID":"0033000E40000033", "hostname":"AAA", "sn":"0017000E40000001", "mac":"0017000E40000001", "version":"3.1.23", "type":"SenHub", "product":"WISE-10xx", "manufacture":"", "status":"1", "commCmd":1, "requestID":30002, "agentID":"0033000E40000033", "handlerName":"general", "sendTS":160081026 }
3. Path: restapi/esl_mgr/Device/<DeviceID>
Reply: Capability ( without data ) with Router
{ "IoTGW": { "Zigbee": { "0022000E40000022": { "Info": { "e": [ {"n": "DeviceList","sv": "","asm": "r"}, {"n": "tx-level","v": 10,"asm": "rw","min":1,"max":20 }, {"n": "zd-fw-version","v":1, "asm": "r"}, {"n": "reboot","bv": 0,"asm": "rw"} ], "bn": "Info" }, "bn": "0022000E40000022", "ver": 1 }, "bn": "Zigbee" }, "HostGateway": "0000852CF4B7B0E8", "ver": 1, "bn": "IoTGW" } }
Reply: Capability ( without data ) with Tag
{ "SenHub": { "SenData": { "e":[ {"n":"image-crc","sv":"","asm":"r"}], "bn":"SenData" }, "Info": { "e":[{"n":"update-period","v":60,"asm":"rw","min":30, "max":3600}, {"n":"timeout","v":30,"asm":"rw","min":1, "max":60}, {"n":"battery","v":70,"asm":"r","min":0, "max":100, "u":"%"}], "bn":"Info" }, "Net": { "e":[{"n":"tx-level","v":1,"asm":"rw"}, {"n":"rssi","v":36,"asm":"r"}, {"n":"fw-version","v":1,"asm":"r"}], "bn":"Net" }, "Action": { "e":[{"n":"image-update","sv":"","asm":"w", "encode":"base64","type":"octe-stream"}, {"n":"refresh-image","bv":0,"asm":"rw"}, {"n":"reboot","bv":0,"asm":"rw"}, {"n":"reset-to-default","bv":0,"asm":"rw"}, "bn":"Action" } "bn":"SenHub" } }
4. Path: restapi/esl_mgr/Device/<DeviceID>/SenHub
Reply: with latest data value
{ "SenHub": { "SenData": { "e":[ {"n":"image-crc","sv":"0xC6EB8EA8"}], "bn":"SenData" }, "Info": { "e":[{"n":"update-period","v":60,"asm":"rw"}, {"n":"timeout","v":30}, {"n":"battry":76}], "bn":"Info" }, "Net": { "e":[{"n":"zd-tx-power","v":1}, {"n":"rssi","v":36}, {"n":"channel","v":11}, {"n":"fw-version","v":1}], "bn":"Net" }, "Action": { "e":[{"n":"image-update","sv":""}, {"n":"refresh-image","bv":0},{"n":"reboot","bv":0}, {"n":"reset-to-default","bv":0}, {"n":"fw-update","sv":""}], "bn":"Action" } "bn":"SenHub" } }
5. Path:restapi/esl_mgr/Device/<DeviceID>/SenHub/SenData
Reply: with latest data
{ "SenData": { "e":[ {"n":"image-crc","sv":"0xC6EB8EA8"}], "bn":"SenData" }
6. restapi/esl_mgr/Device/<DeviceID>/SenHub/SenData/'image-crc
Reply: with latest data
{"v":0xC6EB8EA8}
Put
EIS RESTful only supports change one resource in each request.
Ex: To chagne SenHub's Name by 'PUT' RESTful method
Path: restapi/WSNManage/SenHub/<DeviceID>/SenHub/SenData/GPI01
Data:
{"bv":1}
Reply:
HTTP Code: 200 OK
Data:
{"bv":1}
WebSocket Service
WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C.
WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket Protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request.[1] The WebSocket protocol makes more interaction between a browser and a web server possible, facilitating the real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the browser without being solicited by the client, and allowing for messages to be passed back and forth while keeping the connection open. In this way, a two-way (bi-directional) ongoing conversation can take place between a browser and the server. The communications are done over TCP port number 80, which is of benefit for those environments which block non-web Internet connections using a firewall. Similar two-way browser-server communications have been achieved in non-standardized ways using stopgap technologies such as Comet.
API-Manage Websocket JSON Data Format
{"n":"<GroupName>","event":"event Type","data":{JSON Obj}}
Websocket of WSNManage
Endpoint: ws://ServerIP:Port/WSNManage
Client request Server by this Endpoint to require "WSNManage" service. Server will auto push WSNManage event to client.
Please refer to "WSNManage evnent message" for WSNManage's event and data format.
WSNManage evnent message
events:[ {"event":"eConnectivity_Capability"}, // => Update Connectivity Capability ( Without data ) {"event":"eConnectivity_UpdateData"}, // => Update Connectivity's Data {"event":"eDevice_Connected"}, // => A new SenHub connected {"event":"eDevice_Disconnect"}, // => A SenHub is disconnected {"event":"eDevice_Capability"}, // => Update a SenHub's Capability ( Without Data ) {"event":"eDevice_UpdateData"}] // => Update SenHub's Data
Updtae Connectivity's Capability
event: eConnectivity_Capability
data:
{ "IoTGW": { "Zigbee": { "0000852CF4B7B0E8": { "Info": { "e": [ {"n": "DeviceList","sv": ",","asm": "r"}, {"n": "premit-tag-list","sv": "","asm": "rw"}, {"n": "pan-id","v": 1,"asm": "r"}, {"n": "zd-fw-version","v": 1,"asm": "r"}, {"n": "all-tag-image-update","sv": "","asm": "w","type":"octe-stream","encode":"base64"}, {"n": "reboot","bv": 0,"asm": "rw"} ], "bn": "Info" }, "bn": "0000852CF4B7B0E8", "ver": 1 }, "bn": "Zigbee" }, "HostGateway": "", "ver": 1, "bn": "IoTGW" } }
Updtae data value of connectivity
event Type: eConnectivity_UpdateData
data: Update DeviceList
{ "IoTGW": { "Zigbee": { "0000852CF4B7B0E8": { "Info": { "e": [{"n": "DeviceList","sv": "0000852CF4B7BABB"}], "bn": "Info" }, "bn": "0000852CF4B7B0E8", "ver": 1 }, "bn": "Zigbee" }, "bn": "IoTGW" } }
A new Device connected
event Type: eDevice_Connected
data:
{ "susiCommData": { "devID":"0017000E40000001", "hostname":"AAA", "sn":"0017000E40000001", "mac":"0017000E40000001", "version":"3.1.23", "type":"SenHub", "product":"WISE-101x", "manufacture":"", "status":"1", "commCmd":1, "requestID":30002, "agentID":"0017000E40000001", "handlerName":"general", "sendTS":160081026 } }
A Device disconnected
event Type: eDevice_Disconnect
data:
{ "susiCommData": { "devID":"0017000E40000001", "hostname":"AAA", "sn":"0017000E40000001", "mac":"0017000E40000001", "version":"3.1.23", "type":"SenHub", "product":"WISE-101x", "manufacture":"", "status":"0", "commCmd":1, "requestID":30002, "agentID":"0017000E40000001", "handlerName":"general", "sendTS":160081026 } }
Update capbaility of a Tag
event Type: eDevice_Capability
data: Reply: Capability ( without data ) by Tag
{ "SenHub": { "SenData": { "e":[ {"n":"image-crc","sv":"","asm":"r"}], "bn":"SenData" }, "Info": { "e":[{"n":"update-period","v":60,"asm":"rw","min":30, "max":3600}, {"n":"timeout","v":30,"asm":"rw","min":1, "max":60], "bn":"Info" }, "Net": { "e":[{"n":"tx-level","v":1,"asm":"rw"}, {"n":"rssi","v":36,"asm":"r"}, {"n":"channel","v":11,"asm":"r", "min":11, "max":36}, {"n":"fw-version","v":1,"asm":"r"}], "bn":"Net" }, "Action": { "e":[{"n":"image-update","sv":"","asm":"w", "encode":"base64","type":"octe-stream"}, {"n":"refresh-image","bv":0,"asm":"rw"}, {"n":"reboot","bv":0,"asm":"rw"}, {"n":"reset-to-default","bv":0,"asm":"rw"}, {"n":"fw-update","sv":"","asm":"w", "encode":"base64","type":"octe-stream"}], "bn":"Action" } "bn":"SenHub" } }
Update data value of a Tag
event Type: eDevice_UpdateData
data: Reply: Capability ( without data ) by Tag
{ "SenHub": { "SenData": { "e":[ {"n":"image-crc","sv":"0xC6EB8EA8"}], "bn":"SenData" } "bn":"SenHub" } }