mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-17 09:01:30 +10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5224d115cc | ||
|
|
1fad0901ba | ||
|
|
ff95ba619c |
@@ -18,7 +18,7 @@ permissions: read-all
|
|||||||
jobs:
|
jobs:
|
||||||
pio-build:
|
pio-build:
|
||||||
name: build-${{ inputs.platform }}
|
name: build-${{ inputs.platform }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build ${{ inputs.platform }}
|
- name: Build ${{ inputs.platform }}
|
||||||
id: build
|
id: build
|
||||||
uses: meshtastic/gh-action-firmware@main
|
uses: fifieldt/gh-action-firmware@fifield
|
||||||
with:
|
with:
|
||||||
pio_platform: ${{ inputs.platform }}
|
pio_platform: ${{ inputs.platform }}
|
||||||
pio_env: ${{ inputs.pio_env }}
|
pio_env: ${{ inputs.pio_env }}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
setup:
|
setup:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
- rp2350
|
- rp2350
|
||||||
- stm32
|
- stm32
|
||||||
|
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ on:
|
|||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
- event/*
|
- event/*
|
||||||
|
- self-hosted-testing
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
#- "**.yml"
|
#- "**.yml"
|
||||||
@@ -41,7 +42,7 @@ jobs:
|
|||||||
- rp2350
|
- rp2350
|
||||||
- stm32
|
- stm32
|
||||||
- check
|
- check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
- rp2350
|
- rp2350
|
||||||
- stm32
|
- stm32
|
||||||
- check
|
- check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
|
|||||||
+5
-5
@@ -9,24 +9,24 @@ plugins:
|
|||||||
lint:
|
lint:
|
||||||
enabled:
|
enabled:
|
||||||
- checkov@3.2.471
|
- checkov@3.2.471
|
||||||
- renovate@41.130.1
|
- renovate@41.115.6
|
||||||
- prettier@3.6.2
|
- prettier@3.6.2
|
||||||
- trufflehog@3.90.8
|
- trufflehog@3.90.6
|
||||||
- yamllint@1.37.1
|
- yamllint@1.37.1
|
||||||
- bandit@1.8.6
|
- bandit@1.8.6
|
||||||
- trivy@0.66.0
|
- trivy@0.66.0
|
||||||
- taplo@0.10.0
|
- taplo@0.10.0
|
||||||
- ruff@0.13.1
|
- ruff@0.13.0
|
||||||
- isort@6.0.1
|
- isort@6.0.1
|
||||||
- markdownlint@0.45.0
|
- markdownlint@0.45.0
|
||||||
- oxipng@9.1.5
|
- oxipng@9.1.5
|
||||||
- svgo@4.0.0
|
- svgo@4.0.0
|
||||||
- actionlint@1.7.7
|
- actionlint@1.7.7
|
||||||
- flake8@7.3.0
|
- flake8@7.3.0
|
||||||
- hadolint@2.14.0
|
- hadolint@2.13.1
|
||||||
- shfmt@3.6.0
|
- shfmt@3.6.0
|
||||||
- shellcheck@0.11.0
|
- shellcheck@0.11.0
|
||||||
- black@25.9.0
|
- black@25.1.0
|
||||||
- git-diff-check
|
- git-diff-check
|
||||||
- gitleaks@8.28.0
|
- gitleaks@8.28.0
|
||||||
- clang-format@16.0.3
|
- clang-format@16.0.3
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ build_flags =
|
|||||||
-DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192
|
-DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192
|
||||||
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
|
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
|
||||||
-DSERIAL_BUFFER_SIZE=4096
|
-DSERIAL_BUFFER_SIZE=4096
|
||||||
-DSERIAL_HAS_ON_RECEIVE
|
|
||||||
-DLIBPAX_ARDUINO
|
-DLIBPAX_ARDUINO
|
||||||
-DLIBPAX_WIFI
|
-DLIBPAX_WIFI
|
||||||
-DLIBPAX_BLE
|
-DLIBPAX_BLE
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
[portduino_base]
|
[portduino_base]
|
||||||
platform =
|
platform =
|
||||||
# renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop
|
# renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop
|
||||||
https://github.com/meshtastic/platform-native/archive/d3f6e339534233c7217818867368767590ce549e.zip
|
https://github.com/meshtastic/platform-native/archive/c490bcd019e0658404088a61b96e653c9da22c45.zip
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
|
|||||||
@@ -87,9 +87,6 @@
|
|||||||
</screenshots>
|
</screenshots>
|
||||||
|
|
||||||
<releases>
|
<releases>
|
||||||
<release version="2.7.11" date="2025-09-24">
|
|
||||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.11</url>
|
|
||||||
</release>
|
|
||||||
<release version="2.7.10" date="2025-09-18">
|
<release version="2.7.10" date="2025-09-18">
|
||||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.10</url>
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.10</url>
|
||||||
</release>
|
</release>
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"build": {
|
|
||||||
"arduino": {
|
|
||||||
"ldscript": "nrf52840_s140_v6.ld"
|
|
||||||
},
|
|
||||||
"core": "nRF5",
|
|
||||||
"cpu": "cortex-m4",
|
|
||||||
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
|
|
||||||
"f_cpu": "64000000L",
|
|
||||||
"hwids": [
|
|
||||||
["0x239A", "0x8029"],
|
|
||||||
["0x239A", "0x0029"],
|
|
||||||
["0x239A", "0x002A"],
|
|
||||||
["0x239A", "0x802A"]
|
|
||||||
],
|
|
||||||
"usb_product": "Muzi R1 Neo",
|
|
||||||
"mcu": "nrf52840",
|
|
||||||
"variant": "r1-neo",
|
|
||||||
"bsp": {
|
|
||||||
"name": "adafruit"
|
|
||||||
},
|
|
||||||
"softdevice": {
|
|
||||||
"sd_flags": "-DS140",
|
|
||||||
"sd_name": "s140",
|
|
||||||
"sd_version": "6.1.1",
|
|
||||||
"sd_fwid": "0x00B6"
|
|
||||||
},
|
|
||||||
"bootloader": {
|
|
||||||
"settings_addr": "0xFF000"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"connectivity": ["bluetooth"],
|
|
||||||
"debug": {
|
|
||||||
"jlink_device": "nRF52840_xxAA",
|
|
||||||
"svd_path": "nrf52840.svd",
|
|
||||||
"openocd_target": "nrf52840-mdk-rs"
|
|
||||||
},
|
|
||||||
"frameworks": ["arduino", "freertos"],
|
|
||||||
"name": "WisCore RAK4631 Board",
|
|
||||||
"upload": {
|
|
||||||
"maximum_ram_size": 248832,
|
|
||||||
"maximum_size": 815104,
|
|
||||||
"speed": 115200,
|
|
||||||
"protocol": "nrfutil",
|
|
||||||
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"],
|
|
||||||
"use_1200bps_touch": true,
|
|
||||||
"require_upload_port": true,
|
|
||||||
"wait_for_upload_port": true
|
|
||||||
},
|
|
||||||
"url": "https://muzi.works/",
|
|
||||||
"vendor": "Muzi Works"
|
|
||||||
}
|
|
||||||
Vendored
+42
-3
@@ -1,10 +1,49 @@
|
|||||||
meshtasticd (2.7.11.0) UNRELEASED; urgency=medium
|
meshtasticd (2.7.10.0) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
[ Austin Lane ]
|
|
||||||
* Initial packaging
|
* Initial packaging
|
||||||
* Version 2.5.19
|
* Version 2.5.19
|
||||||
|
|
||||||
[ ]
|
[ ]
|
||||||
* GitHub Actions Automatic version bump
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
-- <github-actions[bot]@users.noreply.github.com> Wed, 24 Sep 2025 11:01:13 +0000
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ Ubuntu ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
-- <github-actions[bot]@users.noreply.github.com> Thu, 18 Sep 2025 22:11:37 +0000
|
||||||
|
|||||||
+1
-2
@@ -56,7 +56,6 @@ build_flags = -Wno-missing-field-initializers
|
|||||||
#-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now
|
#-DBUILD_EPOCH=$UNIX_TIME ; set in platformio-custom.py now
|
||||||
#-D OLED_PL=1
|
#-D OLED_PL=1
|
||||||
#-D DEBUG_HEAP=1 ; uncomment to add free heap space / memory leak debugging logs
|
#-D DEBUG_HEAP=1 ; uncomment to add free heap space / memory leak debugging logs
|
||||||
#-D DEBUG_LOOP_TIMING=1 ; uncomment to add main loop timing logs
|
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_filters = direct
|
monitor_filters = direct
|
||||||
@@ -126,7 +125,7 @@ lib_deps =
|
|||||||
[environmental_base]
|
[environmental_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
# renovate: datasource=custom.pio depName=Adafruit BusIO packageName=adafruit/library/Adafruit BusIO
|
# renovate: datasource=custom.pio depName=Adafruit BusIO packageName=adafruit/library/Adafruit BusIO
|
||||||
adafruit/Adafruit BusIO@1.17.4
|
adafruit/Adafruit BusIO@1.17.3
|
||||||
# renovate: datasource=custom.pio depName=Adafruit Unified Sensor packageName=adafruit/library/Adafruit Unified Sensor
|
# renovate: datasource=custom.pio depName=Adafruit Unified Sensor packageName=adafruit/library/Adafruit Unified Sensor
|
||||||
adafruit/Adafruit Unified Sensor@1.1.15
|
adafruit/Adafruit Unified Sensor@1.1.15
|
||||||
# renovate: datasource=custom.pio depName=Adafruit BMP280 packageName=adafruit/library/Adafruit BMP280 Library
|
# renovate: datasource=custom.pio depName=Adafruit BMP280 packageName=adafruit/library/Adafruit BMP280 Library
|
||||||
|
|||||||
+1
-1
Submodule protobufs updated: 5fa4c44d91...46b81e822a
@@ -26,7 +26,6 @@ class AudioThread : public concurrency::OSThread
|
|||||||
i2sRtttl->begin(rtttlFile, audioOut);
|
i2sRtttl->begin(rtttlFile, audioOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also handles actually playing the RTTTL, needs to be called in loop
|
|
||||||
bool isPlaying()
|
bool isPlaying()
|
||||||
{
|
{
|
||||||
if (i2sRtttl != nullptr) {
|
if (i2sRtttl != nullptr) {
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ const char *DisplayFormatters::getDeviceRole(meshtastic_Config_DeviceConfig_Role
|
|||||||
case meshtastic_Config_DeviceConfig_Role_ROUTER_LATE:
|
case meshtastic_Config_DeviceConfig_Role_ROUTER_LATE:
|
||||||
return "Router Late";
|
return "Router Late";
|
||||||
break;
|
break;
|
||||||
|
case meshtastic_Config_DeviceConfig_Role_REPEATER:
|
||||||
|
return "Repeater";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
break;
|
break;
|
||||||
|
|||||||
+6
-38
@@ -6,14 +6,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_USB_CDC_ON_BOOT) && ARDUINO_USB_CDC_ON_BOOT
|
|
||||||
#define IS_USB_SERIAL
|
|
||||||
#ifdef SERIAL_HAS_ON_RECEIVE
|
|
||||||
#undef SERIAL_HAS_ON_RECEIVE
|
|
||||||
#endif
|
|
||||||
#include "HWCDC.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RP2040_SLOW_CLOCK
|
#ifdef RP2040_SLOW_CLOCK
|
||||||
#define Port Serial2
|
#define Port Serial2
|
||||||
#else
|
#else
|
||||||
@@ -30,12 +22,7 @@ SerialConsole *console;
|
|||||||
|
|
||||||
void consoleInit()
|
void consoleInit()
|
||||||
{
|
{
|
||||||
auto sc = new SerialConsole(); // Must be dynamically allocated because we are now inheriting from thread
|
new SerialConsole(); // Must be dynamically allocated because we are now inheriting from thread
|
||||||
|
|
||||||
#if defined(SERIAL_HAS_ON_RECEIVE)
|
|
||||||
// onReceive does only exist for HardwareSerial not for USB CDC serial
|
|
||||||
Port.onReceive([sc]() { sc->rxInt(); });
|
|
||||||
#endif
|
|
||||||
DEBUG_PORT.rpInit(); // Simply sets up semaphore
|
DEBUG_PORT.rpInit(); // Simply sets up semaphore
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,21 +65,14 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port), con
|
|||||||
int32_t SerialConsole::runOnce()
|
int32_t SerialConsole::runOnce()
|
||||||
{
|
{
|
||||||
#ifdef HELTEC_MESH_SOLAR
|
#ifdef HELTEC_MESH_SOLAR
|
||||||
// After enabling the mesh solar serial port module configuration, command processing is handled by the serial port module.
|
//After enabling the mesh solar serial port module configuration, command processing is handled by the serial port module.
|
||||||
if (moduleConfig.serial.enabled && moduleConfig.serial.override_console_serial_port &&
|
if(moduleConfig.serial.enabled && moduleConfig.serial.override_console_serial_port
|
||||||
moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MS_CONFIG) {
|
&& moduleConfig.serial.mode==meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MS_CONFIG)
|
||||||
|
{
|
||||||
return 250;
|
return 250;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return runOncePart();
|
||||||
int32_t delay = runOncePart();
|
|
||||||
#if defined(SERIAL_HAS_ON_RECEIVE)
|
|
||||||
return Port.available() ? delay : INT32_MAX;
|
|
||||||
#elif defined(IS_USB_SERIAL)
|
|
||||||
return HWCDC::isPlugged() ? delay : (1000 * 20);
|
|
||||||
#else
|
|
||||||
return delay;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialConsole::flush()
|
void SerialConsole::flush()
|
||||||
@@ -100,18 +80,6 @@ void SerialConsole::flush()
|
|||||||
Port.flush();
|
Port.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger tx of serial data
|
|
||||||
void SerialConsole::onNowHasData(uint32_t fromRadioNum)
|
|
||||||
{
|
|
||||||
setIntervalFromNow(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// trigger rx of serial data
|
|
||||||
void SerialConsole::rxInt()
|
|
||||||
{
|
|
||||||
setIntervalFromNow(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
||||||
bool SerialConsole::checkIsConnected()
|
bool SerialConsole::checkIsConnected()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,14 +32,11 @@ class SerialConsole : public StreamAPI, public RedirectablePrint, private concur
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
void flush();
|
void flush();
|
||||||
void rxInt();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Check the current underlying physical link to see if the client is currently connected
|
/// Check the current underlying physical link to see if the client is currently connected
|
||||||
virtual bool checkIsConnected() override;
|
virtual bool checkIsConnected() override;
|
||||||
|
|
||||||
virtual void onNowHasData(uint32_t fromRadioNum) override;
|
|
||||||
|
|
||||||
/// Possibly switch to protobufs if we see a valid protobuf message
|
/// Possibly switch to protobufs if we see a valid protobuf message
|
||||||
virtual void log_to_serial(const char *logLevel, const char *format, va_list arg);
|
virtual void log_to_serial(const char *logLevel, const char *format, va_list arg);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
BuzzerFeedbackThread *buzzerFeedbackThread;
|
BuzzerFeedbackThread *buzzerFeedbackThread;
|
||||||
|
|
||||||
BuzzerFeedbackThread::BuzzerFeedbackThread()
|
BuzzerFeedbackThread::BuzzerFeedbackThread() : OSThread("BuzzerFeedback")
|
||||||
{
|
{
|
||||||
if (inputBroker)
|
if (inputBroker)
|
||||||
inputObserver.observe(inputBroker);
|
inputObserver.observe(inputBroker);
|
||||||
@@ -19,6 +19,10 @@ int BuzzerFeedbackThread::handleInputEvent(const InputEvent *event)
|
|||||||
return 0; // Let other handlers process the event
|
return 0; // Let other handlers process the event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Track last event time for potential future use
|
||||||
|
lastEventTime = millis();
|
||||||
|
needsUpdate = true;
|
||||||
|
|
||||||
// Handle different input events with appropriate buzzer feedback
|
// Handle different input events with appropriate buzzer feedback
|
||||||
switch (event->inputEvent) {
|
switch (event->inputEvent) {
|
||||||
case INPUT_BROKER_USER_PRESS:
|
case INPUT_BROKER_USER_PRESS:
|
||||||
@@ -57,4 +61,15 @@ int BuzzerFeedbackThread::handleInputEvent(const InputEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0; // Allow other handlers to process the event
|
return 0; // Allow other handlers to process the event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t BuzzerFeedbackThread::runOnce()
|
||||||
|
{
|
||||||
|
// This thread is primarily event-driven, but we can use runOnce
|
||||||
|
// for any periodic tasks if needed in the future
|
||||||
|
|
||||||
|
needsUpdate = false;
|
||||||
|
|
||||||
|
// Run every 100ms when active, less frequently when idle
|
||||||
|
return needsUpdate ? 100 : 1000;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
#include "input/InputBroker.h"
|
#include "input/InputBroker.h"
|
||||||
|
|
||||||
class BuzzerFeedbackThread
|
class BuzzerFeedbackThread : public concurrency::OSThread
|
||||||
{
|
{
|
||||||
CallbackObserver<BuzzerFeedbackThread, const InputEvent *> inputObserver =
|
CallbackObserver<BuzzerFeedbackThread, const InputEvent *> inputObserver =
|
||||||
CallbackObserver<BuzzerFeedbackThread, const InputEvent *>(this, &BuzzerFeedbackThread::handleInputEvent);
|
CallbackObserver<BuzzerFeedbackThread, const InputEvent *>(this, &BuzzerFeedbackThread::handleInputEvent);
|
||||||
@@ -12,6 +12,13 @@ class BuzzerFeedbackThread
|
|||||||
public:
|
public:
|
||||||
BuzzerFeedbackThread();
|
BuzzerFeedbackThread();
|
||||||
int handleInputEvent(const InputEvent *event);
|
int handleInputEvent(const InputEvent *event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t lastEventTime = 0;
|
||||||
|
bool needsUpdate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BuzzerFeedbackThread *buzzerFeedbackThread;
|
extern BuzzerFeedbackThread *buzzerFeedbackThread;
|
||||||
|
|||||||
@@ -90,9 +90,7 @@ void OSThread::run()
|
|||||||
if (heap < newHeap)
|
if (heap < newHeap)
|
||||||
LOG_HEAP("++++++ Thread %s freed heap %d -> %d (%d) ++++++", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
LOG_HEAP("++++++ Thread %s freed heap %d -> %d (%d) ++++++", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG_LOOP_TIMING
|
|
||||||
LOG_DEBUG("====== Thread next run in: %d", newDelay);
|
|
||||||
#endif
|
|
||||||
runned();
|
runned();
|
||||||
|
|
||||||
if (newDelay >= 0)
|
if (newDelay >= 0)
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ ScanI2C::FoundDevice ScanI2C::firstScreen() const
|
|||||||
|
|
||||||
ScanI2C::FoundDevice ScanI2C::firstRTC() const
|
ScanI2C::FoundDevice ScanI2C::firstRTC() const
|
||||||
{
|
{
|
||||||
ScanI2C::DeviceType types[] = {RTC_RV3028, RTC_PCF8563, RTC_RX8130CE};
|
ScanI2C::DeviceType types[] = {RTC_RV3028, RTC_PCF8563};
|
||||||
return firstOfOrNONE(3, types);
|
return firstOfOrNONE(2, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
|
ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class ScanI2C
|
|||||||
SCREEN_ST7567,
|
SCREEN_ST7567,
|
||||||
RTC_RV3028,
|
RTC_RV3028,
|
||||||
RTC_PCF8563,
|
RTC_PCF8563,
|
||||||
RTC_RX8130CE,
|
|
||||||
CARDKB,
|
CARDKB,
|
||||||
TDECKKB,
|
TDECKKB,
|
||||||
BBQ10KB,
|
BBQ10KB,
|
||||||
|
|||||||
@@ -197,9 +197,6 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
#ifdef PCF8563_RTC
|
#ifdef PCF8563_RTC
|
||||||
SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563", (uint8_t)addr.address)
|
SCAN_SIMPLE_CASE(PCF8563_RTC, RTC_PCF8563, "PCF8563", (uint8_t)addr.address)
|
||||||
#endif
|
#endif
|
||||||
#ifdef RX8130CE_RTC
|
|
||||||
SCAN_SIMPLE_CASE(RX8130CE_RTC, RTC_RX8130CE, "RX8130CE", (uint8_t)addr.address)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case CARDKB_ADDR:
|
case CARDKB_ADDR:
|
||||||
// Do we have the RAK14006 instead?
|
// Do we have the RAK14006 instead?
|
||||||
|
|||||||
@@ -1104,6 +1104,11 @@ int32_t GPS::runOnce()
|
|||||||
publishUpdate();
|
publishUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repeaters have no need for GPS
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
|
return disable();
|
||||||
|
}
|
||||||
|
|
||||||
if (whileActive()) {
|
if (whileActive()) {
|
||||||
// if we have received valid NMEA claim we are connected
|
// if we have received valid NMEA claim we are connected
|
||||||
setConnected();
|
setConnected();
|
||||||
|
|||||||
@@ -109,35 +109,6 @@ RTCSetResult readFromRTC()
|
|||||||
}
|
}
|
||||||
return RTCSetResultSuccess;
|
return RTCSetResultSuccess;
|
||||||
}
|
}
|
||||||
#elif defined(RX8130CE_RTC)
|
|
||||||
if (rtc_found.address == RX8130CE_RTC) {
|
|
||||||
uint32_t now = millis();
|
|
||||||
ArtronShop_RX8130CE rtc(&Wire);
|
|
||||||
tm t;
|
|
||||||
if (rtc.getTime(&t)) {
|
|
||||||
tv.tv_sec = gm_mktime(&t);
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
uint32_t printableEpoch = tv.tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms
|
|
||||||
LOG_DEBUG("Read RTC time from RX8130CE getDateTime as %02d-%02d-%02d %02d:%02d:%02d (%ld)", t.tm_year + 1900,
|
|
||||||
t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, printableEpoch);
|
|
||||||
#ifdef BUILD_EPOCH
|
|
||||||
if (tv.tv_sec < BUILD_EPOCH) {
|
|
||||||
if (Throttle::isWithinTimespanMs(lastTimeValidationWarning, TIME_VALIDATION_WARNING_INTERVAL_MS) == false) {
|
|
||||||
LOG_WARN("Ignore time (%ld) before build epoch (%ld)!", printableEpoch, BUILD_EPOCH);
|
|
||||||
lastTimeValidationWarning = millis();
|
|
||||||
}
|
|
||||||
return RTCSetResultInvalidTime;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (currentQuality == RTCQualityNone) {
|
|
||||||
timeStartMsec = now;
|
|
||||||
zeroOffsetSecs = tv.tv_sec;
|
|
||||||
currentQuality = RTCQualityDevice;
|
|
||||||
}
|
|
||||||
return RTCSetResultSuccess;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (!gettimeofday(&tv, NULL)) {
|
if (!gettimeofday(&tv, NULL)) {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
@@ -243,17 +214,6 @@ RTCSetResult perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpd
|
|||||||
LOG_DEBUG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
LOG_DEBUG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
||||||
t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
|
t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
|
||||||
}
|
}
|
||||||
#elif defined(RX8130CE_RTC)
|
|
||||||
if (rtc_found.address == RX8130CE_RTC) {
|
|
||||||
ArtronShop_RX8130CE rtc(&Wire);
|
|
||||||
tm *t = gmtime(&tv->tv_sec);
|
|
||||||
if (rtc.setTime(*t)) {
|
|
||||||
LOG_DEBUG("RX8130CE setDateTime %02d-%02d-%02d %02d:%02d:%02d (%ld)", t->tm_year + 1900, t->tm_mon + 1,
|
|
||||||
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, printableEpoch);
|
|
||||||
} else {
|
|
||||||
LOG_WARN("Failed to set time for RX8130CE");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(ARCH_ESP32)
|
#elif defined(ARCH_ESP32)
|
||||||
settimeofday(tv, NULL);
|
settimeofday(tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
#include "sys/time.h"
|
#include "sys/time.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#ifdef RX8130CE_RTC
|
|
||||||
#include <ArtronShop_RX8130CE.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum RTCQuality {
|
enum RTCQuality {
|
||||||
|
|
||||||
/// We haven't had our RTC set yet
|
/// We haven't had our RTC set yet
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ bool EInkDisplay::connect()
|
|||||||
adafruitDisplay->setRotation(1);
|
adafruitDisplay->setRotation(1);
|
||||||
adafruitDisplay->setPartialWindow(0, 0, EINK_WIDTH, EINK_HEIGHT);
|
adafruitDisplay->setPartialWindow(0, 0, EINK_WIDTH, EINK_HEIGHT);
|
||||||
}
|
}
|
||||||
#elif defined(HELTEC_MESH_POCKET) || defined(SEEED_WIO_TRACKER_L1_EINK) || defined(HELTEC_MESH_SOLAR_EINK)
|
#elif defined(HELTEC_MESH_POCKET) || defined(SEEED_WIO_TRACKER_L1_EINK)
|
||||||
{
|
{
|
||||||
spi1 = &SPI1;
|
spi1 = &SPI1;
|
||||||
spi1->begin();
|
spi1->begin();
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class EInkDisplay : public OLEDDisplay
|
|||||||
SPIClass *hspi = NULL;
|
SPIClass *hspi = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HELTEC_MESH_POCKET) || defined(SEEED_WIO_TRACKER_L1_EINK) || defined(HELTEC_MESH_SOLAR_EINK)
|
#if defined(HELTEC_MESH_POCKET) || defined(SEEED_WIO_TRACKER_L1_EINK)
|
||||||
SPIClass *spi1 = NULL;
|
SPIClass *spi1 = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -83,11 +83,6 @@ extern uint16_t TFT_MESH;
|
|||||||
#include "platform/portduino/PortduinoGlue.h"
|
#include "platform/portduino/PortduinoGlue.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(T_LORA_PAGER)
|
|
||||||
// KB backlight control
|
|
||||||
#include "input/cardKbI2cImpl.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace meshtastic; /** @todo remove */
|
using namespace meshtastic; /** @todo remove */
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
@@ -660,19 +655,6 @@ void Screen::setup()
|
|||||||
MeshModule::observeUIEvents(&uiFrameEventObserver);
|
MeshModule::observeUIEvents(&uiFrameEventObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::setOn(bool on, FrameCallback einkScreensaver)
|
|
||||||
{
|
|
||||||
#if defined(T_LORA_PAGER)
|
|
||||||
if (cardKbI2cImpl)
|
|
||||||
cardKbI2cImpl->toggleBacklight(on);
|
|
||||||
#endif
|
|
||||||
if (!on)
|
|
||||||
// We handle off commands immediately, because they might be called because the CPU is shutting down
|
|
||||||
handleSetOn(false, einkScreensaver);
|
|
||||||
else
|
|
||||||
enqueueCmd(ScreenCmd{.cmd = Cmd::SET_ON});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::forceDisplay(bool forceUiUpdate)
|
void Screen::forceDisplay(bool forceUiUpdate)
|
||||||
{
|
{
|
||||||
// Nasty hack to force epaper updates for 'key' frames. FIXME, cleanup.
|
// Nasty hack to force epaper updates for 'key' frames. FIXME, cleanup.
|
||||||
|
|||||||
@@ -259,7 +259,15 @@ class Screen : public concurrency::OSThread
|
|||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
/// Turns the screen on/off. Optionally, pass a custom screensaver frame for E-Ink
|
/// Turns the screen on/off. Optionally, pass a custom screensaver frame for E-Ink
|
||||||
void setOn(bool on, FrameCallback einkScreensaver = NULL);
|
void setOn(bool on, FrameCallback einkScreensaver = NULL)
|
||||||
|
{
|
||||||
|
if (!on)
|
||||||
|
// We handle off commands immediately, because they might be called because the CPU is shutting down
|
||||||
|
handleSetOn(false, einkScreensaver);
|
||||||
|
else
|
||||||
|
enqueueCmd(ScreenCmd{.cmd = Cmd::SET_ON});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the display for the unit going to the lowest power mode possible. Most screens will just
|
* Prepare the display for the unit going to the lowest power mode possible. Most screens will just
|
||||||
* poweroff, but eink screens will show a "I'm sleeping" graphic, possibly with a QR code
|
* poweroff, but eink screens will show a "I'm sleeping" graphic, possibly with a QR code
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
|||||||
int iconX = iconRightEdge - mute_symbol_big_width;
|
int iconX = iconRightEdge - mute_symbol_big_width;
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
||||||
|
|
||||||
if (isInverted && !force_no_invert) {
|
if (isInverted) {
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
||||||
display->setColor(BLACK);
|
display->setColor(BLACK);
|
||||||
|
|||||||
@@ -852,31 +852,24 @@ void menuHandler::GPSFormatMenu()
|
|||||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||||
if (selected == 1) {
|
if (selected == 1) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_DEC;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_DEC;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 2) {
|
} else if (selected == 2) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_DMS;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_DMS;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 3) {
|
} else if (selected == 3) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_UTM;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_UTM;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 4) {
|
} else if (selected == 4) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_MGRS;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_MGRS;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 5) {
|
} else if (selected == 5) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_OLC;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_OLC;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 6) {
|
} else if (selected == 6) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_OSGR;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_OSGR;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else if (selected == 7) {
|
} else if (selected == 7) {
|
||||||
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_MLS;
|
uiconfig.gps_format = meshtastic_DeviceUIConfig_GpsCoordinateFormat_MLS;
|
||||||
saveUIConfig();
|
|
||||||
service->reloadConfig(SEGMENT_CONFIG);
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
} else {
|
} else {
|
||||||
menuQueue = position_base_menu;
|
menuQueue = position_base_menu;
|
||||||
|
|||||||
@@ -125,10 +125,8 @@ void UIRenderer::drawGpsCoordinates(OLEDDisplay *display, int16_t x, int16_t y,
|
|||||||
char displayLine[32];
|
char displayLine[32];
|
||||||
|
|
||||||
if (!gps->getIsConnected() && !config.position.fixed_position) {
|
if (!gps->getIsConnected() && !config.position.fixed_position) {
|
||||||
if (strcmp(mode, "line1") == 0) {
|
strcpy(displayLine, "No GPS present");
|
||||||
strcpy(displayLine, "No GPS present");
|
display->drawString(x, y, displayLine);
|
||||||
display->drawString(x, y, displayLine);
|
|
||||||
}
|
|
||||||
} else if (!gps->getHasLock() && !config.position.fixed_position) {
|
} else if (!gps->getHasLock() && !config.position.fixed_position) {
|
||||||
if (strcmp(mode, "line1") == 0) {
|
if (strcmp(mode, "line1") == 0) {
|
||||||
strcpy(displayLine, "No GPS Lock");
|
strcpy(displayLine, "No GPS Lock");
|
||||||
@@ -1105,18 +1103,6 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
|
|||||||
// === Fourth Row: Line 2 GPS Info ===
|
// === Fourth Row: Line 2 GPS Info ===
|
||||||
UIRenderer::drawGpsCoordinates(display, x, getTextPositions(display)[line++], gpsStatus, "line2");
|
UIRenderer::drawGpsCoordinates(display, x, getTextPositions(display)[line++], gpsStatus, "line2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Final Row: Altitude ===
|
|
||||||
char altitudeLine[32] = {0};
|
|
||||||
int32_t alt = (strcmp(displayLine, "Phone GPS") == 0 && ourNode && nodeDB->hasValidPosition(ourNode))
|
|
||||||
? ourNode->position.altitude
|
|
||||||
: geoCoord.getAltitude();
|
|
||||||
if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) {
|
|
||||||
snprintf(altitudeLine, sizeof(altitudeLine), "Alt: %.0fft", alt * METERS_TO_FEET);
|
|
||||||
} else {
|
|
||||||
snprintf(altitudeLine, sizeof(altitudeLine), "Alt: %.0im", alt);
|
|
||||||
}
|
|
||||||
display->drawString(x, getTextPositions(display)[line++], altitudeLine);
|
|
||||||
}
|
}
|
||||||
#if !defined(M5STACK_UNITC6L)
|
#if !defined(M5STACK_UNITC6L)
|
||||||
// === Draw Compass if heading is valid ===
|
// === Draw Compass if heading is valid ===
|
||||||
|
|||||||
@@ -274,12 +274,7 @@ int32_t ButtonThread::runOnce()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
btnEvent = BUTTON_EVENT_NONE;
|
btnEvent = BUTTON_EVENT_NONE;
|
||||||
|
return 50;
|
||||||
// only pull when the button is pressed, we get notified via IRQ on a new press
|
|
||||||
if (!userButton.isIdle() || waitingForLongPress) {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
return 100; // FIXME: Why can't we rely on interrupts and use INT32_MAX here?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -200,11 +200,6 @@ uint8_t TCA8418KeyboardBase::flush()
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCA8418KeyboardBase::clearInt()
|
|
||||||
{
|
|
||||||
writeRegister(TCA8418_REG_INT_STAT, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t TCA8418KeyboardBase::digitalRead(uint8_t pinnum) const
|
uint8_t TCA8418KeyboardBase::digitalRead(uint8_t pinnum) const
|
||||||
{
|
{
|
||||||
if (pinnum > TCA8418_COL9)
|
if (pinnum > TCA8418_COL9)
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ class TCA8418KeyboardBase
|
|||||||
virtual void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = TCA8418_KB_ADDR);
|
virtual void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = TCA8418_KB_ADDR);
|
||||||
|
|
||||||
virtual void reset(void);
|
virtual void reset(void);
|
||||||
void clearInt(void);
|
|
||||||
|
|
||||||
virtual void trigger(void);
|
virtual void trigger(void);
|
||||||
|
|
||||||
virtual void setBacklight(bool on);
|
virtual void setBacklight(bool on);
|
||||||
|
|||||||
@@ -105,14 +105,7 @@ void TLoraPagerKeyboard::trigger()
|
|||||||
|
|
||||||
void TLoraPagerKeyboard::setBacklight(bool on)
|
void TLoraPagerKeyboard::setBacklight(bool on)
|
||||||
{
|
{
|
||||||
uint32_t _brightness = 0;
|
toggleBacklight(!on);
|
||||||
if (on)
|
|
||||||
_brightness = brightness;
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
|
||||||
ledcWrite(KB_BL_PIN, _brightness);
|
|
||||||
#else
|
|
||||||
ledcWrite(LEDC_BACKLIGHT_CHANNEL, _brightness);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLoraPagerKeyboard::pressed(uint8_t key)
|
void TLoraPagerKeyboard::pressed(uint8_t key)
|
||||||
@@ -199,6 +192,7 @@ void TLoraPagerKeyboard::hapticFeedback()
|
|||||||
// toggle brightness of the backlight in three steps
|
// toggle brightness of the backlight in three steps
|
||||||
void TLoraPagerKeyboard::toggleBacklight(bool off)
|
void TLoraPagerKeyboard::toggleBacklight(bool off)
|
||||||
{
|
{
|
||||||
|
static uint32_t brightness = 0;
|
||||||
if (off) {
|
if (off) {
|
||||||
brightness = 0;
|
brightness = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -212,7 +206,11 @@ void TLoraPagerKeyboard::toggleBacklight(bool off)
|
|||||||
}
|
}
|
||||||
LOG_DEBUG("Toggle backlight: %d", brightness);
|
LOG_DEBUG("Toggle backlight: %d", brightness);
|
||||||
|
|
||||||
setBacklight(true);
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
|
ledcWrite(KB_BL_PIN, brightness);
|
||||||
|
#else
|
||||||
|
ledcWrite(LEDC_BACKLIGHT_CHANNEL, brightness);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLoraPagerKeyboard::updateModifierFlag(uint8_t key)
|
void TLoraPagerKeyboard::updateModifierFlag(uint8_t key)
|
||||||
|
|||||||
@@ -26,5 +26,4 @@ class TLoraPagerKeyboard : public TCA8418KeyboardBase
|
|||||||
uint32_t last_tap;
|
uint32_t last_tap;
|
||||||
uint8_t char_idx;
|
uint8_t char_idx;
|
||||||
int32_t tap_interval;
|
int32_t tap_interval;
|
||||||
uint32_t brightness = 0;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -333,7 +333,6 @@ int32_t KbI2cBase::runOnce()
|
|||||||
}
|
}
|
||||||
TCAKeyboard.trigger();
|
TCAKeyboard.trigger();
|
||||||
}
|
}
|
||||||
TCAKeyboard.clearInt();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x02: {
|
case 0x02: {
|
||||||
@@ -520,11 +519,4 @@ int32_t KbI2cBase::runOnce()
|
|||||||
LOG_WARN("Unknown kb_model 0x%02x", kb_model);
|
LOG_WARN("Unknown kb_model 0x%02x", kb_model);
|
||||||
}
|
}
|
||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KbI2cBase::toggleBacklight(bool on)
|
|
||||||
{
|
|
||||||
#if defined(T_LORA_PAGER)
|
|
||||||
TCAKeyboard.setBacklight(on);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ class KbI2cBase : public Observable<const InputEvent *>, public concurrency::OST
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit KbI2cBase(const char *name);
|
explicit KbI2cBase(const char *name);
|
||||||
void toggleBacklight(bool on);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|||||||
+10
-18
@@ -297,12 +297,6 @@ void printInfo()
|
|||||||
#ifndef PIO_UNIT_TESTING
|
#ifndef PIO_UNIT_TESTING
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
#if defined(R1_NEO)
|
|
||||||
pinMode(DCDC_EN_HOLD, OUTPUT);
|
|
||||||
digitalWrite(DCDC_EN_HOLD, HIGH);
|
|
||||||
pinMode(NRF_ON, OUTPUT);
|
|
||||||
digitalWrite(NRF_ON, HIGH);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PIN_POWER_EN)
|
#if defined(PIN_POWER_EN)
|
||||||
pinMode(PIN_POWER_EN, OUTPUT);
|
pinMode(PIN_POWER_EN, OUTPUT);
|
||||||
@@ -375,7 +369,6 @@ void setup()
|
|||||||
digitalWrite(SDCARD_CS, HIGH);
|
digitalWrite(SDCARD_CS, HIGH);
|
||||||
pinMode(TFT_CS, OUTPUT);
|
pinMode(TFT_CS, OUTPUT);
|
||||||
digitalWrite(TFT_CS, HIGH);
|
digitalWrite(TFT_CS, HIGH);
|
||||||
pinMode(KB_INT, INPUT_PULLUP);
|
|
||||||
// io expander
|
// io expander
|
||||||
io.begin(Wire, XL9555_SLAVE_ADDRESS0, SDA, SCL);
|
io.begin(Wire, XL9555_SLAVE_ADDRESS0, SDA, SCL);
|
||||||
io.pinMode(EXPANDS_DRV_EN, OUTPUT);
|
io.pinMode(EXPANDS_DRV_EN, OUTPUT);
|
||||||
@@ -799,7 +792,14 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
router = new ReliableRouter();
|
// If we're taking on the repeater role, use NextHopRouter and turn off 3V3_S rail because peripherals are not needed
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
|
router = new NextHopRouter();
|
||||||
|
#ifdef PIN_3V3_EN
|
||||||
|
digitalWrite(PIN_3V3_EN, LOW);
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
router = new ReliableRouter();
|
||||||
|
|
||||||
// only play start melody when role is not tracker or sensor
|
// only play start melody when role is not tracker or sensor
|
||||||
if (config.power.is_power_saving == true &&
|
if (config.power.is_power_saving == true &&
|
||||||
@@ -925,7 +925,8 @@ void setup()
|
|||||||
if (sensor_detected == false) {
|
if (sensor_detected == false) {
|
||||||
#endif
|
#endif
|
||||||
if (HAS_GPS) {
|
if (HAS_GPS) {
|
||||||
if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
|
config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
||||||
gps = GPS::createGps();
|
gps = GPS::createGps();
|
||||||
if (gps) {
|
if (gps) {
|
||||||
gpsStatus->observe(&gps->newStatus);
|
gpsStatus->observe(&gps->newStatus);
|
||||||
@@ -1000,7 +1001,6 @@ void setup()
|
|||||||
config.pullupSense = INPUT_PULLUP;
|
config.pullupSense = INPUT_PULLUP;
|
||||||
config.intRoutine = []() {
|
config.intRoutine = []() {
|
||||||
UserButtonThread->userButton.tick();
|
UserButtonThread->userButton.tick();
|
||||||
UserButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1021,7 +1021,6 @@ void setup()
|
|||||||
touchConfig.pullupSense = pullup_sense;
|
touchConfig.pullupSense = pullup_sense;
|
||||||
touchConfig.intRoutine = []() {
|
touchConfig.intRoutine = []() {
|
||||||
TouchButtonThread->userButton.tick();
|
TouchButtonThread->userButton.tick();
|
||||||
TouchButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1041,7 +1040,6 @@ void setup()
|
|||||||
cancelConfig.pullupSense = pullup_sense;
|
cancelConfig.pullupSense = pullup_sense;
|
||||||
cancelConfig.intRoutine = []() {
|
cancelConfig.intRoutine = []() {
|
||||||
CancelButtonThread->userButton.tick();
|
CancelButtonThread->userButton.tick();
|
||||||
CancelButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1062,7 +1060,6 @@ void setup()
|
|||||||
backConfig.pullupSense = pullup_sense;
|
backConfig.pullupSense = pullup_sense;
|
||||||
backConfig.intRoutine = []() {
|
backConfig.intRoutine = []() {
|
||||||
BackButtonThread->userButton.tick();
|
BackButtonThread->userButton.tick();
|
||||||
BackButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1097,7 +1094,6 @@ void setup()
|
|||||||
userConfig.pullupSense = pullup_sense;
|
userConfig.pullupSense = pullup_sense;
|
||||||
userConfig.intRoutine = []() {
|
userConfig.intRoutine = []() {
|
||||||
UserButtonThread->userButton.tick();
|
UserButtonThread->userButton.tick();
|
||||||
UserButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1115,7 +1111,6 @@ void setup()
|
|||||||
userConfigNoScreen.pullupSense = pullup_sense;
|
userConfigNoScreen.pullupSense = pullup_sense;
|
||||||
userConfigNoScreen.intRoutine = []() {
|
userConfigNoScreen.intRoutine = []() {
|
||||||
UserButtonThread->userButton.tick();
|
UserButtonThread->userButton.tick();
|
||||||
UserButtonThread->setIntervalFromNow(0);
|
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
@@ -1611,9 +1606,6 @@ void loop()
|
|||||||
|
|
||||||
// We want to sleep as long as possible here - because it saves power
|
// We want to sleep as long as possible here - because it saves power
|
||||||
if (!runASAP && loopCanSleep()) {
|
if (!runASAP && loopCanSleep()) {
|
||||||
#ifdef DEBUG_LOOP_TIMING
|
|
||||||
LOG_DEBUG("main loop delay: %d", delayMsec);
|
|
||||||
#endif
|
|
||||||
mainDelay.delay(delayMsec);
|
mainDelay.delay(delayMsec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
#include "FloodingRouter.h"
|
#include "FloodingRouter.h"
|
||||||
#include "MeshTypes.h"
|
|
||||||
#include "NodeDB.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
#include "meshUtils.h"
|
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
||||||
#include "modules/TraceRouteModule.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FloodingRouter::FloodingRouter() {}
|
FloodingRouter::FloodingRouter() {}
|
||||||
|
|
||||||
@@ -26,41 +21,7 @@ ErrorCode FloodingRouter::send(meshtastic_MeshPacket *p)
|
|||||||
|
|
||||||
bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
bool wasUpgraded = false;
|
if (wasSeenRecently(p)) { // Note: this will also add a recent packet record
|
||||||
bool seenRecently =
|
|
||||||
wasSeenRecently(p, true, nullptr, nullptr, &wasUpgraded); // Updates history; returns false when an upgrade is detected
|
|
||||||
|
|
||||||
// Handle hop_limit upgrade scenario for rebroadcasters
|
|
||||||
// isRebroadcaster() is duplicated in perhapsRebroadcast(), but this avoids confusing log messages
|
|
||||||
if (wasUpgraded && isRebroadcaster() && iface && p->hop_limit > 0) {
|
|
||||||
// wasSeenRecently() reports false in upgrade cases so we handle replacement before the duplicate short-circuit
|
|
||||||
// If we overhear a duplicate copy of the packet with more hops left than the one we are waiting to
|
|
||||||
// rebroadcast, then remove the packet currently sitting in the TX queue and use this one instead.
|
|
||||||
uint8_t dropThreshold = p->hop_limit; // remove queued packets that have fewer hops remaining
|
|
||||||
if (iface->removePendingTXPacket(getFrom(p), p->id, dropThreshold)) {
|
|
||||||
LOG_DEBUG("Processing upgraded packet 0x%08x for rebroadcast with hop limit %d (dropping queued < %d)", p->id,
|
|
||||||
p->hop_limit, dropThreshold);
|
|
||||||
|
|
||||||
if (nodeDB)
|
|
||||||
nodeDB->updateFrom(*p);
|
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
||||||
if (traceRouteModule && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
|
|
||||||
p->decoded.portnum == meshtastic_PortNum_TRACEROUTE_APP)
|
|
||||||
traceRouteModule->processUpgradedPacket(*p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
perhapsRebroadcast(p);
|
|
||||||
|
|
||||||
// We already enqueued the improved copy, so make sure the incoming packet stops here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No queue entry was replaced by this upgraded copy, so treat it as a duplicate to avoid
|
|
||||||
// delivering the same packet to applications/phone twice with different hop limits.
|
|
||||||
seenRecently = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seenRecently) {
|
|
||||||
printPacket("Ignore dupe incoming msg", p);
|
printPacket("Ignore dupe incoming msg", p);
|
||||||
rxDupe++;
|
rxDupe++;
|
||||||
|
|
||||||
@@ -85,8 +46,9 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
|||||||
bool FloodingRouter::roleAllowsCancelingDupe(const meshtastic_MeshPacket *p)
|
bool FloodingRouter::roleAllowsCancelingDupe(const meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||||
|
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER ||
|
||||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
||||||
// ROUTER, ROUTER_LATE should never cancel relaying a packet (i.e. we should always rebroadcast),
|
// ROUTER, REPEATER, ROUTER_LATE should never cancel relaying a packet (i.e. we should always rebroadcast),
|
||||||
// even if we've heard another station rebroadcast it already.
|
// even if we've heard another station rebroadcast it already.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -105,7 +67,7 @@ bool FloodingRouter::roleAllowsCancelingDupe(const meshtastic_MeshPacket *p)
|
|||||||
void FloodingRouter::perhapsCancelDupe(const meshtastic_MeshPacket *p)
|
void FloodingRouter::perhapsCancelDupe(const meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
if (p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA && roleAllowsCancelingDupe(p)) {
|
if (p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA && roleAllowsCancelingDupe(p)) {
|
||||||
// cancel rebroadcast of this message *if* there was already one, unless we're a router!
|
// cancel rebroadcast of this message *if* there was already one, unless we're a router/repeater!
|
||||||
// But only LoRa packets should be able to trigger this.
|
// But only LoRa packets should be able to trigger this.
|
||||||
if (Router::cancelSending(p->from, p->id))
|
if (Router::cancelSending(p->from, p->id))
|
||||||
txRelayCanceled++;
|
txRelayCanceled++;
|
||||||
@@ -128,12 +90,7 @@ void FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
|||||||
if (isRebroadcaster()) {
|
if (isRebroadcaster()) {
|
||||||
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
|
|
||||||
// Use shared logic to determine if hop_limit should be decremented
|
tosend->hop_limit--; // bump down the hop count
|
||||||
if (shouldDecrementHopLimit(p)) {
|
|
||||||
tosend->hop_limit--; // bump down the hop count
|
|
||||||
} else {
|
|
||||||
LOG_INFO("favorite-ROUTER/CLIENT_BASE-to-ROUTER/CLIENT_BASE flood: preserving hop_limit");
|
|
||||||
}
|
|
||||||
#if USERPREFS_EVENT_MODE
|
#if USERPREFS_EVENT_MODE
|
||||||
if (tosend->hop_limit > 2) {
|
if (tosend->hop_limit > 2) {
|
||||||
// if we are "correcting" the hop_limit, "correct" the hop_start by the same amount to preserve hops away.
|
// if we are "correcting" the hop_limit, "correct" the hop_start by the same amount to preserve hops away.
|
||||||
@@ -141,12 +98,12 @@ void FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
|||||||
tosend->hop_limit = 2;
|
tosend->hop_limit = 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tosend->next_hop = NO_NEXT_HOP_PREFERENCE; // this should already be the case, but just in case
|
tosend->next_hop = NO_NEXT_HOP_PREFERENCE; // this should already be the case, but just in case
|
||||||
|
|
||||||
LOG_INFO("Rebroadcast received floodmsg");
|
LOG_INFO("Rebroadcast received floodmsg");
|
||||||
// Note: we are careful to resend using the original senders node id
|
// Note: we are careful to resend using the original senders node id
|
||||||
send(tosend);
|
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
||||||
|
Router::send(tosend);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("No rebroadcast: Role = CLIENT_MUTE or Rebroadcast Mode = NONE");
|
LOG_DEBUG("No rebroadcast: Role = CLIENT_MUTE or Rebroadcast Mode = NONE");
|
||||||
}
|
}
|
||||||
@@ -170,4 +127,4 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
|
|||||||
|
|
||||||
// handle the packet as normal
|
// handle the packet as normal
|
||||||
Router::sniffReceived(p, c);
|
Router::sniffReceived(p, c);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ class FloodingRouter : public Router
|
|||||||
*/
|
*/
|
||||||
virtual void sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) override;
|
virtual void sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) override;
|
||||||
|
|
||||||
// Return false for roles like ROUTER which should always rebroadcast even when we've heard another rebroadcast of
|
// Return false for roles like ROUTER or REPEATER which should always rebroadcast even when we've heard another rebroadcast of
|
||||||
// the same packet
|
// the same packet
|
||||||
bool roleAllowsCancelingDupe(const meshtastic_MeshPacket *p);
|
bool roleAllowsCancelingDupe(const meshtastic_MeshPacket *p);
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ template <typename T> bool LR11x0Interface<T>::reconfigure()
|
|||||||
if (err != RADIOLIB_ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||||
|
|
||||||
err = lora.setBandwidth(bw, wideLora() && (getFreq() > 1000.0f));
|
err = lora.setBandwidth(bw);
|
||||||
if (err != RADIOLIB_ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||||
|
|
||||||
|
|||||||
@@ -103,26 +103,12 @@ meshtastic_MeshPacket *MeshPacketQueue::getFront()
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a packet from this queue. Returns a pointer to the packet, or NULL if not found. */
|
|
||||||
meshtastic_MeshPacket *MeshPacketQueue::getPacketFromQueue(NodeNum from, PacketId id)
|
|
||||||
{
|
|
||||||
for (auto it = queue.begin(); it != queue.end(); it++) {
|
|
||||||
auto p = (*it);
|
|
||||||
if (getFrom(p) == from && p->id == id) {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Attempt to find and remove a packet from this queue. Returns a pointer to the removed packet, or NULL if not found */
|
/** Attempt to find and remove a packet from this queue. Returns a pointer to the removed packet, or NULL if not found */
|
||||||
meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool tx_normal, bool tx_late, uint8_t hop_limit_lt)
|
meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool tx_normal, bool tx_late)
|
||||||
{
|
{
|
||||||
for (auto it = queue.begin(); it != queue.end(); it++) {
|
for (auto it = queue.begin(); it != queue.end(); it++) {
|
||||||
auto p = (*it);
|
auto p = (*it);
|
||||||
if (getFrom(p) == from && p->id == id && ((tx_normal && !p->tx_after) || (tx_late && p->tx_after)) &&
|
if (getFrom(p) == from && p->id == id && ((tx_normal && !p->tx_after) || (tx_late && p->tx_after))) {
|
||||||
(!hop_limit_lt || p->hop_limit < hop_limit_lt)) {
|
|
||||||
queue.erase(it);
|
queue.erase(it);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -134,7 +120,14 @@ meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool t
|
|||||||
/* Attempt to find a packet from this queue. Return true if it was found. */
|
/* Attempt to find a packet from this queue. Return true if it was found. */
|
||||||
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
|
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
|
||||||
{
|
{
|
||||||
return getPacketFromQueue(from, id) != NULL;
|
for (auto it = queue.begin(); it != queue.end(); it++) {
|
||||||
|
const auto *p = *it;
|
||||||
|
if (getFrom(p) == from && p->id == id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,12 +35,8 @@ class MeshPacketQueue
|
|||||||
|
|
||||||
meshtastic_MeshPacket *getFront();
|
meshtastic_MeshPacket *getFront();
|
||||||
|
|
||||||
/** Get a packet from this queue. Returns a pointer to the packet, or NULL if not found. */
|
|
||||||
meshtastic_MeshPacket *getPacketFromQueue(NodeNum from, PacketId id);
|
|
||||||
|
|
||||||
/** Attempt to find and remove a packet from this queue. Returns the packet which was removed from the queue */
|
/** Attempt to find and remove a packet from this queue. Returns the packet which was removed from the queue */
|
||||||
meshtastic_MeshPacket *remove(NodeNum from, PacketId id, bool tx_normal = true, bool tx_late = true,
|
meshtastic_MeshPacket *remove(NodeNum from, PacketId id, bool tx_normal = true, bool tx_late = true);
|
||||||
uint8_t hop_limit_lt = 0);
|
|
||||||
|
|
||||||
/* Attempt to find a packet from this queue. Return true if it was found. */
|
/* Attempt to find a packet from this queue. Return true if it was found. */
|
||||||
bool find(const NodeNum from, const PacketId id);
|
bool find(const NodeNum from, const PacketId id);
|
||||||
|
|||||||
@@ -85,11 +85,12 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
|
|||||||
powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping
|
powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping
|
||||||
|
|
||||||
nodeDB->updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
|
nodeDB->updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
|
||||||
bool isPreferredRebroadcaster = config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER;
|
bool isPreferredRebroadcaster =
|
||||||
|
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_ROUTER, meshtastic_Config_DeviceConfig_Role_REPEATER);
|
||||||
if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
|
if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
|
||||||
mp->decoded.portnum == meshtastic_PortNum_TELEMETRY_APP && mp->decoded.request_id > 0) {
|
mp->decoded.portnum == meshtastic_PortNum_TELEMETRY_APP && mp->decoded.request_id > 0) {
|
||||||
LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo");
|
LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo"); // because this potentially a Repeater which will
|
||||||
// ignore our request for its NodeInfo
|
// ignore our request for its NodeInfo
|
||||||
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
||||||
nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) {
|
nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) {
|
||||||
if (airTime->isTxAllowedChannelUtil(true)) {
|
if (airTime->isTxAllowedChannelUtil(true)) {
|
||||||
@@ -452,4 +453,4 @@ uint32_t MeshService::GetTimeSinceMeshPacket(const meshtastic_MeshPacket *mp)
|
|||||||
delta = 0;
|
delta = 0;
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
@@ -190,4 +190,4 @@ class MeshService
|
|||||||
friend class RoutingModule;
|
friend class RoutingModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MeshService *service;
|
extern MeshService *service;
|
||||||
+10
-56
@@ -1,10 +1,4 @@
|
|||||||
#include "NextHopRouter.h"
|
#include "NextHopRouter.h"
|
||||||
#include "MeshTypes.h"
|
|
||||||
#include "meshUtils.h"
|
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
||||||
#include "modules/TraceRouteModule.h"
|
|
||||||
#endif
|
|
||||||
#include "NodeDB.h"
|
|
||||||
|
|
||||||
NextHopRouter::NextHopRouter() {}
|
NextHopRouter::NextHopRouter() {}
|
||||||
|
|
||||||
@@ -38,39 +32,7 @@ bool NextHopRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
|||||||
{
|
{
|
||||||
bool wasFallback = false;
|
bool wasFallback = false;
|
||||||
bool weWereNextHop = false;
|
bool weWereNextHop = false;
|
||||||
bool wasUpgraded = false;
|
if (wasSeenRecently(p, true, &wasFallback, &weWereNextHop)) { // Note: this will also add a recent packet record
|
||||||
bool seenRecently = wasSeenRecently(p, true, &wasFallback, &weWereNextHop,
|
|
||||||
&wasUpgraded); // Updates history; returns false when an upgrade is detected
|
|
||||||
|
|
||||||
// Handle hop_limit upgrade scenario for rebroadcasters
|
|
||||||
// isRebroadcaster() is duplicated in perhapsRelay(), but this avoids confusing log messages
|
|
||||||
if (wasUpgraded && isRebroadcaster() && iface && p->hop_limit > 0) {
|
|
||||||
// Upgrade detection bypasses the duplicate short-circuit so we replace the queued packet before exiting
|
|
||||||
uint8_t dropThreshold = p->hop_limit; // remove queued packets that have fewer hops remaining
|
|
||||||
if (iface->removePendingTXPacket(getFrom(p), p->id, dropThreshold)) {
|
|
||||||
LOG_DEBUG("Processing upgraded packet 0x%08x for relay with hop limit %d (dropping queued < %d)", p->id, p->hop_limit,
|
|
||||||
dropThreshold);
|
|
||||||
|
|
||||||
if (nodeDB)
|
|
||||||
nodeDB->updateFrom(*p);
|
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
||||||
if (traceRouteModule && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
|
|
||||||
p->decoded.portnum == meshtastic_PortNum_TRACEROUTE_APP)
|
|
||||||
traceRouteModule->processUpgradedPacket(*p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
perhapsRelay(p);
|
|
||||||
|
|
||||||
// We already enqueued the improved copy, so make sure the incoming packet stops here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No queue entry was replaced by this upgraded copy, so treat it as a duplicate to avoid
|
|
||||||
// delivering the same packet to applications/phone twice with different hop limits.
|
|
||||||
seenRecently = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seenRecently) {
|
|
||||||
printPacket("Ignore dupe incoming msg", p);
|
printPacket("Ignore dupe incoming msg", p);
|
||||||
|
|
||||||
if (p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA) {
|
if (p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA) {
|
||||||
@@ -114,14 +76,11 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||||||
if (origTx) {
|
if (origTx) {
|
||||||
// Either relayer of ACK was also a relayer of the packet, or we were the *only* relayer and the ACK came directly
|
// Either relayer of ACK was also a relayer of the packet, or we were the *only* relayer and the ACK came directly
|
||||||
// from the destination
|
// from the destination
|
||||||
bool wasAlreadyRelayer = wasRelayer(p->relay_node, p->decoded.request_id, p->to);
|
if (wasRelayer(p->relay_node, p->decoded.request_id, p->to) ||
|
||||||
bool weWereSoleRelayer = false;
|
(p->hop_start != 0 && p->hop_start == p->hop_limit &&
|
||||||
bool weWereRelayer = wasRelayer(ourRelayID, p->decoded.request_id, p->to, &weWereSoleRelayer);
|
wasSoleRelayer(ourRelayID, p->decoded.request_id, p->to))) {
|
||||||
if ((weWereRelayer && wasAlreadyRelayer) ||
|
|
||||||
(p->hop_start != 0 && p->hop_start == p->hop_limit && weWereSoleRelayer)) {
|
|
||||||
if (origTx->next_hop != p->relay_node) { // Not already set
|
if (origTx->next_hop != p->relay_node) { // Not already set
|
||||||
LOG_INFO("Update next hop of 0x%x to 0x%x based on ACK/reply (was relayer %d we were sole %d)", p->from,
|
LOG_INFO("Update next hop of 0x%x to 0x%x based on ACK/reply", p->from, p->relay_node);
|
||||||
p->relay_node, wasAlreadyRelayer, weWereSoleRelayer);
|
|
||||||
origTx->next_hop = p->relay_node;
|
origTx->next_hop = p->relay_node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,13 +108,7 @@ bool NextHopRouter::perhapsRelay(const meshtastic_MeshPacket *p)
|
|||||||
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
LOG_INFO("Relaying received message coming from %x", p->relay_node);
|
LOG_INFO("Relaying received message coming from %x", p->relay_node);
|
||||||
|
|
||||||
// Use shared logic to determine if hop_limit should be decremented
|
tosend->hop_limit--; // bump down the hop count
|
||||||
if (shouldDecrementHopLimit(p)) {
|
|
||||||
tosend->hop_limit--; // bump down the hop count
|
|
||||||
} else {
|
|
||||||
LOG_INFO("Router/CLIENT_BASE-to-favorite-router/CLIENT_BASE relay: preserving hop_limit");
|
|
||||||
}
|
|
||||||
|
|
||||||
NextHopRouter::send(tosend);
|
NextHopRouter::send(tosend);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -174,6 +127,7 @@ bool NextHopRouter::perhapsRelay(const meshtastic_MeshPacket *p)
|
|||||||
*/
|
*/
|
||||||
uint8_t NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
uint8_t NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
||||||
{
|
{
|
||||||
|
// When we're a repeater router->sniffReceived will call NextHopRouter directly without checking for broadcast
|
||||||
if (isBroadcast(to))
|
if (isBroadcast(to))
|
||||||
return NO_NEXT_HOP_PREFERENCE;
|
return NO_NEXT_HOP_PREFERENCE;
|
||||||
|
|
||||||
@@ -211,7 +165,7 @@ bool NextHopRouter::roleAllowsCancelingFromTxQueue(const meshtastic_MeshPacket *
|
|||||||
{
|
{
|
||||||
// Return true if we're allowed to cancel a packet in the txQueue (so we may never transmit it even once)
|
// Return true if we're allowed to cancel a packet in the txQueue (so we may never transmit it even once)
|
||||||
|
|
||||||
// Return false for roles like ROUTER, ROUTER_LATE which should always transmit the packet at least once.
|
// Return false for roles like ROUTER, REPEATER, ROUTER_LATE which should always transmit the packet at least once.
|
||||||
|
|
||||||
return roleAllowsCancelingDupe(p); // same logic as FloodingRouter::roleAllowsCancelingDupe
|
return roleAllowsCancelingDupe(p); // same logic as FloodingRouter::roleAllowsCancelingDupe
|
||||||
}
|
}
|
||||||
@@ -224,7 +178,7 @@ bool NextHopRouter::stopRetransmission(GlobalPacketId key)
|
|||||||
/* Only when we already transmitted a packet via LoRa, we will cancel the packet in the Tx queue
|
/* Only when we already transmitted a packet via LoRa, we will cancel the packet in the Tx queue
|
||||||
to avoid canceling a transmission if it was ACKed super fast via MQTT */
|
to avoid canceling a transmission if it was ACKed super fast via MQTT */
|
||||||
if (old->numRetransmissions < NUM_RELIABLE_RETX - 1) {
|
if (old->numRetransmissions < NUM_RELIABLE_RETX - 1) {
|
||||||
// We only cancel it if we are the original sender or if we're not a router(_late)
|
// We only cancel it if we are the original sender or if we're not a router(_late)/repeater
|
||||||
if (isFromUs(p) || roleAllowsCancelingFromTxQueue(p)) {
|
if (isFromUs(p) || roleAllowsCancelingFromTxQueue(p)) {
|
||||||
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
|
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
|
||||||
cancelSending(getFrom(p), p->id);
|
cancelSending(getFrom(p), p->id);
|
||||||
@@ -337,4 +291,4 @@ void NextHopRouter::setNextTx(PendingPacket *pending)
|
|||||||
LOG_DEBUG("Setting next retransmission in %u msecs: ", d);
|
LOG_DEBUG("Setting next retransmission in %u msecs: ", d);
|
||||||
printPacket("", pending->packet);
|
printPacket("", pending->packet);
|
||||||
setReceivedMessage(); // Run ASAP, so we can figure out our correct sleep time
|
setReceivedMessage(); // Run ASAP, so we can figure out our correct sleep time
|
||||||
}
|
}
|
||||||
+13
-4
@@ -204,7 +204,7 @@ NodeDB::NodeDB()
|
|||||||
|
|
||||||
int saveWhat = 0;
|
int saveWhat = 0;
|
||||||
// Get device unique id
|
// Get device unique id
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||||
uint32_t unique_id[4];
|
uint32_t unique_id[4];
|
||||||
// ESP32 factory burns a unique id in efuse for S2+ series and evidently C3+ series
|
// ESP32 factory burns a unique id in efuse for S2+ series and evidently C3+ series
|
||||||
// This is used for HMACs in the esp-rainmaker AIOT platform and seems to be a good choice for us
|
// This is used for HMACs in the esp-rainmaker AIOT platform and seems to be a good choice for us
|
||||||
@@ -554,9 +554,10 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USERPREFS_CONFIG_DEVICE_ROLE
|
#ifdef USERPREFS_CONFIG_DEVICE_ROLE
|
||||||
// Restrict ROUTER*, LOST AND FOUND roles for security reasons
|
// Restrict ROUTER*, LOST AND FOUND, and REPEATER roles for security reasons
|
||||||
if (IS_ONE_OF(USERPREFS_CONFIG_DEVICE_ROLE, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
if (IS_ONE_OF(USERPREFS_CONFIG_DEVICE_ROLE, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
||||||
meshtastic_Config_DeviceConfig_Role_ROUTER_LATE, meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND)) {
|
meshtastic_Config_DeviceConfig_Role_ROUTER_LATE, meshtastic_Config_DeviceConfig_Role_REPEATER,
|
||||||
|
meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND)) {
|
||||||
LOG_WARN("ROUTER roles are restricted, falling back to CLIENT role");
|
LOG_WARN("ROUTER roles are restricted, falling back to CLIENT role");
|
||||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||||
} else {
|
} else {
|
||||||
@@ -700,7 +701,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
|||||||
#ifdef USERPREFS_NETWORK_ENABLED_PROTOCOLS
|
#ifdef USERPREFS_NETWORK_ENABLED_PROTOCOLS
|
||||||
config.network.enabled_protocols = USERPREFS_NETWORK_ENABLED_PROTOCOLS;
|
config.network.enabled_protocols = USERPREFS_NETWORK_ENABLED_PROTOCOLS;
|
||||||
#else
|
#else
|
||||||
config.network.enabled_protocols = 0;
|
config.network.enabled_protocols = 1;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -905,6 +906,11 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
|
|||||||
moduleConfig.telemetry.device_update_interval = ONE_DAY;
|
moduleConfig.telemetry.device_update_interval = ONE_DAY;
|
||||||
owner.has_is_unmessagable = true;
|
owner.has_is_unmessagable = true;
|
||||||
owner.is_unmessagable = true;
|
owner.is_unmessagable = true;
|
||||||
|
} else if (role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
|
owner.has_is_unmessagable = true;
|
||||||
|
owner.is_unmessagable = true;
|
||||||
|
config.display.screen_on_secs = 1;
|
||||||
|
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY;
|
||||||
} else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) {
|
} else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) {
|
||||||
owner.has_is_unmessagable = true;
|
owner.has_is_unmessagable = true;
|
||||||
owner.is_unmessagable = true;
|
owner.is_unmessagable = true;
|
||||||
@@ -1661,6 +1667,9 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG_INFO("Public Key set for node, not updating!");
|
LOG_INFO("Public Key set for node, not updating!");
|
||||||
|
// we copy the key into the incoming packet, to prevent overwrite
|
||||||
|
p.public_key.size = 32;
|
||||||
|
memcpy(p.public_key.bytes, info->user.public_key.bytes, 32);
|
||||||
} else if (p.public_key.size == 32) {
|
} else if (p.public_key.size == 32) {
|
||||||
LOG_INFO("Update Node Pubkey!");
|
LOG_INFO("Update Node Pubkey!");
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-74
@@ -45,8 +45,7 @@ PacketHistory::~PacketHistory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Update recentPackets and return true if we have already seen this packet */
|
/** Update recentPackets and return true if we have already seen this packet */
|
||||||
bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpdate, bool *wasFallback, bool *weWereNextHop,
|
bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpdate, bool *wasFallback, bool *weWereNextHop)
|
||||||
bool *wasUpgraded)
|
|
||||||
{
|
{
|
||||||
if (!initOk()) {
|
if (!initOk()) {
|
||||||
LOG_ERROR("Packet History - Was Seen Recently: NOT INITIALIZED!");
|
LOG_ERROR("Packet History - Was Seen Recently: NOT INITIALIZED!");
|
||||||
@@ -67,14 +66,7 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
|
|||||||
r.id = p->id;
|
r.id = p->id;
|
||||||
r.sender = getFrom(p); // If 0 then use our ID
|
r.sender = getFrom(p); // If 0 then use our ID
|
||||||
r.next_hop = p->next_hop;
|
r.next_hop = p->next_hop;
|
||||||
setHighestHopLimit(r, p->hop_limit);
|
r.relayed_by[0] = p->relay_node;
|
||||||
bool weWillRelay = false;
|
|
||||||
uint8_t ourRelayID = nodeDB->getLastByteOfNodeNum(nodeDB->getNodeNum());
|
|
||||||
if (p->relay_node == ourRelayID) { // If the relay_node is us, store it
|
|
||||||
weWillRelay = true;
|
|
||||||
setOurTxHopLimit(r, p->hop_limit);
|
|
||||||
r.relayed_by[0] = p->relay_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
r.rxTimeMsec = millis(); //
|
r.rxTimeMsec = millis(); //
|
||||||
if (r.rxTimeMsec == 0) // =0 every 49.7 days? 0 is special
|
if (r.rxTimeMsec == 0) // =0 every 49.7 days? 0 is special
|
||||||
@@ -89,17 +81,9 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
|
|||||||
PacketRecord *found = find(r.sender, r.id); // Find the packet record in the recentPackets array
|
PacketRecord *found = find(r.sender, r.id); // Find the packet record in the recentPackets array
|
||||||
bool seenRecently = (found != NULL); // If found -> the packet was seen recently
|
bool seenRecently = (found != NULL); // If found -> the packet was seen recently
|
||||||
|
|
||||||
// Check for hop_limit upgrade scenario
|
|
||||||
if (seenRecently && wasUpgraded && found->hop_limit < p->hop_limit) {
|
|
||||||
LOG_DEBUG("Packet History - Hop limit upgrade: packet 0x%08x from hop_limit=%d to hop_limit=%d", p->id, found->hop_limit,
|
|
||||||
p->hop_limit);
|
|
||||||
*wasUpgraded = true;
|
|
||||||
seenRecently = false; // Allow router processing but prevent duplicate app delivery
|
|
||||||
} else if (wasUpgraded) {
|
|
||||||
*wasUpgraded = false; // Initialize to false if not an upgrade
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seenRecently) {
|
if (seenRecently) {
|
||||||
|
uint8_t ourRelayID = nodeDB->getLastByteOfNodeNum(nodeDB->getNodeNum()); // Get our relay ID from our node number
|
||||||
|
|
||||||
if (wasFallback) {
|
if (wasFallback) {
|
||||||
// If it was seen with a next-hop not set to us and now it's NO_NEXT_HOP_PREFERENCE, and the relayer relayed already
|
// If it was seen with a next-hop not set to us and now it's NO_NEXT_HOP_PREFERENCE, and the relayer relayed already
|
||||||
// before, it's a fallback to flooding. If we didn't already relay and the next-hop neither, we might need to handle
|
// before, it's a fallback to flooding. If we didn't already relay and the next-hop neither, we might need to handle
|
||||||
@@ -141,40 +125,11 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
|
|||||||
found->sender, found->id, found->next_hop, found->relayed_by[0], found->relayed_by[1], found->relayed_by[2],
|
found->sender, found->id, found->next_hop, found->relayed_by[0], found->relayed_by[1], found->relayed_by[2],
|
||||||
millis() - found->rxTimeMsec);
|
millis() - found->rxTimeMsec);
|
||||||
#endif
|
#endif
|
||||||
// Only update the relayer if it heard us directly (meaning hopLimit is decreased by 1)
|
|
||||||
uint8_t startIdx = weWillRelay ? 1 : 0;
|
|
||||||
if (!weWillRelay) {
|
|
||||||
bool weWereRelayer = wasRelayer(ourRelayID, *found);
|
|
||||||
// We were a relayer and the packet came in with a hop limit that is one less than when we sent it out
|
|
||||||
if (weWereRelayer && (p->hop_limit == getOurTxHopLimit(*found) || p->hop_limit == getOurTxHopLimit(*found) - 1)) {
|
|
||||||
r.relayed_by[0] = p->relay_node;
|
|
||||||
startIdx = 1; // Start copying existing relayers from index 1
|
|
||||||
}
|
|
||||||
// keep the original ourTxHopLimit
|
|
||||||
setOurTxHopLimit(r, getOurTxHopLimit(*found));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preserve the highest hop_limit we've ever seen for this packet so upgrades aren't lost when a later copy has
|
// Add the existing relayed_by to the new record
|
||||||
// fewer hops remaining.
|
for (uint8_t i = 0; i < (NUM_RELAYERS - 1); i++) {
|
||||||
if (getHighestHopLimit(*found) > getHighestHopLimit(r))
|
if (found->relayed_by[i] != 0)
|
||||||
setHighestHopLimit(r, getHighestHopLimit(*found));
|
r.relayed_by[i + 1] = found->relayed_by[i];
|
||||||
|
|
||||||
// Add the existing relayed_by to the new record, avoiding duplicates
|
|
||||||
for (uint8_t i = 0; i < (NUM_RELAYERS - startIdx); i++) {
|
|
||||||
if (found->relayed_by[i] == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool exists = false;
|
|
||||||
for (uint8_t j = 0; j < NUM_RELAYERS; j++) {
|
|
||||||
if (r.relayed_by[j] == found->relayed_by[i]) {
|
|
||||||
exists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exists) {
|
|
||||||
r.relayed_by[i + startIdx] = found->relayed_by[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
r.next_hop = found->next_hop; // keep the original next_hop (such that we check whether we were originally asked)
|
r.next_hop = found->next_hop; // keep the original next_hop (such that we check whether we were originally asked)
|
||||||
#if VERBOSE_PACKET_HISTORY
|
#if VERBOSE_PACKET_HISTORY
|
||||||
@@ -397,6 +352,14 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const PacketRecord &r, boo
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a certain node was the *only* relayer of a packet in the history given an ID and sender
|
||||||
|
bool PacketHistory::wasSoleRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender)
|
||||||
|
{
|
||||||
|
bool wasSole = false;
|
||||||
|
wasRelayer(relayer, id, sender, &wasSole);
|
||||||
|
return wasSole;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove a relayer from the list of relayers of a packet in the history given an ID and sender
|
// Remove a relayer from the list of relayers of a packet in the history given an ID and sender
|
||||||
void PacketHistory::removeRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender)
|
void PacketHistory::removeRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender)
|
||||||
{
|
{
|
||||||
@@ -438,24 +401,3 @@ void PacketHistory::removeRelayer(const uint8_t relayer, const uint32_t id, cons
|
|||||||
found->id, found->relayed_by[0], found->relayed_by[1], found->relayed_by[2], relayer, i != j);
|
found->id, found->relayed_by[0], found->relayed_by[1], found->relayed_by[2], relayer, i != j);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters and setters for hop limit fields packed in hop_limit
|
|
||||||
inline uint8_t PacketHistory::getHighestHopLimit(PacketRecord &r)
|
|
||||||
{
|
|
||||||
return r.hop_limit & HOP_LIMIT_HIGHEST_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void PacketHistory::setHighestHopLimit(PacketRecord &r, uint8_t hopLimit)
|
|
||||||
{
|
|
||||||
r.hop_limit = (r.hop_limit & ~HOP_LIMIT_HIGHEST_MASK) | (hopLimit & HOP_LIMIT_HIGHEST_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline uint8_t PacketHistory::getOurTxHopLimit(PacketRecord &r)
|
|
||||||
{
|
|
||||||
return (r.hop_limit & HOP_LIMIT_OUR_TX_MASK) >> HOP_LIMIT_OUR_TX_SHIFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void PacketHistory::setOurTxHopLimit(PacketRecord &r, uint8_t hopLimit)
|
|
||||||
{
|
|
||||||
r.hop_limit = (r.hop_limit & ~HOP_LIMIT_OUR_TX_MASK) | ((hopLimit << HOP_LIMIT_OUR_TX_SHIFT) & HOP_LIMIT_OUR_TX_MASK);
|
|
||||||
}
|
|
||||||
@@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
|
||||||
// Number of relayers we keep track of. Use 6 to be efficient with memory alignment of PacketRecord to 20 bytes
|
#define NUM_RELAYERS \
|
||||||
#define NUM_RELAYERS 6
|
3 // Number of relayer we keep track of. Use 3 to be efficient with memory alignment of PacketRecord to 16 bytes
|
||||||
#define HOP_LIMIT_HIGHEST_MASK 0x07 // Bits 0-2
|
|
||||||
#define HOP_LIMIT_OUR_TX_MASK 0x38 // Bits 3-5
|
|
||||||
#define HOP_LIMIT_OUR_TX_SHIFT 3 // Bits 3-5
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a mixin that adds a record of past packets we have seen
|
* This is a mixin that adds a record of past packets we have seen
|
||||||
@@ -19,10 +16,8 @@ class PacketHistory
|
|||||||
PacketId id;
|
PacketId id;
|
||||||
uint32_t rxTimeMsec; // Unix time in msecs - the time we received it, 0 means empty
|
uint32_t rxTimeMsec; // Unix time in msecs - the time we received it, 0 means empty
|
||||||
uint8_t next_hop; // The next hop asked for this packet
|
uint8_t next_hop; // The next hop asked for this packet
|
||||||
uint8_t hop_limit; // bit 0-2: Highest hop limit observed for this packet,
|
|
||||||
// bit 3-5: our hop limit when we first transmitted it
|
|
||||||
uint8_t relayed_by[NUM_RELAYERS]; // Array of nodes that relayed this packet
|
uint8_t relayed_by[NUM_RELAYERS]; // Array of nodes that relayed this packet
|
||||||
}; // 4B + 4B + 4B + 1B + 1B + 6B = 20B
|
}; // 4B + 4B + 4B + 1B + 3B = 16B
|
||||||
|
|
||||||
uint32_t recentPacketsCapacity =
|
uint32_t recentPacketsCapacity =
|
||||||
0; // Can be set in constructor, no need to recompile. Used to allocate memory for mx_recentPackets.
|
0; // Can be set in constructor, no need to recompile. Used to allocate memory for mx_recentPackets.
|
||||||
@@ -43,11 +38,6 @@ class PacketHistory
|
|||||||
* @return true if node was indeed a relayer, false if not */
|
* @return true if node was indeed a relayer, false if not */
|
||||||
bool wasRelayer(const uint8_t relayer, const PacketRecord &r, bool *wasSole = nullptr);
|
bool wasRelayer(const uint8_t relayer, const PacketRecord &r, bool *wasSole = nullptr);
|
||||||
|
|
||||||
uint8_t getHighestHopLimit(PacketRecord &r);
|
|
||||||
void setHighestHopLimit(PacketRecord &r, uint8_t hopLimit);
|
|
||||||
uint8_t getOurTxHopLimit(PacketRecord &r);
|
|
||||||
void setOurTxHopLimit(PacketRecord &r, uint8_t hopLimit);
|
|
||||||
|
|
||||||
PacketHistory(const PacketHistory &); // non construction-copyable
|
PacketHistory(const PacketHistory &); // non construction-copyable
|
||||||
PacketHistory &operator=(const PacketHistory &); // non copyable
|
PacketHistory &operator=(const PacketHistory &); // non copyable
|
||||||
public:
|
public:
|
||||||
@@ -60,16 +50,18 @@ class PacketHistory
|
|||||||
* @param withUpdate if true and not found we add an entry to recentPackets
|
* @param withUpdate if true and not found we add an entry to recentPackets
|
||||||
* @param wasFallback if not nullptr, packet will be checked for fallback to flooding and value will be set to true if so
|
* @param wasFallback if not nullptr, packet will be checked for fallback to flooding and value will be set to true if so
|
||||||
* @param weWereNextHop if not nullptr, packet will be checked for us being the next hop and value will be set to true if so
|
* @param weWereNextHop if not nullptr, packet will be checked for us being the next hop and value will be set to true if so
|
||||||
* @param wasUpgraded if not nullptr, will be set to true if this packet has better hop_limit than previously seen
|
|
||||||
*/
|
*/
|
||||||
bool wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpdate = true, bool *wasFallback = nullptr,
|
bool wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpdate = true, bool *wasFallback = nullptr,
|
||||||
bool *weWereNextHop = nullptr, bool *wasUpgraded = nullptr);
|
bool *weWereNextHop = nullptr);
|
||||||
|
|
||||||
/* Check if a certain node was a relayer of a packet in the history given an ID and sender
|
/* Check if a certain node was a relayer of a packet in the history given an ID and sender
|
||||||
* If wasSole is not nullptr, it will be set to true if the relayer was the only relayer of that packet
|
* If wasSole is not nullptr, it will be set to true if the relayer was the only relayer of that packet
|
||||||
* @return true if node was indeed a relayer, false if not */
|
* @return true if node was indeed a relayer, false if not */
|
||||||
bool wasRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender, bool *wasSole = nullptr);
|
bool wasRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender, bool *wasSole = nullptr);
|
||||||
|
|
||||||
|
// Check if a certain node was the *only* relayer of a packet in the history given an ID and sender
|
||||||
|
bool wasSoleRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender);
|
||||||
|
|
||||||
// Remove a relayer from the list of relayers of a packet in the history given an ID and sender
|
// Remove a relayer from the list of relayers of a packet in the history given an ID and sender
|
||||||
void removeRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender);
|
void removeRelayer(const uint8_t relayer, const uint32_t id, const NodeNum sender);
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
if (config_nonce == SPECIAL_NONCE_ONLY_NODES) {
|
if (config_nonce == SPECIAL_NONCE_ONLY_NODES) {
|
||||||
// If client only wants node info, jump directly to sending nodes
|
// If client only wants node info, jump directly to sending nodes
|
||||||
state = STATE_SEND_OTHER_NODEINFOS;
|
state = STATE_SEND_OTHER_NODEINFOS;
|
||||||
onNowHasData(0);
|
|
||||||
} else {
|
} else {
|
||||||
state = STATE_SEND_METADATA;
|
state = STATE_SEND_METADATA;
|
||||||
}
|
}
|
||||||
@@ -424,7 +423,6 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
state = STATE_SEND_FILEMANIFEST;
|
state = STATE_SEND_FILEMANIFEST;
|
||||||
} else {
|
} else {
|
||||||
state = STATE_SEND_OTHER_NODEINFOS;
|
state = STATE_SEND_OTHER_NODEINFOS;
|
||||||
onNowHasData(0);
|
|
||||||
}
|
}
|
||||||
config_state = 0;
|
config_state = 0;
|
||||||
}
|
}
|
||||||
@@ -590,7 +588,6 @@ bool PhoneAPI::available()
|
|||||||
nodeInfoForPhone.snr = isUs ? 0 : nodeInfoForPhone.snr;
|
nodeInfoForPhone.snr = isUs ? 0 : nodeInfoForPhone.snr;
|
||||||
nodeInfoForPhone.via_mqtt = isUs ? false : nodeInfoForPhone.via_mqtt;
|
nodeInfoForPhone.via_mqtt = isUs ? false : nodeInfoForPhone.via_mqtt;
|
||||||
nodeInfoForPhone.is_favorite = nodeInfoForPhone.is_favorite || isUs; // Our node is always a favorite
|
nodeInfoForPhone.is_favorite = nodeInfoForPhone.is_favorite || isUs; // Our node is always a favorite
|
||||||
onNowHasData(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; // Always say we have something, because we might need to advance our state machine
|
return true; // Always say we have something, because we might need to advance our state machine
|
||||||
|
|||||||
@@ -317,8 +317,9 @@ uint32_t RadioInterface::getTxDelayMsecWeightedWorst(float snr)
|
|||||||
/** Returns true if we should rebroadcast early like a ROUTER */
|
/** Returns true if we should rebroadcast early like a ROUTER */
|
||||||
bool RadioInterface::shouldRebroadcastEarlyLikeRouter(meshtastic_MeshPacket *p)
|
bool RadioInterface::shouldRebroadcastEarlyLikeRouter(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
// If we are a ROUTER, we always rebroadcast early
|
// If we are a ROUTER or REPEATER, we always rebroadcast early
|
||||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) {
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||||
|
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,12 +189,6 @@ class RadioInterface
|
|||||||
/** If the packet is not already in the late rebroadcast window, move it there */
|
/** If the packet is not already in the late rebroadcast window, move it there */
|
||||||
virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; }
|
virtual void clampToLateRebroadcastWindow(NodeNum from, PacketId id) { return; }
|
||||||
|
|
||||||
/**
|
|
||||||
* If there is a packet pending TX in the queue with a worse hop limit, remove it pending replacement with a better version
|
|
||||||
* @return Whether a pending packet was removed
|
|
||||||
*/
|
|
||||||
virtual bool removePendingTXPacket(NodeNum from, PacketId id, uint32_t hop_limit_lt) { return false; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate airtime per
|
* Calculate airtime per
|
||||||
* https://www.rs-online.com/designspark/rel-assets/ds-assets/uploads/knowledge-items/application-notes-for-the-internet-of-things/LoRa%20Design%20Guide.pdf
|
* https://www.rs-online.com/designspark/rel-assets/ds-assets/uploads/knowledge-items/application-notes-for-the-internet-of-things/LoRa%20Design%20Guide.pdf
|
||||||
@@ -272,4 +266,4 @@ class RadioInterface
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Debug printing for packets
|
/// Debug printing for packets
|
||||||
void printPacket(const char *prefix, const meshtastic_MeshPacket *p);
|
void printPacket(const char *prefix, const meshtastic_MeshPacket *p);
|
||||||
@@ -362,26 +362,6 @@ void RadioLibInterface::clampToLateRebroadcastWindow(NodeNum from, PacketId id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If there is a packet pending TX in the queue with a worse hop limit, remove it pending replacement with a better version
|
|
||||||
* @return Whether a pending packet was removed
|
|
||||||
*/
|
|
||||||
bool RadioLibInterface::removePendingTXPacket(NodeNum from, PacketId id, uint32_t hop_limit_lt)
|
|
||||||
{
|
|
||||||
meshtastic_MeshPacket *p = txQueue.remove(from, id, true, true, hop_limit_lt);
|
|
||||||
if (p) {
|
|
||||||
LOG_DEBUG("Dropping pending-TX packet 0x%08x with hop limit %d", p->id, p->hop_limit);
|
|
||||||
packetPool.release(p);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a packet that is eligible for replacement from the TX queue
|
|
||||||
*/
|
|
||||||
// void RadioLibInterface::removePending
|
|
||||||
|
|
||||||
void RadioLibInterface::handleTransmitInterrupt()
|
void RadioLibInterface::handleTransmitInterrupt()
|
||||||
{
|
{
|
||||||
// This can be null if we forced the device to enter standby mode. In that case
|
// This can be null if we forced the device to enter standby mode. In that case
|
||||||
|
|||||||
@@ -215,11 +215,4 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
|
|||||||
* If the packet is not already in the late rebroadcast window, move it there
|
* If the packet is not already in the late rebroadcast window, move it there
|
||||||
*/
|
*/
|
||||||
void clampToLateRebroadcastWindow(NodeNum from, PacketId id);
|
void clampToLateRebroadcastWindow(NodeNum from, PacketId id);
|
||||||
|
};
|
||||||
/**
|
|
||||||
* If there is a packet pending TX in the queue with a worse hop limit, remove it pending replacement with a better version
|
|
||||||
* @return Whether a pending packet was removed
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool removePendingTXPacket(NodeNum from, PacketId id, uint32_t hop_limit_lt) override;
|
|
||||||
};
|
|
||||||
+33
-52
@@ -69,58 +69,6 @@ Router::Router() : concurrency::OSThread("Router"), fromRadioQueue(MAX_RX_FROMRA
|
|||||||
cryptLock = new concurrency::Lock();
|
cryptLock = new concurrency::Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Router::shouldDecrementHopLimit(const meshtastic_MeshPacket *p)
|
|
||||||
{
|
|
||||||
// First hop MUST always decrement to prevent retry issues
|
|
||||||
bool isFirstHop = (p->hop_start != 0 && p->hop_start == p->hop_limit);
|
|
||||||
if (isFirstHop) {
|
|
||||||
return true; // Always decrement on first hop
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if both local device and previous relay are routers (including CLIENT_BASE)
|
|
||||||
bool localIsRouter =
|
|
||||||
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_ROUTER, meshtastic_Config_DeviceConfig_Role_ROUTER_LATE,
|
|
||||||
meshtastic_Config_DeviceConfig_Role_CLIENT_BASE);
|
|
||||||
|
|
||||||
// If local device isn't a router, always decrement
|
|
||||||
if (!localIsRouter) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For subsequent hops, check if previous relay is a favorite router
|
|
||||||
// Optimized search for favorite routers with matching last byte
|
|
||||||
// Check ordering optimized for IoT devices (cheapest checks first)
|
|
||||||
for (size_t i = 0; i < nodeDB->getNumMeshNodes(); i++) {
|
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNodeByIndex(i);
|
|
||||||
if (!node)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check 1: is_favorite (cheapest - single bool)
|
|
||||||
if (!node->is_favorite)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check 2: has_user (cheap - single bool)
|
|
||||||
if (!node->has_user)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check 3: role check (moderate cost - multiple comparisons)
|
|
||||||
if (!IS_ONE_OF(node->user.role, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
|
||||||
meshtastic_Config_DeviceConfig_Role_ROUTER_LATE)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check 4: last byte extraction and comparison (most expensive)
|
|
||||||
if (nodeDB->getLastByteOfNodeNum(node->num) == p->relay_node) {
|
|
||||||
// Found a favorite router match
|
|
||||||
LOG_DEBUG("Identified favorite relay router 0x%x from last byte 0x%x", node->num, p->relay_node);
|
|
||||||
return false; // Don't decrement hop_limit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No favorite router match found, decrement hop_limit
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* do idle processing
|
* do idle processing
|
||||||
* Mostly looking in our incoming rxPacket queue and calling handleReceived.
|
* Mostly looking in our incoming rxPacket queue and calling handleReceived.
|
||||||
@@ -399,6 +347,10 @@ DecodeState perhapsDecode(meshtastic_MeshPacket *p)
|
|||||||
{
|
{
|
||||||
concurrency::LockGuard g(cryptLock);
|
concurrency::LockGuard g(cryptLock);
|
||||||
|
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
|
config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING)
|
||||||
|
return DecodeState::DECODE_FAILURE;
|
||||||
|
|
||||||
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY &&
|
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY &&
|
||||||
(nodeDB->getMeshNode(p->from) == NULL || !nodeDB->getMeshNode(p->from)->has_user)) {
|
(nodeDB->getMeshNode(p->from) == NULL || !nodeDB->getMeshNode(p->from)->has_user)) {
|
||||||
LOG_DEBUG("Node 0x%x not in nodeDB-> Rebroadcast mode KNOWN_ONLY will ignore packet", p->from);
|
LOG_DEBUG("Node 0x%x not in nodeDB-> Rebroadcast mode KNOWN_ONLY will ignore packet", p->from);
|
||||||
@@ -479,6 +431,35 @@ DecodeState perhapsDecode(meshtastic_MeshPacket *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAS_UDP_MULTICAST
|
||||||
|
// Fallback: for UDP multicast, try default preset names with default PSK if normal channel match failed
|
||||||
|
if (!decrypted && p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MULTICAST_UDP) {
|
||||||
|
if (channels.setDefaultPresetCryptoForHash(p->channel)) {
|
||||||
|
memcpy(bytes, p->encrypted.bytes, rawSize);
|
||||||
|
crypto->decrypt(p->from, p->id, rawSize, bytes);
|
||||||
|
|
||||||
|
meshtastic_Data decodedtmp;
|
||||||
|
memset(&decodedtmp, 0, sizeof(decodedtmp));
|
||||||
|
if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &decodedtmp) &&
|
||||||
|
decodedtmp.portnum != meshtastic_PortNum_UNKNOWN_APP) {
|
||||||
|
p->decoded = decodedtmp;
|
||||||
|
p->which_payload_variant = meshtastic_MeshPacket_decoded_tag;
|
||||||
|
// Map to our local default channel index (name+PSK default), not necessarily primary
|
||||||
|
ChannelIndex defaultIndex = channels.getPrimaryIndex();
|
||||||
|
for (ChannelIndex i = 0; i < channels.getNumChannels(); ++i) {
|
||||||
|
if (channels.isDefaultChannel(i)) {
|
||||||
|
defaultIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chIndex = defaultIndex;
|
||||||
|
decrypted = true;
|
||||||
|
} else {
|
||||||
|
LOG_WARN("UDP fallback decode attempted but failed for hash 0x%x", p->channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (decrypted) {
|
if (decrypted) {
|
||||||
// parsing was successful
|
// parsing was successful
|
||||||
p->channel = chIndex; // change to store the index instead of the hash
|
p->channel = chIndex; // change to store the index instead of the hash
|
||||||
|
|||||||
+1
-13
@@ -104,18 +104,6 @@ class Router : protected concurrency::OSThread, protected PacketHistory
|
|||||||
*/
|
*/
|
||||||
virtual bool shouldFilterReceived(const meshtastic_MeshPacket *p) { return false; }
|
virtual bool shouldFilterReceived(const meshtastic_MeshPacket *p) { return false; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if hop_limit should be decremented for a relay operation.
|
|
||||||
* Returns false (preserve hop_limit) only if all conditions are met:
|
|
||||||
* - It's NOT the first hop (first hop must always decrement)
|
|
||||||
* - Local device is a ROUTER, ROUTER_LATE, or CLIENT_BASE
|
|
||||||
* - Previous relay is a favorite ROUTER, ROUTER_LATE, or CLIENT_BASE
|
|
||||||
*
|
|
||||||
* @param p The packet being relayed
|
|
||||||
* @return true if hop_limit should be decremented, false to preserve it
|
|
||||||
*/
|
|
||||||
bool shouldDecrementHopLimit(const meshtastic_MeshPacket *p);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every (non duplicate) packet this node receives will be passed through this method. This allows subclasses to
|
* Every (non duplicate) packet this node receives will be passed through this method. This allows subclasses to
|
||||||
* update routing tables etc... based on what we overhear (even for messages not destined to our node)
|
* update routing tables etc... based on what we overhear (even for messages not destined to our node)
|
||||||
@@ -174,4 +162,4 @@ PacketId generatePacketId();
|
|||||||
#define BITFIELD_WANT_RESPONSE_SHIFT 1
|
#define BITFIELD_WANT_RESPONSE_SHIFT 1
|
||||||
#define BITFIELD_OK_TO_MQTT_SHIFT 0
|
#define BITFIELD_OK_TO_MQTT_SHIFT 0
|
||||||
#define BITFIELD_WANT_RESPONSE_MASK (1 << BITFIELD_WANT_RESPONSE_SHIFT)
|
#define BITFIELD_WANT_RESPONSE_MASK (1 << BITFIELD_WANT_RESPONSE_SHIFT)
|
||||||
#define BITFIELD_OK_TO_MQTT_MASK (1 << BITFIELD_OK_TO_MQTT_SHIFT)
|
#define BITFIELD_OK_TO_MQTT_MASK (1 << BITFIELD_OK_TO_MQTT_SHIFT)
|
||||||
@@ -55,7 +55,7 @@ extern const pb_msgdesc_t meshtastic_ChannelSet_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size
|
#define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size
|
||||||
#define meshtastic_ChannelSet_size 695
|
#define meshtastic_ChannelSet_size 679
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
@@ -97,8 +97,6 @@ typedef struct _meshtastic_ChannelSettings {
|
|||||||
/* Per-channel module settings. */
|
/* Per-channel module settings. */
|
||||||
bool has_module_settings;
|
bool has_module_settings;
|
||||||
meshtastic_ModuleSettings module_settings;
|
meshtastic_ModuleSettings module_settings;
|
||||||
/* Whether or not we should receive notifactions / alerts through this channel */
|
|
||||||
bool mute;
|
|
||||||
} meshtastic_ChannelSettings;
|
} meshtastic_ChannelSettings;
|
||||||
|
|
||||||
/* A pair of a channel number, mode and the (sharable) settings for that channel */
|
/* A pair of a channel number, mode and the (sharable) settings for that channel */
|
||||||
@@ -130,10 +128,10 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define meshtastic_ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_default, 0}
|
#define meshtastic_ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_default}
|
||||||
#define meshtastic_ModuleSettings_init_default {0, 0}
|
#define meshtastic_ModuleSettings_init_default {0, 0}
|
||||||
#define meshtastic_Channel_init_default {0, false, meshtastic_ChannelSettings_init_default, _meshtastic_Channel_Role_MIN}
|
#define meshtastic_Channel_init_default {0, false, meshtastic_ChannelSettings_init_default, _meshtastic_Channel_Role_MIN}
|
||||||
#define meshtastic_ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_zero, 0}
|
#define meshtastic_ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0, false, meshtastic_ModuleSettings_init_zero}
|
||||||
#define meshtastic_ModuleSettings_init_zero {0, 0}
|
#define meshtastic_ModuleSettings_init_zero {0, 0}
|
||||||
#define meshtastic_Channel_init_zero {0, false, meshtastic_ChannelSettings_init_zero, _meshtastic_Channel_Role_MIN}
|
#define meshtastic_Channel_init_zero {0, false, meshtastic_ChannelSettings_init_zero, _meshtastic_Channel_Role_MIN}
|
||||||
|
|
||||||
@@ -147,7 +145,6 @@ extern "C" {
|
|||||||
#define meshtastic_ChannelSettings_uplink_enabled_tag 5
|
#define meshtastic_ChannelSettings_uplink_enabled_tag 5
|
||||||
#define meshtastic_ChannelSettings_downlink_enabled_tag 6
|
#define meshtastic_ChannelSettings_downlink_enabled_tag 6
|
||||||
#define meshtastic_ChannelSettings_module_settings_tag 7
|
#define meshtastic_ChannelSettings_module_settings_tag 7
|
||||||
#define meshtastic_ChannelSettings_mute_tag 8
|
|
||||||
#define meshtastic_Channel_index_tag 1
|
#define meshtastic_Channel_index_tag 1
|
||||||
#define meshtastic_Channel_settings_tag 2
|
#define meshtastic_Channel_settings_tag 2
|
||||||
#define meshtastic_Channel_role_tag 3
|
#define meshtastic_Channel_role_tag 3
|
||||||
@@ -160,8 +157,7 @@ X(a, STATIC, SINGULAR, STRING, name, 3) \
|
|||||||
X(a, STATIC, SINGULAR, FIXED32, id, 4) \
|
X(a, STATIC, SINGULAR, FIXED32, id, 4) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, uplink_enabled, 5) \
|
X(a, STATIC, SINGULAR, BOOL, uplink_enabled, 5) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, downlink_enabled, 6) \
|
X(a, STATIC, SINGULAR, BOOL, downlink_enabled, 6) \
|
||||||
X(a, STATIC, OPTIONAL, MESSAGE, module_settings, 7) \
|
X(a, STATIC, OPTIONAL, MESSAGE, module_settings, 7)
|
||||||
X(a, STATIC, SINGULAR, BOOL, mute, 8)
|
|
||||||
#define meshtastic_ChannelSettings_CALLBACK NULL
|
#define meshtastic_ChannelSettings_CALLBACK NULL
|
||||||
#define meshtastic_ChannelSettings_DEFAULT NULL
|
#define meshtastic_ChannelSettings_DEFAULT NULL
|
||||||
#define meshtastic_ChannelSettings_module_settings_MSGTYPE meshtastic_ModuleSettings
|
#define meshtastic_ChannelSettings_module_settings_MSGTYPE meshtastic_ModuleSettings
|
||||||
@@ -191,8 +187,8 @@ extern const pb_msgdesc_t meshtastic_Channel_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_MAX_SIZE meshtastic_Channel_size
|
#define MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_MAX_SIZE meshtastic_Channel_size
|
||||||
#define meshtastic_ChannelSettings_size 74
|
#define meshtastic_ChannelSettings_size 72
|
||||||
#define meshtastic_Channel_size 89
|
#define meshtastic_Channel_size 87
|
||||||
#define meshtastic_ModuleSettings_size 8
|
#define meshtastic_ModuleSettings_size 8
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ typedef enum _meshtastic_Config_DeviceConfig_Role {
|
|||||||
meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT = 3,
|
meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT = 3,
|
||||||
/* Description: Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list.
|
/* Description: Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list.
|
||||||
Technical Details: Mesh packets will simply be rebroadcasted over this node. Nodes configured with this role will not originate NodeInfo, Position, Telemetry
|
Technical Details: Mesh packets will simply be rebroadcasted over this node. Nodes configured with this role will not originate NodeInfo, Position, Telemetry
|
||||||
or any other packet type. They will simply rebroadcast any mesh packets on the same frequency, channel num, spread factor, and coding rate.
|
or any other packet type. They will simply rebroadcast any mesh packets on the same frequency, channel num, spread factor, and coding rate. */
|
||||||
Deprecated in v2.7.11 because it creates "holes" in the mesh rebroadcast chain. */
|
|
||||||
meshtastic_Config_DeviceConfig_Role_REPEATER = 4,
|
meshtastic_Config_DeviceConfig_Role_REPEATER = 4,
|
||||||
/* Description: Broadcasts GPS position packets as priority.
|
/* Description: Broadcasts GPS position packets as priority.
|
||||||
Technical Details: Position Mesh packets will be prioritized higher and sent more frequently by default.
|
Technical Details: Position Mesh packets will be prioritized higher and sent more frequently by default.
|
||||||
|
|||||||
@@ -360,8 +360,8 @@ extern const pb_msgdesc_t meshtastic_BackupPreferences_msg;
|
|||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
/* meshtastic_NodeDatabase_size depends on runtime parameters */
|
/* meshtastic_NodeDatabase_size depends on runtime parameters */
|
||||||
#define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_BackupPreferences_size
|
#define MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_MAX_SIZE meshtastic_BackupPreferences_size
|
||||||
#define meshtastic_BackupPreferences_size 2293
|
#define meshtastic_BackupPreferences_size 2277
|
||||||
#define meshtastic_ChannelFile_size 734
|
#define meshtastic_ChannelFile_size 718
|
||||||
#define meshtastic_DeviceState_size 1737
|
#define meshtastic_DeviceState_size 1737
|
||||||
#define meshtastic_NodeInfoLite_size 196
|
#define meshtastic_NodeInfoLite_size 196
|
||||||
#define meshtastic_PositionLite_size 28
|
#define meshtastic_PositionLite_size 28
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ typedef enum _meshtastic_HardwareModel {
|
|||||||
meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1 = 99,
|
meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1 = 99,
|
||||||
/* Seeed Tracker L1 EINK driver */
|
/* Seeed Tracker L1 EINK driver */
|
||||||
meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1_EINK = 100,
|
meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1_EINK = 100,
|
||||||
/* Muzi Works R1 Neo */
|
/* Reserved ID for future and past use */
|
||||||
meshtastic_HardwareModel_MUZI_R1_NEO = 101,
|
meshtastic_HardwareModel_QWANTZ_TINY_ARMS = 101,
|
||||||
/* Lilygo T-Deck Pro */
|
/* Lilygo T-Deck Pro */
|
||||||
meshtastic_HardwareModel_T_DECK_PRO = 102,
|
meshtastic_HardwareModel_T_DECK_PRO = 102,
|
||||||
/* Lilygo TLora Pager */
|
/* Lilygo TLora Pager */
|
||||||
|
|||||||
+20
-40
@@ -611,9 +611,10 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
}
|
}
|
||||||
config.device = c.payload_variant.device;
|
config.device = c.payload_variant.device;
|
||||||
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_NONE &&
|
if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_NONE &&
|
||||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) {
|
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
||||||
|
meshtastic_Config_DeviceConfig_Role_REPEATER)) {
|
||||||
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
|
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
|
||||||
const char *warning = "Rebroadcast mode can't be set to NONE for a router";
|
const char *warning = "Rebroadcast mode can't be set to NONE for a router or repeater";
|
||||||
LOG_WARN(warning);
|
LOG_WARN(warning);
|
||||||
sendWarning(warning);
|
sendWarning(warning);
|
||||||
}
|
}
|
||||||
@@ -626,9 +627,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d", min_node_info_broadcast_secs);
|
LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d", min_node_info_broadcast_secs);
|
||||||
config.device.node_info_broadcast_secs = min_node_info_broadcast_secs;
|
config.device.node_info_broadcast_secs = min_node_info_broadcast_secs;
|
||||||
}
|
}
|
||||||
// Router Client and Repeater deprecated; Set it to client
|
// Router Client is deprecated; Set it to client
|
||||||
if (IS_ONE_OF(c.payload_variant.device.role, meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT,
|
if (c.payload_variant.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT) {
|
||||||
meshtastic_Config_DeviceConfig_Role_REPEATER)) {
|
|
||||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||||
if (moduleConfig.store_forward.enabled && !moduleConfig.store_forward.is_server) {
|
if (moduleConfig.store_forward.enabled && !moduleConfig.store_forward.is_server) {
|
||||||
moduleConfig.store_forward.is_server = true;
|
moduleConfig.store_forward.is_server = true;
|
||||||
@@ -637,9 +637,10 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if USERPREFS_EVENT_MODE
|
#if USERPREFS_EVENT_MODE
|
||||||
// If we're in event mode, nobody is a Router or Router Late
|
// If we're in event mode, nobody is a Router or Repeater
|
||||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE ||
|
||||||
|
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -706,40 +707,20 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
#endif
|
#endif
|
||||||
config.display = c.payload_variant.display;
|
config.display = c.payload_variant.display;
|
||||||
break;
|
break;
|
||||||
|
case meshtastic_Config_lora_tag:
|
||||||
case meshtastic_Config_lora_tag: {
|
|
||||||
// Wrap the entire case in a block to scope variables and avoid crossing initialization
|
|
||||||
auto oldLoraConfig = config.lora;
|
|
||||||
auto validatedLora = c.payload_variant.lora;
|
|
||||||
|
|
||||||
LOG_INFO("Set config: LoRa");
|
LOG_INFO("Set config: LoRa");
|
||||||
config.has_lora = true;
|
config.has_lora = true;
|
||||||
|
|
||||||
if (validatedLora.coding_rate < 4 || validatedLora.coding_rate > 8) {
|
|
||||||
LOG_WARN("Invalid coding_rate %d, setting to 5", validatedLora.coding_rate);
|
|
||||||
validatedLora.coding_rate = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validatedLora.spread_factor < 7 || validatedLora.spread_factor > 12) {
|
|
||||||
LOG_WARN("Invalid spread_factor %d, setting to 11", validatedLora.spread_factor);
|
|
||||||
validatedLora.spread_factor = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validatedLora.bandwidth == 0) {
|
|
||||||
int originalBandwidth = validatedLora.bandwidth;
|
|
||||||
validatedLora.bandwidth = myRegion->wideLora ? 800 : 250;
|
|
||||||
LOG_WARN("Invalid bandwidth %d, setting to default", originalBandwidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no lora radio parameters change, don't need to reboot
|
// If no lora radio parameters change, don't need to reboot
|
||||||
if (oldLoraConfig.use_preset == validatedLora.use_preset && oldLoraConfig.region == validatedLora.region &&
|
if (config.lora.use_preset == c.payload_variant.lora.use_preset && config.lora.region == c.payload_variant.lora.region &&
|
||||||
oldLoraConfig.modem_preset == validatedLora.modem_preset && oldLoraConfig.bandwidth == validatedLora.bandwidth &&
|
config.lora.modem_preset == c.payload_variant.lora.modem_preset &&
|
||||||
oldLoraConfig.spread_factor == validatedLora.spread_factor &&
|
config.lora.bandwidth == c.payload_variant.lora.bandwidth &&
|
||||||
oldLoraConfig.coding_rate == validatedLora.coding_rate && oldLoraConfig.tx_power == validatedLora.tx_power &&
|
config.lora.spread_factor == c.payload_variant.lora.spread_factor &&
|
||||||
oldLoraConfig.frequency_offset == validatedLora.frequency_offset &&
|
config.lora.coding_rate == c.payload_variant.lora.coding_rate &&
|
||||||
oldLoraConfig.override_frequency == validatedLora.override_frequency &&
|
config.lora.tx_power == c.payload_variant.lora.tx_power &&
|
||||||
oldLoraConfig.channel_num == validatedLora.channel_num &&
|
config.lora.frequency_offset == c.payload_variant.lora.frequency_offset &&
|
||||||
oldLoraConfig.sx126x_rx_boosted_gain == validatedLora.sx126x_rx_boosted_gain) {
|
config.lora.override_frequency == c.payload_variant.lora.override_frequency &&
|
||||||
|
config.lora.channel_num == c.payload_variant.lora.channel_num &&
|
||||||
|
config.lora.sx126x_rx_boosted_gain == c.payload_variant.lora.sx126x_rx_boosted_gain) {
|
||||||
requiresReboot = false;
|
requiresReboot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,7 +739,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
digitalWrite(RF95_FAN_EN, HIGH ^ 0);
|
digitalWrite(RF95_FAN_EN, HIGH ^ 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
config.lora = validatedLora;
|
config.lora = c.payload_variant.lora;
|
||||||
// If we're setting region for the first time, init the region and regenerate the keys
|
// If we're setting region for the first time, init the region and regenerate the keys
|
||||||
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
|
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
|
||||||
if (!owner.is_licensed) {
|
if (!owner.is_licensed) {
|
||||||
@@ -790,7 +771,6 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case meshtastic_Config_bluetooth_tag:
|
case meshtastic_Config_bluetooth_tag:
|
||||||
LOG_INFO("Set config: Bluetooth");
|
LOG_INFO("Set config: Bluetooth");
|
||||||
config.has_bluetooth = true;
|
config.has_bluetooth = true;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ bool ascending = true;
|
|||||||
#endif
|
#endif
|
||||||
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
|
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
|
||||||
|
|
||||||
#define EXT_NOTIFICATION_FAST_THREAD_MS 25
|
#define EXT_NOTIFICATION_DEFAULT_THREAD_MS 25
|
||||||
|
|
||||||
#define ASCII_BELL 0x07
|
#define ASCII_BELL 0x07
|
||||||
|
|
||||||
@@ -88,13 +88,12 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
if (!moduleConfig.external_notification.enabled) {
|
if (!moduleConfig.external_notification.enabled) {
|
||||||
return INT32_MAX; // we don't need this thread here...
|
return INT32_MAX; // we don't need this thread here...
|
||||||
} else {
|
} else {
|
||||||
uint32_t delay = EXT_NOTIFICATION_MODULE_OUTPUT_MS;
|
|
||||||
bool isRtttlPlaying = rtttl::isPlaying();
|
bool isPlaying = rtttl::isPlaying();
|
||||||
#ifdef HAS_I2S
|
#ifdef HAS_I2S
|
||||||
// audioThread->isPlaying() also handles actually playing the RTTTL, needs to be called in loop
|
isPlaying = rtttl::isPlaying() || audioThread->isPlaying();
|
||||||
isRtttlPlaying = isRtttlPlaying || audioThread->isPlaying();
|
|
||||||
#endif
|
#endif
|
||||||
if ((nagCycleCutoff < millis()) && !isRtttlPlaying) {
|
if ((nagCycleCutoff < millis()) && !isPlaying) {
|
||||||
// let the song finish if we reach timeout
|
// let the song finish if we reach timeout
|
||||||
nagCycleCutoff = UINT32_MAX;
|
nagCycleCutoff = UINT32_MAX;
|
||||||
LOG_INFO("Turning off external notification: ");
|
LOG_INFO("Turning off external notification: ");
|
||||||
@@ -117,16 +116,21 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
|
|
||||||
// If the output is turned on, turn it back off after the given period of time.
|
// If the output is turned on, turn it back off after the given period of time.
|
||||||
if (isNagging) {
|
if (isNagging) {
|
||||||
delay = (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
||||||
: EXT_NOTIFICATION_MODULE_OUTPUT_MS);
|
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
||||||
if (externalTurnedOn[0] + delay < millis()) {
|
millis()) {
|
||||||
setExternalState(0, !getExternal(0));
|
setExternalState(0, !getExternal(0));
|
||||||
}
|
}
|
||||||
if (externalTurnedOn[1] + delay < millis()) {
|
if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
||||||
|
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
||||||
|
millis()) {
|
||||||
setExternalState(1, !getExternal(1));
|
setExternalState(1, !getExternal(1));
|
||||||
}
|
}
|
||||||
// Only toggle buzzer output if not using PWM mode (to avoid conflict with RTTTL)
|
// Only toggle buzzer output if not using PWM mode (to avoid conflict with RTTTL)
|
||||||
if (!moduleConfig.external_notification.use_pwm && externalTurnedOn[2] + delay < millis()) {
|
if (!moduleConfig.external_notification.use_pwm &&
|
||||||
|
externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
||||||
|
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
||||||
|
millis()) {
|
||||||
LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2] + moduleConfig.external_notification.output_ms,
|
LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2] + moduleConfig.external_notification.output_ms,
|
||||||
millis());
|
millis());
|
||||||
setExternalState(2, !getExternal(2));
|
setExternalState(2, !getExternal(2));
|
||||||
@@ -177,8 +181,6 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
colorState = 1;
|
colorState = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we need fast updates for the color change
|
|
||||||
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef T_WATCH_S3
|
#ifdef T_WATCH_S3
|
||||||
@@ -188,14 +190,12 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
|
|
||||||
// Play RTTTL over i2s audio interface if enabled as buzzer
|
// Play RTTTL over i2s audio interface if enabled as buzzer
|
||||||
#ifdef HAS_I2S
|
#ifdef HAS_I2S
|
||||||
if (moduleConfig.external_notification.use_i2s_as_buzzer) {
|
if (moduleConfig.external_notification.use_i2s_as_buzzer && canBuzz()) {
|
||||||
if (audioThread->isPlaying()) {
|
if (audioThread->isPlaying()) {
|
||||||
// Continue playing
|
// Continue playing
|
||||||
} else if (isNagging && (nagCycleCutoff >= millis())) {
|
} else if (isNagging && (nagCycleCutoff >= millis())) {
|
||||||
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
|
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
|
||||||
}
|
}
|
||||||
// we need fast updates to play the RTTTL
|
|
||||||
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// now let the PWM buzzer play
|
// now let the PWM buzzer play
|
||||||
@@ -206,11 +206,9 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
// start the song again if we have time left
|
// start the song again if we have time left
|
||||||
rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone);
|
rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone);
|
||||||
}
|
}
|
||||||
// we need fast updates to play the RTTTL
|
|
||||||
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return delay;
|
return EXT_NOTIFICATION_DEFAULT_THREAD_MS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+118
-103
@@ -112,191 +112,206 @@
|
|||||||
*/
|
*/
|
||||||
void setupModules()
|
void setupModules()
|
||||||
{
|
{
|
||||||
|
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
#if (HAS_BUTTON || ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_INPUTBROKER
|
#if (HAS_BUTTON || ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
inputBroker = new InputBroker();
|
inputBroker = new InputBroker();
|
||||||
systemCommandsModule = new SystemCommandsModule();
|
systemCommandsModule = new SystemCommandsModule();
|
||||||
buzzerFeedbackThread = new BuzzerFeedbackThread();
|
buzzerFeedbackThread = new BuzzerFeedbackThread();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_ADMIN
|
#if !MESHTASTIC_EXCLUDE_ADMIN
|
||||||
adminModule = new AdminModule();
|
adminModule = new AdminModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_NODEINFO
|
#if !MESHTASTIC_EXCLUDE_NODEINFO
|
||||||
nodeInfoModule = new NodeInfoModule();
|
nodeInfoModule = new NodeInfoModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
positionModule = new PositionModule();
|
positionModule = new PositionModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
||||||
waypointModule = new WaypointModule();
|
waypointModule = new WaypointModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_TEXTMESSAGE
|
#if !MESHTASTIC_EXCLUDE_TEXTMESSAGE
|
||||||
textMessageModule = new TextMessageModule();
|
textMessageModule = new TextMessageModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
||||||
traceRouteModule = new TraceRouteModule();
|
traceRouteModule = new TraceRouteModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_NEIGHBORINFO
|
#if !MESHTASTIC_EXCLUDE_NEIGHBORINFO
|
||||||
if (moduleConfig.has_neighbor_info && moduleConfig.neighbor_info.enabled) {
|
if (moduleConfig.has_neighbor_info && moduleConfig.neighbor_info.enabled) {
|
||||||
neighborInfoModule = new NeighborInfoModule();
|
neighborInfoModule = new NeighborInfoModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_DETECTIONSENSOR
|
#if !MESHTASTIC_EXCLUDE_DETECTIONSENSOR
|
||||||
if (moduleConfig.has_detection_sensor && moduleConfig.detection_sensor.enabled) {
|
if (moduleConfig.has_detection_sensor && moduleConfig.detection_sensor.enabled) {
|
||||||
detectionSensorModule = new DetectionSensorModule();
|
detectionSensorModule = new DetectionSensorModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_ATAK
|
#if !MESHTASTIC_EXCLUDE_ATAK
|
||||||
if (IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_TAK, meshtastic_Config_DeviceConfig_Role_TAK_TRACKER)) {
|
if (IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_TAK,
|
||||||
atakPluginModule = new AtakPluginModule();
|
meshtastic_Config_DeviceConfig_Role_TAK_TRACKER)) {
|
||||||
}
|
atakPluginModule = new AtakPluginModule();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_PKI
|
#if !MESHTASTIC_EXCLUDE_PKI
|
||||||
keyVerificationModule = new KeyVerificationModule();
|
keyVerificationModule = new KeyVerificationModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
||||||
dropzoneModule = new DropzoneModule();
|
dropzoneModule = new DropzoneModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
|
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
|
||||||
new GenericThreadModule();
|
new GenericThreadModule();
|
||||||
#endif
|
#endif
|
||||||
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
|
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
|
||||||
// to a global variable.
|
// to a global variable.
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
||||||
new RemoteHardwareModule();
|
new RemoteHardwareModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_POWERSTRESS
|
#if !MESHTASTIC_EXCLUDE_POWERSTRESS
|
||||||
new PowerStressModule();
|
new PowerStressModule();
|
||||||
#endif
|
#endif
|
||||||
// Example: Put your module here
|
// Example: Put your module here
|
||||||
// new ReplyModule();
|
// new ReplyModule();
|
||||||
#if (HAS_BUTTON || ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_INPUTBROKER
|
#if (HAS_BUTTON || ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
|
||||||
if (!rotaryEncoderInterruptImpl1->init()) {
|
if (!rotaryEncoderInterruptImpl1->init()) {
|
||||||
delete rotaryEncoderInterruptImpl1;
|
delete rotaryEncoderInterruptImpl1;
|
||||||
rotaryEncoderInterruptImpl1 = nullptr;
|
rotaryEncoderInterruptImpl1 = nullptr;
|
||||||
}
|
}
|
||||||
#ifdef T_LORA_PAGER
|
#ifdef T_LORA_PAGER
|
||||||
// use a special FSM based rotary encoder version for T-LoRa Pager
|
// use a special FSM based rotary encoder version for T-LoRa Pager
|
||||||
rotaryEncoderImpl = new RotaryEncoderImpl();
|
rotaryEncoderImpl = new RotaryEncoderImpl();
|
||||||
if (!rotaryEncoderImpl->init()) {
|
if (!rotaryEncoderImpl->init()) {
|
||||||
delete rotaryEncoderImpl;
|
delete rotaryEncoderImpl;
|
||||||
rotaryEncoderImpl = nullptr;
|
rotaryEncoderImpl = nullptr;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
upDownInterruptImpl1 = new UpDownInterruptImpl1();
|
upDownInterruptImpl1 = new UpDownInterruptImpl1();
|
||||||
if (!upDownInterruptImpl1->init()) {
|
if (!upDownInterruptImpl1->init()) {
|
||||||
delete upDownInterruptImpl1;
|
delete upDownInterruptImpl1;
|
||||||
upDownInterruptImpl1 = nullptr;
|
upDownInterruptImpl1 = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cardKbI2cImpl = new CardKbI2cImpl();
|
cardKbI2cImpl = new CardKbI2cImpl();
|
||||||
cardKbI2cImpl->init();
|
cardKbI2cImpl->init();
|
||||||
#if defined(M5STACK_UNITC6L)
|
#if defined(M5STACK_UNITC6L)
|
||||||
i2cButton = new i2cButtonThread("i2cButtonThread");
|
i2cButton = new i2cButtonThread("i2cButtonThread");
|
||||||
#endif
|
#endif
|
||||||
#ifdef INPUTBROKER_MATRIX_TYPE
|
#ifdef INPUTBROKER_MATRIX_TYPE
|
||||||
kbMatrixImpl = new KbMatrixImpl();
|
kbMatrixImpl = new KbMatrixImpl();
|
||||||
kbMatrixImpl->init();
|
kbMatrixImpl->init();
|
||||||
#endif // INPUTBROKER_MATRIX_TYPE
|
#endif // INPUTBROKER_MATRIX_TYPE
|
||||||
#ifdef INPUTBROKER_SERIAL_TYPE
|
#ifdef INPUTBROKER_SERIAL_TYPE
|
||||||
aSerialKeyboardImpl = new SerialKeyboardImpl();
|
aSerialKeyboardImpl = new SerialKeyboardImpl();
|
||||||
aSerialKeyboardImpl->init();
|
aSerialKeyboardImpl->init();
|
||||||
#endif // INPUTBROKER_MATRIX_TYPE
|
#endif // INPUTBROKER_MATRIX_TYPE
|
||||||
}
|
}
|
||||||
#endif // HAS_BUTTON
|
#endif // HAS_BUTTON
|
||||||
#if ARCH_PORTDUINO
|
#if ARCH_PORTDUINO
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
seesawRotary = new SeesawRotary("SeesawRotary");
|
seesawRotary = new SeesawRotary("SeesawRotary");
|
||||||
if (!seesawRotary->init()) {
|
if (!seesawRotary->init()) {
|
||||||
delete seesawRotary;
|
delete seesawRotary;
|
||||||
seesawRotary = nullptr;
|
seesawRotary = nullptr;
|
||||||
|
}
|
||||||
|
aLinuxInputImpl = new LinuxInputImpl();
|
||||||
|
aLinuxInputImpl->init();
|
||||||
}
|
}
|
||||||
aLinuxInputImpl = new LinuxInputImpl();
|
|
||||||
aLinuxInputImpl->init();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER && HAS_TRACKBALL
|
#if !MESHTASTIC_EXCLUDE_INPUTBROKER && HAS_TRACKBALL
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
trackballInterruptImpl1 = new TrackballInterruptImpl1();
|
trackballInterruptImpl1 = new TrackballInterruptImpl1();
|
||||||
trackballInterruptImpl1->init(TB_DOWN, TB_UP, TB_LEFT, TB_RIGHT, TB_PRESS);
|
trackballInterruptImpl1->init(TB_DOWN, TB_UP, TB_LEFT, TB_RIGHT, TB_PRESS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE
|
#ifdef INPUTBROKER_EXPRESSLRSFIVEWAY_TYPE
|
||||||
expressLRSFiveWayInput = new ExpressLRSFiveWay();
|
expressLRSFiveWayInput = new ExpressLRSFiveWay();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_SCREEN && !MESHTASTIC_EXCLUDE_CANNEDMESSAGES
|
#if HAS_SCREEN && !MESHTASTIC_EXCLUDE_CANNEDMESSAGES
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
cannedMessageModule = new CannedMessageModule();
|
cannedMessageModule = new CannedMessageModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ARCH_PORTDUINO
|
#if ARCH_PORTDUINO
|
||||||
new HostMetricsModule();
|
new HostMetricsModule();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_TELEMETRY
|
#if HAS_TELEMETRY
|
||||||
new DeviceTelemetryModule();
|
new DeviceTelemetryModule();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
if (moduleConfig.has_telemetry &&
|
if (moduleConfig.has_telemetry &&
|
||||||
(moduleConfig.telemetry.environment_measurement_enabled || moduleConfig.telemetry.environment_screen_enabled)) {
|
(moduleConfig.telemetry.environment_measurement_enabled || moduleConfig.telemetry.environment_screen_enabled)) {
|
||||||
new EnvironmentTelemetryModule();
|
new EnvironmentTelemetryModule();
|
||||||
}
|
}
|
||||||
#if __has_include("Adafruit_PM25AQI.h")
|
#if __has_include("Adafruit_PM25AQI.h")
|
||||||
if (moduleConfig.has_telemetry && moduleConfig.telemetry.air_quality_enabled &&
|
if (moduleConfig.has_telemetry && moduleConfig.telemetry.air_quality_enabled &&
|
||||||
nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first > 0) {
|
nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I].first > 0) {
|
||||||
new AirQualityTelemetryModule();
|
new AirQualityTelemetryModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_HEALTH_TELEMETRY
|
#if !MESHTASTIC_EXCLUDE_HEALTH_TELEMETRY
|
||||||
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MAX30102].first > 0 ||
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MAX30102].first > 0 ||
|
||||||
nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MLX90614].first > 0) {
|
nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MLX90614].first > 0) {
|
||||||
new HealthTelemetryModule();
|
new HealthTelemetryModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
if (moduleConfig.has_telemetry &&
|
if (moduleConfig.has_telemetry &&
|
||||||
(moduleConfig.telemetry.power_measurement_enabled || moduleConfig.telemetry.power_screen_enabled)) {
|
(moduleConfig.telemetry.power_measurement_enabled || moduleConfig.telemetry.power_screen_enabled)) {
|
||||||
new PowerTelemetryModule();
|
new PowerTelemetryModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
|
||||||
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
#if !MESHTASTIC_EXCLUDE_SERIAL
|
#if !MESHTASTIC_EXCLUDE_SERIAL
|
||||||
if (moduleConfig.has_serial && moduleConfig.serial.enabled &&
|
if (moduleConfig.has_serial && moduleConfig.serial.enabled &&
|
||||||
config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
||||||
new SerialModule();
|
new SerialModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Only run on an esp32 based device.
|
// Only run on an esp32 based device.
|
||||||
#if defined(USE_SX1280) && !MESHTASTIC_EXCLUDE_AUDIO
|
#if defined(USE_SX1280) && !MESHTASTIC_EXCLUDE_AUDIO
|
||||||
audioModule = new AudioModule();
|
audioModule = new AudioModule();
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
|
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
|
||||||
if (moduleConfig.has_paxcounter && moduleConfig.paxcounter.enabled) {
|
if (moduleConfig.has_paxcounter && moduleConfig.paxcounter.enabled) {
|
||||||
paxcounterModule = new PaxcounterModule();
|
paxcounterModule = new PaxcounterModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
|
#if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
|
||||||
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
||||||
if (moduleConfig.has_store_forward && moduleConfig.store_forward.enabled) {
|
if (moduleConfig.has_store_forward && moduleConfig.store_forward.enabled) {
|
||||||
storeForwardModule = new StoreForwardModule();
|
storeForwardModule = new StoreForwardModule();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
||||||
externalNotificationModule = new ExternalNotificationModule();
|
if (moduleConfig.has_external_notification && moduleConfig.external_notification.enabled) {
|
||||||
|
externalNotificationModule = new ExternalNotificationModule();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
||||||
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
|
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
|
||||||
new RangeTestModule();
|
new RangeTestModule();
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
#if !MESHTASTIC_EXCLUDE_ADMIN
|
||||||
|
adminModule = new AdminModule();
|
||||||
|
#endif
|
||||||
|
#if HAS_TELEMETRY
|
||||||
|
new DeviceTelemetryModule();
|
||||||
|
#endif
|
||||||
|
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
||||||
|
traceRouteModule = new TraceRouteModule();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
|
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
|
||||||
// acks
|
// acks
|
||||||
routingModule = new RoutingModule();
|
routingModule = new RoutingModule();
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply()
|
|||||||
u.public_key.bytes[0] = 0;
|
u.public_key.bytes[0] = 0;
|
||||||
u.public_key.size = 0;
|
u.public_key.size = 0;
|
||||||
}
|
}
|
||||||
|
// Coerce unmessagable for Repeater role
|
||||||
|
if (u.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||||
|
u.has_is_unmessagable = true;
|
||||||
|
u.is_unmessagable = true;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Send owner %s/%s/%s", u.id, u.long_name, u.short_name);
|
LOG_INFO("Send owner %s/%s/%s", u.id, u.long_name, u.short_name);
|
||||||
lastSentToMesh = millis();
|
lastSentToMesh = millis();
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ int32_t RangeTestModule::runOnce()
|
|||||||
// moduleConfig.range_test.enabled = 1;
|
// moduleConfig.range_test.enabled = 1;
|
||||||
// moduleConfig.range_test.sender = 30;
|
// moduleConfig.range_test.sender = 30;
|
||||||
// moduleConfig.range_test.save = 1;
|
// moduleConfig.range_test.save = 1;
|
||||||
// moduleConfig.range_test.clear_on_reboot = 1;
|
|
||||||
|
|
||||||
// Fixed position is useful when testing indoors.
|
// Fixed position is useful when testing indoors.
|
||||||
// config.position.fixed_position = 1;
|
// config.position.fixed_position = 1;
|
||||||
|
|
||||||
uint32_t senderHeartbeat = moduleConfig.range_test.sender * 1000;
|
uint32_t senderHeartbeat = moduleConfig.range_test.sender * 1000;
|
||||||
|
|
||||||
if (moduleConfig.range_test.enabled) {
|
if (moduleConfig.range_test.enabled) {
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
@@ -54,11 +54,6 @@ int32_t RangeTestModule::runOnce()
|
|||||||
|
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
|
||||||
if (moduleConfig.range_test.clear_on_reboot) {
|
|
||||||
// User wants to delete previous range test(s)
|
|
||||||
LOG_INFO("Range Test Module - Clearing out previous test file");
|
|
||||||
rangeTestModuleRadio->removeFile();
|
|
||||||
}
|
|
||||||
if (moduleConfig.range_test.sender) {
|
if (moduleConfig.range_test.sender) {
|
||||||
LOG_INFO("Init Range Test Module -- Sender");
|
LOG_INFO("Init Range Test Module -- Sender");
|
||||||
started = millis(); // make a note of when we started
|
started = millis(); // make a note of when we started
|
||||||
@@ -146,6 +141,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!isFromUs(&mp)) {
|
if (!isFromUs(&mp)) {
|
||||||
|
|
||||||
if (moduleConfig.range_test.save) {
|
if (moduleConfig.range_test.save) {
|
||||||
appendFile(mp);
|
appendFile(mp);
|
||||||
}
|
}
|
||||||
@@ -299,42 +295,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
|
|||||||
fileToAppend.printf("\"%s\"\n", p.payload.bytes);
|
fileToAppend.printf("\"%s\"\n", p.payload.bytes);
|
||||||
fileToAppend.flush();
|
fileToAppend.flush();
|
||||||
fileToAppend.close();
|
fileToAppend.close();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#else
|
|
||||||
LOG_ERROR("Failed to store range test results - feature only available for ESP32");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RangeTestModuleRadio::removeFile()
|
|
||||||
{
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
if (!FSBegin()) {
|
|
||||||
LOG_DEBUG("An Error has occurred while mounting the filesystem");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FSCom.exists("/static/rangetest.csv")) {
|
|
||||||
LOG_DEBUG("No range tests found.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO("Deleting previous range test.");
|
|
||||||
bool result = FSCom.remove("/static/rangetest.csv");
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
LOG_ERROR("Failed to delete range test.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
LOG_INFO("Range test removed.");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
LOG_ERROR("Failed to remove range test results - feature only available for ESP32");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@@ -44,11 +44,6 @@ class RangeTestModuleRadio : public SinglePortModule
|
|||||||
*/
|
*/
|
||||||
bool appendFile(const meshtastic_MeshPacket &mp);
|
bool appendFile(const meshtastic_MeshPacket &mp);
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup range test data from filesystem
|
|
||||||
*/
|
|
||||||
bool removeFile();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called to handle a particular incoming message
|
/** Called to handle a particular incoming message
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh
|
|||||||
|
|
||||||
meshtastic_MeshPacket *RoutingModule::allocReply()
|
meshtastic_MeshPacket *RoutingModule::allocReply()
|
||||||
{
|
{
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
|
||||||
|
return NULL;
|
||||||
assert(currentRequest);
|
assert(currentRequest);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ int32_t DeviceTelemetryModule::runOnce()
|
|||||||
Default::getConfiguredOrDefaultMsScaled(moduleConfig.telemetry.device_update_interval,
|
Default::getConfiguredOrDefaultMsScaled(moduleConfig.telemetry.device_update_interval,
|
||||||
default_telemetry_broadcast_interval_secs, numOnlineNodes))) &&
|
default_telemetry_broadcast_interval_secs, numOnlineNodes))) &&
|
||||||
airTime->isTxAllowedChannelUtil(!isImpoliteRole) && airTime->isTxAllowedAirUtil() &&
|
airTime->isTxAllowedChannelUtil(!isImpoliteRole) && airTime->isTxAllowedAirUtil() &&
|
||||||
|
config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) {
|
config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) {
|
||||||
sendTelemetry();
|
sendTelemetry();
|
||||||
lastSentToMesh = uptimeLastMs;
|
lastSentToMesh = uptimeLastMs;
|
||||||
@@ -43,6 +44,10 @@ int32_t DeviceTelemetryModule::runOnce()
|
|||||||
|
|
||||||
bool DeviceTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
|
bool DeviceTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
|
||||||
{
|
{
|
||||||
|
// Don't worry about storing telemetry in NodeDB if we're a repeater
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (t->which_variant == meshtastic_Telemetry_device_metrics_tag) {
|
if (t->which_variant == meshtastic_Telemetry_device_metrics_tag) {
|
||||||
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
||||||
const char *sender = getSenderShortName(mp);
|
const char *sender = getSenderShortName(mp);
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ int32_t HostMetricsModule::runOnce()
|
|||||||
|
|
||||||
bool HostMetricsModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
|
bool HostMetricsModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
|
||||||
{
|
{
|
||||||
|
// Don't worry about storing telemetry in NodeDB if we're a repeater
|
||||||
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (t->which_variant == meshtastic_Telemetry_host_metrics_tag) {
|
if (t->which_variant == meshtastic_Telemetry_host_metrics_tag) {
|
||||||
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
||||||
const char *sender = getSenderShortName(mp);
|
const char *sender = getSenderShortName(mp);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp
|
|||||||
auto &p = mp.decoded;
|
auto &p = mp.decoded;
|
||||||
LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We only store/display messages destined for us.
|
// We only store/display messages destined for us.
|
||||||
// Keep a copy of the most recent text message.
|
// Keep a copy of the most recent text message.
|
||||||
devicestate.rx_text_message = mp;
|
devicestate.rx_text_message = mp;
|
||||||
@@ -31,4 +30,4 @@ ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp
|
|||||||
bool TextMessageModule::wantPacket(const meshtastic_MeshPacket *p)
|
bool TextMessageModule::wantPacket(const meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
return MeshService::isTextPayload(p);
|
return MeshService::isTextPayload(p);
|
||||||
}
|
}
|
||||||
@@ -153,20 +153,6 @@ void TraceRouteModule::alterReceivedProtobuf(meshtastic_MeshPacket &p, meshtasti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceRouteModule::processUpgradedPacket(const meshtastic_MeshPacket &mp)
|
|
||||||
{
|
|
||||||
if (mp.which_payload_variant != meshtastic_MeshPacket_decoded_tag || mp.decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP)
|
|
||||||
return;
|
|
||||||
|
|
||||||
meshtastic_RouteDiscovery decoded = meshtastic_RouteDiscovery_init_zero;
|
|
||||||
if (!pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, &meshtastic_RouteDiscovery_msg, &decoded))
|
|
||||||
return;
|
|
||||||
|
|
||||||
handleReceivedProtobuf(mp, &decoded);
|
|
||||||
// Intentionally modify the packet in-place so downstream relays see our updates.
|
|
||||||
alterReceivedProtobuf(const_cast<meshtastic_MeshPacket &>(mp), &decoded);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceRouteModule::insertUnknownHops(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r, bool isTowardsDestination)
|
void TraceRouteModule::insertUnknownHops(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r, bool isTowardsDestination)
|
||||||
{
|
{
|
||||||
pb_size_t *route_count;
|
pb_size_t *route_count;
|
||||||
@@ -774,4 +760,4 @@ int32_t TraceRouteModule::runOnce()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return INT32_MAX;
|
return INT32_MAX;
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,6 @@ class TraceRouteModule : public ProtobufModule<meshtastic_RouteDiscovery>,
|
|||||||
virtual bool wantUIFrame() override { return shouldDraw(); }
|
virtual bool wantUIFrame() override { return shouldDraw(); }
|
||||||
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
|
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
|
||||||
|
|
||||||
void processUpgradedPacket(const meshtastic_MeshPacket &mp);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_RouteDiscovery *r) override;
|
bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_RouteDiscovery *r) override;
|
||||||
|
|
||||||
@@ -72,4 +70,4 @@ class TraceRouteModule : public ProtobufModule<meshtastic_RouteDiscovery>,
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TraceRouteModule *traceRouteModule;
|
extern TraceRouteModule *traceRouteModule;
|
||||||
@@ -53,8 +53,7 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
|
|||||||
hasChecked = true;
|
hasChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the run is triggered via NimbleBluetoothToRadioCallback and NimbleBluetoothFromRadioCallback
|
return 100;
|
||||||
return INT32_MAX;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
||||||
@@ -175,11 +174,11 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->drawString(x_offset + x, y_offset + y, "Bluetooth");
|
display->drawString(x_offset + x, y_offset + y, "Bluetooth");
|
||||||
#if !defined(M5STACK_UNITC6L)
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM - 4 : y_offset + FONT_HEIGHT_MEDIUM + 5;
|
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM - 4 : y_offset + FONT_HEIGHT_MEDIUM + 5;
|
||||||
display->drawString(x_offset + x, y_offset + y, "Enter this code");
|
display->drawString(x_offset + x, y_offset + y, "Enter this code");
|
||||||
#endif
|
|
||||||
display->setFont(FONT_LARGE);
|
display->setFont(FONT_LARGE);
|
||||||
char pin[8];
|
char pin[8];
|
||||||
snprintf(pin, sizeof(pin), "%.3s %.3s", btPIN, btPIN + 3);
|
snprintf(pin, sizeof(pin), "%.3s %.3s", btPIN, btPIN + 3);
|
||||||
@@ -248,9 +247,6 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
bluetoothPhoneAPI->numBytes = 0;
|
bluetoothPhoneAPI->numBytes = 0;
|
||||||
bluetoothPhoneAPI->queue_size = 0;
|
bluetoothPhoneAPI->queue_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection
|
|
||||||
memset(lastToRadio, 0, sizeof(lastToRadio));
|
|
||||||
#ifdef NIMBLE_TWO
|
#ifdef NIMBLE_TWO
|
||||||
// Restart Advertising
|
// Restart Advertising
|
||||||
ble->startAdvertising();
|
ble->startAdvertising();
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ static BLEDfuSecure bledfusecure; //
|
|||||||
static uint8_t fromRadioBytes[meshtastic_FromRadio_size];
|
static uint8_t fromRadioBytes[meshtastic_FromRadio_size];
|
||||||
static uint8_t toRadioBytes[meshtastic_ToRadio_size];
|
static uint8_t toRadioBytes[meshtastic_ToRadio_size];
|
||||||
|
|
||||||
// Last ToRadio value received from the phone
|
|
||||||
static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE];
|
|
||||||
|
|
||||||
static uint16_t connectionHandle;
|
static uint16_t connectionHandle;
|
||||||
|
|
||||||
class BluetoothPhoneAPI : public PhoneAPI
|
class BluetoothPhoneAPI : public PhoneAPI
|
||||||
@@ -77,9 +74,6 @@ void onDisconnect(uint16_t conn_handle, uint8_t reason)
|
|||||||
bluetoothPhoneAPI->close();
|
bluetoothPhoneAPI->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection
|
|
||||||
memset(lastToRadio, 0, sizeof(lastToRadio));
|
|
||||||
|
|
||||||
// Notify UI (or any other interested firmware components)
|
// Notify UI (or any other interested firmware components)
|
||||||
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
|
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
|
||||||
bluetoothStatus->updateStatus(&newStatus);
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
@@ -151,6 +145,8 @@ void onFromRadioAuthorize(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_e
|
|||||||
}
|
}
|
||||||
authorizeRead(conn_hdl);
|
authorizeRead(conn_hdl);
|
||||||
}
|
}
|
||||||
|
// Last ToRadio value received from the phone
|
||||||
|
static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE];
|
||||||
|
|
||||||
void onToRadioWrite(uint16_t conn_hdl, BLECharacteristic *chr, uint8_t *data, uint16_t len)
|
void onToRadioWrite(uint16_t conn_hdl, BLECharacteristic *chr, uint8_t *data, uint16_t len)
|
||||||
{
|
{
|
||||||
@@ -335,8 +331,7 @@ bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passke
|
|||||||
meshtastic::BluetoothStatus newStatus(textkey);
|
meshtastic::BluetoothStatus newStatus(textkey);
|
||||||
bluetoothStatus->updateStatus(&newStatus);
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
|
|
||||||
#if HAS_SCREEN && \
|
#if !defined(MESHTASTIC_EXCLUDE_SCREEN) // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
||||||
!defined(MESHTASTIC_EXCLUDE_SCREEN) // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screen->startAlert([](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
screen->startAlert([](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
||||||
char btPIN[16] = "888888";
|
char btPIN[16] = "888888";
|
||||||
|
|||||||
@@ -98,8 +98,6 @@
|
|||||||
#define HW_VENDOR meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1_EINK
|
#define HW_VENDOR meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1_EINK
|
||||||
#elif defined(SEEED_WIO_TRACKER_L1)
|
#elif defined(SEEED_WIO_TRACKER_L1)
|
||||||
#define HW_VENDOR meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1
|
#define HW_VENDOR meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1
|
||||||
#elif defined(R1_NEO)
|
|
||||||
#define HW_VENDOR meshtastic_HardwareModel_MUZI_R1_NEO
|
|
||||||
#elif defined(HELTEC_MESH_SOLAR)
|
#elif defined(HELTEC_MESH_SOLAR)
|
||||||
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_MESH_SOLAR
|
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_MESH_SOLAR
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ extern struct portduino_config_struct {
|
|||||||
out << YAML::Key << "RF95_MAX_POWER" << YAML::Value << rf95_max_power;
|
out << YAML::Key << "RF95_MAX_POWER" << YAML::Value << rf95_max_power;
|
||||||
out << YAML::Key << "DIO2_AS_RF_SWITCH" << YAML::Value << dio2_as_rf_switch;
|
out << YAML::Key << "DIO2_AS_RF_SWITCH" << YAML::Value << dio2_as_rf_switch;
|
||||||
if (dio3_tcxo_voltage != 0)
|
if (dio3_tcxo_voltage != 0)
|
||||||
out << YAML::Key << "DIO3_TCXO_VOLTAGE" << YAML::Value << YAML::Precision(3) << (float)dio3_tcxo_voltage / 1000;
|
out << YAML::Key << "DIO3_TCXO_VOLTAGE" << YAML::Value << dio3_tcxo_voltage;
|
||||||
if (lora_usb_pid != 0x5512)
|
if (lora_usb_pid != 0x5512)
|
||||||
out << YAML::Key << "USB_PID" << YAML::Value << YAML::Hex << lora_usb_pid;
|
out << YAML::Key << "USB_PID" << YAML::Value << YAML::Hex << lora_usb_pid;
|
||||||
if (lora_usb_vid != 0x1A86)
|
if (lora_usb_vid != 0x1A86)
|
||||||
|
|||||||
@@ -34,8 +34,6 @@
|
|||||||
#define OCV_ARRAY 4200, 3876, 3826, 3763, 3713, 3660, 3573, 3485, 3422, 3359, 3300
|
#define OCV_ARRAY 4200, 3876, 3826, 3763, 3713, 3660, 3573, 3485, 3422, 3359, 3300
|
||||||
#elif defined(SEEED_SOLAR_NODE)
|
#elif defined(SEEED_SOLAR_NODE)
|
||||||
#define OCV_ARRAY 4200, 3986, 3922, 3812, 3734, 3645, 3527, 3420, 3281, 3087, 2786
|
#define OCV_ARRAY 4200, 3986, 3922, 3812, 3734, 3645, 3527, 3420, 3281, 3087, 2786
|
||||||
#elif defined(R1_NEO)
|
|
||||||
#define OCV_ARRAY 4330, 4292, 4254, 4216, 4178, 4140, 4102, 4064, 4026, 3988, 3950
|
|
||||||
#else // LiIon
|
#else // LiIon
|
||||||
#define OCV_ARRAY 4190, 4050, 3990, 3890, 3800, 3720, 3630, 3530, 3420, 3300, 3100
|
#define OCV_ARRAY 4190, 4050, 3990, 3890, 3800, 3720, 3630, 3530, 3420, 3300, 3100
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+6
-14
@@ -411,16 +411,12 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
|||||||
// assert(uart_set_wakeup_threshold(UART_NUM_0, 3) == ESP_OK);
|
// assert(uart_set_wakeup_threshold(UART_NUM_0, 3) == ESP_OK);
|
||||||
// assert(esp_sleep_enable_uart_wakeup(0) == ESP_OK);
|
// assert(esp_sleep_enable_uart_wakeup(0) == ESP_OK);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ROTARY_PRESS
|
|
||||||
// The enableLoraInterrupt() method is using ext0_wakeup, so we are forced to use GPIO wakeup
|
|
||||||
gpio_wakeup_enable((gpio_num_t)ROTARY_PRESS, GPIO_INTR_LOW_LEVEL);
|
|
||||||
#endif
|
|
||||||
#ifdef KB_INT
|
|
||||||
gpio_wakeup_enable((gpio_num_t)KB_INT, GPIO_INTR_LOW_LEVEL);
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
|
// The enableLoraInterrupt() method is using ext0_wakeup, so we are forced to use GPIO wakeup
|
||||||
gpio_num_t pin = (gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN);
|
gpio_num_t pin = (gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN);
|
||||||
|
|
||||||
gpio_wakeup_enable(pin, GPIO_INTR_LOW_LEVEL);
|
gpio_wakeup_enable(pin, GPIO_INTR_LOW_LEVEL);
|
||||||
|
esp_sleep_enable_gpio_wakeup();
|
||||||
#endif
|
#endif
|
||||||
#ifdef INPUTDRIVER_ENCODER_BTN
|
#ifdef INPUTDRIVER_ENCODER_BTN
|
||||||
gpio_wakeup_enable((gpio_num_t)INPUTDRIVER_ENCODER_BTN, GPIO_INTR_LOW_LEVEL);
|
gpio_wakeup_enable((gpio_num_t)INPUTDRIVER_ENCODER_BTN, GPIO_INTR_LOW_LEVEL);
|
||||||
@@ -454,12 +450,7 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
|||||||
// commented out because it's not that crucial;
|
// commented out because it's not that crucial;
|
||||||
// if it sporadically happens the node will go into light sleep during the next round
|
// if it sporadically happens the node will go into light sleep during the next round
|
||||||
// assert(res == ESP_OK);
|
// assert(res == ESP_OK);
|
||||||
#ifdef ROTARY_PRESS
|
|
||||||
gpio_wakeup_disable((gpio_num_t)ROTARY_PRESS);
|
|
||||||
#endif
|
|
||||||
#ifdef KB_INT
|
|
||||||
gpio_wakeup_disable((gpio_num_t)KB_INT);
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
// Disable wake-on-button interrupt. Re-attach normal button-interrupts
|
// Disable wake-on-button interrupt. Re-attach normal button-interrupts
|
||||||
gpio_wakeup_disable(pin);
|
gpio_wakeup_disable(pin);
|
||||||
@@ -532,7 +523,8 @@ void enableModemSleep()
|
|||||||
|
|
||||||
bool shouldLoraWake(uint32_t msecToWake)
|
bool shouldLoraWake(uint32_t msecToWake)
|
||||||
{
|
{
|
||||||
return msecToWake < portMAX_DELAY && (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER);
|
return msecToWake < portMAX_DELAY && (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||||
|
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableLoraInterrupt()
|
void enableLoraInterrupt()
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
// "USERPREFS_CONFIG_LORA_REGION": "meshtastic_Config_LoRaConfig_RegionCode_US",
|
// "USERPREFS_CONFIG_LORA_REGION": "meshtastic_Config_LoRaConfig_RegionCode_US",
|
||||||
// "USERPREFS_CONFIG_OWNER_LONG_NAME": "My Long Name",
|
// "USERPREFS_CONFIG_OWNER_LONG_NAME": "My Long Name",
|
||||||
// "USERPREFS_CONFIG_OWNER_SHORT_NAME": "MLN",
|
// "USERPREFS_CONFIG_OWNER_SHORT_NAME": "MLN",
|
||||||
// "USERPREFS_CONFIG_DEVICE_ROLE": "meshtastic_Config_DeviceConfig_Role_CLIENT", // Defaults to CLIENT. ROUTER*, and LOST AND FOUND roles are restricted.
|
// "USERPREFS_CONFIG_DEVICE_ROLE": "meshtastic_Config_DeviceConfig_Role_CLIENT", // Defaults to CLIENT. ROUTER*, LOST AND FOUND, and REPEATER roles are restricted.
|
||||||
// "USERPREFS_EVENT_MODE": "1",
|
// "USERPREFS_EVENT_MODE": "1",
|
||||||
// "USERPREFS_FIRMWARE_EDITION": "meshtastic_FirmwareEdition_BURNING_MAN",
|
// "USERPREFS_FIRMWARE_EDITION": "meshtastic_FirmwareEdition_BURNING_MAN",
|
||||||
// "USERPREFS_FIXED_BLUETOOTH": "121212",
|
// "USERPREFS_FIXED_BLUETOOTH": "121212",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
extends = esp32s3_base
|
extends = esp32s3_base
|
||||||
board = heltec_v4
|
board = heltec_v4
|
||||||
board_check = true
|
board_check = true
|
||||||
board_build.partitions = default_16MB.csv
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32s3_base.build_flags}
|
${esp32s3_base.build_flags}
|
||||||
-D HELTEC_V4
|
-D HELTEC_V4
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "configuration.h"
|
|
||||||
|
|
||||||
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
|
||||||
|
|
||||||
// InkHUD-specific components
|
|
||||||
// ---------------------------
|
|
||||||
#include "graphics/niche/InkHUD/InkHUD.h"
|
|
||||||
|
|
||||||
// Applets
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/AllMessage/AllMessageApplet.h"
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/DM/DMApplet.h"
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/Heard/HeardApplet.h"
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/Positions/PositionsApplet.h"
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/RecentsList/RecentsListApplet.h"
|
|
||||||
#include "graphics/niche/InkHUD/Applets/User/ThreadedMessage/ThreadedMessageApplet.h"
|
|
||||||
|
|
||||||
// Shared NicheGraphics components
|
|
||||||
// --------------------------------
|
|
||||||
#include "graphics/niche/Drivers/EInk/E0213A367.h"
|
|
||||||
#include "graphics/niche/Inputs/TwoButton.h"
|
|
||||||
|
|
||||||
void setupNicheGraphics()
|
|
||||||
{
|
|
||||||
using namespace NicheGraphics;
|
|
||||||
|
|
||||||
// SPI
|
|
||||||
// -----------------------------
|
|
||||||
|
|
||||||
// For NRF52 platforms, SPI pins are defined in variant.h
|
|
||||||
SPI1.begin();
|
|
||||||
|
|
||||||
// E-Ink Driver
|
|
||||||
// -----------------------------
|
|
||||||
|
|
||||||
Drivers::EInk *driver = new Drivers::E0213A367;
|
|
||||||
driver->begin(&SPI1, PIN_EINK_DC, PIN_EINK_CS, PIN_EINK_BUSY, PIN_EINK_RES);
|
|
||||||
|
|
||||||
// InkHUD
|
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
InkHUD::InkHUD *inkhud = InkHUD::InkHUD::getInstance();
|
|
||||||
|
|
||||||
// Set the E-Ink driver
|
|
||||||
inkhud->setDriver(driver);
|
|
||||||
|
|
||||||
// Set how many FAST updates per FULL update
|
|
||||||
// Set how unhealthy additional FAST updates beyond this number are
|
|
||||||
inkhud->setDisplayResilience(10, 1.5);
|
|
||||||
|
|
||||||
// Select fonts
|
|
||||||
InkHUD::Applet::fontLarge = FREESANS_12PT_WIN1252;
|
|
||||||
InkHUD::Applet::fontMedium = FREESANS_9PT_WIN1252;
|
|
||||||
InkHUD::Applet::fontSmall = FREESANS_6PT_WIN1252;
|
|
||||||
|
|
||||||
// Customize default settings
|
|
||||||
inkhud->persistence->settings.userTiles.maxCount = 2; // How many tiles can the display handle?
|
|
||||||
inkhud->persistence->settings.rotation = 3; // 270 degrees clockwise
|
|
||||||
inkhud->persistence->settings.userTiles.count = 1; // One tile only by default, keep things simple for new users
|
|
||||||
inkhud->persistence->settings.optionalMenuItems.nextTile = true;
|
|
||||||
|
|
||||||
// Pick applets
|
|
||||||
// Note: order of applets determines priority of "auto-show" feature
|
|
||||||
inkhud->addApplet("All Messages", new InkHUD::AllMessageApplet, true, true); // Activated, autoshown
|
|
||||||
inkhud->addApplet("DMs", new InkHUD::DMApplet); // -
|
|
||||||
inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0)); // -
|
|
||||||
inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1)); // -
|
|
||||||
inkhud->addApplet("Positions", new InkHUD::PositionsApplet, true); // Activated
|
|
||||||
inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet); // -
|
|
||||||
inkhud->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, no autoshow, default on tile 0
|
|
||||||
|
|
||||||
// Start running InkHUD
|
|
||||||
inkhud->begin();
|
|
||||||
|
|
||||||
// Buttons
|
|
||||||
// --------------------------
|
|
||||||
|
|
||||||
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // Shared NicheGraphics component
|
|
||||||
|
|
||||||
// #0: Main User Button
|
|
||||||
buttons->setWiring(0, Inputs::TwoButton::getUserButtonPin());
|
|
||||||
buttons->setHandlerShortPress(0, [inkhud]() { inkhud->shortpress(); });
|
|
||||||
buttons->setHandlerLongPress(0, [inkhud]() { inkhud->longpress(); });
|
|
||||||
|
|
||||||
// Begin handling button events
|
|
||||||
buttons->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
; First prototype nrf52840/sx1262 device
|
; First prototype nrf52840/sx1262 device
|
||||||
[heltec_mesh_solar_base]
|
[env:heltec-mesh-solar]
|
||||||
extends = nrf52840_base
|
extends = nrf52840_base
|
||||||
board = heltec_mesh_solar
|
board = heltec_mesh_solar
|
||||||
board_level = pr
|
board_level = pr
|
||||||
@@ -17,100 +17,3 @@ lib_deps =
|
|||||||
https://github.com/NMIoT/meshsolar/archive/dfc5330dad443982e6cdd37a61d33fc7252f468b.zip
|
https://github.com/NMIoT/meshsolar/archive/dfc5330dad443982e6cdd37a61d33fc7252f468b.zip
|
||||||
lewisxhe/PCF8563_Library@^1.0.1
|
lewisxhe/PCF8563_Library@^1.0.1
|
||||||
ArduinoJson@6.21.4
|
ArduinoJson@6.21.4
|
||||||
[env:heltec-mesh-solar]
|
|
||||||
extends = heltec_mesh_solar_base
|
|
||||||
build_flags = ${heltec_mesh_solar_base.build_flags}
|
|
||||||
-DSPI_INTERFACES_COUNT=1
|
|
||||||
|
|
||||||
[env:heltec-mesh-solar-eink]
|
|
||||||
extends = heltec_mesh_solar_base
|
|
||||||
build_flags = ${heltec_mesh_solar_base.build_flags}
|
|
||||||
-DHELTEC_MESH_SOLAR_EINK
|
|
||||||
-DSPI_INTERFACES_COUNT=2
|
|
||||||
-DUSE_EINK
|
|
||||||
-DPIN_SCREEN_VDD_CTL=3
|
|
||||||
-DPIN_EINK_CS=41
|
|
||||||
-DPIN_EINK_BUSY=11
|
|
||||||
-DPIN_EINK_DC=13
|
|
||||||
-DPIN_EINK_RES=40
|
|
||||||
-DPIN_EINK_SCLK=12
|
|
||||||
-DPIN_EINK_MOSI=2
|
|
||||||
-DPIN_SPI1_MISO=-1
|
|
||||||
-DPIN_SPI1_MOSI=PIN_EINK_MOSI
|
|
||||||
-DPIN_SPI1_SCK=PIN_EINK_SCLK
|
|
||||||
-DEINK_DISPLAY_MODEL=GxEPD2_213_E0213A367
|
|
||||||
-DEINK_WIDTH=250
|
|
||||||
-DEINK_HEIGHT=122
|
|
||||||
-DUSE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk
|
|
||||||
-DEINK_LIMIT_FASTREFRESH=10 ; How many consecutive fast-refreshes are permitted
|
|
||||||
-DEINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates
|
|
||||||
-DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates
|
|
||||||
-DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
|
|
||||||
-DEINK_HASQUIRK_GHOSTING ; Display model is identified as "prone to ghosting"
|
|
||||||
lib_deps =
|
|
||||||
${heltec_mesh_solar_base.lib_deps}
|
|
||||||
https://github.com/meshtastic/GxEPD2/archive/a05c11c02862624266b61599b0d6ba93e33c6f24.zip
|
|
||||||
|
|
||||||
[env:heltec-mesh-solar-inkhud]
|
|
||||||
extends = heltec_mesh_solar_base, inkhud
|
|
||||||
build_src_filter = ${heltec_mesh_solar_base.build_src_filter} ${inkhud.build_src_filter}
|
|
||||||
build_flags = ${heltec_mesh_solar_base.build_flags}
|
|
||||||
${inkhud.build_flags}
|
|
||||||
-DHELTEC_MESH_SOLAR_INKHUD
|
|
||||||
-DSPI_INTERFACES_COUNT=2
|
|
||||||
-DPIN_SCREEN_VDD_CTL=3
|
|
||||||
-DPIN_EINK_CS=41
|
|
||||||
-DPIN_EINK_BUSY=11
|
|
||||||
-DPIN_EINK_DC=13
|
|
||||||
-DPIN_EINK_RES=40
|
|
||||||
-DPIN_EINK_SCLK=12
|
|
||||||
-DPIN_EINK_MOSI=2
|
|
||||||
-DPIN_SPI1_MISO=-1
|
|
||||||
-DPIN_SPI1_MOSI=PIN_EINK_MOSI
|
|
||||||
-DPIN_SPI1_SCK=PIN_EINK_SCLK
|
|
||||||
lib_deps =
|
|
||||||
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot instead of AdafruitGFX
|
|
||||||
${heltec_mesh_solar_base.lib_deps}
|
|
||||||
|
|
||||||
|
|
||||||
[env:heltec-mesh-solar-oled]
|
|
||||||
extends = heltec_mesh_solar_base
|
|
||||||
build_flags = ${heltec_mesh_solar_base.build_flags}
|
|
||||||
-DHELTEC_MESH_SOLAR_OLED
|
|
||||||
-DSPI_INTERFACES_COUNT=1
|
|
||||||
-DPIN_SCREEN_VDD_CTL=3
|
|
||||||
-DHAS_SCREEN=1
|
|
||||||
-DRESET_OLED=40
|
|
||||||
-DPIN_WIRE_SDA=2
|
|
||||||
-DPIN_WIRE_SCL=12
|
|
||||||
|
|
||||||
[env:heltec-mesh-solar-tft]
|
|
||||||
extends = heltec_mesh_solar_base
|
|
||||||
build_flags = ${heltec_mesh_solar_base.build_flags}
|
|
||||||
-DHELTEC_MESH_SOLAR_TFT
|
|
||||||
-DSPI_INTERFACES_COUNT=2
|
|
||||||
-DUSE_ST7789
|
|
||||||
-DST7789_NSS=41
|
|
||||||
-DST7789_RS=13
|
|
||||||
-DST7789_SDA=2
|
|
||||||
-DST7789_SCK=12
|
|
||||||
-DST7789_RESET=40
|
|
||||||
-DST7789_MISO=-1
|
|
||||||
-DST7789_BUSY=-1
|
|
||||||
-DVTFT_CTRL=3
|
|
||||||
-DVTFT_LEDA=11
|
|
||||||
-DTFT_BACKLIGHT_ON=HIGH
|
|
||||||
-DST7789_SPI_HOST=SPI2_HOST
|
|
||||||
-DSPI_FREQUENCY=10000000
|
|
||||||
-DSPI_READ_FREQUENCY=10000000
|
|
||||||
-DTFT_HEIGHT=170
|
|
||||||
-DTFT_WIDTH=320
|
|
||||||
-DTFT_OFFSET_X=0
|
|
||||||
-DTFT_OFFSET_Y=0
|
|
||||||
-DBRIGHTNESS_DEFAULT=100
|
|
||||||
-DPIN_SPI1_MISO=ST7789_MISO
|
|
||||||
-DPIN_SPI1_MOSI=ST7789_SDA
|
|
||||||
-DPIN_SPI1_SCK=ST7789_SCK
|
|
||||||
lib_deps =
|
|
||||||
${heltec_mesh_solar_base.lib_deps}
|
|
||||||
https://github.com/meshtastic/st7789/archive/bd33ea58ddfe4a5e4a66d53300ccbd38d66ac21f.zip
|
|
||||||
|
|||||||
@@ -32,9 +32,5 @@ const uint32_t g_ADigitalPinMap[] = {
|
|||||||
|
|
||||||
void initVariant()
|
void initVariant()
|
||||||
{
|
{
|
||||||
pinMode(BQ4050_EMERGENCY_SHUTDOWN_PIN, INPUT);
|
pinMode(BQ4050_EMERGENCY_SHUTDOWN_PIN, INPUT);
|
||||||
#if defined(PIN_SCREEN_VDD_CTL)
|
|
||||||
pinMode(PIN_SCREEN_VDD_CTL, OUTPUT);
|
|
||||||
digitalWrite(PIN_SCREEN_VDD_CTL, LOW); // Start with power on
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,15 +39,16 @@ extern "C" {
|
|||||||
#define NUM_ANALOG_INPUTS (1)
|
#define NUM_ANALOG_INPUTS (1)
|
||||||
#define NUM_ANALOG_OUTPUTS (0)
|
#define NUM_ANALOG_OUTPUTS (0)
|
||||||
|
|
||||||
#define PIN_LED1 (0 + 4) // green (confirmed on 1.0 board)
|
|
||||||
|
#define PIN_LED1 (0 + 12) // green (confirmed on 1.0 board)
|
||||||
#define LED_BLUE PIN_LED1 // fake for bluefruit library
|
#define LED_BLUE PIN_LED1 // fake for bluefruit library
|
||||||
#define LED_GREEN PIN_LED1
|
#define LED_GREEN PIN_LED1
|
||||||
#define LED_BUILTIN LED_GREEN
|
#define LED_BUILTIN LED_GREEN
|
||||||
#define LED_STATE_ON 0 // State when LED is lit
|
#define LED_STATE_ON 0 // State when LED is lit
|
||||||
|
|
||||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||||
#define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
|
#define NEOPIXEL_DATA (32+15) // gpio pin used to send data to the neopixels
|
||||||
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
|
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -62,6 +63,7 @@ No longer populated on PCB
|
|||||||
*/
|
*/
|
||||||
#define PIN_SERIAL2_RX (0 + 9)
|
#define PIN_SERIAL2_RX (0 + 9)
|
||||||
#define PIN_SERIAL2_TX (0 + 10)
|
#define PIN_SERIAL2_TX (0 + 10)
|
||||||
|
// #define PIN_SERIAL2_EN (0 + 17)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I2C
|
* I2C
|
||||||
@@ -69,16 +71,16 @@ No longer populated on PCB
|
|||||||
|
|
||||||
#define WIRE_INTERFACES_COUNT 2
|
#define WIRE_INTERFACES_COUNT 2
|
||||||
|
|
||||||
#ifndef HELTEC_MESH_SOLAR_OLED
|
|
||||||
// I2C bus 0
|
// I2C bus 0
|
||||||
#define PIN_WIRE_SDA (0 + 6)
|
// Routed to footprint for PCF8563TS RTC
|
||||||
#define PIN_WIRE_SCL (0 + 26)
|
// Not populated on T114 V1, maybe in future?
|
||||||
#endif
|
#define PIN_WIRE_SDA (0 + 6) // P0.26
|
||||||
|
#define PIN_WIRE_SCL (0 + 26) // P0.26
|
||||||
|
|
||||||
// I2C bus 1
|
// I2C bus 1
|
||||||
// Available on header pins, for general use
|
// Available on header pins, for general use
|
||||||
#define PIN_WIRE1_SDA (0 + 30)
|
#define PIN_WIRE1_SDA (0 + 30) // P0.30
|
||||||
#define PIN_WIRE1_SCL (0 + 5)
|
#define PIN_WIRE1_SCL (0 + 5) // P0.13
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lora radio
|
* Lora radio
|
||||||
@@ -87,14 +89,14 @@ No longer populated on PCB
|
|||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
// #define USE_SX1268
|
// #define USE_SX1268
|
||||||
#define SX126X_CS (0 + 24) // FIXME - we really should define LORA_CS instead
|
#define SX126X_CS (0 + 24) // FIXME - we really should define LORA_CS instead
|
||||||
#define LORA_CS (0 + 24)
|
#define LORA_CS (0 + 24)
|
||||||
#define SX126X_DIO1 (0 + 20)
|
#define SX126X_DIO1 (0 + 20)
|
||||||
// Note DIO2 is attached internally to the module to an analog switch for TX/RX switching
|
// Note DIO2 is attached internally to the module to an analog switch for TX/RX switching
|
||||||
// #define SX1262_DIO3 (0 + 21)
|
// #define SX1262_DIO3 (0 + 21)
|
||||||
// This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the
|
// This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the
|
||||||
// main
|
// main
|
||||||
// CPU?
|
// CPU?
|
||||||
#define SX126X_BUSY (0 + 17)
|
#define SX126X_BUSY (0 + 17)
|
||||||
#define SX126X_RESET (0 + 25)
|
#define SX126X_RESET (0 + 25)
|
||||||
// Not really an E22 but TTGO seems to be trying to clone that
|
// Not really an E22 but TTGO seems to be trying to clone that
|
||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
#define SX126X_DIO2_AS_RF_SWITCH
|
||||||
@@ -127,20 +129,21 @@ No longer populated on PCB
|
|||||||
/*
|
/*
|
||||||
* SPI Interfaces
|
* SPI Interfaces
|
||||||
*/
|
*/
|
||||||
|
#define SPI_INTERFACES_COUNT 1
|
||||||
|
|
||||||
// For LORA, spi 0
|
// For LORA, spi 0
|
||||||
#define PIN_SPI_MISO (0 + 23)
|
#define PIN_SPI_MISO (0 + 23)
|
||||||
#define PIN_SPI_MOSI (0 + 22)
|
#define PIN_SPI_MOSI (0 + 22)
|
||||||
#define PIN_SPI_SCK (0 + 19)
|
#define PIN_SPI_SCK (0 + 19)
|
||||||
|
|
||||||
// #define PIN_PWR_EN (0 + 6)
|
// #define PIN_PWR_EN (0 + 6)
|
||||||
|
|
||||||
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
||||||
// #define USE_SEGGER
|
// #define USE_SEGGER
|
||||||
|
|
||||||
#define BQ4050_SDA_PIN (32 + 1) // I2C data line pin
|
#define BQ4050_SDA_PIN (32+1) // I2C data line pin
|
||||||
#define BQ4050_SCL_PIN (32 + 0) // I2C clock line pin
|
#define BQ4050_SCL_PIN (32+0) // I2C clock line pin
|
||||||
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32 + 3) // Emergency shutdown pin
|
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32+3) // Emergency shutdown pin
|
||||||
|
|
||||||
#define HAS_RTC 0
|
#define HAS_RTC 0
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
; The R1 Neo board
|
|
||||||
[env:r1-neo]
|
|
||||||
extends = nrf52840_base
|
|
||||||
board = r1-neo
|
|
||||||
board_check = true
|
|
||||||
build_flags = ${nrf52840_base.build_flags}
|
|
||||||
-Ivariants/nrf52840/r1-neo
|
|
||||||
-D R1_NEO
|
|
||||||
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
|
|
||||||
-DRADIOLIB_EXCLUDE_SX128X=1
|
|
||||||
-DRADIOLIB_EXCLUDE_SX127X=1
|
|
||||||
-DRADIOLIB_EXCLUDE_LR11X0=1
|
|
||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/r1-neo> +<mesh/api/> +<mqtt/>
|
|
||||||
lib_deps =
|
|
||||||
${nrf52840_base.lib_deps}
|
|
||||||
${networking_base.lib_deps}
|
|
||||||
https://github.com/RAKWireless/RAK13800-W5100S/archive/1.0.2.zip
|
|
||||||
rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2
|
|
||||||
artronshop/ArtronShop_RX8130CE@1.0.0
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
|
||||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
|
||||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "variant.h"
|
|
||||||
#include "nrf.h"
|
|
||||||
#include "wiring_constants.h"
|
|
||||||
#include "wiring_digital.h"
|
|
||||||
|
|
||||||
const uint32_t g_ADigitalPinMap[] = {
|
|
||||||
// P0
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
|
||||||
|
|
||||||
// P1
|
|
||||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
|
|
||||||
|
|
||||||
void initVariant()
|
|
||||||
{
|
|
||||||
// LED1 & LED2
|
|
||||||
pinMode(PIN_LED1, OUTPUT);
|
|
||||||
ledOff(PIN_LED1);
|
|
||||||
|
|
||||||
pinMode(PIN_LED2, OUTPUT);
|
|
||||||
ledOff(PIN_LED2);
|
|
||||||
|
|
||||||
// 3V3 Power Rail
|
|
||||||
// pinMode(PIN_3V3_EN, OUTPUT);
|
|
||||||
// digitalWrite(PIN_3V3_EN, HIGH);
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
|
||||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
|
||||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the GNU Lesser General Public License for more details.
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VARIANT_R1NEO_
|
|
||||||
#define _VARIANT_R1NEO_
|
|
||||||
|
|
||||||
#define RAK4630
|
|
||||||
|
|
||||||
/** Master clock frequency */
|
|
||||||
#define VARIANT_MCK (64000000ul)
|
|
||||||
|
|
||||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
|
||||||
// define USE_LFRC // Board uses RC for LF
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Headers
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "WVariant.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
// Number of pins defined in PinDescription array
|
|
||||||
#define PINS_COUNT (48)
|
|
||||||
#define NUM_DIGITAL_PINS (48)
|
|
||||||
#define NUM_ANALOG_INPUTS (1)
|
|
||||||
#define NUM_ANALOG_OUTPUTS (0)
|
|
||||||
|
|
||||||
// LEDs
|
|
||||||
#define PIN_LED1 (32 + 4) // P1.04 Controls Green LED
|
|
||||||
#define PIN_LED2 (28) // P0.28 Controls Blue LED
|
|
||||||
|
|
||||||
#define LED_BUILTIN PIN_LED1
|
|
||||||
#define LED_CONN PIN_LED2
|
|
||||||
|
|
||||||
#define LED_GREEN PIN_LED1
|
|
||||||
#define LED_BLUE PIN_LED2
|
|
||||||
|
|
||||||
#define LED_STATE_ON 1 // State when LED is litted
|
|
||||||
|
|
||||||
// Button
|
|
||||||
#define PIN_BUTTON1 (26)
|
|
||||||
#define BUTTON_ACTIVE_LOW 0
|
|
||||||
#define BUTTON_ACTIVE_PULLUP 0
|
|
||||||
#define BUTTON_SENSE_TYPE INPUT_SENSE_HIGH
|
|
||||||
|
|
||||||
#define ADC_RESOLUTION 14
|
|
||||||
|
|
||||||
// Serial for GPS
|
|
||||||
#define PIN_SERIAL1_RX (25)
|
|
||||||
#define PIN_SERIAL1_TX (24)
|
|
||||||
|
|
||||||
// Connected to Jlink CDC
|
|
||||||
#define PIN_SERIAL2_RX (8)
|
|
||||||
#define PIN_SERIAL2_TX (6)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SPI Interfaces
|
|
||||||
*/
|
|
||||||
#define SPI_INTERFACES_COUNT 1
|
|
||||||
|
|
||||||
#define PIN_SPI_MISO (45)
|
|
||||||
#define PIN_SPI_MOSI (44)
|
|
||||||
#define PIN_SPI_SCK (43)
|
|
||||||
|
|
||||||
static const uint8_t SS = 42;
|
|
||||||
static const uint8_t MOSI = PIN_SPI_MOSI;
|
|
||||||
static const uint8_t MISO = PIN_SPI_MISO;
|
|
||||||
static const uint8_t SCK = PIN_SPI_SCK;
|
|
||||||
|
|
||||||
// R1 Neo Extras
|
|
||||||
#define DCDC_EN_HOLD (13) // P0.13 Keeps DCDC alive after user button is pressed
|
|
||||||
#define NRF_ON (29) // P0.29 Tells IO controller device is on
|
|
||||||
|
|
||||||
// RAKRGB
|
|
||||||
#define HAS_NCP5623
|
|
||||||
|
|
||||||
#define HAS_SCREEN 0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wire Interfaces
|
|
||||||
*/
|
|
||||||
#define WIRE_INTERFACES_COUNT 1
|
|
||||||
|
|
||||||
#define PIN_WIRE_SDA (19) // P0.19 RTC_SDA
|
|
||||||
#define PIN_WIRE_SCL (20) // P0.20 RTC_SCL
|
|
||||||
|
|
||||||
#define PIN_BUZZER (0 + 3) // P0.03
|
|
||||||
|
|
||||||
#define USE_SX1262
|
|
||||||
#define SX126X_CS (42)
|
|
||||||
#define SX126X_DIO1 (47)
|
|
||||||
#define SX126X_BUSY (46)
|
|
||||||
#define SX126X_RESET (38)
|
|
||||||
#define SX126X_POWER_EN (37)
|
|
||||||
|
|
||||||
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
|
||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
|
||||||
|
|
||||||
// Testing USB detection
|
|
||||||
#define NRF_APM
|
|
||||||
|
|
||||||
#define PIN_GPS_EN (32 + 1) // P1.01
|
|
||||||
#define PIN_GPS_PPS (2) // P0.02 Pulse per second input from the GPS
|
|
||||||
|
|
||||||
#define GPS_RX_PIN PIN_SERIAL1_RX
|
|
||||||
#define GPS_TX_PIN PIN_SERIAL1_TX
|
|
||||||
|
|
||||||
// Battery
|
|
||||||
#define BATTERY_PIN (0 + 31) // P0.31 ADC_VBAT
|
|
||||||
// and has 12 bit resolution
|
|
||||||
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
|
||||||
#define BATTERY_SENSE_RESOLUTION 4096.0
|
|
||||||
#undef AREF_VOLTAGE
|
|
||||||
#define AREF_VOLTAGE 3.0
|
|
||||||
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
|
||||||
#define ADC_MULTIPLIER 1.73
|
|
||||||
|
|
||||||
#define HAS_RTC 1
|
|
||||||
|
|
||||||
#define RX8130CE_RTC 0x32
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Arduino objects - C++ only
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 2
|
major = 2
|
||||||
minor = 7
|
minor = 7
|
||||||
build = 11
|
build = 10
|
||||||
|
|||||||
Reference in New Issue
Block a user