Hi,
I am developing a central application that will connect to my custom made peripheral device and continuously read a characteristic available on the peripheral device . I have currently managed to find and connect to my peripheral device, and also request to read the device name characteristic without any problems. However, when I start reading the custom service that is added on the peripheral device, with the sd_ble_gattc_char_value_by_uuid_read function, it returns err_code 7, which I assume is invalid params.
On the peripheral I can see that there are two characteristics that I can read through the nrf connect application.
I had my code in the following way when requesting to read the device name characteristic:
static void repeated_timer_handler(void * p_context) { ret_code_t err_code; ble_uuid_t p_uuid = {.uuid = BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME, .type = BLE_UUID_TYPE_BLE}; ble_gattc_handle_range_t p_handle_range = {.start_handle = 0x0001, .end_handle = 0xFFFF}; err_code = sd_ble_gattc_char_value_by_uuid_read(connection_handle, &p_uuid, &p_handle_range); if(err_code != NRF_SUCCESS) { NRF_LOG_INFO("Failed to send read request to peer error = %d", err_code); } }
And when I now want to read my service characteristic I instead now changed the uuid and type to following:
static void repeated_timer_handler(void * p_context) { ret_code_t err_code; ble_uuid_t p_uuid = {.uuid = 0xF011, .type = BLE_UUID_TYPE_VENDOR_BEGIN}; ble_gattc_handle_range_t p_handle_range = {.start_handle = 0x0001, .end_handle = 0xFFFF}; err_code = sd_ble_gattc_char_value_by_uuid_read(connection_handle, &p_uuid, &p_handle_range); if(err_code != NRF_SUCCESS) { NRF_LOG_INFO("Failed to send read request to peer error = %d", err_code); } }
Am I calling the wrong function or do I have to perform some other function call in order to be able of requesting to read the following service?
I assume that I don't have to use the base uuid to call the specific service, or do I have to? I have seen that some examples perform a service discovery when initiating the connection, but if I know the characteristic uuid, do I still have to call this function? I tried adding this sd_ble_gattc_primary_services_discover function but didn't solve the problem.
Update: I have seen that some have used the sd_ble_gattc_read(connection_handle, 0xF011, 0) function. When I use this instead, I get no error but the value I get in the event handler has a length of 0.
Thanks in advance!
/Hadi