LogoLogo
  • Ruuvi Developer Documentation
  • Ruuvi Hardware
    • RuuviTag B
    • RuuviTag Pro
    • Ruuvi Gateway
    • Ruuvi DevShield
    • Ruuvi Connector Kit
    • TMP 117 External Sensor
  • Ruuvi Connector System
    • Introduction
    • Expansion boards
    • Cables
    • Connectors
  • Ruuvi Sensor Firmware
    • 1.2.12
    • 2.5.9
    • 3.X
      • 3.x Sensors
      • 3.x Heartbeat
    • Device Firmware Update (DFU)
  • Ruuvi Gateway Firmware
    • GW Getting Started
    • GW Web-UI
      • Greeting window
      • Internet connection settings
        • Connection via Wi-Fi
        • Connection via Ethernet
      • Software update
      • Automatic configuration download
      • Automatic updates
      • Access Settings from LAN
      • Cloud Options
        • Backend: HTTP(s)
        • Backend: MQTT(s)
        • Backend: Statistics
      • Time Synchronisation Options
      • Bluetooth Scanning Settings
      • Configuration completion
      • Authentication when accessing from LAN
    • GW Install custom firmware
    • GW nRF52811 Firmware
      • GW nRF52811 selftest
      • GW nRF52811 scanning
      • GW nRF52811 repeating
      • GW nRF52811 UART communication
  • GW ESP32 Firmware
    • GW ESP32 WiFi Hotspot
    • GW ESP32 Button
    • GW ESP32 LED
    • GW ESP32 HTTP Client
    • GW ESP32 MQTT client
  • GW Data formats
    • HTTP: Time-stamped data from Bluetooth-sensors
    • HTTP: Data from Bluetooth-sensors without timestamps
    • MQTT: Time-stamped data from Bluetooth-sensors
    • MQTT: Data from Bluetooth-sensors without timestamps
    • HTTP GET /history (with timestamps) and decoding
    • HTTP: Gateway status
    • Gateway configuration
  • GW Examples
    • Polling mode
    • Poll endpoint "/metrics"
    • Configuration update via API
    • Firmware update via API
    • Configuration download from a remote server via API
    • MQTT examples
    • Home Assistant
    • MQTT+AWS IoT Core
  • Communicate with RuuviTag devices via Bluetooth
    • Bluetooth advertisements
      • Data format 3 (RAWv1)
      • Data format 4 (URL)
      • Data format 5 (RAWv2)
      • Data format C5 (Cut-RAWv2)
      • Data format 8 (Encrypted environmental)
    • Bluetooth connection
      • DIS (Device Information Service)
      • NUS (Nordic UART Service)
        • Heartbeat transmissions
        • Read logged history
    • Real Time Transfer (RTT)
  • Communicate with Ruuvi Cloud
    • Ruuvi Cloud
      • User API
      • Gateway API
      • Internal API
      • Alerts
      • Cloud stored app settings
  • Ruuvi Community projects
    • Integrations
Powered by GitBook
On this page
  • Message format
  • Defines
  • SET sequence
  • Command format
  • Ack message
  • GET sequence
  • Request message
  • Response message
  • REPORT sequence
  • Report message
  • CONFIGURATION REQUEST sequence
  • CFG Request message
Edit on GitHub
  1. Ruuvi Gateway Firmware
  2. GW nRF52811 Firmware

GW nRF52811 UART communication

PreviousGW nRF52811 repeatingNextGW ESP32 Firmware

Last updated 2 years ago

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

Command
CMD
Param
Value

RE_CA_UART_SET_FLTR_TAGS

0x05

Enable/disable BLE tags filter

0...1

RE_CA_UART_SET_FLTR_ID

0x06

Manufacturer ID to be filtered (uint16)

0...65535

RE_CA_UART_SET_CODED_PHY

0x07

Enable/disable BLE coded PHY

0...1

RE_CA_UART_SET_SCAN_1MB_PHY

0x08

Enable/disable BLE scan PHY

0...1

RE_CA_UART_SET_EXT_PAYLOAD

0x09

Enable/disable BLE extended payload

0...1

RE_CA_UART_SET_CH_37

0x0A

Enable/disable BLE channel 37

0...1

RE_CA_UART_SET_CH_38

0x0B

Enable/disable BLE channel 38

0...1

RE_CA_UART_SET_CH_39

0x0C

Enable/disable BLE channel 39

0...1

RE_CA_UART_LED_CTRL

0x0E

Turn on the LED for the specified time interval in milliseconds (uint16)

0...65535

Command
CMD
Param 1
Param 2

RE_CA_UART_SET_ALL

0x0F

Manufacturer 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

Ack
CMD
Param 1
Param 2

RE_CA_UART_ACK

0x20

Command 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:

STX

LEN

CMD

State

DELIMITER

CRC16

ETX

CA

02

0A

01

2C

78B6

0A

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

Ack RE_CA_UART_ACK:

STX

LEN

CMD

Command

DELIMITER

Ack

DELIMITER

CRC16

ETX

CA

04

20

0A

2C

00

2C

7EE7

0A

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

Example: Set all configuration

Command RE_CA_UART_SET_ALL:

STX
LEN
CMD
Filter ID
DELIMITER
State bit-mask
DELIMITER
CRC16
ETX

CA

05

0F

0499

2C

7D

2C

6121

0A

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

Ack RE_CA_UART_ACK:

STX
LEN
CMD
Command
DELIMITER
Ack
DELIMITER
CRC16
ETX

CA

04

20

0F

2C

00

2C

C2A2

0A

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

GET sequence

Request message

Request
CMD
Param

RE_CA_UART_GET_DEVICE_ID

0x18

-

Response message

Response
CMD
Param 1
Param 2

RE_CA_UART_DEVICE_ID

0x11

Device ID (8 bytes)

MAC Address (6 bytes)

Example: Request DEVICE_ID

Command :

STX
LEN
CMD
CRC16
ETX

CA

00

18

8E36

0A

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

Response:

STX
LEN
CMD
Device ID
DELIMITER
MAC Addr
DELIMITER
CRC16
ETX

CA

10

11

0x38E11A5878A79840

2C

2C:9C:8E:2D:25:C8

2C

677F

0A

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

Report
CMD
Param 1
Param 2
Param 3

RE_CA_UART_ADV_RPRT

0x10

MAC 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

STX
LEN
CMD
MAC Addr
DELIMITER
Adv
DELIMITER
RSSI
DELIMITER
CRC16
ETX

CA

29

10

06:AD:E0:B9:A5:C6

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

0811

0A

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

Request
CMD
Param

RE_CA_UART_GET_ALL

0x19

-

Example: Configuration request on the device side

STX
LEN
CMD
CRC16
ETX

CA

00

19

9E17

0A

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