Skip to content

serial commands

bjoerke edited this page Aug 2, 2014 · 5 revisions

Serial commands

You can interface the firmware by sending and receiving data over a serial connection. The connection uses baudrate 9600. Some commands have an additional length field for their payload data while others have a fixed length. Every data field is little endian.

Commands

Test (1)

Simple testing command to check if firmware is ready.

Send:

Opcode: 0x01 (uint8_t)

Receive

ACK: 0x40 (uint8_t)

Set Advertisement Data (2)

Changes the broadcasted advertisement data (not more than 31 Bytes).

Send

Opcode: 0x02 (uint8_t)

Length of following data (uint8_t)

Advertisment Data (uint8[length])

Receive

ACK: 0x40 (uint8_t)

Set Name (3)

Changes the device's name. Note that the name has a maximal length of 20 characters.

Send

Opcode: 0x03 (uint8_t)

Length of Name (uint8_t)

Name (uint8_t[Length]

Get Firmware Info String (4)

Retrieves the firmware string, which contains human-readable information (like Version, etc.). Note that the firmware info string does not has to be null-terminated.

Send

Opcode: 0x04 (uint8_t)

Receive

Length of string (uint8_t)

Firmware info string (uint8_t[Length])

Start (5)

Starts or restarts the device. This means that the iBeacon data is broadcastes (whith the name and Parameters you have chosen). This also means that 'Device Found' responses will be send frequently.

Send

Opcode: 0x05 (uint8_t)

reserved: 0x00 (uint8_t)

reserved: 0x00 (uint8_t)

Receive

ACK: 0x40 (uint8_t)

Later: 'Device Found' Responses

Stop (6)

Stops the device.

Send

Opcode: 0x06 (uint8_t)

Receive

ACK: 0x40 (uint8_t)

Responses

Device Found (2)

This response is send frequently from the firmware after starting the device via 'Start Device'. It contains information about all nearby devices.

Receive

ResponseCode: 0x02 (uint8_t)

Length of following data (uint8_t)

Bluetooth address (uint8_t[6])

-RSSI (int8_t)

Advertising Data (uint8_t[Length-7)

NCK (0x23)

A NCK (not acknowlegded) is received when:

  • an invalid opcode has been send
  • a valid opcode has been send, but it took too long to send the remaining data
  • invalid Parameters have been send (for example advertisment data longer than 31 Bytes)

Receive

NCK: 0x23 (uint8_t)