예제 #1
0
static void discovery_complete_evt_trigger(ble_db_discovery_t * const p_db_discovery)
{
    ble_db_discovery_evt_t          evt;
    ble_db_discovery_evt_handler_t  p_evt_handler;

    // No (more) descriptors found. Send an event to the application.
    p_evt_handler = registered_handler_get(p_db_discovery->srv_being_discovered.srv_uuid.uuid);
    
    if (p_evt_handler != NULL)
    {
        evt.evt_type             = BLE_DB_DISCOVERY_COMPLETE;
        evt.conn_handle          = p_db_discovery->conn_handle;
        evt.params.discovered_db = p_db_discovery->srv_being_discovered;

        uint8_t                   i = 0;
        ble_db_discovery_char_t * p_chars_being_discovered =
                                          &(p_db_discovery->srv_being_discovered.charateristics[0]);

        for (i = 0; i < evt.params.discovered_db.char_count; i++)
        {
            evt.params.discovered_db.charateristics[i].cccd_handle    =
                            p_chars_being_discovered[i].cccd_handle;
            evt.params.discovered_db.charateristics[i].characteristic =
                            p_chars_being_discovered[i].characteristic;
        }

        // Send the event to the registered user module.
        p_evt_handler(&evt);
    }
}
예제 #2
0
static void indicate_error_to_app(ble_db_discovery_t * const   p_db_discovery,
                                  const ble_gattc_evt_t* const p_ble_gattc_evt,
                                  uint32_t                     err_code)
{
    // Indicate the error to the user application registered for the service being
    // discovered.
    ble_db_discovery_evt_t         evt;
    ble_db_discovery_evt_handler_t p_evt_handler;

    p_evt_handler = registered_handler_get(p_db_discovery->srv_being_discovered.srv_uuid.uuid);

    evt.conn_handle     = p_ble_gattc_evt->conn_handle;
    evt.evt_type        = BLE_DB_DISCOVERY_ERROR;
    evt.params.err_code = err_code;

    p_evt_handler(&evt);
}
예제 #3
0
/**@brief     Function for indicating error to the application.
 *
 * @details   This function will fetch the event handler based on the UUID of the service being
 *            discovered. (The event handler is registered by the application beforehand).
 *            The error code is added to the pending events together with the event handler.
 *            If no event handler was found, then this function will do nothing.
 *
 * @param[in] p_db_discovery Pointer to the DB discovery structure.
 * @param[in] err_code       Error code that should be provided to the application.
 * @param[in] conn_handle    Connection Handle.
 *
 */
static void discovery_error_evt_trigger(ble_db_discovery_t * const p_db_discovery,
                                        uint32_t                   err_code,
                                        uint16_t const             conn_handle)
{
    ble_db_discovery_evt_handler_t p_evt_handler;
    ble_gatt_db_srv_t            * p_srv_being_discovered;

    p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]);

    p_evt_handler = registered_handler_get(&(p_srv_being_discovered->srv_uuid));

    if (p_evt_handler != NULL)
    {
        ble_db_discovery_evt_t evt;

        evt.conn_handle     = conn_handle;
        evt.evt_type        = BLE_DB_DISCOVERY_ERROR;
        evt.params.err_code = err_code;

        p_evt_handler(&evt);
    }
}