File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,23 @@ void Wippersnapper_FS::parseSecrets() {
418418 // Attempt to deserialize the file's JSON document
419419 JsonDocument doc;
420420 DeserializationError error = deserializeJson (doc, secretsFile);
421- if (error) {
421+ if (error == DeserializationError::EmptyInput)
422+ {
423+ if (WS.brownOutCausedReset )
424+ {
425+ fsHalt (" ERROR: Empty secrets.json file, can't recreate due to brownout - recharge or must be fixed manually." );
426+ }
427+ else
428+ {
429+ // TODO: Can't serial print here, in next PR check we're not out of space
430+ WS_DEBUG_PRINTLN (" ERROR: Empty secrets.json file, recreating..." );
431+ secretsFile.close ();
432+ wipperFatFs.remove (" /secrets.json" );
433+ createSecretsFile (); // calls fsHalt
434+ }
435+ }
436+ else if (error)
437+ {
422438 fsHalt (String (" ERROR: Unable to parse secrets.json file - "
423439 " deserializeJson() failed with code" ) +
424440 error.c_str ());
You can’t perform that action at this time.
0 commit comments