kopia lustrzana https://github.com/meshtastic/firmware
Set original hop limit in header flags
rodzic
3776064b80
commit
44dc270c8a
|
@ -10,7 +10,7 @@ ErrorCode NextHopRouter::send(meshtastic_MeshPacket *p)
|
|||
// Add any messages _we_ send to the seen message list (so we will ignore all retransmissions we see)
|
||||
wasSeenRecently(p); // FIXME, move this to a sniffSent method
|
||||
|
||||
p->next_hop = getNextHop(p->to, p->current_relayer); // set the next hop
|
||||
p->next_hop = getNextHop(p->to, p->relay_node); // set the next hop
|
||||
LOG_DEBUG("Setting next hop for packet with dest %x to %x\n", p->to, p->next_hop);
|
||||
|
||||
return Router::send(p);
|
||||
|
@ -19,7 +19,7 @@ ErrorCode NextHopRouter::send(meshtastic_MeshPacket *p)
|
|||
bool NextHopRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
||||
{
|
||||
if (wasSeenRecently(p)) { // Note: this will also add a recent packet record
|
||||
if (p->next_hop == getNodeNum()) {
|
||||
if (p->next_hop == (uint8_t)(getNodeNum() & 0xFF)) {
|
||||
LOG_DEBUG("Ignoring incoming msg, because we've already seen it.\n");
|
||||
} else {
|
||||
LOG_DEBUG("Ignoring incoming msg, because we've already seen it and cancel any outgoing packets.\n");
|
||||
|
@ -36,14 +36,14 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||
bool isAck =
|
||||
((c && c->error_reason == meshtastic_Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK
|
||||
if (isAck) {
|
||||
// Update next-hop of this successful transmission to current relayer, but ONLY if "from" is not 0 or ourselves (means
|
||||
// Update next-hop of this successful transmission to the relay node, but ONLY if "from" is not 0 or ourselves (means
|
||||
// implicit ACK or someone is relaying our ACK)
|
||||
if (p->from != 0 && p->from != getNodeNum()) {
|
||||
if (p->current_relayer) {
|
||||
if (p->relay_node) {
|
||||
meshtastic_NodeInfoLite *sentTo = nodeDB.getMeshNode(p->from);
|
||||
if (sentTo) {
|
||||
LOG_DEBUG("Update next hop of %x to %x based on received ACK.\n", p->from, p->current_relayer);
|
||||
sentTo->next_hop = p->current_relayer;
|
||||
LOG_DEBUG("Update next hop of 0x%x to 0x%x based on received ACK.\n", p->from, p->relay_node);
|
||||
sentTo->next_hop = p->relay_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE) {
|
||||
if ((p->to != getNodeNum()) && (getFrom(p) != getNodeNum())) {
|
||||
if (p->next_hop == getNodeNum()) {
|
||||
if (p->next_hop == (uint8_t)(getNodeNum() & 0xFF)) {
|
||||
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||
LOG_INFO("Relaying received next-hop message coming from %x\n", p->current_relayer);
|
||||
LOG_INFO("Relaying received next-hop message coming from %x\n", p->relay_node);
|
||||
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
// If it is a traceRoute request, update the route that it went via me
|
||||
|
@ -71,8 +71,7 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||
LOG_DEBUG("No preference for next hop, using FloodingRouter\n");
|
||||
FloodingRouter::sniffReceived(p, c);
|
||||
} else if (p->to == NODENUM_BROADCAST) {
|
||||
// TODO how to handle broadcast messages?
|
||||
LOG_DEBUG("TODO: Broadcast next-hop message\n");
|
||||
// TODO: Smarter way of handling broadcasts
|
||||
FloodingRouter::sniffReceived(p, c);
|
||||
}
|
||||
}
|
||||
|
@ -84,23 +83,22 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the next hop for a destination, given the current relayer
|
||||
* Get the next hop for a destination, given the relay node
|
||||
* @return the node number of the next hop, 0 if no preference (fallback to FloodingRouter)
|
||||
*/
|
||||
uint32_t NextHopRouter::getNextHop(NodeNum to, NodeNum current_relayer)
|
||||
uint8_t NextHopRouter::getNextHop(NodeNum to, uint8_t relay_node)
|
||||
{
|
||||
meshtastic_NodeInfoLite *node = nodeDB.getMeshNode(to);
|
||||
if (node) {
|
||||
// We are careful not to return the current relayer as the next hop
|
||||
if (node->next_hop != current_relayer) {
|
||||
LOG_DEBUG("Next hop for %x is %x\n", to, node->next_hop);
|
||||
// We are careful not to return the relay node as the next hop
|
||||
if (node->next_hop != relay_node) {
|
||||
LOG_DEBUG("Next hop for 0x%x is 0x%x\n", to, node->next_hop);
|
||||
return node->next_hop;
|
||||
} else {
|
||||
LOG_WARN("Next hop for %x is %x, which is the same as current relayer; setting as no preference\n", to,
|
||||
node->next_hop);
|
||||
return 0;
|
||||
LOG_WARN("Next hop for 0x%x is 0x%x, same as relayer; setting as no preference\n", to, node->next_hop);
|
||||
return NO_NEXT_HOP_PREFERENCE;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
return NO_NEXT_HOP_PREFERENCE;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/*
|
||||
Router which only relays if it is the next hop for a packet.
|
||||
The next hop is set by the current relayer of a packet, which bases this on information from either the NeighborInfoModule, or a
|
||||
The next hop is set by the relay node of a packet, which bases this on information from either the NeighborInfoModule, or a
|
||||
previous successful delivery via flooding. It is only used for DMs and not used for broadcasts. Using the NeighborInfoModule, it
|
||||
can derive the next hop of neighbors and that of neighbors of neighbors. For others, it has no information in the beginning,
|
||||
which results into falling back to the FloodingRouter. Upon successful delivery via flooding, it updates the next hop of the
|
||||
|
@ -40,10 +40,12 @@ class NextHopRouter : public FloodingRouter
|
|||
*/
|
||||
virtual void sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) override;
|
||||
|
||||
constexpr static uint8_t NO_NEXT_HOP_PREFERENCE = 0;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get the next hop for a destination, given the current relayer
|
||||
* Get the next hop for a destination, given the relay node
|
||||
* @return the node number of the next hop, 0 if no preference (fallback to FloodingRouter)
|
||||
*/
|
||||
uint32_t getNextHop(NodeNum to, NodeNum current_relayer);
|
||||
uint8_t getNextHop(NodeNum to, uint8_t relay_node);
|
||||
};
|
|
@ -791,6 +791,11 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp)
|
|||
if (mp.decoded.portnum == meshtastic_PortNum_NODEINFO_APP) {
|
||||
info->channel = mp.channel;
|
||||
}
|
||||
|
||||
// If this packet didn't travel any hops, then it was sent directly to us, so we know what to use as next hop to this node
|
||||
if (mp.original_hop_limit == mp.hop_limit) {
|
||||
info->next_hop = (uint8_t)(mp.from & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -814,16 +819,6 @@ meshtastic_NodeInfoLite *NodeDB::getMeshNode(NodeNum n)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Find a node in the database that matches the last byte, return 0 if not found
|
||||
NodeNum NodeDB::findMatchingNodeNum(uint8_t last_byte)
|
||||
{
|
||||
for (int i = 0; i < *numMeshNodes; i++)
|
||||
if ((uint8_t)(meshNodes[i].num & 0xFF) == last_byte)
|
||||
return meshNodes[i].num;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Find a node in our DB, create an empty NodeInfo if missing
|
||||
meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
||||
{
|
||||
|
|
|
@ -129,7 +129,6 @@ class NodeDB
|
|||
}
|
||||
|
||||
meshtastic_NodeInfoLite *getMeshNode(NodeNum n);
|
||||
NodeNum findMatchingNodeNum(uint8_t last_byte);
|
||||
size_t getNumMeshNodes() { return *numMeshNodes; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -538,8 +538,9 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
|
|||
p->hop_limit = HOP_RELIABLE;
|
||||
}
|
||||
h->flags = p->hop_limit | (p->want_ack ? PACKET_FLAGS_WANT_ACK_MASK : 0);
|
||||
h->next_hop = (p->next_hop & 0xFF); // set last byte of next_hop
|
||||
h->current_relayer = (p->current_relayer & 0xFF); // set last byte of current_relayer
|
||||
h->flags |= (p->original_hop_limit & PACKET_FLAGS_HOP_MASK) << PACKET_FLAGS_ORIG_HOP_SHIFT;
|
||||
h->next_hop = p->next_hop;
|
||||
h->relay_node = p->relay_node;
|
||||
|
||||
// if the sender nodenum is zero, that means uninitialized
|
||||
assert(h->from);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#define PACKET_FLAGS_HOP_MASK 0x07
|
||||
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
|
||||
#define PACKET_FLAGS_ORIG_HOP_MASK 0x70
|
||||
#define PACKET_FLAGS_ORIG_HOP_SHIFT 4
|
||||
|
||||
/**
|
||||
* This structure has to exactly match the wire layout when sent over the radio link. Used to keep compatibility
|
||||
|
@ -35,8 +37,8 @@ typedef struct {
|
|||
// Last byte of the NodeNum of the next-hop for this packet
|
||||
uint8_t next_hop;
|
||||
|
||||
// Last byte of the NodeNum of the current relayer of this packet
|
||||
uint8_t current_relayer;
|
||||
// Last byte of the NodeNum of the node that will relay/relayed this packet
|
||||
uint8_t relay_node;
|
||||
} PacketHeader;
|
||||
|
||||
/**
|
||||
|
|
|
@ -361,9 +361,10 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||
mp->channel = h->channel;
|
||||
assert(HOP_MAX <= PACKET_FLAGS_HOP_MASK); // If hopmax changes, carefully check this code
|
||||
mp->hop_limit = h->flags & PACKET_FLAGS_HOP_MASK;
|
||||
mp->original_hop_limit = (h->flags & PACKET_FLAGS_ORIG_HOP_MASK) >> PACKET_FLAGS_ORIG_HOP_SHIFT;
|
||||
mp->want_ack = !!(h->flags & PACKET_FLAGS_WANT_ACK_MASK);
|
||||
mp->next_hop = nodeDB.findMatchingNodeNum(h->next_hop);
|
||||
mp->current_relayer = nodeDB.findMatchingNodeNum(h->current_relayer);
|
||||
mp->next_hop = h->next_hop;
|
||||
mp->relay_node = h->relay_node;
|
||||
|
||||
addReceiveMetadata(mp);
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
|||
i->second.nextTxMsec += iface->getPacketTime(p);
|
||||
}
|
||||
|
||||
/* Resend implicit ACKs for repeated packets (current relayer is the same as original transmitter)
|
||||
* this way if an implicit ACK is dropped and a packet is resent we'll rebroadcast again.
|
||||
* Resending real ACKs is omitted, as you might receive a packet multiple times due to flooding and
|
||||
* flooding this ACK back to the original sender already adds redundancy. */
|
||||
if (wasSeenRecently(p, false) && p->current_relayer == p->from && !MeshModule::currentReply && p->to != nodeDB.getNodeNum()) {
|
||||
/* Resend implicit ACKs for repeated packets (hop limit is the original setting) this way if an implicit ACK is dropped and a
|
||||
* packet is resent we'll rebroadcast again. Resending real ACKs is omitted, as you might receive a packet multiple times due
|
||||
* to flooding and flooding this ACK back to the original sender already adds redundancy. */
|
||||
if (wasSeenRecently(p, false) && (p->original_hop_limit == p->hop_limit) && !MeshModule::currentReply &&
|
||||
p->to != nodeDB.getNodeNum()) {
|
||||
// retransmission on broadcast has hop_limit still equal to HOP_RELIABLE
|
||||
LOG_DEBUG("Resending implicit ack for a repeated floodmsg\n");
|
||||
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p);
|
||||
|
@ -224,12 +224,12 @@ int32_t ReliableRouter::doRetransmissions()
|
|||
|
||||
if (config.lora.next_hop_routing && p.numRetransmissions == 1) {
|
||||
// Last retransmission, reset next_hop (fallback to FloodingRouter)
|
||||
p.packet->next_hop = 0;
|
||||
p.packet->next_hop = NO_NEXT_HOP_PREFERENCE;
|
||||
// Also reset it in the nodeDB
|
||||
meshtastic_NodeInfoLite *sentTo = nodeDB.getMeshNode(p.packet->to);
|
||||
if (sentTo) {
|
||||
LOG_DEBUG("Resetting next hop for packet with dest %x\n", p.packet->to);
|
||||
sentTo->next_hop = 0;
|
||||
LOG_DEBUG("Resetting next hop for packet with dest 0x%x\n", p.packet->to);
|
||||
sentTo->next_hop = NO_NEXT_HOP_PREFERENCE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,11 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
|||
// the lora we need to make sure we have replaced it with our local address
|
||||
p->from = getFrom(p);
|
||||
|
||||
p->current_relayer = getNodeNum(); // set the current relayer to us
|
||||
// If we are the original transmitter, set the original hop limit
|
||||
if (p->from == nodeDB.getNodeNum())
|
||||
p->original_hop_limit = config.lora.hop_limit ? config.lora.hop_limit : HOP_RELIABLE;
|
||||
|
||||
p->relay_node = (uint8_t)(getNodeNum() & 0xFF); // set the current relayer to us
|
||||
|
||||
// If the packet hasn't yet been encrypted, do so now (it might already be encrypted if we are just forwarding it)
|
||||
|
||||
|
|
|
@ -30,14 +30,10 @@ typedef enum _meshtastic_Config_DeviceConfig_Role {
|
|||
or any other packet type. They will simply rebroadcast any mesh packets on the same frequency, channel num, spread factor, and coding rate. */
|
||||
meshtastic_Config_DeviceConfig_Role_REPEATER = 4,
|
||||
/* Tracker device role
|
||||
Position Mesh packets will be prioritized higher and sent more frequently by default.
|
||||
When used in conjunction with power.is_power_saving = true, nodes will wake up,
|
||||
send position, and then sleep for position.position_broadcast_secs seconds. */
|
||||
Position Mesh packets will be prioritized higher and sent more frequently by default. */
|
||||
meshtastic_Config_DeviceConfig_Role_TRACKER = 5,
|
||||
/* Sensor device role
|
||||
Telemetry Mesh packets will be prioritized higher and sent more frequently by default.
|
||||
When used in conjunction with power.is_power_saving = true, nodes will wake up,
|
||||
send environment telemetry, and then sleep for telemetry.environment_update_interval seconds. */
|
||||
Telemetry Mesh packets will be prioritized higher and sent more frequently by default. */
|
||||
meshtastic_Config_DeviceConfig_Role_SENSOR = 6
|
||||
} meshtastic_Config_DeviceConfig_Role;
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ typedef struct _meshtastic_NodeInfoLite {
|
|||
meshtastic_DeviceMetrics device_metrics;
|
||||
/* local channel index we heard that node on. Only populated if its not the default channel. */
|
||||
uint8_t channel;
|
||||
/* Node number of the node to use as a next hop in order to reach this node. */
|
||||
uint32_t next_hop;
|
||||
/* Last byte of the node number of the node to use as a next hop in order to reach this node. */
|
||||
uint8_t next_hop;
|
||||
} meshtastic_NodeInfoLite;
|
||||
|
||||
/* The on-disk saved channels */
|
||||
|
@ -317,8 +317,8 @@ extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePin_msg;
|
|||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define meshtastic_ChannelFile_size 638
|
||||
#define meshtastic_DeviceState_size 17490
|
||||
#define meshtastic_NodeInfoLite_size 157
|
||||
#define meshtastic_DeviceState_size 17193
|
||||
#define meshtastic_NodeInfoLite_size 154
|
||||
#define meshtastic_NodeRemoteHardwarePin_size 29
|
||||
#define meshtastic_OEMStore_size 3220
|
||||
#define meshtastic_PositionLite_size 28
|
||||
|
|
|
@ -563,12 +563,13 @@ typedef struct _meshtastic_MeshPacket {
|
|||
int32_t rx_rssi;
|
||||
/* Describe if this message is delayed */
|
||||
meshtastic_MeshPacket_Delayed delayed;
|
||||
/* Node number of the node that should be used as the next hop in routing.
|
||||
Only the last byte is sent in the packet header. */
|
||||
uint32_t next_hop;
|
||||
/* Node number of the node that is currently relaying this packet.
|
||||
Only the last byte is sent in the packet header. */
|
||||
uint32_t current_relayer;
|
||||
/* Last byte of the node number of the node that should be used as the next hop in routing. */
|
||||
uint8_t next_hop;
|
||||
/* Last byte of the node number of the node that will relay/relayed this packet. */
|
||||
uint8_t relay_node;
|
||||
/* The hop limit setting of the original transmitter.
|
||||
Useful to determine the amount of hops a packet traveled upon reception, which is this value minus the `hop_limit` with which it arrived. */
|
||||
uint32_t original_hop_limit;
|
||||
} meshtastic_MeshPacket;
|
||||
|
||||
/* The bluetooth to device link:
|
||||
|
@ -864,7 +865,7 @@ extern "C" {
|
|||
#define meshtastic_Data_init_default {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0}
|
||||
#define meshtastic_Waypoint_init_default {0, 0, 0, 0, 0, "", "", 0}
|
||||
#define meshtastic_MqttClientProxyMessage_init_default {"", 0, {{0, {0}}}, 0}
|
||||
#define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0}
|
||||
#define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, 0}
|
||||
#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0}
|
||||
#define meshtastic_MyNodeInfo_init_default {0, 0, 0}
|
||||
#define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN}
|
||||
|
@ -882,7 +883,7 @@ extern "C" {
|
|||
#define meshtastic_Data_init_zero {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0}
|
||||
#define meshtastic_Waypoint_init_zero {0, 0, 0, 0, 0, "", "", 0}
|
||||
#define meshtastic_MqttClientProxyMessage_init_zero {"", 0, {{0, {0}}}, 0}
|
||||
#define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0}
|
||||
#define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN, 0, 0, 0}
|
||||
#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0}
|
||||
#define meshtastic_MyNodeInfo_init_zero {0, 0, 0}
|
||||
#define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN}
|
||||
|
@ -961,7 +962,8 @@ extern "C" {
|
|||
#define meshtastic_MeshPacket_rx_rssi_tag 12
|
||||
#define meshtastic_MeshPacket_delayed_tag 13
|
||||
#define meshtastic_MeshPacket_next_hop_tag 14
|
||||
#define meshtastic_MeshPacket_current_relayer_tag 15
|
||||
#define meshtastic_MeshPacket_relay_node_tag 15
|
||||
#define meshtastic_MeshPacket_original_hop_limit_tag 16
|
||||
#define meshtastic_NodeInfo_num_tag 1
|
||||
#define meshtastic_NodeInfo_user_tag 2
|
||||
#define meshtastic_NodeInfo_position_tag 3
|
||||
|
@ -1118,7 +1120,8 @@ X(a, STATIC, SINGULAR, UENUM, priority, 11) \
|
|||
X(a, STATIC, SINGULAR, INT32, rx_rssi, 12) \
|
||||
X(a, STATIC, SINGULAR, UENUM, delayed, 13) \
|
||||
X(a, STATIC, SINGULAR, UINT32, next_hop, 14) \
|
||||
X(a, STATIC, SINGULAR, UINT32, current_relayer, 15)
|
||||
X(a, STATIC, SINGULAR, UINT32, relay_node, 15) \
|
||||
X(a, STATIC, SINGULAR, UINT32, original_hop_limit, 16)
|
||||
#define meshtastic_MeshPacket_CALLBACK NULL
|
||||
#define meshtastic_MeshPacket_DEFAULT NULL
|
||||
#define meshtastic_MeshPacket_payload_variant_decoded_MSGTYPE meshtastic_Data
|
||||
|
@ -1283,7 +1286,7 @@ extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg;
|
|||
#define meshtastic_DeviceMetadata_size 46
|
||||
#define meshtastic_FromRadio_size 510
|
||||
#define meshtastic_LogRecord_size 81
|
||||
#define meshtastic_MeshPacket_size 333
|
||||
#define meshtastic_MeshPacket_size 334
|
||||
#define meshtastic_MqttClientProxyMessage_size 501
|
||||
#define meshtastic_MyNodeInfo_size 18
|
||||
#define meshtastic_NeighborInfo_size 268
|
||||
|
|
|
@ -69,8 +69,7 @@ typedef enum _meshtastic_PortNum {
|
|||
NOTE: audio frames contain a 3 byte header (0xc0 0xde 0xc2) and a one byte marker for the decompressed bitrate.
|
||||
This marker comes from the 'moduleConfig.audio.bitrate' enum minus one. */
|
||||
meshtastic_PortNum_AUDIO_APP = 9,
|
||||
/* Same as Text Message but originating from Detection Sensor Module.
|
||||
NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9 */
|
||||
/* Same as Text Message but originating from Detection Sensor Module. */
|
||||
meshtastic_PortNum_DETECTION_SENSOR_APP = 10,
|
||||
/* Provides a 'ping' service that replies to any packet it receives.
|
||||
Also serves as a small example module.
|
||||
|
@ -91,8 +90,7 @@ typedef enum _meshtastic_PortNum {
|
|||
ENCODING: Protobuf */
|
||||
meshtastic_PortNum_STORE_FORWARD_APP = 65,
|
||||
/* Optional port for messages for the range test module.
|
||||
ENCODING: ASCII Plaintext
|
||||
NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9 */
|
||||
ENCODING: ASCII Plaintext */
|
||||
meshtastic_PortNum_RANGE_TEST_APP = 66,
|
||||
/* Provides a format to send and receive telemetry data from the Meshtastic network.
|
||||
Maintained by Charles Crossan (crossan007) : crossan007@gmail.com
|
||||
|
|
|
@ -161,7 +161,7 @@ size_t NeighborInfoModule::cleanUpNeighbors()
|
|||
// Clear all next hops of nodes that had this neighbor as next hop
|
||||
for (unsigned int j = 0; j < nodeDB.getNumMeshNodes(); j++) {
|
||||
meshtastic_NodeInfoLite *node = nodeDB.getMeshNodeByIndex(j);
|
||||
if (node->next_hop == neighbors[index].node_id) {
|
||||
if (node->next_hop == (uint8_t)(neighbors[index].node_id & 0xFF)) {
|
||||
node->next_hop = 0;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void NeighborInfoModule::updateNextHops(meshtastic_NeighborInfo *np)
|
|||
meshtastic_NodeInfoLite *currentNode = nodeDB.getMeshNode(np->node_id);
|
||||
// Check if the sender of this neighborInfo packet is a neighbor of ourselves
|
||||
if (currentNode && isANeighbor(np->node_id)) {
|
||||
currentNode->next_hop = np->node_id; // Set the next hop to the sender of this packet
|
||||
currentNode->next_hop = (uint8_t)(np->node_id & 0xFF); // Set the next hop to the sender of this packet
|
||||
for (uint8_t i = 0; i < np->neighbors_count; i++) {
|
||||
if (isANeighbor(np->neighbors[i].node_id))
|
||||
continue; // This node is a neighbor of ourselves
|
||||
|
@ -259,7 +259,7 @@ void NeighborInfoModule::updateNextHops(meshtastic_NeighborInfo *np)
|
|||
meshtastic_NodeInfoLite *neighborOfCurrentNode = nodeDB.getMeshNode(np->neighbors[i].node_id);
|
||||
// Update next hop of this node to the sender of this packet, because it is the most recent neighbor
|
||||
if (neighborOfCurrentNode)
|
||||
neighborOfCurrentNode->next_hop = currentNode->num;
|
||||
neighborOfCurrentNode->next_hop = (uint8_t)(currentNode->num & 0xFF);
|
||||
}
|
||||
} else if (currentNode) { // Sender is not a neighbor
|
||||
// Find common neighbors and use the most recent as next hop to this node
|
||||
|
@ -270,7 +270,7 @@ void NeighborInfoModule::updateNextHops(meshtastic_NeighborInfo *np)
|
|||
if (neighborOfCurrentNode && isANeighbor(neighborOfCurrentNode->num)) {
|
||||
// This neighbor was heard more recently than the current next hop
|
||||
if (neighborOfCurrentNode->last_heard > maxLastHeard) {
|
||||
currentNode->next_hop = neighborOfCurrentNode->num;
|
||||
currentNode->next_hop = (uint8_t)(neighborOfCurrentNode->num & 0xFF);
|
||||
maxLastHeard = neighborOfCurrentNode->last_heard;
|
||||
LOG_DEBUG("More recent node found, so update next_hop of %x to %x\n", currentNode->num,
|
||||
neighborOfCurrentNode->num);
|
||||
|
@ -369,4 +369,4 @@ bool NeighborInfoModule::saveProtoForModule()
|
|||
okay &= nodeDB.saveProto(neighborInfoConfigFile, meshtastic_NeighborInfo_size, &meshtastic_NeighborInfo_msg, &neighborState);
|
||||
|
||||
return okay;
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue