SafeGate Protocol

SafeGate Protocol between iOS application and SafeGate hardware

Version - 0.6.2

Description

Message based protocol featuring commands and responses. Encoded with COBS protocol.
Commands are issued by host
Responds are issued by device

COBS - Consistent overhead byte stuffing

Replaces all 0x00 bytes from data with different values and 2 bytes of overhead (data length < 254 )

This enables the message end delimiters. It also provides for message resynchronization in case of faulty messages

Protocol - Endianess

The protocol uses big endian for transmission of multibyte values

Protocol - Message

Command / ResponseMessage end delimiter
Encoded command or response0x00

Command

CommandData lengthData
1 Byte (unsigned)2 Bytes (unsigned){dataLength} bytes

List of commands

CommandData lengthDataNameDescription
0x001int8_tPingPings the device with a byte of data which is multiplied by 2 and responsed back to application
0x010/DumpEERequest a eeprom dump of sensor
0x020/GetFrameDataRequest a frame data once
0x031uint8_t - resolution (see resolutions)SetResolutionSends the desired resolution at which the sensor should sample the image
0x040/GetCurResolutionRequest the current resolution at which sensor samples the image
0x051uint8_t - refresh rate (see refresh rates)SetRefreshRateSends the desired refresh rate at which the sensor should sample the image
0x060/GetRefreshRateRequest the current refresh rate at which sensor samples the image
0x071uint8_t - mode (see modes)SetModeSends the desired mode of subframe storing
0x080/GetCurModeRequest the current mode of subframe storing
0x091uint8_t - auto (see auto frame sending)SetAutoFrameDataSendingStarts or stops the automated frame data sending
0x0A0/GetFirmwareVersionRetrieves firmware version of device to check for updates
0x0B0/JumpToBootloaderCommands the OTC firmware to jump to DFU bootloader

Response

ResponseData codeData lengthData
1 Byte (unsigned)1 Byte (signed)2 Bytes (unsigned){dataLength} bytes

List of responses

ResponseData codeData lengthDataNameDescription
0x000 ok1int8_t - ping command value * 2PingResponds to ping and multiply the received value by 2
0x010 ok, -1 nack832*2uint16_t[832]DumpEEEEPROM dump of sensor
0x020 ok, -1 nack, -8 I2C frequency too low834*2uint16_t[834]GetFrameDataResponds with frame data
0x030 ok, -1 nack, -2 written value not same0/SetResolutionRespondes with status
0x040 ok, -1 nack1uint8_t - resolution (see resolutions)GetCurResolutionResponds with current resolution at which sensor samples the image
0x050 ok, -1 nack, -2 written value not same0/SetRefreshRateRespondes with status
0x060 ok, -1 nack1uint8_t - refresh rate (see refresh rates)GetRefreshRateResponds with current refresh rate at which sensor samples the image
0x070 ok, -1 nack, -2 written value not same0/SetModeSends the desired mode of subframe storing
0x080 ok, -1 nack1uint8_t - mode (see modes)GetCurModeRequest the current mode of subframe storing
0x090 ok1uint8_t - auto (see auto frame sending)SetAutoFrameDataSendingRespondes with previous auto farme sending value
0x0A0 ok12struct FirmwareVersion (see FirmwareVersion structure)GetFirmwareVersionRespondes with firmware version of device
0x0B-1 error (try again)0/JumpToBootloaderResponse to JumpToBootloader command, if successful, no respond shall be received

Protocol - Additional information

Refresh rates

ValueRate
0x048Hz
0x0516Hz

Resolutions

ValueResolution
0x0016-bit
0x0117-bit
0x0218-bit
0x0319-bit

Modes

ValueMode
0x00interleaved
0x01chess pattern

Auto frame sending

ValueFunction
0x00Disabled
0x01Enabled

FirmwareVersion structure

NameData typeOffsetDescription
Majorint32_t01.0.5
Minorint32_t41.0.5
Revisionint32_t81.0.5