mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 18:22:32 +00:00
Fix excluded modules configuration handling (#7838)
* 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. * 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 * 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
This commit is contained in:
@@ -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
|
||||
@@ -883,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();
|
||||
}
|
||||
@@ -1428,15 +1438,25 @@ 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;
|
||||
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
||||
moduleConfig.has_store_forward = true;
|
||||
#endif
|
||||
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
|
||||
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
|
||||
moduleConfig.has_paxcounter = true;
|
||||
#endif
|
||||
|
||||
success &=
|
||||
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
|
||||
|
||||
Reference in New Issue
Block a user