I am periodically scanning wifi access points as well as using connected cell tower info for location tracking using B404X on device os 5.6.0. I am running into an issue where some of my threads die and I believe the culprit may be my cell scanning.
However, I do this in a separate thread. If I comment out the cellular scanning portion of my code, I can repeatedly trigger the wifi portion of the scan without issue, but if I place cell scanning back in, it runs fine except that I never hear from the main thread again (I am logging from each thread once a second).
Do I need to use some system lock or something when using cellular_global_identity()? I tried cellular.lock(), but it didn't help.
Perhaps there is a better way to get the cell info I need? I need cid, lac, mcc, and mnc. I was looking at CellularHelper, but that is also just using cellular_global_identity under the hood, so I don't think using that would resolve the issue.
You should only use cellular_global_identity. On Gen 3 devices you can't use the AT command directly because the result is a URC that can't be read from Cellular.command.
I'd make sure your worker thread stack is large enough. My guess is that it's getting stuck after it obtains a lock, which eventually deadlocks the system thread and application threads.
You could also try running cellular_global_identity periodically from loop instead, and saving the results globally to see if that makes a difference. If it does, that would be useful data, even if it's not the solution you want to use.
The worker thread that was calling cellular_global_identity had a stack of 4K. It was the only thread that I could tell was running after cell scanning (idk about system threads). I boosted its stack size to 6K, no change.
I move the cell scanning code to main loop and saved the results globally, this is working.