Fix ARM64 CI cross-compile and cap alert emails to one per tick#107
Merged
Conversation
notifyWeatherAlerts() was calling sendEmail() (CURLOPT_TIMEOUT=30s) synchronously for every new alert in one tick. Five simultaneous alerts could freeze the OLED clock, LCD, and ring for up to 150 s. New behaviour: new alerts are pushed into an in-memory emailQueue_ and sentAlertKeys_ is updated immediately to prevent re-queuing. Each call to notifyWeatherAlerts() drains at most one entry from the queue, so the maximum block per tick stays at a single 30 s SMTP timeout. On send failure the entry stays at the front and is retried next tick. Fixes #73 https://claude.ai/code/session_01WFdWug8ZDiJYr1ozfxwkn7
lcd.cpp includes <wiringPiI2C.h> unconditionally, and i2c_bus.cpp does so under #if defined(I2C_REAL) which the CI enables. WiringPi is a Raspberry Pi-only library that is never present in the ubuntu-latest cross-compile runner, so every PR's ARM64 check has been failing with a fatal "curl/wiringPiI2C.h: No such file or directory" error. Fix: add test/stubs/wiringPiI2C.h with bare function declarations that satisfy the compiler, and prepend -Itest/stubs to the cross-compile FLAGS so the stub is found before any system path. The real wiringPi library is still used on the Pi via the normal CMake build; the stubs are only exercised by the compile-only CI job. https://claude.ai/code/session_01WFdWug8ZDiJYr1ozfxwkn7
db27e9c to
91ef456
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two independent fixes.
1. ARM64 CI cross-compile
The ARM64 cross-compile job was failing because
lcd.cppandi2c_bus.cppinclude<wiringPiI2C.h>, which is not present in the CI runner. A minimal stub header is added undertest/stubs/with just enough declarations to satisfy the compiler. The CI compile flags are updated to include that directory. Runtime behavior on the Pi is unaffected.2. Alert emails capped at one per tick
When multiple weather alerts fire simultaneously,
notifyWeatherAlerts()previously attempted one SMTP connection per alert in a single call. Each connection can block for up to 30 seconds, stalling the main loop for minutes when several alerts arrive at once.The fix introduces an in-process email queue: new alert emails are enqueued immediately (keys marked to prevent re-queuing on subsequent ticks), and
drainEmailQueue()sends at most one email per main-loop tick. The loop is never blocked for more than one SMTP timeout regardless of alert volume.Changes
test/stubs/wiringPiI2C.h: minimal stub for CI builds.github/workflows/build.yml: add-Itest/stubsto ARM64 cross-compile flagsinclude/alerter.h: addemailQueue_membersrc/alerter.cpp: enqueue innotifyWeatherAlerts(), drain one perdrainEmailQueue()callTest plan