Compare commits

...

36 Commits

Author SHA1 Message Date
Kevin Hester
fce95431e6 Merge pull request #746 from geeksville/dev1.2
fixing bugs for the sat release
2021-03-19 23:47:12 +08:00
Kevin Hester
591a07c0fe 1.2.11 2021-03-19 23:41:28 +08:00
Kevin Hester
c410f2d151 fix tlora 1.6 build 2021-03-19 23:40:41 +08:00
Kevin Hester
9502fa62e6 todo updates 2021-03-19 23:40:24 +08:00
Kevin Hester
2a6480ec48 update release test scripts 2021-03-19 23:40:04 +08:00
Kevin Hester
7c5ab885be geeksville todo 2021-03-19 15:24:24 +08:00
Kevin Hester
21cfb151a8 specify clang for c++ formatting conventions 2021-03-19 15:24:05 +08:00
Kevin Hester
84505b1717 Merge remote-tracking branch 'root/master' into portduino 2021-03-19 15:22:56 +08:00
Kevin Hester
d735e3006e Merge pull request #745 from geeksville/portduino
add CI integration test using meshtastic-native
2021-03-18 19:59:27 +08:00
Kevin Hester
af5d82dbde Merge remote-tracking branch 'root/master' into portduino 2021-03-18 19:49:13 +08:00
Kevin Hester
a97072eca0 add first integration test for CI 2021-03-18 19:48:06 +08:00
Kevin Hester
cef6e248e7 add newline 2021-03-18 19:40:00 +08:00
Kevin Hester
b4c379f5fc add sim exit cmd 2021-03-18 19:09:31 +08:00
Jm
1b8f41d353 Partial work on s&f 2021-03-17 21:03:11 -07:00
Kevin Hester
449a3959b0 Merge pull request #742 from geeksville/portduino
wifi now works on portduino
2021-03-17 20:43:47 +08:00
Kevin Hester
719a0c485b Merge remote-tracking branch 'root/master' into portduino 2021-03-17 20:30:41 +08:00
Kevin Hester
a4bbdc443f Merge pull request #739 from geeksville/dev
Dev
2021-03-17 20:30:25 +08:00
Kevin Hester
999afdf05e wifi now works on portduino 2021-03-17 20:29:27 +08:00
Kevin Hester
f492f6deb6 progress on Wifi in portduino 2021-03-15 19:59:31 +08:00
Kevin Hester
60f7ec8998 setup for intellij 2021-03-15 13:55:08 +08:00
Kevin Hester
469d0ade72 remove old intellij defs 2021-03-15 13:49:21 +08:00
Kevin Hester
1f33b03c30 turn off broken genieblocks_lora build 2021-03-15 13:43:22 +08:00
Kevin Hester
351be2f327 change portduino so it has a higher chance of building on OS-X and windows 2021-03-15 13:09:52 +08:00
Kevin Hester
3f401e8cac Merge branch 'dev' into portduino
# Conflicts:
#	.vscode/settings.json
2021-03-15 12:09:07 +08:00
Kevin Hester
27c35f69aa Fix flash flippy-flop error after commandline update (thanks @Stephen304) 2021-03-14 12:41:31 +08:00
Kevin Hester
53671283ae change hw_model_deprecated to intentionally break old apps 2021-03-14 10:57:26 +08:00
Kevin Hester
d9fc7b32c3 move hw_model into User 2021-03-14 10:48:20 +08:00
Kevin Hester
9a03536e3d Use enums for hw_model per @sachaw idea. 2021-03-14 10:37:32 +08:00
Kevin Hester
efebb8bb0b remove country from rom support 2021-03-14 10:13:28 +08:00
Kevin Hester
3bd1ae0be4 Merge remote-tracking branch 'root/master' into dev 2021-03-13 14:11:31 +08:00
Kevin Hester
a07291d904 cleanup external notification plugin 2021-03-13 13:32:23 +08:00
Kevin Hester
c0ac457cad lockdown plugins that touch hardware 2021-03-13 13:14:27 +08:00
Kevin Hester
6813a31895 fix hop limit defaults for android 2021-03-13 09:27:44 +08:00
Kevin Hester
da03490310 Merge branch 'dev' into portduino 2021-02-10 16:20:29 +08:00
Kevin Hester
aedca25fa8 Merge branch 'dev' into portduino 2021-02-10 15:51:34 +08:00
Kevin Hester
c25efac0c1 portduino wip 2021-02-07 09:17:46 +08:00
48 changed files with 2641 additions and 305 deletions

View File

@@ -7,7 +7,7 @@
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc... is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
- Please do not check in files that don't have real changes - Please do not check in files that don't have real changes
- Please do not reformat lines that you didn't have to change the code on - Please do not reformat lines that you didn't have to change the code on
- We recommend using the [Visual Studio Code](https://platformio.org/install/ide?install=vscode) editor, - We recommend using the [Visual Studio Code](https://platformio.org/install/ide?install=vscode) editor and the 'clang-format' extension,
because automatically follows our indentation rules and it's auto reformatting will not cause spurious changes to lines. because automatically follows our indentation rules and it's auto reformatting will not cause spurious changes to lines.
- If your PR fixes a bug, mention "fixes #bugnum" somewhere in your pull request description. - If your PR fixes a bug, mention "fixes #bugnum" somewhere in your pull request description.
- If your other co-developers have comments on your PR please tweak as needed. - If your other co-developers have comments on your PR please tweak as needed.

View File

@@ -15,10 +15,10 @@ jobs:
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.x python-version: 3.x
- name: Install Platform IO - name: Install Platform IO and meshtastic-python
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -U platformio pip install -U platformio meshtastic
- name: Install extra python tools - name: Install extra python tools
run: | run: |
pip install -U adafruit-nrfutil pip install -U adafruit-nrfutil
@@ -31,6 +31,11 @@ jobs:
run: platformio run -e heltec run: platformio run -e heltec
- name: Build for lora-relay-v1 - name: Build for lora-relay-v1
run: platformio run -e lora-relay-v1 run: platformio run -e lora-relay-v1
# Turn off linux for now - name: Build for native
#- name: Build for linux run: platformio run -e native
# run: platformio run -e linux - name: Integration test
run: |
.pio/build/native/program &
sleep 1
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'

3
.gitignore vendored
View File

@@ -15,7 +15,8 @@ Thumbs.db
.built .built
.context .context
.cproject .cproject
.idea/*
.vagrant .vagrant
nanopb* nanopb*
flash.uf2 flash.uf2
cmake-build*

7
.idea/codeStyles/Project.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<clangFormatSettings>
<option name="ENABLED" value="true" />
</clangFormatSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

2
.idea/meshtastic-esp32.iml generated Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/meshtastic-esp32.iml" filepath="$PROJECT_DIR$/.idea/meshtastic-esp32.iml" />
</modules>
</component>
</project>

9
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/design" vcs="Git" />
<mapping directory="$PROJECT_DIR$/proto" vcs="Git" />
<mapping directory="$PROJECT_DIR$/sdk-nrfxlib" vcs="Git" />
</component>
</project>

137
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated>
<config projectName="meshtastic-esp32" targetName="Debug" />
<config projectName="meshtastic-esp32" targetName="Production" />
<config projectName="meshtastic-esp32" targetName="Z_DUMMY_TARGET" />
</generated>
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="native" CONFIG_NAME="native" ENABLED="true" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="58922733-b05b-4b90-9655-b9b18914977a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docs/software/TODO.md" beforeDir="false" afterPath="$PROJECT_DIR$/docs/software/TODO.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/proto" beforeDir="false" afterPath="$PROJECT_DIR$/proto" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/mesh/generated/mesh.pb.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/mesh/generated/mesh.pb.h" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:native" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1pmWHw2wau2TbdKvXvmQUB0EUE9" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="cf.advertisement.text.overridden" value="true" />
<property name="cf.first.check.clang-format" value="false" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="settings.editor.selected.configurable" value="CMakeSettings" />
</component>
<component name="RunManager" selected="PlatformIO.PlatformIO Upload">
<configuration default="true" type="CLion_Remote" version="1" remoteCommand="tcp:localhost:2345" symbolFile="" sysroot="">
<debugger kind="GDB" isBundled="true" />
<method v="2" />
</configuration>
<configuration name="gdbremote-localhost-2345" type="CLion_Remote" version="1" remoteCommand="tcp:localhost:2345" symbolFile="" sysroot="">
<debugger kind="GDB" isBundled="true" />
<method v="2" />
</configuration>
<configuration name="Z_DUMMY_TARGET" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="meshtastic-esp32" TARGET_NAME="Z_DUMMY_TARGET" CONFIG_NAME="native" RUN_TARGET_PROJECT_NAME="meshtastic-esp32" RUN_TARGET_NAME="Z_DUMMY_TARGET">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="true" type="GradleAppRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.cpp.gradle.execution.GradleNativeBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="PlatformIO Debug" type="platformio" factoryName="PlatformIO Debug" REDIRECT_INPUT="false" ELEVATE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="meshtastic-esp32" TARGET_NAME="Debug" CONFIG_NAME="native" RUN_TARGET_PROJECT_NAME="meshtastic-esp32" RUN_TARGET_NAME="Debug">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="PlatformIO Upload" type="platformio" factoryName="PlatformIO Upload" REDIRECT_INPUT="false" ELEVATE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="meshtastic-esp32" TARGET_NAME="Production" CONFIG_NAME="native" RUN_TARGET_PROJECT_NAME="meshtastic-esp32" RUN_TARGET_NAME="Production">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="CMake Application.Z_DUMMY_TARGET" />
<item itemvalue="GDB Remote Debug.gdbremote-localhost-2345" />
<item itemvalue="PlatformIO.PlatformIO Debug" />
<item itemvalue="PlatformIO.PlatformIO Upload" />
</list>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="58922733-b05b-4b90-9655-b9b18914977a" name="Default Changelist" comment="" />
<created>1615788661896</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1615788661896</updated>
<workItem from="1615788663210" duration="6661000" />
<workItem from="1615938346019" duration="1208000" />
<workItem from="1615971126983" duration="5945000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/src/mesh/StreamAPI.cpp</url>
<line>20</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/src/mesh/wifi/WiFiServerAPI.cpp</url>
<line>53</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

View File

@@ -2,6 +2,7 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"platformio.platformio-ide" "platformio.platformio-ide",
"xaver.clang-format"
] ]
} }

View File

@@ -69,6 +69,7 @@
"wifi" "wifi"
], ],
"C_Cpp.dimInactiveRegions": true, "C_Cpp.dimInactiveRegions": true,
"cmake.configureOnOpen": true,
"protoc": { "protoc": {
"compile_on_save": false, "compile_on_save": false,
"compile_all_path": "/home/kevinh/development/meshtastic/meshtastic-esp32/proto", "compile_all_path": "/home/kevinh/development/meshtastic/meshtastic-esp32/proto",
@@ -76,5 +77,6 @@
"--java_out=/tmp", "--java_out=/tmp",
"-I=/home/kevinh/development/meshtastic/meshtastic-esp32/proto" "-I=/home/kevinh/development/meshtastic/meshtastic-esp32/proto"
] ]
} },
"editor.formatOnSave": true
} }

36
CMakeLists.txt Normal file
View File

@@ -0,0 +1,36 @@
# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE
# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
#
# If you need to override existing CMake configuration or add extra,
# please create `CMakeListsUser.txt` in the root of project.
# The `CMakeListsUser.txt` will not be overwritten by PlatformIO.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
project("meshtastic-esp32" C CXX)
include(CMakeListsPrivate.txt)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt)
include(CMakeListsUser.txt)
endif()
include_directories("$ENV{HOME}/.platformio/packages/framework-portduino")
include_directories("/usr/include")
add_custom_target(
Production ALL
COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
Debug ALL
COMMAND platformio -c clion run --target debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_executable(Z_DUMMY_TARGET ${SRC_LIST})

2041
CMakeListsPrivate.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,12 +4,6 @@ set -e
VERSION=`bin/buildinfo.py` VERSION=`bin/buildinfo.py`
# We now only do regionless builds
COUNTRIES=""
#COUNTRIES="US EU433 EU865 CN JP ANZ KR"
#COUNTRIES=US
#COUNTRIES=CN
BOARDS_ESP32="tlora-v2 tlora-v1 tlora-v2-1-1.6 tbeam heltec tbeam0.7" BOARDS_ESP32="tlora-v2 tlora-v1 tlora-v2-1-1.6 tbeam heltec tbeam0.7"
#BOARDS_ESP32=tbeam #BOARDS_ESP32=tbeam
@@ -30,26 +24,17 @@ mkdir -p $OUTDIR/bins/universal $OUTDIR/elfs/universal
# build the named environment and copy the bins to the release directory # build the named environment and copy the bins to the release directory
function do_build() { function do_build() {
BOARD=$1 BOARD=$1
COUNTRY=$2
isNrf=$3 isNrf=$3
echo "Building $COUNTRY for $BOARD with $PLATFORMIO_BUILD_FLAGS" echo "Building for $BOARD with $PLATFORMIO_BUILD_FLAGS"
rm -f .pio/build/$BOARD/firmware.* rm -f .pio/build/$BOARD/firmware.*
# The shell vars the build tool expects to find # The shell vars the build tool expects to find
export APP_VERSION=$VERSION export APP_VERSION=$VERSION
# Are we building a universal/regionless rom? # Are we building a universal/regionless rom?
if [ "x$COUNTRY" != "x" ] export HW_VERSION="1.0"
then basename=universal/firmware-$BOARD-$VERSION
export HW_VERSION="1.0-$COUNTRY"
export COUNTRY
basename=firmware-$BOARD-$COUNTRY-$VERSION
else
export HW_VERSION="1.0"
unset COUNTRY
basename=universal/firmware-$BOARD-$VERSION
fi
pio run --environment $BOARD # -v pio run --environment $BOARD # -v
SRCELF=.pio/build/$BOARD/firmware.elf SRCELF=.pio/build/$BOARD/firmware.elf
@@ -71,10 +56,6 @@ function do_boards() {
declare boards=$1 declare boards=$1
declare isNrf=$2 declare isNrf=$2
for board in $boards; do for board in $boards; do
for country in $COUNTRIES; do
do_build $board $country "$isNrf"
done
# Build universal # Build universal
do_build $board "" "$isNrf" do_build $board "" "$isNrf"
done done

View File

@@ -35,6 +35,8 @@ shift "$((OPTIND-1))"
if [ -f "${FILENAME}" ]; then if [ -f "${FILENAME}" ]; then
echo "Trying to flash update ${FILENAME}." echo "Trying to flash update ${FILENAME}."
esptool.py --baud 921600 write_flash 0x10000 ${FILENAME} esptool.py --baud 921600 write_flash 0x10000 ${FILENAME}
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
esptool.py --baud 921600 erase_region 0xe000 0x2000
else else
echo "Invalid file: ${FILENAME}" echo "Invalid file: ${FILENAME}"
show_help show_help

3
bin/native-gdbserver.sh Executable file
View File

@@ -0,0 +1,3 @@
set -e
pio run --environment native
gdbserver --once localhost:2345 .pio/build/native/program

3
bin/native-run.sh Executable file
View File

@@ -0,0 +1,3 @@
set -e
pio run --environment native
.pio/build/native/program

3
bin/program-1.0-tbeam.sh Executable file
View File

@@ -0,0 +1,3 @@
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-EU865-1.0.0.bin
echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
esptool.py --baud 921600 erase_region 0xe000 0x2000

1
bin/program-1.1-tbeam.sh Executable file
View File

@@ -0,0 +1 @@
esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-1.1.50.bin

11
bin/run-both.sh Executable file
View File

@@ -0,0 +1,11 @@
set -e
pio run
echo uploading to usb1
pio run --upload-port /dev/ttyUSB1 -t upload &
echo uploading to usb0
pio run --upload-port /dev/ttyUSB0 -t upload &
wait

View File

@@ -2,11 +2,30 @@
You probably don't care about this section - skip to the next one. You probably don't care about this section - skip to the next one.
## before next release
* DONE timestamps on oled screen are wrong - don't seem to be updating based on message rx (actually: this is expected behavior when no node on the mesh has GPS time)
* DONE add ch-del
* DONE channel hash suffixes are wrong on android
* DONE before next relase: test empty channel sets on android
* DONE channel sharing in android
* DONE test 1.0 firmware update on android
* DONE test 1.1 firmware update on android
* test 1.2.10 firmware update on android
* DONE test link sharing on android
* luxon bug report - seeing rx acks for nodes that are not on the network
* document how to do remote admin
* release py, android, device
## 1.2 cleanup & multichannel support: ## 1.2 cleanup & multichannel support:
* timestamps on oled screen are wrong - don't seem to be updating based on message rx * DONE cleanup the external notification and serial plugins
* luxon bug report - seeing rx acks for nodes that are not on the network * non ack version of stress test fails sometimes!
* channel hash suffixes are wrong on android
* tx fault test has a bug #734
* DONE move device types into an enum in nodeinfo
* fix android to use new device types for firmware update
* cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later * cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later
* nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger) * nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger)
* DONE call RouterPlugin for *all* packets - not just Router packets * DONE call RouterPlugin for *all* packets - not just Router packets

View File

@@ -17,7 +17,7 @@ default_envs = tbeam
;default_envs = lora-relay-v1 # nrf board ;default_envs = lora-relay-v1 # nrf board
;default_envs = eink ;default_envs = eink
;default_envs = nrf52840dk-geeksville ;default_envs = nrf52840dk-geeksville
;default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here ;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
[common] [common]
; common is not currently used ; common is not currently used
@@ -355,19 +355,20 @@ lib_deps =
TFT_eSPI TFT_eSPI
; The Portduino based sim environment on top of linux ; The Portduino based sim environment on top of linux
[env:linux] [env:native]
platform = https://github.com/geeksville/platform-portduino.git platform = https://github.com/geeksville/platform-native.git
src_filter = ${env.src_filter} -<esp32/> -<nimble/> -<nrf52/> -<mesh/http/> -<plugins/esp32> src_filter = ${env.src_filter} -<esp32/> -<nimble/> -<nrf52/> -<mesh/http/> -<plugins/esp32>
build_flags = ${arduino_base.build_flags} -O0 build_flags = ${arduino_base.build_flags} -O0
framework = arduino framework = arduino
board = linux_x86_64 board = native
lib_deps = lib_deps =
${arduino_base.lib_deps} ${arduino_base.lib_deps}
rweather/Crypto rweather/Crypto
; The GenieBlocks LORA prototype board ; The GenieBlocks LORA prototype board
[env:genieblocks_lora] ; note: @geeksville disabled because genieblocks_lora is not checked into the boards directory, please send in a PR to add it ;-)
extends = esp32_base ;[env:genieblocks_lora]
board = genieblocks_lora ;extends = esp32_base
build_flags = ;board = genieblocks_lora
${esp32_base.build_flags} -D GENIEBLOCKS ;build_flags =
; ${esp32_base.build_flags} -D GENIEBLOCKS

2
proto

Submodule proto updated: bf8ac6718c...b8c0499f28

View File

@@ -163,7 +163,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(TBEAM_V10) #if defined(TBEAM_V10)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tbeam" #define HW_VENDOR HardwareModel_TBEAM
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep // #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
@@ -204,7 +204,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TBEAM_V07) #elif defined(TBEAM_V07)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tbeam0.7" #define HW_VENDOR HardwareModel_TBEAM0p7
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep // #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
@@ -228,7 +228,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) #elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "heltec" #define HW_VENDOR HardwareModel_HELTEC
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine. // the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
// Tested on Neo6m module. // Tested on Neo6m module.
@@ -258,7 +258,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V1) #elif defined(TLORA_V1)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tlora-v1" #define HW_VENDOR HardwareModel_TLORA_V1
#undef GPS_RX_PIN #undef GPS_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
#define GPS_RX_PIN 36 #define GPS_RX_PIN 36
@@ -282,7 +282,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V2) #elif defined(TLORA_V2)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tlora-v2" #define HW_VENDOR HardwareModel_TLORA_V2
#undef GPS_RX_PIN #undef GPS_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@@ -311,7 +311,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V1_3) #elif defined(TLORA_V1_3)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tlora-v1-3" #define HW_VENDOR HardwareModel_TLORA_V1p3
#undef GPS_RX_PIN #undef GPS_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@@ -338,7 +338,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V2_1_16) #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 // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tlora-v2-1-1.6" #define HW_VENDOR HardwareModel_TLORA_V2_1_1p6
#undef GPS_RX_PIN #undef GPS_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@@ -366,7 +366,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(GENIEBLOCKS) #elif defined(GENIEBLOCKS)
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "genieblocks" #define HW_VENDOR HardwareModel_GENIEBLOCKS
#undef GPS_RX_PIN #undef GPS_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
#define GPS_RX_PIN 5 #define GPS_RX_PIN 5
@@ -382,8 +382,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define LED_PIN 12 // If defined we will blink this LED #define LED_PIN 12 // If defined we will blink this LED
//#define BUTTON_PIN 36 // If defined, this will be used for user button presses (ToDo problem on that line on debug screen --> //#define BUTTON_PIN 36 // If defined, this will be used for user button presses (ToDo problem on that line on debug screen -->
//Long press start!) #define BUTTON_NEED_PULLUP //GPIOs 34 to 39 are GPIs input only pins. These pins dont have internal // Long press start!) #define BUTTON_NEED_PULLUP //GPIOs 34 to 39 are GPIs input only pins. These pins dont have internal
//pull-ups or pull-down resistors. // pull-ups or pull-down resistors.
#define USE_RF95 #define USE_RF95
#define LORA_DIO0 38 // a No connect on the SX1262 module #define LORA_DIO0 38 // a No connect on the SX1262 module
@@ -399,7 +399,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef ARDUINO_NRF52840_PCA10056 #ifdef ARDUINO_NRF52840_PCA10056
// This string must exactly match the case used in release file names or the android updater won't work // This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "nrf52dk" #define HW_VENDOR HardwareModel_NRF52840DK
// This board uses 0 to be mean LED on // This board uses 0 to be mean LED on
#undef LED_INVERTED #undef LED_INVERTED
@@ -407,15 +407,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(ARDUINO_NRF52840_PPR) #elif defined(ARDUINO_NRF52840_PPR)
#define HW_VENDOR "ppr" #define HW_VENDOR HardwareModel_PPR
#elif NRF52_SERIES #elif NRF52_SERIES
#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board #define HW_VENDOR HardwareModel_NRF52_UNKNOWN
#elif PORTDUINO #elif PORTDUINO
#define HW_VENDOR "portduino" #define HW_VENDOR HardwareModel_PORTDUINO
#define USE_SIM_RADIO #define USE_SIM_RADIO

View File

@@ -32,6 +32,10 @@
#include "nimble/BluetoothUtil.h" #include "nimble/BluetoothUtil.h"
#endif #endif
#ifdef PORTDUINO
#include "mesh/wifi/WiFiServerAPI.h"
#endif
#include "RF95Interface.h" #include "RF95Interface.h"
#include "SX1262Interface.h" #include "SX1262Interface.h"
@@ -365,7 +369,7 @@ void setup()
#endif #endif
// Hello // Hello
DEBUG_MSG("Meshtastic hwvendor=%s, swver=%s, hwver=%s\n", HW_VENDOR, optstr(APP_VERSION), optstr(HW_VERSION)); DEBUG_MSG("Meshtastic hwvendor=%d, swver=%s, hwver=%s\n", HW_VENDOR, optstr(APP_VERSION), optstr(HW_VERSION));
#ifndef NO_ESP32 #ifndef NO_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
@@ -539,6 +543,10 @@ void setup()
webServerThread = new WebServerThread(); webServerThread = new WebServerThread();
#endif #endif
#ifdef PORTDUINO
initApiServer();
#endif
// Start airtime logger thread. // Start airtime logger thread.
airTime = new AirTime(); airTime = new AirTime();

View File

@@ -10,6 +10,10 @@ static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0
Channels channels; Channels channels;
const char *Channels::adminChannel = "admin";
const char *Channels::gpioChannel = "gpio";
const char *Channels::serialChannel = "serial";
uint8_t xorHash(const uint8_t *p, size_t len) uint8_t xorHash(const uint8_t *p, size_t len)
{ {
uint8_t code = 0; uint8_t code = 0;

View File

@@ -29,6 +29,10 @@ class Channels
int16_t hashes[MAX_NUM_CHANNELS]; int16_t hashes[MAX_NUM_CHANNELS];
public: public:
/// Well known channel names
static const char *adminChannel, *gpioChannel, *serialChannel;
const ChannelSettings &getPrimary() { return getByIndex(getPrimaryIndex()).settings; } const ChannelSettings &getPrimary() { return getByIndex(getPrimaryIndex()).settings; }
/** Return the Channel for a specified index */ /** Return the Channel for a specified index */

View File

@@ -195,6 +195,9 @@ void NodeDB::init()
// keep using that nodenum forever. Crummy guess at our nodenum (but we will check against the nodedb to avoid conflicts) // keep using that nodenum forever. Crummy guess at our nodenum (but we will check against the nodedb to avoid conflicts)
pickNewNodeNum(); pickNewNodeNum();
// Set our board type so we can share it with others
owner.hw_model = HW_VENDOR;
// Include our owner in the node db under our nodenum // Include our owner in the node db under our nodenum
NodeInfo *info = getOrCreateNode(getNodeNum()); NodeInfo *info = getOrCreateNode(getNodeNum());
info->user = owner; info->user = owner;
@@ -223,7 +226,10 @@ 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));
strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
// hw_model is no longer stored in myNodeInfo (as of 1.2.11) - we now store it as an enum in nodeinfo
myNodeInfo.hw_model_deprecated[0] = '\0';
// strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
resetRadioConfig(); // If bogus settings got saved, then fix them resetRadioConfig(); // If bogus settings got saved, then fix them

View File

@@ -14,9 +14,10 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
{ {
if (p->want_ack) { if (p->want_ack) {
// 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 // 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.
if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) if (p->to == NODENUM_BROADCAST && p->hop_limit == 0)
p->hop_limit = 1; p->hop_limit = HOP_RELIABLE;
auto copy = packetPool.allocCopy(*p); auto copy = packetPool.allocCopy(*p);
startRetransmission(copy); startRetransmission(copy);

View File

@@ -25,6 +25,7 @@ typedef struct _AdminMessage {
Channel get_channel_response; Channel get_channel_response;
bool confirm_set_channel; bool confirm_set_channel;
bool confirm_set_radio; bool confirm_set_radio;
bool exit_simulator;
}; };
} AdminMessage; } AdminMessage;
@@ -47,6 +48,7 @@ extern "C" {
#define AdminMessage_get_channel_response_tag 7 #define AdminMessage_get_channel_response_tag 7
#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
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define AdminMessage_FIELDLIST(X, a) \ #define AdminMessage_FIELDLIST(X, a) \
@@ -58,7 +60,8 @@ X(a, STATIC, ONEOF, MESSAGE, (variant,get_radio_response,get_radio_respons
X(a, STATIC, ONEOF, UINT32, (variant,get_channel_request,get_channel_request), 6) \ X(a, STATIC, ONEOF, UINT32, (variant,get_channel_request,get_channel_request), 6) \
X(a, STATIC, ONEOF, MESSAGE, (variant,get_channel_response,get_channel_response), 7) \ X(a, STATIC, ONEOF, MESSAGE, (variant,get_channel_response,get_channel_response), 7) \
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)
#define AdminMessage_CALLBACK NULL #define AdminMessage_CALLBACK NULL
#define AdminMessage_DEFAULT NULL #define AdminMessage_DEFAULT NULL
#define AdminMessage_variant_set_radio_MSGTYPE RadioConfig #define AdminMessage_variant_set_radio_MSGTYPE RadioConfig

View File

@@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define LegacyRadioConfig_size 4 #define LegacyRadioConfig_size 4
#define LegacyRadioConfig_LegacyPreferences_size 2 #define LegacyRadioConfig_LegacyPreferences_size 2
#define DeviceState_size 5056 #define DeviceState_size 4898
#define ChannelFile_size 832 #define ChannelFile_size 832
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -45,3 +45,4 @@ PB_BIND(ToRadio, ToRadio, 2)

View File

@@ -11,6 +11,25 @@
#endif #endif
/* Enum definitions */ /* Enum definitions */
typedef enum _HardwareModel {
HardwareModel_UNSET = 0,
HardwareModel_TLORA_V2 = 1,
HardwareModel_TLORA_V1 = 2,
HardwareModel_TLORA_V2_1_1p6 = 3,
HardwareModel_TBEAM = 4,
HardwareModel_HELTEC = 5,
HardwareModel_TBEAM0p7 = 6,
HardwareModel_T_ECHO = 7,
HardwareModel_TLORA_V1_1p3 = 8,
HardwareModel_LORA_RELAY_V1 = 32,
HardwareModel_NRF52840DK = 33,
HardwareModel_PPR = 34,
HardwareModel_GENIEBLOCKS = 35,
HardwareModel_NRF52_UNKNOWN = 36,
HardwareModel_PORTDUINO = 37,
HardwareModel_ANDROID_SIM = 38
} HardwareModel;
typedef enum _Constants { typedef enum _Constants {
Constants_Unused = 0, Constants_Unused = 0,
Constants_DATA_PAYLOAD_LEN = 240 Constants_DATA_PAYLOAD_LEN = 240
@@ -84,7 +103,7 @@ typedef struct _MyNodeInfo {
bool has_gps; bool has_gps;
uint32_t num_bands; uint32_t num_bands;
char region[12]; char region[12];
char hw_model[16]; char hw_model_deprecated[16];
char firmware_version[12]; char firmware_version[12];
CriticalErrorCode error_code; CriticalErrorCode error_code;
uint32_t error_address; uint32_t error_address;
@@ -112,6 +131,7 @@ typedef struct _User {
char long_name[40]; char long_name[40];
char short_name[5]; char short_name[5];
pb_byte_t macaddr[6]; pb_byte_t macaddr[6];
HardwareModel hw_model;
} User; } User;
typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t;
@@ -138,7 +158,6 @@ typedef struct _NodeInfo {
User user; User user;
bool has_position; bool has_position;
Position position; Position position;
uint32_t next_hop;
float snr; float snr;
} NodeInfo; } NodeInfo;
@@ -174,6 +193,10 @@ typedef struct _ToRadio {
/* Helper constants for enums */ /* Helper constants for enums */
#define _HardwareModel_MIN HardwareModel_UNSET
#define _HardwareModel_MAX HardwareModel_ANDROID_SIM
#define _HardwareModel_ARRAYSIZE ((HardwareModel)(HardwareModel_ANDROID_SIM+1))
#define _Constants_MIN Constants_Unused #define _Constants_MIN Constants_Unused
#define _Constants_MAX Constants_DATA_PAYLOAD_LEN #define _Constants_MAX Constants_DATA_PAYLOAD_LEN
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1)) #define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
@@ -201,23 +224,23 @@ extern "C" {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define Position_init_default {0, 0, 0, 0, 0} #define Position_init_default {0, 0, 0, 0, 0}
#define User_init_default {"", "", "", {0}} #define User_init_default {"", "", "", {0}, _HardwareModel_MIN}
#define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_default {0, {RouteDiscovery_init_default}} #define Routing_init_default {0, {RouteDiscovery_init_default}}
#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0}
#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0}
#define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0} #define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}}
#define ToRadio_init_default {0, {MeshPacket_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}}
#define Position_init_zero {0, 0, 0, 0, 0} #define Position_init_zero {0, 0, 0, 0, 0}
#define User_init_zero {"", "", "", {0}} #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN}
#define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}}
#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0}
#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0}
#define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0} #define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}}
@@ -238,7 +261,7 @@ extern "C" {
#define MyNodeInfo_has_gps_tag 2 #define MyNodeInfo_has_gps_tag 2
#define MyNodeInfo_num_bands_tag 3 #define MyNodeInfo_num_bands_tag 3
#define MyNodeInfo_region_tag 4 #define MyNodeInfo_region_tag 4
#define MyNodeInfo_hw_model_tag 5 #define MyNodeInfo_hw_model_deprecated_tag 5
#define MyNodeInfo_firmware_version_tag 6 #define MyNodeInfo_firmware_version_tag 6
#define MyNodeInfo_error_code_tag 7 #define MyNodeInfo_error_code_tag 7
#define MyNodeInfo_error_address_tag 8 #define MyNodeInfo_error_address_tag 8
@@ -256,6 +279,7 @@ extern "C" {
#define User_long_name_tag 2 #define User_long_name_tag 2
#define User_short_name_tag 3 #define User_short_name_tag 3
#define User_macaddr_tag 4 #define User_macaddr_tag 4
#define User_hw_model_tag 6
#define MeshPacket_from_tag 1 #define MeshPacket_from_tag 1
#define MeshPacket_to_tag 2 #define MeshPacket_to_tag 2
#define MeshPacket_channel_tag 3 #define MeshPacket_channel_tag 3
@@ -270,7 +294,6 @@ extern "C" {
#define NodeInfo_num_tag 1 #define NodeInfo_num_tag 1
#define NodeInfo_user_tag 2 #define NodeInfo_user_tag 2
#define NodeInfo_position_tag 3 #define NodeInfo_position_tag 3
#define NodeInfo_next_hop_tag 5
#define NodeInfo_snr_tag 7 #define NodeInfo_snr_tag 7
#define Routing_route_request_tag 1 #define Routing_route_request_tag 1
#define Routing_route_reply_tag 2 #define Routing_route_reply_tag 2
@@ -299,7 +322,8 @@ X(a, STATIC, SINGULAR, FIXED32, time, 9)
X(a, STATIC, SINGULAR, STRING, id, 1) \ X(a, STATIC, SINGULAR, STRING, id, 1) \
X(a, STATIC, SINGULAR, STRING, long_name, 2) \ X(a, STATIC, SINGULAR, STRING, long_name, 2) \
X(a, STATIC, SINGULAR, STRING, short_name, 3) \ X(a, STATIC, SINGULAR, STRING, short_name, 3) \
X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) \
X(a, STATIC, SINGULAR, UENUM, hw_model, 6)
#define User_CALLBACK NULL #define User_CALLBACK NULL
#define User_DEFAULT NULL #define User_DEFAULT NULL
@@ -347,7 +371,6 @@ X(a, STATIC, SINGULAR, UENUM, priority, 12)
X(a, STATIC, SINGULAR, UINT32, num, 1) \ X(a, STATIC, SINGULAR, UINT32, num, 1) \
X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \
X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \ X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \
X(a, STATIC, SINGULAR, UINT32, next_hop, 5) \
X(a, STATIC, SINGULAR, FLOAT, snr, 7) X(a, STATIC, SINGULAR, FLOAT, snr, 7)
#define NodeInfo_CALLBACK NULL #define NodeInfo_CALLBACK NULL
#define NodeInfo_DEFAULT NULL #define NodeInfo_DEFAULT NULL
@@ -359,7 +382,7 @@ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \
X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \ X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \
X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \ X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \
X(a, STATIC, SINGULAR, STRING, region, 4) \ X(a, STATIC, SINGULAR, STRING, region, 4) \
X(a, STATIC, SINGULAR, STRING, hw_model, 5) \ X(a, STATIC, SINGULAR, STRING, hw_model_deprecated, 5) \
X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \ X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \
X(a, STATIC, SINGULAR, UENUM, error_code, 7) \ X(a, STATIC, SINGULAR, UENUM, error_code, 7) \
X(a, STATIC, SINGULAR, UINT32, error_address, 8) \ X(a, STATIC, SINGULAR, UINT32, error_address, 8) \
@@ -427,12 +450,12 @@ extern const pb_msgdesc_t ToRadio_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define Position_size 37 #define Position_size 37
#define User_size 72 #define User_size 74
#define RouteDiscovery_size 40 #define RouteDiscovery_size 40
#define Routing_size 42 #define Routing_size 42
#define Data_size 260 #define Data_size 260
#define MeshPacket_size 298 #define MeshPacket_size 298
#define NodeInfo_size 130 #define NodeInfo_size 126
#define MyNodeInfo_size 89 #define MyNodeInfo_size 89
#define LogRecord_size 81 #define LogRecord_size 81
#define FromRadio_size 307 #define FromRadio_size 307

View File

@@ -14,8 +14,6 @@ static void WiFiEvent(WiFiEvent_t event);
// DNS Server for the Captive Portal // DNS Server for the Captive Portal
DNSServer dnsServer; DNSServer dnsServer;
static WiFiServerPort *apiPort;
uint8_t wifiDisconnectReason = 0; uint8_t wifiDisconnectReason = 0;
// Stores our hostname // Stores our hostname
@@ -180,14 +178,7 @@ void initWifi(bool forceSoftAP)
DEBUG_MSG("Not using WIFI\n"); DEBUG_MSG("Not using WIFI\n");
} }
static void initApiServer()
{
// Start API server on port 4403
if (!apiPort) {
apiPort = new WiFiServerPort();
apiPort->init();
}
}
// Called by the Espressif SDK to // Called by the Espressif SDK to
static void WiFiEvent(WiFiEvent_t event) static void WiFiEvent(WiFiEvent_t event)

View File

@@ -3,6 +3,17 @@
#include "configuration.h" #include "configuration.h"
#include <Arduino.h> #include <Arduino.h>
static WiFiServerPort *apiPort;
void initApiServer()
{
// Start API server on port 4403
if (!apiPort) {
apiPort = new WiFiServerPort();
apiPort->init();
}
}
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : StreamAPI(&client), client(_client) WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : StreamAPI(&client), client(_client)
{ {
DEBUG_MSG("Incoming wifi connection\n"); DEBUG_MSG("Incoming wifi connection\n");
@@ -50,7 +61,7 @@ WiFiServerPort::WiFiServerPort() : WiFiServer(MESHTASTIC_PORTNUM), concurrency::
void WiFiServerPort::init() void WiFiServerPort::init()
{ {
DEBUG_MSG("API server sistening on TCP port %d\n", MESHTASTIC_PORTNUM); DEBUG_MSG("API server listening on TCP port %d\n", MESHTASTIC_PORTNUM);
begin(); begin();
} }

View File

@@ -48,3 +48,5 @@ class WiFiServerPort : public WiFiServer, private concurrency::OSThread
int32_t runOnce(); int32_t runOnce();
}; };
void initApiServer();

View File

@@ -224,7 +224,8 @@ void NRF52Bluetooth::setup()
// Configure and Start the Device Information Service // Configure and Start the Device Information Service
DEBUG_MSG("Configuring the Device Information Service\n"); DEBUG_MSG("Configuring the Device Information Service\n");
bledis.setManufacturer(HW_VENDOR); // FIXME, we should set a mfg string based on our HW_VENDOR enum
// bledis.setManufacturer(HW_VENDOR);
bledis.setModel(optstr(HW_VERSION)); bledis.setModel(optstr(HW_VERSION));
bledis.setFirmwareRev(optstr(APP_VERSION)); bledis.setFirmwareRev(optstr(APP_VERSION));
bledis.begin(); bledis.begin();

View File

@@ -6,6 +6,10 @@
#include "configuration.h" #include "configuration.h"
#include "main.h" #include "main.h"
#ifdef PORTDUINO
#include "unistd.h"
#endif
AdminPlugin *adminPlugin; AdminPlugin *adminPlugin;
void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
@@ -51,7 +55,7 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, const AdminMessag
break; break;
case AdminMessage_set_channel_tag: case AdminMessage_set_channel_tag:
DEBUG_MSG("Client is setting channel\n"); DEBUG_MSG("Client is setting channel %d\n", r->set_channel.index);
handleSetChannel(r->set_channel); handleSetChannel(r->set_channel);
break; break;
@@ -65,6 +69,13 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, const AdminMessag
handleGetRadio(mp); handleGetRadio(mp);
break; break;
#ifdef PORTDUINO
case AdminMessage_exit_simulator_tag:
DEBUG_MSG("Exiting simulator\n");
_exit(0);
break;
#endif
default: default:
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages // Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant); DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant);
@@ -102,8 +113,7 @@ void AdminPlugin::handleSetChannel(const Channel &cc)
if (cc.index == 0) { if (cc.index == 0) {
// FIXME, this updates the user preferences also, which isn't needed - we really just want to notify on configChanged // FIXME, this updates the user preferences also, which isn't needed - we really just want to notify on configChanged
service.reloadConfig(); service.reloadConfig();
} } else {
else {
channels.onConfigChanged(); // tell the radios about this change channels.onConfigChanged(); // tell the radios about this change
nodeDB.saveChannelsToDisk(); nodeDB.saveChannelsToDisk();
} }
@@ -126,5 +136,5 @@ MeshPacket *AdminPlugin::allocReply()
AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields) AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
{ {
// restrict to the admin channel for rx // restrict to the admin channel for rx
boundChannel = "admin"; boundChannel = Channels::adminChannel;
} }

View File

@@ -43,25 +43,17 @@
*/ */
// Default configurations // Default configurations
#define EXT_NOTIFICATION_PLUGIN_OUTPUT 13 #define EXT_NOTIFICATION_PLUGIN_OUTPUT 13
#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000 #define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000
#define ASCII_BELL 0x07 #define ASCII_BELL 0x07
ExternalNotificationPlugin *externalNotificationPlugin;
ExternalNotificationPluginRadio *externalNotificationPluginRadio;
ExternalNotificationPlugin::ExternalNotificationPlugin() : concurrency::OSThread("ExternalNotificationPlugin") {}
bool externalCurrentState = 0; bool externalCurrentState = 0;
uint32_t externalTurnedOn = 0; uint32_t externalTurnedOn = 0;
int32_t ExternalNotificationPlugin::runOnce() int32_t ExternalNotificationPlugin::runOnce()
{ {
#ifndef NO_ESP32
/* /*
Uncomment the preferences below if you want to use the plugin Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
@@ -75,48 +67,19 @@ int32_t ExternalNotificationPlugin::runOnce()
// radioConfig.preferences.ext_notification_plugin_output_ms = 1000; // radioConfig.preferences.ext_notification_plugin_output_ms = 1000;
// radioConfig.preferences.ext_notification_plugin_output = 13; // radioConfig.preferences.ext_notification_plugin_output = 13;
if (radioConfig.preferences.ext_notification_plugin_enabled) { if (externalCurrentState) {
if (firstTime) { // If the output is turned on, turn it back off after the given period of time.
if (externalTurnedOn + (radioConfig.preferences.ext_notification_plugin_output_ms
DEBUG_MSG("Initializing External Notification Plugin\n"); ? radioConfig.preferences.ext_notification_plugin_output_ms
: EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) <
// Set the direction of a pin millis()) {
pinMode((radioConfig.preferences.ext_notification_plugin_output DEBUG_MSG("Turning off external notification\n");
? radioConfig.preferences.ext_notification_plugin_output
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
OUTPUT);
// Turn off the pin
setExternalOff(); setExternalOff();
externalNotificationPluginRadio = new ExternalNotificationPluginRadio();
firstTime = 0;
} else {
if (externalCurrentState) {
// If the output is turned on, turn it back off after the given period of time.
if (externalTurnedOn + (radioConfig.preferences.ext_notification_plugin_output_ms
? radioConfig.preferences.ext_notification_plugin_output_ms
: EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) <
millis()) {
DEBUG_MSG("Turning off external notification\n");
setExternalOff();
}
}
} }
return (25);
} else {
DEBUG_MSG("External Notification Plugin Disabled\n");
return (INT32_MAX);
} }
#else
return INT32_MAX; return (25);
#endif
} }
void ExternalNotificationPlugin::setExternalOn() void ExternalNotificationPlugin::setExternalOn()
@@ -140,7 +103,47 @@ void ExternalNotificationPlugin::setExternalOff()
// -------- // --------
bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp) ExternalNotificationPlugin::ExternalNotificationPlugin()
: SinglePortPlugin("ExternalNotificationPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
"ExternalNotificationPlugin")
{
// restrict to the admin channel for rx
boundChannel = Channels::gpioChannel;
#ifndef NO_ESP32
/*
Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI.
*/
// radioConfig.preferences.ext_notification_plugin_enabled = 1;
// radioConfig.preferences.ext_notification_plugin_alert_message = 1;
// radioConfig.preferences.ext_notification_plugin_active = 1;
// radioConfig.preferences.ext_notification_plugin_alert_bell = 1;
// radioConfig.preferences.ext_notification_plugin_output_ms = 1000;
// radioConfig.preferences.ext_notification_plugin_output = 13;
if (radioConfig.preferences.ext_notification_plugin_enabled) {
DEBUG_MSG("Initializing External Notification Plugin\n");
// Set the direction of a pin
pinMode((radioConfig.preferences.ext_notification_plugin_output ? radioConfig.preferences.ext_notification_plugin_output
: EXT_NOTIFICATION_PLUGIN_OUTPUT),
OUTPUT);
// Turn off the pin
setExternalOff();
} else {
DEBUG_MSG("External Notification Plugin Disabled\n");
enabled = false;
}
#endif
}
bool ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
@@ -156,14 +159,14 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
DEBUG_MSG("externalNotificationPlugin - Notification Bell\n"); DEBUG_MSG("externalNotificationPlugin - Notification Bell\n");
for (int i = 0; i < p.payload.size; i++) { for (int i = 0; i < p.payload.size; i++) {
if (p.payload.bytes[i] == ASCII_BELL) { if (p.payload.bytes[i] == ASCII_BELL) {
externalNotificationPlugin->setExternalOn(); setExternalOn();
} }
} }
} }
if (radioConfig.preferences.ext_notification_plugin_alert_message) { if (radioConfig.preferences.ext_notification_plugin_alert_message) {
DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n"); DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n");
externalNotificationPlugin->setExternalOn(); setExternalOn();
} }
} }

View File

@@ -6,11 +6,12 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
/*
class ExternalNotificationPlugin : private concurrency::OSThread * Radio interface for ExternalNotificationPlugin
*
*/
class ExternalNotificationPlugin : public SinglePortPlugin, private concurrency::OSThread
{ {
bool firstTime = 1;
public: public:
ExternalNotificationPlugin(); ExternalNotificationPlugin();
@@ -19,29 +20,13 @@ class ExternalNotificationPlugin : private concurrency::OSThread
void getExternal(); void getExternal();
protected: protected:
virtual int32_t runOnce(); // virtual MeshPacket *allocReply();
};
extern ExternalNotificationPlugin *externalNotificationPlugin;
/*
* Radio interface for ExternalNotificationPlugin
*
*/
class ExternalNotificationPluginRadio : public SinglePortPlugin
{
public:
ExternalNotificationPluginRadio() : SinglePortPlugin("ExternalNotificationPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
protected:
//virtual MeshPacket *allocReply();
/** Called to handle a particular incoming message /** Called to handle a particular incoming message
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it @return true if you've guaranteed you've handled this message and no other handlers should be considered for it
*/ */
virtual bool handleReceived(const MeshPacket &mp); virtual bool handleReceived(const MeshPacket &mp);
};
extern ExternalNotificationPluginRadio *externalNotificationPluginRadio; virtual int32_t runOnce();
};

View File

@@ -69,7 +69,8 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H
case HardwareMessage_Type_READ_GPIOS: { case HardwareMessage_Type_READ_GPIOS: {
// Print notification to LCD screen // Print notification to LCD screen
screen->print("Read GPIOs\n"); if(screen)
screen->print("Read GPIOs\n");
uint64_t res = digitalReads(p.gpio_mask); uint64_t res = digitalReads(p.gpio_mask);

View File

@@ -61,6 +61,12 @@ SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {}
char serialStringChar[Constants_DATA_PAYLOAD_LEN]; char serialStringChar[Constants_DATA_PAYLOAD_LEN];
SerialPluginRadio::SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP)
{
// restrict to the admin channel for rx
boundChannel = Channels::serialChannel;
}
int32_t SerialPlugin::runOnce() int32_t SerialPlugin::runOnce()
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32

View File

@@ -33,8 +33,7 @@ class SerialPluginRadio : public SinglePortPlugin
from the main code. from the main code.
*/ */
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} SerialPluginRadio();
SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {}
/** /**
* Send our payload into the mesh * Send our payload into the mesh

View File

@@ -8,89 +8,36 @@
#include <Arduino.h> #include <Arduino.h>
#include <map> #include <map>
#define STOREFORWARD_MAX_PACKETS 7500 #define STOREFORWARD_MAX_PACKETS 0
#define STOREFORWARD_SEND_HISTORY_SHORT 600 #define STOREFORWARD_SEND_HISTORY_SHORT 600
StoreForwardPlugin *storeForwardPlugin; StoreForwardPlugin *storeForwardPlugin;
StoreForwardPluginRadio *storeForwardPluginRadio;
StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("StoreForwardPlugin") {}
int32_t StoreForwardPlugin::runOnce() int32_t StoreForwardPlugin::runOnce()
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
/*
Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI.
attn @mc-hamster I moved this back inside the comment because I don't think it was intended to checkin. It was forcing all
nodes to be running this and turning off is_router.
radioConfig.preferences.store_forward_plugin_enabled = 1;
radioConfig.preferences.is_router = 0;
*/
if (radioConfig.preferences.store_forward_plugin_enabled) { if (radioConfig.preferences.store_forward_plugin_enabled) {
if (firstTime) { if (radioConfig.preferences.is_router) {
// Maybe some cleanup functions?
firstTime = 0; this->sawNodeReport();
this->historyReport();
if (radioConfig.preferences.is_router) { return (10 * 1000);
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n");
// Router
if (ESP.getPsramSize()) {
if (ESP.getFreePsram() >= 2048 * 1024) {
// Do the startup here
storeForwardPluginRadio = new StoreForwardPluginRadio();
this->populatePSRAM();
// packetHistory[0].bytes;
return (10 * 1000);
} else {
DEBUG_MSG("Device has less than 2M of PSRAM free. Aborting startup.\n");
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
return (INT32_MAX);
}
} else {
DEBUG_MSG("Device doesn't have PSRAM.\n");
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
return (INT32_MAX);
}
} else {
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n");
return (5 * 1000);
}
} else { } else {
/*
* If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every
* few minutes.
*
* This behavior is expected to change. It's only here until we come up with something better.
*/
if (radioConfig.preferences.is_router) { DEBUG_MSG("Store & Forward Plugin - Sending heartbeat\n");
// Maybe some cleanup functions?
this->sawNodeReport();
this->historyReport();
return (10 * 1000);
} else {
/*
* If the plugin is turned on and is_router is not enabled, then we'll send a heartbeat every
* few minutes.
*/
DEBUG_MSG("Store & Forward Plugin - Sending heartbeat\n"); storeForwardPlugin->sendPayload();
// storeForwardPluginRadio->sendPayloadHeartbeat(); return (4 * 60 * 1000);
if(storeForwardPluginRadio)
storeForwardPluginRadio->sendPayload();
return (1 * 60 * 1000);
}
} }
} else { } else {
@@ -110,24 +57,29 @@ void StoreForwardPlugin::populatePSRAM()
https://learn.upesy.com/en/programmation/psram.html#psram-tab https://learn.upesy.com/en/programmation/psram.html#psram-tab
*/ */
DEBUG_MSG("Before PSRAM initilization\n"); DEBUG_MSG("Before PSRAM initilization:\n");
DEBUG_MSG("Total heap: %d\n", ESP.getHeapSize()); DEBUG_MSG(" Total heap: %d\n", ESP.getHeapSize());
DEBUG_MSG("Free heap: %d\n", ESP.getFreeHeap()); DEBUG_MSG(" Free heap: %d\n", ESP.getFreeHeap());
DEBUG_MSG("Total PSRAM: %d\n", ESP.getPsramSize()); DEBUG_MSG(" Total PSRAM: %d\n", ESP.getPsramSize());
DEBUG_MSG("Free PSRAM: %d\n", ESP.getFreePsram()); DEBUG_MSG(" Free PSRAM: %d\n", ESP.getFreePsram());
// PacketHistoryStruct *packetHistory = (PacketHistoryStruct *)ps_calloc(STOREFORWARD_MAX_PACKETS, // PacketHistoryStruct *packetHistory = (PacketHistoryStruct *)ps_calloc(STOREFORWARD_MAX_PACKETS,
// sizeof(PacketHistoryStruct)); // sizeof(PacketHistoryStruct));
this->packetHistory = (PacketHistoryStruct *)ps_calloc(STOREFORWARD_MAX_PACKETS, sizeof(PacketHistoryStruct));
DEBUG_MSG("After PSRAM initilization\n");
DEBUG_MSG("Total heap: %d\n", ESP.getHeapSize()); // Use a maximum of half the available PSRAM unless otherwise specified.
DEBUG_MSG("Free heap: %d\n", ESP.getFreeHeap()); uint32_t numberOfPackets =
DEBUG_MSG("Total PSRAM: %d\n", ESP.getPsramSize()); STOREFORWARD_MAX_PACKETS ? STOREFORWARD_MAX_PACKETS : ((ESP.getPsramSize() / 2) / sizeof(PacketHistoryStruct));
DEBUG_MSG("Free PSRAM: %d\n", ESP.getFreePsram());
DEBUG_MSG("packetHistory Size - %u", sizeof(packetHistory)); this->packetHistory = (PacketHistoryStruct *)ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct));
DEBUG_MSG("After PSRAM initilization:\n");
DEBUG_MSG(" Total heap: %d\n", ESP.getHeapSize());
DEBUG_MSG(" Free heap: %d\n", ESP.getFreeHeap());
DEBUG_MSG(" Total PSRAM: %d\n", ESP.getPsramSize());
DEBUG_MSG(" Free PSRAM: %d\n", ESP.getFreePsram());
DEBUG_MSG("Store and Forward Stats:\n");
DEBUG_MSG(" numberOfPackets - %u\n", numberOfPackets);
} }
// We saw a node. // We saw a node.
@@ -228,41 +180,32 @@ void StoreForwardPlugin::sawNodeReport()
} }
} }
MeshPacket *StoreForwardPluginRadio::allocReply() MeshPacket *StoreForwardPlugin::allocReply()
{ {
auto reply = allocDataPacket(); // Allocate a packet for sending auto reply = allocDataPacket(); // Allocate a packet for sending
return reply; // attn @mc-hamster this code was commented out and was causing memory corruption return reply;
} }
void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) void StoreForwardPlugin::sendPayload(NodeNum dest, bool wantReplies)
{ {
/* DEBUG_MSG("Sending S&F Payload\n");
MeshPacket *p = this->allocReply(); // attn @mc-hamster, I moved inside the commented block to prevent leaking memory MeshPacket *p = allocReply();
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
p->want_ack = true; p->want_ack = true;
*/ /*
// static char heartbeatString[20]; */
// snprintf(heartbeatString, sizeof(heartbeatString), "1"); static char heartbeatString[20];
snprintf(heartbeatString, sizeof(heartbeatString), "1");
// p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply p->decoded.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply
// memcpy(p->decoded.data.payload.bytes, "1", 1); memcpy(p->decoded.payload.bytes, "1", 1);
// service.sendToMesh(p);
}
void StoreForwardPluginRadio::sendPayloadHeartbeat(NodeNum dest, bool wantReplies)
{
DEBUG_MSG("Sending S&F Heartbeat\n");
MeshPacket *p = this->allocReply();
p->to = dest;
p->decoded.want_response = wantReplies;
service.sendToMesh(p); service.sendToMesh(p);
} }
bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) bool StoreForwardPlugin::handleReceived(const MeshPacket &mp)
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
if (radioConfig.preferences.store_forward_plugin_enabled) { if (radioConfig.preferences.store_forward_plugin_enabled) {
@@ -274,7 +217,7 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
printPacket("----- PACKET FROM RADIO -----", &mp); printPacket("----- PACKET FROM RADIO -----", &mp);
uint32_t sawTime = storeForwardPlugin->sawNode(getFrom(&mp) & 0xffffffff); uint32_t sawTime = storeForwardPlugin->sawNode(getFrom(&mp) & 0xffffffff);
DEBUG_MSG("We last saw this node (%u), %u sec ago\n", mp.from & 0xffffffff, (millis() - sawTime) / 1000); DEBUG_MSG("We last saw this node (%u), %u sec ago\n", mp.from & 0xffffffff, (millis() - sawTime) / 1000);
DEBUG_MSG(" -------------- ");
if (mp.decoded.portnum == PortNum_UNKNOWN_APP) { if (mp.decoded.portnum == PortNum_UNKNOWN_APP) {
DEBUG_MSG("Packet came from - PortNum_UNKNOWN_APP\n"); DEBUG_MSG("Packet came from - PortNum_UNKNOWN_APP\n");
} else if (mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) { } else if (mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) {
@@ -322,3 +265,52 @@ bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp)
return true; // Let others look at this message also if they want return true; // Let others look at this message also if they want
} }
StoreForwardPlugin::StoreForwardPlugin()
: SinglePortPlugin("StoreForwardPlugin", PortNum_STORE_FORWARD_APP), concurrency::OSThread("StoreForwardPlugin")
{
#ifndef NO_ESP32
/*
Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI.
radioConfig.preferences.store_forward_plugin_enabled = 1;
radioConfig.preferences.is_router = 1;
*/
if (radioConfig.preferences.store_forward_plugin_enabled) {
if (radioConfig.preferences.is_router) {
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n");
// Router
if (ESP.getPsramSize()) {
if (ESP.getFreePsram() >= 2048 * 1024) {
// Do the startup here
this->populatePSRAM();
// packetHistory[0].bytes;
// return (10 * 1000);
} else {
DEBUG_MSG("Device has less than 2M of PSRAM free. Aborting startup.\n");
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
// return (INT32_MAX);
}
} else {
DEBUG_MSG("Device doesn't have PSRAM.\n");
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
// return (INT32_MAX);
}
} else {
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n");
// return (5 * 1000);
}
}
#endif
}

View File

@@ -6,7 +6,6 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
struct PacketHistoryStruct { struct PacketHistoryStruct {
uint32_t time; uint32_t time;
uint32_t to; uint32_t to;
@@ -14,7 +13,7 @@ struct PacketHistoryStruct {
uint8_t bytes[MAX_RHPACKETLEN]; uint8_t bytes[MAX_RHPACKETLEN];
}; };
class StoreForwardPlugin : private concurrency::OSThread class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThread
{ {
bool firstTime = 1; bool firstTime = 1;
@@ -37,41 +36,18 @@ class StoreForwardPlugin : private concurrency::OSThread
void historySend(uint32_t msAgo, uint32_t to); void historySend(uint32_t msAgo, uint32_t to);
void populatePSRAM(); void populatePSRAM();
/**
* Send our payload into the mesh
*/
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
virtual MeshPacket *allocReply();
virtual bool wantPortnum(PortNum p) { return true; };
private: private:
// Nothing here // Nothing here
protected: protected:
virtual int32_t runOnce(); virtual int32_t runOnce();
};
extern StoreForwardPlugin *storeForwardPlugin;
/*
* Radio interface for StoreForwardPlugin
*
*/
class StoreForwardPluginRadio : public SinglePortPlugin
{
// uint32_t lastRxID;
public:
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
// StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
/**
* Send our payload into the mesh
*/
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
/**
* Send our payload into the mesh
*/
void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
protected:
virtual MeshPacket *allocReply();
virtual bool wantPortnum(PortNum p) { return true; };
/** Called to handle a particular incoming message /** Called to handle a particular incoming message
@@ -80,4 +56,28 @@ class StoreForwardPluginRadio : public SinglePortPlugin
virtual bool handleReceived(const MeshPacket &mp); virtual bool handleReceived(const MeshPacket &mp);
}; };
extern StoreForwardPlugin *storeForwardPlugin;
/*
* Radio interface for StoreForwardPlugin
*
*/
/*
class StoreForwardPluginRadio : public SinglePortPlugin
{
// uint32_t lastRxID;
public:
StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_STORE_FORWARD_APP) {}
// StoreForwardPluginRadio() : SinglePortPlugin("StoreForwardPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
void sendPayloadHeartbeat(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
protected:
virtual MeshPacket *allocReply2();
};
extern StoreForwardPluginRadio *storeForwardPluginRadio; extern StoreForwardPluginRadio *storeForwardPluginRadio;
*/

View File

@@ -28,7 +28,7 @@ void getMacAddr(uint8_t *dmac)
void setBluetoothEnable(bool on) void setBluetoothEnable(bool on)
{ {
notImplemented("setBluetoothEnable"); // not needed
} }
void cpuDeepSleep(uint64_t msecs) { void cpuDeepSleep(uint64_t msecs) {
@@ -88,7 +88,10 @@ public:
*/ */
void portduinoSetup() { void portduinoSetup() {
printf("Setting up Meshtastic on Porduino...\n"); printf("Setting up Meshtastic on Porduino...\n");
gpioBind(new R595PolledIrqPin());
// FIXME: disable while not testing with real hardware
// gpioBind(new R595PolledIrqPin());
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET"))); // gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent()); // gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
} }

View File

@@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 1 major = 1
minor = 2 minor = 2
build = 10 build = 11