Talking to a Bluetooth (BLE) Pulse Oximeter - Part II - Thu, Jul 29, 2021
These oximeters also continuously record oxygen, heart rate, motion and other values in their internal memory as files. Files are stored in a binary format that can be decoded as described in this note.
The first 40 bytes are the header:
00 int16 version (2 bytes)
02 int16 year
04 byte month
05 byte day
06 byte hour
07 byte minute
08 byte second
09 int16 file size
13 int16 duration in seconds
17 byte average O2
18 byte minimum O2
19 byte 3pct O2
20 byte 4pct O2
22 int16 O2 < 90% seconds
24 byte events under 90%
25 byte score
Take the total length of the file (number of bytes), remove 40 (i.e. the length of the header). Divide by 5 (i.e. the length of a record). You’ll get the total number of records in the file.
You can get the interval between each record by dividing the duration (bytes 13 and 14 of the header) by the number of records.
Reading Records
Skip 40 bytes (the header), you’ll arrive at the beginning of the first record. Take 5 bytes:
00 O2 %
01 Heart Rate bpm
02 ??
03 Motion
04 Vibration
As you already have the interval, you can estimate each record’s timestamp by multiplying record ID by interval, plus the start time (bytes 02 to 08 inclusive of the header).