static void db_discovery_evt_handler(ble_db_discovery_evt_t * p_evt) { // Find the client using the connection handle. client_t * p_client; uint32_t index; bool is_valid_srv_found = false; index = client_find(p_evt->conn_handle); p_client = &m_client[index]; if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) { uint8_t i; for (i = 0; i < p_evt->params.discovered_db.char_count; i++) { ble_db_discovery_char_t * p_characteristic; p_characteristic = &(p_evt->params.discovered_db.charateristics[i]); //See if this is the Ms. Pacman service if ((p_characteristic->characteristic.uuid.uuid == BLE_MS_PACMAN_CHARACTERISTIC_UUID) && (p_characteristic->characteristic.uuid.type == m_base_uuid_type_ms_pacman)) { // Characteristic found. Store the information needed and break. p_client->char_index = i; break; } //See if this is the Nunchuck service else if ((p_characteristic->characteristic.uuid.uuid == BLE_NUNCHUCK_CHARACTERISTIC_UUID) && (p_characteristic->characteristic.uuid.type == m_base_uuid_type_nunchuck)) { // Characteristic found. Store the information needed and break. p_client->char_index = i; is_valid_srv_found = true; break; } } } //Only enable notifications if it is the Nunchuck characteristic if (is_valid_srv_found) { // Enable notification. Maybe don't do this?? notif_enable(p_client); } }
static void db_discovery_evt_handler(ble_db_discovery_evt_t * p_evt) { // Find the client using the connection handle. client_t * p_client; uint32_t index; bool is_valid_srv_found = false; index = client_find(p_evt->conn_handle); p_client = &m_client[index]; if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE) { uint8_t i; for (i = 0; i < p_evt->params.discovered_db.char_count; i++) { ble_gatt_db_char_t * p_characteristic; p_characteristic = &(p_evt->params.discovered_db.charateristics[i]); if ((p_characteristic->characteristic.uuid.uuid == MULTILINK_PERIPHERAL_CHAR_UUID) && (p_characteristic->characteristic.uuid.type == m_base_uuid_type)) { // Characteristic found. Store the information needed and break. p_client->char_index = i; is_valid_srv_found = true; break; } } } if (is_valid_srv_found) { // Enable notification. notif_enable(p_client); } else { p_client->state = STATE_ERROR; } }
ret_code_t client_handling_dm_event_handler(const dm_handle_t * p_handle, const dm_event_t * p_event, const ret_code_t event_result) { client_t * p_client = &m_client[p_handle->connection_id]; switch (p_event->event_id) { case DM_EVT_LINK_SECURED: // Attempt configuring CCCD now that bonding is established. if (event_result == NRF_SUCCESS) { notif_enable(p_client); } break; default: break; } return NRF_SUCCESS; }