mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-11 12:27:28 +00:00
Compare commits
112 Commits
v1.2.53.19
...
1.2-legacy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5b8c17dbf | ||
|
|
df3e3b747e | ||
|
|
c2a2ce0b4e | ||
|
|
0adc5ce3de | ||
|
|
1d5e079fa2 | ||
|
|
33fac6d0f5 | ||
|
|
8e8158ebbc | ||
|
|
a9fcc775d9 | ||
|
|
cf465a3d34 | ||
|
|
6520c51b66 | ||
|
|
98552b6d9d | ||
|
|
7f9c07ae37 | ||
|
|
bfd97558d4 | ||
|
|
44159f75f1 | ||
|
|
dfa9c32665 | ||
|
|
c600135b70 | ||
|
|
179a2624a1 | ||
|
|
3fded9aaa9 | ||
|
|
f423d943a8 | ||
|
|
f251727524 | ||
|
|
f3cc732e7d | ||
|
|
8d74c41802 | ||
|
|
89f7968ca2 | ||
|
|
3b2375a27b | ||
|
|
959962530b | ||
|
|
77816f8f68 | ||
|
|
ee8e544ce2 | ||
|
|
887e6fd761 | ||
|
|
d06aa73947 | ||
|
|
72bfee34ee | ||
|
|
fc48fcde96 | ||
|
|
f0965e2ac4 | ||
|
|
7c253bfc3c | ||
|
|
ba894ae95b | ||
|
|
9879494fc6 | ||
|
|
5088940751 | ||
|
|
888af31d4f | ||
|
|
3ddd74edf6 | ||
|
|
186d7f7d33 | ||
|
|
456f8ab7e8 | ||
|
|
d551c17546 | ||
|
|
af4027e8c8 | ||
|
|
3df0fdd239 | ||
|
|
8510ef3ad0 | ||
|
|
ee419f8b9b | ||
|
|
ab959ded0e | ||
|
|
2a76a5527a | ||
|
|
58d91f0a4b | ||
|
|
e09aafa13f | ||
|
|
aca95248ee | ||
|
|
d81c1c08ee | ||
|
|
317ce2c9cd | ||
|
|
b2827597fd | ||
|
|
6af182228c | ||
|
|
1246c7bb1e | ||
|
|
e6731e28c1 | ||
|
|
d57ac39b02 | ||
|
|
67bc6b1419 | ||
|
|
d328823c03 | ||
|
|
7178d3a2fd | ||
|
|
a0f60f1d07 | ||
|
|
b177313e2d | ||
|
|
53d47146b2 | ||
|
|
f7c6955736 | ||
|
|
9a87e1b53e | ||
|
|
f1478a7c93 | ||
|
|
8fd5d83980 | ||
|
|
5895aaa259 | ||
|
|
1787712a5a | ||
|
|
596a73c0a0 | ||
|
|
d56f8c631b | ||
|
|
682f988c2a | ||
|
|
ce20a2b566 | ||
|
|
d0fc836f0b | ||
|
|
d542267e4a | ||
|
|
756317e7e0 | ||
|
|
ab96579904 | ||
|
|
3f83acdbef | ||
|
|
9db7c62a49 | ||
|
|
d79dc631f1 | ||
|
|
7ea6babb7f | ||
|
|
0b4b901504 | ||
|
|
cc7b5cf136 | ||
|
|
e3df4fe4b4 | ||
|
|
288f2be8ea | ||
|
|
c867af8522 | ||
|
|
856f2f9589 | ||
|
|
e649bc84e1 | ||
|
|
bbcd59ec7b | ||
|
|
e11fd593ae | ||
|
|
868af9dd6b | ||
|
|
10800a6914 | ||
|
|
e567fe7322 | ||
|
|
365120e9c2 | ||
|
|
b21b7de04b | ||
|
|
dd31a829fb | ||
|
|
9a505c27fa | ||
|
|
ed9cd7b03d | ||
|
|
66413d8b7f | ||
|
|
e4fe2c159a | ||
|
|
f5e0718052 | ||
|
|
64ff48c4a5 | ||
|
|
50969c4e42 | ||
|
|
5288f1846a | ||
|
|
c545155b03 | ||
|
|
a4e9fca80c | ||
|
|
3611293a98 | ||
|
|
dc7f376778 | ||
|
|
ff2cad9cac | ||
|
|
b781fb613c | ||
|
|
0a1125d7e4 | ||
|
|
ed2de3b885 |
52
.github/workflows/main.yml
vendored
52
.github/workflows/main.yml
vendored
@@ -1,16 +1,8 @@
|
||||
name: Continuous Integration
|
||||
name: Continuous Integration (Legacy serial build)
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
push:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**.yml'
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
ci-check:
|
||||
@@ -21,6 +13,8 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Install cppcheck
|
||||
run: |
|
||||
@@ -60,6 +54,8 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
@@ -114,22 +110,23 @@ jobs:
|
||||
echo "Simulator started, launching python test..."
|
||||
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'
|
||||
|
||||
# - name: Build for tbeam
|
||||
# run: platformio run -e tbeam
|
||||
# - name: Build for heltec
|
||||
# run: platformio run -e heltec
|
||||
# - name: Build for wisblock RAK4631
|
||||
# run: platformio run -e rak4631
|
||||
- name: Cat bin/build-all.sh
|
||||
run: |
|
||||
cat bin/build-all.sh
|
||||
|
||||
- name: Build everything
|
||||
run: bin/build-all.sh
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
||||
id: version
|
||||
|
||||
- name: Store binaries as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: built
|
||||
path: release/archive/firmware-*.zip
|
||||
retention-days: 30
|
||||
name: firmware-${{ steps.version.outputs.version }}.zip
|
||||
path: release/archive/firmware-${{ steps.version.outputs.version }}.zip
|
||||
retention-days: 90
|
||||
|
||||
- name: Store debugging elf files as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
@@ -137,3 +134,18 @@ jobs:
|
||||
name: debug-elfs
|
||||
path: release/archive/elfs-*.zip
|
||||
retention-days: 7
|
||||
|
||||
- name: Download firmware.zip
|
||||
uses: actions/download-artifact@master
|
||||
with:
|
||||
name: firmware-${{ steps.version.outputs.version }}.zip
|
||||
path: ./
|
||||
|
||||
- name: Pull request artifacts
|
||||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }}
|
||||
uses: gavv/pull-request-artifacts@v1.0.0
|
||||
with:
|
||||
commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }}
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
artifacts-branch: artifacts
|
||||
artifacts: ./firmware-${{ steps.version.outputs.version }}.zip
|
||||
|
||||
349
.github/workflows/main_matrix.yml
vendored
Normal file
349
.github/workflows/main_matrix.yml
vendored
Normal file
@@ -0,0 +1,349 @@
|
||||
name: Continuous Integration PR Checks (1.2 Legacy)
|
||||
on:
|
||||
# # Triggers the workflow on push but only for the master branch
|
||||
push:
|
||||
branches: [ 1.2-legacy ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**.yml'
|
||||
- 'version.properties'
|
||||
|
||||
# Note: This is different from "pull_request". Need to specify ref when doing checkouts.
|
||||
pull_request_target:
|
||||
branches: [ 1.2-legacy ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '**.yml'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
check:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- board: rak11200
|
||||
- board: tlora-v2
|
||||
- board: tlora-v1
|
||||
- board: tlora_v1_3
|
||||
- board: tlora-v2-1-1.6
|
||||
- board: tbeam
|
||||
- board: heltec-v1
|
||||
- board: heltec-v2.0
|
||||
- board: heltec-v2.1
|
||||
- board: tbeam0.7
|
||||
- board: meshtastic-diy-v1
|
||||
- board: rak4631_5005
|
||||
- board: rak4631_19003
|
||||
- board: t-echo
|
||||
- board: nano-g1
|
||||
- board: meshtastic-dr-dev
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Install cppcheck
|
||||
run: |
|
||||
sudo apt-get install -y cppcheck
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Cache python libs
|
||||
uses: actions/cache@v1
|
||||
id: cache-pip # needed in if test
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip
|
||||
|
||||
- name: Upgrade python tools and install platformio
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio
|
||||
|
||||
- name: Upgrade platformio
|
||||
run: |
|
||||
pio upgrade
|
||||
|
||||
- name: Check ${{ matrix.board }}
|
||||
run: bin/check-all.sh ${{ matrix.board }}
|
||||
|
||||
after-checks:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
build-esp32:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- board: rak11200
|
||||
- board: tlora-v2
|
||||
- board: tlora-v1
|
||||
- board: tlora_v1_3
|
||||
- board: tlora-v2-1-1.6
|
||||
- board: tbeam
|
||||
- board: heltec-v1
|
||||
- board: heltec-v2.0
|
||||
- board: heltec-v2.1
|
||||
- board: tbeam0.7
|
||||
- board: meshtastic-diy-v1
|
||||
- board: nano-g1
|
||||
- board: meshtastic-dr-dev
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Cache python libs
|
||||
uses: actions/cache@v1
|
||||
id: cache-pip # needed in if test
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip
|
||||
|
||||
- name: Upgrade python tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio meshtastic adafruit-nrfutil
|
||||
|
||||
- name: Upgrade platformio
|
||||
run: |
|
||||
pio upgrade
|
||||
|
||||
- name: Pull web ui
|
||||
uses: dsaltares/fetch-gh-release-asset@master
|
||||
with:
|
||||
repo: "meshtastic/meshtastic-web"
|
||||
file: "build.tar"
|
||||
target: "build.tar"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Unpack web ui
|
||||
run: |
|
||||
tar -xf build.tar -C data/static
|
||||
rm build.tar
|
||||
|
||||
- name: Build ESP32
|
||||
run: bin/build-esp32.sh ${{ matrix.board }}
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
||||
id: version
|
||||
|
||||
- name: Store binaries as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip
|
||||
path: |
|
||||
release/*.bin
|
||||
release/*.elf
|
||||
retention-days: 90
|
||||
|
||||
build-nrf52:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- board: rak4631_5005
|
||||
- board: rak4631_19003
|
||||
- board: t-echo
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Cache python libs
|
||||
uses: actions/cache@v1
|
||||
id: cache-pip # needed in if test
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip
|
||||
|
||||
- name: Upgrade python tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio meshtastic adafruit-nrfutil
|
||||
|
||||
- name: Upgrade platformio
|
||||
run: |
|
||||
pio upgrade
|
||||
|
||||
- name: Build NRF52
|
||||
run: bin/build-nrf52.sh ${{ matrix.board }}
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
||||
id: version
|
||||
|
||||
- name: Store binaries as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip
|
||||
path: |
|
||||
release/*.uf2
|
||||
release/*.elf
|
||||
retention-days: 90
|
||||
|
||||
build-native:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Cache python libs
|
||||
uses: actions/cache@v1
|
||||
id: cache-pip # needed in if test
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip
|
||||
|
||||
- name: Upgrade python tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U platformio meshtastic adafruit-nrfutil
|
||||
|
||||
- name: Upgrade platformio
|
||||
run: |
|
||||
pio upgrade
|
||||
|
||||
# We now run integration test before other build steps (to quickly see runtime failures)
|
||||
- name: Build for native
|
||||
run: platformio run -e native
|
||||
- name: Integration test
|
||||
run: |
|
||||
.pio/build/native/program &
|
||||
sleep 20 # 5 seconds was not enough
|
||||
echo "Simulator started, launching python test..."
|
||||
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'
|
||||
|
||||
- name: Build Native
|
||||
run: bin/build-native.sh
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
||||
id: version
|
||||
|
||||
- name: Store binaries as an artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware-native-${{ steps.version.outputs.version }}.zip
|
||||
path: |
|
||||
release/meshtasticd_linux_amd64
|
||||
release/device-*.sh
|
||||
release/device-*.bat
|
||||
retention-days: 90
|
||||
|
||||
gather-artifacts:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-esp32, build-nrf52, build-native]
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
path: ./
|
||||
|
||||
- name: Get release version string
|
||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
||||
id: version
|
||||
|
||||
- name: Move files up
|
||||
run: mv -b -t ./ ./*tbeam-*/spiffs*.bin ./*tbeam-*/system-info.bin ./**/firmware*.bin ./**/*.uf2 ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat
|
||||
|
||||
- name: Repackage in single firmware zip
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware-${{ steps.version.outputs.version }}
|
||||
path: |
|
||||
./*.bin
|
||||
./*.uf2
|
||||
./meshtasticd_linux_amd64
|
||||
./device-*.sh
|
||||
./device-*.bat
|
||||
retention-days: 90
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: firmware-${{ steps.version.outputs.version }}
|
||||
path: ./output
|
||||
|
||||
# For diagnostics
|
||||
- name: Show artifacts
|
||||
run: ls -lR
|
||||
|
||||
- name: Zip firmware
|
||||
run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output
|
||||
|
||||
- name: Repackage in single elfs zip
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
||||
path: ./*.elf
|
||||
retention-days: 90
|
||||
|
||||
- name: Create request artifacts
|
||||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }}
|
||||
uses: gavv/pull-request-artifacts@v1.0.0
|
||||
with:
|
||||
commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }}
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
artifacts-token: ${{ secrets.ARTIFACTS_TOKEN }}
|
||||
artifacts-repo: meshtastic/artifacts
|
||||
artifacts-branch: device
|
||||
artifacts-dir: pr
|
||||
artifacts: ./firmware-${{ steps.version.outputs.version }}.zip
|
||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -1,13 +1,13 @@
|
||||
name: Make Release
|
||||
on:
|
||||
# Can optionally take parameters from the github UI, more info here https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/#:~:text=You%20can%20now%20create%20workflows,the%20workflow%20is%20run%20on.
|
||||
# workflow_dispatch:
|
||||
#workflow_dispatch:
|
||||
# inputs:
|
||||
|
||||
# Only want to run if version.properties is bumped in master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 1.2-legacy
|
||||
paths:
|
||||
- 'version.properties'
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,3 +29,4 @@ __pycache__
|
||||
|
||||
venv/
|
||||
release/
|
||||
.vscode/extensions.json
|
||||
|
||||
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -1,6 +1,7 @@
|
||||
[submodule "proto"]
|
||||
path = proto
|
||||
url = https://github.com/meshtastic/Meshtastic-protobufs.git
|
||||
branch = 1.2-legacy
|
||||
[submodule "sdk-nrfxlib"]
|
||||
path = sdk-nrfxlib
|
||||
url = https://github.com/nrfconnect/sdk-nrfxlib.git
|
||||
|
||||
10
README.md
10
README.md
@@ -3,9 +3,17 @@
|
||||
[](https://github.com/meshtastic/Meshtastic-device/actions/workflows/main.yml)
|
||||

|
||||
|
||||
This branch is End-of-Life.
|
||||
|
||||
Requires platformio = 6.0.0
|
||||
|
||||
Recommended to add "core_dir = .platformio" to your cloned platformio.ini and use python-virtualenv for compiling this branch. This will keep your system platformio and platform_packages separate.
|
||||
|
||||
# Old readme below #
|
||||
|
||||
## This repository contains the device firmware used in the [Meshtastic](https://meshtastic.org) project.
|
||||
|
||||
Update Instructions
|
||||
Update Instructions (docs have versioned up, may no longer apply)
|
||||
|
||||
[For ESP32 devices click here](https://meshtastic.org/docs/getting-started/flashing-esp32)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ set -e
|
||||
VERSION=`bin/buildinfo.py long`
|
||||
SHORT_VERSION=`bin/buildinfo.py short`
|
||||
|
||||
BOARDS_ESP32="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1"
|
||||
BOARDS_ESP32="rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 meshtastic-dr-dev"
|
||||
#BOARDS_ESP32=tbeam
|
||||
|
||||
# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine
|
||||
@@ -28,7 +28,7 @@ function do_build() {
|
||||
BOARD=$1
|
||||
isNrf=$3
|
||||
|
||||
echo "Building for $BOARD with $PLATFORMIO_BUILD_FLAGS"
|
||||
echo "Building for $BOARD ($isNrf) with $PLATFORMIO_BUILD_FLAGS"
|
||||
rm -f .pio/build/$BOARD/firmware.*
|
||||
|
||||
# The shell vars the build tool expects to find
|
||||
@@ -59,6 +59,7 @@ function do_boards() {
|
||||
declare isNrf=$2
|
||||
for board in $boards; do
|
||||
# Build universal
|
||||
echo "about to build $board $isNrf"
|
||||
do_build $board "" "$isNrf"
|
||||
done
|
||||
}
|
||||
|
||||
43
bin/build-esp32.sh
Executable file
43
bin/build-esp32.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
VERSION=`bin/buildinfo.py long`
|
||||
SHORT_VERSION=`bin/buildinfo.py short`
|
||||
|
||||
OUTDIR=release/
|
||||
|
||||
rm -f $OUTDIR/firmware*
|
||||
rm -r $OUTDIR/* || true
|
||||
|
||||
# Make sure our submodules are current
|
||||
git submodule update
|
||||
|
||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||
platformio lib update
|
||||
|
||||
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
||||
rm -f .pio/build/$1/firmware.*
|
||||
|
||||
# The shell vars the build tool expects to find
|
||||
export APP_VERSION=$VERSION
|
||||
|
||||
# Are we building a universal/regionless rom?
|
||||
export HW_VERSION="1.0"
|
||||
basename=firmware-$1-$VERSION
|
||||
|
||||
pio run --environment $1 # -v
|
||||
SRCELF=.pio/build/$1/firmware.elf
|
||||
cp $SRCELF $OUTDIR/$basename.elf
|
||||
|
||||
echo "Copying ESP32 bin file"
|
||||
SRCBIN=.pio/build/$1/firmware.bin
|
||||
cp $SRCBIN $OUTDIR/$basename.bin
|
||||
|
||||
echo "Building SPIFFS for ESP32 targets"
|
||||
pio run --environment tbeam -t buildfs
|
||||
cp .pio/build/tbeam/spiffs.bin $OUTDIR/spiffs-$VERSION.bin
|
||||
cp images/system-info.bin $OUTDIR/system-info.bin
|
||||
|
||||
cp bin/device-install.* $OUTDIR
|
||||
cp bin/device-update.* $OUTDIR
|
||||
26
bin/build-native.sh
Executable file
26
bin/build-native.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
VERSION=`bin/buildinfo.py long`
|
||||
SHORT_VERSION=`bin/buildinfo.py short`
|
||||
|
||||
OUTDIR=release/
|
||||
|
||||
rm -f $OUTDIR/firmware*
|
||||
|
||||
mkdir -p $OUTDIR/
|
||||
rm -r $OUTDIR/* || true
|
||||
|
||||
# Make sure our submodules are current
|
||||
git submodule update
|
||||
|
||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||
platformio lib update
|
||||
|
||||
pio run --environment native
|
||||
cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64
|
||||
|
||||
cp bin/device-install.* $OUTDIR
|
||||
cp bin/device-update.* $OUTDIR
|
||||
|
||||
37
bin/build-nrf52.sh
Executable file
37
bin/build-nrf52.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
VERSION=`bin/buildinfo.py long`
|
||||
SHORT_VERSION=`bin/buildinfo.py short`
|
||||
|
||||
OUTDIR=release/
|
||||
|
||||
rm -f $OUTDIR/firmware*
|
||||
rm -r $OUTDIR/* || true
|
||||
|
||||
# Make sure our submodules are current
|
||||
git submodule update
|
||||
|
||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||
platformio lib update
|
||||
|
||||
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
||||
rm -f .pio/build/$1/firmware.*
|
||||
|
||||
# The shell vars the build tool expects to find
|
||||
export APP_VERSION=$VERSION
|
||||
|
||||
export HW_VERSION="1.0"
|
||||
basename=firmware-$1-$VERSION
|
||||
|
||||
pio run --environment $1 # -v
|
||||
SRCELF=.pio/build/$1/firmware.elf
|
||||
cp $SRCELF $OUTDIR/$basename.elf
|
||||
|
||||
echo "Generating NRF52 uf2 file"
|
||||
SRCHEX=.pio/build/$1/firmware.hex
|
||||
bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840
|
||||
|
||||
cp bin/device-install.* $OUTDIR
|
||||
cp bin/device-update.* $OUTDIR
|
||||
@@ -11,12 +11,12 @@ export APP_VERSION=$VERSION
|
||||
|
||||
if [[ $# -gt 0 ]]; then
|
||||
# can override which environment by passing arg
|
||||
BOARDS="-e $@"
|
||||
BOARDS="$@"
|
||||
else
|
||||
BOARDS="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 rak4631_5005 rak4631_19003 t-echo"
|
||||
BOARDS="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 rak4631_5005 rak4631_19003 rak11200 t-echo"
|
||||
fi
|
||||
|
||||
#echo "BOARDS:${BOARDS}"
|
||||
echo "BOARDS:${BOARDS}"
|
||||
|
||||
CHECK=""
|
||||
for BOARD in $BOARDS; do
|
||||
|
||||
39
boards/wiscore_rak11200.json
Normal file
39
boards/wiscore_rak11200.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DARDUINO_ESP32_DEV",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
"variant": "WisCore_RAK11200_Board"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"ethernet",
|
||||
"can"
|
||||
],
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "WisCore RAK11200 Board",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"protocols": [
|
||||
"esptool",
|
||||
"espota",
|
||||
"ftdi"
|
||||
],
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.rakwireless.com",
|
||||
"vendor": "RAKwireless"
|
||||
}
|
||||
@@ -23,10 +23,13 @@ default_envs = tbeam
|
||||
;default_envs = t-echo
|
||||
;default_envs = nrf52840dk-geeksville
|
||||
;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
|
||||
;default_envs = rak4631
|
||||
;default_envs = rak4630
|
||||
;default_envs = rak4631_5005
|
||||
;default_envs = rak4631_5005_eink
|
||||
;default_envs = rak4631_19003
|
||||
;default_envs = nano-g1
|
||||
;default_envs = meshtastic-diy-v1
|
||||
;default_envs = meshtastic-diy-v1.1
|
||||
;default_envs = meshtastic-dr-dev
|
||||
|
||||
; board specific config can be moved to the respective 'variants' file.
|
||||
; See https://docs.platformio.org/en/latest/projectconf/section_platformio.html#extra-configs
|
||||
@@ -78,12 +81,11 @@ debug_tool = jlink
|
||||
|
||||
lib_deps =
|
||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git#d90231dedbb2f52bd7a32fb8ed8edec52cf4a8cb ; ESP8266_SSD1306
|
||||
https://github.com/meshtastic/OneButton.git#3bcba9492d01e2a8a86f46700ab16f96dd2cf1f5 ; OneButton library for non-blocking button debounce
|
||||
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
||||
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
||||
https://github.com/meshtastic/arduino-fsm.git
|
||||
https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git#31015a55e630a2df77d9d714669c621a5bf355ad
|
||||
https://github.com/meshtastic/RadioLib.git#5582ac30578ff3f53f20630a00b2a8a4b8f92c74
|
||||
https://github.com/meshtastic/TinyGPSPlus.git#f0f47067ef2f67c856475933188251c1ef615e79
|
||||
https://github.com/meshtastic/TinyGPSPlus.git
|
||||
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
||||
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
||||
SPI
|
||||
@@ -105,7 +107,7 @@ lib_deps =
|
||||
build_flags = ${env.build_flags} -Os
|
||||
# -DRADIOLIB_GODMODE
|
||||
|
||||
src_filter = ${env.src_filter} -<portduino/>
|
||||
build_src_filter = ${env.build_src_filter} -<portduino/>
|
||||
|
||||
; Common libs for environmental measurements (not included in native / portduino)
|
||||
[environmental]
|
||||
@@ -116,13 +118,14 @@ lib_deps =
|
||||
robtillaart/DS18B20@^0.1.11
|
||||
adafruit/Adafruit BME280 Library@^2.2.2
|
||||
adafruit/Adafruit BME680 Library@^2.0.1
|
||||
adafruit/Adafruit MCP9808 Library@^2.0.0
|
||||
|
||||
; Common settings for ESP targes, mixin with extends = esp32_base
|
||||
[esp32_base]
|
||||
extends = arduino_base
|
||||
platform = espressif32
|
||||
src_filter =
|
||||
${arduino_base.src_filter} -<nrf52/>
|
||||
platform = espressif32@3.5.0
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<nrf52/>
|
||||
upload_speed = 921600
|
||||
debug_init_break = tbreak setup
|
||||
|
||||
@@ -136,9 +139,9 @@ build_flags =
|
||||
lib_deps =
|
||||
${arduino_base.lib_deps}
|
||||
${environmental.lib_deps}
|
||||
https://github.com/meshtastic/esp32_https_server.git
|
||||
h2zero/NimBLE-Arduino@1.3.4
|
||||
tobozo/ESP32-targz@^1.1.4
|
||||
https://github.com/lewisxhe/esp32_https_server.git#6900520645c0e974eefcc699b659fa481a36b870
|
||||
h2zero/NimBLE-Arduino@1.3.6
|
||||
https://github.com/tobozo/ESP32-targz#1.1.4
|
||||
arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a
|
||||
|
||||
# Hmm - this doesn't work yet
|
||||
@@ -176,8 +179,8 @@ board_build.partitions = partition-table.csv
|
||||
;board = cubecell_board_plus
|
||||
; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO
|
||||
;build_flags = ${arduino_base.build_flags} -DARDUINO=100 -Isrc/cubecell
|
||||
;src_filter =
|
||||
; ${arduino_base.src_filter} -<esp32/> -<nrf52/>
|
||||
;build_src_filter =
|
||||
; ${arduino_base.build_src_filter} -<esp32/> -<nrf52/>
|
||||
|
||||
; Common settings for NRF52 based targets
|
||||
[nrf52_base]
|
||||
@@ -192,8 +195,8 @@ build_flags =
|
||||
-Isrc/nrf52
|
||||
-Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.7
|
||||
;-DCFG_DEBUG=3
|
||||
src_filter =
|
||||
${arduino_base.src_filter} -<esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<plugins/esp32> -<mqtt/>
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<plugins/esp32> -<mqtt/>
|
||||
lib_ignore =
|
||||
BluetoothOTA
|
||||
; monitor_port = /dev/ttyACM1
|
||||
@@ -261,6 +264,3 @@ upload_protocol = jlink
|
||||
monitor_port = /dev/ttyUSB0
|
||||
; this board's serial chip can only run at 115200, not faster
|
||||
monitor_speed = 115200
|
||||
|
||||
# For experimenting with RAM sizes
|
||||
# board_build.ldscript = linker/nrf52840_s140_sim832.ld
|
||||
|
||||
2
proto
2
proto
Submodule proto updated: 07ed86d8b4...f1476bf2f6
@@ -63,7 +63,9 @@ class GPSStatus : public Status
|
||||
|
||||
int32_t getLatitude() const {
|
||||
if (radioConfig.preferences.fixed_position){
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed latitude\n");
|
||||
#endif
|
||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||
return node->position.latitude_i;
|
||||
} else {
|
||||
@@ -73,7 +75,9 @@ class GPSStatus : public Status
|
||||
|
||||
int32_t getLongitude() const {
|
||||
if (radioConfig.preferences.fixed_position){
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed longitude\n");
|
||||
#endif
|
||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||
return node->position.longitude_i;
|
||||
} else {
|
||||
@@ -83,7 +87,9 @@ class GPSStatus : public Status
|
||||
|
||||
int32_t getAltitude() const {
|
||||
if (radioConfig.preferences.fixed_position){
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("WARNING: Using fixed altitude\n");
|
||||
#endif
|
||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||
return node->position.altitude;
|
||||
} else {
|
||||
@@ -99,7 +105,7 @@ class GPSStatus : public Status
|
||||
|
||||
bool matches(const GPSStatus *newStatus) const
|
||||
{
|
||||
#if GPS_EXTRAVERBOSE
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("GPSStatus.match() new pos@%x to old pos@%x\n",
|
||||
newStatus->p.pos_timestamp, p.pos_timestamp);
|
||||
#endif
|
||||
|
||||
@@ -100,6 +100,10 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
||||
#ifndef ADC_MULTIPLIER
|
||||
#define ADC_MULTIPLIER 2.0
|
||||
#endif
|
||||
// Override variant or default ADC_MULTIPLIER if we have the override pref
|
||||
float operativeAdcMultiplier = radioConfig.preferences.adc_multiplier_override > 0 ?
|
||||
radioConfig.preferences.adc_multiplier_override :
|
||||
ADC_MULTIPLIER;
|
||||
|
||||
#ifdef BATTERY_PIN
|
||||
// Do not call analogRead() often.
|
||||
@@ -109,7 +113,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
||||
uint32_t raw = analogRead(BATTERY_PIN);
|
||||
float scaled;
|
||||
#ifndef VBAT_RAW_TO_SCALED
|
||||
scaled = 1000.0 * ADC_MULTIPLIER * (AREF_VOLTAGE / 1024.0) * raw;
|
||||
scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw;
|
||||
#else
|
||||
scaled = VBAT_RAW_TO_SCALED(raw); //defined in variant.h
|
||||
#endif
|
||||
|
||||
@@ -279,6 +279,12 @@ void PowerFSM_setup()
|
||||
powerFSM.add_transition(&stateON, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown");
|
||||
powerFSM.add_transition(&stateSERIAL, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown");
|
||||
|
||||
// Inputbroker
|
||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_INPUT, NULL, "Input Device");
|
||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_INPUT, NULL, "Input Device");
|
||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_INPUT, NULL, "Input Device");
|
||||
powerFSM.add_transition(&stateON, &stateON, EVENT_INPUT, NULL, "Input Device"); // restarts the sleep timer
|
||||
|
||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing");
|
||||
powerFSM.add_transition(&stateON, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing");
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define EVENT_POWER_DISCONNECTED 14
|
||||
#define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone
|
||||
#define EVENT_SHUTDOWN 16 //force a full shutdown now (not just sleep)
|
||||
#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen
|
||||
|
||||
extern Fsm powerFSM;
|
||||
extern State statePOWER, stateSERIAL;
|
||||
|
||||
@@ -114,6 +114,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TTGO_T_ECHO
|
||||
#define GPS_UBLOX
|
||||
#endif
|
||||
|
||||
//
|
||||
// Standard definitions for !ESP32 targets
|
||||
//
|
||||
@@ -149,6 +153,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define GPS_BAUDRATE 9600
|
||||
|
||||
#ifndef GPS_THREAD_INTERVAL
|
||||
#define GPS_THREAD_INTERVAL 100
|
||||
#endif
|
||||
|
||||
#if defined(TBEAM_V10)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_TBEAM
|
||||
@@ -161,6 +169,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_DIY_V1
|
||||
|
||||
#elif defined(DR_DEV)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_DR_DEV
|
||||
|
||||
#elif defined(RAK_11200)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_RAK11200
|
||||
|
||||
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
||||
|
||||
#ifdef HELTEC_V2_0
|
||||
@@ -199,6 +215,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
||||
|
||||
#elif defined(PRIVATE_HW)
|
||||
// This string must exactly match the case used in release file names or the android updater won't work
|
||||
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_NRF52840_PCA10056
|
||||
@@ -222,6 +242,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define HW_VENDOR HardwareModel_T_ECHO
|
||||
|
||||
#elif defined(NANO_G1)
|
||||
|
||||
#define HW_VENDOR HardwareModel_NANO_G1
|
||||
|
||||
#elif NRF52_SERIES
|
||||
|
||||
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
||||
@@ -234,4 +258,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "variant.h"
|
||||
#include "RF95Configuration.h"
|
||||
#include "DebugConfiguration.h"
|
||||
#include "DebugConfiguration.h"
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#include "configuration.h"
|
||||
#include "Air530GPS.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
Helpful translations from the Air530 GPS datasheet
|
||||
|
||||
Sat acquision mode
|
||||
捕获电流值@3.3v 42.6 mA
|
||||
|
||||
sat tracking mode
|
||||
跟踪电流值@3.3v 36.7 mA
|
||||
|
||||
Low power mode
|
||||
低功耗模式@3.3V 0.85 mA
|
||||
(发送指令:$PGKC051,0)
|
||||
|
||||
Super low power mode
|
||||
超低功耗模式@3.3V 31 uA
|
||||
(发送指令:$PGKC105,4)
|
||||
|
||||
To exit sleep use WAKE pin
|
||||
|
||||
Commands to enter sleep
|
||||
6、Command: 105
|
||||
进入周期性低功耗模式
|
||||
Arguments:
|
||||
|
||||
Arg1: “0”,正常运行模式 (normal mode)
|
||||
“1”,周期超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (periodic low power tracking mode - keeps sat positions, use wake to wake up)
|
||||
“2”,周期低功耗模式 (periodic low power mode)
|
||||
“4”,直接进入超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (super low power consumption mode immediately, need WAKE to resume)
|
||||
“8”,自动低功耗模式,可以通过串口唤醒 (automatic low power mode, wake by sending characters to serial port)
|
||||
“9”, 自动超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (automatic low power tracking when possible, need wake pin to resume)
|
||||
|
||||
(Arg 2 & 3 only valid if Arg1 is "1" or "2")
|
||||
Arg2:运行时间(毫秒),在 Arg1 为 1、2 的周期模式下,此参数起作用
|
||||
ON time in msecs
|
||||
|
||||
Arg3:睡眠时间(毫秒),在 Arg1 为 1、2 的周期模式下,此参数起作用
|
||||
Sleep time in msecs
|
||||
|
||||
Example:
|
||||
$PGKC105,8*3F<CR><LF>
|
||||
This will set automatic low power mode with waking when we send chars to the serial port. Possibly do this as soon as we get a
|
||||
new location. When we wake again in a minute we send a character to wake up.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void Air530GPS::sendCommand(const char *cmd) {
|
||||
uint8_t sum = 0;
|
||||
|
||||
// Skip the $
|
||||
assert(cmd[0] == '$');
|
||||
const char *p = cmd + 1;
|
||||
while(*p)
|
||||
sum ^= *p++;
|
||||
|
||||
assert(_serial_gps);
|
||||
|
||||
_serial_gps->write(cmd);
|
||||
_serial_gps->printf("*%02x\r\n", sum);
|
||||
|
||||
// DEBUG_MSG("xsum %02x\n", sum);
|
||||
}
|
||||
|
||||
void Air530GPS::sleep() {
|
||||
NMEAGPS::sleep();
|
||||
#ifdef PIN_GPS_WAKE
|
||||
sendCommand("$PGKC105,4");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// wake the GPS into normal operation mode
|
||||
void Air530GPS::wake()
|
||||
{
|
||||
#if 1
|
||||
NMEAGPS::wake();
|
||||
#else
|
||||
// For power testing - keep GPS sleeping forever
|
||||
sleep();
|
||||
#endif
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "NMEAGPS.h"
|
||||
|
||||
/**
|
||||
* A gps class thatreads from a NMEA GPS stream (and FIXME - eventually keeps the gps powered down except when reading)
|
||||
*
|
||||
* When new data is available it will notify observers.
|
||||
*/
|
||||
class Air530GPS : public NMEAGPS
|
||||
{
|
||||
protected:
|
||||
/// If possible force the GPS into sleep/low power mode
|
||||
virtual void sleep() override;
|
||||
|
||||
/// wake the GPS into normal operation mode
|
||||
virtual void wake() override;
|
||||
|
||||
private:
|
||||
/// Send a NMEA cmd with checksum
|
||||
void sendCommand(const char *str);
|
||||
};
|
||||
178
src/gps/GPS.cpp
178
src/gps/GPS.cpp
@@ -16,18 +16,49 @@ HardwareSerial *GPS::_serial_gps = &Serial1;
|
||||
HardwareSerial *GPS::_serial_gps = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef GPS_I2C_ADDRESS
|
||||
uint8_t GPS::i2cAddress = GPS_I2C_ADDRESS;
|
||||
#else
|
||||
uint8_t GPS::i2cAddress = 0;
|
||||
#endif
|
||||
|
||||
GPS *gps;
|
||||
|
||||
/// Multiple GPS instances might use the same serial port (in sequence), but we can
|
||||
/// only init that port once.
|
||||
static bool didSerialInit;
|
||||
|
||||
bool GPS::getACK(uint8_t c, uint8_t i) {
|
||||
uint8_t b;
|
||||
uint8_t ack = 0;
|
||||
const uint8_t ackP[2] = {c, i};
|
||||
uint8_t buf[10] = {0xB5, 0x62, 0x05, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
unsigned long startTime = millis();
|
||||
|
||||
for (int j = 2; j < 6; j++) {
|
||||
buf[8] += buf[j];
|
||||
buf[9] += buf[8];
|
||||
}
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
buf[6 + j] = ackP[j];
|
||||
buf[8] += buf[6 + j];
|
||||
buf[9] += buf[8];
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (ack > 9) {
|
||||
return true;
|
||||
}
|
||||
if (millis() - startTime > 1000) {
|
||||
return false;
|
||||
}
|
||||
if (_serial_gps->available()) {
|
||||
b = _serial_gps->read();
|
||||
if (b == buf[ack]) {
|
||||
ack++;
|
||||
}
|
||||
else {
|
||||
ack = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GPS::setupGPS()
|
||||
{
|
||||
if (_serial_gps && !didSerialInit) {
|
||||
@@ -41,6 +72,96 @@ bool GPS::setupGPS()
|
||||
#endif
|
||||
#ifndef NO_ESP32
|
||||
_serial_gps->setRxBufferSize(2048); // the default is 256
|
||||
#endif
|
||||
#ifdef TTGO_T_ECHO
|
||||
// Switch to 9600 baud, then close and reopen port
|
||||
_serial_gps->end();
|
||||
delay(250);
|
||||
_serial_gps->begin(4800);
|
||||
delay(250);
|
||||
_serial_gps->write("$PCAS01,1*1D\r\n");
|
||||
delay(250);
|
||||
_serial_gps->end();
|
||||
delay(250);
|
||||
_serial_gps->begin(9600);
|
||||
delay(250);
|
||||
// Initialize the L76K Chip, use GPS + GLONASS
|
||||
_serial_gps->write("$PCAS04,5*1C\r\n");
|
||||
delay(250);
|
||||
// only ask for RMC and GGA
|
||||
_serial_gps->write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n");
|
||||
delay(250);
|
||||
// Switch to Vehicle Mode, since SoftRF enables Aviation < 2g
|
||||
_serial_gps->write("$PCAS11,3*1E\r\n");
|
||||
delay(250);
|
||||
#endif
|
||||
#ifdef GPS_UBLOX
|
||||
delay(250);
|
||||
// Set the UART port to output NMEA only
|
||||
byte _message_nmea[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x91, 0xAF};
|
||||
_serial_gps->write(_message_nmea,sizeof(_message_nmea));
|
||||
if (!getACK(0x06, 0x00)) {
|
||||
DEBUG_MSG("WARNING: Unable to enable NMEA Mode.\n");
|
||||
return true;
|
||||
}
|
||||
// disable GGL
|
||||
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x05,0x3A};
|
||||
_serial_gps->write(_message_GGL,sizeof(_message_GGL));
|
||||
if (!getACK(0x06, 0x01)) {
|
||||
DEBUG_MSG("WARNING: Unable to disable NMEA GGL.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// disable GSA
|
||||
byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x06,0x41};
|
||||
_serial_gps->write(_message_GSA,sizeof(_message_GSA));
|
||||
if (!getACK(0x06, 0x01)) {
|
||||
DEBUG_MSG("WARNING: Unable to disable NMEA GSA.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// disable GSV
|
||||
byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x03, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x07,0x48};
|
||||
_serial_gps->write(_message_GSV,sizeof(_message_GSV));
|
||||
if (!getACK(0x06, 0x01)) {
|
||||
DEBUG_MSG("WARNING: Unable to disable NMEA GSV.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// disable VTG
|
||||
byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x09,0x56};
|
||||
_serial_gps->write(_message_VTG,sizeof(_message_VTG));
|
||||
if (!getACK(0x06, 0x01)) {
|
||||
DEBUG_MSG("WARNING: Unable to disable NMEA VTG.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// enable RMC
|
||||
byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x09,0x54};
|
||||
_serial_gps->write(_message_RMC,sizeof(_message_RMC));
|
||||
if (!getACK(0x06, 0x01)) {
|
||||
DEBUG_MSG("WARNING: Unable to enable NMEA RMC.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// enable GGA
|
||||
byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00,
|
||||
0xF0, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x05, 0x38};
|
||||
_serial_gps->write(_message_GGA,sizeof(_message_GGA));
|
||||
if (!getACK(0x06, 0x01)) DEBUG_MSG("WARNING: Unable to enable NMEA GGA.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -51,7 +172,7 @@ bool GPS::setup()
|
||||
{
|
||||
// Master power for the GPS
|
||||
#ifdef PIN_GPS_EN
|
||||
digitalWrite(PIN_GPS_EN, PIN_GPS_EN);
|
||||
digitalWrite(PIN_GPS_EN, 1);
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
#endif
|
||||
|
||||
@@ -82,6 +203,11 @@ GPS::~GPS()
|
||||
|
||||
bool GPS::hasLock() { return hasValidLocation; }
|
||||
|
||||
bool GPS::hasFlow()
|
||||
{
|
||||
return hasGPS;
|
||||
}
|
||||
|
||||
// Allow defining the polarity of the WAKE output. default is active high
|
||||
#ifndef GPS_WAKE_ACTIVE
|
||||
#define GPS_WAKE_ACTIVE 1
|
||||
@@ -218,6 +344,15 @@ int32_t GPS::runOnce()
|
||||
if (whileIdle()) {
|
||||
// if we have received valid NMEA claim we are connected
|
||||
setConnected();
|
||||
} else {
|
||||
#ifdef GPS_UBLOX
|
||||
// reset the GPS on next bootup
|
||||
if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
|
||||
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
|
||||
devicestate.did_gps_reset = false;
|
||||
nodeDB.saveToDisk();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// If we are overdue for an update, turn on the GPS and at least publish the current status
|
||||
@@ -257,7 +392,6 @@ int32_t GPS::runOnce()
|
||||
bool tooLong = wakeTime != UINT32_MAX && (now - lastWakeStartMsec) > wakeTime;
|
||||
|
||||
// Once we get a location we no longer desperately want an update
|
||||
// or if we got a time and we are in GpsOpTimeOnly mode
|
||||
// DEBUG_MSG("gotLoc %d, tooLong %d, gotTime %d\n", gotLoc, tooLong, gotTime);
|
||||
if ((gotLoc && gotTime) || tooLong || (gotTime && getGpsOp() == GpsOperation_GpsOpTimeOnly)) {
|
||||
|
||||
@@ -280,7 +414,7 @@ int32_t GPS::runOnce()
|
||||
|
||||
// 9600bps is approx 1 byte per msec, so considering our buffer size we never need to wake more often than 200ms
|
||||
// if not awake we can run super infrquently (once every 5 secs?) to see if we need to wake.
|
||||
return isAwake ? 100 : 5000;
|
||||
return isAwake ? GPS_THREAD_INTERVAL : 5000;
|
||||
}
|
||||
|
||||
void GPS::forceWake(bool on)
|
||||
@@ -318,13 +452,7 @@ int GPS::prepareDeepSleep(void *unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef GPS_TX_PIN
|
||||
#include "UBloxGPS.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_AIR530_GPS
|
||||
#include "Air530GPS.h"
|
||||
#elif !defined(NO_GPS)
|
||||
#ifndef NO_GPS
|
||||
#include "NMEAGPS.h"
|
||||
#endif
|
||||
|
||||
@@ -339,29 +467,11 @@ GPS *createGps()
|
||||
#else
|
||||
DEBUG_MSG("Using MSL altitude model\n");
|
||||
#endif
|
||||
// If we don't have bidirectional comms, we can't even try talking to UBLOX
|
||||
#ifdef GPS_TX_PIN
|
||||
// Init GPS - first try ublox
|
||||
UBloxGPS *ublox = new UBloxGPS();
|
||||
|
||||
if (!ublox->setup()) {
|
||||
DEBUG_MSG("ERROR: No UBLOX GPS found\n");
|
||||
delete ublox;
|
||||
ublox = NULL;
|
||||
} else {
|
||||
return ublox;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GPS::_serial_gps) {
|
||||
// Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just
|
||||
// assume NMEA at 9600 baud.
|
||||
DEBUG_MSG("Hoping that NMEA might work\n");
|
||||
#ifdef HAS_AIR530_GPS
|
||||
GPS *new_gps = new Air530GPS();
|
||||
#else
|
||||
GPS *new_gps = new NMEAGPS();
|
||||
#endif
|
||||
new_gps->setup();
|
||||
return new_gps;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,6 @@ class GPS : private concurrency::OSThread
|
||||
/** If !NULL we will use this serial port to construct our GPS */
|
||||
static HardwareSerial *_serial_gps;
|
||||
|
||||
/** If !0 we will attempt to connect to the GPS over I2C */
|
||||
static uint8_t i2cAddress;
|
||||
|
||||
Position p = Position_init_default;
|
||||
|
||||
GPS() : concurrency::OSThread("GPS") {}
|
||||
@@ -60,6 +57,9 @@ class GPS : private concurrency::OSThread
|
||||
/// Returns true if we have acquired GPS lock.
|
||||
virtual bool hasLock();
|
||||
|
||||
/// Returns true if there's valid data flow with the chip.
|
||||
virtual bool hasFlow();
|
||||
|
||||
/// Return true if we are connected to a GPS
|
||||
bool isConnected() const { return hasGPS; }
|
||||
|
||||
@@ -140,6 +140,8 @@ class GPS : private concurrency::OSThread
|
||||
|
||||
GpsOperation getGpsOp() const;
|
||||
|
||||
bool getACK(uint8_t c, uint8_t i);
|
||||
|
||||
/**
|
||||
* Tell users we have new GPS readings
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <TinyGPS++.h>
|
||||
|
||||
// GPS solutions older than this will be rejected - see TinyGPSDatum::age()
|
||||
#define GPS_SOL_EXPIRY_MS 300 // in millis
|
||||
#define GPS_SOL_EXPIRY_MS 5000 // in millis. give 1 second time to combine different sentences. NMEA Frequency isn't higher anyway
|
||||
#define NMEA_MSG_GXGSA "GNGSA" // GSA message (GPGSA, GNGSA etc)
|
||||
|
||||
static int32_t toDegInt(RawDegrees d)
|
||||
@@ -17,6 +17,19 @@ static int32_t toDegInt(RawDegrees d)
|
||||
return r;
|
||||
}
|
||||
|
||||
bool NMEAGPS::factoryReset()
|
||||
{
|
||||
#ifdef GPS_UBLOX
|
||||
// Factory Reset
|
||||
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF,
|
||||
0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
|
||||
_serial_gps->write(_message_reset,sizeof(_message_reset));
|
||||
delay(1000);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NMEAGPS::setupGPS()
|
||||
{
|
||||
GPS::setupGPS();
|
||||
@@ -64,11 +77,12 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
|
||||
t.tm_mon = d.month() - 1;
|
||||
t.tm_year = d.year() - 1900;
|
||||
t.tm_isdst = false;
|
||||
DEBUG_MSG("NMEA GPS time %d\n", t.tm_sec);
|
||||
|
||||
perhapsSetRTC(RTCQualityGPS, t);
|
||||
|
||||
return true;
|
||||
if (t.tm_mon > -1){
|
||||
DEBUG_MSG("NMEA GPS time %02d-%02d-%02d %02d:%02d:%02d\n", d.year(), d.month(), t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
|
||||
perhapsSetRTC(RTCQualityGPS, t);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@@ -116,7 +130,7 @@ bool NMEAGPS::lookForLocation()
|
||||
(reader.time.age() < GPS_SOL_EXPIRY_MS) &&
|
||||
(reader.date.age() < GPS_SOL_EXPIRY_MS)))
|
||||
{
|
||||
DEBUG_MSG("SOME data is TOO OLD\n");
|
||||
DEBUG_MSG("SOME data is TOO OLD: LOC %u, TIME %u, DATE %u\n", reader.location.age(), reader.time.age(), reader.date.age());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,10 +141,17 @@ bool NMEAGPS::lookForLocation()
|
||||
// We know the solution is fresh and valid, so just read the data
|
||||
auto loc = reader.location.value();
|
||||
|
||||
// Some GPSes (Air530) seem to send a zero longitude when the current fix is bogus
|
||||
// Bail out EARLY to avoid overwriting previous good data (like #857)
|
||||
if(toDegInt(loc.lat) == 0) {
|
||||
DEBUG_MSG("Ignoring bogus NMEA position\n");
|
||||
if (toDegInt(loc.lat) > 900000000) {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("Bail out EARLY on LAT %i\n",toDegInt(loc.lat));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if (toDegInt(loc.lng) > 1800000000) {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("Bail out EARLY on LNG %i\n",toDegInt(loc.lng));
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -214,6 +235,10 @@ bool NMEAGPS::hasLock()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NMEAGPS::hasFlow()
|
||||
{
|
||||
return reader.passedChecksum() > 0;
|
||||
}
|
||||
|
||||
bool NMEAGPS::whileIdle()
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@ class NMEAGPS : public GPS
|
||||
public:
|
||||
virtual bool setupGPS() override;
|
||||
|
||||
virtual bool factoryReset() override;
|
||||
|
||||
protected:
|
||||
/** Subclasses should look for serial rx characters here and feed it to their GPS parser
|
||||
*
|
||||
@@ -49,4 +51,6 @@ class NMEAGPS : public GPS
|
||||
virtual bool lookForLocation() override;
|
||||
|
||||
virtual bool hasLock() override;
|
||||
|
||||
virtual bool hasFlow() override;
|
||||
};
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
#include "configuration.h"
|
||||
#include "UBloxGPS.h"
|
||||
#include "RTC.h"
|
||||
#include "error.h"
|
||||
#include "sleep.h"
|
||||
#include <assert.h>
|
||||
|
||||
// if gps_update_interval below this value, do not powercycle the GPS
|
||||
#define UBLOX_POWEROFF_THRESHOLD 90
|
||||
|
||||
#define PDOP_INVALID 9999
|
||||
|
||||
// #define UBX_MODE_NMEA
|
||||
|
||||
extern RadioConfig radioConfig;
|
||||
|
||||
UBloxGPS::UBloxGPS() {}
|
||||
|
||||
bool UBloxGPS::tryConnect()
|
||||
{
|
||||
bool c = false;
|
||||
|
||||
if (_serial_gps)
|
||||
c = ublox.begin(*_serial_gps);
|
||||
|
||||
if (!c && i2cAddress) {
|
||||
extern bool neo6M; // Super skanky - if we are talking to the device i2c we assume it is a neo7 on a RAK815, which
|
||||
// supports the newer API
|
||||
neo6M = true;
|
||||
|
||||
c = ublox.begin(Wire, i2cAddress);
|
||||
}
|
||||
|
||||
if (c)
|
||||
setConnected();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
bool UBloxGPS::setupGPS()
|
||||
{
|
||||
GPS::setupGPS();
|
||||
|
||||
// uncomment to see debug info
|
||||
// ublox.enableDebugging(Serial);
|
||||
|
||||
// try a second time, the ublox lib serial parsing is buggy?
|
||||
// see https://github.com/meshtastic/Meshtastic-device/issues/376
|
||||
for (int i = 0; (i < 3) && !tryConnect(); i++)
|
||||
delay(500);
|
||||
|
||||
if (isConnected()) {
|
||||
#ifdef UBX_MODE_NMEA
|
||||
DEBUG_MSG("Connected to UBLOX GPS, downgrading to NMEA mode\n");
|
||||
DEBUG_MSG("- GPS errors below are related and safe to ignore\n");
|
||||
#else
|
||||
DEBUG_MSG("Connected to UBLOX GPS successfully\n");
|
||||
#endif
|
||||
|
||||
if (!setUBXMode())
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
|
||||
|
||||
#ifdef UBX_MODE_NMEA
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool UBloxGPS::setUBXMode()
|
||||
{
|
||||
#ifdef UBX_MODE_NMEA
|
||||
if (_serial_gps) {
|
||||
ublox.setUART1Output(COM_TYPE_NMEA, 1000);
|
||||
}
|
||||
if (i2cAddress) {
|
||||
ublox.setI2COutput(COM_TYPE_NMEA, 1000);
|
||||
}
|
||||
|
||||
return false; // pretend initialization failed to force NMEA mode
|
||||
#endif
|
||||
|
||||
if (_serial_gps) {
|
||||
if (!ublox.setUART1Output(COM_TYPE_UBX, 1000)) // Use native API
|
||||
return false;
|
||||
}
|
||||
if (i2cAddress) {
|
||||
if (!ublox.setI2COutput(COM_TYPE_UBX, 1000))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ublox.setNavigationFrequency(1, 1000)) // Produce 4x/sec to keep the amount of time we stall in getPVT low
|
||||
return false;
|
||||
|
||||
// ok = ublox.setAutoPVT(false); // Not implemented on NEO-6M
|
||||
// assert(ok);
|
||||
// ok = ublox.setDynamicModel(DYN_MODEL_BIKE); // probably PEDESTRIAN but just in case assume bike speeds
|
||||
// assert(ok);
|
||||
|
||||
// per https://github.com/meshtastic/Meshtastic-device/issues/376 powerSaveMode might not work with the marginal
|
||||
// TTGO antennas
|
||||
// if (!ublox.powerSaveMode(true, 2000)) // use power save mode, the default timeout (1100ms seems a bit too tight)
|
||||
// return false;
|
||||
|
||||
if (!ublox.saveConfiguration(3000))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset our GPS back to factory settings
|
||||
*
|
||||
* @return true for success
|
||||
*/
|
||||
bool UBloxGPS::factoryReset()
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
// It is useful to force back into factory defaults (9600baud, NMEA to test the behavior of boards that don't have
|
||||
// GPS_TX connected)
|
||||
ublox.factoryReset();
|
||||
delay(5000);
|
||||
tryConnect(); // sets isConnected
|
||||
|
||||
// try a second time, the ublox lib serial parsing is buggy?
|
||||
for (int i = 0; (i < 3) && !tryConnect(); i++)
|
||||
delay(500);
|
||||
|
||||
DEBUG_MSG("GPS Factory reset success=%d\n", isConnected());
|
||||
if (isConnected())
|
||||
ok = setUBXMode();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/** Idle processing while GPS is looking for lock */
|
||||
void UBloxGPS::whileActive()
|
||||
{
|
||||
ublox.flushPVT(); // reset ALL freshness flags first
|
||||
ublox.getT(maxWait()); // ask for new time data - hopefully ready when we come back
|
||||
|
||||
// Ask for a new position fix - hopefully it will have results ready by next time
|
||||
// the order here is important, because we only check for has latitude when reading
|
||||
|
||||
//ublox.getSIV(maxWait()); // redundant with getPDOP below
|
||||
ublox.getPDOP(maxWait()); // will trigger getSOL on NEO6, getP on others
|
||||
ublox.getP(maxWait()); // will trigger getPosLLH on NEO6, getP on others
|
||||
|
||||
// the fixType flag will be checked and updated in lookForLocation()
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
||||
* Override this method to check for new locations
|
||||
*
|
||||
* @return true if we've acquired a new location
|
||||
*/
|
||||
bool UBloxGPS::lookForTime()
|
||||
{
|
||||
if (ublox.moduleQueried.gpsSecond) {
|
||||
/* Convert to unix time
|
||||
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January
|
||||
1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
|
||||
*/
|
||||
struct tm t;
|
||||
t.tm_sec = ublox.getSecond(0);
|
||||
t.tm_min = ublox.getMinute(0);
|
||||
t.tm_hour = ublox.getHour(0);
|
||||
t.tm_mday = ublox.getDay(0);
|
||||
t.tm_mon = ublox.getMonth(0) - 1;
|
||||
t.tm_year = ublox.getYear(0) - 1900;
|
||||
t.tm_isdst = false;
|
||||
perhapsSetRTC(RTCQualityGPS, t);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
||||
* Override this method to check for new locations
|
||||
*
|
||||
* @return true if we've acquired a new location
|
||||
*/
|
||||
bool UBloxGPS::lookForLocation()
|
||||
{
|
||||
bool foundLocation = false;
|
||||
|
||||
// check if a complete GPS solution set is available for reading
|
||||
// (some of these, like lat/lon are redundant and can be removed)
|
||||
if ( ! (ublox.moduleQueried.fixType &&
|
||||
ublox.moduleQueried.latitude &&
|
||||
ublox.moduleQueried.longitude &&
|
||||
ublox.moduleQueried.altitude &&
|
||||
ublox.moduleQueried.pDOP &&
|
||||
ublox.moduleQueried.SIV &&
|
||||
ublox.moduleQueried.gpsDay))
|
||||
{
|
||||
// Not ready? No problem! We'll try again later.
|
||||
return false;
|
||||
}
|
||||
|
||||
fixType = ublox.getFixType();
|
||||
#ifdef UBLOX_EXTRAVERBOSE
|
||||
DEBUG_MSG("FixType=%d\n", fixType);
|
||||
#endif
|
||||
|
||||
|
||||
// check if GPS has an acceptable lock
|
||||
if (! hasLock()) {
|
||||
ublox.flushPVT(); // reset ALL freshness flags
|
||||
return false;
|
||||
}
|
||||
|
||||
// read lat/lon/alt/dop data into temporary variables to avoid
|
||||
// overwriting global variables with potentially invalid data
|
||||
int32_t tmp_dop = ublox.getPDOP(0); // PDOP (an accuracy metric) is reported in 10^2 units so we have to scale down when we use it
|
||||
int32_t tmp_lat = ublox.getLatitude(0);
|
||||
int32_t tmp_lon = ublox.getLongitude(0);
|
||||
int32_t tmp_alt_msl = ublox.getAltitudeMSL(0);
|
||||
int32_t tmp_alt_hae = ublox.getAltitude(0);
|
||||
int32_t max_dop = PDOP_INVALID;
|
||||
if (radioConfig.preferences.gps_max_dop)
|
||||
max_dop = radioConfig.preferences.gps_max_dop * 100; // scaling
|
||||
|
||||
// Note: heading is only currently implmented in the ublox for the 8m chipset - therefore
|
||||
// don't read it here - it will generate an ignored getPVT command on the 6ms
|
||||
// heading = ublox.getHeading(0);
|
||||
|
||||
// read positional timestamp
|
||||
struct tm t;
|
||||
t.tm_sec = ublox.getSecond(0);
|
||||
t.tm_min = ublox.getMinute(0);
|
||||
t.tm_hour = ublox.getHour(0);
|
||||
t.tm_mday = ublox.getDay(0);
|
||||
t.tm_mon = ublox.getMonth(0) - 1;
|
||||
t.tm_year = ublox.getYear(0) - 1900;
|
||||
t.tm_isdst = false;
|
||||
|
||||
time_t tmp_ts = mktime(&t);
|
||||
|
||||
// FIXME - can opportunistically attempt to set RTC from GPS timestamp?
|
||||
|
||||
// bogus lat lon is reported as 0 or 0 (can be bogus just for one)
|
||||
// Also: apparently when the GPS is initially reporting lock it can output a bogus latitude > 90 deg!
|
||||
// FIXME - NULL ISLAND is a real location on Earth!
|
||||
foundLocation = (tmp_lat != 0) && (tmp_lon != 0) &&
|
||||
(tmp_lat <= 900000000) && (tmp_lat >= -900000000) &&
|
||||
(tmp_dop < max_dop);
|
||||
|
||||
// only if entire dataset is valid, update globals from temp vars
|
||||
if (foundLocation) {
|
||||
p.location_source = Position_LocSource_LOCSRC_GPS_INTERNAL;
|
||||
p.longitude_i = tmp_lon;
|
||||
p.latitude_i = tmp_lat;
|
||||
if (fixType > 2) {
|
||||
// if fix is 2d, ignore altitude data
|
||||
p.altitude = tmp_alt_msl / 1000;
|
||||
p.altitude_hae = tmp_alt_hae / 1000;
|
||||
p.alt_geoid_sep = (tmp_alt_hae - tmp_alt_msl) / 1000;
|
||||
} else {
|
||||
#ifdef GPS_EXTRAVERBOSE
|
||||
DEBUG_MSG("no altitude data (fixType=%d)\n", fixType);
|
||||
#endif
|
||||
// clean up old values in case it's a 3d-2d fix transition
|
||||
p.altitude = p.altitude_hae = p.alt_geoid_sep = 0;
|
||||
}
|
||||
p.pos_timestamp = tmp_ts;
|
||||
p.PDOP = tmp_dop;
|
||||
p.fix_type = fixType;
|
||||
p.sats_in_view = ublox.getSIV(0);
|
||||
// In debug logs, identify position by @timestamp:stage (stage 1 = birth)
|
||||
DEBUG_MSG("lookForLocation() new pos@%x:1\n", tmp_ts);
|
||||
} else {
|
||||
// INVALID solution - should never happen
|
||||
DEBUG_MSG("Invalid location lat/lon/hae/dop %d/%d/%d/%d - discarded\n",
|
||||
tmp_lat, tmp_lon, tmp_alt_hae, tmp_dop);
|
||||
}
|
||||
|
||||
ublox.flushPVT(); // reset ALL freshness flags at the end
|
||||
|
||||
return foundLocation;
|
||||
}
|
||||
|
||||
bool UBloxGPS::hasLock()
|
||||
{
|
||||
if (radioConfig.preferences.gps_accept_2d)
|
||||
return (fixType >= 2 && fixType <= 4);
|
||||
else
|
||||
return (fixType >= 3 && fixType <= 4);
|
||||
}
|
||||
|
||||
bool UBloxGPS::whileIdle()
|
||||
{
|
||||
// if using i2c or serial look too see if any chars are ready
|
||||
return ublox.checkUblox(); // See if new data is available. Process bytes as they come in.
|
||||
}
|
||||
|
||||
/// If possible force the GPS into sleep/low power mode
|
||||
/// Note: ublox doesn't need a wake method, because as soon as we send chars to the GPS it will wake up
|
||||
void UBloxGPS::sleep()
|
||||
{
|
||||
if (radioConfig.preferences.gps_update_interval > UBLOX_POWEROFF_THRESHOLD) {
|
||||
// Tell GPS to power down until we send it characters on serial port (we leave vcc connected)
|
||||
ublox.powerOff();
|
||||
// setGPSPower(false);
|
||||
}
|
||||
}
|
||||
|
||||
void UBloxGPS::wake()
|
||||
{
|
||||
if (radioConfig.preferences.gps_update_interval > UBLOX_POWEROFF_THRESHOLD) {
|
||||
fixType = 0; // assume we have no fix yet
|
||||
}
|
||||
|
||||
// this is idempotent
|
||||
setGPSPower(true);
|
||||
|
||||
// Note: no delay needed because now we leave gps power on always and instead use ublox.powerOff()
|
||||
// Give time for the GPS to boot
|
||||
// delay(200);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "GPS.h"
|
||||
#include "Observer.h"
|
||||
#include "SparkFun_Ublox_Arduino_Library.h"
|
||||
|
||||
/**
|
||||
* A gps class that only reads from the GPS periodically (and FIXME - eventually keeps the gps powered down except when reading)
|
||||
*
|
||||
* When new data is available it will notify observers.
|
||||
*/
|
||||
class UBloxGPS : public GPS
|
||||
{
|
||||
SFE_UBLOX_GPS ublox;
|
||||
uint8_t fixType = 0;
|
||||
|
||||
public:
|
||||
UBloxGPS();
|
||||
|
||||
/**
|
||||
* Reset our GPS back to factory settings
|
||||
*
|
||||
* @return true for success
|
||||
*/
|
||||
bool factoryReset() override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns true if we succeeded
|
||||
*/
|
||||
virtual bool setupGPS() override;
|
||||
|
||||
/** Subclasses should look for serial rx characters here and feed it to their GPS parser
|
||||
*
|
||||
* Return true if we received a valid message from the GPS
|
||||
*/
|
||||
virtual bool whileIdle() override;
|
||||
|
||||
/** Idle processing while GPS is looking for lock */
|
||||
virtual void whileActive() override;
|
||||
|
||||
/**
|
||||
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
||||
* Override this method to check for new locations
|
||||
*
|
||||
* @return true if we've acquired a time
|
||||
*/
|
||||
virtual bool lookForTime() override;
|
||||
|
||||
/**
|
||||
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
||||
* Override this method to check for new locations
|
||||
*
|
||||
* @return true if we've acquired a new location
|
||||
*/
|
||||
virtual bool lookForLocation() override;
|
||||
virtual bool hasLock() override;
|
||||
|
||||
/// If possible force the GPS into sleep/low power mode
|
||||
virtual void sleep() override;
|
||||
virtual void wake() override;
|
||||
|
||||
private:
|
||||
/// Attempt to connect to our GPS, returns false if no gps is present
|
||||
bool tryConnect();
|
||||
|
||||
/// Switch to our desired operating mode and save the settings to flash
|
||||
/// returns true for success
|
||||
bool setUBXMode();
|
||||
|
||||
uint16_t maxWait() const { return i2cAddress ? 300 : 0; /*If using i2c we must poll with wait */ }
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "InputBroker.h"
|
||||
#include "PowerFSM.h" // needed for event trigger
|
||||
|
||||
InputBroker *inputBroker;
|
||||
|
||||
@@ -13,6 +14,7 @@ void InputBroker::registerSource(Observable<const InputEvent *> *source)
|
||||
|
||||
int InputBroker::handleInputEvent(const InputEvent *event)
|
||||
{
|
||||
powerFSM.trigger(EVENT_INPUT);
|
||||
this->notifyObservers(event);
|
||||
return 0;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ int32_t RotaryEncoderInterruptBase::runOnce()
|
||||
}
|
||||
else if (this->action == ROTARY_ACTION_CCW)
|
||||
{
|
||||
DEBUG_MSG("Rotary event CW\n");
|
||||
DEBUG_MSG("Rotary event CCW\n");
|
||||
e.inputEvent = this->_eventCcw;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void RotaryEncoderInterruptBase::intAHandler()
|
||||
return;
|
||||
}
|
||||
this->rotaryLevelA = currentLevelA;
|
||||
intHandler(
|
||||
this->rotaryStateCCW = intHandler(
|
||||
currentLevelA == HIGH,
|
||||
this->rotaryLevelB,
|
||||
ROTARY_ACTION_CCW,
|
||||
|
||||
38
src/main.cpp
38
src/main.cpp
@@ -226,10 +226,6 @@ class ButtonThread : public OSThread
|
||||
|
||||
#ifdef BUTTON_PIN_TOUCH
|
||||
userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true);
|
||||
#ifdef INPUT_PULLUP_SENSE
|
||||
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
||||
pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE);
|
||||
#endif
|
||||
userButtonTouch.attachClick(touchPressed);
|
||||
userButtonTouch.attachDuringLongPress(touchPressedLong);
|
||||
userButtonTouch.attachDoubleClick(touchDoublePressed);
|
||||
@@ -295,7 +291,11 @@ class ButtonThread : public OSThread
|
||||
static void userButtonPressed()
|
||||
{
|
||||
// DEBUG_MSG("press!\n");
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
#ifdef BUTTON_PIN
|
||||
if ((BUTTON_PIN != radioConfig.preferences.rotary1_pin_press) || !radioConfig.preferences.canned_message_plugin_enabled) {
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
static void userButtonPressedLong()
|
||||
{
|
||||
@@ -340,6 +340,9 @@ class ButtonThread : public OSThread
|
||||
{
|
||||
#ifndef NO_ESP32
|
||||
clearNVS();
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
clearBonds();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -401,6 +404,12 @@ void setup()
|
||||
|
||||
initDeepSleep();
|
||||
|
||||
// Testing this fix für erratic T-Echo boot behaviour
|
||||
#if defined(TTGO_T_ECHO) && defined(PIN_EINK_PWR_ON)
|
||||
pinMode(PIN_EINK_PWR_ON, OUTPUT);
|
||||
digitalWrite(PIN_EINK_PWR_ON, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef VEXT_ENABLE
|
||||
pinMode(VEXT_ENABLE, OUTPUT);
|
||||
digitalWrite(VEXT_ENABLE, 0); // turn on the display power
|
||||
@@ -558,6 +567,7 @@ void setup()
|
||||
|
||||
// ONCE we will factory reset the GPS for bug #327
|
||||
if (gps && !devicestate.did_gps_reset) {
|
||||
DEBUG_MSG("GPS FactoryReset requested\n");
|
||||
if (gps->factoryReset()) { // If we don't succeed try again next time
|
||||
devicestate.did_gps_reset = true;
|
||||
nodeDB.saveToDisk();
|
||||
@@ -658,16 +668,16 @@ void setup()
|
||||
|
||||
if (!rIf)
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_NoRadio);
|
||||
else
|
||||
else{
|
||||
router->addInterface(rIf);
|
||||
|
||||
// Calculate and save the bit rate to myNodeInfo
|
||||
// TODO: This needs to be added what ever method changes the channel from the phone.
|
||||
myNodeInfo.bitrate = (float(Constants_DATA_PAYLOAD_LEN) /
|
||||
(float(rIf->getPacketTime(Constants_DATA_PAYLOAD_LEN)))
|
||||
) * 1000;
|
||||
DEBUG_MSG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
|
||||
|
||||
// Calculate and save the bit rate to myNodeInfo
|
||||
// TODO: This needs to be added what ever method changes the channel from the phone.
|
||||
myNodeInfo.bitrate = (float(Constants_DATA_PAYLOAD_LEN) /
|
||||
(float(rIf->getPacketTime(Constants_DATA_PAYLOAD_LEN)))
|
||||
) * 1000;
|
||||
DEBUG_MSG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
|
||||
}
|
||||
|
||||
// This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values
|
||||
PowerFSM_setup(); // we will transition to ON in a couple of seconds, FIXME, only do this for cold boots, not waking from SDS
|
||||
@@ -707,6 +717,8 @@ void powerCommandsCheck()
|
||||
#ifndef NO_ESP32
|
||||
DEBUG_MSG("Rebooting for update\n");
|
||||
ESP.restart();
|
||||
#elif NRF52_SERIES
|
||||
NVIC_SystemReset();
|
||||
#else
|
||||
DEBUG_MSG("FIXME implement reboot for this platform");
|
||||
#endif
|
||||
|
||||
@@ -27,4 +27,4 @@ extern uint32_t shutdownAtMsec;
|
||||
// This will supress the current delay and instead try to run ASAP.
|
||||
extern bool runASAP;
|
||||
|
||||
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop();
|
||||
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds();
|
||||
|
||||
@@ -71,17 +71,7 @@ int MeshService::handleFromRadio(const MeshPacket *mp)
|
||||
printPacket("Forwarding to phone", mp);
|
||||
nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
|
||||
|
||||
fromNum++;
|
||||
|
||||
if (toPhoneQueue.numFree() == 0) {
|
||||
DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n");
|
||||
MeshPacket *d = toPhoneQueue.dequeuePtr(0);
|
||||
if (d)
|
||||
releaseToPool(d);
|
||||
}
|
||||
|
||||
MeshPacket *copied = packetPool.allocCopy(*mp);
|
||||
assert(toPhoneQueue.enqueue(copied, 0)); // FIXME, instead of failing for full queue, delete the oldest mssages
|
||||
sendToPhone((MeshPacket *)mp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -161,12 +151,16 @@ bool MeshService::cancelSending(PacketId id)
|
||||
return router->cancelSending(nodeDB.getNodeNum(), id);
|
||||
}
|
||||
|
||||
void MeshService::sendToMesh(MeshPacket *p, RxSource src)
|
||||
void MeshService::sendToMesh(MeshPacket *p, RxSource src, bool ccToPhone)
|
||||
{
|
||||
nodeDB.updateFrom(*p); // update our local DB for this packet (because phone might have sent position packets etc...)
|
||||
|
||||
// Note: We might return !OK if our fifo was full, at that point the only option we have is to drop it
|
||||
router->sendLocal(p, src);
|
||||
|
||||
if (ccToPhone) {
|
||||
sendToPhone(p);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||
@@ -213,6 +207,20 @@ NodeInfo *MeshService::refreshMyNodeInfo()
|
||||
return node;
|
||||
}
|
||||
|
||||
void MeshService::sendToPhone(MeshPacket *p) {
|
||||
if (toPhoneQueue.numFree() == 0) {
|
||||
DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n");
|
||||
MeshPacket *d = toPhoneQueue.dequeuePtr(0);
|
||||
if (d)
|
||||
releaseToPool(d);
|
||||
}
|
||||
|
||||
MeshPacket *copied = packetPool.allocCopy(*p);
|
||||
perhapsDecode(copied);
|
||||
assert(toPhoneQueue.enqueue(copied, 0)); // FIXME, instead of failing for full queue, delete the oldest mssages
|
||||
fromNum++;
|
||||
}
|
||||
|
||||
int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||
{
|
||||
// Update our local node info with our position (even if we don't decide to update anyone else)
|
||||
|
||||
@@ -75,7 +75,7 @@ class MeshService
|
||||
/// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after
|
||||
/// sending. This is the ONLY function you should use for sending messages into the mesh, because it also updates the nodedb
|
||||
/// cache
|
||||
void sendToMesh(MeshPacket *p, RxSource src = RX_SRC_LOCAL);
|
||||
void sendToMesh(MeshPacket *p, RxSource src = RX_SRC_LOCAL, bool ccToPhone = false);
|
||||
|
||||
/** Attempt to cancel a previously sent packet from this _local_ node. Returns true if a packet was found we could cancel */
|
||||
bool cancelSending(PacketId id);
|
||||
@@ -83,6 +83,9 @@ class MeshService
|
||||
/// Pull the latest power and time info into my nodeinfo
|
||||
NodeInfo *refreshMyNodeInfo();
|
||||
|
||||
/// Send a packet to the phone
|
||||
void sendToPhone(MeshPacket *p);
|
||||
|
||||
private:
|
||||
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
||||
/// returns 0 to allow futher processing
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
#include <nvs_flash.h>
|
||||
#endif
|
||||
|
||||
#ifdef NRF52_SERIES
|
||||
#include <bluefruit.h>
|
||||
#include <utility/bonding.h>
|
||||
#endif
|
||||
|
||||
NodeDB nodeDB;
|
||||
|
||||
// we have plenty of ram so statically alloc this tempbuf (for now)
|
||||
@@ -90,6 +95,25 @@ bool NodeDB::resetRadioConfig()
|
||||
#ifndef NO_ESP32
|
||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||
nvs_flash_erase();
|
||||
#endif
|
||||
#ifdef NRF52_SERIES
|
||||
|
||||
// first, remove the "/prefs" (this removes most prefs)
|
||||
FS.rmdir_r("/prefs");
|
||||
// second, install default state (this will deal with the duplicate mac address issue)
|
||||
installDefaultDeviceState();
|
||||
// third, write to disk
|
||||
saveToDisk();
|
||||
|
||||
Bluefruit.begin();
|
||||
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
|
||||
#endif
|
||||
didFactoryReset = true;
|
||||
}
|
||||
@@ -459,6 +483,9 @@ size_t NodeDB::getNumOnlineNodes()
|
||||
void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
||||
{
|
||||
NodeInfo *info = getOrCreateNode(nodeId);
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (src == RX_SRC_LOCAL) {
|
||||
// Local packet, fully authoritative
|
||||
@@ -502,6 +529,9 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
||||
void NodeDB::updateUser(uint32_t nodeId, const User &p)
|
||||
{
|
||||
NodeInfo *info = getOrCreateNode(nodeId);
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_MSG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
||||
|
||||
@@ -531,6 +561,9 @@ void NodeDB::updateFrom(const MeshPacket &mp)
|
||||
DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
|
||||
|
||||
NodeInfo *info = getOrCreateNode(getFrom(&mp));
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mp.rx_time) // if the packet has a valid timestamp use it to update our last_heard
|
||||
info->last_heard = mp.rx_time;
|
||||
@@ -557,8 +590,12 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
||||
NodeInfo *info = getNode(n);
|
||||
|
||||
if (!info) {
|
||||
if (*numNodes >= MAX_NUM_NODES) {
|
||||
screen->print("error: node_db full!\n");
|
||||
DEBUG_MSG("ERROR! could not create new node, node_db is full! (%d nodes)", *numNodes);
|
||||
return NULL;
|
||||
}
|
||||
// add the node
|
||||
assert(*numNodes < MAX_NUM_NODES);
|
||||
info = &nodes[(*numNodes)++];
|
||||
|
||||
// everything is missing except the nodenum
|
||||
|
||||
@@ -58,7 +58,7 @@ class PhoneAPI
|
||||
|
||||
// Call this when the client drops the connection, resets the state to STATE_SEND_NOTHING
|
||||
// Unregisters our observer. A closed connection **can** be reopened by calling init again.
|
||||
void close();
|
||||
virtual void close();
|
||||
|
||||
/**
|
||||
* Handle a ToRadio protobuf
|
||||
|
||||
@@ -210,6 +210,33 @@ ErrorCode Router::send(MeshPacket *p)
|
||||
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
|
||||
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
||||
|
||||
|
||||
|
||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
||||
//check if we should send decrypted packets to mqtt
|
||||
|
||||
//truth table:
|
||||
/* mqtt_server mqtt_encryption_enabled should_encrypt
|
||||
* not set 0 1
|
||||
* not set 1 1
|
||||
* set 0 0
|
||||
* set 1 1
|
||||
*
|
||||
* => so we only decrypt mqtt if they have a custom mqtt server AND mqtt_encryption_enabled is FALSE
|
||||
*/
|
||||
|
||||
bool shouldActuallyEncrypt = true;
|
||||
if (*radioConfig.preferences.mqtt_server && !radioConfig.preferences.mqtt_encryption_enabled) {
|
||||
shouldActuallyEncrypt = false;
|
||||
}
|
||||
|
||||
DEBUG_MSG("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt);
|
||||
|
||||
//the packet is currently in a decrypted state. send it now if they want decrypted packets
|
||||
if (mqtt && !shouldActuallyEncrypt)
|
||||
mqtt->onSend(*p, chIndex);
|
||||
#endif
|
||||
|
||||
auto encodeResult = perhapsEncode(p);
|
||||
if (encodeResult != Routing_Error_NONE) {
|
||||
abortSendAndNak(encodeResult, p);
|
||||
@@ -217,7 +244,9 @@ ErrorCode Router::send(MeshPacket *p)
|
||||
}
|
||||
|
||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
||||
if (mqtt)
|
||||
//the packet is now encrypted.
|
||||
//check if we should send encrypted packets to mqtt
|
||||
if (mqtt && shouldActuallyEncrypt)
|
||||
mqtt->onSend(*p, chIndex);
|
||||
#endif
|
||||
}
|
||||
@@ -247,7 +276,7 @@ bool perhapsDecode(MeshPacket *p)
|
||||
if (p->which_payloadVariant == MeshPacket_decoded_tag)
|
||||
return true; // If packet was already decoded just return
|
||||
|
||||
assert(p->which_payloadVariant == MeshPacket_encrypted_tag);
|
||||
//assert(p->which_payloadVariant == MeshPacket_encrypted_tag);
|
||||
|
||||
// Try to find a channel that works with this hash
|
||||
for (ChannelIndex chIndex = 0; chIndex < channels.getNumChannels(); chIndex++) {
|
||||
@@ -368,4 +397,4 @@ void Router::perhapsHandleReceived(MeshPacket *p)
|
||||
handleReceived(p);
|
||||
|
||||
packetPool.release(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ bool SX126xInterface<T>::init()
|
||||
#ifdef SX126X_TXEN
|
||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||
if (res == ERR_NONE)
|
||||
res = lora.setDio2AsRfSwitch(false);
|
||||
res = lora.setDio2AsRfSwitch(true);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
@@ -129,9 +129,6 @@ bool SX126xInterface<T>::reconfigure()
|
||||
err = lora.setSyncWord(syncWord);
|
||||
assert(err == ERR_NONE);
|
||||
|
||||
err = lora.setCurrentLimit(currentLimit);
|
||||
assert(err == ERR_NONE);
|
||||
|
||||
err = lora.setPreambleLength(preambleLength);
|
||||
assert(err == ERR_NONE);
|
||||
|
||||
@@ -139,11 +136,11 @@ bool SX126xInterface<T>::reconfigure()
|
||||
if (err != ERR_NONE)
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
if (power > 22) // This chip has lower power limits than some
|
||||
power = 22;
|
||||
if (power > SX126X_MAX_POWER) // This chip has lower power limits than some
|
||||
power = SX126X_MAX_POWER;
|
||||
err = lora.setOutputPower(power);
|
||||
assert(err == ERR_NONE);
|
||||
|
||||
|
||||
startReceive(); // restart receiving
|
||||
|
||||
return ERR_NONE;
|
||||
@@ -191,7 +188,11 @@ void SX126xInterface<T>::addReceiveMetadata(MeshPacket *mp)
|
||||
template<typename T>
|
||||
void SX126xInterface<T>::configHardwareForSend()
|
||||
{
|
||||
#ifdef SX126X_TXEN // we have RXEN/TXEN control - turn on TX power / off RX power
|
||||
// If we have RXEN/TXEN control - turn on TX power / off RX power
|
||||
#ifdef SX126X_RXEN
|
||||
digitalWrite(SX126X_RXEN, LOW);
|
||||
#endif
|
||||
#ifdef SX126X_TXEN
|
||||
digitalWrite(SX126X_TXEN, HIGH);
|
||||
#endif
|
||||
|
||||
@@ -210,7 +211,11 @@ void SX126xInterface<T>::startReceive()
|
||||
|
||||
setStandby();
|
||||
|
||||
#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn on RX power / off TX power
|
||||
// If we have RXEN/TXEN control - turn on RX power / off TX power
|
||||
#ifdef SX126X_TXEN
|
||||
digitalWrite(SX126X_TXEN, LOW);
|
||||
#endif
|
||||
#ifdef SX126X_RXEN
|
||||
digitalWrite(SX126X_RXEN, HIGH);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#ifndef PB_ADMIN_PB_H_INCLUDED
|
||||
#define PB_ADMIN_PB_H_INCLUDED
|
||||
#include <pb.h>
|
||||
#include "cannedmessages.pb.h"
|
||||
#include "channel.pb.h"
|
||||
#include "mesh.pb.h"
|
||||
#include "radioconfig.pb.h"
|
||||
@@ -31,20 +30,17 @@ typedef struct _AdminMessage {
|
||||
bool exit_simulator;
|
||||
int32_t reboot_seconds;
|
||||
bool get_canned_message_plugin_part1_request;
|
||||
CannedMessagePluginMessagePart1 get_canned_message_plugin_part1_response;
|
||||
char get_canned_message_plugin_part1_response[201];
|
||||
bool get_canned_message_plugin_part2_request;
|
||||
CannedMessagePluginMessagePart2 get_canned_message_plugin_part2_response;
|
||||
char get_canned_message_plugin_part2_response[201];
|
||||
bool get_canned_message_plugin_part3_request;
|
||||
CannedMessagePluginMessagePart3 get_canned_message_plugin_part3_response;
|
||||
char get_canned_message_plugin_part3_response[201];
|
||||
bool get_canned_message_plugin_part4_request;
|
||||
CannedMessagePluginMessagePart4 get_canned_message_plugin_part4_response;
|
||||
bool get_canned_message_plugin_part5_request;
|
||||
CannedMessagePluginMessagePart5 get_canned_message_plugin_part5_response;
|
||||
CannedMessagePluginMessagePart1 set_canned_message_plugin_part1;
|
||||
CannedMessagePluginMessagePart2 set_canned_message_plugin_part2;
|
||||
CannedMessagePluginMessagePart3 set_canned_message_plugin_part3;
|
||||
CannedMessagePluginMessagePart4 set_canned_message_plugin_part4;
|
||||
CannedMessagePluginMessagePart5 set_canned_message_plugin_part5;
|
||||
char get_canned_message_plugin_part4_response[201];
|
||||
char set_canned_message_plugin_part1[201];
|
||||
char set_canned_message_plugin_part2[201];
|
||||
char set_canned_message_plugin_part3[201];
|
||||
char set_canned_message_plugin_part4[201];
|
||||
int32_t shutdown_seconds;
|
||||
};
|
||||
} AdminMessage;
|
||||
@@ -80,13 +76,10 @@ extern "C" {
|
||||
#define AdminMessage_get_canned_message_plugin_part3_response_tag 41
|
||||
#define AdminMessage_get_canned_message_plugin_part4_request_tag 42
|
||||
#define AdminMessage_get_canned_message_plugin_part4_response_tag 43
|
||||
#define AdminMessage_get_canned_message_plugin_part5_request_tag 44
|
||||
#define AdminMessage_get_canned_message_plugin_part5_response_tag 45
|
||||
#define AdminMessage_set_canned_message_plugin_part1_tag 46
|
||||
#define AdminMessage_set_canned_message_plugin_part2_tag 47
|
||||
#define AdminMessage_set_canned_message_plugin_part3_tag 48
|
||||
#define AdminMessage_set_canned_message_plugin_part4_tag 49
|
||||
#define AdminMessage_set_canned_message_plugin_part5_tag 50
|
||||
#define AdminMessage_set_canned_message_plugin_part1_tag 44
|
||||
#define AdminMessage_set_canned_message_plugin_part2_tag 45
|
||||
#define AdminMessage_set_canned_message_plugin_part3_tag 46
|
||||
#define AdminMessage_set_canned_message_plugin_part4_tag 47
|
||||
#define AdminMessage_shutdown_seconds_tag 51
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
@@ -105,20 +98,17 @@ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio)
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \
|
||||
X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part1_request,get_canned_message_plugin_part1_request), 36) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part1_response,get_canned_message_plugin_part1_response), 37) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part1_response,get_canned_message_plugin_part1_response), 37) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part2_request,get_canned_message_plugin_part2_request), 38) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part2_response,get_canned_message_plugin_part2_response), 39) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part2_response,get_canned_message_plugin_part2_response), 39) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part3_request,get_canned_message_plugin_part3_request), 40) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part3_response,get_canned_message_plugin_part3_response), 41) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part3_response,get_canned_message_plugin_part3_response), 41) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part4_request,get_canned_message_plugin_part4_request), 42) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part4_response,get_canned_message_plugin_part4_response), 43) \
|
||||
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part5_request,get_canned_message_plugin_part5_request), 44) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part5_response,get_canned_message_plugin_part5_response), 45) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part1,set_canned_message_plugin_part1), 46) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part2,set_canned_message_plugin_part2), 47) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part3,set_canned_message_plugin_part3), 48) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part4,set_canned_message_plugin_part4), 49) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part5,set_canned_message_plugin_part5), 50) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part4_response,get_canned_message_plugin_part4_response), 43) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part1,set_canned_message_plugin_part1), 44) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part2,set_canned_message_plugin_part2), 45) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part3,set_canned_message_plugin_part3), 46) \
|
||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part4,set_canned_message_plugin_part4), 47) \
|
||||
X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51)
|
||||
#define AdminMessage_CALLBACK NULL
|
||||
#define AdminMessage_DEFAULT NULL
|
||||
@@ -128,16 +118,6 @@ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds),
|
||||
#define AdminMessage_variant_get_radio_response_MSGTYPE RadioConfig
|
||||
#define AdminMessage_variant_get_channel_response_MSGTYPE Channel
|
||||
#define AdminMessage_variant_get_owner_response_MSGTYPE User
|
||||
#define AdminMessage_variant_get_canned_message_plugin_part1_response_MSGTYPE CannedMessagePluginMessagePart1
|
||||
#define AdminMessage_variant_get_canned_message_plugin_part2_response_MSGTYPE CannedMessagePluginMessagePart2
|
||||
#define AdminMessage_variant_get_canned_message_plugin_part3_response_MSGTYPE CannedMessagePluginMessagePart3
|
||||
#define AdminMessage_variant_get_canned_message_plugin_part4_response_MSGTYPE CannedMessagePluginMessagePart4
|
||||
#define AdminMessage_variant_get_canned_message_plugin_part5_response_MSGTYPE CannedMessagePluginMessagePart5
|
||||
#define AdminMessage_variant_set_canned_message_plugin_part1_MSGTYPE CannedMessagePluginMessagePart1
|
||||
#define AdminMessage_variant_set_canned_message_plugin_part2_MSGTYPE CannedMessagePluginMessagePart2
|
||||
#define AdminMessage_variant_set_canned_message_plugin_part3_MSGTYPE CannedMessagePluginMessagePart3
|
||||
#define AdminMessage_variant_set_canned_message_plugin_part4_MSGTYPE CannedMessagePluginMessagePart4
|
||||
#define AdminMessage_variant_set_canned_message_plugin_part5_MSGTYPE CannedMessagePluginMessagePart5
|
||||
|
||||
extern const pb_msgdesc_t AdminMessage_msg;
|
||||
|
||||
@@ -145,7 +125,7 @@ extern const pb_msgdesc_t AdminMessage_msg;
|
||||
#define AdminMessage_fields &AdminMessage_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define AdminMessage_size 798
|
||||
#define AdminMessage_size 804
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -6,19 +6,7 @@
|
||||
#error Regenerate this file with the current version of nanopb generator.
|
||||
#endif
|
||||
|
||||
PB_BIND(CannedMessagePluginMessagePart1, CannedMessagePluginMessagePart1, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CannedMessagePluginMessagePart2, CannedMessagePluginMessagePart2, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CannedMessagePluginMessagePart3, CannedMessagePluginMessagePart3, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CannedMessagePluginMessagePart4, CannedMessagePluginMessagePart4, AUTO)
|
||||
|
||||
|
||||
PB_BIND(CannedMessagePluginMessagePart5, CannedMessagePluginMessagePart5, AUTO)
|
||||
PB_BIND(CannedMessagePluginConfig, CannedMessagePluginConfig, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,25 +10,12 @@
|
||||
#endif
|
||||
|
||||
/* Struct definitions */
|
||||
typedef struct _CannedMessagePluginMessagePart1 {
|
||||
char text[200];
|
||||
} CannedMessagePluginMessagePart1;
|
||||
|
||||
typedef struct _CannedMessagePluginMessagePart2 {
|
||||
char text[200];
|
||||
} CannedMessagePluginMessagePart2;
|
||||
|
||||
typedef struct _CannedMessagePluginMessagePart3 {
|
||||
char text[200];
|
||||
} CannedMessagePluginMessagePart3;
|
||||
|
||||
typedef struct _CannedMessagePluginMessagePart4 {
|
||||
char text[200];
|
||||
} CannedMessagePluginMessagePart4;
|
||||
|
||||
typedef struct _CannedMessagePluginMessagePart5 {
|
||||
char text[200];
|
||||
} CannedMessagePluginMessagePart5;
|
||||
typedef struct _CannedMessagePluginConfig {
|
||||
char messagesPart1[201];
|
||||
char messagesPart2[201];
|
||||
char messagesPart3[201];
|
||||
char messagesPart4[201];
|
||||
} CannedMessagePluginConfig;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -36,69 +23,31 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define CannedMessagePluginMessagePart1_init_default {""}
|
||||
#define CannedMessagePluginMessagePart2_init_default {""}
|
||||
#define CannedMessagePluginMessagePart3_init_default {""}
|
||||
#define CannedMessagePluginMessagePart4_init_default {""}
|
||||
#define CannedMessagePluginMessagePart5_init_default {""}
|
||||
#define CannedMessagePluginMessagePart1_init_zero {""}
|
||||
#define CannedMessagePluginMessagePart2_init_zero {""}
|
||||
#define CannedMessagePluginMessagePart3_init_zero {""}
|
||||
#define CannedMessagePluginMessagePart4_init_zero {""}
|
||||
#define CannedMessagePluginMessagePart5_init_zero {""}
|
||||
#define CannedMessagePluginConfig_init_default {"", "", "", ""}
|
||||
#define CannedMessagePluginConfig_init_zero {"", "", "", ""}
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define CannedMessagePluginMessagePart1_text_tag 1
|
||||
#define CannedMessagePluginMessagePart2_text_tag 1
|
||||
#define CannedMessagePluginMessagePart3_text_tag 1
|
||||
#define CannedMessagePluginMessagePart4_text_tag 1
|
||||
#define CannedMessagePluginMessagePart5_text_tag 1
|
||||
#define CannedMessagePluginConfig_messagesPart1_tag 11
|
||||
#define CannedMessagePluginConfig_messagesPart2_tag 12
|
||||
#define CannedMessagePluginConfig_messagesPart3_tag 13
|
||||
#define CannedMessagePluginConfig_messagesPart4_tag 14
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define CannedMessagePluginMessagePart1_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, text, 1)
|
||||
#define CannedMessagePluginMessagePart1_CALLBACK NULL
|
||||
#define CannedMessagePluginMessagePart1_DEFAULT NULL
|
||||
#define CannedMessagePluginConfig_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, messagesPart1, 11) \
|
||||
X(a, STATIC, SINGULAR, STRING, messagesPart2, 12) \
|
||||
X(a, STATIC, SINGULAR, STRING, messagesPart3, 13) \
|
||||
X(a, STATIC, SINGULAR, STRING, messagesPart4, 14)
|
||||
#define CannedMessagePluginConfig_CALLBACK NULL
|
||||
#define CannedMessagePluginConfig_DEFAULT NULL
|
||||
|
||||
#define CannedMessagePluginMessagePart2_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, text, 1)
|
||||
#define CannedMessagePluginMessagePart2_CALLBACK NULL
|
||||
#define CannedMessagePluginMessagePart2_DEFAULT NULL
|
||||
|
||||
#define CannedMessagePluginMessagePart3_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, text, 1)
|
||||
#define CannedMessagePluginMessagePart3_CALLBACK NULL
|
||||
#define CannedMessagePluginMessagePart3_DEFAULT NULL
|
||||
|
||||
#define CannedMessagePluginMessagePart4_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, text, 1)
|
||||
#define CannedMessagePluginMessagePart4_CALLBACK NULL
|
||||
#define CannedMessagePluginMessagePart4_DEFAULT NULL
|
||||
|
||||
#define CannedMessagePluginMessagePart5_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, STRING, text, 1)
|
||||
#define CannedMessagePluginMessagePart5_CALLBACK NULL
|
||||
#define CannedMessagePluginMessagePart5_DEFAULT NULL
|
||||
|
||||
extern const pb_msgdesc_t CannedMessagePluginMessagePart1_msg;
|
||||
extern const pb_msgdesc_t CannedMessagePluginMessagePart2_msg;
|
||||
extern const pb_msgdesc_t CannedMessagePluginMessagePart3_msg;
|
||||
extern const pb_msgdesc_t CannedMessagePluginMessagePart4_msg;
|
||||
extern const pb_msgdesc_t CannedMessagePluginMessagePart5_msg;
|
||||
extern const pb_msgdesc_t CannedMessagePluginConfig_msg;
|
||||
|
||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||
#define CannedMessagePluginMessagePart1_fields &CannedMessagePluginMessagePart1_msg
|
||||
#define CannedMessagePluginMessagePart2_fields &CannedMessagePluginMessagePart2_msg
|
||||
#define CannedMessagePluginMessagePart3_fields &CannedMessagePluginMessagePart3_msg
|
||||
#define CannedMessagePluginMessagePart4_fields &CannedMessagePluginMessagePart4_msg
|
||||
#define CannedMessagePluginMessagePart5_fields &CannedMessagePluginMessagePart5_msg
|
||||
#define CannedMessagePluginConfig_fields &CannedMessagePluginConfig_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define CannedMessagePluginMessagePart1_size 202
|
||||
#define CannedMessagePluginMessagePart2_size 202
|
||||
#define CannedMessagePluginMessagePart3_size 202
|
||||
#define CannedMessagePluginMessagePart4_size 202
|
||||
#define CannedMessagePluginMessagePart5_size 202
|
||||
#define CannedMessagePluginConfig_size 812
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -43,11 +43,6 @@ typedef struct _DeviceState {
|
||||
uint32_t version;
|
||||
bool no_save;
|
||||
bool did_gps_reset;
|
||||
char canned_message_plugin_message_part1[200];
|
||||
char canned_message_plugin_message_part2[200];
|
||||
char canned_message_plugin_message_part3[200];
|
||||
char canned_message_plugin_message_part4[200];
|
||||
char canned_message_plugin_message_part5[200];
|
||||
} DeviceState;
|
||||
|
||||
|
||||
@@ -58,11 +53,11 @@ extern "C" {
|
||||
/* Initializer values for message structs */
|
||||
#define LegacyRadioConfig_init_default {false, LegacyRadioConfig_LegacyPreferences_init_default}
|
||||
#define LegacyRadioConfig_LegacyPreferences_init_default {_RegionCode_MIN}
|
||||
#define DeviceState_init_default {false, LegacyRadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""}
|
||||
#define DeviceState_init_default {false, LegacyRadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0}
|
||||
#define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}}
|
||||
#define LegacyRadioConfig_init_zero {false, LegacyRadioConfig_LegacyPreferences_init_zero}
|
||||
#define LegacyRadioConfig_LegacyPreferences_init_zero {_RegionCode_MIN}
|
||||
#define DeviceState_init_zero {false, LegacyRadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""}
|
||||
#define DeviceState_init_zero {false, LegacyRadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0}
|
||||
#define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}}
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
@@ -78,11 +73,6 @@ extern "C" {
|
||||
#define DeviceState_version_tag 8
|
||||
#define DeviceState_no_save_tag 9
|
||||
#define DeviceState_did_gps_reset_tag 11
|
||||
#define DeviceState_canned_message_plugin_message_part1_tag 13
|
||||
#define DeviceState_canned_message_plugin_message_part2_tag 14
|
||||
#define DeviceState_canned_message_plugin_message_part3_tag 15
|
||||
#define DeviceState_canned_message_plugin_message_part4_tag 16
|
||||
#define DeviceState_canned_message_plugin_message_part5_tag 17
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define LegacyRadioConfig_FIELDLIST(X, a) \
|
||||
@@ -105,12 +95,7 @@ X(a, STATIC, REPEATED, MESSAGE, receive_queue, 5) \
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \
|
||||
X(a, STATIC, SINGULAR, UINT32, version, 8) \
|
||||
X(a, STATIC, SINGULAR, BOOL, no_save, 9) \
|
||||
X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part1, 13) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part2, 14) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part3, 15) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part4, 16) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part5, 17)
|
||||
X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11)
|
||||
#define DeviceState_CALLBACK NULL
|
||||
#define DeviceState_DEFAULT NULL
|
||||
#define DeviceState_legacyRadio_MSGTYPE LegacyRadioConfig
|
||||
@@ -140,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg;
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define LegacyRadioConfig_size 4
|
||||
#define LegacyRadioConfig_LegacyPreferences_size 2
|
||||
#define DeviceState_size 11014
|
||||
#define DeviceState_size 10002
|
||||
#define ChannelFile_size 832
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -33,6 +33,8 @@ typedef enum _HardwareModel {
|
||||
HardwareModel_ANDROID_SIM = 38,
|
||||
HardwareModel_DIY_V1 = 39,
|
||||
HardwareModel_RAK11200 = 40,
|
||||
HardwareModel_NANO_G1 = 41,
|
||||
HardwareModel_DR_DEV = 43,
|
||||
HardwareModel_PRIVATE_HW = 255
|
||||
} HardwareModel;
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType {
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3,
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4,
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280 = 5,
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6,
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808 = 7,
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3 = 8
|
||||
} RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -185,6 +187,7 @@ typedef struct _RadioConfig_UserPreferences {
|
||||
char canned_message_plugin_messages[200];
|
||||
bool canned_message_plugin_send_bell;
|
||||
bool mqtt_encryption_enabled;
|
||||
float adc_multiplier_override;
|
||||
} RadioConfig_UserPreferences;
|
||||
|
||||
typedef struct _RadioConfig {
|
||||
@@ -223,8 +226,8 @@ typedef struct _RadioConfig {
|
||||
#define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1))
|
||||
|
||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11
|
||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680
|
||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680+1))
|
||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3
|
||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3+1))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -233,9 +236,9 @@ extern "C" {
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default}
|
||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0}
|
||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0, 0}
|
||||
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero}
|
||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0}
|
||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0, 0}
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define RadioConfig_UserPreferences_position_broadcast_secs_tag 1
|
||||
@@ -320,6 +323,7 @@ extern "C" {
|
||||
#define RadioConfig_UserPreferences_canned_message_plugin_messages_tag 172
|
||||
#define RadioConfig_UserPreferences_canned_message_plugin_send_bell_tag 173
|
||||
#define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174
|
||||
#define RadioConfig_UserPreferences_adc_multiplier_override_tag 175
|
||||
#define RadioConfig_preferences_tag 1
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
@@ -411,7 +415,8 @@ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_enabled, 170) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_source, 171) \
|
||||
X(a, STATIC, SINGULAR, STRING, canned_message_plugin_messages, 172) \
|
||||
X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_send_bell, 173) \
|
||||
X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174)
|
||||
X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \
|
||||
X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175)
|
||||
#define RadioConfig_UserPreferences_CALLBACK NULL
|
||||
#define RadioConfig_UserPreferences_DEFAULT NULL
|
||||
|
||||
@@ -423,8 +428,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg;
|
||||
#define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define RadioConfig_size 795
|
||||
#define RadioConfig_UserPreferences_size 792
|
||||
#define RadioConfig_size 801
|
||||
#define RadioConfig_UserPreferences_size 798
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -755,7 +755,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
||||
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
||||
res->printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||
Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||
|
||||
client->stop();
|
||||
return;
|
||||
} else {
|
||||
/*
|
||||
@@ -773,6 +773,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
||||
} else {
|
||||
res->printf("Failed to establish http connection\n");
|
||||
Serial.println("Failed to establish http connection");
|
||||
client->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "mesh/PhoneAPI.h"
|
||||
#include "mesh/mesh-pb-constants.h"
|
||||
#include <bluefruit.h>
|
||||
#include <utility/bonding.h>
|
||||
|
||||
static BLEService meshBleService = BLEService(BLEUuid(MESH_SERVICE_UUID_16));
|
||||
static BLECharacteristic fromNum = BLECharacteristic(BLEUuid(FROMNUM_UUID_16));
|
||||
@@ -266,3 +267,13 @@ void updateBatteryLevel(uint8_t level)
|
||||
{
|
||||
blebas.write(level);
|
||||
}
|
||||
|
||||
void NRF52Bluetooth::clearBonds()
|
||||
{
|
||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
}
|
||||
@@ -5,5 +5,6 @@ class NRF52Bluetooth
|
||||
public:
|
||||
void setup();
|
||||
void shutdown();
|
||||
void clearBonds();
|
||||
};
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ void __attribute__((noreturn)) __assert_func(const char *file, int line, const c
|
||||
{
|
||||
DEBUG_MSG("assert failed %s: %d, %s, test=%s\n", file, line, func, failedexpr);
|
||||
// debugger_break(); FIXME doesn't work, possibly not for segger
|
||||
while (1)
|
||||
; // FIXME, reboot!
|
||||
// Reboot cpu
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void getMacAddr(uint8_t *dmac)
|
||||
@@ -75,7 +75,7 @@ void setBluetoothEnable(bool on)
|
||||
else {
|
||||
nrf52Bluetooth = new NRF52Bluetooth();
|
||||
nrf52Bluetooth->setup();
|
||||
|
||||
|
||||
// We delay brownout init until after BLE because BLE starts soft device
|
||||
initBrownout();
|
||||
}
|
||||
@@ -185,4 +185,12 @@ void cpuDeepSleep(uint64_t msecToWake)
|
||||
delay(5000);
|
||||
DEBUG_MSG(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearBonds() {
|
||||
if (!nrf52Bluetooth) {
|
||||
nrf52Bluetooth = new NRF52Bluetooth();
|
||||
nrf52Bluetooth->setup();
|
||||
}
|
||||
nrf52Bluetooth->clearBonds();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "configuration.h"
|
||||
#include "CannedMessagePlugin.h"
|
||||
#include "PowerFSM.h" // neede for button bypass
|
||||
#include "MeshService.h"
|
||||
|
||||
// TODO: reuse defined from Screen.cpp
|
||||
@@ -111,8 +112,13 @@ int CannedMessagePlugin::handleInputEvent(const InputEvent *event)
|
||||
if (event->inputEvent == static_cast<char>(InputEventChar_KEY_SELECT))
|
||||
{
|
||||
DEBUG_MSG("Canned message event Select\n");
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
|
||||
validEvent = true;
|
||||
// when inactive, call the onebutton shortpress instead. Activate Module only on up/down
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) {
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
}else{
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
|
||||
validEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (validEvent)
|
||||
|
||||
@@ -6,19 +6,22 @@
|
||||
#include "Router.h"
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include <DHT.h>
|
||||
#include <DS18B20.h>
|
||||
#include <OLEDDisplay.h>
|
||||
#include <OLEDDisplayUi.h>
|
||||
#include <OneWire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
#define BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
// Sensors
|
||||
#include "Sensor/BME280Sensor.h"
|
||||
#include "Sensor/BME680Sensor.h"
|
||||
#include "Sensor/DHTSensor.h"
|
||||
#include "Sensor/DallasSensor.h"
|
||||
#include "Sensor/MCP9808Sensor.h"
|
||||
|
||||
BME280Sensor bme280Sensor;
|
||||
BME680Sensor bme680Sensor;
|
||||
DHTSensor dhtSensor;
|
||||
DallasSensor dallasSensor;
|
||||
MCP9808Sensor mcp9808Sensor;
|
||||
|
||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
||||
|
||||
@@ -38,6 +41,7 @@
|
||||
#define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL)
|
||||
#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM)
|
||||
|
||||
|
||||
int32_t EnvironmentalMeasurementPlugin::runOnce()
|
||||
{
|
||||
#ifndef PORTDUINO
|
||||
@@ -45,8 +49,8 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
||||
Uncomment the preferences below if you want to use the plugin
|
||||
without having to configure it from the PythonAPI or WebUI.
|
||||
*/
|
||||
|
||||
/*radioConfig.preferences.environmental_measurement_plugin_measurement_enabled = 1;
|
||||
/*
|
||||
radioConfig.preferences.environmental_measurement_plugin_measurement_enabled = 1;
|
||||
radioConfig.preferences.environmental_measurement_plugin_screen_enabled = 1;
|
||||
radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold = 5;
|
||||
radioConfig.preferences.environmental_measurement_plugin_update_interval = 600;
|
||||
@@ -75,72 +79,30 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
||||
// therefore, we should only enable the sensor loop if measurement is also enabled
|
||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11);
|
||||
this->dht->begin();
|
||||
this->dht->read();
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11/DHT12 on pin: %d\n",
|
||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
oneWire = new OneWire(radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
ds18b20 = new DS18B20(oneWire);
|
||||
this->ds18b20->begin();
|
||||
this->ds18b20->setResolution(12);
|
||||
this->ds18b20->requestTemperatures();
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n",
|
||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22);
|
||||
this->dht->begin();
|
||||
this->dht->read();
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n",
|
||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
unsigned bme280Status;
|
||||
// Default i2c address for BME280
|
||||
bme280Status = bme280.begin(0x76);
|
||||
if (!bme280Status) {
|
||||
DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose diagnostics
|
||||
} else {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened BME280 on default i2c bus");
|
||||
}
|
||||
return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
unsigned bme680Status;
|
||||
// Default i2c address for BME280
|
||||
bme680Status = bme680.begin(0x76);
|
||||
if (!bme680Status) {
|
||||
DEBUG_MSG("Could not find a valid BME680 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose diagnostics
|
||||
} else {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened BME680 on default i2c bus");
|
||||
// Set up oversampling and filter initialization
|
||||
bme680.setTemperatureOversampling(BME680_OS_8X);
|
||||
bme680.setHumidityOversampling(BME680_OS_2X);
|
||||
bme680.setPressureOversampling(BME680_OS_4X);
|
||||
bme680.setIIRFilterSize(BME680_FILTER_SIZE_3);
|
||||
bme680.setGasHeater(320, 150); // 320*C for 150 ms
|
||||
}
|
||||
return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
default:
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||
return (INT32_MAX);
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
return dhtSensor.runOnce();
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
return dallasSensor.runOnce();
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
return bme280Sensor.runOnce();
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
return bme680Sensor.runOnce();
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808:
|
||||
return mcp9808Sensor.runOnce();
|
||||
default:
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||
return (INT32_MAX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (INT32_MAX);
|
||||
} else {
|
||||
if (!radioConfig.preferences.environmental_measurement_plugin_measurement_enabled) {
|
||||
// if we somehow got to a second run of this plugin with measurement disabled, then just wait forever
|
||||
// I can't imagine we'd ever get here though.
|
||||
// if we somehow got to a second run of this plugin with measurement disabled, then just wait forever
|
||||
if (!radioConfig.preferences.environmental_measurement_plugin_measurement_enabled)
|
||||
return (INT32_MAX);
|
||||
}
|
||||
// this is not the first time OSThread library has called this function
|
||||
// so just do what we intend to do on the interval
|
||||
if (sensor_read_error_count > radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold) {
|
||||
@@ -167,22 +129,22 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
||||
if (!sendOurEnvironmentalMeasurement()) {
|
||||
// if we failed to read the sensor, then try again
|
||||
// as soon as we can according to the maximum polling frequency
|
||||
// return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
|
||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
default:
|
||||
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808:
|
||||
return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
default:
|
||||
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +218,6 @@ void EnvironmentalMeasurementPlugin::drawFrame(OLEDDisplay *display, OLEDDisplay
|
||||
String last_temp = String(lastMeasurement.temperature, 0) + "°C";
|
||||
if (radioConfig.preferences.environmental_measurement_plugin_display_farenheit) {
|
||||
last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F";
|
||||
;
|
||||
}
|
||||
display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + lastSender + "(" + String(agoSecs) + "s)");
|
||||
display->drawString(x, y += fontHeight(FONT_SMALL) - 2,"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.relative_humidity, 0) + "%");
|
||||
@@ -278,6 +239,7 @@ bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp
|
||||
DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p->relative_humidity);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p->temperature);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", p->barometric_pressure);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->gas_resistance: %f\n", p->gas_resistance);
|
||||
|
||||
lastMeasurementPacket = packetPool.allocCopy(mp);
|
||||
|
||||
@@ -287,62 +249,42 @@ bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp
|
||||
bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum dest, bool wantReplies)
|
||||
{
|
||||
EnvironmentalMeasurement m;
|
||||
|
||||
m.barometric_pressure = 0; // TODO: Add support for barometric sensors
|
||||
m.barometric_pressure = 0;
|
||||
m.gas_resistance = 0;
|
||||
DEBUG_MSG("-----------------------------------------\n");
|
||||
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Read data\n");
|
||||
|
||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
if (!this->dht->read(true)) {
|
||||
sensor_read_error_count++;
|
||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||
return false;
|
||||
}
|
||||
m.relative_humidity = this->dht->readHumidity();
|
||||
m.temperature = this->dht->readTemperature();
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
if (this->ds18b20->isConversionComplete()) {
|
||||
m.temperature = this->ds18b20->getTempC();
|
||||
m.relative_humidity = 0; // This sensor is temperature only
|
||||
this->ds18b20->requestTemperatures();
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||
if (!dallasSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
} else {
|
||||
sensor_read_error_count++;
|
||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
if (!dhtSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
bme280Sensor.getMeasurement(&m);
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
bme680Sensor.getMeasurement(&m);
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808:
|
||||
mcp9808Sensor.getMeasurement(&m);
|
||||
break;
|
||||
default:
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||
return false;
|
||||
}
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||
if (!this->dht->read(true)) {
|
||||
sensor_read_error_count++;
|
||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||
return false;
|
||||
}
|
||||
m.relative_humidity = this->dht->readHumidity();
|
||||
m.temperature = this->dht->readTemperature();
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280:
|
||||
m.temperature = bme280.readTemperature();
|
||||
m.relative_humidity = bme280.readHumidity();
|
||||
m.barometric_pressure = bme280.readPressure() / 100.0F;
|
||||
break;
|
||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680:
|
||||
m.temperature = bme680.readTemperature();
|
||||
m.relative_humidity = bme680.readHumidity();
|
||||
m.barometric_pressure = bme680.readPressure() / 100.0F;
|
||||
break;
|
||||
default:
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", m.relative_humidity);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", m.temperature);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", m.barometric_pressure);
|
||||
DEBUG_MSG("EnvironmentalMeasurement->gas_resistance: %f\n", m.gas_resistance);
|
||||
|
||||
sensor_read_error_count = 0;
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
#pragma once
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "ProtobufPlugin.h"
|
||||
#include <DHT.h>
|
||||
#include <DS18B20.h>
|
||||
#include <OLEDDisplay.h>
|
||||
#include <OLEDDisplayUi.h>
|
||||
#include <OneWire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public ProtobufPlugin<EnvironmentalMeasurement>
|
||||
{
|
||||
@@ -36,11 +30,6 @@ class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public Pro
|
||||
private:
|
||||
float CelsiusToFarenheit(float c);
|
||||
bool firstTime = 1;
|
||||
DHT *dht = NULL;
|
||||
OneWire *oneWire = NULL;
|
||||
DS18B20 *ds18b20 = NULL;
|
||||
Adafruit_BME280 bme280;
|
||||
Adafruit_BME680 bme680;
|
||||
const MeshPacket *lastMeasurementPacket;
|
||||
uint32_t sensor_read_error_count = 0;
|
||||
};
|
||||
29
src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.cpp
Normal file
29
src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "configuration.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include "BME280Sensor.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
BME280Sensor::BME280Sensor() : EnvironmentalMeasurementSensor {} {
|
||||
}
|
||||
|
||||
int32_t BME280Sensor::runOnce() {
|
||||
unsigned bme280Status;
|
||||
// Default i2c address for BME280
|
||||
bme280Status = bme280.begin(0x76);
|
||||
if (!bme280Status) {
|
||||
DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose diagnostics
|
||||
} else {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened BME280 on default i2c bus");
|
||||
}
|
||||
return BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bool BME280Sensor::getMeasurement(EnvironmentalMeasurement *measurement) {
|
||||
measurement->temperature = bme280.readTemperature();
|
||||
measurement->relative_humidity = bme280.readHumidity();
|
||||
measurement->barometric_pressure = bme280.readPressure() / 100.0F;
|
||||
|
||||
return true;
|
||||
}
|
||||
15
src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h
Normal file
15
src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
#define BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class BME280Sensor : virtual public EnvironmentalMeasurementSensor {
|
||||
private:
|
||||
Adafruit_BME280 bme280;
|
||||
|
||||
public:
|
||||
BME280Sensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override;
|
||||
};
|
||||
36
src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.cpp
Normal file
36
src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "configuration.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include "BME680Sensor.h"
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
BME680Sensor::BME680Sensor() : EnvironmentalMeasurementSensor {} {
|
||||
}
|
||||
|
||||
int32_t BME680Sensor::runOnce() {
|
||||
unsigned bme680Status;
|
||||
// Default i2c address for BME680
|
||||
bme680Status = bme680.begin(0x76);
|
||||
if (!bme680Status) {
|
||||
DEBUG_MSG("Could not find a valid BME680 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose diagnosticsEnvironmentalMeasurementSensor
|
||||
} else {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened BME680 on default i2c bus");
|
||||
// Set up oversampling and filter initialization
|
||||
bme680.setTemperatureOversampling(BME680_OS_8X);
|
||||
bme680.setHumidityOversampling(BME680_OS_2X);
|
||||
bme680.setPressureOversampling(BME680_OS_4X);
|
||||
bme680.setIIRFilterSize(BME680_FILTER_SIZE_3);
|
||||
bme680.setGasHeater(320, 150); // 320*C for 150 ms
|
||||
}
|
||||
return (BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
|
||||
bool BME680Sensor::getMeasurement(EnvironmentalMeasurement *measurement) {
|
||||
measurement->temperature = bme680.readTemperature();
|
||||
measurement->relative_humidity = bme680.readHumidity();
|
||||
measurement->barometric_pressure = bme680.readPressure() / 100.0F;
|
||||
measurement->gas_resistance = bme680.readGas() / 1000.0;
|
||||
|
||||
return true;
|
||||
}
|
||||
15
src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h
Normal file
15
src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
#define BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class BME680Sensor : virtual public EnvironmentalMeasurementSensor {
|
||||
private:
|
||||
Adafruit_BME680 bme680;
|
||||
|
||||
public:
|
||||
BME680Sensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override;
|
||||
};
|
||||
36
src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp
Normal file
36
src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "configuration.h"
|
||||
#include "MeshService.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include "DHTSensor.h"
|
||||
#include <DHT.h>
|
||||
|
||||
DHTSensor::DHTSensor() : EnvironmentalMeasurementSensor {} {
|
||||
}
|
||||
|
||||
int32_t DHTSensor::runOnce() {
|
||||
if (RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 ||
|
||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12) {
|
||||
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11);
|
||||
}
|
||||
else {
|
||||
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22);
|
||||
}
|
||||
|
||||
dht->begin();
|
||||
dht->read();
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11/DHT12 on pin: %d\n",
|
||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
|
||||
bool DHTSensor::getMeasurement(EnvironmentalMeasurement *measurement) {
|
||||
if (!dht->read(true)) {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||
return false;
|
||||
}
|
||||
measurement->relative_humidity = dht->readHumidity();
|
||||
measurement->temperature = dht->readTemperature();
|
||||
return true;
|
||||
}
|
||||
15
src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h
Normal file
15
src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include <DHT.h>
|
||||
|
||||
#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class DHTSensor : virtual public EnvironmentalMeasurementSensor {
|
||||
private:
|
||||
DHT *dht = NULL;
|
||||
|
||||
public:
|
||||
DHTSensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override;
|
||||
};
|
||||
31
src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.cpp
Normal file
31
src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "configuration.h"
|
||||
#include "MeshService.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include "DallasSensor.h"
|
||||
#include <DS18B20.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
DallasSensor::DallasSensor() : EnvironmentalMeasurementSensor {} {
|
||||
}
|
||||
|
||||
int32_t DallasSensor::runOnce() {
|
||||
oneWire = new OneWire(radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
ds18b20 = new DS18B20(oneWire);
|
||||
ds18b20->begin();
|
||||
ds18b20->setResolution(12);
|
||||
ds18b20->requestTemperatures();
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n",
|
||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
|
||||
bool DallasSensor::getMeasurement(EnvironmentalMeasurement *measurement) {
|
||||
if (ds18b20->isConversionComplete()) {
|
||||
measurement->temperature = ds18b20->getTempC();
|
||||
measurement->relative_humidity = 0;
|
||||
ds18b20->requestTemperatures();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
17
src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h
Normal file
17
src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include <DS18B20.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class DallasSensor : virtual public EnvironmentalMeasurementSensor {
|
||||
private:
|
||||
OneWire *oneWire = NULL;
|
||||
DS18B20 *ds18b20 = NULL;
|
||||
|
||||
public:
|
||||
DallasSensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class EnvironmentalMeasurementSensor {
|
||||
protected:
|
||||
EnvironmentalMeasurementSensor() { }
|
||||
|
||||
public:
|
||||
virtual int32_t runOnce() = 0;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) = 0;
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "configuration.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include "MCP9808Sensor.h"
|
||||
#include <Adafruit_MCP9808.h>
|
||||
|
||||
MCP9808Sensor::MCP9808Sensor() : EnvironmentalMeasurementSensor {} {
|
||||
}
|
||||
|
||||
int32_t MCP9808Sensor::runOnce() {
|
||||
unsigned mcp9808Status;
|
||||
// Default i2c address for MCP9808
|
||||
mcp9808Status = mcp9808.begin(0x18);
|
||||
if (!mcp9808Status) {
|
||||
DEBUG_MSG("Could not find a valid MCP9808 sensor, check wiring, address, sensor ID!");
|
||||
} else {
|
||||
DEBUG_MSG("EnvironmentalMeasurement: Opened MCP9808 on default i2c bus");
|
||||
// Reduce resolution from 0.0625 degrees (precision) to 0.125 degrees (high).
|
||||
mcp9808.setResolution(2);
|
||||
}
|
||||
return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
|
||||
bool MCP9808Sensor::getMeasurement(EnvironmentalMeasurement *measurement) {
|
||||
measurement->temperature = mcp9808.readTempC();
|
||||
|
||||
return true;
|
||||
}
|
||||
15
src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h
Normal file
15
src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../mesh/generated/environmental_measurement.pb.h"
|
||||
#include "EnvironmentalMeasurementSensor.h"
|
||||
#include <Adafruit_MCP9808.h>
|
||||
|
||||
#define MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class MCP9808Sensor : virtual public EnvironmentalMeasurementSensor {
|
||||
private:
|
||||
Adafruit_MCP9808 mcp9808;
|
||||
|
||||
public:
|
||||
MCP9808Sensor();
|
||||
virtual int32_t runOnce() override;
|
||||
virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override;
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "plugins/AdminPlugin.h"
|
||||
#include "plugins/CannedMessagePlugin.h"
|
||||
#ifndef PORTDUINO
|
||||
#include "plugins/EnvironmentalMeasurementPlugin.h"
|
||||
#include "plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h"
|
||||
#endif
|
||||
#ifndef NO_ESP32
|
||||
#include "plugins/esp32/SerialPlugin.h"
|
||||
|
||||
@@ -121,7 +121,9 @@ void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
|
||||
p->priority = MeshPacket_Priority_BACKGROUND;
|
||||
prevPacketId = p->id;
|
||||
|
||||
service.sendToMesh(p);
|
||||
|
||||
//send to the mesh, and the phone
|
||||
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||
}
|
||||
|
||||
int32_t PositionPlugin::runOnce()
|
||||
|
||||
@@ -36,3 +36,7 @@ cstyleCast
|
||||
// ignore stuff that is not ours
|
||||
*:.pio/*
|
||||
*:*/libdeps/*
|
||||
|
||||
// these two caused issues
|
||||
missingOverride
|
||||
virtualCallInConstructor
|
||||
|
||||
@@ -5,7 +5,7 @@ board = wiscore_rak4631
|
||||
# add our variants files to the include and src paths
|
||||
# define build flags for the TFT_eSPI library
|
||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_5005
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||
debug_tool = jlink
|
||||
|
||||
[env:rak4631_19003]
|
||||
@@ -14,7 +14,7 @@ board = wiscore_rak4631
|
||||
# add our variants files to the include and src paths
|
||||
# define build flags for the TFT_eSPI library
|
||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_19003
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||
debug_tool = jlink
|
||||
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
|
||||
;upload_protocol = jlink
|
||||
68
variants/diy/dr-dev/variant.h
Normal file
68
variants/diy/dr-dev/variant.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// For OLED LCD
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 5
|
||||
|
||||
// GPS
|
||||
#undef GPS_RX_PIN
|
||||
#define GPS_RX_PIN NOT_A_PIN
|
||||
|
||||
#define BUTTON_PIN 2 // The middle button GPIO on the T-Beam
|
||||
#define BUTTON_NEED_PULLUP
|
||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||
|
||||
#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module
|
||||
#define LORA_RESET -1 // RST for SX1276, and for SX1262/SX1268
|
||||
#define LORA_DIO1 27 // IRQ for SX1262/SX1268 (IO26 FOR 22S)
|
||||
#define LORA_DIO2 NOT_A_PIN // BUSY for SX1262/SX1268
|
||||
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled
|
||||
|
||||
// In transmitting, set TXEN as high communication level,RXEN pin is low level;
|
||||
// In receiving, set RXEN as high communication level, TXEN is lowlevel;
|
||||
// Before powering off, set TXEN、RXEN as low level.
|
||||
#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level
|
||||
#define LORA_TXEN -1 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level
|
||||
/* --PINS FOR THE 900M22S
|
||||
#undef RF95_SCK
|
||||
#define RF95_SCK 18
|
||||
#undef RF95_MISO
|
||||
#define RF95_MISO 19
|
||||
#undef RF95_MOSI
|
||||
#define RF95_MOSI 23
|
||||
#undef RF95_NSS
|
||||
#define RF95_NSS 16
|
||||
*/
|
||||
|
||||
// PINS FOR THE 900M30S
|
||||
#undef RF95_SCK
|
||||
#define RF95_SCK 18
|
||||
#undef RF95_MISO
|
||||
#define RF95_MISO 19
|
||||
#undef RF95_MOSI
|
||||
#define RF95_MOSI 23
|
||||
#undef RF95_NSS
|
||||
#define RF95_NSS 33
|
||||
|
||||
// RX/TX for RFM95/SX127x
|
||||
#define RF95_RXEN LORA_RXEN
|
||||
#define RF95_TXEN LORA_TXEN
|
||||
// #define RF95_TCXO <GPIO#>
|
||||
|
||||
// common pinouts for SX126X modules
|
||||
#define SX126X_CS 33
|
||||
#define SX126X_DIO1 LORA_DIO1
|
||||
#define SX126X_BUSY 35
|
||||
#define SX126X_RESET LORA_RESET
|
||||
#define SX126X_RXEN LORA_RXEN
|
||||
#define SX126X_TXEN LORA_TXEN
|
||||
|
||||
// supported modules list
|
||||
#define USE_RF95 // RFM95/SX127x
|
||||
#define USE_SX1262
|
||||
#define USE_SX1268
|
||||
#define USE_LLCC68
|
||||
|
||||
#ifdef EBYTE_E22
|
||||
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
|
||||
// (which is the default for the sx1262interface code)
|
||||
#define SX126X_E22
|
||||
#endif
|
||||
@@ -1,3 +1,13 @@
|
||||
; Meshtastic DIY v1 by Nano VHF Schematic based on ESP32-WROOM-32 (38 pins) devkit & EBYTE E22 SX1262/SX1268 module
|
||||
[env:meshtastic-diy-v1]
|
||||
extends = esp32_base
|
||||
board = esp32doit-devkit-v1
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D DIY_V1
|
||||
-D EBYTE_E22
|
||||
-I variants/diy/v1
|
||||
|
||||
; Meshtastic DIY v1.1 new schematic based on ESP32-WROOM-32 & SX1262/SX1268 modules
|
||||
[env:meshtastic-diy-v1.1]
|
||||
extends = esp32_base
|
||||
@@ -6,4 +16,16 @@ build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D DIY_V1
|
||||
-D EBYTE_E22
|
||||
-I variants/diy/v1_1
|
||||
-I variants/diy/v1_1
|
||||
|
||||
; Port to Disaster Radio's ESP32-v3 Dev Board
|
||||
[env:meshtastic-dr-dev]
|
||||
extends = esp32_base
|
||||
board = esp32doit-devkit-v1
|
||||
board_upload.maximum_size = 4194304
|
||||
board_upload.maximum_ram_size = 532480
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D DR_DEV
|
||||
-D EBYTE_E22
|
||||
-I variants/diy/dr-dev
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
//#define GPS_TX_PIN 12 // not connected
|
||||
|
||||
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
||||
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
|
||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975).
|
||||
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||
|
||||
@@ -45,4 +47,4 @@
|
||||
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
|
||||
// (which is the default for the sx1262interface code)
|
||||
#define SX126X_E22
|
||||
#endif
|
||||
#endif
|
||||
@@ -24,8 +24,7 @@
|
||||
#define LORA_DIO1 35 // Not really used
|
||||
#define LORA_DIO2 34 // Not really used
|
||||
|
||||
// ratio of voltage divider = 3.20 (schematic R12=100k, R10=220k)
|
||||
// device to device variations, the actual ratio can be between 3.2 and 4
|
||||
#define ADC_MULTIPLIER 3.6 // best fit
|
||||
#define ADC_MULTIPLIER 3.8
|
||||
|
||||
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
|
||||
|
||||
@@ -6,7 +6,7 @@ board = lora_isp4520
|
||||
build_flags = ${nrf52_base.build_flags} -Ivariants/lora_isp4520
|
||||
|
||||
# No screen and GPS on the board. We still need RTC.cpp for the RTC clock.
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/lora_isp4520> -<graphics> -<gps> +<gps/GPS.cpp> +<gps/RTC.cpp>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_isp4520> -<graphics> -<gps> +<gps/GPS.cpp> +<gps/RTC.cpp>
|
||||
lib_ignore = ${nrf52_base.lib_ignore}
|
||||
ESP8266_SSD1306
|
||||
SparkFun Ublox Arduino Library
|
||||
|
||||
@@ -14,7 +14,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v1
|
||||
-DTFT_DC=ST7735_RS
|
||||
-DTFT_RST=ST7735_RESET
|
||||
-DSPI_FREQUENCY=27000000
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/lora_relay_v1>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v1>
|
||||
lib_deps =
|
||||
${nrf52840_base.lib_deps}
|
||||
SparkFun BQ27441 LiPo Fuel Gauge Arduino Library
|
||||
|
||||
@@ -16,7 +16,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v2
|
||||
-DSPI_FREQUENCY=27000000
|
||||
-DTFT_WR=ST7735_SDA
|
||||
-DTFT_SCLK=ST7735_SCK
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/lora_relay_v2>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v2>
|
||||
lib_deps =
|
||||
${nrf52840_base.lib_deps}
|
||||
SparkFun BQ27441 LiPo Fuel Gauge Arduino Library
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
; Meshtastic DIY v1 by Nano VHF Schematic based on ESP32-WROOM-32 (38 pins) devkit & EBYTE E22 SX1262/SX1268 module
|
||||
[env:meshtastic-diy-v1]
|
||||
extends = esp32_base
|
||||
board = esp32doit-devkit-v1
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D DIY_V1
|
||||
-D EBYTE_E22
|
||||
-I variants/meshtastic_diy_v1
|
||||
8
variants/nano-g1/platformio.ini
Normal file
8
variants/nano-g1/platformio.ini
Normal file
@@ -0,0 +1,8 @@
|
||||
; The 1.0 release of the nano-g1 board
|
||||
[env:nano-g1]
|
||||
extends = esp32_base
|
||||
board = ttgo-t-beam
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
build_flags =
|
||||
${esp32_base.build_flags} -D NANO_G1 -I variants/nano-g1
|
||||
32
variants/nano-g1/variant.h
Normal file
32
variants/nano-g1/variant.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
|
||||
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
|
||||
#define BUTTON_PIN 36 // The middle button GPIO on the Nano G1
|
||||
//#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented anywhere.
|
||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||
|
||||
// common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
||||
// not found then probe for SX1262
|
||||
#define USE_RF95
|
||||
#define USE_SX1262
|
||||
|
||||
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
||||
#define LORA_RESET 23
|
||||
#define LORA_DIO1 33 // SX1262 IRQ
|
||||
#define LORA_DIO2 32 // SX1262 BUSY
|
||||
#define LORA_DIO3 // Not connected on PCB
|
||||
|
||||
#ifdef USE_SX1262
|
||||
#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead
|
||||
#define SX126X_DIO1 LORA_DIO1
|
||||
#define SX126X_BUSY LORA_DIO2
|
||||
#define SX126X_RESET LORA_RESET
|
||||
#define SX126X_E22 // Not really an E22
|
||||
// Internally the module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface
|
||||
// code)
|
||||
#endif
|
||||
|
||||
// different screen
|
||||
#define USE_SH1106
|
||||
@@ -4,4 +4,4 @@ extends = nrf52840_base
|
||||
board = nrf52840_dk_modified
|
||||
# add our variants files to the include and src paths
|
||||
build_flags = ${nrf52_base.build_flags} -Ivariants/pca10056-rc-clock
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/pca10056-rc-clock>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/pca10056-rc-clock>
|
||||
@@ -1,14 +1,14 @@
|
||||
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
|
||||
[env:native]
|
||||
platform = https://github.com/geeksville/platform-native.git
|
||||
src_filter =
|
||||
${env.src_filter}
|
||||
build_src_filter =
|
||||
${env.build_src_filter}
|
||||
-<esp32/>
|
||||
-<nimble/>
|
||||
-<nrf52/>
|
||||
-<mesh/http/>
|
||||
-<plugins/esp32>
|
||||
-<plugins/EnvironmentalMeasurementPlugin.cpp*>
|
||||
-<plugins/EnvironmentalMeasurement>
|
||||
+<../variants/portduino>
|
||||
build_flags = ${arduino_base.build_flags} -O0 -I variants/portduino
|
||||
framework = arduino
|
||||
@@ -20,14 +20,14 @@ lib_deps =
|
||||
; The Portduino based sim environment on top of a linux OS and touching linux hardware devices
|
||||
[env:linux]
|
||||
platform = https://github.com/geeksville/platform-native.git
|
||||
src_filter =
|
||||
${env.src_filter}
|
||||
build_src_filter =
|
||||
${env.build_src_filter}
|
||||
-<esp32/>
|
||||
-<nimble/>
|
||||
-<nrf52/>
|
||||
-<mesh/http/>
|
||||
-<plugins/esp32>
|
||||
-<plugins/EnvironmentalMeasurementPlugin.cpp*>
|
||||
-<plugins/EnvironmentalMeasurement>
|
||||
+<../variants/portduino>
|
||||
build_flags = ${arduino_base.build_flags} -O0 -lgpiod -I variants/portduino
|
||||
framework = arduino
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
extends = nrf52_base
|
||||
board = ppr1
|
||||
build_flags = ${nrf52_base.build_flags} -Ivariants/ppr1
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/ppr1>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/ppr1>
|
||||
lib_deps =
|
||||
${arduino_base.lib_deps}
|
||||
46
variants/rak11200/pins_arduino.h
Normal file
46
variants/rak11200/pins_arduino.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define EXTERNAL_NUM_INTERRUPTS 16
|
||||
#define NUM_DIGITAL_PINS 40
|
||||
#define NUM_ANALOG_INPUTS 16
|
||||
|
||||
#define analogInputToDigitalPin(p) (((p) < 20) ? (esp32_adc2gpio[(p)]) : -1)
|
||||
#define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1)
|
||||
#define digitalPinHasPWM(p) (p < 34)
|
||||
|
||||
#define LED_GREEN 12
|
||||
#define LED_BLUE 2
|
||||
|
||||
#define LED_BUILTIN LED_GREEN
|
||||
|
||||
static const uint8_t TX = 1;
|
||||
static const uint8_t RX = 3;
|
||||
|
||||
#define TX1 21
|
||||
#define RX1 19
|
||||
|
||||
#define WB_IO1 14
|
||||
#define WB_IO2 27
|
||||
#define WB_IO3 26
|
||||
#define WB_IO4 23
|
||||
#define WB_IO5 13
|
||||
#define WB_IO6 22
|
||||
#define WB_SW1 34
|
||||
#define WB_A0 36
|
||||
#define WB_A1 39
|
||||
#define WB_CS 32
|
||||
#define WB_LED1 12
|
||||
#define WB_LED2 2
|
||||
|
||||
static const uint8_t SDA = 4;
|
||||
static const uint8_t SCL = 5;
|
||||
|
||||
static const uint8_t SS = 32;
|
||||
static const uint8_t MOSI = 25;
|
||||
static const uint8_t MISO = 35;
|
||||
static const uint8_t SCK = 33;
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
5
variants/rak11200/platformio.ini
Normal file
5
variants/rak11200/platformio.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
[env:rak11200]
|
||||
extends = esp32_base
|
||||
board = wiscore_rak11200
|
||||
build_flags =
|
||||
${esp32_base.build_flags} -D RAK_11200 -I variants/rak11200
|
||||
84
variants/rak11200/variant.h
Normal file
84
variants/rak11200/variant.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define EXTERNAL_NUM_INTERRUPTS 16
|
||||
#define NUM_DIGITAL_PINS 40
|
||||
#define NUM_ANALOG_INPUTS 16
|
||||
|
||||
#define analogInputToDigitalPin(p) (((p) < 20) ? (esp32_adc2gpio[(p)]) : -1)
|
||||
#define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1)
|
||||
#define digitalPinHasPWM(p) (p < 34)
|
||||
|
||||
#define LED_GREEN 12
|
||||
#define LED_BLUE 2
|
||||
|
||||
#define LED_BUILTIN LED_GREEN
|
||||
|
||||
static const uint8_t TX = 1;
|
||||
static const uint8_t RX = 3;
|
||||
|
||||
#define TX1 21
|
||||
#define RX1 19
|
||||
|
||||
#define WB_IO1 14
|
||||
#define WB_IO2 27
|
||||
#define WB_IO3 26
|
||||
#define WB_IO4 23
|
||||
#define WB_IO5 13
|
||||
#define WB_IO6 22
|
||||
#define WB_SW1 34
|
||||
#define WB_A0 36
|
||||
#define WB_A1 39
|
||||
#define WB_CS 32
|
||||
#define WB_LED1 12
|
||||
#define WB_LED2 2
|
||||
|
||||
static const uint8_t SDA = 4;
|
||||
static const uint8_t SCL = 5;
|
||||
|
||||
static const uint8_t SS = 32;
|
||||
static const uint8_t MOSI = 25;
|
||||
static const uint8_t MISO = 35;
|
||||
static const uint8_t SCK = 33;
|
||||
#endif /* Pins_Arduino_h */
|
||||
|
||||
/* -------- Meshtastic pins -------- */
|
||||
#define I2C_SDA SDA
|
||||
#define I2C_SCL SCL
|
||||
|
||||
#undef GPS_RX_PIN
|
||||
#define GPS_RX_PIN (RX1)
|
||||
#undef GPS_TX_PIN
|
||||
#define GPS_TX_PIN (TX1)
|
||||
|
||||
#define LED_PIN LED_BLUE
|
||||
|
||||
#define PIN_VBAT WB_A0
|
||||
|
||||
// https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/
|
||||
|
||||
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
||||
#define LORA_RESET WB_IO4 // RST for SX1276, and for SX1262/SX1268
|
||||
#define LORA_DIO1 WB_IO6 // IRQ for SX1262/SX1268
|
||||
#define LORA_DIO2 WB_IO5 // BUSY for SX1262/SX1268
|
||||
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled
|
||||
|
||||
#undef RF95_SCK
|
||||
#define RF95_SCK SCK
|
||||
#undef RF95_MISO
|
||||
#define RF95_MISO MISO
|
||||
#undef RF95_MOSI
|
||||
#define RF95_MOSI MOSI
|
||||
#undef RF95_NSS
|
||||
#define RF95_NSS SS
|
||||
|
||||
#define USE_SX1262
|
||||
#define SX126X_CS (SS)// NSS for SX126X
|
||||
#define SX126X_DIO1 (LORA_DIO1)
|
||||
#define SX126X_BUSY (LORA_DIO2)
|
||||
#define SX126X_RESET (LORA_RESET)
|
||||
#define SX126X_TXEN (-1)
|
||||
#define SX126X_RXEN (WB_IO3)
|
||||
#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
||||
@@ -9,7 +9,7 @@ upload_protocol = jlink
|
||||
# -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30
|
||||
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
||||
src_filter = ${nrf52_base.src_filter} +<../variants/t-echo>
|
||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo>
|
||||
lib_deps =
|
||||
${nrf52840_base.lib_deps}
|
||||
https://github.com/geeksville/GxEPD2.git
|
||||
|
||||
@@ -226,7 +226,7 @@ External serial flash WP25R1635FZUIL0
|
||||
#define PIN_SPI1_SCK PIN_EINK_SCLK
|
||||
|
||||
/*
|
||||
* Air530 GPS pins
|
||||
* GPS pins
|
||||
*/
|
||||
|
||||
#define PIN_GPS_WAKE (32 + 2) // An output to wake GPS, low means allow sleep, high means force wake
|
||||
@@ -235,6 +235,8 @@ External serial flash WP25R1635FZUIL0
|
||||
#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU
|
||||
#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS
|
||||
|
||||
#define GPS_THREAD_INTERVAL 50
|
||||
|
||||
#define PIN_SERIAL1_RX PIN_GPS_TX
|
||||
#define PIN_SERIAL1_TX PIN_GPS_RX
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[VERSION]
|
||||
major = 1
|
||||
minor = 2
|
||||
build = 53
|
||||
build = 65
|
||||
|
||||
Reference in New Issue
Block a user