Add new Setup Mode and new AP mode, fixes #715

This commit is contained in:
Luc 2022-02-06 17:43:11 +08:00
parent c8f7f4dee4
commit a4609aee69
16 changed files with 104 additions and 86 deletions

View File

@ -31,7 +31,7 @@ const char * help[]= {"[ESP] - display this help",
"[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW", "[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW",
#endif //WIFI_FEATURE || ETH_FEATURE #endif //WIFI_FEATURE || ETH_FEATURE
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE) #if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
"[ESP104](State) - display/set sta fallback mode which can be BT, AP, OFF", "[ESP104](State) - display/set sta fallback mode which can be BT, SETUP, OFF",
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE #endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
#if defined (WIFI_FEATURE) #if defined (WIFI_FEATURE)
"[ESP105](SSID) - display/set AP SSID", "[ESP105](SSID) - display/set AP SSID",
@ -40,7 +40,7 @@ const char * help[]= {"[ESP] - display this help",
"[ESP108](Chanel) - display/set AP chanel", "[ESP108](Chanel) - display/set AP chanel",
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE) #if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
"[ESP110](State) - display/set radio state which can be BT, WIFI-STA, WIFI-AP, ETH-STA, OFF", "[ESP110](State) - display/set radio state which can be BT, WIFI-STA, WIFI-AP, WIFI-SETUP, ETH-STA, OFF",
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE #endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
#if defined( WIFI_FEATURE) || defined (ETH_FEATURE) #if defined( WIFI_FEATURE) || defined (ETH_FEATURE)
"[ESP111](header)display current IP", "[ESP111](header)display current IP",

View File

@ -46,8 +46,8 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
output->printMSG("OFF"); output->printMSG("OFF");
} else if (wifiMode == ESP_BT) { } else if (wifiMode == ESP_BT) {
output->printMSG("BT"); output->printMSG("BT");
} else if (wifiMode == ESP_WIFI_AP) { } else if (wifiMode == ESP_AP_SETUP) {
output->printMSG("WIFI-AP"); output->printMSG("WIFI-SETUP");
} else { } else {
output->printMSG("??"); output->printMSG("??");
} }
@ -64,7 +64,7 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
(parameter == "BT") || (parameter == "BT") ||
#endif //BLUETOOTH_FEATURE #endif //BLUETOOTH_FEATURE
#if defined( WIFI_FEATURE) #if defined( WIFI_FEATURE)
(parameter == "WIFI-AP") || (parameter == "WIFI-SETUP") ||
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#if defined( ETH_FEATURE) #if defined( ETH_FEATURE)
(parameter == "ETH-STA") || //(parameter == "ETH-SRV") || (parameter == "ETH-STA") || //(parameter == "ETH-SRV") ||
@ -76,7 +76,7 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
"BT or " "BT or "
#endif //BLUETOOTH_FEATURE #endif //BLUETOOTH_FEATURE
#ifdef WIFI_FEATURE #ifdef WIFI_FEATURE
"WIFI-AP or " "WIFI-SETUP or "
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
"OFF mode supported!"); "OFF mode supported!");
return false; return false;
@ -84,8 +84,8 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
int8_t bbuf = ESP_NO_NETWORK; int8_t bbuf = ESP_NO_NETWORK;
#ifdef WIFI_FEATURE #ifdef WIFI_FEATURE
if(parameter == "WIFI-AP") { if(parameter == "WIFI-SETUP") {
bbuf = ESP_WIFI_AP; bbuf = ESP_AP_SETUP;
} }
#endif //WIFI_FEATURE #endif //WIFI_FEATURE

View File

@ -54,6 +54,8 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
// output->printMSG("ETH-SRV"); // output->printMSG("ETH-SRV");
} else if (wifiMode == ESP_ETH_STA) { } else if (wifiMode == ESP_ETH_STA) {
output->printMSG("ETH-STA"); output->printMSG("ETH-STA");
} else if (wifiMode == ESP_AP_SETUP) {
output->printMSG("WIFI-SETUP");
} else { } else {
output->printMSG("??"); output->printMSG("??");
} }
@ -70,7 +72,7 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
(parameter == "BT") || (parameter == "BT") ||
#endif //BLUETOOTH_FEATURE #endif //BLUETOOTH_FEATURE
#if defined( WIFI_FEATURE) #if defined( WIFI_FEATURE)
(parameter == "WIFI-STA") || (parameter == "WIFI-AP") || (parameter == "WIFI-STA") || (parameter == "WIFI-AP") || (parameter == "WIFI-SETUP") ||
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#if defined( ETH_FEATURE) #if defined( ETH_FEATURE)
(parameter == "ETH-STA") || //(parameter == "ETH-SRV") || (parameter == "ETH-STA") || //(parameter == "ETH-SRV") ||
@ -82,7 +84,7 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
"BT or " "BT or "
#endif //BLUETOOTH_FEATURE #endif //BLUETOOTH_FEATURE
#ifdef WIFI_FEATURE #ifdef WIFI_FEATURE
"WIFI-STA or WIFI-AP or " "WIFI-STA or WIFI-AP or WIFI-SETUP or "
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#ifdef ETH_FEATURE #ifdef ETH_FEATURE
"ETH-STA or " "ETH-STA or "
@ -99,6 +101,9 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
if(parameter == "WIFI-AP") { if(parameter == "WIFI-AP") {
bbuf = ESP_WIFI_AP; bbuf = ESP_WIFI_AP;
} }
if(parameter == "WIFI-SETUP") {
bbuf = ESP_AP_SETUP;
}
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#ifdef ETH_FEATURE #ifdef ETH_FEATURE
if(parameter == "ETH-STA") { if(parameter == "ETH-STA") {

View File

@ -62,7 +62,7 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
output->print (Settings_ESP3D::read_byte(ESP_RADIO_MODE)); output->print (Settings_ESP3D::read_byte(ESP_RADIO_MODE));
output->print ("\",\"H\":\"radio mode\",\"O\":[{\"none\":\"0\"}"); output->print ("\",\"H\":\"radio mode\",\"O\":[{\"none\":\"0\"}");
#ifdef WIFI_FEATURE #ifdef WIFI_FEATURE
output->print (",{\"sta\":\"1\"},{\"ap\":\"2\"}"); output->print (",{\"sta\":\"1\"},{\"ap\":\"2\"},{\"setup\":\"5\"}");
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#ifdef BLUETOOTH_FEATURE #ifdef BLUETOOTH_FEATURE
output->print (",{\"bt\":\"3\"}"); output->print (",{\"bt\":\"3\"}");
@ -147,7 +147,7 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
output->print (Settings_ESP3D::read_byte(ESP_STA_FALLBACK_MODE)); output->print (Settings_ESP3D::read_byte(ESP_STA_FALLBACK_MODE));
output->print ("\",\"H\":\"sta fallback mode\",\"O\":[{\"none\":\"0\"}"); output->print ("\",\"H\":\"sta fallback mode\",\"O\":[{\"none\":\"0\"}");
#ifdef WIFI_FEATURE #ifdef WIFI_FEATURE
output->print (",{\"ap\":\"2\"}"); output->print (",{\"setup\":\"5\"}");
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#ifdef BLUETOOTH_FEATURE #ifdef BLUETOOTH_FEATURE
output->print (",{\"bt\":\"3\"}"); output->print (",{\"bt\":\"3\"}");

View File

@ -67,7 +67,7 @@
#if defined(STATION_WIFI_SSID) && defined(STATION_WIFI_PASSWORD) #if defined(STATION_WIFI_SSID) && defined(STATION_WIFI_PASSWORD)
#define DEFAULT_ESP_RADIO_MODE ESP_WIFI_STA #define DEFAULT_ESP_RADIO_MODE ESP_WIFI_STA
#else #else
#define DEFAULT_ESP_RADIO_MODE ESP_WIFI_AP #define DEFAULT_ESP_RADIO_MODE ESP_AP_SETUP
#endif //STATION_WIFI_SSID && STATION_WIFI_PASSWORD #endif //STATION_WIFI_SSID && STATION_WIFI_PASSWORD
#else //WIFI_FEATURE #else //WIFI_FEATURE
#define DEFAULT_STA_FALLBACK_MODE ESP_NO_NETWORK #define DEFAULT_STA_FALLBACK_MODE ESP_NO_NETWORK

View File

@ -77,6 +77,7 @@
#define ESP_WIFI_AP 2 #define ESP_WIFI_AP 2
#define ESP_BT 3 #define ESP_BT 3
#define ESP_ETH_STA 4 #define ESP_ETH_STA 4
#define ESP_AP_SETUP 5
//#define ESP_ETH_SRV 5 //#define ESP_ETH_SRV 5
//SD mount point //SD mount point

View File

@ -22,7 +22,7 @@
#define _VERSION_ESP3D_H #define _VERSION_ESP3D_H
//version and sources location //version and sources location
#define FW_VERSION "3.0.0.a109" #define FW_VERSION "3.0.0.a110"
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
#endif //_VERSION_ESP3D_H #endif //_VERSION_ESP3D_H

View File

@ -319,6 +319,7 @@ bool Display::display_IP(bool force)
case ESP_WIFI_STA: case ESP_WIFI_STA:
s = WiFi.localIP().toString(); s = WiFi.localIP().toString();
break; break;
case ESP_AP_SETUP:
case ESP_WIFI_AP: case ESP_WIFI_AP:
s = WiFi.softAPIP().toString(); s = WiFi.softAPIP().toString();
break; break;

View File

@ -30,6 +30,7 @@
#endif //ARDUINO_ARCH_ESP8266 #endif //ARDUINO_ARCH_ESP8266
#include "http_server.h" #include "http_server.h"
#include "../authentication/authentication_service.h" #include "../authentication/authentication_service.h"
#include "../network/netconfig.h"
#include "../../core/settings_esp3d.h" #include "../../core/settings_esp3d.h"
#include "../filesystem/esp_filesystem.h" #include "../filesystem/esp_filesystem.h"
#include "../websocket/websocket_server.h" #include "../websocket/websocket_server.h"
@ -79,7 +80,7 @@ void HTTP_Server::init_handlers()
} }
#endif //SSDP_FEATURE #endif //SSDP_FEATURE
#ifdef CAPTIVE_PORTAL_FEATURE #ifdef CAPTIVE_PORTAL_FEATURE
if(WiFi.getMode() == WIFI_AP) { if(NetConfig::getMode() == ESP_AP_SETUP) {
_webserver->on ("/generate_204", HTTP_ANY, handle_root); _webserver->on ("/generate_204", HTTP_ANY, handle_root);
_webserver->on ("/gconnectivitycheck.gstatic.com", HTTP_ANY, handle_root); _webserver->on ("/gconnectivitycheck.gstatic.com", HTTP_ANY, handle_root);
//do not forget the / at the end //do not forget the / at the end

View File

@ -627,8 +627,8 @@ bool MKSService::sendNetworkFrame()
//Wifi_key Segment //Wifi_key Segment
strcpy((char *)&_frame[dataOffset], s.c_str()); strcpy((char *)&_frame[dataOffset], s.c_str());
dataOffset+=s.length(); dataOffset+=s.length();
} else if (NetConfig::getMode() == ESP_WIFI_AP) { } else if (NetConfig::getMode() == ESP_WIFI_AP || (NetConfig::getMode() == ESP_AP_SETUP) {
log_esp3d("AP Mode"); log_esp3d("AP Mode");
/////////////////////////////////// ///////////////////////////////////
//IP Segment //IP Segment
//IP value //IP value
@ -671,61 +671,61 @@ bool MKSService::sendNetworkFrame()
//Cloud Services port Segment //Cloud Services port Segment
//hard coded //hard coded
_frame[MKS_FRAME_DATA_OFFSET +4] = (telnet_server.port()) & 0xff; _frame[MKS_FRAME_DATA_OFFSET +4] = (telnet_server.port()) & 0xff;
_frame[MKS_FRAME_DATA_OFFSET +5] = ((telnet_server.port()) >> 8 ) & 0xff; _frame[MKS_FRAME_DATA_OFFSET +5] = ((telnet_server.port()) >> 8 ) & 0xff;
log_esp3d("Cloud port: %d", (telnet_server.port())); log_esp3d("Cloud port: %d", (telnet_server.port()));
////////////////////////////////// //////////////////////////////////
//Cloud State Segment //Cloud State Segment
//hard coded as disabled in upstream FW //hard coded as disabled in upstream FW
_frame[dataOffset] = MKS_FRAME_CLOUD_DISABLED_STATE; _frame[dataOffset] = MKS_FRAME_CLOUD_DISABLED_STATE;
dataOffset++; dataOffset++;
////////////////////////////////// //////////////////////////////////
//Cloud host len Segment //Cloud host len Segment
//Use ESP3D IP instead //Use ESP3D IP instead
s = NetConfig::localIPAddress().toString(); s = NetConfig::localIPAddress().toString();
_frame[dataOffset] = s.length(); _frame[dataOffset] = s.length();
dataOffset++; dataOffset++;
////////////////////////////////// //////////////////////////////////
//Cloud host Segment //Cloud host Segment
//Use ESP3D IP instead //Use ESP3D IP instead
strcpy((char *)&_frame[dataOffset], s.c_str()); strcpy((char *)&_frame[dataOffset], s.c_str());
dataOffset+=s.length(); dataOffset+=s.length();
////////////////////////////////// //////////////////////////////////
//Cloud host port Segment //Cloud host port Segment
//use webserver port instead //use webserver port instead
_frame[dataOffset] = (HTTP_Server::port()) & 0xff; _frame[dataOffset] = (HTTP_Server::port()) & 0xff;
dataOffset++; dataOffset++;
_frame[dataOffset] = ((HTTP_Server::port())>> 8 ) & 0xff; _frame[dataOffset] = ((HTTP_Server::port())>> 8 ) & 0xff;
dataOffset++; dataOffset++;
////////////////////////////////// //////////////////////////////////
//Module id len Segment //Module id len Segment
//Use hostname instead //Use hostname instead
_frame[dataOffset] = strlen(_moduleId); _frame[dataOffset] = strlen(_moduleId);
dataOffset++; dataOffset++;
////////////////////////////////// //////////////////////////////////
//Module id Segment //Module id Segment
strcpy((char *)&_frame[dataOffset], _moduleId); strcpy((char *)&_frame[dataOffset], _moduleId);
dataOffset+=strlen(_moduleId); dataOffset+=strlen(_moduleId);
////////////////////////////////// //////////////////////////////////
//FW version len Segment //FW version len Segment
_frame[dataOffset] = strlen(FW_VERSION)+6; _frame[dataOffset] = strlen(FW_VERSION)+6;
dataOffset++; dataOffset++;
////////////////////////////////// //////////////////////////////////
//FW version Segment //FW version Segment
strcpy((char *)&_frame[dataOffset], "ESP3D_" FW_VERSION); strcpy((char *)&_frame[dataOffset], "ESP3D_" FW_VERSION);
dataOffset+=strlen(FW_VERSION)+6; dataOffset+=strlen(FW_VERSION)+6;
////////////////////////////////// //////////////////////////////////
//Tail Segment //Tail Segment
_frame[dataOffset] = MKS_FRAME_TAIL_FLAG; _frame[dataOffset] = MKS_FRAME_TAIL_FLAG;
////////////////////////////////// //////////////////////////////////
//Data len Segment //Data len Segment
//Calculated from above //Calculated from above
_frame[MKS_FRAME_DATALEN_OFFSET] = (dataOffset-4) & 0xff; _frame[MKS_FRAME_DATALEN_OFFSET] = (dataOffset-4) & 0xff;
_frame[MKS_FRAME_DATALEN_OFFSET+1] = ((dataOffset-4) >> 8) & 0xff; _frame[MKS_FRAME_DATALEN_OFFSET+1] = ((dataOffset-4) >> 8) & 0xff;
log_esp3d("Size of data in frame %d ", dataOffset-4); log_esp3d("Size of data in frame %d ", dataOffset-4);
if (canSendFrame()) { if (canSendFrame()) {
ESP3DOutput output(ESP_SERIAL_CLIENT); ESP3DOutput output(ESP_SERIAL_CLIENT);
if (output.write(_frame,dataOffset+1) == (dataOffset+1)) { if (output.write(_frame,dataOffset+1) == (dataOffset+1)) {
log_esp3d("Ok"); log_esp3d("Ok");
sendFrameDone(); sendFrameDone();

View File

@ -221,6 +221,11 @@ void NetConfig::onWiFiEvent(WiFiEvent_t event)
} }
} }
void NetConfig::setMode(uint8_t mode)
{
_mode=mode;
}
uint8_t NetConfig::getMode() uint8_t NetConfig::getMode()
{ {
return _mode; return _mode;
@ -272,11 +277,9 @@ bool NetConfig::begin()
return true; return true;
} }
#if defined (WIFI_FEATURE) #if defined (WIFI_FEATURE)
if ((espMode == ESP_WIFI_AP) || (espMode == ESP_WIFI_STA)) { if ((espMode == ESP_AP_SETUP) || (espMode == ESP_WIFI_AP) || (espMode == ESP_WIFI_STA)) {
output.printMSG("Setup wifi"); output.printMSG("Setup wifi");
res = WiFiConfig::begin(espMode); res = WiFiConfig::begin(espMode);
//in case STA failed and fallback to AP mode
_mode = ESP_WIFI_AP;
} }
#endif //WIFI_FEATURE #endif //WIFI_FEATURE
#if defined (ETH_FEATURE) #if defined (ETH_FEATURE)

View File

@ -61,6 +61,7 @@ public:
static void end(); static void end();
static void handle(); static void handle();
static uint8_t getMode(); static uint8_t getMode();
static void setMode(uint8_t mode);
static bool started() static bool started()
{ {
return _started; return _started;

View File

@ -192,7 +192,7 @@ bool NetServices::begin()
#endif //MDNS_FEATURE && ARDUINO_ARCH_ESP8266 #endif //MDNS_FEATURE && ARDUINO_ARCH_ESP8266
#ifdef CAPTIVE_PORTAL_FEATURE #ifdef CAPTIVE_PORTAL_FEATURE
if(WiFi.getMode() == WIFI_AP) { if(NetConfig::getMode() == ESP_AP_SETUP) {
// if DNSServer is started with "*" for domain name, it will reply with // if DNSServer is started with "*" for domain name, it will reply with
// provided IP to all DNS request // provided IP to all DNS request
if (dnsServer.start(DNS_PORT, "*", WiFi.softAPIP())) { if (dnsServer.start(DNS_PORT, "*", WiFi.softAPIP())) {
@ -349,7 +349,7 @@ void NetServices::end()
notificationsservice.end(); notificationsservice.end();
#endif //NOTIFICATION_FEATURE #endif //NOTIFICATION_FEATURE
#ifdef CAPTIVE_PORTAL_FEATURE #ifdef CAPTIVE_PORTAL_FEATURE
if(WiFi.getMode() == WIFI_AP) { if(NetConfig::getMode() == ESP_AP_SETUP) {
dnsServer.stop(); dnsServer.stop();
} }
#endif //CAPTIVE_PORTAL_FEATURE #endif //CAPTIVE_PORTAL_FEATURE
@ -421,7 +421,7 @@ void NetServices::handle()
ArduinoOTA.handle(); ArduinoOTA.handle();
#endif //OTA_FEATURE #endif //OTA_FEATURE
#ifdef CAPTIVE_PORTAL_FEATURE #ifdef CAPTIVE_PORTAL_FEATURE
if (WiFi.getMode()== WIFI_AP ) { if (NetConfig::getMode() == ESP_AP_SETUP) {
dnsServer.processNextRequest(); dnsServer.processNextRequest();
} }
#endif //CAPTIVE_PORTAL_FEATURE #endif //CAPTIVE_PORTAL_FEATURE

View File

@ -273,6 +273,8 @@ bool processingFileFunction (const char * section, const char * key, const char
b=ESP_WIFI_STA; b=ESP_WIFI_STA;
} else if (strcasecmp("WIFI-AP",value)==0) { } else if (strcasecmp("WIFI-AP",value)==0) {
b=ESP_WIFI_AP; b=ESP_WIFI_AP;
} else if (strcasecmp("WIFI-SETUP",value)==0) {
b=ESP_AP_SETUP;
} else if (strcasecmp("ETH-STA",value)==0) { } else if (strcasecmp("ETH-STA",value)==0) {
b=ESP_ETH_STA; b=ESP_ETH_STA;
} else if (strcasecmp("OFF",value)==0) { } else if (strcasecmp("OFF",value)==0) {
@ -290,8 +292,8 @@ bool processingFileFunction (const char * section, const char * key, const char
done = true; done = true;
if (strcasecmp("BT",value)==0) { if (strcasecmp("BT",value)==0) {
b=ESP_BT; b=ESP_BT;
} else if (strcasecmp("WIFI-AP",value)==0) { } else if (strcasecmp("WIFI-SETUP",value)==0) {
b=ESP_WIFI_AP; b=ESP_AP_SETUP;
} else if (strcasecmp("OFF",value)==0) { } else if (strcasecmp("OFF",value)==0) {
b=ESP_NO_NETWORK; b=ESP_NO_NETWORK;
} else { } else {

View File

@ -224,7 +224,7 @@ bool WiFiConfig::StartSTA()
* Setup and start Access point * Setup and start Access point
*/ */
bool WiFiConfig::StartAP() bool WiFiConfig::StartAP(bool setupMode)
{ {
ESP3DOutput output(ESP_ALL_CLIENTS); ESP3DOutput output(ESP_ALL_CLIENTS);
//Sanity check //Sanity check
@ -259,7 +259,10 @@ bool WiFiConfig::StartAP()
if (password.length() > 0) { if (password.length() > 0) {
stmp +="' is started and protected by password"; stmp +="' is started and protected by password";
} else { } else {
stmp +=" is started not protected by passord"; stmp +=" is started not protected by password";
}
if (setupMode) {
stmp += " (setup mode)";
} }
output.printMSG(stmp.c_str()); output.printMSG(stmp.c_str());
log_esp3d("%s",stmp.c_str()); log_esp3d("%s",stmp.c_str());
@ -267,7 +270,7 @@ bool WiFiConfig::StartAP()
Hal::wait(100); Hal::wait(100);
//Set static IP //Set static IP
log_esp3d("Use: %s / %s / %s", ip.toString().c_str(),ip.toString().c_str(),mask.toString().c_str()); log_esp3d("Use: %s / %s / %s", ip.toString().c_str(),ip.toString().c_str(),mask.toString().c_str());
if (!WiFi.softAPConfig(ip, gw, mask)) { if (!WiFi.softAPConfig(ip, setupMode?ip:gw, mask)) {
output.printERROR("Set IP to AP failed"); output.printERROR("Set IP to AP failed");
} else { } else {
output.printMSG(ip.toString().c_str()); output.printMSG(ip.toString().c_str());
@ -302,9 +305,9 @@ bool WiFiConfig::begin(int8_t & espMode)
output.printMSG("Starting WiFi"); output.printMSG("Starting WiFi");
} }
int8_t wifiMode = espMode; int8_t wifiMode = espMode;
if (wifiMode == ESP_WIFI_AP) { if (wifiMode == ESP_WIFI_AP || wifiMode == ESP_AP_SETUP) {
log_esp3d("Starting AP mode"); log_esp3d("Starting AP mode");
res = StartAP(); res = StartAP(wifiMode == ESP_AP_SETUP);
} else if (wifiMode == ESP_WIFI_STA) { } else if (wifiMode == ESP_WIFI_STA) {
log_esp3d("Starting STA"); log_esp3d("Starting STA");
res = StartSTA(); res = StartSTA();
@ -314,9 +317,10 @@ bool WiFiConfig::begin(int8_t & espMode)
output.printMSG("Starting fallback mode"); output.printMSG("Starting fallback mode");
} }
espMode = Settings_ESP3D::read_byte(ESP_STA_FALLBACK_MODE); espMode = Settings_ESP3D::read_byte(ESP_STA_FALLBACK_MODE);
if (espMode == ESP_WIFI_AP) { NetConfig::setMode(espMode);
log_esp3d("Starting AP mode in safe mode"); if (espMode == ESP_AP_SETUP) {
res = StartAP(); log_esp3d("Starting AP mode in setup mode");
res = StartAP(true);
} else { } else {
//let setup to handle the change //let setup to handle the change
res = true; res = true;

View File

@ -56,7 +56,7 @@ class WiFiConfig
public: public:
static bool isPasswordValid (const char * password); static bool isPasswordValid (const char * password);
static bool isSSIDValid (const char * ssid); static bool isSSIDValid (const char * ssid);
static bool StartAP(); static bool StartAP(bool setupMode = false);
static bool StartSTA(); static bool StartSTA();
static void StopWiFi(); static void StopWiFi();
static int32_t getSignal (int32_t RSSI); static int32_t getSignal (int32_t RSSI);