diff --git a/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino b/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino index fe8bab2e..4983f5c1 100644 --- a/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino +++ b/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino @@ -68,9 +68,11 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart AP_SimpleWebServer on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart AP_SimpleWebServer on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); pinMode(led, OUTPUT); // set the LED pin mode @@ -79,12 +81,13 @@ void setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); - + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -103,9 +106,11 @@ void setup() // Create open network. Change this line if you want to create an WEP network: status = WiFi.beginAP(ssid, pass); + if (status != WL_AP_LISTENING) { Serial.println(F("Creating access point failed")); + // don't continue while (true); } @@ -142,31 +147,31 @@ void loop() WiFiClient client = server.available(); // listen for incoming clients - if (client) - { + if (client) + { // if you get a client, Serial.println(F("new client")); // print a message out the serial port String currentLine = ""; // make a String to hold incoming data from the client - - while (client.connected()) + + while (client.connected()) { // This is required for the Arduino Nano RP2040 Connect // otherwise it will loop so fast that SPI will never be served. delayMicroseconds(10); - + // loop while the client's connected - if (client.available()) - { + if (client.available()) + { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor // if the byte is a newline character - if (c == '\n') - { + if (c == '\n') + { // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: - if (currentLine.length() == 0) + if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: @@ -183,30 +188,31 @@ void loop() // break out of the while loop: break; } - else - { + else + { // if you got a newline, then clear currentLine: currentLine = ""; } } - else if (c != '\r') - { + else if (c != '\r') + { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } // Check to see if the client request was "GET /H" or "GET /L": - if (currentLine.endsWith("GET /H")) + if (currentLine.endsWith("GET /H")) { digitalWrite(led, HIGH); // GET /H turns the LED on } - - if (currentLine.endsWith("GET /L")) + + if (currentLine.endsWith("GET /L")) { digitalWrite(led, LOW); // GET /L turns the LED off } } } + // close the connection: client.stop(); Serial.println(F("client disconnected")); diff --git a/examples/AP_SimpleWebServer/defines.h b/examples/AP_SimpleWebServer/defines.h index 609f682f..61befa0e 100644 --- a/examples/AP_SimpleWebServer/defines.h +++ b/examples/AP_SimpleWebServer/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/ConnectNoEncryption/ConnectNoEncryption.ino b/examples/ConnectNoEncryption/ConnectNoEncryption.ino index 10968f09..7f5da09f 100644 --- a/examples/ConnectNoEncryption/ConnectNoEncryption.ino +++ b/examples/ConnectNoEncryption/ConnectNoEncryption.ino @@ -53,20 +53,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ConnectNoEncryption on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ConnectNoEncryption on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -154,6 +158,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -161,6 +166,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ConnectNoEncryption/defines.h b/examples/ConnectNoEncryption/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ConnectNoEncryption/defines.h +++ b/examples/ConnectNoEncryption/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/ConnectWithWEP/ConnectWithWEP.ino b/examples/ConnectWithWEP/ConnectWithWEP.ino index 91a30b4b..602da9fd 100644 --- a/examples/ConnectWithWEP/ConnectWithWEP.ino +++ b/examples/ConnectWithWEP/ConnectWithWEP.ino @@ -66,20 +66,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ConnectWithWEP on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ConnectWithWEP on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -158,6 +162,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -165,6 +170,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ConnectWithWEP/defines.h b/examples/ConnectWithWEP/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ConnectWithWEP/defines.h +++ b/examples/ConnectWithWEP/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/ConnectWithWPA/ConnectWithWPA.ino b/examples/ConnectWithWPA/ConnectWithWPA.ino index 4ceebd43..55146875 100644 --- a/examples/ConnectWithWPA/ConnectWithWPA.ino +++ b/examples/ConnectWithWPA/ConnectWithWPA.ino @@ -53,20 +53,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ConnectWithWPA on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ConnectWithWPA on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -145,6 +149,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -152,6 +157,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ConnectWithWPA/defines.h b/examples/ConnectWithWPA/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ConnectWithWPA/defines.h +++ b/examples/ConnectWithWPA/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/ConnectWithWPA2Enterprise/ConnectWithWPA2Enterprise.ino b/examples/ConnectWithWPA2Enterprise/ConnectWithWPA2Enterprise.ino index ee06c0cd..cc4c2343 100644 --- a/examples/ConnectWithWPA2Enterprise/ConnectWithWPA2Enterprise.ino +++ b/examples/ConnectWithWPA2Enterprise/ConnectWithWPA2Enterprise.ino @@ -51,20 +51,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ConnectWithWPA2Enterprise on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ConnectWithWPA2Enterprise on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -95,14 +99,14 @@ void setup() } -void loop() +void loop() { // check the network connection once every 10 seconds: delay(10000); printCurrentNet(); } -void printWifiData() +void printWifiData() { // print your board's IP address: IPAddress ip = WiFi.localIP(); @@ -148,6 +152,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -155,6 +160,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ConnectWithWPA2Enterprise/defines.h b/examples/ConnectWithWPA2Enterprise/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ConnectWithWPA2Enterprise/defines.h +++ b/examples/ConnectWithWPA2Enterprise/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/MultiServers/MultiServers.ino b/examples/MultiServers/MultiServers.ino index 4a796c8b..92f4df05 100644 --- a/examples/MultiServers/MultiServers.ino +++ b/examples/MultiServers/MultiServers.ino @@ -60,35 +60,48 @@ WebSocketServer webSocketServer; WiFiClient socketClient; boolean on = false; -char webpage_base64[] = "H4sICEGBKl8CAFdlYnBhZ2VTZXJ2ZWRCeUFyZHVpbm8uaHRtbADsWelu00AQ/o/EO5ggLoHvIzZQpHVuoBBDufrPsdcH8RFsN06DeHdmvRvshKucEhJWa8/MfjM7M7vjdaf3rwyfDk7ezEdcVKXJg8uX7pMnl7hZeNTDWQ8kHHc/wq7fUEBXcZXgB7OswkXgevi+SAVsNMWVy3mRW5S4OuqdVQFv9nZjSZwtuQInR70yyovKO6u42MuzHhcVODjq+W7l3o1TN8TihicD9xZuiQ3tDkLIRmiERnAnzxmyc0KOQ7gNyA058Avy3Xjnso8fw/1kUKMfvk7rmWynzvT4sfUc2amNfuaavqmeO2bLT16g42KcoeGJeIpQHTqHeJQ49kMIoVyc1OjFtOP3cwcdn2Yoc2bjevJi+mqBclNU6kfzuZWi4Vw8DdGW8eXg7VZsxw/5jj/jF2g6lE+Q/W4K8UoTxUNPXlUde+Dv2qoGJ1vJPUd6+VJDjwZRiAZ1tAiXt8evZ4kTHh8EYS/REG1O7dFmNHOU10M/t4eBfOqgc1F5g45FK0HDx+IirG/fVp3ls2h08XyOvcEMPQvteAvrg2Rqj8WP0EZUndNnRTw+lrXJxY3Cftq+mRH/LGqvjZ/yGTp5pqEfvDL5NnImy8kTMYJ4p8xea5/MF4YXt7dK09lg5smvSztGz0Vmr82n67xQxdV4spguL250YnqObb8bDt9qbH0O4x8+maf28fjN6x/I51Nkv5i/qlFiTkL0JOjaA35tnaLBFD1z0NT+gfiDt89Ohuro1Fnbyy/kcwP+b+b1j9YnchzHKuxtUX8p/hj9zGXDeozmxJ45gaKd0/Vp7KfATz30M5eLkDxUlsMn60SajBbnCyc3zQmp55U8eeG9QT9zjT003UTN+yE+SeJxar6an79s+Gh7Ggx+wJS4NdfrQBPzhRqimWH1bXGynodiNFzXcyvsm1NzvA6QGPfVMKhvW9rUquZPbXE1VEPRKi1tLj6a46noD9VIVLDRD8zl2jk6+nSAlNV5c9Iscv+ce0+EC9dbhkV+lvm8lyd5cZe7OtJH+nh87/KlD5cvre7ASbbACQUHeVbxgZvGyfldDhWxm9zhSjcr+RIXcUA1BDh3MuxVcZ5x5TqkimtcVLHnJrybxGF2l1vkVZWnVOHQfo3jMKoIJvEBwaRlvMV3OVkw1nU7T1XkSUlV69ivIgBI0rV7XMRMKJK02jQ2/LhcJS54HSSYShpP+LjCaXmX8zA5jZnhso4rL8Ll1xJUR6B1rzup0pmzDw40ennhY0CXeRL7nAx+MBFfuH58BpPqRJa6RRhnfIID0OUb2Mr1/TgLAfBjzoP87VlZxcE5T3ID0r2xfOV6cQVWJEFlkeZZHgQ03L0smt0kAsPgLbLjU5ZneG+8Xc8WtEhyb0m8YFbZQoGAJQC8YsF6Z0WZF8RuBbslyWvs3ztYhwKvsFsRCCMPAau8jMkGbOPfG2ebiSTJjbP94G5zh2F09Mi3FSieFcnNG52PLdjmtzdpcg8+1sw719QB8NcUCfZ8CT5cU4fXFEUWZLiDtMkwk0kSldGcHAjXMa7tfEOlICNySWZ3hoFJs5IioqpaXVPRNWUMP3VdC7Uq5EUIDGhK8ACniJI6AgeJe1UBhRvkRUr1S6hOfE0xBYD3NRhvCJjE+qS1cqsIBnyqkCq6Lug6cUcVJEnzeFnVBEkmnvKKpgiG3LhqCoba8oxg0aiqYJk7VGf0kOhipU9Snhpv+RaMeSLmqRK/58T+Y5vKuiAbGjEiK4JiRrwK9aH017wMi6ZGlAOYZAgygTUCzSNuGIZgqRqva4ImkaFGg+p94giGeE3FBKsaBt9FkkFdEowmOlUWdFnhLVUwNDLU1wVT1nhZloW+vIZwdMX0eKUvSFaTel3o6yqv6YJmEnVNEwy93/J9U5B3SdMlCNQiIAlskjRZkmD1rR1hthIK7tN1YlKDb/RalmGJ++CXZui8bAqaovCGAg/mhME3Lqx55roG8UvEc8BC/nYRklANGXZPV0CD3tKtHsRJwrNXGN2Agk5HSjgFlpjvFBatjjHdtQX2KlIqu/KC1GlUkdkxwV3p8+pULJjB/LxAVUUVVKt1CqQNowaS1HWoK/+aozLZOErX28MagyQ2SwW+/C+w/wX2hwvs055Vpb7sWl/cztLXt7Pe3clAhJ+ock3oG7f2ztq7XoS9JfZ/45kbs8Kh5vKswQL/zx3HqVsV8aZ7HrM52blMCB3WWGOE8c2DWhXoliDQ/++R/++RP/0e+S0HtSbo+wd13xIsSfn1g1qSPFNV/sBZ3dnU/4vsf5H94SL7S4d10zcSd40jQrP/ZQBJ2kgPGMSP11zsH/Xa9k+P8xK3LPdFjaGjHmsDaOSv/t6D+yJo7wxFxaHJXaeHGewIKLKLZc2bFssEDHuA7jRAmMK+jOkwrThbnVVcdb6CAJpvl0W+6dFZmYnMTWFsz2DL+nHpLhLsc3k2iNwsBGTlJsubROkOxz6Gbh3MST+Jgrxo7bQTNoPtPK2MpLQhOsbaJB9y30g/W65dI6dpQFEPDyG0daTpbefIgA7PXtZXO2zb0YMCX9eAeobLVZ6VuLyeLcrVvaDIU0qhwj+Ls/zufXHVNVXhTeUW2N1lHBdrXKS4LN0QlzRFhzKWpUNxkdcglSUA5AlQGlB7IdGWIuvTFSQyEJE+HehCJeRZcg7Z3jm0n+CLZ2q/E6hfPHOv8KLMYedUNF9e5FYVLr6Tr3qnRFPVsixLreSiCbp4Mlq6G5j3sX1r6XEaBsJ3JP6DFQ60gqR+Jg5QJJ4CCbjAAQk4lNYskdKH0hQE0v53vrEdmnQLLA+JSy/bjD0e29/Y+cbjbO1mzS3khbHpaA3ux39nO2+qTQvp6pVPs4YFB7IpSz5vb00mCbuBtOVqsf6cIck4o7dM9nG9bWmiqEpuWW75JLkdGodJofFqV9exLK6FV9XSxRLkwrBPofVhVm9RiJ4/7FYhpx1fZi+9odE4JjrX893SrdrszLWPakeP9788XYz6r75xVuG5efLq+TNYvr6fekgrX3v8+J7hnN6GlDanN/w0oeRqwuLRBU7IRMI86NNE6iQun/AcDyjThDPOpGZURgcSeIwOI0BqfwyZ0CGEjlDojKIYhjWwFJKJItMKBwRwmbSCgaaz3DIOVtU2PNMfgRpGKrn0daKk4qLIfW189gqFZtwXpl5Ph+dOIfU2lK+TeRpM+5/4/HVJnKd1WmSl4RJMjwhD6lSBSrVBqRTSpoakIvWqqpN0ZhSnPiyxe8lkhhnLoKRZVOKZsiXHGMHXqjAky8IaBpiNpnkLlfMCotGqgCg5zcjHAjk1MrL0xSY3BASX0u5FJTRp4SmXGkEOWRNUYZVVJCprMSwjjKB5lXAZYipLoQJMFcCRIyawnaQya4WCvSIzBoYpGDAqKBWMlLSkzkUYac4Ffoz0haoUeehY7yWpS+WHp8uSps6tLv0slEzDJAIuYaRltAbP8IAMhh2A+brssAduXJRz+EcqQ+DnmYTDMFYtTZlaGCokZlIC3iH4lkQFKPrYo7s+9rkq+9jnuexjb0rdx56bCD1GFKDXA+iLsGZzrBtgrywQFOgiVVC1OTxRwESUyEvoGqsG2FA7obUlFV7mLKoQ8lbtR2AkeogdReSjRCpcDpEXfiPB233k9UXkixKSX0cRe6wcXmr81RY/BtjxIo0AE9y5itLXJWcaBQg6acZaY6yoKgoraHwG+jQ9RUtS6dIO3MPFYGsIGRdA7t3DhXcPAnnvHiMHW6PQcVFF6WBn0LYLvqZhaMnFftZW6YLEsrQFbWBjNU07LxVQV0Z10pZ2UWEJJ2Do66RhoW5+0THWsn0XWgYh+uX7jsi9X6Ts74gioKF/uCNkGvDAjzSGlpYG0qmCAkL/CGxYRVH6SoRbbdJmR0TgPrnVerFI4ss/MkIQhyp4b88oudU6Brpvqve71r3wzN4/fif7ylc+aH39/BnC0B1iScwHsU+4PXuAPBtIBBzqPlSrqiXGmdU7R6x/mycTcDGRBH7AGHfZg0hpqzOWZRnx9HXPkKxHru4zQ1wSOTIQ9nigRFePG7eCbkesHZWyi+zL2L9hWM7vaXP/xLAnhj0x7IlhTwx7YtjACEcZdnLAd27hqe5XdBSTNOMsZHsuz2NdngpNPWtlkcTRPhHJpVrH3E9nIHxJQ+0364o+gwlWzg94OB5/+1S8BBf/vMN9gmDAujfQ2Z2U0Zl8mdFtHR6Styt0fHlrOO6v6/rVesOmv9PgiWfq2JE/6kP5IQ1hGseSIYdVtaPkVjKOatUHNurU3vB3bDplQDKJs7+cn7tLzGnPlAim2mbn0NelbcEZc58YHHWNzpnD0jk6zui2Sw12mPM69Fh/2NFdv2lx6LXfbTV03fmxNeqaZt0cDRajyrxebwm2Y4193UHjfxdUPi6MUeYUVJ6CylNQeQoqT0HlKagMjPDzoPJhtZ3/dVyJ+OKvwkoA8peBZe8j7c7S1rV0k7LetaPBVclNJjjn3xnak/RAAexNZfEuB9/APwJo7bNq2zrw7yh573AL6narej1bJDcHbP5Luj+H6SOxwvl4eLezv44NGbBoum2+HIQbCJkWo+83TAh3o/7tP46a07uMzFy0+V8i6HMk4eB2NuogOIzFULH3ZB9CvxoeNuvNyH2Kbd2nbNM4cuZD92G2q8nTh80Wzexs0IIC9lf+mzjXAG4foI6Ss9kOIe9NUmhxXYrxVIsjxkL3UKt/OoRwTqCe2PRCn2fDPoO+q7PZZgPnP/hY1YvRj8AlQ+Ph9xPdHSYJ8bOJOxP/H6PfAJuWEF5BOgAA"; +char webpage_base64[] = + "H4sICEGBKl8CAFdlYnBhZ2VTZXJ2ZWRCeUFyZHVpbm8uaHRtbADsWelu00AQ/o/EO5ggLoHvIzZQpHVuoBBDufrPsdcH8RFsN06DeHdmvRvshKucEhJWa8/MfjM7M7vjdaf3rwyfDk7ezEdcVKXJg8uX7pMnl7hZeNTDWQ8kHHc/wq7fUEBXcZXgB7OswkXgevi+SAVsNMWVy3mRW5S4OuqdVQFv9nZjSZwtuQInR70yyovKO6u42MuzHhcVODjq+W7l3o1TN8TihicD9xZuiQ3tDkLIRmiERnAnzxmyc0KOQ7gNyA058Avy3Xjnso8fw/1kUKMfvk7rmWynzvT4sfUc2amNfuaavqmeO2bLT16g42KcoeGJeIpQHTqHeJQ49kMIoVyc1OjFtOP3cwcdn2Yoc2bjevJi+mqBclNU6kfzuZWi4Vw8DdGW8eXg7VZsxw/5jj/jF2g6lE+Q/W4K8UoTxUNPXlUde+Dv2qoGJ1vJPUd6+VJDjwZRiAZ1tAiXt8evZ4kTHh8EYS/REG1O7dFmNHOU10M/t4eBfOqgc1F5g45FK0HDx+IirG/fVp3ls2h08XyOvcEMPQvteAvrg2Rqj8WP0EZUndNnRTw+lrXJxY3Cftq+mRH/LGqvjZ/yGTp5pqEfvDL5NnImy8kTMYJ4p8xea5/MF4YXt7dK09lg5smvSztGz0Vmr82n67xQxdV4spguL250YnqObb8bDt9qbH0O4x8+maf28fjN6x/I51Nkv5i/qlFiTkL0JOjaA35tnaLBFD1z0NT+gfiDt89Ohuro1Fnbyy/kcwP+b+b1j9YnchzHKuxtUX8p/hj9zGXDeozmxJ45gaKd0/Vp7KfATz30M5eLkDxUlsMn60SajBbnCyc3zQmp55U8eeG9QT9zjT003UTN+yE+SeJxar6an79s+Gh7Ggx+wJS4NdfrQBPzhRqimWH1bXGynodiNFzXcyvsm1NzvA6QGPfVMKhvW9rUquZPbXE1VEPRKi1tLj6a46noD9VIVLDRD8zl2jk6+nSAlNV5c9Iscv+ce0+EC9dbhkV+lvm8lyd5cZe7OtJH+nh87/KlD5cvre7ASbbACQUHeVbxgZvGyfldDhWxm9zhSjcr+RIXcUA1BDh3MuxVcZ5x5TqkimtcVLHnJrybxGF2l1vkVZWnVOHQfo3jMKoIJvEBwaRlvMV3OVkw1nU7T1XkSUlV69ivIgBI0rV7XMRMKJK02jQ2/LhcJS54HSSYShpP+LjCaXmX8zA5jZnhso4rL8Ll1xJUR6B1rzup0pmzDw40ennhY0CXeRL7nAx+MBFfuH58BpPqRJa6RRhnfIID0OUb2Mr1/TgLAfBjzoP87VlZxcE5T3ID0r2xfOV6cQVWJEFlkeZZHgQ03L0smt0kAsPgLbLjU5ZneG+8Xc8WtEhyb0m8YFbZQoGAJQC8YsF6Z0WZF8RuBbslyWvs3ztYhwKvsFsRCCMPAau8jMkGbOPfG2ebiSTJjbP94G5zh2F09Mi3FSieFcnNG52PLdjmtzdpcg8+1sw719QB8NcUCfZ8CT5cU4fXFEUWZLiDtMkwk0kSldGcHAjXMa7tfEOlICNySWZ3hoFJs5IioqpaXVPRNWUMP3VdC7Uq5EUIDGhK8ACniJI6AgeJe1UBhRvkRUr1S6hOfE0xBYD3NRhvCJjE+qS1cqsIBnyqkCq6Lug6cUcVJEnzeFnVBEkmnvKKpgiG3LhqCoba8oxg0aiqYJk7VGf0kOhipU9Snhpv+RaMeSLmqRK/58T+Y5vKuiAbGjEiK4JiRrwK9aH017wMi6ZGlAOYZAgygTUCzSNuGIZgqRqva4ImkaFGg+p94giGeE3FBKsaBt9FkkFdEowmOlUWdFnhLVUwNDLU1wVT1nhZloW+vIZwdMX0eKUvSFaTel3o6yqv6YJmEnVNEwy93/J9U5B3SdMlCNQiIAlskjRZkmD1rR1hthIK7tN1YlKDb/RalmGJ++CXZui8bAqaovCGAg/mhME3Lqx55roG8UvEc8BC/nYRklANGXZPV0CD3tKtHsRJwrNXGN2Agk5HSjgFlpjvFBatjjHdtQX2KlIqu/KC1GlUkdkxwV3p8+pULJjB/LxAVUUVVKt1CqQNowaS1HWoK/+aozLZOErX28MagyQ2SwW+/C+w/wX2hwvs055Vpb7sWl/cztLXt7Pe3clAhJ+ock3oG7f2ztq7XoS9JfZ/45kbs8Kh5vKswQL/zx3HqVsV8aZ7HrM52blMCB3WWGOE8c2DWhXoliDQ/++R/++RP/0e+S0HtSbo+wd13xIsSfn1g1qSPFNV/sBZ3dnU/4vsf5H94SL7S4d10zcSd40jQrP/ZQBJ2kgPGMSP11zsH/Xa9k+P8xK3LPdFjaGjHmsDaOSv/t6D+yJo7wxFxaHJXaeHGewIKLKLZc2bFssEDHuA7jRAmMK+jOkwrThbnVVcdb6CAJpvl0W+6dFZmYnMTWFsz2DL+nHpLhLsc3k2iNwsBGTlJsubROkOxz6Gbh3MST+Jgrxo7bQTNoPtPK2MpLQhOsbaJB9y30g/W65dI6dpQFEPDyG0daTpbefIgA7PXtZXO2zb0YMCX9eAeobLVZ6VuLyeLcrVvaDIU0qhwj+Ls/zufXHVNVXhTeUW2N1lHBdrXKS4LN0QlzRFhzKWpUNxkdcglSUA5AlQGlB7IdGWIuvTFSQyEJE+HehCJeRZcg7Z3jm0n+CLZ2q/E6hfPHOv8KLMYedUNF9e5FYVLr6Tr3qnRFPVsixLreSiCbp4Mlq6G5j3sX1r6XEaBsJ3JP6DFQ60gqR+Jg5QJJ4CCbjAAQk4lNYskdKH0hQE0v53vrEdmnQLLA+JSy/bjD0e29/Y+cbjbO1mzS3khbHpaA3ux39nO2+qTQvp6pVPs4YFB7IpSz5vb00mCbuBtOVqsf6cIck4o7dM9nG9bWmiqEpuWW75JLkdGodJofFqV9exLK6FV9XSxRLkwrBPofVhVm9RiJ4/7FYhpx1fZi+9odE4JjrX893SrdrszLWPakeP9788XYz6r75xVuG5efLq+TNYvr6fekgrX3v8+J7hnN6GlDanN/w0oeRqwuLRBU7IRMI86NNE6iQun/AcDyjThDPOpGZURgcSeIwOI0BqfwyZ0CGEjlDojKIYhjWwFJKJItMKBwRwmbSCgaaz3DIOVtU2PNMfgRpGKrn0daKk4qLIfW189gqFZtwXpl5Ph+dOIfU2lK+TeRpM+5/4/HVJnKd1WmSl4RJMjwhD6lSBSrVBqRTSpoakIvWqqpN0ZhSnPiyxe8lkhhnLoKRZVOKZsiXHGMHXqjAky8IaBpiNpnkLlfMCotGqgCg5zcjHAjk1MrL0xSY3BASX0u5FJTRp4SmXGkEOWRNUYZVVJCprMSwjjKB5lXAZYipLoQJMFcCRIyawnaQya4WCvSIzBoYpGDAqKBWMlLSkzkUYac4Ffoz0haoUeehY7yWpS+WHp8uSps6tLv0slEzDJAIuYaRltAbP8IAMhh2A+brssAduXJRz+EcqQ+DnmYTDMFYtTZlaGCokZlIC3iH4lkQFKPrYo7s+9rkq+9jnuexjb0rdx56bCD1GFKDXA+iLsGZzrBtgrywQFOgiVVC1OTxRwESUyEvoGqsG2FA7obUlFV7mLKoQ8lbtR2AkeogdReSjRCpcDpEXfiPB233k9UXkixKSX0cRe6wcXmr81RY/BtjxIo0AE9y5itLXJWcaBQg6acZaY6yoKgoraHwG+jQ9RUtS6dIO3MPFYGsIGRdA7t3DhXcPAnnvHiMHW6PQcVFF6WBn0LYLvqZhaMnFftZW6YLEsrQFbWBjNU07LxVQV0Z10pZ2UWEJJ2Do66RhoW5+0THWsn0XWgYh+uX7jsi9X6Ts74gioKF/uCNkGvDAjzSGlpYG0qmCAkL/CGxYRVH6SoRbbdJmR0TgPrnVerFI4ss/MkIQhyp4b88oudU6Brpvqve71r3wzN4/fif7ylc+aH39/BnC0B1iScwHsU+4PXuAPBtIBBzqPlSrqiXGmdU7R6x/mycTcDGRBH7AGHfZg0hpqzOWZRnx9HXPkKxHru4zQ1wSOTIQ9nigRFePG7eCbkesHZWyi+zL2L9hWM7vaXP/xLAnhj0x7IlhTwx7YtjACEcZdnLAd27hqe5XdBSTNOMsZHsuz2NdngpNPWtlkcTRPhHJpVrH3E9nIHxJQ+0364o+gwlWzg94OB5/+1S8BBf/vMN9gmDAujfQ2Z2U0Zl8mdFtHR6Styt0fHlrOO6v6/rVesOmv9PgiWfq2JE/6kP5IQ1hGseSIYdVtaPkVjKOatUHNurU3vB3bDplQDKJs7+cn7tLzGnPlAim2mbn0NelbcEZc58YHHWNzpnD0jk6zui2Sw12mPM69Fh/2NFdv2lx6LXfbTV03fmxNeqaZt0cDRajyrxebwm2Y4193UHjfxdUPi6MUeYUVJ6CylNQeQoqT0HlKagMjPDzoPJhtZ3/dVyJ+OKvwkoA8peBZe8j7c7S1rV0k7LetaPBVclNJjjn3xnak/RAAexNZfEuB9/APwJo7bNq2zrw7yh573AL6narej1bJDcHbP5Luj+H6SOxwvl4eLezv44NGbBoum2+HIQbCJkWo+83TAh3o/7tP46a07uMzFy0+V8i6HMk4eB2NuogOIzFULH3ZB9CvxoeNuvNyH2Kbd2nbNM4cuZD92G2q8nTh80Wzexs0IIC9lf+mzjXAG4foI6Ss9kOIe9NUmhxXYrxVIsjxkL3UKt/OoRwTqCe2PRCn2fDPoO+q7PZZgPnP/hY1YvRj8AlQ+Ph9xPdHSYJ8bOJOxP/H6PfAJuWEF5BOgAA"; -void printWifiStatus() +void printWifiStatus() { - Sprint(F("SSID: ")); Sprintln(WiFi.SSID()); - Sprint(F("Signal strength (RSSI): ")); Sprint(WiFi.RSSI()); Sprintln(F(" dBm")); - Sprint(F("IP address: ")); Sprintln(WiFi.localIP()); - Sprint(F("Gateway: ")); Sprintln(WiFi.gatewayIP()); - Sprint(F("Netmask: ")); Sprintln(WiFi.subnetMask()); - Sprint(F("Webpage is at http://")); Sprint(WiFi.localIP()); Sprintln(F("/")); - Sprint(F("Websocket is at http://")); Sprint(WiFi.localIP()); Sprintln(":" + (String)socketPort + "/"); + Sprint(F("SSID: ")); + Sprintln(WiFi.SSID()); + Sprint(F("Signal strength (RSSI): ")); + Sprint(WiFi.RSSI()); + Sprintln(F(" dBm")); + Sprint(F("IP address: ")); + Sprintln(WiFi.localIP()); + Sprint(F("Gateway: ")); + Sprintln(WiFi.gatewayIP()); + Sprint(F("Netmask: ")); + Sprintln(WiFi.subnetMask()); + Sprint(F("Webpage is at http://")); + Sprint(WiFi.localIP()); + Sprintln(F("/")); + Sprint(F("Websocket is at http://")); + Sprint(WiFi.localIP()); + Sprintln(":" + (String)socketPort + "/"); } -void WiFiConnect() +void WiFiConnect() { - while (WiFi.status() != WL_CONNECTED) + while (WiFi.status() != WL_CONNECTED) { - Sprint(F("Connecting to ")); Sprintln(ssid); + Sprint(F("Connecting to ")); + Sprintln(ssid); WiFi.begin(ssid, pass); delay(5000); } - + IPAddress IP = WiFi.localIP(); IP[3] = IPLastByte; - + WiFi.config(IP, WiFi.gatewayIP(), WiFi.gatewayIP(), WiFi.subnetMask()); - Sprint(F("Connected to ")); Sprintln(ssid); - - + Sprint(F("Connected to ")); + Sprintln(ssid); + + webServer.begin(); socketServer.begin(); printWifiStatus(); @@ -100,21 +113,25 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart MultiServers on ")); Serial.println(BOARD_TYPE); - + Serial.print(F("\nStart MultiServers on ")); + Serial.println(BOARD_TYPE); + Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -122,7 +139,7 @@ void setup() Serial.print(F("Please upgrade the firmware to NINA FW v")); Serial.println(WIFI_FIRMWARE_LATEST_VERSION); } - + pinMode(LED_BUILTIN, OUTPUT); WiFiConnect(); } @@ -142,23 +159,26 @@ void loop() if (webClient.connected()) { - Sprint(F("\n--New client: ")); Sprint(webClient.remoteIP()); Sprint(F(":")); Sprintln(webClient.remotePort()); + Sprint(F("\n--New client: ")); + Sprint(webClient.remoteIP()); + Sprint(F(":")); + Sprintln(webClient.remotePort()); String header = ""; while (webClient.available()) { char c = webClient.read(); - if (c != '\r') + if (c != '\r') { header += c; } - - if (header.substring(header.length() - 2) == "\n\n") + + if (header.substring(header.length() - 2) == "\n\n") { Sprint(header.substring(0, header.length() - 1)); - - if (header.indexOf("GET / HTTP") > -1) + + if (header.indexOf("GET / HTTP") > -1) { const int webpage_base64_length = sizeof(webpage_base64); const int webpage_gz_length = base64_dec_len(webpage_base64, webpage_base64_length); @@ -166,55 +186,60 @@ void loop() base64_decode(webpage_gz, webpage_base64, webpage_base64_length); int packetsize = 1024; int done = 0; - + webClient.println("HTTP/1.1 200 OK\nContent-Type: text/html\nContent-Encoding: gzip\n"); - - while (webpage_gz_length > done) + + while (webpage_gz_length > done) { - if (webpage_gz_length - done < packetsize) { - + if (webpage_gz_length - done < packetsize) + { + packetsize = webpage_gz_length - done; } - + webClient.write(webpage_gz + done, packetsize * sizeof(char)); done = done + packetsize; } - + Sprintln(F("--Interface webpage sent")); - } - else + } + else { webClient.println("HTTP/1.1 404 Not Found\nContent-Type: text/plain; charset=utf-8\n\n404 Not Found\n"); Sprintln(F("--Page not found")); } - + webClient.stop(); Sprintln(F("--Client disconnected")); } } } + //} - if (!socketClient.connected()) + if (!socketClient.connected()) { socketClient = socketServer.available(); - - if (socketClient.connected() && webSocketServer.handshake(socketClient)) + + if (socketClient.connected() && webSocketServer.handshake(socketClient)) { - Sprint(F("\n--Websocket connected to: ")); Sprint(socketClient.remoteIP()); Sprint(F(":")); Sprintln(socketClient.remotePort()); - - if (on) + Sprint(F("\n--Websocket connected to: ")); + Sprint(socketClient.remoteIP()); + Sprint(F(":")); + Sprintln(socketClient.remotePort()); + + if (on) { webSocketServer.sendData("sw:true"); - } - else + } + else { webSocketServer.sendData("sw:false"); } - + Sprintln(F("\n--Settings sent")); - } - else + } + else { //Sprintln(F("\n--Couldn't connect websocket")); socketClient.stop(); @@ -222,27 +247,27 @@ void loop() } } - if (socketClient.connected()) + if (socketClient.connected()) { String data = webSocketServer.getData(); - - if (data.length() > 0) + + if (data.length() > 0) { String name = data.substring(0, data.indexOf(":")); String value = data.substring(data.indexOf(":") + 1); boolean goodSettings = true; - - if (name == "switch") + + if (name == "switch") { on = (value == "true"); - } - else + } + else { goodSettings = false; webSocketServer.sendData("message:Bad data; ignored"); } - - if (goodSettings) + + if (goodSettings) { webSocketServer.sendData("message:" + name + " set to " + value); } diff --git a/examples/MultiServers/defines.h b/examples/MultiServers/defines.h index 609f682f..61befa0e 100644 --- a/examples/MultiServers/defines.h +++ b/examples/MultiServers/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/RGB_LED_Test/RGB_LED_Test.ino b/examples/RGB_LED_Test/RGB_LED_Test.ino index 00c1d3df..8739975d 100644 --- a/examples/RGB_LED_Test/RGB_LED_Test.ino +++ b/examples/RGB_LED_Test/RGB_LED_Test.ino @@ -33,9 +33,10 @@ //#include #include -void setup() +void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); Serial.print("RGB_LED_Test on "); @@ -47,25 +48,25 @@ void setup() #elif __has_include("WiFiNINA_Generic.h") Serial.println("WiFiNINA_Generic Library"); #else - #error Error. No WiFiNINA or WiFiNINA_Generic included -#endif +#error Error. No WiFiNINA or WiFiNINA_Generic included +#endif pinMode(LEDR, OUTPUT); pinMode(LEDG, OUTPUT); pinMode(LEDB, OUTPUT); } -void loop() +void loop() { - digitalWrite(LEDR,HIGH); // Turn On RED LED - delay(250); - digitalWrite(LEDR,LOW); // Turn Off RED LED + digitalWrite(LEDR, HIGH); // Turn On RED LED + delay(250); + digitalWrite(LEDR, LOW); // Turn Off RED LED - digitalWrite(LEDG,HIGH); // Turn On GREEN LED - delay(250); - digitalWrite(LEDG,LOW); // Turn Off GREEN LED + digitalWrite(LEDG, HIGH); // Turn On GREEN LED + delay(250); + digitalWrite(LEDG, LOW); // Turn Off GREEN LED - digitalWrite(LEDB,HIGH); // Turn On BLUE LED - delay(250); - digitalWrite(LEDB,LOW); // Turn Off BLUE LED + digitalWrite(LEDB, HIGH); // Turn On BLUE LED + delay(250); + digitalWrite(LEDB, LOW); // Turn Off BLUE LED } diff --git a/examples/ScanNetworks/ScanNetworks.ino b/examples/ScanNetworks/ScanNetworks.ino index 7b54a5c2..372622ab 100644 --- a/examples/ScanNetworks/ScanNetworks.ino +++ b/examples/ScanNetworks/ScanNetworks.ino @@ -52,20 +52,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ScanNetworks on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ScanNetworks on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -98,6 +102,7 @@ void listNetworks() if (numSsid == -1) { Serial.println(F("Couldn't get a WiFi connection")); + while (true); } @@ -127,18 +132,23 @@ void printEncryptionType(int thisType) case ENC_TYPE_WEP: Serial.print(F("WEP")); break; + case ENC_TYPE_TKIP: Serial.print(F("WPA")); break; + case ENC_TYPE_CCMP: Serial.print(F("WPA2")); break; + case ENC_TYPE_NONE: Serial.print(F("None")); break; + case ENC_TYPE_AUTO: Serial.print(F("Auto")); break; + case ENC_TYPE_UNKNOWN: default: Serial.print(F("Unknown")); @@ -156,6 +166,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -163,6 +174,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ScanNetworks/defines.h b/examples/ScanNetworks/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ScanNetworks/defines.h +++ b/examples/ScanNetworks/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/ScanNetworksAdvanced/ScanNetworksAdvanced.ino b/examples/ScanNetworksAdvanced/ScanNetworksAdvanced.ino index 0473e156..f5dbb789 100644 --- a/examples/ScanNetworksAdvanced/ScanNetworksAdvanced.ino +++ b/examples/ScanNetworksAdvanced/ScanNetworksAdvanced.ino @@ -53,20 +53,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart ScanNetworksAdvanced on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart ScanNetworksAdvanced on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -103,6 +107,7 @@ void listNetworks() if (numSsid == -1) { Serial.println(F("Couldn't get a WiFi connection")); + while (true); } @@ -129,6 +134,7 @@ void listNetworks() Serial.println(WiFi.SSID(thisNet)); Serial.flush(); } + Serial.println(); } @@ -140,18 +146,23 @@ void printEncryptionType(int thisType) case ENC_TYPE_WEP: Serial.print(F("WEP")); break; + case ENC_TYPE_TKIP: Serial.print(F("WPA")); break; + case ENC_TYPE_CCMP: Serial.print(F("WPA2")); break; + case ENC_TYPE_NONE: Serial.print(F("None")); break; + case ENC_TYPE_AUTO: Serial.print(F("Auto")); break; + case ENC_TYPE_UNKNOWN: default: Serial.print(F("Unknown")); @@ -165,6 +176,7 @@ void print2Digits(byte thisByte) { Serial.print(F("0")); } + Serial.print(thisByte, HEX); } @@ -176,6 +188,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -183,6 +196,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/ScanNetworksAdvanced/defines.h b/examples/ScanNetworksAdvanced/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/ScanNetworksAdvanced/defines.h +++ b/examples/ScanNetworksAdvanced/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino b/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino index 138d1691..7c6af114 100644 --- a/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino +++ b/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino @@ -70,20 +70,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart SimpleWebServerWiFi on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart SimpleWebServerWiFi on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -103,7 +107,7 @@ void setup() // wait 10 seconds for connection: //delay(10000); } - + server.begin(); // start the web server on port 80 printWiFiStatus(); // you're connected now, so print out the status } @@ -112,27 +116,27 @@ void loop() { WiFiClient client = server.available(); // listen for incoming clients - if (client) - { + if (client) + { // if you get a client, Serial.println(F("New client")); // print a message out the serial port String currentLine = ""; // make a String to hold incoming data from the client - - while (client.connected()) - { + + while (client.connected()) + { // loop while the client's connected - if (client.available()) - { + if (client.available()) + { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor - - if (c == '\n') - { + + if (c == '\n') + { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: - if (currentLine.length() == 0) + if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: @@ -148,31 +152,32 @@ void loop() client.println(); // break out of the while loop: break; - } - else - { + } + else + { // if you got a newline, then clear currentLine: currentLine = ""; } - } - else if (c != '\r') - { + } + else if (c != '\r') + { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } // Check to see if the client request was "GET /H" or "GET /L": - if (currentLine.endsWith("GET /H")) + if (currentLine.endsWith("GET /H")) { digitalWrite(LED_BUILTIN, HIGH); // GET /H turns the LED on } - - if (currentLine.endsWith("GET /L")) + + if (currentLine.endsWith("GET /L")) { digitalWrite(LED_BUILTIN, LOW); // GET /L turns the LED off } } } + // close the connection: client.stop(); Serial.println(F("Client disonnected")); diff --git a/examples/SimpleWebServerWiFi/defines.h b/examples/SimpleWebServerWiFi/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/SimpleWebServerWiFi/defines.h +++ b/examples/SimpleWebServerWiFi/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/Tools/CheckFirmwareVersion/CheckFirmwareVersion.ino b/examples/Tools/CheckFirmwareVersion/CheckFirmwareVersion.ino index ae95da85..6534e6b0 100644 --- a/examples/Tools/CheckFirmwareVersion/CheckFirmwareVersion.ino +++ b/examples/Tools/CheckFirmwareVersion/CheckFirmwareVersion.ino @@ -49,16 +49,19 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); // Print a welcome message - Serial.print(F("\nStart WiFiNINA CheckFirmwareVersion on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiNINA CheckFirmwareVersion on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } @@ -66,7 +69,7 @@ void setup() // Print firmware version on the module String fv = WiFi.firmwareVersion(); String latestFv; - + Serial.print("Firmware version installed: "); Serial.println(fv); @@ -78,7 +81,7 @@ void setup() // Check if the latest version is installed Serial.println(); - + if (fv >= latestFv) { Serial.println(F("Check result: PASSED")); diff --git a/examples/Tools/CheckFirmwareVersion/defines.h b/examples/Tools/CheckFirmwareVersion/defines.h index 609f682f..61befa0e 100644 --- a/examples/Tools/CheckFirmwareVersion/defines.h +++ b/examples/Tools/CheckFirmwareVersion/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/Tools/FirmwareUpdater/ESP32BootROM.cpp b/examples/Tools/FirmwareUpdater/ESP32BootROM.cpp index ca8ed354..d1553641 100644 --- a/examples/Tools/FirmwareUpdater/ESP32BootROM.cpp +++ b/examples/Tools/FirmwareUpdater/ESP32BootROM.cpp @@ -1,7 +1,7 @@ /**************************************************************************************************************************** - ESP32BootROM.cpp - part of the Firmware Updater for the + ESP32BootROM.cpp - part of the Firmware Updater for the Arduino Nano-33 IoT, MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2., Adafruit's nRF52 boards - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -23,13 +23,13 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************************************************************/ #ifdef ARDUINO_SAMD_MKRVIDOR4000 -#include + #include -#define NINA_GPIO0 FPGA_NINA_GPIO0 -#define NINA_RESETN FPGA_SPIWIFI_RESET + #define NINA_GPIO0 FPGA_NINA_GPIO0 + #define NINA_RESETN FPGA_SPIWIFI_RESET #endif @@ -79,12 +79,12 @@ int ESP32BootROMClass::begin(unsigned long baudrate) #elif defined(NINA_B302_ublox) // For NINA_B302_ublox boards. OK now _serial->begin(115200); - + pinMode(_gpio0Pin, OUTPUT); pinMode(_resetnPin, OUTPUT); - + digitalWrite(_gpio0Pin, LOW); - + digitalWrite(_resetnPin, LOW); delay(100); digitalWrite(_resetnPin, HIGH); @@ -96,12 +96,12 @@ int ESP32BootROMClass::begin(unsigned long baudrate) #elif defined(NRF52_SERIES) // For NRF52_SERIES boards. To change accordingly _serial->begin(115200); - + pinMode(_gpio0Pin, OUTPUT); pinMode(_resetnPin, OUTPUT); - + digitalWrite(_gpio0Pin, LOW); - + digitalWrite(_resetnPin, LOW); delay(100); digitalWrite(_resetnPin, HIGH); @@ -171,6 +171,7 @@ int ESP32BootROMClass::begin(unsigned long baudrate) digitalWrite(_resetnPin, HIGH); delay(100); #endif + #else // For remaining boards. To change accordingly @@ -185,20 +186,20 @@ int ESP32BootROMClass::begin(unsigned long baudrate) delay(10); digitalWrite(_resetnPin, LOW); delay(100); -// To check if you need to do this + // To check if you need to do this digitalWrite(_resetnPin, HIGH); delay(100); - + #endif int synced = 0; - for (int retries = 0; !synced && (retries < 5); retries++) + for (int retries = 0; !synced && (retries < 5); retries++) { synced = sync(); } - if (!synced) + if (!synced) { return 0; } @@ -206,9 +207,10 @@ int ESP32BootROMClass::begin(unsigned long baudrate) #if defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_NANO_RP2040_CONNECT) (void)baudrate; #else - if (baudrate != 115200) + + if (baudrate != 115200) { - if (!changeBaudrate(baudrate)) + if (!changeBaudrate(baudrate)) { return 0; } @@ -218,9 +220,10 @@ int ESP32BootROMClass::begin(unsigned long baudrate) _serial->end(); _serial->begin(baudrate); } + #endif - if (!spiAttach()) + if (!spiAttach()) { return 0; } @@ -228,17 +231,17 @@ int ESP32BootROMClass::begin(unsigned long baudrate) return 1; } -void ESP32BootROMClass::end() +void ESP32BootROMClass::end() { _serial->end(); } int ESP32BootROMClass::sync() { - const uint8_t data[] = + const uint8_t data[] = { 0x07, 0x07, 0x12, 0x20, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }; @@ -246,7 +249,7 @@ int ESP32BootROMClass::sync() int results[8]; - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { results[i] = response(0x08, 100); } @@ -256,7 +259,7 @@ int ESP32BootROMClass::sync() int ESP32BootROMClass::changeBaudrate(unsigned long baudrate) { - const uint32_t data[2] = + const uint32_t data[2] = { baudrate, 0 @@ -269,7 +272,7 @@ int ESP32BootROMClass::changeBaudrate(unsigned long baudrate) int ESP32BootROMClass::spiAttach() { - const uint8_t data[] = + const uint8_t data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -279,9 +282,9 @@ int ESP32BootROMClass::spiAttach() return (response(0x0d, 3000) == 0); } -int ESP32BootROMClass::beginFlash(uint32_t offset, uint32_t size, uint32_t chunkSize) +int ESP32BootROMClass::beginFlash(uint32_t offset, uint32_t size, uint32_t chunkSize) { - const uint32_t data[4] = + const uint32_t data[4] = { size, size / chunkSize, @@ -308,7 +311,7 @@ int ESP32BootROMClass::dataFlash(const void* data, uint32_t length) memcpy(&cmdData[4], data, length); - if (length < _chunkSize) + if (length < _chunkSize) { memset(&cmdData[4 + (length / 4)], 0xff, _chunkSize - length); } @@ -318,9 +321,9 @@ int ESP32BootROMClass::dataFlash(const void* data, uint32_t length) return (response(0x03, 3000) == 0); } -int ESP32BootROMClass::endFlash(uint32_t reboot) +int ESP32BootROMClass::endFlash(uint32_t reboot) { - const uint32_t data[1] = + const uint32_t data[1] = { reboot }; @@ -332,7 +335,7 @@ int ESP32BootROMClass::endFlash(uint32_t reboot) int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size, uint8_t* result) { - const uint32_t data[4] = + const uint32_t data[4] = { offset, size, @@ -344,14 +347,14 @@ int ESP32BootROMClass::md5Flash(uint32_t offset, uint32_t size, uint8_t* result) uint8_t asciiResult[32]; - if (response(0x13, 3000, asciiResult) != 0) + if (response(0x13, 3000, asciiResult) != 0) { return 0; } char temp[3] = { 0, 0, 0 }; - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { temp[0] = asciiResult[i * 2]; temp[1] = asciiResult[i * 2 + 1]; @@ -366,11 +369,11 @@ void ESP32BootROMClass::command(int opcode, const void* data, uint16_t length) { uint32_t checksum = 0; - if (opcode == 0x03) + if (opcode == 0x03) { checksum = 0xef; // seed - for (uint16_t i = 16; i < length; i++) + for (uint16_t i = 16; i < length; i++) { checksum ^= ((const uint8_t*)data)[i]; } @@ -383,7 +386,7 @@ void ESP32BootROMClass::command(int opcode, const void* data, uint16_t length) writeEscapedBytes((uint8_t*)&checksum, sizeof(checksum)); writeEscapedBytes((uint8_t*)data, length); _serial->write(0xc0); - + #ifdef ARDUINO_SAMD_MKRVIDOR4000 // _serial->flush(); // doesn't work! #else @@ -398,13 +401,13 @@ int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body) uint8_t responseLength = 4; - for (unsigned long start = millis(); (index < (uint16_t)(10 + responseLength)) && (millis() - start) < timeout;) + for (unsigned long start = millis(); (index < (uint16_t)(10 + responseLength)) && (millis() - start) < timeout;) { - if (_serial->available()) + if (_serial->available()) { data[index] = _serial->read(); - if (index == 3) + if (index == 3) { responseLength = data[index]; } @@ -414,13 +417,14 @@ int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body) } #ifdef DEBUG - if (index) + + if (index) { - for (int i = 0; i < index; i++) + for (int i = 0; i < index; i++) { byte b = data[i]; - if (b < 0x10) + if (b < 0x10) { Serial.print('0'); } @@ -428,22 +432,24 @@ int ESP32BootROMClass::response(int opcode, unsigned long timeout, void* body) Serial.print(b, HEX); Serial.print(' '); } + Serial.println(); } + #endif - if (index != (uint16_t)(10 + responseLength)) + if (index != (uint16_t)(10 + responseLength)) { return -1; } - if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode || data[responseLength + 5] != 0x00 - || data[responseLength + 6] != 0x00 || data[responseLength + 9] != 0xc0) + if (data[0] != 0xc0 || data[1] != 0x01 || data[2] != opcode || data[responseLength + 5] != 0x00 + || data[responseLength + 6] != 0x00 || data[responseLength + 9] != 0xc0) { return -1; } - if (body) + if (body) { memcpy(body, &data[9], responseLength - 4); } @@ -455,21 +461,21 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) { uint16_t written = 0; - while (written < length) + while (written < length) { uint8_t b = data[written++]; - if (b == 0xdb) + if (b == 0xdb) { _serial->write(0xdb); _serial->write(0xdd); - } - else if (b == 0xc0) + } + else if (b == 0xc0) { _serial->write(0xdb); _serial->write(0xdc); - } - else + } + else { _serial->write(b); } @@ -478,15 +484,15 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) /* #define NINA_GPIO0 (12u) // 12, IO8, P1.00 - + #define NINA_RESETN (2u) // 2, IO21, P0.12 #define NINA_ACK (10u) // 10, IO2, P0.14 #define SPIWIFI_SS 4 //PIN_SPI1_SS // 4, IO1, P0.13 #define SPIWIFI_ACK 10 //NINA_ACK // 10, IO2, P0.14 - #define SPIWIFI_RESET 2 //NINA_RESETN // 2, IO21, P0.12 - - */ + #define SPIWIFI_RESET 2 //NINA_RESETN // 2, IO21, P0.12 + +*/ #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) \ @@ -494,35 +500,8 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) \ || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) ) - // For SAMD21 and SAMD51 boards. To be changed and added as necessary - #warning To change the pin defintions to match actual assignment for your board - - #ifndef SerialNina - // Just need to do something such as - #define SerialNina Serial1 //Serial2, etc. - #endif - - #ifndef NINA_GPIO0 - // Just need assign some pin, such as - #define NINA_GPIO0 (26u) // - #endif - - #ifndef NINA_RESETN - // Just need assign some pin, such as - #define NINA_RESETN (27u) // - #endif - - #ifndef NINA_ACK - // Just need assign some pin, such as - #define NINA_ACK (28u) // - #endif - -#elif defined(NINA_B302_ublox) || defined(NRF52_SERIES) - -#if defined(NINA_B302_ublox) - -// For NINA_B302_ublox boards. To be changed and added as necessary -#warning To change the pin defintions to match actual assignment for NINA_B302_ublox +// For SAMD21 and SAMD51 boards. To be changed and added as necessary +#warning To change the pin defintions to match actual assignment for your board #ifndef SerialNina // Just need to do something such as @@ -531,47 +510,127 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) #ifndef NINA_GPIO0 // Just need assign some pin, such as - #define NINA_GPIO0 (22u) // 12, IO8, P1.00 + #define NINA_GPIO0 (26u) // #endif #ifndef NINA_RESETN // Just need assign some pin, such as - #define NINA_RESETN (2u) // 2, IO21, P0.12 + #define NINA_RESETN (27u) // #endif #ifndef NINA_ACK // Just need assign some pin, such as - #define NINA_ACK (10u) // 10, IO2, P0.14 + #define NINA_ACK (28u) // #endif +#elif defined(NINA_B302_ublox) || defined(NRF52_SERIES) + +#if defined(NINA_B302_ublox) + + // For NINA_B302_ublox boards. To be changed and added as necessary + #warning To change the pin defintions to match actual assignment for NINA_B302_ublox + + #ifndef SerialNina + // Just need to do something such as + #define SerialNina Serial1 //Serial2, etc. + #endif + + #ifndef NINA_GPIO0 + // Just need assign some pin, such as + #define NINA_GPIO0 (22u) // 12, IO8, P1.00 + #endif + + #ifndef NINA_RESETN + // Just need assign some pin, such as + #define NINA_RESETN (2u) // 2, IO21, P0.12 + #endif + + #ifndef NINA_ACK + // Just need assign some pin, such as + #define NINA_ACK (10u) // 10, IO2, P0.14 + #endif + #elif defined(NRF52840_ITSYBITSY) -//Just a template for NRF52840_ITSYBITSY boards. Must be changed and added as necessary -#warning To change the pin defintions to match actual assignment for NRF52840_ITSYBITSY -#ifndef SerialNina - // Just need to do something such as - #define SerialNina Serial1 //Serial2, etc. -#endif + //Just a template for NRF52840_ITSYBITSY boards. Must be changed and added as necessary + #warning To change the pin defintions to match actual assignment for NRF52840_ITSYBITSY + #ifndef SerialNina + // Just need to do something such as + #define SerialNina Serial1 //Serial2, etc. + #endif -#ifndef NINA_GPIO0 - // Just need assign some pin, such as - #define NINA_GPIO0 (12u) // 12, IO8, P1.00 -#endif + #ifndef NINA_GPIO0 + // Just need assign some pin, such as + #define NINA_GPIO0 (12u) // 12, IO8, P1.00 + #endif -#ifndef NINA_RESETN - // Just need assign some pin, such as - #define NINA_RESETN (2u) // 2, IO21, P0.12 -#endif + #ifndef NINA_RESETN + // Just need assign some pin, such as + #define NINA_RESETN (2u) // 2, IO21, P0.12 + #endif -#ifndef NINA_ACK - // Just need assign some pin, such as - #define NINA_ACK (10u) // 10, IO2, P0.14 -#endif + #ifndef NINA_ACK + // Just need assign some pin, such as + #define NINA_ACK (10u) // 10, IO2, P0.14 + #endif #elif defined(NRF52_SERIES) -//Just a template for NRF52_SERIES boards. Must be changed and added as necessary -#warning To change the pin defintions to match actual assignment for NRF52_SERIES + //Just a template for NRF52_SERIES boards. Must be changed and added as necessary + #warning To change the pin defintions to match actual assignment for NRF52_SERIES + #ifndef SerialNina + // Just need to do something such as + #define SerialNina Serial1 //Serial2, etc. + #endif + + #ifndef NINA_GPIO0 + // Just need assign some pin, such as + #define NINA_GPIO0 (12u) // 12, IO8, P1.00 + #endif + + #ifndef NINA_RESETN + // Just need assign some pin, such as + #define NINA_RESETN (2u) // 2, IO21, P0.12 + #endif + + #ifndef NINA_ACK + // Just need assign some pin, such as + #define NINA_ACK (10u) // 10, IO2, P0.14 + #endif + +#else + + // For other nRF52 boards. To be changed and added as necessary + #warning To change the pin defintions to match actual assignment for nRF52 + + #ifndef SerialNina + // Just need to do something such as + #define SerialNina Serial1 //Serial2, etc. + #endif + + #ifndef NINA_GPIO0 + // Just need assign some pin, such as + #define NINA_GPIO0 (12u) // 12, IO8, P1.00 + #endif + + #ifndef NINA_RESETN + // Just need assign some pin, such as + #define NINA_RESETN (2u) // 2, IO21, P0.12 + #endif + + #ifndef NINA_ACK + // Just need assign some pin, such as + #define NINA_ACK (10u) // 10, IO2, P0.14 + #endif + +#endif //#if defined(NINA_B302_ublox) + +#elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)\ + || defined(__MK20DX128__) ) + +// For Teensy boards. To be changed and added as necessary +#warning To change the pin defintions to match actual assignment for your board + #ifndef SerialNina // Just need to do something such as #define SerialNina Serial1 //Serial2, etc. @@ -579,23 +638,23 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) #ifndef NINA_GPIO0 // Just need assign some pin, such as - #define NINA_GPIO0 (12u) // 12, IO8, P1.00 + #define NINA_GPIO0 (6u) // #endif #ifndef NINA_RESETN // Just need assign some pin, such as - #define NINA_RESETN (2u) // 2, IO21, P0.12 + #define NINA_RESETN (2u) // #endif #ifndef NINA_ACK // Just need assign some pin, such as - #define NINA_ACK (10u) // 10, IO2, P0.14 + #define NINA_ACK (5u) // #endif #else -// For other nRF52 boards. To be changed and added as necessary -#warning To change the pin defintions to match actual assignment for nRF52 +// For other boards. To be changed and added as necessary +#warning To change the pin defintions to match actual assignment for your board #ifndef SerialNina // Just need to do something such as @@ -617,59 +676,6 @@ void ESP32BootROMClass::writeEscapedBytes(const uint8_t* data, uint16_t length) #define NINA_ACK (10u) // 10, IO2, P0.14 #endif -#endif //#if defined(NINA_B302_ublox) - -#elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)\ - || defined(__MK20DX128__) ) - - // For Teensy boards. To be changed and added as necessary - #warning To change the pin defintions to match actual assignment for your board - - #ifndef SerialNina - // Just need to do something such as - #define SerialNina Serial1 //Serial2, etc. - #endif - - #ifndef NINA_GPIO0 - // Just need assign some pin, such as - #define NINA_GPIO0 (6u) // - #endif - - #ifndef NINA_RESETN - // Just need assign some pin, such as - #define NINA_RESETN (2u) // - #endif - - #ifndef NINA_ACK - // Just need assign some pin, such as - #define NINA_ACK (5u) // - #endif - -#else - - // For other boards. To be changed and added as necessary - #warning To change the pin defintions to match actual assignment for your board - - #ifndef SerialNina - // Just need to do something such as - #define SerialNina Serial1 //Serial2, etc. - #endif - - #ifndef NINA_GPIO0 - // Just need assign some pin, such as - #define NINA_GPIO0 (12u) // 12, IO8, P1.00 - #endif - - #ifndef NINA_RESETN - // Just need assign some pin, such as - #define NINA_RESETN (2u) // 2, IO21, P0.12 - #endif - - #ifndef NINA_ACK - // Just need assign some pin, such as - #define NINA_ACK (10u) // 10, IO2, P0.14 - #endif - #endif //#if defined(NINA_B302_ublox) || defined(NRF52_SERIES) ESP32BootROMClass ESP32BootROM(SerialNina, NINA_GPIO0, NINA_RESETN); diff --git a/examples/Tools/FirmwareUpdater/ESP32BootROM.h b/examples/Tools/FirmwareUpdater/ESP32BootROM.h index 9037dac3..483e5440 100644 --- a/examples/Tools/FirmwareUpdater/ESP32BootROM.h +++ b/examples/Tools/FirmwareUpdater/ESP32BootROM.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** - ESP32BootROM.h - part of the Firmware Updater for the + ESP32BootROM.h - part of the Firmware Updater for the Arduino Nano-33 IoT, MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2., Adafruit's nRF52 boards - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -28,7 +28,7 @@ #include -class ESP32BootROMClass +class ESP32BootROMClass { public: ESP32BootROMClass(HardwareSerial& hwSerial, int gpio0Pin, int resetnPin); diff --git a/examples/Tools/FirmwareUpdater/Endianess.ino b/examples/Tools/FirmwareUpdater/Endianess.ino index 8bbce775..adc87870 100644 --- a/examples/Tools/FirmwareUpdater/Endianess.ino +++ b/examples/Tools/FirmwareUpdater/Endianess.ino @@ -1,7 +1,7 @@ /**************************************************************************************************************************** - Endianess.ino - Network byte order conversion functions - part of the Firmware Updater for the + Endianess.ino - Network byte order conversion functions - part of the Firmware Updater for the Arduino Nano-33 IoT, MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2., Adafruit's nRF52 boards - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -26,59 +26,63 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************************************************************/ -bool isBigEndian() +bool isBigEndian() { uint32_t test = 0x11223344; uint8_t *pTest = reinterpret_cast(&test); return pTest[0] == 0x11; } -uint32_t fromNetwork32(uint32_t from) +uint32_t fromNetwork32(uint32_t from) { static const bool be = isBigEndian(); - - if (be) + + if (be) { return from; - } - else + } + else { uint8_t *pFrom = reinterpret_cast(&from); uint32_t to; - - to = pFrom[0]; to <<= 8; - to |= pFrom[1]; to <<= 8; - to |= pFrom[2]; to <<= 8; + + to = pFrom[0]; + to <<= 8; + to |= pFrom[1]; + to <<= 8; + to |= pFrom[2]; + to <<= 8; to |= pFrom[3]; return to; } } -uint16_t fromNetwork16(uint16_t from) +uint16_t fromNetwork16(uint16_t from) { static bool be = isBigEndian(); - - if (be) + + if (be) { return from; - } - else + } + else { uint8_t *pFrom = reinterpret_cast(&from); uint16_t to; - - to = pFrom[0]; to <<= 8; + + to = pFrom[0]; + to <<= 8; to |= pFrom[1]; return to; } } -uint32_t toNetwork32(uint32_t to) +uint32_t toNetwork32(uint32_t to) { return fromNetwork32(to); } -uint16_t toNetwork16(uint16_t to) +uint16_t toNetwork16(uint16_t to) { return fromNetwork16(to); } diff --git a/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino b/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino index a91107f1..8174ff30 100644 --- a/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino +++ b/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino @@ -1,7 +1,7 @@ /**************************************************************************************************************************** FirmwareUpdater.ino - Firmware Updater for the Arduino Nano-33 IoT, MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2., Adafruit's nRF52 boards - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -23,12 +23,12 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************************************************************/ #include "ESP32BootROM.h" -typedef struct __attribute__((__packed__)) +typedef struct __attribute__((__packed__)) { uint8_t command; uint32_t address; @@ -36,7 +36,8 @@ typedef struct __attribute__((__packed__)) uint16_t payloadLength; // payloadLenght bytes of data follows... -} UartPacket; +} +UartPacket; static const int MAX_PAYLOAD_SIZE = 1024; @@ -49,8 +50,8 @@ static const int MAX_PAYLOAD_SIZE = 1024; void setup() { -#if defined(NINA_B302_ublox) || defined(NRF52_SERIES) - #warning Serial speed currently set to 921,600 for nRF52 and NINA_B302_ublox +#if defined(NINA_B302_ublox) || defined(NRF52_SERIES) +#warning Serial speed currently set to 921,600 for nRF52 and NINA_B302_ublox Serial.begin(921600); #elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ @@ -62,24 +63,25 @@ void setup() || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) // Change according to the speed your board can support // 1000000 is default and working for Nano 33 IoT, ARDUINO_SAMD_MKRWIFI1010, ARDUINO_SAMD_MKRVIDOR4000 - #warning Serial speed currently set to 1,000,000 for SAMD21 and SAMD51 +#warning Serial speed currently set to 1,000,000 for SAMD21 and SAMD51 Serial.begin(1000000); #elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)\ || defined(__MK20DX128__) ) - #if ( defined(__MKL26Z64__) || defined(ARDUINO_ARCH_AVR) ) - #error Teensy LC and 2.0 not supported - #endif +#if ( defined(__MKL26Z64__) || defined(ARDUINO_ARCH_AVR) ) +#error Teensy LC and 2.0 not supported +#endif // Change according to the speed your board can support - #warning Serial speed currently set to 921,600 for Teensy boards - Serial.begin(921600); +#warning Serial speed currently set to 921,600 for Teensy boards + Serial.begin(921600); #else // Change according to the speed your board can support Serial.begin(921600); #endif - if (!ESP32BootROM.begin(921600)) + if (!ESP32BootROM.begin(921600)) { Serial.println(F("Unable to communicate with ESP32 boot ROM!")); + while (1); } @@ -91,14 +93,14 @@ void receivePacket(UartPacket *pkt, uint8_t *payload) // Read command uint8_t *p = reinterpret_cast(pkt); uint16_t l = sizeof(UartPacket); - + while (l > 0) { int c = Serial.read(); - + if (c == -1) continue; - + *p++ = c; l--; } @@ -110,13 +112,14 @@ void receivePacket(UartPacket *pkt, uint8_t *payload) // Read payload l = pkt->payloadLength; - + while (l > 0) { int c = Serial.read(); - + if (c == -1) continue; + *payload++ = c; l--; } @@ -152,7 +155,7 @@ void loop() if (pkt.command == CMD_WRITE_FLASH) { uint32_t len = pkt.payloadLength; - + if (!ESP32BootROM.dataFlash(payload, len)) { Serial.print(F("ER")); @@ -167,7 +170,7 @@ void loop() { uint32_t address = pkt.address; uint32_t len = pkt.arg1; - + if (!ESP32BootROM.beginFlash(address, len, MAX_PAYLOAD_SIZE)) { Serial.print(F("ER")); diff --git a/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino b/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino index 5c458986..e5a9acee 100644 --- a/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino +++ b/examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino @@ -27,11 +27,11 @@ *****************************************************************************************************************************/ #ifdef ARDUINO_SAMD_MKRVIDOR4000 -#include + #include -unsigned long baud = 119400; + unsigned long baud = 119400; #else -unsigned long baud = 115200; + unsigned long baud = 115200; #endif int rts = -1; @@ -46,7 +46,7 @@ int dtr = -1; || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #define USE_RTS_CTS false +#define USE_RTS_CTS false // For SAMD21 and SAMD51 boards. To be changed and added as necessary #warning To change the pin defintions to match actual assignment for your board @@ -58,122 +58,122 @@ int dtr = -1; #ifndef NINA_GPIO0 // Just need assign some pin, such as - #define NINA_GPIO0 (26u) // + #define NINA_GPIO0 (26u) // #endif #ifndef NINA_RESETN // Just need assign some pin, such as - #define NINA_RESETN (27u) // + #define NINA_RESETN (27u) // #endif #ifndef NINA_ACK // Just need assign some pin, such as - #define NINA_ACK (28u) // + #define NINA_ACK (28u) // #endif - + #elif defined(NINA_B302_ublox) || defined(NRF52_SERIES) - #define USE_RTS_CTS false +#define USE_RTS_CTS false + +#if defined(NINA_B302_ublox) - #if defined(NINA_B302_ublox) - // For NINA_B302_ublox boards. To be changed and added as necessary #warning To change the pin defintions to match actual assignment for NINA_B302_ublox - + #ifndef SerialNina // Just need to do something such as #define SerialNina Serial1 //Serial2, etc. #endif - + #ifndef NINA_GPIO0 // Just need assign some pin, such as #define NINA_GPIO0 (22u) // 12, IO8, P1.00 #endif - + #ifndef NINA_RESETN // Just need assign some pin, such as #define NINA_RESETN (2u) // 2, IO21, P0.12 #endif - + #ifndef NINA_ACK // Just need assign some pin, such as #define NINA_ACK (10u) // 10, IO2, P0.14 #endif - - #elif defined(NRF52840_ITSYBITSY) - + +#elif defined(NRF52840_ITSYBITSY) + //Just a template for NRF52840_ITSYBITSY boards. Must be changed and added as necessary #warning To change the pin defintions to match actual assignment for NRF52840_ITSYBITSY #ifndef SerialNina // Just need to do something such as #define SerialNina Serial1 //Serial2, etc. #endif - + #ifndef NINA_GPIO0 // Just need assign some pin, such as #define NINA_GPIO0 (12u) // 12, IO8, P1.00 #endif - + #ifndef NINA_RESETN // Just need assign some pin, such as #define NINA_RESETN (2u) // 2, IO21, P0.12 #endif - + #ifndef NINA_ACK // Just need assign some pin, such as #define NINA_ACK (10u) // 10, IO2, P0.14 #endif - - #elif defined(NRF52_SERIES) - + +#elif defined(NRF52_SERIES) + //Just a template for NRF52_SERIES boards. Must be changed and added as necessary #warning To change the pin defintions to match actual assignment for NRF52_SERIES #ifndef SerialNina // Just need to do something such as #define SerialNina Serial1 //Serial2, etc. #endif - + #ifndef NINA_GPIO0 // Just need assign some pin, such as #define NINA_GPIO0 (12u) // 12, IO8, P1.00 #endif - + #ifndef NINA_RESETN // Just need assign some pin, such as #define NINA_RESETN (2u) // 2, IO21, P0.12 #endif - + #ifndef NINA_ACK // Just need assign some pin, such as #define NINA_ACK (10u) // 10, IO2, P0.14 #endif - #else - +#else + // For other nRF52 boards. To be changed and added as necessary #warning To change the pin defintions to match actual assignment for nRF52 - + #ifndef SerialNina // Just need to do something such as #define SerialNina Serial1 //Serial2, etc. #endif - + #ifndef NINA_GPIO0 // Just need assign some pin, such as #define NINA_GPIO0 (12u) // 12, IO8, P1.00 #endif - + #ifndef NINA_RESETN // Just need assign some pin, such as #define NINA_RESETN (2u) // 2, IO21, P0.12 #endif - + #ifndef NINA_ACK // Just need assign some pin, such as #define NINA_ACK (10u) // 10, IO2, P0.14 #endif - - #endif //#if defined(NINA_B302_ublox) + +#endif //#if defined(NINA_B302_ublox) #elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)\ || defined(__MK20DX128__) ) @@ -188,22 +188,22 @@ int dtr = -1; #ifndef NINA_GPIO0 // Just need assign some pin, such as - #define NINA_GPIO0 (6u) // + #define NINA_GPIO0 (6u) // #endif #ifndef NINA_RESETN // Just need assign some pin, such as - #define NINA_RESETN (2u) // + #define NINA_RESETN (2u) // #endif #ifndef NINA_ACK // Just need assign some pin, such as - #define NINA_ACK (5u) // + #define NINA_ACK (5u) // #endif - + #else - #define USE_RTS_CTS false +#define USE_RTS_CTS false // For other boards. To be changed and added as necessary #warning To change the pin defintions to match actual assignment for your board @@ -269,57 +269,62 @@ void loop() { #if USE_RTS_CTS - - #ifndef ARDUINO_AVR_UNO_WIFI_REV2 - if (rts != Serial.rts()) { - #ifdef ARDUINO_SAMD_MKRVIDOR4000 - FPGA.digitalWrite(FPGA_SPIWIFI_RESET, (Serial.rts() == 1) ? LOW : HIGH); - #elif defined(ARDUINO_SAMD_NANO_33_IOT) - digitalWrite(NINA_RESETN, Serial.rts() ? LOW : HIGH); - #else - digitalWrite(NINA_RESETN, Serial.rts()); - #endif - rts = Serial.rts(); - } - - if (dtr != Serial.dtr()) - { - #ifdef ARDUINO_SAMD_MKRVIDOR4000 - FPGA.digitalWrite(FPGA_NINA_GPIO0, (Serial.dtr() == 1) ? HIGH : LOW); - #else - digitalWrite(NINA_GPIO0, (Serial.dtr() == 0) ? HIGH : LOW); - #endif - dtr = Serial.dtr(); - } - #endif + +#ifndef ARDUINO_AVR_UNO_WIFI_REV2 + + if (rts != Serial.rts()) + { +#ifdef ARDUINO_SAMD_MKRVIDOR4000 + FPGA.digitalWrite(FPGA_SPIWIFI_RESET, (Serial.rts() == 1) ? LOW : HIGH); +#elif defined(ARDUINO_SAMD_NANO_33_IOT) + digitalWrite(NINA_RESETN, Serial.rts() ? LOW : HIGH); +#else + digitalWrite(NINA_RESETN, Serial.rts()); +#endif + rts = Serial.rts(); + } + + if (dtr != Serial.dtr()) + { +#ifdef ARDUINO_SAMD_MKRVIDOR4000 + FPGA.digitalWrite(FPGA_NINA_GPIO0, (Serial.dtr() == 1) ? HIGH : LOW); +#else + digitalWrite(NINA_GPIO0, (Serial.dtr() == 0) ? HIGH : LOW); +#endif + dtr = Serial.dtr(); + } + +#endif #endif // USE_RTS_CTS - - if (Serial.available()) + + if (Serial.available()) { SerialNina.write(Serial.read()); } - if (SerialNina.available()) + if (SerialNina.available()) { Serial.write(SerialNina.read()); } #if USE_RTS_CTS - #ifndef ARDUINO_AVR_UNO_WIFI_REV2 - // check if the USB virtual serial wants a new baud rate - if (Serial.baud() != baud) - { - rts = -1; - dtr = -1; - - baud = Serial.baud(); - #ifndef ARDUINO_SAMD_MKRVIDOR4000 - SerialNina.begin(baud); - #endif - } - #endif +#ifndef ARDUINO_AVR_UNO_WIFI_REV2 + + // check if the USB virtual serial wants a new baud rate + if (Serial.baud() != baud) + { + rts = -1; + dtr = -1; + + baud = Serial.baud(); +#ifndef ARDUINO_SAMD_MKRVIDOR4000 + SerialNina.begin(baud); +#endif + } + +#endif #endif // #if USE_RTS_CTS } diff --git a/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino b/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino index df7b2073..a8d11a02 100644 --- a/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino +++ b/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino @@ -60,20 +60,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiAdvancedChatServer on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiAdvancedChatServer on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -101,23 +105,23 @@ void setup() Serial.println(WiFi.localIP()); } -void loop() +void loop() { // check for any new client connecting, and say hello (before any incoming data) WiFiClient newClient = server.accept(); - - if (newClient) + + if (newClient) { - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (!clients[i]) + if (!clients[i]) { Serial.print("We have a new client #"); Serial.println(i); - + newClient.print("Hello, client number: "); newClient.println(i); - + // Once we "accept", the client is no longer tracked by WiFiServer // so we must store it into our list of clients clients[i] = newClient; @@ -127,20 +131,20 @@ void loop() } // check for incoming data from all clients - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (clients[i] && clients[i].available() > 0) + if (clients[i] && clients[i].available() > 0) { - #define BUFFER_SIZE 80 - +#define BUFFER_SIZE 80 + // read bytes from a client byte buffer[BUFFER_SIZE]; int count = clients[i].read(buffer, BUFFER_SIZE); - + // write the bytes to all other connected clients - for (byte j = 0; j < MAX_NUMBER_CLIENTS; j++) + for (byte j = 0; j < MAX_NUMBER_CLIENTS; j++) { - if (j != i && clients[j].connected()) + if (j != i && clients[j].connected()) { clients[j].write(buffer, count); } @@ -149,9 +153,9 @@ void loop() } // stop any clients which disconnect - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (clients[i] && !clients[i].connected()) + if (clients[i] && !clients[i].connected()) { Serial.print("disconnect client #"); Serial.println(i); diff --git a/examples/WiFiAdvancedChatServer/defines.h b/examples/WiFiAdvancedChatServer/defines.h index a3aef4d7..61befa0e 100644 --- a/examples/WiFiAdvancedChatServer/defines.h +++ b/examples/WiFiAdvancedChatServer/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiChatServer/WiFiChatServer.ino b/examples/WiFiChatServer/WiFiChatServer.ino index a1a58712..9815dce0 100644 --- a/examples/WiFiChatServer/WiFiChatServer.ino +++ b/examples/WiFiChatServer/WiFiChatServer.ino @@ -68,20 +68,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiChatServer on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiChatServer on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -125,7 +129,7 @@ void loop() alreadyConnected = true; } - if (client.available() > 0) + if (client.available() > 0) { // read the bytes incoming from the client: char thisChar = client.read(); diff --git a/examples/WiFiChatServer/defines.h b/examples/WiFiChatServer/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiChatServer/defines.h +++ b/examples/WiFiChatServer/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/WiFiAdvancedChatServer_WiFiMulti.ino b/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/WiFiAdvancedChatServer_WiFiMulti.ino index eb2c980c..9fbf2842 100644 --- a/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/WiFiAdvancedChatServer_WiFiMulti.ino +++ b/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/WiFiAdvancedChatServer_WiFiMulti.ino @@ -78,12 +78,12 @@ void heartBeatPrint() else if (num++ % 10 == 0) { Serial.print(F(" ")); - } + } } uint8_t connectMultiWiFi() { -// For general board, this better be 1000 to enable connect the 1st time + // For general board, this better be 1000 to enable connect the 1st time #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 1000L #define WIFI_MULTI_CONNECT_WAITING_MS 500L @@ -163,7 +163,7 @@ void check_status() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); @@ -185,9 +185,11 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiAdvancedChatServer on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiAdvancedChatServer on ")); + Serial.println(BOARD_NAME); Serial.println(WIFIMULTI_GENERIC_VERSION); Serial.println(WIFININA_GENERIC_VERSION); @@ -195,11 +197,13 @@ void setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -231,25 +235,25 @@ void setup() Serial.println(WiFi.localIP()); } -void loop() +void loop() { check_status(); - + // check for any new client connecting, and say hello (before any incoming data) WiFiClient newClient = server.accept(); - - if (newClient) + + if (newClient) { - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (!clients[i]) + if (!clients[i]) { Serial.print("We have a new client #"); Serial.println(i); - + newClient.print("Hello, client number: "); newClient.println(i); - + // Once we "accept", the client is no longer tracked by WiFiServer // so we must store it into our list of clients clients[i] = newClient; @@ -259,20 +263,20 @@ void loop() } // check for incoming data from all clients - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (clients[i] && clients[i].available() > 0) + if (clients[i] && clients[i].available() > 0) { - #define BUFFER_SIZE 80 - +#define BUFFER_SIZE 80 + // read bytes from a client byte buffer[BUFFER_SIZE]; int count = clients[i].read(buffer, BUFFER_SIZE); - + // write the bytes to all other connected clients - for (byte j = 0; j < MAX_NUMBER_CLIENTS; j++) + for (byte j = 0; j < MAX_NUMBER_CLIENTS; j++) { - if (j != i && clients[j].connected()) + if (j != i && clients[j].connected()) { clients[j].write(buffer, count); } @@ -281,9 +285,9 @@ void loop() } // stop any clients which disconnect - for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) + for (byte i = 0; i < MAX_NUMBER_CLIENTS; i++) { - if (clients[i] && !clients[i].connected()) + if (clients[i] && !clients[i].connected()) { Serial.print("disconnect client #"); Serial.println(i); diff --git a/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/defines.h b/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/defines.h index 426fa717..1793b661 100644 --- a/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/defines.h +++ b/examples/WiFiMulti/WiFiAdvancedChatServer_WiFiMulti/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif -#endif +#endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/WiFiUdpNtpClient_WiFiMulti.ino b/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/WiFiUdpNtpClient_WiFiMulti.ino index 62b21864..a0ef726e 100644 --- a/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/WiFiUdpNtpClient_WiFiMulti.ino +++ b/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/WiFiUdpNtpClient_WiFiMulti.ino @@ -72,11 +72,11 @@ WiFiUDP Udp; WiFiMulti_Generic wifiMulti; // send an NTP request to the time server at the given address -void sendNTPpacket(IPAddress& address) +void sendNTPpacket(IPAddress& address) { // set all bytes in the buffer to 0 memset(packetBuffer, 0, NTP_PACKET_SIZE); - + // Initialize values needed to form NTP request // (see URL above for details on the packets) packetBuffer[0] = 0b11100011; // LI, Version, Mode @@ -116,12 +116,12 @@ void heartBeatPrint() else if (num++ % 10 == 0) { Serial.print(F(" ")); - } + } } uint8_t connectMultiWiFi() { -// For general board, this better be 1000 to enable connect the 1st time + // For general board, this better be 1000 to enable connect the 1st time #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 1000L #define WIFI_MULTI_CONNECT_WAITING_MS 500L @@ -210,7 +210,7 @@ void check_status() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); @@ -232,9 +232,11 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiUdpNtpClient on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiUdpNtpClient on ")); + Serial.println(BOARD_NAME); Serial.println(WIFIMULTI_GENERIC_VERSION); Serial.println(WIFININA_GENERIC_VERSION); @@ -242,11 +244,13 @@ void setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -277,7 +281,7 @@ void setup() void getUDPPacket() { - if (Udp.parsePacket()) + if (Udp.parsePacket()) { Serial.println(F("\nPacket received")); // We've received a packet, read the data from it @@ -291,7 +295,7 @@ void getUDPPacket() // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): unsigned long secsSince1900 = highWord << 16 | lowWord; - + Serial.print(F("Seconds since Jan 1 1900 = ")); Serial.println(secsSince1900); @@ -308,24 +312,24 @@ void getUDPPacket() Serial.print(F("The UTC time is ")); // UTC is the time at Greenwich Meridian (GMT) Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) Serial.print(':'); - - if (((epoch % 3600) / 60) < 10) + + if (((epoch % 3600) / 60) < 10) { // In the first 10 minutes of each hour, we'll want a leading '0' Serial.print('0'); } - + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) Serial.print(':'); - - if ((epoch % 60) < 10) + + if ((epoch % 60) < 10) { // In the first 10 seconds of each minute, we'll want a leading '0' Serial.print('0'); } - + Serial.println(epoch % 60); // print the second - } + } } void loop() diff --git a/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/defines.h b/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/defines.h index 42f9a9bb..1793b661 100644 --- a/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/defines.h +++ b/examples/WiFiMulti/WiFiUdpNtpClient_WiFiMulti/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/WiFiWebClientRepeating_WiFiMulti.ino b/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/WiFiWebClientRepeating_WiFiMulti.ino index fd9f7c96..542d8402 100644 --- a/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/WiFiWebClientRepeating_WiFiMulti.ino +++ b/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/WiFiWebClientRepeating_WiFiMulti.ino @@ -86,12 +86,12 @@ void heartBeatPrint() else if (num++ % 10 == 0) { Serial.print(F(" ")); - } + } } uint8_t connectMultiWiFi() { -// For general board, this better be 1000 to enable connect the 1st time + // For general board, this better be 1000 to enable connect the 1st time #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 1000L #define WIFI_MULTI_CONNECT_WAITING_MS 500L @@ -208,7 +208,7 @@ void check_status() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); @@ -230,9 +230,11 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiWebClientRepeating on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiWebClientRepeating on ")); + Serial.println(BOARD_NAME); Serial.println(WIFIMULTI_GENERIC_VERSION); Serial.println(WIFININA_GENERIC_VERSION); @@ -240,11 +242,13 @@ void setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -273,7 +277,7 @@ void setup() void loop() { check_status(); - + // if there's incoming data from the net connection. // send it out the serial port. This is for debugging // purposes only: diff --git a/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/defines.h b/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/defines.h index 42f9a9bb..1793b661 100644 --- a/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/defines.h +++ b/examples/WiFiMulti/WiFiWebClientRepeating_WiFiMulti/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiMulti/WiFiWebClient_WiFiMulti/WiFiWebClient_WiFiMulti.ino b/examples/WiFiMulti/WiFiWebClient_WiFiMulti/WiFiWebClient_WiFiMulti.ino index f61c8db4..eaf20234 100644 --- a/examples/WiFiMulti/WiFiWebClient_WiFiMulti/WiFiWebClient_WiFiMulti.ino +++ b/examples/WiFiMulti/WiFiWebClient_WiFiMulti/WiFiWebClient_WiFiMulti.ino @@ -91,12 +91,12 @@ void heartBeatPrint() else if (num++ % 10 == 0) { Serial.print(F(" ")); - } + } } uint8_t connectMultiWiFi() { -// For general board, this better be 1000 to enable connect the 1st time + // For general board, this better be 1000 to enable connect the 1st time #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 1000L #define WIFI_MULTI_CONNECT_WAITING_MS 500L @@ -177,7 +177,7 @@ void check_status() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); @@ -199,9 +199,11 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiWebClient on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiWebClient on ")); + Serial.println(BOARD_NAME); Serial.println(WIFIMULTI_GENERIC_VERSION); Serial.println(WIFININA_GENERIC_VERSION); @@ -209,11 +211,13 @@ void setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -255,7 +259,7 @@ void setup() void loop() { check_status(); - + // if there are incoming bytes available // from the server, read them and print them: while (client.available()) diff --git a/examples/WiFiMulti/WiFiWebClient_WiFiMulti/defines.h b/examples/WiFiMulti/WiFiWebClient_WiFiMulti/defines.h index bf726a47..1f0f4a1d 100644 --- a/examples/WiFiMulti/WiFiWebClient_WiFiMulti/defines.h +++ b/examples/WiFiMulti/WiFiWebClient_WiFiMulti/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,55 +323,55 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiNINA_SSL_Test/WiFiNINA_SSL_Test.ino b/examples/WiFiNINA_SSL_Test/WiFiNINA_SSL_Test.ino index 1f2cbda6..4301bf16 100644 --- a/examples/WiFiNINA_SSL_Test/WiFiNINA_SSL_Test.ino +++ b/examples/WiFiNINA_SSL_Test/WiFiNINA_SSL_Test.ino @@ -62,20 +62,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiNINA_SSL_Test on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiNINA_SSL_Test on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -121,7 +125,7 @@ void setup() } } -void loop() +void loop() { // if there are incoming bytes available // from the server, read them and print them: diff --git a/examples/WiFiNINA_SSL_Test/defines.h b/examples/WiFiNINA_SSL_Test/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiNINA_SSL_Test/defines.h +++ b/examples/WiFiNINA_SSL_Test/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiPing/WiFiPing.ino b/examples/WiFiPing/WiFiPing.ino index 42e852df..2ca7044f 100644 --- a/examples/WiFiPing/WiFiPing.ino +++ b/examples/WiFiPing/WiFiPing.ino @@ -64,20 +64,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiPing on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiPing on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -117,8 +121,8 @@ void loop() Serial.print(F("SUCCESS! RTT = ")); Serial.print(pingResult); Serial.println(F(" ms")); - } - else + } + else { Serial.print(F("FAILED! Error code: ")); Serial.println(pingResult); @@ -182,6 +186,7 @@ void printMacAddress(byte mac[]) { Serial.print(F("0")); } + Serial.print(mac[i], HEX); if (i > 0) @@ -189,6 +194,6 @@ void printMacAddress(byte mac[]) Serial.print(F(":")); } } - + Serial.println(); } diff --git a/examples/WiFiPing/defines.h b/examples/WiFiPing/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiPing/defines.h +++ b/examples/WiFiPing/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiSSLClient/WiFiSSLClient.ino b/examples/WiFiSSLClient/WiFiSSLClient.ino index db66d7ab..c8ad891c 100644 --- a/examples/WiFiSSLClient/WiFiSSLClient.ino +++ b/examples/WiFiSSLClient/WiFiSSLClient.ino @@ -66,20 +66,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiSSLClient on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiSSLClient on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -99,12 +103,12 @@ void setup() // wait 10 seconds for connection: //delay(10000); } - + Serial.println(F("Connected to WiFi")); printWiFiStatus(); Serial.println(F("\nStarting connection to server...")); - + // if you get a connection, report back via serial: if (client.connect(server, 443)) { @@ -138,7 +142,7 @@ void loop() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); diff --git a/examples/WiFiSSLClient/defines.h b/examples/WiFiSSLClient/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiSSLClient/defines.h +++ b/examples/WiFiSSLClient/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiStorage/WiFiStorage.ino b/examples/WiFiStorage/WiFiStorage.ino index a2d30f45..d7cb971b 100644 --- a/examples/WiFiStorage/WiFiStorage.ino +++ b/examples/WiFiStorage/WiFiStorage.ino @@ -40,23 +40,27 @@ #define BOARD_NAME "Unknown board" #endif -void setup() +void setup() { Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiStorage on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiStorage on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -67,7 +71,7 @@ void setup() WiFiStorageFile file = WiFiStorage.open("/fs/testfile"); - if (file) + if (file) { file.erase(); } @@ -75,21 +79,21 @@ void setup() Serial.println(F("WiFiStorage error")); String test = "WiFiStorage on " + String(BOARD_NAME) + " is OK if you see this long line."; - + file.write(test.c_str(), test.length()); - if (file) + if (file) { uint8_t buf[128]; file.seek(0); file.read(buf, 128); - + Serial.println((char*) buf); - } + } } -void loop() +void loop() { // put your main code here, to run repeatedly: } diff --git a/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino b/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino index a18efb69..8b931cd7 100644 --- a/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino +++ b/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino @@ -73,20 +73,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiUdpNtpClient on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiUdpNtpClient on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -117,11 +121,11 @@ void setup() void loop() { sendNTPpacket(timeServer); // send an NTP packet to a time server - + // wait to see if a reply is available delay(1000); - - if (Udp.parsePacket()) + + if (Udp.parsePacket()) { Serial.println(F("Packet received")); // We've received a packet, read the data from it @@ -151,24 +155,25 @@ void loop() Serial.print(F("The UTC time is ")); // UTC is the time at Greenwich Meridian (GMT) Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) Serial.print(':'); - - if (((epoch % 3600) / 60) < 10) + + if (((epoch % 3600) / 60) < 10) { // In the first 10 minutes of each hour, we'll want a leading '0' Serial.print('0'); } - + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) Serial.print(':'); - - if ((epoch % 60) < 10) + + if ((epoch % 60) < 10) { // In the first 10 seconds of each minute, we'll want a leading '0' Serial.print('0'); } - + Serial.println(epoch % 60); // print the second } + // wait ten seconds before asking for the time again delay(10000); } @@ -198,7 +203,7 @@ void sendNTPpacket(IPAddress& address) Udp.endPacket(); } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); diff --git a/examples/WiFiUdpNtpClient/defines.h b/examples/WiFiUdpNtpClient/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiUdpNtpClient/defines.h +++ b/examples/WiFiUdpNtpClient/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino b/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino index 12fb3727..c320c059 100644 --- a/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino +++ b/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino @@ -63,20 +63,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiUdpSendReceiveString on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiUdpSendReceiveString on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -96,6 +100,7 @@ void setup() // wait 10 seconds for connection: //delay(10000); } + Serial.println(F("Connected to WiFi")); printWiFiStatus(); @@ -137,7 +142,7 @@ void loop() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); diff --git a/examples/WiFiUdpSendReceiveString/defines.h b/examples/WiFiUdpSendReceiveString/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiUdpSendReceiveString/defines.h +++ b/examples/WiFiUdpSendReceiveString/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiWebClient/WiFiWebClient.ino b/examples/WiFiWebClient/WiFiWebClient.ino index d5a8085b..8a0d91be 100644 --- a/examples/WiFiWebClient/WiFiWebClient.ino +++ b/examples/WiFiWebClient/WiFiWebClient.ino @@ -74,20 +74,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiWebClient on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiWebClient on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -146,7 +150,7 @@ void loop() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); diff --git a/examples/WiFiWebClient/defines.h b/examples/WiFiWebClient/defines.h index 5799e206..21444112 100644 --- a/examples/WiFiWebClient/defines.h +++ b/examples/WiFiWebClient/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,55 +323,55 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiWebClientRepeating/WiFiWebClientRepeating.ino b/examples/WiFiWebClientRepeating/WiFiWebClientRepeating.ino index 702fe836..108b4fb7 100644 --- a/examples/WiFiWebClientRepeating/WiFiWebClientRepeating.ino +++ b/examples/WiFiWebClientRepeating/WiFiWebClientRepeating.ino @@ -68,20 +68,24 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); + while (!Serial && millis() < 5000); - Serial.print(F("\nStart WiFiWebClientRepeating on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStart WiFiWebClientRepeating on ")); + Serial.println(BOARD_NAME); Serial.println(WIFININA_GENERIC_VERSION); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println(F("Communication with WiFi module failed!")); + // don't continue while (true); } String fv = WiFi.firmwareVersion(); + if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.print(F("Your current firmware NINA FW v")); @@ -152,7 +156,7 @@ void httpRequest() } } -void printWiFiStatus() +void printWiFiStatus() { // print the SSID of the network you're attached to: Serial.print(F("SSID: ")); diff --git a/examples/WiFiWebClientRepeating/defines.h b/examples/WiFiWebClientRepeating/defines.h index 609f682f..61befa0e 100644 --- a/examples/WiFiWebClientRepeating/defines.h +++ b/examples/WiFiWebClientRepeating/defines.h @@ -1,7 +1,7 @@ /**************************************************************************************************************************** defines.h For boards with WiFiNINA module/shield. - + Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc. @@ -37,10 +37,10 @@ || defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) - #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD - #endif - #define WIFININA_USE_SAMD true +#if defined(WIFININA_USE_SAMD) + #undef WIFININA_USE_SAMD +#endif +#define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) @@ -150,10 +150,10 @@ #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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 - #endif - #define WIFININA_USE_NRF52 true +#if defined(WIFININA_USE_NRF52) + #undef WIFININA_USE_NRF52 +#endif +#define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) @@ -213,10 +213,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) ) - #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 - #endif - #define WIFININA_USE_STM32 true +#if defined(WIFININA_USE_STM32) + #undef WIFININA_USE_STM32 +#endif +#define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) @@ -275,7 +275,7 @@ #undef WIFININA_USE_TEENSY #endif #define WIFININA_USE_TEENSY true - + #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #define BOARD_TYPE "TEENSY 4.1/4.0" @@ -314,7 +314,7 @@ #if defined(ARDUINO_NANO_RP2040_CONNECT) #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #elif defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_NAME "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" @@ -323,54 +323,54 @@ #else #define BOARD_NAME "MBED Unknown RP2040" #endif - + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__)) - #define BOARD_TYPE "Arduino AVR Mega2560/ADK" - #warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. - +#define BOARD_TYPE "Arduino AVR Mega2560/ADK" +#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK. + #elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \ defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \ defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \ - defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) - #define BOARD_TYPE "Arduino AVR UNO, Nano, etc." - #warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. + defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) ) +#define BOARD_TYPE "Arduino AVR UNO, Nano, etc." +#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano. #elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) - #define BOARD_TYPE "Adafruit AVR ATMega328(P)" - #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. - +#define BOARD_TYPE "Adafruit AVR ATMega328(P)" +#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + #elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) - #define BOARD_TYPE "Arduino AVR ATMega32U4" - #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. - +#define BOARD_TYPE "Arduino AVR ATMega32U4" +#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. + #elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) - #define BOARD_TYPE "Adafruit AVR ATMega32U4" - #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. +#define BOARD_TYPE "Adafruit AVR ATMega32U4" +#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc. #elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" - #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" +#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. #elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" - #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" +#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. #elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) - #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" - #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. +#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" +#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. #elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) - #error These AVR boards are not supported! Please check your Tools->Board setting. - +#error These AVR boards are not supported! Please check your Tools->Board setting. + #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) diff --git a/examples/WiFiWebServer/WiFiWebServer.ino b/examples/WiFiWebServer/WiFiWebServer.ino index 7c73780d..5b3b8c01 100644 --- a/examples/WiFiWebServer/WiFiWebServer.ino +++ b/examples/WiFiWebServer/WiFiWebServer.ino @@ -60,138 +60,138 @@ WiFiServer server(80); void setup() { - //Initialize serial and wait for port to open: - Serial.begin(115200); - - while (!Serial && millis() < 5000); - - Serial.print(F("\nStart WiFiWebServer on ")); - Serial.println(BOARD_NAME); - //Serial.println(WIFININA_GENERIC_VERSION); - - // check for the WiFi module: - if (WiFi.status() == WL_NO_MODULE) - { - Serial.println(F("Communication with WiFi module failed!")); - - // don't continue - while (true); - } - - String fv = WiFi.firmwareVersion(); - - if (fv < WIFI_FIRMWARE_LATEST_VERSION) - { - Serial.print(F("Your current firmware NINA FW v")); - Serial.println(fv); - Serial.print(F("Please upgrade the firmware to NINA FW v")); - Serial.println(WIFI_FIRMWARE_LATEST_VERSION); - } - - // attempt to connect to Wifi network: - while (status != WL_CONNECTED) - { - Serial.print(F("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 10 seconds for connection: - //delay(10000); - } + //Initialize serial and wait for port to open: + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + Serial.print(F("\nStart WiFiWebServer on ")); + Serial.println(BOARD_NAME); + //Serial.println(WIFININA_GENERIC_VERSION); + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) + { + Serial.println(F("Communication with WiFi module failed!")); + + // don't continue + while (true); + } + + String fv = WiFi.firmwareVersion(); + + if (fv < WIFI_FIRMWARE_LATEST_VERSION) + { + Serial.print(F("Your current firmware NINA FW v")); + Serial.println(fv); + Serial.print(F("Please upgrade the firmware to NINA FW v")); + Serial.println(WIFI_FIRMWARE_LATEST_VERSION); + } + + // attempt to connect to Wifi network: + while (status != WL_CONNECTED) + { + Serial.print(F("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 10 seconds for connection: + //delay(10000); + } // you're connected now, so print out the status: printWiFiStatus(); - server.begin(); + server.begin(); } void loop() { - // listen for incoming clients - WiFiClient client = server.available(); - - if (client) - { - Serial.println(F("New client")); - // an http request ends with a blank line - boolean currentLineIsBlank = true; - - while (client.connected()) - { - if (client.available()) - { - char c = client.read(); - Serial.write(c); - - // if you've gotten to the end of the line (received a newline - // character) and the line is blank, the http request has ended, - // so you can send a reply - if (c == '\n' && currentLineIsBlank) - { - // send a standard http response header - client.println("HTTP/1.1 200 OK"); - client.println("Content-Type: text/html"); - client.println("Connection: close"); // the connection will be closed after completion of the response - client.println("Refresh: 5"); // refresh the page automatically every 5 sec - client.println(); - client.println(""); - client.println(""); + // listen for incoming clients + WiFiClient client = server.available(); + + if (client) + { + Serial.println(F("New client")); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + + while (client.connected()) + { + if (client.available()) + { + char c = client.read(); + Serial.write(c); + + // if you've gotten to the end of the line (received a newline + // character) and the line is blank, the http request has ended, + // so you can send a reply + if (c == '\n' && currentLineIsBlank) + { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); // the connection will be closed after completion of the response + client.println("Refresh: 5"); // refresh the page automatically every 5 sec + client.println(); + client.println(""); + client.println(""); int sensorReading; - - // output the value of each analog input pin - for (int analogChannel = 0; analogChannel < 6; analogChannel++) - { + + // output the value of each analog input pin + for (int analogChannel = 0; analogChannel < 6; analogChannel++) + { // analogRead() will hang system in arduino-pico core - sensorReading = millis() % 1024; //analogRead(analogChannel); - client.print("analog input "); - client.print(analogChannel); - client.print(" is "); - client.print(sensorReading); - client.println("
"); - } - - client.println(""); - break; - } - - if (c == '\n') - { - // you're starting a new line - currentLineIsBlank = true; - } - else if (c != '\r') - { - // you've gotten a character on the current line - currentLineIsBlank = false; - } - } - } - - // give the web browser time to receive the data - delay(1); - - // close the connection: - client.stop(); - Serial.println(F("Client disconnected")); - } + sensorReading = millis() % 1024; //analogRead(analogChannel); + client.print("analog input "); + client.print(analogChannel); + client.print(" is "); + client.print(sensorReading); + client.println("
"); + } + + client.println(""); + break; + } + + if (c == '\n') + { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') + { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + + // give the web browser time to receive the data + delay(1); + + // close the connection: + client.stop(); + Serial.println(F("Client disconnected")); + } } void printWiFiStatus() { - // print the SSID of the network you're attached to: - Serial.print(F("SSID: ")); - Serial.println(WiFi.SSID()); - - // print your board's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print(F("IP Address: ")); - Serial.println(ip); - - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print(F("Signal strength (RSSI):")); - Serial.print(rssi); - Serial.println(F(" dBm")); + // print the SSID of the network you're attached to: + Serial.print(F("SSID: ")); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print(F("IP Address: ")); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print(F("Signal strength (RSSI):")); + Serial.print(rssi); + Serial.println(F(" dBm")); } diff --git a/examples/WiFiWebServer/defines.h b/examples/WiFiWebServer/defines.h index a21f2c99..61befa0e 100644 --- a/examples/WiFiWebServer/defines.h +++ b/examples/WiFiWebServer/defines.h @@ -38,112 +38,112 @@ || defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \ || defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) ) #if defined(WIFININA_USE_SAMD) - #undef WIFININA_USE_SAMD + #undef WIFININA_USE_SAMD #endif #define WIFININA_USE_SAMD true #endif #if defined(WIFININA_USE_SAMD) - #if defined(ARDUINO_SAMD_ZERO) - #define BOARD_TYPE "SAMD Zero" - #elif defined(ARDUINO_SAMD_MKR1000) - #define BOARD_TYPE "SAMD MKR1000" - #elif defined(ARDUINO_SAMD_MKRWIFI1010) - #define BOARD_TYPE "SAMD MKRWIFI1010" - #elif defined(ARDUINO_SAMD_NANO_33_IOT) - #define BOARD_TYPE "SAMD NANO_33_IOT" - #elif defined(ARDUINO_SAMD_MKRFox1200) - #define BOARD_TYPE "SAMD MKRFox1200" - #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) - #define BOARD_TYPE "SAMD MKRWAN13X0" - #elif defined(ARDUINO_SAMD_MKRGSM1400) - #define BOARD_TYPE "SAMD MKRGSM1400" - #elif defined(ARDUINO_SAMD_MKRNB1500) - #define BOARD_TYPE "SAMD MKRNB1500" - #elif defined(ARDUINO_SAMD_MKRVIDOR4000) - #define BOARD_TYPE "SAMD MKRVIDOR4000" - #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) - #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" - #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" - #elif defined(ADAFRUIT_METRO_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" - #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" - #elif defined(ADAFRUIT_GEMMA_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" - #elif defined(ADAFRUIT_TRINKET_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" - #elif defined(ADAFRUIT_ITSYBITSY_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" - #elif defined(ARDUINO_SAMD_HALLOWING_M0) - #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" - #elif defined(ADAFRUIT_METRO_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" - #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" - #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" - #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" - #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" - #elif defined(ADAFRUIT_PYPORTAL) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" - #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" - #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" - #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" - #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" - #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" - #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" - #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" - #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" - #elif defined(SEEED_WIO_TERMINAL) - #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" - #elif defined(SEEED_FEMTO_M0) - #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" - #elif defined(SEEED_XIAO_M0) - #define BOARD_TYPE "SAMD SEEED_XIAO_M0" - #elif defined(Wio_Lite_MG126) - #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" - #elif defined(WIO_GPS_BOARD) - #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" - #elif defined(SEEEDUINO_ZERO) - #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" - #elif defined(SEEEDUINO_LORAWAN) - #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" - #elif defined(SEEED_GROVE_UI_WIRELESS) - #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" - #elif defined(__SAMD21E18A__) - #define BOARD_TYPE "SAMD21E18A" - #elif defined(__SAMD21G18A__) - #define BOARD_TYPE "SAMD21G18A" - #elif defined(__SAMD51G19A__) - #define BOARD_TYPE "SAMD51G19A" - #elif defined(__SAMD51J19A__) - #define BOARD_TYPE "SAMD51J19A" - #elif defined(__SAMD51P19A__) - #define BOARD_TYPE "__SAMD51P19A__" - #elif defined(__SAMD51J20A__) - #define BOARD_TYPE "SAMD51J20A" - #elif defined(__SAM3X8E__) - #define BOARD_TYPE "SAM3X8E" - #elif defined(__CPU_ARC__) - #define BOARD_TYPE "CPU_ARC" - #elif defined(__SAMD51__) - #define BOARD_TYPE "SAMD51" - #else - #define BOARD_TYPE "SAMD Unknown" - #endif + #if defined(ARDUINO_SAMD_ZERO) + #define BOARD_TYPE "SAMD Zero" + #elif defined(ARDUINO_SAMD_MKR1000) + #define BOARD_TYPE "SAMD MKR1000" + #elif defined(ARDUINO_SAMD_MKRWIFI1010) + #define BOARD_TYPE "SAMD MKRWIFI1010" + #elif defined(ARDUINO_SAMD_NANO_33_IOT) + #define BOARD_TYPE "SAMD NANO_33_IOT" + #elif defined(ARDUINO_SAMD_MKRFox1200) + #define BOARD_TYPE "SAMD MKRFox1200" + #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) + #define BOARD_TYPE "SAMD MKRWAN13X0" + #elif defined(ARDUINO_SAMD_MKRGSM1400) + #define BOARD_TYPE "SAMD MKRGSM1400" + #elif defined(ARDUINO_SAMD_MKRNB1500) + #define BOARD_TYPE "SAMD MKRNB1500" + #elif defined(ARDUINO_SAMD_MKRVIDOR4000) + #define BOARD_TYPE "SAMD MKRVIDOR4000" + #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" + #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" + #elif defined(ADAFRUIT_METRO_M0_EXPRESS) + #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" + #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" + #elif defined(ADAFRUIT_GEMMA_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" + #elif defined(ADAFRUIT_TRINKET_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" + #elif defined(ADAFRUIT_ITSYBITSY_M0) + #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" + #elif defined(ARDUINO_SAMD_HALLOWING_M0) + #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" + #elif defined(ADAFRUIT_METRO_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" + #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" + #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" + #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" + #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" + #elif defined(ADAFRUIT_PYPORTAL) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" + #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" + #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" + #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) + #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" + #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" + #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" + #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) + #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" + #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" + #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) + #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" + #elif defined(SEEED_WIO_TERMINAL) + #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" + #elif defined(SEEED_FEMTO_M0) + #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" + #elif defined(SEEED_XIAO_M0) + #define BOARD_TYPE "SAMD SEEED_XIAO_M0" + #elif defined(Wio_Lite_MG126) + #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" + #elif defined(WIO_GPS_BOARD) + #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" + #elif defined(SEEEDUINO_ZERO) + #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" + #elif defined(SEEEDUINO_LORAWAN) + #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" + #elif defined(SEEED_GROVE_UI_WIRELESS) + #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" + #elif defined(__SAMD21E18A__) + #define BOARD_TYPE "SAMD21E18A" + #elif defined(__SAMD21G18A__) + #define BOARD_TYPE "SAMD21G18A" + #elif defined(__SAMD51G19A__) + #define BOARD_TYPE "SAMD51G19A" + #elif defined(__SAMD51J19A__) + #define BOARD_TYPE "SAMD51J19A" + #elif defined(__SAMD51P19A__) + #define BOARD_TYPE "__SAMD51P19A__" + #elif defined(__SAMD51J20A__) + #define BOARD_TYPE "SAMD51J20A" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM3X8E" + #elif defined(__CPU_ARC__) + #define BOARD_TYPE "CPU_ARC" + #elif defined(__SAMD51__) + #define BOARD_TYPE "SAMD51" + #else + #define BOARD_TYPE "SAMD Unknown" + #endif #endif @@ -151,62 +151,62 @@ 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(WIFININA_USE_NRF52) - #undef WIFININA_USE_NRF52 + #undef WIFININA_USE_NRF52 #endif #define WIFININA_USE_NRF52 true #endif #if defined(WIFININA_USE_NRF52) - #if defined(NRF52840_FEATHER) - #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" - #elif defined(NRF52832_FEATHER) - #define BOARD_TYPE "NRF52832_FEATHER" - #elif defined(NRF52840_FEATHER_SENSE) - #define BOARD_TYPE "NRF52840_FEATHER_SENSE" - #elif defined(NRF52840_ITSYBITSY) - #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" - #elif defined(NRF52840_CIRCUITPLAY) - #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" - #elif defined(NRF52840_CLUE) - #define BOARD_TYPE "NRF52840_CLUE" - #elif defined(NRF52840_METRO) - #define BOARD_TYPE "NRF52840_METRO_EXPRESS" - #elif defined(NRF52840_PCA10056) - #define BOARD_TYPE "NORDIC_NRF52840DK" - #elif defined(NINA_B302_ublox) - #define BOARD_TYPE "NINA_B302_ublox" - #elif defined(NINA_B112_ublox) - #define BOARD_TYPE "NINA_B112_ublox" - #elif defined(PARTICLE_XENON) - #define BOARD_TYPE "PARTICLE_XENON" - #elif defined(MDBT50Q_RX) - #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" - #elif defined(ARDUINO_NRF52_ADAFRUIT) - #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" - #else - #define BOARD_TYPE "nRF52 Unknown" - #endif + #if defined(NRF52840_FEATHER) + #define BOARD_TYPE "NRF52840_FEATHER_EXPRESS" + #elif defined(NRF52832_FEATHER) + #define BOARD_TYPE "NRF52832_FEATHER" + #elif defined(NRF52840_FEATHER_SENSE) + #define BOARD_TYPE "NRF52840_FEATHER_SENSE" + #elif defined(NRF52840_ITSYBITSY) + #define BOARD_TYPE "NRF52840_ITSYBITSY_EXPRESS" + #elif defined(NRF52840_CIRCUITPLAY) + #define BOARD_TYPE "NRF52840_CIRCUIT_PLAYGROUND" + #elif defined(NRF52840_CLUE) + #define BOARD_TYPE "NRF52840_CLUE" + #elif defined(NRF52840_METRO) + #define BOARD_TYPE "NRF52840_METRO_EXPRESS" + #elif defined(NRF52840_PCA10056) + #define BOARD_TYPE "NORDIC_NRF52840DK" + #elif defined(NINA_B302_ublox) + #define BOARD_TYPE "NINA_B302_ublox" + #elif defined(NINA_B112_ublox) + #define BOARD_TYPE "NINA_B112_ublox" + #elif defined(PARTICLE_XENON) + #define BOARD_TYPE "PARTICLE_XENON" + #elif defined(MDBT50Q_RX) + #define BOARD_TYPE "RAYTAC_MDBT50Q_RX" + #elif defined(ARDUINO_NRF52_ADAFRUIT) + #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" + #else + #define BOARD_TYPE "nRF52 Unknown" + #endif #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) - #if defined(WIFININA_USE_SAMDUE) - #undef WIFININA_USE_SAMDUE - #endif - #define WIFININA_USE_SAMDUE true + #if defined(WIFININA_USE_SAMDUE) + #undef WIFININA_USE_SAMDUE + #endif + #define WIFININA_USE_SAMDUE true #endif #if defined(WIFININA_USE_SAMDUE) - // For SAM DUE - #if defined(ARDUINO_SAM_DUE) - #define BOARD_TYPE "SAM DUE" - #elif defined(__SAM3X8E__) - #define BOARD_TYPE "SAM SAM3X8E" - #else - #define BOARD_TYPE "SAM Unknown" - #endif + // For SAM DUE + #if defined(ARDUINO_SAM_DUE) + #define BOARD_TYPE "SAM DUE" + #elif defined(__SAM3X8E__) + #define BOARD_TYPE "SAM SAM3X8E" + #else + #define BOARD_TYPE "SAM Unknown" + #endif #endif @@ -214,117 +214,117 @@ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) #if defined(WIFININA_USE_STM32) - #undef WIFININA_USE_STM32 + #undef WIFININA_USE_STM32 #endif #define WIFININA_USE_STM32 true #endif #if defined(WIFININA_USE_STM32) - #if defined(STM32F0) - #warning STM32F0 board selected - #define BOARD_TYPE "STM32F0" - #elif defined(STM32F1) - #warning STM32F1 board selected - #define BOARD_TYPE "STM32F1" - #elif defined(STM32F2) - #warning STM32F2 board selected - #define BOARD_TYPE "STM32F2" - #elif defined(STM32F3) - #warning STM32F3 board selected - #define BOARD_TYPE "STM32F3" - #elif defined(STM32F4) - #warning STM32F4 board selected - #define BOARD_TYPE "STM32F4" - #elif defined(STM32F7) - #warning STM32F7 board selected - #define BOARD_TYPE "STM32F7" - #elif defined(STM32L0) - #warning STM32L0 board selected - #define BOARD_TYPE "STM32L0" - #elif defined(STM32L1) - #warning STM32L1 board selected - #define BOARD_TYPE "STM32L1" - #elif defined(STM32L4) - #warning STM32L4 board selected - #define BOARD_TYPE "STM32L4" - #elif defined(STM32H7) - #warning STM32H7 board selected - #define BOARD_TYPE "STM32H7" - #elif defined(STM32G0) - #warning STM32G0 board selected - #define BOARD_TYPE "STM32G0" - #elif defined(STM32G4) - #warning STM32G4 board selected - #define BOARD_TYPE "STM32G4" - #elif defined(STM32WB) - #warning STM32WB board selected - #define BOARD_TYPE "STM32WB" - #elif defined(STM32MP1) - #warning STM32MP1 board selected - #define BOARD_TYPE "STM32MP1" - #else - #warning STM32 unknown board selected - #define BOARD_TYPE "STM32 Unknown" - #endif + #if defined(STM32F0) + #warning STM32F0 board selected + #define BOARD_TYPE "STM32F0" + #elif defined(STM32F1) + #warning STM32F1 board selected + #define BOARD_TYPE "STM32F1" + #elif defined(STM32F2) + #warning STM32F2 board selected + #define BOARD_TYPE "STM32F2" + #elif defined(STM32F3) + #warning STM32F3 board selected + #define BOARD_TYPE "STM32F3" + #elif defined(STM32F4) + #warning STM32F4 board selected + #define BOARD_TYPE "STM32F4" + #elif defined(STM32F7) + #warning STM32F7 board selected + #define BOARD_TYPE "STM32F7" + #elif defined(STM32L0) + #warning STM32L0 board selected + #define BOARD_TYPE "STM32L0" + #elif defined(STM32L1) + #warning STM32L1 board selected + #define BOARD_TYPE "STM32L1" + #elif defined(STM32L4) + #warning STM32L4 board selected + #define BOARD_TYPE "STM32L4" + #elif defined(STM32H7) + #warning STM32H7 board selected + #define BOARD_TYPE "STM32H7" + #elif defined(STM32G0) + #warning STM32G0 board selected + #define BOARD_TYPE "STM32G0" + #elif defined(STM32G4) + #warning STM32G4 board selected + #define BOARD_TYPE "STM32G4" + #elif defined(STM32WB) + #warning STM32WB board selected + #define BOARD_TYPE "STM32WB" + #elif defined(STM32MP1) + #warning STM32MP1 board selected + #define BOARD_TYPE "STM32MP1" + #else + #warning STM32 unknown board selected + #define BOARD_TYPE "STM32 Unknown" + #endif #endif #ifdef CORE_TEENSY - #if defined(WIFININA_USE_TEENSY) - #undef WIFININA_USE_TEENSY - #endif - #define WIFININA_USE_TEENSY true - - #if defined(__IMXRT1062__) - // For Teensy 4.1/4.0 - #define BOARD_TYPE "TEENSY 4.1/4.0" - #elif defined(__MK66FX1M0__) - #define BOARD_TYPE "Teensy 3.6" - #elif defined(__MK64FX512__) - #define BOARD_TYPE "Teensy 3.5" - #elif defined(__MKL26Z64__) - #define BOARD_TYPE "Teensy LC" - #elif defined(__MK20DX256__) - #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) - #elif defined(__MK20DX128__) - #define BOARD_TYPE "Teensy 3.0" - #elif defined(__AVR_AT90USB1286__) - #error Teensy 2.0++ not supported yet - #elif defined(__AVR_ATmega32U4__) - #error Teensy 2.0 not supported yet - #else - // For Other Boards - #define BOARD_TYPE "Unknown Teensy Board" - #endif + #if defined(WIFININA_USE_TEENSY) + #undef WIFININA_USE_TEENSY + #endif + #define WIFININA_USE_TEENSY true + + #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 + #define BOARD_TYPE "TEENSY 4.1/4.0" + #elif defined(__MK66FX1M0__) + #define BOARD_TYPE "Teensy 3.6" + #elif defined(__MK64FX512__) + #define BOARD_TYPE "Teensy 3.5" + #elif defined(__MKL26Z64__) + #define BOARD_TYPE "Teensy LC" + #elif defined(__MK20DX256__) + #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MK20DX128__) + #define BOARD_TYPE "Teensy 3.0" + #elif defined(__AVR_AT90USB1286__) + #error Teensy 2.0++ not supported yet + #elif defined(__AVR_ATmega32U4__) + #error Teensy 2.0 not supported yet + #else + // For Other Boards + #define BOARD_TYPE "Unknown Teensy Board" + #endif #endif #if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) - #if defined(WIFININA_USE_RP2040) - #undef WIFININA_USE_RP2040 - #endif - #define WIFININA_USE_RP2040 true - - #if defined(ARDUINO_ARCH_MBED) - - #if defined(BOARD_NAME) - #undef BOARD_NAME - #endif - - #if defined(ARDUINO_NANO_RP2040_CONNECT) - #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #elif defined(ARDUINO_RASPBERRY_PI_PICO) - #define BOARD_NAME "MBED RASPBERRY_PI_PICO" - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" - #elif defined(ARDUINO_GENERIC_RP2040) - #define BOARD_NAME "MBED GENERIC_RP2040" - #else - #define BOARD_NAME "MBED Unknown RP2040" - #endif - - #endif + #if defined(WIFININA_USE_RP2040) + #undef WIFININA_USE_RP2040 + #endif + #define WIFININA_USE_RP2040 true + + #if defined(ARDUINO_ARCH_MBED) + + #if defined(BOARD_NAME) + #undef BOARD_NAME + #endif + + #if defined(ARDUINO_NANO_RP2040_CONNECT) + #define BOARD_NAME "MBED NANO_RP2040_CONNECT" + #elif defined(ARDUINO_RASPBERRY_PI_PICO) + #define BOARD_NAME "MBED RASPBERRY_PI_PICO" + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) + #define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040" + #elif defined(ARDUINO_GENERIC_RP2040) + #define BOARD_NAME "MBED GENERIC_RP2040" + #else + #define BOARD_NAME "MBED Unknown RP2040" + #endif + + #endif #endif #if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \ @@ -374,23 +374,23 @@ #endif #if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) ) - #if !defined(BOARD_NAME) - #if (ARDUINO_AVR_UNO_WIFI_REV2) - #define BOARD_NAME "megaAVR UNO WiFi Rev2" - #elif (ARDUINO_AVR_NANO_EVERY) - #define BOARD_NAME "megaAVR Nano Every" - #else - #define BOARD_NAME "megaAVR Unknown" - #endif - #endif + #if !defined(BOARD_NAME) + #if (ARDUINO_AVR_UNO_WIFI_REV2) + #define BOARD_NAME "megaAVR UNO WiFi Rev2" + #elif (ARDUINO_AVR_NANO_EVERY) + #define BOARD_NAME "megaAVR Nano Every" + #else + #define BOARD_NAME "megaAVR Unknown" + #endif + #endif #endif #ifndef BOARD_TYPE - #define BOARD_TYPE "Unknown board" + #define BOARD_TYPE "Unknown board" #endif #ifndef BOARD_NAME - #define BOARD_NAME BOARD_TYPE + #define BOARD_NAME BOARD_TYPE #endif #define DEBUG_WIFININA_PORT Serial