From 42ac1ba4edbc29f8113164dd654da8fe10bb03df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=83=D0=B1=D0=B8=D0=BD=D0=B8=D0=BD=20=D0=94=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Wed, 3 Sep 2025 13:01:09 +0300 Subject: [PATCH 1/3] Fix excluded modules configuration handling - Add excluded_modules flags in getDeviceMetadata() for MQTT, PAXCOUNTER, STOREFORWARD, RANGETEST, NEIGHBORINFO - Add conditional compilation guards in AdminModule for RANGETEST, AUDIO, PAXCOUNTER, STOREFORWARD, EXTNOTIF, DETECTIONSENSOR, AMBIENTLIGHTING - Add skip logic in PhoneAPI for excluded modules during config enumeration - Add conditional has_* flags in NodeDB only for included modules Fixes issue where excluded modules still appeared in client applications and sometimes caused PAYLOADVARIANT_NOT_SET errors. --- src/main.cpp | 14 ++++++- src/mesh/NodeDB.cpp | 14 +++++++ src/mesh/PhoneAPI.cpp | 73 +++++++++++++++++++++++++++++++++++++ src/modules/AdminModule.cpp | 29 +++++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 73f68e95e26..2eeaa6169c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1521,6 +1521,9 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() deviceMetadata.hw_model = HW_VENDOR; deviceMetadata.hasRemoteHardware = moduleConfig.remote_hardware.enabled; deviceMetadata.excluded_modules = meshtastic_ExcludedModules_EXCLUDED_NONE; +#if MESHTASTIC_EXCLUDE_MQTT + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_MQTT_CONFIG; +#endif #if MESHTASTIC_EXCLUDE_REMOTEHARDWARE deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_REMOTEHARDWARE_CONFIG; #endif @@ -1543,9 +1546,18 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() #if NO_EXT_GPIO && NO_GPS || MESHTASTIC_EXCLUDE_SERIAL deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_SERIAL_CONFIG; #endif -#ifndef ARCH_ESP32 +#if MESHTASTIC_EXCLUDE_PAXCOUNTER deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_PAXCOUNTER_CONFIG; #endif +#if MESHTASTIC_EXCLUDE_STOREFORWARD + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_STOREFORWARD_CONFIG; +#endif +#if MESHTASTIC_EXCLUDE_RANGETEST + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_RANGETEST_CONFIG; +#endif +#if MESHTASTIC_EXCLUDE_NEIGHBORINFO + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_NEIGHBORINFO_CONFIG; +#endif #if !defined(HAS_RGB_LED) && !RAK_4631 deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_AMBIENTLIGHTING_CONFIG; #endif diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c8eba1b2e73..a3ab199ade3 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -775,7 +775,9 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.version = DEVICESTATE_CUR_VER; moduleConfig.has_mqtt = true; +#if !MESHTASTIC_EXCLUDE_RANGETEST moduleConfig.has_range_test = true; +#endif moduleConfig.has_serial = true; moduleConfig.has_store_forward = true; moduleConfig.has_telemetry = true; @@ -841,6 +843,12 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.canned_message.inputbroker_event_press = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT; #endif moduleConfig.has_canned_message = true; +#if !MESHTASTIC_EXCLUDE_AUDIO + moduleConfig.has_audio = true; +#endif +#if !MESHTASTIC_EXCLUDE_PAXCOUNTER + moduleConfig.has_paxcounter = true; +#endif #if USERPREFS_MQTT_ENABLED && !MESHTASTIC_EXCLUDE_MQTT moduleConfig.mqtt.enabled = true; #endif @@ -1428,15 +1436,21 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat) moduleConfig.has_canned_message = true; moduleConfig.has_external_notification = true; moduleConfig.has_mqtt = true; +#if !MESHTASTIC_EXCLUDE_RANGETEST moduleConfig.has_range_test = true; +#endif moduleConfig.has_serial = true; moduleConfig.has_store_forward = true; moduleConfig.has_telemetry = true; moduleConfig.has_neighbor_info = true; moduleConfig.has_detection_sensor = true; moduleConfig.has_ambient_lighting = true; +#if !MESHTASTIC_EXCLUDE_AUDIO moduleConfig.has_audio = true; +#endif +#if !MESHTASTIC_EXCLUDE_PAXCOUNTER moduleConfig.has_paxcounter = true; +#endif success &= saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig); diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index a3a8a208712..ed1e153bf3e 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -354,20 +354,63 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.payload_variant.serial = moduleConfig.serial; break; case meshtastic_ModuleConfig_external_notification_tag: +#if !(NO_EXT_GPIO || MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION) LOG_DEBUG("Send module config: ext notification"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_external_notification_tag; fromRadioScratch.moduleConfig.payload_variant.external_notification = moduleConfig.external_notification; break; +#else + LOG_DEBUG("External Notification module excluded from build, skipping"); + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +#endif case meshtastic_ModuleConfig_store_forward_tag: +#if !MESHTASTIC_EXCLUDE_STOREFORWARD LOG_DEBUG("Send module config: store forward"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_store_forward_tag; fromRadioScratch.moduleConfig.payload_variant.store_forward = moduleConfig.store_forward; break; +#else + LOG_DEBUG("Store & Forward module excluded from build, skipping"); + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +#endif case meshtastic_ModuleConfig_range_test_tag: +#if !MESHTASTIC_EXCLUDE_RANGETEST LOG_DEBUG("Send module config: range test"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_range_test_tag; fromRadioScratch.moduleConfig.payload_variant.range_test = moduleConfig.range_test; break; +#else + LOG_DEBUG("Range Test module excluded from build, skipping"); + // Skip this config completely - advance to next without sending + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +#endif case meshtastic_ModuleConfig_telemetry_tag: LOG_DEBUG("Send module config: telemetry"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_telemetry_tag; @@ -379,10 +422,25 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.payload_variant.canned_message = moduleConfig.canned_message; break; case meshtastic_ModuleConfig_audio_tag: +#if !MESHTASTIC_EXCLUDE_AUDIO LOG_DEBUG("Send module config: audio"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_audio_tag; fromRadioScratch.moduleConfig.payload_variant.audio = moduleConfig.audio; break; +#else + LOG_DEBUG("Audio module excluded from build, skipping"); + // Skip this config completely - advance to next without sending + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +#endif case meshtastic_ModuleConfig_remote_hardware_tag: LOG_DEBUG("Send module config: remote hardware"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_remote_hardware_tag; @@ -404,10 +462,25 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.payload_variant.ambient_lighting = moduleConfig.ambient_lighting; break; case meshtastic_ModuleConfig_paxcounter_tag: +#if !MESHTASTIC_EXCLUDE_PAXCOUNTER LOG_DEBUG("Send module config: paxcounter"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_paxcounter_tag; fromRadioScratch.moduleConfig.payload_variant.paxcounter = moduleConfig.paxcounter; break; +#else + LOG_DEBUG("Paxcounter module excluded from build, skipping"); + // Skip this config completely - advance to next without sending + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +#endif default: LOG_ERROR("Unknown module config type %d", config_state); } diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 407003f7e1b..736ec8e7080 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -1040,19 +1040,32 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const res.get_module_config_response.payload_variant.serial = moduleConfig.serial; break; case meshtastic_AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG: +#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION LOG_INFO("Get module config: External Notification"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_external_notification_tag; res.get_module_config_response.payload_variant.external_notification = moduleConfig.external_notification; +#else + LOG_DEBUG("External Notification module excluded from build, skipping config"); +#endif break; case meshtastic_AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG: +#if !MESHTASTIC_EXCLUDE_STOREFORWARD LOG_INFO("Get module config: Store & Forward"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_store_forward_tag; res.get_module_config_response.payload_variant.store_forward = moduleConfig.store_forward; +#else + LOG_DEBUG("Store & Forward module excluded from build, skipping config"); +#endif break; case meshtastic_AdminMessage_ModuleConfigType_RANGETEST_CONFIG: +#if !MESHTASTIC_EXCLUDE_RANGETEST LOG_INFO("Get module config: Range Test"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_range_test_tag; res.get_module_config_response.payload_variant.range_test = moduleConfig.range_test; +#else + LOG_DEBUG("Range Test module excluded from build, skipping config"); + // Don't set payload variant - will result in empty response +#endif break; case meshtastic_AdminMessage_ModuleConfigType_TELEMETRY_CONFIG: LOG_INFO("Get module config: Telemetry"); @@ -1065,9 +1078,13 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const res.get_module_config_response.payload_variant.canned_message = moduleConfig.canned_message; break; case meshtastic_AdminMessage_ModuleConfigType_AUDIO_CONFIG: +#if !MESHTASTIC_EXCLUDE_AUDIO LOG_INFO("Get module config: Audio"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_audio_tag; res.get_module_config_response.payload_variant.audio = moduleConfig.audio; +#else + LOG_DEBUG("Audio module excluded from build, skipping config"); +#endif break; case meshtastic_AdminMessage_ModuleConfigType_REMOTEHARDWARE_CONFIG: LOG_INFO("Get module config: Remote Hardware"); @@ -1080,19 +1097,31 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const res.get_module_config_response.payload_variant.neighbor_info = moduleConfig.neighbor_info; break; case meshtastic_AdminMessage_ModuleConfigType_DETECTIONSENSOR_CONFIG: +#if !(NO_EXT_GPIO || MESHTASTIC_EXCLUDE_DETECTIONSENSOR) LOG_INFO("Get module config: Detection Sensor"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_detection_sensor_tag; res.get_module_config_response.payload_variant.detection_sensor = moduleConfig.detection_sensor; +#else + LOG_DEBUG("Detection Sensor module excluded from build, skipping config"); +#endif break; case meshtastic_AdminMessage_ModuleConfigType_AMBIENTLIGHTING_CONFIG: +#if !defined(HAS_RGB_LED) && !RAK_4631 + LOG_DEBUG("Ambient Lighting module excluded from build, skipping config"); +#else LOG_INFO("Get module config: Ambient Lighting"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_ambient_lighting_tag; res.get_module_config_response.payload_variant.ambient_lighting = moduleConfig.ambient_lighting; +#endif break; case meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG: +#if !MESHTASTIC_EXCLUDE_PAXCOUNTER LOG_INFO("Get module config: Paxcounter"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_paxcounter_tag; res.get_module_config_response.payload_variant.paxcounter = moduleConfig.paxcounter; +#else + LOG_DEBUG("Paxcounter module excluded from build, skipping config"); +#endif break; } From 019f0fef7e912cedd2092879b4026ec30cf7ad38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=83=D0=B1=D0=B8=D0=BD=D0=B8=D0=BD=20=D0=94=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 4 Sep 2025 16:25:15 +0300 Subject: [PATCH 2/3] Fix excluded modules issues and refactor code - Restore original PAXCOUNTER logic: only exclude on non-ESP32 platforms due to memory constraints - Fix has_store_forward flag to be conditionally compiled based on MESHTASTIC_EXCLUDE_STOREFORWARD - Refactor PhoneAPI module config skipping logic to use helper function skipExcludedModuleConfig() - Reduce code duplication in PhoneAPI by extracting common skip logic This addresses the three issues identified in the code review: 1. PAXCOUNTER memory impact on non-ESP32 devices 2. Unconditional has_store_forward flag setting 3. Duplicated state management logic across multiple #else blocks --- src/main.cpp | 4 ++- src/mesh/NodeDB.cpp | 2 ++ src/mesh/PhoneAPI.cpp | 73 ++++++++++++------------------------------- src/mesh/PhoneAPI.h | 3 ++ 4 files changed, 28 insertions(+), 54 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2eeaa6169c5..69d1e1de4c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1546,7 +1546,9 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() #if NO_EXT_GPIO && NO_GPS || MESHTASTIC_EXCLUDE_SERIAL deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_SERIAL_CONFIG; #endif -#if MESHTASTIC_EXCLUDE_PAXCOUNTER +#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_PAXCOUNTER + // PAXCOUNTER is only supported on ESP32 due to memory constraints +#else deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_PAXCOUNTER_CONFIG; #endif #if MESHTASTIC_EXCLUDE_STOREFORWARD diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index a3ab199ade3..2817163ab66 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1440,7 +1440,9 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat) moduleConfig.has_range_test = true; #endif moduleConfig.has_serial = true; +#if !MESHTASTIC_EXCLUDE_STOREFORWARD moduleConfig.has_store_forward = true; +#endif moduleConfig.has_telemetry = true; moduleConfig.has_neighbor_info = true; moduleConfig.has_detection_sensor = true; diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index ed1e153bf3e..b16d52a1335 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -34,6 +34,21 @@ // Flag to indicate a heartbeat was received and we should send queue status bool heartbeatReceived = false; +// Helper function to skip excluded module configs and advance state +size_t PhoneAPI::skipExcludedModuleConfig(uint8_t *buf) +{ + config_state++; + if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { + if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { + state = STATE_SEND_FILEMANIFEST; + } else { + state = STATE_SEND_OTHER_NODEINFOS; + } + config_state = 0; + } + return getFromRadio(buf); +} + PhoneAPI::PhoneAPI() { lastContactMsec = millis(); @@ -361,16 +376,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; #else LOG_DEBUG("External Notification module excluded from build, skipping"); - config_state++; - if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { - state = STATE_SEND_FILEMANIFEST; - } else { - state = STATE_SEND_OTHER_NODEINFOS; - } - config_state = 0; - } - return getFromRadio(buf); + return skipExcludedModuleConfig(buf); #endif case meshtastic_ModuleConfig_store_forward_tag: #if !MESHTASTIC_EXCLUDE_STOREFORWARD @@ -380,16 +386,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; #else LOG_DEBUG("Store & Forward module excluded from build, skipping"); - config_state++; - if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { - state = STATE_SEND_FILEMANIFEST; - } else { - state = STATE_SEND_OTHER_NODEINFOS; - } - config_state = 0; - } - return getFromRadio(buf); + return skipExcludedModuleConfig(buf); #endif case meshtastic_ModuleConfig_range_test_tag: #if !MESHTASTIC_EXCLUDE_RANGETEST @@ -399,17 +396,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; #else LOG_DEBUG("Range Test module excluded from build, skipping"); - // Skip this config completely - advance to next without sending - config_state++; - if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { - state = STATE_SEND_FILEMANIFEST; - } else { - state = STATE_SEND_OTHER_NODEINFOS; - } - config_state = 0; - } - return getFromRadio(buf); + return skipExcludedModuleConfig(buf); #endif case meshtastic_ModuleConfig_telemetry_tag: LOG_DEBUG("Send module config: telemetry"); @@ -429,17 +416,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; #else LOG_DEBUG("Audio module excluded from build, skipping"); - // Skip this config completely - advance to next without sending - config_state++; - if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { - state = STATE_SEND_FILEMANIFEST; - } else { - state = STATE_SEND_OTHER_NODEINFOS; - } - config_state = 0; - } - return getFromRadio(buf); + return skipExcludedModuleConfig(buf); #endif case meshtastic_ModuleConfig_remote_hardware_tag: LOG_DEBUG("Send module config: remote hardware"); @@ -469,17 +446,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; #else LOG_DEBUG("Paxcounter module excluded from build, skipping"); - // Skip this config completely - advance to next without sending - config_state++; - if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - if (config_nonce == SPECIAL_NONCE_ONLY_CONFIG) { - state = STATE_SEND_FILEMANIFEST; - } else { - state = STATE_SEND_OTHER_NODEINFOS; - } - config_state = 0; - } - return getFromRadio(buf); + return skipExcludedModuleConfig(buf); #endif default: LOG_ERROR("Unknown module config type %d", config_state); diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 0d7772d1761..6b4bb6fc1b7 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -172,4 +172,7 @@ class PhoneAPI /// If the mesh service tells us fromNum has changed, tell the phone virtual int onNotify(uint32_t newValue) override; + + /// Helper function to skip excluded module configs and advance state + size_t skipExcludedModuleConfig(uint8_t *buf); }; From b69460f8e948d428c4cef71eca054fd8975cd27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=83=D0=B1=D0=B8=D0=BD=D0=B8=D0=BD=20=D0=94=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 4 Sep 2025 18:01:47 +0300 Subject: [PATCH 3/3] Fix ambient lighting module exclusion in PhoneAPI and AdminModule - Add conditional compilation guards for ambient lighting in PhoneAPI.cpp - Replace old HAS_RGB_LED logic with MESHTASTIC_EXCLUDE_AMBIENTLIGHTING check in AdminModule.cpp - Ensure ambient lighting module is properly excluded when MESHTASTIC_EXCLUDE_AMBIENTLIGHTING=1 --- src/configuration.h | 1 + src/main.cpp | 2 +- src/mesh/NodeDB.cpp | 4 ++++ src/mesh/PhoneAPI.cpp | 5 +++++ src/modules/AdminModule.cpp | 6 +++--- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 81632c89e17..d5adba02892 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -431,6 +431,7 @@ along with this program. If not, see . #define MESHTASTIC_EXCLUDE_SERIAL 1 #define MESHTASTIC_EXCLUDE_POWERSTRESS 1 #define MESHTASTIC_EXCLUDE_ADMIN 1 +#define MESHTASTIC_EXCLUDE_AMBIENTLIGHTING 1 #endif // // Turn off wifi even if HW supports wifi (webserver relies on wifi and is also disabled) diff --git a/src/main.cpp b/src/main.cpp index 69d1e1de4c2..b941e3e819f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1560,7 +1560,7 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() #if MESHTASTIC_EXCLUDE_NEIGHBORINFO deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_NEIGHBORINFO_CONFIG; #endif -#if !defined(HAS_RGB_LED) && !RAK_4631 +#if (!defined(HAS_RGB_LED) && !defined(RAK_4631)) || defined(MESHTASTIC_EXCLUDE_AMBIENTLIGHTING) deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_AMBIENTLIGHTING_CONFIG; #endif diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 2817163ab66..59ad7424657 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -891,12 +891,14 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.detection_sensor.detection_trigger_type = meshtastic_ModuleConfig_DetectionSensorConfig_TriggerType_LOGIC_HIGH; moduleConfig.detection_sensor.minimum_broadcast_secs = 45; +#if !MESHTASTIC_EXCLUDE_AMBIENTLIGHTING moduleConfig.has_ambient_lighting = true; moduleConfig.ambient_lighting.current = 10; // Default to a color based on our node number moduleConfig.ambient_lighting.red = (myNodeInfo.my_node_num & 0xFF0000) >> 16; moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8; moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF; +#endif initModuleConfigIntervals(); } @@ -1446,7 +1448,9 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat) moduleConfig.has_telemetry = true; moduleConfig.has_neighbor_info = true; moduleConfig.has_detection_sensor = true; +#if !MESHTASTIC_EXCLUDE_AMBIENTLIGHTING moduleConfig.has_ambient_lighting = true; +#endif #if !MESHTASTIC_EXCLUDE_AUDIO moduleConfig.has_audio = true; #endif diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index b16d52a1335..d11eff9e718 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -434,10 +434,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.moduleConfig.payload_variant.detection_sensor = moduleConfig.detection_sensor; break; case meshtastic_ModuleConfig_ambient_lighting_tag: +#if !MESHTASTIC_EXCLUDE_AMBIENTLIGHTING LOG_DEBUG("Send module config: ambient lighting"); fromRadioScratch.moduleConfig.which_payload_variant = meshtastic_ModuleConfig_ambient_lighting_tag; fromRadioScratch.moduleConfig.payload_variant.ambient_lighting = moduleConfig.ambient_lighting; break; +#else + LOG_DEBUG("Ambient Lighting module excluded from build, skipping"); + return skipExcludedModuleConfig(buf); +#endif case meshtastic_ModuleConfig_paxcounter_tag: #if !MESHTASTIC_EXCLUDE_PAXCOUNTER LOG_DEBUG("Send module config: paxcounter"); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 736ec8e7080..78c101765ae 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -1106,12 +1106,12 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const #endif break; case meshtastic_AdminMessage_ModuleConfigType_AMBIENTLIGHTING_CONFIG: -#if !defined(HAS_RGB_LED) && !RAK_4631 - LOG_DEBUG("Ambient Lighting module excluded from build, skipping config"); -#else +#if !MESHTASTIC_EXCLUDE_AMBIENTLIGHTING LOG_INFO("Get module config: Ambient Lighting"); res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_ambient_lighting_tag; res.get_module_config_response.payload_variant.ambient_lighting = moduleConfig.ambient_lighting; +#else + LOG_DEBUG("Ambient Lighting module excluded from build, skipping config"); #endif break; case meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG: