Good day!
Work with nrf51822 central with S130,
I've read this questions and links in answers:
- https://devzone.nordicsemi.com/f/nordic-q-a/20924/sd_ble_gattc_char_value_by_uuid_read---again
- https://devzone.nordicsemi.com/f/nordic-q-a/10489/read-custom-characteristics-value-in-multilink-example-central
- https://devzone.nordicsemi.com/f/nordic-q-a/7491/using-function-sd_ble_gattc_char_value_by_uuid_read
- https://devzone.nordicsemi.com/f/nordic-q-a/7454/read-the-characteristic-value
- https://devzone.nordicsemi.com/f/nordic-q-a/5320/how-to-retrieve-the-handle-for-a-characteristic-value-by-uuid
I've read documentation:
- https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v3.0.0/group___b_l_e___g_a_t_t_c___f_u_n_c_t_i_o_n_s.html?cp=2_3_1_1_4_2_2_2_1#ga1e5d6f7c678b7db3205fa6b5c419f665
- https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___b_l_e___g_a_t_t_c___r_e_a_d___u_u_i_d___m_s_c.html
- https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___b_l_e___g_a_t_t_c___e_n_u_m_e_r_a_t_i_o_n_s.html&anchor=ggafd9b8b42eeb832d688e33f4561f97efca9741363d5e934220a35f1c01f62a194c
Finally all I've done:
main.c
ble_uuid_t m_uuid; m_uuid.type = m_ble_lgs_c.uuid_type; m_uuid.uuid = LGS_UUID_SERVICE; ble_gattc_handle_range_t handle_range; handle_range.start_handle = 0x0001; handle_range.end_handle = 0xFFFF; err_code = sd_ble_gattc_char_value_by_uuid_read(m_ble_lgs_c.conn_handle, &m_uuid, &handle_range); APP_ERROR_CHECK(err_code);
and to handle event
static void on_ble_evt(const ble_evt_t * const p_ble_evt) { ret_code_t err_code; // For readability. const ble_gap_evt_t * const p_gap_evt = &p_ble_evt->evt.gap_evt; switch (p_ble_evt->header.evt_id) { // Upon connection, check which peripheral has connected (HR or RSC), initiate DB // discovery, update LEDs status and resume scanning if necessary. */ case BLE_GAP_EVT_CONNECTED: { NRF_LOG_INFO("Connected.\r\n"); err_code = ble_lgs_c_handles_assign(&m_ble_lgs_c, p_gap_evt->conn_handle, NULL); APP_ERROR_CHECK(err_code); err_code = ble_db_discovery_start(&m_ble_db_discovery, p_gap_evt->conn_handle); APP_ERROR_CHECK(err_code); // Update LEDs status, and check if we should be looking for more // peripherals to connect to. bsp_board_led_on(CENTRAL_CONNECTED_LED); bsp_board_led_off(CENTRAL_SCANNING_LED); } break; // Upon disconnection, reset the connection handle of the peer which disconnected, update // the LEDs status and start scanning again. case BLE_GAP_EVT_DISCONNECTED: { NRF_LOG_INFO("Disconnected.\r\n"); play_sound(df_DCONNECT); scan_start(); } break; case BLE_GAP_EVT_ADV_REPORT: { on_adv_report(p_ble_evt); } break; case BLE_GAP_EVT_TIMEOUT: { // We have not specified a timeout for scanning, so only connection attemps can timeout. if (p_gap_evt->params.timeout.src == BLE_GAP_TIMEOUT_SRC_CONN) { NRF_LOG_DEBUG("Connection request timed out.\r\n"); } } break; case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { // Accept parameters requested by peer. err_code = sd_ble_gap_conn_param_update(p_gap_evt->conn_handle, &p_gap_evt->params.conn_param_update_request.conn_params); APP_ERROR_CHECK(err_code); } break; case BLE_GATTC_EVT_TIMEOUT: { // Disconnect on GATT Client timeout event. NRF_LOG_DEBUG("GATT Client Timeout.\r\n"); err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } break; case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP: { } break; case BLE_GATTS_EVT_TIMEOUT: { // Disconnect on GATT Server timeout event. NRF_LOG_DEBUG("GATT Server Timeout.\r\n"); err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } break; #if (NRF_SD_BLE_API_VERSION == 3) case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { err_code = sd_ble_gatts_exchange_mtu_reply(p_ble_evt->evt.gatts_evt.conn_handle, NRF_BLE_MAX_MTU_SIZE); APP_ERROR_CHECK(err_code); }break; #endif default: // No implementation needed. break; } }
The question is: what to do in case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP?