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

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
### Releases v1.2.2

1. Fix rare Config Portal bug not updating Config and dynamic Params data successfully in very noisy or weak WiFi situation
  • Loading branch information
khoih-prog authored Jan 29, 2021
1 parent fe40128 commit 7480b73
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 156 deletions.
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [Why using Async](#why-using-async)
* [Currently supported Boards](#currently-supported-boards)
* [Changelog](#changelog)
* [Releases v1.2.2](#releases-v122)
* [Releases v1.2.1](#releases-v121)
* [Major Releases v1.2.0](#major-releases-v120)
* [Releases v1.1.0](#releases-v110)
Expand Down Expand Up @@ -143,6 +144,10 @@ This [**BlynkESP32_BT_WF** library](https://github.com/khoih-prog/BlynkESP32_BT_

## Changelog

### Releases v1.2.2

1. Fix rare Config Portal bug not updating Config and dynamic Params data successfully in very noisy or weak WiFi situation

### Releases v1.2.1

1. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](https://github.com/khoih-prog/Blynk_WM/issues/25)
Expand Down Expand Up @@ -1203,7 +1208,7 @@ The following is the sample terminal output when running example [Async_ESP8266W

```
Starting Async_ESP8266WM_MRD_Config using LittleFS with SSL on ESP8266_NODEMCU
Blynk_Async_WM SSL for ESP8266 v1.2.1
Blynk_Async_WM SSL for ESP8266 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1283,7 +1288,7 @@ BBBBBB

```
Starting Async_ESP8266WM_MRD_Config using LittleFS with SSL on ESP8266_NODEMCU
Blynk_Async_WM SSL for ESP8266 v1.2.1
Blynk_Async_WM SSL for ESP8266 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFC0003
multiResetDetectorFlag = 0xFFFC0003
Expand Down Expand Up @@ -1394,7 +1399,7 @@ F[229521] id: = HueNet1

```
Starting Async_ESP8266WM_MRD_Config using LittleFS with SSL on ESP8266_NODEMCU
Blynk_Async_WM SSL for ESP8266 v1.2.1
Blynk_Async_WM SSL for ESP8266 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1480,7 +1485,7 @@ The following is the sample terminal output when running example [Async_ESP32WM_

```
Starting Async_ESP32WM_MRD_Config using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1559,7 +1564,7 @@ Pubs Topics = default-mqtt-PubTopic

```
Starting Async_ESP32WM_MRD_Config using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFC0003
multiResetDetectorFlag = 0xFFFC0003
Expand Down Expand Up @@ -1664,7 +1669,7 @@ RFRFRF[188660] id: = HueNet1

```
Starting Async_ESP32WM_MRD_Config using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1801,7 +1806,7 @@ The following is the sample terminal output when running example [Async_ESP32_Mu

```
Starting Async_ESP32_MultiTask using LittleFS without SSL on ESP32_DEV
Blynk_Async_WM for ESP32 v1.2.1
Blynk_Async_WM for ESP32 v1.2.2
ESP_DoubleResetDetector v1.1.1
[1431] Hostname=ESP32-Async-MTask
[1517] LoadCfgFile
Expand Down Expand Up @@ -2013,7 +2018,7 @@ Blynk.resetAndEnterConfigPortal();

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2104,7 +2109,7 @@ Non-Persistent CP will be removed after first reset, even you didn't enter the C

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2219,7 +2224,7 @@ RF[66298] id: = HueNet1

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2318,7 +2323,7 @@ Blynk.resetAndEnterConfigPortalPersistent();

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2409,7 +2414,7 @@ Persistent CP will remain after resets. The only way to get rid of Config Portal

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2521,7 +2526,7 @@ Enter CP, input (even fake data or none) and `Save` config data to exit persiste

```
Starting Async_ESP32WM_MRD_ForcedConfig using LittleFS with SSL on ESP32_DEV
Blynk_Async_WM SSL for ESP32 v1.2.1
Blynk_Async_WM SSL for ESP32 v1.2.2
ESP_MultiResetDetector v1.1.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -2635,6 +2640,10 @@ Sometimes, the library will only work if you update the board core to the latest

## Releases

### Releases v1.2.2

1. Fix rare Config Portal bug not updating Config and dynamic Params data successfully in very noisy or weak WiFi situation

### Releases v1.2.1

1. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](https://github.com/khoih-prog/Blynk_WM/issues/25)
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Blynk_Async_WM",
"version": "1.2.1",
"version": "1.2.2",
"description": "Library, using AsyncWebServer instead of (ESP8266)WebServer, for configuring/auto(re)connecting ESP8266/ESP32 modules to best or available MultiWiFi APs and MultiBlynk servers at runtime. Enable adding dynamic custom parameters from sketch and input using the same Config Portal. Config Portal will be auto-adjusted to match the number of dynamic parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Static STA IP and DHCP Hostname as well as Config Portal AP channel, IP, SSID, Password can be configured. Multi or Double DetectDetector feature permits entering Config Portal as requested.",
"keywords": "sensors, control, device, smartphone, mobile, app, web, cloud, communication, protocol, iot, m2m, wifi, ble, bluetooth, ethernet, usb, serial, gsm, gprs, 3g, data, esp8266, esp32, http, drd, mrd, double-reset, multi-reset, configportal, portal, credentials, async",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Blynk_Async_WM
version=1.2.1
version=1.2.2
author=Khoi Hoang
license=MIT
maintainer=Khoi Hoang <[email protected]>
Expand Down
109 changes: 74 additions & 35 deletions src/BlynkSimpleEsp32_Async_WM.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@date Jan 2015
@brief
Version: 1.2.1
Version: 1.2.2
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -26,6 +26,7 @@
1.1.0 K Hoang 26/11/2020 Add examples using RTOS MultiTask to avoid blocking in operation.
1.2.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD
1.2.1 K Hoang 16/01/2021 Add functions to control Config Portal from software or Virtual Switches
1.2.2 K Hoang 28/01/2021 Fix Config Portal and Dynamic Params bugs
********************************************************************************************************************************/

#pragma once
Expand All @@ -34,7 +35,7 @@
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
#endif

#define BLYNK_ASYNC_WM_VERSION "Blynk_Async_WM for ESP32 v1.2.1"
#define BLYNK_ASYNC_WM_VERSION "Blynk_Async_WM for ESP32 v1.2.2"

#define BLYNK_SEND_ATOMIC

Expand Down Expand Up @@ -197,6 +198,7 @@ typedef struct
#if USE_DYNAMIC_PARAMETERS
extern uint16_t NUM_MENU_ITEMS;
extern MenuItem myMenuItems [];
bool *menuItemUpdated = NULL;
#endif

#define SSID_MAX_LEN 32
Expand Down Expand Up @@ -2033,100 +2035,134 @@ class BlynkWifi
memset(&BlynkESP32_WM_config, 0, sizeof(BlynkESP32_WM_config));
strcpy(BlynkESP32_WM_config.header, BLYNK_BOARD_TYPE);
}

if (key == "id")

#if USE_DYNAMIC_PARAMETERS
if (!menuItemUpdated)
{
BLYNK_LOG2(BLYNK_F("id: = "), value.c_str());
// Don't need to free
menuItemUpdated = new bool[NUM_MENU_ITEMS];

if (menuItemUpdated)
{
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
// To flag item is not yet updated
menuItemUpdated[i] = false;
}
#if ( BLYNK_WM_DEBUG > 2)
BLYNK_LOG1(BLYNK_F("h: Init menuItemUpdated" ));
#endif
}
else
{
BLYNK_LOG1(BLYNK_F("h: Error can't alloc memory for menuItemUpdated" ));
}
}
#endif

static bool id_Updated = false;
static bool pw_Updated = false;
static bool id1_Updated = false;
static bool pw1_Updated = false;
static bool sv_Updated = false;
static bool tk_Updated = false;
static bool sv1_Updated = false;
static bool tk1_Updated = false;
static bool pt_Updated = false;
static bool nm_Updated = false;

if (!id_Updated && (key == String("id")))
{
id_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.WiFi_Creds[0].wifi_ssid) - 1)
strcpy(BlynkESP32_WM_config.WiFi_Creds[0].wifi_ssid, value.c_str());
else
strncpy(BlynkESP32_WM_config.WiFi_Creds[0].wifi_ssid, value.c_str(), sizeof(BlynkESP32_WM_config.WiFi_Creds[0].wifi_ssid) - 1);
}
else if (key == "pw")
else if (!pw_Updated && (key == String("pw")))
{
BLYNK_LOG2(BLYNK_F("pw = "), value.c_str());

pw_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.WiFi_Creds[0].wifi_pw) - 1)
strcpy(BlynkESP32_WM_config.WiFi_Creds[0].wifi_pw, value.c_str());
else
strncpy(BlynkESP32_WM_config.WiFi_Creds[0].wifi_pw, value.c_str(), sizeof(BlynkESP32_WM_config.WiFi_Creds[0].wifi_pw) - 1);
}

else if (key == "id1")
else if (!id1_Updated && (key == String("id1")))
{
BLYNK_LOG2(BLYNK_F("id1 = "), value.c_str());

id1_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.WiFi_Creds[1].wifi_ssid) - 1)
strcpy(BlynkESP32_WM_config.WiFi_Creds[1].wifi_ssid, value.c_str());
else
strncpy(BlynkESP32_WM_config.WiFi_Creds[1].wifi_ssid, value.c_str(), sizeof(BlynkESP32_WM_config.WiFi_Creds[1].wifi_ssid) - 1);
}
else if (key == "pw1")
else if (!pw1_Updated && (key == String("pw1")))
{
BLYNK_LOG2(BLYNK_F("pw1 = "), value.c_str());

pw1_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.WiFi_Creds[1].wifi_pw) - 1)
strcpy(BlynkESP32_WM_config.WiFi_Creds[1].wifi_pw, value.c_str());
else
strncpy(BlynkESP32_WM_config.WiFi_Creds[1].wifi_pw, value.c_str(), sizeof(BlynkESP32_WM_config.WiFi_Creds[1].wifi_pw) - 1);
}
else if (key == "sv")
else if (!sv_Updated && (key == String("sv")))
{
BLYNK_LOG2(BLYNK_F("sv = "), value.c_str());

sv_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.Blynk_Creds[0].blynk_server) - 1)
strcpy(BlynkESP32_WM_config.Blynk_Creds[0].blynk_server, value.c_str());
else
strncpy(BlynkESP32_WM_config.Blynk_Creds[0].blynk_server, value.c_str(), sizeof(BlynkESP32_WM_config.Blynk_Creds[0].blynk_server) - 1);
}
else if (key == "tk")
else if (!tk_Updated && (key == String("tk")))
{
BLYNK_LOG2(BLYNK_F("tk = "), value.c_str());

tk_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.Blynk_Creds[0].blynk_token) - 1)
strcpy(BlynkESP32_WM_config.Blynk_Creds[0].blynk_token, value.c_str());
else
strncpy(BlynkESP32_WM_config.Blynk_Creds[0].blynk_token, value.c_str(), sizeof(BlynkESP32_WM_config.Blynk_Creds[0].blynk_token) - 1);
}
else if (key == "sv1")
else if (!sv1_Updated && (key == String("sv1")))
{
BLYNK_LOG2(BLYNK_F("sv1 = "), value.c_str());

sv1_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.Blynk_Creds[1].blynk_server) - 1)
strcpy(BlynkESP32_WM_config.Blynk_Creds[1].blynk_server, value.c_str());
else
strncpy(BlynkESP32_WM_config.Blynk_Creds[1].blynk_server, value.c_str(), sizeof(BlynkESP32_WM_config.Blynk_Creds[1].blynk_server) - 1);
}
else if (key == "tk1")
else if (!tk1_Updated && (key == String("tk1")))
{
BLYNK_LOG2(BLYNK_F("tk1 = "), value.c_str());

tk1_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.Blynk_Creds[1].blynk_token) - 1)
strcpy(BlynkESP32_WM_config.Blynk_Creds[1].blynk_token, value.c_str());
else
strncpy(BlynkESP32_WM_config.Blynk_Creds[1].blynk_token, value.c_str(), sizeof(BlynkESP32_WM_config.Blynk_Creds[1].blynk_token) - 1);
}
else if (key == "pt")
else if (!pt_Updated && (key == String("pt")))
{
BLYNK_LOG2(BLYNK_F("pt = "), value.toInt());

pt_Updated = true;
number_items_Updated++;

BlynkESP32_WM_config.blynk_port = value.toInt();
}
else if (key == "nm")
else if (!nm_Updated && (key == String("nm")))
{
BLYNK_LOG2(BLYNK_F("nm = "), value.c_str());

nm_Updated = true;
number_items_Updated++;

if (strlen(value.c_str()) < sizeof(BlynkESP32_WM_config.board_name) - 1)
strcpy(BlynkESP32_WM_config.board_name, value.c_str());
else
Expand All @@ -2136,9 +2172,12 @@ class BlynkWifi
#if USE_DYNAMIC_PARAMETERS
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
if (key == myMenuItems[i].id)
if ( !menuItemUpdated[i] && (key == myMenuItems[i].id) )
{
//BLYNK_LOG4(F("h:"), myMenuItems[i].id, F("="), value.c_str() );
BLYNK_LOG4(BLYNK_F("h:"), myMenuItems[i].id, BLYNK_F("="), value.c_str() );

menuItemUpdated[i] = true;

number_items_Updated++;

// Actual size of pdata is [maxlen + 1]
Expand Down
Loading

0 comments on commit 7480b73

Please sign in to comment.