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

Multiperipheral NUS crashes

Module: ilumi H52 BLE module (nRF52832)
SDK: nRF5_SDK_15.2.0_9412b96
Softdevice: 132_nrf52_6.1.0_softdevice.hex
Compiler: gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (15:7-2018-q2-4)


I have integrated the code from example "ble_app_uart" into example "ble_app_multiperipheral". Unfortunately there is some strange behaviour:

(1) NUS in single- and multiperipheral mode:
If I send debug information to UART instantly after connection established, the module crashes.

(2) NUS in single peripheral mode:
NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 1
NRF_SDH_BLE_GATT_MAX_MTU_SIZE = 247

If I send a big amount of data from UART to BLE the modules crashes sometimes. I can't figure out why.

(3) NUS in multiperipheral mode:
NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 3
NRF_SDH_BLE_GATT_MAX_MTU_SIZE = 247 / NRF_SDH_BLE_PERIPHERAL_LINK_COUNT

The module crashes frequently. It depends on how much data is sent from UART to BLE. It does not depend on of how many central devices are connected.

for (uint8_t i = 0; i < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; i++)
{
  if (m_qwr[i].conn_handle != BLE_CONN_HANDLE_INVALID)
  {
    do
    {
      uint16_t length = (uint16_t)uart_rx_index;
      err_code = ble_nus_data_send(&m_nus, uart_rx_data_array, &length, m_qwr[i].conn_handle);
      if ((err_code != NRF_ERROR_INVALID_STATE) && \
          (err_code != NRF_ERROR_RESOURCES) && \
          (err_code != NRF_ERROR_NOT_FOUND))
      {
        APP_ERROR_CHECK(err_code);
      }
    } while (err_code == NRF_ERROR_RESOURCES);
  }
}


I have no idea how to figure out the reason. How can I check if BLE buffer is full? What ways of debugging can I use to figure out why the module crashes?

  • Why does an UART frame error lead to a fatal error?

    Or are you asking why Nordic chose to make UART Frame errors Fatal?

    That is, indeed, a good question!

  • I've disabled APP_ERROR_HANDLER.

    The error messages have disapeared. But the communication is very slow and the module still crashes if a large amount of data is sent (without RTT messages). "Slow" means approximately 1200 Baud data throughput. What could be the reason? How to debug?

    Back to one of my initial questions: How can I check if BLE buffer is full?

    err_code = ble_nus_data_send(&m_nus, uart_rx_data_array, &length, m_qwr[i].conn_handle);

    I can send data to BLE. But how do I know if data can't be sent?

  • Remember that BLE is not designed for either large volumes of data, or for high speed data.

    Are you sending individual bytes, or are you collecting bytes until you have a full "frame" ?

    how do I know if data can't be sent?

    That's what the do...while loop is about in the code you posted:

     do
        {
          uint16_t length = (uint16_t)uart_rx_index;
          err_code = ble_nus_data_send(&m_nus, uart_rx_data_array, &length, m_qwr[i].conn_handle);
          if ((err_code != NRF_ERROR_INVALID_STATE) && \
              (err_code != NRF_ERROR_RESOURCES) && \
              (err_code != NRF_ERROR_NOT_FOUND))
          {
            APP_ERROR_CHECK(err_code);
          }
        } while (err_code == NRF_ERROR_RESOURCES);

  • Remember that BLE is not designed for either large volumes of data, or for high speed data.

    I've tested different BLE modules before and the desired data throughput (about 80 kBaud) has never been a problem.

    Are you sending individual bytes, or are you collecting bytes until you have a full "frame" ?

    Bytes are collected and sent every 10 ms or if (uart_rx_index >= m_ble_nus_max_data_len).

    I'd like to know where the UART communication errors arise.

    case APP_UART_COMMUNICATION_ERROR:
    {
      NRF_LOG_ERROR("APP_UART_COMMUNICATION_ERROR");
      break;
    }

    <info> app: Multiperipheral example started.
    <info> app: Connection with link 0x0 established.
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <error> app: APP_UART_COMMUNICATION_ERROR
    <info> app: Data len is set to 0x4F(79)

Related