The other Arduino WiFi libraries I've used (ESP32, Raspberry Pi Pico W) provide a function WiFi.waitForConnectResult() which you call after WiFi.begin() to get the return code (such as WL_CONNECTED or WL_CONNECT_FAILED), but the GIGA WiFi library doesn't seem to provide this, and I get the error:
'class arduino::WiFiClass' has no member named 'waitForConnectResult'
Wi-Fi support is enabled via the built-in WiFi library that is shipped with the Arduino Mbed Core. Installing the core automatically installs the WiFi library.
// check for the WiFi module:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 3 seconds for connection:
delay(3000);
}
(they initialise the status variable with int status = WL_IDLE_STATUS; so you enter the while loop where begin() is called)
(you could argue the delay is only needed if status was not WL_CONNECTED and that this while loop could be better written)
waitForConnectResult is not part of the standard Arduino WiFi API.
it was added by the maintainers of the esp8266 WiFi library and then the library was ported for esp32 and later for Pico W