mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 23:25:54 +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 "command.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "wifi.h"
|
||||||
#include "webinterface.h"
|
#include "webinterface.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
@ -49,6 +50,21 @@ void COMMAND::execute_command(int cmd,String cmd_params)
|
|||||||
Serial.print("\r\n");
|
Serial.print("\r\n");
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case 888:
|
||||||
if (cmd_params=="RESTART")
|
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_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_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;
|
if(!CONFIG::write_buffer(EP_E_FEEDRATE,(const byte *)&DEFAULT_E_FEEDRATE,INTEGER_LENGTH))return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ void CONFIG::print_config()
|
|||||||
int ibuf=0;
|
int ibuf=0;
|
||||||
if (CONFIG::read_byte(EP_WIFI_MODE, &bbuf ))Serial.println(byte(bbuf));
|
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_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_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_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));
|
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_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_Z_FEEDRATE, (byte *)&ibuf , INTEGER_LENGTH))Serial.println(ibuf);
|
||||||
if (CONFIG::read_buffer(EP_E_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
|
#define SSDP_FEATURE
|
||||||
|
|
||||||
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
|
//CAPTIVE_PORTAL_FEATURE: In SoftAP redirect all unknow call to main page
|
||||||
//#define CAPTIVE_PORTAL_FEATURE
|
#define CAPTIVE_PORTAL_FEATURE
|
||||||
|
|
||||||
#ifndef CONFIG_h
|
#ifndef CONFIG_h
|
||||||
#define CONFIG_h
|
#define CONFIG_h
|
||||||
|
@ -57,6 +57,8 @@ WiFiClient serverClients[MAX_SRV_CLIENTS];
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// init :
|
// init :
|
||||||
|
web_interface = NULL;
|
||||||
|
data_server = NULL;
|
||||||
// ESP.wdtDisable();
|
// ESP.wdtDisable();
|
||||||
system_update_cpu_freq(SYS_CPU_160MHZ);
|
system_update_cpu_freq(SYS_CPU_160MHZ);
|
||||||
delay(8000);
|
delay(8000);
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
|
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||||
|
#include <DNSServer.h>
|
||||||
|
extern DNSServer dnsServer;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char * WIFI_CONFIG::get_hostname(){
|
const char * WIFI_CONFIG::get_hostname(){
|
||||||
if (WiFi.hostname().length()==0)
|
if (WiFi.hostname().length()==0)
|
||||||
@ -105,6 +109,10 @@ char * WIFI_CONFIG::ip2str(IPAddress Ip )
|
|||||||
|
|
||||||
void WIFI_CONFIG::Safe_Setup()
|
void WIFI_CONFIG::Safe_Setup()
|
||||||
{
|
{
|
||||||
|
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||||
|
dnsServer.stop();
|
||||||
|
delay(100);
|
||||||
|
#endif
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
//setup Soft AP
|
//setup Soft AP
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
@ -115,10 +123,9 @@ void WIFI_CONFIG::Safe_Setup()
|
|||||||
String pwd = FPSTR(DEFAULT_PASSWORD);
|
String pwd = FPSTR(DEFAULT_PASSWORD);
|
||||||
WiFi.softAP(ssid.c_str(),pwd.c_str());
|
WiFi.softAP(ssid.c_str(),pwd.c_str());
|
||||||
delay(500);
|
delay(500);
|
||||||
wifi_set_phy_mode(PHY_MODE_11B);
|
|
||||||
WiFi.softAPConfig( local_ip, gateway, subnet);
|
WiFi.softAPConfig( local_ip, gateway, subnet);
|
||||||
Serial.println(F("M117 Safe mode started"));
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
Serial.println(F("M117 Safe mode started"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read configuration settings and apply them
|
//Read configuration settings and apply them
|
||||||
|
Loading…
x
Reference in New Issue
Block a user