The communication protocol consists of little-endian binary encoded messages. All the messages will be described by packed C structures. The general structure of message:
struct msg { uint32_t length; uint16_t id; uint8_t data[]; };
length | - | message length (including length of this variable) |
id | - | unique (per direction) message identifier |
data | - | flexible array containing optional data |
Some messages are to be responded, so messages can be differentiated in two main groups: commands and responses. It is defined, that the highest (15th) bit of message identifier serves as response flag (set for response, cleared for command). If the response bit is set, then the remaining bits equal identifier of the responded (command) message.
Any character string contained in message is zero terminated, unless otherwise specified.
Each message is described by a fixed array of attributes followed by an accompanying text. The array of attributes has the following form:
(<length>, <identifier>, <data>, <direction>, <message>)
length | - | message length (see struct msg) |
id | - | message identifier (see struct msg) |
data | - | type of contained data (see struct msg) |
direction | - | direction from view of MGB device |
message | - | responding or responded message |
(6, 0x0000, none, RX, RSP_PING)
Just a ping message.
(6, 0x8000, none, TX, CMD_PING)
Just a ping response message.
(6, 0x0001, none, RX, none)
Shuts down MGB. There is no response, but the socket gets closed.
(6, 0x0002, none, RX, none)
Reboots MGB. There is no response, but the socket gets closed.
(undefined, 0x0003, string, RX, RSP_SET_TIMEZONE)
Sets timezone. Data holds the Olson timezone.
(6, 0x8003, uint8_t, TX, CMD_SET_TIMEZONE)
Response to timezone setting. Data holds the response code (0 - success, 1 - error).
(6, 0x0004, none, RX, RSP_GET_TIMEZONE)
Gets timezone.
(undefined, 0x8004, string, TX, CMD_GET_TIMEZONE)
Response to timezone getting. Data holds the Olson timezone.
(undefined, 0x0004, string, TX, none)
Information about timezone. Data holds the Olson timezone.
(13, 0x0005, struct datetime, RX, RSP_SET_DATETIME)
Sets date/time. The values are considered as local for configured timezone.
(6, 0x8005, uint8_t, TX, CMD_SET_DATETIME)
Response to date/time setting. Data holds the response code (0 - success, 1 - error).
(6, 0x0006, none, RX, RSP_GET_DATETIME)
Gets date/time.
(13, 0x8006, struct datetime, TX, CMD_GET_DATETIME)
Response to date/time getting. The values are considered as local for configured timezone.
(13, 0x0006, struct datetime, TX, none)
Information about date/time. The values are considered as local for configured timezone.
struct datetime { uint16_t year; uint8_t month; uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; };