Skip to content

Enhance build of advertising data #117

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

Merged

Conversation

polldo
Copy link
Contributor

@polldo polldo commented Sep 25, 2020

While the old way of preparing advertising data is still supported, an alternative enhanced method to build advertising packets is now available.
It consists in defining and configuring an object of type 'BLEAdvertisingData' to build the desired packet.
When it has been configured, by setting the appropriate parameters, it can be used to populate the advertising data packet or the scan response data packet.
Following this way, the user can decide in which packet each parameter should be put.
Also, it is now possible to configure an advertising packet (advertising or scan response) by passing a raw data packet.
If an advertising packet has a raw data parameter set, all its other parameters will be ignored.

Also, advertising parameters such as manufacturer data, service data or raw data should have a GLOBAL scope, because they are passed as pointers and are not copied internally.

@polldo polldo requested a review from facchinm September 25, 2020 16:49
Now all the set methods of advertising data parameters return a bool value.
This bool indicates whether the parameter has been correctly set or not, depending on the size of the passed value.
A remaining length parameter of advertising data has been introduced. It can be publicly read, it indicates how many bytes can be still written into the packet.
In BLELocalDevice constructor, the flags field of the advertising data is set to a default value.
If a new advertising data is passed to BLELocalDevice, then:
     if it has no flags -> default flags are set (if there is enough space)
     if it already has flags -> nothing happens, the already set flags are used
Add raw data class.
When an AdvertisingData object has a rawData parameter set, the only advertised data will be the rawData parameter itself.
If the new value for the parameter is not valid, because too large, then
the old value will remain the actual value of the parameter.
@Kaly380
Copy link

Kaly380 commented Aug 30, 2022

If I didn't misunderstand all this implementation is for peripheral mode.
No, yes, someone could guide me and tell me if I need to implement Advertising Services but my arduino as central and obtain the data from the advertising services.
how can i do it please

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