diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index a6757e04bcb..0bebb64aadb 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -57,7 +57,10 @@ bool ascending = true; #define ASCII_BELL 0x07 +#if !MESHTASTIC_EXCLUDE_RTTTL meshtastic_RTTTLConfig rtttlConfig; +static const char *rtttlConfigFile = "/prefs/ringtone.proto"; +#endif ExternalNotificationModule *externalNotificationModule; @@ -65,8 +68,6 @@ bool externalCurrentState[3] = {}; uint32_t externalTurnedOn[3] = {}; -static const char *rtttlConfigFile = "/prefs/ringtone.proto"; - int32_t ExternalNotificationModule::runOnce() { if (!moduleConfig.external_notification.enabled) { @@ -135,7 +136,7 @@ int32_t ExternalNotificationModule::runOnce() } // Play RTTTL over i2s audio interface if enabled as buzzer -#ifdef HAS_I2S +#if defined(HAS_I2S) && !MESHTASTIC_EXCLUDE_RTTTL if (moduleConfig.external_notification.use_i2s_as_buzzer) { if (audioThread->isPlaying()) { // Continue playing @@ -146,6 +147,7 @@ int32_t ExternalNotificationModule::runOnce() delay = EXT_NOTIFICATION_FAST_THREAD_MS; } #endif +#if !MESHTASTIC_EXCLUDE_RTTTL // now let the PWM buzzer play if (moduleConfig.external_notification.use_pwm && config.device.buzzer_gpio && canBuzz() && buzzerShouldAlert) { if (rtttl::isPlaying()) { @@ -157,6 +159,7 @@ int32_t ExternalNotificationModule::runOnce() // we need fast updates to play the RTTTL delay = EXT_NOTIFICATION_FAST_THREAD_MS; } +#endif return delay; } @@ -320,16 +323,18 @@ ExternalNotificationModule::ExternalNotificationModule() // moduleConfig.external_notification.alert_message_buzzer = true; if (moduleConfig.external_notification.enabled) { -#if !defined(MESHTASTIC_EXCLUDE_INPUTBROKER) +#if !MESHTASTIC_EXCLUDE_INPUTBROKER if (inputBroker) // put our callback in the inputObserver list inputObserver.observe(inputBroker); #endif +#if !MESHTASTIC_EXCLUDE_RTTTL if (nodeDB->loadProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, sizeof(meshtastic_RTTTLConfig), &meshtastic_RTTTLConfig_msg, &rtttlConfig) != LoadFileResult::LOAD_SUCCESS) { memset(rtttlConfig.ringtone, 0, sizeof(rtttlConfig.ringtone)); // The default ringtone is always loaded from userPrefs.jsonc strncpy(rtttlConfig.ringtone, USERPREFS_RINGTONE_RTTTL, sizeof(rtttlConfig.ringtone)); } +#endif LOG_INFO("Init External Notification Module"); @@ -459,11 +464,13 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP } else { // Buzz if buzzer mode is not in DIRECT_MSG_ONLY or is DM to us if (moduleConfig.external_notification.use_i2s_as_buzzer) { -#ifdef HAS_I2S +#if defined(HAS_I2S) && !MESHTASTIC_EXCLUDE_RTTTL audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #endif } else if (moduleConfig.external_notification.use_pwm) { +#if !MESHTASTIC_EXCLUDE_RTTTL rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); +#endif } else { setExternalState(2, true); } @@ -495,6 +502,7 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule AdminMessageHandleResult result; switch (request->which_payload_variant) { +#if !MESHTASTIC_EXCLUDE_RTTTL case meshtastic_AdminMessage_get_ringtone_request_tag: LOG_INFO("Client getting ringtone"); this->handleGetRingtone(mp, response); @@ -506,6 +514,7 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule this->handleSetRingtone(request->set_canned_message_module_messages); result = AdminMessageHandleResult::HANDLED; break; +#endif default: result = AdminMessageHandleResult::NOT_HANDLED; @@ -514,6 +523,7 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule return result; } +#if !MESHTASTIC_EXCLUDE_RTTTL void ExternalNotificationModule::handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response) { LOG_INFO("*** handleGetRingtone"); @@ -537,7 +547,9 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } } +#endif +#if !MESHTASTIC_EXCLUDE_INPUTBROKER int ExternalNotificationModule::handleInputEvent(const InputEvent *event) { if (nagCycleCutoff != UINT32_MAX) { @@ -546,3 +558,4 @@ int ExternalNotificationModule::handleInputEvent(const InputEvent *event) } return 0; } +#endif diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 03eac036bb6..ea4759ad59f 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -23,10 +23,10 @@ extern AmbientLightingThread *ambientLightingThread; #endif #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(CONFIG_IDF_TARGET_ESP32C6) +#if !MESHTASTIC_EXCLUDE_RTTTL #include #else -// Noop class for portduino. +// Noop class for portduino/STM32WL/ESP32C6 - none can drive PWM RTTTL playback. class rtttl { public: @@ -47,8 +47,10 @@ class rtttl */ class ExternalNotificationModule : public SinglePortModule, private concurrency::OSThread { +#if !MESHTASTIC_EXCLUDE_INPUTBROKER CallbackObserver inputObserver = CallbackObserver(this, &ExternalNotificationModule::handleInputEvent); +#endif uint32_t output = 0; #ifdef NEOPIXEL_STATUS_NOTIFICATION_PIN @@ -58,7 +60,9 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: public: ExternalNotificationModule(); +#if !MESHTASTIC_EXCLUDE_INPUTBROKER int handleInputEvent(const InputEvent *arg); +#endif uint32_t nagCycleCutoff = 1; @@ -73,8 +77,10 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: void stopNow(); +#if !MESHTASTIC_EXCLUDE_RTTTL void handleGetRingtone(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response); void handleSetRingtone(const char *from_msg); +#endif protected: /** Called to handle a particular incoming message diff --git a/variants/esp32c6/esp32c6.ini b/variants/esp32c6/esp32c6.ini index ae91e6e81fd..4c75fa90b9b 100644 --- a/variants/esp32c6/esp32c6.ini +++ b/variants/esp32c6/esp32c6.ini @@ -9,6 +9,8 @@ build_flags = ; Exclude Paxcounter, it uses 'esp_vhci_host_send_packet' whch is not available on ESP32-C6 ; https://github.com/espressif/arduino-esp32/issues/11716 -DMESHTASTIC_EXCLUDE_PAXCOUNTER + ; No PWM/RTTTL ringtone playback support on this platform. + -DMESHTASTIC_EXCLUDE_RTTTL build_src_filter = ${esp32_common.build_src_filter} diff --git a/variants/native/portduino.ini b/variants/native/portduino.ini index 98cbaf6c3d7..20e0e0d7c61 100644 --- a/variants/native/portduino.ini +++ b/variants/native/portduino.ini @@ -49,6 +49,7 @@ build_flags_common = -fPIC -Isrc/platform/portduino -DRADIOLIB_EEPROM_UNSUPPORTED + -DMESHTASTIC_EXCLUDE_RTTTL ; No PWM/RTTTL ringtone playback support on this platform. -lpthread -lyaml-cpp -ljsoncpp diff --git a/variants/stm32/stm32.ini b/variants/stm32/stm32.ini index 4300e3b7aac..7d1d3e00404 100644 --- a/variants/stm32/stm32.ini +++ b/variants/stm32/stm32.ini @@ -16,20 +16,21 @@ build_flags = ${arduino_base.build_flags} -flto -Isrc/platform/stm32wl -g - -DMESHTASTIC_EXCLUDE_AUDIO=1 -DMESHTASTIC_EXCLUDE_ATAK=1 ; ATAK is quite big, disable it for big flash savings. + -DMESHTASTIC_EXCLUDE_AUDIO=1 + -DMESHTASTIC_EXCLUDE_BLUETOOTH=1 -DMESHTASTIC_EXCLUDE_INPUTBROKER=1 - -DMESHTASTIC_EXCLUDE_POWERMON=1 - -DMESHTASTIC_EXCLUDE_SCREEN=1 -DMESHTASTIC_EXCLUDE_MQTT=1 - -DMESHTASTIC_EXCLUDE_BLUETOOTH=1 - -DMESHTASTIC_EXCLUDE_WIFI=1 - -DMESHTASTIC_EXCLUDE_TZ=1 ; Exclude TZ to save some flash space. - -DMESHTASTIC_EXCLUDE_XEDDSA=1 ; The Ed25519 signing code does not fit in the 256KB flash. Packets are sent unsigned, like pre-XEdDSA firmware. -DMESHTASTIC_EXCLUDE_PKT_HISTORY_HASH=1 + -DMESHTASTIC_EXCLUDE_POWERMON=1 + -DMESHTASTIC_EXCLUDE_POWER_TELEMETRY=1 -DMESHTASTIC_EXCLUDE_RANGETEST=1 + -DMESHTASTIC_EXCLUDE_RTTTL=1 ; No PWM/RTTTL ringtone playback support on this platform. + -DMESHTASTIC_EXCLUDE_SCREEN=1 + -DMESHTASTIC_EXCLUDE_TZ=1 ; Exclude TZ to save some flash space. -DMESHTASTIC_EXCLUDE_WAYPOINT=1 - -DMESHTASTIC_EXCLUDE_POWER_TELEMETRY=1 + -DMESHTASTIC_EXCLUDE_WIFI=1 + -DMESHTASTIC_EXCLUDE_XEDDSA=1 ; The Ed25519 signing code does not fit in the 256KB flash. Packets are sent unsigned, like pre-XEdDSA firmware. -DSERIAL_RX_BUFFER_SIZE=256 ; For GPS - the default of 64 is too small. -DHAS_SCREEN=0 ; Always disable screen for STM32, it is not supported. ;-DPIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF ; Enable this if enabling debugg logging. It is REQUIRED for at least traceroute debug prints - without it the length returned by printf ends up uninitialized.