Skip to content

Commit a4609ae

Browse files
committed
Add new Setup Mode and new AP mode, fixes #715
1 parent c8f7f4d commit a4609ae

File tree

16 files changed

+106
-88
lines changed

16 files changed

+106
-88
lines changed

esp3d/src/core/espcmd/ESP0.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const char * help[]= {"[ESP] - display this help",
3131
"[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW",
3232
#endif //WIFI_FEATURE || ETH_FEATURE
3333
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
34-
"[ESP104](State) - display/set sta fallback mode which can be BT, AP, OFF",
34+
"[ESP104](State) - display/set sta fallback mode which can be BT, SETUP, OFF",
3535
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
3636
#if defined (WIFI_FEATURE)
3737
"[ESP105](SSID) - display/set AP SSID",
@@ -40,7 +40,7 @@ const char * help[]= {"[ESP] - display this help",
4040
"[ESP108](Chanel) - display/set AP chanel",
4141
#endif //WIFI_FEATURE
4242
#if defined( WIFI_FEATURE) || defined( BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
43-
"[ESP110](State) - display/set radio state which can be BT, WIFI-STA, WIFI-AP, ETH-STA, OFF",
43+
"[ESP110](State) - display/set radio state which can be BT, WIFI-STA, WIFI-AP, WIFI-SETUP, ETH-STA, OFF",
4444
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
4545
#if defined( WIFI_FEATURE) || defined (ETH_FEATURE)
4646
"[ESP111](header)display current IP",

esp3d/src/core/espcmd/ESP104.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
4646
output->printMSG("OFF");
4747
} else if (wifiMode == ESP_BT) {
4848
output->printMSG("BT");
49-
} else if (wifiMode == ESP_WIFI_AP) {
50-
output->printMSG("WIFI-AP");
49+
} else if (wifiMode == ESP_AP_SETUP) {
50+
output->printMSG("WIFI-SETUP");
5151
} else {
5252
output->printMSG("??");
5353
}
@@ -64,7 +64,7 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
6464
(parameter == "BT") ||
6565
#endif //BLUETOOTH_FEATURE
6666
#if defined( WIFI_FEATURE)
67-
(parameter == "WIFI-AP") ||
67+
(parameter == "WIFI-SETUP") ||
6868
#endif //WIFI_FEATURE
6969
#if defined( ETH_FEATURE)
7070
(parameter == "ETH-STA") || //(parameter == "ETH-SRV") ||
@@ -76,16 +76,16 @@ bool Commands::ESP104(const char* cmd_params, level_authenticate_type auth_type,
7676
"BT or "
7777
#endif //BLUETOOTH_FEATURE
7878
#ifdef WIFI_FEATURE
79-
"WIFI-AP or "
79+
"WIFI-SETUP or "
8080
#endif //WIFI_FEATURE
8181
"OFF mode supported!");
8282
return false;
8383
}
8484

8585
int8_t bbuf = ESP_NO_NETWORK;
8686
#ifdef WIFI_FEATURE
87-
if(parameter == "WIFI-AP") {
88-
bbuf = ESP_WIFI_AP;
87+
if(parameter == "WIFI-SETUP") {
88+
bbuf = ESP_AP_SETUP;
8989
}
9090
#endif //WIFI_FEATURE
9191

esp3d/src/core/espcmd/ESP110.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
5454
// output->printMSG("ETH-SRV");
5555
} else if (wifiMode == ESP_ETH_STA) {
5656
output->printMSG("ETH-STA");
57+
} else if (wifiMode == ESP_AP_SETUP) {
58+
output->printMSG("WIFI-SETUP");
5759
} else {
5860
output->printMSG("??");
5961
}
@@ -70,7 +72,7 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
7072
(parameter == "BT") ||
7173
#endif //BLUETOOTH_FEATURE
7274
#if defined( WIFI_FEATURE)
73-
(parameter == "WIFI-STA") || (parameter == "WIFI-AP") ||
75+
(parameter == "WIFI-STA") || (parameter == "WIFI-AP") || (parameter == "WIFI-SETUP") ||
7476
#endif //WIFI_FEATURE
7577
#if defined( ETH_FEATURE)
7678
(parameter == "ETH-STA") || //(parameter == "ETH-SRV") ||
@@ -82,7 +84,7 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
8284
"BT or "
8385
#endif //BLUETOOTH_FEATURE
8486
#ifdef WIFI_FEATURE
85-
"WIFI-STA or WIFI-AP or "
87+
"WIFI-STA or WIFI-AP or WIFI-SETUP or "
8688
#endif //WIFI_FEATURE
8789
#ifdef ETH_FEATURE
8890
"ETH-STA or "
@@ -99,6 +101,9 @@ bool Commands::ESP110(const char* cmd_params, level_authenticate_type auth_type,
99101
if(parameter == "WIFI-AP") {
100102
bbuf = ESP_WIFI_AP;
101103
}
104+
if(parameter == "WIFI-SETUP") {
105+
bbuf = ESP_AP_SETUP;
106+
}
102107
#endif //WIFI_FEATURE
103108
#ifdef ETH_FEATURE
104109
if(parameter == "ETH-STA") {

esp3d/src/core/espcmd/ESP400.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
6262
output->print (Settings_ESP3D::read_byte(ESP_RADIO_MODE));
6363
output->print ("\",\"H\":\"radio mode\",\"O\":[{\"none\":\"0\"}");
6464
#ifdef WIFI_FEATURE
65-
output->print (",{\"sta\":\"1\"},{\"ap\":\"2\"}");
65+
output->print (",{\"sta\":\"1\"},{\"ap\":\"2\"},{\"setup\":\"5\"}");
6666
#endif //WIFI_FEATURE
6767
#ifdef BLUETOOTH_FEATURE
6868
output->print (",{\"bt\":\"3\"}");
@@ -147,7 +147,7 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
147147
output->print (Settings_ESP3D::read_byte(ESP_STA_FALLBACK_MODE));
148148
output->print ("\",\"H\":\"sta fallback mode\",\"O\":[{\"none\":\"0\"}");
149149
#ifdef WIFI_FEATURE
150-
output->print (",{\"ap\":\"2\"}");
150+
output->print (",{\"setup\":\"5\"}");
151151
#endif //WIFI_FEATURE
152152
#ifdef BLUETOOTH_FEATURE
153153
output->print (",{\"bt\":\"3\"}");

esp3d/src/core/settings_esp3d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
#if defined(STATION_WIFI_SSID) && defined(STATION_WIFI_PASSWORD)
6868
#define DEFAULT_ESP_RADIO_MODE ESP_WIFI_STA
6969
#else
70-
#define DEFAULT_ESP_RADIO_MODE ESP_WIFI_AP
70+
#define DEFAULT_ESP_RADIO_MODE ESP_AP_SETUP
7171
#endif //STATION_WIFI_SSID && STATION_WIFI_PASSWORD
7272
#else //WIFI_FEATURE
7373
#define DEFAULT_STA_FALLBACK_MODE ESP_NO_NETWORK

esp3d/src/include/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#define ESP_WIFI_AP 2
7878
#define ESP_BT 3
7979
#define ESP_ETH_STA 4
80+
#define ESP_AP_SETUP 5
8081
//#define ESP_ETH_SRV 5
8182

8283
//SD mount point

esp3d/src/include/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define _VERSION_ESP3D_H
2323

2424
//version and sources location
25-
#define FW_VERSION "3.0.0.a109"
25+
#define FW_VERSION "3.0.0.a110"
2626
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
2727

2828
#endif //_VERSION_ESP3D_H

esp3d/src/modules/display/advanceddisplay.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ bool Display::display_IP(bool force)
319319
case ESP_WIFI_STA:
320320
s = WiFi.localIP().toString();
321321
break;
322+
case ESP_AP_SETUP:
322323
case ESP_WIFI_AP:
323324
s = WiFi.softAPIP().toString();
324325
break;

esp3d/src/modules/http/http_server.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#endif //ARDUINO_ARCH_ESP8266
3131
#include "http_server.h"
3232
#include "../authentication/authentication_service.h"
33+
#include "../network/netconfig.h"
3334
#include "../../core/settings_esp3d.h"
3435
#include "../filesystem/esp_filesystem.h"
3536
#include "../websocket/websocket_server.h"
@@ -79,7 +80,7 @@ void HTTP_Server::init_handlers()
7980
}
8081
#endif //SSDP_FEATURE
8182
#ifdef CAPTIVE_PORTAL_FEATURE
82-
if(WiFi.getMode() == WIFI_AP) {
83+
if(NetConfig::getMode() == ESP_AP_SETUP) {
8384
_webserver->on ("/generate_204", HTTP_ANY, handle_root);
8485
_webserver->on ("/gconnectivitycheck.gstatic.com", HTTP_ANY, handle_root);
8586
//do not forget the / at the end

esp3d/src/modules/mks/mks_service.cpp

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ bool MKSService::sendNetworkFrame()
627627
//Wifi_key Segment
628628
strcpy((char *)&_frame[dataOffset], s.c_str());
629629
dataOffset+=s.length();
630-
} else if (NetConfig::getMode() == ESP_WIFI_AP) {
631-
log_esp3d("AP Mode");
630+
} else if (NetConfig::getMode() == ESP_WIFI_AP || (NetConfig::getMode() == ESP_AP_SETUP) {
631+
log_esp3d("AP Mode");
632632
///////////////////////////////////
633633
//IP Segment
634634
//IP value
@@ -671,61 +671,61 @@ bool MKSService::sendNetworkFrame()
671671
//Cloud Services port Segment
672672
//hard coded
673673
_frame[MKS_FRAME_DATA_OFFSET +4] = (telnet_server.port()) & 0xff;
674-
_frame[MKS_FRAME_DATA_OFFSET +5] = ((telnet_server.port()) >> 8 ) & 0xff;
675-
log_esp3d("Cloud port: %d", (telnet_server.port()));
676-
677-
//////////////////////////////////
678-
//Cloud State Segment
679-
//hard coded as disabled in upstream FW
680-
_frame[dataOffset] = MKS_FRAME_CLOUD_DISABLED_STATE;
681-
dataOffset++;
682-
//////////////////////////////////
683-
//Cloud host len Segment
684-
//Use ESP3D IP instead
685-
s = NetConfig::localIPAddress().toString();
686-
_frame[dataOffset] = s.length();
687-
dataOffset++;
688-
//////////////////////////////////
689-
//Cloud host Segment
690-
//Use ESP3D IP instead
691-
strcpy((char *)&_frame[dataOffset], s.c_str());
692-
dataOffset+=s.length();
693-
//////////////////////////////////
694-
//Cloud host port Segment
695-
//use webserver port instead
696-
_frame[dataOffset] = (HTTP_Server::port()) & 0xff;
697-
dataOffset++;
698-
_frame[dataOffset] = ((HTTP_Server::port())>> 8 ) & 0xff;
699-
dataOffset++;
700-
//////////////////////////////////
701-
//Module id len Segment
702-
//Use hostname instead
703-
_frame[dataOffset] = strlen(_moduleId);
704-
dataOffset++;
705-
//////////////////////////////////
706-
//Module id Segment
707-
strcpy((char *)&_frame[dataOffset], _moduleId);
708-
dataOffset+=strlen(_moduleId);
709-
//////////////////////////////////
710-
//FW version len Segment
711-
_frame[dataOffset] = strlen(FW_VERSION)+6;
712-
dataOffset++;
713-
//////////////////////////////////
714-
//FW version Segment
715-
strcpy((char *)&_frame[dataOffset], "ESP3D_" FW_VERSION);
716-
dataOffset+=strlen(FW_VERSION)+6;
717-
//////////////////////////////////
718-
//Tail Segment
719-
_frame[dataOffset] = MKS_FRAME_TAIL_FLAG;
720-
721-
//////////////////////////////////
722-
//Data len Segment
723-
//Calculated from above
724-
_frame[MKS_FRAME_DATALEN_OFFSET] = (dataOffset-4) & 0xff;
725-
_frame[MKS_FRAME_DATALEN_OFFSET+1] = ((dataOffset-4) >> 8) & 0xff;
726-
log_esp3d("Size of data in frame %d ", dataOffset-4);
674+
_frame[MKS_FRAME_DATA_OFFSET +5] = ((telnet_server.port()) >> 8 ) & 0xff;
675+
log_esp3d("Cloud port: %d", (telnet_server.port()));
676+
677+
//////////////////////////////////
678+
//Cloud State Segment
679+
//hard coded as disabled in upstream FW
680+
_frame[dataOffset] = MKS_FRAME_CLOUD_DISABLED_STATE;
681+
dataOffset++;
682+
//////////////////////////////////
683+
//Cloud host len Segment
684+
//Use ESP3D IP instead
685+
s = NetConfig::localIPAddress().toString();
686+
_frame[dataOffset] = s.length();
687+
dataOffset++;
688+
//////////////////////////////////
689+
//Cloud host Segment
690+
//Use ESP3D IP instead
691+
strcpy((char *)&_frame[dataOffset], s.c_str());
692+
dataOffset+=s.length();
693+
//////////////////////////////////
694+
//Cloud host port Segment
695+
//use webserver port instead
696+
_frame[dataOffset] = (HTTP_Server::port()) & 0xff;
697+
dataOffset++;
698+
_frame[dataOffset] = ((HTTP_Server::port())>> 8 ) & 0xff;
699+
dataOffset++;
700+
//////////////////////////////////
701+
//Module id len Segment
702+
//Use hostname instead
703+
_frame[dataOffset] = strlen(_moduleId);
704+
dataOffset++;
705+
//////////////////////////////////
706+
//Module id Segment
707+
strcpy((char *)&_frame[dataOffset], _moduleId);
708+
dataOffset+=strlen(_moduleId);
709+
//////////////////////////////////
710+
//FW version len Segment
711+
_frame[dataOffset] = strlen(FW_VERSION)+6;
712+
dataOffset++;
713+
//////////////////////////////////
714+
//FW version Segment
715+
strcpy((char *)&_frame[dataOffset], "ESP3D_" FW_VERSION);
716+
dataOffset+=strlen(FW_VERSION)+6;
717+
//////////////////////////////////
718+
//Tail Segment
719+
_frame[dataOffset] = MKS_FRAME_TAIL_FLAG;
720+
721+
//////////////////////////////////
722+
//Data len Segment
723+
//Calculated from above
724+
_frame[MKS_FRAME_DATALEN_OFFSET] = (dataOffset-4) & 0xff;
725+
_frame[MKS_FRAME_DATALEN_OFFSET+1] = ((dataOffset-4) >> 8) & 0xff;
726+
log_esp3d("Size of data in frame %d ", dataOffset-4);
727727
if (canSendFrame()) {
728-
ESP3DOutput output(ESP_SERIAL_CLIENT);
728+
ESP3DOutput output(ESP_SERIAL_CLIENT);
729729
if (output.write(_frame,dataOffset+1) == (dataOffset+1)) {
730730
log_esp3d("Ok");
731731
sendFrameDone();

0 commit comments

Comments
 (0)