Problem setting wifi credentials on photon

hello,

i am want to present wifi credentials for a test device (photon, device os 3.3.0) for a customer. i am trying with my own network and i cannot get it added. see code below: photon connected to my network (using the particle app on the phone), it is in the list. the list is cleared and network is added but then does not show up in the list and the photon does not connect.

anyone any idea what i am doing wrong?!

thanks
frank

ps: i have also noticed that with newer device os after wifi listening and setting up via ap/phone the led will only breath green (and not go to breath cyan) even though it is connected to the cloud.

code:

    // does not startup connectivity only after Particle.connect() is called
    SYSTEM_MODE(SEMI_AUTOMATIC); 

    // allow loop to continue without wifi
    SYSTEM_THREAD(ENABLED);

    ....

    WiFiAccessPoint ap[5];
    int found = WiFi.getCredentials(ap, 5);
    Log.info("Found %d credentials:",found);
    for (int i = 0; i < found; i++) {
      Log.info("- ssid: %s, security: %d, cipher: %d", ap[i].ssid, (int) ap[i].security, (int) ap[i].cipher);
    }
    
    if(found!=2) {

      Log.info("Setting WiFi credentials");
      WiFi.clearCredentials();

      // Options are WPA2, WPA, or WEP
      // Cipher options are WLAN_CIPHER_AES, WLAN_CIPHER_TKIP and WLAN_CIPHER_AES_TKIP
      WiFi.setCredentials("qq", "....", WPA2, WLAN_CIPHER_AES);
    }


    delay(10000);

    found = WiFi.getCredentials(ap, 5);
    Log.info("Found %d credentials:",found);
    for (int i = 0; i < found; i++) {
      Log.info("- ssid: %s, security: %d, cipher: %d", ap[i].ssid, (int) ap[i].security, (int) ap[i].cipher);
    }

    Log.info("Try connect to cloud");

    Particle.connect();

output:

0000009109 [app] INFO: Found 1 credentials:
0000009109 [app] INFO: - ssid: qq, security: 3, cipher: 1
0000009110 [app] INFO: Setting WiFi credentials
0000019421 [app] INFO: Found 0 credentials:
0000019524 [app] INFO: Try connect to cloud

The breathing green when cloud connected is an issue that was brought up here: DeviceOs 2.2.0-rc2 seems to toast softAP connection to cloud
No fix has been pushed out for it though.

1 Like