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

Commit

Permalink
Major Release v1.1.0
Browse files Browse the repository at this point in the history
### Major Release v1.1.0

1. Configurable **Customs HTML Headers**, including Customs Style, Customs Head Elements, CORS Header.
2. Fix Config Portal Bug. 
3. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](khoih-prog/Blynk_WM#25)
4. Use more efficient [FlashStorage_SAMD v1.1.0](https://github.com/khoih-prog/FlashStorage_SAMD) and [FlashStorage_STM32 v1.0.0](https://github.com/khoih-prog/FlashStorage_STM32)
5. Optimize code. 
6. Update examples
  • Loading branch information
khoih-prog authored Feb 22, 2021
1 parent 95dc311 commit 850a57f
Show file tree
Hide file tree
Showing 39 changed files with 2,264 additions and 677 deletions.
209 changes: 175 additions & 34 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/MKR1000_WiFi101/Credentials.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
Credentials.h
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down
59 changes: 43 additions & 16 deletions examples/MKR1000_WiFi101/MKR1000_WiFi101.ino
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/****************************************************************************************************************************
MKR1000_WiFi101.ino
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_Generic_Lite
Licensed under MIT license
Version: 1.0.2
Version: 1.1.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 04/02/2021 Initial coding for generic boards using generic WiFi.
1.0.1 K Hoang 05/02/2021 Fix bug. Drop Mega support due to marginal memory.
1.0.2 K Hoang 06/02/2021 Add support to STM32F/L/H/G/WB/MP1 using ATWINC1500/WiFi101
1.0.2 K Hoang 06/02/2021 Add support to STM32F/L/H/G/WB/MP1 using ATWINC1500/WiFi101
1.1.0 K Hoang 21/02/2021 Optimize code and use better FlashStorage_SAMD and FlashStorage_STM32.
Add customs HTML header feature. Fix bug.
*****************************************************************************************************************************/

#include "defines.h"
Expand Down Expand Up @@ -57,6 +59,11 @@ void check_status()

WiFiManager_Generic_Lite* WiFiManager_Generic;

#if USING_CUSTOMS_STYLE
const char NewCustomsStyle[] /*PROGMEM*/ = "<style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>";
#endif

void setup()
{
// Debug console
Expand All @@ -74,38 +81,47 @@ void setup()

// Optional to change default AP IP(192.168.4.1) and channel(10)
//WiFiManager_Generic->setConfigPortalIP(IPAddress(192, 168, 120, 1));
//WiFiManager_Generic->setConfigPortalChannel(1);
WiFiManager_Generic->setConfigPortalChannel(0);

#if USING_CUSTOMS_STYLE
WiFiManager_Generic->setCustomsStyle(NewCustomsStyle);
#endif

#if USING_CUSTOMS_HEAD_ELEMENT
WiFiManager_Generic->setCustomsHeadElement("<style>html{filter: invert(10%);}</style>");
#endif

#if USING_CORS_FEATURE
WiFiManager_Generic->setCORSHeader("Your Access-Control-Allow-Origin");
#endif

// Set customized DHCP HostName
WiFiManager_Generic->begin(HOST_NAME);
//Or use default Hostname "SAMD-WIFI-XXXXXX"
//Or use default Hostname "MKR1000-WIFI-XXXXXX"
//WiFiManager_Generic->begin();

}

#if USE_DYNAMIC_PARAMETERS
void displayCredentials(void)
void displayCredentials()
{
Serial.println("\nYour stored Credentials :");
Serial.println(F("\nYour stored Credentials :"));

for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
Serial.println(String(myMenuItems[i].displayName) + " = " + myMenuItems[i].pdata);
Serial.print(myMenuItems[i].displayName);
Serial.print(F(" = "));
Serial.println(myMenuItems[i].pdata);
}
}
#endif

void loop()
void displayCredentialsInLoop()
{
WiFiManager_Generic->run();
check_status();

#if USE_DYNAMIC_PARAMETERS
static bool displayedCredentials = false;

if (!displayedCredentials)
{
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
for (int i = 0; i < NUM_MENU_ITEMS; i++)
{
if (!strlen(myMenuItems[i].pdata))
{
Expand All @@ -119,5 +135,16 @@ void loop()
}
}
}
}

#endif

void loop()
{
WiFiManager_Generic->run();
check_status();

#if USE_DYNAMIC_PARAMETERS
displayCredentialsInLoop();
#endif
}
9 changes: 8 additions & 1 deletion examples/MKR1000_WiFi101/defines.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
defines.h
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down Expand Up @@ -51,6 +51,13 @@

/////////////////////////////////////////////

// Add customs headers from v1.1.0
#define USING_CUSTOMS_STYLE true
#define USING_CUSTOMS_HEAD_ELEMENT true
#define USING_CORS_FEATURE true

/////////////////////////////////////////////

#define USE_WIFI101 true

#if defined(USE_WIFI_NINA)
Expand Down
2 changes: 1 addition & 1 deletion examples/MKR1000_WiFi101/dynamicParams.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
dynamicParams.h
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down
2 changes: 1 addition & 1 deletion examples/MKR1000_WiFi101_MQTT/Credentials.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
Credentials.h for SAMD_WiFiNINA_MQTT.ino
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down
44 changes: 34 additions & 10 deletions examples/MKR1000_WiFi101_MQTT/MKR1000_WiFi101_MQTT.ino
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/****************************************************************************************************************************
MKR1000_WiFi101_MQTT.ino
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_Generic_Lite
Licensed under MIT license
Version: 1.0.2
Version: 1.1.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 04/02/2021 Initial coding for generic boards using generic WiFi.
1.0.1 K Hoang 05/02/2021 Fix bug. Drop Mega support due to marginal memory.
1.0.2 K Hoang 06/02/2021 Add support to STM32F/L/H/G/WB/MP1 using ATWINC1500/WiFi101
1.1.0 K Hoang 21/02/2021 Optimize code and use better FlashStorage_SAMD and FlashStorage_STM32.
Add customs HTML header feature. Fix bug.
*****************************************************************************************************************************/
/****************************************************************************************************************************
You have to modify file ./libraries/Adafruit_MQTT_Library/Adafruit_MQTT.cpp as follows to avoid dtostrf error, if exists
Expand Down Expand Up @@ -279,6 +281,11 @@ void MQTT_connect()
#endif
}

#if USING_CUSTOMS_STYLE
const char NewCustomsStyle[] /*PROGMEM*/ = "<style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>";
#endif

void setup()
{
// Debug console
Expand All @@ -297,11 +304,23 @@ void setup()

// Optional to change default AP IP(192.168.4.1) and channel(10)
//WiFiManager_Generic->setConfigPortalIP(IPAddress(192, 168, 120, 1));
WiFiManager_Generic->setConfigPortalChannel(1);
WiFiManager_Generic->setConfigPortalChannel(0);

#if USING_CUSTOMS_STYLE
WiFiManager_Generic->setCustomsStyle(NewCustomsStyle);
#endif

#if USING_CUSTOMS_HEAD_ELEMENT
WiFiManager_Generic->setCustomsHeadElement("<style>html{filter: invert(10%);}</style>");
#endif

#if USING_CORS_FEATURE
WiFiManager_Generic->setCORSHeader("Your Access-Control-Allow-Origin");
#endif

// Set customized DHCP HostName
WiFiManager_Generic->begin(HOST_NAME);
//Or use default Hostname "SAMD-WIFI-XXXXXX"
//Or use default Hostname "MKR1000-WIFI-XXXXXX"
//WiFiManager_Generic->begin();
}

Expand All @@ -317,17 +336,14 @@ void displayCredentials()
Serial.println(myMenuItems[i].pdata);
}
}
#endif

void loop()
void displayCredentialsInLoop()
{

#if USE_DYNAMIC_PARAMETERS
static bool displayedCredentials = false;

if (!displayedCredentials)
{
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
for (int i = 0; i < NUM_MENU_ITEMS; i++)
{
if (!strlen(myMenuItems[i].pdata))
{
Expand All @@ -341,8 +357,16 @@ void loop()
}
}
}
}

#endif

void loop()
{
WiFiManager_Generic->run();
check_status();

#if USE_DYNAMIC_PARAMETERS
displayCredentialsInLoop();
#endif
}
9 changes: 8 additions & 1 deletion examples/MKR1000_WiFi101_MQTT/defines.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
defines.h for SAMD_WiFiNINA_MQTT.ino
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down Expand Up @@ -51,6 +51,13 @@

/////////////////////////////////////////////

// Add customs headers from v1.1.0
#define USING_CUSTOMS_STYLE true
#define USING_CUSTOMS_HEAD_ELEMENT true
#define USING_CORS_FEATURE true

/////////////////////////////////////////////

#define USE_WIFI101 true

#if defined(USE_WIFI_NINA)
Expand Down
2 changes: 1 addition & 1 deletion examples/MKR1000_WiFi101_MQTT/dynamicParams.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************************************************************
dynamicParams.h
For SAMD 21 MKR1000 boards using WiFi101 Modules/Shields
For SAMD21 MKR1000 boards using WiFi101 Modules/Shields
WiFiManager_Generic_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_Generic_Lite) to enable store Credentials in EEPROM/LittleFS for easy
Expand Down
Loading

0 comments on commit 850a57f

Please sign in to comment.