Difference between revisions of "EI-Agent Handshake Protocol"
(Add EI-Agent Command Format) |
m (Scott68.chang moved page EI-Agent Command Format to EI-Agent Handshake Protocol: Not Just Command Format) |
(No difference)
|
Revision as of 01:45, 17 May 2017
Contents
Message Topics
- MQTT Topic Define
- From Server to Agent:
/wisepaas/<tenantId>/<product>/<agentId>/<function>ack - From Agent to Server:
/wisepaas/<tenantId>/<product>/<agentId>/<function>req
- From Server to Agent:
- Preserved Topic for Common use, the product name "device" is preserved for common use.
- Agent Registration Topic: /wisepaas/<tenantId>/device/<agentId>/agentinfoack
- Will Message Topic: /wisepaas/<tenantId>/device/<agentId>/willmessage Or /wisepaas/<tenantId>/device/<serverId>/willmessage
- Command Topic: /wisepaas/<tenantId>/device/<agentId>/agentactionreq
- Response Topic: /wisepaas/<tenantId>/device/<agentId>/agentactionack
- Report Data Topic: /wisepaas/<tenantId>/device/<agentId>/devinfoack
- Custom Topic Sample
- For example, the product name is "custom" and function name is "powerctrl", the topic for Power ON/OFF control will be:
- Server send command with topic: /wisepaas/<tenantId>/custom/<agentId>/powerctrlreq
- Agent send response with topic: /wisepaas/<tenantId>/custom/<agentId>/powerctrlack
- For example, the product name is "custom" and function name is "powerctrl", the topic for Power ON/OFF control will be:
Handshake Sequence
Normal sign in and sign out sequence:
Agent lost connection with will message sequence:
Server lost connection with will message sequence:
Data Format
Agent ID Format
Agent ID Format is based on UUID format, which is represented as 32 characters, displayed in six groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters. In this format the UUID could map to Agent ID directly.
- Format define
For example:
The UUID is:
123e4567-e89b-12d3-a456-426655440000
Mapping to the Agent ID is:
123e4567-e89b-12d3-a456-426655440000
- Generate Agent ID
If the target device has it own unique ID, but less the 32 characters, then we could follow the steps to generate the Unique Agent ID:
For example:
- Retrieve Unique ID as key, for example: MAC address or IMEI.
- The first 8 digits is predefined to identify the Unique ID source.
- 00000001: MAC
- 00000002: IMEU
- 00000004: Hardware System config, ex: "/sys/fsl_otp/HW_OCOTP_CFG0"
- 00000005: Custom generates serial number. The serial number may not be unique, so we add the product or brand name before the serial number to make sure the ID is unique.
- Add 'Zero'(0) to extended to 24 lowercase hexadecimal digits as UUID format.
Unique ID with MAC address:
MAC:000babbb7ef3Agent ID:00000001-0000-0000-0000-000babbb7ef3
Custom Serial number:
Serial number for Advantech ARK 1120 :KSA0451097Agent ID:00000005-0000-0000-000a-rkksa0451097
Basic JSON Format
- JSON (JavaScript Object Notation) is a lightweight data-interchange format.
- JSON is built on two structures:
- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
- JSON Forms:
- Object: { string : value}
- Array: [ value ]
- Value: string
number
object
array
true
false
null
- WISE-PaaS predefined string:
- agentID: target device ID, value type is string.
- handlerName: target device supported function block (Plugin or Handler) name, value type is string.
- commCmd: the sub command ID in function block (Plugin or Handler), value type is unsigned integer.
- content: the contain data.
- opTS: message generated time stamp (optional), the unit is millisecond.
- format: "opTS":{"$date":1494308768000}
- Device Registration Format:
{
"agentID":"00000001-0000-0000-0000-000babbb7ef3",
"handlerName":"general", //defined for device registration
"commCmd":1, //defined for device registration
"content": {
"parentID":"", //the parent device ID if the target device has parent device.
"hostname":"PC001104", //target device name
"sn":"14DAE996BE04", //target device serial number
"mac":"14DAE996BE04", //target device mac address
"version":"1.0.0.0", //client application version
"type":"IPC", //target device type
"tag":"RMM,Custom", //target device tag for supported software product name.
"product":"", //target device hardware product name
"manufacture":"", //target device hardware manufacture
"account":"anonymous", //bind target device to a specific account
"password":"", //encrypt with DES and Base64
"status":1 //1: registration, 0: un-registration
}
}
- Report Data Format:
{
"agentID":"00000001-0000-0000-0000-000babbb7ef3",
"handlerName":"custom",
"commCmd":123,
"content":{
"opTS":{"$date":1494308768000},
"custom_object":{ //User defined report data object.
"custom_data1":"string_value",
"custom_data2":123,
"custom_data3":false
}
}
}
IPSO Format (Application Framework)
The IPSO Application Framework makes use of IETF standards as building blocks for a simple and efficient RESTful design model for IP smart objects. The framework may be used over either HTTP or CoAP web transfer protocols. HTTP, REST, XML, JSON, COAP and other key components of web technology are powerful mechanisms in an Internet of Things application.
Note: The objective of the Alliance is not to define technologies, but to document the use of IP-based technologies defined at the standard organizations such as IETF with focus on support by the Alliance of various use cases. Function Sets: The framework is organized into groups of resource types called Function Sets. A Function Set has a recommended root path, under which its sub-resources are organized. Each Function Set is assigned a Resource Type parameter, therefore making it possible to discover it.
Function Set
Root Path
Resource Type
General Purpose IO
/gpio
gpio
Power
/pwr
pwr
Load Control
/load
load
Sensors
/sen
sen
Light Control
/lt
lt
Message
/msg
msg
Location
/loc
loc
Configuration
/cfg
cfg
- IPSO Smart Object
IPSO Smart Object [2] Guidelines provide a common design pattern, an object model, which can effectively use the IETF CoAP protocol to provide high level interoperability between Smart Object devices and connected software applications on other devices and services
The common object model is based on the Lightweight M2M (LWM2M 1.0) specification from the Open Mobile Alliance. OMA LWM2M is a device management and service architecture specification based on IETF CoAP, and provides a simple and flexible object template (object model) for constrained device management.
The object model from OMA LWM2M is reused to define application level IPSO Smart Objects. This enables the OMA Name Authority (OMNA) to be used to register new objects, and enables existing LWM2M compliant device libraries and server software to be used as an infrastructure for IPSO Smart Objects
- Media Types for Sensor Markup Language (SENML)
- Semantics
SenML
JSON
Type
Description
Base Name
bn
String
This is a string that is prepended to the names found in the entries
Base Time
bt
Integer
A base time that is added to the time found in an entry
Base Units
bu
String
A base unit that is assumed for all entries, unless otherwise indicated
Version
ver
Number
Version number of media type format
Measurement or Parameters
e
Array
Array of values for sensor measurements or other generic parameters
Name
n
String
Name of the sensor or parameter
Units
u
String
Units for a measurement value
Value
v
Float
Value of the entry
String Value
sv
String
Boolean Value
bv
Boolean
Value Sum
s
Float
Integrated sum of the values over time
Time
t
Integer
Time when value was recorded
Update Time
ut
Integer
Update time. A time in seconds that represents the maximum time before this sensor will provide an updated reading for a measurement.
- The Data Type of Sensor Data Type
Data Type (type)
SenML Field
b (boolean)
bv
s (string)
s
e (enum)
e
i (integer)
v
d (decimal)
v
h(hexadecimal)
s
o(octet-stream)
s
- Advantech Sensor Semantics
SenML
JSON
Type
Description
Min Range Value
min
Float
The minimum value that can be measured by the sensor
Max Range Value
max
Float
The maximum value that can be measured by the sensor
Access Mode
asm
String
The access mode of the resource. Ex: read (r), write (w), read/write (rw)
Standard Format
st
String
The sensor format is which standard format
Health Status
Health
Integer
The health status of network or device. Range: -1 ~ 100
Good: > 80, Average: 60 ~ 80, Below Average: 40~60, Bad:0~40, -1: Off line or Fault
- IPSO Report Data Format:
{
"agentID":"00000001-0000-0000-0000-000babbb7ef3",
"handlerName":"custom",
"commCmd":123,
"content":{
"opTS":{"$date":1494308768000},
"custom_object":{ //User defined report data object in IPSO format.
"bn":"custom_object",
"e":[
{"n":"custom_data1","sv":"string_value"},
{"n":"custom_data2","v":123},
{"n":"custom_data3","bv":false}
]
}
}
}