Particle.disconnect() after WiFi.clearCredentials() hangs photon

I am using SYSTEM_THREAD(ENABLED) and 0.8.0-RC.10

I have a user command that allows existing WAP credentials to be cleared. Excerpt as shown below. This works first time through but then on the second use will hang the photon. Is this because A. Particle.disconnect() is application thread blocking and B. WiFi.clearCredentials() has already disconnected the cloud connection?

                    if (WiFi.clearCredentials())
                        statusMessage("All WAP Credentials Cleared");
                        hasStoredCredentials = false;
                        isTriedConnectOnce = false;         //to ensure when reconnecting that particle connect is called once
                        WiFi.on();                          //bounce required to ensure the wifi module forgets it had creds

Would a solution be to test if connected before the Particle.disconnect();?

Let me ping someone that might be able to help, @rickkas7, @ParticleD, or @mstanley are you able to assist?

@KyleG Thanks for sweeping the posts. I have had a response related to this topic from @rickkas7 on a different thread WiFi.connect() are there any other parameters than WIFI_CONNECT_SKIP_LISTEN? and I was waiting for some further input. Maybe best to close this thread and refer to the other one?

1 Like