Skip to contentSkip to conversation

Battery1 vs. GATT reporting

DISCUSSION Ed Beroset 3 participants 9 messages Feb 28, 2022 – May 17, 2022 Bluetooth drivers

lore
Share & tools
lore

Ed Beroset

author
#0 lore raw

In https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=713f6f09 a flag named "external" was added which, if I'm understanding correctly, is supposed to mark the Battery1 profile as safe to also share via GATT.
However, I was recently working on an application that relies on the
GATT API for battery power and found that it only seemed to work as expected (reporting via both) if I set the flag to false rather than true as in the commit. I looked through the code and it all looks correct, but my observation indicates that perhaps the sense of the flag is somehow inverted.

Here's the project I was working on, with the relevant bug report.
https://github.com/AsteroidOS/libasteroid/issues/13

So can someone verify that:
1. the interface is intended to be shared via GATT and Battery1
2. that it does not work that way today

Ed

#1 lore raw

Hi Ed,

Your understanding is correct about the purpose of that flag. So I can confirm that (1) is true. For (2), I can confirm otherwise, since I am able to get both battery values from GATT API and Battery1 API. Here is my output:

```
// pair and connect to an LE device with battery service first (e.g an LE Mouse)
// [bluetoothctl]# gatt.list-attributes
// [bluetoothctl]# gatt.select-attribute
/org/bluez/hci0/dev_C6_XX/service000e/char000f

// via GATT API
[BluetoothMouse3600:/service000e/char000f]# gatt.read
Attempting to read /org/bluez/hci0/dev_C6_XX/service000e/char000f
[CHG] Attribute /org/bluez/hci0/dev_C6_XX/service000e/char000f Value:
  4d                                               M
  4d                                               M

// via Battery API
[BluetoothMouse3600:/service000e/char000f]# info
Device C6:XX (random)
        Name: BluetoothMouse3600
        Alias: BluetoothMouse3600
        ...
        Battery Percentage: 0x4e (78)
[BluetoothMouse3600:/service000e/char000f]#
```

Could you try the same with bluetoothctl and share the output?

Quoted 21 lines · Ed Beroset

In
https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=713f6f09 a flag named "external" was added which, if I'm understanding correctly, is supposed to mark the Battery1 profile as safe to also share via GATT.
However, I was recently working on an application that relies on the
GATT API for battery power and found that it only seemed to work as expected (reporting via both) if I set the flag to false rather than true as in the commit. I looked through the code and it all looks correct, but my observation indicates that perhaps the sense of the flag is somehow inverted.

Here's the project I was working on, with the relevant bug report.
https://github.com/AsteroidOS/libasteroid/issues/13

So can someone verify that:
1. the interface is intended to be shared via GATT and Battery1
2. that it does not work that way today

Ed

author
#2 lore raw
Quoted 30 lines · Sonny Sasaka

Hi Ed,

Your understanding is correct about the purpose of that flag. So I can confirm that (1) is true. For (2), I can confirm otherwise, since I am able to get both battery values from GATT API and Battery1 API. Here is my output:

```
// pair and connect to an LE device with battery service first (e.g an LE Mouse)
// [bluetoothctl]# gatt.list-attributes
// [bluetoothctl]# gatt.select-attribute
/org/bluez/hci0/dev_C6_XX/service000e/char000f

// via GATT API
[BluetoothMouse3600:/service000e/char000f]# gatt.read
Attempting to read /org/bluez/hci0/dev_C6_XX/service000e/char000f
[CHG] Attribute /org/bluez/hci0/dev_C6_XX/service000e/char000f Value:
   4d                                               M
   4d                                               M

// via Battery API
[BluetoothMouse3600:/service000e/char000f]# info
Device C6:XX (random)
         Name: BluetoothMouse3600
         Alias: BluetoothMouse3600
         ...
         Battery Percentage: 0x4e (78)
[BluetoothMouse3600:/service000e/char000f]#
```
Quoted 1 line

Could you try the same with bluetoothctl and share the output?

I'm not very sure of how to use bluetoothctl (no man page and I wasn't able to find a lot in my searches on the internet) but what I did was to pair and list the attributes using gatt.list-attributes, but I didn't find anything that I could identify as a battery service or battery attribute. I looked for 180f or 2a19 and found neither:

turgeon]# gatt.list-attributes 43:43:A0:12:1F:AC Primary Service (Handle 0x0000)

	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049
	00005071-0000-0000-0000-00a57e401d05
	Vendor specific
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049/char004a
	00005001-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049/char004a/desc004c
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041
	00006071-0000-0000-0000-00a57e401d05
	Vendor specific
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045
	00006002-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045/desc0048
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045/desc0047
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0042
	00006001-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0042/desc0044
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029
	00007071-0000-0000-0000-00a57e401d05
	Vendor specific
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0039
	00007006-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0039/desc003b
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0036
	00007005-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0036/desc0038
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0033
	00007004-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0033/desc0035
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0030
	00007003-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0030/desc0032
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002d
	00007002-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002d/desc002f
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002a
	00007001-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002a/desc002c
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c
	00008071-0000-0000-0000-00a57e401d05
	Vendor specific
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0026
	00008003-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0026/desc0028
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0023
	00008004-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0023/desc0025
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0020
	00008002-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0020/desc0022
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char001d
	00008001-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char001d/desc001f
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015
	00009071-0000-0000-0000-00a57e401d05
	Vendor specific
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0019
	00009002-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0019/desc001b
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0016
	00009001-0000-0000-0000-00a57e401d05
	Vendor specific
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0016/desc0018
	00002900-0000-1000-8000-00805f9b34fb
	Characteristic Extended Properties
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0012
	0000180a-0000-1000-8000-00805f9b34fb
	Device Information
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0012/char0013
	00002a50-0000-1000-8000-00805f9b34fb
	PnP ID
Primary Service (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008
	00001801-0000-1000-8000-00805f9b34fb
	Generic Attribute Profile
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char000e
	00002b3a-0000-1000-8000-00805f9b34fb
	Server Supported Features
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char000c
	00002b29-0000-1000-8000-00805f9b34fb
	Client Supported Features
Characteristic (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char0009
	00002a05-0000-1000-8000-00805f9b34fb
	Service Changed
Descriptor (Handle 0x0000)
	/org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char0009/desc000b
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration


However when I try info, it correctly reports both the battery service and the battery percentage

	Battery Percentage: 0x2b (43)

So I'm not sure how to make the step from gatt.list-attributes to gatt.select-attributes. Any guidance?

Ed

#3 lore raw

Hi Ed,

What I do is call gatt.select-attribute on the characteristic called "Battery Level", but it is not shown in your case. So maybe this is the bug that you are encountering. What is the exact version of your BlueZ (commit sha if possible)? Could you also try tip of tree to see if this is already fixed?

Quoted 224 lines · Ed Beroset
Quoted 30 lines · Sonny Sasaka

Hi Ed,

Your understanding is correct about the purpose of that flag. So I can confirm that (1) is true. For (2), I can confirm otherwise, since I am able to get both battery values from GATT API and Battery1 API. Here is my output:

```
// pair and connect to an LE device with battery service first (e.g an LE Mouse)
// [bluetoothctl]# gatt.list-attributes
// [bluetoothctl]# gatt.select-attribute
/org/bluez/hci0/dev_C6_XX/service000e/char000f

// via GATT API
[BluetoothMouse3600:/service000e/char000f]# gatt.read
Attempting to read /org/bluez/hci0/dev_C6_XX/service000e/char000f
[CHG] Attribute /org/bluez/hci0/dev_C6_XX/service000e/char000f Value:
   4d                                               M
   4d                                               M

// via Battery API
[BluetoothMouse3600:/service000e/char000f]# info
Device C6:XX (random)
         Name: BluetoothMouse3600
         Alias: BluetoothMouse3600
         ...
         Battery Percentage: 0x4e (78)
[BluetoothMouse3600:/service000e/char000f]#
```
Quoted 1 line

Could you try the same with bluetoothctl and share the output?

I'm not very sure of how to use bluetoothctl (no man page and I wasn't able to find a lot in my searches on the internet) but what I did was to pair and list the attributes using gatt.list-attributes, but I didn't find anything that I could identify as a battery service or battery attribute. I looked for 180f or 2a19 and found neither:

[sturgeon] # gatt.list-attributes 43:43:A0:12:1F:AC
Primary Service (Handle 0x0000)

        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049
        00005071-0000-0000-0000-00a57e401d05
        Vendor specific
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049/char004a
        00005001-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0049/char004a/desc004c
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041
        00006071-0000-0000-0000-00a57e401d05
        Vendor specific
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045
        00006002-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045/desc0048
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0045/desc0047
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0042
        00006001-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0041/char0042/desc0044
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029
        00007071-0000-0000-0000-00a57e401d05
        Vendor specific
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0039
        00007006-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0039/desc003b
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0036
        00007005-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0036/desc0038
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0033
        00007004-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0033/desc0035
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0030
        00007003-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char0030/desc0032
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002d
        00007002-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002d/desc002f
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002a
        00007001-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0029/char002a/desc002c
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c
        00008071-0000-0000-0000-00a57e401d05
        Vendor specific
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0026
        00008003-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0026/desc0028
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0023
        00008004-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0023/desc0025
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0020
        00008002-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char0020/desc0022
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char001d
        00008001-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service001c/char001d/desc001f
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015
        00009071-0000-0000-0000-00a57e401d05
        Vendor specific
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0019
        00009002-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0019/desc001b
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0016
        00009001-0000-0000-0000-00a57e401d05
        Vendor specific
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0015/char0016/desc0018
        00002900-0000-1000-8000-00805f9b34fb
        Characteristic Extended Properties
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0012
        0000180a-0000-1000-8000-00805f9b34fb
        Device Information
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0012/char0013
        00002a50-0000-1000-8000-00805f9b34fb
        PnP ID
Primary Service (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008
        00001801-0000-1000-8000-00805f9b34fb
        Generic Attribute Profile
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char000e
        00002b3a-0000-1000-8000-00805f9b34fb
        Server Supported Features
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char000c
        00002b29-0000-1000-8000-00805f9b34fb
        Client Supported Features
Characteristic (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char0009
        00002a05-0000-1000-8000-00805f9b34fb
        Service Changed
Descriptor (Handle 0x0000)
        /org/bluez/hci0/dev_43_43_A0_12_1F_AC/service0008/char0009/desc000b
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration

However when I try info, it correctly reports both the battery service and the battery percentage

        Battery Percentage: 0x2b (43)

So I'm not sure how to make the step from gatt.list-attributes to gatt.select-attributes. Any guidance?

Ed

author
#4 lore raw
Quoted 7 lines · Sonny Sasaka

Hi Ed,

What I do is call gatt.select-attribute on the characteristic called "Battery Level", but it is not shown in your case. So maybe this is the bug that you are encountering. What is the exact version of your BlueZ (commit sha if possible)? Could you also try tip of tree to see if this is already fixed?

Hi Sonny,

I'm sorry, I should have noted that this is with the tip of tree, commit bf09e1f048. Thanks for your help with this!

Ed

author
#5 lore raw
Quoted 9 lines · Ed Beroset
Quoted 7 lines · Sonny Sasaka

Hi Ed,

What I do is call gatt.select-attribute on the characteristic called "Battery Level", but it is not shown in your case. So maybe this is the bug that you are encountering. What is the exact version of your BlueZ (commit sha if possible)? Could you also try tip of tree to see if this is already fixed?

Quoted 3 lines

Hi Sonny,

I'm sorry, I should have noted that this is with the tip of tree, commit bf09e1f048.  Thanks for your help with this!

I am trying this from a different computer today and I find that now the Battery Service and Battery Level characteristic are showing up, even on the same devices I was reading the other day. Not sure what's going on, but I am investigating further. At the moment, it seems more likely that the problem is either with my devices or with my software. I just wanted to report back to avoid having you all waste your time. When I figure this out, I'll send another update. Thanks for the help so far.

Ed

author
#6 lore raw
Quoted 10 lines · Ed Beroset
Quoted 9 lines · Ed Beroset
Quoted 7 lines · Sonny Sasaka

Hi Ed,

What I do is call gatt.select-attribute on the characteristic called "Battery Level", but it is not shown in your case. So maybe this is the bug that you are encountering. What is the exact version of your BlueZ (commit sha if possible)? Could you also try tip of tree to see if this is already fixed?

Quoted 5 lines
Quoted 3 lines

Hi Sonny,

I'm sorry, I should have noted that this is with the tip of tree, commit bf09e1f048.  Thanks for your help with this!

I am trying this from a different computer today and I find that now the Battery Service and Battery Level characteristic are showing up, even on the same devices I was reading the other day.  Not sure what's going on, but I am investigating further.  At the moment, it seems more likely that the problem is either with my devices or with my software.  I just wanted to report back to avoid having you all waste your time.  When I figure this out, I'll send another update.  Thanks for the help so far.

OK, it's been a while, but the problem was eventually tracked not to BlueZ but a Qt component I was using. Essentially, changes in BlueZ were being tracked by changes in Qt, but there was a problem with the Qt implementation starting with BlueZ version 5.55. No change required in BlueZ, and already fixed in Qt, but I thought I'd circle back around and let you all know the resolution.

https://bugreports.qt.io/browse/QTBUG-70222

Ed

#7 lore raw

Thanks for circling back, I appreciate it!

Quoted 35 lines · Ed Beroset
Quoted 15 lines · Ed Beroset
Quoted 9 lines · Ed Beroset
Quoted 7 lines · Sonny Sasaka

Hi Ed,

What I do is call gatt.select-attribute on the characteristic called "Battery Level", but it is not shown in your case. So maybe this is the bug that you are encountering. What is the exact version of your BlueZ (commit sha if possible)? Could you also try tip of tree to see if this is already fixed?

Quoted 4 lines

Hi Sonny,

I'm sorry, I should have noted that this is with the tip of tree, commit bf09e1f048. Thanks for your help with this!

Quoted 7 lines

I am trying this from a different computer today and I find that now the Battery Service and Battery Level characteristic are showing up, even on the same devices I was reading the other day. Not sure what's going on, but I am investigating further. At the moment, it seems more likely that the problem is either with my devices or with my software. I just wanted to report back to avoid having you all waste your time. When I figure this out, I'll send another update. Thanks for the help so far.

OK, it's been a while, but the problem was eventually tracked not to BlueZ but a Qt component I was using. Essentially, changes in BlueZ were being tracked by changes in Qt, but there was a problem with the Qt implementation starting with BlueZ version 5.55. No change required in BlueZ, and already fixed in Qt, but I thought I'd circle back around and let you all know the resolution.

https://bugreports.qt.io/browse/QTBUG-70222

Ed

#8 lore raw
In reply to Ed Beroset

Hi Ed,

Quoted 12 lines · Ed Beroset

In
https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=713f6f09 a flag named "external" was added which, if I'm understanding correctly, is supposed to mark the Battery1 profile as safe to also share via GATT.
However, I was recently working on an application that relies on the
GATT API for battery power and found that it only seemed to work as expected (reporting via both) if I set the flag to false rather than true as in the commit. I looked through the code and it all looks correct, but my observation indicates that perhaps the sense of the flag is somehow inverted.

Quoted 6 lines

Here's the project I was working on, with the relevant bug report.
https://github.com/AsteroidOS/libasteroid/issues/13

So can someone verify that:
1. the interface is intended to be shared via GATT and Battery1
2. that it does not work that way today

Did you check if that was not fixed already? It seems to work alright with git latest using bluetoothctl:

[NEW] Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0020
0000180f-0000-1000-8000-00805f9b34fb
Battery Service

Signature · 1 line
Luiz Augusto von Dentz