Argon WiFi.setCredentials not working as expected

I’ve tried using Wifi.setCredentials("SSSSS","PPPPP",WPA2,WLAN_CIPHER_AES_TKIP;) both in setup() as well as a STARTUP function without success on an Argon for a non-hidden WiFi network as a test at home. So…I’m a bit confused myself. Yes, SSSSS and PPPPP are placeholders for the real credentials. The application has no other code in it and is running on a 1.5.2 Argon. It configures fine via the CLI and the app.

Have you spun up the WiFi coprocessor via WiFi.on() before setting credentials?

Yes, I did. I tried in setup() as well as in a STARTUP() function–different versions of the program. However, the device simply remains in listening mode throughout, even when reset. So…I’m doing something wrong, but can’t see it.

I didn’t think WiFi.on() needed called unless I had turned WiFi off or had it in something than AUTOMATIC mode. As I stated earlier, my application consists only of the aforementioned WiFi commands.

I have just tested this and it works as expected

SYSTEM_THREAD(ENABLED)
SYSTEM_MODE(SEMI_AUTOMATIC)

void setCreds() {
    WiFi.on();
    delay(10);
    WiFi.setCredentials("SSID", "PWD", WPA2, WLAN_CIPHER_AES_TKIP);
    delay(10);
    WiFi.off();
    Particle.connect();
}

STARTUP(setCreds())

The delays and WiFi restart are just for safe measure, but it should be a valid starting point.
You can try cutting this down as far as possible.

I tried the following code and now I’m getting and S.O.S. with 1 red blink. Obviously, I need another coffee this morning.

SYSTEM_THREAD(ENABLED)
SYSTEM_MODE(SEMI_AUTOMATIC)

void setCreds() {
    WiFi.on();
    delay(10);
    WiFi.setCredentials("SSID", "PPP", WPA2, WLAN_CIPHER_AES_TKIP);
    delay(10);
    WiFi.off();
    Particle.connect();
}

STARTUP(setCreds())

void setup() {

}

void loop() {

}

What device OS version are you running? I did it on a Photon against v2.0.0.-rc.2.

(as the original thread this has been split off was tagged “photon”)

With Argon v1.5.2 I also get SOS+1 - not really great UX I must say :flushed:
Just tested Argon v2.0.0-rc.2: Same SOS+1 (even omitted the security cypher as it is not shown in the doc samples)

As it seems you cannot use WiFi.setCredentials() in a STARTUP() macro on the Argon - something the would - at least - need documenting but better fixing IMHO.

@no1089, I guess this is also a bug that would need logging :wink:

@ScruffR, yes, sorry for posting on the wrong thread, but I “assumed” (duh) it was a more common issue. As you tested, the device is running 1.5.2. Does it require being in a STARTUP() function or can it be called in setup()? Just curious for future reference.

The logical place would be STARTUP() as you typically want the credentials set as early as possible even before the cloud spin-up starts.
But since that’s not possible on the Argon, it has to be in setup() but then you cannot run AUTOMATIC mode without SYSTEM_THREAD(ENABLED) as setup() will not be executed before the device falls into Listening Mode if there aren’t already valid credentials stored and the connection can be made.

I continue to have issues with this device at the installed location (not in my office). I had entered the credentials for the hidden network via particle serial wifi, but it never connected to the network. I installed the argon.bin WiFi debug program and have the following output, but can’t tell what’s happening. Any guidance would be greatly appreciated. I’m about to throw in the towel and simply install a Boron and get on with life.

The output from the debug program:

Serial monitor opened successfully:
0000007411 [gsm0710muxer] INFO: Resuming channel 1
0000007413 [gsm0710muxer] INFO: Resuming channel 1
0000007415 [ncp.at] TRACE: > AT
0000007466 [ncp.at] TRACE: < OK
0000007467 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000007516 [ncp.at] TRACE: < OK
0000007517 [hal] TRACE: NCP state changed: 1
0000007518 [net.esp32ncp] TRACE: NCP event 1
0000007520 [ncp.at] TRACE: > AT+CWLAP
0000010067 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-65,"d8:54:a2:63:95:d4",11)
SSID=CFA-BYOD security=wpa2 channel=11 rssi=-65
0000010073 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-65,"d8:54:a2:63:95:d8",11)
SSID=CFA-Wifi security=unsecured channel=11 rssi=-65
0000010077 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-67,"d8:54:a2:63:95:d5",11)
SSID=CFA-Guest security=unsecured channel=11 rssi=-67
0000010081 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-67,"d8:54:a2:63:95:d7",11)
SSID=CFA-Vistors security=wpa2 channel=11 rssi=-67
0000010085 [ncp.at] TRACE: < +CWLAP:(3,"",-67,"d8:54:a2:63:95:d6",11)
SSID= security=wpa2 channel=11 rssi=-67
0000010089 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-77,"d8:54:a2:62:48:17",6)
SSID=CFA-Vistors security=wpa2 channel=6 rssi=-77
0000010093 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-77,"d8:54:a2:62:48:15",6)
SSID=CFA-Guest security=unsecured channel=6 rssi=-77
0000010096 [ncp.at] TRACE: < +CWLAP:(3,"",-77,"d8:54:a2:62:48:16",6)
SSID= security=wpa2 channel=6 rssi=-77
0000010100 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-81,"d8:54:a2:62:48:14",6)
SSID=CFA-BYOD security=wpa2 channel=6 rssi=-81
0000010103 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-81,"d8:54:a2:62:48:18",6)
SSID=CFA-Wifi security=unsecured channel=6 rssi=-81
0000010107 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-87,"d8:54:a2:62:97:d7",6)
SSID=CFA-Vistors security=wpa2 channel=6 rssi=-87
0000010111 [ncp.at] TRACE: < +CWLAP:(3,"",-88,"d8:54:a2:62:97:d6",6)
SSID= security=wpa2 channel=6 rssi=-88
0000010115 [ncp.at] TRACE: < +CWLAP:(3,"CFA",-89,"74:8a:0d:ff:2f:54",6)
SSID=CFA security=wpa2 channel=6 rssi=-89
0000010118 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-92,"d8:54:a2:62:a3:17",11)
SSID=CFA-Vistors security=wpa2 channel=11 rssi=-92
0000010122 [ncp.at] TRACE: < +CWLAP:(3,"",-92,"c8:67:5e:81:4b:d6",11)
SSID= security=wpa2 channel=11 rssi=-92
0000010126 [ncp.at] TRACE: < +CWLAP:(3,"",-93,"d8:54:a2:62:a3:16",11)
SSID= security=wpa2 channel=11 rssi=-93
0000010129 [ncp.at] TRACE: < +CWLAP:(3,"",-94,"d8:54:a2:62:35:16",1)
SSID= security=wpa2 channel=1 rssi=-94
0000010133 [ncp.at] TRACE: < OK
connecting to WiFi
0000010141 [system.nm] INFO: State changed: IFACE_DOWN -> IFACE_REQUEST_UP
0000010145 [net.ifapi] INFO: Netif wl3 state UP
0000010147 [system.nm] INFO: State changed: IFACE_REQUEST_UP -> IFACE_UP
0000010154 [ncp.at] TRACE: > AT+CWLAP
0000012673 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-65,"d8:54:a2:63:95:d4",11)
0000012676 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-65,"d8:54:a2:63:95:d8",11)
0000012679 [ncp.at] TRACE: < +CWLAP:(3,"",-67,"d8:54:a2:63:95:d6",11)
0000012681 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-68,"d8:54:a2:63:95:d5",11)
0000012683 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-68,"d8:54:a2:63:95:d7",11)
0000012686 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-78,"d8:54:a2:62:48:17",6)
0000012689 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-79,"d8:54:a2:62:48:18",6)
0000012691 [ncp.at] TRACE: < +CWLAP:(3,"",-79,"d8:54:a2:62:48:16",6)
0000012693 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-80,"d8:54:a2:62:48:14",6)
0000012696 [ncp.at] TRACE: < +CWLAP:(3,"CFA",-89,"74:8a:0d:ff:2f:54",6)
0000012698 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-91,"d8:54:a2:62:48:15",6)
0000012701 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-91,"c8:67:5e:81:4b:d7",11)
0000012703 [ncp.at] TRACE: < +CWLAP:(3,"",-94,"c8:67:5e:81:4b:d6",11)
0000012705 [ncp.at] TRACE: < OK
0000012707 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170
0000012708 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000012710 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000012712 [gsm0710muxer] INFO: Closing all muxed channels
0000012713 [gsm0710muxer] INFO: Closing mux channel 1
0000012715 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000012716 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000012718 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000012820 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000012872 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000012874 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000012876 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000012877 [hal] TRACE: NCP state changed: 0
0000012879 [net.esp32ncp] TRACE: NCP event 1
0000014286 [ncp.at] TRACE: > AT
0000014287 [ncp.at] TRACE: < OK
0000015288 [hal] TRACE: NCP ready to accept AT commands
0000015289 [ncp.at] TRACE: > AT+CMUX=0
0000015291 [ncp.at] TRACE: < OK
0000015292 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000015294 [gsm0710muxer] INFO: Openning mux channel 0
0000015295 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000015348 [gsm0710muxer] INFO: Resuming channel 0
0000015349 [gsm0710muxer] INFO: Openning mux channel 1
0000015450 [gsm0710muxer] INFO: Resuming channel 1
0000015451 [gsm0710muxer] INFO: Resuming channel 1
0000015453 [ncp.at] TRACE: > AT
0000015504 [ncp.at] TRACE: < OK
0000015505 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000015554 [ncp.at] TRACE: < OK
0000015555 [hal] TRACE: NCP state changed: 1
0000015556 [net.esp32ncp] TRACE: NCP event 1
0000015560 [ncp.at] TRACE: > AT+CWLAP
0000018105 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-64,"d8:54:a2:63:95:d4",11)
0000018108 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-64,"d8:54:a2:63:95:d8",11)
0000018110 [ncp.at] TRACE: < +CWLAP:(3,"",-65,"d8:54:a2:63:95:d6",11)
0000018112 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-68,"d8:54:a2:63:95:d5",11)
0000018114 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-68,"d8:54:a2:63:95:d7",11)
0000018117 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-76,"d8:54:a2:62:48:17",6)
0000018119 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-77,"d8:54:a2:62:48:15",6)
0000018121 [ncp.at] TRACE: < +CWLAP:(3,"",-77,"d8:54:a2:62:48:16",6)
0000018123 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-79,"d8:54:a2:62:48:18",6)
0000018126 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-85,"d8:54:a2:62:97:d7",6)
0000018128 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-87,"d8:54:a2:62:35:17",1)
0000018130 [ncp.at] TRACE: < +CWLAP:(3,"",-89,"d8:54:a2:62:97:d6",6)
0000018133 [ncp.at] TRACE: < OK
0000018134 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170
0000018136 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000018137 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000018139 [gsm0710muxer] INFO: Closing all muxed channels
0000018141 [gsm0710muxer] INFO: Closing mux channel 1
0000018143 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000018145 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000018146 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000018248 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000018299 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000018301 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000018303 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000018305 [hal] TRACE: NCP state changed: 0
0000018306 [net.esp32ncp] TRACE: NCP event 1
0000019713 [ncp.at] TRACE: > AT
0000019714 [ncp.at] TRACE: < OK
0000020715 [hal] TRACE: NCP ready to accept AT commands
0000020716 [ncp.at] TRACE: > AT+CMUX=0
0000020718 [ncp.at] TRACE: < OK
0000020719 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000020721 [gsm0710muxer] INFO: Openning mux channel 0
0000020722 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000020774 [gsm0710muxer] INFO: Resuming channel 0
0000020776 [gsm0710muxer] INFO: Openning mux channel 1
0000020877 [gsm0710muxer] INFO: Resuming channel 1
0000020879 [gsm0710muxer] INFO: Resuming channel 1
0000020881 [ncp.at] TRACE: > AT
0000020932 [ncp.at] TRACE: < OK
0000020933 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000020982 [ncp.at] TRACE: < OK
0000020983 [hal] TRACE: NCP state changed: 1
0000020985 [net.esp32ncp] TRACE: NCP event 1
0000020988 [ncp.at] TRACE: > AT+CWLAP
0000023533 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-65,"d8:54:a2:63:95:d4",11)
0000023536 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-65,"d8:54:a2:63:95:d8",11)
0000023539 [ncp.at] TRACE: < +CWLAP:(3,"",-66,"d8:54:a2:63:95:d6",11)
0000023541 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-68,"d8:54:a2:63:95:d5",11)
0000023544 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-69,"d8:54:a2:63:95:d7",11)
0000023546 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-76,"d8:54:a2:62:48:17",6)
0000023549 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-78,"d8:54:a2:62:48:15",6)
0000023552 [ncp.at] TRACE: < +CWLAP:(3,"",-79,"d8:54:a2:62:48:16",6)
0000023554 [ncp.at] TRACE: < +CWLAP:(5,"CFA-Wifi",-80,"d8:54:a2:62:48:18",6)
0000023556 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-81,"d8:54:a2:62:48:14",6)
0000023559 [ncp.at] TRACE: < +CWLAP:(3,"",-86,"d8:54:a2:62:97:d6",6)
0000023561 [ncp.at] TRACE: < +CWLAP:(3,"",-91,"c8:67:5e:81:4b:d6",11)
0000023563 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-92,"c8:67:5e:81:4b:d7",11)
0000023566 [ncp.at] TRACE: < OK
0000023567 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170
0000023568 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000023570 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000023571 [gsm0710muxer] INFO: Closing all muxed channels
0000023573 [gsm0710muxer] INFO: Closing mux channel 1
0000023575 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000023576 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000023578 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000023680 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000023732 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000023734 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000023736 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000023737 [hal] TRACE: NCP state changed: 0
0000023738 [net.esp32ncp] TRACE: NCP event 1
0000025146 [ncp.at] TRACE: > AT
0000025147 [ncp.at] TRACE: < OK
0000026148 [hal] TRACE: NCP ready to accept AT commands
0000026149 [ncp.at] TRACE: > AT+CMUX=0
0000026151 [ncp.at] TRACE: < OK
0000026152 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000026154 [gsm0710muxer] INFO: Openning mux channel 0
0000026155 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000026207 [gsm0710muxer] INFO: Resuming channel 0
0000026209 [gsm0710muxer] INFO: Openning mux channel 1
0000026309 [gsm0710muxer] INFO: Resuming channel 1
0000026310 [gsm0710muxer] INFO: Resuming channel 1
0000026312 [ncp.at] TRACE: > AT
0000026363 [ncp.at] TRACE: < OK
0000026364 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000026413 [ncp.at] TRACE: < OK
0000026414 [hal] TRACE: NCP state changed: 1
0000026415 [net.esp32ncp] TRACE: NCP event 1
0000026419 [ncp.at] TRACE: > AT+CWLAP
0000028964 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-66,"d8:54:a2:63:95:d4",11)
0000028966 [ncp.at] TRACE: < +CWLAP:(3,"",-68,"d8:54:a2:63:95:d6",11)
0000028968 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-69,"d8:54:a2:63:95:d7",11)
0000028970 [ncp.at] TRACE: < +CWLAP:(0,"CFA-Guest",-80,"d8:54:a2:62:48:15",6)
0000028973 [ncp.at] TRACE: < +CWLAP:(3,"",-80,"d8:54:a2:62:48:16",6)
0000028975 [ncp.at] TRACE: < +CWLAP:(3,"CFA-BYOD",-83,"d8:54:a2:62:48:14",6)
0000028978 [ncp.at] TRACE: < +CWLAP:(3,"",-86,"d8:54:a2:62:97:d6",6)
0000028980 [ncp.at] TRACE: < +CWLAP:(3,"CFA-Vistors",-88,"d8:54:a2:62:97:d7",6)
0000028982 [ncp.at] TRACE: < OK
0000028983 [net.esp32ncp] TRACE: Failed to connect to WiFi: -170
0000028985 [gsm0710muxer] INFO: Stopping GSM07.10 muxer
0000028987 [gsm0710muxer] INFO: Gracefully stopping GSM07.10 muxer
0000028989 [gsm0710muxer] INFO: Closing all muxed channels
0000028990 [gsm0710muxer] INFO: Closing mux channel 1
0000028992 [gsm0710muxer] INFO: Muxed channel 2 already closed
0000028994 [gsm0710muxer] INFO: Muxed channel 3 already closed
0000028996 [gsm0710muxer] INFO: Muxed channel 4 already closed
0000029098 [gsm0710muxer] INFO: Sending CLD (multiplexer close down)
0000029150 [gsm0710muxer] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000029152 [gsm0710muxer] INFO: GSM07.10 muxer thread exiting
0000029154 [gsm0710muxer] INFO: GSM07.10 muxer stopped
0000029156 [hal] TRACE: NCP state changed: 0
0000029157 [net.esp32ncp] TRACE: NCP event 1
0000030564 [ncp.at] TRACE: > AT
0000030565 [ncp.at] TRACE: < OK
0000031566 [hal] TRACE: NCP ready to accept AT commands
0000031567 [ncp.at] TRACE: > AT+CMUX=0
0000031569 [ncp.at] TRACE: < OK
0000031570 [gsm0710muxer] INFO: Starting GSM07.10 muxer
0000031572 [gsm0710muxer] INFO: Openning mux channel 0
0000031573 [gsm0710muxer] INFO: GSM07.10 muxer thread started
0000031625 [gsm0710muxer] INFO: Resuming channel 0
0000031627 [gsm0710muxer] INFO: Openning mux channel 1
0000031727 [gsm0710muxer] INFO: Resuming channel 1
0000031728 [gsm0710muxer] INFO: Resuming channel 1
0000031731 [ncp.at] TRACE: > AT
0000031781 [ncp.at] TRACE: < OK
0000031782 [ncp.at] TRACE: > AT+CWDHCP=0,3
0000031831 [ncp.at] TRACE: < OK
0000031832 [hal] TRACE: NCP state changed: 1
0000031833 [net.esp32ncp] TRACE: NCP event 1
0000031837 [ncp.at] TRACE: > AT+CWLAP

Could it be that this network requires white listing of the MAC address of all devices that can connect to the network?
Are all the other factors correct: 2.4GHz, 20MHz width, no captive portal (CFA-WiFi and CFA-Guest seem to be one of these), …

@ScruffR, you may have reminded me of something. I seem to recall having to notify their IT department when WiFi thermostats were installed. I believe they needed to know the MAC address of devices on the hidden network and they would define a static address for each device, whereas the other networks were served via DHCP. I posed the question to them earlier this evening, as I’m not sure if it was this site or another.

Was there something in the debug listing that pointed you in that direction?

Not really, but rather what was not in the log :wink:
The connection process looked as it should but only got a Failed to connect to WiFi without an distinct error from the device. Hence I deduced the network refused to let the device connect.

2 Likes

Still having issues, even though they say they’ve set up a reservation for me.

One other odd thing, when I do a particle serial mac I get: 24:6f:28:3c:8b:e0

However, when my device is in listening mode, my WiFi scanner is reporting a WiFi with: 24:6f:28:3c:8b:e1. Is that to be expected?