Skip to content

Commit

Permalink
fix token validity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tcsullivan committed Jul 20, 2024
1 parent 3d3aefa commit c6f1226
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions noisemeter-device/noisemeter-device.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void setup() {
SERIAL.println(" done.");

isAPNeeded = true;
} else if (Creds.get(Storage::Entry::Token).length() == 0) {
} else if (Creds.get(Storage::Entry::Token)[0] == '\0') {
isAPNeeded = true;
} else if (tryWifiConnection(WIFI_STA) < 0) {
isAPNeeded = true;
Expand Down Expand Up @@ -292,8 +292,10 @@ std::optional<const char *> saveNetworkCreds(String ssid, String psk, String ema
} else {
return "The sensor was not able to register with the server.";
}
} else {
} else if (Creds.get(Storage::Entry::Token)[0] != '\0') {
return {};
} else {
return "An email is required to register the sensor with the server.";
}
} else {
return "The sensor connected to your WiFi, but failed to reach the internet.";
Expand Down
1 change: 1 addition & 0 deletions noisemeter-device/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void Storage::clear() noexcept
for (auto i = 0u; i < addrOf(Entry::TotalSize); ++i)
writeByte(i, 0xFF);

set(Entry::Token, "\0");
EEPROMClass::commit();
}

Expand Down

0 comments on commit c6f1226

Please sign in to comment.