Protocols | Bluetooth Packet Structure
Table of Contents
All packets have a leading byte as header that contains a nibble for packet type and a nibble for flags. Packets are either static sized or dynamic. In the static case the length is deducted from the current settings and data type, in the dynamic case there is a length field. Also headers can be dynamic sized, the size can be deducted from the flags in the header byte.
There is a synchronization packet sent in a fixed interval based on the amount of packets sent in between, which is used by the client side to identify the start of the data stream. It used to be used to pick up the stream if corruption was ever encountered. Since Bluetooth gives us reliable transmission, it serves no purpose and should be ignored; in the cosmically unlikely event that a cosmic ray flips a bit in RAM, the safe and practical thing to do is to just drop and restart the connection.
If a payload does not round up to full bytes the remainder is bitstuffed. All readings are bitpacked, so 3 readings of 10 bits each are packed into a 32bit payload.
These are identifiers, so all 16 values can be used and will translate into a single data type. These packet types are currently defined:
|0xF||First nibble of sync packet|
These are OR-ed together, so there are only 4 flags available. If this field is zero there is no more information in the header and payload starts right away.
There is currently one flag:
- Bit 4 ( 0x8 ) – representing “samples have been dropped”
- If this flag is set, a two-byte number (short) is concatenated to the header. The two extra bytes specify numbers of samples dropped by the Muse since the last successful package of same type. Currently only EEG and Accelerometer samples transmit information about dropped samples, as the rest of the data types are less critical.
There are 4 channels with 10 bit sample width each. The order is the one specified in eegChannelLayout in the status output.Diagram:
Payload is 10-bit DRL reading and 10-bit REF reading.
1 byte header, 3 byte payload
Packet header can contain dropped sample count. The payload contains three 10-bit wide samples.
Four 16bit integers (total of 8 bytes), representing:
- Percentage of battery charge remaining * 100
- Millivolts of battery as measured from the fuel gauge
- Millivolts of the battery as measured from ADC
- Temperature in Celsius
This is internal health information raised by checks in the firmware. 32bit flag field, so payload length is 4 byte. It would be highly unusual to receive a packet of this type. It is safe to simply drop this type of packet.
Contents: 1 byte header, 4 byte payload
Sync packet consists of the following 4 bytes: FF FF AA 55.
It is sent every 4 packets of any kind during streaming mode.
This was used at one point to recover from packets being garbled. This is a legacy packet and is really not needed by the protocol, but for now it remains in the firmware as it it harmless. You can safely ignore it.