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

ble_app_uart_c multilink issue when I simultaneously connect more than 1 peripherals

Hi,

based on my previous posts (2nd post, 1st post) regarding the ble_app_uart_c multilink example I now face another issue.

When I run the multilink example on my nRF52840 DK and 5 devices have been already activated, an error: NRF_ERROR_BUSY is thrown in  BLE_GAP_EVT_CONNECTED event  of the ble_evt_handler(), after the ble_db_discovery_start() for the connected peripheral discovery of services.

Initially I removed the app_error_check()  ( after ble_db_discovery_start()) to see what will happen. All devices were able to connect to the DK (central) but only 2 of them wee able to accept commands from the central. The other two did nothing. I repeated the process 2 more times with the same result.

Then I placed the following part under ble_db_discovery_start() to wait until the process is complete

err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
while(err_code == NRF_ERROR_BUSY)
{
   err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
   NRF_LOG_INFO("Discovery in progress"); 
   
}

but the code freezes somewhere in the ble_db_discovery_start() when the second peripheral device is identified by the central.

On the other hand when the five peripheral devices are turned off and I activate them one by one the central never throws an error and all devices are connected and handled properly

So, any ideas ?

Thank you for your time

Parents
  • but the code freezes somewhere in the ble_db_discovery_start() when the second peripheral device is identified by the central.

    It is possible to get the context of where the MCU is looping when you start the program in the debugger. Getting the context of this stuck/freeze state is important to get some idea on how to diagnose this situation.

    More code snippets on your changes would also be helpful.

Reply
  • but the code freezes somewhere in the ble_db_discovery_start() when the second peripheral device is identified by the central.

    It is possible to get the context of where the MCU is looping when you start the program in the debugger. Getting the context of this stuck/freeze state is important to get some idea on how to diagnose this situation.

    More code snippets on your changes would also be helpful.

Children
  • Hi,  as I said in my first post...

    When I run the multilink example on my nRF52840 DK and 5 devices have been already activated, error: NRF_ERROR_BUSY is thrown in  BLE_GAP_EVT_CONNECTED event  of the ble_evt_handler(), after the ble_db_discovery_start().

    On the other hand when the five peripheral devices are already turned off and I activate them one by one the central never throws an error and all devices are connected and handled properly.

    the point where the error is thrown in the ble_evt_handler() is here

    err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);         
    APP_ERROR_CHECK(err_code);  

    And this error comes from this part inside ble_db_discovery_start()

    if (p_db_discovery->discovery_in_progress)
    {
        return NRF_ERROR_BUSY;
    }

    and I cannot find out why it cannot complete the discovery  and furthermore why it happens always on the second device.

  • Sorry for missing the initial points.

    masterLee said:
    and I cannot find out why it cannot complete the discovery  and furthermore why it happens always on the second device.

    The only way NRF_ERROR_BUSY is thrown with ble_db_discovery_start is when the discovery procedure has already started and is in progress while you requested to start the discovery again. So we need to check where the discovery has started before this. Air sniffer logs using wireshark or Ellysis sniffer would give you more insights into this.

  • I think I fixed it at some point...
    I increased the advertising interval of the peripheral devices to 1024. Sometimes the error is thrown again but most of the times it works and all the devices are connected .

    It takes longer for all the devices to be connected to the central though.

    It seems to me that the ble_db_discovery_start() cannot handle many connection events from peripheral devices that occur in close time periods. I don;t know if that makes sense but in practice it seems like that

Related