mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-29 21:22:03 +00:00
Compare commits
35 Commits
v2.1.6.567
...
v2.1.8.ee9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee971e376a | ||
|
|
eeeb7c5080 | ||
|
|
f526c4cc5a | ||
|
|
a9eb19fc62 | ||
|
|
29c13b5c30 | ||
|
|
f0c4c18a79 | ||
|
|
320bf57687 | ||
|
|
43cff7adc9 | ||
|
|
d4e42898b1 | ||
|
|
82ab38d3e6 | ||
|
|
aa96ea02c6 | ||
|
|
242f880764 | ||
|
|
de08360271 | ||
|
|
990d418dc8 | ||
|
|
fc8d16bb08 | ||
|
|
af65013e49 | ||
|
|
b1937e03ac | ||
|
|
23e6bc32c0 | ||
|
|
bd1e747fc9 | ||
|
|
3c0817340a | ||
|
|
9a42861766 | ||
|
|
038ff0f6cb | ||
|
|
918b509be8 | ||
|
|
9239698004 | ||
|
|
71479a6b17 | ||
|
|
b4bcae98cd | ||
|
|
294771cb44 | ||
|
|
1398611276 | ||
|
|
fbc3b2beee | ||
|
|
6bf538e26f | ||
|
|
713b5fbe96 | ||
|
|
ed96321406 | ||
|
|
3f07251d23 | ||
|
|
657f22d058 | ||
|
|
bf1fbc6c0d |
1
.github/workflows/main_matrix.yml
vendored
1
.github/workflows/main_matrix.yml
vendored
@@ -42,6 +42,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-base
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
- name: Trunk Check
|
- name: Trunk Check
|
||||||
|
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||||
uses: trunk-io/trunk-action@v1
|
uses: trunk-io/trunk-action@v1
|
||||||
|
|
||||||
- name: Check ${{ matrix.board }}
|
- name: Check ${{ matrix.board }}
|
||||||
|
|||||||
3
.trunk/configs/.flake8
Normal file
3
.trunk/configs/.flake8
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Autoformatter friendly flake8 config (all formatting rules disabled)
|
||||||
|
[flake8]
|
||||||
|
extend-ignore = D1, D2, E1, E2, E3, E501, W1, W2, W3, W5
|
||||||
2
.trunk/configs/.isort.cfg
Normal file
2
.trunk/configs/.isort.cfg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[settings]
|
||||||
|
profile=black
|
||||||
10
.trunk/configs/.yamllint.yaml
Normal file
10
.trunk/configs/.yamllint.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
rules:
|
||||||
|
quoted-strings:
|
||||||
|
required: only-when-needed
|
||||||
|
extra-allowed: ["{|}"]
|
||||||
|
empty-values:
|
||||||
|
forbid-in-block-mappings: true
|
||||||
|
forbid-in-flow-mappings: true
|
||||||
|
key-duplicates: {}
|
||||||
|
octal-values:
|
||||||
|
forbid-implicit-octal: true
|
||||||
5
.trunk/configs/ruff.toml
Normal file
5
.trunk/configs/ruff.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Generic, formatter-friendly config.
|
||||||
|
select = ["B", "D3", "D4", "E", "F"]
|
||||||
|
|
||||||
|
# Never enforce `E501` (line length violations). This should be handled by formatters.
|
||||||
|
ignore = ["E501"]
|
||||||
@@ -1,18 +1,31 @@
|
|||||||
version: 0.1
|
version: 0.1
|
||||||
cli:
|
cli:
|
||||||
version: 1.3.1
|
version: 1.7.0
|
||||||
plugins:
|
plugins:
|
||||||
sources:
|
sources:
|
||||||
- id: trunk
|
- id: trunk
|
||||||
ref: v0.0.8
|
ref: v0.0.14
|
||||||
uri: https://github.com/trunk-io/plugins
|
uri: https://github.com/trunk-io/plugins
|
||||||
lint:
|
lint:
|
||||||
enabled:
|
enabled:
|
||||||
|
- ruff@0.0.260
|
||||||
|
- yamllint@1.30.0
|
||||||
|
- isort@5.12.0
|
||||||
|
- markdownlint@0.33.0
|
||||||
|
- oxipng@8.0.0
|
||||||
|
- svgo@3.0.2
|
||||||
|
- actionlint@1.6.23
|
||||||
|
- flake8@6.0.0
|
||||||
|
- hadolint@2.12.0
|
||||||
|
- shfmt@3.5.0
|
||||||
|
- shellcheck@0.9.0
|
||||||
|
- black@23.3.0
|
||||||
- git-diff-check
|
- git-diff-check
|
||||||
- gitleaks@8.15.2
|
- gitleaks@8.16.2
|
||||||
- clang-format@14.0.0
|
- clang-format@14.0.0
|
||||||
- prettier@2.8.3
|
- prettier@2.8.7
|
||||||
disabled:
|
disabled:
|
||||||
|
- taplo@0.7.0
|
||||||
- shellcheck@0.9.0
|
- shellcheck@0.9.0
|
||||||
- shfmt@3.5.0
|
- shfmt@3.5.0
|
||||||
- oxipng@8.0.0
|
- oxipng@8.0.0
|
||||||
@@ -22,7 +35,8 @@ lint:
|
|||||||
- svgo@3.0.2
|
- svgo@3.0.2
|
||||||
runtimes:
|
runtimes:
|
||||||
enabled:
|
enabled:
|
||||||
- go@1.18.3
|
- python@3.10.8
|
||||||
|
- go@1.19.5
|
||||||
- node@18.12.1
|
- node@18.12.1
|
||||||
actions:
|
actions:
|
||||||
disabled:
|
disabled:
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs ..\protobufs\meshtastic\*.proto
|
cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --experimental_allow_proto3_optional --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs ..\protobufs\meshtastic\*.proto
|
||||||
|
|
||||||
@REM cd ../src/mesh/generated/meshtastic
|
|
||||||
@REM sed -i 's/#include "meshtastic/#include "./g' *
|
|
||||||
@REM sed -i 's/meshtastic_//g' *
|
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ lib_deps =
|
|||||||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||||
nanopb/Nanopb@^0.4.7
|
nanopb/Nanopb@^0.4.7
|
||||||
erriez/ErriezCRC32@^1.0.1
|
erriez/ErriezCRC32@^1.0.1
|
||||||
jgromes/RadioLib@^5.7.0
|
; temp: do this till > 5.7.0 release to keep (some) SX1262 and SX1280 working - resolves -705 error during init
|
||||||
|
https://github.com/jgromes/RadioLib.git#45c5859338590b7eede23cb2f95284c3fb0cf08e
|
||||||
|
; jgromes/RadioLib@^5.7.0
|
||||||
|
|
||||||
; Used for the code analysis in PIO Home / Inspect
|
; Used for the code analysis in PIO Home / Inspect
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
|
|||||||
Submodule protobufs updated: ef83ba1d91...ee6f408bb3
@@ -123,14 +123,10 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
static void userButtonPressedLong()
|
static void userButtonPressedLong()
|
||||||
{
|
{
|
||||||
// LOG_DEBUG("Long press!\n");
|
// LOG_DEBUG("Long press!\n");
|
||||||
// If user button is held down for 5 seconds, shutdown the device.
|
screen->adjustBrightness();
|
||||||
if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
|
// If user button is held down for 10 seconds, shutdown the device.
|
||||||
#ifdef HAS_PMU
|
if ((millis() - longPressTime > 10000) && (longPressTime > 0)) {
|
||||||
if (pmu_found == true) {
|
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
||||||
setLed(false);
|
|
||||||
power->shutdown();
|
|
||||||
}
|
|
||||||
#elif defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
|
||||||
// Do actual shutdown when button released, otherwise the button release
|
// Do actual shutdown when button released, otherwise the button release
|
||||||
// may wake the board immediatedly.
|
// may wake the board immediatedly.
|
||||||
if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) {
|
if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) {
|
||||||
|
|||||||
@@ -160,8 +160,18 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
|
|
||||||
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
||||||
/// in power
|
/// in power
|
||||||
|
/// On some boards we don't have the power management chip (like AXPxxxx)
|
||||||
|
/// so we use EXT_PWR_DETECT GPIO pin to detect external power source
|
||||||
virtual bool isVbusIn() override
|
virtual bool isVbusIn() override
|
||||||
{
|
{
|
||||||
|
#ifdef EXT_PWR_DETECT
|
||||||
|
// if external powered that pin will be pulled up
|
||||||
|
if (digitalRead(EXT_PWR_DETECT) == HIGH) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// if it's not HIGH - check the battery
|
||||||
|
#endif
|
||||||
|
|
||||||
return getBattVoltage() > chargingVolt;
|
return getBattVoltage() > chargingVolt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +218,10 @@ Power::Power() : OSThread("Power")
|
|||||||
|
|
||||||
bool Power::analogInit()
|
bool Power::analogInit()
|
||||||
{
|
{
|
||||||
|
#ifdef EXT_PWR_DETECT
|
||||||
|
pinMode(EXT_PWR_DETECT, INPUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BATTERY_PIN
|
#ifdef BATTERY_PIN
|
||||||
LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN);
|
LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN);
|
||||||
|
|
||||||
@@ -263,12 +277,11 @@ void Power::shutdown()
|
|||||||
LOG_INFO("Shutting down\n");
|
LOG_INFO("Shutting down\n");
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
if (PMU) {
|
if (pmu_found == true) {
|
||||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||||
|
PMU->shutdown();
|
||||||
}
|
}
|
||||||
#endif
|
#elif defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
||||||
|
|
||||||
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
|
||||||
#ifdef PIN_LED1
|
#ifdef PIN_LED1
|
||||||
ledOff(PIN_LED1);
|
ledOff(PIN_LED1);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ static bool isPowered()
|
|||||||
1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise)
|
1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise)
|
||||||
|
|
||||||
2) If we detect USB power from the power management chip, we must be getting power externally.
|
2) If we detect USB power from the power management chip, we must be getting power externally.
|
||||||
|
|
||||||
|
3) On some boards we don't have the power management chip (like AXPxxxx) so we use EXT_PWR_DETECT GPIO pin to detect
|
||||||
|
external power source (see `isVbusIn()` in `Power.cpp`)
|
||||||
*/
|
*/
|
||||||
return !isPowerSavingMode && powerStatus && (!powerStatus->getHasBattery() || powerStatus->getHasUSB());
|
return !isPowerSavingMode && powerStatus && (!powerStatus->getHasBattery() || powerStatus->getHasUSB());
|
||||||
}
|
}
|
||||||
@@ -66,11 +69,11 @@ static void lsIdle()
|
|||||||
|
|
||||||
// Do we have more sleeping to do?
|
// Do we have more sleeping to do?
|
||||||
if (secsSlept < config.power.ls_secs) {
|
if (secsSlept < config.power.ls_secs) {
|
||||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
|
||||||
uint32_t sleepTime = 30;
|
|
||||||
|
|
||||||
// If some other service would stall sleep, don't let sleep happen yet
|
// If some other service would stall sleep, don't let sleep happen yet
|
||||||
if (doPreflightSleep()) {
|
if (doPreflightSleep()) {
|
||||||
|
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||||
|
uint32_t sleepTime = 30;
|
||||||
|
|
||||||
setLed(false); // Never leave led on while in light sleep
|
setLed(false); // Never leave led on while in light sleep
|
||||||
esp_sleep_source_t wakeCause2 = doLightSleep(sleepTime * 1000LL);
|
esp_sleep_source_t wakeCause2 = doLightSleep(sleepTime * 1000LL);
|
||||||
|
|
||||||
@@ -100,8 +103,7 @@ static void lsIdle()
|
|||||||
#else
|
#else
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
#endif
|
#endif
|
||||||
if (pressed) // If we woke because of press, instead generate a PRESS event.
|
if (pressed) { // If we woke because of press, instead generate a PRESS event.
|
||||||
{
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
powerFSM.trigger(EVENT_PRESS);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
||||||
@@ -169,7 +171,11 @@ static void powerEnter()
|
|||||||
} else {
|
} else {
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
screen->print("Powered...\n");
|
// within enter() the function getState() returns the state we came from
|
||||||
|
if (strcmp(powerFSM.getState()->name, "BOOT") != 0 && strcmp(powerFSM.getState()->name, "POWER") != 0 &&
|
||||||
|
strcmp(powerFSM.getState()->name, "DARK") != 0) {
|
||||||
|
screen->print("Powered...\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +192,8 @@ static void powerExit()
|
|||||||
{
|
{
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
screen->print("Unpowered...\n");
|
if (!isPowered())
|
||||||
|
screen->print("Unpowered...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onEnter()
|
static void onEnter()
|
||||||
@@ -246,7 +253,7 @@ void PowerFSM_setup()
|
|||||||
// Handle press events - note: we ignore button presses when in API mode
|
// Handle press events - note: we ignore button presses when in API mode
|
||||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateDARK, isPowered() ? &statePOWER : &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, screenPress, "Press");
|
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, screenPress, "Press");
|
||||||
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, screenPress, "Press"); // reenter On to restart our timers
|
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, screenPress, "Press"); // reenter On to restart our timers
|
||||||
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, screenPress,
|
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, screenPress,
|
||||||
@@ -319,6 +326,12 @@ void PowerFSM_setup()
|
|||||||
powerFSM.add_timed_transition(&stateON, &stateDARK,
|
powerFSM.add_timed_transition(&stateON, &stateDARK,
|
||||||
getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL,
|
getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL,
|
||||||
"Screen-on timeout");
|
"Screen-on timeout");
|
||||||
|
powerFSM.add_timed_transition(&statePOWER, &stateDARK,
|
||||||
|
getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL,
|
||||||
|
"Screen-on timeout");
|
||||||
|
powerFSM.add_timed_transition(&stateDARK, &stateDARK,
|
||||||
|
getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL,
|
||||||
|
"Screen-on timeout");
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
State *lowPowerState = &stateLS;
|
State *lowPowerState = &stateLS;
|
||||||
@@ -340,4 +353,4 @@ void PowerFSM_setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#if defined(TTGO_T_ECHO)
|
#if defined(TTGO_T_ECHO)
|
||||||
#define TECHO_DISPLAY_MODEL GxEPD2_154_D67
|
#define TECHO_DISPLAY_MODEL GxEPD2_154_D67
|
||||||
#elif defined(RAK4630) || defined(MAKERPYTHON)
|
#elif defined(RAK4630)
|
||||||
|
|
||||||
// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update
|
// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update
|
||||||
// support
|
// support
|
||||||
@@ -27,6 +27,10 @@
|
|||||||
// 1.54 inch 200x200 - GxEPD2_154_M09
|
// 1.54 inch 200x200 - GxEPD2_154_M09
|
||||||
//#define TECHO_DISPLAY_MODEL GxEPD2_154_M09
|
//#define TECHO_DISPLAY_MODEL GxEPD2_154_M09
|
||||||
|
|
||||||
|
#elif defined(MAKERPYTHON)
|
||||||
|
// 2.9 inch 296x128 - GxEPD2_290_T5D
|
||||||
|
#define TECHO_DISPLAY_MODEL GxEPD2_290_T5D
|
||||||
|
|
||||||
#elif defined(PCA10059)
|
#elif defined(PCA10059)
|
||||||
|
|
||||||
// 4.2 inch 300x400 - GxEPD2_420_M01
|
// 4.2 inch 300x400 - GxEPD2_420_M01
|
||||||
@@ -45,19 +49,22 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY
|
|||||||
{
|
{
|
||||||
#if defined(TTGO_T_ECHO)
|
#if defined(TTGO_T_ECHO)
|
||||||
setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT);
|
setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT);
|
||||||
#elif defined(RAK4630) || defined(MAKERPYTHON)
|
#elif defined(RAK4630)
|
||||||
|
|
||||||
// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122
|
// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122
|
||||||
// setGeometry(GEOMETRY_RAWMODE, 250, 122);
|
setGeometry(GEOMETRY_RAWMODE, 250, 122);
|
||||||
|
|
||||||
// GxEPD2_420_M01
|
// GxEPD2_420_M01
|
||||||
// setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
// setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
||||||
|
|
||||||
// GxEPD2_290_T5D
|
// GxEPD2_290_T5D
|
||||||
setGeometry(GEOMETRY_RAWMODE, 296, 128);
|
// setGeometry(GEOMETRY_RAWMODE, 296, 128);
|
||||||
|
|
||||||
// GxEPD2_154_M09
|
// GxEPD2_154_M09
|
||||||
// setGeometry(GEOMETRY_RAWMODE, 200, 200);
|
// setGeometry(GEOMETRY_RAWMODE, 200, 200);
|
||||||
|
#elif defined(MAKERPYTHON)
|
||||||
|
// GxEPD2_290_T5D
|
||||||
|
setGeometry(GEOMETRY_RAWMODE, 296, 128);
|
||||||
|
|
||||||
#elif defined(PCA10059)
|
#elif defined(PCA10059)
|
||||||
|
|
||||||
@@ -243,4 +250,4 @@ bool EInkDisplay::connect()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1206,7 +1206,7 @@ void Screen::setFrames()
|
|||||||
LOG_DEBUG("Total frame count: %d\n", totalFrameCount);
|
LOG_DEBUG("Total frame count: %d\n", totalFrameCount);
|
||||||
|
|
||||||
// We don't show the node info our our node (if we have it yet - we should)
|
// We don't show the node info our our node (if we have it yet - we should)
|
||||||
size_t numnodes = nodeStatus->getNumTotal();
|
size_t numnodes = nodeDB.getNumNodes();
|
||||||
if (numnodes > 0)
|
if (numnodes > 0)
|
||||||
numnodes--;
|
numnodes--;
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,9 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST:
|
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST:
|
||||||
channelName = "LongFast";
|
channelName = "LongFast";
|
||||||
break;
|
break;
|
||||||
|
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE:
|
||||||
|
channelName = "LongMod";
|
||||||
|
break;
|
||||||
case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
|
case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
|
||||||
channelName = "VLongSlow";
|
channelName = "VLongSlow";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
concurrency::Lock *cryptLock;
|
||||||
|
|
||||||
void CryptoEngine::setKey(const CryptoKey &k)
|
void CryptoEngine::setKey(const CryptoKey &k)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Using AES%d key!\n", k.length * 8);
|
LOG_DEBUG("Using AES%d key!\n", k.length * 8);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "concurrency/LockGuard.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
extern concurrency::Lock *cryptLock;
|
||||||
|
|
||||||
struct CryptoKey {
|
struct CryptoKey {
|
||||||
uint8_t bytes[32];
|
uint8_t bytes[32];
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ void MeshService::reloadOwner(bool shouldSave)
|
|||||||
// update everyone else and save to disk
|
// update everyone else and save to disk
|
||||||
if (nodeInfoModule && shouldSave) {
|
if (nodeInfoModule && shouldSave) {
|
||||||
nodeInfoModule->sendOurNodeInfo();
|
nodeInfoModule->sendOurNodeInfo();
|
||||||
nodeDB.saveToDisk(SEGMENT_DEVICESTATE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -689,11 +689,11 @@ void NodeDB::updateTelemetry(uint32_t nodeId, const meshtastic_Telemetry &t, RxS
|
|||||||
|
|
||||||
/** Update user info for this node based on received user data
|
/** Update user info for this node based on received user data
|
||||||
*/
|
*/
|
||||||
void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
bool NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
||||||
{
|
{
|
||||||
meshtastic_NodeInfo *info = getOrCreateNode(nodeId);
|
meshtastic_NodeInfo *info = getOrCreateNode(nodeId);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
||||||
@@ -710,10 +710,11 @@ void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
|||||||
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
||||||
notifyObservers(true); // Force an update whether or not our node counts have changed
|
notifyObservers(true); // Force an update whether or not our node counts have changed
|
||||||
|
|
||||||
// Not really needed - we will save anyways when we go to sleep
|
|
||||||
// We just changed something important about the user, store our DB
|
// We just changed something important about the user, store our DB
|
||||||
// saveToDisk();
|
saveToDisk(SEGMENT_DEVICESTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// given a subpacket sniffed from the network, update our DB state
|
/// given a subpacket sniffed from the network, update our DB state
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class NodeDB
|
|||||||
|
|
||||||
/** Update user info for this node based on received user data
|
/** Update user info for this node based on received user data
|
||||||
*/
|
*/
|
||||||
void updateUser(uint32_t nodeId, const meshtastic_User &p);
|
bool updateUser(uint32_t nodeId, const meshtastic_User &p);
|
||||||
|
|
||||||
/// @return our node number
|
/// @return our node number
|
||||||
NodeNum getNodeNum() { return myNodeInfo.my_node_num; }
|
NodeNum getNodeNum() { return myNodeInfo.my_node_num; }
|
||||||
|
|||||||
@@ -281,8 +281,8 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
|||||||
if (p->priority != 0)
|
if (p->priority != 0)
|
||||||
out += DEBUG_PORT.mt_sprintf(" priority=%d", p->priority);
|
out += DEBUG_PORT.mt_sprintf(" priority=%d", p->priority);
|
||||||
|
|
||||||
out += ")\n";
|
out += ")";
|
||||||
LOG_DEBUG("%s", out.c_str());
|
LOG_DEBUG("%s\n", out.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioInterface::RadioInterface()
|
RadioInterface::RadioInterface()
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ Router::Router() : concurrency::OSThread("Router"), fromRadioQueue(MAX_RX_FROMRA
|
|||||||
LOG_DEBUG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */
|
LOG_DEBUG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */
|
||||||
|
|
||||||
fromRadioQueue.setReader(this);
|
fromRadioQueue.setReader(this);
|
||||||
|
|
||||||
|
// init Lockguard for crypt operations
|
||||||
|
assert(!cryptLock);
|
||||||
|
cryptLock = new concurrency::Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,6 +309,8 @@ void Router::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Rout
|
|||||||
|
|
||||||
bool perhapsDecode(meshtastic_MeshPacket *p)
|
bool perhapsDecode(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
|
concurrency::LockGuard g(cryptLock);
|
||||||
|
|
||||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||||
config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING)
|
config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING)
|
||||||
return false;
|
return false;
|
||||||
@@ -371,6 +377,8 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
|
|||||||
*/
|
*/
|
||||||
meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
|
concurrency::LockGuard g(cryptLock);
|
||||||
|
|
||||||
// If the packet is not yet encrypted, do so now
|
// If the packet is not yet encrypted, do so now
|
||||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||||
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
|
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
|
||||||
|
|||||||
@@ -31,11 +31,9 @@ typedef enum _meshtastic_Channel_Role {
|
|||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t;
|
typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t;
|
||||||
/* Full settings (center freq, spread factor, pre-shared secret key etc...)
|
/* This information can be encoded as a QRcode/url so that other users can configure
|
||||||
needed to configure a radio for speaking on a particular channel This
|
|
||||||
information can be encoded as a QRcode/url so that other users can configure
|
|
||||||
their radio to join the same channel.
|
their radio to join the same channel.
|
||||||
A note about how channel names are shown to users: channelname-Xy
|
A note about how channel names are shown to users: channelname-X
|
||||||
poundsymbol is a prefix used to indicate this is a channel name (idea from @professr).
|
poundsymbol is a prefix used to indicate this is a channel name (idea from @professr).
|
||||||
Where X is a letter from A-Z (base 26) representing a hash of the PSK for this
|
Where X is a letter from A-Z (base 26) representing a hash of the PSK for this
|
||||||
channel - so that if the user changes anything about the channel (which does
|
channel - so that if the user changes anything about the channel (which does
|
||||||
@@ -45,8 +43,6 @@ typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t;
|
|||||||
The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26"
|
The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26"
|
||||||
This also allows the option of someday if people have the PSK off (zero), the
|
This also allows the option of someday if people have the PSK off (zero), the
|
||||||
users COULD type in a channel name and be able to talk.
|
users COULD type in a channel name and be able to talk.
|
||||||
Y is a lower case letter from a-z that represents the channel 'speed' settings
|
|
||||||
(for some future definition of speed)
|
|
||||||
FIXME: Add description of multi-channel support and how primary vs secondary channels are used.
|
FIXME: Add description of multi-channel support and how primary vs secondary channels are used.
|
||||||
FIXME: explain how apps use channels for security.
|
FIXME: explain how apps use channels for security.
|
||||||
explain how remote settings and remote gpio are managed as an example */
|
explain how remote settings and remote gpio are managed as an example */
|
||||||
@@ -60,7 +56,7 @@ typedef struct _meshtastic_ChannelSettings {
|
|||||||
because they are listed in this source code.
|
because they are listed in this source code.
|
||||||
Those bytes are mapped using the following scheme:
|
Those bytes are mapped using the following scheme:
|
||||||
`0` = No crypto
|
`0` = No crypto
|
||||||
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}
|
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01}
|
||||||
`2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
`2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
||||||
Shown to user as simple1 through 10 */
|
Shown to user as simple1 through 10 */
|
||||||
meshtastic_ChannelSettings_psk_t psk;
|
meshtastic_ChannelSettings_psk_t psk;
|
||||||
|
|||||||
12
src/mesh/generated/meshtastic/clientonly.pb.c
Normal file
12
src/mesh/generated/meshtastic/clientonly.pb.c
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/* Automatically generated nanopb constant definitions */
|
||||||
|
/* Generated by nanopb-0.4.7 */
|
||||||
|
|
||||||
|
#include "meshtastic/clientonly.pb.h"
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PB_BIND(meshtastic_DeviceProfile, meshtastic_DeviceProfile, 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
73
src/mesh/generated/meshtastic/clientonly.pb.h
Normal file
73
src/mesh/generated/meshtastic/clientonly.pb.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/* Automatically generated nanopb header */
|
||||||
|
/* Generated by nanopb-0.4.7 */
|
||||||
|
|
||||||
|
#ifndef PB_MESHTASTIC_MESHTASTIC_CLIENTONLY_PB_H_INCLUDED
|
||||||
|
#define PB_MESHTASTIC_MESHTASTIC_CLIENTONLY_PB_H_INCLUDED
|
||||||
|
#include <pb.h>
|
||||||
|
#include "meshtastic/localonly.pb.h"
|
||||||
|
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Struct definitions */
|
||||||
|
/* This abstraction is used to contain any configuration for provisioning a node on any client.
|
||||||
|
It is useful for importing and exporting configurations. */
|
||||||
|
typedef struct _meshtastic_DeviceProfile {
|
||||||
|
/* Long name for the node */
|
||||||
|
bool has_long_name;
|
||||||
|
char long_name[40];
|
||||||
|
/* Short name of the node */
|
||||||
|
bool has_short_name;
|
||||||
|
char short_name[5];
|
||||||
|
/* The url of the channels from our node */
|
||||||
|
pb_callback_t channel_url;
|
||||||
|
/* The Config of the node */
|
||||||
|
bool has_config;
|
||||||
|
meshtastic_LocalConfig config;
|
||||||
|
/* The ModuleConfig of the node */
|
||||||
|
bool has_module_config;
|
||||||
|
meshtastic_LocalModuleConfig module_config;
|
||||||
|
} meshtastic_DeviceProfile;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initializer values for message structs */
|
||||||
|
#define meshtastic_DeviceProfile_init_default {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default}
|
||||||
|
#define meshtastic_DeviceProfile_init_zero {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero}
|
||||||
|
|
||||||
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
|
#define meshtastic_DeviceProfile_long_name_tag 1
|
||||||
|
#define meshtastic_DeviceProfile_short_name_tag 2
|
||||||
|
#define meshtastic_DeviceProfile_channel_url_tag 3
|
||||||
|
#define meshtastic_DeviceProfile_config_tag 4
|
||||||
|
#define meshtastic_DeviceProfile_module_config_tag 5
|
||||||
|
|
||||||
|
/* Struct field encoding specification for nanopb */
|
||||||
|
#define meshtastic_DeviceProfile_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, OPTIONAL, STRING, long_name, 1) \
|
||||||
|
X(a, STATIC, OPTIONAL, STRING, short_name, 2) \
|
||||||
|
X(a, CALLBACK, OPTIONAL, STRING, channel_url, 3) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, config, 4) \
|
||||||
|
X(a, STATIC, OPTIONAL, MESSAGE, module_config, 5)
|
||||||
|
#define meshtastic_DeviceProfile_CALLBACK pb_default_field_callback
|
||||||
|
#define meshtastic_DeviceProfile_DEFAULT NULL
|
||||||
|
#define meshtastic_DeviceProfile_config_MSGTYPE meshtastic_LocalConfig
|
||||||
|
#define meshtastic_DeviceProfile_module_config_MSGTYPE meshtastic_LocalModuleConfig
|
||||||
|
|
||||||
|
extern const pb_msgdesc_t meshtastic_DeviceProfile_msg;
|
||||||
|
|
||||||
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
|
#define meshtastic_DeviceProfile_fields &meshtastic_DeviceProfile_msg
|
||||||
|
|
||||||
|
/* Maximum encoded size of messages (where known) */
|
||||||
|
/* meshtastic_DeviceProfile_size depends on runtime parameters */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -188,7 +188,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg;
|
|||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define meshtastic_ChannelFile_size 638
|
#define meshtastic_ChannelFile_size 638
|
||||||
#define meshtastic_DeviceState_size 22040
|
#define meshtastic_DeviceState_size 22040
|
||||||
#define meshtastic_OEMStore_size 3022
|
#define meshtastic_OEMStore_size 3041
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg;
|
|||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define meshtastic_LocalConfig_size 456
|
#define meshtastic_LocalConfig_size 456
|
||||||
#define meshtastic_LocalModuleConfig_size 420
|
#define meshtastic_LocalModuleConfig_size 439
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ typedef struct _meshtastic_ModuleConfig_MQTTConfig {
|
|||||||
bool encryption_enabled;
|
bool encryption_enabled;
|
||||||
/* Whether to send / consume json packets on MQTT */
|
/* Whether to send / consume json packets on MQTT */
|
||||||
bool json_enabled;
|
bool json_enabled;
|
||||||
|
/* If true, we attempt to establish a secure connection using TLS */
|
||||||
|
bool tls_enabled;
|
||||||
|
/* The root topic to use for MQTT messages. Default is "msh".
|
||||||
|
This is useful if you want to use a single MQTT server for multiple meshtastic networks and separate them via ACLs */
|
||||||
|
char root[16];
|
||||||
} meshtastic_ModuleConfig_MQTTConfig;
|
} meshtastic_ModuleConfig_MQTTConfig;
|
||||||
|
|
||||||
/* RemoteHardwareModule Config */
|
/* RemoteHardwareModule Config */
|
||||||
@@ -323,7 +328,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}}
|
#define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}}
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0}
|
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0, ""}
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0}
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0}
|
||||||
#define meshtastic_ModuleConfig_AudioConfig_init_default {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
#define meshtastic_ModuleConfig_AudioConfig_init_default {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
||||||
#define meshtastic_ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
#define meshtastic_ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
||||||
@@ -333,7 +338,7 @@ extern "C" {
|
|||||||
#define meshtastic_ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0}
|
#define meshtastic_ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0}
|
||||||
#define meshtastic_ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
#define meshtastic_ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
||||||
#define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}}
|
#define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}}
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0}
|
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0, ""}
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0}
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0}
|
||||||
#define meshtastic_ModuleConfig_AudioConfig_init_zero {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
#define meshtastic_ModuleConfig_AudioConfig_init_zero {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
||||||
#define meshtastic_ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
#define meshtastic_ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
||||||
@@ -350,6 +355,8 @@ extern "C" {
|
|||||||
#define meshtastic_ModuleConfig_MQTTConfig_password_tag 4
|
#define meshtastic_ModuleConfig_MQTTConfig_password_tag 4
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_encryption_enabled_tag 5
|
#define meshtastic_ModuleConfig_MQTTConfig_encryption_enabled_tag 5
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_json_enabled_tag 6
|
#define meshtastic_ModuleConfig_MQTTConfig_json_enabled_tag 6
|
||||||
|
#define meshtastic_ModuleConfig_MQTTConfig_tls_enabled_tag 7
|
||||||
|
#define meshtastic_ModuleConfig_MQTTConfig_root_tag 8
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_enabled_tag 1
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_enabled_tag 1
|
||||||
#define meshtastic_ModuleConfig_AudioConfig_codec2_enabled_tag 1
|
#define meshtastic_ModuleConfig_AudioConfig_codec2_enabled_tag 1
|
||||||
#define meshtastic_ModuleConfig_AudioConfig_ptt_pin_tag 2
|
#define meshtastic_ModuleConfig_AudioConfig_ptt_pin_tag 2
|
||||||
@@ -444,7 +451,9 @@ X(a, STATIC, SINGULAR, STRING, address, 2) \
|
|||||||
X(a, STATIC, SINGULAR, STRING, username, 3) \
|
X(a, STATIC, SINGULAR, STRING, username, 3) \
|
||||||
X(a, STATIC, SINGULAR, STRING, password, 4) \
|
X(a, STATIC, SINGULAR, STRING, password, 4) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, encryption_enabled, 5) \
|
X(a, STATIC, SINGULAR, BOOL, encryption_enabled, 5) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, json_enabled, 6)
|
X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, tls_enabled, 7) \
|
||||||
|
X(a, STATIC, SINGULAR, STRING, root, 8)
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_CALLBACK NULL
|
#define meshtastic_ModuleConfig_MQTTConfig_CALLBACK NULL
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL
|
#define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL
|
||||||
|
|
||||||
@@ -562,13 +571,13 @@ extern const pb_msgdesc_t meshtastic_ModuleConfig_CannedMessageConfig_msg;
|
|||||||
#define meshtastic_ModuleConfig_AudioConfig_size 19
|
#define meshtastic_ModuleConfig_AudioConfig_size 19
|
||||||
#define meshtastic_ModuleConfig_CannedMessageConfig_size 49
|
#define meshtastic_ModuleConfig_CannedMessageConfig_size 49
|
||||||
#define meshtastic_ModuleConfig_ExternalNotificationConfig_size 40
|
#define meshtastic_ModuleConfig_ExternalNotificationConfig_size 40
|
||||||
#define meshtastic_ModuleConfig_MQTTConfig_size 201
|
#define meshtastic_ModuleConfig_MQTTConfig_size 220
|
||||||
#define meshtastic_ModuleConfig_RangeTestConfig_size 10
|
#define meshtastic_ModuleConfig_RangeTestConfig_size 10
|
||||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_size 2
|
#define meshtastic_ModuleConfig_RemoteHardwareConfig_size 2
|
||||||
#define meshtastic_ModuleConfig_SerialConfig_size 26
|
#define meshtastic_ModuleConfig_SerialConfig_size 26
|
||||||
#define meshtastic_ModuleConfig_StoreForwardConfig_size 22
|
#define meshtastic_ModuleConfig_StoreForwardConfig_size 22
|
||||||
#define meshtastic_ModuleConfig_TelemetryConfig_size 26
|
#define meshtastic_ModuleConfig_TelemetryConfig_size 26
|
||||||
#define meshtastic_ModuleConfig_size 204
|
#define meshtastic_ModuleConfig_size 223
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
|||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
|
|
||||||
nodeDB.updateUser(getFrom(&mp), p);
|
bool hasChanged = nodeDB.updateUser(getFrom(&mp), p);
|
||||||
|
|
||||||
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
||||||
|
|
||||||
@@ -23,6 +23,10 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
|||||||
screen->print(lcd.c_str());
|
screen->print(lcd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if user has changed while packet was not for us, inform phone
|
||||||
|
if (hasChanged && !wasBroadcast && mp.to != nodeDB.getNodeNum())
|
||||||
|
service.sendToPhone(packetPool.allocCopy(mp));
|
||||||
|
|
||||||
// LOG_DEBUG("did handleReceived\n");
|
// LOG_DEBUG("did handleReceived\n");
|
||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ const int reconnectMax = 5;
|
|||||||
|
|
||||||
MQTT *mqtt;
|
MQTT *mqtt;
|
||||||
|
|
||||||
std::string statusTopic = "msh/2/stat/";
|
std::string statusTopic = "/2/stat/";
|
||||||
std::string cryptTopic = "msh/2/c/"; // msh/2/c/CHANNELID/NODEID
|
std::string cryptTopic = "/2/c/"; // msh/2/c/CHANNELID/NODEID
|
||||||
std::string jsonTopic = "msh/2/json/"; // msh/2/json/CHANNELID/NODEID
|
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
|
||||||
|
|
||||||
static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool;
|
static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool;
|
||||||
|
|
||||||
@@ -164,6 +164,16 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient), mqttQueue(MAX_
|
|||||||
assert(!mqtt);
|
assert(!mqtt);
|
||||||
mqtt = this;
|
mqtt = this;
|
||||||
|
|
||||||
|
if (moduleConfig.mqtt.root) {
|
||||||
|
statusTopic = moduleConfig.mqtt.root + statusTopic;
|
||||||
|
cryptTopic = moduleConfig.mqtt.root + cryptTopic;
|
||||||
|
jsonTopic = moduleConfig.mqtt.root + jsonTopic;
|
||||||
|
} else {
|
||||||
|
statusTopic = "msh" + statusTopic;
|
||||||
|
cryptTopic = "msh" + cryptTopic;
|
||||||
|
jsonTopic = "msh" + jsonTopic;
|
||||||
|
}
|
||||||
|
|
||||||
pubSub.setCallback(mqttCallback);
|
pubSub.setCallback(mqttCallback);
|
||||||
|
|
||||||
// preflightSleepObserver.observe(&preflightSleep);
|
// preflightSleepObserver.observe(&preflightSleep);
|
||||||
@@ -192,6 +202,26 @@ void MQTT::reconnect()
|
|||||||
mqttPassword = moduleConfig.mqtt.password;
|
mqttPassword = moduleConfig.mqtt.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||||
|
if (moduleConfig.mqtt.tls_enabled) {
|
||||||
|
// change default for encrypted to 8883
|
||||||
|
try {
|
||||||
|
serverPort = 8883;
|
||||||
|
wifiSecureClient.setInsecure();
|
||||||
|
|
||||||
|
pubSub.setClient(wifiSecureClient);
|
||||||
|
LOG_INFO("Using TLS-encrypted session\n");
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
LOG_ERROR("MQTT ERROR: %s\n", e.what());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Using non-TLS-encrypted session\n");
|
||||||
|
pubSub.setClient(mqttClient);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pubSub.setClient(mqttClient);
|
||||||
|
#endif
|
||||||
|
|
||||||
String server = String(serverAddr);
|
String server = String(serverAddr);
|
||||||
int delimIndex = server.indexOf(':');
|
int delimIndex = server.indexOf(':');
|
||||||
if (delimIndex > 0) {
|
if (delimIndex > 0) {
|
||||||
@@ -528,4 +558,4 @@ std::string MQTT::downstreamPacketToJson(meshtastic_MeshPacket *mp)
|
|||||||
|
|
||||||
delete value;
|
delete value;
|
||||||
return jsonStr;
|
return jsonStr;
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,9 @@
|
|||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
|
#if !defined(ARCH_PORTDUINO)
|
||||||
|
#include <WiFiClientSecure.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if HAS_ETHERNET
|
#if HAS_ETHERNET
|
||||||
#include <EthernetClient.h>
|
#include <EthernetClient.h>
|
||||||
@@ -23,9 +26,11 @@ class MQTT : private concurrency::OSThread
|
|||||||
{
|
{
|
||||||
// supposedly the current version is busted:
|
// supposedly the current version is busted:
|
||||||
// http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html
|
// http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html
|
||||||
// WiFiClientSecure wifiClient;
|
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
WiFiClient mqttClient;
|
WiFiClient mqttClient;
|
||||||
|
#if !defined(ARCH_PORTDUINO)
|
||||||
|
WiFiClientSecure wifiSecureClient;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if HAS_ETHERNET
|
#if HAS_ETHERNET
|
||||||
EthernetClient mqttClient;
|
EthernetClient mqttClient;
|
||||||
@@ -87,4 +92,4 @@ class MQTT : private concurrency::OSThread
|
|||||||
|
|
||||||
void mqttInit();
|
void mqttInit();
|
||||||
|
|
||||||
extern MQTT *mqtt;
|
extern MQTT *mqtt;
|
||||||
@@ -162,7 +162,7 @@ void esp32Loop()
|
|||||||
// radio.radioIf.canSleep();
|
// radio.radioIf.canSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuDeepSleep(uint64_t msecToWake)
|
void cpuDeepSleep(uint32_t msecToWake)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default.
|
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default.
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ void nrf52Setup()
|
|||||||
nRFCrypto.end();
|
nRFCrypto.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuDeepSleep(uint64_t msecToWake)
|
void cpuDeepSleep(uint32_t msecToWake)
|
||||||
{
|
{
|
||||||
// FIXME, configure RTC or button press to wake us
|
// FIXME, configure RTC or button press to wake us
|
||||||
// FIXME, power down SPI, I2C, RAMs
|
// FIXME, power down SPI, I2C, RAMs
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void setBluetoothEnable(bool on)
|
|||||||
// not needed
|
// not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuDeepSleep(uint64_t msecs)
|
void cpuDeepSleep(uint32_t msecs)
|
||||||
{
|
{
|
||||||
notImplemented("cpuDeepSleep");
|
notImplemented("cpuDeepSleep");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ void setBluetoothEnable(bool on)
|
|||||||
// not needed
|
// not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuDeepSleep(uint64_t msecs)
|
void cpuDeepSleep(uint32_t msecs)
|
||||||
{
|
{
|
||||||
// not needed
|
// not needed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void getMacAddr(uint8_t *dmac)
|
|||||||
dmac[i] = i;
|
dmac[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuDeepSleep(uint64_t msecToWake) {}
|
void cpuDeepSleep(uint32_t msecToWake) {}
|
||||||
|
|
||||||
/* pacify libc_nano */
|
/* pacify libc_nano */
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
esp_sleep_source_t wakeCause; // the reason we booted this time
|
esp_sleep_source_t wakeCause; // the reason we booted this time
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef INCLUDE_vTaskSuspend
|
||||||
|
#define INCLUDE_vTaskSuspend 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
#include "XPowersLibInterface.hpp"
|
#include "XPowersLibInterface.hpp"
|
||||||
extern XPowersLibInterface *PMU;
|
extern XPowersLibInterface *PMU;
|
||||||
@@ -201,9 +205,13 @@ void doGPSpowersave(bool on)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void doDeepSleep(uint64_t msecToWake)
|
void doDeepSleep(uint32_t msecToWake)
|
||||||
{
|
{
|
||||||
LOG_INFO("Entering deep sleep for %lu seconds\n", msecToWake / 1000);
|
if (INCLUDE_vTaskSuspend && (msecToWake == portMAX_DELAY)) {
|
||||||
|
LOG_INFO("Entering deep sleep forever\n");
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Entering deep sleep for %u seconds\n", msecToWake / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
// not using wifi yet, but once we are this is needed to shutoff the radio hw
|
// not using wifi yet, but once we are this is needed to shutoff the radio hw
|
||||||
// esp_wifi_stop();
|
// esp_wifi_stop();
|
||||||
@@ -301,7 +309,10 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
|||||||
// assert(esp_sleep_enable_uart_wakeup(0) == ESP_OK);
|
// assert(esp_sleep_enable_uart_wakeup(0) == ESP_OK);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low
|
esp_sleep_enable_ext0_wakeup((gpio_num_t)BUTTON_PIN, LOW); // when user presses, this button goes low
|
||||||
|
#endif
|
||||||
|
#if defined(LORA_DIO1) && (LORA_DIO1 != RADIOLIB_NC)
|
||||||
|
gpio_wakeup_enable((gpio_num_t)LORA_DIO1, GPIO_INTR_HIGH_LEVEL); // SX126x/SX128x interrupt, active high
|
||||||
#endif
|
#endif
|
||||||
#ifdef RF95_IRQ
|
#ifdef RF95_IRQ
|
||||||
gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
|
gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
void doDeepSleep(uint64_t msecToWake), cpuDeepSleep(uint64_t msecToWake);
|
void doDeepSleep(uint32_t msecToWake), cpuDeepSleep(uint32_t msecToWake);
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
||||||
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||||
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
|
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
|
||||||
|
#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards
|
||||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||||
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 2
|
major = 2
|
||||||
minor = 1
|
minor = 1
|
||||||
build = 6
|
build = 8
|
||||||
|
|||||||
Reference in New Issue
Block a user