mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-30 05:32:08 +00:00
Compare commits
267 Commits
v1.3.12.63
...
v1.3.34.40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
401b5d92aa | ||
|
|
572f9f9295 | ||
|
|
96ce40040c | ||
|
|
d0a1aad7d1 | ||
|
|
ab0095cb05 | ||
|
|
591ae7a803 | ||
|
|
de47cc55a0 | ||
|
|
7e6c22f542 | ||
|
|
2fac581fa3 | ||
|
|
1155727a45 | ||
|
|
1c8e64319c | ||
|
|
ca1e687fd4 | ||
|
|
4c215530f6 | ||
|
|
472fb6e5b0 | ||
|
|
00846439d0 | ||
|
|
a10e56265b | ||
|
|
9fe2ddb082 | ||
|
|
a9ad314307 | ||
|
|
688ac3f8ee | ||
|
|
e79ef0dd35 | ||
|
|
9bc2b4d8d7 | ||
|
|
720cd62943 | ||
|
|
4073ba7572 | ||
|
|
39aa7f9880 | ||
|
|
71a9f46451 | ||
|
|
18d5712ecd | ||
|
|
295dca8415 | ||
|
|
7b438cd16b | ||
|
|
d285a2e70a | ||
|
|
2ad9e238e2 | ||
|
|
2d2f306982 | ||
|
|
7afc14991e | ||
|
|
86095323e5 | ||
|
|
01ac8d10b5 | ||
|
|
874d308b50 | ||
|
|
1f8878bd89 | ||
|
|
b39b58c87b | ||
|
|
fab20f5acf | ||
|
|
21f75686a4 | ||
|
|
4ad2e58047 | ||
|
|
e26975ca12 | ||
|
|
47da3b695a | ||
|
|
151321ac3c | ||
|
|
faac761dc0 | ||
|
|
5e2acc43f5 | ||
|
|
25a229ce85 | ||
|
|
41f9541f95 | ||
|
|
d64c552865 | ||
|
|
785c2b32da | ||
|
|
ba9d52da25 | ||
|
|
44ffdc5172 | ||
|
|
edd6f049cf | ||
|
|
97684c6c73 | ||
|
|
ade32b1827 | ||
|
|
69ac8c0353 | ||
|
|
fd27a814b7 | ||
|
|
f0518bc99a | ||
|
|
13a287ce5c | ||
|
|
7e7872605b | ||
|
|
a41735544b | ||
|
|
dcc6a4b5e7 | ||
|
|
c88ba583c6 | ||
|
|
b36cd32c03 | ||
|
|
43733ce150 | ||
|
|
0010231172 | ||
|
|
50300957db | ||
|
|
07d4773722 | ||
|
|
62aa740c93 | ||
|
|
c292e539d4 | ||
|
|
4de6d5bdb0 | ||
|
|
cf4c814b59 | ||
|
|
ca8e307976 | ||
|
|
b51b7d3eb7 | ||
|
|
ea7da3178b | ||
|
|
3011d09c8c | ||
|
|
d179f02519 | ||
|
|
67a7056025 | ||
|
|
930b023d10 | ||
|
|
4daf2cc3fa | ||
|
|
85f46d3231 | ||
|
|
d56094fb7c | ||
|
|
9c21064634 | ||
|
|
20d7d1b162 | ||
|
|
97a2bf6221 | ||
|
|
dff69157d6 | ||
|
|
38088253f8 | ||
|
|
7485c312dd | ||
|
|
0e560b376f | ||
|
|
6ff5ada7d6 | ||
|
|
cf331dc58b | ||
|
|
8c2af4f3d5 | ||
|
|
d7d574e0a7 | ||
|
|
5462d84bfc | ||
|
|
1efcd5e125 | ||
|
|
9fd7abf3d4 | ||
|
|
4a08f86f96 | ||
|
|
3f0ff45232 | ||
|
|
f8ee1ac4f9 | ||
|
|
f26441727c | ||
|
|
c725a6b65f | ||
|
|
9c6da233b9 | ||
|
|
0f2aa7660d | ||
|
|
004a6f9c25 | ||
|
|
d81b043f1d | ||
|
|
9f78dff25f | ||
|
|
e7dfd14917 | ||
|
|
bc47dd574b | ||
|
|
41d5ccc29f | ||
|
|
aead7a23f9 | ||
|
|
c9fd591942 | ||
|
|
c81fbd867d | ||
|
|
cfb76290cb | ||
|
|
46e13d23d9 | ||
|
|
45b2c169aa | ||
|
|
90baf9d8a0 | ||
|
|
a390fc7ea8 | ||
|
|
e0f912ab2a | ||
|
|
646d6f5615 | ||
|
|
cf00ac593f | ||
|
|
ff9f973a1d | ||
|
|
7a50ab4de2 | ||
|
|
c80f260fba | ||
|
|
a7d527c3c3 | ||
|
|
2e2c485f4c | ||
|
|
388865aba7 | ||
|
|
21c6e595a1 | ||
|
|
4a2522dbd3 | ||
|
|
877d72cbad | ||
|
|
63238cb810 | ||
|
|
e87c5d8d34 | ||
|
|
f9bbbfccb3 | ||
|
|
089c91a7ac | ||
|
|
9a5ff935f9 | ||
|
|
515a411e8c | ||
|
|
52f299ec49 | ||
|
|
9285316c78 | ||
|
|
cf380e6cb6 | ||
|
|
c3c359c0cb | ||
|
|
68465f294a | ||
|
|
f63b876b71 | ||
|
|
22fca01323 | ||
|
|
d4a4bcf91a | ||
|
|
d726ed6e7c | ||
|
|
349f6bf502 | ||
|
|
192c10d6d7 | ||
|
|
be8fb73204 | ||
|
|
bc9a4367d1 | ||
|
|
3d3511ceeb | ||
|
|
74e926ef00 | ||
|
|
f3a433f906 | ||
|
|
3c6a2f7bb6 | ||
|
|
1996a2a193 | ||
|
|
b40abbf3ad | ||
|
|
af335e9c06 | ||
|
|
8684fd1c49 | ||
|
|
49e47f3e6d | ||
|
|
d0a8a3018d | ||
|
|
7566ee1fea | ||
|
|
43d48d4fb9 | ||
|
|
2a6633a666 | ||
|
|
0146761850 | ||
|
|
0943e5f500 | ||
|
|
a1dc350231 | ||
|
|
d5a258cebd | ||
|
|
125f76d984 | ||
|
|
b127479961 | ||
|
|
d18aa2e7cb | ||
|
|
d301144efe | ||
|
|
058b5ceddd | ||
|
|
e85baf00c4 | ||
|
|
4a6cad6e46 | ||
|
|
bc05f98685 | ||
|
|
6e671d808a | ||
|
|
1df3dd5f78 | ||
|
|
c9822dee93 | ||
|
|
e1783df49f | ||
|
|
6b8afdadc2 | ||
|
|
f918548e44 | ||
|
|
a1b07ed6aa | ||
|
|
b059fb9e8e | ||
|
|
553b35d0ad | ||
|
|
04478081c6 | ||
|
|
7bd07db2a8 | ||
|
|
5c44c4f772 | ||
|
|
7ff940409e | ||
|
|
cb5c32490c | ||
|
|
e0b63c6692 | ||
|
|
dc8d1d9a84 | ||
|
|
710e2694ef | ||
|
|
7594140afc | ||
|
|
e793d933c6 | ||
|
|
9d8f9613d4 | ||
|
|
61427528b6 | ||
|
|
47ad27f9f6 | ||
|
|
77f096e56c | ||
|
|
5106433572 | ||
|
|
4458b470aa | ||
|
|
90957e6994 | ||
|
|
b73fd32f71 | ||
|
|
2a3272b7d0 | ||
|
|
3fd756900a | ||
|
|
beb8bc9e72 | ||
|
|
1ad5cdc93c | ||
|
|
e8e72d2e08 | ||
|
|
1d0badd468 | ||
|
|
9e87be4f22 | ||
|
|
97899aed26 | ||
|
|
0ee4ba4975 | ||
|
|
bbcccde787 | ||
|
|
42c285bc31 | ||
|
|
c831242f25 | ||
|
|
3c6f36c8f7 | ||
|
|
dfde6cc9c1 | ||
|
|
7816800012 | ||
|
|
ebf132ad21 | ||
|
|
67cf3018b5 | ||
|
|
eafbef0c2f | ||
|
|
4ab831c103 | ||
|
|
3df5ec0b11 | ||
|
|
c5c2765fb4 | ||
|
|
df9e9bc223 | ||
|
|
1ff0032c20 | ||
|
|
18024f1d25 | ||
|
|
313c50d6cf | ||
|
|
80e08f6de9 | ||
|
|
5a256323e2 | ||
|
|
45495c51e6 | ||
|
|
40ded630d0 | ||
|
|
432d06741e | ||
|
|
03b7f2f837 | ||
|
|
2e1b895791 | ||
|
|
9821a0535b | ||
|
|
0b666b827d | ||
|
|
235cacf9b9 | ||
|
|
db28a1562e | ||
|
|
f61d2d9eb4 | ||
|
|
5aef58e87f | ||
|
|
77a2054254 | ||
|
|
48ee995e0d | ||
|
|
c7dfd245e3 | ||
|
|
4e813b098a | ||
|
|
e57dbdd26c | ||
|
|
9512ea45de | ||
|
|
0d09767efd | ||
|
|
5828e6f423 | ||
|
|
c7a9ce7f49 | ||
|
|
95f091041b | ||
|
|
f33e6a0e66 | ||
|
|
fe8bfdb762 | ||
|
|
e8afd4fb4b | ||
|
|
71a43a97cc | ||
|
|
b34b26518b | ||
|
|
b9f25eb85c | ||
|
|
a7fbe024e4 | ||
|
|
1f7fee8e2a | ||
|
|
b8e7c6ee7a | ||
|
|
06b2ed4ebe | ||
|
|
32245a1a8d | ||
|
|
f6982ca726 | ||
|
|
03bbc5eff4 | ||
|
|
0767c0b0e8 | ||
|
|
0d574e35c6 | ||
|
|
b88e75cf2a | ||
|
|
2ee003f2a1 | ||
|
|
1ef70a2489 | ||
|
|
ca3192b3dc | ||
|
|
e1f28982cf |
146
.github/workflows/main.yml
vendored
146
.github/workflows/main.yml
vendored
@@ -1,146 +0,0 @@
|
|||||||
name: Continuous Integration (Legacy serial build)
|
|
||||||
on:
|
|
||||||
# Triggers the workflow on push or pull request events but only for the master branch
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
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 everything
|
|
||||||
run: bin/check-all.sh
|
|
||||||
|
|
||||||
ci-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
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
|
|
||||||
# We actually want to run this every time
|
|
||||||
# if: steps.cache-pip.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio meshtastic adafruit-nrfutil
|
|
||||||
|
|
||||||
# - name: Cache platformio
|
|
||||||
# uses: actions/cache@v1
|
|
||||||
# id: cache-platformio # needed in if test
|
|
||||||
# with:
|
|
||||||
# path: ~/.platformio
|
|
||||||
# key: ${{ runner.os }}-platformio
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
# 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: 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: 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
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
8
.github/workflows/main_matrix.yml
vendored
8
.github/workflows/main_matrix.yml
vendored
@@ -38,7 +38,10 @@ jobs:
|
|||||||
- board: rak4631_eink
|
- board: rak4631_eink
|
||||||
- board: t-echo
|
- board: t-echo
|
||||||
- board: nano-g1
|
- board: nano-g1
|
||||||
|
- board: station-g1
|
||||||
|
- board: m5stack-core
|
||||||
|
- board: m5stack-coreink
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -93,6 +96,9 @@ jobs:
|
|||||||
- board: tbeam0.7
|
- board: tbeam0.7
|
||||||
- board: meshtastic-diy-v1
|
- board: meshtastic-diy-v1
|
||||||
- board: nano-g1
|
- board: nano-g1
|
||||||
|
- board: station-g1
|
||||||
|
- board: m5stack-core
|
||||||
|
- board: m5stack-coreink
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
6
.github/workflows/update_protobufs.yml
vendored
6
.github/workflows/update_protobufs.yml
vendored
@@ -17,9 +17,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Download nanopb
|
- name: Download nanopb
|
||||||
run: |
|
run: |
|
||||||
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.5-linux-x86.tar.gz
|
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.6-linux-x86.tar.gz
|
||||||
tar xvzf nanopb-0.4.5-linux-x86.tar.gz
|
tar xvzf nanopb-0.4.6-linux-x86.tar.gz
|
||||||
mv nanopb-0.4.5-linux-x86 nanopb-0.4.5
|
mv nanopb-0.4.6-linux-x86 nanopb-0.4.6
|
||||||
|
|
||||||
- name: Re-generate protocol buffers
|
- name: Re-generate protocol buffers
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -51,7 +51,8 @@
|
|||||||
"iterator": "cpp",
|
"iterator": "cpp",
|
||||||
"shared_mutex": "cpp",
|
"shared_mutex": "cpp",
|
||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
"esp_nimble_hci.h": "c"
|
"esp_nimble_hci.h": "c",
|
||||||
|
"map": "cpp"
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Blox",
|
"Blox",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ set -e
|
|||||||
VERSION=`bin/buildinfo.py long`
|
VERSION=`bin/buildinfo.py long`
|
||||||
SHORT_VERSION=`bin/buildinfo.py short`
|
SHORT_VERSION=`bin/buildinfo.py short`
|
||||||
|
|
||||||
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"
|
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 station-g1 m5stack-core m5stack-coreink"
|
||||||
#BOARDS_ESP32=tbeam
|
#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
|
# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ IF "__%FILENAME%__" == "____" (
|
|||||||
)
|
)
|
||||||
IF EXIST %FILENAME% (
|
IF EXIST %FILENAME% (
|
||||||
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
||||||
%PYTHON% -m esptool --baud 921600 erase_flash
|
%PYTHON% -m esptool --baud 115200 erase_flash
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x1000 system-info.bin
|
%PYTHON% -m esptool --baud 115200 write_flash 0x1000 system-info.bin
|
||||||
for %%f in (littlefs-*.bin) do (
|
for %%f in (littlefs-*.bin) do (
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x00390000 %%f
|
%PYTHON% -m esptool --baud 115200 write_flash 0x00390000 %%f
|
||||||
)
|
)
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME%
|
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
|
||||||
) else (
|
) else (
|
||||||
echo "Invalid file: %FILENAME%"
|
echo "Invalid file: %FILENAME%"
|
||||||
goto HELP
|
goto HELP
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ IF "__%FILENAME%__" == "____" (
|
|||||||
)
|
)
|
||||||
IF EXIST %FILENAME% (
|
IF EXIST %FILENAME% (
|
||||||
echo Trying to flash update %FILENAME%
|
echo Trying to flash update %FILENAME%
|
||||||
%PYTHON% -m esptool --baud 921600 write_flash 0x10000 %FILENAME%
|
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
|
||||||
echo Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used
|
echo Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used
|
||||||
%PYTHON% -m esptool --baud 921600 erase_region 0xe000 0x2000
|
%PYTHON% -m esptool --baud 115200 erase_region 0xe000 0x2000
|
||||||
) else (
|
) else (
|
||||||
echo "Invalid file: %FILENAME%"
|
echo "Invalid file: %FILENAME%"
|
||||||
goto HELP
|
goto HELP
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ shift "$((OPTIND-1))"
|
|||||||
|
|
||||||
if [ -f "${FILENAME}" ]; then
|
if [ -f "${FILENAME}" ]; then
|
||||||
echo "Trying to flash update ${FILENAME}."
|
echo "Trying to flash update ${FILENAME}."
|
||||||
$PYTHON -m esptool --baud 921600 write_flash 0x10000 ${FILENAME}
|
$PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME}
|
||||||
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
|
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
|
||||||
$PYTHON -m esptool --baud 921600 erase_region 0xe000 0x2000
|
$PYTHON -m esptool --baud 115200 erase_region 0xe000 0x2000
|
||||||
else
|
else
|
||||||
echo "Invalid file: ${FILENAME}"
|
echo "Invalid file: ${FILENAME}"
|
||||||
show_help
|
show_help
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Import("projenv")
|
|||||||
|
|
||||||
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
||||||
verObj = readProps(prefsLoc)
|
verObj = readProps(prefsLoc)
|
||||||
print("Using meshtastic platform-custom.py, firmare version " + verObj['long'])
|
print("Using meshtastic platformio-custom.py, firmware version " + verObj['long'])
|
||||||
# print("path is" + ','.join(sys.path))
|
# print("path is" + ','.join(sys.path))
|
||||||
|
|
||||||
# General options that are passed to the C and C++ compilers
|
# General options that are passed to the C and C++ compilers
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
esptool.py --baud 921600 read_flash 0x1000 0xf000 system-info.img
|
esptool.py --baud 115200 read_flash 0x1000 0xf000 system-info.img
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ def readProps(prefsLoc):
|
|||||||
# traceback.print_exc()
|
# traceback.print_exc()
|
||||||
verObj['long'] = verObj['short']
|
verObj['long'] = verObj['short']
|
||||||
|
|
||||||
# print("firmare version " + verStr)
|
# print("firmware version " + verStr)
|
||||||
return verObj
|
return verObj
|
||||||
# print("path is" + ','.join(sys.path))
|
# print("path is" + ','.join(sys.path))
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
cd protobufs && ..\nanopb-0.4.5\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs *.proto
|
cd protobufs && ..\nanopb-0.4.6\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs *.proto
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.5 to be located in the"
|
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.6 to be located in the"
|
||||||
echo "meshtastic-device root directory if the following step fails, you should download the correct"
|
echo "meshtastic-device root directory if the following step fails, you should download the correct"
|
||||||
echo "prebuilt binaries for your computer into nanopb-0.4.5"
|
echo "prebuilt binaries for your computer into nanopb-0.4.6"
|
||||||
|
|
||||||
# the nanopb tool seems to require that the .options file be in the current directory!
|
# the nanopb tool seems to require that the .options file be in the current directory!
|
||||||
cd protobufs
|
cd protobufs
|
||||||
../nanopb-0.4.5/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated -I=../protobufs *.proto
|
../nanopb-0.4.6/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated -I=../protobufs *.proto
|
||||||
|
|
||||||
#echo "Regenerating protobuf documentation - if you see an error message"
|
#echo "Regenerating protobuf documentation - if you see an error message"
|
||||||
#echo "you can ignore it unless doing a new protobuf release to github."
|
#echo "you can ignore it unless doing a new protobuf release to github."
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ default_envs = tbeam
|
|||||||
;default_envs = pca10059_diy_eink
|
;default_envs = pca10059_diy_eink
|
||||||
;default_envs = meshtastic-diy-v1
|
;default_envs = meshtastic-diy-v1
|
||||||
;default_envs = meshtastic-diy-v1.1
|
;default_envs = meshtastic-diy-v1.1
|
||||||
|
;default_envs = m5stack-coreink
|
||||||
|
|
||||||
extra_configs = variants/*/platformio.ini
|
extra_configs = variants/*/platformio.ini
|
||||||
|
|
||||||
@@ -37,22 +38,18 @@ build_flags = -Wno-missing-field-initializers
|
|||||||
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
|
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
-DPB_ENABLE_MALLOC=1
|
-DPB_ENABLE_MALLOC=1
|
||||||
|
|
||||||
monitor_speed = 921600
|
monitor_speed = 115200
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git#53580644255b48ebb7a737343c6b4e71c7e11cf2 ; ESP8266_SSD1306
|
https://github.com/meshtastic/esp8266-oled-ssd1306.git#53580644255b48ebb7a737343c6b4e71c7e11cf2 ; ESP8266_SSD1306
|
||||||
mathertel/OneButton@^2.0.3 ; 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
|
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/arduino-fsm.git
|
||||||
https://github.com/meshtastic/RadioLib.git#5582ac30578ff3f53f20630a00b2a8a4b8f92c74
|
|
||||||
https://github.com/meshtastic/TinyGPSPlus.git
|
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
|
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
||||||
SPI
|
SPI
|
||||||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||||
PubSubClient
|
|
||||||
nanopb/Nanopb@^0.4.6
|
nanopb/Nanopb@^0.4.6
|
||||||
meshtastic/json11@^1.0.2
|
|
||||||
|
|
||||||
; Used for the code analysis in PIO Home / Inspect
|
; Used for the code analysis in PIO Home / Inspect
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
@@ -63,30 +60,42 @@ check_skip_packages = yes
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
; Portduino is using meshtastic fork for now
|
||||||
|
https://github.com/jgromes/RadioLib.git
|
||||||
|
|
||||||
build_flags = ${env.build_flags} -Os
|
build_flags = ${env.build_flags} -Os
|
||||||
# -DRADIOLIB_GODMODE
|
# -DRADIOLIB_GODMODE
|
||||||
build_src_filter = ${env.build_src_filter} -<portduino/>
|
build_src_filter = ${env.build_src_filter} -<portduino/>
|
||||||
|
|
||||||
; Common libs for environmental measurements (not included in native / portduino)
|
; Common libs for communicating over TCP/IP networks such as MQTT
|
||||||
[environmental]
|
[networking_base]
|
||||||
|
lib_deps =
|
||||||
|
PubSubClient
|
||||||
|
meshtastic/json11@^1.0.2
|
||||||
|
|
||||||
|
; Common libs for environmental measurements in telemetry module
|
||||||
|
; (not included in native / portduino)
|
||||||
|
[environmental_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BusIO@^1.11.4
|
adafruit/Adafruit BusIO@^1.11.4
|
||||||
adafruit/DHT sensor library@^1.4.1
|
|
||||||
adafruit/Adafruit Unified Sensor@^1.1.4
|
adafruit/Adafruit Unified Sensor@^1.1.4
|
||||||
paulstoffregen/OneWire@^2.3.5
|
paulstoffregen/OneWire@^2.3.5
|
||||||
robtillaart/DS18B20@^0.1.11
|
robtillaart/DS18B20@^0.1.11
|
||||||
|
adafruit/Adafruit BMP280 Library@^2.6.3
|
||||||
adafruit/Adafruit BME280 Library@^2.2.2
|
adafruit/Adafruit BME280 Library@^2.2.2
|
||||||
adafruit/Adafruit BME680 Library@^2.0.1
|
adafruit/Adafruit BME680 Library@^2.0.1
|
||||||
adafruit/Adafruit MCP9808 Library@^2.0.0
|
adafruit/Adafruit MCP9808 Library@^2.0.0
|
||||||
|
adafruit/Adafruit INA260 Library@^1.5.0
|
||||||
|
adafruit/Adafruit INA219@^1.2.0
|
||||||
; Common settings for ESP targes, mixin with extends = esp32_base
|
; Common settings for ESP targes, mixin with extends = esp32_base
|
||||||
[esp32_base]
|
[esp32_base]
|
||||||
extends = arduino_base
|
extends = arduino_base
|
||||||
platform = espressif32@3.5.0
|
platform = espressif32@3.5.0
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${arduino_base.build_src_filter} -<nrf52/>
|
${arduino_base.build_src_filter} -<nrf52/> -<stm32wl>
|
||||||
upload_speed = 921600
|
upload_speed = 115200
|
||||||
debug_init_break = tbreak setup
|
debug_init_break = tbreak setup
|
||||||
|
|
||||||
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||||
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||||
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
||||||
@@ -94,14 +103,17 @@ debug_init_break = tbreak setup
|
|||||||
build_flags =
|
build_flags =
|
||||||
${arduino_base.build_flags} -Wall -Wextra -Isrc/esp32 -Isrc/esp32-mfix-esp32-psram-cache-issue -lnimble -std=c++11
|
${arduino_base.build_flags} -Wall -Wextra -Isrc/esp32 -Isrc/esp32-mfix-esp32-psram-cache-issue -lnimble -std=c++11
|
||||||
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
||||||
-DAXP_DEBUG_PORT=Serial -DUSE_NEW_ESP32_BLUETOOTH
|
-DAXP_DEBUG_PORT=Serial -DUSE_NEW_ESP32_BLUETOOTH -DCONFIG_BT_NIMBLE_ENABLED -DCONFIG_NIMBLE_CPP_LOG_LEVEL=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${arduino_base.lib_deps}
|
${arduino_base.lib_deps}
|
||||||
${environmental.lib_deps}
|
${networking_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
https://github.com/meshtastic/esp32_https_server.git
|
https://github.com/meshtastic/esp32_https_server.git
|
||||||
h2zero/NimBLE-Arduino@1.3.7
|
h2zero/NimBLE-Arduino@1.4.0
|
||||||
arduino-libraries/NTPClient@^3.1.0
|
arduino-libraries/NTPClient@^3.1.0
|
||||||
lorol/LittleFS_esp32@^1.0.6
|
lorol/LittleFS_esp32@^1.0.6
|
||||||
|
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
||||||
|
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
segger_rtt
|
segger_rtt
|
||||||
ESP32 BLE Arduino
|
ESP32 BLE Arduino
|
||||||
@@ -132,7 +144,7 @@ build_flags =
|
|||||||
${arduino_base.build_flags} -Wno-unused-variable
|
${arduino_base.build_flags} -Wno-unused-variable
|
||||||
-Isrc/nrf52
|
-Isrc/nrf52
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${arduino_base.build_src_filter} -<esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/>
|
${arduino_base.build_src_filter} -<esp32/> -<stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/>
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
BluetoothOTA
|
BluetoothOTA
|
||||||
|
|
||||||
@@ -141,7 +153,7 @@ extends = nrf52_base
|
|||||||
build_flags = ${nrf52_base.build_flags}
|
build_flags = ${nrf52_base.build_flags}
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${arduino_base.lib_deps}
|
${arduino_base.lib_deps}
|
||||||
${environmental.lib_deps}
|
${environmental_base.lib_deps}
|
||||||
https://github.com/Kongduino/Adafruit_nRFCrypto.git
|
https://github.com/Kongduino/Adafruit_nRFCrypto.git
|
||||||
|
|
||||||
; Note: By default no lora device is created for this build - it uses a simulated interface
|
; Note: By default no lora device is created for this build - it uses a simulated interface
|
||||||
|
|||||||
Submodule protobufs updated: e7791c33fd...7ea5bd3922
@@ -7,7 +7,7 @@
|
|||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include <OneButton.h>
|
#include <OneButton.h>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "nimble/BluetoothUtil.h"
|
#include "nimble/BluetoothUtil.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
static void userButtonPressedLong()
|
static void userButtonPressedLong()
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("Long press!\n");
|
// DEBUG_MSG("Long press!\n");
|
||||||
#ifndef NRF52_SERIES
|
#ifdef ARCH_ESP32
|
||||||
screen->adjustBrightness();
|
screen->adjustBrightness();
|
||||||
#endif
|
#endif
|
||||||
// If user button is held down for 5 seconds, shutdown the device.
|
// If user button is held down for 5 seconds, shutdown the device.
|
||||||
@@ -137,15 +137,22 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
setLed(false);
|
setLed(false);
|
||||||
power->shutdown();
|
power->shutdown();
|
||||||
}
|
}
|
||||||
#elif NRF52_SERIES
|
#elif defined(ARCH_NRF52)
|
||||||
// Do actual shutdown when button released, otherwise the button release
|
// Do actual shutdown when button released, otherwise the button release
|
||||||
// may wake the board immediatedly.
|
// may wake the board immediatedly.
|
||||||
if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) {
|
if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) {
|
||||||
screen->startShutdownScreen();
|
screen->startShutdownScreen();
|
||||||
DEBUG_MSG("Shutdown from long press");
|
DEBUG_MSG("Shutdown from long press");
|
||||||
playBeep();
|
playBeep();
|
||||||
|
#ifdef PIN_LED1
|
||||||
ledOff(PIN_LED1);
|
ledOff(PIN_LED1);
|
||||||
|
#endif
|
||||||
|
#ifdef PIN_LED2
|
||||||
ledOff(PIN_LED2);
|
ledOff(PIN_LED2);
|
||||||
|
#endif
|
||||||
|
#ifdef PIN_LED3
|
||||||
|
ledOff(PIN_LED3);
|
||||||
|
#endif
|
||||||
shutdown_on_long_stop = true;
|
shutdown_on_long_stop = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -156,19 +163,19 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
|
|
||||||
static void userButtonDoublePressed()
|
static void userButtonDoublePressed()
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
disablePin();
|
disablePin();
|
||||||
#elif defined(HAS_EINK)
|
#elif defined(USE_EINK)
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void userButtonMultiPressed()
|
static void userButtonMultiPressed()
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
clearNVS();
|
clearNVS();
|
||||||
#endif
|
#endif
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
clearBonds();
|
clearBonds();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,36 +10,13 @@
|
|||||||
#ifdef CONSOLE_MAX_BAUD
|
#ifdef CONSOLE_MAX_BAUD
|
||||||
#define SERIAL_BAUD CONSOLE_MAX_BAUD
|
#define SERIAL_BAUD CONSOLE_MAX_BAUD
|
||||||
#else
|
#else
|
||||||
#define SERIAL_BAUD 921600 // Serial debug baud rate
|
#define SERIAL_BAUD 115200 // Serial debug baud rate
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SerialConsole.h"
|
#include "SerialConsole.h"
|
||||||
|
|
||||||
#define DEBUG_PORT (*console) // Serial debug port
|
#define DEBUG_PORT (*console) // Serial debug port
|
||||||
|
|
||||||
// What platforms should use SEGGER?
|
|
||||||
#ifdef NRF52_SERIES
|
|
||||||
|
|
||||||
// Always include the SEGGER code on NRF52 - because useful for debugging
|
|
||||||
#include "SEGGER_RTT.h"
|
|
||||||
|
|
||||||
// The channel we send stdout data to
|
|
||||||
#define SEGGER_STDOUT_CH 0
|
|
||||||
|
|
||||||
// Debug printing to segger console
|
|
||||||
#define SEGGER_MSG(...) SEGGER_RTT_printf(SEGGER_STDOUT_CH, __VA_ARGS__)
|
|
||||||
|
|
||||||
// If we are not on a NRF52840 (which has built in USB-ACM serial support) and we don't have serial pins hooked up, then we MUST
|
|
||||||
// use SEGGER for debug output
|
|
||||||
#if !defined(PIN_SERIAL_RX) && !defined(NRF52840_XXAA)
|
|
||||||
// No serial ports on this board - ONLY use segger in memory console
|
|
||||||
#define USE_SEGGER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SEGGER
|
#ifdef USE_SEGGER
|
||||||
#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1,9 +1,49 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
|
|
||||||
void listDir(const char * dirname, uint8_t levels)
|
|
||||||
#ifdef FSCom
|
bool copyFile(const char* from, const char* to)
|
||||||
{
|
{
|
||||||
|
#ifdef FSCom
|
||||||
|
unsigned char cbuffer[16];
|
||||||
|
|
||||||
|
File f1 = FSCom.open(from, FILE_O_READ);
|
||||||
|
if (!f1){
|
||||||
|
DEBUG_MSG("Failed to open file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File f2 = FSCom.open(to, FILE_O_WRITE);
|
||||||
|
if (!f2) {
|
||||||
|
DEBUG_MSG("Failed to open file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (f1.available() > 0) {
|
||||||
|
byte i = f1.read(cbuffer, 16);
|
||||||
|
f2.write(cbuffer, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
f2.close();
|
||||||
|
f1.close();
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool renameFile(const char* pathFrom, const char* pathTo)
|
||||||
|
{
|
||||||
|
#ifdef FSCom
|
||||||
|
if (copyFile(pathFrom, pathTo) && FSCom.remove(pathFrom) ) {
|
||||||
|
return true;
|
||||||
|
} else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void listDir(const char * dirname, uint8_t levels)
|
||||||
|
{
|
||||||
|
#ifdef FSCom
|
||||||
File root = FSCom.open(dirname);
|
File root = FSCom.open(dirname);
|
||||||
if(!root){
|
if(!root){
|
||||||
return;
|
return;
|
||||||
@@ -28,6 +68,46 @@ void listDir(const char * dirname, uint8_t levels)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rmDir(const char * dirname)
|
||||||
|
{
|
||||||
|
#ifdef FSCom
|
||||||
|
File file = FSCom.open(dirname);
|
||||||
|
if(!file){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!file.isDirectory()){
|
||||||
|
file.close();
|
||||||
|
FSCom.remove(file.name());
|
||||||
|
// DEBUG_MSG("Remove FILE %s\n", file.name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.rewindDirectory();
|
||||||
|
while (true) {
|
||||||
|
File entry = file.openNextFile();
|
||||||
|
if (!entry) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
char dirpath[100]; // array to hold the result.
|
||||||
|
strcpy(dirpath, dirname); // copy string one into the result.
|
||||||
|
strcat(dirpath,"/"); // append string two to the result.
|
||||||
|
strcat(dirpath,entry.name()); // append string two to the result.
|
||||||
|
if(entry.isDirectory() && !String(entry.name()).endsWith(".")) {
|
||||||
|
entry.close();
|
||||||
|
// DEBUG_MSG("Descend DIR %s\n", dirpath);
|
||||||
|
rmDir(dirpath);
|
||||||
|
} else {
|
||||||
|
entry.close();
|
||||||
|
// DEBUG_MSG("Remove FILE %s\n", entry.name());
|
||||||
|
FSCom.remove(entry.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FSCom.rmdir(dirname);
|
||||||
|
// DEBUG_MSG("Remove DIR %s\n", dirname);
|
||||||
|
file.close();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void fsInit()
|
void fsInit()
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
|
|||||||
@@ -4,21 +4,25 @@
|
|||||||
|
|
||||||
// Cross platform filesystem API
|
// Cross platform filesystem API
|
||||||
|
|
||||||
#ifdef PORTDUINO
|
#if defined(ARCH_PORTDUINO)
|
||||||
// Portduino version
|
// Portduino version
|
||||||
#include "PortduinoFS.h"
|
#include "PortduinoFS.h"
|
||||||
#define FSCom PortduinoFS
|
#define FSCom PortduinoFS
|
||||||
#define FSBegin() true
|
#define FSBegin() true
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#elif !defined(NO_ESP32)
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARCH_ESP32)
|
||||||
// ESP32 version
|
// ESP32 version
|
||||||
#include "LITTLEFS.h"
|
#include "LITTLEFS.h"
|
||||||
#define FSCom LITTLEFS
|
#define FSCom LITTLEFS
|
||||||
#define FSBegin() FSCom.begin(true)
|
#define FSBegin() FSCom.begin(true)
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARCH_NRF52)
|
||||||
// NRF52 version
|
// NRF52 version
|
||||||
#include "InternalFileSystem.h"
|
#include "InternalFileSystem.h"
|
||||||
#define FSCom InternalFS
|
#define FSCom InternalFS
|
||||||
@@ -26,4 +30,7 @@
|
|||||||
using namespace Adafruit_LittleFS_Namespace;
|
using namespace Adafruit_LittleFS_Namespace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void fsInit();
|
void fsInit();
|
||||||
|
bool renameFile(const char* pathFrom, const char* pathTo);
|
||||||
|
void listDir(const char * dirname, uint8_t levels);
|
||||||
|
void rmDir(const char * dirname);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ bool scheduleOSCallback(PendableFunction callback, void *param1, uint32_t param2
|
|||||||
return xTimerPendFunctionCall(callback, param1, param2, pdMS_TO_TICKS(delayMsec));
|
return xTimerPendFunctionCall(callback, param1, param2, pdMS_TO_TICKS(delayMsec));
|
||||||
} */
|
} */
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
// Super skanky quick hack to use hardware timers of the ESP32
|
// Super skanky quick hack to use hardware timers of the ESP32
|
||||||
static hw_timer_t *timer;
|
static hw_timer_t *timer;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "buzz/buzz.h"
|
||||||
|
|
||||||
#ifdef TBEAM_V10
|
#ifdef TBEAM_V10
|
||||||
// FIXME. nasty hack cleanup how we load axp192
|
// FIXME. nasty hack cleanup how we load axp192
|
||||||
@@ -45,7 +46,7 @@ Power *power;
|
|||||||
using namespace meshtastic;
|
using namespace meshtastic;
|
||||||
|
|
||||||
#ifndef AREF_VOLTAGE
|
#ifndef AREF_VOLTAGE
|
||||||
#if defined(NRF52_SERIES)
|
#if defined(ARCH_NRF52)
|
||||||
/*
|
/*
|
||||||
* Internal Reference is +/-0.6V, with an adjustable gain of 1/6, 1/5, 1/4,
|
* Internal Reference is +/-0.6V, with an adjustable gain of 1/6, 1/5, 1/4,
|
||||||
* 1/3, 1/2 or 1, meaning 3.6, 3.0, 2.4, 1.8, 1.2 or 0.6V for the ADC levels.
|
* 1/3, 1/2 or 1, meaning 3.6, 3.0, 2.4, 1.8, 1.2 or 0.6V for the ADC levels.
|
||||||
@@ -83,7 +84,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
if (v < noBatVolt)
|
if (v < noBatVolt)
|
||||||
return -1; // If voltage is super low assume no battery installed
|
return -1; // If voltage is super low assume no battery installed
|
||||||
|
|
||||||
#ifndef NRF52_SERIES
|
#ifdef ARCH_ESP32
|
||||||
// This does not work on a RAK4631 with battery connected
|
// This does not work on a RAK4631 with battery connected
|
||||||
if (v > chargingVolt)
|
if (v > chargingVolt)
|
||||||
return 0; // While charging we can't report % full on the battery
|
return 0; // While charging we can't report % full on the battery
|
||||||
@@ -111,7 +112,18 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
const uint32_t min_read_interval = 5000;
|
const uint32_t min_read_interval = 5000;
|
||||||
if (millis() - last_read_time_ms > min_read_interval) {
|
if (millis() - last_read_time_ms > min_read_interval) {
|
||||||
last_read_time_ms = millis();
|
last_read_time_ms = millis();
|
||||||
|
|
||||||
|
#ifdef BATTERY_SENSE_SAMPLES
|
||||||
|
//Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment.
|
||||||
|
uint32_t raw = 0;
|
||||||
|
for(uint32_t i=0; i<BATTERY_SENSE_SAMPLES;i++){
|
||||||
|
raw += analogRead(BATTERY_PIN);
|
||||||
|
}
|
||||||
|
raw = raw/BATTERY_SENSE_SAMPLES;
|
||||||
|
#else
|
||||||
uint32_t raw = analogRead(BATTERY_PIN);
|
uint32_t raw = analogRead(BATTERY_PIN);
|
||||||
|
#endif
|
||||||
|
|
||||||
float scaled;
|
float scaled;
|
||||||
#ifndef VBAT_RAW_TO_SCALED
|
#ifndef VBAT_RAW_TO_SCALED
|
||||||
scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw;
|
scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw;
|
||||||
@@ -168,11 +180,11 @@ bool Power::analogInit()
|
|||||||
// disable any internal pullups
|
// disable any internal pullups
|
||||||
pinMode(BATTERY_PIN, INPUT);
|
pinMode(BATTERY_PIN, INPUT);
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// ESP32 needs special analog stuff
|
// ESP32 needs special analog stuff
|
||||||
adcAttachPin(BATTERY_PIN);
|
adcAttachPin(BATTERY_PIN);
|
||||||
#endif
|
#endif
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
#ifdef VBAT_AR_INTERNAL
|
#ifdef VBAT_AR_INTERNAL
|
||||||
analogReference(VBAT_AR_INTERNAL);
|
analogReference(VBAT_AR_INTERNAL);
|
||||||
#else
|
#else
|
||||||
@@ -211,8 +223,12 @@ void Power::shutdown()
|
|||||||
{
|
{
|
||||||
#ifdef TBEAM_V10
|
#ifdef TBEAM_V10
|
||||||
DEBUG_MSG("Shutting down\n");
|
DEBUG_MSG("Shutting down\n");
|
||||||
|
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||||
axp.shutdown();
|
axp.shutdown();
|
||||||
#elif NRF52_SERIES
|
#elif defined(ARCH_NRF52)
|
||||||
|
playBeep();
|
||||||
|
ledOff(PIN_LED1);
|
||||||
|
ledOff(PIN_LED2);
|
||||||
doDeepSleep(DELAY_FOREVER);
|
doDeepSleep(DELAY_FOREVER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -251,7 +267,7 @@ void Power::readPowerStatus()
|
|||||||
|
|
||||||
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
|
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
|
||||||
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
|
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
||||||
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) {
|
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) {
|
||||||
low_voltage_counter++;
|
low_voltage_counter++;
|
||||||
|
|||||||
@@ -11,23 +11,23 @@
|
|||||||
/// Should we behave as if we have AC power now?
|
/// Should we behave as if we have AC power now?
|
||||||
static bool isPowered()
|
static bool isPowered()
|
||||||
{
|
{
|
||||||
// Completely circumvents the battery / power sensing logic and assumes constant power source
|
// Circumvent the battery sensing logic and assumes constant power if no battery pin or power mgmt IC
|
||||||
if (config.power.is_always_powered) {
|
#if !defined(BATTERY_PIN) && !defined(AXP192_SLAVE_ADDRESS)
|
||||||
return true;
|
return true;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
|
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
|
||||||
|
|
||||||
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
|
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
|
||||||
// We assume routers might be powered all the time, but from a low current (solar) source
|
// We assume routers might be powered all the time, but from a low current (solar) source
|
||||||
bool isLowPower = config.power.is_low_power || isRouter;
|
bool isPowerSavingMode = config.power.is_power_saving || isRouter;
|
||||||
|
|
||||||
/* To determine if we're externally powered, assumptions
|
/* To determine if we're externally powered, assumptions
|
||||||
1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise)
|
1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise)
|
||||||
|
|
||||||
2) If we detect USB power from the power management chip, we must be getting power externally.
|
2) If we detect USB power from the power management chip, we must be getting power externally.
|
||||||
*/
|
*/
|
||||||
return !isLowPower && powerStatus && (!powerStatus->getHasBattery() || powerStatus->getHasUSB());
|
return !isPowerSavingMode && powerStatus && (!powerStatus->getHasBattery() || powerStatus->getHasUSB());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdsEnter()
|
static void sdsEnter()
|
||||||
@@ -63,7 +63,7 @@ static void lsIdle()
|
|||||||
{
|
{
|
||||||
// DEBUG_MSG("lsIdle begin ls_secs=%u\n", getPref_ls_secs());
|
// DEBUG_MSG("lsIdle begin ls_secs=%u\n", getPref_ls_secs());
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
// Do we have more sleeping to do?
|
// Do we have more sleeping to do?
|
||||||
if (secsSlept < config.power.ls_secs ? config.power.ls_secs : default_ls_secs * 1000) {
|
if (secsSlept < config.power.ls_secs ? config.power.ls_secs : default_ls_secs * 1000) {
|
||||||
@@ -335,7 +335,7 @@ void PowerFSM_setup()
|
|||||||
|
|
||||||
powerFSM.add_timed_transition(&stateON, &stateDARK,
|
powerFSM.add_timed_transition(&stateON, &stateDARK,
|
||||||
config.display.screen_on_secs ? config.display.screen_on_secs
|
config.display.screen_on_secs ? config.display.screen_on_secs
|
||||||
: 60 * 1000,
|
: 60 * 1000 * 10,
|
||||||
NULL, "Screen-on timeout");
|
NULL, "Screen-on timeout");
|
||||||
|
|
||||||
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
|
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
|
||||||
@@ -343,14 +343,11 @@ void PowerFSM_setup()
|
|||||||
|
|
||||||
uint32_t meshSds = 0;
|
uint32_t meshSds = 0;
|
||||||
|
|
||||||
#ifndef NRF52_SERIES
|
#ifdef ARCH_ESP32
|
||||||
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
|
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
|
||||||
|
|
||||||
// See: https://github.com/meshtastic/Meshtastic-device/issues/1071
|
// See: https://github.com/meshtastic/Meshtastic-device/issues/1071
|
||||||
if (isRouter || config.power.is_power_saving) {
|
if (isRouter || config.power.is_power_saving) {
|
||||||
|
|
||||||
// I don't think this transition is correct, turning off for now - @geeksville
|
|
||||||
// powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout");
|
|
||||||
powerFSM.add_timed_transition(&stateNB, &stateLS,
|
powerFSM.add_timed_transition(&stateNB, &stateLS,
|
||||||
config.power.min_wake_secs ? config.power.min_wake_secs
|
config.power.min_wake_secs ? config.power.min_wake_secs
|
||||||
: default_min_wake_secs * 1000,
|
: default_min_wake_secs * 1000,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#define Port Serial
|
#define Port Serial
|
||||||
|
// Defaulting to the formerly removed phone_timeout_secs value of 15 minutes
|
||||||
|
#define SERIAL_CONNECTION_TIMEOUT (15 * 60) * 1000UL
|
||||||
|
|
||||||
SerialConsole *console;
|
SerialConsole *console;
|
||||||
|
|
||||||
@@ -28,7 +30,7 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
|||||||
// setDestination(&noopPrint); for testing, try turning off 'all' debug output and see what leaks
|
// setDestination(&noopPrint); for testing, try turning off 'all' debug output and see what leaks
|
||||||
|
|
||||||
Port.begin(SERIAL_BAUD);
|
Port.begin(SERIAL_BAUD);
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
time_t timeout = millis();
|
time_t timeout = millis();
|
||||||
while (!Port) {
|
while (!Port) {
|
||||||
if ((millis() - timeout) < 5000) {
|
if ((millis() - timeout) < 5000) {
|
||||||
@@ -41,13 +43,12 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
|||||||
emitRebooted();
|
emitRebooted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
||||||
bool SerialConsole::checkIsConnected()
|
bool SerialConsole::checkIsConnected()
|
||||||
{
|
{
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
return (now - lastContactMsec) < config.power.phone_timeout_secs
|
return (now - lastContactMsec) < SERIAL_CONNECTION_TIMEOUT;
|
||||||
? config.power.phone_timeout_secs
|
|
||||||
: default_phone_timeout_secs * 1000UL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#ifdef RV3028_RTC
|
#ifdef RV3028_RTC
|
||||||
#include "Melopero_RV3028.h"
|
#include "Melopero_RV3028.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -61,79 +62,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
||||||
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
||||||
|
|
||||||
#ifdef PORTDUINO
|
// Nop definition for these attributes that are specific to ESP32
|
||||||
|
#ifndef EXT_RAM_ATTR
|
||||||
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
#define EXT_RAM_ATTR
|
||||||
|
|
||||||
#elif defined(NRF52_SERIES) // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
|
|
||||||
// board specific
|
|
||||||
|
|
||||||
//
|
|
||||||
// Standard definitions for NRF52 targets
|
|
||||||
//
|
|
||||||
|
|
||||||
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
|
||||||
|
|
||||||
// We bind to the GPS using variant.h instead for this platform (Serial1)
|
|
||||||
|
|
||||||
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
|
|
||||||
|
|
||||||
// If the variant filed defines as standard button
|
|
||||||
#ifdef PIN_BUTTON1
|
|
||||||
#define BUTTON_PIN PIN_BUTTON1
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef IRAM_ATTR
|
||||||
#ifdef PIN_BUTTON2
|
#define IRAM_ATTR
|
||||||
#define BUTTON_PIN_ALT PIN_BUTTON2
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef RTC_DATA_ATTR
|
||||||
#ifdef PIN_BUTTON_TOUCH
|
#define RTC_DATA_ATTR
|
||||||
#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
//
|
|
||||||
// Standard definitions for ESP32 targets
|
|
||||||
//
|
|
||||||
|
|
||||||
#define HAS_WIFI
|
|
||||||
|
|
||||||
#define GPS_SERIAL_NUM 1
|
|
||||||
#define GPS_RX_PIN 34
|
|
||||||
#ifdef USE_JTAG
|
|
||||||
#define GPS_TX_PIN -1
|
|
||||||
#else
|
|
||||||
#define GPS_TX_PIN 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// LoRa SPI
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// NRF52 boards will define this in variant.h
|
|
||||||
#ifndef RF95_SCK
|
|
||||||
#define RF95_SCK 5
|
|
||||||
#define RF95_MISO 19
|
|
||||||
#define RF95_MOSI 27
|
|
||||||
#define RF95_NSS 18
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TTGO_T_ECHO
|
|
||||||
#define GPS_UBLOX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// Standard definitions for !ESP32 targets
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef NO_ESP32
|
|
||||||
// Nop definition for these attributes - not used on NRF52
|
|
||||||
#define EXT_RAM_ATTR
|
|
||||||
#define IRAM_ATTR
|
|
||||||
#define RTC_DATA_ATTR
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -141,10 +78,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Disable use of the NTP library and related features
|
// Disable use of the NTP library and related features
|
||||||
//#define DISABLE_NTP
|
// #define DISABLE_NTP
|
||||||
|
|
||||||
// Disable the welcome screen and allow
|
// Disable the welcome screen and allow
|
||||||
//#define DISABLE_WELCOME_UNSET
|
#define DISABLE_WELCOME_UNSET
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// OLED & Input
|
// OLED & Input
|
||||||
@@ -170,6 +107,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// The older M5 Faces I2C Keyboard
|
// The older M5 Faces I2C Keyboard
|
||||||
#define FACESKB_ADDR 0x88
|
#define FACESKB_ADDR 0x88
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// SENSOR
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
#define BME_ADDR 0x76
|
||||||
|
#define BME_ADDR_ALTERNATE 0x77
|
||||||
|
#define MCP9808_ADDR 0x18
|
||||||
|
#define INA_ADDR 0x40
|
||||||
|
#define INA_ADDR_ALTERNATE 0x41
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// GPS
|
// GPS
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -180,109 +126,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define GPS_THREAD_INTERVAL 100
|
#define GPS_THREAD_INTERVAL 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TBEAM_V10)
|
/* Step #1: offer chance for variant-specific defines */
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_TBEAM
|
|
||||||
|
|
||||||
#elif defined(TBEAM_V07)
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_TBEAM0p7
|
|
||||||
|
|
||||||
#elif defined(DIY_V1)
|
|
||||||
// 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(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
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HELTEC_V2_1
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_HELTEC_V1
|
|
||||||
|
|
||||||
#elif defined(TLORA_V1)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_TLORA_V1
|
|
||||||
|
|
||||||
#elif defined(TLORA_V2)
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_TLORA_V2
|
|
||||||
|
|
||||||
#elif defined(TLORA_V1_3)
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_TLORA_V1_1p3
|
|
||||||
|
|
||||||
#elif defined(TLORA_V2_1_16)
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_TLORA_V2_1_1p6
|
|
||||||
|
|
||||||
#elif defined(GENIEBLOCKS)
|
|
||||||
// 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
|
|
||||||
|
|
||||||
// This string must exactly match the case used in release file names or the android updater won't work
|
|
||||||
#define HW_VENDOR HardwareModel_NRF52840DK
|
|
||||||
|
|
||||||
// This board uses 0 to be mean LED on
|
|
||||||
#undef LED_INVERTED
|
|
||||||
#define LED_INVERTED 1
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_NRF52840_PPR)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_PPR
|
|
||||||
|
|
||||||
#elif defined(RAK4630)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_RAK4631
|
|
||||||
|
|
||||||
#elif defined(TTGO_T_ECHO)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_T_ECHO
|
|
||||||
|
|
||||||
#elif defined(NANO_G1)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_NANO_G1
|
|
||||||
|
|
||||||
#elif defined(NORDIC_PCA10059)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
|
|
||||||
|
|
||||||
#elif defined(M5STACK)
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_M5STACK
|
|
||||||
|
|
||||||
#elif NRF52_SERIES
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
|
||||||
|
|
||||||
#elif PORTDUINO
|
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_PORTDUINO
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
|
||||||
|
/* Step #2: follow with defines common to the architecture;
|
||||||
|
also enable HAS_ option not specifically disabled by variant.h */
|
||||||
|
#include "architecture.h"
|
||||||
|
|
||||||
|
/* Step #3: mop up with disabled values for HAS_ options not handled by the above two */
|
||||||
|
|
||||||
|
#ifndef HAS_WIFI
|
||||||
|
#define HAS_WIFI 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_SCREEN
|
||||||
|
#define HAS_SCREEN 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_WIRE
|
||||||
|
#define HAS_WIRE 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_GPS
|
||||||
|
#define HAS_GPS 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_BUTTON
|
||||||
|
#define HAS_BUTTON 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_TELEMETRY
|
||||||
|
#define HAS_TELEMETRY 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_RADIO
|
||||||
|
#define HAS_RADIO 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_RTC
|
||||||
|
#define HAS_RTC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "RF95Configuration.h"
|
#include "RF95Configuration.h"
|
||||||
#include "DebugConfiguration.h"
|
#include "DebugConfiguration.h"
|
||||||
|
|
||||||
|
#ifndef HW_VENDOR
|
||||||
|
#error HW_VENDOR must be defined
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,8 +1,27 @@
|
|||||||
#include "../configuration.h"
|
#include "../configuration.h"
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#include "mesh/generated/telemetry.pb.h"
|
||||||
|
|
||||||
|
#if HAS_WIRE
|
||||||
|
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
|
||||||
|
uint16_t value = 0x00;
|
||||||
|
Wire.beginTransmission(address);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.endTransmission();
|
||||||
|
delay(20);
|
||||||
|
Wire.requestFrom(address, length);
|
||||||
|
DEBUG_MSG("Wire.available() = %d\n", Wire.available());
|
||||||
|
if (Wire.available() == 2) {
|
||||||
|
// Read MSB, then LSB
|
||||||
|
value = (uint16_t)Wire.read() << 8;
|
||||||
|
value |= Wire.read();
|
||||||
|
} else if (Wire.available()) {
|
||||||
|
value = Wire.read();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NO_WIRE
|
|
||||||
uint8_t oled_probe(byte addr)
|
uint8_t oled_probe(byte addr)
|
||||||
{
|
{
|
||||||
uint8_t r = 0;
|
uint8_t r = 0;
|
||||||
@@ -34,7 +53,7 @@ uint8_t oled_probe(byte addr)
|
|||||||
void scanI2Cdevice(void)
|
void scanI2Cdevice(void)
|
||||||
{
|
{
|
||||||
byte err, addr;
|
byte err, addr;
|
||||||
uint8_t r = 0x00;
|
uint16_t registerValue = 0x00;
|
||||||
int nDevices = 0;
|
int nDevices = 0;
|
||||||
for (addr = 1; addr < 127; addr++) {
|
for (addr = 1; addr < 127; addr++) {
|
||||||
Wire.beginTransmission(addr);
|
Wire.beginTransmission(addr);
|
||||||
@@ -74,15 +93,8 @@ void scanI2Cdevice(void)
|
|||||||
if (addr == CARDKB_ADDR) {
|
if (addr == CARDKB_ADDR) {
|
||||||
cardkb_found = addr;
|
cardkb_found = addr;
|
||||||
// Do we have the RAK14006 instead?
|
// Do we have the RAK14006 instead?
|
||||||
Wire.beginTransmission(addr);
|
registerValue = getRegisterValue(addr, 0x04, 1);
|
||||||
Wire.write(0x04); // SENSOR_GET_VERSION
|
if (registerValue == 0x02) { // KEYPAD_VERSION
|
||||||
Wire.endTransmission();
|
|
||||||
delay(20);
|
|
||||||
Wire.requestFrom((int)addr, 1);
|
|
||||||
if (Wire.available()) {
|
|
||||||
r = Wire.read();
|
|
||||||
}
|
|
||||||
if (r == 0x02) { // KEYPAD_VERSION
|
|
||||||
DEBUG_MSG("RAK14004 found\n");
|
DEBUG_MSG("RAK14004 found\n");
|
||||||
kb_model = 0x02;
|
kb_model = 0x02;
|
||||||
} else {
|
} else {
|
||||||
@@ -104,6 +116,34 @@ void scanI2Cdevice(void)
|
|||||||
DEBUG_MSG("axp192 PMU found\n");
|
DEBUG_MSG("axp192 PMU found\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (addr == BME_ADDR || addr == BME_ADDR_ALTERNATE) {
|
||||||
|
registerValue = getRegisterValue(addr, 0xD0, 1); // GET_ID
|
||||||
|
if (registerValue == 0x61) {
|
||||||
|
DEBUG_MSG("BME-680 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = addr;
|
||||||
|
} else if (registerValue == 0x60) {
|
||||||
|
DEBUG_MSG("BME-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_BME280] = addr;
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("BMP-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_BMP280] = addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addr == INA_ADDR || addr == INA_ADDR_ALTERNATE) {
|
||||||
|
registerValue = getRegisterValue(addr, 0xFE, 2);
|
||||||
|
DEBUG_MSG("Register MFG_UID: 0x%x\n", registerValue);
|
||||||
|
if (registerValue == 0x5449) {
|
||||||
|
DEBUG_MSG("INA260 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_INA260] = addr;
|
||||||
|
} else { // Assume INA219 if INA260 ID is not found
|
||||||
|
DEBUG_MSG("INA219 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_INA219] = addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addr == MCP9808_ADDR) {
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
||||||
|
DEBUG_MSG("MCP9808 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
|
}
|
||||||
} else if (err == 4) {
|
} else if (err == 4) {
|
||||||
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ PhoneAPI *bluetoothPhoneAPI;
|
|||||||
class ESP32BluetoothToRadioCallback : public NimBLECharacteristicCallbacks {
|
class ESP32BluetoothToRadioCallback : public NimBLECharacteristicCallbacks {
|
||||||
virtual void onWrite(NimBLECharacteristic *pCharacteristic) {
|
virtual void onWrite(NimBLECharacteristic *pCharacteristic) {
|
||||||
DEBUG_MSG("To Radio onwrite\n");
|
DEBUG_MSG("To Radio onwrite\n");
|
||||||
auto valueString = pCharacteristic->getValue();
|
auto val = pCharacteristic->getValue();
|
||||||
|
|
||||||
bluetoothPhoneAPI->handleToRadio(reinterpret_cast<const uint8_t*>(&valueString[0]), pCharacteristic->getDataLength());
|
bluetoothPhoneAPI->handleToRadio(val.data(), val.length());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ESP32CryptoEngine : public CryptoEngine
|
|||||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||||
size_t nc_off = 0;
|
size_t nc_off = 0;
|
||||||
|
|
||||||
// DEBUG_MSG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
DEBUG_MSG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||||
initNonce(fromNode, packetId);
|
initNonce(fromNode, packetId);
|
||||||
assert(numBytes <= MAX_BLOCKSIZE);
|
assert(numBytes <= MAX_BLOCKSIZE);
|
||||||
memcpy(scratch, bytes, numBytes);
|
memcpy(scratch, bytes, numBytes);
|
||||||
@@ -68,8 +68,6 @@ class ESP32CryptoEngine : public CryptoEngine
|
|||||||
|
|
||||||
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("ESP32 decrypt!\n");
|
|
||||||
|
|
||||||
// For CTR, the implementation is the same
|
// For CTR, the implementation is the same
|
||||||
encrypt(fromNode, packetId, numBytes, bytes);
|
encrypt(fromNode, packetId, numBytes, bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
106
src/esp32/architecture.h
Normal file
106
src/esp32/architecture.h
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define ARCH_ESP32
|
||||||
|
|
||||||
|
//
|
||||||
|
// defaults for ESP32 architecture
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef HAS_WIFI
|
||||||
|
#define HAS_WIFI 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_SCREEN
|
||||||
|
#define HAS_SCREEN 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_WIRE
|
||||||
|
#define HAS_WIRE 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_GPS
|
||||||
|
#define HAS_GPS 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_BUTTON
|
||||||
|
#define HAS_BUTTON 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_TELEMETRY
|
||||||
|
#define HAS_TELEMETRY 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_RADIO
|
||||||
|
#define HAS_RADIO 1
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_RTC
|
||||||
|
#define HAS_RTC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// set HW_VENDOR
|
||||||
|
//
|
||||||
|
|
||||||
|
// This string must exactly match the case used in release file names or the android updater won't work
|
||||||
|
|
||||||
|
#if defined(TBEAM_V10)
|
||||||
|
#define HW_VENDOR HardwareModel_TBEAM
|
||||||
|
#elif defined(TBEAM_V07)
|
||||||
|
#define HW_VENDOR HardwareModel_TBEAM0p7
|
||||||
|
#elif defined(DIY_V1)
|
||||||
|
#define HW_VENDOR HardwareModel_DIY_V1
|
||||||
|
#elif defined(RAK_11200)
|
||||||
|
#define HW_VENDOR HardwareModel_RAK11200
|
||||||
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
||||||
|
#ifdef HELTEC_V2_0
|
||||||
|
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
||||||
|
#endif
|
||||||
|
#ifdef HELTEC_V2_1
|
||||||
|
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
||||||
|
#endif
|
||||||
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
|
||||||
|
#define HW_VENDOR HardwareModel_HELTEC_V1
|
||||||
|
#elif defined(TLORA_V1)
|
||||||
|
#define HW_VENDOR HardwareModel_TLORA_V1
|
||||||
|
#elif defined(TLORA_V2)
|
||||||
|
#define HW_VENDOR HardwareModel_TLORA_V2
|
||||||
|
#elif defined(TLORA_V1_3)
|
||||||
|
#define HW_VENDOR HardwareModel_TLORA_V1_1p3
|
||||||
|
#elif defined(TLORA_V2_1_16)
|
||||||
|
#define HW_VENDOR HardwareModel_TLORA_V2_1_1p6
|
||||||
|
#elif defined(GENIEBLOCKS)
|
||||||
|
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
||||||
|
#elif defined(PRIVATE_HW)
|
||||||
|
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||||
|
#elif defined(NANO_G1)
|
||||||
|
#define HW_VENDOR HardwareModel_NANO_G1
|
||||||
|
#elif defined(M5STACK)
|
||||||
|
#define HW_VENDOR HardwareModel_M5STACK
|
||||||
|
#elif defined(STATION_G1)
|
||||||
|
#define HW_VENDOR HardwareModel_STATION_G1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Standard definitions for ESP32 targets
|
||||||
|
//
|
||||||
|
|
||||||
|
#define GPS_SERIAL_NUM 1
|
||||||
|
#ifndef GPS_RX_PIN
|
||||||
|
#define GPS_RX_PIN 34
|
||||||
|
#endif
|
||||||
|
#ifndef GPS_TX_PIN
|
||||||
|
#ifdef USE_JTAG
|
||||||
|
#define GPS_TX_PIN -1
|
||||||
|
#else
|
||||||
|
#define GPS_TX_PIN 12
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// LoRa SPI
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// NRF52 boards will define this in variant.h
|
||||||
|
#ifndef RF95_SCK
|
||||||
|
#define RF95_SCK 5
|
||||||
|
#define RF95_MISO 19
|
||||||
|
#define RF95_MOSI 27
|
||||||
|
#define RF95_NSS 18
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ bool GPS::setupGPS()
|
|||||||
didSerialInit = true;
|
didSerialInit = true;
|
||||||
|
|
||||||
// ESP32 has a special set of parameters vs other arduino ports
|
// ESP32 has a special set of parameters vs other arduino ports
|
||||||
#if defined(GPS_RX_PIN) && !defined(NO_ESP32)
|
#if defined(GPS_RX_PIN) && defined(ARCH_ESP32)
|
||||||
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||||
#else
|
#else
|
||||||
_serial_gps->begin(GPS_BAUDRATE);
|
_serial_gps->begin(GPS_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
_serial_gps->setRxBufferSize(2048); // the default is 256
|
_serial_gps->setRxBufferSize(2048); // the default is 256
|
||||||
#endif
|
#endif
|
||||||
#ifdef TTGO_T_ECHO
|
#ifdef TTGO_T_ECHO
|
||||||
@@ -330,7 +330,7 @@ int32_t GPS::runOnce()
|
|||||||
if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
|
if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
|
||||||
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
|
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
|
||||||
devicestate.did_gps_reset = false;
|
devicestate.did_gps_reset = false;
|
||||||
nodeDB.saveToDisk();
|
nodeDB.saveDeviceStateToDisk();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -432,14 +432,14 @@ int GPS::prepareDeepSleep(void *unused)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_GPS
|
#if HAS_GPS
|
||||||
#include "NMEAGPS.h"
|
#include "NMEAGPS.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GPS *createGps()
|
GPS *createGps()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef NO_GPS
|
#if !HAS_GPS
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
if (!config.position.gps_disabled) {
|
if (!config.position.gps_disabled) {
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ float GeoCoord::latLongToMeter(double lat_a, double lng_a, double lat_b, double
|
|||||||
* Latitude of the second point
|
* Latitude of the second point
|
||||||
* @param lon2
|
* @param lon2
|
||||||
* Longitude of the second point
|
* Longitude of the second point
|
||||||
* @return Bearing between the two points in radians. A value of 0 means due
|
* @return Bearing from point 1 to point 2 in radians. A value of 0 means due
|
||||||
* north.
|
* north.
|
||||||
*/
|
*/
|
||||||
float GeoCoord::bearing(double lat1, double lon1, double lat2, double lon2)
|
float GeoCoord::bearing(double lat1, double lon1, double lat2, double lon2)
|
||||||
|
|||||||
@@ -115,12 +115,12 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv)
|
|||||||
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_hour, t->tm_min, t->tm_sec);
|
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_hour, t->tm_min, t->tm_sec);
|
||||||
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
||||||
}
|
}
|
||||||
#elif !defined(NO_ESP32)
|
#elif defined(ARCH_ESP32)
|
||||||
settimeofday(tv, NULL);
|
settimeofday(tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// nrf52 doesn't have a readable RTC (yet - software not written)
|
// nrf52 doesn't have a readable RTC (yet - software not written)
|
||||||
#if defined(PORTDUINO) || !defined(NO_ESP32) || defined(RV3028_RTC) || defined(PCF8563_RTC)
|
#ifdef HAS_RTC
|
||||||
readFromRTC();
|
readFromRTC();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#ifdef HAS_EINK
|
#ifdef USE_EINK
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "EInkDisplay2.h"
|
#include "EInkDisplay2.h"
|
||||||
#include "SPILock.h"
|
#include "SPILock.h"
|
||||||
@@ -31,6 +31,11 @@
|
|||||||
//4.2 inch 300x400 - GxEPD2_420_M01
|
//4.2 inch 300x400 - GxEPD2_420_M01
|
||||||
#define TECHO_DISPLAY_MODEL GxEPD2_420_M01
|
#define TECHO_DISPLAY_MODEL GxEPD2_420_M01
|
||||||
|
|
||||||
|
#elif defined(M5_COREINK)
|
||||||
|
//M5Stack CoreInk
|
||||||
|
//1.54 inch 200x200 - GxEPD2_154_M09
|
||||||
|
#define TECHO_DISPLAY_MODEL GxEPD2_154_M09
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT> *adafruitDisplay;
|
GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT> *adafruitDisplay;
|
||||||
@@ -58,6 +63,12 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl)
|
|||||||
//GxEPD2_420_M01
|
//GxEPD2_420_M01
|
||||||
setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
||||||
|
|
||||||
|
#elif defined(M5_COREINK)
|
||||||
|
|
||||||
|
//M5Stack_CoreInk 200x200
|
||||||
|
//1.54 inch 200x200 - GxEPD2_154_M09
|
||||||
|
setGeometry(GEOMETRY_RAWMODE, EPD_HEIGHT, EPD_WIDTH);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution
|
// setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution
|
||||||
// setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does
|
// setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does
|
||||||
@@ -108,7 +119,7 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit)
|
|||||||
// 4.2 inch 300x400 - GxEPD2_420_M01
|
// 4.2 inch 300x400 - GxEPD2_420_M01
|
||||||
//adafruitDisplay->nextPage();
|
//adafruitDisplay->nextPage();
|
||||||
|
|
||||||
#elif defined(PCA10059)
|
#elif defined(PCA10059) || defined(M5_COREINK)
|
||||||
adafruitDisplay->nextPage();
|
adafruitDisplay->nextPage();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -180,35 +191,10 @@ bool EInkDisplay::connect()
|
|||||||
adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||||
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
|
||||||
adafruitDisplay->setRotation(3);
|
adafruitDisplay->setRotation(3);
|
||||||
//For 1.54, 2.9 and 4.2
|
//For 1.54, 2.9 and 4.2
|
||||||
//adafruitDisplay->setRotation(1);
|
//adafruitDisplay->setRotation(1);
|
||||||
|
//adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
|
||||||
} else {
|
} else {
|
||||||
(void)adafruitDisplay;
|
(void)adafruitDisplay;
|
||||||
}
|
}
|
||||||
@@ -221,6 +207,12 @@ bool EInkDisplay::connect()
|
|||||||
adafruitDisplay->setRotation(3);
|
adafruitDisplay->setRotation(3);
|
||||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||||
}
|
}
|
||||||
|
#elif defined(M5_COREINK)
|
||||||
|
auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY);
|
||||||
|
adafruitDisplay = new GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||||
|
adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||||
|
adafruitDisplay->setRotation(0);
|
||||||
|
adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
|
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -64,7 +64,7 @@ namespace graphics
|
|||||||
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
||||||
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
||||||
static char btPIN[16] = "888888";
|
static char btPIN[16] = "888888";
|
||||||
|
|
||||||
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
||||||
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ static uint16_t displayWidth, displayHeight;
|
|||||||
#define SCREEN_WIDTH displayWidth
|
#define SCREEN_WIDTH displayWidth
|
||||||
#define SCREEN_HEIGHT displayHeight
|
#define SCREEN_HEIGHT displayHeight
|
||||||
|
|
||||||
#if defined(HAS_EINK) || defined(ILI9341_DRIVER)
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER)
|
||||||
// The screen is bigger so use bigger fonts
|
// The screen is bigger so use bigger fonts
|
||||||
#define FONT_SMALL ArialMT_Plain_16
|
#define FONT_SMALL ArialMT_Plain_16
|
||||||
#define FONT_MEDIUM ArialMT_Plain_24
|
#define FONT_MEDIUM ArialMT_Plain_24
|
||||||
@@ -212,7 +212,7 @@ static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(64 + x, y, "Creating SSL certificate");
|
display->drawString(64 + x, y, "Creating SSL certificate");
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
yield();
|
yield();
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
#endif
|
#endif
|
||||||
@@ -253,13 +253,13 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
yield();
|
yield();
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_EINK
|
#ifdef USE_EINK
|
||||||
/// Used on eink displays while in deep sleep
|
/// Used on eink displays while in deep sleep
|
||||||
static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
@@ -595,7 +595,7 @@ class Point
|
|||||||
void rotate(float radian)
|
void rotate(float radian)
|
||||||
{
|
{
|
||||||
float cos = cosf(radian), sin = sinf(radian);
|
float cos = cosf(radian), sin = sinf(radian);
|
||||||
float rx = x * cos - y * sin, ry = x * sin + y * cos;
|
float rx = x * cos + y * sin, ry = -x * sin + y * cos;
|
||||||
|
|
||||||
x = rx;
|
x = rx;
|
||||||
y = ry;
|
y = ry;
|
||||||
@@ -609,8 +609,10 @@ class Point
|
|||||||
|
|
||||||
void scale(float f)
|
void scale(float f)
|
||||||
{
|
{
|
||||||
|
//We use -f here to counter the flip that happens
|
||||||
|
//on the y axis when drawing and rotating on screen
|
||||||
x *= f;
|
x *= f;
|
||||||
y *= f;
|
y *= -f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -682,16 +684,21 @@ static void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t comp
|
|||||||
drawLine(display, rightArrow, tip);
|
drawLine(display, rightArrow, tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the compass heading
|
// Draw north
|
||||||
static void drawCompassHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
||||||
{
|
{
|
||||||
Point N1(-0.04f, -0.65f), N2(0.04f, -0.65f);
|
//If north is supposed to be at the top of the compass we want rotation to be +0
|
||||||
Point N3(-0.04f, -0.55f), N4(0.04f, -0.55f);
|
if(config.display.compass_north_top)
|
||||||
|
myHeading = -0;
|
||||||
|
|
||||||
|
Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f);
|
||||||
|
Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f);
|
||||||
Point *rosePoints[] = {&N1, &N2, &N3, &N4};
|
Point *rosePoints[] = {&N1, &N2, &N3, &N4};
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
rosePoints[i]->rotate(myHeading);
|
// North on compass will be negative of heading
|
||||||
rosePoints[i]->scale(-1 * COMPASS_DIAM);
|
rosePoints[i]->rotate(-myHeading);
|
||||||
|
rosePoints[i]->scale(COMPASS_DIAM);
|
||||||
rosePoints[i]->translate(compassX, compassY);
|
rosePoints[i]->translate(compassX, compassY);
|
||||||
}
|
}
|
||||||
drawLine(display, N1, N3);
|
drawLine(display, N1, N3);
|
||||||
@@ -762,7 +769,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
if (ourNode && hasPosition(ourNode)) {
|
if (ourNode && hasPosition(ourNode)) {
|
||||||
Position &op = ourNode->position;
|
Position &op = ourNode->position;
|
||||||
float myHeading = estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i));
|
float myHeading = estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i));
|
||||||
drawCompassHeading(display, compassX, compassY, myHeading);
|
drawCompassNorth(display, compassX, compassY, myHeading);
|
||||||
|
|
||||||
if (hasPosition(node)) {
|
if (hasPosition(node)) {
|
||||||
// display direction toward node
|
// display direction toward node
|
||||||
@@ -775,12 +782,13 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
else
|
else
|
||||||
snprintf(distStr, sizeof(distStr), "%.1f km", d / 1000);
|
snprintf(distStr, sizeof(distStr), "%.1f km", d / 1000);
|
||||||
|
|
||||||
// FIXME, also keep the guess at the operators heading and add/substract
|
|
||||||
// it. currently we don't do this and instead draw north up only.
|
|
||||||
float bearingToOther =
|
float bearingToOther =
|
||||||
GeoCoord::bearing(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
||||||
float headingRadian = bearingToOther - myHeading;
|
// If the top of the compass is a static north then bearingToOther can be drawn on the compass directly
|
||||||
drawNodeHeading(display, compassX, compassY, headingRadian);
|
// If the top of the compass is not a static north we need adjust bearingToOther based on heading
|
||||||
|
if(!config.display.compass_north_top)
|
||||||
|
bearingToOther -= myHeading;
|
||||||
|
drawNodeHeading(display, compassX, compassY, bearingToOther);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasNodeHeading)
|
if (!hasNodeHeading)
|
||||||
@@ -843,7 +851,7 @@ Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue
|
|||||||
*/
|
*/
|
||||||
void Screen::doDeepSleep()
|
void Screen::doDeepSleep()
|
||||||
{
|
{
|
||||||
#ifdef HAS_EINK
|
#ifdef USE_EINK
|
||||||
static FrameCallback sleepFrames[] = {drawSleepScreen};
|
static FrameCallback sleepFrames[] = {drawSleepScreen};
|
||||||
static const int sleepFrameCount = sizeof(sleepFrames) / sizeof(sleepFrames[0]);
|
static const int sleepFrameCount = sizeof(sleepFrames) / sizeof(sleepFrames[0]);
|
||||||
ui.setFrames(sleepFrames, sleepFrameCount);
|
ui.setFrames(sleepFrames, sleepFrameCount);
|
||||||
@@ -935,9 +943,11 @@ void Screen::setup()
|
|||||||
handleSetOn(true);
|
handleSetOn(true);
|
||||||
|
|
||||||
// On some ssd1306 clones, the first draw command is discarded, so draw it
|
// On some ssd1306 clones, the first draw command is discarded, so draw it
|
||||||
// twice initially.
|
// twice initially. Skip this for EINK Displays to save a few seconds during boot
|
||||||
ui.update();
|
ui.update();
|
||||||
|
#ifndef USE_EINK
|
||||||
ui.update();
|
ui.update();
|
||||||
|
#endif
|
||||||
serialSinceMsec = millis();
|
serialSinceMsec = millis();
|
||||||
|
|
||||||
// Subscribe to status updates
|
// Subscribe to status updates
|
||||||
@@ -954,7 +964,7 @@ void Screen::setup()
|
|||||||
void Screen::forceDisplay()
|
void Screen::forceDisplay()
|
||||||
{
|
{
|
||||||
// Nasty hack to force epaper updates for 'key' frames. FIXME, cleanup.
|
// Nasty hack to force epaper updates for 'key' frames. FIXME, cleanup.
|
||||||
#ifdef HAS_EINK
|
#ifdef USE_EINK
|
||||||
dispdev.forceDisplay();
|
dispdev.forceDisplay();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1055,7 +1065,7 @@ int32_t Screen::runOnce()
|
|||||||
DEBUG_MSG("Setting idle framerate\n");
|
DEBUG_MSG("Setting idle framerate\n");
|
||||||
targetFramerate = IDLE_FRAMERATE;
|
targetFramerate = IDLE_FRAMERATE;
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
setCPUFast(false); // Turn up the CPU to improve screen animations
|
setCPUFast(false); // Turn up the CPU to improve screen animations
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1180,7 +1190,7 @@ void Screen::setFrames()
|
|||||||
// call a method on debugInfoScreen object (for more details)
|
// call a method on debugInfoScreen object (for more details)
|
||||||
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;
|
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
if (isWifiAvailable()) {
|
if (isWifiAvailable()) {
|
||||||
// call a method on debugInfoScreen object (for more details)
|
// call a method on debugInfoScreen object (for more details)
|
||||||
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
|
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
|
||||||
@@ -1287,7 +1297,7 @@ void Screen::setFastFramerate()
|
|||||||
// We are about to start a transition so speed up fps
|
// We are about to start a transition so speed up fps
|
||||||
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
setCPUFast(true); // Turn up the CPU to improve screen animations
|
setCPUFast(true); // Turn up the CPU to improve screen animations
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1342,7 +1352,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
// Jm
|
// Jm
|
||||||
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
#ifdef HAS_WIFI
|
#if HAS_WIFI
|
||||||
const char *wifiName = config.wifi.ssid;
|
const char *wifiName = config.wifi.ssid;
|
||||||
const char *wifiPsw = config.wifi.psk;
|
const char *wifiPsw = config.wifi.psk;
|
||||||
|
|
||||||
@@ -1355,7 +1365,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
|
|
||||||
if (isSoftAPForced()) {
|
if (isSoftAPForced()) {
|
||||||
display->drawString(x, y, String("WiFi: Software AP (Admin)"));
|
display->drawString(x, y, String("WiFi: Software AP (Admin)"));
|
||||||
} else if (config.wifi.ap_mode) {
|
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
||||||
display->drawString(x, y, String("WiFi: Software AP"));
|
display->drawString(x, y, String("WiFi: Software AP"));
|
||||||
} else if (WiFi.status() != WL_CONNECTED) {
|
} else if (WiFi.status() != WL_CONNECTED) {
|
||||||
display->drawString(x, y, String("WiFi: Not Connected"));
|
display->drawString(x, y, String("WiFi: Not Connected"));
|
||||||
@@ -1378,8 +1388,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
- WL_NO_SHIELD: assigned when no WiFi shield is present;
|
- WL_NO_SHIELD: assigned when no WiFi shield is present;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.ap_mode) {
|
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
||||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str()));
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str()));
|
||||||
|
|
||||||
// Number of connections to the AP. Default max for the esp32 is 4
|
// Number of connections to the AP. Default max for the esp32 is 4
|
||||||
@@ -1471,7 +1481,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (config.wifi.ap_mode) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
||||||
if ((millis() / 10000) % 2) {
|
if ((millis() / 10000) % 2) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
||||||
} else {
|
} else {
|
||||||
@@ -1520,25 +1530,25 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
|
|
||||||
switch (config.lora.modem_preset) {
|
switch (config.lora.modem_preset) {
|
||||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
||||||
mode = "ShortSlow";
|
mode = "ShortS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_ShortFast:
|
case Config_LoRaConfig_ModemPreset_ShortFast:
|
||||||
mode = "ShortFast";
|
mode = "ShortF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidSlow:
|
case Config_LoRaConfig_ModemPreset_MedSlow:
|
||||||
mode = "MediumSlow";
|
mode = "MedS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidFast:
|
case Config_LoRaConfig_ModemPreset_MedFast:
|
||||||
mode = "MediumFast";
|
mode = "MedF";
|
||||||
break;
|
|
||||||
case Config_LoRaConfig_ModemPreset_LongFast:
|
|
||||||
mode = "LongFast";
|
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongSlow:
|
case Config_LoRaConfig_ModemPreset_LongSlow:
|
||||||
mode = "LongSlow";
|
mode = "LongS";
|
||||||
|
break;
|
||||||
|
case Config_LoRaConfig_ModemPreset_LongFast:
|
||||||
|
mode = "LongF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
||||||
mode = "VLongSlow";
|
mode = "VeryL";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mode = "Custom";
|
mode = "Custom";
|
||||||
@@ -1665,4 +1675,5 @@ int Screen::handleUIFrameEvent(const UIFrameEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
#endif // NO_SCREEN
|
|
||||||
|
#endif // HAS_SCREEN
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef NO_SCREEN
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#if !HAS_SCREEN
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
@@ -315,7 +317,7 @@ class Screen : public concurrency::OSThread
|
|||||||
SSD1306Wire dispdev;
|
SSD1306Wire dispdev;
|
||||||
#elif defined(ST7735_CS) || defined(ILI9341_DRIVER)
|
#elif defined(ST7735_CS) || defined(ILI9341_DRIVER)
|
||||||
TFTDisplay dispdev;
|
TFTDisplay dispdev;
|
||||||
#elif defined(HAS_EINK)
|
#elif defined(USE_EINK)
|
||||||
EInkDisplay dispdev;
|
EInkDisplay dispdev;
|
||||||
#elif defined(USE_ST7567)
|
#elif defined(USE_ST7567)
|
||||||
ST7567Wire dispdev;
|
ST7567Wire dispdev;
|
||||||
|
|||||||
49
src/main.cpp
49
src/main.cpp
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
|
|
||||||
#ifdef USE_NEW_ESP32_BLUETOOTH
|
#ifdef USE_NEW_ESP32_BLUETOOTH
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
#if HAS_WIFI
|
||||||
#include "mesh/wifi/WiFiServerAPI.h"
|
#include "mesh/wifi/WiFiServerAPI.h"
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -52,7 +52,9 @@
|
|||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
#include "SX1268Interface.h"
|
#include "SX1268Interface.h"
|
||||||
|
|
||||||
|
#if HAS_BUTTON
|
||||||
#include "ButtonThread.h"
|
#include "ButtonThread.h"
|
||||||
|
#endif
|
||||||
#include "PowerFSMThread.h"
|
#include "PowerFSMThread.h"
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
@@ -90,6 +92,9 @@ uint32_t serialSinceMsec;
|
|||||||
|
|
||||||
bool axp192_found;
|
bool axp192_found;
|
||||||
|
|
||||||
|
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
|
||||||
|
uint8_t nodeTelemetrySensorsMap[7] = { 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
||||||
|
|
||||||
const char *getDeviceName()
|
const char *getDeviceName()
|
||||||
@@ -98,9 +103,15 @@ const char *getDeviceName()
|
|||||||
|
|
||||||
getMacAddr(dmac);
|
getMacAddr(dmac);
|
||||||
|
|
||||||
// Meshtastic_ab3c
|
// Meshtastic_ab3c or Shortname_abcd
|
||||||
static char name[20];
|
static char name[20];
|
||||||
sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]);
|
sprintf(name, "%02x%02x", dmac[4], dmac[5]);
|
||||||
|
// if the shortname exists and is NOT the new default of ab3c, use it for BLE name.
|
||||||
|
if ((owner.short_name != NULL) && (strcmp(owner.short_name, name) != 0)) {
|
||||||
|
sprintf(name, "%s_%02x%02x", owner.short_name, dmac[4], dmac[5]);
|
||||||
|
} else {
|
||||||
|
sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]);
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,11 +128,15 @@ static int32_t ledBlinker()
|
|||||||
|
|
||||||
uint32_t timeLastPowered = 0;
|
uint32_t timeLastPowered = 0;
|
||||||
|
|
||||||
|
#if HAS_BUTTON
|
||||||
bool ButtonThread::shutdown_on_long_stop = false;
|
bool ButtonThread::shutdown_on_long_stop = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static Periodic *ledPeriodic;
|
static Periodic *ledPeriodic;
|
||||||
static OSThread *powerFSMthread, *buttonThread;
|
static OSThread *powerFSMthread, *buttonThread;
|
||||||
|
#if HAS_BUTTON
|
||||||
uint32_t ButtonThread::longPressTime = 0;
|
uint32_t ButtonThread::longPressTime = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
RadioInterface *rIf = NULL;
|
RadioInterface *rIf = NULL;
|
||||||
|
|
||||||
@@ -178,7 +193,7 @@ void setup()
|
|||||||
bool forceSoftAP = 0;
|
bool forceSoftAP = 0;
|
||||||
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
// If the button is connected to GPIO 12, don't enable the ability to use
|
// If the button is connected to GPIO 12, don't enable the ability to use
|
||||||
// meshtasticAdmin on the device.
|
// meshtasticAdmin on the device.
|
||||||
@@ -209,7 +224,7 @@ void setup()
|
|||||||
|
|
||||||
#ifdef I2C_SDA
|
#ifdef I2C_SDA
|
||||||
Wire.begin(I2C_SDA, I2C_SCL);
|
Wire.begin(I2C_SDA, I2C_SCL);
|
||||||
#elif !defined(NO_WIRE)
|
#elif HAS_WIRE
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -227,8 +242,10 @@ void setup()
|
|||||||
// scanEInkDevice();
|
// scanEInkDevice();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_BUTTON
|
||||||
// Buttons & LED
|
// Buttons & LED
|
||||||
buttonThread = new ButtonThread();
|
buttonThread = new ButtonThread();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LED_PIN
|
#ifdef LED_PIN
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
@@ -238,7 +255,7 @@ void setup()
|
|||||||
// Hello
|
// Hello
|
||||||
DEBUG_MSG("Meshtastic hwvendor=%d, swver=%s\n", HW_VENDOR, optstr(APP_VERSION));
|
DEBUG_MSG("Meshtastic hwvendor=%d, swver=%s\n", HW_VENDOR, optstr(APP_VERSION));
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Don't init display if we don't have one or we are waking headless due to a timer event
|
// Don't init display if we don't have one or we are waking headless due to a timer event
|
||||||
if (wakeCause == ESP_SLEEP_WAKEUP_TIMER)
|
if (wakeCause == ESP_SLEEP_WAKEUP_TIMER)
|
||||||
screen_found = 0; // forget we even have the hardware
|
screen_found = 0; // forget we even have the hardware
|
||||||
@@ -246,7 +263,7 @@ void setup()
|
|||||||
esp32Setup();
|
esp32Setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
nrf52Setup();
|
nrf52Setup();
|
||||||
#endif
|
#endif
|
||||||
playStartMelody();
|
playStartMelody();
|
||||||
@@ -262,7 +279,7 @@ void setup()
|
|||||||
|
|
||||||
// Init our SPI controller (must be before screen and lora)
|
// Init our SPI controller (must be before screen and lora)
|
||||||
initSPI();
|
initSPI();
|
||||||
#ifdef NO_ESP32
|
#ifndef ARCH_ESP32
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
#else
|
#else
|
||||||
// ESP32
|
// ESP32
|
||||||
@@ -297,7 +314,7 @@ void setup()
|
|||||||
|
|
||||||
// Don't call screen setup until after nodedb is setup (because we need
|
// Don't call screen setup until after nodedb is setup (because we need
|
||||||
// the current region name)
|
// the current region name)
|
||||||
#if defined(ST7735_CS) || defined(HAS_EINK) || defined(ILI9341_DRIVER)
|
#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER)
|
||||||
screen->setup();
|
screen->setup();
|
||||||
#else
|
#else
|
||||||
if (screen_found)
|
if (screen_found)
|
||||||
@@ -377,7 +394,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SIM_RADIO
|
#if !HAS_RADIO
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
rIf = new SimRadio;
|
rIf = new SimRadio;
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
@@ -390,19 +407,19 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PORTDUINO) || defined(HAS_WIFI)
|
#if HAS_WIFI
|
||||||
mqttInit();
|
mqttInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
initWifi(forceSoftAP);
|
initWifi(forceSoftAP);
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Start web server thread.
|
// Start web server thread.
|
||||||
webServerThread = new WebServerThread();
|
webServerThread = new WebServerThread();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
initApiServer();
|
initApiServer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -443,10 +460,10 @@ void loop()
|
|||||||
|
|
||||||
// heap_caps_check_integrity_all(true); // FIXME - disable this expensive check
|
// heap_caps_check_integrity_all(true); // FIXME - disable this expensive check
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
esp32Loop();
|
esp32Loop();
|
||||||
#endif
|
#endif
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
nrf52Loop();
|
nrf52Loop();
|
||||||
#endif
|
#endif
|
||||||
powerCommandsCheck();
|
powerCommandsCheck();
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include "GPSStatus.h"
|
#include "GPSStatus.h"
|
||||||
#include "NodeStatus.h"
|
#include "NodeStatus.h"
|
||||||
#include "PowerStatus.h"
|
#include "PowerStatus.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
|
#include "mesh/generated/telemetry.pb.h"
|
||||||
|
|
||||||
extern uint8_t screen_found;
|
extern uint8_t screen_found;
|
||||||
extern uint8_t screen_model;
|
extern uint8_t screen_model;
|
||||||
@@ -17,6 +19,8 @@ extern bool axp192_found;
|
|||||||
extern bool isCharging;
|
extern bool isCharging;
|
||||||
extern bool isUSBPowered;
|
extern bool isUSBPowered;
|
||||||
|
|
||||||
|
extern uint8_t nodeTelemetrySensorsMap[7];
|
||||||
|
|
||||||
// Global Screen singleton.
|
// Global Screen singleton.
|
||||||
extern graphics::Screen *screen;
|
extern graphics::Screen *screen;
|
||||||
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
||||||
|
|||||||
@@ -211,29 +211,29 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
// the app fucked up and forgot to set channelSettings.name
|
// the app fucked up and forgot to set channelSettings.name
|
||||||
|
|
||||||
if (config.lora.bandwidth != 0)
|
if (config.lora.bandwidth != 0)
|
||||||
channelName = "Unset";
|
channelName = "Custom";
|
||||||
else
|
else
|
||||||
switch (config.lora.modem_preset) {
|
switch (config.lora.modem_preset) {
|
||||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
||||||
channelName = "ShortSlow";
|
channelName = "ShortS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_ShortFast:
|
case Config_LoRaConfig_ModemPreset_ShortFast:
|
||||||
channelName = "ShortFast";
|
channelName = "ShortF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidSlow:
|
case Config_LoRaConfig_ModemPreset_MedSlow:
|
||||||
channelName = "MediumSlow";
|
channelName = "MedS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidFast:
|
case Config_LoRaConfig_ModemPreset_MedFast:
|
||||||
channelName = "MediumFast";
|
channelName = "MedF";
|
||||||
break;
|
|
||||||
case Config_LoRaConfig_ModemPreset_LongFast:
|
|
||||||
channelName = "LongFast";
|
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongSlow:
|
case Config_LoRaConfig_ModemPreset_LongSlow:
|
||||||
channelName = "LongSlow";
|
channelName = "LongS";
|
||||||
|
break;
|
||||||
|
case Config_LoRaConfig_ModemPreset_LongFast:
|
||||||
|
channelName = "LongF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
||||||
channelName = "VLongSlow";
|
channelName = "VeryL";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
channelName = "Invalid";
|
channelName = "Invalid";
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
|
|
||||||
void CryptoEngine::setKey(const CryptoKey &k)
|
void CryptoEngine::setKey(const CryptoKey &k)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Installing AES%d key!\n", k.length * 8);
|
DEBUG_MSG("Using AES%d key!\n", k.length * 8);
|
||||||
/* for(uint8_t i = 0; i < k.length; i++)
|
|
||||||
DEBUG_MSG("%02x ", k.bytes[i]);
|
|
||||||
DEBUG_MSG("\n"); */
|
|
||||||
|
|
||||||
key = k;
|
key = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +32,4 @@ void CryptoEngine::initNonce(uint32_t fromNode, uint64_t packetId)
|
|||||||
// use memcpy to avoid breaking strict-aliasing
|
// use memcpy to avoid breaking strict-aliasing
|
||||||
memcpy(nonce, &packetId, sizeof(uint64_t));
|
memcpy(nonce, &packetId, sizeof(uint64_t));
|
||||||
memcpy(nonce + sizeof(uint64_t), &fromNode, sizeof(uint32_t));
|
memcpy(nonce + sizeof(uint64_t), &fromNode, sizeof(uint32_t));
|
||||||
//*((uint64_t *)&nonce[0]) = packetId;
|
|
||||||
//*((uint32_t *)&nonce[8]) = fromNode;
|
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,12 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p)
|
|||||||
|
|
||||||
void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||||
{
|
{
|
||||||
|
PacketId ackId = ((c && c->error_reason == Routing_Error_NONE) || !c) ? p->decoded.request_id : 0;
|
||||||
if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
|
if (ackId && p->to != getNodeNum()) {
|
||||||
|
// do not flood direct message that is ACKed
|
||||||
|
DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
||||||
|
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
|
||||||
|
} else if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
|
||||||
if (p->id != 0) {
|
if (p->id != 0) {
|
||||||
if (config.device.role != Config_DeviceConfig_Role_ClientMute) {
|
if (config.device.role != Config_DeviceConfig_Role_ClientMute) {
|
||||||
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "mesh/MeshTypes.h"
|
#include "mesh/MeshTypes.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
#include <OLEDDisplayUi.h>
|
#include <OLEDDisplayUi.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -72,7 +72,7 @@ class MeshModule
|
|||||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||||
static AdminMessageHandleResult handleAdminMessageForAllPlugins(
|
static AdminMessageHandleResult handleAdminMessageForAllPlugins(
|
||||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response);
|
const MeshPacket &mp, AdminMessage *request, AdminMessage *response);
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { return; }
|
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { return; }
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
|||||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||||
assert(node);
|
assert(node);
|
||||||
|
|
||||||
if (node->has_position) {
|
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
||||||
if (positionModule) {
|
if (positionModule) {
|
||||||
DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies);
|
||||||
positionModule->sendOurPosition(dest, wantReplies);
|
positionModule->sendOurPosition(dest, wantReplies);
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
#include "modules/esp32/StoreForwardModule.h"
|
#include "modules/esp32/StoreForwardModule.h"
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NRF52_SERIES
|
#ifdef ARCH_NRF52
|
||||||
#include <bluefruit.h>
|
#include <bluefruit.h>
|
||||||
#include <utility/bonding.h>
|
#include <utility/bonding.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -43,14 +43,6 @@ ChannelFile channelFile;
|
|||||||
*/
|
*/
|
||||||
uint32_t radioGeneration;
|
uint32_t radioGeneration;
|
||||||
|
|
||||||
/*
|
|
||||||
DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a
|
|
||||||
#define here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DEVICESTATE_CUR_VER 11
|
|
||||||
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
|
|
||||||
|
|
||||||
// FIXME - move this somewhere else
|
// FIXME - move this somewhere else
|
||||||
extern void getMacAddr(uint8_t *dmac);
|
extern void getMacAddr(uint8_t *dmac);
|
||||||
|
|
||||||
@@ -89,27 +81,7 @@ bool NodeDB::resetRadioConfig()
|
|||||||
|
|
||||||
// radioConfig.has_preferences = true;
|
// radioConfig.has_preferences = true;
|
||||||
if (config.device.factory_reset) {
|
if (config.device.factory_reset) {
|
||||||
DEBUG_MSG("Performing factory reset!\n");
|
didFactoryReset = factoryReset();
|
||||||
installDefaultDeviceState();
|
|
||||||
#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)
|
|
||||||
FSCom.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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
||||||
@@ -143,9 +115,35 @@ bool NodeDB::resetRadioConfig()
|
|||||||
return didFactoryReset;
|
return didFactoryReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NodeDB::factoryReset()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Performing factory reset!\n");
|
||||||
|
// first, remove the "/prefs" (this removes most prefs)
|
||||||
|
rmDir("/prefs");
|
||||||
|
// second, install default state (this will deal with the duplicate mac address issue)
|
||||||
|
installDefaultDeviceState();
|
||||||
|
// third, write to disk
|
||||||
|
saveToDisk();
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||||
|
nvs_flash_erase();
|
||||||
|
#endif
|
||||||
|
#ifdef ARCH_NRF52
|
||||||
|
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
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultConfig()
|
void NodeDB::installDefaultConfig()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default LocalConfig\n");
|
||||||
memset(&config, 0, sizeof(LocalConfig));
|
memset(&config, 0, sizeof(LocalConfig));
|
||||||
|
config.version = DEVICESTATE_CUR_VER;
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
config.has_display = true;
|
config.has_display = true;
|
||||||
config.has_lora = true;
|
config.has_lora = true;
|
||||||
@@ -164,35 +162,28 @@ void NodeDB::installDefaultConfig()
|
|||||||
|
|
||||||
void NodeDB::installDefaultModuleConfig()
|
void NodeDB::installDefaultModuleConfig()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default ModuleConfig\n");
|
||||||
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
||||||
moduleConfig.has_canned_message = true;
|
moduleConfig.version = DEVICESTATE_CUR_VER;
|
||||||
moduleConfig.has_external_notification = true;
|
|
||||||
moduleConfig.has_mqtt = true;
|
moduleConfig.has_mqtt = true;
|
||||||
moduleConfig.has_range_test = true;
|
moduleConfig.has_range_test = true;
|
||||||
moduleConfig.has_serial = true;
|
moduleConfig.has_serial = true;
|
||||||
moduleConfig.has_store_forward = true;
|
moduleConfig.has_store_forward = true;
|
||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_telemetry = true;
|
||||||
|
moduleConfig.has_external_notification = true;
|
||||||
|
moduleConfig.has_canned_message = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void NodeDB::installDefaultRadioConfig()
|
|
||||||
// {
|
|
||||||
// memset(&radioConfig, 0, sizeof(radioConfig));
|
|
||||||
// radioConfig.has_preferences = true;
|
|
||||||
// resetRadioConfig();
|
|
||||||
|
|
||||||
// // for backward compat, default position flags are BAT+ALT+MSL (0x23 = 35)
|
|
||||||
// config.position.position_flags =
|
|
||||||
// (Config_PositionConfig_PositionFlags_POS_BATTERY | Config_PositionConfig_PositionFlags_POS_ALTITUDE |
|
|
||||||
// Config_PositionConfig_PositionFlags_POS_ALT_MSL);
|
|
||||||
// }
|
|
||||||
|
|
||||||
void NodeDB::installDefaultChannels()
|
void NodeDB::installDefaultChannels()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default ChannelFile\n");
|
||||||
memset(&channelFile, 0, sizeof(ChannelFile));
|
memset(&channelFile, 0, sizeof(ChannelFile));
|
||||||
|
channelFile.version = DEVICESTATE_CUR_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultDeviceState()
|
void NodeDB::installDefaultDeviceState()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default DeviceState\n");
|
||||||
memset(&devicestate, 0, sizeof(DeviceState));
|
memset(&devicestate, 0, sizeof(DeviceState));
|
||||||
|
|
||||||
*numNodes = 0; // Forget node DB
|
*numNodes = 0; // Forget node DB
|
||||||
@@ -214,28 +205,22 @@ void NodeDB::installDefaultDeviceState()
|
|||||||
|
|
||||||
// Set default owner name
|
// Set default owner name
|
||||||
pickNewNodeNum(); // based on macaddr now
|
pickNewNodeNum(); // based on macaddr now
|
||||||
sprintf(owner.long_name, "Unknown %02x%02x", ourMacAddr[4], ourMacAddr[5]);
|
sprintf(owner.long_name, "Meshtastic %02x%02x", ourMacAddr[4], ourMacAddr[5]);
|
||||||
sprintf(owner.short_name, "?%02X", (unsigned)(myNodeInfo.my_node_num & 0xff));
|
sprintf(owner.short_name, "%02x%02x", ourMacAddr[4], ourMacAddr[5]);
|
||||||
|
|
||||||
sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
||||||
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
||||||
|
|
||||||
installDefaultChannels();
|
|
||||||
installDefaultConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::init()
|
void NodeDB::init()
|
||||||
{
|
{
|
||||||
installDefaultDeviceState();
|
DEBUG_MSG("Initializing NodeDB\n");
|
||||||
|
|
||||||
// saveToDisk();
|
// saveToDisk();
|
||||||
loadFromDisk();
|
loadFromDisk();
|
||||||
// saveToDisk();
|
|
||||||
|
|
||||||
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
||||||
|
|
||||||
myNodeInfo.error_code =
|
myNodeInfo.error_code = CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash)
|
||||||
CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash)
|
|
||||||
myNodeInfo.error_address = 0;
|
myNodeInfo.error_address = 0;
|
||||||
|
|
||||||
// likewise - we always want the app requirements to come from the running appload
|
// likewise - we always want the app requirements to come from the running appload
|
||||||
@@ -255,7 +240,7 @@ void NodeDB::init()
|
|||||||
|
|
||||||
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
|
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
Preferences preferences;
|
Preferences preferences;
|
||||||
preferences.begin("meshtastic", false);
|
preferences.begin("meshtastic", false);
|
||||||
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
|
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
|
||||||
@@ -269,8 +254,8 @@ void NodeDB::init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
resetRadioConfig(); // If bogus settings got saved, then fix them
|
resetRadioConfig(); // If bogus settings got saved, then fix them
|
||||||
|
|
||||||
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
||||||
|
saveToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We reserve a few nodenums for future use
|
// We reserve a few nodenums for future use
|
||||||
@@ -300,20 +285,20 @@ void NodeDB::pickNewNodeNum()
|
|||||||
myNodeInfo.my_node_num = r;
|
myNodeInfo.my_node_num = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *preffile = "/prefs/db.proto";
|
static const char *prefFileName = "/prefs/db.proto";
|
||||||
static const char *configfile = "/prefs/config.proto";
|
static const char *configFileName = "/prefs/config.proto";
|
||||||
static const char *moduleConfigfile = "/prefs/module.proto";
|
static const char *moduleConfigFileName = "/prefs/module.proto";
|
||||||
static const char *channelfile = "/prefs/channels.proto";
|
static const char *channelFileName = "/prefs/channels.proto";
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||||
{
|
{
|
||||||
|
bool okay = false;
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
|
|
||||||
auto f = FSCom.open(filename);
|
auto f = FSCom.open(filename);
|
||||||
|
|
||||||
bool okay = false;
|
|
||||||
if (f) {
|
if (f) {
|
||||||
DEBUG_MSG("Loading %s\n", filename);
|
DEBUG_MSG("Loading %s\n", filename);
|
||||||
pb_istream_t stream = {&readcb, &f, protoSize};
|
pb_istream_t stream = {&readcb, &f, protoSize};
|
||||||
@@ -340,39 +325,72 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
void NodeDB::loadFromDisk()
|
void NodeDB::loadFromDisk()
|
||||||
{
|
{
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
if (!loadProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate)) {
|
if (!loadProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate)) {
|
||||||
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
||||||
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
||||||
installDefaultDeviceState();
|
installDefaultDeviceState();
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||||
|
nvs_flash_erase();
|
||||||
|
#endif
|
||||||
|
#ifdef ARCH_NRF52
|
||||||
|
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
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Loaded saved preferences version %d\n", devicestate.version);
|
DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
|
if (!loadProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
|
||||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||||
|
} else {
|
||||||
|
if (config.version < DEVICESTATE_MIN_VER) {
|
||||||
|
DEBUG_MSG("Warn: config %d is old, discarding\n", config.version);
|
||||||
|
installDefaultConfig();
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Loaded saved config version %d\n", config.version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(moduleConfigfile, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig)) {
|
if (!loadProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig)) {
|
||||||
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||||
|
} else {
|
||||||
|
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
||||||
|
DEBUG_MSG("Warn: moduleConfig %d is old, discarding\n", moduleConfig.version);
|
||||||
|
installDefaultModuleConfig();
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Loaded saved moduleConfig version %d\n", moduleConfig.version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
if (!loadProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
|
} else {
|
||||||
|
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
||||||
|
DEBUG_MSG("Warn: channelFile %d is old, discarding\n", channelFile.version);
|
||||||
|
installDefaultChannels();
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save a protobuf from a file, return true for success */
|
/** Save a protobuf from a file, return true for success */
|
||||||
bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
||||||
{
|
{
|
||||||
|
bool okay = false;
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
String filenameTmp = filename;
|
String filenameTmp = filename;
|
||||||
filenameTmp += ".tmp";
|
filenameTmp += ".tmp";
|
||||||
auto f = FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
|
auto f = FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
|
||||||
bool okay = false;
|
|
||||||
if (f) {
|
if (f) {
|
||||||
DEBUG_MSG("Saving %s\n", filename);
|
DEBUG_MSG("Saving %s\n", filename);
|
||||||
pb_ostream_t stream = {&writecb, &f, protoSize};
|
pb_ostream_t stream = {&writecb, &f, protoSize};
|
||||||
@@ -388,7 +406,7 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
// brief window of risk here ;-)
|
// brief window of risk here ;-)
|
||||||
if (FSCom.exists(filename) && !FSCom.remove(filename))
|
if (FSCom.exists(filename) && !FSCom.remove(filename))
|
||||||
DEBUG_MSG("Warning: Can't remove old pref file\n");
|
DEBUG_MSG("Warning: Can't remove old pref file\n");
|
||||||
if (!FSCom.rename(filenameTmp.c_str(), filename))
|
if (!renameFile(filenameTmp.c_str(), filename))
|
||||||
DEBUG_MSG("Error: can't rename new pref file\n");
|
DEBUG_MSG("Error: can't rename new pref file\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Can't write prefs\n");
|
DEBUG_MSG("Can't write prefs\n");
|
||||||
@@ -405,7 +423,17 @@ void NodeDB::saveChannelsToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
saveProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeDB::saveDeviceStateToDisk()
|
||||||
|
{
|
||||||
|
if (!devicestate.no_save) {
|
||||||
|
#ifdef FSCom
|
||||||
|
FSCom.mkdir("/prefs");
|
||||||
|
#endif
|
||||||
|
saveProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +443,7 @@ void NodeDB::saveToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
|
|
||||||
// save all config segments
|
// save all config segments
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
@@ -424,7 +452,7 @@ void NodeDB::saveToDisk()
|
|||||||
config.has_position = true;
|
config.has_position = true;
|
||||||
config.has_power = true;
|
config.has_power = true;
|
||||||
config.has_wifi = true;
|
config.has_wifi = true;
|
||||||
saveProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
|
saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
|
||||||
|
|
||||||
moduleConfig.has_canned_message = true;
|
moduleConfig.has_canned_message = true;
|
||||||
moduleConfig.has_external_notification = true;
|
moduleConfig.has_external_notification = true;
|
||||||
@@ -433,10 +461,9 @@ void NodeDB::saveToDisk()
|
|||||||
moduleConfig.has_serial = true;
|
moduleConfig.has_serial = true;
|
||||||
moduleConfig.has_store_forward = true;
|
moduleConfig.has_store_forward = true;
|
||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_telemetry = true;
|
||||||
saveProto(moduleConfigfile, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig);
|
saveProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig);
|
||||||
|
|
||||||
saveChannelsToDisk();
|
saveChannelsToDisk();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||||
}
|
}
|
||||||
@@ -644,7 +671,7 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
|
|||||||
myNodeInfo.error_count++;
|
myNodeInfo.error_count++;
|
||||||
|
|
||||||
// Currently portuino is mostly used for simulation. Make sue the user notices something really bad happend
|
// Currently portuino is mostly used for simulation. Make sue the user notices something really bad happend
|
||||||
#ifdef PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
DEBUG_MSG("A critical failure occurred, portduino is exiting...");
|
DEBUG_MSG("A critical failure occurred, portduino is exiting...");
|
||||||
exit(2);
|
exit(2);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,6 +8,14 @@
|
|||||||
#include "NodeStatus.h"
|
#include "NodeStatus.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
DeviceState versions used to be defined in the .proto file but really only this function cares. So changed to a
|
||||||
|
#define here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEVICESTATE_CUR_VER 14
|
||||||
|
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
|
||||||
|
|
||||||
extern DeviceState devicestate;
|
extern DeviceState devicestate;
|
||||||
extern ChannelFile channelFile;
|
extern ChannelFile channelFile;
|
||||||
extern MyNodeInfo &myNodeInfo;
|
extern MyNodeInfo &myNodeInfo;
|
||||||
@@ -44,7 +52,7 @@ class NodeDB
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
/// write to flash
|
/// write to flash
|
||||||
void saveToDisk(), saveChannelsToDisk();
|
void saveToDisk(), saveChannelsToDisk(), saveDeviceStateToDisk();
|
||||||
|
|
||||||
/** Reinit radio config if needed, because either:
|
/** Reinit radio config if needed, because either:
|
||||||
* a) sometimes a buggy android app might send us bogus settings or
|
* a) sometimes a buggy android app might send us bogus settings or
|
||||||
@@ -119,6 +127,8 @@ class NodeDB
|
|||||||
newStatus.notifyObservers(&status);
|
newStatus.notifyObservers(&status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool factoryReset();
|
||||||
|
|
||||||
/// read our db from flash
|
/// read our db from flash
|
||||||
void loadFromDisk();
|
void loadFromDisk();
|
||||||
|
|
||||||
@@ -138,7 +148,7 @@ extern NodeDB nodeDB;
|
|||||||
/*
|
/*
|
||||||
If is_router is set, we use a number of different default values
|
If is_router is set, we use a number of different default values
|
||||||
|
|
||||||
# FIXME - after tuning, move these params into the on-device defaults based on is_router and is_low_power
|
# FIXME - after tuning, move these params into the on-device defaults based on is_router and is_power_saving
|
||||||
|
|
||||||
# prefs.position_broadcast_secs = FIXME possibly broadcast only once an hr
|
# prefs.position_broadcast_secs = FIXME possibly broadcast only once an hr
|
||||||
prefs.wait_bluetooth_secs = 1 # Don't stay in bluetooth mode
|
prefs.wait_bluetooth_secs = 1 # Don't stay in bluetooth mode
|
||||||
@@ -152,7 +162,7 @@ extern NodeDB nodeDB;
|
|||||||
# get a new GPS position once per day
|
# get a new GPS position once per day
|
||||||
prefs.gps_update_interval = oneday
|
prefs.gps_update_interval = oneday
|
||||||
|
|
||||||
prefs.is_low_power = True
|
prefs.is_power_saving = True
|
||||||
|
|
||||||
# allow up to five minutes for each new GPS lock attempt
|
# allow up to five minutes for each new GPS lock attempt
|
||||||
prefs.gps_attempt_time = 300
|
prefs.gps_attempt_time = 300
|
||||||
@@ -168,7 +178,6 @@ extern NodeDB nodeDB;
|
|||||||
#define default_mesh_sds_timeout_secs IF_ROUTER(NODE_DELAY_FOREVER, 2 * 60 * 60)
|
#define default_mesh_sds_timeout_secs IF_ROUTER(NODE_DELAY_FOREVER, 2 * 60 * 60)
|
||||||
#define default_sds_secs 365 * 24 * 60 * 60
|
#define default_sds_secs 365 * 24 * 60 * 60
|
||||||
#define default_ls_secs IF_ROUTER(24 * 60 * 60, 5 * 60)
|
#define default_ls_secs IF_ROUTER(24 * 60 * 60, 5 * 60)
|
||||||
#define default_phone_timeout_secs 15 * 60
|
|
||||||
#define default_min_wake_secs 10
|
#define default_min_wake_secs 10
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,20 +79,17 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
|||||||
memset(&toRadioScratch, 0, sizeof(toRadioScratch));
|
memset(&toRadioScratch, 0, sizeof(toRadioScratch));
|
||||||
if (pb_decode_from_bytes(buf, bufLength, ToRadio_fields, &toRadioScratch)) {
|
if (pb_decode_from_bytes(buf, bufLength, ToRadio_fields, &toRadioScratch)) {
|
||||||
switch (toRadioScratch.which_payloadVariant) {
|
switch (toRadioScratch.which_payloadVariant) {
|
||||||
case ToRadio_packet_tag:
|
case ToRadio_packet_tag:
|
||||||
return handleToRadioPacket(toRadioScratch.packet);
|
return handleToRadioPacket(toRadioScratch.packet);
|
||||||
|
case ToRadio_want_config_id_tag:
|
||||||
case ToRadio_want_config_id_tag:
|
config_nonce = toRadioScratch.want_config_id;
|
||||||
config_nonce = toRadioScratch.want_config_id;
|
DEBUG_MSG("Client wants config, nonce=%u\n", config_nonce);
|
||||||
DEBUG_MSG("Client wants config, nonce=%u\n", config_nonce);
|
|
||||||
|
|
||||||
handleStartConfig();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ToRadio_disconnect_tag:
|
|
||||||
close();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
handleStartConfig();
|
||||||
|
break;
|
||||||
|
case ToRadio_disconnect_tag:
|
||||||
|
close();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Ignore nop messages
|
// Ignore nop messages
|
||||||
// DEBUG_MSG("Error: unexpected ToRadio variant\n");
|
// DEBUG_MSG("Error: unexpected ToRadio variant\n");
|
||||||
@@ -112,8 +109,8 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
|||||||
*
|
*
|
||||||
* Our sending states progress in the following sequence (the client app ASSUMES THIS SEQUENCE, DO NOT CHANGE IT):
|
* Our sending states progress in the following sequence (the client app ASSUMES THIS SEQUENCE, DO NOT CHANGE IT):
|
||||||
* STATE_SEND_MY_INFO, // send our my info record
|
* STATE_SEND_MY_INFO, // send our my info record
|
||||||
STATE_SEND_RADIO,
|
* STATE_SEND_NODEINFO, // states progress in this order as the device sends to the client
|
||||||
STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client
|
STATE_SEND_CONFIG,
|
||||||
STATE_SEND_COMPLETE_ID,
|
STATE_SEND_COMPLETE_ID,
|
||||||
STATE_SEND_PACKETS // send packets or debug strings
|
STATE_SEND_PACKETS // send packets or debug strings
|
||||||
*/
|
*/
|
||||||
@@ -157,13 +154,92 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
// Stay in current state until done sending nodeinfos
|
// Stay in current state until done sending nodeinfos
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Done sending nodeinfos\n");
|
DEBUG_MSG("Done sending nodeinfos\n");
|
||||||
state = STATE_SEND_COMPLETE_ID;
|
state = STATE_SEND_CONFIG;
|
||||||
// Go ahead and send that ID right now
|
// Go ahead and send that ID right now
|
||||||
return getFromRadio(buf);
|
return getFromRadio(buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case STATE_SEND_CONFIG:
|
||||||
|
fromRadioScratch.which_payloadVariant = FromRadio_config_tag;
|
||||||
|
switch (config_state) {
|
||||||
|
case Config_device_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_device_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.device = config.device;
|
||||||
|
break;
|
||||||
|
case Config_position_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_position_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.position = config.position;
|
||||||
|
break;
|
||||||
|
case Config_power_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_power_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.power = config.power;
|
||||||
|
fromRadioScratch.config.payloadVariant.power.ls_secs = default_ls_secs;
|
||||||
|
break;
|
||||||
|
case Config_wifi_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_wifi_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.wifi = config.wifi;
|
||||||
|
break;
|
||||||
|
case Config_display_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_display_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.display = config.display;
|
||||||
|
break;
|
||||||
|
case Config_lora_tag:
|
||||||
|
fromRadioScratch.config.which_payloadVariant = Config_lora_tag;
|
||||||
|
fromRadioScratch.config.payloadVariant.lora = config.lora;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
|
||||||
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
|
|
||||||
|
config_state++;
|
||||||
|
// Advance when we have sent all of our config objects
|
||||||
|
if (config_state > Config_lora_tag) {
|
||||||
|
state = STATE_SEND_MODULECONFIG;
|
||||||
|
config_state = ModuleConfig_mqtt_tag;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_SEND_MODULECONFIG:
|
||||||
|
fromRadioScratch.which_payloadVariant = FromRadio_moduleConfig_tag;
|
||||||
|
switch (config_state) {
|
||||||
|
case ModuleConfig_mqtt_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_mqtt_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.mqtt = moduleConfig.mqtt;
|
||||||
|
break;
|
||||||
|
case ModuleConfig_serial_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_serial_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.serial = moduleConfig.serial;
|
||||||
|
break;
|
||||||
|
case ModuleConfig_external_notification_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_external_notification_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.external_notification = moduleConfig.external_notification;
|
||||||
|
break;
|
||||||
|
case ModuleConfig_range_test_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_range_test_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.range_test = moduleConfig.range_test;
|
||||||
|
break;
|
||||||
|
case ModuleConfig_telemetry_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_telemetry_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.telemetry = moduleConfig.telemetry;
|
||||||
|
break;
|
||||||
|
case ModuleConfig_canned_message_tag:
|
||||||
|
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_canned_message_tag;
|
||||||
|
fromRadioScratch.moduleConfig.payloadVariant.canned_message = moduleConfig.canned_message;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_state++;
|
||||||
|
// Advance when we have sent all of our ModuleConfig objects
|
||||||
|
if (config_state > ModuleConfig_canned_message_tag) {
|
||||||
|
state = STATE_SEND_COMPLETE_ID;
|
||||||
|
config_state = Config_device_tag;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_SEND_COMPLETE_ID:
|
case STATE_SEND_COMPLETE_ID:
|
||||||
fromRadioScratch.which_payloadVariant = FromRadio_config_complete_id_tag;
|
fromRadioScratch.which_payloadVariant = FromRadio_config_complete_id_tag;
|
||||||
fromRadioScratch.config_complete_id = config_nonce;
|
fromRadioScratch.config_complete_id = config_nonce;
|
||||||
@@ -220,6 +296,12 @@ bool PhoneAPI::available()
|
|||||||
|
|
||||||
case STATE_SEND_MY_INFO:
|
case STATE_SEND_MY_INFO:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case STATE_SEND_CONFIG:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case STATE_SEND_MODULECONFIG:
|
||||||
|
return true;
|
||||||
|
|
||||||
case STATE_SEND_NODEINFO:
|
case STATE_SEND_NODEINFO:
|
||||||
if (!nodeInfoForPhone)
|
if (!nodeInfoForPhone)
|
||||||
@@ -269,4 +351,4 @@ int PhoneAPI::onNotify(uint32_t newValue)
|
|||||||
DEBUG_MSG("(Client not yet interested in packets)\n");
|
DEBUG_MSG("(Client not yet interested in packets)\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,19 @@ class PhoneAPI
|
|||||||
: public Observer<uint32_t> // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member
|
: public Observer<uint32_t> // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member
|
||||||
{
|
{
|
||||||
enum State {
|
enum State {
|
||||||
STATE_UNUSED, // (no longer used) old default state - until Android apps are all updated, uses the old BLE API
|
STATE_SEND_NOTHING, // Initial state, don't send anything until the client starts asking for config
|
||||||
STATE_SEND_NOTHING, // (Eventual) Initial state, don't send anything until the client starts asking for config
|
|
||||||
// (disconnected)
|
|
||||||
STATE_SEND_MY_INFO, // send our my info record
|
STATE_SEND_MY_INFO, // send our my info record
|
||||||
STATE_SEND_GROUPS,
|
|
||||||
// STATE_SEND_RADIO, // in 1.2 we now send this as a regular mesh packet
|
|
||||||
// STATE_SEND_OWNER, no need to send Owner specially, it is just part of the nodedb
|
|
||||||
STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client
|
STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client
|
||||||
|
STATE_SEND_CONFIG, // Replacement for the old Radioconfig
|
||||||
|
STATE_SEND_MODULECONFIG, // Send Module specific config
|
||||||
STATE_SEND_COMPLETE_ID,
|
STATE_SEND_COMPLETE_ID,
|
||||||
STATE_SEND_PACKETS // send packets or debug strings
|
STATE_SEND_PACKETS // send packets or debug strings
|
||||||
};
|
};
|
||||||
|
|
||||||
State state = STATE_SEND_NOTHING;
|
State state = STATE_SEND_NOTHING;
|
||||||
|
|
||||||
|
int8_t config_state = Config_device_tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each packet sent to the phone has an incrementing count
|
* Each packet sent to the phone has an incrementing count
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -77,10 +77,13 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
|||||||
T *decoded = NULL;
|
T *decoded = NULL;
|
||||||
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
|
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
|
||||||
memset(&scratch, 0, sizeof(scratch));
|
memset(&scratch, 0, sizeof(scratch));
|
||||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch))
|
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
||||||
decoded = &scratch;
|
decoded = &scratch;
|
||||||
else
|
} else {
|
||||||
DEBUG_MSG("Error decoding protobuf module!\n");
|
DEBUG_MSG("Error decoding protobuf module!\n");
|
||||||
|
// if we can't decode it, nobody can process it!
|
||||||
|
return ProcessMessage::STOP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;
|
return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;
|
||||||
|
|||||||
@@ -70,19 +70,23 @@ bool RF95Interface::init()
|
|||||||
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength);
|
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength);
|
||||||
DEBUG_MSG("RF95 init result %d\n", res);
|
DEBUG_MSG("RF95 init result %d\n", res);
|
||||||
|
|
||||||
|
DEBUG_MSG("Frequency set to %f\n", getFreq());
|
||||||
|
DEBUG_MSG("Bandwidth set to %f\n", bw);
|
||||||
|
DEBUG_MSG("Power output set to %d\n", power);
|
||||||
|
|
||||||
// current limit was removed from module' ctor
|
// current limit was removed from module' ctor
|
||||||
// override default value (60 mA)
|
// override default value (60 mA)
|
||||||
res = lora->setCurrentLimit(currentLimit);
|
res = lora->setCurrentLimit(currentLimit);
|
||||||
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
||||||
DEBUG_MSG("Current limit set result %d\n", res);
|
DEBUG_MSG("Current limit set result %d\n", res);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora->setCRC(SX126X_LORA_CRC_ON);
|
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
startReceive(); // start receiving
|
startReceive(); // start receiving
|
||||||
|
|
||||||
return res == ERR_NONE;
|
return res == RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
||||||
@@ -99,39 +103,39 @@ bool RF95Interface::reconfigure()
|
|||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
int err = lora->setSpreadingFactor(sf);
|
int err = lora->setSpreadingFactor(sf);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setBandwidth(bw);
|
err = lora->setBandwidth(bw);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setCodingRate(cr);
|
err = lora->setCodingRate(cr);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setSyncWord(syncWord);
|
err = lora->setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setCurrentLimit(currentLimit);
|
err = lora->setCurrentLimit(currentLimit);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setPreambleLength(preambleLength);
|
err = lora->setPreambleLength(preambleLength);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setFrequency(getFreq());
|
err = lora->setFrequency(getFreq());
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
if (power > MAX_POWER) // This chip has lower power limits than some
|
if (power > MAX_POWER) // This chip has lower power limits than some
|
||||||
power = MAX_POWER;
|
power = MAX_POWER;
|
||||||
err = lora->setOutputPower(power);
|
err = lora->setOutputPower(power);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
startReceive(); // restart receiving
|
startReceive(); // restart receiving
|
||||||
|
|
||||||
return ERR_NONE;
|
return RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +151,7 @@ void RF95Interface::addReceiveMetadata(MeshPacket *mp)
|
|||||||
void RF95Interface::setStandby()
|
void RF95Interface::setStandby()
|
||||||
{
|
{
|
||||||
int err = lora->standby();
|
int err = lora->standby();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = false; // If we were receiving, not any more
|
isReceiving = false; // If we were receiving, not any more
|
||||||
disableInterrupt();
|
disableInterrupt();
|
||||||
@@ -168,7 +172,7 @@ void RF95Interface::startReceive()
|
|||||||
setTransmitEnable(false);
|
setTransmitEnable(false);
|
||||||
setStandby();
|
setStandby();
|
||||||
int err = lora->startReceive();
|
int err = lora->startReceive();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = true;
|
isReceiving = true;
|
||||||
|
|
||||||
@@ -184,12 +188,11 @@ bool RF95Interface::isChannelActive()
|
|||||||
setStandby(); // needed for smooth transition
|
setStandby(); // needed for smooth transition
|
||||||
result = lora->scanChannel();
|
result = lora->scanChannel();
|
||||||
|
|
||||||
if (result == PREAMBLE_DETECTED) {
|
if (result == RADIOLIB_PREAMBLE_DETECTED) {
|
||||||
// DEBUG_MSG("Channel is busy!\n");
|
// DEBUG_MSG("Channel is busy!\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
||||||
assert(result != ERR_WRONG_MODEM);
|
|
||||||
|
|
||||||
// DEBUG_MSG("Channel is free!\n");
|
// DEBUG_MSG("Channel is free!\n");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ class RF95Interface : public RadioLibInterface
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
||||||
|
|
||||||
bool isIRQPending() override { return lora->getPendingIRQ(); }
|
//TODO: Verify that this irq flag works with RFM95 / SX1276 radios the way it used to
|
||||||
|
bool isIRQPending() override { return lora->getIRQFlags() & RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER; }
|
||||||
|
|
||||||
/// Initialise the Driver transport hardware and software.
|
/// Initialise the Driver transport hardware and software.
|
||||||
/// Make sure the Driver is properly configured before calling init().
|
/// Make sure the Driver is properly configured before calling init().
|
||||||
|
|||||||
@@ -35,8 +35,15 @@ const RegionInfo regions[] = {
|
|||||||
https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true
|
https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true
|
||||||
|
|
||||||
audio_permitted = false per regulation
|
audio_permitted = false per regulation
|
||||||
|
|
||||||
|
Special Note:
|
||||||
|
The link above describes LoRaWAN's band plan, stating a power limit of 16 dBm. This is their own suggested specification,
|
||||||
|
we do not need to follow it. The European Union regulations clearly state that the power limit for this frequency range is 500 mW, or 27 dBm.
|
||||||
|
It also states that we can use interference avoidance and spectrum access techniques to avoid a duty cycle.
|
||||||
|
(Please refer to section 4.21 in the following document)
|
||||||
|
https://ec.europa.eu/growth/tools-databases/tris/index.cfm/ro/search/?trisaction=search.detail&year=2021&num=528&dLang=EN
|
||||||
*/
|
*/
|
||||||
RDEF(EU868, 869.4f, 869.65f, 10, 0, 16, false, false),
|
RDEF(EU868, 869.4f, 869.65f, 10, 0, 27, false, false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
|
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
|
||||||
@@ -159,61 +166,50 @@ uint32_t RadioInterface::getPacketTime(MeshPacket *p)
|
|||||||
/** The delay to use for retransmitting dropped packets */
|
/** The delay to use for retransmitting dropped packets */
|
||||||
uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
|
uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
|
||||||
{
|
{
|
||||||
assert(shortPacketMsec); // Better be non zero
|
assert(slotTimeMsec); // Better be non zero
|
||||||
static uint8_t bytes[MAX_RHPACKETLEN];
|
static uint8_t bytes[MAX_RHPACKETLEN];
|
||||||
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
|
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
|
||||||
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
|
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
|
||||||
uint32_t tCADmsec = 2 * (1 << sf) / bw; // duration of CAD is roughly 2 symbols according to SX127x datasheet
|
// Make sure enough time has elapsed for this packet to be sent and an ACK is received.
|
||||||
/* Make sure enough time has elapsed for this packet to be sent and an ACK is received.
|
// DEBUG_MSG("Waiting for flooding message with airtime %d and slotTime is %d\n", packetAirtime, slotTimeMsec);
|
||||||
* Right now we have to wait until another node floods the same packet, as that is our implicit ACK.
|
float channelUtil = airTime->channelUtilizationPercent();
|
||||||
* TODO: Revise when want_ack will be used (right now it is always set to 0 afterwards).
|
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||||
*/
|
// Assuming we pick max. of CWsize and there will be a receiver with SNR at half the range
|
||||||
return 2*packetAirtime + 2*MIN_TX_WAIT_MSEC + shortPacketMsec + shortPacketMsec*2 + PROCESSING_TIME_MSEC + 2*tCADmsec;
|
return 2*packetAirtime + (pow(2, CWsize) + pow(2, int((CWmax+CWmin)/2))) * slotTimeMsec + PROCESSING_TIME_MSEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The delay to use when we want to send something but the ether is busy */
|
/** The delay to use when we want to send something */
|
||||||
uint32_t RadioInterface::getTxDelayMsec()
|
uint32_t RadioInterface::getTxDelayMsec()
|
||||||
{
|
{
|
||||||
/** At the low end we want to pick a delay large enough that anyone who just completed sending (some other node)
|
/** We wait a random multiple of 'slotTimes' (see definition in header file) in order to avoid collisions.
|
||||||
* has had enough time to switch their radio back into receive mode.
|
The pool to take a random multiple from is the contention window (CW), which size depends on the
|
||||||
*/
|
current channel utilization. */
|
||||||
const uint32_t MIN_TX_WAIT_MSEC = 100;
|
float channelUtil = airTime->channelUtilizationPercent();
|
||||||
|
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||||
/**
|
// DEBUG_MSG("Current channel utilization is %f so setting CWsize to %d\n", channelUtil, CWsize);
|
||||||
* At the high end, this value is used to spread node attempts across time so when they are replying to a packet
|
return random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||||
* they don't both check that the airwaves are clear at the same moment. As long as they are off by some amount
|
|
||||||
* one of the two will be first to start transmitting and the other will see that. I bet 500ms is more than enough
|
|
||||||
* to guarantee this.
|
|
||||||
*/
|
|
||||||
// const uint32_t MAX_TX_WAIT_MSEC = 2000; // stress test would still fail occasionally with 1000
|
|
||||||
|
|
||||||
return random((MIN_TX_WAIT_MSEC), (MIN_TX_WAIT_MSEC + shortPacketMsec));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The delay to use when we want to send something but the ether is busy */
|
/** The delay to use when we want to flood a message */
|
||||||
uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||||
{
|
{
|
||||||
/** At the low end we want to pick a delay large enough that anyone who just completed sending (some other node)
|
|
||||||
* has had enough time to switch their radio back into receive mode.
|
|
||||||
*/
|
|
||||||
const uint32_t MIN_TX_WAIT_MSEC = 100;
|
|
||||||
|
|
||||||
// The minimum value for a LoRa SNR
|
// The minimum value for a LoRa SNR
|
||||||
const uint32_t SNR_MIN = -20;
|
const uint32_t SNR_MIN = -20;
|
||||||
|
|
||||||
// The maximum value for a LoRa SNR
|
// The maximum value for a LoRa SNR
|
||||||
const uint32_t SNR_MAX = 15;
|
const uint32_t SNR_MAX = 15;
|
||||||
|
|
||||||
// high SNR = Long Delay
|
// high SNR = large CW size (Long Delay)
|
||||||
// low SNR = Short Delay
|
// low SNR = small CW size (Short Delay)
|
||||||
uint32_t delay = 0;
|
uint32_t delay = 0;
|
||||||
|
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
|
||||||
|
// DEBUG_MSG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
||||||
if (config.device.role == Config_DeviceConfig_Role_Router ||
|
if (config.device.role == Config_DeviceConfig_Role_Router ||
|
||||||
config.device.role == Config_DeviceConfig_Role_RouterClient) {
|
config.device.role == Config_DeviceConfig_Role_RouterClient) {
|
||||||
delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC, (MIN_TX_WAIT_MSEC + (shortPacketMsec / 2)));
|
delay = random(0, 2*CWsize) * slotTimeMsec;
|
||||||
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
||||||
} else {
|
} else {
|
||||||
delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC + (shortPacketMsec / 2), (MIN_TX_WAIT_MSEC + shortPacketMsec * 2));
|
delay = random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||||
DEBUG_MSG("rx_snr found in packet. Setting tx delay:%d\n", delay);
|
DEBUG_MSG("rx_snr found in packet. Setting tx delay:%d\n", delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,12 +367,12 @@ void RadioInterface::applyModemConfig()
|
|||||||
cr = 8;
|
cr = 8;
|
||||||
sf = 8;
|
sf = 8;
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidFast:
|
case Config_LoRaConfig_ModemPreset_MedFast:
|
||||||
bw = 250;
|
bw = 250;
|
||||||
cr = 8;
|
cr = 8;
|
||||||
sf = 9;
|
sf = 9;
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MidSlow:
|
case Config_LoRaConfig_ModemPreset_MedSlow:
|
||||||
bw = 250;
|
bw = 250;
|
||||||
cr = 8;
|
cr = 8;
|
||||||
sf = 10;
|
sf = 10;
|
||||||
@@ -411,27 +407,36 @@ void RadioInterface::applyModemConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
power = loraConfig.tx_power;
|
power = loraConfig.tx_power;
|
||||||
shortPacketMsec = getPacketTime(sizeof(PacketHeader));
|
|
||||||
assert(myRegion); // Should have been found in init
|
assert(myRegion); // Should have been found in init
|
||||||
|
|
||||||
|
if ((power == 0) || (power > myRegion->powerLimit))
|
||||||
|
power = myRegion->powerLimit;
|
||||||
|
|
||||||
|
if (power == 0)
|
||||||
|
power = 17; // Default to default power if we don't have a valid power
|
||||||
|
|
||||||
// Calculate the number of channels
|
// Calculate the number of channels
|
||||||
uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart) / (myRegion->spacing + (bw / 1000)));
|
uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart) / (myRegion->spacing + (bw / 1000)));
|
||||||
|
|
||||||
// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
|
// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
|
||||||
const char *channelName = channels.getName(channels.getPrimaryIndex());
|
const char *channelName = channels.getName(channels.getPrimaryIndex());
|
||||||
int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels;
|
int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels;
|
||||||
float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
|
||||||
|
// Old frequency selection formula
|
||||||
|
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
||||||
|
|
||||||
|
// New frequency selection formula
|
||||||
|
float freq = myRegion->freqStart + (bw / 2000) + ( channel_num * (bw / 1000));
|
||||||
|
|
||||||
saveChannelNum(channel_num);
|
saveChannelNum(channel_num);
|
||||||
saveFreq(freq);
|
saveFreq(freq + config.lora.frequency_offset);
|
||||||
|
|
||||||
DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, power=%d\n", channelName, loraConfig.modem_preset, channel_num, power);
|
DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power);
|
||||||
DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd,
|
DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart);
|
||||||
myRegion->freqEnd - myRegion->freqStart);
|
|
||||||
DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels);
|
DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels);
|
||||||
DEBUG_MSG("Radio channel_num: %d\n", channel_num);
|
DEBUG_MSG("Radio channel_num: %d\n", channel_num);
|
||||||
DEBUG_MSG("Radio frequency: %f\n", getFreq());
|
DEBUG_MSG("Radio frequency: %f\n", getFreq());
|
||||||
DEBUG_MSG("Short packet time: %u msec\n", shortPacketMsec);
|
DEBUG_MSG("Slot time: %u msec\n", slotTimeMsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ class RadioInterface
|
|||||||
CallbackObserver<RadioInterface, void *> notifyDeepSleepObserver =
|
CallbackObserver<RadioInterface, void *> notifyDeepSleepObserver =
|
||||||
CallbackObserver<RadioInterface, void *>(this, &RadioInterface::notifyDeepSleepCb);
|
CallbackObserver<RadioInterface, void *>(this, &RadioInterface::notifyDeepSleepCb);
|
||||||
|
|
||||||
/// Number of msecs we expect our shortest actual packet to be over the wire (used in retry timeout calcs)
|
|
||||||
uint32_t shortPacketMsec;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
@@ -61,10 +59,16 @@ class RadioInterface
|
|||||||
float bw = 125;
|
float bw = 125;
|
||||||
uint8_t sf = 9;
|
uint8_t sf = 9;
|
||||||
uint8_t cr = 7;
|
uint8_t cr = 7;
|
||||||
|
/** Slottime is the minimum time to wait, consisting of:
|
||||||
|
- CAD duration (maximum of SX126x and SX127x);
|
||||||
|
- roundtrip air propagation time (assuming max. 30km between nodes);
|
||||||
|
- Tx/Rx turnaround time (maximum of SX126x and SX127x);
|
||||||
|
- MAC processing time (measured on T-beam) */
|
||||||
|
uint32_t slotTimeMsec = 8.5 * pow(2, sf)/bw + 0.2 + 0.4 + 7;
|
||||||
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
|
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
|
||||||
const uint32_t MIN_TX_WAIT_MSEC = 100; // minimum time to wait before transmitting after sensing the channel in ms
|
|
||||||
const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined)
|
const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined)
|
||||||
|
const uint8_t CWmin = 2; // minimum CWsize
|
||||||
|
const uint8_t CWmax = 8; // maximum CWsize
|
||||||
|
|
||||||
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
||||||
uint32_t lastTxStart = 0L;
|
uint32_t lastTxStart = 0L;
|
||||||
@@ -128,10 +132,10 @@ class RadioInterface
|
|||||||
/** The delay to use for retransmitting dropped packets */
|
/** The delay to use for retransmitting dropped packets */
|
||||||
uint32_t getRetransmissionMsec(const MeshPacket *p);
|
uint32_t getRetransmissionMsec(const MeshPacket *p);
|
||||||
|
|
||||||
/** The delay to use when we want to send something but the ether is busy */
|
/** The delay to use when we want to send something */
|
||||||
uint32_t getTxDelayMsec();
|
uint32_t getTxDelayMsec();
|
||||||
|
|
||||||
/** The delay to use when we want to send something but the ether is busy. Use a weighted scale based on SNR */
|
/** The delay to use when we want to flood a message. Use a weighted scale based on SNR */
|
||||||
uint32_t getTxDelayMsecWeighted(float snr);
|
uint32_t getTxDelayMsecWeighted(float snr);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
// FIXME, we default to 4MHz SPI, SPI mode 0, check if the datasheet says it can really do that
|
// FIXME, we default to 4MHz SPI, SPI mode 0, check if the datasheet says it can really do that
|
||||||
static SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0);
|
static SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0);
|
||||||
|
|
||||||
|
#ifdef ARCH_PORTDUINO
|
||||||
|
|
||||||
void LockingModule::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes)
|
void LockingModule::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes)
|
||||||
{
|
{
|
||||||
concurrency::LockGuard g(spiLock);
|
concurrency::LockGuard g(spiLock);
|
||||||
@@ -18,6 +20,24 @@ void LockingModule::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint
|
|||||||
Module::SPItransfer(cmd, reg, dataOut, dataIn, numBytes);
|
Module::SPItransfer(cmd, reg, dataOut, dataIn, numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void LockingModule::SPIbeginTransaction()
|
||||||
|
{
|
||||||
|
spiLock->lock();
|
||||||
|
|
||||||
|
Module::SPIbeginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LockingModule::SPIendTransaction()
|
||||||
|
{
|
||||||
|
spiLock->unlock();
|
||||||
|
|
||||||
|
Module::SPIendTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
RadioLibInterface::RadioLibInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy,
|
RadioLibInterface::RadioLibInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy,
|
||||||
SPIClass &spi, PhysicalLayer *_iface)
|
SPIClass &spi, PhysicalLayer *_iface)
|
||||||
: NotifiedWorkerThread("RadioIf"), module(cs, irq, rst, busy, spi, spiSettings), iface(_iface)
|
: NotifiedWorkerThread("RadioIf"), module(cs, irq, rst, busy, spi, spiSettings), iface(_iface)
|
||||||
@@ -25,7 +45,7 @@ RadioLibInterface::RadioLibInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// ESP32 doesn't use that flag
|
// ESP32 doesn't use that flag
|
||||||
#define YIELD_FROM_ISR(x) portYIELD_FROM_ISR()
|
#define YIELD_FROM_ISR(x) portYIELD_FROM_ISR()
|
||||||
#else
|
#else
|
||||||
@@ -76,7 +96,7 @@ bool RadioLibInterface::canSendImmediately()
|
|||||||
if (busyTx && (millis() - lastTxStart > 60000)) {
|
if (busyTx && (millis() - lastTxStart > 60000)) {
|
||||||
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
|
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_TransmitFailed);
|
RECORD_CRITICALERROR(CriticalErrorCode_TransmitFailed);
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
|
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
#endif
|
#endif
|
||||||
@@ -170,17 +190,11 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** radio helper thread callback.
|
/** radio helper thread callback.
|
||||||
|
We never immediately transmit after any operation (either Rx or Tx). Instead we should wait a random multiple of
|
||||||
We never immediately transmit after any operation (either rx or tx). Instead we should start receiving and
|
'slotTimes' (see definition in RadioInterface.h) taken from a contention window (CW) to lower the chance of collision.
|
||||||
wait a random delay of 100ms to 100ms+shortPacketMsec to make sure we are not stomping on someone else. The 100ms delay
|
The CW size is determined by setTransmitDelay() and depends either on the current channel utilization or SNR in case
|
||||||
at the beginning ensures all possible listeners have had time to finish processing the previous packet and now have their
|
of a flooding message. After this, we perform channel activity detection (CAD) and reset the transmit delay if it is
|
||||||
radio in RX state. The up to 100ms+shortPacketMsec random delay gives a chance for all possible senders to have high odds
|
currently active.
|
||||||
of detecting that someone else started transmitting first and then they will wait until that packet finishes.
|
|
||||||
|
|
||||||
NOTE: the large flood rebroadcast delay might still be needed even with this approach. Because we might not be able to
|
|
||||||
hear other transmitters that we are potentially stomping on. Requires further thought.
|
|
||||||
|
|
||||||
FIXME, the MIN_TX_WAIT_MSEC and MAX_TX_WAIT_MSEC values should be tuned via logic analyzer later.
|
|
||||||
*/
|
*/
|
||||||
void RadioLibInterface::onNotify(uint32_t notification)
|
void RadioLibInterface::onNotify(uint32_t notification)
|
||||||
{
|
{
|
||||||
@@ -308,7 +322,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
|||||||
xmitMsec = getPacketTime(length);
|
xmitMsec = getPacketTime(length);
|
||||||
|
|
||||||
int state = iface->readData(radiobuf, length);
|
int state = iface->readData(radiobuf, length);
|
||||||
if (state != ERR_NONE) {
|
if (state != RADIOLIB_ERR_NONE) {
|
||||||
DEBUG_MSG("ignoring received packet due to error=%d\n", state);
|
DEBUG_MSG("ignoring received packet due to error=%d\n", state);
|
||||||
rxBad++;
|
rxBad++;
|
||||||
|
|
||||||
@@ -374,7 +388,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
|||||||
size_t numbytes = beginSending(txp);
|
size_t numbytes = beginSending(txp);
|
||||||
|
|
||||||
int res = iface->startTransmit(radiobuf, numbytes);
|
int res = iface->startTransmit(radiobuf, numbytes);
|
||||||
if (res != ERR_NONE) {
|
if (res != RADIOLIB_ERR_NONE) {
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_RadioSpiBug);
|
RECORD_CRITICALERROR(CriticalErrorCode_RadioSpiBug);
|
||||||
|
|
||||||
// This send failed, but make sure to 'complete' it properly
|
// This send failed, but make sure to 'complete' it properly
|
||||||
|
|||||||
@@ -40,21 +40,13 @@ class LockingModule : public Module
|
|||||||
: Module(cs, irq, rst, gpio, spi, spiSettings)
|
: Module(cs, irq, rst, gpio, spi, spiSettings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
#ifdef ARCH_PORTDUINO
|
||||||
\brief SPI single transfer method.
|
void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes) override;
|
||||||
|
#else
|
||||||
\param cmd SPI access command (read/write/burst/...).
|
void SPIbeginTransaction() override;
|
||||||
|
void SPIendTransaction() override;
|
||||||
\param reg Address of SPI register to transfer to/from.
|
#endif
|
||||||
|
|
||||||
\param dataOut Data that will be transfered from master to slave.
|
|
||||||
|
|
||||||
\param dataIn Data that was transfered from slave to master.
|
|
||||||
|
|
||||||
\param numBytes Number of bytes to transfer.
|
|
||||||
*/
|
|
||||||
virtual void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread
|
class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
|||||||
{
|
{
|
||||||
// execute common part
|
// execute common part
|
||||||
int16_t state = SX127x::begin(RF95_CHIP_VERSION, syncWord, preambleLength);
|
int16_t state = SX127x::begin(RF95_CHIP_VERSION, syncWord, preambleLength);
|
||||||
if (state != ERR_NONE)
|
if (state != RADIOLIB_ERR_NONE)
|
||||||
state = SX127x::begin(RF95_ALT_VERSION, syncWord, preambleLength);
|
state = SX127x::begin(RF95_ALT_VERSION, syncWord, preambleLength);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
|||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
#ifdef RF95_TCXO
|
#ifdef RF95_TCXO
|
||||||
state = _mod->SPIsetRegValue(SX127X_REG_TCXO, 0x10 | _mod->SPIgetRegValue(SX127X_REG_TCXO));
|
state = _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_TCXO, 0x10 | _mod->SPIgetRegValue(RADIOLIB_SX127X_REG_TCXO));
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ int16_t RadioLibRF95::setFrequency(float freq)
|
|||||||
bool RadioLibRF95::isReceiving()
|
bool RadioLibRF95::isReceiving()
|
||||||
{
|
{
|
||||||
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
||||||
uint8_t reg = readReg(SX127X_REG_MODEM_STAT);
|
uint8_t reg = readReg(RADIOLIB_SX127X_REG_MODEM_STAT);
|
||||||
// Serial.printf("reg %x\n", reg);
|
// Serial.printf("reg %x\n", reg);
|
||||||
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
||||||
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class RadioLibRF95: public SX1278 {
|
|||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint16_t preambleLength = 8, uint8_t gain = 0);
|
int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 17, uint16_t preambleLength = 8, uint8_t gain = 0);
|
||||||
|
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
|
|||||||
// If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our
|
// If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our
|
||||||
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
|
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
|
||||||
// counts and we want this message to get through the whole mesh, so use the default.
|
// counts and we want this message to get through the whole mesh, so use the default.
|
||||||
if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) {
|
if (p->hop_limit == 0) {
|
||||||
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
|
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
|
||||||
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
|
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
|
||||||
} else {
|
} else {
|
||||||
@@ -34,7 +34,7 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
|
|||||||
bool ReliableRouter::shouldFilterReceived(MeshPacket *p)
|
bool ReliableRouter::shouldFilterReceived(MeshPacket *p)
|
||||||
{
|
{
|
||||||
// Note: do not use getFrom() here, because we want to ignore messages sent from phone
|
// Note: do not use getFrom() here, because we want to ignore messages sent from phone
|
||||||
if (p->to == NODENUM_BROADCAST && p->from == getNodeNum()) {
|
if (p->from == getNodeNum()) {
|
||||||
printPacket("Rx someone rebroadcasting for us", p);
|
printPacket("Rx someone rebroadcasting for us", p);
|
||||||
|
|
||||||
// We are seeing someone rebroadcast one of our broadcast attempts.
|
// We are seeing someone rebroadcast one of our broadcast attempts.
|
||||||
@@ -231,4 +231,4 @@ void ReliableRouter::setNextTx(PendingPacket *pending)
|
|||||||
DEBUG_MSG("Setting next retransmission in %u msecs: ", d);
|
DEBUG_MSG("Setting next retransmission in %u msecs: ", d);
|
||||||
printPacket("", pending->packet);
|
printPacket("", pending->packet);
|
||||||
setReceivedMessage(); // Run ASAP, so we can figure out our correct sleep time
|
setReceivedMessage(); // Run ASAP, so we can figure out our correct sleep time
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ extern "C" {
|
|||||||
#include "mesh/compression/unishox2.h"
|
#include "mesh/compression/unishox2.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
#if HAS_WIFI
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ ErrorCode Router::send(MeshPacket *p)
|
|||||||
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
|
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
|
||||||
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
||||||
|
|
||||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
#if HAS_WIFI
|
||||||
// check if we should send decrypted packets to mqtt
|
// check if we should send decrypted packets to mqtt
|
||||||
|
|
||||||
// truth table:
|
// truth table:
|
||||||
@@ -244,7 +244,7 @@ ErrorCode Router::send(MeshPacket *p)
|
|||||||
return encodeResult; // FIXME - this isn't a valid ErrorCode
|
return encodeResult; // FIXME - this isn't a valid ErrorCode
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAS_WIFI) || defined(PORTDUINO)
|
#if HAS_WIFI
|
||||||
// the packet is now encrypted.
|
// the packet is now encrypted.
|
||||||
// check if we should send encrypted packets to mqtt
|
// check if we should send encrypted packets to mqtt
|
||||||
if (mqtt && shouldActuallyEncrypt)
|
if (mqtt && shouldActuallyEncrypt)
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ bool SX126xInterface<T>::init()
|
|||||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||||
DEBUG_MSG("SX126x init result %d\n", res);
|
DEBUG_MSG("SX126x init result %d\n", res);
|
||||||
|
|
||||||
|
DEBUG_MSG("Frequency set to %f\n", getFreq());
|
||||||
|
DEBUG_MSG("Bandwidth set to %f\n", bw);
|
||||||
|
DEBUG_MSG("Power output set to %d\n", power);
|
||||||
|
|
||||||
// current limit was removed from module' ctor
|
// current limit was removed from module' ctor
|
||||||
// override default value (60 mA)
|
// override default value (60 mA)
|
||||||
res = lora.setCurrentLimit(currentLimit);
|
res = lora.setCurrentLimit(currentLimit);
|
||||||
@@ -64,7 +68,7 @@ bool SX126xInterface<T>::init()
|
|||||||
|
|
||||||
#ifdef SX126X_TXEN
|
#ifdef SX126X_TXEN
|
||||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora.setDio2AsRfSwitch(true);
|
res = lora.setDio2AsRfSwitch(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -72,7 +76,7 @@ bool SX126xInterface<T>::init()
|
|||||||
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
||||||
uint8_t crcLSB = 0;
|
uint8_t crcLSB = 0;
|
||||||
int err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
int err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
//if(crcLSB != 0x0f)
|
//if(crcLSB != 0x0f)
|
||||||
@@ -80,11 +84,11 @@ bool SX126xInterface<T>::init()
|
|||||||
|
|
||||||
crcLSB = 0x5a;
|
crcLSB = 0x5a;
|
||||||
err = lora.writeRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
err = lora.writeRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
if(crcLSB != 0x5a)
|
if(crcLSB != 0x5a)
|
||||||
@@ -92,13 +96,13 @@ bool SX126xInterface<T>::init()
|
|||||||
// If we got this far register accesses (and therefore SPI comms) are good
|
// If we got this far register accesses (and therefore SPI comms) are good
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora.setCRC(SX126X_LORA_CRC_ON);
|
res = lora.setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
startReceive(); // start receiving
|
startReceive(); // start receiving
|
||||||
|
|
||||||
return res == ERR_NONE;
|
return res == RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -111,42 +115,43 @@ bool SX126xInterface<T>::reconfigure()
|
|||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
int err = lora.setSpreadingFactor(sf);
|
int err = lora.setSpreadingFactor(sf);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora.setBandwidth(bw);
|
err = lora.setBandwidth(bw);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora.setCodingRate(cr);
|
err = lora.setCodingRate(cr);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
||||||
err = lora.setRxGain(true);
|
// TODO: Confirm gain registers are okay now
|
||||||
assert(err == ERR_NONE);
|
// err = lora.setRxGain(true);
|
||||||
|
// assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setSyncWord(syncWord);
|
err = lora.setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setCurrentLimit(currentLimit);
|
err = lora.setCurrentLimit(currentLimit);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setPreambleLength(preambleLength);
|
err = lora.setPreambleLength(preambleLength);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setFrequency(getFreq());
|
err = lora.setFrequency(getFreq());
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
if (power > 22) // This chip has lower power limits than some
|
if (power > 22) // This chip has lower power limits than some
|
||||||
power = 22;
|
power = 22;
|
||||||
err = lora.setOutputPower(power);
|
err = lora.setOutputPower(power);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
startReceive(); // restart receiving
|
startReceive(); // restart receiving
|
||||||
|
|
||||||
return ERR_NONE;
|
return RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -161,7 +166,7 @@ void SX126xInterface<T>::setStandby()
|
|||||||
checkNotification(); // handle any pending interrupts before we force standby
|
checkNotification(); // handle any pending interrupts before we force standby
|
||||||
|
|
||||||
int err = lora.standby();
|
int err = lora.standby();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn off RX and TX power
|
#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn off RX and TX power
|
||||||
digitalWrite(SX126X_RXEN, LOW);
|
digitalWrite(SX126X_RXEN, LOW);
|
||||||
@@ -223,7 +228,7 @@ void SX126xInterface<T>::startReceive()
|
|||||||
// int err = lora.startReceive();
|
// int err = lora.startReceive();
|
||||||
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in
|
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in
|
||||||
// standby mostly.
|
// standby mostly.
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = true;
|
isReceiving = true;
|
||||||
|
|
||||||
@@ -241,10 +246,10 @@ bool SX126xInterface<T>::isChannelActive()
|
|||||||
|
|
||||||
setStandby();
|
setStandby();
|
||||||
result = lora.scanChannel();
|
result = lora.scanChannel();
|
||||||
if (result == PREAMBLE_DETECTED)
|
if (result == RADIOLIB_PREAMBLE_DETECTED)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
assert(result != ERR_WRONG_MODEM);
|
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -259,7 +264,7 @@ bool SX126xInterface<T>::isActivelyReceiving()
|
|||||||
// never even get a valid header, so we don't want preamble to get set and stay set due to noise on the network.
|
// never even get a valid header, so we don't want preamble to get set and stay set due to noise on the network.
|
||||||
|
|
||||||
uint16_t irq = lora.getIrqStatus();
|
uint16_t irq = lora.getIrqStatus();
|
||||||
bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID);
|
bool hasPreamble = (irq & RADIOLIB_SX126X_IRQ_HEADER_VALID);
|
||||||
|
|
||||||
// this is not correct - often always true - need to add an extra conditional
|
// this is not correct - often always true - need to add an extra conditional
|
||||||
// size_t bytesPending = lora.getPacketLength();
|
// size_t bytesPending = lora.getPacketLength();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "admin.pb.h"
|
#include "admin.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_ADMIN_PB_H_INCLUDED
|
#ifndef PB_ADMIN_PB_H_INCLUDED
|
||||||
#define PB_ADMIN_PB_H_INCLUDED
|
#define PB_ADMIN_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
#include "config.pb.h"
|
#include "config.pb.h"
|
||||||
|
#include "device_metadata.pb.h"
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
#include "module_config.pb.h"
|
#include "module_config.pb.h"
|
||||||
|
|
||||||
@@ -38,41 +39,86 @@ typedef enum _AdminMessage_ModuleConfigType {
|
|||||||
This message is used to do settings operations to both remote AND local nodes.
|
This message is used to do settings operations to both remote AND local nodes.
|
||||||
(Prior to 1.2 these operations were done via special ToRadio operations) */
|
(Prior to 1.2 these operations were done via special ToRadio operations) */
|
||||||
typedef struct _AdminMessage {
|
typedef struct _AdminMessage {
|
||||||
/* Set the owner for this node */
|
|
||||||
pb_size_t which_variant;
|
pb_size_t which_variant;
|
||||||
union {
|
union {
|
||||||
|
/* Set the owner for this node */
|
||||||
User set_owner;
|
User set_owner;
|
||||||
|
/* Set channels (using the new API).
|
||||||
|
A special channel is the "primary channel".
|
||||||
|
The other records are secondary channels.
|
||||||
|
Note: only one channel can be marked as primary.
|
||||||
|
If the client sets a particular channel to be primary, the previous channel will be set to SECONDARY automatically. */
|
||||||
Channel set_channel;
|
Channel set_channel;
|
||||||
|
/* Send the specified channel in the response to this message
|
||||||
|
NOTE: This field is sent with the channel index + 1 (to ensure we never try to send 'zero' - which protobufs treats as not present) */
|
||||||
uint32_t get_channel_request;
|
uint32_t get_channel_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
Channel get_channel_response;
|
Channel get_channel_response;
|
||||||
|
/* Send the current owner data in the response to this message. */
|
||||||
bool get_owner_request;
|
bool get_owner_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
User get_owner_response;
|
User get_owner_response;
|
||||||
|
/* Ask for the following config data to be sent */
|
||||||
AdminMessage_ConfigType get_config_request;
|
AdminMessage_ConfigType get_config_request;
|
||||||
|
/* Send the current Config in the response to this message. */
|
||||||
Config get_config_response;
|
Config get_config_response;
|
||||||
|
/* Set the current Config */
|
||||||
Config set_config;
|
Config set_config;
|
||||||
|
/* Sent immediatly after a config change has been sent to ensure comms, if this is not recieved, the config will be reverted after 10 mins */
|
||||||
bool confirm_set_config;
|
bool confirm_set_config;
|
||||||
|
/* Ask for the following config data to be sent */
|
||||||
AdminMessage_ModuleConfigType get_module_config_request;
|
AdminMessage_ModuleConfigType get_module_config_request;
|
||||||
|
/* Send the current Config in the response to this message. */
|
||||||
ModuleConfig get_module_config_response;
|
ModuleConfig get_module_config_response;
|
||||||
|
/* Set the current Config */
|
||||||
ModuleConfig set_module_config;
|
ModuleConfig set_module_config;
|
||||||
|
/* Sent immediatly after a config change has been sent to ensure comms, if this is not recieved, the config will be reverted after 10 mins */
|
||||||
bool confirm_set_module_config;
|
bool confirm_set_module_config;
|
||||||
|
/* Send all channels in the response to this message */
|
||||||
|
bool get_all_channel_request;
|
||||||
|
/* Setting channels/radio config remotely carries the risk that you might send an invalid config and the radio never talks to your mesh again.
|
||||||
|
Therefore if setting either of these properties remotely, you must send a confirm_xxx message within 10 minutes.
|
||||||
|
If you fail to do so, the radio will assume loss of comms and revert your changes.
|
||||||
|
These messages are optional when changing the local node. */
|
||||||
bool confirm_set_channel;
|
bool confirm_set_channel;
|
||||||
|
/* TODO: REPLACE */
|
||||||
bool confirm_set_radio;
|
bool confirm_set_radio;
|
||||||
|
/* This message is only supported for the simulator porduino build.
|
||||||
|
If received the simulator will exit successfully. */
|
||||||
bool exit_simulator;
|
bool exit_simulator;
|
||||||
|
/* Tell the node to reboot in this many seconds (or <0 to cancel reboot) */
|
||||||
int32_t reboot_seconds;
|
int32_t reboot_seconds;
|
||||||
|
/* Get the Canned Message Module message part1 in the response to this message. */
|
||||||
bool get_canned_message_module_part1_request;
|
bool get_canned_message_module_part1_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
char get_canned_message_module_part1_response[201];
|
char get_canned_message_module_part1_response[201];
|
||||||
|
/* Get the Canned Message Module message part2 in the response to this message. */
|
||||||
bool get_canned_message_module_part2_request;
|
bool get_canned_message_module_part2_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
char get_canned_message_module_part2_response[201];
|
char get_canned_message_module_part2_response[201];
|
||||||
|
/* Get the Canned Message Module message part3 in the response to this message. */
|
||||||
bool get_canned_message_module_part3_request;
|
bool get_canned_message_module_part3_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
char get_canned_message_module_part3_response[201];
|
char get_canned_message_module_part3_response[201];
|
||||||
|
/* Get the Canned Message Module message part4 in the response to this message. */
|
||||||
bool get_canned_message_module_part4_request;
|
bool get_canned_message_module_part4_request;
|
||||||
|
/* TODO: REPLACE */
|
||||||
char get_canned_message_module_part4_response[201];
|
char get_canned_message_module_part4_response[201];
|
||||||
|
/* Set the canned message module part 1 text. */
|
||||||
char set_canned_message_module_part1[201];
|
char set_canned_message_module_part1[201];
|
||||||
|
/* Set the canned message module part 2 text. */
|
||||||
char set_canned_message_module_part2[201];
|
char set_canned_message_module_part2[201];
|
||||||
|
/* Set the canned message module part 3 text. */
|
||||||
char set_canned_message_module_part3[201];
|
char set_canned_message_module_part3[201];
|
||||||
|
/* Set the canned message module part 4 text. */
|
||||||
char set_canned_message_module_part4[201];
|
char set_canned_message_module_part4[201];
|
||||||
|
/* Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) */
|
||||||
int32_t shutdown_seconds;
|
int32_t shutdown_seconds;
|
||||||
};
|
/* Request the node to send device metadata (firmware, protobuf version, etc) */
|
||||||
|
uint32_t get_device_metadata_request;
|
||||||
|
/* Device metadata response */
|
||||||
|
DeviceMetadata get_device_metadata_response;
|
||||||
|
};
|
||||||
} AdminMessage;
|
} AdminMessage;
|
||||||
|
|
||||||
|
|
||||||
@@ -109,6 +155,7 @@ extern "C" {
|
|||||||
#define AdminMessage_get_module_config_response_tag 15
|
#define AdminMessage_get_module_config_response_tag 15
|
||||||
#define AdminMessage_set_module_config_tag 16
|
#define AdminMessage_set_module_config_tag 16
|
||||||
#define AdminMessage_confirm_set_module_config_tag 17
|
#define AdminMessage_confirm_set_module_config_tag 17
|
||||||
|
#define AdminMessage_get_all_channel_request_tag 18
|
||||||
#define AdminMessage_confirm_set_channel_tag 32
|
#define AdminMessage_confirm_set_channel_tag 32
|
||||||
#define AdminMessage_confirm_set_radio_tag 33
|
#define AdminMessage_confirm_set_radio_tag 33
|
||||||
#define AdminMessage_exit_simulator_tag 34
|
#define AdminMessage_exit_simulator_tag 34
|
||||||
@@ -126,6 +173,8 @@ extern "C" {
|
|||||||
#define AdminMessage_set_canned_message_module_part3_tag 46
|
#define AdminMessage_set_canned_message_module_part3_tag 46
|
||||||
#define AdminMessage_set_canned_message_module_part4_tag 47
|
#define AdminMessage_set_canned_message_module_part4_tag 47
|
||||||
#define AdminMessage_shutdown_seconds_tag 51
|
#define AdminMessage_shutdown_seconds_tag 51
|
||||||
|
#define AdminMessage_get_device_metadata_request_tag 52
|
||||||
|
#define AdminMessage_get_device_metadata_response_tag 53
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
#define AdminMessage_FIELDLIST(X, a) \
|
#define AdminMessage_FIELDLIST(X, a) \
|
||||||
@@ -143,6 +192,7 @@ X(a, STATIC, ONEOF, UENUM, (variant,get_module_config_request,get_module
|
|||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_module_config_response,get_module_config_response), 15) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,get_module_config_response,get_module_config_response), 15) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_module_config,set_module_config), 16) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,set_module_config,set_module_config), 16) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_module_config,confirm_set_module_config), 17) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_module_config,confirm_set_module_config), 17) \
|
||||||
|
X(a, STATIC, ONEOF, BOOL, (variant,get_all_channel_request,get_all_channel_request), 18) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \
|
X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \
|
||||||
@@ -159,7 +209,9 @@ X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part1,set_
|
|||||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part2,set_canned_message_module_part2), 45) \
|
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part2,set_canned_message_module_part2), 45) \
|
||||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part3,set_canned_message_module_part3), 46) \
|
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part3,set_canned_message_module_part3), 46) \
|
||||||
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part4,set_canned_message_module_part4), 47) \
|
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part4,set_canned_message_module_part4), 47) \
|
||||||
X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51)
|
X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51) \
|
||||||
|
X(a, STATIC, ONEOF, UINT32, (variant,get_device_metadata_request,get_device_metadata_request), 52) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (variant,get_device_metadata_response,get_device_metadata_response), 53)
|
||||||
#define AdminMessage_CALLBACK NULL
|
#define AdminMessage_CALLBACK NULL
|
||||||
#define AdminMessage_DEFAULT NULL
|
#define AdminMessage_DEFAULT NULL
|
||||||
#define AdminMessage_variant_set_owner_MSGTYPE User
|
#define AdminMessage_variant_set_owner_MSGTYPE User
|
||||||
@@ -170,6 +222,7 @@ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds),
|
|||||||
#define AdminMessage_variant_set_config_MSGTYPE Config
|
#define AdminMessage_variant_set_config_MSGTYPE Config
|
||||||
#define AdminMessage_variant_get_module_config_response_MSGTYPE ModuleConfig
|
#define AdminMessage_variant_get_module_config_response_MSGTYPE ModuleConfig
|
||||||
#define AdminMessage_variant_set_module_config_MSGTYPE ModuleConfig
|
#define AdminMessage_variant_set_module_config_MSGTYPE ModuleConfig
|
||||||
|
#define AdminMessage_variant_get_device_metadata_response_MSGTYPE DeviceMetadata
|
||||||
|
|
||||||
extern const pb_msgdesc_t AdminMessage_msg;
|
extern const pb_msgdesc_t AdminMessage_msg;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "apponly.pb.h"
|
#include "apponly.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_APPONLY_PB_H_INCLUDED
|
#ifndef PB_APPONLY_PB_H_INCLUDED
|
||||||
#define PB_APPONLY_PB_H_INCLUDED
|
#define PB_APPONLY_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
|
#include "config.pb.h"
|
||||||
|
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
#error Regenerate this file with the current version of nanopb generator.
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
@@ -17,9 +18,12 @@
|
|||||||
No DISABLED channels are included.
|
No DISABLED channels are included.
|
||||||
This abstraction is used only on the the 'app side' of the world (ie python, javascript and android etc) to show a group of Channels as a (long) URL */
|
This abstraction is used only on the the 'app side' of the world (ie python, javascript and android etc) to show a group of Channels as a (long) URL */
|
||||||
typedef struct _ChannelSet {
|
typedef struct _ChannelSet {
|
||||||
/* TODO: REPLACE */
|
/* Channel list with settings */
|
||||||
pb_size_t settings_count;
|
pb_size_t settings_count;
|
||||||
ChannelSettings settings[8];
|
ChannelSettings settings[8];
|
||||||
|
/* LoRa config */
|
||||||
|
bool has_lora_config;
|
||||||
|
Config_LoRaConfig lora_config;
|
||||||
} ChannelSet;
|
} ChannelSet;
|
||||||
|
|
||||||
|
|
||||||
@@ -28,18 +32,21 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define ChannelSet_init_default {0, {ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default}}
|
#define ChannelSet_init_default {0, {ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default}, false, Config_LoRaConfig_init_default}
|
||||||
#define ChannelSet_init_zero {0, {ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero}}
|
#define ChannelSet_init_zero {0, {ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero}, false, Config_LoRaConfig_init_zero}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define ChannelSet_settings_tag 1
|
#define ChannelSet_settings_tag 1
|
||||||
|
#define ChannelSet_lora_config_tag 2
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
#define ChannelSet_FIELDLIST(X, a) \
|
#define ChannelSet_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, REPEATED, MESSAGE, settings, 1)
|
X(a, STATIC, REPEATED, MESSAGE, settings, 1) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, lora_config, 2)
|
||||||
#define ChannelSet_CALLBACK NULL
|
#define ChannelSet_CALLBACK NULL
|
||||||
#define ChannelSet_DEFAULT NULL
|
#define ChannelSet_DEFAULT NULL
|
||||||
#define ChannelSet_settings_MSGTYPE ChannelSettings
|
#define ChannelSet_settings_MSGTYPE ChannelSettings
|
||||||
|
#define ChannelSet_lora_config_MSGTYPE Config_LoRaConfig
|
||||||
|
|
||||||
extern const pb_msgdesc_t ChannelSet_msg;
|
extern const pb_msgdesc_t ChannelSet_msg;
|
||||||
|
|
||||||
@@ -47,7 +54,7 @@ extern const pb_msgdesc_t ChannelSet_msg;
|
|||||||
#define ChannelSet_fields &ChannelSet_msg
|
#define ChannelSet_fields &ChannelSet_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define ChannelSet_size 504
|
#define ChannelSet_size 573
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "cannedmessages.pb.h"
|
#include "cannedmessages.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_CANNEDMESSAGES_PB_H_INCLUDED
|
#ifndef PB_CANNEDMESSAGES_PB_H_INCLUDED
|
||||||
#define PB_CANNEDMESSAGES_PB_H_INCLUDED
|
#define PB_CANNEDMESSAGES_PB_H_INCLUDED
|
||||||
@@ -13,13 +13,13 @@
|
|||||||
/* Canned message module configuration. */
|
/* Canned message module configuration. */
|
||||||
typedef struct _CannedMessageModuleConfig {
|
typedef struct _CannedMessageModuleConfig {
|
||||||
/* Predefined messages for canned message module separated by '|' characters. */
|
/* Predefined messages for canned message module separated by '|' characters. */
|
||||||
char messagesPart1[201];
|
char messagesPart1[201];
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
char messagesPart2[201];
|
char messagesPart2[201];
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
char messagesPart3[201];
|
char messagesPart3[201];
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
char messagesPart4[201];
|
char messagesPart4[201];
|
||||||
} CannedMessageModuleConfig;
|
} CannedMessageModuleConfig;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_CHANNEL_PB_H_INCLUDED
|
#ifndef PB_CHANNEL_PB_H_INCLUDED
|
||||||
#define PB_CHANNEL_PB_H_INCLUDED
|
#define PB_CHANNEL_PB_H_INCLUDED
|
||||||
@@ -38,6 +38,26 @@ typedef PB_BYTES_ARRAY_T(32) ChannelSettings_psk_t;
|
|||||||
FIXME: explain how apps use channels for security.
|
FIXME: explain how apps use channels for security.
|
||||||
explain how remote settings and remote gpio are managed as an example */
|
explain how remote settings and remote gpio are managed as an example */
|
||||||
typedef struct _ChannelSettings {
|
typedef struct _ChannelSettings {
|
||||||
|
/* A simple pre-shared key for now for crypto.
|
||||||
|
Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256).
|
||||||
|
A special shorthand is used for 1 byte long psks.
|
||||||
|
These psks should be treated as only minimally secure,
|
||||||
|
because they are listed in this source code.
|
||||||
|
Those bytes are mapped using the following scheme:
|
||||||
|
`0` = No crypto
|
||||||
|
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}
|
||||||
|
`2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
||||||
|
Shown to user as simple1 through 10 */
|
||||||
|
ChannelSettings_psk_t psk;
|
||||||
|
/* A SHORT name that will be packed into the URL.
|
||||||
|
Less than 12 bytes.
|
||||||
|
Something for end users to call the channel
|
||||||
|
If this is the empty string it is assumed that this channel
|
||||||
|
is the special (minimally secure) "Default"channel.
|
||||||
|
In user interfaces it should be rendered as a local language translation of "X".
|
||||||
|
For channel_num hashing empty string will be treated as "X".
|
||||||
|
Where "X" is selected based on the English words listed above for ModemPreset */
|
||||||
|
char name[12];
|
||||||
/* NOTE: this field is _independent_ and unrelated to the concepts in channel.proto.
|
/* NOTE: this field is _independent_ and unrelated to the concepts in channel.proto.
|
||||||
this is controlling the actual hardware frequency the radio is transmitting on.
|
this is controlling the actual hardware frequency the radio is transmitting on.
|
||||||
In a perfect world we would have called it something else (band?) but I forgot to make this change during the big 1.2 renaming.
|
In a perfect world we would have called it something else (band?) but I forgot to make this change during the big 1.2 renaming.
|
||||||
@@ -56,27 +76,7 @@ typedef struct _ChannelSettings {
|
|||||||
hash = ((hash << 5) + hash) + (unsigned char) c;
|
hash = ((hash << 5) + hash) + (unsigned char) c;
|
||||||
return hash;
|
return hash;
|
||||||
} */
|
} */
|
||||||
ChannelSettings_psk_t psk;
|
uint8_t channel_num;
|
||||||
/* A simple pre-shared key for now for crypto.
|
|
||||||
Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256).
|
|
||||||
A special shorthand is used for 1 byte long psks.
|
|
||||||
These psks should be treated as only minimally secure,
|
|
||||||
because they are listed in this source code.
|
|
||||||
Those bytes are mapped using the following scheme:
|
|
||||||
`0` = No crypto
|
|
||||||
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}
|
|
||||||
`2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
|
||||||
Shown to user as simple1 through 10 */
|
|
||||||
char name[12];
|
|
||||||
/* A SHORT name that will be packed into the URL.
|
|
||||||
Less than 12 bytes.
|
|
||||||
Something for end users to call the channel
|
|
||||||
If this is the empty string it is assumed that this channel
|
|
||||||
is the special (minimally secure) "Default"channel.
|
|
||||||
In user interfaces it should be rendered as a local language translation of "X".
|
|
||||||
For channel_num hashing empty string will be treated as "X".
|
|
||||||
Where "X" is selected based on the English words listed above for ModemPreset */
|
|
||||||
uint8_t channel_num;
|
|
||||||
/* Used to construct a globally unique channel ID.
|
/* Used to construct a globally unique channel ID.
|
||||||
The full globally unique ID will be: "name.id" where ID is shown as base36.
|
The full globally unique ID will be: "name.id" where ID is shown as base36.
|
||||||
Assuming that the number of meshtastic users is below 20K (true for a long time)
|
Assuming that the number of meshtastic users is below 20K (true for a long time)
|
||||||
@@ -88,11 +88,11 @@ typedef struct _ChannelSettings {
|
|||||||
Those channels do not have a numeric id included in the settings, but instead it is pulled from
|
Those channels do not have a numeric id included in the settings, but instead it is pulled from
|
||||||
a table of well known IDs.
|
a table of well known IDs.
|
||||||
(see Well Known Channels FIXME) */
|
(see Well Known Channels FIXME) */
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
/* If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe */
|
/* If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe */
|
||||||
bool uplink_enabled;
|
bool uplink_enabled;
|
||||||
/* If true, messages seen on the internet will be forwarded to the local mesh. */
|
/* If true, messages seen on the internet will be forwarded to the local mesh. */
|
||||||
bool downlink_enabled;
|
bool downlink_enabled;
|
||||||
} ChannelSettings;
|
} ChannelSettings;
|
||||||
|
|
||||||
/* A pair of a channel number, mode and the (sharable) settings for that channel */
|
/* A pair of a channel number, mode and the (sharable) settings for that channel */
|
||||||
@@ -100,12 +100,12 @@ typedef struct _Channel {
|
|||||||
/* The index of this channel in the channel table (from 0 to MAX_NUM_CHANNELS-1)
|
/* The index of this channel in the channel table (from 0 to MAX_NUM_CHANNELS-1)
|
||||||
(Someday - not currently implemented) An index of -1 could be used to mean "set by name",
|
(Someday - not currently implemented) An index of -1 could be used to mean "set by name",
|
||||||
in which case the target node will find and set the channel by settings.name. */
|
in which case the target node will find and set the channel by settings.name. */
|
||||||
int8_t index;
|
int8_t index;
|
||||||
/* The new settings, or NULL to disable that channel */
|
/* The new settings, or NULL to disable that channel */
|
||||||
bool has_settings;
|
bool has_settings;
|
||||||
ChannelSettings settings;
|
ChannelSettings settings;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
Channel_Role role;
|
Channel_Role role;
|
||||||
} Channel;
|
} Channel;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "config.pb.h"
|
#include "config.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
@@ -34,3 +34,4 @@ PB_BIND(Config_LoRaConfig, Config_LoRaConfig, 2)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_CONFIG_PB_H_INCLUDED
|
#ifndef PB_CONFIG_PB_H_INCLUDED
|
||||||
#define PB_CONFIG_PB_H_INCLUDED
|
#define PB_CONFIG_PB_H_INCLUDED
|
||||||
@@ -26,7 +26,9 @@ typedef enum _Config_PositionConfig_PositionFlags {
|
|||||||
Config_PositionConfig_PositionFlags_POS_HVDOP = 16,
|
Config_PositionConfig_PositionFlags_POS_HVDOP = 16,
|
||||||
Config_PositionConfig_PositionFlags_POS_SATINVIEW = 32,
|
Config_PositionConfig_PositionFlags_POS_SATINVIEW = 32,
|
||||||
Config_PositionConfig_PositionFlags_POS_SEQ_NOS = 64,
|
Config_PositionConfig_PositionFlags_POS_SEQ_NOS = 64,
|
||||||
Config_PositionConfig_PositionFlags_POS_TIMESTAMP = 128
|
Config_PositionConfig_PositionFlags_POS_TIMESTAMP = 128,
|
||||||
|
Config_PositionConfig_PositionFlags_POS_HEADING = 256,
|
||||||
|
Config_PositionConfig_PositionFlags_POS_SPEED = 512
|
||||||
} Config_PositionConfig_PositionFlags;
|
} Config_PositionConfig_PositionFlags;
|
||||||
|
|
||||||
typedef enum _Config_PowerConfig_ChargeCurrent {
|
typedef enum _Config_PowerConfig_ChargeCurrent {
|
||||||
@@ -49,6 +51,12 @@ typedef enum _Config_PowerConfig_ChargeCurrent {
|
|||||||
Config_PowerConfig_ChargeCurrent_MA1320 = 16
|
Config_PowerConfig_ChargeCurrent_MA1320 = 16
|
||||||
} Config_PowerConfig_ChargeCurrent;
|
} Config_PowerConfig_ChargeCurrent;
|
||||||
|
|
||||||
|
typedef enum _Config_WiFiConfig_WiFiMode {
|
||||||
|
Config_WiFiConfig_WiFiMode_Client = 0,
|
||||||
|
Config_WiFiConfig_WiFiMode_AccessPoint = 1,
|
||||||
|
Config_WiFiConfig_WiFiMode_AccessPointHidden = 2
|
||||||
|
} Config_WiFiConfig_WiFiMode;
|
||||||
|
|
||||||
typedef enum _Config_DisplayConfig_GpsCoordinateFormat {
|
typedef enum _Config_DisplayConfig_GpsCoordinateFormat {
|
||||||
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec = 0,
|
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec = 0,
|
||||||
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS = 1,
|
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS = 1,
|
||||||
@@ -78,77 +86,72 @@ typedef enum _Config_LoRaConfig_ModemPreset {
|
|||||||
Config_LoRaConfig_ModemPreset_LongFast = 0,
|
Config_LoRaConfig_ModemPreset_LongFast = 0,
|
||||||
Config_LoRaConfig_ModemPreset_LongSlow = 1,
|
Config_LoRaConfig_ModemPreset_LongSlow = 1,
|
||||||
Config_LoRaConfig_ModemPreset_VLongSlow = 2,
|
Config_LoRaConfig_ModemPreset_VLongSlow = 2,
|
||||||
Config_LoRaConfig_ModemPreset_MidSlow = 3,
|
Config_LoRaConfig_ModemPreset_MedSlow = 3,
|
||||||
Config_LoRaConfig_ModemPreset_MidFast = 4,
|
Config_LoRaConfig_ModemPreset_MedFast = 4,
|
||||||
Config_LoRaConfig_ModemPreset_ShortSlow = 5,
|
Config_LoRaConfig_ModemPreset_ShortSlow = 5,
|
||||||
Config_LoRaConfig_ModemPreset_ShortFast = 6
|
Config_LoRaConfig_ModemPreset_ShortFast = 6
|
||||||
} Config_LoRaConfig_ModemPreset;
|
} Config_LoRaConfig_ModemPreset;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef struct _Config_DeviceConfig {
|
typedef struct _Config_DeviceConfig {
|
||||||
Config_DeviceConfig_Role role;
|
Config_DeviceConfig_Role role;
|
||||||
bool serial_disabled;
|
bool serial_disabled;
|
||||||
bool factory_reset;
|
bool factory_reset;
|
||||||
bool debug_log_enabled;
|
bool debug_log_enabled;
|
||||||
char ntp_server[33];
|
char ntp_server[33];
|
||||||
} Config_DeviceConfig;
|
} Config_DeviceConfig;
|
||||||
|
|
||||||
typedef struct _Config_DisplayConfig {
|
typedef struct _Config_DisplayConfig {
|
||||||
uint32_t screen_on_secs;
|
uint32_t screen_on_secs;
|
||||||
Config_DisplayConfig_GpsCoordinateFormat gps_format;
|
Config_DisplayConfig_GpsCoordinateFormat gps_format;
|
||||||
uint32_t auto_screen_carousel_secs;
|
uint32_t auto_screen_carousel_secs;
|
||||||
|
bool compass_north_top;
|
||||||
} Config_DisplayConfig;
|
} Config_DisplayConfig;
|
||||||
|
|
||||||
typedef struct _Config_LoRaConfig {
|
typedef struct _Config_LoRaConfig {
|
||||||
int32_t tx_power;
|
int32_t tx_power;
|
||||||
Config_LoRaConfig_ModemPreset modem_preset;
|
Config_LoRaConfig_ModemPreset modem_preset;
|
||||||
uint32_t bandwidth;
|
uint32_t bandwidth;
|
||||||
uint32_t spread_factor;
|
uint32_t spread_factor;
|
||||||
uint32_t coding_rate;
|
uint32_t coding_rate;
|
||||||
float frequency_offset;
|
float frequency_offset;
|
||||||
Config_LoRaConfig_RegionCode region;
|
Config_LoRaConfig_RegionCode region;
|
||||||
uint32_t hop_limit;
|
uint32_t hop_limit;
|
||||||
bool tx_disabled;
|
bool tx_disabled;
|
||||||
pb_size_t ignore_incoming_count;
|
pb_size_t ignore_incoming_count;
|
||||||
uint32_t ignore_incoming[3];
|
uint32_t ignore_incoming[3];
|
||||||
} Config_LoRaConfig;
|
} Config_LoRaConfig;
|
||||||
|
|
||||||
typedef struct _Config_PositionConfig {
|
typedef struct _Config_PositionConfig {
|
||||||
uint32_t position_broadcast_secs;
|
uint32_t position_broadcast_secs;
|
||||||
bool position_broadcast_smart_disabled;
|
bool position_broadcast_smart_disabled;
|
||||||
bool fixed_position;
|
bool fixed_position;
|
||||||
bool gps_disabled;
|
bool gps_disabled;
|
||||||
uint32_t gps_update_interval;
|
uint32_t gps_update_interval;
|
||||||
uint32_t gps_attempt_time;
|
uint32_t gps_attempt_time;
|
||||||
bool gps_accept_2d;
|
uint32_t position_flags;
|
||||||
uint32_t gps_max_dop;
|
|
||||||
uint32_t position_flags;
|
|
||||||
} Config_PositionConfig;
|
} Config_PositionConfig;
|
||||||
|
|
||||||
typedef struct _Config_PowerConfig {
|
typedef struct _Config_PowerConfig {
|
||||||
Config_PowerConfig_ChargeCurrent charge_current;
|
Config_PowerConfig_ChargeCurrent charge_current;
|
||||||
bool is_low_power;
|
bool is_power_saving;
|
||||||
bool is_always_powered;
|
uint32_t on_battery_shutdown_after_secs;
|
||||||
uint32_t on_battery_shutdown_after_secs;
|
float adc_multiplier_override;
|
||||||
bool is_power_saving;
|
uint32_t wait_bluetooth_secs;
|
||||||
float adc_multiplier_override;
|
uint32_t mesh_sds_timeout_secs;
|
||||||
uint32_t wait_bluetooth_secs;
|
uint32_t sds_secs;
|
||||||
uint32_t phone_timeout_secs;
|
uint32_t ls_secs;
|
||||||
uint32_t mesh_sds_timeout_secs;
|
uint32_t min_wake_secs;
|
||||||
uint32_t sds_secs;
|
|
||||||
uint32_t ls_secs;
|
|
||||||
uint32_t min_wake_secs;
|
|
||||||
} Config_PowerConfig;
|
} Config_PowerConfig;
|
||||||
|
|
||||||
typedef struct _Config_WiFiConfig {
|
typedef struct _Config_WiFiConfig {
|
||||||
char ssid[33];
|
bool enabled;
|
||||||
char psk[64];
|
Config_WiFiConfig_WiFiMode mode;
|
||||||
bool ap_mode;
|
char ssid[33];
|
||||||
bool ap_hidden;
|
char psk[64];
|
||||||
} Config_WiFiConfig;
|
} Config_WiFiConfig;
|
||||||
|
|
||||||
typedef struct _Config {
|
typedef struct _Config {
|
||||||
/* TODO: REPLACE */
|
|
||||||
pb_size_t which_payloadVariant;
|
pb_size_t which_payloadVariant;
|
||||||
union {
|
union {
|
||||||
Config_DeviceConfig device;
|
Config_DeviceConfig device;
|
||||||
@@ -157,7 +160,7 @@ typedef struct _Config {
|
|||||||
Config_WiFiConfig wifi;
|
Config_WiFiConfig wifi;
|
||||||
Config_DisplayConfig display;
|
Config_DisplayConfig display;
|
||||||
Config_LoRaConfig lora;
|
Config_LoRaConfig lora;
|
||||||
} payloadVariant;
|
} payloadVariant;
|
||||||
} Config;
|
} Config;
|
||||||
|
|
||||||
|
|
||||||
@@ -167,13 +170,17 @@ typedef struct _Config {
|
|||||||
#define _Config_DeviceConfig_Role_ARRAYSIZE ((Config_DeviceConfig_Role)(Config_DeviceConfig_Role_RouterClient+1))
|
#define _Config_DeviceConfig_Role_ARRAYSIZE ((Config_DeviceConfig_Role)(Config_DeviceConfig_Role_RouterClient+1))
|
||||||
|
|
||||||
#define _Config_PositionConfig_PositionFlags_MIN Config_PositionConfig_PositionFlags_POS_UNDEFINED
|
#define _Config_PositionConfig_PositionFlags_MIN Config_PositionConfig_PositionFlags_POS_UNDEFINED
|
||||||
#define _Config_PositionConfig_PositionFlags_MAX Config_PositionConfig_PositionFlags_POS_TIMESTAMP
|
#define _Config_PositionConfig_PositionFlags_MAX Config_PositionConfig_PositionFlags_POS_SPEED
|
||||||
#define _Config_PositionConfig_PositionFlags_ARRAYSIZE ((Config_PositionConfig_PositionFlags)(Config_PositionConfig_PositionFlags_POS_TIMESTAMP+1))
|
#define _Config_PositionConfig_PositionFlags_ARRAYSIZE ((Config_PositionConfig_PositionFlags)(Config_PositionConfig_PositionFlags_POS_SPEED+1))
|
||||||
|
|
||||||
#define _Config_PowerConfig_ChargeCurrent_MIN Config_PowerConfig_ChargeCurrent_MAUnset
|
#define _Config_PowerConfig_ChargeCurrent_MIN Config_PowerConfig_ChargeCurrent_MAUnset
|
||||||
#define _Config_PowerConfig_ChargeCurrent_MAX Config_PowerConfig_ChargeCurrent_MA1320
|
#define _Config_PowerConfig_ChargeCurrent_MAX Config_PowerConfig_ChargeCurrent_MA1320
|
||||||
#define _Config_PowerConfig_ChargeCurrent_ARRAYSIZE ((Config_PowerConfig_ChargeCurrent)(Config_PowerConfig_ChargeCurrent_MA1320+1))
|
#define _Config_PowerConfig_ChargeCurrent_ARRAYSIZE ((Config_PowerConfig_ChargeCurrent)(Config_PowerConfig_ChargeCurrent_MA1320+1))
|
||||||
|
|
||||||
|
#define _Config_WiFiConfig_WiFiMode_MIN Config_WiFiConfig_WiFiMode_Client
|
||||||
|
#define _Config_WiFiConfig_WiFiMode_MAX Config_WiFiConfig_WiFiMode_AccessPointHidden
|
||||||
|
#define _Config_WiFiConfig_WiFiMode_ARRAYSIZE ((Config_WiFiConfig_WiFiMode)(Config_WiFiConfig_WiFiMode_AccessPointHidden+1))
|
||||||
|
|
||||||
#define _Config_DisplayConfig_GpsCoordinateFormat_MIN Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec
|
#define _Config_DisplayConfig_GpsCoordinateFormat_MIN Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec
|
||||||
#define _Config_DisplayConfig_GpsCoordinateFormat_MAX Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR
|
#define _Config_DisplayConfig_GpsCoordinateFormat_MAX Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR
|
||||||
#define _Config_DisplayConfig_GpsCoordinateFormat_ARRAYSIZE ((Config_DisplayConfig_GpsCoordinateFormat)(Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR+1))
|
#define _Config_DisplayConfig_GpsCoordinateFormat_ARRAYSIZE ((Config_DisplayConfig_GpsCoordinateFormat)(Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR+1))
|
||||||
@@ -194,17 +201,17 @@ extern "C" {
|
|||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define Config_init_default {0, {Config_DeviceConfig_init_default}}
|
#define Config_init_default {0, {Config_DeviceConfig_init_default}}
|
||||||
#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
|
#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
|
||||||
#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0}
|
||||||
#define Config_PowerConfig_init_default {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define Config_PowerConfig_init_default {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define Config_WiFiConfig_init_default {"", "", 0, 0}
|
#define Config_WiFiConfig_init_default {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""}
|
||||||
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0}
|
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0}
|
||||||
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
|
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
|
||||||
#define Config_init_zero {0, {Config_DeviceConfig_init_zero}}
|
#define Config_init_zero {0, {Config_DeviceConfig_init_zero}}
|
||||||
#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
|
#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
|
||||||
#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0}
|
||||||
#define Config_PowerConfig_init_zero {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
#define Config_PowerConfig_init_zero {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define Config_WiFiConfig_init_zero {"", "", 0, 0}
|
#define Config_WiFiConfig_init_zero {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""}
|
||||||
#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0}
|
#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0}
|
||||||
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
|
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
@@ -216,6 +223,7 @@ extern "C" {
|
|||||||
#define Config_DisplayConfig_screen_on_secs_tag 1
|
#define Config_DisplayConfig_screen_on_secs_tag 1
|
||||||
#define Config_DisplayConfig_gps_format_tag 2
|
#define Config_DisplayConfig_gps_format_tag 2
|
||||||
#define Config_DisplayConfig_auto_screen_carousel_secs_tag 3
|
#define Config_DisplayConfig_auto_screen_carousel_secs_tag 3
|
||||||
|
#define Config_DisplayConfig_compass_north_top_tag 4
|
||||||
#define Config_LoRaConfig_tx_power_tag 1
|
#define Config_LoRaConfig_tx_power_tag 1
|
||||||
#define Config_LoRaConfig_modem_preset_tag 2
|
#define Config_LoRaConfig_modem_preset_tag 2
|
||||||
#define Config_LoRaConfig_bandwidth_tag 3
|
#define Config_LoRaConfig_bandwidth_tag 3
|
||||||
@@ -232,25 +240,20 @@ extern "C" {
|
|||||||
#define Config_PositionConfig_gps_disabled_tag 5
|
#define Config_PositionConfig_gps_disabled_tag 5
|
||||||
#define Config_PositionConfig_gps_update_interval_tag 6
|
#define Config_PositionConfig_gps_update_interval_tag 6
|
||||||
#define Config_PositionConfig_gps_attempt_time_tag 7
|
#define Config_PositionConfig_gps_attempt_time_tag 7
|
||||||
#define Config_PositionConfig_gps_accept_2d_tag 8
|
|
||||||
#define Config_PositionConfig_gps_max_dop_tag 9
|
|
||||||
#define Config_PositionConfig_position_flags_tag 10
|
#define Config_PositionConfig_position_flags_tag 10
|
||||||
#define Config_PowerConfig_charge_current_tag 1
|
#define Config_PowerConfig_charge_current_tag 1
|
||||||
#define Config_PowerConfig_is_low_power_tag 2
|
#define Config_PowerConfig_is_power_saving_tag 2
|
||||||
#define Config_PowerConfig_is_always_powered_tag 3
|
|
||||||
#define Config_PowerConfig_on_battery_shutdown_after_secs_tag 4
|
#define Config_PowerConfig_on_battery_shutdown_after_secs_tag 4
|
||||||
#define Config_PowerConfig_is_power_saving_tag 5
|
|
||||||
#define Config_PowerConfig_adc_multiplier_override_tag 6
|
#define Config_PowerConfig_adc_multiplier_override_tag 6
|
||||||
#define Config_PowerConfig_wait_bluetooth_secs_tag 7
|
#define Config_PowerConfig_wait_bluetooth_secs_tag 7
|
||||||
#define Config_PowerConfig_phone_timeout_secs_tag 8
|
|
||||||
#define Config_PowerConfig_mesh_sds_timeout_secs_tag 9
|
#define Config_PowerConfig_mesh_sds_timeout_secs_tag 9
|
||||||
#define Config_PowerConfig_sds_secs_tag 10
|
#define Config_PowerConfig_sds_secs_tag 10
|
||||||
#define Config_PowerConfig_ls_secs_tag 11
|
#define Config_PowerConfig_ls_secs_tag 11
|
||||||
#define Config_PowerConfig_min_wake_secs_tag 12
|
#define Config_PowerConfig_min_wake_secs_tag 12
|
||||||
#define Config_WiFiConfig_ssid_tag 1
|
#define Config_WiFiConfig_enabled_tag 1
|
||||||
#define Config_WiFiConfig_psk_tag 2
|
#define Config_WiFiConfig_mode_tag 2
|
||||||
#define Config_WiFiConfig_ap_mode_tag 3
|
#define Config_WiFiConfig_ssid_tag 3
|
||||||
#define Config_WiFiConfig_ap_hidden_tag 4
|
#define Config_WiFiConfig_psk_tag 4
|
||||||
#define Config_device_tag 1
|
#define Config_device_tag 1
|
||||||
#define Config_position_tag 2
|
#define Config_position_tag 2
|
||||||
#define Config_power_tag 3
|
#define Config_power_tag 3
|
||||||
@@ -291,21 +294,16 @@ X(a, STATIC, SINGULAR, BOOL, fixed_position, 3) \
|
|||||||
X(a, STATIC, SINGULAR, BOOL, gps_disabled, 5) \
|
X(a, STATIC, SINGULAR, BOOL, gps_disabled, 5) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 6) \
|
X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 6) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, gps_attempt_time, 7) \
|
X(a, STATIC, SINGULAR, UINT32, gps_attempt_time, 7) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, gps_accept_2d, 8) \
|
|
||||||
X(a, STATIC, SINGULAR, UINT32, gps_max_dop, 9) \
|
|
||||||
X(a, STATIC, SINGULAR, UINT32, position_flags, 10)
|
X(a, STATIC, SINGULAR, UINT32, position_flags, 10)
|
||||||
#define Config_PositionConfig_CALLBACK NULL
|
#define Config_PositionConfig_CALLBACK NULL
|
||||||
#define Config_PositionConfig_DEFAULT NULL
|
#define Config_PositionConfig_DEFAULT NULL
|
||||||
|
|
||||||
#define Config_PowerConfig_FIELDLIST(X, a) \
|
#define Config_PowerConfig_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, SINGULAR, UENUM, charge_current, 1) \
|
X(a, STATIC, SINGULAR, UENUM, charge_current, 1) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, is_low_power, 2) \
|
X(a, STATIC, SINGULAR, BOOL, is_power_saving, 2) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, is_always_powered, 3) \
|
|
||||||
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 4) \
|
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 4) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, is_power_saving, 5) \
|
|
||||||
X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 6) \
|
X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 6) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, wait_bluetooth_secs, 7) \
|
X(a, STATIC, SINGULAR, UINT32, wait_bluetooth_secs, 7) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, phone_timeout_secs, 8) \
|
|
||||||
X(a, STATIC, SINGULAR, UINT32, mesh_sds_timeout_secs, 9) \
|
X(a, STATIC, SINGULAR, UINT32, mesh_sds_timeout_secs, 9) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, sds_secs, 10) \
|
X(a, STATIC, SINGULAR, UINT32, sds_secs, 10) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, ls_secs, 11) \
|
X(a, STATIC, SINGULAR, UINT32, ls_secs, 11) \
|
||||||
@@ -314,17 +312,18 @@ X(a, STATIC, SINGULAR, UINT32, min_wake_secs, 12)
|
|||||||
#define Config_PowerConfig_DEFAULT NULL
|
#define Config_PowerConfig_DEFAULT NULL
|
||||||
|
|
||||||
#define Config_WiFiConfig_FIELDLIST(X, a) \
|
#define Config_WiFiConfig_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, SINGULAR, STRING, ssid, 1) \
|
X(a, STATIC, SINGULAR, BOOL, enabled, 1) \
|
||||||
X(a, STATIC, SINGULAR, STRING, psk, 2) \
|
X(a, STATIC, SINGULAR, UENUM, mode, 2) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, ap_mode, 3) \
|
X(a, STATIC, SINGULAR, STRING, ssid, 3) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, ap_hidden, 4)
|
X(a, STATIC, SINGULAR, STRING, psk, 4)
|
||||||
#define Config_WiFiConfig_CALLBACK NULL
|
#define Config_WiFiConfig_CALLBACK NULL
|
||||||
#define Config_WiFiConfig_DEFAULT NULL
|
#define Config_WiFiConfig_DEFAULT NULL
|
||||||
|
|
||||||
#define Config_DisplayConfig_FIELDLIST(X, a) \
|
#define Config_DisplayConfig_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, screen_on_secs, 1) \
|
X(a, STATIC, SINGULAR, UINT32, screen_on_secs, 1) \
|
||||||
X(a, STATIC, SINGULAR, UENUM, gps_format, 2) \
|
X(a, STATIC, SINGULAR, UENUM, gps_format, 2) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 3)
|
X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 3) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, compass_north_top, 4)
|
||||||
#define Config_DisplayConfig_CALLBACK NULL
|
#define Config_DisplayConfig_CALLBACK NULL
|
||||||
#define Config_DisplayConfig_DEFAULT NULL
|
#define Config_DisplayConfig_DEFAULT NULL
|
||||||
|
|
||||||
@@ -361,10 +360,10 @@ extern const pb_msgdesc_t Config_LoRaConfig_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define Config_DeviceConfig_size 42
|
#define Config_DeviceConfig_size 42
|
||||||
#define Config_DisplayConfig_size 14
|
#define Config_DisplayConfig_size 16
|
||||||
#define Config_LoRaConfig_size 67
|
#define Config_LoRaConfig_size 67
|
||||||
#define Config_PositionConfig_size 38
|
#define Config_PositionConfig_size 30
|
||||||
#define Config_PowerConfig_size 55
|
#define Config_PowerConfig_size 45
|
||||||
#define Config_WiFiConfig_size 103
|
#define Config_WiFiConfig_size 103
|
||||||
#define Config_size 105
|
#define Config_size 105
|
||||||
|
|
||||||
|
|||||||
12
src/mesh/generated/device_metadata.pb.c
Normal file
12
src/mesh/generated/device_metadata.pb.c
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/* Automatically generated nanopb constant definitions */
|
||||||
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
|
#include "device_metadata.pb.h"
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PB_BIND(DeviceMetadata, DeviceMetadata, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
53
src/mesh/generated/device_metadata.pb.h
Normal file
53
src/mesh/generated/device_metadata.pb.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* Automatically generated nanopb header */
|
||||||
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
|
#ifndef PB_DEVICE_METADATA_PB_H_INCLUDED
|
||||||
|
#define PB_DEVICE_METADATA_PB_H_INCLUDED
|
||||||
|
#include <pb.h>
|
||||||
|
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Struct definitions */
|
||||||
|
/* Device metadata response */
|
||||||
|
typedef struct _DeviceMetadata {
|
||||||
|
/* Device firmware version string */
|
||||||
|
char firmware_version[18];
|
||||||
|
/* Device state version */
|
||||||
|
uint32_t device_state_version;
|
||||||
|
} DeviceMetadata;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initializer values for message structs */
|
||||||
|
#define DeviceMetadata_init_default {"", 0}
|
||||||
|
#define DeviceMetadata_init_zero {"", 0}
|
||||||
|
|
||||||
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
|
#define DeviceMetadata_firmware_version_tag 1
|
||||||
|
#define DeviceMetadata_device_state_version_tag 2
|
||||||
|
|
||||||
|
/* Struct field encoding specification for nanopb */
|
||||||
|
#define DeviceMetadata_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, device_state_version, 2)
|
||||||
|
#define DeviceMetadata_CALLBACK NULL
|
||||||
|
#define DeviceMetadata_DEFAULT NULL
|
||||||
|
|
||||||
|
extern const pb_msgdesc_t DeviceMetadata_msg;
|
||||||
|
|
||||||
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
|
#define DeviceMetadata_fields &DeviceMetadata_msg
|
||||||
|
|
||||||
|
/* Maximum encoded size of messages (where known) */
|
||||||
|
#define DeviceMetadata_size 25
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "deviceonly.pb.h"
|
#include "deviceonly.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
@@ -15,11 +15,5 @@ PB_BIND(ChannelFile, ChannelFile, 2)
|
|||||||
PB_BIND(OEMStore, OEMStore, 2)
|
PB_BIND(OEMStore, OEMStore, 2)
|
||||||
|
|
||||||
|
|
||||||
PB_BIND(LocalConfig, LocalConfig, 2)
|
|
||||||
|
|
||||||
|
|
||||||
PB_BIND(LocalModuleConfig, LocalModuleConfig, 2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_DEVICEONLY_PB_H_INCLUDED
|
#ifndef PB_DEVICEONLY_PB_H_INCLUDED
|
||||||
#define PB_DEVICEONLY_PB_H_INCLUDED
|
#define PB_DEVICEONLY_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
#include "config.pb.h"
|
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
#include "module_config.pb.h"
|
|
||||||
|
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
#error Regenerate this file with the current version of nanopb generator.
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
@@ -29,7 +27,11 @@ typedef enum _ScreenFonts {
|
|||||||
typedef struct _ChannelFile {
|
typedef struct _ChannelFile {
|
||||||
/* The channels our node knows about */
|
/* The channels our node knows about */
|
||||||
pb_size_t channels_count;
|
pb_size_t channels_count;
|
||||||
Channel channels[8];
|
Channel channels[8];
|
||||||
|
/* A version integer used to invalidate old save files when we make
|
||||||
|
incompatible changes This integer is set at build time and is private to
|
||||||
|
NodeDB.cpp in the device code. */
|
||||||
|
uint32_t version;
|
||||||
} ChannelFile;
|
} ChannelFile;
|
||||||
|
|
||||||
/* This message is never sent over the wire, but it is used for serializing DB
|
/* This message is never sent over the wire, but it is used for serializing DB
|
||||||
@@ -40,91 +42,46 @@ typedef struct _ChannelFile {
|
|||||||
typedef struct _DeviceState {
|
typedef struct _DeviceState {
|
||||||
/* Read only settings/info about this node */
|
/* Read only settings/info about this node */
|
||||||
bool has_my_node;
|
bool has_my_node;
|
||||||
MyNodeInfo my_node;
|
MyNodeInfo my_node;
|
||||||
/* My owner info */
|
/* My owner info */
|
||||||
bool has_owner;
|
bool has_owner;
|
||||||
User owner;
|
User owner;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
pb_size_t node_db_count;
|
pb_size_t node_db_count;
|
||||||
NodeInfo node_db[64];
|
NodeInfo node_db[80];
|
||||||
/* Received packets saved for delivery to the phone */
|
/* Received packets saved for delivery to the phone */
|
||||||
pb_size_t receive_queue_count;
|
pb_size_t receive_queue_count;
|
||||||
MeshPacket receive_queue[1];
|
MeshPacket receive_queue[1];
|
||||||
/* A version integer used to invalidate old save files when we make
|
|
||||||
incompatible changes This integer is set at build time and is private to
|
|
||||||
NodeDB.cpp in the device code. */
|
|
||||||
bool has_rx_text_message;
|
|
||||||
MeshPacket rx_text_message;
|
|
||||||
/* We keep the last received text message (only) stored in the device flash,
|
/* We keep the last received text message (only) stored in the device flash,
|
||||||
so we can show it on the screen.
|
so we can show it on the screen.
|
||||||
Might be null */
|
Might be null */
|
||||||
uint32_t version;
|
bool has_rx_text_message;
|
||||||
|
MeshPacket rx_text_message;
|
||||||
|
/* A version integer used to invalidate old save files when we make
|
||||||
|
incompatible changes This integer is set at build time and is private to
|
||||||
|
NodeDB.cpp in the device code. */
|
||||||
|
uint32_t version;
|
||||||
/* Used only during development.
|
/* Used only during development.
|
||||||
Indicates developer is testing and changes should never be saved to flash. */
|
Indicates developer is testing and changes should never be saved to flash. */
|
||||||
bool no_save;
|
bool no_save;
|
||||||
/* Some GPSes seem to have bogus settings from the factory, so we always do one factory reset. */
|
/* Some GPSes seem to have bogus settings from the factory, so we always do one factory reset. */
|
||||||
bool did_gps_reset;
|
bool did_gps_reset;
|
||||||
} DeviceState;
|
} DeviceState;
|
||||||
|
|
||||||
typedef struct _LocalConfig {
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_device;
|
|
||||||
Config_DeviceConfig device;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_position;
|
|
||||||
Config_PositionConfig position;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_power;
|
|
||||||
Config_PowerConfig power;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_wifi;
|
|
||||||
Config_WiFiConfig wifi;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_display;
|
|
||||||
Config_DisplayConfig display;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_lora;
|
|
||||||
Config_LoRaConfig lora;
|
|
||||||
} LocalConfig;
|
|
||||||
|
|
||||||
typedef struct _LocalModuleConfig {
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_mqtt;
|
|
||||||
ModuleConfig_MQTTConfig mqtt;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_serial;
|
|
||||||
ModuleConfig_SerialConfig serial;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_external_notification;
|
|
||||||
ModuleConfig_ExternalNotificationConfig external_notification;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_store_forward;
|
|
||||||
ModuleConfig_StoreForwardConfig store_forward;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_range_test;
|
|
||||||
ModuleConfig_RangeTestConfig range_test;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_telemetry;
|
|
||||||
ModuleConfig_TelemetryConfig telemetry;
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
bool has_canned_message;
|
|
||||||
ModuleConfig_CannedMessageConfig canned_message;
|
|
||||||
} LocalModuleConfig;
|
|
||||||
|
|
||||||
typedef PB_BYTES_ARRAY_T(2048) OEMStore_oem_icon_bits_t;
|
typedef PB_BYTES_ARRAY_T(2048) OEMStore_oem_icon_bits_t;
|
||||||
/* This can be used for customizing the firmware distribution. If populated,
|
/* This can be used for customizing the firmware distribution. If populated,
|
||||||
show a secondary bootup screen with cuatom logo and text for 2.5 seconds. */
|
show a secondary bootup screen with cuatom logo and text for 2.5 seconds. */
|
||||||
typedef struct _OEMStore {
|
typedef struct _OEMStore {
|
||||||
/* The Logo width in Px */
|
/* The Logo width in Px */
|
||||||
uint32_t oem_icon_width;
|
uint32_t oem_icon_width;
|
||||||
/* The Logo height in Px */
|
/* The Logo height in Px */
|
||||||
uint32_t oem_icon_height;
|
uint32_t oem_icon_height;
|
||||||
/* The Logo in xbm bytechar format */
|
/* The Logo in xbm bytechar format */
|
||||||
OEMStore_oem_icon_bits_t oem_icon_bits;
|
OEMStore_oem_icon_bits_t oem_icon_bits;
|
||||||
/* Use this font for the OEM text. */
|
/* Use this font for the OEM text. */
|
||||||
ScreenFonts oem_font;
|
ScreenFonts oem_font;
|
||||||
/* Use this font for the OEM text. */
|
/* Use this font for the OEM text. */
|
||||||
char oem_text[40];
|
char oem_text[40];
|
||||||
} OEMStore;
|
} OEMStore;
|
||||||
|
|
||||||
|
|
||||||
@@ -139,19 +96,16 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define DeviceState_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, 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, 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, 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, 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 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}, 0}
|
||||||
#define OEMStore_init_default {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
#define OEMStore_init_default {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
||||||
#define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_WiFiConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default}
|
#define DeviceState_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, 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, 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 LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default}
|
#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}, 0}
|
||||||
#define DeviceState_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, 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}}
|
|
||||||
#define OEMStore_init_zero {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
#define OEMStore_init_zero {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
||||||
#define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_WiFiConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero}
|
|
||||||
#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero}
|
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define ChannelFile_channels_tag 1
|
#define ChannelFile_channels_tag 1
|
||||||
|
#define ChannelFile_version_tag 2
|
||||||
#define DeviceState_my_node_tag 2
|
#define DeviceState_my_node_tag 2
|
||||||
#define DeviceState_owner_tag 3
|
#define DeviceState_owner_tag 3
|
||||||
#define DeviceState_node_db_tag 4
|
#define DeviceState_node_db_tag 4
|
||||||
@@ -160,19 +114,6 @@ extern "C" {
|
|||||||
#define DeviceState_version_tag 8
|
#define DeviceState_version_tag 8
|
||||||
#define DeviceState_no_save_tag 9
|
#define DeviceState_no_save_tag 9
|
||||||
#define DeviceState_did_gps_reset_tag 11
|
#define DeviceState_did_gps_reset_tag 11
|
||||||
#define LocalConfig_device_tag 1
|
|
||||||
#define LocalConfig_position_tag 2
|
|
||||||
#define LocalConfig_power_tag 3
|
|
||||||
#define LocalConfig_wifi_tag 4
|
|
||||||
#define LocalConfig_display_tag 5
|
|
||||||
#define LocalConfig_lora_tag 6
|
|
||||||
#define LocalModuleConfig_mqtt_tag 1
|
|
||||||
#define LocalModuleConfig_serial_tag 2
|
|
||||||
#define LocalModuleConfig_external_notification_tag 3
|
|
||||||
#define LocalModuleConfig_store_forward_tag 4
|
|
||||||
#define LocalModuleConfig_range_test_tag 5
|
|
||||||
#define LocalModuleConfig_telemetry_tag 6
|
|
||||||
#define LocalModuleConfig_canned_message_tag 7
|
|
||||||
#define OEMStore_oem_icon_width_tag 1
|
#define OEMStore_oem_icon_width_tag 1
|
||||||
#define OEMStore_oem_icon_height_tag 2
|
#define OEMStore_oem_icon_height_tag 2
|
||||||
#define OEMStore_oem_icon_bits_tag 3
|
#define OEMStore_oem_icon_bits_tag 3
|
||||||
@@ -198,7 +139,8 @@ X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11)
|
|||||||
#define DeviceState_rx_text_message_MSGTYPE MeshPacket
|
#define DeviceState_rx_text_message_MSGTYPE MeshPacket
|
||||||
|
|
||||||
#define ChannelFile_FIELDLIST(X, a) \
|
#define ChannelFile_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, REPEATED, MESSAGE, channels, 1)
|
X(a, STATIC, REPEATED, MESSAGE, channels, 1) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, version, 2)
|
||||||
#define ChannelFile_CALLBACK NULL
|
#define ChannelFile_CALLBACK NULL
|
||||||
#define ChannelFile_DEFAULT NULL
|
#define ChannelFile_DEFAULT NULL
|
||||||
#define ChannelFile_channels_MSGTYPE Channel
|
#define ChannelFile_channels_MSGTYPE Channel
|
||||||
@@ -212,58 +154,18 @@ X(a, STATIC, SINGULAR, STRING, oem_text, 5)
|
|||||||
#define OEMStore_CALLBACK NULL
|
#define OEMStore_CALLBACK NULL
|
||||||
#define OEMStore_DEFAULT NULL
|
#define OEMStore_DEFAULT NULL
|
||||||
|
|
||||||
#define LocalConfig_FIELDLIST(X, a) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, device, 1) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, position, 2) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, power, 3) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, wifi, 4) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, display, 5) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, lora, 6)
|
|
||||||
#define LocalConfig_CALLBACK NULL
|
|
||||||
#define LocalConfig_DEFAULT NULL
|
|
||||||
#define LocalConfig_device_MSGTYPE Config_DeviceConfig
|
|
||||||
#define LocalConfig_position_MSGTYPE Config_PositionConfig
|
|
||||||
#define LocalConfig_power_MSGTYPE Config_PowerConfig
|
|
||||||
#define LocalConfig_wifi_MSGTYPE Config_WiFiConfig
|
|
||||||
#define LocalConfig_display_MSGTYPE Config_DisplayConfig
|
|
||||||
#define LocalConfig_lora_MSGTYPE Config_LoRaConfig
|
|
||||||
|
|
||||||
#define LocalModuleConfig_FIELDLIST(X, a) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, mqtt, 1) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, serial, 2) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, external_notification, 3) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, store_forward, 4) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, range_test, 5) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, telemetry, 6) \
|
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, canned_message, 7)
|
|
||||||
#define LocalModuleConfig_CALLBACK NULL
|
|
||||||
#define LocalModuleConfig_DEFAULT NULL
|
|
||||||
#define LocalModuleConfig_mqtt_MSGTYPE ModuleConfig_MQTTConfig
|
|
||||||
#define LocalModuleConfig_serial_MSGTYPE ModuleConfig_SerialConfig
|
|
||||||
#define LocalModuleConfig_external_notification_MSGTYPE ModuleConfig_ExternalNotificationConfig
|
|
||||||
#define LocalModuleConfig_store_forward_MSGTYPE ModuleConfig_StoreForwardConfig
|
|
||||||
#define LocalModuleConfig_range_test_MSGTYPE ModuleConfig_RangeTestConfig
|
|
||||||
#define LocalModuleConfig_telemetry_MSGTYPE ModuleConfig_TelemetryConfig
|
|
||||||
#define LocalModuleConfig_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig
|
|
||||||
|
|
||||||
extern const pb_msgdesc_t DeviceState_msg;
|
extern const pb_msgdesc_t DeviceState_msg;
|
||||||
extern const pb_msgdesc_t ChannelFile_msg;
|
extern const pb_msgdesc_t ChannelFile_msg;
|
||||||
extern const pb_msgdesc_t OEMStore_msg;
|
extern const pb_msgdesc_t OEMStore_msg;
|
||||||
extern const pb_msgdesc_t LocalConfig_msg;
|
|
||||||
extern const pb_msgdesc_t LocalModuleConfig_msg;
|
|
||||||
|
|
||||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
#define DeviceState_fields &DeviceState_msg
|
#define DeviceState_fields &DeviceState_msg
|
||||||
#define ChannelFile_fields &ChannelFile_msg
|
#define ChannelFile_fields &ChannelFile_msg
|
||||||
#define OEMStore_fields &OEMStore_msg
|
#define OEMStore_fields &OEMStore_msg
|
||||||
#define LocalConfig_fields &LocalConfig_msg
|
|
||||||
#define LocalModuleConfig_fields &LocalModuleConfig_msg
|
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define ChannelFile_size 624
|
#define ChannelFile_size 630
|
||||||
#define DeviceState_size 19184
|
#define DeviceState_size 23728
|
||||||
#define LocalConfig_size 331
|
|
||||||
#define LocalModuleConfig_size 282
|
|
||||||
#define OEMStore_size 2106
|
#define OEMStore_size 2106
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
15
src/mesh/generated/localonly.pb.c
Normal file
15
src/mesh/generated/localonly.pb.c
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/* Automatically generated nanopb constant definitions */
|
||||||
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
|
#include "localonly.pb.h"
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PB_BIND(LocalConfig, LocalConfig, 2)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(LocalModuleConfig, LocalModuleConfig, 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
148
src/mesh/generated/localonly.pb.h
Normal file
148
src/mesh/generated/localonly.pb.h
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/* Automatically generated nanopb header */
|
||||||
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
|
#ifndef PB_LOCALONLY_PB_H_INCLUDED
|
||||||
|
#define PB_LOCALONLY_PB_H_INCLUDED
|
||||||
|
#include <pb.h>
|
||||||
|
#include "config.pb.h"
|
||||||
|
#include "module_config.pb.h"
|
||||||
|
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Struct definitions */
|
||||||
|
typedef struct _LocalConfig {
|
||||||
|
/* The part of the config that is specific to the Device */
|
||||||
|
bool has_device;
|
||||||
|
Config_DeviceConfig device;
|
||||||
|
/* The part of the config that is specific to the GPS Position */
|
||||||
|
bool has_position;
|
||||||
|
Config_PositionConfig position;
|
||||||
|
/* The part of the config that is specific to the Power settings */
|
||||||
|
bool has_power;
|
||||||
|
Config_PowerConfig power;
|
||||||
|
/* The part of the config that is specific to the Wifi Settings */
|
||||||
|
bool has_wifi;
|
||||||
|
Config_WiFiConfig wifi;
|
||||||
|
/* The part of the config that is specific to the Display */
|
||||||
|
bool has_display;
|
||||||
|
Config_DisplayConfig display;
|
||||||
|
/* The part of the config that is specific to the Lora Radio */
|
||||||
|
bool has_lora;
|
||||||
|
Config_LoRaConfig lora;
|
||||||
|
/* A version integer used to invalidate old save files when we make
|
||||||
|
incompatible changes This integer is set at build time and is private to
|
||||||
|
NodeDB.cpp in the device code. */
|
||||||
|
uint32_t version;
|
||||||
|
} LocalConfig;
|
||||||
|
|
||||||
|
typedef struct _LocalModuleConfig {
|
||||||
|
/* The part of the config that is specific to the MQTT module */
|
||||||
|
bool has_mqtt;
|
||||||
|
ModuleConfig_MQTTConfig mqtt;
|
||||||
|
/* The part of the config that is specific to the Serial module */
|
||||||
|
bool has_serial;
|
||||||
|
ModuleConfig_SerialConfig serial;
|
||||||
|
/* The part of the config that is specific to the ExternalNotification module */
|
||||||
|
bool has_external_notification;
|
||||||
|
ModuleConfig_ExternalNotificationConfig external_notification;
|
||||||
|
/* The part of the config that is specific to the Store & Forward module */
|
||||||
|
bool has_store_forward;
|
||||||
|
ModuleConfig_StoreForwardConfig store_forward;
|
||||||
|
/* The part of the config that is specific to the RangeTest module */
|
||||||
|
bool has_range_test;
|
||||||
|
ModuleConfig_RangeTestConfig range_test;
|
||||||
|
/* The part of the config that is specific to the Telemetry module */
|
||||||
|
bool has_telemetry;
|
||||||
|
ModuleConfig_TelemetryConfig telemetry;
|
||||||
|
/* The part of the config that is specific to the Canned Message module */
|
||||||
|
bool has_canned_message;
|
||||||
|
ModuleConfig_CannedMessageConfig canned_message;
|
||||||
|
/* A version integer used to invalidate old save files when we make
|
||||||
|
incompatible changes This integer is set at build time and is private to
|
||||||
|
NodeDB.cpp in the device code. */
|
||||||
|
uint32_t version;
|
||||||
|
} LocalModuleConfig;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initializer values for message structs */
|
||||||
|
#define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_WiFiConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, 0}
|
||||||
|
#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0}
|
||||||
|
#define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_WiFiConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, 0}
|
||||||
|
#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0}
|
||||||
|
|
||||||
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
|
#define LocalConfig_device_tag 1
|
||||||
|
#define LocalConfig_position_tag 2
|
||||||
|
#define LocalConfig_power_tag 3
|
||||||
|
#define LocalConfig_wifi_tag 4
|
||||||
|
#define LocalConfig_display_tag 5
|
||||||
|
#define LocalConfig_lora_tag 6
|
||||||
|
#define LocalConfig_version_tag 7
|
||||||
|
#define LocalModuleConfig_mqtt_tag 1
|
||||||
|
#define LocalModuleConfig_serial_tag 2
|
||||||
|
#define LocalModuleConfig_external_notification_tag 3
|
||||||
|
#define LocalModuleConfig_store_forward_tag 4
|
||||||
|
#define LocalModuleConfig_range_test_tag 5
|
||||||
|
#define LocalModuleConfig_telemetry_tag 6
|
||||||
|
#define LocalModuleConfig_canned_message_tag 7
|
||||||
|
#define LocalModuleConfig_version_tag 8
|
||||||
|
|
||||||
|
/* Struct field encoding specification for nanopb */
|
||||||
|
#define LocalConfig_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, device, 1) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, position, 2) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, power, 3) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, wifi, 4) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, display, 5) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, lora, 6) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, version, 7)
|
||||||
|
#define LocalConfig_CALLBACK NULL
|
||||||
|
#define LocalConfig_DEFAULT NULL
|
||||||
|
#define LocalConfig_device_MSGTYPE Config_DeviceConfig
|
||||||
|
#define LocalConfig_position_MSGTYPE Config_PositionConfig
|
||||||
|
#define LocalConfig_power_MSGTYPE Config_PowerConfig
|
||||||
|
#define LocalConfig_wifi_MSGTYPE Config_WiFiConfig
|
||||||
|
#define LocalConfig_display_MSGTYPE Config_DisplayConfig
|
||||||
|
#define LocalConfig_lora_MSGTYPE Config_LoRaConfig
|
||||||
|
|
||||||
|
#define LocalModuleConfig_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, mqtt, 1) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, serial, 2) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, external_notification, 3) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, store_forward, 4) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, range_test, 5) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, telemetry, 6) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, canned_message, 7) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, version, 8)
|
||||||
|
#define LocalModuleConfig_CALLBACK NULL
|
||||||
|
#define LocalModuleConfig_DEFAULT NULL
|
||||||
|
#define LocalModuleConfig_mqtt_MSGTYPE ModuleConfig_MQTTConfig
|
||||||
|
#define LocalModuleConfig_serial_MSGTYPE ModuleConfig_SerialConfig
|
||||||
|
#define LocalModuleConfig_external_notification_MSGTYPE ModuleConfig_ExternalNotificationConfig
|
||||||
|
#define LocalModuleConfig_store_forward_MSGTYPE ModuleConfig_StoreForwardConfig
|
||||||
|
#define LocalModuleConfig_range_test_MSGTYPE ModuleConfig_RangeTestConfig
|
||||||
|
#define LocalModuleConfig_telemetry_MSGTYPE ModuleConfig_TelemetryConfig
|
||||||
|
#define LocalModuleConfig_canned_message_MSGTYPE ModuleConfig_CannedMessageConfig
|
||||||
|
|
||||||
|
extern const pb_msgdesc_t LocalConfig_msg;
|
||||||
|
extern const pb_msgdesc_t LocalModuleConfig_msg;
|
||||||
|
|
||||||
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
|
#define LocalConfig_fields &LocalConfig_msg
|
||||||
|
#define LocalModuleConfig_fields &LocalModuleConfig_msg
|
||||||
|
|
||||||
|
/* Maximum encoded size of messages (where known) */
|
||||||
|
#define LocalConfig_size 321
|
||||||
|
#define LocalModuleConfig_size 268
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_MESH_PB_H_INCLUDED
|
#ifndef PB_MESH_PB_H_INCLUDED
|
||||||
#define PB_MESH_PB_H_INCLUDED
|
#define PB_MESH_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
|
#include "config.pb.h"
|
||||||
|
#include "module_config.pb.h"
|
||||||
#include "portnums.pb.h"
|
#include "portnums.pb.h"
|
||||||
#include "telemetry.pb.h"
|
#include "telemetry.pb.h"
|
||||||
|
|
||||||
@@ -69,6 +71,8 @@ typedef enum _HardwareModel {
|
|||||||
HardwareModel_DR_DEV = 43,
|
HardwareModel_DR_DEV = 43,
|
||||||
/* M5 esp32 based MCU modules with enclosure, TFT and LORA Shields. All Variants (Basic, Core, Fire, Core2, Paper) https://m5stack.com/ */
|
/* M5 esp32 based MCU modules with enclosure, TFT and LORA Shields. All Variants (Basic, Core, Fire, Core2, Paper) https://m5stack.com/ */
|
||||||
HardwareModel_M5STACK = 44,
|
HardwareModel_M5STACK = 44,
|
||||||
|
/* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */
|
||||||
|
HardwareModel_STATION_G1 = 45,
|
||||||
/* Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. */
|
/* Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. */
|
||||||
HardwareModel_PRIVATE_HW = 255
|
HardwareModel_PRIVATE_HW = 255
|
||||||
} HardwareModel;
|
} HardwareModel;
|
||||||
@@ -237,22 +241,22 @@ typedef enum _LogRecord_Level {
|
|||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef PB_BYTES_ARRAY_T(237) Compressed_data_t;
|
typedef PB_BYTES_ARRAY_T(237) Compressed_data_t;
|
||||||
typedef struct _Compressed {
|
typedef struct _Compressed {
|
||||||
PortNum portnum;
|
PortNum portnum;
|
||||||
Compressed_data_t data;
|
Compressed_data_t data;
|
||||||
} Compressed;
|
} Compressed;
|
||||||
|
|
||||||
/* Location of a waypoint to associate with a message */
|
/* Location of a waypoint to associate with a message */
|
||||||
typedef struct _Location {
|
typedef struct _Location {
|
||||||
/* Id of the location */
|
/* Id of the location */
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
/* latitude_i */
|
/* latitude_i */
|
||||||
int32_t latitude_i;
|
int32_t latitude_i;
|
||||||
/* longitude_i */
|
/* longitude_i */
|
||||||
int32_t longitude_i;
|
int32_t longitude_i;
|
||||||
/* Time the location is to expire (epoch) */
|
/* Time the location is to expire (epoch) */
|
||||||
uint32_t expire;
|
uint32_t expire;
|
||||||
/* If true, only allow the original sender to update the location. */
|
/* If true, only allow the original sender to update the location. */
|
||||||
bool locked;
|
bool locked;
|
||||||
} Location;
|
} Location;
|
||||||
|
|
||||||
/* Debug output from the device.
|
/* Debug output from the device.
|
||||||
@@ -262,13 +266,13 @@ typedef struct _Location {
|
|||||||
and then extend as needed by emitting multiple records. */
|
and then extend as needed by emitting multiple records. */
|
||||||
typedef struct _LogRecord {
|
typedef struct _LogRecord {
|
||||||
/* Log levels, chosen to match python logging conventions. */
|
/* Log levels, chosen to match python logging conventions. */
|
||||||
char message[64];
|
char message[64];
|
||||||
/* Seconds since 1970 - or 0 for unknown/unset */
|
/* Seconds since 1970 - or 0 for unknown/unset */
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
/* Usually based on thread name - if known */
|
/* Usually based on thread name - if known */
|
||||||
char source[8];
|
char source[8];
|
||||||
/* Not yet set */
|
/* Not yet set */
|
||||||
LogRecord_Level level;
|
LogRecord_Level level;
|
||||||
} LogRecord;
|
} LogRecord;
|
||||||
|
|
||||||
/* Unique local debugging info for this node
|
/* Unique local debugging info for this node
|
||||||
@@ -277,134 +281,134 @@ typedef struct _LogRecord {
|
|||||||
typedef struct _MyNodeInfo {
|
typedef struct _MyNodeInfo {
|
||||||
/* Tells the phone what our node number is, default starting value is
|
/* Tells the phone what our node number is, default starting value is
|
||||||
lowbyte of macaddr, but it will be fixed if that is already in use */
|
lowbyte of macaddr, but it will be fixed if that is already in use */
|
||||||
uint32_t my_node_num;
|
uint32_t my_node_num;
|
||||||
/* Note: This flag merely means we detected a hardware GPS in our node.
|
/* Note: This flag merely means we detected a hardware GPS in our node.
|
||||||
Not the same as UserPreferences.location_sharing */
|
Not the same as UserPreferences.location_sharing */
|
||||||
bool has_gps;
|
bool has_gps;
|
||||||
/* The maximum number of 'software' channels that can be set on this node. */
|
|
||||||
char firmware_version[18];
|
|
||||||
/* 0.0.5 etc... */
|
/* 0.0.5 etc... */
|
||||||
CriticalErrorCode error_code;
|
char firmware_version[18];
|
||||||
/* An error message we'd like to report back to the mothership through analytics.
|
/* An error message we'd like to report back to the mothership through analytics.
|
||||||
It indicates a serious bug occurred on the device, the device coped with it,
|
It indicates a serious bug occurred on the device, the device coped with it,
|
||||||
but we still want to tell the devs about the bug.
|
but we still want to tell the devs about the bug.
|
||||||
This field will be cleared after the phone reads MyNodeInfo
|
This field will be cleared after the phone reads MyNodeInfo
|
||||||
(i.e. it will only be reported once)
|
(i.e. it will only be reported once)
|
||||||
a numeric error code to go with error message, zero means no error */
|
a numeric error code to go with error message, zero means no error */
|
||||||
uint32_t error_address;
|
CriticalErrorCode error_code;
|
||||||
/* A numeric error address (nonzero if available) */
|
/* A numeric error address (nonzero if available) */
|
||||||
uint32_t error_count;
|
uint32_t error_address;
|
||||||
/* The total number of errors this node has ever encountered
|
/* The total number of errors this node has ever encountered
|
||||||
(well - since the last time we discarded preferences) */
|
(well - since the last time we discarded preferences) */
|
||||||
uint32_t reboot_count;
|
uint32_t error_count;
|
||||||
/* The total number of reboots this node has ever encountered
|
/* The total number of reboots this node has ever encountered
|
||||||
(well - since the last time we discarded preferences) */
|
(well - since the last time we discarded preferences) */
|
||||||
float bitrate;
|
uint32_t reboot_count;
|
||||||
/* Calculated bitrate of the current channel (in Bytes Per Second) */
|
/* Calculated bitrate of the current channel (in Bytes Per Second) */
|
||||||
uint32_t message_timeout_msec;
|
float bitrate;
|
||||||
/* How long before we consider a message abandoned and we can clear our
|
/* How long before we consider a message abandoned and we can clear our
|
||||||
caches of any messages in flight Normally quite large to handle the worst case
|
caches of any messages in flight Normally quite large to handle the worst case
|
||||||
message delivery time, 5 minutes.
|
message delivery time, 5 minutes.
|
||||||
Formerly called FLOOD_EXPIRE_TIME in the device code */
|
Formerly called FLOOD_EXPIRE_TIME in the device code */
|
||||||
uint32_t min_app_version;
|
uint32_t message_timeout_msec;
|
||||||
/* The minimum app version that can talk to this device.
|
/* The minimum app version that can talk to this device.
|
||||||
Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */
|
Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */
|
||||||
uint32_t max_channels;
|
uint32_t min_app_version;
|
||||||
|
/* The maximum number of 'software' channels that can be set on this node. */
|
||||||
|
uint32_t max_channels;
|
||||||
/* 24 time windows of 1hr each with the airtime transmitted out of the device per hour. */
|
/* 24 time windows of 1hr each with the airtime transmitted out of the device per hour. */
|
||||||
pb_size_t air_period_tx_count;
|
pb_size_t air_period_tx_count;
|
||||||
uint32_t air_period_tx[8];
|
uint32_t air_period_tx[8];
|
||||||
/* 24 time windows of 1hr each with the airtime of valid packets for your mesh. */
|
/* 24 time windows of 1hr each with the airtime of valid packets for your mesh. */
|
||||||
pb_size_t air_period_rx_count;
|
pb_size_t air_period_rx_count;
|
||||||
uint32_t air_period_rx[8];
|
uint32_t air_period_rx[8];
|
||||||
/* Is the device wifi capable? */
|
/* Is the device wifi capable? */
|
||||||
bool has_wifi;
|
bool has_wifi;
|
||||||
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
|
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
|
||||||
float channel_utilization;
|
float channel_utilization;
|
||||||
/* Percent of airtime for transmission used within the last hour. */
|
/* Percent of airtime for transmission used within the last hour. */
|
||||||
float air_util_tx;
|
float air_util_tx;
|
||||||
} MyNodeInfo;
|
} MyNodeInfo;
|
||||||
|
|
||||||
/* a gps position */
|
/* a gps position */
|
||||||
typedef struct _Position {
|
typedef struct _Position {
|
||||||
/* The new preferred location encoding, divide by 1e-7 to get degrees
|
/* The new preferred location encoding, divide by 1e-7 to get degrees
|
||||||
in floating point */
|
in floating point */
|
||||||
int32_t latitude_i;
|
int32_t latitude_i;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
int32_t longitude_i;
|
int32_t longitude_i;
|
||||||
/* In meters above MSL (but see issue #359) */
|
/* In meters above MSL (but see issue #359) */
|
||||||
int32_t altitude;
|
int32_t altitude;
|
||||||
/* This is usually not sent over the mesh (to save space), but it is sent
|
/* This is usually not sent over the mesh (to save space), but it is sent
|
||||||
from the phone so that the local device can set its RTC If it is sent over
|
from the phone so that the local device can set its RTC If it is sent over
|
||||||
the mesh (because there are devices on the mesh without GPS), it will only
|
the mesh (because there are devices on the mesh without GPS), it will only
|
||||||
be sent by devices which has a hardware GPS clock.
|
be sent by devices which has a hardware GPS clock.
|
||||||
seconds since 1970 */
|
seconds since 1970 */
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
Position_LocSource location_source;
|
Position_LocSource location_source;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
Position_AltSource altitude_source;
|
Position_AltSource altitude_source;
|
||||||
/* Positional timestamp (actual timestamp of GPS solution) in integer epoch seconds */
|
/* Positional timestamp (actual timestamp of GPS solution) in integer epoch seconds */
|
||||||
uint32_t pos_timestamp;
|
uint32_t pos_timestamp;
|
||||||
/* Pos. timestamp milliseconds adjustment (rarely available or required) */
|
/* Pos. timestamp milliseconds adjustment (rarely available or required) */
|
||||||
int32_t pos_time_millis;
|
int32_t pos_time_millis;
|
||||||
/* HAE altitude in meters - can be used instead of MSL altitude */
|
/* HAE altitude in meters - can be used instead of MSL altitude */
|
||||||
int32_t altitude_hae;
|
int32_t altitude_hae;
|
||||||
/* Geoidal separation in meters */
|
/* Geoidal separation in meters */
|
||||||
int32_t alt_geoid_sep;
|
int32_t alt_geoid_sep;
|
||||||
/* Horizontal, Vertical and Position Dilution of Precision, in 1/100 units
|
/* Horizontal, Vertical and Position Dilution of Precision, in 1/100 units
|
||||||
- PDOP is sufficient for most cases
|
- PDOP is sufficient for most cases
|
||||||
- for higher precision scenarios, HDOP and VDOP can be used instead,
|
- for higher precision scenarios, HDOP and VDOP can be used instead,
|
||||||
in which case PDOP becomes redundant (PDOP=sqrt(HDOP^2 + VDOP^2))
|
in which case PDOP becomes redundant (PDOP=sqrt(HDOP^2 + VDOP^2))
|
||||||
TODO: REMOVE/INTEGRATE */
|
TODO: REMOVE/INTEGRATE */
|
||||||
uint32_t PDOP;
|
uint32_t PDOP;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
uint32_t HDOP;
|
uint32_t HDOP;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
uint32_t VDOP;
|
uint32_t VDOP;
|
||||||
/* GPS accuracy (a hardware specific constant) in mm
|
/* GPS accuracy (a hardware specific constant) in mm
|
||||||
multiplied with DOP to calculate positional accuracy
|
multiplied with DOP to calculate positional accuracy
|
||||||
Default: "'bout three meters-ish" :) */
|
Default: "'bout three meters-ish" :) */
|
||||||
uint32_t gps_accuracy;
|
uint32_t gps_accuracy;
|
||||||
/* Ground speed in m/s and True North TRACK in 1/100 degrees
|
/* Ground speed in m/s and True North TRACK in 1/100 degrees
|
||||||
Clarification of terms:
|
Clarification of terms:
|
||||||
- "track" is the direction of motion (measured in horizontal plane)
|
- "track" is the direction of motion (measured in horizontal plane)
|
||||||
- "heading" is where the fuselage points (measured in horizontal plane)
|
- "heading" is where the fuselage points (measured in horizontal plane)
|
||||||
- "yaw" indicates a relative rotation about the vertical axis
|
- "yaw" indicates a relative rotation about the vertical axis
|
||||||
TODO: REMOVE/INTEGRATE */
|
TODO: REMOVE/INTEGRATE */
|
||||||
uint32_t ground_speed;
|
uint32_t ground_speed;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
uint32_t ground_track;
|
uint32_t ground_track;
|
||||||
/* GPS fix quality (from NMEA GxGGA statement or similar) */
|
/* GPS fix quality (from NMEA GxGGA statement or similar) */
|
||||||
uint32_t fix_quality;
|
uint32_t fix_quality;
|
||||||
/* GPS fix type 2D/3D (from NMEA GxGSA statement) */
|
/* GPS fix type 2D/3D (from NMEA GxGSA statement) */
|
||||||
uint32_t fix_type;
|
uint32_t fix_type;
|
||||||
/* GPS "Satellites in View" number */
|
/* GPS "Satellites in View" number */
|
||||||
uint32_t sats_in_view;
|
uint32_t sats_in_view;
|
||||||
/* Sensor ID - in case multiple positioning sensors are being used */
|
/* Sensor ID - in case multiple positioning sensors are being used */
|
||||||
uint32_t sensor_id;
|
uint32_t sensor_id;
|
||||||
/* Estimated/expected time (in seconds) until next update:
|
/* Estimated/expected time (in seconds) until next update:
|
||||||
- if we update at fixed intervals of X seconds, use X
|
- if we update at fixed intervals of X seconds, use X
|
||||||
- if we update at dynamic intervals (based on relative movement etc),
|
- if we update at dynamic intervals (based on relative movement etc),
|
||||||
but "AT LEAST every Y seconds", use Y */
|
but "AT LEAST every Y seconds", use Y */
|
||||||
uint32_t pos_next_update;
|
uint32_t pos_next_update;
|
||||||
/* A sequence number, incremented with each Position message to help
|
/* A sequence number, incremented with each Position message to help
|
||||||
detect lost updates if needed */
|
detect lost updates if needed */
|
||||||
uint32_t pos_seq_number;
|
uint32_t pos_seq_number;
|
||||||
} Position;
|
} Position;
|
||||||
|
|
||||||
/* A message used in our Dynamic Source Routing protocol (RFC 4728 based) */
|
/* A message used in our Dynamic Source Routing protocol (RFC 4728 based) */
|
||||||
typedef struct _RouteDiscovery {
|
typedef struct _RouteDiscovery {
|
||||||
/* The list of nodenums this packet has visited so far */
|
/* The list of nodenums this packet has visited so far */
|
||||||
pb_size_t route_count;
|
pb_size_t route_count;
|
||||||
uint32_t route[8];
|
uint32_t route[8];
|
||||||
} RouteDiscovery;
|
} RouteDiscovery;
|
||||||
|
|
||||||
/* Compressed message payload */
|
/* Compressed message payload */
|
||||||
typedef struct _ToRadio_PeerInfo {
|
typedef struct _ToRadio_PeerInfo {
|
||||||
/* PortNum to determine the how to handle the compressed payload. */
|
/* PortNum to determine the how to handle the compressed payload. */
|
||||||
uint32_t app_version;
|
uint32_t app_version;
|
||||||
/* Compressed data. */
|
/* Compressed data. */
|
||||||
bool mqtt_gateway;
|
bool mqtt_gateway;
|
||||||
} ToRadio_PeerInfo;
|
} ToRadio_PeerInfo;
|
||||||
|
|
||||||
/* Broadcast when a newly powered mesh node wants to find a node num it can use
|
/* Broadcast when a newly powered mesh node wants to find a node num it can use
|
||||||
@@ -432,35 +436,35 @@ typedef struct _User {
|
|||||||
In the case of Signal that would mean +16504442323, for the default macaddr derived id it would be !<8 hexidecimal bytes>.
|
In the case of Signal that would mean +16504442323, for the default macaddr derived id it would be !<8 hexidecimal bytes>.
|
||||||
Note: app developers are encouraged to also use the following standard
|
Note: app developers are encouraged to also use the following standard
|
||||||
node IDs "^all" (for broadcast), "^local" (for the locally connected node) */
|
node IDs "^all" (for broadcast), "^local" (for the locally connected node) */
|
||||||
char id[16];
|
char id[16];
|
||||||
/* A full name for this user, i.e. "Kevin Hester" */
|
/* A full name for this user, i.e. "Kevin Hester" */
|
||||||
char long_name[40];
|
char long_name[40];
|
||||||
/* A VERY short name, ideally two characters.
|
/* A VERY short name, ideally two characters.
|
||||||
Suitable for a tiny OLED screen */
|
Suitable for a tiny OLED screen */
|
||||||
char short_name[5];
|
char short_name[5];
|
||||||
/* This is the addr of the radio.
|
/* This is the addr of the radio.
|
||||||
Not populated by the phone, but added by the esp32 when broadcasting */
|
Not populated by the phone, but added by the esp32 when broadcasting */
|
||||||
pb_byte_t macaddr[6];
|
pb_byte_t macaddr[6];
|
||||||
/* TBEAM, HELTEC, etc...
|
/* TBEAM, HELTEC, etc...
|
||||||
Starting in 1.2.11 moved to hw_model enum in the NodeInfo object.
|
Starting in 1.2.11 moved to hw_model enum in the NodeInfo object.
|
||||||
Apps will still need the string here for older builds
|
Apps will still need the string here for older builds
|
||||||
(so OTA update can find the right image), but if the enum is available it will be used instead. */
|
(so OTA update can find the right image), but if the enum is available it will be used instead. */
|
||||||
HardwareModel hw_model;
|
HardwareModel hw_model;
|
||||||
/* In some regions Ham radio operators have different bandwidth limitations than others.
|
/* In some regions Ham radio operators have different bandwidth limitations than others.
|
||||||
If this user is a licensed operator, set this flag.
|
If this user is a licensed operator, set this flag.
|
||||||
Also, "long_name" should be their licence number. */
|
Also, "long_name" should be their licence number. */
|
||||||
bool is_licensed;
|
bool is_licensed;
|
||||||
/* Transmit power at antenna connector, in decibel-milliwatt
|
/* Transmit power at antenna connector, in decibel-milliwatt
|
||||||
An optional self-reported value useful in network planning, discovery
|
An optional self-reported value useful in network planning, discovery
|
||||||
and positioning - along with ant_gain_dbi and ant_azimuth below */
|
and positioning - along with ant_gain_dbi and ant_azimuth below */
|
||||||
uint32_t tx_power_dbm;
|
uint32_t tx_power_dbm;
|
||||||
/* Antenna gain (applicable to both Tx and Rx), in decibel-isotropic */
|
/* Antenna gain (applicable to both Tx and Rx), in decibel-isotropic */
|
||||||
uint32_t ant_gain_dbi;
|
uint32_t ant_gain_dbi;
|
||||||
/* Directional antenna true azimuth *if applicable*, in degrees (0-360)
|
/* Directional antenna true azimuth *if applicable*, in degrees (0-360)
|
||||||
Only applicable in case of stationary nodes with a directional antenna
|
Only applicable in case of stationary nodes with a directional antenna
|
||||||
Zero = not applicable (mobile or omni) or not specified
|
Zero = not applicable (mobile or omni) or not specified
|
||||||
(use a value of 360 to indicate an antenna azimuth of zero degrees) */
|
(use a value of 360 to indicate an antenna azimuth of zero degrees) */
|
||||||
uint32_t ant_azimuth;
|
uint32_t ant_azimuth;
|
||||||
} User;
|
} User;
|
||||||
|
|
||||||
typedef PB_BYTES_ARRAY_T(237) Data_payload_t;
|
typedef PB_BYTES_ARRAY_T(237) Data_payload_t;
|
||||||
@@ -469,34 +473,34 @@ typedef PB_BYTES_ARRAY_T(237) Data_payload_t;
|
|||||||
inside a radio packet (because from/to are broken out by the comms library) */
|
inside a radio packet (because from/to are broken out by the comms library) */
|
||||||
typedef struct _Data {
|
typedef struct _Data {
|
||||||
/* Formerly named typ and of type Type */
|
/* Formerly named typ and of type Type */
|
||||||
PortNum portnum;
|
PortNum portnum;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
Data_payload_t payload;
|
Data_payload_t payload;
|
||||||
/* Not normally used, but for testing a sender can request that recipient
|
/* Not normally used, but for testing a sender can request that recipient
|
||||||
responds in kind (i.e. if it received a position, it should unicast back it's position).
|
responds in kind (i.e. if it received a position, it should unicast back it's position).
|
||||||
Note: that if you set this on a broadcast you will receive many replies. */
|
Note: that if you set this on a broadcast you will receive many replies. */
|
||||||
bool want_response;
|
bool want_response;
|
||||||
/* The address of the destination node.
|
/* The address of the destination node.
|
||||||
This field is is filled in by the mesh radio device software, application
|
This field is is filled in by the mesh radio device software, application
|
||||||
layer software should never need it.
|
layer software should never need it.
|
||||||
RouteDiscovery messages _must_ populate this.
|
RouteDiscovery messages _must_ populate this.
|
||||||
Other message types might need to if they are doing multihop routing. */
|
Other message types might need to if they are doing multihop routing. */
|
||||||
uint32_t dest;
|
uint32_t dest;
|
||||||
/* The address of the original sender for this message.
|
/* The address of the original sender for this message.
|
||||||
This field should _only_ be populated for reliable multihop packets (to keep
|
This field should _only_ be populated for reliable multihop packets (to keep
|
||||||
packets small). */
|
packets small). */
|
||||||
uint32_t source;
|
uint32_t source;
|
||||||
/* Only used in routing or response messages.
|
/* Only used in routing or response messages.
|
||||||
Indicates the original message ID that this message is reporting failure on. (formerly called original_id) */
|
Indicates the original message ID that this message is reporting failure on. (formerly called original_id) */
|
||||||
uint32_t request_id;
|
uint32_t request_id;
|
||||||
/* If set, this message is intened to be a reply to a previously sent message with the defined id. */
|
/* If set, this message is intened to be a reply to a previously sent message with the defined id. */
|
||||||
uint32_t reply_id;
|
uint32_t reply_id;
|
||||||
/* Defaults to false. If true, then what is in the payload should be treated as an emoji like giving
|
/* Defaults to false. If true, then what is in the payload should be treated as an emoji like giving
|
||||||
a message a heart or poop emoji. */
|
a message a heart or poop emoji. */
|
||||||
uint32_t emoji;
|
uint32_t emoji;
|
||||||
/* Location structure */
|
/* Location structure */
|
||||||
bool has_location;
|
bool has_location;
|
||||||
Location location;
|
Location location;
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
/* The bluetooth to device link:
|
/* The bluetooth to device link:
|
||||||
@@ -517,33 +521,36 @@ typedef struct _Data {
|
|||||||
Full information about a node on the mesh */
|
Full information about a node on the mesh */
|
||||||
typedef struct _NodeInfo {
|
typedef struct _NodeInfo {
|
||||||
/* The node number */
|
/* The node number */
|
||||||
uint32_t num;
|
uint32_t num;
|
||||||
/* The user info for this node */
|
/* The user info for this node */
|
||||||
bool has_user;
|
bool has_user;
|
||||||
User user;
|
User user;
|
||||||
/* This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true.
|
/* This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true.
|
||||||
Position.time now indicates the last time we received a POSITION from that node. */
|
Position.time now indicates the last time we received a POSITION from that node. */
|
||||||
bool has_position;
|
bool has_position;
|
||||||
Position position;
|
Position position;
|
||||||
/* Returns the Signal-to-noise ratio (SNR) of the last received message,
|
/* Returns the Signal-to-noise ratio (SNR) of the last received message,
|
||||||
as measured by the receiver. Return SNR of the last received message in dB */
|
as measured by the receiver. Return SNR of the last received message in dB */
|
||||||
float snr;
|
float snr;
|
||||||
/* Set to indicate the last time we received a packet from this node */
|
/* Set to indicate the last time we received a packet from this node */
|
||||||
uint32_t last_heard;
|
uint32_t last_heard;
|
||||||
/* The latest device metrics for the node. */
|
/* The latest device metrics for the node. */
|
||||||
bool has_device_metrics;
|
bool has_device_metrics;
|
||||||
DeviceMetrics device_metrics;
|
DeviceMetrics device_metrics;
|
||||||
} NodeInfo;
|
} NodeInfo;
|
||||||
|
|
||||||
/* A Routing control Data packet handled by the routing module */
|
/* A Routing control Data packet handled by the routing module */
|
||||||
typedef struct _Routing {
|
typedef struct _Routing {
|
||||||
/* A route request going from the requester */
|
|
||||||
pb_size_t which_variant;
|
pb_size_t which_variant;
|
||||||
union {
|
union {
|
||||||
|
/* A route request going from the requester */
|
||||||
RouteDiscovery route_request;
|
RouteDiscovery route_request;
|
||||||
|
/* A route reply */
|
||||||
RouteDiscovery route_reply;
|
RouteDiscovery route_reply;
|
||||||
|
/* A failure in delivering a message (usually used for routing control messages, but might be provided
|
||||||
|
in addition to ack.fail_id to provide details on the type of failure). */
|
||||||
Routing_Error error_reason;
|
Routing_Error error_reason;
|
||||||
};
|
};
|
||||||
} Routing;
|
} Routing;
|
||||||
|
|
||||||
typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t;
|
typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t;
|
||||||
@@ -555,10 +562,10 @@ typedef struct _MeshPacket {
|
|||||||
Note: Our crypto implementation uses this field as well.
|
Note: Our crypto implementation uses this field as well.
|
||||||
See [crypto](/docs/developers/firmware/encryption) for details.
|
See [crypto](/docs/developers/firmware/encryption) for details.
|
||||||
FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */
|
FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. */
|
||||||
uint32_t from;
|
uint32_t from;
|
||||||
/* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only
|
/* The (immediatSee Priority description for more details.y should be fixed32 instead, this encoding only
|
||||||
hurts the ble link though. */
|
hurts the ble link though. */
|
||||||
uint32_t to;
|
uint32_t to;
|
||||||
/* (Usually) If set, this indicates the index in the secondary_channels table that this packet was sent/received on.
|
/* (Usually) If set, this indicates the index in the secondary_channels table that this packet was sent/received on.
|
||||||
If unset, packet was on the primary channel.
|
If unset, packet was on the primary channel.
|
||||||
A particular node might know only a subset of channels in use on the mesh.
|
A particular node might know only a subset of channels in use on the mesh.
|
||||||
@@ -566,15 +573,14 @@ typedef struct _MeshPacket {
|
|||||||
Very briefly, while sending and receiving deep inside the device Router code, this field instead
|
Very briefly, while sending and receiving deep inside the device Router code, this field instead
|
||||||
contains the 'channel hash' instead of the index.
|
contains the 'channel hash' instead of the index.
|
||||||
This 'trick' is only used while the payloadVariant is an 'encrypted'. */
|
This 'trick' is only used while the payloadVariant is an 'encrypted'. */
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
/* TODO: REPLACE */
|
|
||||||
pb_size_t which_payloadVariant;
|
pb_size_t which_payloadVariant;
|
||||||
union {
|
union {
|
||||||
|
/* TODO: REPLACE */
|
||||||
Data decoded;
|
Data decoded;
|
||||||
|
/* TODO: REPLACE */
|
||||||
MeshPacket_encrypted_t encrypted;
|
MeshPacket_encrypted_t encrypted;
|
||||||
};
|
};
|
||||||
/* TODO: REPLACE */
|
|
||||||
uint32_t id;
|
|
||||||
/* A unique ID for this packet.
|
/* A unique ID for this packet.
|
||||||
Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space).
|
Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space).
|
||||||
Otherwise a unique ID for this packet, useful for flooding algorithms.
|
Otherwise a unique ID for this packet, useful for flooding algorithms.
|
||||||
@@ -585,21 +591,21 @@ typedef struct _MeshPacket {
|
|||||||
See [crypto](/docs/developers/firmware/encryption) for details.
|
See [crypto](/docs/developers/firmware/encryption) for details.
|
||||||
FIXME - really should be fixed32 instead, this encoding only
|
FIXME - really should be fixed32 instead, this encoding only
|
||||||
hurts the ble link though. */
|
hurts the ble link though. */
|
||||||
uint32_t rx_time;
|
uint32_t id;
|
||||||
/* The time this message was received by the esp32 (secs since 1970).
|
/* The time this message was received by the esp32 (secs since 1970).
|
||||||
Note: this field is _never_ sent on the radio link itself (to save space) Times
|
Note: this field is _never_ sent on the radio link itself (to save space) Times
|
||||||
are typically not sent over the mesh, but they will be added to any Packet
|
are typically not sent over the mesh, but they will be added to any Packet
|
||||||
(chain of SubPacket) sent to the phone (so the phone can know exact time of reception) */
|
(chain of SubPacket) sent to the phone (so the phone can know exact time of reception) */
|
||||||
float rx_snr;
|
uint32_t rx_time;
|
||||||
/* *Never* sent over the radio links.
|
/* *Never* sent over the radio links.
|
||||||
Set during reception to indicate the SNR of this packet.
|
Set during reception to indicate the SNR of this packet.
|
||||||
Used to collect statistics on current link quality. */
|
Used to collect statistics on current link quality. */
|
||||||
uint8_t hop_limit;
|
float rx_snr;
|
||||||
/* If unset treated as zero (no forwarding, send to adjacent nodes only)
|
/* If unset treated as zero (no forwarding, send to adjacent nodes only)
|
||||||
if 1, allow hopping through one node, etc...
|
if 1, allow hopping through one node, etc...
|
||||||
For our usecase real world topologies probably have a max of about 3.
|
For our usecase real world topologies probably have a max of about 3.
|
||||||
This field is normally placed into a few of bits in the header. */
|
This field is normally placed into a few of bits in the header. */
|
||||||
bool want_ack;
|
uint8_t hop_limit;
|
||||||
/* This packet is being sent as a reliable message, we would prefer it to arrive at the destination.
|
/* This packet is being sent as a reliable message, we would prefer it to arrive at the destination.
|
||||||
We would like to receive a ack packet in response.
|
We would like to receive a ack packet in response.
|
||||||
Broadcasts messages treat this flag specially: Since acks for broadcasts would
|
Broadcasts messages treat this flag specially: Since acks for broadcasts would
|
||||||
@@ -609,12 +615,14 @@ typedef struct _MeshPacket {
|
|||||||
So FloodingRouter.cpp generates an implicit ack which is delivered to the original sender.
|
So FloodingRouter.cpp generates an implicit ack which is delivered to the original sender.
|
||||||
If after some time we don't hear anyone rebroadcast our packet, we will timeout and retransmit, using the regular resend logic.
|
If after some time we don't hear anyone rebroadcast our packet, we will timeout and retransmit, using the regular resend logic.
|
||||||
Note: This flag is normally sent in a flag bit in the header when sent over the wire */
|
Note: This flag is normally sent in a flag bit in the header when sent over the wire */
|
||||||
MeshPacket_Priority priority;
|
bool want_ack;
|
||||||
/* The priority of this message for sending.
|
/* The priority of this message for sending.
|
||||||
See MeshPacket.Priority description for more details. */
|
See MeshPacket.Priority description for more details. */
|
||||||
int32_t rx_rssi;
|
MeshPacket_Priority priority;
|
||||||
/* rssi of received packet. Only sent to phone for dispay purposes. */
|
/* rssi of received packet. Only sent to phone for dispay purposes. */
|
||||||
MeshPacket_Delayed delayed;
|
int32_t rx_rssi;
|
||||||
|
/* Describe if this message is delayed */
|
||||||
|
MeshPacket_Delayed delayed;
|
||||||
} MeshPacket;
|
} MeshPacket;
|
||||||
|
|
||||||
/* Packets from the radio to the phone will appear on the fromRadio characteristic.
|
/* Packets from the radio to the phone will appear on the fromRadio characteristic.
|
||||||
@@ -624,30 +632,60 @@ typedef struct _MeshPacket {
|
|||||||
typedef struct _FromRadio {
|
typedef struct _FromRadio {
|
||||||
/* The packet id, used to allow the phone to request missing read packets from the FIFO,
|
/* The packet id, used to allow the phone to request missing read packets from the FIFO,
|
||||||
see our bluetooth docs */
|
see our bluetooth docs */
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
/* Log levels, chosen to match python logging conventions. */
|
|
||||||
pb_size_t which_payloadVariant;
|
pb_size_t which_payloadVariant;
|
||||||
union {
|
union {
|
||||||
|
/* Tells the phone what our node number is, can be -1 if we've not yet joined a mesh.
|
||||||
|
NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. */
|
||||||
MyNodeInfo my_info;
|
MyNodeInfo my_info;
|
||||||
|
/* One packet is sent for each node in the on radio DB
|
||||||
|
starts over with the first node in our DB */
|
||||||
NodeInfo node_info;
|
NodeInfo node_info;
|
||||||
|
/* Include a part of the config (was: RadioConfig radio) */
|
||||||
|
Config config;
|
||||||
|
/* Set to send debug console output over our protobuf stream */
|
||||||
LogRecord log_record;
|
LogRecord log_record;
|
||||||
|
/* Sent as true once the device has finished sending all of the responses to want_config
|
||||||
|
recipient should check if this ID matches our original request nonce, if
|
||||||
|
not, it means your config responses haven't started yet.
|
||||||
|
NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. */
|
||||||
uint32_t config_complete_id;
|
uint32_t config_complete_id;
|
||||||
|
/* Sent to tell clients the radio has just rebooted.
|
||||||
|
Set to true if present.
|
||||||
|
Not used on all transports, currently just used for the serial console.
|
||||||
|
NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. */
|
||||||
bool rebooted;
|
bool rebooted;
|
||||||
|
/* Include module config */
|
||||||
|
ModuleConfig moduleConfig;
|
||||||
|
/* Log levels, chosen to match python logging conventions. */
|
||||||
MeshPacket packet;
|
MeshPacket packet;
|
||||||
};
|
};
|
||||||
} FromRadio;
|
} FromRadio;
|
||||||
|
|
||||||
/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic.
|
/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic.
|
||||||
Once the write completes the phone can assume it is handled. */
|
Once the write completes the phone can assume it is handled. */
|
||||||
typedef struct _ToRadio {
|
typedef struct _ToRadio {
|
||||||
/* Send this packet on the mesh */
|
|
||||||
pb_size_t which_payloadVariant;
|
pb_size_t which_payloadVariant;
|
||||||
union {
|
union {
|
||||||
|
/* Send this packet on the mesh */
|
||||||
MeshPacket packet;
|
MeshPacket packet;
|
||||||
|
/* Information about the peer, sent after the phone sneds want_config_id.
|
||||||
|
Old clients do not send this, which is fine. */
|
||||||
ToRadio_PeerInfo peer_info;
|
ToRadio_PeerInfo peer_info;
|
||||||
|
/* Phone wants radio to send full node db to the phone, This is
|
||||||
|
typically the first packet sent to the radio when the phone gets a
|
||||||
|
bluetooth connection. The radio will respond by sending back a
|
||||||
|
MyNodeInfo, a owner, a radio config and a series of
|
||||||
|
FromRadio.node_infos, and config_complete
|
||||||
|
the integer you write into this field will be reported back in the
|
||||||
|
config_complete_id response this allows clients to never be confused by
|
||||||
|
a stale old partially sent config. */
|
||||||
uint32_t want_config_id;
|
uint32_t want_config_id;
|
||||||
|
/* Tell API server we are disconnecting now.
|
||||||
|
This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link.
|
||||||
|
(Sending this message is optional for clients) */
|
||||||
bool disconnect;
|
bool disconnect;
|
||||||
};
|
};
|
||||||
} ToRadio;
|
} ToRadio;
|
||||||
|
|
||||||
|
|
||||||
@@ -819,9 +857,11 @@ extern "C" {
|
|||||||
#define FromRadio_id_tag 1
|
#define FromRadio_id_tag 1
|
||||||
#define FromRadio_my_info_tag 3
|
#define FromRadio_my_info_tag 3
|
||||||
#define FromRadio_node_info_tag 4
|
#define FromRadio_node_info_tag 4
|
||||||
|
#define FromRadio_config_tag 6
|
||||||
#define FromRadio_log_record_tag 7
|
#define FromRadio_log_record_tag 7
|
||||||
#define FromRadio_config_complete_id_tag 8
|
#define FromRadio_config_complete_id_tag 8
|
||||||
#define FromRadio_rebooted_tag 9
|
#define FromRadio_rebooted_tag 9
|
||||||
|
#define FromRadio_moduleConfig_tag 10
|
||||||
#define FromRadio_packet_tag 11
|
#define FromRadio_packet_tag 11
|
||||||
#define ToRadio_packet_tag 2
|
#define ToRadio_packet_tag 2
|
||||||
#define ToRadio_peer_info_tag 3
|
#define ToRadio_peer_info_tag 3
|
||||||
@@ -968,15 +1008,19 @@ X(a, STATIC, SINGULAR, UENUM, level, 4)
|
|||||||
X(a, STATIC, SINGULAR, UINT32, id, 1) \
|
X(a, STATIC, SINGULAR, UINT32, id, 1) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,my_info,my_info), 3) \
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,my_info,my_info), 3) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,node_info,node_info), 4) \
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,node_info,node_info), 4) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,config,config), 6) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,log_record,log_record), 7) \
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,log_record,log_record), 7) \
|
||||||
X(a, STATIC, ONEOF, UINT32, (payloadVariant,config_complete_id,config_complete_id), 8) \
|
X(a, STATIC, ONEOF, UINT32, (payloadVariant,config_complete_id,config_complete_id), 8) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (payloadVariant,rebooted,rebooted), 9) \
|
X(a, STATIC, ONEOF, BOOL, (payloadVariant,rebooted,rebooted), 9) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,moduleConfig,moduleConfig), 10) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11)
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11)
|
||||||
#define FromRadio_CALLBACK NULL
|
#define FromRadio_CALLBACK NULL
|
||||||
#define FromRadio_DEFAULT NULL
|
#define FromRadio_DEFAULT NULL
|
||||||
#define FromRadio_payloadVariant_my_info_MSGTYPE MyNodeInfo
|
#define FromRadio_payloadVariant_my_info_MSGTYPE MyNodeInfo
|
||||||
#define FromRadio_payloadVariant_node_info_MSGTYPE NodeInfo
|
#define FromRadio_payloadVariant_node_info_MSGTYPE NodeInfo
|
||||||
|
#define FromRadio_payloadVariant_config_MSGTYPE Config
|
||||||
#define FromRadio_payloadVariant_log_record_MSGTYPE LogRecord
|
#define FromRadio_payloadVariant_log_record_MSGTYPE LogRecord
|
||||||
|
#define FromRadio_payloadVariant_moduleConfig_MSGTYPE ModuleConfig
|
||||||
#define FromRadio_payloadVariant_packet_MSGTYPE MeshPacket
|
#define FromRadio_payloadVariant_packet_MSGTYPE MeshPacket
|
||||||
|
|
||||||
#define ToRadio_FIELDLIST(X, a) \
|
#define ToRadio_FIELDLIST(X, a) \
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "module_config.pb.h"
|
#include "module_config.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED
|
#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
#define PB_MODULE_CONFIG_PB_H_INCLUDED
|
#define PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
@@ -49,85 +49,87 @@ typedef enum _ModuleConfig_CannedMessageConfig_InputEventChar {
|
|||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef struct _ModuleConfig_CannedMessageConfig {
|
typedef struct _ModuleConfig_CannedMessageConfig {
|
||||||
bool rotary1_enabled;
|
bool rotary1_enabled;
|
||||||
uint32_t inputbroker_pin_a;
|
uint32_t inputbroker_pin_a;
|
||||||
uint32_t inputbroker_pin_b;
|
uint32_t inputbroker_pin_b;
|
||||||
uint32_t inputbroker_pin_press;
|
uint32_t inputbroker_pin_press;
|
||||||
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_cw;
|
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_cw;
|
||||||
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_ccw;
|
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_ccw;
|
||||||
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_press;
|
ModuleConfig_CannedMessageConfig_InputEventChar inputbroker_event_press;
|
||||||
bool updown1_enabled;
|
bool updown1_enabled;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
char allow_input_source[16];
|
char allow_input_source[16];
|
||||||
bool send_bell;
|
bool send_bell;
|
||||||
} ModuleConfig_CannedMessageConfig;
|
} ModuleConfig_CannedMessageConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_ExternalNotificationConfig {
|
typedef struct _ModuleConfig_ExternalNotificationConfig {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
uint32_t output_ms;
|
uint32_t output_ms;
|
||||||
uint32_t output;
|
uint32_t output;
|
||||||
bool active;
|
bool active;
|
||||||
bool alert_message;
|
bool alert_message;
|
||||||
bool alert_bell;
|
bool alert_bell;
|
||||||
} ModuleConfig_ExternalNotificationConfig;
|
} ModuleConfig_ExternalNotificationConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_MQTTConfig {
|
typedef struct _ModuleConfig_MQTTConfig {
|
||||||
bool disabled;
|
bool disabled;
|
||||||
char address[32];
|
char address[32];
|
||||||
char username[32];
|
char username[32];
|
||||||
char password[32];
|
char password[32];
|
||||||
bool encryption_enabled;
|
bool encryption_enabled;
|
||||||
} ModuleConfig_MQTTConfig;
|
} ModuleConfig_MQTTConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_RangeTestConfig {
|
typedef struct _ModuleConfig_RangeTestConfig {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
uint32_t sender;
|
uint32_t sender;
|
||||||
bool save;
|
bool save;
|
||||||
} ModuleConfig_RangeTestConfig;
|
} ModuleConfig_RangeTestConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_SerialConfig {
|
typedef struct _ModuleConfig_SerialConfig {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool echo;
|
bool echo;
|
||||||
uint32_t rxd;
|
uint32_t rxd;
|
||||||
uint32_t txd;
|
uint32_t txd;
|
||||||
ModuleConfig_SerialConfig_Serial_Baud baud;
|
ModuleConfig_SerialConfig_Serial_Baud baud;
|
||||||
uint32_t timeout;
|
uint32_t timeout;
|
||||||
ModuleConfig_SerialConfig_Serial_Mode mode;
|
ModuleConfig_SerialConfig_Serial_Mode mode;
|
||||||
} ModuleConfig_SerialConfig;
|
} ModuleConfig_SerialConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_StoreForwardConfig {
|
typedef struct _ModuleConfig_StoreForwardConfig {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool heartbeat;
|
bool heartbeat;
|
||||||
uint32_t records;
|
uint32_t records;
|
||||||
uint32_t history_return_max;
|
uint32_t history_return_max;
|
||||||
uint32_t history_return_window;
|
uint32_t history_return_window;
|
||||||
} ModuleConfig_StoreForwardConfig;
|
} ModuleConfig_StoreForwardConfig;
|
||||||
|
|
||||||
typedef struct _ModuleConfig_TelemetryConfig {
|
typedef struct _ModuleConfig_TelemetryConfig {
|
||||||
uint32_t device_update_interval;
|
uint32_t device_update_interval;
|
||||||
uint32_t environment_update_interval;
|
uint32_t environment_update_interval;
|
||||||
bool environment_measurement_enabled;
|
bool environment_measurement_enabled;
|
||||||
bool environment_screen_enabled;
|
bool environment_screen_enabled;
|
||||||
uint32_t environment_read_error_count_threshold;
|
bool environment_display_fahrenheit;
|
||||||
uint32_t environment_recovery_interval;
|
|
||||||
bool environment_display_fahrenheit;
|
|
||||||
TelemetrySensorType environment_sensor_type;
|
|
||||||
uint32_t environment_sensor_pin;
|
|
||||||
} ModuleConfig_TelemetryConfig;
|
} ModuleConfig_TelemetryConfig;
|
||||||
|
|
||||||
/* TODO: REPLACE */
|
/* Module Config */
|
||||||
typedef struct _ModuleConfig {
|
typedef struct _ModuleConfig {
|
||||||
/* TODO: REPLACE */
|
|
||||||
pb_size_t which_payloadVariant;
|
pb_size_t which_payloadVariant;
|
||||||
union {
|
union {
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_MQTTConfig mqtt;
|
ModuleConfig_MQTTConfig mqtt;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_SerialConfig serial;
|
ModuleConfig_SerialConfig serial;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_ExternalNotificationConfig external_notification;
|
ModuleConfig_ExternalNotificationConfig external_notification;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_StoreForwardConfig store_forward;
|
ModuleConfig_StoreForwardConfig store_forward;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_RangeTestConfig range_test;
|
ModuleConfig_RangeTestConfig range_test;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_TelemetryConfig telemetry;
|
ModuleConfig_TelemetryConfig telemetry;
|
||||||
|
/* TODO: REPLACE */
|
||||||
ModuleConfig_CannedMessageConfig canned_message;
|
ModuleConfig_CannedMessageConfig canned_message;
|
||||||
} payloadVariant;
|
} payloadVariant;
|
||||||
} ModuleConfig;
|
} ModuleConfig;
|
||||||
|
|
||||||
|
|
||||||
@@ -156,7 +158,7 @@ extern "C" {
|
|||||||
#define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0}
|
#define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0}
|
#define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_RangeTestConfig_init_default {0, 0, 0}
|
#define ModuleConfig_RangeTestConfig_init_default {0, 0, 0}
|
||||||
#define ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0, _TelemetrySensorType_MIN, 0}
|
#define ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
#define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
||||||
#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}}
|
#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}}
|
||||||
#define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0}
|
#define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0}
|
||||||
@@ -164,7 +166,7 @@ extern "C" {
|
|||||||
#define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0}
|
#define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0}
|
#define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_RangeTestConfig_init_zero {0, 0, 0}
|
#define ModuleConfig_RangeTestConfig_init_zero {0, 0, 0}
|
||||||
#define ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0, 0, 0, _TelemetrySensorType_MIN, 0}
|
#define ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0}
|
||||||
#define ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
#define ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
@@ -209,11 +211,7 @@ extern "C" {
|
|||||||
#define ModuleConfig_TelemetryConfig_environment_update_interval_tag 2
|
#define ModuleConfig_TelemetryConfig_environment_update_interval_tag 2
|
||||||
#define ModuleConfig_TelemetryConfig_environment_measurement_enabled_tag 3
|
#define ModuleConfig_TelemetryConfig_environment_measurement_enabled_tag 3
|
||||||
#define ModuleConfig_TelemetryConfig_environment_screen_enabled_tag 4
|
#define ModuleConfig_TelemetryConfig_environment_screen_enabled_tag 4
|
||||||
#define ModuleConfig_TelemetryConfig_environment_read_error_count_threshold_tag 5
|
|
||||||
#define ModuleConfig_TelemetryConfig_environment_recovery_interval_tag 6
|
|
||||||
#define ModuleConfig_TelemetryConfig_environment_display_fahrenheit_tag 7
|
#define ModuleConfig_TelemetryConfig_environment_display_fahrenheit_tag 7
|
||||||
#define ModuleConfig_TelemetryConfig_environment_sensor_type_tag 8
|
|
||||||
#define ModuleConfig_TelemetryConfig_environment_sensor_pin_tag 9
|
|
||||||
#define ModuleConfig_mqtt_tag 1
|
#define ModuleConfig_mqtt_tag 1
|
||||||
#define ModuleConfig_serial_tag 2
|
#define ModuleConfig_serial_tag 2
|
||||||
#define ModuleConfig_external_notification_tag 3
|
#define ModuleConfig_external_notification_tag 3
|
||||||
@@ -292,11 +290,7 @@ X(a, STATIC, SINGULAR, UINT32, device_update_interval, 1) \
|
|||||||
X(a, STATIC, SINGULAR, UINT32, environment_update_interval, 2) \
|
X(a, STATIC, SINGULAR, UINT32, environment_update_interval, 2) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, environment_measurement_enabled, 3) \
|
X(a, STATIC, SINGULAR, BOOL, environment_measurement_enabled, 3) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, environment_screen_enabled, 4) \
|
X(a, STATIC, SINGULAR, BOOL, environment_screen_enabled, 4) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, environment_read_error_count_threshold, 5) \
|
X(a, STATIC, SINGULAR, BOOL, environment_display_fahrenheit, 7)
|
||||||
X(a, STATIC, SINGULAR, UINT32, environment_recovery_interval, 6) \
|
|
||||||
X(a, STATIC, SINGULAR, BOOL, environment_display_fahrenheit, 7) \
|
|
||||||
X(a, STATIC, SINGULAR, UENUM, environment_sensor_type, 8) \
|
|
||||||
X(a, STATIC, SINGULAR, UINT32, environment_sensor_pin, 9)
|
|
||||||
#define ModuleConfig_TelemetryConfig_CALLBACK NULL
|
#define ModuleConfig_TelemetryConfig_CALLBACK NULL
|
||||||
#define ModuleConfig_TelemetryConfig_DEFAULT NULL
|
#define ModuleConfig_TelemetryConfig_DEFAULT NULL
|
||||||
|
|
||||||
@@ -341,7 +335,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg;
|
|||||||
#define ModuleConfig_RangeTestConfig_size 10
|
#define ModuleConfig_RangeTestConfig_size 10
|
||||||
#define ModuleConfig_SerialConfig_size 26
|
#define ModuleConfig_SerialConfig_size 26
|
||||||
#define ModuleConfig_StoreForwardConfig_size 22
|
#define ModuleConfig_StoreForwardConfig_size 22
|
||||||
#define ModuleConfig_TelemetryConfig_size 38
|
#define ModuleConfig_TelemetryConfig_size 18
|
||||||
#define ModuleConfig_size 105
|
#define ModuleConfig_size 105
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "mqtt.pb.h"
|
#include "mqtt.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_MQTT_PB_H_INCLUDED
|
#ifndef PB_MQTT_PB_H_INCLUDED
|
||||||
#define PB_MQTT_PB_H_INCLUDED
|
#define PB_MQTT_PB_H_INCLUDED
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
/* This message wraps a MeshPacket with extra metadata about the sender and how it arrived. */
|
/* This message wraps a MeshPacket with extra metadata about the sender and how it arrived. */
|
||||||
typedef struct _ServiceEnvelope {
|
typedef struct _ServiceEnvelope {
|
||||||
/* The (probably encrypted) packet */
|
/* The (probably encrypted) packet */
|
||||||
struct _MeshPacket *packet;
|
struct _MeshPacket *packet;
|
||||||
/* The global channel ID it was sent on */
|
/* The global channel ID it was sent on */
|
||||||
char *channel_id;
|
char *channel_id;
|
||||||
/* The sending gateway node ID. Can we use this to authenticate/prevent fake
|
/* The sending gateway node ID. Can we use this to authenticate/prevent fake
|
||||||
nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as
|
nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as
|
||||||
the globally trusted nodenum */
|
the globally trusted nodenum */
|
||||||
char *gateway_id;
|
char *gateway_id;
|
||||||
} ServiceEnvelope;
|
} ServiceEnvelope;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "portnums.pb.h"
|
#include "portnums.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_PORTNUMS_PB_H_INCLUDED
|
#ifndef PB_PORTNUMS_PB_H_INCLUDED
|
||||||
#define PB_PORTNUMS_PB_H_INCLUDED
|
#define PB_PORTNUMS_PB_H_INCLUDED
|
||||||
@@ -48,6 +48,8 @@ typedef enum _PortNum {
|
|||||||
PortNum_ADMIN_APP = 6,
|
PortNum_ADMIN_APP = 6,
|
||||||
/* Compressed TEXT_MESSAGE payloads. */
|
/* Compressed TEXT_MESSAGE payloads. */
|
||||||
PortNum_TEXT_MESSAGE_COMPRESSED_APP = 7,
|
PortNum_TEXT_MESSAGE_COMPRESSED_APP = 7,
|
||||||
|
/* Waypoint payloads. */
|
||||||
|
PortNum_WAYPOINT_APP = 8,
|
||||||
/* Provides a 'ping' service that replies to any packet it receives.
|
/* Provides a 'ping' service that replies to any packet it receives.
|
||||||
Also serves as a small example module. */
|
Also serves as a small example module. */
|
||||||
PortNum_REPLY_APP = 32,
|
PortNum_REPLY_APP = 32,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "remote_hardware.pb.h"
|
#include "remote_hardware.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_REMOTE_HARDWARE_PB_H_INCLUDED
|
#ifndef PB_REMOTE_HARDWARE_PB_H_INCLUDED
|
||||||
#define PB_REMOTE_HARDWARE_PB_H_INCLUDED
|
#define PB_REMOTE_HARDWARE_PB_H_INCLUDED
|
||||||
@@ -31,12 +31,12 @@ typedef enum _HardwareMessage_Type {
|
|||||||
(a special channel once multichannel support is included?) */
|
(a special channel once multichannel support is included?) */
|
||||||
typedef struct _HardwareMessage {
|
typedef struct _HardwareMessage {
|
||||||
/* What type of HardwareMessage is this? */
|
/* What type of HardwareMessage is this? */
|
||||||
HardwareMessage_Type typ;
|
HardwareMessage_Type typ;
|
||||||
/* What gpios are we changing. Not used for all MessageTypes, see MessageType for details */
|
/* What gpios are we changing. Not used for all MessageTypes, see MessageType for details */
|
||||||
uint64_t gpio_mask;
|
uint64_t gpio_mask;
|
||||||
/* For gpios that were listed in gpio_mask as valid, what are the signal levels for those gpios.
|
/* For gpios that were listed in gpio_mask as valid, what are the signal levels for those gpios.
|
||||||
Not used for all MessageTypes, see MessageType for details */
|
Not used for all MessageTypes, see MessageType for details */
|
||||||
uint64_t gpio_value;
|
uint64_t gpio_value;
|
||||||
} HardwareMessage;
|
} HardwareMessage;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "storeforward.pb.h"
|
#include "storeforward.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_STOREFORWARD_PB_H_INCLUDED
|
#ifndef PB_STOREFORWARD_PB_H_INCLUDED
|
||||||
#define PB_STOREFORWARD_PB_H_INCLUDED
|
#define PB_STOREFORWARD_PB_H_INCLUDED
|
||||||
@@ -28,41 +28,41 @@ typedef enum _StoreAndForward_RequestResponse {
|
|||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef struct _StoreAndForward_Heartbeat {
|
typedef struct _StoreAndForward_Heartbeat {
|
||||||
uint32_t period;
|
uint32_t period;
|
||||||
uint32_t secondary;
|
uint32_t secondary;
|
||||||
} StoreAndForward_Heartbeat;
|
} StoreAndForward_Heartbeat;
|
||||||
|
|
||||||
typedef struct _StoreAndForward_History {
|
typedef struct _StoreAndForward_History {
|
||||||
uint32_t history_messages;
|
uint32_t history_messages;
|
||||||
uint32_t window;
|
uint32_t window;
|
||||||
uint32_t last_request;
|
uint32_t last_request;
|
||||||
} StoreAndForward_History;
|
} StoreAndForward_History;
|
||||||
|
|
||||||
typedef struct _StoreAndForward_Statistics {
|
typedef struct _StoreAndForward_Statistics {
|
||||||
uint32_t messages_total;
|
uint32_t messages_total;
|
||||||
uint32_t messages_saved;
|
uint32_t messages_saved;
|
||||||
uint32_t messages_max;
|
uint32_t messages_max;
|
||||||
uint32_t up_time;
|
uint32_t up_time;
|
||||||
uint32_t requests;
|
uint32_t requests;
|
||||||
uint32_t requests_history;
|
uint32_t requests_history;
|
||||||
bool heartbeat;
|
bool heartbeat;
|
||||||
uint32_t return_max;
|
uint32_t return_max;
|
||||||
uint32_t return_window;
|
uint32_t return_window;
|
||||||
} StoreAndForward_Statistics;
|
} StoreAndForward_Statistics;
|
||||||
|
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
typedef struct _StoreAndForward {
|
typedef struct _StoreAndForward {
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
StoreAndForward_RequestResponse rr;
|
StoreAndForward_RequestResponse rr;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
bool has_stats;
|
bool has_stats;
|
||||||
StoreAndForward_Statistics stats;
|
StoreAndForward_Statistics stats;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
bool has_history;
|
bool has_history;
|
||||||
StoreAndForward_History history;
|
StoreAndForward_History history;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
bool has_heartbeat;
|
bool has_heartbeat;
|
||||||
StoreAndForward_Heartbeat heartbeat;
|
StoreAndForward_Heartbeat heartbeat;
|
||||||
} StoreAndForward;
|
} StoreAndForward;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#include "telemetry.pb.h"
|
#include "telemetry.pb.h"
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* Generated by nanopb-0.4.5 */
|
/* Generated by nanopb-0.4.6 */
|
||||||
|
|
||||||
#ifndef PB_TELEMETRY_PB_H_INCLUDED
|
#ifndef PB_TELEMETRY_PB_H_INCLUDED
|
||||||
#define PB_TELEMETRY_PB_H_INCLUDED
|
#define PB_TELEMETRY_PB_H_INCLUDED
|
||||||
@@ -12,55 +12,49 @@
|
|||||||
/* Enum definitions */
|
/* Enum definitions */
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
typedef enum _TelemetrySensorType {
|
typedef enum _TelemetrySensorType {
|
||||||
/* No external telemetry sensor */
|
/* No external telemetry sensor explicitly set */
|
||||||
TelemetrySensorType_NotSet = 0,
|
TelemetrySensorType_NotSet = 0,
|
||||||
/* TODO: REPLACE */
|
/* High accuracy temperature, pressure, humidity */
|
||||||
TelemetrySensorType_DHT11 = 1,
|
TelemetrySensorType_BME280 = 1,
|
||||||
/* TODO: REPLACE */
|
/* High accuracy temperature, pressure, humidity, and air resistance */
|
||||||
TelemetrySensorType_DS18B20 = 2,
|
TelemetrySensorType_BME680 = 2,
|
||||||
/* TODO: REPLACE */
|
/* Very high accuracy temperature */
|
||||||
TelemetrySensorType_DHT12 = 3,
|
TelemetrySensorType_MCP9808 = 3,
|
||||||
/* TODO: REPLACE */
|
/* Moderate accuracy current and voltage */
|
||||||
TelemetrySensorType_DHT21 = 4,
|
TelemetrySensorType_INA260 = 4,
|
||||||
/* TODO: REPLACE */
|
/* Moderate accuracy current and voltage */
|
||||||
TelemetrySensorType_DHT22 = 5,
|
TelemetrySensorType_INA219 = 5,
|
||||||
/* TODO: REPLACE */
|
/* High accuracy temperature and pressure */
|
||||||
TelemetrySensorType_BME280 = 6,
|
TelemetrySensorType_BMP280 = 6
|
||||||
/* TODO: REPLACE */
|
|
||||||
TelemetrySensorType_BME680 = 7,
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
TelemetrySensorType_MCP9808 = 8,
|
|
||||||
/* TODO: REPLACE */
|
|
||||||
TelemetrySensorType_SHTC3 = 9
|
|
||||||
} TelemetrySensorType;
|
} TelemetrySensorType;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
/* Key native device metrics such as battery level */
|
/* Key native device metrics such as battery level */
|
||||||
typedef struct _DeviceMetrics {
|
typedef struct _DeviceMetrics {
|
||||||
/* 1-100 (0 means powered) */
|
/* 1-100 (0 means powered) */
|
||||||
uint32_t battery_level;
|
uint32_t battery_level;
|
||||||
/* Voltage measured */
|
/* Voltage measured */
|
||||||
float voltage;
|
float voltage;
|
||||||
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
|
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
|
||||||
float channel_utilization;
|
float channel_utilization;
|
||||||
/* Percent of airtime for transmission used within the last hour. */
|
/* Percent of airtime for transmission used within the last hour. */
|
||||||
float air_util_tx;
|
float air_util_tx;
|
||||||
} DeviceMetrics;
|
} DeviceMetrics;
|
||||||
|
|
||||||
/* Weather station or other environmental metrics */
|
/* Weather station or other environmental metrics */
|
||||||
typedef struct _EnvironmentMetrics {
|
typedef struct _EnvironmentMetrics {
|
||||||
/* Temperature measured */
|
/* Temperature measured */
|
||||||
float temperature;
|
float temperature;
|
||||||
/* Relative humidity percent measured */
|
/* Relative humidity percent measured */
|
||||||
float relative_humidity;
|
float relative_humidity;
|
||||||
/* Barometric pressure in hPA measured */
|
/* Barometric pressure in hPA measured */
|
||||||
float barometric_pressure;
|
float barometric_pressure;
|
||||||
/* Gas resistance in mOhm measured */
|
/* Gas resistance in mOhm measured */
|
||||||
float gas_resistance;
|
float gas_resistance;
|
||||||
/* Voltage measured */
|
/* Voltage measured */
|
||||||
float voltage;
|
float voltage;
|
||||||
/* Current measured */
|
/* Current measured */
|
||||||
float current;
|
float current;
|
||||||
} EnvironmentMetrics;
|
} EnvironmentMetrics;
|
||||||
|
|
||||||
/* Types of Measurements the telemetry module is equipped to handle */
|
/* Types of Measurements the telemetry module is equipped to handle */
|
||||||
@@ -70,20 +64,21 @@ typedef struct _Telemetry {
|
|||||||
the mesh (because there are devices on the mesh without GPS), it will only
|
the mesh (because there are devices on the mesh without GPS), it will only
|
||||||
be sent by devices which has a hardware GPS clock (IE Mobile Phone).
|
be sent by devices which has a hardware GPS clock (IE Mobile Phone).
|
||||||
seconds since 1970 */
|
seconds since 1970 */
|
||||||
uint32_t time;
|
uint32_t time;
|
||||||
/* Key native device metrics such as battery level */
|
|
||||||
pb_size_t which_variant;
|
pb_size_t which_variant;
|
||||||
union {
|
union {
|
||||||
|
/* Key native device metrics such as battery level */
|
||||||
DeviceMetrics device_metrics;
|
DeviceMetrics device_metrics;
|
||||||
|
/* Weather station or other environmental metrics */
|
||||||
EnvironmentMetrics environment_metrics;
|
EnvironmentMetrics environment_metrics;
|
||||||
} variant;
|
} variant;
|
||||||
} Telemetry;
|
} Telemetry;
|
||||||
|
|
||||||
|
|
||||||
/* Helper constants for enums */
|
/* Helper constants for enums */
|
||||||
#define _TelemetrySensorType_MIN TelemetrySensorType_NotSet
|
#define _TelemetrySensorType_MIN TelemetrySensorType_NotSet
|
||||||
#define _TelemetrySensorType_MAX TelemetrySensorType_SHTC3
|
#define _TelemetrySensorType_MAX TelemetrySensorType_BMP280
|
||||||
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_SHTC3+1))
|
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_BMP280+1))
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <HTTPURLEncodedBodyParser.hpp>
|
#include <HTTPURLEncodedBodyParser.hpp>
|
||||||
#include <json11.hpp>
|
#include <json11.hpp>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -610,7 +610,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
// data->wifi
|
// data->wifi
|
||||||
String ipStr;
|
String ipStr;
|
||||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) {
|
||||||
ipStr = String(WiFi.softAPIP().toString());
|
ipStr = String(WiFi.softAPIP().toString());
|
||||||
} else {
|
} else {
|
||||||
ipStr = String(WiFi.localIP().toString());
|
ipStr = String(WiFi.localIP().toString());
|
||||||
@@ -716,8 +716,6 @@ void handleAdminSettings(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->println("<tr><td><input type=checkbox></td><td>WiFi Password</td><td>false</td><td><input type=radio></td></tr>\n");
|
res->println("<tr><td><input type=checkbox></td><td>WiFi Password</td><td>false</td><td><input type=radio></td></tr>\n");
|
||||||
res->println(
|
res->println(
|
||||||
"<tr><td><input type=checkbox></td><td>Smart Position Update</td><td>false</td><td><input type=radio></td></tr>\n");
|
"<tr><td><input type=checkbox></td><td>Smart Position Update</td><td>false</td><td><input type=radio></td></tr>\n");
|
||||||
res->println("<tr><td><input type=checkbox></td><td>is_always_powered</td><td>false</td><td><input type=radio></td></tr>\n");
|
|
||||||
res->println("<tr><td><input type=checkbox></td><td>is_always_powered</td><td>false</td><td><input type=radio></td></tr>\n");
|
|
||||||
res->println("</table>\n");
|
res->println("</table>\n");
|
||||||
res->println("<table>\n");
|
res->println("<table>\n");
|
||||||
res->println("<input type=submit value=Apply New Settings>\n");
|
res->println("<input type=submit value=Apply New Settings>\n");
|
||||||
@@ -789,7 +787,7 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
|||||||
count = count - 1;
|
count = count - 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
screen->blink();
|
screen->blink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ void createSSLCert()
|
|||||||
|
|
||||||
yield();
|
yield();
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
if (millis() / 1000 >= 3) {
|
if (millis() / 1000 >= 3) {
|
||||||
screen->setSSLFrames();
|
screen->setSSLFrames();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,10 +191,14 @@ bool initWifi(bool forceSoftAP)
|
|||||||
|
|
||||||
if (forceSoftAP) {
|
if (forceSoftAP) {
|
||||||
DEBUG_MSG("WiFi ... Forced AP Mode\n");
|
DEBUG_MSG("WiFi ... Forced AP Mode\n");
|
||||||
} else if (config.wifi.ap_mode) {
|
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint) {
|
||||||
DEBUG_MSG("WiFi ... AP Mode\n");
|
DEBUG_MSG("WiFi ... AP Mode\n");
|
||||||
} else {
|
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
||||||
|
DEBUG_MSG("WiFi ... Hidden AP Mode\n");
|
||||||
|
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_Client) {
|
||||||
DEBUG_MSG("WiFi ... Client Mode\n");
|
DEBUG_MSG("WiFi ... Client Mode\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("WiFi ... WiFi Disabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
createSSLCert();
|
createSSLCert();
|
||||||
@@ -203,7 +207,7 @@ bool initWifi(bool forceSoftAP)
|
|||||||
wifiPsw = NULL;
|
wifiPsw = NULL;
|
||||||
|
|
||||||
if (*wifiName || forceSoftAP) {
|
if (*wifiName || forceSoftAP) {
|
||||||
if (config.wifi.ap_mode || forceSoftAP) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || forceSoftAP) {
|
||||||
|
|
||||||
IPAddress apIP(192, 168, 42, 1);
|
IPAddress apIP(192, 168, 42, 1);
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
@@ -218,11 +222,11 @@ bool initWifi(bool forceSoftAP)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If AP is configured to be hidden hidden
|
// If AP is configured to be hidden hidden
|
||||||
if (config.wifi.ap_hidden) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
||||||
|
|
||||||
// The configurations on softAP are from the espresif library
|
// The configurations on softAP are from the espresif library
|
||||||
int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4);
|
int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4);
|
||||||
DEBUG_MSG("Starting hiddem WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
DEBUG_MSG("Starting hidden WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
||||||
} else {
|
} else {
|
||||||
int ok = WiFi.softAP(wifiName, wifiPsw);
|
int ok = WiFi.softAP(wifiName, wifiPsw);
|
||||||
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
DEBUG_MSG("Starting WIFI AP: ssid=%s, ok=%d\n", wifiName, ok);
|
||||||
@@ -373,7 +377,7 @@ static void WiFiEvent(WiFiEvent_t event)
|
|||||||
|
|
||||||
void handleDNSResponse()
|
void handleDNSResponse()
|
||||||
{
|
{
|
||||||
if (config.wifi.ap_mode || isSoftAPForced()) {
|
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) {
|
||||||
dnsServer.processNextRequest();
|
dnsServer.processNextRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#ifdef HAS_WIFI
|
#ifdef ARCH_ESP32
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ bool pb_decode_from_bytes(const uint8_t *srcbuf, size_t srcbufsize, const pb_msg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FSCom
|
||||||
/// Read from an Arduino File
|
/// Read from an Arduino File
|
||||||
bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
|
||||||
{
|
{
|
||||||
@@ -59,6 +60,7 @@ bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
|
|||||||
// DEBUG_MSG("writing %d bytes to protobuf file\n", count);
|
// DEBUG_MSG("writing %d bytes to protobuf file\n", count);
|
||||||
return file->write(buf, count) == count;
|
return file->write(buf, count) == count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
|
bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mesh/generated/mesh.pb.h"
|
#include "mesh/generated/mesh.pb.h"
|
||||||
|
#include "mesh/generated/localonly.pb.h"
|
||||||
#include "mesh/generated/deviceonly.pb.h"
|
#include "mesh/generated/deviceonly.pb.h"
|
||||||
#include "mesh/generated/admin.pb.h"
|
#include "mesh/generated/admin.pb.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#ifdef PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -17,14 +17,6 @@ AdminModule *adminModule;
|
|||||||
/// a change.
|
/// a change.
|
||||||
static const char *secretReserved = "sekrit";
|
static const char *secretReserved = "sekrit";
|
||||||
|
|
||||||
/// If buf is !empty, change it to secret
|
|
||||||
static void hideSecret(char *buf)
|
|
||||||
{
|
|
||||||
if (*buf) {
|
|
||||||
strcpy(buf, secretReserved);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// If buf is the reserved secret word, replace the buffer with currentVal
|
/// If buf is the reserved secret word, replace the buffer with currentVal
|
||||||
static void writeSecret(char *buf, const char *currentVal)
|
static void writeSecret(char *buf, const char *currentVal)
|
||||||
{
|
{
|
||||||
@@ -58,7 +50,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
|
|
||||||
case AdminMessage_get_config_request_tag:
|
case AdminMessage_get_config_request_tag:
|
||||||
DEBUG_MSG("Client is getting config\n");
|
DEBUG_MSG("Client is getting config\n");
|
||||||
handleGetConfig(mp, r->get_channel_request);
|
handleGetConfig(mp, r->get_config_request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_get_module_config_request_tag:
|
case AdminMessage_get_module_config_request_tag:
|
||||||
@@ -117,8 +109,13 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AdminMessage_get_device_metadata_request_tag: {
|
||||||
|
DEBUG_MSG("Client is getting device metadata\n");
|
||||||
|
handleGetDeviceMetadata(mp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
case AdminMessage_exit_simulator_tag:
|
case AdminMessage_exit_simulator_tag:
|
||||||
DEBUG_MSG("Exiting simulator\n");
|
DEBUG_MSG("Exiting simulator\n");
|
||||||
_exit(0);
|
_exit(0);
|
||||||
@@ -314,11 +311,10 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
|
||||||
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
// using to the app (so that even old phone apps work with new device loads).
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
||||||
// r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
|
||||||
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
||||||
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
||||||
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
|
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
|
||||||
@@ -371,11 +367,10 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
// NOTE: The phone app needs to know the ls_secsvalue so it can properly expect sleep behavior.
|
||||||
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
// using to the app (so that even old phone apps work with new device loads).
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
||||||
// r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
|
||||||
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
||||||
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
||||||
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
|
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
|
||||||
@@ -384,6 +379,18 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) {
|
||||||
|
AdminMessage r = AdminMessage_init_default;
|
||||||
|
|
||||||
|
DeviceMetadata deviceMetadata;
|
||||||
|
strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18);
|
||||||
|
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
|
||||||
|
|
||||||
|
r.get_device_metadata_response = deviceMetadata;
|
||||||
|
r.which_variant = AdminMessage_get_device_metadata_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
|
|
||||||
void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
||||||
{
|
{
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class AdminModule : public ProtobufModule<AdminMessage>
|
|||||||
void handleGetConfig(const MeshPacket &req, uint32_t configType);
|
void handleGetConfig(const MeshPacket &req, uint32_t configType);
|
||||||
void handleGetModuleConfig(const MeshPacket &req, uint32_t configType);
|
void handleGetModuleConfig(const MeshPacket &req, uint32_t configType);
|
||||||
void handleGetChannel(const MeshPacket &req, uint32_t channelIndex);
|
void handleGetChannel(const MeshPacket &req, uint32_t channelIndex);
|
||||||
|
void handleGetDeviceMetadata(const MeshPacket &req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setters
|
* Setters
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#ifndef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
#include "CannedMessageModule.h"
|
#include "CannedMessageModule.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifdef NO_SCREEN
|
#if HAS_SCREEN
|
||||||
#else
|
|
||||||
#include "ProtobufModule.h"
|
#include "ProtobufModule.h"
|
||||||
#include "input/InputBroker.h"
|
#include "input/InputBroker.h"
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ ExternalNotificationModule::ExternalNotificationModule()
|
|||||||
// restrict to the admin channel for rx
|
// restrict to the admin channel for rx
|
||||||
boundChannel = Channels::gpioChannel;
|
boundChannel = Channels::gpioChannel;
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#ifdef EXT_NOTIFY_OUT
|
#ifdef EXT_NOTIFY_OUT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -154,7 +154,7 @@ ExternalNotificationModule::ExternalNotificationModule()
|
|||||||
|
|
||||||
ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#ifdef EXT_NOTIFY_OUT
|
#ifdef EXT_NOTIFY_OUT
|
||||||
|
|
||||||
if (moduleConfig.external_notification.enabled) {
|
if (moduleConfig.external_notification.enabled) {
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
#include "modules/RoutingModule.h"
|
#include "modules/RoutingModule.h"
|
||||||
#include "modules/TextMessageModule.h"
|
#include "modules/TextMessageModule.h"
|
||||||
#include "modules/Telemetry/DeviceTelemetry.h"
|
#include "modules/Telemetry/DeviceTelemetry.h"
|
||||||
#ifndef PORTDUINO
|
#if HAS_TELEMETRY
|
||||||
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "modules/esp32/RangeTestModule.h"
|
#include "modules/esp32/RangeTestModule.h"
|
||||||
#include "modules/esp32/SerialModule.h"
|
#include "modules/esp32/SerialModule.h"
|
||||||
#include "modules/esp32/StoreForwardModule.h"
|
#include "modules/esp32/StoreForwardModule.h"
|
||||||
@@ -28,7 +28,9 @@
|
|||||||
*/
|
*/
|
||||||
void setupModules()
|
void setupModules()
|
||||||
{
|
{
|
||||||
|
#if HAS_BUTTON
|
||||||
inputBroker = new InputBroker();
|
inputBroker = new InputBroker();
|
||||||
|
#endif
|
||||||
adminModule = new AdminModule();
|
adminModule = new AdminModule();
|
||||||
nodeInfoModule = new NodeInfoModule();
|
nodeInfoModule = new NodeInfoModule();
|
||||||
positionModule = new PositionModule();
|
positionModule = new PositionModule();
|
||||||
@@ -39,6 +41,7 @@ void setupModules()
|
|||||||
|
|
||||||
new RemoteHardwareModule();
|
new RemoteHardwareModule();
|
||||||
new ReplyModule();
|
new ReplyModule();
|
||||||
|
#if HAS_BUTTON
|
||||||
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
||||||
rotaryEncoderInterruptImpl1->init();
|
rotaryEncoderInterruptImpl1->init();
|
||||||
upDownInterruptImpl1 = new UpDownInterruptImpl1();
|
upDownInterruptImpl1 = new UpDownInterruptImpl1();
|
||||||
@@ -47,14 +50,15 @@ void setupModules()
|
|||||||
cardKbI2cImpl->init();
|
cardKbI2cImpl->init();
|
||||||
facesKbI2cImpl = new FacesKbI2cImpl();
|
facesKbI2cImpl = new FacesKbI2cImpl();
|
||||||
facesKbI2cImpl->init();
|
facesKbI2cImpl->init();
|
||||||
#ifndef NO_SCREEN
|
#endif
|
||||||
|
#if HAS_SCREEN
|
||||||
cannedMessageModule = new CannedMessageModule();
|
cannedMessageModule = new CannedMessageModule();
|
||||||
#endif
|
#endif
|
||||||
#ifndef PORTDUINO
|
#if HAS_TELEMETRY
|
||||||
new DeviceTelemetryModule();
|
new DeviceTelemetryModule();
|
||||||
new EnvironmentTelemetryModule();
|
new EnvironmentTelemetryModule();
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Only run on an esp32 based device.
|
// Only run on an esp32 based device.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ MeshPacket *PositionModule::allocReply()
|
|||||||
} else
|
} else
|
||||||
DEBUG_MSG("Providing time to mesh %u\n", p.time);
|
DEBUG_MSG("Providing time to mesh %u\n", p.time);
|
||||||
|
|
||||||
|
DEBUG_MSG("Position reply: time=%i, latI=%i, lonI=-%i\n", p.time, p.latitude_i, p.longitude_i);
|
||||||
|
|
||||||
return allocDataProtobuf(p);
|
return allocDataProtobuf(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,22 +135,21 @@ int32_t PositionModule::runOnce()
|
|||||||
|
|
||||||
// Only send packets if the channel is less than 40% utilized.
|
// Only send packets if the channel is less than 40% utilized.
|
||||||
if (airTime->channelUtilizationPercent() < 40) {
|
if (airTime->channelUtilizationPercent() < 40) {
|
||||||
|
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
||||||
|
lastGpsSend = now;
|
||||||
|
|
||||||
lastGpsSend = now;
|
lastGpsLatitude = node->position.latitude_i;
|
||||||
|
lastGpsLongitude = node->position.longitude_i;
|
||||||
|
|
||||||
lastGpsLatitude = node->position.latitude_i;
|
// If we changed channels, ask everyone else for their latest info
|
||||||
lastGpsLongitude = node->position.longitude_i;
|
bool requestReplies = currentGeneration != radioGeneration;
|
||||||
|
currentGeneration = radioGeneration;
|
||||||
// If we changed channels, ask everyone else for their latest info
|
|
||||||
bool requestReplies = currentGeneration != radioGeneration;
|
|
||||||
currentGeneration = radioGeneration;
|
|
||||||
|
|
||||||
DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies);
|
|
||||||
|
|
||||||
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
|
||||||
|
|
||||||
|
DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies);
|
||||||
|
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Channel utilization is >50 percent. Skipping this opportunity to send.\n");
|
DEBUG_MSG("Channel utilization is >40 percent. Skipping this opportunity to send.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!config.position.position_broadcast_smart_disabled) {
|
} else if (!config.position.position_broadcast_smart_disabled) {
|
||||||
@@ -171,23 +172,26 @@ int32_t PositionModule::runOnce()
|
|||||||
|
|
||||||
// Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear.
|
// Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear.
|
||||||
const float distanceTravelMath = 1203 / (sqrt(pow(myNodeInfo.bitrate, 1.5) / 1.1));
|
const float distanceTravelMath = 1203 / (sqrt(pow(myNodeInfo.bitrate, 1.5) / 1.1));
|
||||||
uint32_t distanceTravel =
|
uint32_t distanceTravelThreshold =
|
||||||
(distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum;
|
(distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum;
|
||||||
|
|
||||||
// Yes, this has a bunch of magic numbers. Sorry.
|
// Yes, this has a bunch of magic numbers. Sorry.
|
||||||
uint32_t timeTravel =
|
uint32_t timeTravel =
|
||||||
((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum;
|
((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum;
|
||||||
|
// If the distance traveled since the last update is greater than distanceTravelMinimum meters
|
||||||
// If the distance traveled since the last update is greater than 100 meters
|
// and it's been at least timeTravelMinimum seconds since the last update
|
||||||
// and it's been at least 60 seconds since the last update
|
if ((abs(distance) >= distanceTravelThreshold) && (now - lastGpsSend) >= (timeTravel * 1000)) {
|
||||||
if ((abs(distance) >= distanceTravel) && (now - lastGpsSend >= timeTravel * 1000)) {
|
|
||||||
bool requestReplies = currentGeneration != radioGeneration;
|
bool requestReplies = currentGeneration != radioGeneration;
|
||||||
currentGeneration = radioGeneration;
|
currentGeneration = radioGeneration;
|
||||||
|
|
||||||
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, dt=%d, tt=%d)\n", node2->position.pos_timestamp,
|
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, d=%d, dtt=%d, tt=%d)\n", node2->position.pos_timestamp,
|
||||||
requestReplies, distanceTravel, timeTravel);
|
requestReplies, distance, distanceTravelThreshold, timeTravel);
|
||||||
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
||||||
|
|
||||||
|
// Set the current coords as our last ones, after we've compared distance with current and decided to send
|
||||||
|
lastGpsLatitude = node->position.latitude_i;
|
||||||
|
lastGpsLongitude = node->position.longitude_i;
|
||||||
|
|
||||||
/* Update lastGpsSend to now. This means if the device is stationary, then
|
/* Update lastGpsSend to now. This means if the device is stationary, then
|
||||||
getPref_position_broadcast_secs will still apply.
|
getPref_position_broadcast_secs will still apply.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user