Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using detection_callback with service UUID in MacOS 12.4 #961

Closed
damianjwilliams opened this issue Aug 25, 2022 · 5 comments
Closed

Using detection_callback with service UUID in MacOS 12.4 #961

damianjwilliams opened this issue Aug 25, 2022 · 5 comments
Labels
Backend: Core Bluetooth Issues and PRs relating to the Core Bluetooth backend bug Something isn't working

Comments

@damianjwilliams
Copy link

damianjwilliams commented Aug 25, 2022

  • bleak version: 0.15.1
  • Python version: 3.8
  • Operating System: MacOS 12.4 and Windows 10

Description

Describe what you were trying to get done.
Use detection_callback.py example with MacOS 12.4

Tell us what happened, what went wrong, and what you expected to happen.
I wish to read advertising data from an ESP32 peripheral using the detection_callback.py example, but no advertising data is displayed. I know that when using MacOS 12.4, service UUIDs need to be provided to read advertising data (as discussed extensively, but I am still struggling to get it to work.

What I Did

My ESP32 is set up as a server using the BLE_server example from Arduino. The ESP32 will intermittently broadcast advertising data including a service UUID (in this case, 4fafc201-1fb5-459e-8fcc-c5c9c331914b)

It all works as expected on my PC running Windows 10:
I use discover.py example to determine the ESP32 MAC address.
Output:
94:B9:7E:DA:7C:FE: Long name works now

then service_explorer.py to confirm the service UUID.
Ouput:

INFO:__main__:	[Characteristic] 00002a05-0000-1000-8000-00805f9b34fb (Handle: 2): Service Changed (indicate), Value: None
INFO:__main__:		[Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 4): Client Characteristic Configuration) | Value: b'\x02\x00'
INFO:__main__:[Service] 00001800-0000-1000-8000-00805f9b34fb (Handle: 20): Generic Access Profile
INFO:__main__:	[Characteristic] 00002a00-0000-1000-8000-00805f9b34fb (Handle: 21): Device Name (read), Value: b'Long name works now'
INFO:__main__:	[Characteristic] 00002a01-0000-1000-8000-00805f9b34fb (Handle: 23): Appearance (read), Value: b'\x00\x00'
INFO:__main__:	[Characteristic] 00002aa6-0000-1000-8000-00805f9b34fb (Handle: 25): Central Address Resolution (read), Value: b'\x00'
INFO:__main__:[Service] 4fafc201-1fb5-459e-8fcc-c5c9c331914b (Handle: 40): Unknown
INFO:__main__:	[Characteristic] beb5483e-36e1-4688-b7f5-ea07361b26a8 (Handle: 41): Unknown (read,write), Value: b'Hello World says Neil'

The correct service UUID is given in the second to last line.
I can also see this service UUID using the BLE scanner app I have on my phone.

I can then run detection_callback.py with this service_uuid
(i.e. including scanner = BleakScanner(simple_callback, ["4fafc201-1fb5-459e-8fcc-c5c9c331914b"])).
Output:

2022-08-24 22:10:29,835 __main__ INFO: 94:B9:7E:DA:7C:FE RSSI: -62, AdvertisementData(service_uuids=['4fafc201-1fb5-459e-8fcc-c5c9c331914b'])
2022-08-24 22:10:29,842 __main__ INFO: 94:B9:7E:DA:7C:FE RSSI: -62, AdvertisementData(local_name='Long name works now', service_uuids=['4fafc201-1fb5-459e-8fcc-c5c9c331914b'])
2022-08-24 22:10:29,952 __main__ INFO: 94:B9:7E:DA:7C:FE RSSI: -62, AdvertisementData(local_name='Long name works now', service_uuids=['4fafc201-1fb5-459e-8fcc-c5c9c331914b'])
2022-08-24 22:10:29,961 __main__ INFO: 94:B9:7E:DA:7C:FE RSSI: -60, AdvertisementData(local_name='Long name works now', service_uuids=['4fafc201-1fb5-459e-8fcc-c5c9c331914b'])
2022-08-24 22:10:30,171 __main__ INFO: 94:B9:7E:DA:7C:FE RSSI: -60, AdvertisementData(local_name='Long name works now', service_uuids=['4fafc201-1fb5

Everything seems to be working on my PC. However when I use the same detection_callback.py script including the service UUID on my Mac, all I get is

(re)starting scanner
(re)starting scanner

Am I missing something obvious?

@dlech
Copy link
Collaborator

dlech commented Aug 25, 2022

If you have a question, please start a discussion: /~https://github.com/hbldh/bleak/discussions

@dlech dlech closed this as completed Aug 25, 2022
@damianjwilliams damianjwilliams changed the title Using detection Using detection_callback with service UUID in MacOS 12.4 Aug 25, 2022
@damianjwilliams
Copy link
Author

Oop, I accidentally posted the issue in the middle of writing it. I've updated it now.

@dlech
Copy link
Collaborator

dlech commented Aug 25, 2022

I know that when using MacOS 12.4, service UUIDs need to be provided to read advertising data (as discussed extensively, but I am still struggling to get it to work.

Apple fixed the bug in 12.3, so it is no longer required.

Am I missing something obvious?

Not that I can see. I've confirmed it is also not working on 12.5.1. I wonder if Apple introduced a new bug?

As a workaround, you can just leave out the service uuids.

@dlech dlech reopened this Aug 25, 2022
@dlech dlech added bug Something isn't working Backend: Core Bluetooth Issues and PRs relating to the Core Bluetooth backend labels Aug 25, 2022
@dlech
Copy link
Collaborator

dlech commented Aug 25, 2022

After trying it a few more times, it is working again (I also started the Packet Logger app in the meantime). Not sure what could have been the difference from the times when I was able to reproduce the issue.

@damianjwilliams
Copy link
Author

I just updated my MacOS from 12.4 to 12.5.1 and it seems to be working now! Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend: Core Bluetooth Issues and PRs relating to the Core Bluetooth backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants