-
Notifications
You must be signed in to change notification settings - Fork 710
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
Need a way to pass an array of UUIDs #115
Comments
Howdy, For example ... if your services are UUID 0x0001, UUID 0x0002 and UUID 0x0003 then all of these would be included in the outbound advertisement issued by the ESP32 when it advertises your BLE server. I wasn't aware that a BLE advertisement could advertise more than one service. By any chance have you examined the BLE specification and determine that this is a valid/lawful thing we can do? Currently, the BLE C++ implementation is populating an esp_ble_adv_data_t structure ... see: This structure contains the "content" that can be published. If we look deeply at it, we find that it appears to only be able to advertise a single service. However, I am also aware of another API called My gut is saying that Espressif made publishing advertisements simple through esp_ble_gap_config_adv_data() ... but that is too limiting for your needs. Espressif also provided a "catch all" through esp_ble_gap_config_adv_data_raw() but my suspicion is that is too low level for your needs. I'm sensing what you would really like is for the BLE C++ classes to take high level requests (i.e. here is a set of 1 or more service UUIDs to advertise) and it worry about how to build a correctly formatted low level advertisement and call esp_ble_gap_config_adv_data_raw(). We can do this ... assuming this is what you want ... but it will take some time. |
Neil, In the BLE specification, one of the data types that can be sent is 0x03, This is the complete list of This is how the Nordic Semi HR monitor app only shows heart-rate monitor devices. I am not sure if The code I posted in the first message, does exactly this and creates a heart-rate monitor that the So what I am looking for is a way to pass the UUID array and have you put it into the p_service_uuid and set the length. Or if you knew of another way to accomplish getting the data type 0x03 into the advertising packet without my having to create a raw advertising packet. Thanks |
I'm confused by the advertising API ... If I supply an array of 8 16 bit UUIDs for services then the |
I have created a ticket for clarification on the subject at the ESP-IDF git issues location: |
Neil, What I pass is an array of 128 bit UUIDs if I pass 2 this arrays length is 32. These 128 UUIDs are the full When I create an array of 32 bytes with these in it and pass it to the ESP API as the p_service_uuid with This is what I want. I just want a way to do it with your code without my having to hack your code.
The simple method I added to your BLEAdvertising.h is
|
Howdy my friend, From my perspective, pretty obviously I could expose an API to achieve just that. However, my thinking is to look at the bigger picture. It seems to me that in the BLE advertising spec, we can advertise lists of UUIDs in an advertisement. The payload of the advertisement specifies:
What I'd thus like to do is create an API that would look something like:
or could just as easily code:
However, achieving this is not as simple as it might appear. We have a mystery in the semantics of the underlying API called |
Neil, It appears you may have misunderstood me. I am passing in 2 128 bit UUIDs, they are the full UUIDs of
|
If we take a look at this spec page here: https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile We see the possible content of advertised payloads. We see that an advertisement is composed of fields and each field is composed of type and data. Of the types of interest to us, we see the following:
The reason for these distinctions is that an advertising packet can be a maximum of 31 bytes in length. It is quite constrained but has to be in order to fit the data in fixed size radio bursts. If we take this at face value, we immediately see that we actually can't transmit 2 x 128bit UUIDs as an advertised service because that would be 32 bytes and we are constrained to 31 bytes (which includes other overheads). The question then becomes one of contemplating and comprehending Espressif's thinking on their exposed APIs. My thinking is that they have given us a high level "basic" capability exposing 90% of the things we want to do most of the time (1 service UUID, 1 device name, 1 TX power ... etc). But when we want to do something more advanced, Espressif then gave us a super-low level API for driving the advertising ourselves. The BLE C++ APIs use the high level APIs and I think what needs to be examined is the possibility of driving the low level APIs giving us maximum flexibility. However, to design and code that up will take a little bit of time and, before just jumping on it, I want to check with Espressif (using the Github post to their repository) to make sure that we aren't missing something which would make our story simpler or better. |
The implementation of exposing advertised services from the BLEServer has now been changed. Instead of Please have a go at testing and let me know if this meets your needs and, if not, how we can change. When you are delighted, go ahead and close out the issue. |
It works great. Thank you. |
I am working with your BLE C++ and I am trying to get the advertising packet to include the 16 bit UUIDs complete. I can do this by putting multiple 128-bit UUIDs into an array and pointing the advertising data pointer to it. The only issue I have is that I am not happy with what I did to get to the advertising data pointer (hacked your code). and was wondering if you knew of a better why to accomplish what I want.
Thank you, Michael
Here is my code for a Heart-Rate monitor that connects to Nordic Semi utility App.
Editor: Moved code to pastebin: https://pastebin.com/Ax8Sib1c
The text was updated successfully, but these errors were encountered: