Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MeshCore Protocol Specification

Section 18: Companion Protocol

Overview

The companion protocol enables BLE (Bluetooth Low Energy) and serial communication between a MeshCore radio and a companion app (phone, tablet, or computer). It uses a binary framing format over the Nordic UART Service (NUS) BLE profile.

BLE Service

UUIDDescription
6E400001-B5A3-F393-E0A9-E50E24DCCA9ENordic UART Service
6E400002-...RX Characteristic (app writes to radio)
6E400003-...TX Characteristic (radio notifies app)

Frame Format

Each companion protocol frame consists of a 1-byte type identifier followed by variable-length data:

[type(1)][data(0-171)]

Maximum frame size is 172 bytes.

Message Types (Radio to App)

TypeValueDescription
PACKET_CHANNEL_MSG_RECV0x01Channel message received
PACKET_CONTACT_MSG_RECV0x02Contact message received
PACKET_ADV_RECV0x03Advertisement received
PACKET_CONTACT_MSG_RECV_V30x04Contact message V3 (includes SNR)
PACKET_CHANNEL_MSG_RECV_V30x05Channel message V3 (includes SNR)

Command Types (App to Radio)

CommandValueDescription
CMD_APP_START0x01Initialize connection
CMD_DEVICE_QUERY0x02Query device info
CMD_SET_CHANNEL0x03Set active channel
CMD_SEND_CHANNEL_MESSAGE0x04Send message to channel
CMD_SEND_CONTACT_MESSAGE0x05Send message to contact
CMD_GET_CONTACTS0x06Get contact list
CMD_GET_CHANNELS0x07Get channel list
CMD_SET_TIME0x08Set device time
CMD_ADD_CONTACT0x09Add a contact
CMD_ADD_CHANNEL0x0AAdd a channel
CMD_SEND_LOGIN0x0BLogin to room/repeater
CMD_GET_SETTINGS0x0CGet device settings
CMD_SET_SETTINGS0x0DSet device settings
CMD_REMOVE_CONTACT0x0ERemove a contact
CMD_REMOVE_CHANNEL0x0FRemove a channel
CMD_SHARE_CONTACT0x10Share contact info
CMD_SET_ADV_NAME0x11Set advertisement name
CMD_REBOOT0x12Reboot device
CMD_SEND_RAW0x13Send raw packet

Connection Sequence

  1. Scan for BLE devices advertising the Nordic UART Service.
  2. Connect and discover services.
  3. Enable notifications on the TX characteristic.
  4. Send CMD_APP_START to initialize.
  5. Send CMD_DEVICE_QUERY to get device info.
  6. Send CMD_SET_TIME to synchronize clock.
  7. Send CMD_GET_CONTACTS and CMD_GET_CHANNELS to fetch state.

Byte Order

All multi-byte integers in the companion protocol are little-endian, except for CayenneLPP sensor data which uses big-endian.

Message Length Limit

Text messages are limited to 133 characters.

MTU Considerations

The default BLE MTU is 23 bytes (20 bytes of payload). For complex operations, implementations SHOULD request a larger MTU (up to 512 bytes).

Cross-References

Reference Implementation

  • docs/companion_protocol.md in the MeshCore repository