I am trying to emulate a vendor's tool, whose BLE properties are configured as follows:Custom 128 bit Service UUID like XXXXXXXX-0000-XXXX-XXXX-XXXXXXXXXXXX
Custom 128 bit Characteristic UUID like XXXXXXXX-0001-XXXX-XXXX-XXXXXXXXXXXX
There are five more characteristics like this. With the nrf5 SDK, it appears that I can add a characteristic to a service with a base UUID, but it will modify the 12th and 13th octet. In other words, when I try to add the characteristic to the service, I end up with a UUID that looks like this: XXXX0001-XXXX-XXXX--XXXX-XXXXXXXXXXXX
This is not what I want.
Is there a way to add a characteristic with a completely different 128 bit UUID base to a service, without having to add a new service to the gatt table?I don't want to create 6 different services just so I can have a characteristic with a different base UUID.Thanks.
I believe this should work.
You need to call sd_ble_uuid_vs_add for all 6 UUIDs, make sure that you buffer away the uuid_type for each of the calls, since the uuid_type is the handle that you need to reference later when adding the characteristics (or services).
When you later want to add the charactertistics you use sd_ble_gatts_characteristic_add() as normal, however make sure that the p_attr_char_value now reference the uuid_type (e.g. UUID) that you want to use in p_attr_char_value:
Hi,Thank you. Your suggestion worked. I can now see all my 6 characteristics attached to the same service.
I do have one more question:My application has three services, including battery service and device information service.In my main.c file, I try to add the services, along with my custom service for advertising. However, this causes a crash.This is the piece of code that adds my service uuid. How do I make my custom service advertise its UUID?
// YOUR_JOB: Use UUIDs for service(s) used in your application.
static ble_uuid_t m_adv_uuids = /**< Universally unique service identifiers. */
What have you configured to NRF_SDH_BLE_VS_UUID_COUNT to?
Have you tried to debug to find where the error code that is causing the crash is coming from? Typically by checking app_error_fault_handler().
I configured NRF_SDH_BLE_VS_UUID_COUNT count to 7. The failure happens in during advertising initialization, in function ble_advdadta_encode. The failure goes away if I don't include my custom service in the m_adv_uuids array.