mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-06 03:29:17 +00:00
Merge branch 'master' into use_detected_ina_addr
This commit is contained in:
commit
443d033cb8
2
.github/actions/setup-base/action.yml
vendored
2
.github/actions/setup-base/action.yml
vendored
@ -5,7 +5,7 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
2
.github/workflows/build_debian_src.yml
vendored
2
.github/workflows/build_debian_src.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
|
40
.github/workflows/build_esp32.yml
vendored
40
.github/workflows/build_esp32.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Build ESP32
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-esp32:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.bin
|
||||
release/*.elf
|
40
.github/workflows/build_esp32_c3.yml
vendored
40
.github/workflows/build_esp32_c3.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Build ESP32-C3
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-esp32-c3:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.bin
|
||||
release/*.elf
|
40
.github/workflows/build_esp32_c6.yml
vendored
40
.github/workflows/build_esp32_c6.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Build ESP32-C6
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-esp32-c6:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.bin
|
||||
release/*.elf
|
40
.github/workflows/build_esp32_s3.yml
vendored
40
.github/workflows/build_esp32_s3.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Build ESP32-S3
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-esp32-s3:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.bin
|
||||
release/*.elf
|
66
.github/workflows/build_firmware.yml
vendored
Normal file
66
.github/workflows/build_firmware.yml
vendored
Normal file
@ -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@v5
|
||||
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
|
40
.github/workflows/build_nrf52.yml
vendored
40
.github/workflows/build_nrf52.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Build NRF52
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-nrf52:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.uf2
|
||||
release/*.elf
|
||||
release/*.hex
|
||||
release/*-ota.zip
|
38
.github/workflows/build_rpi2040.yml
vendored
38
.github/workflows/build_rpi2040.yml
vendored
@ -1,38 +0,0 @@
|
||||
name: Build RPI2040
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-rpi2040:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.uf2
|
||||
release/*.elf
|
39
.github/workflows/build_stm32.yml
vendored
39
.github/workflows/build_stm32.yml
vendored
@ -1,39 +0,0 @@
|
||||
name: Build STM32
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
board:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-stm32:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get release version string
|
||||
shell: bash
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- 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 }}-${{ steps.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: |
|
||||
release/*.hex
|
||||
release/*.bin
|
||||
release/*.elf
|
2
.github/workflows/docker_build.yml
vendored
2
.github/workflows/docker_build.yml
vendored
@ -47,7 +47,7 @@ jobs:
|
||||
runs-on: ${{ inputs.runs-on }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
2
.github/workflows/docker_manifest.yml
vendored
2
.github/workflows/docker_manifest.yml
vendored
@ -83,7 +83,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
2
.github/workflows/hook_copr.yml
vendored
2
.github/workflows/hook_copr.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{ github.ref }}
|
||||
|
250
.github/workflows/main_matrix.yml
vendored
250
.github/workflows/main_matrix.yml
vendored
@ -30,18 +30,31 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [esp32, esp32s3, esp32c3, esp32c6, nrf52840, rp2040, stm32, check]
|
||||
runs-on: ubuntu-latest
|
||||
arch:
|
||||
- esp32
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32c6
|
||||
- nrf52840
|
||||
- rp2040
|
||||
- rp2350
|
||||
- stm32
|
||||
- check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- id: checkout
|
||||
uses: actions/checkout@v4
|
||||
name: Checkout base
|
||||
- id: jsonStep
|
||||
- uses: actions/checkout@v5
|
||||
- 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}})
|
||||
else
|
||||
TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}} quick)
|
||||
TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}} pr)
|
||||
fi
|
||||
echo "Name: $GITHUB_REF_NAME Base: $GITHUB_BASE_REF Ref: $GITHUB_REF Targets: $TARGETS"
|
||||
echo "${{matrix.arch}}=$(jq -cn --argjson environments "$TARGETS" '{board: $environments}')" >> $GITHUB_OUTPUT
|
||||
@ -52,9 +65,25 @@ jobs:
|
||||
esp32c6: ${{ steps.jsonStep.outputs.esp32c6 }}
|
||||
nrf52840: ${{ steps.jsonStep.outputs.nrf52840 }}
|
||||
rp2040: ${{ steps.jsonStep.outputs.rp2040 }}
|
||||
rp2350: ${{ steps.jsonStep.outputs.rp2350 }}
|
||||
stm32: ${{ steps.jsonStep.outputs.stm32 }}
|
||||
check: ${{ steps.jsonStep.outputs.check }}
|
||||
|
||||
version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Get release version string
|
||||
run: |
|
||||
echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
echo "deb=$(./bin/buildinfo.py deb)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
env:
|
||||
BUILD_LOCATION: local
|
||||
outputs:
|
||||
long: ${{ steps.version.outputs.long }}
|
||||
deb: ${{ steps.version.outputs.deb }}
|
||||
|
||||
check:
|
||||
needs: setup
|
||||
strategy:
|
||||
@ -64,7 +93,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Build base
|
||||
id: base
|
||||
uses: ./.github/actions/setup-base
|
||||
@ -72,67 +101,92 @@ jobs:
|
||||
run: bin/check-all.sh ${{ matrix.board }}
|
||||
|
||||
build-esp32:
|
||||
needs: setup
|
||||
needs: [setup, version]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup.outputs.esp32) }}
|
||||
uses: ./.github/workflows/build_esp32.yml
|
||||
uses: ./.github/workflows/build_firmware.yml
|
||||
with:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: esp32
|
||||
|
||||
build-esp32-s3:
|
||||
needs: setup
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: esp32s3
|
||||
|
||||
build-esp32-c3:
|
||||
needs: setup
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: esp32c3
|
||||
|
||||
build-esp32-c6:
|
||||
needs: setup
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: esp32c6
|
||||
|
||||
build-nrf52:
|
||||
needs: setup
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: nrf52840
|
||||
|
||||
build-rpi2040:
|
||||
needs: setup
|
||||
build-rp2040:
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: rp2040
|
||||
|
||||
build-rp2350:
|
||||
needs: [setup, version]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup.outputs.rp2350) }}
|
||||
uses: ./.github/workflows/build_firmware.yml
|
||||
with:
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: rp2350
|
||||
|
||||
build-stm32:
|
||||
needs: setup
|
||||
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:
|
||||
board: ${{ matrix.board }}
|
||||
version: ${{ needs.version.outputs.long }}
|
||||
pio_env: ${{ matrix.board }}
|
||||
platform: stm32
|
||||
|
||||
build-debian-src:
|
||||
if: github.repository == 'meshtastic/firmware'
|
||||
@ -210,26 +264,36 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [esp32, esp32s3, esp32c3, esp32c6, nrf52840, rp2040, stm32]
|
||||
arch:
|
||||
- esp32
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32c6
|
||||
- nrf52840
|
||||
- rp2040
|
||||
- rp2350
|
||||
- stm32
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
[
|
||||
version,
|
||||
build-esp32,
|
||||
build-esp32-s3,
|
||||
build-esp32-c3,
|
||||
build-esp32-c6,
|
||||
build-nrf52,
|
||||
build-rpi2040,
|
||||
build-esp32s3,
|
||||
build-esp32c3,
|
||||
build-esp32c6,
|
||||
build-nrf52840,
|
||||
build-rp2040,
|
||||
build-rp2350,
|
||||
build-stm32,
|
||||
]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
path: ./
|
||||
pattern: firmware-${{matrix.arch}}-*
|
||||
@ -238,17 +302,13 @@ jobs:
|
||||
- name: Display structure of downloaded files
|
||||
run: ls -R
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- name: Move files up
|
||||
run: mv -b -t ./ ./bin/device-*.sh ./bin/device-*.bat
|
||||
|
||||
- name: Repackage in single firmware zip
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}
|
||||
name: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
overwrite: true
|
||||
path: |
|
||||
./firmware-*.bin
|
||||
@ -262,9 +322,9 @@ jobs:
|
||||
./Meshtastic_nRF52_factory_erase*.uf2
|
||||
retention-days: 30
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}
|
||||
name: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
path: ./output
|
||||
|
||||
@ -278,12 +338,12 @@ jobs:
|
||||
chmod +x ./output/device-update.sh
|
||||
|
||||
- name: Zip firmware
|
||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip ./output
|
||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||
|
||||
- name: Repackage in single elfs zip
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: debug-elfs-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip
|
||||
name: debug-elfs-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip
|
||||
overwrite: true
|
||||
path: ./*.elf
|
||||
retention-days: 30
|
||||
@ -291,8 +351,8 @@ jobs:
|
||||
- uses: scruplelesswizard/comment-artifact@main
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
with:
|
||||
name: firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}
|
||||
description: "Download firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip. This artifact will be available for 90 days from creation"
|
||||
name: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
description: "Download firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip. This artifact will be available for 90 days from creation"
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
release-artifacts:
|
||||
@ -301,56 +361,49 @@ jobs:
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
needs:
|
||||
- version
|
||||
- gather-artifacts
|
||||
- build-debian-src
|
||||
- package-pio-deps-native-tft
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Get release version string
|
||||
run: |
|
||||
echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
echo "deb=$(./bin/buildinfo.py deb)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
env:
|
||||
BUILD_LOCATION: local
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
id: create_release
|
||||
with:
|
||||
draft: true
|
||||
prerelease: true
|
||||
name: Meshtastic Firmware ${{ steps.version.outputs.long }} Alpha
|
||||
tag_name: v${{ steps.version.outputs.long }}
|
||||
name: Meshtastic Firmware ${{ needs.version.outputs.long }} Alpha
|
||||
tag_name: v${{ needs.version.outputs.long }}
|
||||
body: |
|
||||
Autogenerated by github action, developer should edit as required before publishing...
|
||||
|
||||
- name: Download source deb
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: firmware-debian-${{ steps.version.outputs.deb }}~UNRELEASED-src
|
||||
pattern: firmware-debian-${{ needs.version.outputs.deb }}~UNRELEASED-src
|
||||
merge-multiple: true
|
||||
path: ./output/debian-src
|
||||
|
||||
- name: Download `native-tft` pio deps
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: platformio-deps-native-tft-${{ steps.version.outputs.long }}
|
||||
pattern: platformio-deps-native-tft-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
path: ./output/pio-deps-native-tft
|
||||
|
||||
- name: Zip Linux sources
|
||||
working-directory: output
|
||||
run: |
|
||||
zip -j -9 -r ./meshtasticd-${{ steps.version.outputs.deb }}-src.zip ./debian-src
|
||||
zip -9 -r ./platformio-deps-native-tft-${{ steps.version.outputs.long }}.zip ./pio-deps-native-tft
|
||||
zip -j -9 -r ./meshtasticd-${{ needs.version.outputs.deb }}-src.zip ./debian-src
|
||||
zip -9 -r ./platformio-deps-native-tft-${{ needs.version.outputs.long }}.zip ./pio-deps-native-tft
|
||||
|
||||
# For diagnostics
|
||||
- name: Display structure of downloaded files
|
||||
@ -360,8 +413,8 @@ jobs:
|
||||
# Only run when targeting master branch with workflow_dispatch
|
||||
if: ${{ github.ref_name == 'master' }}
|
||||
run: |
|
||||
gh release upload v${{ steps.version.outputs.long }} ./output/meshtasticd-${{ steps.version.outputs.deb }}-src.zip
|
||||
gh release upload v${{ steps.version.outputs.long }} ./output/platformio-deps-native-tft-${{ steps.version.outputs.long }}.zip
|
||||
gh release upload v${{ needs.version.outputs.long }} ./output/meshtasticd-${{ needs.version.outputs.deb }}-src.zip
|
||||
gh release upload v${{ needs.version.outputs.long }} ./output/platformio-deps-native-tft-${{ needs.version.outputs.long }}.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@ -369,26 +422,30 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [esp32, esp32s3, esp32c3, esp32c6, nrf52840, rp2040, stm32]
|
||||
arch:
|
||||
- esp32
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32c6
|
||||
- nrf52840
|
||||
- rp2040
|
||||
- rp2350
|
||||
- stm32
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
needs: [release-artifacts]
|
||||
needs: [release-artifacts, version]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}
|
||||
pattern: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
path: ./output
|
||||
|
||||
@ -401,16 +458,16 @@ jobs:
|
||||
chmod +x ./output/device-update.sh
|
||||
|
||||
- name: Zip firmware
|
||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip ./output
|
||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: debug-elfs-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip
|
||||
name: debug-elfs-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip
|
||||
merge-multiple: true
|
||||
path: ./elfs
|
||||
|
||||
- name: Zip debug elfs
|
||||
run: zip -j -9 -r ./debug-elfs-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip ./elfs
|
||||
run: zip -j -9 -r ./debug-elfs-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./elfs
|
||||
|
||||
# For diagnostics
|
||||
- name: Display structure of downloaded files
|
||||
@ -420,33 +477,30 @@ jobs:
|
||||
# Only run when targeting master branch with workflow_dispatch
|
||||
if: ${{ github.ref_name == 'master' }}
|
||||
run: |
|
||||
gh release upload v${{ steps.version.outputs.long }} ./firmware-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip
|
||||
gh release upload v${{ steps.version.outputs.long }} ./debug-elfs-${{matrix.arch}}-${{ steps.version.outputs.long }}.zip
|
||||
gh release upload v${{ needs.version.outputs.long }} ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip
|
||||
gh release upload v${{ needs.version.outputs.long }} ./debug-elfs-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
publish-firmware:
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
needs: [release-firmware]
|
||||
needs: [release-firmware, version]
|
||||
env:
|
||||
targets: esp32,esp32s3,esp32c3,esp32c6,nrf52840,rp2040,stm32
|
||||
targets: |-
|
||||
esp32,esp32s3,esp32c3,esp32c6,nrf52840,rp2040,rp2350,stm32
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
id: version
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: firmware-{${{ env.targets }}}-${{ steps.version.outputs.long }}
|
||||
pattern: firmware-{${{ env.targets }}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
path: ./publish
|
||||
|
||||
@ -460,9 +514,9 @@ jobs:
|
||||
external_repository: meshtastic/meshtastic.github.io
|
||||
publish_branch: master
|
||||
publish_dir: ./publish
|
||||
destination_dir: ${{ env.DEST_PREFIX }}firmware-${{ steps.version.outputs.long }}
|
||||
destination_dir: ${{ env.DEST_PREFIX }}firmware-${{ needs.version.outputs.long }}
|
||||
keep_files: true
|
||||
user_name: github-actions[bot]
|
||||
user_email: github-actions[bot]@users.noreply.github.com
|
||||
commit_message: ${{ steps.version.outputs.long }}
|
||||
commit_message: ${{ needs.version.outputs.long }}
|
||||
enable_jekyll: true
|
||||
|
4
.github/workflows/nightly.yml
vendored
4
.github/workflows/nightly.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
@ -31,7 +31,7 @@ jobs:
|
||||
pull-requests: write # For trunk to create PRs
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Trunk Upgrade
|
||||
uses: trunk-io/trunk-action/upgrade@v1
|
||||
|
4
.github/workflows/package_obs.yml
vendored
4
.github/workflows/package_obs.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
||||
needs: build-debian-src
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
@ -58,7 +58,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: firmware-debian-${{ steps.version.outputs.deb }}~${{ inputs.series }}-src
|
||||
merge-multiple: true
|
||||
|
2
.github/workflows/package_pio_deps.yml
vendored
2
.github/workflows/package_pio_deps.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
4
.github/workflows/package_ppa.yml
vendored
4
.github/workflows/package_ppa.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
needs: build-debian-src
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
@ -60,7 +60,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: firmware-debian-${{ steps.version.outputs.deb }}~${{ inputs.series }}-src
|
||||
merge-multiple: true
|
||||
|
24
.github/workflows/pr_enforce_labels.yml
vendored
Normal file
24
.github/workflows/pr_enforce_labels.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Check PR Labels
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, labeled, unlabeled, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-label:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Check for PR labels
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const labels = context.payload.pull_request.labels.map(label => label.name);
|
||||
const requiredLabels = ['bugfix', 'enhancement', 'hardware-support', 'dependencies', 'submodules', 'github_actions', 'trunk'];
|
||||
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
|
||||
if (!hasRequiredLabel) {
|
||||
core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`);
|
||||
}
|
5
.github/workflows/release_channels.yml
vendored
5
.github/workflows/release_channels.yml
vendored
@ -60,7 +60,7 @@ jobs:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
@ -103,8 +103,9 @@ jobs:
|
||||
with:
|
||||
base: ${{ github.event.repository.default_branch }}
|
||||
branch: create-pull-request/bump-version
|
||||
labels: github_actions
|
||||
title: Bump release version
|
||||
commit-message: automated bumps
|
||||
commit-message: Automated version bumps
|
||||
add-paths: |
|
||||
version.properties
|
||||
debian/changelog
|
||||
|
2
.github/workflows/sec_sast_semgrep_cron.yml
vendored
2
.github/workflows/sec_sast_semgrep_cron.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
steps:
|
||||
# step 1
|
||||
- name: clone application source code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
# step 2
|
||||
- name: full scan
|
||||
|
2
.github/workflows/sec_sast_semgrep_pull.yml
vendored
2
.github/workflows/sec_sast_semgrep_pull.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
steps:
|
||||
# step 1
|
||||
- name: clone application source code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
10
.github/workflows/test_native.yml
vendored
10
.github/workflows/test_native.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
name: Native Simulator Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@ -70,7 +70,7 @@ jobs:
|
||||
name: Native PlatformIO Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@ -127,7 +127,7 @@ jobs:
|
||||
- platformio-tests
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@ -137,7 +137,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download test artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: platformio-test-report-${{ steps.version.outputs.long }}.zip
|
||||
merge-multiple: true
|
||||
@ -150,7 +150,7 @@ jobs:
|
||||
reporter: java-junit
|
||||
|
||||
- name: Download coverage artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: lcov-coverage-info-native-*-${{ steps.version.outputs.long }}.zip
|
||||
path: code-coverage-report
|
||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
runs-on: test-runner
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
# - uses: actions/setup-python@v5
|
||||
# with:
|
||||
|
2
.github/workflows/trunk_annotate_pr.yml
vendored
2
.github/workflows/trunk_annotate_pr.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
|
2
.github/workflows/trunk_check.yml
vendored
2
.github/workflows/trunk_check.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
|
2
.github/workflows/trunk_format_pr.yml
vendored
2
.github/workflows/trunk_format_pr.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
4
.github/workflows/update_protobufs.yml
vendored
4
.github/workflows/update_protobufs.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
@ -34,7 +34,9 @@ jobs:
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
branch: create-pull-request/update-protobufs
|
||||
labels: submodules
|
||||
title: Update protobufs and classes
|
||||
commit-message: Update protobufs
|
||||
add-paths: |
|
||||
protobufs
|
||||
src/mesh
|
||||
|
@ -1,6 +1,6 @@
|
||||
version: 0.1
|
||||
cli:
|
||||
version: 1.24.0
|
||||
version: 1.25.0
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
@ -8,15 +8,15 @@ plugins:
|
||||
uri: https://github.com/trunk-io/plugins
|
||||
lint:
|
||||
enabled:
|
||||
- checkov@3.2.450
|
||||
- renovate@41.30.5
|
||||
- checkov@3.2.461
|
||||
- renovate@41.63.0
|
||||
- prettier@3.6.2
|
||||
- trufflehog@3.89.2
|
||||
- trufflehog@3.90.3
|
||||
- yamllint@1.37.1
|
||||
- bandit@1.8.6
|
||||
- trivy@0.64.1
|
||||
- taplo@0.9.3
|
||||
- ruff@0.12.2
|
||||
- ruff@0.12.7
|
||||
- isort@6.0.1
|
||||
- markdownlint@0.45.0
|
||||
- oxipng@9.1.5
|
||||
@ -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]
|
||||
|
@ -3,7 +3,7 @@
|
||||
# trunk-ignore-all(hadolint/DL3008): Do not pin apt package versions
|
||||
# trunk-ignore-all(hadolint/DL3013): Do not pin pip package versions
|
||||
|
||||
FROM python:3.13-bookworm AS builder
|
||||
FROM python:3.13-slim-trixie AS builder
|
||||
ARG PIO_ENV=native
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Etc/UTC
|
||||
@ -36,7 +36,7 @@ RUN curl -L "https://github.com/meshtastic/web/releases/download/v$(cat /tmp/fir
|
||||
|
||||
##### PRODUCTION BUILD #############
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
FROM debian:trixie-slim
|
||||
LABEL org.opencontainers.image.title="Meshtastic" \
|
||||
org.opencontainers.image.description="Debian Meshtastic daemon and web interface" \
|
||||
org.opencontainers.image.url="https://meshtastic.org" \
|
||||
@ -51,8 +51,8 @@ ENV TZ=Etc/UTC
|
||||
USER root
|
||||
|
||||
RUN apt-get update && apt-get --no-install-recommends -y install \
|
||||
libc-bin libc6 libgpiod2 libyaml-cpp0.7 libi2c0 libuv1 libusb-1.0-0-dev \
|
||||
liborcania2.3 libulfius2.7 libssl3 \
|
||||
libc-bin libc6 libgpiod3 libyaml-cpp0.8 libi2c0 libuv1t64 libusb-1.0-0-dev \
|
||||
liborcania2.3 libulfius2.7t64 libssl3t64 \
|
||||
libx11-6 libinput10 libxkbcommon-x11-0 \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /var/lib/meshtasticd \
|
||||
|
@ -54,8 +54,8 @@ lib_deps =
|
||||
h2zero/NimBLE-Arduino@^1.4.3
|
||||
# renovate: datasource=git-refs depName=libpax packageName=https://github.com/dbinfrago/libpax gitBranch=master
|
||||
https://github.com/dbinfrago/libpax/archive/3cdc0371c375676a97967547f4065607d4c53fd1.zip
|
||||
# renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib
|
||||
lewisxhe/XPowersLib@0.3.0
|
||||
# renovate: datasource=github-tags depName=XPowersLib packageName=lewisxhe/XPowersLib
|
||||
https://github.com/lewisxhe/XPowersLib/archive/v0.3.0.zip
|
||||
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
|
||||
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
|
||||
# renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto
|
||||
|
@ -17,7 +17,6 @@ build_src_filter =
|
||||
+<mesh/raspihttp/>
|
||||
-<mesh/eth/>
|
||||
-<modules/esp32>
|
||||
+<../variants/portduino>
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
@ -35,11 +34,12 @@ lib_deps =
|
||||
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
-D ARCH_PORTDUINO
|
||||
-fPIC
|
||||
-Isrc/platform/portduino
|
||||
-DRADIOLIB_EEPROM_UNSUPPORTED
|
||||
-DPORTDUINO_LINUX_HARDWARE
|
||||
-DHAS_UDP_MULTICAST
|
||||
-DHAS_UDP_MULTICAST=1
|
||||
-lpthread
|
||||
-lstdc++fs
|
||||
-lbluetooth
|
||||
|
@ -2,7 +2,7 @@
|
||||
extends = arduino_base
|
||||
platform =
|
||||
# renovate: datasource=custom.pio depName=platformio/ststm32 packageName=platformio/platform/ststm32
|
||||
platformio/ststm32@19.2.0
|
||||
platformio/ststm32@19.3.0
|
||||
platform_packages =
|
||||
# TODO renovate
|
||||
platformio/framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/2.10.1.zip
|
||||
|
@ -11,7 +11,7 @@ elif (echo $2 | grep -q "nrf52"); then
|
||||
elif (echo $2 | grep -q "stm32"); then
|
||||
bin/build-stm32.sh $1
|
||||
elif (echo $2 | grep -q "rpi2040"); then
|
||||
bin/build-rpi2040.sh $1
|
||||
bin/build-rp2xx0.sh $1
|
||||
else
|
||||
echo "Unknown target $2"
|
||||
exit 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
PYTHON=${PYTHON:-$(which python3 python|head -n 1)}
|
||||
CHANGE_MODE=false
|
||||
|
@ -2,50 +2,71 @@
|
||||
|
||||
"""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):
|
||||
print(json.dumps(random.sample(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 mutually exclusive with other options (except 'pr')
|
||||
if "check" in options:
|
||||
for env in all_envs:
|
||||
if env['board_check']:
|
||||
if "pr" in options:
|
||||
if env['board_level'] == 'pr':
|
||||
outlist.append(env['name'])
|
||||
else:
|
||||
outlist.append(env['name'])
|
||||
# Filter (non-check) builds by platform
|
||||
else:
|
||||
print(json.dumps(outlist))
|
||||
for env in all_envs:
|
||||
if options[0] == env['platform']:
|
||||
# Always include board_level = 'pr'
|
||||
if env['board_level'] == 'pr':
|
||||
outlist.append(env['name'])
|
||||
# Include board_level = 'extra' when requested
|
||||
elif "extra" in options and env['board_level'] == "extra":
|
||||
outlist.append(env['name'])
|
||||
# If no board level is specified, include in release builds (not PR)
|
||||
elif "pr" not in options and not env['board_level']:
|
||||
outlist.append(env['name'])
|
||||
|
||||
# Return as a JSON list
|
||||
print(json.dumps(outlist))
|
||||
|
@ -87,6 +87,15 @@
|
||||
</screenshots>
|
||||
|
||||
<releases>
|
||||
<release version="2.7.6" date="2025-08-12">
|
||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.6</url>
|
||||
</release>
|
||||
<release version="2.7.5" date="2025-08-09">
|
||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.5</url>
|
||||
</release>
|
||||
<release version="2.7.4" date="2025-07-19">
|
||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.4</url>
|
||||
</release>
|
||||
<release version="2.7.3" date="2025-07-10">
|
||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.3</url>
|
||||
</release>
|
||||
|
43
boards/t-deck-pro.json
Normal file
43
boards/t-deck-pro.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"memory_type": "qio_qspi",
|
||||
"partitions": "default_16MB.csv"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_RUNNING_CORE=1",
|
||||
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"hwids": [["0x303A", "0x1001"]],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3"
|
||||
},
|
||||
"connectivity": ["wifi", "bluetooth", "lora"],
|
||||
"debug": {
|
||||
"default_tool": "esp-builtin",
|
||||
"onboard_tools": ["esp-builtin"],
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": ["arduino", "espidf"],
|
||||
"name": "LilyGo T-Deck Pro S3 (16M Flash 8M QSPI PSRAM )",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"require_upload_port": true,
|
||||
"speed": 921600
|
||||
},
|
||||
"monitor": {
|
||||
"speed": 115200
|
||||
},
|
||||
"url": "https://lilygo.cc/products/t-deck-pro",
|
||||
"vendor": "LilyGo"
|
||||
}
|
13
debian/changelog
vendored
13
debian/changelog
vendored
@ -1,4 +1,4 @@
|
||||
meshtasticd (2.7.3.0) UNRELEASED; urgency=medium
|
||||
meshtasticd (2.7.6.0) UNRELEASED; urgency=medium
|
||||
|
||||
[ Austin Lane ]
|
||||
* Initial packaging
|
||||
@ -31,4 +31,13 @@ meshtasticd (2.7.3.0) UNRELEASED; urgency=medium
|
||||
[ Ubuntu ]
|
||||
* GitHub Actions Automatic version bump
|
||||
|
||||
-- Ubuntu <github-actions[bot]@users.noreply.github.com> Thu, 10 Jul 2025 16:29:27 +0000
|
||||
[ ]
|
||||
* GitHub Actions Automatic version bump
|
||||
|
||||
[ ]
|
||||
* GitHub Actions Automatic version bump
|
||||
|
||||
[ ]
|
||||
* GitHub Actions Automatic version bump
|
||||
|
||||
-- <github-actions[bot]@users.noreply.github.com> Tue, 12 Aug 2025 23:48:48 +0000
|
||||
|
2
debian/meshtasticd.postinst
vendored
2
debian/meshtasticd.postinst
vendored
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# postinst script for meshtasticd
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
2
debian/meshtasticd.postrm
vendored
2
debian/meshtasticd.postrm
vendored
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# postrm script for meshtasticd
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
@ -6,7 +6,8 @@ default_envs = tbeam
|
||||
|
||||
extra_configs =
|
||||
arch/*/*.ini
|
||||
variants/*/platformio.ini
|
||||
variants/*/*/platformio.ini
|
||||
variants/*/diy/*/platformio.ini
|
||||
src/graphics/niche/InkHUD/PlatformioConfig.ini
|
||||
|
||||
description = Meshtastic
|
||||
@ -60,8 +61,8 @@ monitor_filters = direct
|
||||
lib_deps =
|
||||
# renovate: datasource=git-refs depName=meshtastic-esp8266-oled-ssd1306 packageName=https://github.com/meshtastic/esp8266-oled-ssd1306 gitBranch=master
|
||||
https://github.com/meshtastic/esp8266-oled-ssd1306/archive/0119501e9983bd894830b02f545c377ee08d66fe.zip
|
||||
# renovate: datasource=custom.pio depName=OneButton packageName=mathertel/library/OneButton
|
||||
mathertel/OneButton@2.6.1
|
||||
# renovate: datasource=git-refs depName=meshtastic-OneButton packageName=https://github.com/meshtastic/OneButton gitBranch=master
|
||||
https://github.com/meshtastic/OneButton/archive/fa352d668c53f290cfa480a5f79ad422cd828c70.zip
|
||||
# renovate: datasource=git-refs depName=meshtastic-arduino-fsm packageName=https://github.com/meshtastic/arduino-fsm gitBranch=master
|
||||
https://github.com/meshtastic/arduino-fsm/archive/7db3702bf0cfe97b783d6c72595e3f38e0b19159.zip
|
||||
# renovate: datasource=git-refs depName=meshtastic-TinyGPSPlus packageName=https://github.com/meshtastic/TinyGPSPlus gitBranch=master
|
||||
@ -109,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/0cd108ff783539e41ef38258ba2784ab3b1bdc97.zip
|
||||
|
||||
; Common libs for environmental measurements in telemetry module
|
||||
[environmental_base]
|
||||
@ -177,7 +178,7 @@ lib_deps =
|
||||
# renovate: datasource=custom.pio depName=Adafruit MAX1704X packageName=adafruit/library/Adafruit MAX1704X
|
||||
adafruit/Adafruit MAX1704X@1.0.3
|
||||
# renovate: datasource=custom.pio depName=Adafruit SHTC3 packageName=adafruit/library/Adafruit SHTC3 Library
|
||||
adafruit/Adafruit SHTC3 Library@1.0.1
|
||||
adafruit/Adafruit SHTC3 Library@1.0.2
|
||||
# renovate: datasource=custom.pio depName=Adafruit LPS2X packageName=adafruit/library/Adafruit LPS2X
|
||||
adafruit/Adafruit LPS2X@2.0.6
|
||||
# renovate: datasource=custom.pio depName=Adafruit SHT31 packageName=adafruit/library/Adafruit SHT31 Library
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f6448be7770a3521bf52407ff8f5fa5b9b06da7b
|
||||
Subproject commit 5dd723fe6f33a8613ec81acf5e15be26365c7cce
|
217
src/Power.cpp
217
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"
|
||||
@ -122,6 +127,15 @@ NullSensor max17048Sensor;
|
||||
RAK9154Sensor rak9154Sensor;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PPM
|
||||
// note: XPOWERS_CHIP_XXX must be defined in variant.h
|
||||
#include <XPowersLib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BQ27220
|
||||
#include "bq27220.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
XPowersLibInterface *PMU = NULL;
|
||||
#else
|
||||
@ -738,6 +752,8 @@ bool Power::setup()
|
||||
found = true;
|
||||
} else if (lipoInit()) {
|
||||
found = true;
|
||||
} else if (lipoChargerInit()) {
|
||||
found = true;
|
||||
} else if (analogInit()) {
|
||||
found = true;
|
||||
}
|
||||
@ -752,9 +768,61 @@ 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;
|
||||
screen = nullptr;
|
||||
}
|
||||
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()
|
||||
{
|
||||
LOG_INFO("Shutting Down");
|
||||
|
||||
#if HAS_SCREEN
|
||||
if (screen) {
|
||||
screen->showSimpleBanner("Shutting Down...", 0); // stays on screen
|
||||
}
|
||||
#endif
|
||||
#if !defined(ARCH_STM32WL)
|
||||
playShutdownMelody();
|
||||
#endif
|
||||
nodeDB->saveToDisk();
|
||||
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_ESP32) || defined(ARCH_RP2040)
|
||||
#ifdef PIN_LED1
|
||||
@ -766,7 +834,11 @@ void Power::shutdown()
|
||||
#ifdef PIN_LED3
|
||||
ledOff(PIN_LED3);
|
||||
#endif
|
||||
doDeepSleep(DELAY_FOREVER, false, false);
|
||||
doDeepSleep(DELAY_FOREVER, false, true);
|
||||
#elif defined(ARCH_PORTDUINO)
|
||||
exit(EXIT_SUCCESS);
|
||||
#else
|
||||
LOG_WARN("FIXME implement shutdown for this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1310,3 +1382,144 @@ bool Power::lipoInit()
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAS_PPM) && HAS_PPM
|
||||
|
||||
/**
|
||||
* Adapter class for BQ25896/BQ27220 Lipo battery charger.
|
||||
*/
|
||||
class LipoCharger : public HasBatteryLevel
|
||||
{
|
||||
private:
|
||||
XPowersPPM *ppm = nullptr;
|
||||
BQ27220 *bq = nullptr;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Init the I2C BQ25896 Lipo battery charger
|
||||
*/
|
||||
bool runOnce()
|
||||
{
|
||||
if (ppm == nullptr) {
|
||||
ppm = new XPowersPPM;
|
||||
bool result = ppm->init(Wire, I2C_SDA, I2C_SCL, BQ25896_ADDR);
|
||||
if (result) {
|
||||
LOG_INFO("PPM BQ25896 init succeeded");
|
||||
// Set the minimum operating voltage. Below this voltage, the PPM will protect
|
||||
// ppm->setSysPowerDownVoltage(3100);
|
||||
|
||||
// Set input current limit, default is 500mA
|
||||
// ppm->setInputCurrentLimit(800);
|
||||
|
||||
// Disable current limit pin
|
||||
// ppm->disableCurrentLimitPin();
|
||||
|
||||
// Set the charging target voltage, Range:3840 ~ 4608mV ,step:16 mV
|
||||
ppm->setChargeTargetVoltage(4288);
|
||||
|
||||
// Set the precharge current , Range: 64mA ~ 1024mA ,step:64mA
|
||||
// ppm->setPrechargeCurr(64);
|
||||
|
||||
// The premise is that limit pin is disabled, or it will
|
||||
// only follow the maximum charging current set by limit pin.
|
||||
// Set the charging current , Range:0~5056mA ,step:64mA
|
||||
ppm->setChargerConstantCurr(1024);
|
||||
|
||||
// To obtain voltage data, the ADC must be enabled first
|
||||
ppm->enableMeasure();
|
||||
|
||||
// Turn on charging function
|
||||
// If there is no battery connected, do not turn on the charging function
|
||||
ppm->enableCharge();
|
||||
} else {
|
||||
LOG_WARN("PPM BQ25896 init failed");
|
||||
delete ppm;
|
||||
ppm = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (bq == nullptr) {
|
||||
bq = new BQ27220;
|
||||
bq->setDefaultCapacity(BQ27220_DESIGN_CAPACITY);
|
||||
|
||||
bool result = bq->init();
|
||||
if (result) {
|
||||
LOG_DEBUG("BQ27220 design capacity: %d", bq->getDesignCapacity());
|
||||
LOG_DEBUG("BQ27220 fullCharge capacity: %d", bq->getFullChargeCapacity());
|
||||
LOG_DEBUG("BQ27220 remaining capacity: %d", bq->getRemainingCapacity());
|
||||
return true;
|
||||
} else {
|
||||
LOG_WARN("BQ27220 init failed");
|
||||
delete bq;
|
||||
bq = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Battery state of charge, from 0 to 100 or -1 for unknown
|
||||
*/
|
||||
virtual int getBatteryPercent() override
|
||||
{
|
||||
return -1;
|
||||
// return bq->getChargePercent(); // don't use BQ27220 for battery percent, it is not calibrated
|
||||
}
|
||||
|
||||
/**
|
||||
* The raw voltage of the battery in millivolts, or NAN if unknown
|
||||
*/
|
||||
virtual uint16_t getBattVoltage() override { return bq->getVoltage(); }
|
||||
|
||||
/**
|
||||
* return true if there is a battery installed in this unit
|
||||
*/
|
||||
virtual bool isBatteryConnect() override { return ppm->getBattVoltage() > 0; }
|
||||
|
||||
/**
|
||||
* return true if there is an external power source detected
|
||||
*/
|
||||
virtual bool isVbusIn() override { return ppm->getVbusVoltage() > 0; }
|
||||
|
||||
/**
|
||||
* return true if the battery is currently charging
|
||||
*/
|
||||
virtual bool isCharging() override
|
||||
{
|
||||
bool isCharging = ppm->isCharging();
|
||||
if (isCharging) {
|
||||
LOG_DEBUG("BQ27220 time to full charge: %d min", bq->getTimeToFull());
|
||||
} else {
|
||||
if (!ppm->isVbusIn()) {
|
||||
LOG_DEBUG("BQ27220 time to empty: %d min (%d mAh)", bq->getTimeToEmpty(), bq->getRemainingCapacity());
|
||||
}
|
||||
}
|
||||
return isCharging;
|
||||
}
|
||||
};
|
||||
|
||||
LipoCharger lipoCharger;
|
||||
|
||||
/**
|
||||
* Init the Lipo battery charger
|
||||
*/
|
||||
bool Power::lipoChargerInit()
|
||||
{
|
||||
bool result = lipoCharger.runOnce();
|
||||
LOG_DEBUG("Power::lipoChargerInit lipo sensor is %s", result ? "ready" : "not ready yet");
|
||||
if (!result)
|
||||
return false;
|
||||
batteryLevel = &lipoCharger;
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* The Lipo battery level sensor is unavailable - default to AnalogBatteryLevel
|
||||
*/
|
||||
bool Power::lipoChargerInit()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -72,7 +72,7 @@ extern Power *power;
|
||||
static void shutdownEnter()
|
||||
{
|
||||
LOG_DEBUG("State: SHUTDOWN");
|
||||
power->shutdown();
|
||||
shutdownAtMsec = millis();
|
||||
}
|
||||
|
||||
#include "error.h"
|
||||
|
@ -47,10 +47,6 @@ int BuzzerFeedbackThread::handleInputEvent(const InputEvent *event)
|
||||
playComboTune(); // Ping sent feedback
|
||||
break;
|
||||
|
||||
case INPUT_BROKER_SHUTDOWN:
|
||||
playShutdownMelody(); // Shutdown feedback
|
||||
break;
|
||||
|
||||
default:
|
||||
// For other events, check if it's a printable character
|
||||
if (event->kbchar >= 32 && event->kbchar <= 126) {
|
||||
@ -69,10 +65,7 @@ int32_t BuzzerFeedbackThread::runOnce()
|
||||
// This thread is primarily event-driven, but we can use runOnce
|
||||
// for any periodic tasks if needed in the future
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
// Could add any periodic processing here
|
||||
}
|
||||
needsUpdate = false;
|
||||
|
||||
// Run every 100ms when active, less frequently when idle
|
||||
return needsUpdate ? 100 : 1000;
|
||||
|
@ -150,11 +150,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// Define if screen should be mirrored left to right
|
||||
// #define SCREEN_MIRROR
|
||||
|
||||
// I2C Keyboards (M5Stack, RAK14004, T-Deck)
|
||||
// I2C Keyboards (M5Stack, RAK14004, T-Deck, T-Deck Pro, T-Lora Pager, CardKB, BBQ10, MPR121, TCA8418)
|
||||
#define CARDKB_ADDR 0x5F
|
||||
#define TDECK_KB_ADDR 0x55
|
||||
#define BBQ10_KB_ADDR 0x1F
|
||||
#define MPR121_KB_ADDR 0x5A
|
||||
#define TCA8418_KB_ADDR 0x34
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SENSOR
|
||||
@ -193,8 +194,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define MLX90614_ADDR_DEF 0x5A
|
||||
#define CGRADSENS_ADDR 0x66
|
||||
#define LTR390UV_ADDR 0x53
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 // same adress as TCA8418
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 // same adress as TCA8418_KB
|
||||
#define PCT2075_ADDR 0x37
|
||||
#define BQ27220_ADDR 0x55 // same address as TDECK_KB
|
||||
#define BQ25896_ADDR 0x6B
|
||||
#define LTR553ALS_ADDR 0x23
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ACCELEROMETER
|
||||
@ -208,6 +212,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define BMX160_ADDR 0x69
|
||||
#define ICM20948_ADDR 0x69
|
||||
#define ICM20948_ADDR_ALT 0x68
|
||||
#define BHI260AP_ADDR 0x28
|
||||
#define BMM150_ADDR 0x13
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -230,6 +235,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// Touchscreen
|
||||
// -----------------------------------------------------------------------------
|
||||
#define FT6336U_ADDR 0x48
|
||||
#define CST328_ADDR 0x1A
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// RAK12035VB Soil Monitor (using RAK12023 up to 3 RAK12035 monitors can be connected)
|
||||
|
@ -74,7 +74,12 @@ class ScanI2C
|
||||
RAK12035,
|
||||
TCA8418KB,
|
||||
PCT2075,
|
||||
BMM150,
|
||||
CST328,
|
||||
BQ25896,
|
||||
BQ27220,
|
||||
LTR553ALS,
|
||||
BHI260AP,
|
||||
BMM150
|
||||
} DeviceType;
|
||||
|
||||
// typedef uint8_t DeviceAddress;
|
||||
|
@ -184,8 +184,13 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
type = RTC_RV3028;
|
||||
logFoundDevice("RV3028", (uint8_t)addr.address);
|
||||
rtc.initI2C(*i2cBus);
|
||||
rtc.writeToRegister(0x35, 0x07); // no Clkout
|
||||
rtc.writeToRegister(0x37, 0xB4);
|
||||
// Update RTC EEPROM settings, if necessary
|
||||
if (rtc.readEEPROMRegister(0x35) != 0x07) {
|
||||
rtc.writeEEPROMRegister(0x35, 0x07); // no Clkout
|
||||
}
|
||||
if (rtc.readEEPROMRegister(0x37) != 0xB4) {
|
||||
rtc.writeEEPROMRegister(0x37, 0xB4);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -206,7 +211,17 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
}
|
||||
break;
|
||||
|
||||
SCAN_SIMPLE_CASE(TDECK_KB_ADDR, TDECKKB, "T-Deck keyboard", (uint8_t)addr.address);
|
||||
case TDECK_KB_ADDR:
|
||||
// Do we have the T-Deck keyboard or the T-Deck Pro battery sensor?
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x04), 1);
|
||||
if (registerValue != 0) {
|
||||
logFoundDevice("BQ27220", (uint8_t)addr.address);
|
||||
type = BQ27220;
|
||||
} else {
|
||||
logFoundDevice("TDECKKB", (uint8_t)addr.address);
|
||||
type = TDECKKB;
|
||||
}
|
||||
break;
|
||||
SCAN_SIMPLE_CASE(BBQ10_KB_ADDR, BBQ10KB, "BB Q10", (uint8_t)addr.address);
|
||||
|
||||
SCAN_SIMPLE_CASE(ST7567_ADDRESS, SCREEN_ST7567, "ST7567", (uint8_t)addr.address);
|
||||
@ -396,6 +411,12 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
logFoundDevice("BQ24295", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x14), 1); // get ID
|
||||
if ((registerValue & 0b00000011) == 0b00000010) {
|
||||
type = BQ25896;
|
||||
logFoundDevice("BQ25896", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1); // get ID
|
||||
if (registerValue == 0x6A) {
|
||||
type = LSM6DS3;
|
||||
@ -447,6 +468,9 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(CST328_ADDR, CST328, "CST328", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(LTR553ALS_ADDR, LTR553ALS, "LTR553ALS", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(BHI260AP_ADDR, BHI260AP, "BHI260AP", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(SCD4X_ADDR, SCD4X, "SCD4X", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(BMM150_ADDR, BMM150, "BMM150", (uint8_t)addr.address);
|
||||
#ifdef HAS_TPS65233
|
||||
|
@ -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
|
||||
@ -1503,7 +1511,7 @@ bool GPS::lookForTime()
|
||||
|
||||
#ifdef GNSS_AIROHA
|
||||
uint8_t fix = reader.fixQuality();
|
||||
if (fix > 0) {
|
||||
if (fix >= 1 && fix <= 5) {
|
||||
if (lastFixStartMsec > 0) {
|
||||
if (Throttle::isWithinTimespanMs(lastFixStartMsec, GPS_FIX_HOLD_TIME)) {
|
||||
return false;
|
||||
@ -1558,7 +1566,7 @@ bool GPS::lookForLocation()
|
||||
#ifdef GNSS_AIROHA
|
||||
if ((config.position.gps_update_interval * 1000) >= (GPS_FIX_HOLD_TIME * 2)) {
|
||||
uint8_t fix = reader.fixQuality();
|
||||
if (fix > 0) {
|
||||
if (fix >= 1 && fix <= 5) {
|
||||
if (lastFixStartMsec > 0) {
|
||||
if (Throttle::isWithinTimespanMs(lastFixStartMsec, GPS_FIX_HOLD_TIME)) {
|
||||
return false;
|
||||
|
@ -226,7 +226,14 @@ RTCSetResult perhapsSetRTC(RTCQuality q, struct tm &t)
|
||||
time_t res = gm_mktime(&t);
|
||||
struct timeval tv;
|
||||
tv.tv_sec = res;
|
||||
tv.tv_usec = 0; // time.centisecond() * (10 / 1000);
|
||||
tv.tv_usec = 0; // time.centisecond() * (10 / 1000);
|
||||
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
|
||||
#ifdef BUILD_EPOCH
|
||||
if (tv.tv_sec < BUILD_EPOCH) {
|
||||
LOG_WARN("Ignore time (%ld) before build epoch (%ld)!", printableEpoch, BUILD_EPOCH);
|
||||
return RTCSetResultInvalidTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
// LOG_DEBUG("Got time from GPS month=%d, year=%d, unixtime=%ld", t.tm_mon, t.tm_year, tv.tv_sec);
|
||||
if (t.tm_year < 0 || t.tm_year >= 300) {
|
||||
|
@ -151,6 +151,21 @@ bool EInkDisplay::connect()
|
||||
#else
|
||||
adafruitDisplay->setRotation(3);
|
||||
#endif
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
}
|
||||
#elif defined(ELECROW_ThinkNode_M5)
|
||||
{
|
||||
// Start HSPI
|
||||
hspi = new SPIClass(HSPI);
|
||||
hspi->begin(PIN_EINK_SCLK, -1, PIN_EINK_MOSI, PIN_EINK_CS); // SCLK, MISO, MOSI, SS
|
||||
|
||||
auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, *hspi);
|
||||
|
||||
adafruitDisplay = new GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||
adafruitDisplay->init();
|
||||
|
||||
adafruitDisplay->setRotation(4);
|
||||
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
}
|
||||
#elif defined(MESHLINK)
|
||||
@ -206,7 +221,7 @@ bool EInkDisplay::connect()
|
||||
adafruitDisplay->setRotation(0);
|
||||
adafruitDisplay->setPartialWindow(0, 0, EINK_WIDTH, EINK_HEIGHT);
|
||||
}
|
||||
#elif defined(M5_COREINK)
|
||||
#elif defined(M5_COREINK) || defined(T_DECK_PRO)
|
||||
auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY);
|
||||
adafruitDisplay = new GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||
adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
|
@ -80,7 +80,7 @@ class EInkDisplay : public OLEDDisplay
|
||||
// If display uses HSPI
|
||||
#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_VISION_MASTER_E213) || \
|
||||
defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) || defined(CROWPANEL_ESP32S3_5_EPAPER) || \
|
||||
defined(CROWPANEL_ESP32S3_4_EPAPER) || defined(CROWPANEL_ESP32S3_2_EPAPER)
|
||||
defined(CROWPANEL_ESP32S3_4_EPAPER) || defined(CROWPANEL_ESP32S3_2_EPAPER) || defined(ELECROW_ThinkNode_M5)
|
||||
SPIClass *hspi = NULL;
|
||||
#endif
|
||||
|
||||
|
@ -365,9 +365,6 @@ void Screen::doDeepSleep()
|
||||
{
|
||||
#ifdef USE_EINK
|
||||
setOn(false, graphics::UIRenderer::drawDeepSleepFrame);
|
||||
#ifdef PIN_EINK_EN
|
||||
digitalWrite(PIN_EINK_EN, LOW); // power off backlight
|
||||
#endif
|
||||
#else
|
||||
// Without E-Ink display:
|
||||
setOn(false);
|
||||
@ -391,6 +388,14 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
dispdev->displayOn();
|
||||
#endif
|
||||
|
||||
#ifdef PIN_EINK_EN
|
||||
if (uiconfig.screen_brightness == 1)
|
||||
digitalWrite(PIN_EINK_EN, HIGH);
|
||||
#elif defined(PCA_PIN_EINK_EN)
|
||||
if (uiconfig.screen_brightness == 1)
|
||||
io.digitalWrite(PCA_PIN_EINK_EN, HIGH);
|
||||
#endif
|
||||
|
||||
#if defined(ST7789_CS) && \
|
||||
!defined(M5STACK) // set display brightness when turning on screens. Just moved function from TFTDisplay to here.
|
||||
static_cast<TFTDisplay *>(dispdev)->setDisplayBrightness(brightness);
|
||||
@ -420,11 +425,13 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
// eInkScreensaver parameter is usually NULL (default argument), default frame used instead
|
||||
setScreensaverFrames(einkScreensaver);
|
||||
#endif
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
||||
digitalWrite(PIN_EINK_EN, LOW);
|
||||
}
|
||||
|
||||
#ifdef PIN_EINK_EN
|
||||
digitalWrite(PIN_EINK_EN, LOW);
|
||||
#elif defined(PCA_PIN_EINK_EN)
|
||||
io.digitalWrite(PCA_PIN_EINK_EN, LOW);
|
||||
#endif
|
||||
|
||||
dispdev->displayOff();
|
||||
#ifdef USE_ST7789
|
||||
SPI1.end();
|
||||
@ -579,7 +586,7 @@ void Screen::setup()
|
||||
touchScreenImpl1->init();
|
||||
}
|
||||
}
|
||||
#elif HAS_TOUCHSCREEN
|
||||
#elif HAS_TOUCHSCREEN && !defined(USE_EINK)
|
||||
touchScreenImpl1 =
|
||||
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
|
||||
touchScreenImpl1->init();
|
||||
@ -1001,7 +1008,7 @@ void Screen::setFrames(FrameFocus focus)
|
||||
// Insert favorite frames *after* collecting them all
|
||||
if (!favoriteFrames.empty()) {
|
||||
fsi.positions.firstFavorite = numframes;
|
||||
for (auto &f : favoriteFrames) {
|
||||
for (const auto &f : favoriteFrames) {
|
||||
normalFrames[numframes++] = f;
|
||||
indicatorIcons.push_back(icon_node);
|
||||
}
|
||||
@ -1264,40 +1271,39 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
||||
if (shouldWakeOnReceivedMessage()) {
|
||||
setOn(true); // Wake up the screen first
|
||||
forceDisplay(); // Forces screen redraw
|
||||
|
||||
// === Prepare banner content ===
|
||||
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(packet->from);
|
||||
const char *longName = (node && node->has_user) ? node->user.long_name : nullptr;
|
||||
|
||||
const char *msgRaw = reinterpret_cast<const char *>(packet->decoded.payload.bytes);
|
||||
|
||||
char banner[256];
|
||||
|
||||
// Check for bell character in message to determine alert type
|
||||
bool isAlert = false;
|
||||
for (size_t i = 0; i < packet->decoded.payload.size && i < 100; i++) {
|
||||
if (msgRaw[i] == '\x07') {
|
||||
isAlert = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAlert) {
|
||||
if (longName && longName[0]) {
|
||||
snprintf(banner, sizeof(banner), "Alert Received from\n%s", longName);
|
||||
} else {
|
||||
strcpy(banner, "Alert Received");
|
||||
}
|
||||
} else {
|
||||
if (longName && longName[0]) {
|
||||
snprintf(banner, sizeof(banner), "New Message from\n%s", longName);
|
||||
} else {
|
||||
strcpy(banner, "New Message");
|
||||
}
|
||||
}
|
||||
|
||||
screen->showSimpleBanner(banner, 3000);
|
||||
}
|
||||
// === Prepare banner content ===
|
||||
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(packet->from);
|
||||
const char *longName = (node && node->has_user) ? node->user.long_name : nullptr;
|
||||
|
||||
const char *msgRaw = reinterpret_cast<const char *>(packet->decoded.payload.bytes);
|
||||
|
||||
char banner[256];
|
||||
|
||||
// Check for bell character in message to determine alert type
|
||||
bool isAlert = false;
|
||||
for (size_t i = 0; i < packet->decoded.payload.size && i < 100; i++) {
|
||||
if (msgRaw[i] == '\x07') {
|
||||
isAlert = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAlert) {
|
||||
if (longName && longName[0]) {
|
||||
snprintf(banner, sizeof(banner), "Alert Received from\n%s", longName);
|
||||
} else {
|
||||
strcpy(banner, "Alert Received");
|
||||
}
|
||||
} else {
|
||||
if (longName && longName[0]) {
|
||||
snprintf(banner, sizeof(banner), "New Message from\n%s", longName);
|
||||
} else {
|
||||
strcpy(banner, "New Message");
|
||||
}
|
||||
}
|
||||
|
||||
screen->showSimpleBanner(banner, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "graphics/fonts/OLEDDisplayFontsCS.h"
|
||||
#endif
|
||||
|
||||
#ifdef CROWPANEL_ESP32S3_5_EPAPER
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER) && defined(USE_EINK)
|
||||
#include "graphics/fonts/EinkDisplayFonts.h"
|
||||
#endif
|
||||
|
||||
@ -40,6 +40,9 @@
|
||||
#ifdef OLED_PL
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_PL // Height: 19
|
||||
#else
|
||||
#ifdef OLED_RU
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_RU // Height: 19
|
||||
#else
|
||||
#ifdef OLED_UA
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_UA // Height: 19
|
||||
#else
|
||||
@ -50,9 +53,13 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef OLED_PL
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_PL // Height: 28
|
||||
#else
|
||||
#ifdef OLED_RU
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_RU // Height: 28
|
||||
#else
|
||||
#ifdef OLED_UA
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_UA // Height: 28
|
||||
#else
|
||||
@ -63,6 +70,7 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS)) && \
|
||||
@ -77,7 +85,7 @@
|
||||
#define FONT_LARGE FONT_LARGE_LOCAL // Height: 28
|
||||
#endif
|
||||
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER)
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER) && defined(USE_EINK)
|
||||
#undef FONT_SMALL
|
||||
#undef FONT_MEDIUM
|
||||
#undef FONT_LARGE
|
||||
|
@ -218,7 +218,6 @@ void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int1
|
||||
hour %= 12;
|
||||
if (hour == 0)
|
||||
hour = 12;
|
||||
bool isPM = hour >= 12;
|
||||
snprintf(timeString, sizeof(timeString), "%d:%02d", hour, minute);
|
||||
} else {
|
||||
snprintf(timeString, sizeof(timeString), "%02d:%02d", hour, minute);
|
||||
@ -367,7 +366,7 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
// hour hand radius and y coordinate
|
||||
int16_t hourHandRadius = radius * 0.35;
|
||||
if (isHighResolution) {
|
||||
int16_t hourHandRadius = radius * 0.55;
|
||||
hourHandRadius = radius * 0.55;
|
||||
}
|
||||
int16_t hourHandNoonY = centerY - hourHandRadius;
|
||||
|
||||
@ -386,7 +385,7 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
|
||||
bool isPM = hour >= 12;
|
||||
if (config.display.use_12h_clock) {
|
||||
bool isPM = hour >= 12;
|
||||
isPM = hour >= 12;
|
||||
display->setFont(FONT_SMALL);
|
||||
int yOffset = isHighResolution ? 1 : 0;
|
||||
#ifdef USE_EINK
|
||||
|
@ -412,9 +412,9 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
||||
float freq = RadioLibInterface::instance->getFreq();
|
||||
snprintf(freqStr, sizeof(freqStr), "%.3f", freq);
|
||||
if (config.lora.channel_num == 0) {
|
||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %smhz", freqStr);
|
||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %sMHz", freqStr);
|
||||
} else {
|
||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Ch: %smhz (%d)", freqStr, config.lora.channel_num);
|
||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Ch: %sMHz (%d)", freqStr, config.lora.channel_num);
|
||||
}
|
||||
size_t len = strlen(frequencyslot);
|
||||
if (len >= 4 && strcmp(frequencyslot + len - 4, " (0)") == 0) {
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include "modules/CannedMessageModule.h"
|
||||
#include "modules/KeyVerificationModule.h"
|
||||
|
||||
#include "modules/TraceRouteModule.h"
|
||||
#include <functional>
|
||||
|
||||
extern uint16_t TFT_MESH;
|
||||
|
||||
namespace graphics
|
||||
@ -51,12 +54,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)) {
|
||||
@ -115,6 +120,22 @@ void menuHandler::TwelveHourPicker()
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
}
|
||||
|
||||
// Reusable confirmation prompt function
|
||||
void menuHandler::showConfirmationBanner(const char *message, std::function<void()> onConfirm)
|
||||
{
|
||||
static const char *confirmOptions[] = {"No", "Yes"};
|
||||
BannerOverlayOptions confirmBanner;
|
||||
confirmBanner.message = message;
|
||||
confirmBanner.optionsArrayPtr = confirmOptions;
|
||||
confirmBanner.optionsCount = 2;
|
||||
confirmBanner.bannerCallback = [onConfirm](int confirmSelected) -> void {
|
||||
if (confirmSelected == 1) {
|
||||
onConfirm();
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(confirmBanner);
|
||||
}
|
||||
|
||||
void menuHandler::ClockFacePicker()
|
||||
{
|
||||
static const char *optionsArray[] = {"Back", "Digital", "Analog"};
|
||||
@ -151,6 +172,7 @@ void menuHandler::TZPicker()
|
||||
"US/Mountain",
|
||||
"US/Central",
|
||||
"US/Eastern",
|
||||
"BR/Brasilia",
|
||||
"UTC",
|
||||
"EU/Western",
|
||||
"EU/"
|
||||
@ -165,7 +187,7 @@ void menuHandler::TZPicker()
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Pick Timezone";
|
||||
bannerOptions.optionsArrayPtr = optionsArray;
|
||||
bannerOptions.optionsCount = 17;
|
||||
bannerOptions.optionsCount = 19;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == 0) {
|
||||
menuHandler::menuQueue = menuHandler::clock_menu;
|
||||
@ -184,25 +206,27 @@ void menuHandler::TZPicker()
|
||||
strncpy(config.device.tzdef, "CST6CDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||
} else if (selected == 7) { // Eastern
|
||||
strncpy(config.device.tzdef, "EST5EDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||
} else if (selected == 8) { // UTC
|
||||
strncpy(config.device.tzdef, "UTC", sizeof(config.device.tzdef));
|
||||
} else if (selected == 9) { // EU/Western
|
||||
} else if (selected == 8) { // Brazil
|
||||
strncpy(config.device.tzdef, "BRT3", sizeof(config.device.tzdef));
|
||||
} else if (selected == 9) { // UTC
|
||||
strncpy(config.device.tzdef, "UTC0", sizeof(config.device.tzdef));
|
||||
} else if (selected == 10) { // EU/Western
|
||||
strncpy(config.device.tzdef, "GMT0BST,M3.5.0/1,M10.5.0", sizeof(config.device.tzdef));
|
||||
} else if (selected == 10) { // EU/Central
|
||||
} else if (selected == 11) { // EU/Central
|
||||
strncpy(config.device.tzdef, "CET-1CEST,M3.5.0,M10.5.0/3", sizeof(config.device.tzdef));
|
||||
} else if (selected == 11) { // EU/Eastern
|
||||
} else if (selected == 12) { // EU/Eastern
|
||||
strncpy(config.device.tzdef, "EET-2EEST,M3.5.0/3,M10.5.0/4", sizeof(config.device.tzdef));
|
||||
} else if (selected == 12) { // Asia/Kolkata
|
||||
} else if (selected == 13) { // Asia/Kolkata
|
||||
strncpy(config.device.tzdef, "IST-5:30", sizeof(config.device.tzdef));
|
||||
} else if (selected == 13) { // China
|
||||
} else if (selected == 14) { // China
|
||||
strncpy(config.device.tzdef, "HKT-8", sizeof(config.device.tzdef));
|
||||
} else if (selected == 14) { // AU/AWST
|
||||
} else if (selected == 15) { // AU/AWST
|
||||
strncpy(config.device.tzdef, "AWST-8", sizeof(config.device.tzdef));
|
||||
} else if (selected == 15) { // AU/ACST
|
||||
} else if (selected == 16) { // AU/ACST
|
||||
strncpy(config.device.tzdef, "ACST-9:30ACDT,M10.1.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||
} else if (selected == 16) { // AU/AEST
|
||||
} else if (selected == 17) { // AU/AEST
|
||||
strncpy(config.device.tzdef, "AEST-10AEDT,M10.1.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||
} else if (selected == 17) { // NZ
|
||||
} else if (selected == 18) { // NZ
|
||||
strncpy(config.device.tzdef, "NZST-12NZDT,M9.5.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||
}
|
||||
if (selected != 0) {
|
||||
@ -288,13 +312,13 @@ void menuHandler::messageResponseMenu()
|
||||
|
||||
void menuHandler::homeBaseMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Backlight, Position, Preset, Freetext, Bluetooth, Sleep, enumEnd };
|
||||
enum optionsNumbers { Back, Backlight, Position, Preset, Freetext, Sleep, enumEnd };
|
||||
|
||||
static const char *optionsArray[enumEnd] = {"Back"};
|
||||
static int optionsEnumArray[enumEnd] = {Back};
|
||||
int options = 1;
|
||||
|
||||
#ifdef PIN_EINK_EN
|
||||
#if defined(PIN_EINK_EN) || defined(PCA_PIN_EINK_EN)
|
||||
optionsArray[options] = "Toggle Backlight";
|
||||
optionsEnumArray[options++] = Backlight;
|
||||
#else
|
||||
@ -310,8 +334,6 @@ void menuHandler::homeBaseMenu()
|
||||
optionsArray[options] = "New Freetext Msg";
|
||||
optionsEnumArray[options++] = Freetext;
|
||||
}
|
||||
optionsArray[options] = "Bluetooth Toggle";
|
||||
optionsEnumArray[options++] = Bluetooth;
|
||||
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Home Action";
|
||||
@ -320,12 +342,24 @@ void menuHandler::homeBaseMenu()
|
||||
bannerOptions.optionsCount = options;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == Backlight) {
|
||||
#ifdef PIN_EINK_EN
|
||||
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
||||
#if defined(PIN_EINK_EN)
|
||||
if (uiconfig.screen_brightness == 1) {
|
||||
uiconfig.screen_brightness = 0;
|
||||
digitalWrite(PIN_EINK_EN, LOW);
|
||||
} else {
|
||||
uiconfig.screen_brightness = 1;
|
||||
digitalWrite(PIN_EINK_EN, HIGH);
|
||||
}
|
||||
saveUIConfig();
|
||||
#elif defined(PCA_PIN_EINK_EN)
|
||||
if (uiconfig.screen_brightness == 1) {
|
||||
uiconfig.screen_brightness = 0;
|
||||
io.digitalWrite(PCA_PIN_EINK_EN, LOW);
|
||||
} else {
|
||||
uiconfig.screen_brightness = 1;
|
||||
io.digitalWrite(PCA_PIN_EINK_EN, HIGH);
|
||||
}
|
||||
saveUIConfig();
|
||||
#endif
|
||||
} else if (selected == Sleep) {
|
||||
screen->setOn(false);
|
||||
@ -336,9 +370,6 @@ void menuHandler::homeBaseMenu()
|
||||
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
||||
} else if (selected == Freetext) {
|
||||
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
||||
} else if (selected == Bluetooth) {
|
||||
menuQueue = bluetooth_toggle_menu;
|
||||
screen->runNow();
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
@ -375,7 +406,7 @@ void menuHandler::textMessageBaseMenu()
|
||||
|
||||
void menuHandler::systemBaseMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Notifications, ScreenOptions, PowerMenu, Test, enumEnd };
|
||||
enum optionsNumbers { Back, Notifications, ScreenOptions, Bluetooth, PowerMenu, Test, enumEnd };
|
||||
static const char *optionsArray[enumEnd] = {"Back"};
|
||||
static int optionsEnumArray[enumEnd] = {Back};
|
||||
int options = 1;
|
||||
@ -388,6 +419,9 @@ void menuHandler::systemBaseMenu()
|
||||
optionsEnumArray[options++] = ScreenOptions;
|
||||
#endif
|
||||
|
||||
optionsArray[options] = "Bluetooth Toggle";
|
||||
optionsEnumArray[options++] = Bluetooth;
|
||||
|
||||
optionsArray[options] = "Reboot/Shutdown";
|
||||
optionsEnumArray[options++] = PowerMenu;
|
||||
|
||||
@ -414,6 +448,9 @@ void menuHandler::systemBaseMenu()
|
||||
} else if (selected == Test) {
|
||||
menuHandler::menuQueue = menuHandler::test_menu;
|
||||
screen->runNow();
|
||||
} else if (selected == Bluetooth) {
|
||||
menuQueue = bluetooth_toggle_menu;
|
||||
screen->runNow();
|
||||
} else if (selected == Back && !test_enabled) {
|
||||
test_count++;
|
||||
if (test_count > 4) {
|
||||
@ -426,7 +463,7 @@ void menuHandler::systemBaseMenu()
|
||||
|
||||
void menuHandler::favoriteBaseMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Preset, Freetext, Remove, enumEnd };
|
||||
enum optionsNumbers { Back, Preset, Freetext, Remove, TraceRoute, enumEnd };
|
||||
static const char *optionsArray[enumEnd] = {"Back", "New Preset Msg"};
|
||||
static int optionsEnumArray[enumEnd] = {Back, Preset};
|
||||
int options = 2;
|
||||
@ -435,6 +472,8 @@ void menuHandler::favoriteBaseMenu()
|
||||
optionsArray[options] = "New Freetext Msg";
|
||||
optionsEnumArray[options++] = Freetext;
|
||||
}
|
||||
optionsArray[options] = "Trace Route";
|
||||
optionsEnumArray[options++] = TraceRoute;
|
||||
optionsArray[options] = "Remove Favorite";
|
||||
optionsEnumArray[options++] = Remove;
|
||||
|
||||
@ -451,6 +490,10 @@ void menuHandler::favoriteBaseMenu()
|
||||
} else if (selected == Remove) {
|
||||
menuHandler::menuQueue = menuHandler::remove_favorite;
|
||||
screen->runNow();
|
||||
} else if (selected == TraceRoute) {
|
||||
if (traceRouteModule) {
|
||||
traceRouteModule->launch(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||
}
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
@ -489,12 +532,12 @@ void menuHandler::positionBaseMenu()
|
||||
|
||||
void menuHandler::nodeListMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Favorite, Verify, Reset };
|
||||
static const char *optionsArray[] = {"Back", "Add Favorite", "Key Verification", "Reset NodeDB"};
|
||||
enum optionsNumbers { Back, Favorite, TraceRoute, Verify, Reset, enumEnd };
|
||||
static const char *optionsArray[] = {"Back", "Add Favorite", "Trace Route", "Key Verification", "Reset NodeDB"};
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Node Action";
|
||||
bannerOptions.optionsArrayPtr = optionsArray;
|
||||
bannerOptions.optionsCount = 4;
|
||||
bannerOptions.optionsCount = 5;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == Favorite) {
|
||||
menuQueue = add_favorite;
|
||||
@ -505,6 +548,9 @@ void menuHandler::nodeListMenu()
|
||||
} else if (selected == Reset) {
|
||||
menuQueue = reset_node_db_menu;
|
||||
screen->runNow();
|
||||
} else if (selected == TraceRoute) {
|
||||
menuQueue = trace_route_menu;
|
||||
screen->runNow();
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
@ -815,9 +861,8 @@ void menuHandler::shutdownMenu()
|
||||
bannerOptions.optionsCount = 2;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
IF_SCREEN(screen->showSimpleBanner("Shutting Down...", 0));
|
||||
nodeDB->saveToDisk();
|
||||
power->shutdown();
|
||||
InputEvent event = {.inputEvent = (input_broker_event)INPUT_BROKER_SHUTDOWN, .kbchar = 0, .touchX = 0, .touchY = 0};
|
||||
inputBroker->injectInputEvent(&event);
|
||||
} else {
|
||||
menuQueue = power_menu;
|
||||
screen->runNow();
|
||||
@ -858,6 +903,16 @@ void menuHandler::removeFavoriteMenu()
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
}
|
||||
|
||||
void menuHandler::traceRouteMenu()
|
||||
{
|
||||
screen->showNodePicker("Node to Trace", 30000, [](uint32_t nodenum) -> void {
|
||||
LOG_INFO("Menu: Node picker selected node 0x%08x, traceRouteModule=%p", nodenum, traceRouteModule);
|
||||
if (traceRouteModule) {
|
||||
traceRouteModule->startTraceRoute(nodenum);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void menuHandler::testMenu()
|
||||
{
|
||||
|
||||
@ -1130,6 +1185,9 @@ void menuHandler::handleMenuSwitch(OLEDDisplay *display)
|
||||
case remove_favorite:
|
||||
removeFavoriteMenu();
|
||||
break;
|
||||
case trace_route_menu:
|
||||
traceRouteMenu();
|
||||
break;
|
||||
case test_menu:
|
||||
testMenu();
|
||||
break;
|
||||
|
@ -36,12 +36,14 @@ class menuHandler
|
||||
system_base_menu,
|
||||
key_verification_init,
|
||||
key_verification_final_prompt,
|
||||
throttle_message
|
||||
trace_route_menu,
|
||||
throttle_message,
|
||||
};
|
||||
static screenMenus menuQueue;
|
||||
|
||||
static void LoraRegionPicker(uint32_t duration = 30000);
|
||||
static void handleMenuSwitch(OLEDDisplay *display);
|
||||
static void showConfirmationBanner(const char *message, std::function<void()> onConfirm);
|
||||
static void clockMenu();
|
||||
static void TZPicker();
|
||||
static void TwelveHourPicker();
|
||||
@ -64,6 +66,7 @@ class menuHandler
|
||||
static void shutdownMenu();
|
||||
static void addFavoriteMenu();
|
||||
static void removeFavoriteMenu();
|
||||
static void traceRouteMenu();
|
||||
static void testMenu();
|
||||
static void numberTest();
|
||||
static void wifiBaseMenu();
|
||||
|
@ -137,7 +137,11 @@ void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string
|
||||
display->drawString(cursorX + 1, fontY, textChunk.c_str());
|
||||
}
|
||||
display->drawString(cursorX, fontY, textChunk.c_str());
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
cursorX += display->getStringWidth(textChunk.c_str(), textChunk.length(), true);
|
||||
#else
|
||||
cursorX += display->getStringWidth(textChunk.c_str());
|
||||
#endif
|
||||
i = nextControl;
|
||||
continue;
|
||||
}
|
||||
@ -155,7 +159,12 @@ void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string
|
||||
display->drawString(cursorX + 1, fontY, remaining.c_str());
|
||||
}
|
||||
display->drawString(cursorX, fontY, remaining.c_str());
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
cursorX += display->getStringWidth(remaining.c_str(), remaining.length(), true);
|
||||
#else
|
||||
cursorX += display->getStringWidth(remaining.c_str());
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -273,7 +282,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
currentKey ^= ((size_t)mp.id << 24);
|
||||
|
||||
if (cachedKey != currentKey) {
|
||||
LOG_INFO("Message cache key is misssed cachedKey=0x%0x, currentKey=0x%x", cachedKey, currentKey);
|
||||
LOG_INFO("Onscreen message scroll cache key needs updating: cachedKey=0x%0x, currentKey=0x%x", cachedKey, currentKey);
|
||||
|
||||
// Cache miss - regenerate lines and heights
|
||||
cachedLines = generateLines(display, headerStr, messageBuf, textWidth);
|
||||
@ -374,10 +383,16 @@ std::vector<std::string> generateLines(OLEDDisplay *display, const char *headerS
|
||||
} else {
|
||||
word += ch;
|
||||
std::string test = line + word;
|
||||
// Keep these lines for diagnostics
|
||||
// LOG_INFO("Char: '%c' (0x%02X)", ch, (unsigned char)ch);
|
||||
// LOG_INFO("Current String: %s", test.c_str());
|
||||
if (display->getStringWidth(test.c_str()) > textWidth) {
|
||||
// Keep these lines for diagnostics
|
||||
// LOG_INFO("Char: '%c' (0x%02X)", ch, (unsigned char)ch);
|
||||
// LOG_INFO("Current String: %s", test.c_str());
|
||||
// Note: there are boolean comparison uint16 (getStringWidth) with int (textWidth), hope textWidth is always positive :)
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
uint16_t strWidth = display->getStringWidth(test.c_str(), test.length(), true);
|
||||
#else
|
||||
uint16_t strWidth = display->getStringWidth(test.c_str());
|
||||
#endif
|
||||
if (strWidth > textWidth) {
|
||||
if (!line.empty())
|
||||
lines.push_back(line);
|
||||
line = word;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#ifdef USE_EINK
|
||||
|
||||
#include "EinkDisplayFonts.h"
|
||||
|
||||
// Created by https://oleddisplay.squix.ch/ Consider a donation
|
||||
@ -1182,3 +1184,5 @@ const uint8_t Monospaced_plain_30[] PROGMEM = {
|
||||
0xF0, 0xFF, 0x01, 0x00, 0x00, 0xC0, 0x7F, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0xE0, 0x00, 0xFE, 0x03, 0x00, 0xE0, 0x80, 0x7F,
|
||||
0x00, 0x00, 0xE0, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0xF0, 0x03, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x10 // 255
|
||||
};
|
||||
|
||||
#endif // USE_EINK
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef EINKDISPLAYFONTS_h
|
||||
#define EINKDISPLAYFONTS_h
|
||||
|
||||
#ifdef USE_EINK
|
||||
|
||||
#ifdef ARDUINO
|
||||
#include <Arduino.h>
|
||||
#elif __MBED__
|
||||
@ -11,4 +13,7 @@
|
||||
* Monospaced Plain 30
|
||||
*/
|
||||
extern const uint8_t Monospaced_plain_30[] PROGMEM;
|
||||
|
||||
#endif // USE_EINK
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,5 @@
|
||||
#ifdef OLED_CS
|
||||
|
||||
#include "OLEDDisplayFontsCS.h"
|
||||
|
||||
// Font generated or edited with the glyphEditor
|
||||
@ -1860,4 +1862,6 @@ const uint8_t ArialMT_Plain_24_CS[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x06, 0xC0, 0xF0, 0x01, 0x06, 0xC0, 0x80, 0x0F, 0x07, 0x00,
|
||||
0x00, 0xFE, 0x03, 0x00, 0x00, 0xFC, 0x00, 0xC0, 0xC0, 0x1F, 0x00, 0xC0, 0xF8, 0x03, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00,
|
||||
0x06, // 255
|
||||
};
|
||||
};
|
||||
|
||||
#endif // OLED_CS
|
@ -1,4 +1,5 @@
|
||||
// trunk-ignore-all(clang-format): Preserve long lines
|
||||
#ifdef OLED_PL
|
||||
#include "OLEDDisplayFontsPL.h"
|
||||
|
||||
const uint8_t ArialMT_Plain_10_PL[] PROGMEM = {
|
||||
@ -1310,4 +1311,6 @@ const uint8_t ArialMT_Plain_24_PL[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x06, 0x00, 0xF0, 0x01, 0x06, 0x00, 0x80, 0x0F, 0x07, 0x80, 0x00, 0xFE, 0x03, 0xE0, 0x00, 0xFC, 0x00, 0x60, 0xC0, 0x1F, 0x00, 0x20, 0xF8, 0x03, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x06, // 253
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x1C, 0x18, 0x00, 0x00, 0x06, 0x30, 0x00, 0x00, 0x06, 0x30, 0x00, 0x00, 0x06, 0x30, 0x00, 0x00, 0x0E, 0x38, 0x00, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF0, 0x03, // 254
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x06, 0xC0, 0xF0, 0x01, 0x06, 0xC0, 0x80, 0x0F, 0x07, 0x00, 0x00, 0xFE, 0x03, 0x00, 0x00, 0xFC, 0x00, 0xC0, 0xC0, 0x1F, 0x00, 0xC0, 0xF8, 0x03, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x06, // 255
|
||||
};
|
||||
};
|
||||
|
||||
#endif // OLED_PL
|
File diff suppressed because it is too large
Load Diff
@ -8,4 +8,6 @@
|
||||
#endif
|
||||
|
||||
extern const uint8_t ArialMT_Plain_10_RU[] PROGMEM;
|
||||
extern const uint8_t ArialMT_Plain_16_RU[] PROGMEM;
|
||||
extern const uint8_t ArialMT_Plain_24_RU[] PROGMEM;
|
||||
#endif
|
@ -1,3 +1,5 @@
|
||||
#ifdef OLED_UA
|
||||
|
||||
#include "OLEDDisplayFontsUA.h"
|
||||
|
||||
// Font generated or edited with the glyphEditor
|
||||
@ -1920,4 +1922,6 @@ const uint8_t ArialMT_Plain_24_UA[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC1, 0x00, 0x00, 0xF0, 0xE3, 0x00, 0x00, 0x38, 0x7B, 0x00, 0x00, 0x18, 0x1A, 0x00, 0x00,
|
||||
0x18, 0x0E, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0xF8, 0xFF, 0x00, 0x00, 0xF8,
|
||||
0xFF, // 1103
|
||||
};
|
||||
};
|
||||
|
||||
#endif // OLED_UA
|
@ -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;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
[inkhud]
|
||||
build_src_filter =
|
||||
+<graphics/niche/>; Include the nicheGraphics directory
|
||||
+<../variants/$PIOENV>; Include nicheGraphics.h from our variant folder
|
||||
build_flags =
|
||||
-D MESHTASTIC_INCLUDE_NICHE_GRAPHICS ; Use NicheGraphics
|
||||
-D MESHTASTIC_INCLUDE_INKHUD ; Use InkHUD (a NicheGraphics UI)
|
||||
|
@ -53,23 +53,21 @@ bool ButtonThread::initButton(const ButtonConfig &config)
|
||||
},
|
||||
this);
|
||||
|
||||
if (config.longPress != INPUT_BROKER_NONE) {
|
||||
_longPress = config.longPress;
|
||||
userButton.attachLongPressStart(
|
||||
[](void *callerThread) -> void {
|
||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||
// if (millis() > 30000) // hold off 30s after boot
|
||||
thread->btnEvent = BUTTON_EVENT_LONG_PRESSED;
|
||||
},
|
||||
this);
|
||||
userButton.attachLongPressStop(
|
||||
[](void *callerThread) -> void {
|
||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||
// if (millis() > 30000) // hold off 30s after boot
|
||||
thread->btnEvent = BUTTON_EVENT_LONG_RELEASED;
|
||||
},
|
||||
this);
|
||||
}
|
||||
_longPress = config.longPress;
|
||||
userButton.attachLongPressStart(
|
||||
[](void *callerThread) -> void {
|
||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||
// if (millis() > 30000) // hold off 30s after boot
|
||||
thread->btnEvent = BUTTON_EVENT_LONG_PRESSED;
|
||||
},
|
||||
this);
|
||||
userButton.attachLongPressStop(
|
||||
[](void *callerThread) -> void {
|
||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
||||
// if (millis() > 30000) // hold off 30s after boot
|
||||
thread->btnEvent = BUTTON_EVENT_LONG_RELEASED;
|
||||
},
|
||||
this);
|
||||
|
||||
if (config.doublePress != INPUT_BROKER_NONE) {
|
||||
_doublePress = config.doublePress;
|
||||
@ -94,8 +92,11 @@ bool ButtonThread::initButton(const ButtonConfig &config)
|
||||
if (config.shortLong != INPUT_BROKER_NONE) {
|
||||
_shortLong = config.shortLong;
|
||||
}
|
||||
|
||||
#ifdef USE_EINK
|
||||
userButton.setDebounceMs(0);
|
||||
#else
|
||||
userButton.setDebounceMs(1);
|
||||
#endif
|
||||
userButton.setPressMs(_longPressTime);
|
||||
|
||||
if (screen) {
|
||||
@ -202,11 +203,11 @@ int32_t ButtonThread::runOnce()
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Forward long press to InputBroker (but NOT as DOWN/SELECT, just forward a "button long press" event)
|
||||
evt.inputEvent = _longPress;
|
||||
this->notifyObservers(&evt);
|
||||
|
||||
if (_longPress != INPUT_BROKER_NONE) {
|
||||
// Forward long press to InputBroker (but NOT as DOWN/SELECT, just forward a "button long press" event)
|
||||
evt.inputEvent = _longPress;
|
||||
this->notifyObservers(&evt);
|
||||
}
|
||||
// Reset combination tracking
|
||||
waitingForLongPress = false;
|
||||
|
||||
@ -253,7 +254,7 @@ int32_t ButtonThread::runOnce()
|
||||
// may wake the board immediatedly.
|
||||
case BUTTON_EVENT_LONG_RELEASED: {
|
||||
|
||||
LOG_INFO("LONG PRESS RELEASE");
|
||||
LOG_INFO("LONG PRESS RELEASE AFTER %u MILLIS", millis() - buttonPressStartTime);
|
||||
if (millis() > 30000 && _longLongPress != INPUT_BROKER_NONE &&
|
||||
(millis() - buttonPressStartTime) >= _longLongPressTime) {
|
||||
evt.inputEvent = _longLongPress;
|
||||
|
@ -18,13 +18,13 @@ struct ButtonConfig {
|
||||
uint16_t longPressTime = 500;
|
||||
input_broker_event doublePress = INPUT_BROKER_NONE;
|
||||
input_broker_event longLongPress = INPUT_BROKER_NONE;
|
||||
uint16_t longLongPressTime = 5000;
|
||||
uint16_t longLongPressTime = 3900;
|
||||
input_broker_event triplePress = INPUT_BROKER_NONE;
|
||||
input_broker_event shortLong = INPUT_BROKER_NONE;
|
||||
bool touchQuirk = false;
|
||||
|
||||
// Constructor to set required parameter
|
||||
ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
|
||||
explicit ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
|
||||
};
|
||||
|
||||
#ifndef BUTTON_CLICK_MS
|
||||
@ -62,7 +62,7 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
|
||||
BUTTON_EVENT_COMBO_SHORT_LONG,
|
||||
};
|
||||
|
||||
ButtonThread(const char *name);
|
||||
explicit ButtonThread(const char *name);
|
||||
int32_t runOnce() override;
|
||||
OneButton userButton;
|
||||
void attachButtonInterrupts();
|
||||
|
@ -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;
|
||||
@ -233,14 +233,7 @@ void ExpressLRSFiveWay::sendAdhocPing()
|
||||
// Contained as one method for easier remapping of buttons by user
|
||||
void ExpressLRSFiveWay::shutdown()
|
||||
{
|
||||
LOG_INFO("Shutdown from long press");
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
screen->startAlert("Shutting Down...");
|
||||
// Don't set alerting = true. We don't want to auto-dismiss this alert.
|
||||
|
||||
playShutdownMelody(); // In case user adds a buzzer
|
||||
|
||||
shutdownAtMsec = millis() + 3000;
|
||||
sendKey(INPUT_BROKER_SHUTDOWN);
|
||||
}
|
||||
|
||||
void ExpressLRSFiveWay::click()
|
||||
|
@ -1,116 +1,18 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
|
||||
#include "TCA8418Keyboard.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// REGISTERS
|
||||
// #define _TCA8418_REG_RESERVED 0x00
|
||||
#define _TCA8418_REG_CFG 0x01 // Configuration register
|
||||
#define _TCA8418_REG_INT_STAT 0x02 // Interrupt status
|
||||
#define _TCA8418_REG_KEY_LCK_EC 0x03 // Key lock and event counter
|
||||
#define _TCA8418_REG_KEY_EVENT_A 0x04 // Key event register A
|
||||
#define _TCA8418_REG_KEY_EVENT_B 0x05 // Key event register B
|
||||
#define _TCA8418_REG_KEY_EVENT_C 0x06 // Key event register C
|
||||
#define _TCA8418_REG_KEY_EVENT_D 0x07 // Key event register D
|
||||
#define _TCA8418_REG_KEY_EVENT_E 0x08 // Key event register E
|
||||
#define _TCA8418_REG_KEY_EVENT_F 0x09 // Key event register F
|
||||
#define _TCA8418_REG_KEY_EVENT_G 0x0A // Key event register G
|
||||
#define _TCA8418_REG_KEY_EVENT_H 0x0B // Key event register H
|
||||
#define _TCA8418_REG_KEY_EVENT_I 0x0C // Key event register I
|
||||
#define _TCA8418_REG_KEY_EVENT_J 0x0D // Key event register J
|
||||
#define _TCA8418_REG_KP_LCK_TIMER 0x0E // Keypad lock1 to lock2 timer
|
||||
#define _TCA8418_REG_UNLOCK_1 0x0F // Unlock register 1
|
||||
#define _TCA8418_REG_UNLOCK_2 0x10 // Unlock register 2
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_1 0x11 // GPIO interrupt status 1
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_2 0x12 // GPIO interrupt status 2
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_3 0x13 // GPIO interrupt status 3
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_1 0x14 // GPIO data status 1
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_2 0x15 // GPIO data status 2
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_3 0x16 // GPIO data status 3
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_1 0x17 // GPIO data out 1
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_2 0x18 // GPIO data out 2
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_3 0x19 // GPIO data out 3
|
||||
#define _TCA8418_REG_GPIO_INT_EN_1 0x1A // GPIO interrupt enable 1
|
||||
#define _TCA8418_REG_GPIO_INT_EN_2 0x1B // GPIO interrupt enable 2
|
||||
#define _TCA8418_REG_GPIO_INT_EN_3 0x1C // GPIO interrupt enable 3
|
||||
#define _TCA8418_REG_KP_GPIO_1 0x1D // Keypad/GPIO select 1
|
||||
#define _TCA8418_REG_KP_GPIO_2 0x1E // Keypad/GPIO select 2
|
||||
#define _TCA8418_REG_KP_GPIO_3 0x1F // Keypad/GPIO select 3
|
||||
#define _TCA8418_REG_GPI_EM_1 0x20 // GPI event mode 1
|
||||
#define _TCA8418_REG_GPI_EM_2 0x21 // GPI event mode 2
|
||||
#define _TCA8418_REG_GPI_EM_3 0x22 // GPI event mode 3
|
||||
#define _TCA8418_REG_GPIO_DIR_1 0x23 // GPIO data direction 1
|
||||
#define _TCA8418_REG_GPIO_DIR_2 0x24 // GPIO data direction 2
|
||||
#define _TCA8418_REG_GPIO_DIR_3 0x25 // GPIO data direction 3
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_1 0x26 // GPIO edge/level detect 1
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_2 0x27 // GPIO edge/level detect 2
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_3 0x28 // GPIO edge/level detect 3
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_1 0x29 // Debounce disable 1
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_2 0x2A // Debounce disable 2
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_3 0x2B // Debounce disable 3
|
||||
#define _TCA8418_REG_GPIO_PULL_1 0x2C // GPIO pull-up disable 1
|
||||
#define _TCA8418_REG_GPIO_PULL_2 0x2D // GPIO pull-up disable 2
|
||||
#define _TCA8418_REG_GPIO_PULL_3 0x2E // GPIO pull-up disable 3
|
||||
// #define _TCA8418_REG_RESERVED 0x2F
|
||||
|
||||
// FIELDS CONFIG REGISTER 1
|
||||
#define _TCA8418_REG_CFG_AI 0x80 // Auto-increment for read/write
|
||||
#define _TCA8418_REG_CFG_GPI_E_CGF 0x40 // Event mode config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_M 0x20 // Overflow mode enable
|
||||
#define _TCA8418_REG_CFG_INT_CFG 0x10 // Interrupt config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_IEN 0x08 // Overflow interrupt enable
|
||||
#define _TCA8418_REG_CFG_K_LCK_IEN 0x04 // Keypad lock interrupt enable
|
||||
#define _TCA8418_REG_CFG_GPI_IEN 0x02 // GPI interrupt enable
|
||||
#define _TCA8418_REG_CFG_KE_IEN 0x01 // Key events interrupt enable
|
||||
|
||||
// FIELDS INT_STAT REGISTER 2
|
||||
#define _TCA8418_REG_STAT_CAD_INT 0x10 // Ctrl-alt-del seq status
|
||||
#define _TCA8418_REG_STAT_OVR_FLOW_INT 0x08 // Overflow interrupt status
|
||||
#define _TCA8418_REG_STAT_K_LCK_INT 0x04 // Key lock interrupt status
|
||||
#define _TCA8418_REG_STAT_GPI_INT 0x02 // GPI interrupt status
|
||||
#define _TCA8418_REG_STAT_K_INT 0x01 // Key events interrupt status
|
||||
|
||||
// FIELDS KEY_LCK_EC REGISTER 3
|
||||
#define _TCA8418_REG_LCK_EC_K_LCK_EN 0x40 // Key lock enable
|
||||
#define _TCA8418_REG_LCK_EC_LCK_2 0x20 // Keypad lock status 2
|
||||
#define _TCA8418_REG_LCK_EC_LCK_1 0x10 // Keypad lock status 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_3 0x08 // Key event count bit 3
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_2 0x04 // Key event count bit 2
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_1 0x02 // Key event count bit 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_0 0x01 // Key event count bit 0
|
||||
|
||||
// Pin IDs for matrix rows/columns
|
||||
enum {
|
||||
_TCA8418_ROW0, // Pin ID for row 0
|
||||
_TCA8418_ROW1, // Pin ID for row 1
|
||||
_TCA8418_ROW2, // Pin ID for row 2
|
||||
_TCA8418_ROW3, // Pin ID for row 3
|
||||
_TCA8418_ROW4, // Pin ID for row 4
|
||||
_TCA8418_ROW5, // Pin ID for row 5
|
||||
_TCA8418_ROW6, // Pin ID for row 6
|
||||
_TCA8418_ROW7, // Pin ID for row 7
|
||||
_TCA8418_COL0, // Pin ID for column 0
|
||||
_TCA8418_COL1, // Pin ID for column 1
|
||||
_TCA8418_COL2, // Pin ID for column 2
|
||||
_TCA8418_COL3, // Pin ID for column 3
|
||||
_TCA8418_COL4, // Pin ID for column 4
|
||||
_TCA8418_COL5, // Pin ID for column 5
|
||||
_TCA8418_COL6, // Pin ID for column 6
|
||||
_TCA8418_COL7, // Pin ID for column 7
|
||||
_TCA8418_COL8, // Pin ID for column 8
|
||||
_TCA8418_COL9 // Pin ID for column 9
|
||||
};
|
||||
|
||||
#define _TCA8418_COLS 3
|
||||
#define _TCA8418_ROWS 4
|
||||
#define _TCA8418_NUM_KEYS 12
|
||||
|
||||
uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {13, 7, 7, 7, 7, 7,
|
||||
9, 7, 9, 2, 2, 2}; // Num chars per key, Modulus for rotating through characters
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 750
|
||||
|
||||
unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = {
|
||||
using Key = TCA8418KeyboardBase::TCA8418Key;
|
||||
|
||||
// Num chars per key, Modulus for rotating through characters
|
||||
static uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {13, 7, 7, 7, 7, 7, 9, 7, 9, 2, 2, 2};
|
||||
|
||||
static unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = {
|
||||
{'1', '.', ',', '?', '!', ':', ';', '-', '_', '\\', '/', '(', ')'}, // 1
|
||||
{'2', 'a', 'b', 'c', 'A', 'B', 'C'}, // 2
|
||||
{'3', 'd', 'e', 'f', 'D', 'E', 'F'}, // 3
|
||||
@ -125,176 +27,35 @@ unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = {
|
||||
{'#', '@'}, // #
|
||||
};
|
||||
|
||||
unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
|
||||
_TCA8418_ESC, // 1
|
||||
_TCA8418_UP, // 2
|
||||
_TCA8418_NONE, // 3
|
||||
_TCA8418_LEFT, // 4
|
||||
_TCA8418_NONE, // 5
|
||||
_TCA8418_RIGHT, // 6
|
||||
_TCA8418_NONE, // 7
|
||||
_TCA8418_DOWN, // 8
|
||||
_TCA8418_NONE, // 9
|
||||
_TCA8418_BSP, // *
|
||||
_TCA8418_NONE, // 0
|
||||
_TCA8418_NONE, // #
|
||||
static unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
|
||||
Key::ESC, // 1
|
||||
Key::UP, // 2
|
||||
Key::NONE, // 3
|
||||
Key::LEFT, // 4
|
||||
Key::NONE, // 5
|
||||
Key::RIGHT, // 6
|
||||
Key::NONE, // 7
|
||||
Key::DOWN, // 8
|
||||
Key::NONE, // 9
|
||||
Key::BSP, // *
|
||||
Key::NONE, // 0
|
||||
Key::NONE, // #
|
||||
};
|
||||
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 750
|
||||
|
||||
TCA8418Keyboard::TCA8418Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr)
|
||||
TCA8418Keyboard::TCA8418Keyboard()
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), last_key(-1), next_key(-1), last_tap(0L), char_idx(0), tap_interval(0),
|
||||
should_backspace(false)
|
||||
{
|
||||
state = Init;
|
||||
last_key = -1;
|
||||
should_backspace = false;
|
||||
last_tap = 0L;
|
||||
char_idx = 0;
|
||||
tap_interval = 0;
|
||||
backlight_on = true;
|
||||
queue = "";
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::begin(uint8_t addr, TwoWire *wire)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = wire;
|
||||
|
||||
m_wire->begin();
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = nullptr;
|
||||
writeCallback = w;
|
||||
readCallback = r;
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::reset()
|
||||
{
|
||||
LOG_DEBUG("TCA8418 Reset");
|
||||
// GPIO
|
||||
// set default all GIO pins to INPUT
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_2, 0x00);
|
||||
TCA8418KeyboardBase::reset();
|
||||
|
||||
// Set COL9 as GPIO output
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_3, 0x02);
|
||||
writeRegister(TCA8418_REG_GPIO_DIR_3, 0x02);
|
||||
// Switch off keyboard backlight (COL9 = LOW)
|
||||
writeRegister(_TCA8418_REG_GPIO_DAT_OUT_3, 0x00);
|
||||
|
||||
// add all pins to key events
|
||||
writeRegister(_TCA8418_REG_GPI_EM_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPI_EM_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPI_EM_3, 0xFF);
|
||||
|
||||
// set all pins to FALLING interrupts
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_2, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_3, 0x00);
|
||||
|
||||
// add all pins to interrupts
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_3, 0xFF);
|
||||
|
||||
// Set keyboard matrix size
|
||||
matrix(_TCA8418_ROWS, _TCA8418_COLS);
|
||||
enableDebounce();
|
||||
flush();
|
||||
state = Idle;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::matrix(uint8_t rows, uint8_t columns)
|
||||
{
|
||||
if ((rows > 8) || (columns > 10))
|
||||
return false;
|
||||
|
||||
// Skip zero size matrix
|
||||
if ((rows != 0) && (columns != 0)) {
|
||||
// Setup the keypad matrix.
|
||||
uint8_t mask = 0x00;
|
||||
for (int r = 0; r < rows; r++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_1, mask);
|
||||
|
||||
mask = 0x00;
|
||||
for (int c = 0; c < columns && c < 8; c++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_2, mask);
|
||||
|
||||
if (columns > 8) {
|
||||
if (columns == 9)
|
||||
mask = 0x01;
|
||||
else
|
||||
mask = 0x03;
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_3, mask);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::keyCount() const
|
||||
{
|
||||
uint8_t eventCount = readRegister(_TCA8418_REG_KEY_LCK_EC);
|
||||
eventCount &= 0x0F; // lower 4 bits only
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::hasEvent()
|
||||
{
|
||||
return queue.length() > 0;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::queueEvent(char next)
|
||||
{
|
||||
if (next == _TCA8418_NONE) {
|
||||
return;
|
||||
}
|
||||
queue.concat(next);
|
||||
}
|
||||
|
||||
char TCA8418Keyboard::dequeueEvent()
|
||||
{
|
||||
if (queue.length() < 1) {
|
||||
return _TCA8418_NONE;
|
||||
}
|
||||
char next = queue.charAt(0);
|
||||
queue.remove(0, 1);
|
||||
return next;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::trigger()
|
||||
{
|
||||
if (keyCount() == 0) {
|
||||
return;
|
||||
}
|
||||
if (state != Init) {
|
||||
// Read the key register
|
||||
uint8_t k = readRegister(_TCA8418_REG_KEY_EVENT_A);
|
||||
uint8_t key = k & 0x7F;
|
||||
if (k & 0x80) {
|
||||
if (state == Idle)
|
||||
pressed(key);
|
||||
return;
|
||||
} else {
|
||||
if (state == Held) {
|
||||
released();
|
||||
}
|
||||
state = Idle;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
writeRegister(TCA8418_REG_GPIO_DAT_OUT_3, 0x00);
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::pressed(uint8_t key)
|
||||
@ -354,7 +115,7 @@ void TCA8418Keyboard::released()
|
||||
int32_t held_interval = now - last_tap;
|
||||
last_tap = now;
|
||||
if (tap_interval < _TCA8418_MULTI_TAP_THRESHOLD && should_backspace) {
|
||||
queueEvent(_TCA8418_BSP);
|
||||
queueEvent(BSP);
|
||||
}
|
||||
if (held_interval > _TCA8418_LONG_PRESS_THRESHOLD) {
|
||||
queueEvent(TCA8418LongPressMap[last_key]);
|
||||
@ -366,195 +127,11 @@ void TCA8418Keyboard::released()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::flush()
|
||||
{
|
||||
// Flush key events
|
||||
uint8_t count = 0;
|
||||
while (readRegister(_TCA8418_REG_KEY_EVENT_A) != 0)
|
||||
count++;
|
||||
// Flush gpio events
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_1);
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_2);
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_3);
|
||||
// Clear INT_STAT register
|
||||
writeRegister(_TCA8418_REG_INT_STAT, 3);
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::digitalRead(uint8_t pinnum) const
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return 0xFF;
|
||||
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DAT_STAT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (value & mask)
|
||||
return HIGH;
|
||||
return LOW;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::digitalWrite(uint8_t pinnum, uint8_t level)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DAT_OUT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (level == LOW)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::pinMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DIR_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Mode 0 = input 1 = output
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == OUTPUT)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Pullup 0 = enabled 1 = disabled
|
||||
reg = _TCA8418_REG_GPIO_PULL_1 + idx;
|
||||
value = readRegister(reg);
|
||||
if (mode == INPUT_PULLUP)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::pinIRQMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
if ((mode != RISING) && (mode != FALLING))
|
||||
return false;
|
||||
|
||||
// Mode 0 = falling 1 = rising
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = _TCA8418_REG_GPIO_INT_LVL_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == RISING)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Enable interrupt
|
||||
reg = _TCA8418_REG_GPIO_INT_EN_1 + idx;
|
||||
value = readRegister(reg);
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::enableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value |= (_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::disableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value &= ~(_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::enableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value |= _TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::disableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value &= ~_TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::enableDebounce()
|
||||
{
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_2, 0x00);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_3, 0x00);
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::disableDebounce()
|
||||
{
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_3, 0xFF);
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::setBacklight(bool on)
|
||||
{
|
||||
if (on) {
|
||||
digitalWrite(_TCA8418_COL9, HIGH);
|
||||
digitalWrite(TCA8418_COL9, HIGH);
|
||||
} else {
|
||||
digitalWrite(_TCA8418_COL9, LOW);
|
||||
digitalWrite(TCA8418_COL9, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::readRegister(uint8_t reg) const
|
||||
{
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(reg);
|
||||
m_wire->endTransmission();
|
||||
|
||||
m_wire->requestFrom(m_addr, (uint8_t)1);
|
||||
if (m_wire->available() < 1)
|
||||
return 0;
|
||||
|
||||
return m_wire->read();
|
||||
}
|
||||
if (readCallback) {
|
||||
uint8_t data;
|
||||
readCallback(m_addr, reg, &data, 1);
|
||||
return data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::writeRegister(uint8_t reg, uint8_t value)
|
||||
{
|
||||
uint8_t data[2];
|
||||
data[0] = reg;
|
||||
data[1] = value;
|
||||
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(data, sizeof(uint8_t) * 2);
|
||||
m_wire->endTransmission();
|
||||
}
|
||||
if (writeCallback) {
|
||||
writeCallback(m_addr, data[0], &(data[1]), 1);
|
||||
}
|
||||
}
|
@ -1,82 +1,23 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
#include "configuration.h"
|
||||
#include <Wire.h>
|
||||
#include "TCA8418KeyboardBase.h"
|
||||
|
||||
#define _TCA8418_NONE 0x00
|
||||
#define _TCA8418_REBOOT 0x90
|
||||
#define _TCA8418_LEFT 0xb4
|
||||
#define _TCA8418_UP 0xb5
|
||||
#define _TCA8418_DOWN 0xb6
|
||||
#define _TCA8418_RIGHT 0xb7
|
||||
#define _TCA8418_ESC 0x1b
|
||||
#define _TCA8418_BSP 0x08
|
||||
#define _TCA8418_SELECT 0x0d
|
||||
|
||||
class TCA8418Keyboard
|
||||
/**
|
||||
* @brief 3x4 keypad with 3 columns and 4 rows
|
||||
*/
|
||||
class TCA8418Keyboard : public TCA8418KeyboardBase
|
||||
{
|
||||
public:
|
||||
typedef uint8_t (*i2c_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data, uint8_t len);
|
||||
TCA8418Keyboard();
|
||||
void reset(void) override;
|
||||
void setBacklight(bool on) override;
|
||||
|
||||
enum KeyState { Init = 0, Idle, Held, Busy };
|
||||
protected:
|
||||
void pressed(uint8_t key) override;
|
||||
void released(void) override;
|
||||
|
||||
KeyState state;
|
||||
int8_t last_key;
|
||||
bool should_backspace;
|
||||
int8_t next_key;
|
||||
uint32_t last_tap;
|
||||
uint8_t char_idx;
|
||||
int32_t tap_interval;
|
||||
bool backlight_on;
|
||||
|
||||
String queue;
|
||||
|
||||
TCA8418Keyboard();
|
||||
|
||||
void begin(uint8_t addr = XPOWERS_AXP192_AXP2101_ADDRESS, TwoWire *wire = &Wire);
|
||||
void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = XPOWERS_AXP192_AXP2101_ADDRESS);
|
||||
|
||||
void reset(void);
|
||||
// Configure the size of the keypad.
|
||||
// All other rows and columns are set as inputs.
|
||||
bool matrix(uint8_t rows, uint8_t columns);
|
||||
|
||||
// Flush all events in the FIFO buffer + GPIO events.
|
||||
uint8_t flush(void);
|
||||
|
||||
// Key events available in the internal FIFO buffer.
|
||||
uint8_t keyCount(void) const;
|
||||
|
||||
void trigger(void);
|
||||
void pressed(uint8_t key);
|
||||
void released(void);
|
||||
bool hasEvent(void);
|
||||
char dequeueEvent(void);
|
||||
void queueEvent(char);
|
||||
|
||||
uint8_t digitalRead(uint8_t pinnum) const;
|
||||
bool digitalWrite(uint8_t pinnum, uint8_t level);
|
||||
bool pinMode(uint8_t pinnum, uint8_t mode);
|
||||
bool pinIRQMode(uint8_t pinnum, uint8_t mode); // MODE FALLING or RISING
|
||||
|
||||
// enable / disable interrupts for matrix and GPI pins
|
||||
void enableInterrupts();
|
||||
void disableInterrupts();
|
||||
|
||||
// ignore key events when FIFO buffer is full or not.
|
||||
void enableMatrixOverflow();
|
||||
void disableMatrixOverflow();
|
||||
|
||||
// debounce keys.
|
||||
void enableDebounce();
|
||||
void disableDebounce();
|
||||
|
||||
void setBacklight(bool on);
|
||||
|
||||
uint8_t readRegister(uint8_t reg) const;
|
||||
void writeRegister(uint8_t reg, uint8_t value);
|
||||
|
||||
private:
|
||||
TwoWire *m_wire;
|
||||
uint8_t m_addr;
|
||||
i2c_com_fptr_t readCallback;
|
||||
i2c_com_fptr_t writeCallback;
|
||||
bool should_backspace;
|
||||
};
|
||||
|
372
src/input/TCA8418KeyboardBase.cpp
Normal file
372
src/input/TCA8418KeyboardBase.cpp
Normal file
@ -0,0 +1,372 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
|
||||
#include "TCA8418KeyboardBase.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// FIELDS CONFIG REGISTER 1
|
||||
#define _TCA8418_REG_CFG_AI 0x80 // Auto-increment for read/write
|
||||
#define _TCA8418_REG_CFG_GPI_E_CGF 0x40 // Event mode config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_M 0x20 // Overflow mode enable
|
||||
#define _TCA8418_REG_CFG_INT_CFG 0x10 // Interrupt config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_IEN 0x08 // Overflow interrupt enable
|
||||
#define _TCA8418_REG_CFG_K_LCK_IEN 0x04 // Keypad lock interrupt enable
|
||||
#define _TCA8418_REG_CFG_GPI_IEN 0x02 // GPI interrupt enable
|
||||
#define _TCA8418_REG_CFG_KE_IEN 0x01 // Key events interrupt enable
|
||||
|
||||
// FIELDS INT_STAT REGISTER 2
|
||||
#define _TCA8418_REG_STAT_CAD_INT 0x10 // Ctrl-alt-del seq status
|
||||
#define _TCA8418_REG_STAT_OVR_FLOW_INT 0x08 // Overflow interrupt status
|
||||
#define _TCA8418_REG_STAT_K_LCK_INT 0x04 // Key lock interrupt status
|
||||
#define _TCA8418_REG_STAT_GPI_INT 0x02 // GPI interrupt status
|
||||
#define _TCA8418_REG_STAT_K_INT 0x01 // Key events interrupt status
|
||||
|
||||
// FIELDS KEY_LCK_EC REGISTER 3
|
||||
#define _TCA8418_REG_LCK_EC_K_LCK_EN 0x40 // Key lock enable
|
||||
#define _TCA8418_REG_LCK_EC_LCK_2 0x20 // Keypad lock status 2
|
||||
#define _TCA8418_REG_LCK_EC_LCK_1 0x10 // Keypad lock status 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_3 0x08 // Key event count bit 3
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_2 0x04 // Key event count bit 2
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_1 0x02 // Key event count bit 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_0 0x01 // Key event count bit 0
|
||||
|
||||
TCA8418KeyboardBase::TCA8418KeyboardBase(uint8_t rows, uint8_t columns)
|
||||
: rows(rows), columns(columns), state(Init), queue(""), m_wire(nullptr), m_addr(0), readCallback(nullptr),
|
||||
writeCallback(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::begin(uint8_t addr, TwoWire *wire)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = wire;
|
||||
m_wire->begin();
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = nullptr;
|
||||
writeCallback = w;
|
||||
readCallback = r;
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::reset()
|
||||
{
|
||||
LOG_DEBUG("TCA8418 Reset");
|
||||
// GPIO
|
||||
// set default all GIO pins to INPUT
|
||||
writeRegister(TCA8418_REG_GPIO_DIR_1, 0x00);
|
||||
writeRegister(TCA8418_REG_GPIO_DIR_2, 0x00);
|
||||
writeRegister(TCA8418_REG_GPIO_DIR_3, 0x00);
|
||||
|
||||
// add all pins to key events
|
||||
writeRegister(TCA8418_REG_GPI_EM_1, 0xFF);
|
||||
writeRegister(TCA8418_REG_GPI_EM_2, 0xFF);
|
||||
writeRegister(TCA8418_REG_GPI_EM_3, 0xFF);
|
||||
|
||||
// set all pins to FALLING interrupts
|
||||
writeRegister(TCA8418_REG_GPIO_INT_LVL_1, 0x00);
|
||||
writeRegister(TCA8418_REG_GPIO_INT_LVL_2, 0x00);
|
||||
writeRegister(TCA8418_REG_GPIO_INT_LVL_3, 0x00);
|
||||
|
||||
// add all pins to interrupts
|
||||
writeRegister(TCA8418_REG_GPIO_INT_EN_1, 0xFF);
|
||||
writeRegister(TCA8418_REG_GPIO_INT_EN_2, 0xFF);
|
||||
writeRegister(TCA8418_REG_GPIO_INT_EN_3, 0xFF);
|
||||
|
||||
// Set keyboard matrix size
|
||||
matrix(rows, columns);
|
||||
enableDebounce();
|
||||
flush();
|
||||
state = Idle;
|
||||
}
|
||||
|
||||
bool TCA8418KeyboardBase::matrix(uint8_t rows, uint8_t columns)
|
||||
{
|
||||
if (rows < 1 || rows > 8 || columns < 1 || columns > 10)
|
||||
return false;
|
||||
|
||||
// Setup the keypad matrix.
|
||||
uint8_t mask = 0x00;
|
||||
for (int r = 0; r < rows; r++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(TCA8418_REG_KP_GPIO_1, mask);
|
||||
|
||||
mask = 0x00;
|
||||
for (int c = 0; c < columns && c < 8; c++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(TCA8418_REG_KP_GPIO_2, mask);
|
||||
|
||||
if (columns > 8) {
|
||||
if (columns == 9)
|
||||
mask = 0x01;
|
||||
else
|
||||
mask = 0x03;
|
||||
writeRegister(TCA8418_REG_KP_GPIO_3, mask);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t TCA8418KeyboardBase::keyCount() const
|
||||
{
|
||||
uint8_t eventCount = readRegister(TCA8418_REG_KEY_LCK_EC);
|
||||
eventCount &= 0x0F; // lower 4 bits only
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
bool TCA8418KeyboardBase::hasEvent() const
|
||||
{
|
||||
return queue.length() > 0;
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::queueEvent(char next)
|
||||
{
|
||||
if (next == NONE) {
|
||||
return;
|
||||
}
|
||||
queue.concat(next);
|
||||
}
|
||||
|
||||
char TCA8418KeyboardBase::dequeueEvent()
|
||||
{
|
||||
if (queue.length() < 1) {
|
||||
return NONE;
|
||||
}
|
||||
char next = queue.charAt(0);
|
||||
queue.remove(0, 1);
|
||||
return next;
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::trigger()
|
||||
{
|
||||
if (keyCount() == 0) {
|
||||
return;
|
||||
}
|
||||
if (state != Init) {
|
||||
// Read the key register
|
||||
uint8_t k = readRegister(TCA8418_REG_KEY_EVENT_A);
|
||||
uint8_t key = k & 0x7F;
|
||||
if (k & 0x80) {
|
||||
if (state == Idle)
|
||||
pressed(key);
|
||||
return;
|
||||
} else {
|
||||
if (state == Held) {
|
||||
released();
|
||||
}
|
||||
state = Idle;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::pressed(uint8_t key)
|
||||
{
|
||||
// must be defined in derived class
|
||||
LOG_ERROR("pressed() not implemented in derived class");
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::released()
|
||||
{
|
||||
// must be defined in derived class
|
||||
LOG_ERROR("released() not implemented in derived class");
|
||||
}
|
||||
|
||||
uint8_t TCA8418KeyboardBase::flush()
|
||||
{
|
||||
// Flush key events
|
||||
uint8_t count = 0;
|
||||
while (readRegister(TCA8418_REG_KEY_EVENT_A) != 0)
|
||||
count++;
|
||||
|
||||
// Flush gpio events
|
||||
readRegister(TCA8418_REG_GPIO_INT_STAT_1);
|
||||
readRegister(TCA8418_REG_GPIO_INT_STAT_2);
|
||||
readRegister(TCA8418_REG_GPIO_INT_STAT_3);
|
||||
|
||||
// Clear INT_STAT register
|
||||
writeRegister(TCA8418_REG_INT_STAT, 3);
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t TCA8418KeyboardBase::digitalRead(uint8_t pinnum) const
|
||||
{
|
||||
if (pinnum > TCA8418_COL9)
|
||||
return 0xFF;
|
||||
|
||||
uint8_t reg = TCA8418_REG_GPIO_DAT_STAT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (value & mask)
|
||||
return HIGH;
|
||||
return LOW;
|
||||
}
|
||||
|
||||
bool TCA8418KeyboardBase::digitalWrite(uint8_t pinnum, uint8_t level)
|
||||
{
|
||||
if (pinnum > TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t reg = TCA8418_REG_GPIO_DAT_OUT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (level == LOW)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418KeyboardBase::pinMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = TCA8418_REG_GPIO_DIR_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Mode 0 = input 1 = output
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == OUTPUT)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Pullup 0 = enabled 1 = disabled
|
||||
reg = TCA8418_REG_GPIO_PULL_1 + idx;
|
||||
value = readRegister(reg);
|
||||
if (mode == INPUT_PULLUP)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418KeyboardBase::pinIRQMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > TCA8418_COL9)
|
||||
return false;
|
||||
if ((mode != RISING) && (mode != FALLING))
|
||||
return false;
|
||||
|
||||
// Mode 0 = falling 1 = rising
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = TCA8418_REG_GPIO_INT_LVL_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == RISING)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Enable interrupt
|
||||
reg = TCA8418_REG_GPIO_INT_EN_1 + idx;
|
||||
value = readRegister(reg);
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::enableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(TCA8418_REG_CFG);
|
||||
value |= (_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418KeyboardBase::disableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(TCA8418_REG_CFG);
|
||||
value &= ~(_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418KeyboardBase::enableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(TCA8418_REG_CFG);
|
||||
value |= _TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418KeyboardBase::disableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(TCA8418_REG_CFG);
|
||||
value &= ~_TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418KeyboardBase::enableDebounce()
|
||||
{
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_1, 0x00);
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_2, 0x00);
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_3, 0x00);
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::disableDebounce()
|
||||
{
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_1, 0xFF);
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_2, 0xFF);
|
||||
writeRegister(TCA8418_REG_DEBOUNCE_DIS_3, 0xFF);
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::setBacklight(bool on) {}
|
||||
|
||||
uint8_t TCA8418KeyboardBase::readRegister(uint8_t reg) const
|
||||
{
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(reg);
|
||||
m_wire->endTransmission();
|
||||
|
||||
m_wire->requestFrom(m_addr, (uint8_t)1);
|
||||
if (m_wire->available() < 1)
|
||||
return 0;
|
||||
|
||||
return m_wire->read();
|
||||
}
|
||||
if (readCallback) {
|
||||
uint8_t data;
|
||||
readCallback(m_addr, reg, &data, 1);
|
||||
return data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TCA8418KeyboardBase::writeRegister(uint8_t reg, uint8_t value)
|
||||
{
|
||||
uint8_t data[2];
|
||||
data[0] = reg;
|
||||
data[1] = value;
|
||||
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(data, sizeof(uint8_t) * 2);
|
||||
m_wire->endTransmission();
|
||||
}
|
||||
if (writeCallback) {
|
||||
writeCallback(m_addr, data[0], &(data[1]), 1);
|
||||
}
|
||||
}
|
170
src/input/TCA8418KeyboardBase.h
Normal file
170
src/input/TCA8418KeyboardBase.h
Normal file
@ -0,0 +1,170 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
#include "configuration.h"
|
||||
#include <Wire.h>
|
||||
|
||||
/**
|
||||
* @brief TCA8418KeyboardBase is the base class for TCA8418 keyboard handling.
|
||||
* It provides basic functionality for reading key events, managing the keyboard matrix,
|
||||
* and handling key states. It is designed to be extended for specific keyboard implementations.
|
||||
* It supports both I2C communication and function pointers for custom I2C operations.
|
||||
*/
|
||||
class TCA8418KeyboardBase
|
||||
{
|
||||
public:
|
||||
enum TCA8418Key : uint8_t {
|
||||
NONE = 0x00,
|
||||
BSP = 0x08,
|
||||
TAB = 0x09,
|
||||
SELECT = 0x0d,
|
||||
ESC = 0x1b,
|
||||
REBOOT = 0x90,
|
||||
LEFT = 0xb4,
|
||||
UP = 0xb5,
|
||||
DOWN = 0xb6,
|
||||
RIGHT = 0xb7,
|
||||
BT_TOGGLE = 0xAA,
|
||||
GPS_TOGGLE = 0x9E,
|
||||
MUTE_TOGGLE = 0xAC,
|
||||
SEND_PING = 0xAF,
|
||||
BL_TOGGLE = 0xAB
|
||||
};
|
||||
|
||||
typedef uint8_t (*i2c_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data, uint8_t len);
|
||||
|
||||
TCA8418KeyboardBase(uint8_t rows, uint8_t columns);
|
||||
|
||||
virtual void begin(uint8_t addr = TCA8418_KB_ADDR, TwoWire *wire = &Wire);
|
||||
virtual void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = TCA8418_KB_ADDR);
|
||||
|
||||
virtual void reset(void);
|
||||
virtual void trigger(void);
|
||||
|
||||
virtual void setBacklight(bool on);
|
||||
|
||||
// Key events available
|
||||
virtual bool hasEvent(void) const;
|
||||
virtual char dequeueEvent(void);
|
||||
|
||||
protected:
|
||||
enum KeyState { Init, Idle, Held, Busy };
|
||||
|
||||
enum TCA8418Register : uint8_t {
|
||||
TCA8418_REG_RESERVED = 0x00,
|
||||
TCA8418_REG_CFG = 0x01,
|
||||
TCA8418_REG_INT_STAT = 0x02,
|
||||
TCA8418_REG_KEY_LCK_EC = 0x03,
|
||||
TCA8418_REG_KEY_EVENT_A = 0x04,
|
||||
TCA8418_REG_KEY_EVENT_B = 0x05,
|
||||
TCA8418_REG_KEY_EVENT_C = 0x06,
|
||||
TCA8418_REG_KEY_EVENT_D = 0x07,
|
||||
TCA8418_REG_KEY_EVENT_E = 0x08,
|
||||
TCA8418_REG_KEY_EVENT_F = 0x09,
|
||||
TCA8418_REG_KEY_EVENT_G = 0x0A,
|
||||
TCA8418_REG_KEY_EVENT_H = 0x0B,
|
||||
TCA8418_REG_KEY_EVENT_I = 0x0C,
|
||||
TCA8418_REG_KEY_EVENT_J = 0x0D,
|
||||
TCA8418_REG_KP_LCK_TIMER = 0x0E,
|
||||
TCA8418_REG_UNLOCK_1 = 0x0F,
|
||||
TCA8418_REG_UNLOCK_2 = 0x10,
|
||||
TCA8418_REG_GPIO_INT_STAT_1 = 0x11,
|
||||
TCA8418_REG_GPIO_INT_STAT_2 = 0x12,
|
||||
TCA8418_REG_GPIO_INT_STAT_3 = 0x13,
|
||||
TCA8418_REG_GPIO_DAT_STAT_1 = 0x14,
|
||||
TCA8418_REG_GPIO_DAT_STAT_2 = 0x15,
|
||||
TCA8418_REG_GPIO_DAT_STAT_3 = 0x16,
|
||||
TCA8418_REG_GPIO_DAT_OUT_1 = 0x17,
|
||||
TCA8418_REG_GPIO_DAT_OUT_2 = 0x18,
|
||||
TCA8418_REG_GPIO_DAT_OUT_3 = 0x19,
|
||||
TCA8418_REG_GPIO_INT_EN_1 = 0x1A,
|
||||
TCA8418_REG_GPIO_INT_EN_2 = 0x1B,
|
||||
TCA8418_REG_GPIO_INT_EN_3 = 0x1C,
|
||||
TCA8418_REG_KP_GPIO_1 = 0x1D,
|
||||
TCA8418_REG_KP_GPIO_2 = 0x1E,
|
||||
TCA8418_REG_KP_GPIO_3 = 0x1F,
|
||||
TCA8418_REG_GPI_EM_1 = 0x20,
|
||||
TCA8418_REG_GPI_EM_2 = 0x21,
|
||||
TCA8418_REG_GPI_EM_3 = 0x22,
|
||||
TCA8418_REG_GPIO_DIR_1 = 0x23,
|
||||
TCA8418_REG_GPIO_DIR_2 = 0x24,
|
||||
TCA8418_REG_GPIO_DIR_3 = 0x25,
|
||||
TCA8418_REG_GPIO_INT_LVL_1 = 0x26,
|
||||
TCA8418_REG_GPIO_INT_LVL_2 = 0x27,
|
||||
TCA8418_REG_GPIO_INT_LVL_3 = 0x28,
|
||||
TCA8418_REG_DEBOUNCE_DIS_1 = 0x29,
|
||||
TCA8418_REG_DEBOUNCE_DIS_2 = 0x2A,
|
||||
TCA8418_REG_DEBOUNCE_DIS_3 = 0x2B,
|
||||
TCA8418_REG_GPIO_PULL_1 = 0x2C,
|
||||
TCA8418_REG_GPIO_PULL_2 = 0x2D,
|
||||
TCA8418_REG_GPIO_PULL_3 = 0x2E
|
||||
};
|
||||
|
||||
// Pin IDs for matrix rows/columns
|
||||
enum TCA8418PinId : uint8_t {
|
||||
TCA8418_ROW0, // Pin ID for row 0
|
||||
TCA8418_ROW1, // Pin ID for row 1
|
||||
TCA8418_ROW2, // Pin ID for row 2
|
||||
TCA8418_ROW3, // Pin ID for row 3
|
||||
TCA8418_ROW4, // Pin ID for row 4
|
||||
TCA8418_ROW5, // Pin ID for row 5
|
||||
TCA8418_ROW6, // Pin ID for row 6
|
||||
TCA8418_ROW7, // Pin ID for row 7
|
||||
TCA8418_COL0, // Pin ID for column 0
|
||||
TCA8418_COL1, // Pin ID for column 1
|
||||
TCA8418_COL2, // Pin ID for column 2
|
||||
TCA8418_COL3, // Pin ID for column 3
|
||||
TCA8418_COL4, // Pin ID for column 4
|
||||
TCA8418_COL5, // Pin ID for column 5
|
||||
TCA8418_COL6, // Pin ID for column 6
|
||||
TCA8418_COL7, // Pin ID for column 7
|
||||
TCA8418_COL8, // Pin ID for column 8
|
||||
TCA8418_COL9 // Pin ID for column 9
|
||||
};
|
||||
|
||||
virtual void pressed(uint8_t key);
|
||||
virtual void released(void);
|
||||
|
||||
virtual void queueEvent(char);
|
||||
|
||||
virtual ~TCA8418KeyboardBase() {}
|
||||
|
||||
protected:
|
||||
// Set the size of the keypad matrix
|
||||
// All other rows and columns are set as inputs.
|
||||
bool matrix(uint8_t rows, uint8_t columns);
|
||||
|
||||
uint8_t keyCount(void) const;
|
||||
|
||||
// Flush all events in the FIFO buffer + GPIO events.
|
||||
uint8_t flush(void);
|
||||
|
||||
// debounce keys.
|
||||
void enableDebounce();
|
||||
void disableDebounce();
|
||||
|
||||
// enable / disable interrupts for matrix and GPI pins
|
||||
void enableInterrupts();
|
||||
void disableInterrupts();
|
||||
|
||||
// ignore key events when FIFO buffer is full or not.
|
||||
void enableMatrixOverflow();
|
||||
void disableMatrixOverflow();
|
||||
|
||||
uint8_t digitalRead(uint8_t pinnum) const;
|
||||
bool digitalWrite(uint8_t pinnum, uint8_t level);
|
||||
bool pinMode(uint8_t pinnum, uint8_t mode);
|
||||
bool pinIRQMode(uint8_t pinnum, uint8_t mode); // MODE FALLING or RISING
|
||||
uint8_t readRegister(uint8_t reg) const;
|
||||
void writeRegister(uint8_t reg, uint8_t value);
|
||||
|
||||
protected:
|
||||
uint8_t rows;
|
||||
uint8_t columns;
|
||||
KeyState state;
|
||||
String queue;
|
||||
|
||||
private:
|
||||
TwoWire *m_wire;
|
||||
uint8_t m_addr;
|
||||
i2c_com_fptr_t readCallback;
|
||||
i2c_com_fptr_t writeCallback;
|
||||
};
|
196
src/input/TDeckProKeyboard.cpp
Normal file
196
src/input/TDeckProKeyboard.cpp
Normal file
@ -0,0 +1,196 @@
|
||||
#if defined(T_DECK_PRO)
|
||||
|
||||
#include "TDeckProKeyboard.h"
|
||||
|
||||
#define _TCA8418_COLS 10
|
||||
#define _TCA8418_ROWS 4
|
||||
#define _TCA8418_NUM_KEYS 35
|
||||
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 1500
|
||||
|
||||
using Key = TCA8418KeyboardBase::TCA8418Key;
|
||||
|
||||
constexpr uint8_t modifierRightShiftKey = 31 - 1; // keynum -1
|
||||
constexpr uint8_t modifierRightShift = 0b0001;
|
||||
constexpr uint8_t modifierLeftShiftKey = 35 - 1;
|
||||
constexpr uint8_t modifierLeftShift = 0b0001;
|
||||
constexpr uint8_t modifierSymKey = 32 - 1;
|
||||
constexpr uint8_t modifierSym = 0b0010;
|
||||
constexpr uint8_t modifierAltKey = 30 - 1;
|
||||
constexpr uint8_t modifierAlt = 0b0100;
|
||||
|
||||
// Num chars per key, Modulus for rotating through characters
|
||||
static uint8_t TDeckProTapMod[_TCA8418_NUM_KEYS] = {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
|
||||
|
||||
static unsigned char TDeckProTapMap[_TCA8418_NUM_KEYS][5] = {
|
||||
{'p', 'P', '@', 0x00, Key::SEND_PING},
|
||||
{'o', 'O', '+'},
|
||||
{'i', 'I', '-'},
|
||||
{'u', 'U', '_'},
|
||||
{'y', 'Y', ')'},
|
||||
{'t', 'T', '(', 0x00, Key::TAB},
|
||||
{'r', 'R', '3'},
|
||||
{'e', 'E', '2', 0x00, Key::UP},
|
||||
{'w', 'W', '1'},
|
||||
{'q', 'Q', '#', 0x00, Key::ESC}, // p, o, i, u, y, t, r, e, w, q
|
||||
{Key::BSP, 0x00, 0x00},
|
||||
{'l', 'L', '"'},
|
||||
{'k', 'K', '\''},
|
||||
{'j', 'J', ';'},
|
||||
{'h', 'H', ':'},
|
||||
{'g', 'G', '/', 0x00, Key::GPS_TOGGLE},
|
||||
{'f', 'F', '6', 0x00, Key::RIGHT},
|
||||
{'d', 'D', '5'},
|
||||
{'s', 'S', '4', 0x00, Key::LEFT},
|
||||
{'a', 'A', '*'}, // bsp, l, k, j, h, g, f, d, s, a
|
||||
{0x0d, 0x00, 0x00},
|
||||
{'$', 0x00, 0x00},
|
||||
{'m', 'M', '.', 0x00, Key::MUTE_TOGGLE},
|
||||
{'n', 'N', ','},
|
||||
{'b', 'B', '!', 0x00, Key::BL_TOGGLE},
|
||||
{'v', 'V', '?'},
|
||||
{'c', 'C', '9'},
|
||||
{'x', 'X', '8', 0x00, Key::DOWN},
|
||||
{'z', 'Z', '7'},
|
||||
{0x00, 0x00, 0x00}, // Ent, $, m, n, b, v, c, x, z, alt
|
||||
{0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00},
|
||||
{0x20, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00} // R_Shift, sym, space, mic, L_Shift
|
||||
};
|
||||
|
||||
TDeckProKeyboard::TDeckProKeyboard()
|
||||
: TCA8418KeyboardBase(_TCA8418_ROWS, _TCA8418_COLS), modifierFlag(0), last_modifier_time(0), last_key(-1), next_key(-1),
|
||||
last_tap(0L), char_idx(0), tap_interval(0)
|
||||
{
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::reset()
|
||||
{
|
||||
TCA8418KeyboardBase::reset();
|
||||
pinMode(KB_BL_PIN, OUTPUT);
|
||||
setBacklight(false);
|
||||
}
|
||||
|
||||
// handle multi-key presses (shift and alt)
|
||||
void TDeckProKeyboard::trigger()
|
||||
{
|
||||
uint8_t count = keyCount();
|
||||
if (count == 0)
|
||||
return;
|
||||
for (uint8_t i = 0; i < count; ++i) {
|
||||
uint8_t k = readRegister(TCA8418_REG_KEY_EVENT_A + i);
|
||||
uint8_t key = k & 0x7F;
|
||||
if (k & 0x80) {
|
||||
pressed(key);
|
||||
} else {
|
||||
released();
|
||||
state = Idle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::pressed(uint8_t key)
|
||||
{
|
||||
if (state == Init || state == Busy) {
|
||||
return;
|
||||
}
|
||||
if (modifierFlag && (millis() - last_modifier_time > _TCA8418_MULTI_TAP_THRESHOLD)) {
|
||||
modifierFlag = 0;
|
||||
}
|
||||
|
||||
uint8_t next_key = 0;
|
||||
int row = (key - 1) / 10;
|
||||
int col = (key - 1) % 10;
|
||||
|
||||
if (row >= _TCA8418_ROWS || col >= _TCA8418_COLS) {
|
||||
return; // Invalid key
|
||||
}
|
||||
|
||||
next_key = row * _TCA8418_COLS + col;
|
||||
state = Held;
|
||||
|
||||
uint32_t now = millis();
|
||||
tap_interval = now - last_tap;
|
||||
|
||||
updateModifierFlag(next_key);
|
||||
if (isModifierKey(next_key)) {
|
||||
last_modifier_time = now;
|
||||
}
|
||||
|
||||
if (tap_interval < 0) {
|
||||
last_tap = 0;
|
||||
state = Busy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (next_key != last_key || tap_interval > _TCA8418_MULTI_TAP_THRESHOLD) {
|
||||
char_idx = 0;
|
||||
} else {
|
||||
char_idx += 1;
|
||||
}
|
||||
|
||||
last_key = next_key;
|
||||
last_tap = now;
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::released()
|
||||
{
|
||||
if (state != Held) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (last_key < 0 || last_key >= _TCA8418_NUM_KEYS) {
|
||||
last_key = -1;
|
||||
state = Idle;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t now = millis();
|
||||
last_tap = now;
|
||||
|
||||
if (TDeckProTapMap[last_key][modifierFlag % TDeckProTapMod[last_key]] == Key::BL_TOGGLE) {
|
||||
toggleBacklight();
|
||||
return;
|
||||
}
|
||||
|
||||
queueEvent(TDeckProTapMap[last_key][modifierFlag % TDeckProTapMod[last_key]]);
|
||||
if (isModifierKey(last_key) == false)
|
||||
modifierFlag = 0;
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::setBacklight(bool on)
|
||||
{
|
||||
if (on) {
|
||||
digitalWrite(KB_BL_PIN, HIGH);
|
||||
} else {
|
||||
digitalWrite(KB_BL_PIN, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::toggleBacklight(void)
|
||||
{
|
||||
digitalWrite(KB_BL_PIN, !digitalRead(KB_BL_PIN));
|
||||
}
|
||||
|
||||
void TDeckProKeyboard::updateModifierFlag(uint8_t key)
|
||||
{
|
||||
if (key == modifierRightShiftKey) {
|
||||
modifierFlag ^= modifierRightShift;
|
||||
} else if (key == modifierLeftShiftKey) {
|
||||
modifierFlag ^= modifierLeftShift;
|
||||
} else if (key == modifierSymKey) {
|
||||
modifierFlag ^= modifierSym;
|
||||
} else if (key == modifierAltKey) {
|
||||
modifierFlag ^= modifierAlt;
|
||||
}
|
||||
}
|
||||
|
||||
bool TDeckProKeyboard::isModifierKey(uint8_t key)
|
||||
{
|
||||
return (key == modifierRightShiftKey || key == modifierLeftShiftKey || key == modifierAltKey || key == modifierSymKey);
|
||||
}
|
||||
|
||||
#endif // T_DECK_PRO
|
27
src/input/TDeckProKeyboard.h
Normal file
27
src/input/TDeckProKeyboard.h
Normal file
@ -0,0 +1,27 @@
|
||||
#include "TCA8418KeyboardBase.h"
|
||||
|
||||
class TDeckProKeyboard : public TCA8418KeyboardBase
|
||||
{
|
||||
public:
|
||||
TDeckProKeyboard();
|
||||
void reset(void) override;
|
||||
void trigger(void) override;
|
||||
void setBacklight(bool on) override;
|
||||
|
||||
protected:
|
||||
void pressed(uint8_t key) override;
|
||||
void released(void) override;
|
||||
|
||||
void updateModifierFlag(uint8_t key);
|
||||
bool isModifierKey(uint8_t key);
|
||||
void toggleBacklight(void);
|
||||
|
||||
private:
|
||||
uint8_t modifierFlag; // Flag to indicate if a modifier key is pressed
|
||||
uint32_t last_modifier_time; // Timestamp of the last modifier key press
|
||||
int8_t last_key;
|
||||
int8_t next_key;
|
||||
uint32_t last_tap;
|
||||
uint8_t char_idx;
|
||||
int32_t tap_interval;
|
||||
};
|
12
src/input/TLoraPagerKeyboard.h
Normal file
12
src/input/TLoraPagerKeyboard.h
Normal file
@ -0,0 +1,12 @@
|
||||
#include "TCA8418KeyboardBase.h"
|
||||
|
||||
class TLoraPagerKeyboard : public TCA8418KeyboardBase
|
||||
{
|
||||
public:
|
||||
TLoraPagerKeyboard();
|
||||
void setBacklight(bool on) override{};
|
||||
|
||||
protected:
|
||||
void pressed(uint8_t key) override{};
|
||||
void released(void) override{};
|
||||
};
|
@ -3,10 +3,26 @@
|
||||
#include "detect/ScanI2C.h"
|
||||
#include "detect/ScanI2CTwoWire.h"
|
||||
|
||||
#if defined(T_DECK_PRO)
|
||||
#include "TDeckProKeyboard.h"
|
||||
#elif defined(T_LORA_PAGER)
|
||||
#include "TLoraPagerKeyboard.h"
|
||||
#else
|
||||
#include "TCA8418Keyboard.h"
|
||||
#endif
|
||||
|
||||
extern ScanI2C::DeviceAddress cardkb_found;
|
||||
extern uint8_t kb_model;
|
||||
|
||||
KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
||||
KbI2cBase::KbI2cBase(const char *name)
|
||||
: concurrency::OSThread(name),
|
||||
#if defined(T_DECK_PRO)
|
||||
TCAKeyboard(*(new TDeckProKeyboard()))
|
||||
#elif defined(T_LORA_PAGER)
|
||||
TCAKeyboard(*(new TLoraPagerKeyboard()))
|
||||
#else
|
||||
TCAKeyboard(*(new TCA8418Keyboard()))
|
||||
#endif
|
||||
{
|
||||
this->_originName = name;
|
||||
}
|
||||
@ -43,8 +59,8 @@ int32_t KbI2cBase::runOnce()
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire1);
|
||||
}
|
||||
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire1);
|
||||
if (cardkb_found.address == TCA8418_KB_ADDR) {
|
||||
TCAKeyboard.begin(TCA8418_KB_ADDR, &Wire1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@ -58,8 +74,8 @@ int32_t KbI2cBase::runOnce()
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire);
|
||||
}
|
||||
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire);
|
||||
if (cardkb_found.address == TCA8418_KB_ADDR) {
|
||||
TCAKeyboard.begin(TCA8418_KB_ADDR, &Wire);
|
||||
}
|
||||
break;
|
||||
case ScanI2C::NO_I2C:
|
||||
@ -241,41 +257,65 @@ int32_t KbI2cBase::runOnce()
|
||||
e.kbchar = 0x00;
|
||||
e.source = this->_originName;
|
||||
switch (nextEvent) {
|
||||
case _TCA8418_NONE:
|
||||
case TCA8418KeyboardBase::NONE:
|
||||
e.inputEvent = INPUT_BROKER_NONE;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_REBOOT:
|
||||
case TCA8418KeyboardBase::REBOOT:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_REBOOT;
|
||||
break;
|
||||
case _TCA8418_LEFT:
|
||||
case TCA8418KeyboardBase::LEFT:
|
||||
e.inputEvent = INPUT_BROKER_LEFT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_UP:
|
||||
case TCA8418KeyboardBase::UP:
|
||||
e.inputEvent = INPUT_BROKER_UP;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_DOWN:
|
||||
case TCA8418KeyboardBase::DOWN:
|
||||
e.inputEvent = INPUT_BROKER_DOWN;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_RIGHT:
|
||||
case TCA8418KeyboardBase::RIGHT:
|
||||
e.inputEvent = INPUT_BROKER_RIGHT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_BSP:
|
||||
case TCA8418KeyboardBase::BSP:
|
||||
e.inputEvent = INPUT_BROKER_BACK;
|
||||
e.kbchar = 0x08;
|
||||
break;
|
||||
case _TCA8418_SELECT:
|
||||
case TCA8418KeyboardBase::SELECT:
|
||||
e.inputEvent = INPUT_BROKER_SELECT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_ESC:
|
||||
case TCA8418KeyboardBase::ESC:
|
||||
e.inputEvent = INPUT_BROKER_CANCEL;
|
||||
e.kbchar = 0;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case TCA8418KeyboardBase::GPS_TOGGLE:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_GPS_TOGGLE;
|
||||
break;
|
||||
case TCA8418KeyboardBase::SEND_PING:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_SEND_PING;
|
||||
break;
|
||||
case TCA8418KeyboardBase::MUTE_TOGGLE:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_MUTE_TOGGLE;
|
||||
break;
|
||||
case TCA8418KeyboardBase::BT_TOGGLE:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_BLUETOOTH_TOGGLE;
|
||||
break;
|
||||
case TCA8418KeyboardBase::BL_TOGGLE:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_BLUETOOTH_TOGGLE;
|
||||
break;
|
||||
case TCA8418KeyboardBase::TAB:
|
||||
e.inputEvent = INPUT_BROKER_ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_TAB;
|
||||
break;
|
||||
default:
|
||||
if (nextEvent > 127) {
|
||||
@ -291,6 +331,7 @@ int32_t KbI2cBase::runOnce()
|
||||
LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar);
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
TCAKeyboard.trigger();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3,10 +3,11 @@
|
||||
#include "BBQ10Keyboard.h"
|
||||
#include "InputBroker.h"
|
||||
#include "MPR121Keyboard.h"
|
||||
#include "TCA8418Keyboard.h"
|
||||
#include "Wire.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
|
||||
class TCA8418KeyboardBase;
|
||||
|
||||
class KbI2cBase : public Observable<const InputEvent *>, public concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
@ -22,6 +23,6 @@ class KbI2cBase : public Observable<const InputEvent *>, public concurrency::OST
|
||||
|
||||
BBQ10Keyboard Q10keyboard;
|
||||
MPR121Keyboard MPRkeyboard;
|
||||
TCA8418Keyboard TCAKeyboard;
|
||||
TCA8418KeyboardBase &TCAKeyboard;
|
||||
bool is_sym = false;
|
||||
};
|
45
src/main.cpp
45
src/main.cpp
@ -33,12 +33,15 @@
|
||||
#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 <memory>
|
||||
#include <utility>
|
||||
|
||||
#ifdef ELECROW_ThinkNode_M5
|
||||
PCA9557 io(0x18, &Wire);
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
#include "freertosinc.h"
|
||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||
@ -303,6 +306,14 @@ void setup()
|
||||
digitalWrite(PIN_POWER_EN, HIGH);
|
||||
#endif
|
||||
|
||||
#if defined(ELECROW_ThinkNode_M5)
|
||||
Wire.begin(48, 47);
|
||||
io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
|
||||
io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
|
||||
io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
|
||||
// io.pinMode(C2_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
#ifdef LED_POWER
|
||||
pinMode(LED_POWER, OUTPUT);
|
||||
digitalWrite(LED_POWER, LED_STATE_ON);
|
||||
@ -341,6 +352,15 @@ void setup()
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
delay(100);
|
||||
#elif defined(T_DECK_PRO)
|
||||
pinMode(LORA_EN, OUTPUT);
|
||||
digitalWrite(LORA_EN, HIGH);
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(PIN_EINK_CS, OUTPUT);
|
||||
digitalWrite(PIN_EINK_CS, HIGH);
|
||||
#endif
|
||||
|
||||
concurrency::hasBeenSetup = true;
|
||||
@ -906,14 +926,20 @@ void setup()
|
||||
service = new MeshService();
|
||||
service->init();
|
||||
|
||||
if (nodeDB->keyIsLowEntropy) {
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||
}
|
||||
|
||||
// Now that the mesh service is created, create any modules
|
||||
setupModules();
|
||||
|
||||
// warn the user about a low entropy key
|
||||
if (nodeDB->keyIsLowEntropy && !nodeDB->hasWarned) {
|
||||
LOG_WARN(LOW_ENTROPY_WARNING);
|
||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||
cn->time = getValidTime(RTCQualityFromNet);
|
||||
sprintf(cn->message, LOW_ENTROPY_WARNING);
|
||||
service->sendClientNotification(cn);
|
||||
nodeDB->hasWarned = true;
|
||||
}
|
||||
|
||||
// buttons are now inputBroker, so have to come after setupModules
|
||||
#if HAS_BUTTON
|
||||
int pullup_sense = 0;
|
||||
@ -1054,8 +1080,9 @@ void setup()
|
||||
mainDelay.interruptFromISR(&higherWake);
|
||||
};
|
||||
userConfigNoScreen.singlePress = INPUT_BROKER_USER_PRESS;
|
||||
userConfigNoScreen.longPress = INPUT_BROKER_SHUTDOWN;
|
||||
userConfigNoScreen.longPressTime = 5000;
|
||||
userConfigNoScreen.longPress = INPUT_BROKER_NONE;
|
||||
userConfigNoScreen.longPressTime = 500;
|
||||
userConfigNoScreen.longLongPress = INPUT_BROKER_SHUTDOWN;
|
||||
userConfigNoScreen.doublePress = INPUT_BROKER_SEND_PING;
|
||||
userConfigNoScreen.triplePress = INPUT_BROKER_GPS_TOGGLE;
|
||||
UserButtonThread->initButton(userConfigNoScreen);
|
||||
@ -1532,7 +1559,7 @@ void loop()
|
||||
#ifdef ARCH_NRF52
|
||||
nrf52Loop();
|
||||
#endif
|
||||
powerCommandsCheck();
|
||||
power->powerCommandsCheck();
|
||||
|
||||
#ifdef DEBUG_STACK
|
||||
static uint32_t lastPrint = 0;
|
||||
|
@ -53,6 +53,11 @@ extern Adafruit_DRV2605 drv;
|
||||
extern AudioThread *audioThread;
|
||||
#endif
|
||||
|
||||
#ifdef ELECROW_ThinkNode_M5
|
||||
#include <PCA9557.h>
|
||||
extern PCA9557 io;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_UDP_MULTICAST
|
||||
#include "mesh/udp/UdpMulticastHandler.h"
|
||||
extern UdpMulticastHandler *udpHandler;
|
||||
|
@ -47,8 +47,10 @@ void FloodingRouter::perhapsCancelDupe(const meshtastic_MeshPacket *p)
|
||||
{
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER &&
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER_LATE &&
|
||||
p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA) {
|
||||
// cancel rebroadcast of this message *if* there was already one, unless we're a router/repeater!
|
||||
// But only LoRa packets should be able to trigger this.
|
||||
if (Router::cancelSending(p->from, p->id))
|
||||
txRelayCanceled++;
|
||||
}
|
||||
|
@ -85,8 +85,11 @@ meshtastic_MeshPacket *MeshModule::allocErrorResponse(meshtastic_Routing_Error e
|
||||
return r;
|
||||
}
|
||||
|
||||
void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
||||
void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src, const char *specificModule)
|
||||
{
|
||||
if (specificModule) {
|
||||
LOG_DEBUG("Calling specific module: %s", specificModule);
|
||||
}
|
||||
// LOG_DEBUG("In call modules");
|
||||
bool moduleFound = false;
|
||||
|
||||
@ -104,6 +107,11 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
|
||||
// If specificModule is provided, only call that specific module
|
||||
if (specificModule && (!pi.name || strcmp(pi.name, specificModule) != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pi.currentRequest = ∓
|
||||
|
||||
/// We only call modules that are interested in the packet (and the message is destined to us or we are promiscious)
|
||||
|
@ -73,7 +73,7 @@ class MeshModule
|
||||
|
||||
/** For use only by MeshService
|
||||
*/
|
||||
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
||||
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO, const char *specificModule = nullptr);
|
||||
|
||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames(int startIndex);
|
||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||
|
@ -121,7 +121,7 @@ meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool t
|
||||
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
|
||||
{
|
||||
for (auto it = queue.begin(); it != queue.end(); it++) {
|
||||
const auto p = (*it);
|
||||
const auto *p = *it;
|
||||
if (getFrom(p) == from && p->id == id) {
|
||||
return true;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "meshUtils.h"
|
||||
#include "modules/NodeInfoModule.h"
|
||||
#include "modules/PositionModule.h"
|
||||
#include "modules/RoutingModule.h"
|
||||
#include "power.h"
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
@ -333,6 +334,21 @@ void MeshService::sendMqttMessageToClientProxy(meshtastic_MqttClientProxyMessage
|
||||
fromNum++;
|
||||
}
|
||||
|
||||
void MeshService::sendRoutingErrorResponse(meshtastic_Routing_Error error, const meshtastic_MeshPacket *mp)
|
||||
{
|
||||
if (!mp) {
|
||||
LOG_WARN("Cannot send routing error response: null packet");
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the routing module to send the error response
|
||||
if (routingModule) {
|
||||
routingModule->sendAckNak(error, mp->from, mp->id, mp->channel);
|
||||
} else {
|
||||
LOG_ERROR("Cannot send routing error response: no routing module");
|
||||
}
|
||||
}
|
||||
|
||||
void MeshService::sendClientNotification(meshtastic_ClientNotification *n)
|
||||
{
|
||||
LOG_DEBUG("Send client notification to phone");
|
||||
|
@ -146,7 +146,10 @@ class MeshService
|
||||
virtual void sendMqttMessageToClientProxy(meshtastic_MqttClientProxyMessage *m);
|
||||
|
||||
/// Send a ClientNotification to the phone
|
||||
void sendClientNotification(meshtastic_ClientNotification *cn);
|
||||
virtual void sendClientNotification(meshtastic_ClientNotification *cn);
|
||||
|
||||
/// Send an error response to the phone
|
||||
void sendRoutingErrorResponse(meshtastic_Routing_Error error, const meshtastic_MeshPacket *mp);
|
||||
|
||||
bool isToPhoneQueueEmpty();
|
||||
|
||||
|
@ -264,12 +264,12 @@ NodeDB::NodeDB()
|
||||
|
||||
if (!owner.is_licensed && config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
|
||||
bool keygenSuccess = false;
|
||||
if (config.security.private_key.size == 32) {
|
||||
keyIsLowEntropy = checkLowEntropyPublicKey(config.security.public_key);
|
||||
if (config.security.private_key.size == 32 && !keyIsLowEntropy) {
|
||||
if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) {
|
||||
keygenSuccess = true;
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("Generate new PKI keys");
|
||||
crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes);
|
||||
keygenSuccess = true;
|
||||
}
|
||||
@ -288,16 +288,6 @@ NodeDB::NodeDB()
|
||||
crypto->setDHPrivateKey(config.security.private_key.bytes);
|
||||
}
|
||||
#endif
|
||||
keyIsLowEntropy = checkLowEntropyPublicKey(config.security.public_key);
|
||||
if (keyIsLowEntropy) {
|
||||
LOG_WARN("Erasing low entropy keys");
|
||||
config.security.private_key.size = 0;
|
||||
memfll(config.security.private_key.bytes, '\0', sizeof(config.security.private_key.bytes));
|
||||
config.security.public_key.size = 0;
|
||||
memfll(config.security.public_key.bytes, '\0', sizeof(config.security.public_key.bytes));
|
||||
owner.public_key.size = 0;
|
||||
memfll(owner.public_key.bytes, '\0', sizeof(owner.public_key.bytes));
|
||||
}
|
||||
// Include our owner in the node db under our nodenum
|
||||
meshtastic_NodeInfoLite *info = getOrCreateMeshNode(getNodeNum());
|
||||
info->user = TypeConversions::ConvertToUserLite(owner);
|
||||
@ -406,6 +396,9 @@ NodeDB::NodeDB()
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
config.position.gps_enabled = 0;
|
||||
}
|
||||
#ifdef USERPREFS_FIRMWARE_EDITION
|
||||
myNodeInfo.firmware_edition = USERPREFS_FIRMWARE_EDITION;
|
||||
#endif
|
||||
#ifdef USERPREFS_FIXED_GPS
|
||||
if (myNodeInfo.reboot_count == 1) { // Check if First boot ever or after Factory Reset.
|
||||
meshtastic_Position fixedGPS = meshtastic_Position_init_default;
|
||||
@ -628,11 +621,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
|
||||
@ -735,7 +723,6 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
||||
config.display.screen_on_secs = 30;
|
||||
config.display.wake_on_tap_or_motion = true;
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WIFI
|
||||
if (WiFiOTA::isUpdated()) {
|
||||
WiFiOTA::recoverConfig(&config.network);
|
||||
@ -796,6 +783,13 @@ void NodeDB::installDefaultModuleConfig()
|
||||
moduleConfig.external_notification.alert_message_buzzer = true;
|
||||
moduleConfig.external_notification.nag_timeout = default_ringtone_nag_secs;
|
||||
#endif
|
||||
#if defined(PIN_VIBRATION)
|
||||
moduleConfig.external_notification.enabled = true;
|
||||
moduleConfig.external_notification.output_vibra = PIN_VIBRATION;
|
||||
moduleConfig.external_notification.alert_message_vibra = true;
|
||||
moduleConfig.external_notification.output_ms = 500;
|
||||
moduleConfig.external_notification.nag_timeout = 2;
|
||||
#endif
|
||||
#if defined(RAK4630) || defined(RAK11310) || defined(RAK3312)
|
||||
// Default to RAK led pin 2 (blue)
|
||||
moduleConfig.external_notification.enabled = true;
|
||||
@ -1643,7 +1637,6 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
||||
"to regenerate your public keys.";
|
||||
LOG_WARN(warning, p.long_name);
|
||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||
cn->which_payload_variant = meshtastic_ClientNotification_duplicated_public_key_tag;
|
||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||
cn->time = getValidTime(RTCQualityFromNet);
|
||||
sprintf(cn->message, warning, p.long_name);
|
||||
@ -1868,34 +1861,16 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum)
|
||||
return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed;
|
||||
}
|
||||
|
||||
bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t keyToTest)
|
||||
bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest)
|
||||
{
|
||||
if (keyToTest.size == 32) {
|
||||
uint8_t keyHash[32] = {0};
|
||||
memcpy(keyHash, keyToTest.bytes, keyToTest.size);
|
||||
crypto->hash(keyHash, 32);
|
||||
if (memcmp(keyHash, LOW_ENTROPY_HASH1, sizeof(LOW_ENTROPY_HASH1)) ==
|
||||
0 || // should become an array that gets looped through rather than this abomination
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH2, sizeof(LOW_ENTROPY_HASH2)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH3, sizeof(LOW_ENTROPY_HASH3)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH4, sizeof(LOW_ENTROPY_HASH4)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH5, sizeof(LOW_ENTROPY_HASH5)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH6, sizeof(LOW_ENTROPY_HASH6)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH7, sizeof(LOW_ENTROPY_HASH7)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH8, sizeof(LOW_ENTROPY_HASH8)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH9, sizeof(LOW_ENTROPY_HASH9)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH10, sizeof(LOW_ENTROPY_HASH10)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH11, sizeof(LOW_ENTROPY_HASH11)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH12, sizeof(LOW_ENTROPY_HASH12)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH13, sizeof(LOW_ENTROPY_HASH13)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH14, sizeof(LOW_ENTROPY_HASH14)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH15, sizeof(LOW_ENTROPY_HASH15)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH16, sizeof(LOW_ENTROPY_HASH16)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH17, sizeof(LOW_ENTROPY_HASH17)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH18, sizeof(LOW_ENTROPY_HASH18)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH19, sizeof(LOW_ENTROPY_HASH19)) == 0 ||
|
||||
memcmp(keyHash, LOW_ENTROPY_HASH20, sizeof(LOW_ENTROPY_HASH20)) == 0) {
|
||||
return true;
|
||||
for (uint16_t i = 0; i < sizeof(LOW_ENTROPY_HASHES) / sizeof(LOW_ENTROPY_HASHES[0]); i++) {
|
||||
if (memcmp(keyHash, LOW_ENTROPY_HASHES[i], sizeof(LOW_ENTROPY_HASHES[0])) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -18,68 +18,57 @@
|
||||
#endif
|
||||
|
||||
#if !defined(MESHTASTIC_EXCLUDE_PKI)
|
||||
|
||||
static const uint8_t LOW_ENTROPY_HASH1[] = {0xf4, 0x7e, 0xcc, 0x17, 0xe6, 0xb4, 0xa3, 0x22, 0xec, 0xee, 0xd9,
|
||||
0x08, 0x4f, 0x39, 0x63, 0xea, 0x80, 0x75, 0xe1, 0x24, 0xce, 0x05,
|
||||
0x36, 0x69, 0x63, 0xb2, 0xcb, 0xc0, 0x28, 0xd3, 0x34, 0x8b};
|
||||
static const uint8_t LOW_ENTROPY_HASH2[] = {0x5a, 0x9e, 0xa2, 0xa6, 0x8a, 0xa6, 0x66, 0xc1, 0x5f, 0x55, 0x00,
|
||||
0x64, 0xa3, 0xa6, 0xfe, 0x71, 0xc0, 0xbb, 0x82, 0xc3, 0x32, 0x3d,
|
||||
0x7a, 0x7a, 0xe3, 0x6e, 0xfd, 0xdd, 0xad, 0x3a, 0x66, 0xb9};
|
||||
static const uint8_t LOW_ENTROPY_HASH3[] = {0xb3, 0xdf, 0x3b, 0x2e, 0x67, 0xb6, 0xd5, 0xf8, 0xdf, 0x76, 0x2c,
|
||||
0x45, 0x5e, 0x2e, 0xbd, 0x16, 0xc5, 0xf8, 0x67, 0xaa, 0x15, 0xf8,
|
||||
0x92, 0x0b, 0xdf, 0x5a, 0x66, 0x50, 0xac, 0x0d, 0xbb, 0x2f};
|
||||
static const uint8_t LOW_ENTROPY_HASH4[] = {0x3b, 0x8f, 0x86, 0x3a, 0x38, 0x1f, 0x77, 0x39, 0xa9, 0x4e, 0xef,
|
||||
0x91, 0x18, 0x5a, 0x62, 0xe1, 0xaa, 0x9d, 0x36, 0xea, 0xce, 0x60,
|
||||
0x35, 0x8d, 0x9d, 0x1f, 0xf4, 0xb8, 0xc9, 0x13, 0x6a, 0x5d};
|
||||
static const uint8_t LOW_ENTROPY_HASH5[] = {0x36, 0x7e, 0x2d, 0xe1, 0x84, 0x5f, 0x42, 0x52, 0x29, 0x11, 0x0a,
|
||||
0x25, 0x64, 0x54, 0x6a, 0x6b, 0xfd, 0xb6, 0x65, 0xff, 0x15, 0x1a,
|
||||
0x51, 0x71, 0x22, 0x40, 0x57, 0xf6, 0x91, 0x9b, 0x64, 0x58};
|
||||
static const uint8_t LOW_ENTROPY_HASH6[] = {0x16, 0x77, 0xeb, 0xa4, 0x52, 0x91, 0xfb, 0x26, 0xcf, 0x8f, 0xd7,
|
||||
0xd9, 0xd1, 0x5d, 0xc4, 0x68, 0x73, 0x75, 0xed, 0xc5, 0x95, 0x58,
|
||||
0xee, 0x90, 0x56, 0xd4, 0x2f, 0x31, 0x29, 0xf7, 0x8c, 0x1f};
|
||||
static const uint8_t LOW_ENTROPY_HASH7[] = {0x31, 0x8c, 0xa9, 0x5e, 0xed, 0x3c, 0x12, 0xbf, 0x97, 0x9c, 0x47,
|
||||
0x8e, 0x98, 0x9d, 0xc2, 0x3e, 0x86, 0x23, 0x90, 0x29, 0xc8, 0xb0,
|
||||
0x20, 0xf8, 0xb1, 0xb0, 0xaa, 0x19, 0x2a, 0xcf, 0x0a, 0x54};
|
||||
static const uint8_t LOW_ENTROPY_HASH8[] = {0xa4, 0x8a, 0x99, 0x0e, 0x51, 0xdc, 0x12, 0x20, 0xf3, 0x13, 0xf5,
|
||||
0x2b, 0x3a, 0xe2, 0x43, 0x42, 0xc6, 0x52, 0x98, 0xcd, 0xbb, 0xca,
|
||||
0xb1, 0x31, 0xa0, 0xd4, 0xd6, 0x30, 0xf3, 0x27, 0xfb, 0x49};
|
||||
static const uint8_t LOW_ENTROPY_HASH9[] = {0xd2, 0x3f, 0x13, 0x8d, 0x22, 0x04, 0x8d, 0x07, 0x59, 0x58, 0xa0,
|
||||
0xf9, 0x55, 0xcf, 0x30, 0xa0, 0x2e, 0x2f, 0xca, 0x80, 0x20, 0xe4,
|
||||
0xde, 0xa1, 0xad, 0xd9, 0x58, 0xb3, 0x43, 0x2b, 0x22, 0x70};
|
||||
static const uint8_t LOW_ENTROPY_HASH10[] = {0x40, 0x41, 0xec, 0x6a, 0xd2, 0xd6, 0x03, 0xe4, 0x9a, 0x9e, 0xbd,
|
||||
0x6c, 0x0a, 0x9b, 0x75, 0xa4, 0xbc, 0xab, 0x6f, 0xa7, 0x95, 0xff,
|
||||
0x2d, 0xf6, 0xe9, 0xb9, 0xab, 0x4c, 0x0c, 0x1c, 0xd0, 0x3b};
|
||||
static const uint8_t LOW_ENTROPY_HASH11[] = {0x22, 0x49, 0x32, 0x2b, 0x00, 0xf9, 0x22, 0xfa, 0x17, 0x02, 0xe9,
|
||||
0x64, 0x82, 0xf0, 0x4d, 0x1b, 0xc7, 0x04, 0xfc, 0xdc, 0x8c, 0x5e,
|
||||
0xb6, 0xd9, 0x16, 0xd6, 0x37, 0xce, 0x59, 0xaa, 0x09, 0x49};
|
||||
static const uint8_t LOW_ENTROPY_HASH12[] = {0x48, 0x6f, 0x1e, 0x48, 0x97, 0x88, 0x64, 0xac, 0xe8, 0xeb, 0x30,
|
||||
0xa3, 0xc3, 0xe1, 0xcf, 0x97, 0x39, 0xa6, 0x55, 0x5b, 0x5f, 0xbf,
|
||||
0x18, 0xb7, 0x3a, 0xdf, 0xa8, 0x75, 0xe7, 0x9d, 0xe0, 0x1e};
|
||||
static const uint8_t LOW_ENTROPY_HASH13[] = {0x09, 0xb4, 0xe2, 0x6d, 0x28, 0x98, 0xc9, 0x47, 0x66, 0x46, 0xbf,
|
||||
0xff, 0x58, 0x17, 0x91, 0xaa, 0xc3, 0xbf, 0x4a, 0x9d, 0x0b, 0x88,
|
||||
0xb1, 0xf1, 0x03, 0xdd, 0x61, 0xd7, 0xba, 0x9e, 0x64, 0x98};
|
||||
static const uint8_t LOW_ENTROPY_HASH14[] = {0x39, 0x39, 0x84, 0xe0, 0x22, 0x2f, 0x7d, 0x78, 0x45, 0x18, 0x72,
|
||||
0xb4, 0x13, 0xd2, 0x01, 0x2f, 0x3c, 0xa1, 0xb0, 0xfe, 0x39, 0xd0,
|
||||
0xf1, 0x3c, 0x72, 0xd6, 0xef, 0x54, 0xd5, 0x77, 0x22, 0xa0};
|
||||
static const uint8_t LOW_ENTROPY_HASH15[] = {0x0a, 0xda, 0x5f, 0xec, 0xff, 0x5c, 0xc0, 0x2e, 0x5f, 0xc4, 0x8d,
|
||||
0x03, 0xe5, 0x80, 0x59, 0xd3, 0x5d, 0x49, 0x86, 0xe9, 0x8d, 0xf6,
|
||||
0xf6, 0x16, 0x35, 0x3d, 0xf9, 0x9b, 0x29, 0x55, 0x9e, 0x64};
|
||||
static const uint8_t LOW_ENTROPY_HASH16[] = {0x08, 0x56, 0xF0, 0xD7, 0xEF, 0x77, 0xD6, 0x11, 0x1C, 0x8F, 0x95,
|
||||
0x2D, 0x3C, 0xDF, 0xB1, 0x22, 0xBF, 0x60, 0x9B, 0xE5, 0xA9, 0xC0,
|
||||
0x6E, 0x4B, 0x01, 0xDC, 0xD1, 0x57, 0x44, 0xB2, 0xA5, 0xCF};
|
||||
static const uint8_t LOW_ENTROPY_HASH17[] = {0x2C, 0xB2, 0x77, 0x85, 0xD6, 0xB7, 0x48, 0x9C, 0xFE, 0xBC, 0x80,
|
||||
0x26, 0x60, 0xF4, 0x6D, 0xCE, 0x11, 0x31, 0xA2, 0x1E, 0x33, 0x0A,
|
||||
0x6D, 0x2B, 0x00, 0xFA, 0x0C, 0x90, 0x95, 0x8F, 0x5C, 0x6B};
|
||||
static const uint8_t LOW_ENTROPY_HASH18[] = {0xFA, 0x59, 0xC8, 0x6E, 0x94, 0xEE, 0x75, 0xC9, 0x9A, 0xB0, 0xFE,
|
||||
0x89, 0x36, 0x40, 0xC9, 0x99, 0x4A, 0x3B, 0xF4, 0xAA, 0x12, 0x24,
|
||||
0xA2, 0x0F, 0xF9, 0xD1, 0x08, 0xCB, 0x78, 0x19, 0xAA, 0xE5};
|
||||
static const uint8_t LOW_ENTROPY_HASH19[] = {0x6E, 0x42, 0x7A, 0x4A, 0x8C, 0x61, 0x62, 0x22, 0xA1, 0x89, 0xD3,
|
||||
0xA4, 0xC2, 0x19, 0xA3, 0x83, 0x53, 0xA7, 0x7A, 0x0A, 0x89, 0xE2,
|
||||
0x54, 0x52, 0x62, 0x3D, 0xE7, 0xCA, 0x8C, 0xF6, 0x6A, 0x60};
|
||||
static const uint8_t LOW_ENTROPY_HASH20[] = {0x20, 0x27, 0x2F, 0xBA, 0x0C, 0x99, 0xD7, 0x29, 0xF3, 0x11, 0x35,
|
||||
0x89, 0x9D, 0x0E, 0x24, 0xA1, 0xC3, 0xCB, 0xDF, 0x8A, 0xF1, 0xC6,
|
||||
0xFE, 0xD0, 0xD7, 0x9F, 0x92, 0xD6, 0x8F, 0x59, 0xBF, 0xE4};
|
||||
static const char LOW_ENTROPY_WARNING[] = "Compromised keys detected, please regenerate.";
|
||||
// E3B0C442 is the blank hash
|
||||
static const uint8_t LOW_ENTROPY_HASHES[][32] = {
|
||||
{0xf4, 0x7e, 0xcc, 0x17, 0xe6, 0xb4, 0xa3, 0x22, 0xec, 0xee, 0xd9, 0x08, 0x4f, 0x39, 0x63, 0xea,
|
||||
0x80, 0x75, 0xe1, 0x24, 0xce, 0x05, 0x36, 0x69, 0x63, 0xb2, 0xcb, 0xc0, 0x28, 0xd3, 0x34, 0x8b},
|
||||
{0x5a, 0x9e, 0xa2, 0xa6, 0x8a, 0xa6, 0x66, 0xc1, 0x5f, 0x55, 0x00, 0x64, 0xa3, 0xa6, 0xfe, 0x71,
|
||||
0xc0, 0xbb, 0x82, 0xc3, 0x32, 0x3d, 0x7a, 0x7a, 0xe3, 0x6e, 0xfd, 0xdd, 0xad, 0x3a, 0x66, 0xb9},
|
||||
{0xb3, 0xdf, 0x3b, 0x2e, 0x67, 0xb6, 0xd5, 0xf8, 0xdf, 0x76, 0x2c, 0x45, 0x5e, 0x2e, 0xbd, 0x16,
|
||||
0xc5, 0xf8, 0x67, 0xaa, 0x15, 0xf8, 0x92, 0x0b, 0xdf, 0x5a, 0x66, 0x50, 0xac, 0x0d, 0xbb, 0x2f},
|
||||
{0x3b, 0x8f, 0x86, 0x3a, 0x38, 0x1f, 0x77, 0x39, 0xa9, 0x4e, 0xef, 0x91, 0x18, 0x5a, 0x62, 0xe1,
|
||||
0xaa, 0x9d, 0x36, 0xea, 0xce, 0x60, 0x35, 0x8d, 0x9d, 0x1f, 0xf4, 0xb8, 0xc9, 0x13, 0x6a, 0x5d},
|
||||
{0x36, 0x7e, 0x2d, 0xe1, 0x84, 0x5f, 0x42, 0x52, 0x29, 0x11, 0x0a, 0x25, 0x64, 0x54, 0x6a, 0x6b,
|
||||
0xfd, 0xb6, 0x65, 0xff, 0x15, 0x1a, 0x51, 0x71, 0x22, 0x40, 0x57, 0xf6, 0x91, 0x9b, 0x64, 0x58},
|
||||
{0x16, 0x77, 0xeb, 0xa4, 0x52, 0x91, 0xfb, 0x26, 0xcf, 0x8f, 0xd7, 0xd9, 0xd1, 0x5d, 0xc4, 0x68,
|
||||
0x73, 0x75, 0xed, 0xc5, 0x95, 0x58, 0xee, 0x90, 0x56, 0xd4, 0x2f, 0x31, 0x29, 0xf7, 0x8c, 0x1f},
|
||||
{0x31, 0x8c, 0xa9, 0x5e, 0xed, 0x3c, 0x12, 0xbf, 0x97, 0x9c, 0x47, 0x8e, 0x98, 0x9d, 0xc2, 0x3e,
|
||||
0x86, 0x23, 0x90, 0x29, 0xc8, 0xb0, 0x20, 0xf8, 0xb1, 0xb0, 0xaa, 0x19, 0x2a, 0xcf, 0x0a, 0x54},
|
||||
{0xa4, 0x8a, 0x99, 0x0e, 0x51, 0xdc, 0x12, 0x20, 0xf3, 0x13, 0xf5, 0x2b, 0x3a, 0xe2, 0x43, 0x42,
|
||||
0xc6, 0x52, 0x98, 0xcd, 0xbb, 0xca, 0xb1, 0x31, 0xa0, 0xd4, 0xd6, 0x30, 0xf3, 0x27, 0xfb, 0x49},
|
||||
{0xd2, 0x3f, 0x13, 0x8d, 0x22, 0x04, 0x8d, 0x07, 0x59, 0x58, 0xa0, 0xf9, 0x55, 0xcf, 0x30, 0xa0,
|
||||
0x2e, 0x2f, 0xca, 0x80, 0x20, 0xe4, 0xde, 0xa1, 0xad, 0xd9, 0x58, 0xb3, 0x43, 0x2b, 0x22, 0x70},
|
||||
{0x40, 0x41, 0xec, 0x6a, 0xd2, 0xd6, 0x03, 0xe4, 0x9a, 0x9e, 0xbd, 0x6c, 0x0a, 0x9b, 0x75, 0xa4,
|
||||
0xbc, 0xab, 0x6f, 0xa7, 0x95, 0xff, 0x2d, 0xf6, 0xe9, 0xb9, 0xab, 0x4c, 0x0c, 0x1c, 0xd0, 0x3b},
|
||||
{0x22, 0x49, 0x32, 0x2b, 0x00, 0xf9, 0x22, 0xfa, 0x17, 0x02, 0xe9, 0x64, 0x82, 0xf0, 0x4d, 0x1b,
|
||||
0xc7, 0x04, 0xfc, 0xdc, 0x8c, 0x5e, 0xb6, 0xd9, 0x16, 0xd6, 0x37, 0xce, 0x59, 0xaa, 0x09, 0x49},
|
||||
{0x48, 0x6f, 0x1e, 0x48, 0x97, 0x88, 0x64, 0xac, 0xe8, 0xeb, 0x30, 0xa3, 0xc3, 0xe1, 0xcf, 0x97,
|
||||
0x39, 0xa6, 0x55, 0x5b, 0x5f, 0xbf, 0x18, 0xb7, 0x3a, 0xdf, 0xa8, 0x75, 0xe7, 0x9d, 0xe0, 0x1e},
|
||||
{0x09, 0xb4, 0xe2, 0x6d, 0x28, 0x98, 0xc9, 0x47, 0x66, 0x46, 0xbf, 0xff, 0x58, 0x17, 0x91, 0xaa,
|
||||
0xc3, 0xbf, 0x4a, 0x9d, 0x0b, 0x88, 0xb1, 0xf1, 0x03, 0xdd, 0x61, 0xd7, 0xba, 0x9e, 0x64, 0x98},
|
||||
{0x39, 0x39, 0x84, 0xe0, 0x22, 0x2f, 0x7d, 0x78, 0x45, 0x18, 0x72, 0xb4, 0x13, 0xd2, 0x01, 0x2f,
|
||||
0x3c, 0xa1, 0xb0, 0xfe, 0x39, 0xd0, 0xf1, 0x3c, 0x72, 0xd6, 0xef, 0x54, 0xd5, 0x77, 0x22, 0xa0},
|
||||
{0x0a, 0xda, 0x5f, 0xec, 0xff, 0x5c, 0xc0, 0x2e, 0x5f, 0xc4, 0x8d, 0x03, 0xe5, 0x80, 0x59, 0xd3,
|
||||
0x5d, 0x49, 0x86, 0xe9, 0x8d, 0xf6, 0xf6, 0x16, 0x35, 0x3d, 0xf9, 0x9b, 0x29, 0x55, 0x9e, 0x64},
|
||||
{0x08, 0x56, 0xF0, 0xD7, 0xEF, 0x77, 0xD6, 0x11, 0x1C, 0x8F, 0x95, 0x2D, 0x3C, 0xDF, 0xB1, 0x22,
|
||||
0xBF, 0x60, 0x9B, 0xE5, 0xA9, 0xC0, 0x6E, 0x4B, 0x01, 0xDC, 0xD1, 0x57, 0x44, 0xB2, 0xA5, 0xCF},
|
||||
{0x2C, 0xB2, 0x77, 0x85, 0xD6, 0xB7, 0x48, 0x9C, 0xFE, 0xBC, 0x80, 0x26, 0x60, 0xF4, 0x6D, 0xCE,
|
||||
0x11, 0x31, 0xA2, 0x1E, 0x33, 0x0A, 0x6D, 0x2B, 0x00, 0xFA, 0x0C, 0x90, 0x95, 0x8F, 0x5C, 0x6B},
|
||||
{0xFA, 0x59, 0xC8, 0x6E, 0x94, 0xEE, 0x75, 0xC9, 0x9A, 0xB0, 0xFE, 0x89, 0x36, 0x40, 0xC9, 0x99,
|
||||
0x4A, 0x3B, 0xF4, 0xAA, 0x12, 0x24, 0xA2, 0x0F, 0xF9, 0xD1, 0x08, 0xCB, 0x78, 0x19, 0xAA, 0xE5},
|
||||
{0x6E, 0x42, 0x7A, 0x4A, 0x8C, 0x61, 0x62, 0x22, 0xA1, 0x89, 0xD3, 0xA4, 0xC2, 0x19, 0xA3, 0x83,
|
||||
0x53, 0xA7, 0x7A, 0x0A, 0x89, 0xE2, 0x54, 0x52, 0x62, 0x3D, 0xE7, 0xCA, 0x8C, 0xF6, 0x6A, 0x60},
|
||||
{0x20, 0x27, 0x2F, 0xBA, 0x0C, 0x99, 0xD7, 0x29, 0xF3, 0x11, 0x35, 0x89, 0x9D, 0x0E, 0x24, 0xA1,
|
||||
0xC3, 0xCB, 0xDF, 0x8A, 0xF1, 0xC6, 0xFE, 0xD0, 0xD7, 0x9F, 0x92, 0xD6, 0x8F, 0x59, 0xBF, 0xE4},
|
||||
{0x91, 0x70, 0xb4, 0x7c, 0xfb, 0xff, 0xa0, 0x59, 0x6a, 0x25, 0x1c, 0xa9, 0x9e, 0xe9, 0x43, 0x81,
|
||||
0x5d, 0x74, 0xb1, 0xb1, 0x09, 0x28, 0x00, 0x4a, 0xaf, 0xe3, 0xfc, 0xa9, 0x4e, 0x27, 0x76, 0x4c},
|
||||
{0x85, 0xfe, 0x7c, 0xec, 0xb6, 0x78, 0x74, 0xc3, 0xec, 0xe1, 0x32, 0x7f, 0xb0, 0xb7, 0x02, 0x74,
|
||||
0xf9, 0x23, 0xd8, 0xe7, 0xfa, 0x14, 0xe6, 0xee, 0x66, 0x44, 0xb1, 0x8c, 0xa5, 0x2f, 0x7e, 0xd2},
|
||||
{0x8e, 0x66, 0x65, 0x7b, 0x3b, 0x6f, 0x7e, 0xcc, 0x57, 0xb4, 0x57, 0xea, 0xcc, 0x83, 0xf5, 0xaa,
|
||||
0xf7, 0x65, 0xa3, 0xce, 0x93, 0x72, 0x13, 0xc1, 0xb6, 0x46, 0x7b, 0x29, 0x45, 0xb5, 0xc8, 0x93},
|
||||
{0xcc, 0x11, 0xfb, 0x1a, 0xab, 0xa1, 0x31, 0x87, 0x6a, 0xc6, 0xde, 0x88, 0x87, 0xa9, 0xb9, 0x59,
|
||||
0x37, 0x82, 0x8d, 0xb2, 0xcc, 0xd8, 0x97, 0x40, 0x9a, 0x5c, 0x8f, 0x40, 0x55, 0xcb, 0x4c, 0x3e}};
|
||||
static const char LOW_ENTROPY_WARNING[] = "Compromised keys were detected and regenerated.";
|
||||
#endif
|
||||
/*
|
||||
DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a
|
||||
@ -279,7 +268,7 @@ class NodeDB
|
||||
|
||||
bool hasValidPosition(const meshtastic_NodeInfoLite *n);
|
||||
|
||||
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t keyToTest);
|
||||
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest);
|
||||
|
||||
bool backupPreferences(meshtastic_AdminMessage_BackupLocation location);
|
||||
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
||||
|
@ -181,7 +181,7 @@ PacketHistory::PacketRecord *PacketHistory::find(NodeNum sender, PacketId id)
|
||||
}
|
||||
|
||||
/** Insert/Replace oldest PacketRecord in recentPackets. */
|
||||
void PacketHistory::insert(PacketRecord &r)
|
||||
void PacketHistory::insert(const PacketRecord &r)
|
||||
{
|
||||
uint32_t now_millis = millis(); // Should not jump with time changes
|
||||
uint32_t OldtrxTimeMsec = 0;
|
||||
@ -308,7 +308,7 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N
|
||||
return false;
|
||||
}
|
||||
|
||||
PacketRecord *found = find(sender, id);
|
||||
const PacketRecord *found = find(sender, id);
|
||||
|
||||
if (found == NULL) {
|
||||
#if VERBOSE_PACKET_HISTORY
|
||||
@ -327,7 +327,7 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N
|
||||
|
||||
/* Check if a certain node was a relayer of a packet in the history given iterator
|
||||
* @return true if node was indeed a relayer, false if not */
|
||||
bool PacketHistory::wasRelayer(const uint8_t relayer, PacketRecord &r)
|
||||
bool PacketHistory::wasRelayer(const uint8_t relayer, const PacketRecord &r)
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_RELAYERS; i++) {
|
||||
if (r.relayed_by[i] == relayer) {
|
||||
|
@ -31,11 +31,11 @@ class PacketHistory
|
||||
|
||||
/** Insert/Replace oldest PacketRecord in mx_recentPackets.
|
||||
* @param r PacketRecord to insert or replace */
|
||||
void insert(PacketRecord &r); // Insert or replace a packet record in the history
|
||||
void insert(const PacketRecord &r); // Insert or replace a packet record in the history
|
||||
|
||||
/* Check if a certain node was a relayer of a packet in the history given iterator
|
||||
* @return true if node was indeed a relayer, false if not */
|
||||
bool wasRelayer(const uint8_t relayer, PacketRecord &r);
|
||||
bool wasRelayer(const uint8_t relayer, const PacketRecord &r);
|
||||
|
||||
PacketHistory(const PacketHistory &); // non construction-copyable
|
||||
PacketHistory &operator=(const PacketHistory &); // non copyable
|
||||
|
@ -31,6 +31,9 @@
|
||||
#include "Throttle.h"
|
||||
#include <RTC.h>
|
||||
|
||||
// Flag to indicate a heartbeat was received and we should send queue status
|
||||
bool heartbeatReceived = false;
|
||||
|
||||
PhoneAPI::PhoneAPI()
|
||||
{
|
||||
lastContactMsec = millis();
|
||||
@ -155,6 +158,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
||||
#endif
|
||||
case meshtastic_ToRadio_heartbeat_tag:
|
||||
LOG_DEBUG("Got client heartbeat");
|
||||
heartbeatReceived = true;
|
||||
break;
|
||||
default:
|
||||
// Ignore nop messages
|
||||
@ -194,6 +198,17 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
// In case we send a FromRadio packet
|
||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||
|
||||
// Respond to heartbeat by sending queue status
|
||||
if (heartbeatReceived) {
|
||||
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_queueStatus_tag;
|
||||
fromRadioScratch.queueStatus = router->getQueueStatus();
|
||||
heartbeatReceived = false;
|
||||
size_t numbytes = pb_encode_to_bytes(buf, meshtastic_FromRadio_size, &meshtastic_FromRadio_msg, &fromRadioScratch);
|
||||
LOG_DEBUG("FromRadio=STATE_SEND_QUEUE_STATUS, numbytes=%u", numbytes);
|
||||
return numbytes;
|
||||
}
|
||||
|
||||
// Advance states as needed
|
||||
switch (state) {
|
||||
case STATE_SEND_NOTHING:
|
||||
@ -205,6 +220,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||
// app not to send locations on our behalf.
|
||||
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_my_info_tag;
|
||||
strncpy(myNodeInfo.pio_env, optstr(APP_ENV), sizeof(myNodeInfo.pio_env));
|
||||
myNodeInfo.nodedb_count = static_cast<uint16_t>(nodeDB->getNumMeshNodes());
|
||||
fromRadioScratch.my_info = myNodeInfo;
|
||||
state = STATE_SEND_UIDATA;
|
||||
|
||||
@ -686,7 +702,8 @@ bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p)
|
||||
LOG_WARN("Rate limit portnum %d", p.decoded.portnum);
|
||||
meshtastic_QueueStatus qs = router->getQueueStatus();
|
||||
service->sendQueueStatusToPhone(qs, 0, p.id);
|
||||
sendNotification(meshtastic_LogRecord_Level_WARNING, p.id, "Text messages can only be sent once every 2 seconds");
|
||||
service->sendRoutingErrorResponse(meshtastic_Routing_Error_RATE_LIMIT_EXCEEDED, &p);
|
||||
// sendNotification(meshtastic_LogRecord_Level_WARNING, p.id, "Text messages can only be sent once every 2 seconds");
|
||||
return false;
|
||||
}
|
||||
lastPortNumToRadio[p.decoded.portnum] = millis();
|
||||
|
@ -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,20 @@ 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.
|
||||
*/
|
||||
@ -320,8 +335,9 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
||||
{
|
||||
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
||||
std::string out = DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id,
|
||||
p->from, p->to, p->want_ack, p->hop_limit, p->channel);
|
||||
std::string out =
|
||||
DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, transport = %u, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id,
|
||||
p->from, p->to, p->transport_mechanism, p->want_ack, p->hop_limit, p->channel);
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
auto &s = p->decoded;
|
||||
|
||||
@ -650,8 +666,10 @@ void RadioInterface::limitPower(int8_t loraMaxPower)
|
||||
|
||||
void RadioInterface::deliverToReceiver(meshtastic_MeshPacket *p)
|
||||
{
|
||||
if (router)
|
||||
if (router) {
|
||||
p->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA;
|
||||
router->enqueueReceivedMessage(p);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -224,9 +224,10 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
||||
if (!config.lora.override_duty_cycle && myRegion->dutyCycle < 100) {
|
||||
float hourlyTxPercent = airTime->utilizationTXPercent();
|
||||
if (hourlyTxPercent > myRegion->dutyCycle) {
|
||||
#ifdef DEBUG_PORT
|
||||
uint8_t silentMinutes = airTime->getSilentMinutes(hourlyTxPercent, myRegion->dutyCycle);
|
||||
|
||||
LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d mins", silentMinutes);
|
||||
|
||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||
cn->has_reply_id = true;
|
||||
cn->reply_id = p->id;
|
||||
@ -234,7 +235,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
||||
cn->time = getValidTime(RTCQualityFromNet);
|
||||
sprintf(cn->message, "Duty cycle limit exceeded. You can send again in %d mins", silentMinutes);
|
||||
service->sendClientNotification(cn);
|
||||
#endif
|
||||
|
||||
meshtastic_Routing_Error err = meshtastic_Routing_Error_DUTY_CYCLE_LIMIT;
|
||||
if (isFromUs(p)) { // only send NAK to API, not to the mesh
|
||||
abortSendAndNak(err, p);
|
||||
@ -548,20 +549,6 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
numbytes += MESHTASTIC_PKC_OVERHEAD;
|
||||
p->channel = 0;
|
||||
p->pki_encrypted = true;
|
||||
|
||||
// warn the user about a low entropy key
|
||||
if (nodeDB->keyIsLowEntropy) {
|
||||
LOG_WARN(LOW_ENTROPY_WARNING);
|
||||
if (!nodeDB->hasWarned) {
|
||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||
cn->which_payload_variant = meshtastic_ClientNotification_low_entropy_key_tag;
|
||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||
cn->time = getValidTime(RTCQualityFromNet);
|
||||
sprintf(cn->message, LOW_ENTROPY_WARNING);
|
||||
service->sendClientNotification(cn);
|
||||
nodeDB->hasWarned = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (p->pki_encrypted == true) {
|
||||
// Client specifically requested PKI encryption
|
||||
@ -651,11 +638,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
shouldIgnoreNonstandardPorts = true;
|
||||
#endif
|
||||
if (shouldIgnoreNonstandardPorts && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
|
||||
IS_ONE_OF(p->decoded.portnum, meshtastic_PortNum_ATAK_FORWARDER, meshtastic_PortNum_ATAK_PLUGIN,
|
||||
meshtastic_PortNum_PAXCOUNTER_APP, meshtastic_PortNum_IP_TUNNEL_APP, meshtastic_PortNum_AUDIO_APP,
|
||||
meshtastic_PortNum_PRIVATE_APP, meshtastic_PortNum_DETECTION_SENSOR_APP, meshtastic_PortNum_RANGE_TEST_APP,
|
||||
meshtastic_PortNum_REMOTE_HARDWARE_APP)) {
|
||||
LOG_DEBUG("Ignore packet on blacklisted portnum for CORE_PORTNUMS_ONLY");
|
||||
!IS_ONE_OF(p->decoded.portnum, meshtastic_PortNum_TEXT_MESSAGE_APP, meshtastic_PortNum_TEXT_MESSAGE_COMPRESSED_APP,
|
||||
meshtastic_PortNum_POSITION_APP, meshtastic_PortNum_NODEINFO_APP, meshtastic_PortNum_ROUTING_APP,
|
||||
meshtastic_PortNum_TELEMETRY_APP, meshtastic_PortNum_ADMIN_APP, meshtastic_PortNum_ALERT_APP,
|
||||
meshtastic_PortNum_KEY_VERIFICATION_APP, meshtastic_PortNum_WAYPOINT_APP,
|
||||
meshtastic_PortNum_STORE_FORWARD_APP, meshtastic_PortNum_TRACEROUTE_APP)) {
|
||||
LOG_DEBUG("Ignore packet on non-standard portnum for CORE_PORTNUMS_ONLY");
|
||||
cancelSending(p->from, p->id);
|
||||
skipHandle = true;
|
||||
}
|
||||
@ -664,7 +652,8 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
}
|
||||
|
||||
// call modules here
|
||||
if (!skipHandle) {
|
||||
// If this could be a spoofed packet, don't let the modules see it.
|
||||
if (!skipHandle && p->from != nodeDB->getNodeNum()) {
|
||||
MeshModule::callModules(*p, src);
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||
@ -678,6 +667,8 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
!isFromUs(p) && mqtt)
|
||||
mqtt->onSend(*p_encrypted, *p, p->channel);
|
||||
#endif
|
||||
} else if (p->from == nodeDB->getNodeNum() && !skipHandle) {
|
||||
MeshModule::callModules(*p, src, ROUTING_MODULE);
|
||||
}
|
||||
|
||||
packetPool.release(p_encrypted); // Release the encrypted packet
|
||||
|
@ -59,6 +59,7 @@ bool PacketAPI::receivePacket(void)
|
||||
switch (mr->which_payload_variant) {
|
||||
case meshtastic_ToRadio_packet_tag: {
|
||||
meshtastic_MeshPacket *mp = &mr->packet;
|
||||
mp->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API;
|
||||
printPacket("PACKET FROM QUEUE", mp);
|
||||
service->handleToRadio(*mp);
|
||||
break;
|
||||
@ -70,7 +71,7 @@ bool PacketAPI::receivePacket(void)
|
||||
break;
|
||||
}
|
||||
case meshtastic_ToRadio_heartbeat_tag:
|
||||
if (mr->heartbeat.dummy_field == 1) {
|
||||
if (mr->heartbeat.nonce == 1) {
|
||||
if (nodeInfoModule) {
|
||||
LOG_INFO("Broadcasting nodeinfo ping");
|
||||
nodeInfoModule->sendOurNodeInfo(NODENUM_BROADCAST, true, 0, true);
|
||||
|
@ -17,7 +17,10 @@ void initApiServer(int port)
|
||||
}
|
||||
void deInitApiServer()
|
||||
{
|
||||
delete apiPort;
|
||||
if (apiPort) {
|
||||
delete apiPort;
|
||||
apiPort = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client)
|
||||
|
@ -68,6 +68,11 @@ static int32_t reconnectETH()
|
||||
initApiServer();
|
||||
}
|
||||
#endif
|
||||
#if HAS_UDP_MULTICAST
|
||||
if (udpHandler && config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) {
|
||||
udpHandler->start();
|
||||
}
|
||||
#endif
|
||||
|
||||
ethStartupComplete = true;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "configuration.h"
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
bool initEthernet();
|
||||
bool isEthernetAvailable();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user