Reputation: 1
I am trying to retrieive heart-rate date from a polar belt to use as part of emotion recognition algorithm. I am using a Raspberry pi 3b with raspbian. I am able to connect to the device with bluetoothctl When I open info I get a list of the UUID´s
Here is where it stops. I have tried to use hcitool according to the example below, but that does not work. When I try to connect I get the message: Connection Refused(111)
$ sudo gatttool -i hci1 -b 00:22:D0:33:1E:0F -I
[ ][00:22:D0:33:1E:0F][LE]> connect
[CON][00:22:D0:33:1E:0F][LE]>
So I tried to use bleak and pygatt and I´m not able to make this work. I am quite a newbee, so I am probably doing something wrong. But now I have run out of ideas. Any suggestions will be appreciated.
Upvotes: 0
Views: 1301
Reputation: 7984
hciattach
, hciconfig
, hcitool
, hcidump
, rfcomm
, sdptool
, ciptool
, and gatttool
were deprecated by the BlueZ project in 2017. If you are following a tutorial that uses them, there is a chance that it might be out of date.
For testing it is best to use the bluetoothctl
tool.
You say that you have successfully connected and get a list of UUIDs. Was 00002A37-0000-1000-8000-00805F9B34FB
one of them?
If it is then select that inside bluetoothctl
e.g.
gatt.select-attribute 00002a37-0000-1000-8000-00805f9b34fb
If that is succussful then you should be able to read the value with:
gatt.read
Or to test notifications:
gatt.notify on
This should start data being displayed from the belt.
gatt.notify off
will stop the data being sent.
If you have this working with bluetoothctl
then reproducing it with Python should be done with confidence that the RPi and belt are able to connect successfully.
There is an example of building a BLE client with Python at:
https://stackoverflow.com/a/63751113/7721752
I noticed in your gatttool
example you are using hci1
rather than the more typical value of hci0
. This is normally the case if you have added a USB BLE dongle. I the above example you would have to change ADAPTER_PATH = '/org/bluez/hci0'
to end with hci1
.
There is also the example with Bleak at:
https://stackoverflow.com/a/72541361/7721752
For bleak
to select an alternative adapter would add the adapter address to the BleakClient
e.g.:
async with BleakClient(address, adapter="yy:yy:yy:yy:yy:yy") as client:
Upvotes: 2