Skip to main content

Module parse

Module parse 

Source
Expand description

Binary decoders for MW75 BLE notification and RFCOMM data payloads.

All public functions in this module are pure (no I/O, no allocation beyond the returned collections) and are safe to call from any async or sync context.

§Packet layout

The MW75 streams 63-byte binary packets at 500 Hz over RFCOMM channel 25. Each packet starts with a 0xAA sync byte and ends with a 16-bit little-endian checksum:

Offset  Size  Field
──────  ────  ─────
  0       1   Sync byte (0xAA)
  1       1   Event ID (239 = EEG)
  2       1   Data length
  3       1   Counter (0–255, wrapping)
  4       4   REF electrode value (f32 LE)
  8       4   DRL electrode value (f32 LE)
 12      48   12 × EEG channels (f32 LE each)
 60       1   Feature status byte
 61       2   Checksum (u16 LE = sum of bytes[0..61] & 0xFFFF)

§Buffered processing

RFCOMM delivers arbitrary-sized chunks (e.g. 64 bytes) while MW75 packets are exactly 63 bytes. PacketProcessor accumulates data across chunks and handles sync-byte alignment, checksum validation, and buffer overflow protection.

Structs§

PacketProcessor
Processes a continuous byte stream into MW75 packets.

Functions§

parse_eeg_packet
Parse a 63-byte MW75 packet into a structured EegPacket.
validate_checksum
Validate the MW75 packet checksum.