Skip to content

Commit

Permalink
Clear null secrets as some text readers wont open binary
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Dec 12, 2024
1 parent 2ac1767 commit 4aa19d8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ bool Wippersnapper_FS::configFileExists() {
// Does secrets.json file exist?
if (!wipperFatFs.exists("/secrets.json"))
return false;
File32 file = wipperFatFs.open("/secrets.json", FILE_READ);
if (!file)
return false;
int firstChar = file.peek();
file.close();
if (firstChar <= 0 || firstChar == 255)
return false;
return true;
}

Expand Down Expand Up @@ -324,7 +331,7 @@ bool Wippersnapper_FS::createBootFile() {
void Wippersnapper_FS::createSecretsFile() {
// Open file for writing
File32 secretsFile = wipperFatFs.open("/secrets.json", FILE_WRITE);

secretsFile.truncate(0);
// Create a default secretsConfig structure
secretsConfig secretsConfig;
strcpy(secretsConfig.aio_user, "YOUR_IO_USERNAME_HERE");
Expand All @@ -339,7 +346,7 @@ void Wippersnapper_FS::createSecretsFile() {
serializeJsonPretty(doc, secretsFile);
secretsFile.flush();
secretsFile.close();

writeToBootOut(
"ERROR: Please edit the secrets.json file. Then, reset your board.\n");
#ifdef USE_DISPLAY
Expand Down

0 comments on commit 4aa19d8

Please sign in to comment.