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

Expose stop service advertisment on Windows #281

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

johnb8
Copy link

@johnb8 johnb8 commented Aug 7, 2024

It seems like you need to call StopAdvertising on the GattServiceProvider when you want to change the service being advertised or else Windows will just advertise both services. This just exposes that function on the adapter but only for Windows. I added a dummy function on the Linux implementation so apps that use it still build without having to make Linux and Windows specific files.

I'm not sure if a Linux implementation is needed or if BlueZ handles this differently.

@@ -49,6 +49,8 @@ func (a *Adapter) AddService(s *Service) error {
return err
}

a.gattServiceProvider = serviceProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly each GATT service requires its own GattServiceProvider. So if someone adds two services this would only store the latest created.

Users should be able to add and stop the specific service they want.

I was thinking that a map with the UUID and the service provider could work, but the BLE spec allows UUIDs to be repeated (a problem already found on other ble libraries hbldh/bleak#362).

So maybe AddService() should return some handle to the created service to stop it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe AddService() should return some handle to the created service to stop it?

That sounds like a very reasonable suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants