Merge branch 'task/wifi-prov-retries' into 'master'

app_network: Use new wifi retry count field for better resilience in poor network conditions

See merge request app-frameworks/esp-rainmaker!590
This commit is contained in:
Piyush Shah
2025-11-12 18:08:19 +05:30
4 changed files with 33 additions and 16 deletions

View File

@@ -1,5 +1,20 @@
# Changelog
## 1.7.8
## Changes
- Make version dependency for network_provisioning more flexible
## 1.7.7
### New Feature
- Added AWS credential provider APIs, required for RainMaker Camera applications.
## 1.7.6
## Changes
- Disabled esp_bt code from ota code for supporting esp32-p4, which uses network adapters for Bluetooth.
## 1.7.5
### Bug Fixes

View File

@@ -1,5 +1,5 @@
## IDF Component Manager Manifest File
version: "1.7.7"
version: "1.7.8"
description: ESP RainMaker firmware agent
url: https://github.com/espressif/esp-rainmaker/tree/master/components/esp_rainmaker
repository: https://github.com/espressif/esp-rainmaker.git
@@ -21,7 +21,7 @@ dependencies:
espressif/esp_schedule:
version: "~1.3.2"
espressif/network_provisioning:
version: "~1.0.0"
version: ">=1.*"
espressif/esp_rcp_update:
# This allows all the minor version updates
version: "^1.2.0"

View File

@@ -36,10 +36,6 @@ static const char* TAG = "app_wifi";
static void event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
#ifdef CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
static int retries = 0;
#endif
if (event_base == NETWORK_PROV_EVENT) {
switch (event_id) {
case NETWORK_PROV_START:
@@ -60,21 +56,20 @@ static void event_handler(void* arg, esp_event_base_t event_base,
(*reason == NETWORK_PROV_WIFI_STA_AUTH_ERROR) ?
"Wi-Fi station authentication failed" : "Wi-Fi access-point not found");
#ifdef CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
retries++;
if (retries >= CONFIG_APP_NETWORK_PROV_MAX_RETRY_CNT) {
ESP_LOGI(TAG, "Failed to connect with provisioned AP, reseting provisioned credentials");
network_prov_mgr_reset_wifi_sm_state_on_failure();
esp_event_post(APP_NETWORK_EVENT, APP_NETWORK_EVENT_PROV_RESTART, NULL, 0, portMAX_DELAY);
retries = 0;
}
/* Reset the state machine on provisioning failure.
* This is enabled by the CONFIG_EXAMPLE_RESET_PROV_MGR_ON_FAILURE configuration.
* It allows the provisioning manager to retry the provisioning process
* based on the number of attempts specified in wifi_conn_attempts. After attempting
* the maximum number of retries, the provisioning manager will reset the state machine
* and the provisioning process will be terminated.
*/
ESP_LOGI(TAG, "Failed to connect with provisioned AP, reseting provisioned credentials");
network_prov_mgr_reset_wifi_sm_state_on_failure();
#endif // CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
break;
}
case NETWORK_PROV_WIFI_CRED_SUCCESS:
ESP_LOGI(TAG, "Provisioning successful");
#ifdef CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
retries = 0;
#endif
break;
default:
break;
@@ -120,6 +115,11 @@ esp_err_t app_wifi_internal_start(const char *pop, const char *service_name,
#ifdef CONFIG_ESP_RMAKER_NETWORK_OVER_WIFI
/* Configuration for the provisioning manager */
network_prov_mgr_config_t config = {
#ifdef CONFIG_APP_NETWORK_RESET_PROV_ON_FAILURE
.network_prov_wifi_conn_cfg = {
.wifi_conn_attempts = CONFIG_APP_NETWORK_PROV_MAX_RETRY_CNT,
},
#endif
/* What is the Provisioning Scheme that we want ?
* network_prov_scheme_softap or network_prov_scheme_ble */
#ifdef CONFIG_APP_NETWORK_PROV_TRANSPORT_BLE

View File

@@ -2,3 +2,5 @@
dependencies:
espressif/qrcode:
version: "*"
espressif/network_provisioning:
version: "~1.2.0"