feat: retry wifi 3 times on provision, reset on fail

This commit is contained in:
2026-05-13 15:26:04 +02:00
parent 3fc50e797d
commit 8f1f91997a
3 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -77,6 +77,7 @@ static void prov_event_handler(void *arg, esp_event_base_t base,
network_prov_wifi_sta_fail_reason_t *reason = (network_prov_wifi_sta_fail_reason_t *)data;
ESP_LOGE(TAG, "Provisioning failed: %s",
(*reason == NETWORK_PROV_WIFI_STA_AUTH_ERROR) ? "auth error" : "AP not found");
network_prov_mgr_reset_wifi_sm_state_on_failure();
break;
}
case NETWORK_PROV_WIFI_CRED_SUCCESS:
@@ -101,8 +102,9 @@ esp_err_t provisioning_run(void)
prov_event_handler, NULL);
network_prov_mgr_config_t config = {
.scheme = network_prov_scheme_ble,
.scheme_event_handler = NETWORK_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM,
.scheme = network_prov_scheme_ble,
.scheme_event_handler = NETWORK_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM,
.network_prov_wifi_conn_cfg = { .wifi_conn_attempts = 3 },
};
ESP_ERROR_CHECK(network_prov_mgr_init(config));
+1 -1
View File
@@ -174,7 +174,7 @@ void app_main(void)
ble_scanner_start();
led_indicator_set(LED_SCANNING);
ESP_LOGI(TAG, "Anchor running scanning BLE and publishing RSSI");
ESP_LOGI(TAG, "Anchor running - scanning BLE and publishing RSSI");
// main event loop
const EventBits_t cmd_bits =
+1
View File
@@ -6,6 +6,7 @@ CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# WiFi
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
CONFIG_NETWORK_PROV_WIFI_STA_ALL_CHANNEL_SCAN=y
# MQTT
CONFIG_MQTT_BUFFER_SIZE=512