diff --git a/build.sh b/build.sh index d1a19d49b..b1ce554e0 100755 --- a/build.sh +++ b/build.sh @@ -90,7 +90,7 @@ $ bash build.sh Build all firmwares for device targets containing the string "RAK_4631" $ bash build.sh build-matching-firmwares -Build all firmwares in three profiles, adding MQTT observer firmware with logging off after the logging-off and logging-on passes: +Build all firmwares in three mutually exclusive profiles: standard, USB logging, and MQTT observer (USB logging off): $ bash build.sh build-firmwares-logging-matrix Build all companion firmwares @@ -1509,6 +1509,16 @@ apply_debug_overrides() { esac } +disable_usb_logging_for_mqtt() { + local env_name=$1 + + if is_mqtt_bridge_target "$env_name" || [ "${MQTT_BRIDGE_OVERRIDE,,}" == "on" ]; then + # MQTT observers already export packet traffic through the bridge. Keep the + # serial console available for the CLI without compiling a second logging path. + export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -UMESH_DEBUG -UMESH_PACKET_LOGGING -UMQTT_DEBUG -UMQTT_MEMORY_DEBUG" + fi +} + is_lora_ota_build() { local env_name=$1 local env_name_lc=${env_name,,} @@ -1526,10 +1536,11 @@ is_lora_ota_build() { return 1 fi - # PlatformIO environment names are not consistently cased (for example, several ESP32 targets use - # `_Repeater`). Match roles case-insensitively while keeping OTA limited to unattended deployments. + # LoRa firmware distribution is a repeater-only feature. MQTT observers use + # their WiFi manifest updater; companion, room-server, and sensor roles do not + # advertise or accept firmware over the mesh. case "$env_name_lc" in - *repeater*|*repeatr*|*room_server*|*room_svr*|*sensor*) return 0 ;; + *repeater*|*repeatr*) return 0 ;; *) return 1 ;; esac } @@ -1720,7 +1731,10 @@ get_firmware_filename() { local firmware_version_string=$2 local filename_infix=$FIRMWARE_FILENAME_INFIX - if [ -z "$filename_infix" ] && [ "${PACKET_LOGGING_OVERRIDE,,}" == "on" ]; then + if [ -z "$filename_infix" ] \ + && [ "${PACKET_LOGGING_OVERRIDE,,}" == "on" ] \ + && [ "${MQTT_BRIDGE_OVERRIDE,,}" != "on" ] \ + && ! is_mqtt_bridge_target "$env_name"; then filename_infix="logging" fi @@ -1823,6 +1837,7 @@ build_firmware() { disable_debug_flags apply_debug_overrides apply_mqtt_bridge_override + disable_usb_logging_for_mqtt "$env_name" apply_lora_ota_override "$env_name" apply_radio_overrides apply_firmware_profile_overrides @@ -2282,8 +2297,15 @@ main() { if is_logging_matrix_command "${SELECTED_COMMAND_ARGS[0]}"; then echo "Skipping debug and MQTT prompts; this action builds all three profiles automatically." else - prompt_for_debug_build_settings prompt_for_mqtt_bridge_build_setting + if [ "${MQTT_BRIDGE_OVERRIDE,,}" == "on" ]; then + MESHDEBUG_OVERRIDE="off" + PACKET_LOGGING_OVERRIDE="off" + MQTT_DEBUG_OVERRIDE="off" + echo "MQTT bridge selected; USB debug and packet logging are disabled." + else + prompt_for_debug_build_settings + fi fi prompt_for_radio_build_settings prompt_for_firmware_profile_settings diff --git a/variants/station_g2/platformio.ini b/variants/station_g2/platformio.ini index 2dfe8ec00..ac119693c 100644 --- a/variants/station_g2/platformio.ini +++ b/variants/station_g2/platformio.ini @@ -1,7 +1,9 @@ [Station_G2] extends = esp32_base board = station-g2 -board_build.partitions = default_16MB.csv +; Preserve the original 0x10000/0x150000 dual-OTA layout so app-only updates do +; not require replacing the partition table or erasing an installed G2. +board_build.partitions = default.csv build_flags = ${esp32_base.build_flags} ${sensor_base.build_flags} @@ -32,6 +34,10 @@ build_flags = -D SX126X_RX_BOOSTED_GAIN=0 ; Default value when 'radio.rxgain' has not been set. Must be OFF for the Station G2, see: ; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance -D DISPLAY_CLASS=SH1106Display + ; Keep the browser firmware uploader, but use CLI configuration so ordinary + ; G2 roles remain below each legacy 0x140000 (1.25 MiB) application slot. + -D LIGHTWEIGHT_WIFI_OTA=1 + -D WEBCONFIG_DISABLED=1 build_src_filter = ${esp32_base.build_src_filter} +<../variants/station_g2> + @@ -45,7 +51,7 @@ lib_deps = [env:Station_G2_repeater] extends = Station_G2 -board_build.partitions = default_16MB.csv ; standard 16MB partition table (compatible with MQTT bridge) +board_build.partitions = default.csv build_flags = ${Station_G2.build_flags} -D ADVERT_NAME='"Station G2 Repeater"' @@ -182,6 +188,16 @@ board_ssl_cert_source = adafruit-full board_build.embed_files = src/certs/x509_crt_bundle.bin build_flags = ${Station_G2.build_flags} + ; MQTT observers retain the full WebConfig portal and large 16 MB layout, but + ; update over WiFi rather than distributing firmware over LoRa. + -ULIGHTWEIGHT_WIFI_OTA + -UWEBCONFIG_DISABLED + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 + -UMESH_DEBUG + -UMESH_PACKET_LOGGING + -UMQTT_DEBUG + -UMQTT_MEMORY_DEBUG -D ADVERT_NAME='"Station G2 Room Observer"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -191,7 +207,6 @@ build_flags = -D OTA_MANIFEST_BASE='"https://observer.gessaman.com/v"' -D MAX_MQTT_BROKERS=3 -D MQTT_MAX_PACKET_SIZE=1024 - -D MQTT_DEBUG=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -D CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y @@ -217,6 +232,8 @@ build_src_filter = ${Station_G2.build_src_filter} +<../examples/simple_room_server> build_flags = ${Station_G2.build_flags} + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 -D ADVERT_NAME='"Station G2 Room"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -232,6 +249,8 @@ lib_deps = extends = Station_G2 build_flags = ${Station_G2.build_flags} + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 -I examples/companion_radio/ui-new -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 @@ -249,11 +268,16 @@ lib_deps = extends = Station_G2 build_flags = ${Station_G2.build_flags} + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 + ; BLE plus the optional VL53L0X/BME680 drivers leaves no safe growth margin + ; in a legacy slot. Common temperature, pressure, current, and GPS sensors remain. + -UENV_INCLUDE_VL53L0X + -UENV_INCLUDE_BME680 -I examples/companion_radio/ui-new -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 -D BLE_PIN_CODE=123456 - -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -269,6 +293,8 @@ lib_deps = extends = Station_G2 build_flags = ${Station_G2.build_flags} + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 -I examples/companion_radio/ui-new -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 @@ -288,6 +314,10 @@ lib_deps = [env:Station_G2_kiss_modem] extends = Station_G2 +build_flags = + ${Station_G2.build_flags} + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 build_src_filter = ${Station_G2.build_src_filter} +<../examples/kiss_modem/> @@ -301,6 +331,16 @@ board_ssl_cert_source = adafruit-full board_build.embed_files = src/certs/x509_crt_bundle.bin build_flags = ${Station_G2.build_flags} + ; MQTT observers retain the full WebConfig portal and large 16 MB layout, but + ; update over WiFi rather than distributing firmware over LoRa. + -ULIGHTWEIGHT_WIFI_OTA + -UWEBCONFIG_DISABLED + -UENABLE_OTA + -D DISABLE_LORA_OTA=1 + -UMESH_DEBUG + -UMESH_PACKET_LOGGING + -UMQTT_DEBUG + -UMQTT_MEMORY_DEBUG -D ADVERT_NAME='"MQTT Observer"' -D ADVERT_LAT=0.0 -D ADVERT_LON=0.0 @@ -310,7 +350,6 @@ build_flags = -D OTA_MANIFEST_BASE='"https://observer.gessaman.com/v"' -D MAX_MQTT_BROKERS=3 -D MQTT_MAX_PACKET_SIZE=1024 - -D MQTT_DEBUG=1 # -D MESH_PACKET_LOGGING=1 # -D MESH_DEBUG=1 -D CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y