This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

One Service with Multiple Characteristics or Multiple Services with Single Characteristic each?

Hi,

I wanted to know what is the recommended way of data transfer through ble if there are multiple sensors. Is Creating one service with multiple characteristics a good way or creating multiple services with one characteristic each the best option.

Parents
  • Hi soumil and Carles,

    To be fair there are some details which make difference, e.g. creating too many Services/Characteristics (= GATT handles) can make Service Discovery procedure (from GATT client side) longer - and I've seen cases where inefficient GATT Server profile made connection time longer by several seconds (speaking about generic "multi-application" BLE central stack such as mobile phones). So in case you don't care about connection "performance" (e.g. because you typically connect once and then operate in continuous connection for long time) or because you have control over both parts of BLE stack (GATT server as well as client) so you can make the discovery efficient then it's really almost equal approach (not mentioning that at some point you need to scale GATT table in Nordic Soft Device as well). If you want to overcome these drawbacks of "many Services and Characteristics" approach and your device is "single application" (meaning that all these sensors or "features" will be always accessed only by one app) then you can simply group everything into single Primary Service + Characteristic and define your own protocol on top of it. (I'd actually recommend this over creating of crowded GATT stack but choice is yours;)

    Cheers Jan

  • Hi Jan

    Are you saying that Service Discovery time is shorter when all Characteristics are grouped in the one service, maintaining the same total number of Characteristics ?

    Can you explain or direct me to somewhere which the math/sense behind this ? 

    Thanks !

  • Hi,

    Most likely that would be because of the number of roundtrips required for the Service Discovery procedure.

    In short, you discover one Service at a time, and each additional Service means an additional back-and-forth to discover that Service.

    You also get one additional back-and-forth looking for Characteristics, for each additional Service. This is because the procedure is to fetch one Characteristic at a time until you get an "attribute not found" response indicating there are no more Characteristics on that Service.

    Regards,
    Terje

Reply
  • Hi,

    Most likely that would be because of the number of roundtrips required for the Service Discovery procedure.

    In short, you discover one Service at a time, and each additional Service means an additional back-and-forth to discover that Service.

    You also get one additional back-and-forth looking for Characteristics, for each additional Service. This is because the procedure is to fetch one Characteristic at a time until you get an "attribute not found" response indicating there are no more Characteristics on that Service.

    Regards,
    Terje

Children
No Data
Related