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

How to poll BLE events using nrf_sdh_evts_poll()? Please let me know if there is an example?

What I need?

I should be able to perform scanning, connecting, disconnecting and accessing service from main() (in a infinite while loop) rather than interrupts. I see that there is an API nrf_sdh_evts_poll(), but I am not able to get my application working with it. Please let me know if you have any example using BLE via polling.

Why I need this?

the nRF52840 chip is connected to a computer via UART and I'm not able to receive data at 115200 baud rate with hardware flow control when BLE is enabled (due to high priority interrupts). If I can access the BLE events in the main loop, then it would not harm UART data reception as there is no BLE interrupts.

Details:

SDK: 15.3

SD: s140_nrf52_6.1.1

MCU: nRF52840 in BLE central mode.

I'm stuck at a critical stage of my development, any help is highly appriciated.

  • Hello,

     

    I should be able to perform scanning, connecting, disconnecting and accessing service from main() (in a infinite while loop) rather than interrupts.

     What is the reason for this?

    The reason that the BLE stack has a high priority is that it is very time critical. If you would want to override this by having the BLE stack wait for finished UART transfers, then your BLE stack will not work properly. It will crash frequently, and you would have to restart your application. I don't think that is the behavior your are looking for.

    That being said. Can you elaborate what you mean by "I'm not able to receive data at 115200 baud rate with hardware flow control when BLE is enabled"? Do you get some bytes, but not all? Or do you not receive any bytes at all?

    What rate are you sending UART messages on?

    Have you seen the example found in:

    SDK15.3.0\examples\ble_peripheral\ble_app_uart? This example uses an interrupt driven UART with baudrate 115200. It is working fine with interrupts and the softdevice concurrently.

    Best regards,

    Edvin

Related