diff --git a/.github/workflows/build_esp32.yml b/.github/workflows/build_esp32.yml deleted file mode 100644 index 2c4622f43..000000000 --- a/.github/workflows/build_esp32.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build ESP32 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-esp32: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build ESP32 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: esp32 - pio_env: ${{ inputs.board }} - pio_target: build - ota_firmware_source: firmware.bin - ota_firmware_target: release/bleota.bin - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-esp32-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.bin - release/*.elf diff --git a/.github/workflows/build_esp32_c3.yml b/.github/workflows/build_esp32_c3.yml deleted file mode 100644 index 3e7746166..000000000 --- a/.github/workflows/build_esp32_c3.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build ESP32-C3 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-esp32-c3: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build ESP32-C3 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: esp32 - pio_env: ${{ inputs.board }} - pio_target: build - ota_firmware_source: firmware-c3.bin - ota_firmware_target: release/bleota-c3.bin - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-esp32c3-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.bin - release/*.elf diff --git a/.github/workflows/build_esp32_c6.yml b/.github/workflows/build_esp32_c6.yml deleted file mode 100644 index 6f32eb3c6..000000000 --- a/.github/workflows/build_esp32_c6.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build ESP32-C6 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-esp32-c6: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build ESP32-C6 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: esp32 - pio_env: ${{ inputs.board }} - pio_target: build - ota_firmware_source: firmware-c3.bin - ota_firmware_target: release/bleota-c3.bin - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-esp32c6-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.bin - release/*.elf diff --git a/.github/workflows/build_esp32_s3.yml b/.github/workflows/build_esp32_s3.yml deleted file mode 100644 index 6527d6d7c..000000000 --- a/.github/workflows/build_esp32_s3.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build ESP32-S3 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-esp32-s3: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build ESP32-S3 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: esp32 - pio_env: ${{ inputs.board }} - pio_target: build - ota_firmware_source: firmware-s3.bin - ota_firmware_target: release/bleota-s3.bin - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-esp32s3-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.bin - release/*.elf diff --git a/.github/workflows/build_firmware.yml b/.github/workflows/build_firmware.yml new file mode 100644 index 000000000..df1035e62 --- /dev/null +++ b/.github/workflows/build_firmware.yml @@ -0,0 +1,66 @@ +name: Build + +on: + workflow_call: + inputs: + version: + required: true + type: string + platform: + required: true + type: string + pio_env: + required: true + type: string + +permissions: read-all + +jobs: + pio-build: + name: build-${{ inputs.platform }} + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Set OTA firmware source and target + if: startsWith(inputs.platform, 'esp32') + id: ota_dir + env: + PIO_PLATFORM: ${{ inputs.platform }} + run: | + if [ "$PIO_PLATFORM" = "esp32s3" ]; then + echo "src=firmware-s3.bin" >> $GITHUB_OUTPUT + echo "tgt=release/bleota-s3.bin" >> $GITHUB_OUTPUT + elif [ "$PIO_PLATFORM" = "esp32c3" ] || [ "$PIO_PLATFORM" = "esp32c6" ]; then + echo "src=firmware-c3.bin" >> $GITHUB_OUTPUT + echo "tgt=release/bleota-c3.bin" >> $GITHUB_OUTPUT + elif [ "$PIO_PLATFORM" = "esp32" ]; then + echo "src=firmware.bin" >> $GITHUB_OUTPUT + echo "tgt=release/bleota.bin" >> $GITHUB_OUTPUT + fi + + - name: Build ${{ inputs.platform }} + id: build + uses: meshtastic/gh-action-firmware@main + with: + pio_platform: ${{ inputs.platform }} + pio_env: ${{ inputs.pio_env }} + pio_target: build + ota_firmware_source: ${{ steps.ota_dir.outputs.src || '' }} + ota_firmware_target: ${{ steps.ota_dir.outputs.tgt || '' }} + + - name: Store binaries as an artifact + uses: actions/upload-artifact@v4 + with: + name: firmware-${{ inputs.platform }}-${{ inputs.pio_env }}-${{ inputs.version }}.zip + overwrite: true + path: | + release/*.bin + release/*.elf + release/*.uf2 + release/*.hex + release/*-ota.zip diff --git a/.github/workflows/build_nrf52.yml b/.github/workflows/build_nrf52.yml deleted file mode 100644 index 89be40187..000000000 --- a/.github/workflows/build_nrf52.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build NRF52 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-nrf52: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build NRF52 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: nrf52 - pio_env: ${{ inputs.board }} - pio_target: build - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-nrf52840-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.uf2 - release/*.elf - release/*.hex - release/*-ota.zip diff --git a/.github/workflows/build_rpi2040.yml b/.github/workflows/build_rpi2040.yml deleted file mode 100644 index fbaa21684..000000000 --- a/.github/workflows/build_rpi2040.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build RPI2040 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-rpi2040: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build Raspberry Pi 2040 - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: rp2xx0 - pio_env: ${{ inputs.board }} - pio_target: build - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-rp2040-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.uf2 - release/*.elf diff --git a/.github/workflows/build_stm32.yml b/.github/workflows/build_stm32.yml deleted file mode 100644 index f06e8f3b8..000000000 --- a/.github/workflows/build_stm32.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Build STM32 - -on: - workflow_call: - inputs: - version: - required: true - type: string - board: - required: true - type: string - -permissions: read-all - -jobs: - build-stm32: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Build STM32WL - id: build - uses: meshtastic/gh-action-firmware@main - with: - pio_platform: stm32wl - pio_env: ${{ inputs.board }} - pio_target: build - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v4 - with: - name: firmware-stm32-${{ inputs.board }}-${{ inputs.version }}.zip - overwrite: true - path: | - release/*.hex - release/*.bin - release/*.elf diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 9d5cb0981..0760c0491 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -31,10 +31,16 @@ jobs: fail-fast: false matrix: arch: [esp32, esp32s3, esp32c3, esp32c6, nrf52840, rp2040, stm32, check] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - id: jsonStep + - uses: actions/setup-python@v5 + with: + python-version: 3.x + cache: pip + - run: pip install -U platformio + - name: Generate matrix + id: jsonStep run: | if [[ "$GITHUB_HEAD_REF" == "" ]]; then TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}}) @@ -89,70 +95,77 @@ jobs: strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32) }} - uses: ./.github/workflows/build_esp32.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: esp32 - build-esp32-s3: + build-esp32s3: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32s3) }} - uses: ./.github/workflows/build_esp32_s3.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: esp32s3 - build-esp32-c3: + build-esp32c3: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32c3) }} - uses: ./.github/workflows/build_esp32_c3.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: esp32c3 - build-esp32-c6: + build-esp32c6: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32c6) }} - uses: ./.github/workflows/build_esp32_c6.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: esp32c6 - build-nrf52: + build-nrf52840: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.nrf52840) }} - uses: ./.github/workflows/build_nrf52.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: nrf52840 build-rpi2040: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.rp2040) }} - uses: ./.github/workflows/build_rpi2040.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: rp2040 build-stm32: needs: [setup, version] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.stm32) }} - uses: ./.github/workflows/build_stm32.yml + uses: ./.github/workflows/build_firmware.yml with: version: ${{ needs.version.outputs.long }} - board: ${{ matrix.board }} + pio_env: ${{ matrix.board }} + platform: stm32 build-debian-src: if: github.repository == 'meshtastic/firmware' @@ -236,10 +249,10 @@ jobs: [ version, build-esp32, - build-esp32-s3, - build-esp32-c3, - build-esp32-c6, - build-nrf52, + build-esp32s3, + build-esp32c3, + build-esp32c6, + build-nrf52840, build-rpi2040, build-stm32, ] diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index d6a8cc8c1..2d4d3fc16 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -9,9 +9,9 @@ plugins: lint: enabled: - checkov@3.2.451 - - renovate@41.38.1 + - renovate@41.40.0 - prettier@3.6.2 - - trufflehog@3.90.0 + - trufflehog@3.90.1 - yamllint@1.37.1 - bandit@1.8.6 - trivy@0.64.1 @@ -28,7 +28,7 @@ lint: - shellcheck@0.10.0 - black@25.1.0 - git-diff-check - - gitleaks@8.27.2 + - gitleaks@8.28.0 - clang-format@16.0.3 ignore: - linters: [ALL] diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py index 0ce6b0f6b..acc0a9fb7 100755 --- a/bin/generate_ci_matrix.py +++ b/bin/generate_ci_matrix.py @@ -2,50 +2,67 @@ """Generate the CI matrix.""" -import configparser import json -import os import sys import random - -rootdir = "variants/" +import re +from platformio.project.config import ProjectConfig options = sys.argv[1:] outlist = [] if len(options) < 1: - print(json.dumps(outlist)) - exit() + print(json.dumps(outlist)) + exit(1) -for subdir, dirs, files in os.walk(rootdir): - for file in files: - if file == "platformio.ini": - config = configparser.ConfigParser() - config.read(subdir + "/" + file) - for c in config.sections(): - if c.startswith("env:"): - section = config[c].name[4:] - if "extends" in config[config[c].name]: - if options[0] + "_base" in config[config[c].name]["extends"]: - if "board_level" in config[config[c].name]: - if ( - config[config[c].name]["board_level"] == "extra" - ) & ("extra" in options): - outlist.append(section) - else: - outlist.append(section) - # Add the TFT variants if the base variant is selected - elif section.replace("-tft", "") in outlist and config[config[c].name].get("board_level") != "extra": - outlist.append(section) - elif section.replace("-inkhud", "") in outlist and config[config[c].name].get("board_level") != "extra": - outlist.append(section) - if "board_check" in config[config[c].name]: - if (config[config[c].name]["board_check"] == "true") & ( - "check" in options - ): - outlist.append(section) -if ("quick" in options) & (len(outlist) > 3): +cfg = ProjectConfig.get_instance() +pio_envs = cfg.envs() + +# Gather all PlatformIO environments for filtering later +all_envs = [] +for pio_env in pio_envs: + env_build_flags = cfg.get(f"env:{pio_env}", 'build_flags') + env_platform = None + for flag in env_build_flags: + # Extract the platform from the build flags + # Example flag: -I variants/esp32s3/heltec-v3 + match = re.search(r"-I\s?variants/([^/]+)", flag) + if match: + env_platform = match.group(1) + break + # Intentionally fail if platform cannot be determined + if not env_platform: + print(f"Error: Could not determine platform for environment '{pio_env}'") + exit(1) + # Store env details as a dictionary, and add to 'all_envs' list + env = { + 'name': pio_env, + 'platform': env_platform, + 'board_level': cfg.get(f"env:{pio_env}", 'board_level', default=None), + 'board_check': bool(cfg.get(f"env:{pio_env}", 'board_check', default=False)) + } + all_envs.append(env) + +# Filter outputs based on options +# Check is currently mutually exclusive with other options +if "check" in options: + for env in all_envs: + if env['board_check']: + outlist.append(env['name']) +# Filter (non-check) builds by platform +else: + for env in all_envs: + if options[0] == env['platform']: + # If no board level is specified, always include it + if not env['board_level']: + outlist.append(env['name']) + # Include `extra` boards when requested + elif "extra" in options and env['board_level'] == "extra": + outlist.append(env['name']) + +# Return as a JSON list +if ("quick" in options) and (len(outlist) > 3): print(json.dumps(random.sample(outlist, 3))) else: - print(json.dumps(outlist)) \ No newline at end of file + print(json.dumps(outlist)) diff --git a/platformio.ini b/platformio.ini index c0eb6fedb..8bf56cf5b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,7 +6,6 @@ default_envs = tbeam extra_configs = arch/*/*.ini - variants/*/platformio.ini ; Remove when all variants migrated to new dir structure variants/*/*/platformio.ini variants/*/diy/*/platformio.ini src/graphics/niche/InkHUD/PlatformioConfig.ini @@ -111,7 +110,7 @@ lib_deps = [device-ui_base] lib_deps = # renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master - https://github.com/meshtastic/device-ui/archive/86a09a7360f92d10053fbbf8d74f67f85b0ceb09.zip + https://github.com/meshtastic/device-ui/archive/c75d545bf9e8d1fe20051c319f427f711113ff22.zip ; Common libs for environmental measurements in telemetry module [environmental_base] diff --git a/protobufs b/protobufs index fa02e14d8..d31cd890d 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit fa02e14d8d01850336eaea0e9552aef4f08f0a40 +Subproject commit d31cd890d58ffa7e3524e0685a8617bbd181a1c6 diff --git a/src/Power.cpp b/src/Power.cpp index 298f08e0d..b489bc33c 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -20,6 +20,11 @@ #include "meshUtils.h" #include "sleep.h" +#if defined(ARCH_PORTDUINO) +#include "api/WiFiServerAPI.h" +#include "input/LinuxInputImpl.h" +#endif + // Working USB detection for powered/charging states on the RAK platform #ifdef NRF_APM #include "nrfx_power.h" @@ -690,6 +695,47 @@ bool Power::setup() return found; } +void Power::powerCommandsCheck() +{ + if (rebootAtMsec && millis() > rebootAtMsec) { + LOG_INFO("Rebooting"); + reboot(); + } + + if (shutdownAtMsec && millis() > shutdownAtMsec) { + shutdownAtMsec = 0; + shutdown(); + } +} + +void Power::reboot() +{ + notifyReboot.notifyObservers(NULL); +#if defined(ARCH_ESP32) + ESP.restart(); +#elif defined(ARCH_NRF52) + NVIC_SystemReset(); +#elif defined(ARCH_RP2040) + rp2040.reboot(); +#elif defined(ARCH_PORTDUINO) + deInitApiServer(); + if (aLinuxInputImpl) + aLinuxInputImpl->deInit(); + SPI.end(); + Wire.end(); + Serial1.end(); + if (screen) + delete screen; + LOG_DEBUG("final reboot!"); + reboot(); +#elif defined(ARCH_STM32WL) + HAL_NVIC_SystemReset(); +#else + rebootAtMsec = -1; + LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied"); +#endif +} + void Power::shutdown() { diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 3b3f8080d..322b877ff 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -72,7 +72,7 @@ extern Power *power; static void shutdownEnter() { LOG_DEBUG("State: SHUTDOWN"); - power->shutdown(); + shutdownAtMsec = millis(); } #include "error.h" diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 3a6b19f64..f3624c627 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -643,8 +643,16 @@ bool GPS::setup() delay(250); } else if (IS_ONE_OF(gnssModel, GNSS_MODEL_AG3335, GNSS_MODEL_AG3352)) { - _serial_gps->write("$PAIR066,1,0,1,0,0,1*3B\r\n"); // Enable GPS+GALILEO+NAVIC - + if (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_IN || + config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_NP_865) { + _serial_gps->write("$PAIR066,1,0,1,0,0,1*3B\r\n"); // Enable GPS+GALILEO+NAVIC + // GPS GLONASS GALILEO BDS QZSS NAVIC + // 1 0 1 0 0 1 + } else { + _serial_gps->write("$PAIR066,1,1,1,1,0,0*3A\r\n"); // Enable GPS+GLONASS+GALILEO+BDS + // GPS GLONASS GALILEO BDS QZSS NAVIC + // 1 1 1 1 0 0 + } // Configure NMEA (sentences will output once per fix) _serial_gps->write("$PAIR062,0,1*3F\r\n"); // GGA ON _serial_gps->write("$PAIR062,1,0*3F\r\n"); // GLL OFF diff --git a/src/graphics/draw/MenuHandler.cpp b/src/graphics/draw/MenuHandler.cpp index 83198a7c5..5eaa2c6bf 100644 --- a/src/graphics/draw/MenuHandler.cpp +++ b/src/graphics/draw/MenuHandler.cpp @@ -51,12 +51,14 @@ void menuHandler::LoraRegionPicker(uint32_t duration) "PH_915", "ANZ_433", "KZ_433", - "KZ_863"}; + "KZ_863", + "NP_865", + "BR_902"}; BannerOverlayOptions bannerOptions; bannerOptions.message = "Set the LoRa region"; bannerOptions.durationMs = duration; bannerOptions.optionsArrayPtr = optionsArray; - bannerOptions.optionsCount = 25; + bannerOptions.optionsCount = 27; bannerOptions.InitialSelected = 0; bannerOptions.bannerCallback = [](int selected) -> void { if (selected != 0 && config.lora.region != _meshtastic_Config_LoRaConfig_RegionCode(selected)) { diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp index a1f79a28f..7876276a8 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp @@ -223,7 +223,7 @@ void InkHUD::MenuApplet::execute(MenuItem item) case SHUTDOWN: LOG_INFO("Shutting down from menu"); - power->shutdown(); + shutdownAtMsec = millis(); // Menu is then sent to background via onShutdown break; diff --git a/src/input/ExpressLRSFiveWay.cpp b/src/input/ExpressLRSFiveWay.cpp index 77f9e9993..776b9001d 100644 --- a/src/input/ExpressLRSFiveWay.cpp +++ b/src/input/ExpressLRSFiveWay.cpp @@ -199,7 +199,7 @@ void ExpressLRSFiveWay::sendKey(input_broker_event key) void ExpressLRSFiveWay::toggleGPS() { #if HAS_GPS && !MESHTASTIC_EXCLUDE_GPS - if (!config.device.disable_triple_click && (gps != nullptr)) { + if (gps != nullptr) { gps->toggleGpsMode(); screen->startAlert("GPS Toggled"); alerting = true; diff --git a/src/main.cpp b/src/main.cpp index c3e7c2a33..1868d98c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,6 @@ #include "mesh/generated/meshtastic/config.pb.h" #include "meshUtils.h" #include "modules/Modules.h" -#include "shutdown.h" #include "sleep.h" #include "target_specific.h" #include @@ -1530,7 +1529,7 @@ void loop() #ifdef ARCH_NRF52 nrf52Loop(); #endif - powerCommandsCheck(); + power->powerCommandsCheck(); #ifdef DEBUG_STACK static uint32_t lastPrint = 0; diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 38e213167..b7120a064 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -628,11 +628,6 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) #ifdef PIN_GPS_EN config.position.gps_en_gpio = PIN_GPS_EN; #endif -#ifdef GPS_POWER_TOGGLE - config.device.disable_triple_click = false; -#else - config.device.disable_triple_click = true; -#endif #if defined(USERPREFS_CONFIG_GPS_MODE) config.position.gps_mode = USERPREFS_CONFIG_GPS_MODE; #elif !HAS_GPS || GPS_DEFAULT_NOT_PRESENT diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index faa67a1c2..7590ac34d 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -67,6 +67,7 @@ const RegionInfo regions[] = { /* https://www.iot.org.au/wp/wp-content/uploads/2016/12/IoTSpectrumFactSheet.pdf https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf + Also used in Brazil. */ RDEF(ANZ, 915.0f, 928.0f, 100, 0, 30, true, false, false), @@ -169,6 +170,21 @@ const RegionInfo regions[] = { */ RDEF(KZ_433, 433.075f, 434.775f, 100, 0, 10, true, false, false), RDEF(KZ_863, 863.0f, 868.0f, 100, 0, 30, true, false, true), + + /* + Nepal + 865 MHz to 868 MHz frequency band for IoT (Internet of Things), M2M (Machine-to-Machine), and smart metering use, specifically in non-cellular mode. + https://www.nta.gov.np/uploads/contents/Radio-Frequency-Policy-2080-English.pdf + */ + RDEF(NP_865, 865.0f, 868.0f, 100, 0, 30, true, false, false), + + /* + Brazil + 902 - 907.5 MHz , 1W power limit, no duty cycle restrictions + https://github.com/meshtastic/firmware/issues/3741 + */ + RDEF(BR_902, 902.0f, 907.5f, 100, 0, 30, true, false, false), + /* 2.4 GHZ WLAN Band equivalent. Only for SX128x chips. */ diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index b02b2083d..e709db6c4 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -362,7 +362,7 @@ extern const pb_msgdesc_t meshtastic_BackupPreferences_msg; #define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_BackupPreferences_size #define meshtastic_BackupPreferences_size 2271 #define meshtastic_ChannelFile_size 718 -#define meshtastic_DeviceState_size 1722 +#define meshtastic_DeviceState_size 1724 #define meshtastic_NodeInfoLite_size 196 #define meshtastic_PositionLite_size 28 #define meshtastic_UserLite_size 98 diff --git a/src/mesh/generated/meshtastic/mesh.pb.cpp b/src/mesh/generated/meshtastic/mesh.pb.cpp index 361d01b9a..85735357a 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.cpp +++ b/src/mesh/generated/meshtastic/mesh.pb.cpp @@ -117,6 +117,8 @@ PB_BIND(meshtastic_ChunkedPayloadResponse, meshtastic_ChunkedPayloadResponse, AU + + diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index d1a38b565..abc06e635 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -325,6 +325,25 @@ typedef enum _meshtastic_CriticalErrorCode { meshtastic_CriticalErrorCode_FLASH_CORRUPTION_UNRECOVERABLE = 13 } meshtastic_CriticalErrorCode; +/* Enum to indicate to clients whether this firmware is a special firmware build, like an event. + The first 16 values are reserved for non-event special firmwares, like the Smart Citizen use case. */ +typedef enum _meshtastic_FirmwareEdition { + /* Vanilla firmware */ + meshtastic_FirmwareEdition_VANILLA = 0, + /* Firmware for use in the Smart Citizen environmental monitoring network */ + meshtastic_FirmwareEdition_SMART_CITIZEN = 1, + /* Open Sauce, the maker conference held yearly in CA */ + meshtastic_FirmwareEdition_OPEN_SAUCE = 16, + /* DEFCON, the yearly hacker conference */ + meshtastic_FirmwareEdition_DEFCON = 17, + /* Burning Man, the yearly hippie gathering in the desert */ + meshtastic_FirmwareEdition_BURNING_MAN = 18, + /* Hamvention, the Dayton amateur radio convention */ + meshtastic_FirmwareEdition_HAMVENTION = 19, + /* Placeholder for DIY and unofficial events */ + meshtastic_FirmwareEdition_DIY_EDITION = 127 +} meshtastic_FirmwareEdition; + /* Enum for modules excluded from a device's configuration. Each value represents a ModuleConfigType that can be toggled as excluded by setting its corresponding bit in the `excluded_modules` bitmask field. */ @@ -914,6 +933,8 @@ typedef struct _meshtastic_MyNodeInfo { meshtastic_MyNodeInfo_device_id_t device_id; /* The PlatformIO environment used to build this firmware */ char pio_env[40]; + /* The indicator for whether this device is running event firmware and which */ + meshtastic_FirmwareEdition firmware_edition; } meshtastic_MyNodeInfo; /* Debug output from the device. @@ -1212,6 +1233,10 @@ extern "C" { #define _meshtastic_CriticalErrorCode_MAX meshtastic_CriticalErrorCode_FLASH_CORRUPTION_UNRECOVERABLE #define _meshtastic_CriticalErrorCode_ARRAYSIZE ((meshtastic_CriticalErrorCode)(meshtastic_CriticalErrorCode_FLASH_CORRUPTION_UNRECOVERABLE+1)) +#define _meshtastic_FirmwareEdition_MIN meshtastic_FirmwareEdition_VANILLA +#define _meshtastic_FirmwareEdition_MAX meshtastic_FirmwareEdition_DIY_EDITION +#define _meshtastic_FirmwareEdition_ARRAYSIZE ((meshtastic_FirmwareEdition)(meshtastic_FirmwareEdition_DIY_EDITION+1)) + #define _meshtastic_ExcludedModules_MIN meshtastic_ExcludedModules_EXCLUDED_NONE #define _meshtastic_ExcludedModules_MAX meshtastic_ExcludedModules_NETWORK_CONFIG #define _meshtastic_ExcludedModules_ARRAYSIZE ((meshtastic_ExcludedModules)(meshtastic_ExcludedModules_NETWORK_CONFIG+1)) @@ -1258,6 +1283,7 @@ extern "C" { #define meshtastic_MeshPacket_delayed_ENUMTYPE meshtastic_MeshPacket_Delayed +#define meshtastic_MyNodeInfo_firmware_edition_ENUMTYPE meshtastic_FirmwareEdition #define meshtastic_LogRecord_level_ENUMTYPE meshtastic_LogRecord_Level @@ -1296,7 +1322,7 @@ extern "C" { #define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0} #define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0, 0, 0, 0} #define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0, 0, false, 0, 0, 0, 0} -#define meshtastic_MyNodeInfo_init_default {0, 0, 0, {0, {0}}, ""} +#define meshtastic_MyNodeInfo_init_default {0, 0, 0, {0, {0}}, "", _meshtastic_FirmwareEdition_MIN} #define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_default {0, 0, 0, 0} #define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}} @@ -1327,7 +1353,7 @@ extern "C" { #define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0} #define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, {0, {0}}, 0, 0, 0, 0} #define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0, 0, false, 0, 0, 0, 0} -#define meshtastic_MyNodeInfo_init_zero {0, 0, 0, {0, {0}}, ""} +#define meshtastic_MyNodeInfo_init_zero {0, 0, 0, {0, {0}}, "", _meshtastic_FirmwareEdition_MIN} #define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_zero {0, 0, 0, 0} #define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}} @@ -1450,6 +1476,7 @@ extern "C" { #define meshtastic_MyNodeInfo_min_app_version_tag 11 #define meshtastic_MyNodeInfo_device_id_tag 12 #define meshtastic_MyNodeInfo_pio_env_tag 13 +#define meshtastic_MyNodeInfo_firmware_edition_tag 14 #define meshtastic_LogRecord_message_tag 1 #define meshtastic_LogRecord_time_tag 2 #define meshtastic_LogRecord_source_tag 3 @@ -1682,7 +1709,8 @@ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, UINT32, reboot_count, 8) \ X(a, STATIC, SINGULAR, UINT32, min_app_version, 11) \ X(a, STATIC, SINGULAR, BYTES, device_id, 12) \ -X(a, STATIC, SINGULAR, STRING, pio_env, 13) +X(a, STATIC, SINGULAR, STRING, pio_env, 13) \ +X(a, STATIC, SINGULAR, UENUM, firmware_edition, 14) #define meshtastic_MyNodeInfo_CALLBACK NULL #define meshtastic_MyNodeInfo_DEFAULT NULL @@ -1965,7 +1993,7 @@ extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; #define meshtastic_LowEntropyKey_size 0 #define meshtastic_MeshPacket_size 378 #define meshtastic_MqttClientProxyMessage_size 501 -#define meshtastic_MyNodeInfo_size 77 +#define meshtastic_MyNodeInfo_size 79 #define meshtastic_NeighborInfo_size 258 #define meshtastic_Neighbor_size 22 #define meshtastic_NodeInfo_size 323 diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 8d3e710df..33d5e1016 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -596,7 +596,6 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) if (config.device.button_gpio == c.payload_variant.device.button_gpio && config.device.buzzer_gpio == c.payload_variant.device.buzzer_gpio && config.device.role == c.payload_variant.device.role && - config.device.disable_triple_click == c.payload_variant.device.disable_triple_click && config.device.rebroadcast_mode == c.payload_variant.device.rebroadcast_mode) { requiresReboot = false; } diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 2a4f1cf4d..ed930db41 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -56,6 +56,7 @@ CannedMessageModule::CannedMessageModule() disable(); } else { LOG_INFO("CannedMessageModule is enabled"); + moduleConfig.canned_message.enabled = true; this->inputObserver.observe(inputBroker); } } @@ -2075,6 +2076,9 @@ void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_ if (changed) { this->saveProtoForModule(); + if (splitConfiguredMessages()) { + moduleConfig.canned_message.enabled = true; + } } } diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 685f0d077..5f99ec2c3 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -34,6 +34,7 @@ Ch341Hal *ch341Hal = nullptr; char *configPath = nullptr; char *optionMac = nullptr; bool forceSimulated = false; +bool verboseEnabled = false; const char *argp_program_version = optstr(APP_VERSION); @@ -70,7 +71,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 'h': optionMac = arg; break; - + case 'v': + verboseEnabled = true; + break; case ARGP_KEY_ARG: return 0; default: @@ -85,6 +88,7 @@ void portduinoCustomInit() {"config", 'c', "CONFIG_PATH", 0, "Full path of the .yaml config file to use."}, {"hwid", 'h', "HWID", 0, "The mac address to assign to this virtual machine"}, {"sim", 's', 0, 0, "Run in Simulated radio mode"}, + {"verbose", 'v', 0, 0, "Set log level to full debug"}, {0}}; static void *childArguments; static char doc[] = "Meshtastic native build."; @@ -417,6 +421,9 @@ void portduinoSetup() exit(EXIT_FAILURE); } } + if (verboseEnabled && settingsMap[logoutputlevel] != level_trace) { + settingsMap[logoutputlevel] = level_debug; + } return; } diff --git a/src/power.h b/src/power.h index 046980bd6..1c078c06d 100644 --- a/src/power.h +++ b/src/power.h @@ -110,7 +110,7 @@ class Power : private concurrency::OSThread Power(); - void shutdown(); + void powerCommandsCheck(); void readPowerStatus(); virtual bool setup(); virtual int32_t runOnce() override; @@ -130,6 +130,8 @@ class Power : private concurrency::OSThread bool lipoChargerInit(); private: + void shutdown(); + void reboot(); // open circuit voltage lookup table uint8_t low_voltage_counter; #ifdef DEBUG_HEAP diff --git a/src/shutdown.h b/src/shutdown.h deleted file mode 100644 index 973e388b1..000000000 --- a/src/shutdown.h +++ /dev/null @@ -1,47 +0,0 @@ -#include "buzz.h" -#include "configuration.h" -#include "graphics/Screen.h" -#include "main.h" -#include "power.h" -#include "sleep.h" -#if defined(ARCH_PORTDUINO) -#include "api/WiFiServerAPI.h" -#include "input/LinuxInputImpl.h" - -#endif - -void powerCommandsCheck() -{ - if (rebootAtMsec && millis() > rebootAtMsec) { - LOG_INFO("Rebooting"); - notifyReboot.notifyObservers(NULL); -#if defined(ARCH_ESP32) - ESP.restart(); -#elif defined(ARCH_NRF52) - NVIC_SystemReset(); -#elif defined(ARCH_RP2040) - rp2040.reboot(); -#elif defined(ARCH_PORTDUINO) - deInitApiServer(); - if (aLinuxInputImpl) - aLinuxInputImpl->deInit(); - SPI.end(); - Wire.end(); - Serial1.end(); - if (screen) - delete screen; - LOG_DEBUG("final reboot!"); - reboot(); -#elif defined(ARCH_STM32WL) - HAL_NVIC_SystemReset(); -#else - rebootAtMsec = -1; - LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied"); -#endif - } - - if (shutdownAtMsec && millis() > shutdownAtMsec) { - shutdownAtMsec = 0; - power->shutdown(); - } -} \ No newline at end of file diff --git a/variants/tlora_c6/platformio.ini b/variants/esp32c6/tlora_c6/platformio.ini similarity index 85% rename from variants/tlora_c6/platformio.ini rename to variants/esp32c6/tlora_c6/platformio.ini index 2da10138a..a06306add 100644 --- a/variants/tlora_c6/platformio.ini +++ b/variants/esp32c6/tlora_c6/platformio.ini @@ -4,6 +4,6 @@ board = esp32-c6-devkitm-1 build_flags = ${esp32c6_base.build_flags} -D TLORA_C6 - -I variants/tlora_c6 + -I variants/esp32c6/tlora_c6 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 diff --git a/variants/tlora_c6/variant.h b/variants/esp32c6/tlora_c6/variant.h similarity index 100% rename from variants/tlora_c6/variant.h rename to variants/esp32c6/tlora_c6/variant.h diff --git a/variants/mesh-tab/pins_arduino.h b/variants/esp32s3/mesh-tab/pins_arduino.h similarity index 100% rename from variants/mesh-tab/pins_arduino.h rename to variants/esp32s3/mesh-tab/pins_arduino.h diff --git a/variants/mesh-tab/platformio.ini b/variants/esp32s3/mesh-tab/platformio.ini similarity index 99% rename from variants/mesh-tab/platformio.ini rename to variants/esp32s3/mesh-tab/platformio.ini index 52f9fc13c..e21bc38e1 100644 --- a/variants/mesh-tab/platformio.ini +++ b/variants/esp32s3/mesh-tab/platformio.ini @@ -45,7 +45,7 @@ build_flags = ${esp32s3_base.build_flags} -D LGFX_TOUCH_INT=41 -D VIEW_320x240 -D USE_PACKET_API - -I variants/mesh-tab + -I variants/esp32s3/mesh-tab build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} diff --git a/variants/mesh-tab/variant.h b/variants/esp32s3/mesh-tab/variant.h similarity index 100% rename from variants/mesh-tab/variant.h rename to variants/esp32s3/mesh-tab/variant.h diff --git a/variants/portduino-buildroot/platformio.ini b/variants/native/portduino-buildroot/platformio.ini similarity index 75% rename from variants/portduino-buildroot/platformio.ini rename to variants/native/portduino-buildroot/platformio.ini index 3fbd26910..d1bd39e10 100644 --- a/variants/portduino-buildroot/platformio.ini +++ b/variants/native/portduino-buildroot/platformio.ini @@ -2,7 +2,7 @@ extends = portduino_base ; Optional libraries should be appended to `PLATFORMIO_BUILD_FLAGS` ; environment variable in the buildroot environment. -build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino-buildroot +build_flags = ${portduino_base.build_flags} -O0 -I variants/native/portduino-buildroot board = buildroot lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} \ No newline at end of file diff --git a/variants/portduino-buildroot/variant.h b/variants/native/portduino-buildroot/variant.h similarity index 100% rename from variants/portduino-buildroot/variant.h rename to variants/native/portduino-buildroot/variant.h diff --git a/variants/portduino/platformio.ini b/variants/native/portduino/platformio.ini similarity index 97% rename from variants/portduino/platformio.ini rename to variants/native/portduino/platformio.ini index 5293b12b9..732b2a1d4 100644 --- a/variants/portduino/platformio.ini +++ b/variants/native/portduino/platformio.ini @@ -1,6 +1,6 @@ [native_base] extends = portduino_base -build_flags = ${portduino_base.build_flags} -I variants/portduino +build_flags = ${portduino_base.build_flags} -I variants/native/portduino -D ARCH_PORTDUINO -I /usr/include board = cross_platform diff --git a/variants/portduino/variant.h b/variants/native/portduino/variant.h similarity index 100% rename from variants/portduino/variant.h rename to variants/native/portduino/variant.h