mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
add configclear function
This commit is contained in:
parent
70f82c07e7
commit
370c6cd9fc
@ -374,6 +374,25 @@ void configSetup()
|
||||
//#endif
|
||||
}
|
||||
|
||||
void configClear()
|
||||
{
|
||||
#if defined(STM32F4xx)
|
||||
// Method 2
|
||||
Log.verbose(F("CONF: Clearing EEPROM"));
|
||||
char buffer[1024 + 128];
|
||||
memset(buffer, 1 ,sizeof(buffer));
|
||||
if(sizeof(buffer) > 0) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < sizeof(buffer); i++) eeprom_buffered_write_byte(i, buffer[i]);
|
||||
eeprom_buffered_write_byte(i, 0);
|
||||
eeprom_buffer_flush();
|
||||
Log.verbose(F("CONF: [SUCCESS] Cleared EEPROM"));
|
||||
} else {
|
||||
Log.error(F("CONF: Failed to clear to EEPROM"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void configOutput(const JsonObject & settings)
|
||||
{
|
||||
String output((char *)0);
|
||||
|
@ -38,6 +38,7 @@ void configStop(void);
|
||||
void configSetConfig(JsonObject & settings);
|
||||
void configGetConfig(JsonDocument & settings);
|
||||
void configWriteConfig();
|
||||
void configClear(void);
|
||||
void configOutput(const JsonObject & settings);
|
||||
|
||||
bool configSet(int8_t & value, const JsonVariant & setting, const char * name);
|
||||
|
@ -119,6 +119,9 @@ void dispatchAttribute(String strTopic, const char * payload)
|
||||
} else if(strTopic == F("update")) {
|
||||
dispatchWebUpdate(payload);
|
||||
|
||||
} else if(strTopic == F("clearconfig")) {
|
||||
configClear();
|
||||
|
||||
} else if(strTopic == F("setupap")) {
|
||||
// haspDisplayAP(String(F("HASP-ABC123")).c_str(), String(F("haspadmin")).c_str());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user