@@ -248,6 +248,22 @@ void onControl(AsyncWebServerRequest *request) {
248248 AppHttpd.serialSendCommand (value.c_str ());
249249 request->send (200 , " " , " OK" );
250250 return ;
251+ }
252+ else if (variable == " save_prefs" ) {
253+ CLAppComponent * component = (value == " conn" ?(CLAppComponent*)&AppConn:(CLAppComponent*)&AppCam);
254+ if (component->removePrefs () == OS_SUCCESS)
255+ request->send (200 , " " , " OK" );
256+ else
257+ request->send (500 , " " , " Failed to save preferences" );
258+ return ;
259+ }
260+ else if (variable == " remove_prefs" ) {
261+ CLAppComponent * component = (value == " conn" ?(CLAppComponent*)&AppConn:(CLAppComponent*)&AppCam);
262+ if (component->removePrefs () == OS_SUCCESS)
263+ request->send (200 , " " , " OK" );
264+ else
265+ request->send (500 , " " , " Failed to reset preferences" );
266+ return ;
251267 }
252268
253269 int val = value.toInt ();
@@ -291,12 +307,6 @@ void onControl(AsyncWebServerRequest *request) {
291307 else if (variable == " lamp" && AppCam.getLamp () != -1 ) {
292308 AppCam.setLamp (constrain (val,0 ,100 ));
293309 }
294- else if (variable == " save_prefs" ) {
295- AppCam.savePrefs ();
296- }
297- else if (variable == " clear_prefs" ) {
298- AppCam.removePrefs ();
299- }
300310 else if (variable == " reboot" ) {
301311 if (AppCam.getLamp () != -1 ) AppCam.setLamp (0 ); // kill the lamp; otherwise it can remain on during the soft-reboot
302312 esp_task_wdt_init (3 ,true ); // schedule a a watchdog panic event for 3 seconds in the future
0 commit comments