Friday, July 19, 2013

Connecting to the SportTracker ST HRM2 bluetooth belt from the CLI

For quickly getting the raw data out from the ST HRM2 belt, the CLI is the fastest way. No need to code up anything.

Prepare the belt first, you should know how, it will turn on automatically when the device detects a heartbeat. You need to scan and connect to it inside a couple of minutes as otherwise it will turn off automatically, I don't remember exactly how long it stays on.

First, scan for the device:

$ hcitool scan
Scanning ...
    FF:0B:AE:1C:xx:yy    ST HRM2


The do a rfcomm bind:

$ sudo rfcomm connect  FF:0B:AE:1C:xx:yy
...
Connected /dev/rfcomm0 to FF:0B:AE:1C:xx:yy on channel 1
Press CTRL-C for hangup


Now you can access the raw data stream from /dev/rfcomm0 for example with plain old 'cat'.

Unfortunately the data is not in a nice NMEA style text format but binary so to make any sense of it, pipe it to something that can convert the output to a more human friendly format, I used hexdump, like this:

$ sudo cat /dev/rfcomm0 | hexdump
0000000 46fa 81b9 372c 2046 0000 0000 0000 4e00
0000010 425c a0ba 45fa 81ba 342c c448 004e 0000
0000020 0000 5e00 fa47 b946 2c81 4434 0010 0000
0000030 0000 0000 b635 47fa 81b8 352c 1043 0000
0000040 0000 0000 8000 f2c3 47fa 81b8 362c 6443
0000050 007e 0000 0000 5f00 faab bb44 2c81 4436
0000060 00a0 0000 0000 0000 180b 4c10 45fa 81ba
0000070 372c f045 0000 0000 0000 2200 fa43 b946
0000080 2c81 4337 5664 0000 0000 0000 50d8 6363
0000090 46fa 81b9 372c 103f 0000 0000 0000 c800
...


You can adjust the output of hexdump to suit your needs.

Or just get any Bluetooth Smart HRM belt that provides a standard interface that you can use :)

No comments: