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

hci: add advertiser support for ManufacturerData and ServiceData #307

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

Conversation

deadprogram
Copy link
Member

@deadprogram deadprogram commented Nov 27, 2024

This PR adds advertiser support for ManufacturerData and ServiceData to the HCI implementation.

Addresses #306

@@ -125,6 +125,26 @@ func (a *Advertisement) Stop() error {
return nil
}

// SetServiceData sets the service data for the advertisement.
func (a *Advertisement) SetServiceData(sd []ServiceDataElement) error {
Copy link
Member Author

Choose a reason for hiding this comment

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

@aykevl do you happen to know how I can do this? 😸

Copy link
Member

Choose a reason for hiding this comment

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

What is your goal?

If you want to change advertisement data then I think you can stop and restart the advertisement with the new service data. Looking at the API I don't see a straightforward way to update any part of the advertisement. But this is straightforward to do from userspace: simply stop and restart the advertisement with the new parameters.

See:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.LEAdvertisement.rst
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.LEAdvertisingManager.rst

Copy link
Member Author

Choose a reason for hiding this comment

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

If you want to change advertisement data then I think you can stop and restart the advertisement

OK I will probably do that in a separate PR.

gap_nrf51.go Outdated Show resolved Hide resolved
@@ -125,6 +125,26 @@ func (a *Advertisement) Stop() error {
return nil
}

// SetServiceData sets the service data for the advertisement.
func (a *Advertisement) SetServiceData(sd []ServiceDataElement) error {
Copy link
Member

Choose a reason for hiding this comment

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

What is your goal?

If you want to change advertisement data then I think you can stop and restart the advertisement with the new service data. Looking at the API I don't see a straightforward way to update any part of the advertisement. But this is straightforward to do from userspace: simply stop and restart the advertisement with the new parameters.

See:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.LEAdvertisement.rst
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.LEAdvertisingManager.rst

Comment on lines 90 to 91
// TODO: implement
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this can be implemented here, but it needs a different API.
https://docs.nordicsemi.com/bundle/s132_v6.0.0_api/page/group_b_l_e_g_a_p_f_u_n_c_t_i_o_n_s.html#ga9969047f4e7485c3f856c841978cc31a
Instead of a SetServiceData, you'd need to construct an entirely new advertisement payload (bluetooth.AdvertisementOptions) and set it as a whole.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about preserve the initial options and then set a new payload when SetServiceData is changed?

Please see the new example beacon for how I am trying to use this function.

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.

2 participants