-
I'm writing here because I exhausted other resources (nordic forums, chat gpt, google and datasheets) I'm trying to build a Bluetooth LE application for the nRF52840 chip. So far it was easy to understand from examples how to configure the GATT profile while using a single custom service (with custom UUID) - but now I would like to structure my application such that the service is not cluttered with characteristics that don't belong in the same category (for example I want a service that provides raw data from sensors and one that provides computed sensor outputs), a service for button controls and a service for controlling an LED array. I can't wrap my head around the concept of how services are discovered and whether every service has to be shown at advertising time or whether there is a possibility to discover the services AFTER the connection is done with the device - to my understanding this is what happens with the rest of attributes. But this could be wrong. Please correct me. Now, IF the first option is right, and all services have to be shown at advertising time, then how does extended advertising work and how can uplift the limit of 31 bytes (at most one 128 bit/16 bytes vendor specific UUIDs will fit in a 31 byte packet)? In my search for answering this question I stumbled upon this broadcaster_multiple example and this multiple advertisement sets example, but neither of them quite does what I would like it to do, which is channeling multiple services with their respective UUIDs into one device. Here is an example from a sone Bluetooth device I own and is the functionality I want to replicate: Thank you for reading until the end. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The GATT server can have any number of services, each containing any number of characteristics. You can use multiple The services present in the GATT server are not required to be present in the advertising data. Some standardized profiles may require this but you can do as you want if you are defining your own service. If you add the UUIDs to the advertising data you can avoid connecting to devices that do not have the services you are looking for. In any case you will have to do service discovery once connected to get the handles of the attributes. This is normally only required the first time you connect to the server, the layout of the GATT database usually doesn't change. You can subscribe to "Service Changed Indications" or read the "Database Hash Characteristic" to know if the database has changed and re-discovery is required. |
Beta Was this translation helpful? Give feedback.
Does the peripheral sample work for you? Can you see all the services there (GATT, GAP, BAS, CTS, DIS, HRS, IAS, Custom/Unknown)? If you copy-paste the custom service can you see two "Unknown service"?