This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Get error 0x08: GATT_CONN_TIMEOUT when transmit data to mobile application continuosly.

Dear DevZone Team,

I am developing a application on nrf51822 with SDK 11 and face a problem.

The thing is during connection time, I was trying to transmit data via bluetooth contiounsly (period is around 100 ms). Each packet is from 5 to 20 bytes.

After 2-3 mins, I got error from nrf connect said that Error 0x08: GATT_CONN_TIMEOUT. 

In logging screen via JLinkViewer, it just stopped and did not come back to advertising state. 

I have tried to change the code for clock configuration: 

xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM and 500, 20, 50 and it's still not work. 

Any suggestion on how to fix this? Thank you very much.

Parents Reply Children
  • Hi,

    Well, I have tried and fix it, I tried to call malloc function before every time I send data to phone via notification all the time, and somehow delete it fix this. Maybe because of the memory error? 

    void bluetooth_send(uint8_t* data, uint16_t len)
    {
        uint8_t * p_data = (uint8_t*) malloc ( sizeof(data) + 2* sizeof(uint8_t);
        p_data[0] = 0xFF;
        p_data[1] = 0xFF;
        for(uint8_t i = 0; i < len; i ++)
        {
            p_data[i+2] = data[i];
        }
    	if (len <= 18)
    	{
    		ble_nus_string_send(&m_nus, p_data, len + 2);
    	}
    	else
    	{
    		ble_nus_string_send(&m_nus, p_data, 20);
    		ble_nus_string_send(&m_nus, p_data + 20, len - 18);
    	}
    }

    And then I just delete and it looks like this:

    void bluetooth_send(uint8_t* data, uint16_t len)
    {
    	if (len <= 20)
    	{
    		ble_nus_string_send(&m_nus, data, len + 2);
    	}
    	else
    	{
    		ble_nus_string_send(&m_nus, data, 20);
    		ble_nus_string_send(&m_nus, data + 20, len - 20);
    	}
    }

    And it works, and I add 2 headers before I go into this function. I dont know why it not works with the malloc function.

    The function it looks like this: 

    uint32_t ble_nus_string_send(ble_nus_t *p_nus, uint8_t *p_string, uint16_t length)
    {
        ble_gatts_hvx_params_t hvx_params;
    
        VERIFY_PARAM_NOT_NULL(p_nus);
    
        if ((p_nus->conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_nus->is_notification_enabled))
        {
            return NRF_ERROR_INVALID_STATE;
        }
    
        if (length > BLE_NUS_MAX_DATA_LEN)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
    
        memset(&hvx_params, 0, sizeof(hvx_params));
    
        hvx_params.handle = p_nus->rx_handles.value_handle;
        hvx_params.p_data = p_string;
        hvx_params.p_len = &length;
        hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
    
        return sd_ble_gatts_hvx(p_nus->conn_handle, &hvx_params);
    }

  • Take a look at this thread regarding the use of malloc.

    Also if you could turn on either UART or RTT logging, and capture the error caused by the chip, that would help getting to the bottom of the issue.

    Best regards,

    Simon

Related