Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CivicTechTO/proj-noisemeter-device …
Browse files Browse the repository at this point in the history
…into access-point-update
  • Loading branch information
tcsullivan committed Jul 22, 2024
2 parents c6f1226 + 6768b30 commit 512eb22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion noisemeter-device/noisemeter-device.ino
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,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 @@ -276,6 +276,7 @@ std::optional<const char *> saveNetworkCreds(String ssid, String psk, String ema
if (!ssid.isEmpty() && Creds.canStore(ssid) && Creds.canStore(psk)) {
Creds.set(Storage::Entry::SSID, ssid);
Creds.set(Storage::Entry::Passkey, psk);
Creds.set(Storage::Entry::Unused, {});
Creds.commit();

if (tryWifiConnection(WIFI_AP_STA, WIFI_NEW_CONNECT_TIMEOUT_SEC) == 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
4 changes: 2 additions & 2 deletions noisemeter-device/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#define SEC_TO_MS(s) (s * 1000)
#define MIN_TO_SEC(m) (m * 60)
#define HR_TO_SEC(h) MIN_TO_SEC(60)
#define DAY_TO_SEC(h) HR_TO_SEC(24)
#define HR_TO_SEC(h) (h * MIN_TO_SEC(60))
#define DAY_TO_SEC(d) (d * HR_TO_SEC(24))

/** Maximum number of milliseconds to wait for NTP sync to succeed. */
constexpr auto NTP_CONNECT_TIMEOUT_MS = SEC_TO_MS(20);
Expand Down

0 comments on commit 512eb22

Please sign in to comment.