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

Commit de0ce06

Browse files
authored
v1.8.14-7 to remove analogRead() from example
### 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`
1 parent 7e21529 commit de0ce06

File tree

55 files changed

+1929
-1768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1929
-1768
lines changed

examples/AP_SimpleWebServer/AP_SimpleWebServer.ino

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ void setup()
6868
{
6969
//Initialize serial and wait for port to open:
7070
Serial.begin(115200);
71+
7172
while (!Serial && millis() < 5000);
7273

73-
Serial.print(F("\nStart AP_SimpleWebServer on ")); Serial.println(BOARD_NAME);
74+
Serial.print(F("\nStart AP_SimpleWebServer on "));
75+
Serial.println(BOARD_NAME);
7476
Serial.println(WIFININA_GENERIC_VERSION);
7577

7678
pinMode(led, OUTPUT); // set the LED pin mode
@@ -79,12 +81,13 @@ void setup()
7981
if (WiFi.status() == WL_NO_MODULE)
8082
{
8183
Serial.println(F("Communication with WiFi module failed!"));
84+
8285
// don't continue
8386
while (true);
8487
}
8588

8689
String fv = WiFi.firmwareVersion();
87-
90+
8891
if (fv < WIFI_FIRMWARE_LATEST_VERSION)
8992
{
9093
Serial.print(F("Your current firmware NINA FW v"));
@@ -103,9 +106,11 @@ void setup()
103106

104107
// Create open network. Change this line if you want to create an WEP network:
105108
status = WiFi.beginAP(ssid, pass);
109+
106110
if (status != WL_AP_LISTENING)
107111
{
108112
Serial.println(F("Creating access point failed"));
113+
109114
// don't continue
110115
while (true);
111116
}
@@ -142,31 +147,31 @@ void loop()
142147

143148
WiFiClient client = server.available(); // listen for incoming clients
144149

145-
if (client)
146-
{
150+
if (client)
151+
{
147152
// if you get a client,
148153
Serial.println(F("new client")); // print a message out the serial port
149154
String currentLine = ""; // make a String to hold incoming data from the client
150-
151-
while (client.connected())
155+
156+
while (client.connected())
152157
{
153158
// This is required for the Arduino Nano RP2040 Connect
154159
// otherwise it will loop so fast that SPI will never be served.
155160
delayMicroseconds(10);
156-
161+
157162
// loop while the client's connected
158-
if (client.available())
159-
{
163+
if (client.available())
164+
{
160165
// if there's bytes to read from the client,
161166
char c = client.read(); // read a byte, then
162167
Serial.write(c); // print it out the serial monitor
163168

164169
// if the byte is a newline character
165-
if (c == '\n')
166-
{
170+
if (c == '\n')
171+
{
167172
// if the current line is blank, you got two newline characters in a row.
168173
// that's the end of the client HTTP request, so send a response:
169-
if (currentLine.length() == 0)
174+
if (currentLine.length() == 0)
170175
{
171176
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
172177
// and a content-type so the client knows what's coming, then a blank line:
@@ -183,30 +188,31 @@ void loop()
183188
// break out of the while loop:
184189
break;
185190
}
186-
else
187-
{
191+
else
192+
{
188193
// if you got a newline, then clear currentLine:
189194
currentLine = "";
190195
}
191196
}
192-
else if (c != '\r')
193-
{
197+
else if (c != '\r')
198+
{
194199
// if you got anything else but a carriage return character,
195200
currentLine += c; // add it to the end of the currentLine
196201
}
197202

198203
// Check to see if the client request was "GET /H" or "GET /L":
199-
if (currentLine.endsWith("GET /H"))
204+
if (currentLine.endsWith("GET /H"))
200205
{
201206
digitalWrite(led, HIGH); // GET /H turns the LED on
202207
}
203-
204-
if (currentLine.endsWith("GET /L"))
208+
209+
if (currentLine.endsWith("GET /L"))
205210
{
206211
digitalWrite(led, LOW); // GET /L turns the LED off
207212
}
208213
}
209214
}
215+
210216
// close the connection:
211217
client.stop();
212218
Serial.println(F("client disconnected"));

examples/AP_SimpleWebServer/defines.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/****************************************************************************************************************************
22
defines.h
33
For boards with WiFiNINA module/shield.
4-
4+
55
Based on and modified from WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA
66
to support nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, etc. boards besides Nano-33 IoT, MKRWIFI1010, MKRVIDOR400, etc.
77
@@ -37,10 +37,10 @@
3737
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
3838
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
3939
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
40-
#if defined(WIFININA_USE_SAMD)
41-
#undef WIFININA_USE_SAMD
42-
#endif
43-
#define WIFININA_USE_SAMD true
40+
#if defined(WIFININA_USE_SAMD)
41+
#undef WIFININA_USE_SAMD
42+
#endif
43+
#define WIFININA_USE_SAMD true
4444
#endif
4545

4646
#if defined(WIFININA_USE_SAMD)
@@ -150,10 +150,10 @@
150150
#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
151151
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \
152152
defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
153-
#if defined(WIFININA_USE_NRF52)
154-
#undef WIFININA_USE_NRF52
155-
#endif
156-
#define WIFININA_USE_NRF52 true
153+
#if defined(WIFININA_USE_NRF52)
154+
#undef WIFININA_USE_NRF52
155+
#endif
156+
#define WIFININA_USE_NRF52 true
157157
#endif
158158

159159
#if defined(WIFININA_USE_NRF52)
@@ -213,10 +213,10 @@
213213
#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
214214
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
215215
defined(STM32WB) || defined(STM32MP1) )
216-
#if defined(WIFININA_USE_STM32)
217-
#undef WIFININA_USE_STM32
218-
#endif
219-
#define WIFININA_USE_STM32 true
216+
#if defined(WIFININA_USE_STM32)
217+
#undef WIFININA_USE_STM32
218+
#endif
219+
#define WIFININA_USE_STM32 true
220220
#endif
221221

222222
#if defined(WIFININA_USE_STM32)
@@ -275,7 +275,7 @@
275275
#undef WIFININA_USE_TEENSY
276276
#endif
277277
#define WIFININA_USE_TEENSY true
278-
278+
279279
#if defined(__IMXRT1062__)
280280
// For Teensy 4.1/4.0
281281
#define BOARD_TYPE "TEENSY 4.1/4.0"
@@ -314,7 +314,7 @@
314314

315315
#if defined(ARDUINO_NANO_RP2040_CONNECT)
316316
#define BOARD_NAME "MBED NANO_RP2040_CONNECT"
317-
#elif defined(ARDUINO_RASPBERRY_PI_PICO)
317+
#elif defined(ARDUINO_RASPBERRY_PI_PICO)
318318
#define BOARD_NAME "MBED RASPBERRY_PI_PICO"
319319
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
320320
#define BOARD_NAME "MBED DAFRUIT_FEATHER_RP2040"
@@ -323,54 +323,54 @@
323323
#else
324324
#define BOARD_NAME "MBED Unknown RP2040"
325325
#endif
326-
326+
327327
#endif
328328
#endif
329329

330330
#if ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \
331331
defined(__AVR_ATmega640__) || defined(__AVR_ATmega641__))
332-
#define BOARD_TYPE "Arduino AVR Mega2560/ADK"
333-
#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK.
334-
332+
#define BOARD_TYPE "Arduino AVR Mega2560/ADK"
333+
#warning Using Arduino AVR Mega, Mega640(P), Mega2560/ADK.
334+
335335
#elif ( defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || \
336336
defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || \
337337
defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || \
338-
defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) )
339-
#define BOARD_TYPE "Arduino AVR UNO, Nano, etc."
340-
#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano.
338+
defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || defined(ARDUINO_AVR_DUEMILANOVE) )
339+
#define BOARD_TYPE "Arduino AVR UNO, Nano, etc."
340+
#warning Using Aduino AVR ATMega644(P), ATMega328(P) such as UNO, Nano.
341341

342342
#elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \
343343
defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) )
344-
#define BOARD_TYPE "Adafruit AVR ATMega328(P)"
345-
#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO.
346-
344+
#define BOARD_TYPE "Adafruit AVR ATMega328(P)"
345+
#warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO.
346+
347347
#elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \
348348
defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \
349349
defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) )
350-
#define BOARD_TYPE "Arduino AVR ATMega32U4"
351-
#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH.
352-
350+
#define BOARD_TYPE "Arduino AVR ATMega32U4"
351+
#warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH.
352+
353353
#elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \
354354
defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) )
355-
#define BOARD_TYPE "Adafruit AVR ATMega32U4"
356-
#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc.
355+
#define BOARD_TYPE "Adafruit AVR ATMega32U4"
356+
#warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc.
357357

358358
#elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \
359359
defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) )
360-
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4"
361-
#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc.
360+
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4"
361+
#warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc.
362362

363363
#elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) )
364-
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P"
365-
#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc.
364+
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P"
365+
#warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc.
366366

367367
#elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) )
368-
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1"
369-
#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc.
368+
#define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1"
369+
#warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc.
370370

371371
#elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) )
372-
#error These AVR boards are not supported! Please check your Tools->Board setting.
373-
372+
#error These AVR boards are not supported! Please check your Tools->Board setting.
373+
374374
#endif
375375

376376
#if ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) )

examples/ConnectNoEncryption/ConnectNoEncryption.ino

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,24 @@ void setup()
5353
{
5454
//Initialize serial and wait for port to open:
5555
Serial.begin(115200);
56+
5657
while (!Serial && millis() < 5000);
5758

58-
Serial.print(F("\nStart ConnectNoEncryption on ")); Serial.println(BOARD_NAME);
59+
Serial.print(F("\nStart ConnectNoEncryption on "));
60+
Serial.println(BOARD_NAME);
5961
Serial.println(WIFININA_GENERIC_VERSION);
6062

6163
// check for the WiFi module:
6264
if (WiFi.status() == WL_NO_MODULE)
6365
{
6466
Serial.println(F("Communication with WiFi module failed!"));
67+
6568
// don't continue
6669
while (true);
6770
}
6871

6972
String fv = WiFi.firmwareVersion();
73+
7074
if (fv < WIFI_FIRMWARE_LATEST_VERSION)
7175
{
7276
Serial.print(F("Your current firmware NINA FW v"));
@@ -154,13 +158,14 @@ void printMacAddress(byte mac[])
154158
{
155159
Serial.print(F("0"));
156160
}
161+
157162
Serial.print(mac[i], HEX);
158163

159164
if (i > 0)
160165
{
161166
Serial.print(F(":"));
162167
}
163168
}
164-
169+
165170
Serial.println();
166171
}

0 commit comments

Comments
 (0)