Battery service (180F) not available
See original GitHub issueNot sure if this is a Linux/Chrome bug or related to #94. I’m running on Ubuntu 18.04 with Chrome. Heartrate test seems to work fine, so I’m confused why there are issues with Battery simulation.
I’m testing through this page: https://googlechrome.github.io/samples/web-bluetooth/battery-level.html Seeing the following “Live Output”:
Requesting Bluetooth Device...
Connecting to GATT Server...
Getting Battery Service...
Argh! NotFoundError: No Services matching UUID 0000180f-0000-1000-8000-00805f9b34fb found in Device.
I found that exact 0000180f-...
battery_service UUID in the android code here:
https://github.com/WebBluetoothCG/ble-test-peripheral-android/blob/277fbf7c586d579a9d270d71f7891144dea5e4d5/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java#L45
The reset energy app works: https://googlechrome.github.io/samples/web-bluetooth/reset-energy.html
Live output of:
Requesting Bluetooth Device...
Connecting to GATT Server...
Getting Heart Rate Service...
Getting Heart Rate Control Point Characteristic...
Writing Heart Rate Control Point Characteristic...
> Energy expended has been reset.
Which successfully resets the energy expended
value to zero in the android app.
Trying to troubleshoot with bluetoothctl
(Linux CLI utility). Seeing reasonable GATT listing “Heart Rate Control Point” (2A39) when opening the heartrate tab in the android app:
menu gatt
list-attributes
Primary Service
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0001
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
Characteristic
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0001/char0002
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
Primary Service
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028
0000180d-0000-1000-8000-00805f9b34fb
Heart Rate
Characteristic
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028/char0029
00002a37-0000-1000-8000-00805f9b34fb
Heart Rate Measurement
Descriptor
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028/char0029/desc002b
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Descriptor
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028/char0029/desc002c
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
Characteristic
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028/char002d
00002a38-0000-1000-8000-00805f9b34fb
Body Sensor Location
Characteristic
/org/bluez/hci0/dev_65_56_A7_7E_47_2C/service0028/char002f
00002a39-0000-1000-8000-00805f9b34fb
Heart Rate Control Point
But when switching over to the Battery tab, I don’t see the battery service listed.
menu gatt
list-attributes
Primary Service
/org/bluez/hci0/dev_5C_91_FB_35_1C_CE/service0001
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
Characteristic
/org/bluez/hci0/dev_5C_91_FB_35_1C_CE/service0001/char0002
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
Upon a fresh connection, I do see the 180F
battery status UUID logged with the [CHG] tag, but it does not persist with list-attributes
.
[miles g5]# connect 5C:91:FB:35:1C:CE
Attempting to connect to 5C:91:FB:35:1C:CE
[CHG] Device 5C:91:FB:35:1C:CE Connected: yes
Connection successful
[CHG] Device 54:59:49:F9:57:73 ServicesResolved: no
[CHG] Device 54:59:49:F9:57:73 Connected: no
[DEL] Characteristic
/org/bluez/hci0/dev_54_59_49_F9_57_73/service0001/char0002
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
[DEL] Primary Service
/org/bluez/hci0/dev_54_59_49_F9_57_73/service0001
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[DEL] Device 54:59:49:F9:57:73 miles g5
[NEW] Primary Service
/org/bluez/hci0/dev_5C_91_FB_35_1C_CE/service0001
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Characteristic
/org/bluez/hci0/dev_5C_91_FB_35_1C_CE/service0001/char0002
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
[CHG] Device 5C:91:FB:35:1C:CE UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:91:FB:35:1C:CE UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:91:FB:35:1C:CE UUIDs: 0000180f-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:91:FB:35:1C:CE ServicesResolved: yes
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
FWIW,
sudo systemctl edit bluetooth.service
with the following contents will probably work better for most people.If changes are made directly to
/lib/systemd/system/bluetooth.service
, they will be overwritten whenever thebluez
package is updated.It is not an “empty” command, it means delete all previous commands. Since the
dbus
type can only have one command, we have to delete the old one before we can add a new one. In the end there is still exactly one command.