Skip to content

Latest commit

 

History

History
127 lines (64 loc) · 9.81 KB

gw-nrf52811-uart-communication.md

File metadata and controls

127 lines (64 loc) · 9.81 KB

GW nRF52811 UART communication

Message format

The host and device (nRF52) communicate with each other via UART using the following message format:

Note 1: LEN field determines the length of the payload (CMD field is not included in LEN).
Thus, the message with LEN=0 contains only the CMD byte and no Payload.

Note 2: CRC16 is calculated for Header (LEN and CMD) and Payload.

CRC is CRC-16-CCITT-FALSE, Polynomial Formula: x16+x12+x5+1, Polynomial: 1021

Defines

Constant Value
STX 0xCA
ETX 0x0A
DELIMITER 0x2C

SET sequence

Command format

CommandCMDParamValue
RE_CA_UART_SET_FLTR_TAGS0x05Enable/disable BLE tags filter0...1
RE_CA_UART_SET_FLTR_ID0x06Manufacturer ID to be filtered (uint16)0...65535
RE_CA_UART_SET_CODED_PHY0x07Enable/disable BLE coded PHY0...1
RE_CA_UART_SET_SCAN_1MB_PHY0x08Enable/disable BLE scan PHY0...1
RE_CA_UART_SET_EXT_PAYLOAD0x09Enable/disable BLE extended payload0...1
RE_CA_UART_SET_CH_370x0AEnable/disable BLE channel 370...1
RE_CA_UART_SET_CH_380x0BEnable/disable BLE channel 380...1
RE_CA_UART_SET_CH_390x0CEnable/disable BLE channel 390...1
RE_CA_UART_LED_CTRL0x0ETurn on the LED for the specified time interval in milliseconds (uint16)0...65535
CommandCMDParam 1Param 2
RE_CA_UART_SET_ALL0x0FManufacturer ID to be filtered:
0...65535
Bit-mask (uint8) for all state flags:
- bit 0: Filter tags
- bit 1: BLE coded PHY
- bit 2: BLE scan PHY
- bit 3: BLE extended payload
- bit 4: BLE chan 37
- bit 5: BLE chan 38
- bit 6: BLE chan 39

Ack message

AckCMDParam 1Param 2
RE_CA_UART_ACK0x20Command to which the ACK responds:
0x05...0x0C, 0x0F
Ack state:
0 - OK
1 - Error

Example: Set the state of channel 37

Command RE_CA_UART_SET_CH_37:

STXLENCMDStateDELIMITERCRC16ETX
STXLENCMDStateDELIMITERCRC16ETX
CA020A012C78B60A

Complete message: CA 02 0A 01 2C B6 78 0A

Ack RE_CA_UART_ACK:

STXLENCMDCommandDELIMITERAckDELIMITERCRC16ETX
STXLENCMDCommandDELIMITERAckDELIMITERCRC16ETX
CA04200A2C002C7EE70A

Complete message: CA 04 20 0A 2C 00 2C E7 7E 0A

Example: Set all configuration

Command RE_CA_UART_SET_ALL:

STXLENCMDFilter IDDELIMITERState bit-maskDELIMITERCRC16ETX
CA050F04992C7D2C61210A

Complete message: CA 05 0F 99 04 2C 7D 2C 21 61 0A

Ack RE_CA_UART_ACK:

STXLENCMDCommandDELIMITERAckDELIMITERCRC16ETX
CA04200F2C002CC2A20A

Complete message: CA 04 20 0F 2C 00 2C A2 C2 0A

GET sequence

Request message

RequestCMDParam
RE_CA_UART_GET_DEVICE_ID0x18-

Response message

ResponseCMDParam 1Param 2
RE_CA_UART_DEVICE_ID0x11Device ID
(8 bytes)
MAC Address
(6 bytes)

Example: Request DEVICE_ID

Command :

STXLENCMDCRC16ETX
CA00188E360A

Complete request message: CA 00 18 36 8E 0A

Response:

STXLENCMDDevice IDDELIMITERMAC AddrDELIMITERCRC16ETX
CA10110x38E11A5878A798402C2C:9C:8E:2D:25:C82C677F0A

Complete response message: CA 10 11 40 98 A7 78 58 1A E1 38 2C C8 25 2D 8E 9C 2C 2C 7F 67 0A

REPORT sequence

Report message

ReportCMDParam 1Param 2Param 3
RE_CA_UART_ADV_RPRT0x10MAC address
(6 bytes)
Advertisement:
Variable length (MAX 31 Bytes)
RSSI in dB:
-128...127

Note: The length of the Advertisement is determined by the LEN field in the Header.
Adv_Len := LEN - 10

Example of report

STXLENCMDMAC AddrDELIMITERAdvDELIMITERRSSIDELIMITERCRC16ETX
CA291006:AD:E0:B9:A5:C62C02 01 06 1B FF 99 04 05 14 64 47 25 C4 41 00 34 00 00 04 1C A9 36 11 01 58 C6 A5 B9 E0 AD 062CD92C08110A

Complete report message: CA 29 10 C6 A5 B9 E0 AD 06 2C 02 01 06 1B FF 99 04 05 14 64 47 25 C4 41 00 34 00 00 04 1C A9 36 11 01 58 C6 A5 B9 E0 AD 06 2C D9 2C 11 08 0A

CONFIGURATION REQUEST sequence

CFG Request message

RequestCMDParam
RE_CA_UART_GET_ALL0x19-

Example: Configuration request on the device side

STXLENCMDCRC16ETX
CA00199E170A

Complete configuration request message: CA 00 19 17 9E 0A