WiFi.setCredentials fail to save an offline network

I am running this program on a Photon with firmware v3.0.0.

During listening mode (SYSTEM_MODE(SEMI_AUTOMATIC); SYSTEM_THREAD(ENABLED); ) I pass the arguments to the function: ssid, password, security and cipher.

If the network is available, the photon works fine, but if the networks is not there it is not stored.

In my code I check the saved networks before and after to verify if it was saved. When I try it wit an offline network, allways fails

        mem = WiFi.getCredentials(ap, 5);
        Serial.printlnf("Networks saved  before:%d",mem);       


        mem = WiFi.getCredentials(ap, 5);
        Serial.printlnf("Networks saved after:%d",mem); 

What could make this process to fail?

Very interesting. I think there has been a change in behaviours with V3.0.0 (which I haven’t used) that has been now back ported to the LTS 2.2.0-RC.1. I have just noticed very different behaviour at startup where there is no WAP available for the credential(s) stored. It now tries for a bit and then turns off the WiFi if it can’t connect. This avoids other problems with SPI and I2C.