Reduce ExternalNotificationModule flash usage (RTTTL + InputBroker)#10989
Reduce ExternalNotificationModule flash usage (RTTTL + InputBroker)#10989ndoo wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change adds platform-specific RTTTL exclusion flags and applies RTTTL and input-broker conditional compilation throughout ChangesConditional Notification Features
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⚡ Try this PR in the Web FlasherNote Building this pull request… the flash button, badges and supported-board |
b4b69ab to
05f8ac6
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modules/ExternalNotificationModule.cpp`:
- Around line 60-63: Guard the I2S playback paths that reference rtttlConfig,
including the logic near the I2S handlers around lines 144 and 468, with
!MESHTASTIC_EXCLUDE_RTTTL alongside HAS_I2S. Ensure builds with
MESHTASTIC_EXCLUDE_RTTTL enabled do not compile any rtttlConfig references while
preserving the existing I2S ringtone behavior when RTTTL is enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9f6e8150-7ab7-45c7-96d4-cd27c6f7ba32
📒 Files selected for processing (5)
src/modules/ExternalNotificationModule.cppsrc/modules/ExternalNotificationModule.hsrc/platform/esp32/architecture.hsrc/platform/portduino/architecture.hsrc/platform/stm32wl/architecture.h
05f8ac6 to
2cfd6a9
Compare
|
@coderabbitai review Fixed: the two HAS_I2S ringtone-playback call sites (audioThread->beginRttl in runOnce() and handleReceived()) referenced rtttlConfig without also checking !MESHTASTIC_EXCLUDE_RTTTL, even though rtttlConfig is now only declared under that guard. No platform currently defines both HAS_I2S and MESHTASTIC_EXCLUDE_RTTTL, so this had no effect on any build today, but it would have broken compilation for a future HAS_I2S platform that also excludes RTTTL. Both sites now check |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n "HAS_I2S" src/modules/ExternalNotificationModule.cpp -B2 -A2Length of output: 1512 Confirms the fix is in place at both call sites (Line 139 and Line 467) with
✏️ Learnings added
✅ Action performedReview finished.
|
ExternalNotificationModule already stubbed out RTTTL playback for STM32WL/portduino/ESP32C6 via a raw ARCH/CONFIG_IDF check, but the ringtone config plumbing around it (protobuf message, encode/decode tables, /prefs/ringtone.proto persistence, admin get/set-ringtone handlers) still compiled in even though it can never do anything on those platforms. Introduce MESHTASTIC_EXCLUDE_RTTTL and gate the dead ringtone plumbing behind it too. The flag is set in each architecture's *_base build_flags (stm32_base, esp32c6_base, portduino_base) rather than in the module itself - this matches how every other MESHTASTIC_EXCLUDE_* flag in the tree is set (e.g. stm32_base already sets ten of them directly, and esp32c6_base already excludes PAXCOUNTER for an analogous platform-can't-support-this reason), rather than introducing a new per-architecture C header pattern. Behavior is unchanged on all three platforms; overridable via -D like every other MESHTASTIC_EXCLUDE_* flag. Also guard the two HAS_I2S ringtone-playback call sites with !MESHTASTIC_EXCLUDE_RTTTL alongside HAS_I2S, since rtttlConfig itself is now only declared when RTTTL is not excluded. No current platform defines both HAS_I2S and MESHTASTIC_EXCLUDE_RTTTL simultaneously, so this has no effect today, but prevents a future HAS_I2S platform that also excludes RTTTL from failing to compile. Saves 368 bytes flash / 236 bytes RAM on wio-e5 with no loss to the GPIO on/off notification toggle itself, which does not depend on RTTTL. Signed-off-by: Andrew Yong <me@ndoo.sg> Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
The inputObserver CallbackObserver member was declared unconditionally, even though its only use site was already gated behind MESHTASTIC_EXCLUDE_INPUTBROKER (set for all of stm32 in stm32.ini). Because it's a non-trivial member, the compiler still generated its constructor/destructor as part of ExternalNotificationModule's own lifecycle even when InputBroker is compiled out entirely. Gate the member and its only consumer, handleInputEvent(), behind the same flag as their use site, and match the codebase's dominant !MESHTASTIC_EXCLUDE_X style (used ~330 times) rather than !defined(MESHTASTIC_EXCLUDE_X) (used ~20 times) while touching this flag's other call site. Saves an additional 288 bytes flash on wio-e5, no RAM change, no functional impact since InputBroker was already unused on this platform. Signed-off-by: Andrew Yong <me@ndoo.sg> Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2cfd6a9 to
aff3a3b
Compare
|
Moved MESHTASTIC_EXCLUDE_RTTTL's definition from src/platform/{stm32wl,portduino,esp32}/architecture.h into each architecture's |
|
@ndoo can you fix the conflicts |
meshtastic#10992 landed on develop after this branch forked, inserting new MESHTASTIC_EXCLUDE_* flags at the same point this PR adds MESHTASTIC_EXCLUDE_RTTTL. Combine both sets and alphabetize the whole exclude-flag block in stm32_base's build_flags. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Andrew Yong <me@ndoo.sg>
Done and sorted the excludes list while we're touching the file |
Summary
MESHTASTIC_EXCLUDE_RTTTL, set in each architecture's*_basebuild_flags(stm32_base,esp32c6_base,portduino_base), replacing the inlineARCH_STM32WL/ARCH_PORTDUINO/CONFIG_IDF_TARGET_ESP32C6check inExternalNotificationModule.hthat already stubbed out RTTTL playback on these platforms. Also gates the ringtone config/persistence/admin-message plumbing around that already-stubbed playback path behind the same flag.ExternalNotificationModule'sinputObserver(CallbackObserver) member andhandleInputEvent()behindMESHTASTIC_EXCLUDE_INPUTBROKER, matching the flag its only use site already checked.wio-e5: 656 bytes flash saved (368 + 288), ~236 bytes RAM saved. No behavior change on any platform.What changed
variants/stm32/stm32.ini(stm32_base),variants/esp32c6/esp32c6.ini(esp32c6_base),variants/native/portduino.ini(portduino_base): setMESHTASTIC_EXCLUDE_RTTTLfor the three platforms that previously got the inline RTTTL stub. This matches how every otherMESHTASTIC_EXCLUDE_*flag in the tree is set (stm32_basealready sets ten directly;esp32c6_basealready excludesPAXCOUNTERfor an analogous platform-limitation reason) rather than introducing a new per-architecture header mechanism.src/modules/ExternalNotificationModule.h/.cpp: consumeMESHTASTIC_EXCLUDE_RTTTLinstead of the inline ARCH check; gate ringtone get/setAdminMessagehandlers,/prefs/ringtone.protopersistence, and the PWM-playback call site behind it. GateinputObserver/handleInputEvent()behindMESHTASTIC_EXCLUDE_INPUTBROKER.Testing
pio run -e wio-e5: confirmed flash/RAM deltas in isolation and combined; usednm --size-sort -Son the linked ELF to confirm removed code was unreachable, not live functionality.pio run -e native-macos -v: confirmed-DMESHTASTIC_EXCLUDE_RTTTLreaches the compiled build-flag set for portduino (full link not verifiable on this machine due to an unrelated missingargp-standalonedependency).🤝 Attestations
Summary by CodeRabbit