factory reset function
This commit is contained in:
parent
bec4c1b0ce
commit
8004da624d
|
@ -123,6 +123,7 @@ void setup()
|
||||||
lcd_send_stop_bit();
|
lcd_send_stop_bit();
|
||||||
lcd_init();
|
lcd_init();
|
||||||
lcd_begin();
|
lcd_begin();
|
||||||
|
check_boot_reset();
|
||||||
#ifdef ENABLE_EXTERNAL_LCD
|
#ifdef ENABLE_EXTERNAL_LCD
|
||||||
Serial2.print("rest");
|
Serial2.print("rest");
|
||||||
Serial2.write(0xFF);
|
Serial2.write(0xFF);
|
||||||
|
@ -1191,4 +1192,36 @@ void set_mqtt_useauth(bool use_auth)
|
||||||
{
|
{
|
||||||
MQTT_USE_AUTH = use_auth;
|
MQTT_USE_AUTH = use_auth;
|
||||||
ESPMega_FRAM.write8(EEPROM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH);
|
ESPMega_FRAM.write8(EEPROM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void factory_reset() {
|
||||||
|
for(int i=5;i>0;i--) {
|
||||||
|
if(digitalRead(2)==HIGH) {
|
||||||
|
lcd_send_command("boot_state.txt=\"Factory Reset Canceled, Restarting\"");
|
||||||
|
delay(5000);
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
Serial.printf("boot_state.txt=\"Factory Reset in %d\"",i);
|
||||||
|
lcd_send_stop_bit();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
lcd_send_command("boot_state.txt=\"Factory Reseting . . .\"");
|
||||||
|
// Format FRAM
|
||||||
|
for(int i=0;i<32768;i++) {
|
||||||
|
ESPMega_FRAM.write8(i,0);
|
||||||
|
}
|
||||||
|
// Load Default Values
|
||||||
|
set_ip("192.168.0.10");
|
||||||
|
set_gw("192.168.0.1");
|
||||||
|
// Reboot
|
||||||
|
lcd_send_stop_bit();
|
||||||
|
lcd_send_command("boot_state.txt=\"Factory Reset OK. Release Button.\"");
|
||||||
|
delay(3000);
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
void check_boot_reset() {
|
||||||
|
pinMode(2, INPUT_PULLUP);
|
||||||
|
if(digitalRead(2)==LOW) {
|
||||||
|
factory_reset();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -104,4 +104,7 @@ void eeprom_mqtt_password_retrieve();
|
||||||
void set_mqtt_username(String username);
|
void set_mqtt_username(String username);
|
||||||
void set_mqtt_password(String password);
|
void set_mqtt_password(String password);
|
||||||
void eeprom_mqtt_useauth_retrieve();
|
void eeprom_mqtt_useauth_retrieve();
|
||||||
void set_mqtt_useauth(bool use_auth);
|
void set_mqtt_useauth(bool use_auth);
|
||||||
|
|
||||||
|
void factory_reset();
|
||||||
|
void check_boot_reset();
|
Loading…
Reference in New Issue