Listening Mode Blocks setup() Even In Manual Mode

I’m working on a way to provision WiFi credentials through an app over BLE to an Argon (and soon a P2). Right now I start this provisioning process in setup() if either the device has no credentials or if it isn’t able to connect to WiFi in a set timeout. However, when I’m testing this by clearing the credentials and then attempting to provision them, the device enters listening mode on reset, I assume because it now has no saved credentials. My problem is that setup() is apparently never called while in listening mode, even with the system mode set to manual. How to I get setup() to run while listening mode is on?

Also, I should mention, I am using system_thread(enabled) as well

An extremely hacky way I’ve gotten this to work is to ensure devices always have one fake WiFi ssid and password saved to prevent it from entering listening mode at all, and using the BLE provisioning if there is exactly one credential saved and it is for this fake network.

This is extremely convoluted however and I’d love it if there was a way to run setup() in listening mode, or (even better) if there was a way to disable automatically going into listening mode when no credentials are saved.

That’s not what’s supposed to happen with system thread enabled. Which device and which version of Device OS are you using?

Right now I’m using an Argon running 4.0.0; I’d like to use this firmware with the P2 in the future as well but I haven’t had a chance to debug it on a P2 yet.

Is only system_thread(enabled) usually necessary to accomplish this or is it also necessary to set the system mode to non-automatic?

Some more odd behavior: it seems that setup() is somehow being called, because I added a line to change the RGB color at the beginning of setup() if there are no WiFi credentials, and this is happening. However, nothing else is happening. The device is not showing up on BLE scans, and it isn’t logging anything to serial, even though it should be entering a while loop as long as it isn’t connected to the cloud.