Hi,
I am working on the client program to retrieve the value from 4 characteristics at the same time using notifications. I have already done with the server program. Using nrf connect to connect with my program, it looks like this:
I would like to collect the value from these four characteristics using notifications. Here' s the code to update 4 characteristic data on server:
void ble_eeg_update_4ch(ble_eeg_t *p_eeg) { //packet 1: uint32_t err_code; if (p_eeg->conn_handle != BLE_CONN_HANDLE_INVALID && p_eeg->ads1299_current_configuration[4] != 0xE1) { uint16_t hvx_len = EEG_PACKET_LENGTH;//The length is 60 ble_gatts_hvx_params_t const hvx_params = { .handle = p_eeg->eeg_ch1_handles.value_handle, .type = BLE_GATT_HVX_NOTIFICATION, .offset = 0, .p_len = &hvx_len, .p_data = p_eeg->eeg_ch1_buffer, }; err_code = sd_ble_gatts_hvx(p_eeg->conn_handle, &hvx_params); } if (err_code == NRF_ERROR_RESOURCES) { NRF_LOG_INFO("sd_ble_gatts_hvx() ERR/RES: 0x%x\r\n", err_code); } //Packet 2 if (p_eeg->conn_handle != BLE_CONN_HANDLE_INVALID && p_eeg->ads1299_current_configuration[5] != 0xE1) { uint16_t hvx_len = EEG_PACKET_LENGTH;//The length is 60 ble_gatts_hvx_params_t const hvx_params = { .handle = p_eeg->eeg_ch2_handles.value_handle, .type = BLE_GATT_HVX_NOTIFICATION, .offset = 0, .p_len = &hvx_len, .p_data = p_eeg->eeg_ch2_buffer, }; err_code = sd_ble_gatts_hvx(p_eeg->conn_handle, &hvx_params); } if (err_code == NRF_ERROR_RESOURCES) { NRF_LOG_INFO("sd_ble_gatts_hvx() ERR/RES: 0x%x\r\n", err_code); } //Packet 3 if (p_eeg->conn_handle != BLE_CONN_HANDLE_INVALID && p_eeg->ads1299_current_configuration[6] != 0xE1) { uint16_t hvx_len = EEG_PACKET_LENGTH;//The length is 60 ble_gatts_hvx_params_t const hvx_params = { .handle = p_eeg->eeg_ch3_handles.value_handle, .type = BLE_GATT_HVX_NOTIFICATION, .offset = 0, .p_len = &hvx_len, .p_data = p_eeg->eeg_ch3_buffer, }; err_code = sd_ble_gatts_hvx(p_eeg->conn_handle, &hvx_params); } if (err_code == NRF_ERROR_RESOURCES) { NRF_LOG_INFO("sd_ble_gatts_hvx() ERR/RES: 0x%x\r\n", err_code); } //Packet 4 if (p_eeg->conn_handle != BLE_CONN_HANDLE_INVALID && p_eeg->ads1299_current_configuration[7] != 0xE1) { uint16_t hvx_len = EEG_PACKET_LENGTH;//The length is 60 ble_gatts_hvx_params_t const hvx_params = { .handle = p_eeg->eeg_ch4_handles.value_handle, .type = BLE_GATT_HVX_NOTIFICATION, .offset = 0, .p_len = &hvx_len, .p_data = p_eeg->eeg_ch4_buffer, }; err_code = sd_ble_gatts_hvx(p_eeg->conn_handle, &hvx_params); } if (err_code == NRF_ERROR_RESOURCES) { NRF_LOG_INFO("sd_ble_gatts_hvx() ERR/RES: 0x%x\r\n", err_code); } }
Question:
1. Do you have examples that have multiple characteristics that need notifications in one service? I read the code of ble_app_hrs_c, but this program is not what I want.
2. If I can get retrieve these 4 characteristics data on the client, how to differentiate them?