Skip to content

Add enhanced advertising examples #134

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 Nov 2, 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.

Example EnhancedAdvertising.ino shows how to build generic advertising and scan response packets.
Example RawDataAdvertising.ino shows how to configure an advertising packet given an already encoded raw advertising packet

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.
@sebromero
Copy link

@polldo Interesting. Does it affect the performance? If so, how?

@polldo
Copy link
Contributor Author

polldo commented Nov 3, 2020

Hi @sebromero
There should't be any critical performance penalty, however it is required slightly more CPU work to perform:

  • some checks more when building the actual advertising packet plus some extra memcpy of very few bytes
  • some checks more when setting its parameters

The aspect I'm mostly concerned about in terms of performance is that each time the BLE.advertise() function is called, the advertising packets (advertising data and scan response data) are always rebuilt (i.e. their paramaters are encoded) even if their parameters did not change at all. (However, this was the original behaviour, even before this PR)
To handle this, it could be added a flag indicating whether or not any of the advertising data parameters have been changed.

@gmacario
Copy link

gmacario commented May 13, 2022

Hello,

That's an interesting concept but I see no updates for a long time.

Is the PR ready to be merged? If not, what is still missing?

@facchinm
Copy link
Contributor

@manchoz @giulcioffi can we merge it?

@manchoz
Copy link
Collaborator

manchoz commented May 13, 2022

@facchinm LGTM. Tested working.

@per1234 per1234 added type: enhancement Proposed improvement topic: documentation Related to documentation for the project labels May 13, 2022
@facchinm facchinm marked this pull request as ready for review May 13, 2022 10:13
@facchinm facchinm merged commit f2f73e8 into arduino-libraries:master May 13, 2022
@Nasrino17

This comment was marked as off-topic.

@per1234
Copy link
Contributor

per1234 commented Nov 5, 2024

@Nasrino17 this is not an appropriate place to request assistance. If you want help, make a topic on Arduino Forum:

https://forum.arduino.cc/

I'm sure we'll be able to help you solve the problem over there.

@arduino-libraries arduino-libraries locked as resolved and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: documentation Related to documentation for the project type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants