Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bug in Discovery Module ble_db_discovery.c

This is on SDK 15: Not all services are reported when doing service discovery on more than one connection at a time.

Basically, 'ble_db_discovery.c' uses 'm_pending_usr_evt_index' to keep track of the number of services discovered, and when all services for a connection is discovered, it reports it to the higher layer handling function as a BLE_DB_DISCOVERY_COMPLETE event. However, this variable (m_pending_usr_evt_index) is cleared when a new service discovery starts. So if one service discovery is busy and another start, the variable is cleared for both discovery processes and the first discovery process loses track of its discovered services resulting in the already discovered services to never be reported to the higher layer driver.

An easy fix is to simply send the BLE_DB_DISCOVERY_COMPLETE event as soon as one service is discovered and not to wait for all services to be discovered. Alternatively m_pending_user_evts and m_pending_usr_evt_index must be adjusted to have a specific instance for each connection.

Related