From 0e927b58fd7995b49d28dc2801ffeca7aafb1970 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Thu, 24 Nov 2022 16:29:03 -0500 Subject: [PATCH] v1.10.1 to use new `WiFi101_Generic` library ### Releases v1.10.1 1. Using new [`WiFi101_Generic library`](https://github.com/khoih-prog/WiFi101_Generic) for sending larger data 2. Update `Packages' Patches` --- .../HTTPClient/BasicAuthGet/BasicAuthGet.ino | 66 +++++++++-------- examples/HTTPClient/BasicAuthGet/defines.h | 50 ++++++------- .../HTTPClient/CustomHeader/CustomHeader.ino | 66 +++++++++-------- examples/HTTPClient/CustomHeader/defines.h | 50 ++++++------- examples/HTTPClient/DweetGet/DweetGet.ino | 70 +++++++++--------- examples/HTTPClient/DweetGet/defines.h | 50 ++++++------- examples/HTTPClient/DweetPost/DweetPost.ino | 72 ++++++++++--------- examples/HTTPClient/DweetPost/defines.h | 50 ++++++------- examples/HTTPClient/HueBlink/HueBlink.ino | 66 +++++++++-------- examples/HTTPClient/HueBlink/defines.h | 50 ++++++------- .../PostWithHeaders/PostWithHeaders.ino | 64 +++++++++-------- examples/HTTPClient/PostWithHeaders/defines.h | 50 ++++++------- .../HTTPClient/SimpleDelete/SimpleDelete.ino | 64 +++++++++-------- examples/HTTPClient/SimpleDelete/defines.h | 50 ++++++------- examples/HTTPClient/SimpleGet/SimpleGet.ino | 64 +++++++++-------- examples/HTTPClient/SimpleGet/defines.h | 50 ++++++------- .../SimpleHTTPExample/SimpleHTTPExample.ino | 60 +++++++++------- .../HTTPClient/SimpleHTTPExample/defines.h | 50 ++++++------- examples/HTTPClient/SimplePost/SimplePost.ino | 64 +++++++++-------- examples/HTTPClient/SimplePost/defines.h | 50 ++++++------- examples/HTTPClient/SimplePut/SimplePut.ino | 65 +++++++++-------- examples/HTTPClient/SimplePut/defines.h | 50 ++++++------- .../SimpleWebSocket/SimpleWebSocket.ino | 72 ++++++++++--------- examples/HTTPClient/SimpleWebSocket/defines.h | 50 ++++++------- 24 files changed, 733 insertions(+), 660 deletions(-) diff --git a/examples/HTTPClient/BasicAuthGet/BasicAuthGet.ino b/examples/HTTPClient/BasicAuthGet/BasicAuthGet.ino index 82e23630..85e167e5 100644 --- a/examples/HTTPClient/BasicAuthGet/BasicAuthGet.ino +++ b/examples/HTTPClient/BasicAuthGet/BasicAuthGet.ino @@ -2,7 +2,7 @@ BasicAuthGet.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -51,10 +51,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting BasicAuthGet on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting BasicAuthGet on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -65,46 +68,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -113,7 +119,7 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("making GET request with HTTP basic authentication"); httpClient.beginRequest(); @@ -129,7 +135,7 @@ void loop() Serial.println(statusCode); Serial.print("Response: "); Serial.println(response); - + Serial.println("Wait five seconds"); delay(5000); } diff --git a/examples/HTTPClient/BasicAuthGet/defines.h b/examples/HTTPClient/BasicAuthGet/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/BasicAuthGet/defines.h +++ b/examples/HTTPClient/BasicAuthGet/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/CustomHeader/CustomHeader.ino b/examples/HTTPClient/CustomHeader/CustomHeader.ino index 5c2a5a2f..947dcc84 100644 --- a/examples/HTTPClient/CustomHeader/CustomHeader.ino +++ b/examples/HTTPClient/CustomHeader/CustomHeader.ino @@ -2,7 +2,7 @@ CustomHeader.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -48,10 +48,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting CustomHeader on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting CustomHeader on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -62,46 +65,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -110,11 +116,11 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("Making GET request"); httpClient.beginRequest(); - + httpClient.get("/"); httpClient.sendHeader("X-CUSTOM-HEADER", "custom_value"); httpClient.endRequest(); diff --git a/examples/HTTPClient/CustomHeader/defines.h b/examples/HTTPClient/CustomHeader/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/CustomHeader/defines.h +++ b/examples/HTTPClient/CustomHeader/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/DweetGet/DweetGet.ino b/examples/HTTPClient/DweetGet/DweetGet.ino index 43774a86..88703b6d 100644 --- a/examples/HTTPClient/DweetGet/DweetGet.ino +++ b/examples/HTTPClient/DweetGet/DweetGet.ino @@ -2,7 +2,7 @@ DweetGet.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -51,10 +51,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting DweetGet on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting DweetGet on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -65,46 +68,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -144,13 +150,13 @@ void loop() */ // now parse the response looking for "content": int labelStart = response.indexOf("content\":"); - + // find the first { after "content": int contentStart = response.indexOf("{", labelStart); - + // find the following } and get what's between the braces: int contentEnd = response.indexOf("}", labelStart); - + String content = response.substring(contentStart + 1, contentEnd); Serial.println(content); @@ -158,7 +164,7 @@ void loop() int valueStart = content.indexOf(":"); String valueString = content.substring(valueStart + 1); int number = valueString.toInt(); - + Serial.print("Value string: "); Serial.println(valueString); Serial.print("Actual value: "); diff --git a/examples/HTTPClient/DweetGet/defines.h b/examples/HTTPClient/DweetGet/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/DweetGet/defines.h +++ b/examples/HTTPClient/DweetGet/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/DweetPost/DweetPost.ino b/examples/HTTPClient/DweetPost/DweetPost.ino index 39bb8874..5dc2f09b 100644 --- a/examples/HTTPClient/DweetPost/DweetPost.ino +++ b/examples/HTTPClient/DweetPost/DweetPost.ino @@ -2,7 +2,7 @@ DweetPost.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -51,10 +51,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting DweetPost on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting DweetPost on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -65,46 +68,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -117,13 +123,13 @@ void setup() String dweetName = "Hello-from-" + String(BOARD_NAME); String path = "/dweet/for/" + dweetName; String contentType = "application/json"; - -void loop() -{ + +void loop() +{ // assemble the body of the POST message: int sensorValue = analogRead(A0); - - String postData = "{\"sensorValue\":\""; + + String postData = "{\"sensorValue\":\""; postData += sensorValue; postData += "\"}"; diff --git a/examples/HTTPClient/DweetPost/defines.h b/examples/HTTPClient/DweetPost/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/DweetPost/defines.h +++ b/examples/HTTPClient/DweetPost/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/HueBlink/HueBlink.ino b/examples/HTTPClient/HueBlink/HueBlink.ino index aac4108b..aa2a0766 100644 --- a/examples/HTTPClient/HueBlink/HueBlink.ino +++ b/examples/HTTPClient/HueBlink/HueBlink.ino @@ -2,7 +2,7 @@ HueBlink.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -56,10 +56,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting HueBlink on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting HueBlink on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -70,46 +73,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -118,7 +124,7 @@ void setup() printWifiStatus(); } -void sendRequest(int light, String cmd, String value) +void sendRequest(int light, String cmd, String value) { // make a String for the HTTP request path: String request = "/api/" + hueUserName; @@ -133,7 +139,7 @@ void sendRequest(int light, String cmd, String value) hueCmd += "\":"; hueCmd += value; hueCmd += "}"; - + // see what you assembled to send: Serial.print("PUT request to server: "); Serial.println(request); diff --git a/examples/HTTPClient/HueBlink/defines.h b/examples/HTTPClient/HueBlink/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/HueBlink/defines.h +++ b/examples/HTTPClient/HueBlink/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/PostWithHeaders/PostWithHeaders.ino b/examples/HTTPClient/PostWithHeaders/PostWithHeaders.ino index 6df17152..a4dd9878 100644 --- a/examples/HTTPClient/PostWithHeaders/PostWithHeaders.ino +++ b/examples/HTTPClient/PostWithHeaders/PostWithHeaders.ino @@ -2,7 +2,7 @@ PostWithHeaders.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -51,10 +51,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting PostWithHeaders on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting PostWithHeaders on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -65,46 +68,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -113,7 +119,7 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("making POST request"); String postData = "name=Alice&age=12"; diff --git a/examples/HTTPClient/PostWithHeaders/defines.h b/examples/HTTPClient/PostWithHeaders/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/PostWithHeaders/defines.h +++ b/examples/HTTPClient/PostWithHeaders/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimpleDelete/SimpleDelete.ino b/examples/HTTPClient/SimpleDelete/SimpleDelete.ino index 4e73fc3a..0ee20c9f 100644 --- a/examples/HTTPClient/SimpleDelete/SimpleDelete.ino +++ b/examples/HTTPClient/SimpleDelete/SimpleDelete.ino @@ -2,7 +2,7 @@ SimpleDelete.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -48,10 +48,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimpleDelete on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimpleDelete on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -62,46 +65,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -110,7 +116,7 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("making DELETE request"); String contentType = "application/x-www-form-urlencoded"; diff --git a/examples/HTTPClient/SimpleDelete/defines.h b/examples/HTTPClient/SimpleDelete/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimpleDelete/defines.h +++ b/examples/HTTPClient/SimpleDelete/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimpleGet/SimpleGet.ino b/examples/HTTPClient/SimpleGet/SimpleGet.ino index c74f94ef..eac45aeb 100644 --- a/examples/HTTPClient/SimpleGet/SimpleGet.ino +++ b/examples/HTTPClient/SimpleGet/SimpleGet.ino @@ -2,7 +2,7 @@ SimpleGet.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -47,10 +47,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimpleGet on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimpleGet on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -61,46 +64,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -109,7 +115,7 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("making GET request"); httpClient.get("/"); diff --git a/examples/HTTPClient/SimpleGet/defines.h b/examples/HTTPClient/SimpleGet/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimpleGet/defines.h +++ b/examples/HTTPClient/SimpleGet/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimpleHTTPExample/SimpleHTTPExample.ino b/examples/HTTPClient/SimpleHTTPExample/SimpleHTTPExample.ino index 166eb604..c5bd615f 100644 --- a/examples/HTTPClient/SimpleHTTPExample/SimpleHTTPExample.ino +++ b/examples/HTTPClient/SimpleHTTPExample/SimpleHTTPExample.ino @@ -2,7 +2,7 @@ SimpleHTTPExample.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -51,10 +51,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimpleHTTPExample on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimpleHTTPExample on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -65,46 +68,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } diff --git a/examples/HTTPClient/SimpleHTTPExample/defines.h b/examples/HTTPClient/SimpleHTTPExample/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimpleHTTPExample/defines.h +++ b/examples/HTTPClient/SimpleHTTPExample/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimplePost/SimplePost.ino b/examples/HTTPClient/SimplePost/SimplePost.ino index f5020cf3..35b36afe 100644 --- a/examples/HTTPClient/SimplePost/SimplePost.ino +++ b/examples/HTTPClient/SimplePost/SimplePost.ino @@ -2,7 +2,7 @@ SimplePost.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -48,10 +48,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimplePost on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimplePost on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -62,46 +65,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -110,7 +116,7 @@ void setup() printWifiStatus(); } -void loop() +void loop() { Serial.println("making POST request"); String contentType = "application/x-www-form-urlencoded"; diff --git a/examples/HTTPClient/SimplePost/defines.h b/examples/HTTPClient/SimplePost/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimplePost/defines.h +++ b/examples/HTTPClient/SimplePost/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimplePut/SimplePut.ino b/examples/HTTPClient/SimplePut/SimplePut.ino index a3a1cd0a..8e262687 100644 --- a/examples/HTTPClient/SimplePut/SimplePut.ino +++ b/examples/HTTPClient/SimplePut/SimplePut.ino @@ -2,7 +2,7 @@ SimplePut.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -48,10 +48,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimplePut on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimplePut on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -62,46 +65,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } - - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif + #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -110,7 +116,8 @@ void setup() printWifiStatus(); } -void loop() { +void loop() +{ Serial.println("making PUT request"); String contentType = "application/x-www-form-urlencoded"; String putData = "name=light&age=46"; diff --git a/examples/HTTPClient/SimplePut/defines.h b/examples/HTTPClient/SimplePut/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimplePut/defines.h +++ b/examples/HTTPClient/SimplePut/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include diff --git a/examples/HTTPClient/SimpleWebSocket/SimpleWebSocket.ino b/examples/HTTPClient/SimpleWebSocket/SimpleWebSocket.ino index 90242a31..81fdddf0 100644 --- a/examples/HTTPClient/SimpleWebSocket/SimpleWebSocket.ino +++ b/examples/HTTPClient/SimpleWebSocket/SimpleWebSocket.ino @@ -2,7 +2,7 @@ SimpleWebSocket.ino - Simple Arduino web server sample for WiFi shield For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -52,10 +52,13 @@ void printWifiStatus() void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStarting SimpleWebSocket on ")); Serial.print(BOARD_NAME); - Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); + Serial.print(F("\nStarting SimpleWebSocket on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); Serial.println(WIFI_WEBSERVER_VERSION); #if WIFI_USING_ESP_AT @@ -66,46 +69,49 @@ void setup() WiFi.init(&EspSerial); Serial.println(F("WiFi shield init done")); - + #endif #if !(ESP32 || ESP8266) - + // check for the presence of the shield - #if USE_WIFI_NINA - if (WiFi.status() == WL_NO_MODULE) - #else - if (WiFi.status() == WL_NO_SHIELD) - #endif - { - Serial.println(F("WiFi shield not present")); - // don't continue - while (true); - } +#if USE_WIFI_NINA + + if (WiFi.status() == WL_NO_MODULE) +#else + if (WiFi.status() == WL_NO_SHIELD) +#endif + { + Serial.println(F("WiFi shield not present")); + + // don't continue + while (true); + } + +#if USE_WIFI_NINA + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.println(F("Please upgrade the firmware")); + } + +#endif - #if USE_WIFI_NINA - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.println(F("Please upgrade the firmware")); - } - #endif - #endif Serial.print(F("Connecting to SSID: ")); Serial.println(ssid); - + status = WiFi.begin(ssid, pass); delay(1000); - + // attempt to connect to WiFi network while ( status != WL_CONNECTED) { delay(500); - + // Connect to WPA/WPA2 network status = WiFi.status(); } @@ -117,12 +123,12 @@ void setup() void loop() { static String data = " => Hello from SimpleWebSocket on " + String(BOARD_NAME) + ", millis = "; - + Serial.println("Starting WebSocket client"); - + wsClient.begin(); - while (wsClient.connected()) + while (wsClient.connected()) { Serial.print("Sending Hello "); Serial.println(count); @@ -130,10 +136,10 @@ void loop() // send a hello # wsClient.beginMessage(TYPE_TEXT); wsClient.print(count); - + wsClient.print(data); wsClient.print(millis()); - + wsClient.endMessage(); // increment count for next message @@ -142,7 +148,7 @@ void loop() // check if a message is available to be received int messageSize = wsClient.parseMessage(); - if (messageSize > 0) + if (messageSize > 0) { Serial.println("Received a message:"); Serial.println(wsClient.readString()); diff --git a/examples/HTTPClient/SimpleWebSocket/defines.h b/examples/HTTPClient/SimpleWebSocket/defines.h index 22faedce..ce32a029 100644 --- a/examples/HTTPClient/SimpleWebSocket/defines.h +++ b/examples/HTTPClient/SimpleWebSocket/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc - + WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA @@ -36,21 +36,21 @@ #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false - + #elif (ESP32) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM false #elif (ESP8266) #define USE_WIFI_NINA false - // To use the default WiFi library here + // To use the default WiFi library here #define USE_WIFI_CUSTOM true #elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) ) @@ -66,23 +66,23 @@ #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) - + #define USE_WIFI_NINA false #define USE_WIFI101 false #define USE_WIFI_CUSTOM false #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) - + #define USE_WIFI_NINA false #define USE_WIFI101 true #define USE_WIFI_CUSTOM false - + #else #define USE_WIFI_NINA false #define USE_WIFI101 false - - // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here + + // If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here #define USE_WIFI_CUSTOM true #endif @@ -115,21 +115,21 @@ #define SHIELD_TYPE "ESP WiFi using WiFi Library" #elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #warning Using RP2040W CYW43439 WiFi - #define SHIELD_TYPE "RP2040W CYW43439 WiFi" + #define SHIELD_TYPE "RP2040W CYW43439 WiFi" #elif USE_WIFI_CUSTOM #warning Using Custom WiFi using Custom WiFi Library #define SHIELD_TYPE "Custom WiFi using Custom WiFi Library" #else - #define SHIELD_TYPE "Unknown WiFi shield/Library" + #define SHIELD_TYPE "Unknown WiFi shield/Library" #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(WIFI_USE_NRF528XX) - #undef WIFI_USE_NRF528XX - #endif - #define WIFI_USE_NRF528XX true +#if defined(WIFI_USE_NRF528XX) + #undef WIFI_USE_NRF528XX +#endif +#define WIFI_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -137,10 +137,10 @@ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(WIFI_USE_SAMD) - #undef WIFI_USE_SAMD - #endif - #define WIFI_USE_SAMD true +#if defined(WIFI_USE_SAMD) + #undef WIFI_USE_SAMD +#endif +#define WIFI_USE_SAMD true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) @@ -154,10 +154,10 @@ #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) - #if defined(WIFI_USE_STM32) - #undef WIFI_USE_STM32 - #endif - #define WIFI_USE_STM32 true +#if defined(WIFI_USE_STM32) + #undef WIFI_USE_STM32 +#endif +#define WIFI_USE_STM32 true #endif #ifdef CORE_TEENSY @@ -380,7 +380,7 @@ #define BOARD_NAME BOARD_TYPE #else #define BOARD_NAME "Unknown Board" - #endif + #endif #endif #include