Compare commits

...

25 Commits

Author SHA1 Message Date
Ben Meadors
aafbde0f10 Remove the dirty d 2023-01-28 14:50:07 -06:00
Ben Meadors
f29beeb748 Merge pull request #2217 from meshtastic/tracker-role
Tracker role and role based defaults
2023-01-28 14:45:58 -06:00
Ben Meadors
75ea6fd704 Update interval 2023-01-28 14:44:47 -06:00
Ben Meadors
171c1df3fa Role based defaults 2023-01-28 14:32:57 -06:00
Ben Meadors
e05a007fc6 Merge pull request #2214 from meshtastic/repeater-role
Skip decoding packets for Repeaters
2023-01-28 13:49:12 -06:00
Ben Meadors
30a1810e12 Merge branch 'master' into repeater-role 2023-01-28 13:49:02 -06:00
Ben Meadors
bdf3fe3f5c Logging tweaks 2023-01-28 13:40:14 -06:00
Ben Meadors
d9af4f46fa Skip decoding for Repeaters 2023-01-28 13:28:57 -06:00
Ben Meadors
9d2fbec511 Merge pull request #2213 from meshtastic/repeater-role
Start of repeater role with in firmware
2023-01-28 11:44:28 -06:00
Ben Meadors
f45a25b358 Fmt 2023-01-28 09:18:06 -06:00
Ben Meadors
92a43685a8 Modules 2023-01-28 09:13:01 -06:00
Ben Meadors
103f1992dd Yank repeater module and just guard clause the alloc 2023-01-28 09:11:12 -06:00
Ben Meadors
e229a67d25 More friends 2023-01-28 08:44:29 -06:00
Ben Meadors
a7153a7aa9 Be a friend 2023-01-28 08:40:50 -06:00
Ben Meadors
14372c7e35 Fmt 2023-01-28 08:18:56 -06:00
Ben Meadors
a5f80167e0 Remove comments 2023-01-28 08:18:47 -06:00
Ben Meadors
654d38ed3f Router 2023-01-28 08:17:29 -06:00
Ben Meadors
e01e830c0e Print 2023-01-28 08:09:10 -06:00
Ben Meadors
db192481bd Swap out reliable router with flood router and dump modules 2023-01-28 08:03:32 -06:00
Ben Meadors
e8908784f9 Format 2023-01-28 06:39:14 -06:00
Ben Meadors
de82119415 Start of repeater role with in firmware 2023-01-28 06:38:13 -06:00
Ben Meadors
cda7e8b6a5 Merge pull request #2212 from meshtastic/create-pull-request/patch
Changes by create-pull-request action
2023-01-27 14:17:50 -06:00
thebentern
96f763dfa3 [create-pull-request] automated change 2023-01-27 20:16:23 +00:00
Ben Meadors
57b47cf1e1 Merge pull request #2211 from meshtastic/create-pull-request/patch
Changes by create-pull-request action
2023-01-27 12:27:22 -06:00
thebentern
7950739d85 [create-pull-request] automated change 2023-01-27 17:56:16 +00:00
16 changed files with 95 additions and 68 deletions

View File

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

View File

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

View File

@@ -310,6 +310,10 @@ void setup()
// but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
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();
// fixed screen override?

View File

@@ -48,15 +48,13 @@ void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
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
// We are careful not to call our hooked version of send() - because we don't want to check this again
Router::send(tosend);
} else {
LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
}
} else {
LOG_DEBUG("Ignoring a simple (0 id) broadcast\n");
}

View File

@@ -225,6 +225,25 @@ void NodeDB::installDefaultModuleConfig()
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()
{
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,
p.longitude_i, p.altitude);
info->position = p;
} 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
// (stop-gap fix for issue #900)
LOG_DEBUG("updatePosition SPECIAL time setting time=%u\n", p.time);
info->position.time = p.time;
} else {
// 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

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 saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct);
void installRoleDefaults(meshtastic_Config_DeviceConfig_Role role);
private:
/// Find a node in our DB, create an empty NodeInfo if missing
meshtastic_NodeInfo *getOrCreateNode(NodeNum n);

View File

@@ -300,8 +300,8 @@ void Router::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Rout
bool perhapsDecode(meshtastic_MeshPacket *p)
{
// LOG_DEBUG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
return false;
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag)
return true; // If packet was already decoded just return
@@ -367,7 +367,6 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
{
// If the packet is not yet encrypted, do so now
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
// Only allow encryption on the text message app.
@@ -454,7 +453,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
else
printPacket("handleReceived(REMOTE)", p);
} else {
printPacket("packet decoding failed (no PSK?)", p);
printPacket("packet decoding failed or skipped (no PSK?)", p);
}
// call modules here

View File

@@ -73,9 +73,6 @@ class Router : protected concurrency::OSThread
*/
void enqueueReceivedMessage(meshtastic_MeshPacket *p);
protected:
friend class RoutingModule;
/**
* Send a packet on a suitable interface. This routine will
* 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);
protected:
friend class RoutingModule;
/**
* Should this incoming filter be dropped?
*

View File

@@ -112,13 +112,6 @@ typedef struct _meshtastic_AdminMessage {
bool begin_edit_settings;
/* Commits an open transaction for any edits made to config, module config, owner, and channel 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)
Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. */
int32_t reboot_ota_seconds;
@@ -181,8 +174,6 @@ extern "C" {
#define meshtastic_AdminMessage_set_ringtone_message_tag 37
#define meshtastic_AdminMessage_begin_edit_settings_tag 64
#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_exit_simulator_tag 96
#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, 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,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, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \
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,
/* Router device role.
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,
/* 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. */
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;
/* Bit field of boolean configuration options, indicating which optional
@@ -419,8 +427,8 @@ extern "C" {
/* Helper constants for enums */
#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_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT+1))
#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_TRACKER+1))
#define _meshtastic_Config_PositionConfig_PositionFlags_MIN meshtastic_Config_PositionConfig_PositionFlags_UNSET
#define _meshtastic_Config_PositionConfig_PositionFlags_MAX meshtastic_Config_PositionConfig_PositionFlags_SPEED

View File

@@ -225,7 +225,7 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
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);
switch (c.which_payload_variant) {
@@ -234,10 +234,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
config.has_device = true;
config.device = c.payload_variant.device;
// 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) {
nodeDB.initConfigIntervals();
nodeDB.initModuleConfigIntervals();
}
if (existingRole != c.payload_variant.device.role)
nodeDB.installRoleDefaults(c.payload_variant.device.role);
break;
case meshtastic_Config_position_tag:
LOG_INFO("Setting config: Position\n");

View File

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

View File

@@ -129,7 +129,10 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies)
meshtastic_MeshPacket *p = allocReply();
p->to = dest;
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;
service.sendToMesh(p, RX_SRC_LOCAL, true);
@@ -161,7 +164,6 @@ int32_t PositionModule::runOnce()
sendOurPosition(NODENUM_BROADCAST, requestReplies);
}
}
} else if (config.position.position_broadcast_smart_enabled) {
// 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()
{
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
return NULL;
assert(currentRequest);
// 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]
major = 2
minor = 0
build = 14
build = 15