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

Commit

Permalink
v1.10.1 to use new WiFi101_Generic library
Browse files Browse the repository at this point in the history
### Releases v1.10.1

1. Using new [`WiFi101_Generic library`](https://github.com/khoih-prog/WiFi101_Generic) for sending larger data
2. Update `Packages' Patches`
  • Loading branch information
khoih-prog authored Nov 24, 2022
1 parent 215d87c commit 42be38f
Show file tree
Hide file tree
Showing 54 changed files with 5,032 additions and 4,786 deletions.
86 changes: 48 additions & 38 deletions examples/AP_SimpleWebServer/AP_SimpleWebServer.ino
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/****************************************************************************************************************************
AP_SimpleWebServer.ino - Simple Arduino WiFi Web Server LED Blink sample for SAMD21 running WiFiNINA shield
For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc
WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA
Built by Khoi Hoang https://github.com/khoih-prog/WiFiWebServer
Licensed under MIT license
A simple web server that lets you blink an LED via the web.
This sketch will create a new access point (with no password).
It will then launch a new server and print out the IP address
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on pin 13.
If the IP address of your board is yourAddress:
http://yourAddress/H turns the LED on
http://yourAddress/L turns it off
created 25 Nov 2012
by Tom Igoe
adapted to WiFi AP by Adafruit
Expand Down Expand Up @@ -48,16 +48,16 @@ void printWiFiStatus()

#if (ESP32 || ESP8266)
IPAddress ip = WiFi.softAPIP();
#else
#else

// print the SSID of the network you're attached to:
Serial.print(F("SSID: "));

Serial.println(WiFi.SSID());

IPAddress ip = WiFi.localIP();
#endif

Serial.print(F("IP Address: "));
Serial.println(ip);

Expand All @@ -70,12 +70,15 @@ void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(115200);

while (!Serial && millis() < 5000);

delay(200);

Serial.print(F("\nStarting AP_SimpleWebServer on ")); Serial.print(BOARD_NAME);
Serial.print(F(" with ")); Serial.println(SHIELD_TYPE);
Serial.print(F("\nStarting AP_SimpleWebServer on "));
Serial.print(BOARD_NAME);
Serial.print(F(" with "));
Serial.println(SHIELD_TYPE);
Serial.println(WIFI_WEBSERVER_VERSION);

pinMode(led, OUTPUT); // set the LED pin mode
Expand All @@ -88,32 +91,35 @@ void setup()
WiFi.init(&EspSerial);

Serial.println(F("WiFi shield init done"));

#endif

#if !(ESP32 || ESP8266)

// check for the presence of the shield
#if USE_WIFI_NINA
if (WiFi.status() == WL_NO_MODULE)
#else
if (WiFi.status() == WL_NO_SHIELD)
#endif
{
Serial.println(F("WiFi shield not present"));
// don't continue
while (true);
}
#if USE_WIFI_NINA

if (WiFi.status() == WL_NO_MODULE)
#else
if (WiFi.status() == WL_NO_SHIELD)
#endif
{
Serial.println(F("WiFi shield not present"));

// don't continue
while (true);
}

#if USE_WIFI_NINA
String fv = WiFi.firmwareVersion();

if (fv < WIFI_FIRMWARE_LATEST_VERSION)
{
Serial.println(F("Please upgrade the firmware"));
}

#endif

#if USE_WIFI_NINA
String fv = WiFi.firmwareVersion();

if (fv < WIFI_FIRMWARE_LATEST_VERSION)
{
Serial.println(F("Please upgrade the firmware"));
}
#endif

#endif

// by default the local IP address of will be 192.168.4.1
Expand All @@ -129,23 +135,25 @@ void setup()
#if (ESP32 || ESP8266)

WiFi.softAP(ssid, pass);

#else

// Create open network. Change this line if you want to create an WEP network:
// default AP channel = 1
uint8_t ap_channel = 2;

status = WiFi.beginAP(ssid, pass, ap_channel);

//status = WiFi.beginAP(ssid, pass);

if (status != WL_AP_LISTENING)
{
Serial.println(F("Creating access point failed"));

// don't continue
while (true);
}

#endif

// wait 10 seconds for connection:
Expand All @@ -161,6 +169,7 @@ void setup()
void loop()
{
#if !(ESP32 || ESP8266)

// compare the previous status to the current status
if (status != WiFi.status())
{
Expand All @@ -172,13 +181,14 @@ void loop()
{
// a device has connected to the AP
Serial.println(F("Device connected to AP"));
}
}
else
{
// a device has disconnected from the AP, and we are back in listening mode
Serial.println(F("Device disconnected from AP"));
}
}
}

#endif

WiFiClient client = server.available(); // listen for incoming clients
Expand All @@ -188,7 +198,7 @@ void loop()
// 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())
{
// loop while the client's connected
Expand Down Expand Up @@ -237,14 +247,14 @@ void loop()
{
digitalWrite(led, HIGH); // GET /H turns the LED on
}

if (currentLine.endsWith(F("GET /L")))
{
digitalWrite(led, LOW); // GET /L turns the LED off
}
}
}

// close the connection:
client.stop();
Serial.println(F("Client disconnected"));
Expand Down
114 changes: 57 additions & 57 deletions examples/AP_SimpleWebServer/defines.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************************************************************
defines.h
For any WiFi shields, such as WiFiNINA W101, W102, W13x, or custom, such as ESP8266/ESP32-AT, Ethernet, etc
WiFiWebServer is a library for the ESP32-based WiFi shields to run WebServer
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Based on and modified from Arduino WiFiNINA library https://www.arduino.cc/en/Reference/WiFiNINA
Expand All @@ -20,71 +20,71 @@

#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) )

#if defined(BOARD_NAME)
#undef BOARD_NAME
#endif
#if defined(BOARD_NAME)
#undef BOARD_NAME
#endif

#if defined(CORE_CM7)
#warning Using Portenta H7 M7 core
#define BOARD_NAME "PORTENTA_H7_M7"
#else
#warning Using Portenta H7 M4 core
#define BOARD_NAME "PORTENTA_H7_M4"
#endif
#if defined(CORE_CM7)
#warning Using Portenta H7 M7 core
#define BOARD_NAME "PORTENTA_H7_M7"
#else
#warning Using Portenta H7 M4 core
#define BOARD_NAME "PORTENTA_H7_M4"
#endif

#define USE_WIFI_PORTENTA_H7 true

#define USE_WIFI_PORTENTA_H7 true
#define USE_WIFI_NINA false

#define USE_WIFI_NINA false
// To use the default WiFi library here
#define USE_WIFI_CUSTOM false

// To use the default WiFi library here
#define USE_WIFI_CUSTOM false

#elif (ESP32)

#define USE_WIFI_NINA false
#define USE_WIFI_NINA false

// To use the default WiFi library here
#define USE_WIFI_CUSTOM false
// To use the default WiFi library here
#define USE_WIFI_CUSTOM false

#elif (ESP8266)

#define USE_WIFI_NINA false
#define USE_WIFI_NINA false

// To use the default WiFi library here
#define USE_WIFI_CUSTOM true
// To use the default WiFi library here
#define USE_WIFI_CUSTOM true

#elif ( defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) )

#define USE_WIFI_NINA false
#define USE_WIFI101 true
#define USE_WIFI_CUSTOM false
#define USE_WIFI_NINA false
#define USE_WIFI101 true
#define USE_WIFI_CUSTOM false

#elif ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_SAMD_NANO_33_IOT) )

#define USE_WIFI_NINA true
#define USE_WIFI101 false
#define USE_WIFI_CUSTOM false
#define USE_WIFI_NINA true
#define USE_WIFI101 false
#define USE_WIFI_CUSTOM false

#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
#define USE_WIFI_NINA false
#define USE_WIFI101 false
#define USE_WIFI_CUSTOM false

#define USE_WIFI_NINA false
#define USE_WIFI101 false
#define USE_WIFI_CUSTOM false

#elif ( defined(__AVR_ATmega4809__) || defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || \
defined(ARDUINO_AVR_ATmega4809) || defined(ARDUINO_AVR_ATmega4808) || defined(ARDUINO_AVR_ATmega3209) || \
defined(ARDUINO_AVR_ATmega3208) || defined(ARDUINO_AVR_ATmega1609) || defined(ARDUINO_AVR_ATmega1608) || \
defined(ARDUINO_AVR_ATmega809) || defined(ARDUINO_AVR_ATmega808) )

#error Not supported. Lack of memory for megaAVR

#else

#define USE_WIFI_NINA false
#define USE_WIFI101 false

// If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here
#define USE_WIFI_CUSTOM true
#error Not supported. Lack of memory for megaAVR

#else

#define USE_WIFI_NINA false
#define USE_WIFI101 false

// If not USE_WIFI_NINA, you can USE_WIFI_CUSTOM, then include the custom WiFi library here
#define USE_WIFI_CUSTOM true

#endif

Expand Down Expand Up @@ -116,32 +116,32 @@
#define SHIELD_TYPE "ESP WiFi using WiFi Library"
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
#warning Using RP2040W CYW43439 WiFi
#define SHIELD_TYPE "RP2040W CYW43439 WiFi"
#define SHIELD_TYPE "RP2040W CYW43439 WiFi"
#elif USE_WIFI_CUSTOM
#warning Using Custom WiFi using Custom WiFi Library
#define SHIELD_TYPE "Custom WiFi using Custom WiFi Library"
#else
#define SHIELD_TYPE "Unknown WiFi shield/Library"
#define SHIELD_TYPE "Unknown WiFi shield/Library"
#endif

#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \
defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
#if defined(WIFI_USE_NRF528XX)
#undef WIFI_USE_NRF528XX
#endif
#define WIFI_USE_NRF528XX true
#if defined(WIFI_USE_NRF528XX)
#undef WIFI_USE_NRF528XX
#endif
#define WIFI_USE_NRF528XX true
#endif

#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \
|| defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) )
#if defined(WIFI_USE_SAMD)
#undef WIFI_USE_SAMD
#endif
#define WIFI_USE_SAMD true
#if defined(WIFI_USE_SAMD)
#undef WIFI_USE_SAMD
#endif
#define WIFI_USE_SAMD true
#endif

#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
Expand All @@ -155,10 +155,10 @@
#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) ) && ! ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) )
#if defined(WIFI_USE_STM32)
#undef WIFI_USE_STM32
#endif
#define WIFI_USE_STM32 true
#if defined(WIFI_USE_STM32)
#undef WIFI_USE_STM32
#endif
#define WIFI_USE_STM32 true
#endif

#ifdef CORE_TEENSY
Expand Down Expand Up @@ -381,7 +381,7 @@
#define BOARD_NAME BOARD_TYPE
#else
#define BOARD_NAME "Unknown Board"
#endif
#endif
#endif

#include <WiFiWebServer.h>
Expand Down
Loading

0 comments on commit 42be38f

Please sign in to comment.