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

BLE Peripheral NUS connected to multiple Central devices on nrf52840 S140 and SDK V16.0.0

Hello,

Is it possible to configure the board as a peripheral device that provides the Nordic UART Service and allows multiple central devices to connect and exchange data.

Sort of like the "usbd_ble_uart_freertos" example but allows more than one Central device to connect at the same time.

Thanks

Omid

Parents
  • Thanks very much

    I checked that out and it sure works as expected.  For our project we have modified the "usbd_ble_uart_freertos" and when I attempted to change the NRF_SDH_BLE_PERIPHERAL_LINK_COUNT  to allow for multi connections the build is successful but I get the following error @ runtime

    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at /home/nikola/gitlabRepo/nikola-nordic-ble/nikola_nRF5_SDK_16.0.0/nikola-ws/nikola/nikola-ble/main.c:583
    PC at: 0x0003965B
    <error> app: End of error report

    It occurs at this instruction

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    Thanks for your help

  • If you have enabled logging, the log probably says something about some recommended RAM settings right before it returns this error. You should change the RAM settings accordingly. Let me know what IDE you are using, if you are not sure how to do this in your project. The lines you should look for should look something like this:

    RAM start location can be adjusted to 0x...
    
    RAM size for application can be adjusted to 0x...

    The simple reason for this is that if you want to support more connections, the softdevice requires more RAM in order to hold the information for the multiple devices' services and characteristics.

    Best regards,

    Edvin

  • Hi Edvin,

    So I guess the reason I couldn't see the debug output is because I am using the "usbd_ble_uart_freertos" example and the logger task does not get the chance to output before the fault handler stops the execution.

    Any way I was able to find the ram_start location and the ram max size and changed them in the Linker "Section Placement Macros" and now I am able to build and run the app.  I also placed the code to restart advertising after a connection provided the num_peripherals is less than the MAX

    if (periph_link_cnt < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT)
    {
    // Continue advertising. More connections can be established because the maximum link count has not been reached.
    advertising_start(NULL);
    }

    It appears I still have some issues because the moment I connect the board crashes in the softdevice_task when it tries to start advertising again.  I am probably missing an important piece of the puzzle.

    Would you be able to modify the "usbd_ble_uart_freertos"  SDK 16.0.0 , pca10056 example to handle multiple connections.  Our application requires the rtos version because we need to spawn other tasks for other functionality.

    I would much appreciate your help.

  • I am not that experienced with FreeRTOS. Why don't you explain kind of issues you encounter when you establish the connection? Is it the error handler that kicks in? Is it a hardfault? (NB Hardfault != Error handler). 

    It is probably a bit too late, but do you really need FreeRTOS? In my experience many users think they need it, but it creates more issues than it solves. Usually, you can use interrupts and timers to do pretty much everything that you need.

  • Hi Edvin,

    To make this effort more manageable I took the "ble_app_uart" example which does not use the rtos and attempted to establish multiple central connections,

    Changed the NRF_SDH_BLE_PERIPHERAL_LINK_COUNT  to 2

    Set up the linker Linker Section Placement correctly

    I also included the code to restart the advertising once  the first connection is established in the ble_evt_handler.

    The program stops with this error as soon as the first connection is established.

    <info> app_timer: RTC: initialized.
    <info> app: Debug logging for UART over RTT started.
    <info> app: Connected
    <error> app: ERROR 18 [NRF_ERROR_CONN_COUNT] at /home/nikola/Nordic-tools/nRF5_SDK_16.0.0_98a08e2/examples/ble_peripheral/ble_app_uart/main.c:700
    PC at: 0x000305FD
    <error> app: End of error report

    If I remove the code that restarts the advertising the app works fine.  Obviously there are other modifications that I need to make but have not been able to make any progress.

    I have zipped and attached the project.

    I work for NikolaMotor https://nikolamotor.com/ and this project is for providing remote access to our trucks.  Nordic sales team was very excited to hear that we have chosen nrf52840 for our production.  At this point I am in a situation that requires me to demonstrate multiple connections with ble_uart service.  I appreciate your help. 

    Regards

    4606.ble_app_uart.zip

  • I see that you didn't change NRF_SDH_BLE_TOTAL_LINK_COUNT as well as NRF_SDH_BLE_PERIPHERAL_LINK_COUNT.

    I don't know why NRF_SDH_BLE_TOTAL_LINK_COUNT isn't dynamic (just adding NRF_SDH_BLE_PERIPHERAL_LINK_COUNT and NRF_SDH_BLE_CENTRAL_LINK_COUNT), but I tested your project. Setting NRF_SDH_BLE_TOTAL_LINK_COUNT to 2, and adjusting to the RAM settings again made the peripheral able to keep advertising after the first connection was made. Also, there were no issues when I connected the second device.

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks very much for your help. That certainly was what I was missing. It is working fine.

    Regards

Reply Children
No Data
Related