Skip to content

Fix ARM64 CI cross-compile and cap alert emails to one per tick#107

Merged
GageLawton merged 2 commits into
mainfrom
claude/sweet-knuth-CKD1R
May 27, 2026
Merged

Fix ARM64 CI cross-compile and cap alert emails to one per tick#107
GageLawton merged 2 commits into
mainfrom
claude/sweet-knuth-CKD1R

Conversation

@GageLawton
Copy link
Copy Markdown
Owner

Summary

Two independent fixes.

1. ARM64 CI cross-compile

The ARM64 cross-compile job was failing because lcd.cpp and i2c_bus.cpp include <wiringPiI2C.h>, which is not present in the CI runner. A minimal stub header is added under test/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/stubs to ARM64 cross-compile flags
  • include/alerter.h: add emailQueue_ member
  • src/alerter.cpp: enqueue in notifyWeatherAlerts(), drain one per drainEmailQueue() call

Test plan

  • Confirm ARM64 CI job passes
  • Simulate multiple simultaneous alerts and confirm one SMTP connection per tick
  • Confirm all queued emails are eventually delivered

claude added 2 commits May 27, 2026 01:39
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
@GageLawton GageLawton force-pushed the claude/sweet-knuth-CKD1R branch from db27e9c to 91ef456 Compare May 27, 2026 01:39
@GageLawton GageLawton merged commit af9b360 into main May 27, 2026
2 checks passed
@GageLawton GageLawton deleted the claude/sweet-knuth-CKD1R branch May 27, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants