setCredentials using vars

I’m reading/using my SSID & network password from a file on SD successfully but I’m having trouble doing the same with the third and fourth arguments for WiFi.setCredentials.

WiFi.setCredentials(networkSSID, networkPass, WPA2, WLAN_CIPHER_AES);

I’m storing all four variables as char arrays, and networkSSID and networkPass both work fine. However, according to compile errors the authentication procedure and cipher both need to be long integers. I tried converting my char arrays to Strings, and then using the .toInt() method, which allowed it to compile, but the Photon couldn’t connect using the credentials.

I want to include all four arguments on SD in order to cover all bases, as this will potentially be used in many different network environments. Any help would be appreciated.

Following up on my own post, it looks like security type and cipher are defined as the following integers by the Particle libraries, and you can use them instead of the phrases when calling WiFi.setCredentials. I’ve only tested WPA2/AES, but it works.

WLAN_SEC_UNSEC = 0
WLAN_SEC_WEP = 1
WLAN_SEC_WPA = 2
WLAN_SEC_WPA2 = 3

WLAN_CIPHER_NOT_SET = 0
WLAN_CIPHER_AES = 1
WLAN_CIPHER_TKIP = 2
WLAN_CIPHER_AES_TKIP = 3
1 Like