Crate rawzeo

Source
Expand description

A library to help deode the raw data protocol of the Zeo headband.

§Protocol specification

The serial port is set at baud 38400, no parity, one stop bit. Data is sent Least Significant Byte first.

The serial protocol is: AncllLLTttsidddd, where:

  • A is a character starting the message
  • n is the protocol “version”, ie “4”
  • c is a one byte checksum formed by summing the identifier byte and all the data bytes
  • ll is a two byte message length sent LSB first. This length includes the size of the data block plus the identifier.
  • LL is the inverse of ll sent for redundancy. If ll does not match !LL, we can start looking for the start of the next block immediately, instead of reading some arbitrary number of bytes, based on a bad length.
  • T is the lower 8 bits of Zeo’s unix time.
  • tt is the 16-bit sub-second (runs through 0xFFFF in 1second), LSB first. NOTE: max value seen is 16, so it’s 0xF in 1 second
  • s is an 8-bit sequence number.
  • i is the datatype
  • d is the array of binary data (seems to be 4 len minimum)

Enums§

DataType
All the types of events the base may send.
EventType
All the types of events that may be fired.
FrequencyBins
All the frequency bins.
SleepStages
The sleep stages output by the base.

Functions§

filter60hz
Filters out 60hz noise from a signal. In practice it is a sinc low pass filter with cutoff frequency of 50hz.