I am trying to troubleshoot a problem wherein the nRF5340 stops advertising and won't resume once a central has connected to it and disconnected. Occasionally, I am able to connect to the nRF5340, transfer some data, disconnect and have advertising resume. But more than half the time it will not resume and I can't get it to advertise again until I have reset the device.
My first thought was to debug this with printk statements to UART, which I already have in place. I re-enable the UART in prj.conf and in the devicetree overlay and am able to get debug statements, but if the UART is enabled, the problem never happens. Unfortunately, I cannot just leave the UART enabled and call it good, because of the need to minimize power consumption.
I've read a number of similar posts here on DevZone, but have not yet found anything that helps me to pin down the cause of the issue. I did note one poster observed removing some print statements seemed to magically fix the issue, and given the behavior varies with enabling the UART, I went through the parts of our code that seem related and commented out all printk statements, but no magic happened.
Loosely, my architecture is I have another micro sending commands to the nRF5340 via SPI. The app core communicates with the net core via HCI to provide BTLE functionality.
I am using nRF Connect SDK version 1.7.1 and VSCode.
The nRF5340 resides on a custom board in a Fanstel BT40F module. I program and debug using an external J-Link.
I have the disconnected callback set thus:
Any pointers as to where I might ought to be investigating, or tools that might be useful in cracking the mystery, would be greatly appreciated. The fact that enabling the UART makes the problem go away takes away one of my best troubleshooting tools!
Scott