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 an
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 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
[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.