@@ -28,6 +28,10 @@ To appreciate the power of the [ESPAsyncWebServer](https://github.com/me-no-dev/
28
28
29
29
---
30
30
31
+ ### Releases v1.1.2
32
+
33
+ 1 . Fix bug in examples.
34
+
31
35
### Major Releases v1.1.1
32
36
33
37
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
59
63
60
64
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.
61
65
66
+ ---
62
67
---
63
68
64
69
## Prerequisite
65
70
66
71
1 . [ ` Arduino IDE 1.8.12+ ` for Arduino] ( https://www.arduino.cc/en/Main/Software )
67
72
2 . [ ` ESP8266 Core 2.7.3+ ` ] ( https://github.com/esp8266/Arduino ) for ESP8266-based boards.
68
73
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
72
77
73
78
---
74
79
@@ -1051,18 +1056,6 @@ ESPAsync_wifiManager.setRemoveDuplicateAPs(false);
1051
1056
### Example [ Async_ConfigOnDRD_FS_MQTT_Ptr] ( examples/Async_ConfigOnDRD_FS_MQTT_Ptr )
1052
1057
1053
1058
``` 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
- *****************************************************************************************************************************/
1066
1059
#if !( defined(ESP8266) || defined(ESP32) )
1067
1060
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
1068
1061
#endif
@@ -1203,7 +1196,7 @@ const char* CONFIG_FILE = "/ConfigMQTT.json";
1203
1196
// Default configuration values for Adafruit IO MQTT
1204
1197
// This actually works
1205
1198
#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
1207
1200
#define AIO_USERNAME "private" //Adafruit IO
1208
1201
#define AIO_KEY "private"
1209
1202
@@ -1219,11 +1212,12 @@ String MQTT_Pub_Topic = "private/feeds/Temperature";
1219
1212
// Variables to save custom parameters to...
1220
1213
// I would like to use these instead of #defines
1221
1214
#define custom_AIO_SERVER_LEN 20
1215
+ #define custom_AIO_PORT_LEN 5
1222
1216
#define custom_AIO_USERNAME_LEN 20
1223
1217
#define custom_AIO_KEY_LEN 40
1224
1218
1225
1219
char custom_AIO_SERVER[custom_AIO_SERVER_LEN];
1226
- int custom_AIO_SERVERPORT;
1220
+ char custom_AIO_SERVERPORT[custom_AIO_PORT_LEN] ;
1227
1221
char custom_AIO_USERNAME[custom_AIO_USERNAME_LEN];
1228
1222
char custom_AIO_KEY[custom_AIO_KEY_LEN];
1229
1223
@@ -1351,6 +1345,79 @@ WiFiClient *client = NULL;
1351
1345
Adafruit_MQTT_Client * mqtt = NULL;
1352
1346
Adafruit_MQTT_Publish * Temperature = NULL;
1353
1347
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
+
1354
1421
void toggleLED()
1355
1422
{
1356
1423
//toggle state
@@ -1404,7 +1471,7 @@ void check_WiFi(void)
1404
1471
Serial.println(F("\nWiFi lost. Call connectMultiWiFi in loop"));
1405
1472
connectMultiWiFi();
1406
1473
}
1407
- }
1474
+ }
1408
1475
1409
1476
void check_status(void)
1410
1477
{
@@ -1487,76 +1554,6 @@ void saveConfigData(void)
1487
1554
}
1488
1555
}
1489
1556
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
-
1560
1557
void deleteOldInstances(void)
1561
1558
{
1562
1559
// Delete previous instances
@@ -1574,7 +1571,7 @@ void deleteOldInstances(void)
1574
1571
Temperature = NULL;
1575
1572
1576
1573
Serial.println(F("Deleting old Temperature object"));
1577
- }
1574
+ }
1578
1575
}
1579
1576
1580
1577
void createNewInstances(void)
@@ -1591,7 +1588,7 @@ void createNewInstances(void)
1591
1588
if (!mqtt)
1592
1589
{
1593
1590
// 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);
1595
1592
1596
1593
Serial.print(F("Creating new MQTT object : "));
1597
1594
@@ -1672,9 +1669,8 @@ void wifi_manager()
1672
1669
// AIO_SERVER
1673
1670
ESPAsync_WMParameter AIO_SERVER_FIELD(AIO_SERVER_Label, "AIO SERVER", custom_AIO_SERVER, custom_AIO_SERVER_LEN + 1);
1674
1671
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);
1678
1674
1679
1675
// AIO_USERNAME
1680
1676
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()
1774
1770
// Getting posted form values and overriding local variables parameters
1775
1771
// Config file is written regardless the connection state
1776
1772
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());
1778
1774
strcpy(custom_AIO_USERNAME, AIO_USERNAME_FIELD.getValue());
1779
1775
strcpy(custom_AIO_KEY, AIO_KEY_FIELD.getValue());
1780
-
1776
+
1781
1777
// Writing JSON config file to flash for next boot
1782
1778
writeConfigFile();
1783
1779
@@ -1852,7 +1848,7 @@ bool readConfigFile()
1852
1848
1853
1849
if (json.containsKey(AIO_SERVERPORT_Label))
1854
1850
{
1855
- custom_AIO_SERVERPORT = json[AIO_SERVERPORT_Label];
1851
+ strcpy( custom_AIO_SERVERPORT, json[AIO_SERVERPORT_Label]) ;
1856
1852
}
1857
1853
1858
1854
if (json.containsKey(AIO_USERNAME_Label))
@@ -1883,10 +1879,10 @@ bool writeConfigFile()
1883
1879
#endif
1884
1880
1885
1881
// 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;
1890
1886
1891
1887
// Open file for writing
1892
1888
File f = FileFS.open(CONFIG_FILE, "w");
@@ -2115,7 +2111,6 @@ Configuring AP SSID = ESP_E92DE6B4
2115
2111
[ WM] AP IP address = 192.168.4.1
2116
2112
[ WM] HTTP server started
2117
2113
[ WM] ESPAsync_WiFiManager::startConfigPortal : Enter loop
2118
- dhcps: send_offer>>udp_sendto result 0
2119
2114
[ WM] Connecting to new AP
2120
2115
[ WM] Previous settings invalidated
2121
2116
[ WM] Custom STA IP/GW/Subnet
@@ -2134,7 +2129,7 @@ Local IP: 192.168.2.232
2134
2129
Saving Config File
2135
2130
{
2136
2131
"AIO_SERVER_Label": "io.adafruit.com",
2137
- "AIO_SERVERPORT_Label": 1883,
2132
+ "AIO_SERVERPORT_Label": " 1883" ,
2138
2133
"AIO_USERNAME_Label": "account",
2139
2134
"AIO_KEY_Label": "aio_token"
2140
2135
}
@@ -2162,8 +2157,7 @@ Config File successfully parsed
2162
2157
LittleFS Flag read = 0xd0d01234
2163
2158
doubleResetDetected
2164
2159
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
2167
2161
2168
2162
Config Portal requested.
2169
2163
[ WM] RFC925 Hostname = ConfigOnSwichFS-MQTT
@@ -2201,7 +2195,7 @@ Local IP: 192.168.2.186
2201
2195
Saving Config File
2202
2196
{
2203
2197
"AIO_SERVER_Label": "io.adafruit.com",
2204
- "AIO_SERVERPORT_Label": 1883,
2198
+ "AIO_SERVERPORT_Label": " 1883" ,
2205
2199
"AIO_USERNAME_Label": "account",
2206
2200
"AIO_KEY_Label": "aio_token"
2207
2201
}
@@ -2439,6 +2433,10 @@ Submit issues to: [ESPAsync_WiFiManager issues](https://github.com/khoih-prog/ES
2439
2433
---
2440
2434
---
2441
2435
2436
+ ### Releases v1.1.2
2437
+
2438
+ 1 . Fix bug in examples.
2439
+
2442
2440
### Major Releases v1.1.1
2443
2441
2444
2442
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-
2469
2467
### Contributions and Thanks
2470
2468
2471
2469
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 )
2473
2471
3 . Thanks to good work of [ Miguel Alexandre Wisintainer] ( https://github.com/tcpipchip ) for working with, developing, debugging and testing.
2474
2472
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 ) .
2475
2473
2476
2474
2477
2475
<table >
2478
2476
<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>
2480
2478
<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>
2482
2480
<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>
2484
2482
<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>
2485
2483
</tr >
2486
2484
</table >
0 commit comments