From 0eefd0912ff36a56418cb4ee5799080cd3655239 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 28 Jul 2023 10:28:14 -0500 Subject: [PATCH] Move node_broadcast_interval_secs --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 26 ++++++++++++------------- src/modules/NeighborInfoModule.cpp | 19 ++++++++---------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/protobufs b/protobufs index af693fe02..869b48314 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit af693fe022bc73c2fb3245c54f6e3abf8f086bd8 +Subproject commit 869b4831452e6ce80f4029fdc58c69b2f2dad29a diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index bfdf66343..5d6ab6285 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -679,8 +679,6 @@ typedef struct _meshtastic_Neighbor { uint32_t node_id; /* SNR of last heard message */ float snr; - /* Broadcast interval of the represented node (in seconds) */ - uint16_t node_broadcast_interval_secs; } meshtastic_Neighbor; /* Full info on edges for a single node */ @@ -689,6 +687,8 @@ typedef struct _meshtastic_NeighborInfo { uint32_t node_id; /* Field to pass neighbor info for the next sending cycle */ uint32_t last_sent_by_id; + /* Broadcast interval of the represented node (in seconds) */ + uint32_t node_broadcast_interval_secs; /* The list of out edges from this node */ pb_size_t neighbors_count; meshtastic_Neighbor neighbors[10]; @@ -853,8 +853,8 @@ extern "C" { #define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}} #define meshtastic_ToRadio_init_default {0, {meshtastic_MeshPacket_init_default}} #define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}} -#define meshtastic_NeighborInfo_init_default {0, 0, 0, {meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default}} -#define meshtastic_Neighbor_init_default {0, 0, 0} +#define meshtastic_NeighborInfo_init_default {0, 0, 0, 0, {meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default}} +#define meshtastic_Neighbor_init_default {0, 0} #define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0} @@ -871,8 +871,8 @@ extern "C" { #define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_ToRadio_init_zero {0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}} -#define meshtastic_NeighborInfo_init_zero {0, 0, 0, {meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero}} -#define meshtastic_Neighbor_init_zero {0, 0, 0} +#define meshtastic_NeighborInfo_init_zero {0, 0, 0, 0, {meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero}} +#define meshtastic_Neighbor_init_zero {0, 0} #define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} /* Field tags (for use in manual encoding/decoding) */ @@ -968,10 +968,10 @@ extern "C" { #define meshtastic_Compressed_data_tag 2 #define meshtastic_Neighbor_node_id_tag 1 #define meshtastic_Neighbor_snr_tag 2 -#define meshtastic_Neighbor_node_broadcast_interval_secs_tag 3 #define meshtastic_NeighborInfo_node_id_tag 1 #define meshtastic_NeighborInfo_last_sent_by_id_tag 2 -#define meshtastic_NeighborInfo_neighbors_tag 3 +#define meshtastic_NeighborInfo_node_broadcast_interval_secs_tag 3 +#define meshtastic_NeighborInfo_neighbors_tag 4 #define meshtastic_DeviceMetadata_firmware_version_tag 1 #define meshtastic_DeviceMetadata_device_state_version_tag 2 #define meshtastic_DeviceMetadata_canShutdown_tag 3 @@ -1185,15 +1185,15 @@ X(a, STATIC, SINGULAR, BYTES, data, 2) #define meshtastic_NeighborInfo_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, node_id, 1) \ X(a, STATIC, SINGULAR, UINT32, last_sent_by_id, 2) \ -X(a, STATIC, REPEATED, MESSAGE, neighbors, 3) +X(a, STATIC, SINGULAR, UINT32, node_broadcast_interval_secs, 3) \ +X(a, STATIC, REPEATED, MESSAGE, neighbors, 4) #define meshtastic_NeighborInfo_CALLBACK NULL #define meshtastic_NeighborInfo_DEFAULT NULL #define meshtastic_NeighborInfo_neighbors_MSGTYPE meshtastic_Neighbor #define meshtastic_Neighbor_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, node_id, 1) \ -X(a, STATIC, SINGULAR, FLOAT, snr, 2) \ -X(a, STATIC, SINGULAR, UINT32, node_broadcast_interval_secs, 3) +X(a, STATIC, SINGULAR, FLOAT, snr, 2) #define meshtastic_Neighbor_CALLBACK NULL #define meshtastic_Neighbor_DEFAULT NULL @@ -1259,8 +1259,8 @@ extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; #define meshtastic_MeshPacket_size 321 #define meshtastic_MqttClientProxyMessage_size 501 #define meshtastic_MyNodeInfo_size 18 -#define meshtastic_NeighborInfo_size 182 -#define meshtastic_Neighbor_size 15 +#define meshtastic_NeighborInfo_size 148 +#define meshtastic_Neighbor_size 11 #define meshtastic_NodeInfo_size 261 #define meshtastic_Position_size 137 #define meshtastic_QueueStatus_size 23 diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index bd8506a51..4fc840839 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -21,8 +21,7 @@ void NeighborInfoModule::printNeighborInfo(const char *header, const meshtastic_ LOG_DEBUG("----------------\n"); LOG_DEBUG("Packet contains %d neighbors\n", np->neighbors_count); for (int i = 0; i < np->neighbors_count; i++) { - LOG_DEBUG("Neighbor %d: node_id=%d, snr=%d, broadcast_interval=%d\n", i, np->neighbors[i].node_id, np->neighbors[i].snr, - np->neighbors[i].node_broadcast_interval_secs); + LOG_DEBUG("Neighbor %d: node_id=%d, snr=%d\n", i, np->neighbors[i].node_id, np->neighbors[i].snr); } LOG_DEBUG("----------------\n"); } @@ -38,8 +37,7 @@ void NeighborInfoModule::printNodeDBNodes(const char *header) LOG_DEBUG("DB contains %d nodes\n", num_nodes); for (int i = 0; i < num_nodes; i++) { meshtastic_NodeInfoLite *dbEntry = nodeDB.getMeshNodeByIndex(i); - LOG_DEBUG(" Node %d: node_id=%d, snr=%.2f, broadcast_interval=%d\n", i, dbEntry->num, dbEntry->snr, - dbEntry->node_broadcast_interval_secs); + LOG_DEBUG(" Node %d: node_id=%d, snr=%.2f\n", i, dbEntry->num, dbEntry->snr); } LOG_DEBUG("----------------\n"); } @@ -56,8 +54,7 @@ void NeighborInfoModule::printNodeDBNeighbors(const char *header) LOG_DEBUG("DB contains %d neighbors\n", num_neighbors); for (int i = 0; i < num_neighbors; i++) { meshtastic_Neighbor *dbEntry = getNeighborByIndex(i); - LOG_DEBUG(" Node %d: node_id=%d, snr=%.2f, broadcast_interval=%d\n", i, dbEntry->node_id, dbEntry->snr, - dbEntry->node_broadcast_interval_secs); + LOG_DEBUG(" Node %d: node_id=%d, snr=%.2f\n", i, dbEntry->node_id, dbEntry->snr); } LOG_DEBUG("----------------\n"); } @@ -82,11 +79,9 @@ void NeighborInfoModule::printNodeDBSelection(const char *header, const meshtast } } if (!chosen) { - LOG_DEBUG(" Node %d: neighbor=%d, snr=%.2f, broadcast_interval=%d\n", i, dbEntry->node_id, dbEntry->snr, - dbEntry->node_broadcast_interval_secs); + LOG_DEBUG(" Node %d: neighbor=%d, snr=%.2f\n", i, dbEntry->node_id, dbEntry->snr); } else { - LOG_DEBUG("---> Node %d: neighbor=%d, snr=%.2f, broadcast_interval=%d\n", i, dbEntry->node_id, dbEntry->snr, - dbEntry->node_broadcast_interval_secs); + LOG_DEBUG("---> Node %d: neighbor=%d, snr=%.2f\n", i, dbEntry->node_id, dbEntry->snr); } } LOG_DEBUG("----------------\n"); @@ -130,8 +125,10 @@ uint32_t NeighborInfoModule::collectNeighborInfo(meshtastic_NeighborInfo *neighb int my_node_id = nodeDB.getNodeNum(); neighborInfo->node_id = my_node_id; neighborInfo->last_sent_by_id = my_node_id; + neighborInfo->node_broadcast_interval_secs = moduleConfig.neighbor_info.broadcast_interval_secs; - for (int i = 0; i < num_neighbors; i++) { + for (int i = 0; i < num_neighbors; i++) + { meshtastic_Neighbor *dbEntry = getNeighborByIndex(i); if ((neighborInfo->neighbors_count < MAX_NUM_NEIGHBORS) && (dbEntry->node_id != my_node_id)) { neighborInfo->neighbors[neighborInfo->neighbors_count].node_id = dbEntry->node_id;