From f9f2ec65227bbcc69a3c72e02c0731b229f433a0 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Tue, 23 Nov 2021 16:37:48 +0800 Subject: [PATCH] Fix AP randomly do not set IP Decrease AP workload by disabling gateway --- esp3d/src/include/version.h | 2 +- esp3d/src/modules/wifi/wificonfig.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 0e97b0ce..a0952d5d 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a107" +#define FW_VERSION "3.0.0.a108" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/wifi/wificonfig.cpp b/esp3d/src/modules/wifi/wificonfig.cpp index 1455a3d6..669df610 100644 --- a/esp3d/src/modules/wifi/wificonfig.cpp +++ b/esp3d/src/modules/wifi/wificonfig.cpp @@ -251,14 +251,8 @@ bool WiFiConfig::StartAP() //IP int32_t IP = Settings_ESP3D::read_IP(ESP_AP_IP_VALUE); IPAddress ip(IP); + IPAddress gw(0,0,0,0); IPAddress mask(DEFAULT_AP_MASK_VALUE); - //Set static IP - log_esp3d("Use: %s / %s / %s", ip.toString().c_str(),ip.toString().c_str(),mask.toString().c_str()); - if (!WiFi.softAPConfig(ip, ip, mask)) { - output.printERROR("Set IP to AP failed"); - } else { - output.printMSG(ip.toString().c_str()); - } //Start AP if(WiFi.softAP(SSID.c_str(), (password.length() > 0)?password.c_str():nullptr, channel)) { String stmp = "AP SSID: '" + SSID; @@ -270,6 +264,14 @@ bool WiFiConfig::StartAP() output.printMSG(stmp.c_str()); log_esp3d("%s",stmp.c_str()); //must be done after starting AP not before + Hal::wait(100); + //Set static IP + log_esp3d("Use: %s / %s / %s", ip.toString().c_str(),ip.toString().c_str(),mask.toString().c_str()); + if (!WiFi.softAPConfig(ip, gw, mask)) { + output.printERROR("Set IP to AP failed"); + } else { + output.printMSG(ip.toString().c_str()); + } #if defined (ARDUINO_ARCH_ESP32) WiFi.setSleep(false); WiFi.softAPsetHostname(NetConfig::hostname(true));