This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with Characteristic read out with sd_ble_gattc_read()

Hello everyone,

I went through the forum and saw some topics regarding the implementation of the characteristic read out over sd_ble_gattc_read. I implemented it as desribed in the other post, but I am not able to read out the characteristic values...

As basis for my Software I am using the Multirole example with LE and MITM security. What I did was I replaced the Hearte Rate Service with an Custom Service. Within my Custom Service I implemented a characteristic. With the NRF connect App I am able to connect and bond to my NRF52832. I am also able to read out the value and write into the value.

My next step was to pair two NRF52832 with each other and let the one read out the value from the other one. Therefore I am starting both chips they are pairing and I start with the sd_ble_gattc_read() function within the main().

        if (m_conn_handle_hrs_c != BLE_CONN_HANDLE_INVALID)
        {
        nrf_delay_ms(500); // Has to be added to the QWR bla
        ret_code_t             err_code;

        err_code= sd_ble_gattc_read(m_conn_handle_hrs_c, m_data_value , read_char_offset);
        
        APP_ERROR_CHECK(err_code);
        }

I didn´t know what to put for the m_data_value handler so there is a simple NULL behind. The read_char_offset starts with a 0 ( first of all I try only to read data <20byte).

After that I jump into my "on_ble_evt" with BLE_GATTC_EVT_READ_RSP.

static void on_ble_evt(uint16_t conn_handle, ble_evt_t const * p_ble_evt)
{
    char        passkey[BLE_GAP_PASSKEY_LEN + 1];
    uint16_t    role = ble_conn_state_role(conn_handle);

    pm_handler_secure_on_connection(p_ble_evt);
    
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GATTC_EVT_READ_RSP:
        if (m_conn_handle_hrs_c != BLE_CONN_HANDLE_INVALID)
        {
        NRF_LOG_DEBUG("GATTC Read response.");

          ble_gattc_evt_read_rsp_t data;
        
          data = p_ble_evt->evt.gattc_evt.params.read_rsp;
          read_data = p_ble_evt->evt.gattc_evt.params.read_rsp.data;
     }
        break;

The code is jumping into the event and everything is going well. The only problem is I dont get any data from my peripheral chip. I dont get any information for the length and also for the data.

I really searched long and was not able to find the problem. I hope you guys can help me. I think I forget something but cant find it.

Best regards!

Related