Threads and BLE

Hello, 

I've been running into some issues while using BLE and threads.\

I have two threads that run every 'n' seconds. Each thread suspends itself when it is done doing what it has to do, which is to notify some data to a central device using BLE.

The issue is, that the nRF52840 resets itself when I call bt_svc_notify() from each thread. The application works fine when I only notify from one thread, but when I add bt_svc_notify() to both threads, the system crashes and reboots itself. 

I imagine it has something to do with not properly releasing the BLE module resource before each threads suspends itself. 

Any idea on how to solve this issue?

Thanks in advance, 

Hector

  • Hi Hector,

    Generally, there should not be any issue making Bluetooth API calls from different threads. There is no bt_svc_notify() in the SDK (Zephyr Bluetooth APIs), though. Is this your own function, or do you mean another (perhaps bt_gatt_notify())?

    Also, what do you see in the log before the reset? If you enable debug logging, you will in many cases find useful information about the fault in the log.

Related