There are different types of messages:
- Ping / Pong
- Write upstream
- Write downstream
- Read upstream
- Read downstream
x | x - x+8 | x+8 - x+8+16 |
---|---|---|
Data | device_id | initialization_vector |
0 - 3 | 4 - 7 | 8-23 | 24 - * |
---|---|---|---|
Version | Action | Payload len | Content |
0-9 | 10 | 11-18 |
---|---|---|
name | type | value |
When a device sends a message to the server, the server responds in the
following way:
- Version: X
- Action: PING
- Content: []
- Version: X
- Action: WRITE_UP
- Content: [
name, type, value
]
- Version: X
- Action: READ_UP
- Content: [XXX]
- Version: X
- Action: PONG
- Content: []
- Version: X
- Action: WRITE_DOWN
- Content: [XXX]
- Version: X
- Action: READ_DOWN
- Content: [XXX]
/api/hexified(md5sum(hexified(device_id)))/
device_id
- The device id represented as RAW bytes.hexified
- A string-friendly hex representation where each byte is represented in hex.md5sum
- The md5sum of the input.
The payload of a packet is constructed as follows:
- The version, action and payload length is added to the first x bytes.
- The data content is appended
- Pad bytes are appended, since AES requires input to be in block size of X (16 for AES128).
- The device Id is appended (as raw bytes)
- Payload is encrypted with AES128
- The iv used for encryption is appended
AES128( version + action + len + content + device_id ) + iv