Automatic switching between a 'regular' WiFi and an Phone hotspot not working

I have Photon running with Credentials for a regular WiFi network and credentials for an iPhone hotspot. Both are functioning well if I power up the system with only one of those networks being available. I was hoping that once one of those networks would be disabled, the other one would take over automatically

However, that is not the case: When one of them is switched off I have to power off the Photon, and then power on again before the other Photon connects to the other network.

Might this have something to do with one of these networks being a iPhone hotspot???

If not what could be a proper solution?

It should automatically switch. Is this a Photon 1 or Photon 2? Which version of Device OS?

When you switch off the network, what does the status LED do? Does it switch to blinking green?

Getting a debugging log may be helpful to see what it's doing.

It is aPhoton1, Device OS 2.3.0.

And it switches to blinking green, indeed.

That should work. I would add this to your firmware:

SerialLogHandler logHandler(LOG_LEVEL_TRACE);

and monitor the USB serial debug output, such as with particle serial monitor.

It's also a good idea to enable threading if you haven't already done so:

SYSTEM_THREAD(ENABLED);

And you actually have both credentials pre-configured, correct? You're not trying to do it manually from firmware.

About you last question:

For now I did setup the device for both networks; I believe that is what you call pre-configured, I assume.

However in my final application I intend also to let my application switch between networks using setCredentials() etc. Are there any pitfalls that I should avoid in doing so?