fix(mesh): set Meshtastic hop limit and show LoRa pill

This commit is contained in:
archipelago
2026-06-30 05:59:53 -04:00
parent c2c4b5af7d
commit a91814641e
2 changed files with 27 additions and 3 deletions
+25 -1
View File
@@ -856,8 +856,22 @@ fn packet_to_inbound_frame(
contacts: &mut HashMap<u32, ParsedContact>,
peer_pubkeys: &mut HashMap<u32, Vec<u8>>,
) -> Option<InboundFrame> {
let packet = parse_mesh_packet(data)?;
let Some(packet) = parse_mesh_packet(data) else {
debug!(
len = data.len(),
head = %hex::encode(&data[..data.len().min(16)]),
"Meshtastic FromRadio.packet did not parse into a decoded MeshPacket"
);
return None;
};
if packet.portnum != TEXT_MESSAGE_APP || packet.payload.is_empty() {
debug!(
from = ?packet.from.map(|n| format!("!{:08x}", n)),
portnum = packet.portnum,
payload_len = packet.payload.len(),
pki = packet.pki_encrypted,
"Meshtastic packet ignored because it is not a text payload"
);
return None;
}
if packet_is_stale(packet.rx_time) {
@@ -870,6 +884,10 @@ fn packet_to_inbound_frame(
}
let from = packet.from.unwrap_or(0);
if Some(from) == local_node_num {
debug!(
from = format!("!{:08x}", from),
"Ignoring Meshtastic local echo packet"
);
return None;
}
info!(
@@ -1132,6 +1150,12 @@ fn encode_mesh_packet(to: u32, portnum: u32, payload: &[u8]) -> Vec<u8> {
encode_len_field(4, &decoded, &mut packet);
encode_fixed32_field(6, next_packet_id(), &mut packet);
encode_fixed32_field(7, now_unix_secs(), &mut packet);
// Meshtastic treats an unset hop_limit as zero, i.e. direct-neighbor only.
// Set a normal mesh hop limit so stock-device DMs can route beyond one hop.
encode_varint_field_into(9, 3, &mut packet);
if to != BROADCAST_NUM {
encode_varint_field_into(10, 1, &mut packet);
}
packet
}