From 667b4ef0f2f5183a062fecf591e024068f0ab34e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 10 Nov 2024 13:36:49 -0600 Subject: [PATCH] Exclude some niche modules by default and populate exclude_modules (#5300) * Exclude some niche modules by default * Start of intelligently excluding modules --------- Co-authored-by: Tom Fifield --- arch/nrf52/nrf52.ini | 1 + platformio.ini | 3 +++ src/main.cpp | 25 +++++++++++++++++++++ variants/heltec_wireless_paper/variant.h | 3 +++ variants/heltec_wireless_paper_v1/variant.h | 3 +++ variants/t-echo/variant.h | 2 ++ 6 files changed, 37 insertions(+) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 1af68198bf..99b38900b2 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -14,6 +14,7 @@ build_flags = -Wno-unused-variable -Isrc/platform/nrf52 -DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818 + -DMESHTASTIC_EXCLUDE_AUDIO=1 build_src_filter = ${arduino_base.build_src_filter} - - - - - - - - - - diff --git a/platformio.ini b/platformio.ini index 03a8a301c3..7057d574f6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,6 +53,7 @@ extra_scripts = bin/platformio-custom.py ; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc ; The Radiolib stuff will speed up building considerably. Exclud all the stuff we dont need. build_flags = -Wno-missing-field-initializers + -Wno-format -Isrc -Isrc/mesh -Isrc/mesh/generated -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map -DUSE_THREAD_NAMES @@ -80,8 +81,10 @@ build_flags = -Wno-missing-field-initializers -DRADIOLIB_EXCLUDE_LORAWAN=1 -DMESHTASTIC_EXCLUDE_DROPZONE=1 -DMESHTASTIC_EXCLUDE_REMOTEHARDWARE=1 + -DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware #-DBUILD_EPOCH=$UNIX_TIME ;-D OLED_PL + monitor_speed = 115200 monitor_filters = direct lib_deps = diff --git a/src/main.cpp b/src/main.cpp index 9f765eeb29..97a64a378d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1161,6 +1161,31 @@ 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_REMOTEHARDWARE + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_REMOTEHARDWARE_CONFIG; +#endif +#if MESHTASTIC_EXCLUDE_AUDIO + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_AUDIO_CONFIG; +#endif +#if !HAS_SCREEN || NO_EXT_GPIO + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_CANNEDMSG_CONFIG | meshtastic_ExcludedModules_EXTNOTIF_CONFIG; +#endif +// Only edge case here is if we apply this a device with built in Accelerometer and want to detect interrupts +// We'll have to macro guard against those targets potentially +#if NO_EXT_GPIO + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_DETECTIONSENSOR_CONFIG; +#endif +// If we don't have any GPIO and we don't have GPS, no purpose in having serial config +#if NO_EXT_GPIO && NO_GPS + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_SERIAL_CONFIG; +#endif +#ifndef ARCH_ESP32 + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_PAXCOUNTER_CONFIG; +#endif +#if !defined(HAS_NCP5623) && !defined(RGBLED_RED) && !defined(HAS_NEOPIXEL) && !defined(UNPHONE) && !RAK_4631 + deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_AMBIENTLIGHTING_CONFIG; +#endif + #if !(MESHTASTIC_EXCLUDE_PKI) deviceMetadata.hasPKC = true; #endif diff --git a/variants/heltec_wireless_paper/variant.h b/variants/heltec_wireless_paper/variant.h index 520dcec9b3..fe8f391df4 100644 --- a/variants/heltec_wireless_paper/variant.h +++ b/variants/heltec_wireless_paper/variant.h @@ -32,6 +32,9 @@ #define HAS_32768HZ #define ADC_CTRL_ENABLED LOW +#define NO_EXT_GPIO 1 +#define NO_GPS 1 + // LoRa #define USE_SX1262 diff --git a/variants/heltec_wireless_paper_v1/variant.h b/variants/heltec_wireless_paper_v1/variant.h index 520dcec9b3..fe8f391df4 100644 --- a/variants/heltec_wireless_paper_v1/variant.h +++ b/variants/heltec_wireless_paper_v1/variant.h @@ -32,6 +32,9 @@ #define HAS_32768HZ #define ADC_CTRL_ENABLED LOW +#define NO_EXT_GPIO 1 +#define NO_GPS 1 + // LoRa #define USE_SX1262 diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 9abb4ea69d..365dfd804f 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -216,6 +216,8 @@ External serial flash WP25R1635FZUIL0 #define VBAT_AR_INTERNAL AR_INTERNAL_3_0 #define ADC_MULTIPLIER (2.0F) +#define NO_EXT_GPIO 1 + #define HAS_RTC 1 #ifdef __cplusplus