1. SDK version : nRF5_SDK_15.0.0
2. Platform : nRF52832
3. Purpose: NUS service with example ble_app_hrs_rscs_relay.
4. Problem : NUS device connection only success "BLE_NUS_C_EVT_DISCOVERY_COMPLETE" in second time power on.
5. Debug Information : RELAY device power on and NUS device connect at first time, always fail in on_primary_srv_discovery_rsp() and in function characteristics_discover().
static void on_primary_srv_discovery_rsp(ble_db_discovery_t * p_db_discovery, ble_gattc_evt_t const * p_ble_gattc_evt) { ble_gatt_db_srv_t * p_srv_being_discovered; p_srv_being_discovered = &(p_db_discovery->services[p_db_discovery->curr_srv_ind]); if (p_ble_gattc_evt->conn_handle != p_db_discovery->conn_handle) { return; } if (p_ble_gattc_evt->gatt_status == BLE_GATT_STATUS_SUCCESS) { uint32_t err_code; ble_gattc_evt_prim_srvc_disc_rsp_t const * p_prim_srvc_disc_rsp_evt; NRF_LOG_DEBUG("Found service UUID 0x%x.", p_srv_being_discovered->srv_uuid.uuid); p_prim_srvc_disc_rsp_evt = &(p_ble_gattc_evt->params.prim_srvc_disc_rsp); p_srv_being_discovered->srv_uuid = p_prim_srvc_disc_rsp_evt->services[0].uuid; p_srv_being_discovered->handle_range = p_prim_srvc_disc_rsp_evt->services[0].handle_range; err_code = characteristics_discover(p_db_discovery, p_ble_gattc_evt->conn_handle); if (err_code != NRF_SUCCESS) { p_db_discovery->discovery_in_progress = false; // Error with discovering the service. // Indicate the error to the registered user application. discovery_error_evt_trigger(p_db_discovery, err_code, p_ble_gattc_evt->conn_handle); m_pending_user_evts[0].evt.evt_type = BLE_DB_DISCOVERY_AVAILABLE; m_pending_user_evts[0].evt.conn_handle = p_ble_gattc_evt->conn_handle; } } else { NRF_LOG_DEBUG("Service UUID 0x%x not found.", p_srv_being_discovered->srv_uuid.uuid); // Trigger Service Not Found event to the application. discovery_complete_evt_trigger(p_db_discovery, false, p_ble_gattc_evt->conn_handle); on_srv_disc_completion(p_db_discovery, p_ble_gattc_evt->conn_handle); } }
6. Relay device debug log.
when NUS device power on in first time, connection fail.
<info> app: Relay example started. <info> app: Fast advertising. <info> app: new on_adv_report, find target uuid <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0. <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0. <info> app: Central connected <info> app: Attempt to find HRS or RSC or eNUS on conn_handle 0x0 <debug> ble_db_disc: Starting discovery of service with UUID 0x180D on connection handle 0x0. <debug> nrf_ble_gatt: BLE GATTS EVT_EXCHANGE MTU REQUES <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes. <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0. <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response). <debug> ble_db_disc: Starting discovery of service with UUID 0x180D on connection handle 0x0. <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0. <debug> nrf_ble_gatt: max_rx_octets: 251 <debug> nrf_ble_gatt: max_tx_octets: 251 <debug> nrf_ble_gatt: max_rx_time: 2120 <debug> nrf_ble_gatt: max_tx_time: 2120 <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x180D. <debug> ble_db_disc: Service UUID 0x180D not found. <debug> ble_db_disc: Starting discovery of service with UUID 0x1814 on connection handle 0x0. <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x0. <debug> ble_db_disc: Service UUID 0x0 not found. <debug> ble_db_disc: Starting discovery of service with UUID 0x1814 on connection handle 0x0. <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1814. <debug> ble_db_disc: Service UUID 0x1814 not found. <debug> ble_db_disc: Starting discovery of service with UUID 0x1 on connection handle 0x0. <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1814. <debug> ble_db_disc: Service UUID 0x1814 not found. <debug> ble_db_disc: Starting discovery of service with UUID 0x1 on connection handle 0x0. <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1. <debug> ble_db_disc: Found service UUID 0x1. <debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1. <debug> ble_db_disc: Found service UUID 0x1. <debug> ble_db_disc: Discovery of service with UUID 0x1 completed with success on connection handle 0x0. <debug> ble_db_disc: Discovery of service with UUID 0x1 completed with success on connection handle 0x0.
when NUS device power on in second time, connection success.
<info> app: new on_adv_report, find target uuid
<debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x1.
<debug> nrf_ble_gatt: Updating data length to 251 on connection 0x1.
<info> app: Central connected
<info> app: Attempt to find HRS or RSC or eNUS on conn_handle 0x1
<debug> ble_db_disc: Starting discovery of service with UUID 0x180D on connection handle 0x1.
<debug> nrf_ble_gatt: BLE GATTS EVT_EXCHANGE MTU REQUES
<debug> nrf_ble_gatt: Peer on connection 0x1 requested an ATT MTU of 247 bytes.
<debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x1.
<debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x1 (response).
<debug> ble_db_disc: Starting discovery of service with UUID 0x180D on connection handle 0x1.
<debug> nrf_ble_gatt: Data length updated to 251 on connection 0x1.
<debug> nrf_ble_gatt: max_rx_octets: 251
<debug> nrf_ble_gatt: max_tx_octets: 251
<debug> nrf_ble_gatt: max_rx_time: 2120
<debug> nrf_ble_gatt: max_tx_time: 2120
<debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x180D.
<debug> ble_db_disc: Service UUID 0x180D not found.
<debug> ble_db_disc: Starting discovery of service with UUID 0x1814 on connection handle 0x1.
<debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1814.
<debug> ble_db_disc: Service UUID 0x1814 not found.
<debug> ble_db_disc: Starting discovery of service with UUID 0x1 on connection handle 0x1.
<debug> ble_db_disc: on_primary_srv_discovery_rsp try to Found service UUID 0x1.
<debug> ble_db_disc: Found service UUID 0x1.
<debug> ble_db_disc: Discovery of service with UUID 0x1 completed with success on connection handle 0x1.
<info> app: Discovery complete.
<info> app: eTest Nus discovered on conn_handle 0x1
<info> app: Connected to device with Nordic UART Service.