Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
v1.8.14-7 to remove analogRead() from example
Browse files Browse the repository at this point in the history
### Releases v1.8.14-7

1. Modify [WiFiWebServer](https://github.com/khoih-prog/WiFiNINA_Generic/tree/master/examples/WiFiWebServer) example to avoid `analogRead()` crash in `arduino-pico` core. Check [WiFi.localIP() hangs in Nano RP2040 Connect with Arduino-Pico core (EarlePhilhower) #24](#24)
2. Use `allman astyle` and add `utils`
3. Update `Packages' Patches`
  • Loading branch information
khoih-prog authored Nov 11, 2022
1 parent 7e21529 commit de0ce06
Show file tree
Hide file tree
Showing 55 changed files with 1,929 additions and 1,768 deletions.
44 changes: 25 additions & 19 deletions examples/AP_SimpleWebServer/AP_SimpleWebServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"));
Expand All @@ -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);
}
Expand Down Expand Up @@ -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:
Expand All @@ -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"));
Expand Down
76 changes: 38 additions & 38 deletions examples/AP_SimpleWebServer/defines.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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) )
Expand Down
9 changes: 7 additions & 2 deletions examples/ConnectNoEncryption/ConnectNoEncryption.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -154,13 +158,14 @@ void printMacAddress(byte mac[])
{
Serial.print(F("0"));
}

Serial.print(mac[i], HEX);

if (i > 0)
{
Serial.print(F(":"));
}
}

Serial.println();
}
Loading

0 comments on commit de0ce06

Please sign in to comment.