This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Service discovery when peripheral has the same service multiple times

My peripheral uses a generic sensor service which I use for various sensors. Most of the sensors only have one integer as value and can be abstracted the same, hence I made a generic sensor service. Now there will be cases where the peripheral has two sensors, each having their instance of my sensor service. This seems to work fine on the nRF Connect app.

The issues I am having is discovering both these services in my central device. I registered the uuid using ble_db_discovery_evt_register(), but I only get one event.

  • Do I understand it correctly that your two primary services (representing two sensors) have different UUIDs (because that's what BT SIG demands)?

  • They don't, it's the same UUID. I thought it was allowed because of this in the Core Spec Vol 3 Part G 3.1 Service Definition: A device or higher level specification may have multiple service definitions and may have multiple service definitions with the same service UUID.. I thought this meant it was fine to implement the exact same service twice.

  • OK, you seems to be right, that's what BT spec says. It doesn't make much sense to me (because on GATT you cannot do any straight forward enumeration) but you probably can do it if you want. However if ble_db module works on UUID level it's no surprise it cannot handle it. To be sure it is limitation/bug in that module you can either wait for someone else to answer (I'm not using it, I prefer custom Service Discovery mechanism done by my code) or get BLE RF sniffer log and verify that really both services were "discovered" on radio but you got triggered only once.

  • FormerMember
    0 FormerMember

    My first thought is that the problem is related to how the db_discovery module works on the central side, it does only look for the services and the number of services it expects to find, see on_srv_disc_completion(), the variable p_db_discovery->discoveries_countand the variable m_num_of_handlers_reg.

    To make the central look for the "duplicate" service, you would need to make sure that the central looks for one more service than it currently does. And possibly also associate the extra service discovery with a UUID. (Note: I haven't tested this..)

  • I suppose it would be easier to change my services in that case. Thanks for the answer.

Related