Compare commits

...

6 Commits

Author SHA1 Message Date
Tom Fifield
9d15af70ac
Merge e906c39171 into 834c3c5cc2 2025-08-28 10:25:51 +00:00
GUVWAF
e906c39171
Merge branch 'master' into mqtt-investigation 2025-08-28 12:25:47 +02:00
Ben Meadors
834c3c5cc2 Add this back in 2025-08-27 16:24:57 -05:00
Tom Fifield
0a5263a4aa AvOid memleak 2025-07-29 21:07:19 +10:00
Tom Fifield
439534f1fb Include all the things 2025-07-29 21:07:19 +10:00
Tom Fifield
05b34449d9 Only send Neighbours if we have some to send.
The original intent of NeighborInfo was that when a NeighbourInfo
was sent all of the nodes that saw it would reply with NeighbourInfo.
So, NeighbourInfo was sent even if there were no hop-zero nodes in
the NodeDB.

Since 2023, when this was implemented, our understanding of running city-wide
meshes has improved substantially. We have taken steps to reduce the impact
of NeighborInfo over LoRa.

This change aligns with those ideas: we will now only send NeighborInfo
if we have some neighbors to contribute.

The impact of this change is that a node must first see another directly
connected node in another packet type before NeighborInfo is sent. This means
that a node with no neighbors is no longer able to trigger other nodes
to broadcast NeighborInfo. It will, however, receive the regular periodic
broadcast of NeighborInfo, and will be able to send NeighborInfo if it
has at least 1 neighbor.
2025-07-29 21:07:19 +10:00
2 changed files with 18 additions and 18 deletions

View File

@ -105,14 +105,15 @@ void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies)
{
meshtastic_NeighborInfo neighborInfo = meshtastic_NeighborInfo_init_zero;
collectNeighborInfo(&neighborInfo);
meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo);
// send regardless of whether or not we have neighbors in our DB,
// because we want to get neighbors for the next cycle
p->to = dest;
p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
printNeighborInfo("SENDING", &neighborInfo);
service->sendToMesh(p, RX_SRC_LOCAL, true);
// only send neighbours if we have some to send
if (neighborInfo.neighbors_count > 0) {
meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo);
p->to = dest;
p->decoded.want_response = wantReplies;
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
printNeighborInfo("SENDING", &neighborInfo);
service->sendToMesh(p, RX_SRC_LOCAL, true);
}
}
/*
@ -214,4 +215,4 @@ meshtastic_Neighbor *NeighborInfoModule::getOrCreateNeighbor(NodeNum originalSen
neighbors.push_back(new_nbr);
}
return &neighbors.back();
}
}

View File

@ -45,7 +45,7 @@
*/
#ifdef HELTEC_MESH_SOLAR
#ifdef HELTEC_MESH_SOLAR
#include "meshSolarApp.h"
#endif
@ -63,9 +63,8 @@
SerialModule *serialModule;
SerialModuleRadio *serialModuleRadio;
#if defined(TTGO_T_ECHO) || defined(CANARYONE) || defined(MESHLINK) || defined(ELECROW_ThinkNode_M1) || \
defined(ELECROW_ThinkNode_M5) || defined(HELTEC_MESH_SOLAR)
defined(ELECROW_ThinkNode_M5) || defined(HELTEC_MESH_SOLAR) || defined(T_ECHO_LITE)
SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("Serial") {}
static Print *serialPrint = &Serial;
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
@ -83,7 +82,7 @@ bool SerialModule::isValidConfig(const meshtastic_ModuleConfig_SerialConfig &con
{
if (config.override_console_serial_port && !IS_ONE_OF(config.mode, meshtastic_ModuleConfig_SerialConfig_Serial_Mode_NMEA,
meshtastic_ModuleConfig_SerialConfig_Serial_Mode_CALTOPO,
meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MS_CONFIG)) {
meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MS_CONFIG)) {
const char *warning =
"Invalid Serial config: override console serial port is only supported in NMEA and CalTopo output-only modes.";
LOG_ERROR(warning);
@ -249,11 +248,11 @@ int32_t SerialModule::runOnce()
}
#if defined(HELTEC_MESH_SOLAR)
else if ((moduleConfig.serial.mode == meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MS_CONFIG)) {
serialPayloadSize = Serial.readBytes(serialBytes, sizeof(serialBytes)-1);
//If the parsing fails, the following parsing will be performed.
if((serialPayloadSize > 0) && (meshSolarCmdHandle(serialBytes)!=0)) {
return runOncePart(serialBytes,serialPayloadSize);
}
serialPayloadSize = Serial.readBytes(serialBytes, sizeof(serialBytes) - 1);
// If the parsing fails, the following parsing will be performed.
if ((serialPayloadSize > 0) && (meshSolarCmdHandle(serialBytes) != 0)) {
return runOncePart(serialBytes, serialPayloadSize);
}
}
#endif
else {