hbldh / bleak

A cross platform Bluetooth Low Energy Client for Python using asyncio
MIT License
1.6k stars 280 forks source link

Characteristic with UUID could not be found #1493

Open Honusnap opened 5 months ago

Honusnap commented 5 months ago

Description

I'm using an other project called dbus-serialbattery, it use Bleak API to connect to bluetooth devices. I've narrowed the error at this command client = BleakClient(3C:A5:50:81:D7:C6)

Error => Characteristic with UUID 00002a24-0000-1000-8000-00805f9b34fb could not be found!

Using "bluetoothctl connect 3C:A5:50:81:D7:C6" work and return a "connected" message There is a PIN code for this device and it has been paired succesfully in bluetoothctl

Logs

I then created 2 test scripts ( BleakTest1.py and BleakTest2.py) with your 2 examples here : https://bleak.readthedocs.io/en/latest/usage.html and have included my own address for the "address" constant.

root@einstein:~# python3 BleakTest1.py
Traceback (most recent call last):
  File "BleakTest2.py", line 12, in <module>
    asyncio.run(main(address))
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "BleakTest2.py", line 8, in main
    async with BleakClient(address) as client:
  File "/usr/lib/python3.8/site-packages/bleak/__init__.py", line 565, in __aenter__
    await self.connect()
  File "/usr/lib/python3.8/site-packages/bleak/__init__.py", line 605, in connect
    return await self._backend.connect(**kwargs)
  File "/usr/lib/python3.8/site-packages/bleak/backends/bluezdbus/client.py", line 249, in connect
    assert_reply(reply)
  File "/usr/lib/python3.8/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort
root@einstein:~#

running BleakTest2.py return  => Characteristic with UUID 2A24 could not be found!
dlech commented 5 months ago

Bleak is meant to be run as a normal user, not root.

If you run the service explorer example, is the 2A24 characteristic listed?

Honusnap commented 5 months ago

Bleak is meant to be run as a normal user, not root.

If you run the service explorer example, is the 2A24 characteristic listed?

I can't see it, here is the output :

root@einstein:~# python3 service_explorer.py --address 3C:A5:50:81:D7:C6
2024-01-09 17:19:12,083 __main__ INFO: starting scan...
2024-01-09 17:19:13,569 __main__ INFO: connecting to device...
2024-01-09 17:19:14,768 __main__ INFO: connected
2024-01-09 17:19:14,770 __main__ INFO: [Service] 0000ffe0-0000-1000-8000-00805f9b34fb (Handle: 8): Vendor specific
2024-01-09 17:19:14,772 __main__ INFO:   [Characteristic] 0000ffe3-0000-1000-8000-00805f9b34fb (Handle: 15): Vendor specific (write-without-response,write)
2024-01-09 17:19:14,806 __main__ INFO:     [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration, Value: bytearray(b'\x00\x00')
2024-01-09 17:19:14,807 __main__ INFO:   [Characteristic] 0000ffe1-0000-1000-8000-00805f9b34fb (Handle: 9): Vendor specific (write-without-response,write,notify)
2024-01-09 17:19:14,836 __main__ INFO:     [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 11): Client Characteristic Configuration, Value: bytearray(b'\x00\x00')
2024-01-09 17:19:14,837 __main__ INFO:   [Characteristic] 0000ffe2-0000-1000-8000-00805f9b34fb (Handle: 12): Vendor specific (write-without-response,write,notify)
2024-01-09 17:19:14,866 __main__ INFO:     [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 14): Client Characteristic Configuration, Value: bytearray(b'\x00\x00')
2024-01-09 17:19:14,868 __main__ INFO: disconnecting...
2024-01-09 17:19:17,257 __main__ INFO: disconnected
dlech commented 5 months ago

Then either the device doesn't have that characteristic or BlueZ is hiding it. You could log Bluetooth packets to see if the device actually provides this characteristic.

Honusnap commented 5 months ago

2A24

This is the VendorString right ? Does it mean that if this device do not have this characteristic prevent from using it in Bleak ? I can connect to this bluetooth device from 2 different PC (windows / home assistant), from my Phone (Android) with no problem.

I used btmon, is this log usefull ?

Bluetooth monitor ver 5.55 = Note: Linux version 5.10.109-venus-12 (armv7l) 0.678686 = Note: Bluetooth subsystem version 2.22 0.678700 = New Index: DC:1A:B7:C6:96:78 (Primary,UART,hci1) [hci1] 0.678705 = Open Index: DC:1A:B7:C6:96:78 [hci1] 0.678707 = Index Info: DC:1A:B7:C6:96:78 (Broadcom Corporation) [hci1] 0.678708 = New Index: 68:4E:05:4A:51:A3 (Primary,USB,hci0) [hci0] 0.678711 = Open Index: 68:4E:05:4A:51:A3 [hci0] 0.678713 = Index Info: 68:4E:05:4.. (Realtek Semiconductor Corporation) [hci0] 0.678714 @ MGMT Open: bluetoothd (privileged) version 1.18 {0x0001} 0.678718 @ MGMT Command: Disconnect (0x0014) plen 7 {0x0001} [hci0] 2.231098 LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) < HCI Command: Disconnect (0x01|0x0006) plen 3 #1 [hci0] 2.231207 Handle: 16 Reason: Remote User Terminated Connection (0x13)

HCI Event: Command Status (0x0f) plen 4 #2 [hci0] 2.232164 Disconnect (0x01|0x0006) ncmd 2 Status: Success (0x00) HCI Event: Disconnect Complete (0x05) plen 4 #3 [hci0] 2.240171 Status: Success (0x00) Handle: 16 Reason: Connection Terminated By Local Host (0x16) @ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 2.240255 Disconnect (0x0014) plen 7 Status: Success (0x00) LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) HCI Event: Command Complete (0x0e) plen 4 #4 [hci0] 2.241149 Vendor (0x3f|0x0019) ncmd 3 Status: Success (0x00) @ MGMT Command: Start Service Disco.. (0x003a) plen 4 {0x0001} [hci0] 3.398554 Address type: 0x07 BR/EDR LE Public LE Random RSSI: invalid (0x7f) UUIDs: 0 < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #5 [hci0] 3.398709 Type: Active (0x01) Interval: 22.500 msec (0x0024) Window: 11.250 msec (0x0012) Own address type: Random (0x01) Filter policy: Accept all advertisement (0x00) HCI Event: Command Complete (0x0e) plen 4 #6 [hci0] 3.400140 LE Set Scan Parameters (0x08|0x000b) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #7 [hci0] 3.400232 Scanning: Enabled (0x01) Filter duplicates: Enabled (0x01) HCI Event: Command Complete (0x0e) plen 4 #8 [hci0] 3.401123 LE Set Scan Enable (0x08|0x000c) ncmd 2 Status: Success (0x00) < HCI Command: Inquiry (0x01|0x0001) plen 5 #9 [hci0] 3.401183 Access code: 0x9e8b33 (General Inquiry) Length: 10.24s (0x08) Num responses: 0 HCI Event: Command Status (0x0f) plen 4 #10 [hci0] 3.402116 Inquiry (0x01|0x0001) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 3.402184 Start Service Discovery (0x003a) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 3.402202 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) HCI Event: LE Meta Event (0x3e) plen 33 #11 [hci0] 3.485105 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Public (0x00) Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Data length: 21 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 RSSI: -66 dBm (0xbe) HCI Event: LE Meta Event (0x3e) plen 26 #12 [hci0] 3.487106 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Public (0x00) Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Data length: 14 Name (complete): JK-B1A24S15P RSSI: -66 dBm (0xbe) @ MGMT Event: Device Found (0x0012) plen 49 {0x0001} [hci0] 3.487155 LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) RSSI: -66 dBm (0xbe) Flags: 0x00000000 Data length: 35 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 Name (complete): JK-B1A24S15P HCI Event: LE Meta Event (0x3e) plen 37 #13 [hci0] 3.561139 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Public (0x00) Address: 38:3B:26:79:70:61 (OUI 38-3B-26) Data length: 25 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: not assigned (43863) Data: 0701434839313431 Company: not assigned (57100) Data: 310000000000 RSSI: -64 dBm (0xc0) HCI Event: LE Meta Event (0x3e) plen 29 #14 [hci0] 3.563126 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Public (0x00) Address: 38:3B:26:79:70:61 (OUI 38-3B-26) Data length: 17 Slave Conn. Interval: 0x0006 - 0x0010 TX power: 0 dBm Name (complete): BTG044 RSSI: -66 dBm (0xbe) @ MGMT Event: Device Found (0x0012) plen 56 {0x0001} [hci0] 3.563215 LE Address: 38:3B:26:79:70:61 (OUI 38-3B-26) RSSI: -66 dBm (0xbe) Flags: 0x00000000 Data length: 42 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: not assigned (43863) Data: 0701434839313431 Company: not assigned (57100) Data: 310000000000 Slave Conn. Interval: 0x0006 - 0x0010 TX power: 0 dBm Name (complete): BTG044 HCI Event: LE Meta Event (0x3e) plen 39 #15 [hci0] 3.820106 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Random (0x01) Address: C9:DF:8D:06:A1:D5 (Static) Data length: 27 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: Victron Energy BV (737) Data: 100010a1017a7c946c58aeb3d02f7d06b533bf7b RSSI: -48 dBm (0xd0) HCI Event: LE Meta Event (0x3e) plen 26 #16 [hci0] 3.822105 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Random (0x01) Address: C9:DF:8D:06:A1:D5 (Static) Data length: 14 Name (complete): MPPT 450/100 RSSI: -48 dBm (0xd0) @ MGMT Event: Device Found (0x0012) plen 55 {0x0001} [hci0] 3.822144 LE Address: C9:DF:8D:06:A1:D5 (Static) RSSI: -48 dBm (0xd0) Flags: 0x00000000 Data length: 41 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: Victron Energy BV (737) Data: 100010a1017a7c946c58aeb3d02f7d06b533bf7b Name (complete): MPPT 450/100 @ MGMT Command: Stop Discovery (0x0024) plen 1 {0x0001} [hci0] 4.229772 Address type: 0x07 BR/EDR LE Public LE Random < HCI Command: Inquiry Cancel (0x01|0x0002) plen 0 #17 [hci0] 4.229919 HCI Event: Command Complete (0x0e) plen 4 #18 [hci0] 4.233178 Inquiry Cancel (0x01|0x0002) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #19 [hci0] 4.233419 Scanning: Disabled (0x00) Filter duplicates: Disabled (0x00) HCI Event: Command Complete (0x0e) plen 4 #20 [hci0] 4.235169 LE Set Scan Enable (0x08|0x000c) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 4.235361 Stop Discovery (0x0024) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 4.235392 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Disabled (0x00) < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #21 [hci0] 4.235902 Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 60.000 msec (0x0060) Own address type: Random (0x01) Filter policy: Ignore not in white list (0x01) HCI Event: Command Complete (0x0e) plen 4 #22 [hci0] 4.237171 LE Set Scan Parameters (0x08|0x000b) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #23 [hci0] 4.237317 Scanning: Enabled (0x01) Filter duplicates: Enabled (0x01) HCI Event: Command Complete (0x0e) plen 4 #24 [hci0] 4.238147 LE Set Scan Enable (0x08|0x000c) ncmd 2 Status: Success (0x00) HCI Event: LE Meta Event (0x3e) plen 33 #25 [hci0] 4.512109 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Public (0x00) Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Data length: 21 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 RSSI: -72 dBm (0xb8) < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #26 [hci0] 4.512238 Scanning: Disabled (0x00) Filter duplicates: Disabled (0x00) HCI Event: Command Complete (0x0e) plen 4 #27 [hci0] 4.513126 LE Set Scan Enable (0x08|0x000c) ncmd 2 Status: Success (0x00) < HCI Command: LE Create Connection (0x08|0x000d) plen 25 #28 [hci0] 4.513193 Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Filter policy: White list is not used (0x00) Peer address type: Public (0x00) Peer address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Own address type: Random (0x01) Min connection interval: 10.00 msec (0x0008) Max connection interval: 20.00 msec (0x0010) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) HCI Event: Command Status (0x0f) plen 4 #29 [hci0] 4.515118 LE Create Connection (0x08|0x000d) ncmd 2 Status: Success (0x00) HCI Event: LE Meta Event (0x3e) plen 19 #30 [hci0] 4.713113 LE Connection Complete (0x01) Status: Success (0x00) Handle: 16 Role: Master (0x00) Peer address type: Public (0x00) Peer address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Connection interval: 15.00 msec (0x000c) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) Master clock accuracy: 0x00 @ MGMT Event: Device Connected (0x000b) plen 34 {0x0001} [hci0] 4.713188 LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Flags: 0x00000000 Data length: 21 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 < HCI Command: LE Read Remote Used... (0x08|0x0016) plen 2 #31 [hci0] 4.713558 Handle: 16 HCI Event: Command Complete (0x0e) plen 4 #32 [hci0] 4.714147 Vendor (0x3f|0x0019) ncmd 3 Status: Success (0x00) HCI Event: Command Complete (0x0e) plen 4 #33 [hci0] 4.715127 Vendor (0x3f|0x0019) ncmd 3 Status: Success (0x00) HCI Event: Command Status (0x0f) plen 4 #34 [hci0] 4.716157 LE Read Remote Used Features (0x08|0x0016) ncmd 2 Status: Success (0x00) HCI Event: LE Meta Event (0x3e) plen 12 #35 [hci0] 4.738151 LE Read Remote Used Features (0x04) Status: Success (0x00) Handle: 16 Features: 0x3d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 LE Encryption Extended Reject Indication Slave-initiated Features Exchange LE Ping LE Data Packet Length Extension < ACL Data TX: Handle 16 flags 0x00 dlen 7 #36 [hci0] 4.739382 ATT: Exchange MTU Request (0x02) len 2 Client RX MTU: 517 HCI Event: Number of Completed Packets (0x13) plen 5 #37 [hci0] 4.753156 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 7 #38 [hci0] 4.767506 ATT: Exchange MTU Response (0x03) len 2 Server RX MTU: 244 HCI Event: LE Meta Event (0x3e) plen 11 #39 [hci0] 4.768150 LE Data Length Change (0x07) Handle: 16 Max TX octets: 251 Max TX time: 2120 Max RX octets: 251 Max RX time: 2120 < ACL Data TX: Handle 16 flags 0x00 dlen 7 #40 [hci0] 4.769701 ATT: Read Request (0x0a) len 2 Handle: 0x0003 HCI Event: Number of Completed Packets (0x13) plen 5 #41 [hci0] 4.782151 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 18 #42 [hci0] 4.796831 ATT: Read Response (0x0b) len 13 Value: 4a4b2d42314132345331355000 < ACL Data TX: Handle 16 flags 0x00 dlen 7 #43 [hci0] 4.797298 ATT: Read Request (0x0a) len 2 Handle: 0x0005 HCI Event: Number of Completed Packets (0x13) plen 5 #44 [hci0] 4.812130 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 7 #45 [hci0] 4.826538 ATT: Read Response (0x0b) len 2 Value: 0000 < ACL Data TX: Handle 16 flags 0x00 dlen 11 #46 [hci0] 4.826916 ATT: Read By Type Request (0x08) len 6 Handle range: 0x0001-0xffff Attribute type: Unknown (0x2b3a) ACL Data RX: Handle 16 flags 0x02 dlen 16 #47 [hci0] 4.827374 LE L2CAP: Connection Parameter Update Request (0x12) ident 195 len 8 Min interval: 8 Max interval: 16 Slave latency: 0 Timeout multiplier: 500 @ MGMT Event: New Connection Param.. (0x001c) plen 16 {0x0001} [hci0] 4.827452 Store hint: Reserved (0xc6) LE Address: 01:3C:A5:50:81:D7 (OUI 01-3C-A5) Min connection interval: 8 Max connection interval: 16 Connection latency: 0 (0x0000) Supervision timeout: 500 < ACL Data TX: Handle 16 flags 0x00 dlen 10 #48 [hci0] 4.827476 LE L2CAP: Connection Parameter Update Response (0x13) ident 195 len 2 Result: Connection Parameters accepted (0x0000) < HCI Command: LE Connection Update (0x08|0x0013) plen 14 #49 [hci0] 4.827509 Handle: 16 Min connection interval: 10.00 msec (0x0008) Max connection interval: 20.00 msec (0x0010) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) HCI Event: Command Status (0x0f) plen 4 #50 [hci0] 4.829151 LE Connection Update (0x08|0x0013) ncmd 2 Status: Success (0x00) HCI Event: LE Meta Event (0x3e) plen 10 #51 [hci0] 4.830140 LE Connection Update Complete (0x03) Status: Success (0x00) Handle: 16 Connection interval: 15.00 msec (0x000c) Connection latency: 0 (0x0000) Supervision timeout: 5000 msec (0x01f4) HCI Event: Number of Completed Packets (0x13) plen 5 #52 [hci0] 4.842145 Num handles: 1 Handle: 16 Count: 1 HCI Event: Number of Completed Packets (0x13) plen 5 #53 [hci0] 4.843119 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 9 #54 [hci0] 4.856749 ATT: Error Response (0x01) len 4 Read By Type Request (0x08) Handle: 0x0001 Error: Attribute Not Found (0x0a) < ACL Data TX: Handle 16 flags 0x00 dlen 11 #55 [hci0] 4.857113 ATT: Read By Group Type Request (0x10) len 6 Handle range: 0x0001-0xffff Attribute group type: Primary Service (0x2800) HCI Event: Number of Completed Packets (0x13) plen 5 #56 [hci0] 4.872148 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 18 #57 [hci0] 4.886859 ATT: Read By Group Type Response (0x11) len 13 Attribute data length: 6 Attribute group list: 2 entries Handle range: 0x0001-0x0007 UUID: Generic Access Profile (0x1800) Handle range: 0x0008-0xffff UUID: Unknown (0xffe0) < ACL Data TX: Handle 16 flags 0x00 dlen 7 #58 [hci0] 4.921105 ATT: Read Request (0x0a) len 2 Handle: 0x0011 HCI Event: Number of Completed Packets (0x13) plen 5 #59 [hci0] 4.932133 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 7 #60 [hci0] 4.946756 ATT: Read Response (0x0b) len 2 Value: 0000 < ACL Data TX: Handle 16 flags 0x00 dlen 7 #61 [hci0] 4.959767 ATT: Read Request (0x0a) len 2 Handle: 0x000e HCI Event: Number of Completed Packets (0x13) plen 5 #62 [hci0] 4.962127 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 7 #63 [hci0] 4.976757 ATT: Read Response (0x0b) len 2 Value: 0000 < ACL Data TX: Handle 16 flags 0x00 dlen 7 #64 [hci0] 4.990131 ATT: Read Request (0x0a) len 2 Handle: 0x000b HCI Event: Number of Completed Packets (0x13) plen 5 #65 [hci0] 5.007133 Num handles: 1 Handle: 16 Count: 1 ACL Data RX: Handle 16 flags 0x02 dlen 7 #66 [hci0] 5.021669 ATT: Read Response (0x0b) len 2 Value: 0000 @ MGMT Command: Disconnect (0x0014) plen 7 {0x0001} [hci0] 7.229531 LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) < HCI Command: Disconnect (0x01|0x0006) plen 3 #67 [hci0] 7.229639 Handle: 16 Reason: Remote User Terminated Connection (0x13) HCI Event: Command Status (0x0f) plen 4 #68 [hci0] 7.231131 Disconnect (0x01|0x0006) ncmd 2 Status: Success (0x00) HCI Event: Disconnect Complete (0x05) plen 4 #69 [hci0] 7.242133 Status: Success (0x00) Handle: 16 Reason: Connection Terminated By Local Host (0x16) @ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 7.242182 Disconnect (0x0014) plen 7 Status: Success (0x00) LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) HCI Event: Command Complete (0x0e) plen 4 #70 [hci0] 7.243117 Vendor (0x3f|0x0019) ncmd 3 Status: Success (0x00) @ MGMT Command: Start Discovery (0x0023) plen 1 {0x0001} [hci0] 8.229507 Address type: 0x07 BR/EDR LE Public LE Random < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #71 [hci0] 8.229662 Type: Active (0x01) Interval: 22.500 msec (0x0024) Window: 11.250 msec (0x0012) Own address type: Random (0x01) Filter policy: Accept all advertisement (0x00) HCI Event: Command Complete (0x0e) plen 4 #72 [hci0] 8.231159 LE Set Scan Parameters (0x08|0x000b) ncmd 2 Status: Success (0x00) < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #73 [hci0] 8.231283 Scanning: Enabled (0x01) Filter duplicates: Enabled (0x01) HCI Event: Command Complete (0x0e) plen 4 #74 [hci0] 8.232122 LE Set Scan Enable (0x08|0x000c) ncmd 2 Status: Success (0x00) < HCI Command: Inquiry (0x01|0x0001) plen 5 #75 [hci0] 8.232194 Access code: 0x9e8b33 (General Inquiry) Length: 10.24s (0x08) Num responses: 0 HCI Event: Command Status (0x0f) plen 4 #76 [hci0] 8.233115 Inquiry (0x01|0x0001) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 8.233188 Start Discovery (0x0023) plen 1 Status: Success (0x00) Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 8.233204 Address type: 0x07 BR/EDR LE Public LE Random Discovery: Enabled (0x01) HCI Event: LE Meta Event (0x3e) plen 37 #77 [hci0] 8.241105 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Public (0x00) Address: 38:3B:26:79:70:61 (OUI 38-3B-26) Data length: 25 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: not assigned (43863) Data: 0701434839313431 Company: not assigned (57612) Data: 310000000000 RSSI: -66 dBm (0xbe) HCI Event: LE Meta Event (0x3e) plen 29 #78 [hci0] 8.243106 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Public (0x00) Address: 38:3B:26:79:70:61 (OUI 38-3B-26) Data length: 17 Slave Conn. Interval: 0x0006 - 0x0010 TX power: 0 dBm Name (complete): BTG044 RSSI: -66 dBm (0xbe) @ MGMT Event: Device Found (0x0012) plen 56 {0x0001} [hci0] 8.243152 LE Address: 38:3B:26:79:70:61 (OUI 38-3B-26) RSSI: -66 dBm (0xbe) Flags: 0x00000000 Data length: 42 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: not assigned (43863) Data: 0701434839313431 Company: not assigned (57612) Data: 310000000000 Slave Conn. Interval: 0x0006 - 0x0010 TX power: 0 dBm Name (complete): BTG044 HCI Event: LE Meta Event (0x3e) plen 33 #79 [hci0] 8.689115 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Public (0x00) Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Data length: 21 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 RSSI: -72 dBm (0xb8) HCI Event: LE Meta Event (0x3e) plen 26 #80 [hci0] 8.691106 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Public (0x00) Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) Data length: 14 Name (complete): JK-B1A24S15P RSSI: -72 dBm (0xb8) @ MGMT Event: Device Found (0x0012) plen 49 {0x0001} [hci0] 8.691152 LE Address: 3C:A5:50:81:D7:C6 (OUI 3C-A5-50) RSSI: -72 dBm (0xb8) Flags: 0x00000000 Data length: 35 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported 16-bit Service UUIDs (partial): 2 entries Unknown (0xffe0) Tencent Holdings Limited. (0xfee7) Company: not assigned (64214) Data: 88a03ca55081d7c6 Name (complete): JK-B1A24S15P HCI Event: LE Meta Event (0x3e) plen 39 #81 [hci0] 8.842105 LE Advertising Report (0x02) Num reports: 1 Event type: Connectable undirected - ADV_IND (0x00) Address type: Random (0x01) Address: C9:DF:8D:06:A1:D5 (Static) Data length: 27 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: Victron Energy BV (737) Data: 100010a1017f7c94840d938dd7fbd1a1df798615 RSSI: -40 dBm (0xd8) HCI Event: LE Meta Event (0x3e) plen 26 #82 [hci0] 8.844106 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Random (0x01) Address: C9:DF:8D:06:A1:D5 (Static) Data length: 14 Name (complete): MPPT 450/100 RSSI: -40 dBm (0xd8) @ MGMT Event: Device Found (0x0012) plen 55 {0x0001} [hci0] 8.844152 LE Address: C9:DF:8D:06:A1:D5 (Static) RSSI: -40 dBm (0xd8) Flags: 0x00000000 Data length: 41 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Company: Victron Energy BV (737) Data: 100010a1017f7c94840d938dd7fbd1a1df798615 Name (complete): MPPT 450/100 root@einstein:~#

Honusnap commented 5 months ago

Then either the device doesn't have that characteristic or BlueZ is hiding it. You could log Bluetooth packets to see if the device actually provides this characteristic.

Hello, I've replaced the device with a newer version of this same device and .. it work. Would you like me to get some more info on this non working bluetooth device to improve connection to those devices ?

mr-manuel commented 3 months ago

@Honusnap if you can proceed with this others would be very thankful!

https://github.com/Louisvdw/dbus-serialbattery/issues/819

mr-manuel commented 3 months ago

Here some data from the BlueZ (version 5.55) dbus from a JKBMS where "00002a24-0000-1000-8000-00805f9b34fb" is not found. This indicates that the data is already missing in BlueZ right?

manuel@raspberrypi2:~# dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0/dev_20_22_08_25_17_41 org.freedesktop.DBus.Properties.GetAll string:"org.bluez.Device1"
method return time=1708694825.738213 sender=:1.225 -> destination=:1.284 serial=102 reply_serial=2
   array [
      dict entry(
         string "Address"
         variant             string "20:22:08:25:17:41"
      )
      dict entry(
         string "AddressType"
         variant             string "public"
      )
      dict entry(
         string "Name"
         variant             string "JK_BD4A24S04"
      )
      dict entry(
         string "Alias"
         variant             string "JK_BD4A24S04"
      )
      dict entry(
         string "Paired"
         variant             boolean false
      )
      dict entry(
         string "Trusted"
         variant             boolean true
      )
      dict entry(
         string "Blocked"
         variant             boolean false
      )
      dict entry(
         string "LegacyPairing"
         variant             boolean false
      )
      dict entry(
         string "Connected"
         variant             boolean true
      )
      dict entry(
         string "UUIDs"
         variant             array [
               string "0000ffe0-0000-1000-8000-00805f9b34fb"
            ]
      )
      dict entry(
         string "Adapter"
         variant             object path "/org/bluez/hci0"
      )
      dict entry(
         string "ManufacturerData"
         variant             array [
               dict entry(
                  uint16 19274
                  variant                      array of bytes [
                        00 01
                     ]
               )
            ]
      )
      dict entry(
         string "ServicesResolved"
         variant             boolean true
      )
      dict entry(
         string "AdvertisingFlags"
         variant             array of bytes [
               06
            ]
      )
   ]

manuel@raspberrypi2:~# bluetoothctl info 20:22:08:25:17:41
Device 20:22:08:25:17:41 (public)
        Name: JK_BD4A24S04
        Alias: JK_BD4A24S04
        Paired: no
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Unknown                   (0000ffe0-0000-1000-8000-00805f9b34fb)
        ManufacturerData Key: 0x4b4a
        ManufacturerData Value:
  00 01                                            ..
        AdvertisingFlags:
  06                                               .