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

BLE UART issue

I run SDK 15.3  "examples \ ble_peripheral \ ble_app_uart"  in 52-DK .  and send UART data to nrf Connect in my Phone,  i found if i close the ble connect while TX Characteristic is open, and then reconnect ble connect and not open TX Characteristic, then send UART data to the Phone, the 52-DK would restart.  because of the "ble_nus_data_send" code return error 0x3401.

is it a bug in SDK?  for customer demand ,if the TX Characteristic is not open, the ble device can not restart or crash whatever ble device send data or not.

Parents
  • It seems like a bug to me.

    The error 0x3401 is BLE_ERROR_GATTS_SYS_ATTR_MISSING, which means that the ble stack does not know the state of the CCCD, and if notifications are enabled or not.

    When executing the steps you explained, you end up with a server device not knowing the state of the CCCD, and calling sd_ble_gatts_sys_attr_set() gives you BLE_ERROR_GATTS_SYS_ATTR_MISSING (0x3401). This should be handled by calling sd_ble_gatts_sys_attr_set() in response.

    However, I solved it by simply adding BLE_ERROR_GATTS_SYS_ATTR_MISSING as one of the errors to skip after ble_nus_data_send(). I think this is a valid solution, then nothing will happen on the 52-DK when trying to send data, and when notifications are enabled on the phone, it will work.

    .
    .
    .
    err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
        if ((err_code != NRF_ERROR_INVALID_STATE) &&
            (err_code != NRF_ERROR_RESOURCES) &&
            (err_code != NRF_ERROR_NOT_FOUND) &&
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)) //Added this
        {
            APP_ERROR_CHECK(err_code);
        }
    .
    .
    .

    Best regards,

    Simon

Reply
  • It seems like a bug to me.

    The error 0x3401 is BLE_ERROR_GATTS_SYS_ATTR_MISSING, which means that the ble stack does not know the state of the CCCD, and if notifications are enabled or not.

    When executing the steps you explained, you end up with a server device not knowing the state of the CCCD, and calling sd_ble_gatts_sys_attr_set() gives you BLE_ERROR_GATTS_SYS_ATTR_MISSING (0x3401). This should be handled by calling sd_ble_gatts_sys_attr_set() in response.

    However, I solved it by simply adding BLE_ERROR_GATTS_SYS_ATTR_MISSING as one of the errors to skip after ble_nus_data_send(). I think this is a valid solution, then nothing will happen on the 52-DK when trying to send data, and when notifications are enabled on the phone, it will work.

    .
    .
    .
    err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
        if ((err_code != NRF_ERROR_INVALID_STATE) &&
            (err_code != NRF_ERROR_RESOURCES) &&
            (err_code != NRF_ERROR_NOT_FOUND) &&
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)) //Added this
        {
            APP_ERROR_CHECK(err_code);
        }
    .
    .
    .

    Best regards,

    Simon

Children
No Data
Related