Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
Keep extra storage entry so checksum is not ruined; clear API token if re-registering; blink faster for multi-packet send
  • Loading branch information
tcsullivan committed Jul 2, 2024
1 parent e9566d7 commit fae14a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion noisemeter-device/noisemeter-device.ino
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void loop() {

// Only blink if there's multiple packets to send
if (++packets.cbegin() != packets.cend())
bl.emplace(300);
bl.emplace(200);

packets.remove_if([&api](const auto& pkt) {
return pkt.count <= 0 || api.sendMeasurement(pkt);
Expand Down Expand Up @@ -281,6 +281,9 @@ std::optional<const char *> saveNetworkCreds(WebServer& httpServer)
if (!ssid.isEmpty() && Creds.canStore(ssid) && Creds.canStore(psk)) {
Creds.set(Storage::Entry::SSID, ssid);
Creds.set(Storage::Entry::Passkey, psk);
if (!email.isEmpty())
Creds.set(Storage::Entry::Token, {});
Creds.set(Storage::Entry::Unused, {});
Creds.commit();

if (tryWifiConnection(WIFI_AP_STA, WIFI_NEW_CONNECT_TIMEOUT_SEC) == 0 && Timestamp::synchronize() == 0) {
Expand Down
3 changes: 2 additions & 1 deletion noisemeter-device/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Storage : protected EEPROMClass
SSID = Checksum + sizeof(uint32_t), /** User's WiFi SSID */
Passkey = SSID + StringSize, /** User's WiFi passkey */
Token = Passkey + StringSize, /** Device API token */
TotalSize = Token + StringSize /** Marks storage end address */
Unused = Token + StringSize, /** Unused (used to be email) */
TotalSize = Unused + StringSize /** Marks storage end address */
};

/**
Expand Down

0 comments on commit fae14a7

Please sign in to comment.