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

Commit 5783700

Browse files
authored
v1.1.2
### Releases v1.1.2 1. Fix bug in examples.
1 parent a31432d commit 5783700

File tree

24 files changed

+979
-938
lines changed

24 files changed

+979
-938
lines changed

README.md

Lines changed: 107 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ To appreciate the power of the [ESPAsyncWebServer](https://github.com/me-no-dev/
2828

2929
---
3030

31+
### Releases v1.1.2
32+
33+
1. Fix bug in examples.
34+
3135
### Major Releases v1.1.1
3236

3337
1. Add **MultiWiFi feature to auto(Re)connect to the best WiFi at runtime**
@@ -59,16 +63,17 @@ This is an `ESP32 / ESP8266` WiFi Connection Manager with fallback Web ConfigPor
5963

6064
Thanks to this [ESPAsync_WiFiManager library](https://github.com/khoih-prog/ESPAsync_WiFiManager) is based on and sync'ed with [`ESP_WiFiManager`](https://github.com/khoih-prog/ESP_WiFiManager), all the features currently supported by [`ESP_WiFiManager`](https://github.com/khoih-prog/ESP_WiFiManager) will be available. Please have a look at [`ESP_WiFiManager`](https://github.com/khoih-prog/ESP_WiFiManager) for those too-many-to-list features.
6165

66+
---
6267
---
6368

6469
## Prerequisite
6570

6671
1. [`Arduino IDE 1.8.12+` for Arduino](https://www.arduino.cc/en/Main/Software)
6772
2. [`ESP8266 Core 2.7.3+`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
6873
3. [`ESP32 Core 1.0.4+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
69-
4. [`ESPAsyncWebServer v1.2.3+`](https://github.com/me-no-dev/ESPAsyncWebServer)
70-
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266
71-
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32
74+
4. [`ESPAsyncWebServer v1.2.3+`](https://github.com/me-no-dev/ESPAsyncWebServer) for all ESP32/ESP8266-based boards.
75+
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266-based boards.
76+
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32-based boards
7277

7378
---
7479

@@ -1051,18 +1056,6 @@ ESPAsync_wifiManager.setRemoveDuplicateAPs(false);
10511056
### Example [Async_ConfigOnDRD_FS_MQTT_Ptr](examples/Async_ConfigOnDRD_FS_MQTT_Ptr)
10521057

10531058
```cpp
1054-
/****************************************************************************************************************************
1055-
This example will open a Config Portal when there is no stored WiFi Credentials or when a DRD is detected.
1056-
1057-
You can reconfigure to use another pin, such as the convenience FLASH / BOOT button @ PIN_D0;.
1058-
1059-
A password is required to connect to the Config Portal so that only who know the password can access the Config Portal.
1060-
1061-
The Credentials, being input via Config Portal, will then be saved into LittleFS / SPIFFS file, and be used to connect to
1062-
Adafruit MQTT Server at "io.adafruit.com" and publish a Temperature Topic
1063-
1064-
Based on original sketch posted by "Marko"(https://github.com/wackoo-arduino) on https://forum.arduino.cc/index.php?topic=692108
1065-
*****************************************************************************************************************************/
10661059
#if !( defined(ESP8266) || defined(ESP32) )
10671060
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
10681061
#endif
@@ -1203,7 +1196,7 @@ const char* CONFIG_FILE = "/ConfigMQTT.json";
12031196
// Default configuration values for Adafruit IO MQTT
12041197
// This actually works
12051198
#define AIO_SERVER "io.adafruit.com"
1206-
#define AIO_SERVERPORT 1883 //1883, or 8883 for SSL
1199+
#define AIO_SERVERPORT "1883" //1883, or 8883 for SSL
12071200
#define AIO_USERNAME "private" //Adafruit IO
12081201
#define AIO_KEY "private"
12091202

@@ -1219,11 +1212,12 @@ String MQTT_Pub_Topic = "private/feeds/Temperature";
12191212
// Variables to save custom parameters to...
12201213
// I would like to use these instead of #defines
12211214
#define custom_AIO_SERVER_LEN 20
1215+
#define custom_AIO_PORT_LEN 5
12221216
#define custom_AIO_USERNAME_LEN 20
12231217
#define custom_AIO_KEY_LEN 40
12241218

12251219
char custom_AIO_SERVER[custom_AIO_SERVER_LEN];
1226-
int custom_AIO_SERVERPORT;
1220+
char custom_AIO_SERVERPORT[custom_AIO_PORT_LEN];
12271221
char custom_AIO_USERNAME[custom_AIO_USERNAME_LEN];
12281222
char custom_AIO_KEY[custom_AIO_KEY_LEN];
12291223

@@ -1351,6 +1345,79 @@ WiFiClient *client = NULL;
13511345
Adafruit_MQTT_Client *mqtt = NULL;
13521346
Adafruit_MQTT_Publish *Temperature = NULL;
13531347

1348+
// Forward Declaration
1349+
1350+
1351+
uint8_t connectMultiWiFi(void)
1352+
{
1353+
#if ESP32
1354+
// For ESP32, this better be 0 to shorten the connect time
1355+
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 0
1356+
#else
1357+
// For ESP8266, this better be 2200 to enable connect the 1st time
1358+
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L
1359+
#endif
1360+
1361+
#define WIFI_MULTI_CONNECT_WAITING_MS 100L
1362+
1363+
uint8_t status;
1364+
1365+
LOGERROR(F("ConnectMultiWiFi with :"));
1366+
1367+
if ( (Router_SSID != "") && (Router_Pass != "") )
1368+
{
1369+
LOGERROR3(F("* Flash-stored Router_SSID = "), Router_SSID, F(", Router_Pass = "), Router_Pass );
1370+
}
1371+
1372+
for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++)
1373+
{
1374+
// Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8)
1375+
if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != "") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) )
1376+
{
1377+
LOGERROR3(F("* Additional SSID = "), WM_config.WiFi_Creds[i].wifi_ssid, F(", PW = "), WM_config.WiFi_Creds[i].wifi_pw );
1378+
}
1379+
}
1380+
1381+
LOGERROR(F("Connecting MultiWifi..."));
1382+
1383+
WiFi.mode(WIFI_STA);
1384+
1385+
#if !USE_DHCP_IP
1386+
#if USE_CONFIGURABLE_DNS
1387+
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5
1388+
WiFi.config(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
1389+
#else
1390+
// Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2.
1391+
WiFi.config(stationIP, gatewayIP, netMask);
1392+
#endif
1393+
#endif
1394+
1395+
int i = 0;
1396+
status = wifiMulti.run();
1397+
delay(WIFI_MULTI_1ST_CONNECT_WAITING_MS);
1398+
1399+
while ( ( i++ < 20 ) && ( status != WL_CONNECTED ) )
1400+
{
1401+
status = wifiMulti.run();
1402+
1403+
if ( status == WL_CONNECTED )
1404+
break;
1405+
else
1406+
delay(WIFI_MULTI_CONNECT_WAITING_MS);
1407+
}
1408+
1409+
if ( status == WL_CONNECTED )
1410+
{
1411+
LOGERROR1(F("WiFi connected after time: "), i);
1412+
LOGERROR3(F("SSID:"), WiFi.SSID(), F(",RSSI="), WiFi.RSSI());
1413+
LOGERROR3(F("Channel:"), WiFi.channel(), F(",IP address:"), WiFi.localIP() );
1414+
}
1415+
else
1416+
LOGERROR(F("WiFi not connected"));
1417+
1418+
return status;
1419+
}
1420+
13541421
void toggleLED()
13551422
{
13561423
//toggle state
@@ -1404,7 +1471,7 @@ void check_WiFi(void)
14041471
Serial.println(F("\nWiFi lost. Call connectMultiWiFi in loop"));
14051472
connectMultiWiFi();
14061473
}
1407-
}
1474+
}
14081475

14091476
void check_status(void)
14101477
{
@@ -1487,76 +1554,6 @@ void saveConfigData(void)
14871554
}
14881555
}
14891556

1490-
uint8_t connectMultiWiFi(void)
1491-
{
1492-
#if ESP32
1493-
// For ESP32, this better be 0 to shorten the connect time
1494-
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 0
1495-
#else
1496-
// For ESP8266, this better be 2200 to enable connect the 1st time
1497-
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L
1498-
#endif
1499-
1500-
#define WIFI_MULTI_CONNECT_WAITING_MS 100L
1501-
1502-
uint8_t status;
1503-
1504-
LOGERROR(F("ConnectMultiWiFi with :"));
1505-
1506-
if ( (Router_SSID != "") && (Router_Pass != "") )
1507-
{
1508-
LOGERROR3(F("* Flash-stored Router_SSID = "), Router_SSID, F(", Router_Pass = "), Router_Pass );
1509-
}
1510-
1511-
for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++)
1512-
{
1513-
// Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8)
1514-
if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != "") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) )
1515-
{
1516-
LOGERROR3(F("* Additional SSID = "), WM_config.WiFi_Creds[i].wifi_ssid, F(", PW = "), WM_config.WiFi_Creds[i].wifi_pw );
1517-
}
1518-
}
1519-
1520-
LOGERROR(F("Connecting MultiWifi..."));
1521-
1522-
WiFi.mode(WIFI_STA);
1523-
1524-
#if !USE_DHCP_IP
1525-
#if USE_CONFIGURABLE_DNS
1526-
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5
1527-
WiFi.config(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
1528-
#else
1529-
// Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2.
1530-
WiFi.config(stationIP, gatewayIP, netMask);
1531-
#endif
1532-
#endif
1533-
1534-
int i = 0;
1535-
status = wifiMulti.run();
1536-
delay(WIFI_MULTI_1ST_CONNECT_WAITING_MS);
1537-
1538-
while ( ( i++ < 20 ) && ( status != WL_CONNECTED ) )
1539-
{
1540-
status = wifiMulti.run();
1541-
1542-
if ( status == WL_CONNECTED )
1543-
break;
1544-
else
1545-
delay(WIFI_MULTI_CONNECT_WAITING_MS);
1546-
}
1547-
1548-
if ( status == WL_CONNECTED )
1549-
{
1550-
LOGERROR1(F("WiFi connected after time: "), i);
1551-
LOGERROR3(F("SSID:"), WiFi.SSID(), F(",RSSI="), WiFi.RSSI());
1552-
LOGERROR3(F("Channel:"), WiFi.channel(), F(",IP address:"), WiFi.localIP() );
1553-
}
1554-
else
1555-
LOGERROR(F("WiFi not connected"));
1556-
1557-
return status;
1558-
}
1559-
15601557
void deleteOldInstances(void)
15611558
{
15621559
// Delete previous instances
@@ -1574,7 +1571,7 @@ void deleteOldInstances(void)
15741571
Temperature = NULL;
15751572

15761573
Serial.println(F("Deleting old Temperature object"));
1577-
}
1574+
}
15781575
}
15791576

15801577
void createNewInstances(void)
@@ -1591,7 +1588,7 @@ void createNewInstances(void)
15911588
if (!mqtt)
15921589
{
15931590
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
1594-
mqtt = new Adafruit_MQTT_Client(client, custom_AIO_SERVER, custom_AIO_SERVERPORT, custom_AIO_USERNAME, custom_AIO_KEY);
1591+
mqtt = new Adafruit_MQTT_Client(client, custom_AIO_SERVER, atoi(custom_AIO_SERVERPORT), custom_AIO_USERNAME, custom_AIO_KEY);
15951592

15961593
Serial.print(F("Creating new MQTT object : "));
15971594

@@ -1672,9 +1669,8 @@ void wifi_manager()
16721669
// AIO_SERVER
16731670
ESPAsync_WMParameter AIO_SERVER_FIELD(AIO_SERVER_Label, "AIO SERVER", custom_AIO_SERVER, custom_AIO_SERVER_LEN + 1);
16741671

1675-
// AIO_SERVERPORT (because it is int, it needs to be converted to string)
1676-
String convertedValue = String(custom_AIO_SERVERPORT);
1677-
ESPAsync_WMParameter AIO_SERVERPORT_FIELD(AIO_SERVERPORT_Label, "AIO SERVER PORT", convertedValue.c_str(), convertedValue.length() + 1);
1672+
// AIO_SERVERPORT
1673+
ESPAsync_WMParameter AIO_SERVERPORT_FIELD(AIO_SERVERPORT_Label, "AIO SERVER PORT", custom_AIO_SERVERPORT, custom_AIO_PORT_LEN + 1);
16781674

16791675
// AIO_USERNAME
16801676
ESPAsync_WMParameter AIO_USERNAME_FIELD(AIO_USERNAME_Label, "AIO USERNAME", custom_AIO_USERNAME, custom_AIO_USERNAME_LEN + 1);
@@ -1774,10 +1770,10 @@ void wifi_manager()
17741770
// Getting posted form values and overriding local variables parameters
17751771
// Config file is written regardless the connection state
17761772
strcpy(custom_AIO_SERVER, AIO_SERVER_FIELD.getValue());
1777-
custom_AIO_SERVERPORT = atoi(AIO_SERVERPORT_FIELD.getValue());
1773+
strcpy(custom_AIO_SERVERPORT, AIO_SERVERPORT_FIELD.getValue());
17781774
strcpy(custom_AIO_USERNAME, AIO_USERNAME_FIELD.getValue());
17791775
strcpy(custom_AIO_KEY, AIO_KEY_FIELD.getValue());
1780-
1776+
17811777
// Writing JSON config file to flash for next boot
17821778
writeConfigFile();
17831779

@@ -1852,7 +1848,7 @@ bool readConfigFile()
18521848

18531849
if (json.containsKey(AIO_SERVERPORT_Label))
18541850
{
1855-
custom_AIO_SERVERPORT = json[AIO_SERVERPORT_Label];
1851+
strcpy(custom_AIO_SERVERPORT, json[AIO_SERVERPORT_Label]);
18561852
}
18571853

18581854
if (json.containsKey(AIO_USERNAME_Label))
@@ -1883,10 +1879,10 @@ bool writeConfigFile()
18831879
#endif
18841880

18851881
// JSONify local configuration parameters
1886-
json[AIO_SERVER_Label] = custom_AIO_SERVER;
1887-
json[AIO_SERVERPORT_Label] = custom_AIO_SERVERPORT;
1888-
json[AIO_USERNAME_Label] = custom_AIO_USERNAME;
1889-
json[AIO_KEY_Label] = custom_AIO_KEY;
1882+
json[AIO_SERVER_Label] = custom_AIO_SERVER;
1883+
json[AIO_SERVERPORT_Label] = custom_AIO_SERVERPORT;
1884+
json[AIO_USERNAME_Label] = custom_AIO_USERNAME;
1885+
json[AIO_KEY_Label] = custom_AIO_KEY;
18901886

18911887
// Open file for writing
18921888
File f = FileFS.open(CONFIG_FILE, "w");
@@ -2115,7 +2111,6 @@ Configuring AP SSID = ESP_E92DE6B4
21152111
[WM] AP IP address = 192.168.4.1
21162112
[WM] HTTP server started
21172113
[WM] ESPAsync_WiFiManager::startConfigPortal : Enter loop
2118-
dhcps: send_offer>>udp_sendto result 0
21192114
[WM] Connecting to new AP
21202115
[WM] Previous settings invalidated
21212116
[WM] Custom STA IP/GW/Subnet
@@ -2134,7 +2129,7 @@ Local IP: 192.168.2.232
21342129
Saving Config File
21352130
{
21362131
"AIO_SERVER_Label": "io.adafruit.com",
2137-
"AIO_SERVERPORT_Label": 1883,
2132+
"AIO_SERVERPORT_Label": "1883",
21382133
"AIO_USERNAME_Label": "account",
21392134
"AIO_KEY_Label": "aio_token"
21402135
}
@@ -2162,8 +2157,7 @@ Config File successfully parsed
21622157
LittleFS Flag read = 0xd0d01234
21632158
doubleResetDetected
21642159
Saving config file...
2165-
Saving config file OK
2166-
Open Config Portal without Timeout: Double Reset Detected
2160+
Saving config file OK Config Portal without Timeout: Double Reset Detected
21672161

21682162
Config Portal requested.
21692163
[WM] RFC925 Hostname = ConfigOnSwichFS-MQTT
@@ -2201,7 +2195,7 @@ Local IP: 192.168.2.186
22012195
Saving Config File
22022196
{
22032197
"AIO_SERVER_Label": "io.adafruit.com",
2204-
"AIO_SERVERPORT_Label": 1883,
2198+
"AIO_SERVERPORT_Label": "1883",
22052199
"AIO_USERNAME_Label": "account",
22062200
"AIO_KEY_Label": "aio_token"
22072201
}
@@ -2439,6 +2433,10 @@ Submit issues to: [ESPAsync_WiFiManager issues](https://github.com/khoih-prog/ES
24392433
---
24402434
---
24412435

2436+
### Releases v1.1.2
2437+
2438+
1. Fix bug in examples.
2439+
24422440
### Major Releases v1.1.1
24432441

24442442
1. Add **MultiWiFi feature to auto(Re)connect to the best WiFi at runtime**
@@ -2469,18 +2467,18 @@ to use the better **asynchronous** [ESPAsyncWebServer](https://github.com/me-no-
24692467
### Contributions and Thanks
24702468

24712469
1. Based on and modified from [Tzapu](https://github.com/tzapu/WiFiManager), [KenTaylor's version]( https://github.com/kentaylor/WiFiManager), [`Alan Steremberg's ESPAsyncWiFiManager`](https://github.com/alanswx/ESPAsyncWiFiManager) and [`Khoi Hoang's ESP_WiFiManager`](https://github.com/khoih-prog/ESP_WiFiManager).
2472-
2. Thanks to [me-no-dev](https://github.com/me-no-dev) for great [ESPAsyncWebServer Library](https://github.com/me-no-dev/ESPAsyncWebServer)
2470+
2. Thanks to [Hristo Gochkov](https://github.com/me-no-dev) for great [ESPAsyncWebServer Library](https://github.com/me-no-dev/ESPAsyncWebServer)
24732471
3. Thanks to good work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip) for working with, developing, debugging and testing.
24742472
4. Thanks to [cancodr](https://github.com/cancodr) for requesting an enhancement in [Issue #29: Is it possible to use AsyncWebServer.h instead of WebServer.h?](https://github.com/khoih-prog/ESP_WiFiManager/issues/29), leading to this [ESPAsync_WiFiManager Library](https://github.com/khoih-prog/ESPAsync_WiFiManager).
24752473

24762474

24772475
<table>
24782476
<tr>
2479-
<td align="center"><a href="https://github.com/me-no-dev"><img src="https://github.com/me-no-dev.png" width="100px;" alt="me-no-dev"/><br /><sub><b>⭐️⭐️ me-no-dev</b></sub></a><br /></td>
2477+
<td align="center"><a href="https://github.com/me-no-dev"><img src="https://github.com/me-no-dev.png" width="100px;" alt="me-no-dev"/><br /><sub><b>⭐️⭐️ Hristo Gochkov</b></sub></a><br /></td>
24802478
<td align="center"><a href="https://github.com/Tzapu"><img src="https://github.com/Tzapu.png" width="100px;" alt="Tzapu"/><br /><sub><b>⭐️ Tzapu</b></sub></a><br /></td>
2481-
<td align="center"><a href="https://github.com/kentaylor"><img src="https://github.com/kentaylor.png" width="100px;" alt="kentaylor"/><br /><sub><b>⭐️ kentaylor</b></sub></a><br /></td>
2479+
<td align="center"><a href="https://github.com/kentaylor"><img src="https://github.com/kentaylor.png" width="100px;" alt="kentaylor"/><br /><sub><b>⭐️ Ken Taylor</b></sub></a><br /></td>
24822480
<td align="center"><a href="https://github.com/alanswx"><img src="https://github.com/alanswx.png" width="100px;" alt="alanswx"/><br /><sub><b>⭐️ Alan Steremberg</b></sub></a><br /></td>
2483-
<td align="center"><a href="https://github.com/tcpipchip"><img src="https://github.com/tcpipchip.png" width="100px;" alt="tcpipchip"/><br /><sub><b>tcpipchip</b></sub></a><br /></td>
2481+
<td align="center"><a href="https://github.com/tcpipchip"><img src="https://github.com/tcpipchip.png" width="100px;" alt="tcpipchip"/><br /><sub><b>Miguel Wisintainer</b></sub></a><br /></td>
24842482
<td align="center"><a href="https://github.com/cancodr"><img src="https://github.com/cancodr.png" width="100px;" alt="cancodr"/><br /><sub><b>cancodr</b></sub></a><br /></td>
24852483
</tr>
24862484
</table>

0 commit comments

Comments
 (0)