Skip to content

Instantly share code, notes, and snippets.

@flaviut
Last active Jan 10, 2022
Embed
What would you like to do?
Prefer https://github.com/flaviut/PC-60FW-BLE-Reader, it does auto retries.
import sys
import datetime
"""
Dumps the data from a bluetooth-connected PC-60FW fingertip oximeter to a CSV
on stdout.
# Getting started
Make sure you have CMake, gcc, and python 3.7+ installed.
```
git clone https://github.com/flaviut/gattlib.git
cd gattlib
git checkout flush-uart-read
wget https://gist.githubusercontent.com/flaviut/be90563e4122248e51a65c24f6648236/raw/parse_hrmonitor.py
mkdir build
cd build
cmake .. -DGATTLIB_BUILD_DOCS=OFF
make -j$(nproc)
cd ..
# find the MAC address of your monitor and replace the address below with it
./build/examples/nordic_uart/nordic_uart FA:37:2D:C6:3E:3D | python ./parse_hrmonitor.py
```
You can get your oximeter's MAC address either using `bluetoothctl scan on` or
in other ways: https://www.google.com/search?q=+get+bluetooth+mac+address
# Output example:
```
time,spo2,heartrate
2021-12-02T22:31:50-05:00,98,86
2021-12-02T22:31:51-05:00,98,86
2021-12-02T22:31:52-05:00,98,86
2021-12-02T22:31:53-05:00,98,86
2021-12-02T22:31:54-05:00,97,90
2021-12-02T22:31:55-05:00,97,91
2021-12-02T22:31:56-05:00,98,92
2021-12-02T22:31:57-05:00,99,97
2021-12-02T22:31:58-05:00,99,97
2021-12-02T22:31:59-05:00,99,97
2021-12-02T22:32:00-05:00,99,97
2021-12-02T22:32:01-05:00,99,97
2021-12-02T22:32:02-05:00,98,93
2021-12-02T22:32:03-05:00,98,89
2021-12-02T22:32:04-05:00,98,86
2021-12-02T22:32:05-05:00,98,84
```
"""
def readb(n=1):
return sys.stdin.buffer.read(n)
if __name__ == '__main__':
print("time,spo2,heartrate")
while True:
if readb() == b'\xaa' and \
readb() == b'\x55' and \
readb() == b'\x0f' and \
readb() == b'\x08' and \
readb() == b'\x01':
time = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat()
print(f'{time},{ord(readb())},{ord(readb())}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment