Bluetooth callback is not called occasionally in multi-threaded application

Hi team,

I am using nRFConnect SDK v2.2.0, and developing multi-threaded application which has BLE and ethernet.

I had three thread, each has the same priority of 7.

The first one is BLE central thread, and starting scan and connect, send/receive data to device, and disconnect.

The second one is running MQTT client, and waiting for message from the network.

The third one is running DHCP client and monitoring network management events.

When the second thread received message from internet, it sends signal to start BLE scan to the first thread, and by sequential calling Bluetooth event callback, the first thread is sending/receiving data to some other BLE device.

If all the bluetooth callback is called properly, the first thread will finish its function properly, but sometimes BLE callback is not called and the thread is blocked.

When I manually send signal via shell or something, it works fine, but the second thread sends signal, the callback is not called from time to time.

Specifically, after connected callback is called, no further callbacks like MTU exchange or GATT discover is called any more.

More strange point is that I schedule a delayed work to cancel work after specified timeout, but delayed work is not started, too.

I think some data related to the scheduler or work queue is corrupted, but don't know how can I fix this.

There is no crash log or error log displayed, and increasing privileged stack size does not fix problem.

Related