bluetooth-lowenergybluetooth-peripheral

Multiple or Single BLE Services


What, if any, is the value of having multiple BLE services? Versus just throwing all of the characteristics in one single service?

I'm building a BLE interface from a (peripheral) device of our own making. I'm using the STMicro BlueNRG-ms chip. My first prototype has employed 9 characteristics, nicely organized in 4 services. Writing the app side of it now, I'm finding that the separate services just create more UUIDs that I have to map, and don't really seem to add any value. The 9 characteristics are all unique, so I don't get any real needed namespacing out of the separate services.


Solution

  • You will typically use a single service for a set of related characteristics.

    The Bluetooth SIG defines a number of service specifications for common scenarios and a peripheral will use often implement one or more of these and possibly its own 'private' service.

    Say I had a special peripheral for people attending raves. It has a heart rate monitor and temperature monitor to track health and a set of color LEDs to make interesting patters with. It could implement

    The use of standard services means that other apps can access this functionality of my peripheral. A private service is typically used where there is no standard service available (although I could create a 'closed' peripheral and use private services for the other features as well).

    Now, lets say I create version 2 which has a noise maker as well. Rather than change my original private service I can add another private service with characteristics for the noise maker. This way I don't need to change my original code and can keep it more modular. I can also tell in my code whether I have a v1 or a v2 simply by the services that are discovered.

    Finally, the services you offer and the services you advertise can be different. Typically you would advertise the 'primary' service (this would be my private service in the example) so that you can easily discover peripherals of the right type. Once you connect to the peripheral you can discover the other services it offers (battery, heart rate and so on)