Monday, November 17, 2014

Polar H7 Bluetooth LE Device Name

While messing around with my Polar H7 trying to figure out how to read real time heart rate information I inadvertently overwrote the device name. I didn't even realize that this was possible, but apparently it is.

When running a hcitool lescan I would no longer get the device name listed. I was getting a weird character.


This made life a bit harder. On my Android devices when scanning for the device I'd just get a blank name. I thought for sure I royally screwed something up. I decided to give fixing it a shot, and luckily I have another unit which I could use to compare the values in the different characteristics.

It turns out I didn't even need to do that. If I'd just looked at the Bluetooth specification and especially org.bluetooth.characteristic.gap.device_name I'd have had it figured out pretty quick. But, I guess the 30 mins I spent on this wasn't too bad either.


To read the device name value I did

# gatttool -i hci0 -b 00:22:D0:33:1E:0F -I
[   ][00:22:D0:33:1E:0F][LE]> connect
[CON][00:22:D0:33:1E:0F][LE]> primary
attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000e uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000f, end grp handle: 0x0014 uuid: 0000180d-0000-1000-8000-00805f9b34fb
attr handle: 0x0015, end grp handle: 0x0023 uuid: 0000180a-0000-1000-8000-00805f9b34fb
attr handle: 0x0024, end grp handle: 0x0026 uuid: 0000180f-0000-1000-8000-00805f9b34fb
attr handle: 0x0027, end grp handle: 0xffff uuid: 6217ff49-ac7b-547e-eecf-016a06970ba9
[CON][00:22:D0:33:1E:0F][LE]> char-desc 0x0001 0x000b
handle: 0x0001, uuid: 2800
handle: 0x0002, uuid: 2803
handle: 0x0003, uuid: 2a00
handle: 0x0004, uuid: 2803
handle: 0x0005, uuid: 2a01
[CON][00:22:D0:33:1E:0F][LE]> char-read-hnd 0x0003
Characteristic value/descriptor: 01 

The value of "01" is not what should be there. The standard naming on the Polar H7 devices are "Polar H7 XXXXXX" where the Xs are the last 3 octects of the MAC address. So for me the name should've been "Polar H7 331E0F" which thanks the ASCII-to-HEX converter at http://www.rapidtables.com/convert/number/ascii-to-hex.htm is 506f6c617220483720333331453046

[CON][00:22:D0:33:1E:0F][LE]> char-write-cmd 0x0003 506f6c617220483720333331453046
[CON][00:22:D0:33:1E:0F][LE]> char-read-hnd 0x0003
Characteristic value/descriptor: 50 6f 6c 61 72 20 48 37 20 33 33 31 45 30 46 

That was it! Problem solved.




4 comments:

  1. I'm interested in developed a similar project. I want to display real time heart rate date on my computer screen. Is this a project you would be interested in taking? Can you provide me your email or skype so we can discuss and you can give me an estimated cost please. my skype is shockdav

    ReplyDelete
    Replies
    1. I am not able to dedicate any time to this. You might want to try a website which can put you in touch with a freelancer.

      Delete
    2. The WiCis sports app I-Streme will read the H7 and send its data directly to your own dashboard inside a browser once per second. You will be able to set alert limits as well as work with other wearables simultaneously. Good luck!

      Delete
  2. Hi, struggled quite a lot with HR monitors from other brands, as gatttool and then connect resulted in an error.

    solution is to start gatttool with "-t random" flag and then it connects without a problem. Thought I post it as it took me a week to find after reading this great tutorial

    ReplyDelete