void ble_db_discovery_on_ble_evt(ble_db_discovery_t * const p_db_discovery, const ble_evt_t * const p_ble_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_db_discovery); VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt); VERIFY_MODULE_INITIALIZED_VOID(); switch (p_ble_evt->header.evt_id) { case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: on_primary_srv_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt)); break; case BLE_GATTC_EVT_CHAR_DISC_RSP: on_characteristic_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt)); break; case BLE_GATTC_EVT_DESC_DISC_RSP: on_descriptor_discovery_rsp(p_db_discovery, &(p_ble_evt->evt.gattc_evt)); break; case BLE_GAP_EVT_DISCONNECTED: on_disconnected(p_db_discovery, &(p_ble_evt->evt.gap_evt)); break; default: break; } }
void ble_dfu_on_ble_evt(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_dfu); VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt); switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: on_connect(p_dfu, p_ble_evt); break; case BLE_GAP_EVT_DISCONNECTED: on_disconnect(p_dfu, p_ble_evt); break; case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: on_rw_authorize_req(p_dfu, p_ble_evt); break; case BLE_GATTS_EVT_WRITE: on_write(p_dfu, p_ble_evt); break; default: // no implementation break; } }
void nrf_ble_bms_on_ble_evt(nrf_ble_bms_t * p_bms, ble_evt_t * p_ble_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_bms); VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt); switch (p_ble_evt->header.evt_id) { case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: on_rw_auth_req(p_bms, &p_ble_evt->evt.gatts_evt); break; default: break; } }
/**@brief Function for handling the @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: BLE_GATTS_AUTHORIZE_TYPE_WRITE: event from the SoftDevice. * * @param[in] p_escs Eddystone Configuration Service structure. * @param[in] p_ble_evt Pointer to the event received from BLE stack. */ static void on_long_write(nrf_ble_escs_t * p_escs, ble_evt_t * p_ble_evt) { static uint16_t write_evt_uuid; static bool write_evt_uuid_set = false; uint32_t err_code; VERIFY_PARAM_NOT_NULL_VOID(p_escs); VERIFY_PARAM_NOT_NULL_VOID(p_ble_evt); ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.authorize_request.request.write; ble_gatts_rw_authorize_reply_params_t reply = {0}; if (p_evt_write->op == BLE_GATTS_OP_PREP_WRITE_REQ) { err_code = get_evt_type_for_handle(p_evt_write->handle, &write_evt_uuid); APP_ERROR_CHECK(err_code); write_evt_uuid_set = true; reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; reply.params.write.update = 0; reply.params.write.offset = 0; reply.params.write.len = p_evt_write->len; reply.params.write.p_data = NULL; err_code = sd_ble_gatts_rw_authorize_reply(p_escs->conn_handle, &reply); APP_ERROR_CHECK(err_code); } else if (p_evt_write->op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) { uint8_t value_buffer[ESCS_ADV_SLOT_CHAR_LENGTH_MAX] = {0}; ble_gatts_value_t value = { .len = sizeof(value_buffer), .offset = 0, .p_value = &(value_buffer[0]) }; ASSERT(write_evt_uuid_set); write_evt_uuid_set = false; reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS; reply.params.write.update = 0; reply.params.write.offset = 0; reply.params.write.len = p_evt_write->len; reply.params.write.p_data = NULL; err_code = sd_ble_gatts_rw_authorize_reply(p_escs->conn_handle, &reply); APP_ERROR_CHECK(err_code); // Now that the value has been accepted using 'sd_ble_gatts_rw_authorize_reply', it can be found in the database. err_code = sd_ble_gatts_value_get( p_escs->conn_handle, p_escs->rw_adv_slot_handles.value_handle, &value); APP_ERROR_CHECK(err_code); p_escs->write_evt_handler(p_escs, write_evt_uuid, p_evt_write->handle, value.p_value, value.len); } else { } }
/**@brief Function for handling the @ref BLE_GAP_EVT_DISCONNECTED event from the SoftDevice. * * @param[in] p_escs Eddystone Configuration Service structure. * @param[in] p_ble_evt Pointer to the event received from BLE stack. */ static void on_disconnect(nrf_ble_escs_t * p_escs, ble_evt_t * p_ble_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_escs); UNUSED_PARAMETER(p_ble_evt); p_escs->conn_handle = BLE_CONN_HANDLE_INVALID; }
/**@brief Function for handling the @ref BLE_GAP_EVT_CONNECTED event from the SoftDevice. * * @param[in] p_escs Eddystone Configuration Service structure. * @param[in] p_ble_evt Pointer to the event received from BLE stack. */ static void on_connect(nrf_ble_escs_t * p_escs, ble_evt_t * p_ble_evt) { VERIFY_PARAM_NOT_NULL_VOID(p_escs); p_escs->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; }