mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 01:52:04 +00:00
Merge branch 'master' into eink-special-frames
This commit is contained in:
commit
4b4bd07d5c
1
.github/workflows/build_esp32.yml
vendored
1
.github/workflows/build_esp32.yml
vendored
@ -35,6 +35,7 @@ jobs:
|
|||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
||||||
|
|
||||||
- name: Build ESP32
|
- name: Build ESP32
|
||||||
run: bin/build-esp32.sh ${{ inputs.board }}
|
run: bin/build-esp32.sh ${{ inputs.board }}
|
||||||
|
62
.github/workflows/build_esp32_c3.yml
vendored
Normal file
62
.github/workflows/build_esp32_c3.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Build ESP32-C3
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
board:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-esp32-c3:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build base
|
||||||
|
id: base
|
||||||
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
|
- name: Pull web ui
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4
|
||||||
|
with:
|
||||||
|
repo: meshtastic/web
|
||||||
|
file: build.tar
|
||||||
|
target: build.tar
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Unpack web ui
|
||||||
|
run: |
|
||||||
|
tar -xf build.tar -C data/static
|
||||||
|
rm build.tar
|
||||||
|
- name: Remove debug flags for release
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
run: |
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
||||||
|
- name: Build ESP32
|
||||||
|
run: bin/build-esp32.sh ${{ inputs.board }}
|
||||||
|
|
||||||
|
- name: Pull OTA Firmware
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4
|
||||||
|
with:
|
||||||
|
repo: meshtastic/firmware-ota
|
||||||
|
file: firmware-c3.bin
|
||||||
|
target: release/bleota-c3.bin
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
shell: bash
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
||||||
|
path: |
|
||||||
|
release/*.bin
|
||||||
|
release/*.elf
|
1
.github/workflows/build_esp32_s3.yml
vendored
1
.github/workflows/build_esp32_s3.yml
vendored
@ -34,6 +34,7 @@ jobs:
|
|||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
|
||||||
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
|
||||||
|
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32c3.ini
|
||||||
- name: Build ESP32
|
- name: Build ESP32
|
||||||
run: bin/build-esp32.sh ${{ inputs.board }}
|
run: bin/build-esp32.sh ${{ inputs.board }}
|
||||||
|
|
||||||
|
14
.github/workflows/main_matrix.yml
vendored
14
.github/workflows/main_matrix.yml
vendored
@ -67,7 +67,6 @@ jobs:
|
|||||||
- board: tlora-v2-1-1_6-tcxo
|
- board: tlora-v2-1-1_6-tcxo
|
||||||
- board: tlora-v2-1-1_8
|
- board: tlora-v2-1-1_8
|
||||||
- board: tbeam
|
- board: tbeam
|
||||||
- board: heltec-ht62-esp32c3-sx1262
|
|
||||||
- board: heltec-v2_0
|
- board: heltec-v2_0
|
||||||
- board: heltec-v2_1
|
- board: heltec-v2_1
|
||||||
- board: tbeam0_7
|
- board: tbeam0_7
|
||||||
@ -105,6 +104,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
board: ${{ matrix.board }}
|
board: ${{ matrix.board }}
|
||||||
|
|
||||||
|
build-esp32-c3:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- board: heltec-ht62-esp32c3-sx1262
|
||||||
|
uses: ./.github/workflows/build_esp32_c3.yml
|
||||||
|
with:
|
||||||
|
board: ${{ matrix.board }}
|
||||||
|
|
||||||
build-nrf52:
|
build-nrf52:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -226,6 +235,7 @@ jobs:
|
|||||||
[
|
[
|
||||||
build-esp32,
|
build-esp32,
|
||||||
build-esp32-s3,
|
build-esp32-s3,
|
||||||
|
build-esp32-c3,
|
||||||
build-nrf52,
|
build-nrf52,
|
||||||
build-raspbian,
|
build-raspbian,
|
||||||
build-native,
|
build-native,
|
||||||
@ -251,7 +261,7 @@ jobs:
|
|||||||
id: version
|
id: version
|
||||||
|
|
||||||
- name: Move files up
|
- name: Move files up
|
||||||
run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./*tbeam-s3*/bleota-s3.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase_v2.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat ./firmware-raspbian-*/release/meshtasticd_linux_aarch64 ./firmware-raspbian-*/bin/config-dist.yaml
|
run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./*tbeam-s3*/bleota-s3.bin ./*esp32c3*/bleota-c3.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase_v2.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat ./firmware-raspbian-*/release/meshtasticd_linux_aarch64 ./firmware-raspbian-*/bin/config-dist.yaml
|
||||||
|
|
||||||
- name: Repackage in single firmware zip
|
- name: Repackage in single firmware zip
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
@ -31,9 +31,13 @@ IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% (
|
|||||||
%PYTHON% -m esptool --baud 115200 erase_flash
|
%PYTHON% -m esptool --baud 115200 erase_flash
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME%
|
%PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME%
|
||||||
|
|
||||||
@REM Account for S3 board's different OTA partition
|
@REM Account for S3 and C3 board's different OTA partition
|
||||||
IF x%FILENAME:s3=%==x%FILENAME% IF x%FILENAME:v3=%==x%FILENAME% IF x%FILENAME:t-deck=%==x%FILENAME% IF x%FILENAME:wireless-paper=%==x%FILENAME% IF x%FILENAME:wireless-tracker=%==x%FILENAME% (
|
IF x%FILENAME:s3=%==x%FILENAME% IF x%FILENAME:v3=%==x%FILENAME% IF x%FILENAME:t-deck=%==x%FILENAME% IF x%FILENAME:wireless-paper=%==x%FILENAME% IF x%FILENAME:wireless-tracker=%==x%FILENAME% (
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota.bin
|
IF x%FILENAME:esp32c3=%==x%FILENAME% (
|
||||||
|
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota.bin
|
||||||
|
) else (
|
||||||
|
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota-c3.bin
|
||||||
|
)
|
||||||
) else (
|
) else (
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota-s3.bin
|
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota-s3.bin
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PYTHON=${PYTHON:-$(which python3 python|head -n 1)}
|
PYTHON=${PYTHON:-$(which python3 python | head -n 1)}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Usage info
|
# Usage info
|
||||||
show_help() {
|
show_help() {
|
||||||
cat << EOF
|
cat <<EOF
|
||||||
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME]
|
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME]
|
||||||
Flash image file to device, but first erasing and writing system information"
|
Flash image file to device, but first erasing and writing system information"
|
||||||
|
|
||||||
@ -18,44 +18,50 @@ Flash image file to device, but first erasing and writing system information"
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while getopts ":hp:P:f:" opt; do
|
while getopts ":hp:P:f:" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
h)
|
h)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
p) export ESPTOOL_PORT=${OPTARG}
|
p)
|
||||||
;;
|
export ESPTOOL_PORT=${OPTARG}
|
||||||
P) PYTHON=${OPTARG}
|
;;
|
||||||
;;
|
P)
|
||||||
f) FILENAME=${OPTARG}
|
PYTHON=${OPTARG}
|
||||||
;;
|
;;
|
||||||
*)
|
f)
|
||||||
echo "Invalid flag."
|
FILENAME=${OPTARG}
|
||||||
show_help >&2
|
;;
|
||||||
exit 1
|
*)
|
||||||
;;
|
echo "Invalid flag."
|
||||||
esac
|
show_help >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND - 1))"
|
||||||
|
|
||||||
[ -z "$FILENAME" -a -n "$1" ] && {
|
[ -z "$FILENAME" -a -n "$1" ] && {
|
||||||
FILENAME=$1
|
FILENAME=$1
|
||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ] && [ ! -z "${FILENAME##*"update"*}" ]; then
|
if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
||||||
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
||||||
"$PYTHON" -m esptool erase_flash
|
"$PYTHON" -m esptool erase_flash
|
||||||
"$PYTHON" -m esptool write_flash 0x00 ${FILENAME}
|
"$PYTHON" -m esptool write_flash 0x00 ${FILENAME}
|
||||||
# Account for S3 board's different OTA partition
|
# Account for S3 board's different OTA partition
|
||||||
if [ ! -z "${FILENAME##*"s3"*}" ] && [ ! -z "${FILENAME##*"-v3"*}" ] && [ ! -z "${FILENAME##*"t-deck"*}" ] && [ ! -z "${FILENAME##*"wireless-paper"*}" ] && [ ! -z "${FILENAME##*"wireless-tracker"*}" ]; then
|
if [ -n "${FILENAME##*"s3"*}" ] && [ -n "${FILENAME##*"-v3"*}" ] && [ -n "${FILENAME##*"t-deck"*}" ] && [ -n "${FILENAME##*"wireless-paper"*}" ] && [ -n "${FILENAME##*"wireless-tracker"*}" ]; then
|
||||||
"$PYTHON" -m esptool write_flash 0x260000 bleota.bin
|
if [ -n "${FILENAME##*"esp32c3"*}" ]; then
|
||||||
|
"$PYTHON" -m esptool write_flash 0x260000 bleota.bin
|
||||||
|
else
|
||||||
|
"$PYTHON" -m esptool write_flash 0x260000 bleota-c3.bin
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
"$PYTHON" -m esptool write_flash 0x260000 bleota-s3.bin
|
"$PYTHON" -m esptool write_flash 0x260000 bleota-s3.bin
|
||||||
fi
|
fi
|
||||||
"$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin
|
"$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin
|
||||||
|
|
||||||
else
|
else
|
||||||
show_help
|
show_help
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 5a97acb17543a10e114675a205e3274a83e721af
|
Subproject commit 00332412b238fe559175a6e83fdf8d31fa5e209a
|
@ -103,12 +103,21 @@ class AccelerometerThread : public concurrency::OSThread
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct bma423_axes_remap remap_data;
|
struct bma423_axes_remap remap_data;
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
remap_data.x_axis = 1;
|
||||||
|
remap_data.x_axis_sign = 0;
|
||||||
|
remap_data.y_axis = 0;
|
||||||
|
remap_data.y_axis_sign = 0;
|
||||||
|
remap_data.z_axis = 2;
|
||||||
|
remap_data.z_axis_sign = 1;
|
||||||
|
#else
|
||||||
remap_data.x_axis = 0;
|
remap_data.x_axis = 0;
|
||||||
remap_data.x_axis_sign = 1;
|
remap_data.x_axis_sign = 1;
|
||||||
remap_data.y_axis = 1;
|
remap_data.y_axis = 1;
|
||||||
remap_data.y_axis_sign = 0;
|
remap_data.y_axis_sign = 0;
|
||||||
remap_data.z_axis = 2;
|
remap_data.z_axis = 2;
|
||||||
remap_data.z_axis_sign = 1;
|
remap_data.z_axis_sign = 1;
|
||||||
|
#endif
|
||||||
// Need to raise the wrist function, need to set the correct axis
|
// Need to raise the wrist function, need to set the correct axis
|
||||||
bmaSensor.setRemapAxes(&remap_data);
|
bmaSensor.setRemapAxes(&remap_data);
|
||||||
// sensor.enableFeature(BMA423_STEP_CNTR, true);
|
// sensor.enableFeature(BMA423_STEP_CNTR, true);
|
||||||
@ -171,4 +180,4 @@ class AccelerometerThread : public concurrency::OSThread
|
|||||||
Adafruit_LIS3DH lis;
|
Adafruit_LIS3DH lis;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace concurrency
|
} // namespace concurrency
|
||||||
|
@ -239,4 +239,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define MESHTASTIC_EXCLUDE_NEIGHBORINFO 1
|
#define MESHTASTIC_EXCLUDE_NEIGHBORINFO 1
|
||||||
#define MESHTASTIC_EXCLUDE_TRACEROUTE 1
|
#define MESHTASTIC_EXCLUDE_TRACEROUTE 1
|
||||||
#define MESHTASTIC_EXCLUDE_WAYPOINT 1
|
#define MESHTASTIC_EXCLUDE_WAYPOINT 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_INPUTBROKER 1
|
||||||
|
#define MESHTASTIC_EXCLUDE_SERIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#define PI 3.1415926535897932384626433832795
|
#define PI 3.1415926535897932384626433832795
|
||||||
#define OLC_CODE_LEN 11
|
#define OLC_CODE_LEN 11
|
||||||
#define DEG_CONVERT 180 / PI
|
#define DEG_CONVERT (180 / PI)
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
// Raises a number to an exponent, handling negative exponents.
|
// Raises a number to an exponent, handling negative exponents.
|
||||||
|
@ -184,6 +184,7 @@ bool EInkDisplay::connect()
|
|||||||
// Init GxEPD2
|
// Init GxEPD2
|
||||||
adafruitDisplay->init();
|
adafruitDisplay->init();
|
||||||
adafruitDisplay->setRotation(3);
|
adafruitDisplay->setRotation(3);
|
||||||
|
adafruitDisplay->clearScreen(); // Clearing now, so the boot logo will draw nice and smoothe (fast refresh)
|
||||||
}
|
}
|
||||||
#elif defined(PCA10059)
|
#elif defined(PCA10059)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "DisplayFormatters.h"
|
#include "DisplayFormatters.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
#include "RadioInterface.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -254,6 +255,25 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
return channelName;
|
return channelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Channels::hasDefaultChannel()
|
||||||
|
{
|
||||||
|
// If we don't use a preset or the default frequency slot, or we override the frequency, we don't have a default channel
|
||||||
|
if (!config.lora.use_preset || !RadioInterface::uses_default_frequency_slot || config.lora.override_frequency)
|
||||||
|
return false;
|
||||||
|
// Check if any of the channels are using the default name and PSK
|
||||||
|
for (size_t i = 0; i < getNumChannels(); i++) {
|
||||||
|
const auto &ch = getByIndex(i);
|
||||||
|
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
|
||||||
|
const char *name = getName(i);
|
||||||
|
const char *presetName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
|
// Check if the name is the default derived from the modem preset
|
||||||
|
if (strcmp(name, presetName) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a short suffix used to disambiguate channels that might have the same "name" entered by the human but different PSKs.
|
* Generate a short suffix used to disambiguate channels that might have the same "name" entered by the human but different PSKs.
|
||||||
* The ideas is that the PSK changing should be visible to the user so that they see they probably messed up and that's why they
|
* The ideas is that the PSK changing should be visible to the user so that they see they probably messed up and that's why they
|
||||||
|
@ -102,6 +102,9 @@ class Channels
|
|||||||
*/
|
*/
|
||||||
int16_t setActiveByIndex(ChannelIndex channelIndex);
|
int16_t setActiveByIndex(ChannelIndex channelIndex);
|
||||||
|
|
||||||
|
// Returns true if we can be reached via a channel with the default settings given a region and modem preset
|
||||||
|
bool hasDefaultChannel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Given a channel index, change to use the crypto key specified by that index
|
/** Given a channel index, change to use the crypto key specified by that index
|
||||||
*
|
*
|
||||||
|
@ -744,14 +744,17 @@ uint32_t sinceReceived(const meshtastic_MeshPacket *p)
|
|||||||
|
|
||||||
#define NUM_ONLINE_SECS (60 * 60 * 2) // 2 hrs to consider someone offline
|
#define NUM_ONLINE_SECS (60 * 60 * 2) // 2 hrs to consider someone offline
|
||||||
|
|
||||||
size_t NodeDB::getNumOnlineMeshNodes()
|
size_t NodeDB::getNumOnlineMeshNodes(bool localOnly)
|
||||||
{
|
{
|
||||||
size_t numseen = 0;
|
size_t numseen = 0;
|
||||||
|
|
||||||
// FIXME this implementation is kinda expensive
|
// FIXME this implementation is kinda expensive
|
||||||
for (int i = 0; i < *numMeshNodes; i++)
|
for (int i = 0; i < *numMeshNodes; i++) {
|
||||||
|
if (localOnly && meshNodes[i].via_mqtt)
|
||||||
|
continue;
|
||||||
if (sinceLastSeen(&meshNodes[i]) < NUM_ONLINE_SECS)
|
if (sinceLastSeen(&meshNodes[i]) < NUM_ONLINE_SECS)
|
||||||
numseen++;
|
numseen++;
|
||||||
|
}
|
||||||
|
|
||||||
return numseen;
|
return numseen;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,10 @@ class NodeDB
|
|||||||
// get channel channel index we heard a nodeNum on, defaults to 0 if not found
|
// get channel channel index we heard a nodeNum on, defaults to 0 if not found
|
||||||
uint8_t getMeshNodeChannel(NodeNum n);
|
uint8_t getMeshNodeChannel(NodeNum n);
|
||||||
|
|
||||||
/// Return the number of nodes we've heard from recently (within the last 2 hrs?)
|
/* Return the number of nodes we've heard from recently (within the last 2 hrs?)
|
||||||
size_t getNumOnlineMeshNodes();
|
* @param localOnly if true, ignore nodes heard via MQTT
|
||||||
|
*/
|
||||||
|
size_t getNumOnlineMeshNodes(bool localOnly = false);
|
||||||
|
|
||||||
void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(uint nodeNum);
|
void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(uint nodeNum);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "RadioInterface.h"
|
#include "RadioInterface.h"
|
||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
|
#include "DisplayFormatters.h"
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
@ -143,6 +144,7 @@ const RegionInfo regions[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const RegionInfo *myRegion;
|
const RegionInfo *myRegion;
|
||||||
|
bool RadioInterface::uses_default_frequency_slot = true;
|
||||||
|
|
||||||
static uint8_t bytes[MAX_RHPACKETLEN];
|
static uint8_t bytes[MAX_RHPACKETLEN];
|
||||||
|
|
||||||
@ -486,6 +488,10 @@ void RadioInterface::applyModemConfig()
|
|||||||
// channel_num is actually (channel_num - 1), since modulus (%) returns values from 0 to (numChannels - 1)
|
// channel_num is actually (channel_num - 1), since modulus (%) returns values from 0 to (numChannels - 1)
|
||||||
int channel_num = (loraConfig.channel_num ? loraConfig.channel_num - 1 : hash(channelName)) % numChannels;
|
int channel_num = (loraConfig.channel_num ? loraConfig.channel_num - 1 : hash(channelName)) % numChannels;
|
||||||
|
|
||||||
|
// Check if we use the default frequency slot
|
||||||
|
RadioInterface::uses_default_frequency_slot =
|
||||||
|
channel_num == hash(DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false)) % numChannels;
|
||||||
|
|
||||||
// Old frequency selection formula
|
// Old frequency selection formula
|
||||||
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
||||||
|
|
||||||
|
@ -175,6 +175,9 @@ class RadioInterface
|
|||||||
/// Some boards (1st gen Pinetab Lora module) have broken IRQ wires, so we need to poll via i2c registers
|
/// Some boards (1st gen Pinetab Lora module) have broken IRQ wires, so we need to poll via i2c registers
|
||||||
virtual bool isIRQPending() { return false; }
|
virtual bool isIRQPending() { return false; }
|
||||||
|
|
||||||
|
// Whether we use the default frequency slot given our LoRa config (region and modem preset)
|
||||||
|
static bool uses_default_frequency_slot;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int8_t power = 17; // Set by applyModemConfig()
|
int8_t power = 17; // Set by applyModemConfig()
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePin_msg;
|
|||||||
#define meshtastic_DeviceState_size 17571
|
#define meshtastic_DeviceState_size 17571
|
||||||
#define meshtastic_NodeInfoLite_size 158
|
#define meshtastic_NodeInfoLite_size 158
|
||||||
#define meshtastic_NodeRemoteHardwarePin_size 29
|
#define meshtastic_NodeRemoteHardwarePin_size 29
|
||||||
#define meshtastic_OEMStore_size 3246
|
#define meshtastic_OEMStore_size 3262
|
||||||
#define meshtastic_PositionLite_size 28
|
#define meshtastic_PositionLite_size 28
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -181,7 +181,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define meshtastic_LocalConfig_size 469
|
#define meshtastic_LocalConfig_size 469
|
||||||
#define meshtastic_LocalModuleConfig_size 631
|
#define meshtastic_LocalModuleConfig_size 647
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -6,12 +6,15 @@
|
|||||||
#error Regenerate this file with the current version of nanopb generator.
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PB_BIND(meshtastic_ModuleConfig, meshtastic_ModuleConfig, AUTO)
|
PB_BIND(meshtastic_ModuleConfig, meshtastic_ModuleConfig, 2)
|
||||||
|
|
||||||
|
|
||||||
PB_BIND(meshtastic_ModuleConfig_MQTTConfig, meshtastic_ModuleConfig_MQTTConfig, AUTO)
|
PB_BIND(meshtastic_ModuleConfig_MQTTConfig, meshtastic_ModuleConfig_MQTTConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(meshtastic_ModuleConfig_MapReportSettings, meshtastic_ModuleConfig_MapReportSettings, AUTO)
|
||||||
|
|
||||||
|
|
||||||
PB_BIND(meshtastic_ModuleConfig_RemoteHardwareConfig, meshtastic_ModuleConfig_RemoteHardwareConfig, AUTO)
|
PB_BIND(meshtastic_ModuleConfig_RemoteHardwareConfig, meshtastic_ModuleConfig_RemoteHardwareConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +84,14 @@ typedef enum _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar {
|
|||||||
} meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar;
|
} meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
|
/* Settings for reporting unencrypted information about our node to a map via MQTT */
|
||||||
|
typedef struct _meshtastic_ModuleConfig_MapReportSettings {
|
||||||
|
/* How often we should report our info to the map (in seconds) */
|
||||||
|
uint32_t publish_interval_secs;
|
||||||
|
/* Bits of precision for the location sent (default of 32 is full precision). */
|
||||||
|
uint32_t position_precision;
|
||||||
|
} meshtastic_ModuleConfig_MapReportSettings;
|
||||||
|
|
||||||
/* MQTT Client Config */
|
/* MQTT Client Config */
|
||||||
typedef struct _meshtastic_ModuleConfig_MQTTConfig {
|
typedef struct _meshtastic_ModuleConfig_MQTTConfig {
|
||||||
/* If a meshtastic node is able to reach the internet it will normally attempt to gateway any channels that are marked as
|
/* If a meshtastic node is able to reach the internet it will normally attempt to gateway any channels that are marked as
|
||||||
@ -114,6 +122,11 @@ typedef struct _meshtastic_ModuleConfig_MQTTConfig {
|
|||||||
char root[16];
|
char root[16];
|
||||||
/* If true, we can use the connected phone / client to proxy messages to MQTT instead of a direct connection */
|
/* If true, we can use the connected phone / client to proxy messages to MQTT instead of a direct connection */
|
||||||
bool proxy_to_client_enabled;
|
bool proxy_to_client_enabled;
|
||||||
|
/* If true, we will periodically report unencrypted information about our node to a map via MQTT */
|
||||||
|
bool map_reporting_enabled;
|
||||||
|
/* Settings for reporting information about our node to a map via MQTT */
|
||||||
|
bool has_map_report_settings;
|
||||||
|
meshtastic_ModuleConfig_MapReportSettings map_report_settings;
|
||||||
} meshtastic_ModuleConfig_MQTTConfig;
|
} meshtastic_ModuleConfig_MQTTConfig;
|
||||||
|
|
||||||
/* NeighborInfoModule Config */
|
/* NeighborInfoModule Config */
|
||||||
@ -427,6 +440,7 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define meshtastic_ModuleConfig_AudioConfig_bitrate_ENUMTYPE meshtastic_ModuleConfig_AudioConfig_Audio_Baud
|
#define meshtastic_ModuleConfig_AudioConfig_bitrate_ENUMTYPE meshtastic_ModuleConfig_AudioConfig_Audio_Baud
|
||||||
|
|
||||||
|
|
||||||
@ -447,7 +461,8 @@ extern "C" {
|
|||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}}
|
#define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}}
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0, "", 0}
|
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0, "", 0, 0, false, meshtastic_ModuleConfig_MapReportSettings_init_default}
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_init_default {0, 0}
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0, 0, 0, {meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default}}
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0, 0, 0, {meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default}}
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_init_default {0, 0}
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_init_default {0, 0}
|
||||||
#define meshtastic_ModuleConfig_DetectionSensorConfig_init_default {0, 0, 0, 0, "", 0, 0, 0}
|
#define meshtastic_ModuleConfig_DetectionSensorConfig_init_default {0, 0, 0, 0, "", 0, 0, 0}
|
||||||
@ -462,7 +477,8 @@ extern "C" {
|
|||||||
#define meshtastic_ModuleConfig_AmbientLightingConfig_init_default {0, 0, 0, 0, 0}
|
#define meshtastic_ModuleConfig_AmbientLightingConfig_init_default {0, 0, 0, 0, 0}
|
||||||
#define meshtastic_RemoteHardwarePin_init_default {0, "", _meshtastic_RemoteHardwarePinType_MIN}
|
#define meshtastic_RemoteHardwarePin_init_default {0, "", _meshtastic_RemoteHardwarePinType_MIN}
|
||||||
#define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}}
|
#define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}}
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0, "", 0}
|
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0, "", 0, 0, false, meshtastic_ModuleConfig_MapReportSettings_init_zero}
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_init_zero {0, 0}
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0, 0, 0, {meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero}}
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0, 0, 0, {meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero}}
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_init_zero {0, 0}
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_init_zero {0, 0}
|
||||||
#define meshtastic_ModuleConfig_DetectionSensorConfig_init_zero {0, 0, 0, 0, "", 0, 0, 0}
|
#define meshtastic_ModuleConfig_DetectionSensorConfig_init_zero {0, 0, 0, 0, "", 0, 0, 0}
|
||||||
@ -478,6 +494,8 @@ extern "C" {
|
|||||||
#define meshtastic_RemoteHardwarePin_init_zero {0, "", _meshtastic_RemoteHardwarePinType_MIN}
|
#define meshtastic_RemoteHardwarePin_init_zero {0, "", _meshtastic_RemoteHardwarePinType_MIN}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_publish_interval_secs_tag 1
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_position_precision_tag 2
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_enabled_tag 1
|
#define meshtastic_ModuleConfig_MQTTConfig_enabled_tag 1
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_address_tag 2
|
#define meshtastic_ModuleConfig_MQTTConfig_address_tag 2
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_username_tag 3
|
#define meshtastic_ModuleConfig_MQTTConfig_username_tag 3
|
||||||
@ -487,6 +505,8 @@ extern "C" {
|
|||||||
#define meshtastic_ModuleConfig_MQTTConfig_tls_enabled_tag 7
|
#define meshtastic_ModuleConfig_MQTTConfig_tls_enabled_tag 7
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_root_tag 8
|
#define meshtastic_ModuleConfig_MQTTConfig_root_tag 8
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_proxy_to_client_enabled_tag 9
|
#define meshtastic_ModuleConfig_MQTTConfig_proxy_to_client_enabled_tag 9
|
||||||
|
#define meshtastic_ModuleConfig_MQTTConfig_map_reporting_enabled_tag 10
|
||||||
|
#define meshtastic_ModuleConfig_MQTTConfig_map_report_settings_tag 11
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_enabled_tag 1
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_enabled_tag 1
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_update_interval_tag 2
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_update_interval_tag 2
|
||||||
#define meshtastic_ModuleConfig_DetectionSensorConfig_enabled_tag 1
|
#define meshtastic_ModuleConfig_DetectionSensorConfig_enabled_tag 1
|
||||||
@ -623,9 +643,18 @@ X(a, STATIC, SINGULAR, BOOL, encryption_enabled, 5) \
|
|||||||
X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) \
|
X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, tls_enabled, 7) \
|
X(a, STATIC, SINGULAR, BOOL, tls_enabled, 7) \
|
||||||
X(a, STATIC, SINGULAR, STRING, root, 8) \
|
X(a, STATIC, SINGULAR, STRING, root, 8) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, proxy_to_client_enabled, 9)
|
X(a, STATIC, SINGULAR, BOOL, proxy_to_client_enabled, 9) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, map_reporting_enabled, 10) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, map_report_settings, 11)
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_CALLBACK NULL
|
#define meshtastic_ModuleConfig_MQTTConfig_CALLBACK NULL
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL
|
#define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL
|
||||||
|
#define meshtastic_ModuleConfig_MQTTConfig_map_report_settings_MSGTYPE meshtastic_ModuleConfig_MapReportSettings
|
||||||
|
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, publish_interval_secs, 1) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, position_precision, 2)
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_CALLBACK NULL
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_DEFAULT NULL
|
||||||
|
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_FIELDLIST(X, a) \
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_FIELDLIST(X, a) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, enabled, 1) \
|
X(a, STATIC, SINGULAR, BOOL, enabled, 1) \
|
||||||
@ -764,6 +793,7 @@ X(a, STATIC, SINGULAR, UENUM, type, 3)
|
|||||||
|
|
||||||
extern const pb_msgdesc_t meshtastic_ModuleConfig_msg;
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_msg;
|
||||||
extern const pb_msgdesc_t meshtastic_ModuleConfig_MQTTConfig_msg;
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_MQTTConfig_msg;
|
||||||
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_MapReportSettings_msg;
|
||||||
extern const pb_msgdesc_t meshtastic_ModuleConfig_RemoteHardwareConfig_msg;
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_RemoteHardwareConfig_msg;
|
||||||
extern const pb_msgdesc_t meshtastic_ModuleConfig_NeighborInfoConfig_msg;
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_NeighborInfoConfig_msg;
|
||||||
extern const pb_msgdesc_t meshtastic_ModuleConfig_DetectionSensorConfig_msg;
|
extern const pb_msgdesc_t meshtastic_ModuleConfig_DetectionSensorConfig_msg;
|
||||||
@ -781,6 +811,7 @@ extern const pb_msgdesc_t meshtastic_RemoteHardwarePin_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 meshtastic_ModuleConfig_fields &meshtastic_ModuleConfig_msg
|
#define meshtastic_ModuleConfig_fields &meshtastic_ModuleConfig_msg
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_fields &meshtastic_ModuleConfig_MQTTConfig_msg
|
#define meshtastic_ModuleConfig_MQTTConfig_fields &meshtastic_ModuleConfig_MQTTConfig_msg
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_fields &meshtastic_ModuleConfig_MapReportSettings_msg
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_fields &meshtastic_ModuleConfig_RemoteHardwareConfig_msg
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_fields &meshtastic_ModuleConfig_RemoteHardwareConfig_msg
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_fields &meshtastic_ModuleConfig_NeighborInfoConfig_msg
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_fields &meshtastic_ModuleConfig_NeighborInfoConfig_msg
|
||||||
#define meshtastic_ModuleConfig_DetectionSensorConfig_fields &meshtastic_ModuleConfig_DetectionSensorConfig_msg
|
#define meshtastic_ModuleConfig_DetectionSensorConfig_fields &meshtastic_ModuleConfig_DetectionSensorConfig_msg
|
||||||
@ -801,7 +832,8 @@ extern const pb_msgdesc_t meshtastic_RemoteHardwarePin_msg;
|
|||||||
#define meshtastic_ModuleConfig_CannedMessageConfig_size 49
|
#define meshtastic_ModuleConfig_CannedMessageConfig_size 49
|
||||||
#define meshtastic_ModuleConfig_DetectionSensorConfig_size 44
|
#define meshtastic_ModuleConfig_DetectionSensorConfig_size 44
|
||||||
#define meshtastic_ModuleConfig_ExternalNotificationConfig_size 42
|
#define meshtastic_ModuleConfig_ExternalNotificationConfig_size 42
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_size 222
|
#define meshtastic_ModuleConfig_MQTTConfig_size 238
|
||||||
|
#define meshtastic_ModuleConfig_MapReportSettings_size 12
|
||||||
#define meshtastic_ModuleConfig_NeighborInfoConfig_size 8
|
#define meshtastic_ModuleConfig_NeighborInfoConfig_size 8
|
||||||
#define meshtastic_ModuleConfig_PaxcounterConfig_size 8
|
#define meshtastic_ModuleConfig_PaxcounterConfig_size 8
|
||||||
#define meshtastic_ModuleConfig_RangeTestConfig_size 10
|
#define meshtastic_ModuleConfig_RangeTestConfig_size 10
|
||||||
@ -809,7 +841,7 @@ extern const pb_msgdesc_t meshtastic_RemoteHardwarePin_msg;
|
|||||||
#define meshtastic_ModuleConfig_SerialConfig_size 28
|
#define meshtastic_ModuleConfig_SerialConfig_size 28
|
||||||
#define meshtastic_ModuleConfig_StoreForwardConfig_size 22
|
#define meshtastic_ModuleConfig_StoreForwardConfig_size 22
|
||||||
#define meshtastic_ModuleConfig_TelemetryConfig_size 36
|
#define meshtastic_ModuleConfig_TelemetryConfig_size 36
|
||||||
#define meshtastic_ModuleConfig_size 225
|
#define meshtastic_ModuleConfig_size 241
|
||||||
#define meshtastic_RemoteHardwarePin_size 21
|
#define meshtastic_RemoteHardwarePin_size 21
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -9,4 +9,7 @@
|
|||||||
PB_BIND(meshtastic_ServiceEnvelope, meshtastic_ServiceEnvelope, AUTO)
|
PB_BIND(meshtastic_ServiceEnvelope, meshtastic_ServiceEnvelope, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(meshtastic_MapReport, meshtastic_MapReport, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#define PB_MESHTASTIC_MESHTASTIC_MQTT_PB_H_INCLUDED
|
#define PB_MESHTASTIC_MESHTASTIC_MQTT_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "meshtastic/mesh.pb.h"
|
#include "meshtastic/mesh.pb.h"
|
||||||
|
#include "meshtastic/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.
|
||||||
@ -23,6 +24,38 @@ typedef struct _meshtastic_ServiceEnvelope {
|
|||||||
char *gateway_id;
|
char *gateway_id;
|
||||||
} meshtastic_ServiceEnvelope;
|
} meshtastic_ServiceEnvelope;
|
||||||
|
|
||||||
|
/* Information about a node intended to be reported unencrypted to a map using MQTT. */
|
||||||
|
typedef struct _meshtastic_MapReport {
|
||||||
|
/* A full name for this user, i.e. "Kevin Hester" */
|
||||||
|
char long_name[40];
|
||||||
|
/* A VERY short name, ideally two characters.
|
||||||
|
Suitable for a tiny OLED screen */
|
||||||
|
char short_name[5];
|
||||||
|
/* Role of the node that applies specific settings for a particular use-case */
|
||||||
|
meshtastic_Config_DeviceConfig_Role role;
|
||||||
|
/* Hardware model of the node, i.e. T-Beam, Heltec V3, etc... */
|
||||||
|
meshtastic_HardwareModel hw_model;
|
||||||
|
/* Device firmware version string */
|
||||||
|
char firmware_version[18];
|
||||||
|
/* The region code for the radio (US, CN, EU433, etc...) */
|
||||||
|
meshtastic_Config_LoRaConfig_RegionCode region;
|
||||||
|
/* Modem preset used by the radio (LongFast, MediumSlow, etc...) */
|
||||||
|
meshtastic_Config_LoRaConfig_ModemPreset modem_preset;
|
||||||
|
/* Whether the node has a channel with default PSK and name (LongFast, MediumSlow, etc...)
|
||||||
|
and it uses the default frequency slot given the region and modem preset. */
|
||||||
|
bool has_default_channel;
|
||||||
|
/* Latitude: multiply by 1e-7 to get degrees in floating point */
|
||||||
|
int32_t latitude_i;
|
||||||
|
/* Longitude: multiply by 1e-7 to get degrees in floating point */
|
||||||
|
int32_t longitude_i;
|
||||||
|
/* Altitude in meters above MSL */
|
||||||
|
int32_t altitude;
|
||||||
|
/* Indicates the bits of precision for latitude and longitude set by the sending node */
|
||||||
|
uint32_t position_precision;
|
||||||
|
/* Number of online nodes (heard in the last 2 hours) this node has in its list that were received locally (not via MQTT) */
|
||||||
|
uint16_t num_online_local_nodes;
|
||||||
|
} meshtastic_MapReport;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -30,12 +63,27 @@ extern "C" {
|
|||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define meshtastic_ServiceEnvelope_init_default {NULL, NULL, NULL}
|
#define meshtastic_ServiceEnvelope_init_default {NULL, NULL, NULL}
|
||||||
|
#define meshtastic_MapReport_init_default {"", "", _meshtastic_Config_DeviceConfig_Role_MIN, _meshtastic_HardwareModel_MIN, "", _meshtastic_Config_LoRaConfig_RegionCode_MIN, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, 0, 0}
|
||||||
#define meshtastic_ServiceEnvelope_init_zero {NULL, NULL, NULL}
|
#define meshtastic_ServiceEnvelope_init_zero {NULL, NULL, NULL}
|
||||||
|
#define meshtastic_MapReport_init_zero {"", "", _meshtastic_Config_DeviceConfig_Role_MIN, _meshtastic_HardwareModel_MIN, "", _meshtastic_Config_LoRaConfig_RegionCode_MIN, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, 0, 0}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define meshtastic_ServiceEnvelope_packet_tag 1
|
#define meshtastic_ServiceEnvelope_packet_tag 1
|
||||||
#define meshtastic_ServiceEnvelope_channel_id_tag 2
|
#define meshtastic_ServiceEnvelope_channel_id_tag 2
|
||||||
#define meshtastic_ServiceEnvelope_gateway_id_tag 3
|
#define meshtastic_ServiceEnvelope_gateway_id_tag 3
|
||||||
|
#define meshtastic_MapReport_long_name_tag 1
|
||||||
|
#define meshtastic_MapReport_short_name_tag 2
|
||||||
|
#define meshtastic_MapReport_role_tag 3
|
||||||
|
#define meshtastic_MapReport_hw_model_tag 4
|
||||||
|
#define meshtastic_MapReport_firmware_version_tag 5
|
||||||
|
#define meshtastic_MapReport_region_tag 6
|
||||||
|
#define meshtastic_MapReport_modem_preset_tag 7
|
||||||
|
#define meshtastic_MapReport_has_default_channel_tag 8
|
||||||
|
#define meshtastic_MapReport_latitude_i_tag 9
|
||||||
|
#define meshtastic_MapReport_longitude_i_tag 10
|
||||||
|
#define meshtastic_MapReport_altitude_tag 11
|
||||||
|
#define meshtastic_MapReport_position_precision_tag 12
|
||||||
|
#define meshtastic_MapReport_num_online_local_nodes_tag 13
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
#define meshtastic_ServiceEnvelope_FIELDLIST(X, a) \
|
#define meshtastic_ServiceEnvelope_FIELDLIST(X, a) \
|
||||||
@ -46,13 +94,33 @@ X(a, POINTER, SINGULAR, STRING, gateway_id, 3)
|
|||||||
#define meshtastic_ServiceEnvelope_DEFAULT NULL
|
#define meshtastic_ServiceEnvelope_DEFAULT NULL
|
||||||
#define meshtastic_ServiceEnvelope_packet_MSGTYPE meshtastic_MeshPacket
|
#define meshtastic_ServiceEnvelope_packet_MSGTYPE meshtastic_MeshPacket
|
||||||
|
|
||||||
|
#define meshtastic_MapReport_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, SINGULAR, STRING, long_name, 1) \
|
||||||
|
X(a, STATIC, SINGULAR, STRING, short_name, 2) \
|
||||||
|
X(a, STATIC, SINGULAR, UENUM, role, 3) \
|
||||||
|
X(a, STATIC, SINGULAR, UENUM, hw_model, 4) \
|
||||||
|
X(a, STATIC, SINGULAR, STRING, firmware_version, 5) \
|
||||||
|
X(a, STATIC, SINGULAR, UENUM, region, 6) \
|
||||||
|
X(a, STATIC, SINGULAR, UENUM, modem_preset, 7) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, has_default_channel, 8) \
|
||||||
|
X(a, STATIC, SINGULAR, SFIXED32, latitude_i, 9) \
|
||||||
|
X(a, STATIC, SINGULAR, SFIXED32, longitude_i, 10) \
|
||||||
|
X(a, STATIC, SINGULAR, INT32, altitude, 11) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, position_precision, 12) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, num_online_local_nodes, 13)
|
||||||
|
#define meshtastic_MapReport_CALLBACK NULL
|
||||||
|
#define meshtastic_MapReport_DEFAULT NULL
|
||||||
|
|
||||||
extern const pb_msgdesc_t meshtastic_ServiceEnvelope_msg;
|
extern const pb_msgdesc_t meshtastic_ServiceEnvelope_msg;
|
||||||
|
extern const pb_msgdesc_t meshtastic_MapReport_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 meshtastic_ServiceEnvelope_fields &meshtastic_ServiceEnvelope_msg
|
#define meshtastic_ServiceEnvelope_fields &meshtastic_ServiceEnvelope_msg
|
||||||
|
#define meshtastic_MapReport_fields &meshtastic_MapReport_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
/* meshtastic_ServiceEnvelope_size depends on runtime parameters */
|
/* meshtastic_ServiceEnvelope_size depends on runtime parameters */
|
||||||
|
#define meshtastic_MapReport_size 108
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -122,6 +122,8 @@ typedef enum _meshtastic_PortNum {
|
|||||||
/* ATAK Plugin
|
/* ATAK Plugin
|
||||||
Portnum for payloads from the official Meshtastic ATAK plugin */
|
Portnum for payloads from the official Meshtastic ATAK plugin */
|
||||||
meshtastic_PortNum_ATAK_PLUGIN = 72,
|
meshtastic_PortNum_ATAK_PLUGIN = 72,
|
||||||
|
/* Provides unencrypted information about a node for consumption by a map via MQTT */
|
||||||
|
meshtastic_PortNum_MAP_REPORT_APP = 73,
|
||||||
/* Private applications should use portnums >= 256.
|
/* Private applications should use portnums >= 256.
|
||||||
To simplify initial development and testing you can use "PRIVATE_APP"
|
To simplify initial development and testing you can use "PRIVATE_APP"
|
||||||
in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) */
|
in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) */
|
||||||
|
@ -39,11 +39,11 @@
|
|||||||
#if HAS_TELEMETRY
|
#if HAS_TELEMETRY
|
||||||
#include "modules/Telemetry/DeviceTelemetry.h"
|
#include "modules/Telemetry/DeviceTelemetry.h"
|
||||||
#endif
|
#endif
|
||||||
#if HAS_SENSOR && !EXCLUDE_ENVIRONMENTAL_SENSOR
|
#if HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
#include "modules/Telemetry/AirQualityTelemetry.h"
|
#include "modules/Telemetry/AirQualityTelemetry.h"
|
||||||
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
||||||
#endif
|
#endif
|
||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !EXCLUDE_POWER_TELEMETRY
|
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY
|
||||||
#include "modules/Telemetry/PowerTelemetry.h"
|
#include "modules/Telemetry/PowerTelemetry.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
@ -138,13 +138,13 @@ void setupModules()
|
|||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
||||||
new DeviceTelemetryModule();
|
new DeviceTelemetryModule();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_SENSOR && !EXCLUDE_ENVIRONMENTAL_SENSOR
|
#if HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
new EnvironmentTelemetryModule();
|
new EnvironmentTelemetryModule();
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first > 0) {
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first > 0) {
|
||||||
new AirQualityTelemetryModule();
|
new AirQualityTelemetryModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !EXCLUDE_POWER_TELEMETRY
|
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY
|
||||||
new PowerTelemetryModule();
|
new PowerTelemetryModule();
|
||||||
#endif
|
#endif
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \
|
||||||
|
@ -113,7 +113,7 @@ void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
|
|||||||
meshtastic_MeshPacket *p = allocDataPacket();
|
meshtastic_MeshPacket *p = allocDataPacket();
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
p->decoded.want_response = wantReplies;
|
p->decoded.want_response = wantReplies;
|
||||||
|
p->hop_limit = 0;
|
||||||
p->want_ack = true;
|
p->want_ack = true;
|
||||||
|
|
||||||
packetSequence++;
|
packetSequence++;
|
||||||
@ -295,4 +295,4 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ int32_t SHT31Sensor::runOnce()
|
|||||||
if (!hasSensor()) {
|
if (!hasSensor()) {
|
||||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
}
|
}
|
||||||
status = sht31.begin();
|
status = sht31.begin(nodeTelemetrySensorsMap[sensorType].first);
|
||||||
return initI2CSensor();
|
return initI2CSensor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
class SHT31Sensor : public TelemetrySensor
|
class SHT31Sensor : public TelemetrySensor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Adafruit_SHT31 sht31 = Adafruit_SHT31();
|
Adafruit_SHT31 sht31 = Adafruit_SHT31(nodeTelemetrySensorsMap[sensorType].second);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setup() override;
|
virtual void setup() override;
|
||||||
|
@ -7,9 +7,19 @@
|
|||||||
|
|
||||||
PaxcounterModule *paxcounterModule;
|
PaxcounterModule *paxcounterModule;
|
||||||
|
|
||||||
void NullFunc(){};
|
/**
|
||||||
|
* Callback function for libpax.
|
||||||
// paxcounterModule->sendInfo(NODENUM_BROADCAST);
|
* We only clear our sent flag here, since this function is called from another thread, so we
|
||||||
|
* cannot send to the mesh directly.
|
||||||
|
*/
|
||||||
|
void PaxcounterModule::handlePaxCounterReportRequest()
|
||||||
|
{
|
||||||
|
// The libpax library already updated our data structure, just before invoking this callback.
|
||||||
|
LOG_INFO("PaxcounterModule: libpax reported new data: wifi=%d; ble=%d; uptime=%lu\n",
|
||||||
|
paxcounterModule->count_from_libpax.wifi_count, paxcounterModule->count_from_libpax.ble_count, millis() / 1000);
|
||||||
|
paxcounterModule->reportedDataSent = false;
|
||||||
|
paxcounterModule->setIntervalFromNow(0);
|
||||||
|
}
|
||||||
|
|
||||||
PaxcounterModule::PaxcounterModule()
|
PaxcounterModule::PaxcounterModule()
|
||||||
: concurrency::OSThread("PaxcounterModule"),
|
: concurrency::OSThread("PaxcounterModule"),
|
||||||
@ -17,11 +27,20 @@ PaxcounterModule::PaxcounterModule()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the Pax information to the mesh if we got new data from libpax.
|
||||||
|
* This is called periodically from our runOnce() method and will actually send the data to the mesh
|
||||||
|
* if libpax updated it since the last transmission through the callback.
|
||||||
|
* @param dest - destination node (usually NODENUM_BROADCAST)
|
||||||
|
* @return false if sending is unnecessary, true if information was sent
|
||||||
|
*/
|
||||||
bool PaxcounterModule::sendInfo(NodeNum dest)
|
bool PaxcounterModule::sendInfo(NodeNum dest)
|
||||||
{
|
{
|
||||||
libpax_counter_count(&count_from_libpax);
|
if (paxcounterModule->reportedDataSent)
|
||||||
LOG_INFO("(Sending): pax: wifi=%d; ble=%d; uptime=%d\n", count_from_libpax.wifi_count, count_from_libpax.ble_count,
|
return false;
|
||||||
millis() / 1000);
|
|
||||||
|
LOG_INFO("PaxcounterModule: sending pax info wifi=%d; ble=%d; uptime=%lu\n", count_from_libpax.wifi_count,
|
||||||
|
count_from_libpax.ble_count, millis() / 1000);
|
||||||
|
|
||||||
meshtastic_Paxcount pl = meshtastic_Paxcount_init_default;
|
meshtastic_Paxcount pl = meshtastic_Paxcount_init_default;
|
||||||
pl.wifi = count_from_libpax.wifi_count;
|
pl.wifi = count_from_libpax.wifi_count;
|
||||||
@ -34,6 +53,9 @@ bool PaxcounterModule::sendInfo(NodeNum dest)
|
|||||||
p->priority = meshtastic_MeshPacket_Priority_MIN;
|
p->priority = meshtastic_MeshPacket_Priority_MIN;
|
||||||
|
|
||||||
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||||
|
|
||||||
|
paxcounterModule->reportedDataSent = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +89,7 @@ int32_t PaxcounterModule::runOnce()
|
|||||||
libpax_default_config(&configuration);
|
libpax_default_config(&configuration);
|
||||||
|
|
||||||
configuration.blecounter = 1;
|
configuration.blecounter = 1;
|
||||||
configuration.blescantime = 0; // infinit
|
configuration.blescantime = 0; // infinite
|
||||||
configuration.wificounter = 1;
|
configuration.wificounter = 1;
|
||||||
configuration.wifi_channel_map = WIFI_CHANNEL_ALL;
|
configuration.wifi_channel_map = WIFI_CHANNEL_ALL;
|
||||||
configuration.wifi_channel_switch_interval = 50;
|
configuration.wifi_channel_switch_interval = 50;
|
||||||
@ -76,7 +98,8 @@ int32_t PaxcounterModule::runOnce()
|
|||||||
libpax_update_config(&configuration);
|
libpax_update_config(&configuration);
|
||||||
|
|
||||||
// internal processing initialization
|
// internal processing initialization
|
||||||
libpax_counter_init(NullFunc, &count_from_libpax, UINT16_MAX, 1);
|
libpax_counter_init(handlePaxCounterReportRequest, &count_from_libpax,
|
||||||
|
moduleConfig.paxcounter.paxcounter_update_interval, 0);
|
||||||
libpax_counter_start();
|
libpax_counter_start();
|
||||||
} else {
|
} else {
|
||||||
sendInfo(NODENUM_BROADCAST);
|
sendInfo(NODENUM_BROADCAST);
|
||||||
|
@ -8,11 +8,15 @@
|
|||||||
#include <libpax_api.h>
|
#include <libpax_api.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple example module that just replies with "Message received" to any message it receives.
|
* Wrapper module for the estimate passenger (PAX) count library (https://github.com/dbinfrago/libpax) which
|
||||||
|
* implements the core functionality of the ESP32 Paxcounter project (https://github.com/cyberman54/ESP32-Paxcounter)
|
||||||
*/
|
*/
|
||||||
class PaxcounterModule : private concurrency::OSThread, public ProtobufModule<meshtastic_Paxcount>
|
class PaxcounterModule : private concurrency::OSThread, public ProtobufModule<meshtastic_Paxcount>
|
||||||
{
|
{
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
|
bool reportedDataSent = true;
|
||||||
|
|
||||||
|
static void handlePaxCounterReportRequest();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaxcounterModule();
|
PaxcounterModule();
|
||||||
|
@ -77,8 +77,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
|
|||||||
if (jsonPayloadStr.length() <= sizeof(p->decoded.payload.bytes)) {
|
if (jsonPayloadStr.length() <= sizeof(p->decoded.payload.bytes)) {
|
||||||
memcpy(p->decoded.payload.bytes, jsonPayloadStr.c_str(), jsonPayloadStr.length());
|
memcpy(p->decoded.payload.bytes, jsonPayloadStr.c_str(), jsonPayloadStr.length());
|
||||||
p->decoded.payload.size = jsonPayloadStr.length();
|
p->decoded.payload.size = jsonPayloadStr.length();
|
||||||
meshtastic_MeshPacket *packet = packetPool.allocCopy(*p);
|
service.sendToMesh(p, RX_SRC_LOCAL);
|
||||||
service.sendToMesh(packet, RX_SRC_LOCAL);
|
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("Received MQTT json payload too long, dropping\n");
|
LOG_WARN("Received MQTT json payload too long, dropping\n");
|
||||||
}
|
}
|
||||||
@ -186,10 +185,17 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
|
|||||||
statusTopic = moduleConfig.mqtt.root + statusTopic;
|
statusTopic = moduleConfig.mqtt.root + statusTopic;
|
||||||
cryptTopic = moduleConfig.mqtt.root + cryptTopic;
|
cryptTopic = moduleConfig.mqtt.root + cryptTopic;
|
||||||
jsonTopic = moduleConfig.mqtt.root + jsonTopic;
|
jsonTopic = moduleConfig.mqtt.root + jsonTopic;
|
||||||
|
mapTopic = moduleConfig.mqtt.root + jsonTopic;
|
||||||
} else {
|
} else {
|
||||||
statusTopic = "msh" + statusTopic;
|
statusTopic = "msh" + statusTopic;
|
||||||
cryptTopic = "msh" + cryptTopic;
|
cryptTopic = "msh" + cryptTopic;
|
||||||
jsonTopic = "msh" + jsonTopic;
|
jsonTopic = "msh" + jsonTopic;
|
||||||
|
mapTopic = "msh" + mapTopic;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moduleConfig.mqtt.map_reporting_enabled && moduleConfig.mqtt.has_map_report_settings) {
|
||||||
|
map_position_precision = moduleConfig.mqtt.map_report_settings.position_precision;
|
||||||
|
map_publish_interval_secs = moduleConfig.mqtt.map_report_settings.publish_interval_secs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_NETWORKING
|
#ifdef HAS_NETWORKING
|
||||||
@ -365,27 +371,30 @@ void MQTT::sendSubscriptions()
|
|||||||
|
|
||||||
bool MQTT::wantsLink() const
|
bool MQTT::wantsLink() const
|
||||||
{
|
{
|
||||||
bool hasChannel = false;
|
bool hasChannelorMapReport = false;
|
||||||
|
|
||||||
if (moduleConfig.mqtt.enabled) {
|
if (moduleConfig.mqtt.enabled) {
|
||||||
// No need for link if no channel needed it
|
hasChannelorMapReport = moduleConfig.mqtt.map_reporting_enabled;
|
||||||
size_t numChan = channels.getNumChannels();
|
if (!hasChannelorMapReport) {
|
||||||
for (size_t i = 0; i < numChan; i++) {
|
// No need for link if no channel needed it
|
||||||
const auto &ch = channels.getByIndex(i);
|
size_t numChan = channels.getNumChannels();
|
||||||
if (ch.settings.uplink_enabled || ch.settings.downlink_enabled) {
|
for (size_t i = 0; i < numChan; i++) {
|
||||||
hasChannel = true;
|
const auto &ch = channels.getByIndex(i);
|
||||||
break;
|
if (ch.settings.uplink_enabled || ch.settings.downlink_enabled) {
|
||||||
|
hasChannelorMapReport = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasChannel && moduleConfig.mqtt.proxy_to_client_enabled)
|
if (hasChannelorMapReport && moduleConfig.mqtt.proxy_to_client_enabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
return hasChannel && WiFi.isConnected();
|
return hasChannelorMapReport && WiFi.isConnected();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_ETHERNET
|
#if HAS_ETHERNET
|
||||||
return hasChannel && Ethernet.linkStatus() == LinkON;
|
return hasChannelorMapReport && Ethernet.linkStatus() == LinkON;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -397,6 +406,8 @@ int32_t MQTT::runOnce()
|
|||||||
|
|
||||||
bool wantConnection = wantsLink();
|
bool wantConnection = wantsLink();
|
||||||
|
|
||||||
|
perhapsReportToMap();
|
||||||
|
|
||||||
// If connected poll rapidly, otherwise only occasionally check for a wifi connection change and ability to contact server
|
// If connected poll rapidly, otherwise only occasionally check for a wifi connection change and ability to contact server
|
||||||
if (moduleConfig.mqtt.proxy_to_client_enabled) {
|
if (moduleConfig.mqtt.proxy_to_client_enabled) {
|
||||||
publishQueuedMessages();
|
publishQueuedMessages();
|
||||||
@ -536,6 +547,78 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MQTT::perhapsReportToMap()
|
||||||
|
{
|
||||||
|
if (!moduleConfig.mqtt.map_reporting_enabled || !(moduleConfig.mqtt.proxy_to_client_enabled || isConnectedDirectly()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (map_position_precision == 0 || (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)) {
|
||||||
|
LOG_WARN("MQTT Map reporting is enabled, but precision is 0 or no position available.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (millis() - last_report_to_map < map_publish_interval_secs * 1000) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// Allocate ServiceEnvelope and fill it
|
||||||
|
meshtastic_ServiceEnvelope *se = mqttPool.allocZeroed();
|
||||||
|
se->channel_id = (char *)channels.getGlobalId(channels.getPrimaryIndex()); // Use primary channel as the channel_id
|
||||||
|
se->gateway_id = owner.id;
|
||||||
|
|
||||||
|
// Allocate MeshPacket and fill it
|
||||||
|
meshtastic_MeshPacket *mp = packetPool.allocZeroed();
|
||||||
|
mp->which_payload_variant = meshtastic_MeshPacket_decoded_tag;
|
||||||
|
mp->from = nodeDB.getNodeNum();
|
||||||
|
mp->to = NODENUM_BROADCAST;
|
||||||
|
mp->decoded.portnum = meshtastic_PortNum_MAP_REPORT_APP;
|
||||||
|
|
||||||
|
// Fill MapReport message
|
||||||
|
meshtastic_MapReport mapReport = meshtastic_MapReport_init_default;
|
||||||
|
memcpy(mapReport.long_name, owner.long_name, sizeof(owner.long_name));
|
||||||
|
memcpy(mapReport.short_name, owner.short_name, sizeof(owner.short_name));
|
||||||
|
mapReport.role = config.device.role;
|
||||||
|
mapReport.hw_model = owner.hw_model;
|
||||||
|
strncpy(mapReport.firmware_version, optstr(APP_VERSION), sizeof(mapReport.firmware_version));
|
||||||
|
mapReport.region = config.lora.region;
|
||||||
|
mapReport.modem_preset = config.lora.modem_preset;
|
||||||
|
mapReport.has_default_channel = channels.hasDefaultChannel();
|
||||||
|
|
||||||
|
// Set position with precision (same as in PositionModule)
|
||||||
|
if (map_position_precision < 32 && map_position_precision > 0) {
|
||||||
|
mapReport.latitude_i = localPosition.latitude_i & (UINT32_MAX << (32 - map_position_precision));
|
||||||
|
mapReport.longitude_i = localPosition.longitude_i & (UINT32_MAX << (32 - map_position_precision));
|
||||||
|
mapReport.latitude_i += (1 << (31 - map_position_precision));
|
||||||
|
mapReport.longitude_i += (1 << (31 - map_position_precision));
|
||||||
|
} else {
|
||||||
|
mapReport.latitude_i = localPosition.latitude_i;
|
||||||
|
mapReport.longitude_i = localPosition.longitude_i;
|
||||||
|
}
|
||||||
|
mapReport.altitude = localPosition.altitude;
|
||||||
|
mapReport.position_precision = map_position_precision;
|
||||||
|
|
||||||
|
mapReport.num_online_local_nodes = nodeDB.getNumOnlineMeshNodes(true);
|
||||||
|
|
||||||
|
// Encode MapReport message and set it to MeshPacket in ServiceEnvelope
|
||||||
|
mp->decoded.payload.size = pb_encode_to_bytes(mp->decoded.payload.bytes, sizeof(mp->decoded.payload.bytes),
|
||||||
|
&meshtastic_MapReport_msg, &mapReport);
|
||||||
|
se->packet = mp;
|
||||||
|
|
||||||
|
// FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets
|
||||||
|
static uint8_t bytes[meshtastic_MeshPacket_size + 64];
|
||||||
|
size_t numBytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_ServiceEnvelope_msg, se);
|
||||||
|
|
||||||
|
LOG_INFO("MQTT Publish map report to %s\n", mapTopic.c_str());
|
||||||
|
publish(mapTopic.c_str(), bytes, numBytes, false);
|
||||||
|
|
||||||
|
// Release the allocated memory for ServiceEnvelope and MeshPacket
|
||||||
|
mqttPool.release(se);
|
||||||
|
packetPool.release(mp);
|
||||||
|
|
||||||
|
// Update the last report time
|
||||||
|
last_report_to_map = millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// converts a downstream packet into a json message
|
// converts a downstream packet into a json message
|
||||||
std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp)
|
std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp)
|
||||||
{
|
{
|
||||||
@ -655,6 +738,9 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp)
|
|||||||
if ((int)decoded->VDOP) {
|
if ((int)decoded->VDOP) {
|
||||||
msgPayload["VDOP"] = new JSONValue((int)decoded->VDOP);
|
msgPayload["VDOP"] = new JSONValue((int)decoded->VDOP);
|
||||||
}
|
}
|
||||||
|
if ((int)decoded->precision_bits) {
|
||||||
|
msgPayload["precision_bits"] = new JSONValue((int)decoded->precision_bits);
|
||||||
|
}
|
||||||
jsonObj["payload"] = new JSONValue(msgPayload);
|
jsonObj["payload"] = new JSONValue(msgPayload);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("Error decoding protobuf for position message!\n");
|
LOG_ERROR("Error decoding protobuf for position message!\n");
|
||||||
|
@ -79,11 +79,18 @@ class MQTT : private concurrency::OSThread
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string statusTopic = "/2/stat/";
|
std::string statusTopic = "/2/stat/"; // For "online"/"offline" message
|
||||||
std::string cryptTopic = "/2/e/"; // msh/2/e/CHANNELID/NODEID
|
std::string cryptTopic = "/2/e/"; // msh/2/e/CHANNELID/NODEID
|
||||||
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
|
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
|
||||||
/** return true if we have a channel that wants uplink/downlink
|
std::string mapTopic = "/2/map/"; // For protobuf-encoded MapReport messages
|
||||||
*/
|
|
||||||
|
// For map reporting (only applies when enabled)
|
||||||
|
uint32_t last_report_to_map = 0;
|
||||||
|
uint32_t map_position_precision = 32; // default to full precision
|
||||||
|
uint32_t map_publish_interval_secs = 60 * 15; // default to 15 minutes
|
||||||
|
|
||||||
|
/** return true if we have a channel that wants uplink/downlink or map reporting is enabled
|
||||||
|
*/
|
||||||
bool wantsLink() const;
|
bool wantsLink() const;
|
||||||
|
|
||||||
/** Tell the server what subscriptions we want (based on channels.downlink_enabled)
|
/** Tell the server what subscriptions we want (based on channels.downlink_enabled)
|
||||||
@ -102,6 +109,9 @@ class MQTT : private concurrency::OSThread
|
|||||||
void publishStatus();
|
void publishStatus();
|
||||||
void publishQueuedMessages();
|
void publishQueuedMessages();
|
||||||
|
|
||||||
|
// Check if we should report unencrypted information about our node for consumption by a map
|
||||||
|
void perhapsReportToMap();
|
||||||
|
|
||||||
// returns true if this is a valid JSON envelope which we accept on downlink
|
// returns true if this is a valid JSON envelope which we accept on downlink
|
||||||
bool isValidJsonEnvelope(JSONObject &json);
|
bool isValidJsonEnvelope(JSONObject &json);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ build_flags =
|
|||||||
-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
|
-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${esp32s3_base.lib_deps}
|
${esp32s3_base.lib_deps}
|
||||||
https://github.com/todd-herbert/meshtastic-GxEPD2#async
|
https://github.com/meshtastic/GxEPD2#55f618961db45a23eff0233546430f1e5a80f63a
|
||||||
adafruit/Adafruit BusIO@^1.13.2
|
adafruit/Adafruit BusIO@^1.13.2
|
||||||
lewisxhe/PCF8563_Library@^1.0.1
|
lewisxhe/PCF8563_Library@^1.0.1
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
@ -20,7 +20,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
|||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo>
|
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${nrf52840_base.lib_deps}
|
${nrf52840_base.lib_deps}
|
||||||
https://github.com/todd-herbert/meshtastic-GxEPD2#async
|
https://github.com/meshtastic/GxEPD2#55f618961db45a23eff0233546430f1e5a80f63a
|
||||||
adafruit/Adafruit BusIO@^1.13.2
|
adafruit/Adafruit BusIO@^1.13.2
|
||||||
lewisxhe/PCF8563_Library@^1.0.1
|
lewisxhe/PCF8563_Library@^1.0.1
|
||||||
;upload_protocol = fs
|
;upload_protocol = fs
|
||||||
|
Loading…
Reference in New Issue
Block a user