-
-
Notifications
You must be signed in to change notification settings - Fork 343
Communication Details
Every devices has a devId
as well as a gwId
. The devId
is usually the same as the gwId
, but may not be in some cases (when a controller acts as a hub for multiple devices).
Every devices has a JSON interface for getting and setting properties. These properties are represented as an object with string keys. The object is named dps
. For example:
{
dps: {
'1': true,
'2': 0
}
}
To get the state of a device, send a payload of { gwId: '<gwId>', devId: '<devId>' }
to the device with the appropriate command byte.
To set the state, send a payload with the following structure (where the dps
key contains the intended state):
{
devId: '<devId>',
uid: '',
t: '<seconds since epoch>',
dps: {
'1': true
}
}
Again, use the correct command byte.
Devices send a UDP packet at a regular interval to the network's broadcast address on port 6666. The packet contains their devId
as well as their IP.
Get requests are not encrypted. Set requests, however, are required to be encrypted.
- Prefix:
0x000055aa
- Sequence number (32 bits): device will return the same sequence number passed to it in the command
- Command byte (32 bits): refer to table
- Payload length (32 bits): byte count of the remainder of the frame
- Return code (32 bits): only present in responses from the device, non-zero indicates an error
- Payload: the actual data (potentially encrypted)
- CRC (32 bits): the payload checksum. Devices don't seem to care about this, so it's possible to just use
0x00000000
. - Suffix:
0x0000aa55
{
int32_t prefix
int32_t sequence // pass a unique number to the device and it will be included in the response
int32_t command
int32_t payloadSize // byte count from this point forward
char[] payload // if receiving from the device, the first four bytes are the return code
int32_t crc // everything through the payload, be sure to include the prefix
int32_t suffix // essentially the marker to know that we can consider parsing another message
}