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

Interface inconsistency when discovering multiple services

registered_handler_get() in ble_db_discovery.c searches a table for the appropriate handler to call for a given UUID.

However, ble_db_discovery_evt_register() assigns the same handler for all UUIDs:

uint32_t ble_db_discovery_evt_register(ble_uuid_t const * p_uuid)
{
    VERIFY_PARAM_NOT_NULL(p_uuid);
    VERIFY_MODULE_INITIALIZED();

    return registered_handler_set(p_uuid, m_evt_handler);
}

Is the intent for ble_db_discovery to call each service handler directly (and only with events that pertain to that service)?

Or is the intent for ble_db_discovery to call a single handler which dispatches to all service handlers (in this case, the service handlers may get events for other services).

  • All events from the database discovery module is dispatched a single handler.

    You can have a look at ble_app_hrs, where you have

    /**@brief Function for handling database discovery events.
     *
     * @details This function is callback function to handle events from the database discovery module.
     *          Depending on the UUIDs that are discovered, this function should forward the events
     *          to their respective services.
     *
     * @param[in] p_event  Pointer to the database discovery event.
     */
    static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
    {
        ble_hrs_on_db_disc_evt(&m_hrs_c, p_evt);
        ble_bas_on_db_disc_evt(&m_bas_c, p_evt);
    }
    
Related