Open Egidio92 opened 2 years ago
Have you tried the troubleshooting recommendations in the Bleak docs (enable logging, capturing Bluetooth packets)?
Thanks for the quick response. I tried to install Xcode to acquire bluetooth packets but I don't have enough memory space ... Instead from the logs I get:
2022-06-08 23:55:11,255 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManagerDidUpdateState_
2022-06-08 23:55:11,256 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Bluetooth powered on
2022-06-08 23:55:11,308 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: 'isScanning' changed
2022-06-08 23:55:11,467 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:11,468 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device A70B7C91-2959-4105-9A26-2E7E5875B04E: None @ RSSI: -93 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:11,484 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:11,485 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:11,486 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 69D6FD30-01D0-4310-AEDF-B7D91EB02850: None @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:11,486 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 69D6FD30-01D0-4310-AEDF-B7D91EB02850: None @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:11,773 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:11,774 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 8D1CE81E-1EBD-4BBA-A0DD-B4DA13AE7A01: None @ RSSI: -94 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:12,650 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:12,651 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:12,652 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device ACF7BD93-CAD1-427E-B056-A5CE4CEAA28F: None @ RSSI: -36 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:12,652 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device ACF7BD93-CAD1-427E-B056-A5CE4CEAA28F: None @ RSSI: -36 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:12,949 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:12,951 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 61F94717-1906-4C8A-BED8-6C9017021397: None @ RSSI: -36 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:12,962 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:12,962 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:12,963 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device D7888FE2-72E6-4407-94F3-2EB5CC43F761: None @ RSSI: -90 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:12,964 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device D7888FE2-72E6-4407-94F3-2EB5CC43F761: None @ RSSI: -92 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:14,201 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:14,202 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 2F11A1E4-E957-4A02-9A4D-03BBA7E6D23A: None @ RSSI: -92 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:14,204 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:14,205 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 2F11A1E4-E957-4A02-9A4D-03BBA7E6D23A: [TV] Samsung 7 Series (55) @ RSSI: -91 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName', 'kCBAdvDataChannel'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:15,031 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:15,032 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device A70B7C91-2959-4105-9A26-2E7E5875B04E: None @ RSSI: -90 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:15,355 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:15,356 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 86FC5AD4-BF42-4112-B3D7-48C4CA325CB0: None @ RSSI: -92 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:16,866 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:16,867 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device A84B10CE-3E4C-4C93-BCB3-5544E9C34979: None @ RSSI: -80 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:16,869 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:16,869 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device A84B10CE-3E4C-4C93-BCB3-5544E9C34979: Polar Unite 80548720 @ RSSI: -81 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName', 'kCBAdvDataChannel'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:17,135 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDiscoverPeripheral_advertisementData_RSSI_
2022-06-08 23:55:17,136 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 775A199B-A238-4AB7-86EB-4EFF8C404F9A: None @ RSSI: -43 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataManufacturerData', 'kCBAdvDataServiceData'])>) and Central: <CBCentralManager: 0x7fedf9cc8180>
2022-06-08 23:55:17,136 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: 'isScanning' changed
2022-06-08 23:55:17,137 bleak.backends.corebluetooth.client DEBUG: CentralManagerDelegate at <CentralManagerDelegate: 0x7fedf9cf77c0>
2022-06-08 23:55:17,137 bleak.backends.corebluetooth.client DEBUG: Connecting to BLE device @ 775A199B-A238-4AB7-86EB-4EFF8C404F9A
2022-06-08 23:55:17,914 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didConnectPeripheral_
2022-06-08 23:55:17,914 bleak.backends.corebluetooth.client DEBUG: Retrieving services...
2022-06-08 23:55:17,915 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverServices_
2022-06-08 23:55:17,916 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Services discovered
2022-06-08 23:55:17,916 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 180A
2022-06-08 23:55:18,073 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverCharacteristicsForService_error_
2022-06-08 23:55:18,074 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2022-06-08 23:55:18,074 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A25
2022-06-08 23:55:18,075 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,076 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 15
2022-06-08 23:55:18,076 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A27
2022-06-08 23:55:18,077 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,077 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 17
2022-06-08 23:55:18,078 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A28
2022-06-08 23:55:18,078 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,078 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 19
2022-06-08 23:55:18,079 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A23
2022-06-08 23:55:18,079 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,079 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 21
2022-06-08 23:55:18,080 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A50
2022-06-08 23:55:18,080 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,080 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 23
2022-06-08 23:55:18,081 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 181D
2022-06-08 23:55:18,209 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverCharacteristicsForService_error_
2022-06-08 23:55:18,209 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2022-06-08 23:55:18,210 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A2B
2022-06-08 23:55:18,211 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,211 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 26
2022-06-08 23:55:18,212 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A9E
2022-06-08 23:55:18,212 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,213 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 28
2022-06-08 23:55:18,213 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A9D
2022-06-08 23:55:18,268 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,269 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 30
2022-06-08 23:55:18,270 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 00002A2F-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,298 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,299 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 33
2022-06-08 23:55:18,299 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 00001530-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,465 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverCharacteristicsForService_error_
2022-06-08 23:55:18,465 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2022-06-08 23:55:18,466 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 00001531-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,493 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,494 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 37
2022-06-08 23:55:18,494 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 00001532-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,495 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,495 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 40
2022-06-08 23:55:18,496 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A04
2022-06-08 23:55:18,523 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,524 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 42
2022-06-08 23:55:18,524 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 00001542-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,553 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,554 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 45
2022-06-08 23:55:18,554 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 00001543-0000-3512-2118-0009AF100700
2022-06-08 23:55:18,583 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didDiscoverDescriptorsForCharacteristic_error_
2022-06-08 23:55:18,583 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 48
2022-06-08 23:55:18,584 bleak.backends.corebluetooth.client DEBUG: Services resolved for BleakClientCoreBluetooth (775A199B-A238-4AB7-86EB-4EFF8C404F9A)
Connected: True
2022-06-08 23:55:18,613 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didUpdateNotificationStateForCharacteristic_error_
2022-06-08 23:55:18,613 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Character Notify Update
2022-06-08 23:55:48,644 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: peripheral_didUpdateNotificationStateForCharacteristic_error_
2022-06-08 23:55:48,644 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Character Notify Update
2022-06-08 23:55:48,687 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: centralManager_didDisconnectPeripheral_error_
2022-06-08 23:55:48,687 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Peripheral Device disconnected!
On the other hand, if I launch from spyder without enable logging, I get:
Connected: True
Traceback (most recent call last):
File "/Users/Egidio/Documents/Python/Tesi/BLE/BLE17.py", line 42, in <module>
asyncio.run(
File "/Users/Egidio/opt/anaconda3/envs/BLE/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Users/Egidio/opt/anaconda3/envs/BLE/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/Egidio/Documents/Python/Tesi/BLE/BLE17.py", line 37, in main
await client.stop_notify(char_uuid)
File "/Users/Egidio/opt/anaconda3/envs/BLE/lib/python3.9/site-packages/bleak/backends/corebluetooth/client.py", line 406, in stop_notify
await self._delegate.stop_notifications(characteristic.obj)
File "/Users/Egidio/opt/anaconda3/envs/BLE/lib/python3.9/site-packages/bleak/backends/corebluetooth/PeripheralDelegate.py", line 230, in stop_notifications
await future
bleak.exc.BleakError: disconnected
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
I think the problem is related to caches or in general to the saving session... What do you think about it? Thanks again
tried to install Xcode to acquire bluetooth packets but I don't have enough memory space
You don't need to install XCode, just the hardware utilities from the apple developer website
I think the problem is related to caches or in general to the saving session... What do you think about it?
If the device is listed in the Bluetooth system settings, try removing it there.
Hi @Egidio92 ... I'm with the same problem, the code run on windows but on mac os, when I call the start notify for the connected BleClient, I receive the same error that you: ... await Future ...
Did you discover or had a workaround for that error?
Thanks in an advance...
start_notify appears to try to open a SPP in MacOS instead of subscription to a GATT notification. What I'm seeing on an ESP32
I (66892) BLE: 8c 85 90 7c 61 27
I (66966) BLE: ESP_GATTS_MTU_EVT, MTU 500
I (67126) BLE: update connection params status = 0, min_int = 16, max_int = 32,conn_int = 32,latency = 0, timeout = 400
W (68125) BT_HCI: hcif disc complete: hdl 0x1, rsn 0x13
I (68126) BLE: ESP_GATTS_DISCONNECT_EVT, reason = 0x13
I (68132) BLE: Advertising start successfully
and bleak
bleak.exc.BleakError: Failed to update the notification status for characteristic 58: Error Domain=CBATTErrorDomain Code=10 "The attribute could not be found." UserInfo={NSLocalizedDescription=The attribute could not be found.}
I dusted off an old nRF dongle and confirmed that it gets notification updates from my ESP32 dev board. This problem also occurs with the simpleblepy module. Must be a Mac OS thing.
Operating System: macOS 10.15.7
Hi! I have to read the weight from a Mi Smart Scale 2 scale via Mac.
The weight is encoded in a BLE characteristic. However, sometimes it reads the weight, other times it doesn't.
I'm using the code found in the Bleak repository examples and this is my code: