Sensor control protocol specification
Data types
uint8_t // 1 byte
uint16_t // 2 bytes, little-endian, low byte first
float // 4 bytes
zone_index_t
byte, zone index.
Possible values: - .
uint8_t zone_index;
version_t
Zone version.
uint8_t name[32]; // device name
uint8_t build[16]; // build number
uint8_t date[16]; // build date
uint8_t time[16]; // build time
name, build, date and time are strings are encoded as ASCII
channel_mem_t
Channel configration.
bool enabled; // channel enabled
float difference; // difference
float errHigh; // error high limit
float errLow; // error low limit
float holdtime; // hold time
channel_t
Channel runtime data + channel configuration.
uint8_t status; // channel status
uint16_t clearErrorTime; // error time left
float saved_value; // saved value
float read_value; // read value
channel_mem_t mem; // channel memory values
device_t
Device runtime
uint8_t index; // zone index 0-32
channel_t channel[16]; // status for 16 channels
uint8_t status; // zone status code
// status bits:
// 0: Digital Input A
// 1: Tamper
// 2: Channels A
// 3: Digital Input B
// 4: Channels B
// 5-7: [spare]
status:
High bit means an error.
Errors are firmare-dependant.
Channels ( - ) will raise “Channels A” error
Channels ( - ) will raise “Channels B” error.
For example, an error on channel will raise “Channels B” error.
Device status code of value x means an errors on both Digital Input A and Channels A
log_channel_data_t
uint8_t channel; // channel index
uint8_t status; // channel status
uint8_t prev_status; // channel previous status
float value; // channel read value
float reference; // channel reference value
// status bits:
// 0: Cable disconnected
// 1: Cable disconnected
// 2: Difference
// 3: Error (Low)
// 4: Error (High)
// 5-7: [spare]
channel_values_t
uint8_t channel; // channel index. 0-15
uint8_t enabled; // 0x00 or 0x01. (Disable: 0x00, Enable: 0x01)
float difference; // difference
float errHigh; // error high limit
float errLow; // error low limit
float holdtime; // hold time
Command structure
Device --> Zone
Start (6 bytes) Length (uint16) Data (n bytes) Checksum (byte)
Start (6 bytes) Length (uint16) Data (n bytes) Checksum (byte)
0x11 0x55 0x22 0x55 0x33 0x55 (length) (data) (checksum)
length: number of bytes of (data)
checksum: sum of (data) bytes % xFF
data: device command
Zone --> Device
Start (byte) Length (uint16) Data (n bytes) Checksum (byte) Stop (byte)
0x66 (length) (data) (checksum) 0xAA
length: uint
checksum: sum of (data) bytes % xFF
Device commands
Read version
Read zone version.
command (uint16) Zone (zone_index_t)
0x000a (zone-id)
Example (zone # ):
x A x x
Read version (response)
command (uint16) Version (version_t)
0x000b (version)
Clear alarm
Clears and resets current alarm state.
command (uint16) Zone (zone_index_t)
0x0006 (zone-id)
Example (zone # ):
x x x
Clear alarm (response)
command (uint16) Status (device_t)
0x0007 (device-status)
Reset
command (uint16) Zone (zone_index_t)
0x000c (zone-id)
Example (zone # ):
x c x x
Reset (reponse)
command (uint16)
0x000d
Read log
command (uint16) Zone (zone_index_t)
0x0011 (zone-id)
Example (zone # ):
x x x
Read log (response)
Response may contain multiple packets.
Read log response will always end with “end of log” packet (packet type # ).
Packet type #1: Zone channel changed
command (uint16) Channel log (log_channel_data_t)
0x0012 (channel-log)
index: channel index, -
status: channel status
previous-status: previous channel status
value: channel read value
reference: channel reference value
Packet type #2: Zone status changed
command (uint16) status (uint8_t) previous status (uint8_t)
0x0013 (status) (previous-status)
status as defined in device_t
Packet type #3: End of log
command (uint16)
0x0014
Read status
command (uint16) Zone (zone_index_t)
0x0008 (zone-id)
Example (zone # ):
x x x
Read status (response)
command (uint16) Status (device_t)
0x0007 (device-status)
Set channel configuration
command (uint16) Zone (zone_index_t) Values (channel_values_t)
0x0004 (zone-id) (values)
Set channel configuration (response)
command (uint16) mem (channel_mem_t)
0x0010 (mem)
Example
Send (read version packet):
Get version of zone # :
11 55 22 55 33 55 03 00 0A 00 00 0A
Get version of zone # :
11 55 22 55 33 55 03 00 0A 00 01 0B
Receive (get version response packet):
66 52 00 0B 00 53 65 6E 73 6F 72 73 20 63 6F 6E fR...Sensors con
74 72 6F 6C 6C 65 72 20 5B 6C 6F 67 67 65 72 20 troller [logger
31 36 43 48 5D 31 2E 31 32 30 00 00 00 00 00 00 16CH]1.120......
00 00 00 00 00 4F 63 74 20 33 31 20 32 30 31 38 .....Oct 31 2018
00 00 00 00 00 31 35 3A 30 36 3A 34 31 00 00 00 .....15:06:41...
00 00 00 00 00 F2 AA .....òª
In this example:
name: Sensors controller [logger 16CH]
build: 1.120
date: Oct 31 2018
time: 15:06:41