mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 00:26:02 +08:00
Add RESET/CONFIG/SAFEMODE to command line
[ESP444]RESET will set default values to EEPROM and restart module [ESP444]CONFIG will display EEPROM but password [ESP444]SAFEMODE will switch to safe mode = default mode but without modifying EEPROM and no restart
This commit is contained in:
parent
26ce0ba15b
commit
65ec16f4d5
@ -20,6 +20,7 @@
|
||||
|
||||
#include "command.h"
|
||||
#include "config.h"
|
||||
#include "wifi.h"
|
||||
#include "webinterface.h"
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
@ -49,6 +50,21 @@ void COMMAND::execute_command(int cmd,String cmd_params)
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
break;
|
||||
case 444:
|
||||
if (cmd_params=="RESET")
|
||||
{
|
||||
CONFIG::reset_config();
|
||||
web_interface->restartmodule=true;
|
||||
}
|
||||
if (cmd_params=="SAFEMODE")
|
||||
{
|
||||
wifi_config.Safe_Setup();
|
||||
}
|
||||
if (cmd_params=="CONFIG")
|
||||
{
|
||||
CONFIG::print_config();
|
||||
}
|
||||
break;
|
||||
case 888:
|
||||
if (cmd_params=="RESTART")
|
||||
{
|
||||
|
@ -159,7 +159,6 @@ bool CONFIG::reset_config()
|
||||
if(!CONFIG::write_buffer(EP_XY_FEEDRATE,(const byte *)&DEFAULT_XY_FEEDRATE,INTEGER_LENGTH))return false;
|
||||
if(!CONFIG::write_buffer(EP_Z_FEEDRATE,(const byte *)&DEFAULT_Z_FEEDRATE,INTEGER_LENGTH))return false;
|
||||
if(!CONFIG::write_buffer(EP_E_FEEDRATE,(const byte *)&DEFAULT_E_FEEDRATE,INTEGER_LENGTH))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -171,7 +170,7 @@ void CONFIG::print_config()
|
||||
int ibuf=0;
|
||||
if (CONFIG::read_byte(EP_WIFI_MODE, &bbuf ))Serial.println(byte(bbuf));
|
||||
if (CONFIG::read_string(EP_SSID, sbuf , MAX_SSID_LENGTH))Serial.println(sbuf);
|
||||
if (CONFIG::read_string(EP_PASSWORD, sbuf , MAX_PASSWORD_LENGTH))Serial.println(sbuf);
|
||||
//if (CONFIG::read_string(EP_PASSWORD, sbuf , MAX_PASSWORD_LENGTH))Serial.println(sbuf);
|
||||
if (CONFIG::read_byte(EP_IP_MODE, &bbuf ))Serial.println(byte(bbuf));
|
||||
if (CONFIG::read_buffer(EP_IP_VALUE,(byte *)sbuf , IP_LENGTH))Serial.println(wifi_config.ip2str((byte *)sbuf));
|
||||
if (CONFIG::read_buffer(EP_MASK_VALUE, (byte *)sbuf , IP_LENGTH))Serial.println(wifi_config.ip2str((byte *)sbuf));
|
||||
@ -189,5 +188,4 @@ void CONFIG::print_config()
|
||||
if (CONFIG::read_buffer(EP_XY_FEEDRATE, (byte *)&ibuf , INTEGER_LENGTH))Serial.println(ibuf);
|
||||
if (CONFIG::read_buffer(EP_Z_FEEDRATE, (byte *)&ibuf , INTEGER_LENGTH))Serial.println(ibuf);
|
||||
if (CONFIG::read_buffer(EP_E_FEEDRATE, (byte *)&ibuf , INTEGER_LENGTH))Serial.println(ibuf);
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define SSDP_FEATURE
|
||||
|
||||
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
|
||||
//#define CAPTIVE_PORTAL_FEATURE
|
||||
#define CAPTIVE_PORTAL_FEATURE
|
||||
|
||||
#ifndef CONFIG_h
|
||||
#define CONFIG_h
|
||||
|
@ -57,6 +57,8 @@ WiFiClient serverClients[MAX_SRV_CLIENTS];
|
||||
|
||||
void setup() {
|
||||
// init :
|
||||
web_interface = NULL;
|
||||
data_server = NULL;
|
||||
// ESP.wdtDisable();
|
||||
system_update_cpu_freq(SYS_CPU_160MHZ);
|
||||
delay(8000);
|
||||
|
@ -28,6 +28,10 @@
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
#include <DNSServer.h>
|
||||
extern DNSServer dnsServer;
|
||||
#endif
|
||||
|
||||
const char * WIFI_CONFIG::get_hostname(){
|
||||
if (WiFi.hostname().length()==0)
|
||||
@ -105,20 +109,23 @@ char * WIFI_CONFIG::ip2str(IPAddress Ip )
|
||||
|
||||
void WIFI_CONFIG::Safe_Setup()
|
||||
{
|
||||
WiFi.disconnect();
|
||||
//setup Soft AP
|
||||
WiFi.mode(WIFI_AP);
|
||||
IPAddress local_ip (DEFAULT_IP_VALUE[0],DEFAULT_IP_VALUE[1],DEFAULT_IP_VALUE[2],DEFAULT_IP_VALUE[3]);
|
||||
IPAddress gateway (DEFAULT_GATEWAY_VALUE[0],DEFAULT_GATEWAY_VALUE[1],DEFAULT_GATEWAY_VALUE[2],DEFAULT_GATEWAY_VALUE[3]);
|
||||
IPAddress subnet (DEFAULT_MASK_VALUE[0],DEFAULT_MASK_VALUE[1],DEFAULT_MASK_VALUE[2],DEFAULT_MASK_VALUE[3]);
|
||||
String ssid = FPSTR(DEFAULT_SSID);
|
||||
String pwd = FPSTR(DEFAULT_PASSWORD);
|
||||
WiFi.softAP(ssid.c_str(),pwd.c_str());
|
||||
delay(500);
|
||||
wifi_set_phy_mode(PHY_MODE_11B);
|
||||
WiFi.softAPConfig( local_ip, gateway, subnet);
|
||||
Serial.println(F("M117 Safe mode started"));
|
||||
delay(1000);
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
dnsServer.stop();
|
||||
delay(100);
|
||||
#endif
|
||||
WiFi.disconnect();
|
||||
//setup Soft AP
|
||||
WiFi.mode(WIFI_AP);
|
||||
IPAddress local_ip (DEFAULT_IP_VALUE[0],DEFAULT_IP_VALUE[1],DEFAULT_IP_VALUE[2],DEFAULT_IP_VALUE[3]);
|
||||
IPAddress gateway (DEFAULT_GATEWAY_VALUE[0],DEFAULT_GATEWAY_VALUE[1],DEFAULT_GATEWAY_VALUE[2],DEFAULT_GATEWAY_VALUE[3]);
|
||||
IPAddress subnet (DEFAULT_MASK_VALUE[0],DEFAULT_MASK_VALUE[1],DEFAULT_MASK_VALUE[2],DEFAULT_MASK_VALUE[3]);
|
||||
String ssid = FPSTR(DEFAULT_SSID);
|
||||
String pwd = FPSTR(DEFAULT_PASSWORD);
|
||||
WiFi.softAP(ssid.c_str(),pwd.c_str());
|
||||
delay(500);
|
||||
WiFi.softAPConfig( local_ip, gateway, subnet);
|
||||
delay(1000);
|
||||
Serial.println(F("M117 Safe mode started"));
|
||||
}
|
||||
|
||||
//Read configuration settings and apply them
|
||||
|
Loading…
x
Reference in New Issue
Block a user