Merge branch 'master' into timestamp-in-recv-msgs

This commit is contained in:
Thomas Göttgens 2023-01-29 19:25:41 +01:00 committed by GitHub
commit cf5485112b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 198 additions and 173 deletions

View File

@ -28,7 +28,7 @@ body:
description: What LoRa IC does the board have? description: What LoRa IC does the board have?
validations: validations:
required: true required: true
- type: input - type: input
id: link id: link
attributes: attributes:

View File

@ -1,5 +1,5 @@
name: 'Setup Build Base Composite Action' name: "Setup Build Base Composite Action"
description: 'Base build actions for Meshtastic Platform IO steps' description: "Base build actions for Meshtastic Platform IO steps"
runs: runs:
using: "composite" using: "composite"
@ -10,7 +10,7 @@ runs:
submodules: "recursive" submodules: "recursive"
ref: ${{github.event.pull_request.head.ref}} ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}} repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Install cppcheck - name: Install cppcheck
shell: bash shell: bash
run: | run: |
@ -38,4 +38,4 @@ runs:
- name: Upgrade platformio - name: Upgrade platformio
shell: bash shell: bash
run: | run: |
pio upgrade pio upgrade

View File

@ -7,7 +7,7 @@ on:
required: true required: true
type: string type: string
jobs: jobs:
build-esp32: build-esp32:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -31,7 +31,7 @@ jobs:
- name: Remove debug flags for release - name: Remove debug flags for release
if: ${{ github.event_name == 'workflow_dispatch' }} if: ${{ github.event_name == 'workflow_dispatch' }}
run: | run: |
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32.ini
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s2.ini
sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini sed -i '/DDEBUG_HEAP/d' ./arch/esp32/esp32s3.ini
@ -46,7 +46,7 @@ jobs:
file: "firmware.bin" file: "firmware.bin"
target: "release/bleota.bin" target: "release/bleota.bin"
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Get release version string - name: Get release version string
shell: bash shell: bash
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT

View File

@ -7,7 +7,7 @@ on:
required: true required: true
type: string type: string
jobs: jobs:
build-nrf52: build-nrf52:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -30,4 +30,4 @@ jobs:
path: | path: |
release/*.uf2 release/*.uf2
release/*.elf release/*.elf
release/*.zip release/*.zip

View File

@ -7,7 +7,7 @@ on:
required: true required: true
type: string type: string
jobs: jobs:
build-rpi2040: build-rpi2040:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -29,4 +29,4 @@ jobs:
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
path: | path: |
release/*.uf2 release/*.uf2
release/*.elf release/*.elf

View File

@ -10,31 +10,31 @@ on:
jobs: jobs:
flawfinder: flawfinder:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Flawfinder name: Flawfinder
steps: steps:
# step 1 # step 1
- name: clone application source code - name: clone application source code
uses: actions/checkout@v3 uses: actions/checkout@v3
# step 2 # step 2
- name: flawfinder_scan - name: flawfinder_scan
uses: david-a-wheeler/flawfinder@2.0.19 uses: david-a-wheeler/flawfinder@2.0.19
with: with:
arguments: '--sarif ./' arguments: "--sarif ./"
output: 'flawfinder_report.sarif' output: "flawfinder_report.sarif"
# step 3 # step 3
- name: save report as pipeline artifact - name: save report as pipeline artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: flawfinder_report.sarif name: flawfinder_report.sarif
path: flawfinder_report.sarif path: flawfinder_report.sarif
# step 4 # step 4
- name: publish code scanning alerts - name: publish code scanning alerts
uses: github/codeql-action/upload-sarif@v2 uses: github/codeql-action/upload-sarif@v2
with: with:
sarif_file: flawfinder_report.sarif sarif_file: flawfinder_report.sarif
category: flawfinder category: flawfinder

View File

@ -6,39 +6,37 @@ on:
branches: branches:
- master - master
schedule: schedule:
- cron: '0 1 * * 6' - cron: "0 1 * * 6"
jobs: jobs:
semgrep-full: semgrep-full:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: returntocorp/semgrep image: returntocorp/semgrep
steps: steps:
# step 1
- name: clone application source code
uses: actions/checkout@v3
# step 1 # step 2
- name: clone application source code - name: full scan
uses: actions/checkout@v3 run: |
semgrep \
--sarif --output report.sarif \
--metrics=off \
--config="p/default"
# step 2 # step 3
- name: full scan - name: save report as pipeline artifact
run: | uses: actions/upload-artifact@v3
semgrep \ with:
--sarif --output report.sarif \ name: report.sarif
--metrics=off \ path: report.sarif
--config="p/default"
# step 3 # step 4
- name: save report as pipeline artifact - name: publish code scanning alerts
uses: actions/upload-artifact@v3 uses: github/codeql-action/upload-sarif@v2
with: with:
name: report.sarif sarif_file: report.sarif
path: report.sarif category: semgrep
# step 4
- name: publish code scanning alerts
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: report.sarif
category: semgrep

View File

@ -1,17 +1,14 @@
--- ---
name: Semgrep Differential Scan name: Semgrep Differential Scan
on: on: pull_request
pull_request
jobs: jobs:
semgrep-diff: semgrep-diff:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: returntocorp/semgrep image: returntocorp/semgrep
steps: steps:
# step 1 # step 1
- name: clone application source code - name: clone application source code
uses: actions/checkout@v3 uses: actions/checkout@v3

30
.vscode/tasks.json vendored
View File

@ -1,17 +1,15 @@
{ {
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"type": "PlatformIO", "type": "PlatformIO",
"task": "Build", "task": "Build",
"problemMatcher": [ "problemMatcher": ["$platformio"],
"$platformio" "group": {
], "kind": "build",
"group": { "isDefault": true
"kind": "build", },
"isDefault": true "label": "PlatformIO: Build"
}, }
"label": "PlatformIO: Build" ]
} }
]
}

View File

@ -22,9 +22,9 @@ def readProps(prefsLoc):
isDirty = subprocess.check_output( isDirty = subprocess.check_output(
['git', 'diff', 'HEAD']).decode("utf-8").strip() ['git', 'diff', 'HEAD']).decode("utf-8").strip()
suffix = sha suffix = sha
if isDirty: # if isDirty:
# short for 'dirty', we want to keep our verstrings source for protobuf reasons # # short for 'dirty', we want to keep our verstrings source for protobuf reasons
suffix = sha + "-d" # suffix = sha + "-d"
verObj['long'] = "{}.{}.{}.{}".format( verObj['long'] = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix) version["major"], version["minor"], version["build"], suffix)
except: except:

@ -1 +1 @@
Subproject commit 8cb6ed3c91e23062cf0a4b8e50e4f98ef36170d3 Subproject commit 22ffb71c35ee7f097b9fb54d282f9c1d3f3d953f

View File

@ -1,9 +1,5 @@
#include "OSThread.h" #include "OSThread.h"
#include "configuration.h" #include "configuration.h"
#ifdef HAS_SCREEN
#include "graphics/Screen.h"
#endif
#include "main.h"
#include <assert.h> #include <assert.h>
namespace concurrency namespace concurrency
@ -83,21 +79,12 @@ void OSThread::run()
#endif #endif
currentThread = this; currentThread = this;
auto newDelay = runOnce(); auto newDelay = runOnce();
#ifdef ARCH_ESP32
auto newHeap = ESP.getFreeHeap();
if (newHeap < 10000) {
LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n");
#ifdef HAS_SCREEN
screen->startRebootScreen();
#endif
rebootAtMsec = millis() + 5000;
}
#ifdef DEBUG_HEAP #ifdef DEBUG_HEAP
auto newHeap = ESP.getFreeHeap();
if (newHeap < heap) if (newHeap < heap)
LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
if (heap < newHeap) if (heap < newHeap)
LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
#endif
#endif #endif
runned(); runned();

View File

@ -190,7 +190,6 @@ bool GPS::setupGPS()
// Switch to Vehicle Mode, since SoftRF enables Aviation < 2g // Switch to Vehicle Mode, since SoftRF enables Aviation < 2g
_serial_gps->write("$PCAS11,3*1E\r\n"); _serial_gps->write("$PCAS11,3*1E\r\n");
delay(250); delay(250);
} else if (gnssModel == GNSS_MODEL_UBLOX) { } else if (gnssModel == GNSS_MODEL_UBLOX) {
/* /*
@ -429,6 +428,10 @@ void GPS::publishUpdate()
int32_t GPS::runOnce() int32_t GPS::runOnce()
{ {
// Repeaters have no need for GPS
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
disable();
if (whileIdle()) { if (whileIdle()) {
// if we have received valid NMEA claim we are connected // if we have received valid NMEA claim we are connected
setConnected(); setConnected();

View File

@ -618,7 +618,6 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
} else { } else {
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(coordinateLine))) / 2, y, coordinateLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(coordinateLine))) / 2, y, coordinateLine);
} }
} else { } else {
char latLine[22]; char latLine[22];
char lonLine[22]; char lonLine[22];
@ -1703,6 +1702,9 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST: case meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST:
mode = "LongF"; mode = "LongF";
break; break;
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE:
mode = "LongM";
break;
case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW: case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
mode = "VeryL"; mode = "VeryL";
break; break;

View File

@ -128,6 +128,17 @@ static int32_t ledBlinker()
setLed(ledOn); setLed(ledOn);
#ifdef ARCH_ESP32
auto newHeap = ESP.getFreeHeap();
if (newHeap < 11000) {
LOG_DEBUG("\n\n====== heap too low [11000] -> reboot in 1s ======\n\n");
#ifdef HAS_SCREEN
screen->startRebootScreen();
#endif
rebootAtMsec = millis() + 900;
}
#endif
// have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that // have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000); return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
} }
@ -299,6 +310,10 @@ void setup()
// but we need to do this after main cpu iniot (esp32setup), because we need the random seed set // but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
nodeDB.init(); nodeDB.init();
// If we're taking on the repeater role, use flood router
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
router = new FloodingRouter();
playStartMelody(); playStartMelody();
// fixed screen override? // fixed screen override?

View File

@ -48,15 +48,13 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
traceRouteModule->updateRoute(tosend); traceRouteModule->updateRoute(tosend);
} }
LOG_INFO("Rebroadcasting received floodmsg to neighbors", p); LOG_INFO("Rebroadcasting received floodmsg to neighbors\n");
// Note: we are careful to resend using the original senders node id // Note: we are careful to resend using the original senders node id
// We are careful not to call our hooked version of send() - because we don't want to check this again // We are careful not to call our hooked version of send() - because we don't want to check this again
Router::send(tosend); Router::send(tosend);
} else { } else {
LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n"); LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
} }
} else { } else {
LOG_DEBUG("Ignoring a simple (0 id) broadcast\n"); LOG_DEBUG("Ignoring a simple (0 id) broadcast\n");
} }

View File

@ -225,6 +225,25 @@ void NodeDB::installDefaultModuleConfig()
initModuleConfigIntervals(); initModuleConfigIntervals();
} }
void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
{
if (role == meshtastic_Config_DeviceConfig_Role_ROUTER) {
initConfigIntervals();
initModuleConfigIntervals();
} else if (role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
config.display.screen_on_secs = 1;
meshtastic_Channel &ch = channels.getByIndex(channels.getPrimaryIndex());
meshtastic_ChannelSettings &channelSettings = ch.settings;
uint8_t defaultpskIndex = 1;
channelSettings.psk.bytes[0] = defaultpskIndex;
channelSettings.psk.size = 1;
} else if (role == meshtastic_Config_DeviceConfig_Role_TRACKER) {
config.position.position_broadcast_smart_enabled = false;
config.position.position_broadcast_secs = 120;
config.position.gps_update_interval = 60;
}
}
void NodeDB::initModuleConfigIntervals() void NodeDB::initModuleConfigIntervals()
{ {
moduleConfig.telemetry.device_update_interval = default_broadcast_interval_secs; moduleConfig.telemetry.device_update_interval = default_broadcast_interval_secs;
@ -609,13 +628,11 @@ void NodeDB::updatePosition(uint32_t nodeId, const meshtastic_Position &p, RxSou
LOG_INFO("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i, LOG_INFO("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i,
p.longitude_i, p.altitude); p.longitude_i, p.altitude);
info->position = p; info->position = p;
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) { } else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) {
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO // FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
// (stop-gap fix for issue #900) // (stop-gap fix for issue #900)
LOG_DEBUG("updatePosition SPECIAL time setting time=%u\n", p.time); LOG_DEBUG("updatePosition SPECIAL time setting time=%u\n", p.time);
info->position.time = p.time; info->position.time = p.time;
} else { } else {
// Be careful to only update fields that have been set by the REMOTE sender // Be careful to only update fields that have been set by the REMOTE sender
// A lot of position reports don't have time populated. In that case, be careful to not blow away the time we // A lot of position reports don't have time populated. In that case, be careful to not blow away the time we

View File

@ -129,6 +129,8 @@ class NodeDB
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct); bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct); bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct);
void installRoleDefaults(meshtastic_Config_DeviceConfig_Role role);
private: private:
/// Find a node in our DB, create an empty NodeInfo if missing /// Find a node in our DB, create an empty NodeInfo if missing
meshtastic_NodeInfo *getOrCreateNode(NodeNum n); meshtastic_NodeInfo *getOrCreateNode(NodeNum n);

View File

@ -401,13 +401,18 @@ void RadioInterface::applyModemConfig()
cr = 8; cr = 8;
sf = 11; sf = 11;
break; break;
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE:
bw = (myRegion->wideLora) ? 406.25 : 125;
cr = 8;
sf = 11;
break;
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_SLOW: case meshtastic_Config_LoRaConfig_ModemPreset_LONG_SLOW:
bw = (myRegion->wideLora) ? 406.25 : 125; bw = (myRegion->wideLora) ? 406.25 : 125;
cr = 8; cr = 8;
sf = 12; sf = 12;
break; break;
case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW: case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
bw = (myRegion->wideLora) ? 203.125 : 31.25; bw = (myRegion->wideLora) ? 203.125 : 62.5;
cr = 8; cr = 8;
sf = 12; sf = 12;
break; break;

View File

@ -301,8 +301,6 @@ void Router::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Rout
bool perhapsDecode(meshtastic_MeshPacket *p) bool perhapsDecode(meshtastic_MeshPacket *p)
{ {
// LOG_DEBUG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant);
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag)
return true; // If packet was already decoded just return return true; // If packet was already decoded just return
@ -367,7 +365,6 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
{ {
// 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);
// Only allow encryption on the text message app. // Only allow encryption on the text message app.
@ -454,7 +451,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
else else
printPacket("handleReceived(REMOTE)", p); printPacket("handleReceived(REMOTE)", p);
} else { } else {
printPacket("packet decoding failed (no PSK?)", p); printPacket("packet decoding failed or skipped (no PSK?)", p);
} }
// call modules here // call modules here

View File

@ -73,9 +73,6 @@ class Router : protected concurrency::OSThread
*/ */
void enqueueReceivedMessage(meshtastic_MeshPacket *p); void enqueueReceivedMessage(meshtastic_MeshPacket *p);
protected:
friend class RoutingModule;
/** /**
* Send a packet on a suitable interface. This routine will * Send a packet on a suitable interface. This routine will
* later free() the packet to pool. This routine is not allowed to stall. * later free() the packet to pool. This routine is not allowed to stall.
@ -85,6 +82,9 @@ class Router : protected concurrency::OSThread
*/ */
virtual ErrorCode send(meshtastic_MeshPacket *p); virtual ErrorCode send(meshtastic_MeshPacket *p);
protected:
friend class RoutingModule;
/** /**
* Should this incoming filter be dropped? * Should this incoming filter be dropped?
* *

View File

@ -112,13 +112,6 @@ typedef struct _meshtastic_AdminMessage {
bool begin_edit_settings; bool begin_edit_settings;
/* Commits an open transaction for any edits made to config, module config, owner, and channel settings */ /* Commits an open transaction for any edits made to config, module config, owner, and channel settings */
bool commit_edit_settings; bool commit_edit_settings;
/* Setting channels/radio config remotely carries the risk that you might send an invalid config and the radio never talks to your mesh again.
Therefore if setting either of these properties remotely, you must send a confirm_xxx message within 10 minutes.
If you fail to do so, the radio will assume loss of comms and revert your changes.
These messages are optional when changing the local node. */
bool confirm_set_channel;
/* TODO: REPLACE */
bool confirm_set_radio;
/* Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot) /* Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot)
Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. */ Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. */
int32_t reboot_ota_seconds; int32_t reboot_ota_seconds;
@ -181,8 +174,6 @@ extern "C" {
#define meshtastic_AdminMessage_set_ringtone_message_tag 37 #define meshtastic_AdminMessage_set_ringtone_message_tag 37
#define meshtastic_AdminMessage_begin_edit_settings_tag 64 #define meshtastic_AdminMessage_begin_edit_settings_tag 64
#define meshtastic_AdminMessage_commit_edit_settings_tag 65 #define meshtastic_AdminMessage_commit_edit_settings_tag 65
#define meshtastic_AdminMessage_confirm_set_channel_tag 66
#define meshtastic_AdminMessage_confirm_set_radio_tag 67
#define meshtastic_AdminMessage_reboot_ota_seconds_tag 95 #define meshtastic_AdminMessage_reboot_ota_seconds_tag 95
#define meshtastic_AdminMessage_exit_simulator_tag 96 #define meshtastic_AdminMessage_exit_simulator_tag 96
#define meshtastic_AdminMessage_reboot_seconds_tag 97 #define meshtastic_AdminMessage_reboot_seconds_tag 97
@ -214,8 +205,6 @@ X(a, STATIC, ONEOF, STRING, (payload_variant,set_canned_message_module_me
X(a, STATIC, ONEOF, STRING, (payload_variant,set_ringtone_message,set_ringtone_message), 37) \ X(a, STATIC, ONEOF, STRING, (payload_variant,set_ringtone_message,set_ringtone_message), 37) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_channel,confirm_set_channel), 66) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_radio,confirm_set_radio), 67) \
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_ota_seconds,reboot_ota_seconds), 95) \ X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_ota_seconds,reboot_ota_seconds), 95) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_seconds,reboot_seconds), 97) \ X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_seconds,reboot_seconds), 97) \

View File

@ -19,11 +19,19 @@ typedef enum _meshtastic_Config_DeviceConfig_Role {
meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE = 1, meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE = 1,
/* Router device role. /* Router device role.
Mesh packets will prefer to be routed over this node. This node will not be used by client apps. Mesh packets will prefer to be routed over this node. This node will not be used by client apps.
The wifi/ble radios and the oled screen will be put to sleep. */ The wifi/ble radios and the oled screen will be put to sleep.
This mode may still potentially have higher power usage due to it's preference in message rebroadcasting on the mesh. */
meshtastic_Config_DeviceConfig_Role_ROUTER = 2, meshtastic_Config_DeviceConfig_Role_ROUTER = 2,
/* Router Client device role /* Router Client device role
Mesh packets will prefer to be routed over this node. The Router Client can be used as both a Router and an app connected Client. */ Mesh packets will prefer to be routed over this node. The Router Client can be used as both a Router and an app connected Client. */
meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT = 3 meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT = 3,
/* Repeater device role
Mesh packets will simply be rebroadcasted over this node. Nodes under this role node 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 factory, and coding rate. */
meshtastic_Config_DeviceConfig_Role_REPEATER = 4,
/* Tracker device role
Position Mesh packets for will be higher priority and sent more frequently by default. */
meshtastic_Config_DeviceConfig_Role_TRACKER = 5
} meshtastic_Config_DeviceConfig_Role; } meshtastic_Config_DeviceConfig_Role;
/* Bit field of boolean configuration options, indicating which optional /* Bit field of boolean configuration options, indicating which optional
@ -172,7 +180,9 @@ typedef enum _meshtastic_Config_LoRaConfig_ModemPreset {
/* Short Range - Slow */ /* Short Range - Slow */
meshtastic_Config_LoRaConfig_ModemPreset_SHORT_SLOW = 5, meshtastic_Config_LoRaConfig_ModemPreset_SHORT_SLOW = 5,
/* Short Range - Fast */ /* Short Range - Fast */
meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST = 6 meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST = 6,
/* Long Range - Moderately Fast */
meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE = 7
} meshtastic_Config_LoRaConfig_ModemPreset; } meshtastic_Config_LoRaConfig_ModemPreset;
typedef enum _meshtastic_Config_BluetoothConfig_PairingMode { typedef enum _meshtastic_Config_BluetoothConfig_PairingMode {
@ -419,8 +429,8 @@ extern "C" {
/* Helper constants for enums */ /* Helper constants for enums */
#define _meshtastic_Config_DeviceConfig_Role_MIN meshtastic_Config_DeviceConfig_Role_CLIENT #define _meshtastic_Config_DeviceConfig_Role_MIN meshtastic_Config_DeviceConfig_Role_CLIENT
#define _meshtastic_Config_DeviceConfig_Role_MAX meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT #define _meshtastic_Config_DeviceConfig_Role_MAX meshtastic_Config_DeviceConfig_Role_TRACKER
#define _meshtastic_Config_DeviceConfig_Role_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT+1)) #define _meshtastic_Config_DeviceConfig_Role_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_TRACKER+1))
#define _meshtastic_Config_PositionConfig_PositionFlags_MIN meshtastic_Config_PositionConfig_PositionFlags_UNSET #define _meshtastic_Config_PositionConfig_PositionFlags_MIN meshtastic_Config_PositionConfig_PositionFlags_UNSET
#define _meshtastic_Config_PositionConfig_PositionFlags_MAX meshtastic_Config_PositionConfig_PositionFlags_SPEED #define _meshtastic_Config_PositionConfig_PositionFlags_MAX meshtastic_Config_PositionConfig_PositionFlags_SPEED
@ -451,8 +461,8 @@ extern "C" {
#define _meshtastic_Config_LoRaConfig_RegionCode_ARRAYSIZE ((meshtastic_Config_LoRaConfig_RegionCode)(meshtastic_Config_LoRaConfig_RegionCode_UA_868+1)) #define _meshtastic_Config_LoRaConfig_RegionCode_ARRAYSIZE ((meshtastic_Config_LoRaConfig_RegionCode)(meshtastic_Config_LoRaConfig_RegionCode_UA_868+1))
#define _meshtastic_Config_LoRaConfig_ModemPreset_MIN meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST #define _meshtastic_Config_LoRaConfig_ModemPreset_MIN meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST
#define _meshtastic_Config_LoRaConfig_ModemPreset_MAX meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST #define _meshtastic_Config_LoRaConfig_ModemPreset_MAX meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE
#define _meshtastic_Config_LoRaConfig_ModemPreset_ARRAYSIZE ((meshtastic_Config_LoRaConfig_ModemPreset)(meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST+1)) #define _meshtastic_Config_LoRaConfig_ModemPreset_ARRAYSIZE ((meshtastic_Config_LoRaConfig_ModemPreset)(meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE+1))
#define _meshtastic_Config_BluetoothConfig_PairingMode_MIN meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN #define _meshtastic_Config_BluetoothConfig_PairingMode_MIN meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN
#define _meshtastic_Config_BluetoothConfig_PairingMode_MAX meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN #define _meshtastic_Config_BluetoothConfig_PairingMode_MAX meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN

View File

@ -225,7 +225,7 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
void AdminModule::handleSetConfig(const meshtastic_Config &c) void AdminModule::handleSetConfig(const meshtastic_Config &c)
{ {
bool isRouter = (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER); auto existingRole = config.device.role;
bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET); bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET);
switch (c.which_payload_variant) { switch (c.which_payload_variant) {
@ -234,10 +234,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
config.has_device = true; config.has_device = true;
config.device = c.payload_variant.device; config.device = c.payload_variant.device;
// If we're setting router role for the first time, install its intervals // If we're setting router role for the first time, install its intervals
if (!isRouter && c.payload_variant.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) { if (existingRole != c.payload_variant.device.role)
nodeDB.initConfigIntervals(); nodeDB.installRoleDefaults(c.payload_variant.device.role);
nodeDB.initModuleConfigIntervals();
}
break; break;
case meshtastic_Config_position_tag: case meshtastic_Config_position_tag:
LOG_INFO("Setting config: Position\n"); LOG_INFO("Setting config: Position\n");

View File

@ -33,51 +33,56 @@
*/ */
void setupModules() void setupModules()
{ {
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) {
#if HAS_BUTTON #if HAS_BUTTON
inputBroker = new InputBroker(); inputBroker = new InputBroker();
#endif #endif
adminModule = new AdminModule(); adminModule = new AdminModule();
nodeInfoModule = new NodeInfoModule(); nodeInfoModule = new NodeInfoModule();
positionModule = new PositionModule(); positionModule = new PositionModule();
waypointModule = new WaypointModule(); waypointModule = new WaypointModule();
textMessageModule = new TextMessageModule(); textMessageModule = new TextMessageModule();
traceRouteModule = new TraceRouteModule(); traceRouteModule = new TraceRouteModule();
// 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.
new RemoteHardwareModule(); new RemoteHardwareModule();
new ReplyModule(); new ReplyModule();
#if HAS_BUTTON #if HAS_BUTTON
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
rotaryEncoderInterruptImpl1->init(); rotaryEncoderInterruptImpl1->init();
upDownInterruptImpl1 = new UpDownInterruptImpl1(); upDownInterruptImpl1 = new UpDownInterruptImpl1();
upDownInterruptImpl1->init(); upDownInterruptImpl1->init();
cardKbI2cImpl = new CardKbI2cImpl(); cardKbI2cImpl = new CardKbI2cImpl();
cardKbI2cImpl->init(); cardKbI2cImpl->init();
#endif #endif
#if HAS_SCREEN #if HAS_SCREEN
cannedMessageModule = new CannedMessageModule(); cannedMessageModule = new CannedMessageModule();
#endif #endif
#if HAS_TELEMETRY #if HAS_TELEMETRY
new DeviceTelemetryModule(); new DeviceTelemetryModule();
new EnvironmentTelemetryModule(); new EnvironmentTelemetryModule();
#endif #endif
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) #if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2)
new SerialModule(); new SerialModule();
#endif #endif
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
// Only run on an esp32 based device. // Only run on an esp32 based device.
audioModule = new AudioModule(); audioModule = new AudioModule();
externalNotificationModule = new ExternalNotificationModule(); externalNotificationModule = new ExternalNotificationModule();
storeForwardModule = new StoreForwardModule(); storeForwardModule = new StoreForwardModule();
new RangeTestModule(); new RangeTestModule();
#elif defined(ARCH_NRF52) #elif defined(ARCH_NRF52)
externalNotificationModule = new ExternalNotificationModule(); externalNotificationModule = new ExternalNotificationModule();
#endif #endif
} else {
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks adminModule = new AdminModule();
traceRouteModule = new TraceRouteModule();
}
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
// acks
routingModule = new RoutingModule(); routingModule = new RoutingModule();
} }

View File

@ -129,7 +129,10 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies)
meshtastic_MeshPacket *p = allocReply(); meshtastic_MeshPacket *p = allocReply();
p->to = dest; p->to = dest;
p->decoded.want_response = wantReplies; p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; if (config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER)
p->priority = meshtastic_MeshPacket_Priority_RELIABLE;
else
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
prevPacketId = p->id; prevPacketId = p->id;
service.sendToMesh(p, RX_SRC_LOCAL, true); service.sendToMesh(p, RX_SRC_LOCAL, true);
@ -161,7 +164,6 @@ int32_t PositionModule::runOnce()
sendOurPosition(NODENUM_BROADCAST, requestReplies); sendOurPosition(NODENUM_BROADCAST, requestReplies);
} }
} }
} else if (config.position.position_broadcast_smart_enabled) { } else if (config.position.position_broadcast_smart_enabled) {
// Only send packets if the channel is less than 25% utilized. // Only send packets if the channel is less than 25% utilized.

View File

@ -24,6 +24,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);
// We only consider making replies if the request was a legit routing packet (not just something we were sniffing) // We only consider making replies if the request was a legit routing packet (not just something we were sniffing)

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 2 major = 2
minor = 0 minor = 0
build = 14 build = 16