reconnect after wifi change maybe
This commit is contained in:
@@ -37,7 +37,7 @@ static int cmd_set(console_ctx_t *ctx, cmd_signature_t *reg)
|
||||
return CONSOLE_OK;
|
||||
}
|
||||
|
||||
strncpy(g_Settings.console_pw, args.pw->sval[0], CONSOLE_PW_LEN);
|
||||
strncpy(g_Settings.console_pw, args.pw->sval[0], CONSOLE_PW_LEN-1);
|
||||
console_printf("Access pw set to: \"%.*s\"\n", CONSOLE_PW_LEN, args.pw->sval[0]);
|
||||
settings_persist(SETTINGS_console_pw);
|
||||
return 0;
|
||||
|
||||
@@ -228,9 +228,9 @@ static int cmd_sta_forget(console_ctx_t *ctx, cmd_signature_t *reg)
|
||||
static bool wifi_join(const char* ssid, const char* pass, int timeout_ms)
|
||||
{
|
||||
wifi_config_t wifi_config = {};
|
||||
strncpy((char*) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid));
|
||||
strncpy((char*) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid)-1);
|
||||
if (pass) {
|
||||
strncpy((char*) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password));
|
||||
strncpy((char*) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password) - 1);
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@
|
||||
#include "application.h"
|
||||
#include "dhcp_wd.h"
|
||||
|
||||
#define WIFI_MAX_RETRY 5
|
||||
//#define WIFI_MAX_RETRY 5
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected*/
|
||||
EventGroupHandle_t g_wifi_event_group;
|
||||
@@ -36,13 +36,13 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
dhcp_watchdog_notify(dhcp_wd, DHCP_WD_NOTIFY_DISCONNECTED);
|
||||
}
|
||||
|
||||
if (s_retry_num < WIFI_MAX_RETRY) {
|
||||
// if (s_retry_num < WIFI_MAX_RETRY) {
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "Retry to connect (try %d)", s_retry_num+1);
|
||||
} else {
|
||||
xEventGroupSetBits(g_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
// } else {
|
||||
// xEventGroupSetBits(g_wifi_event_group, WIFI_FAIL_BIT);
|
||||
// }
|
||||
} else if (event_base == IP_EVENT && event_id == WIFI_EVENT_STA_CONNECTED) {
|
||||
if (dhcp_wd) {
|
||||
dhcp_watchdog_notify(dhcp_wd, DHCP_WD_NOTIFY_CONNECTED);
|
||||
|
||||
Reference in New Issue
Block a user