Skip to content

Commit

Permalink
Clear RSSI/SNR when not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
lukipuki committed May 23, 2024
1 parent 7d3c81e commit 44cd613
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ impl MessageHandler {
}
if let Some(rssi_snr) = log_message.rssi_snr.as_ref() {
status.update_rssi_snr(rssi_snr.clone());
} else {
status.clear_rssi_snr();
}
if let Some((_, battery)) = log_message.voltage_battery.as_ref() {
status.update_battery(*battery);
Expand Down Expand Up @@ -358,5 +360,21 @@ mod test_punch {
let node_infos = handler.node_infos();
assert_eq!(node_infos.len(), 1);
assert_eq!(node_infos[0].rssi_dbm, Some(-98));

let envelope2 = ServiceEnvelope {
packet: Some(MeshPacket {
payload_variant: Some(PayloadVariant::Decoded(data)),
..Default::default()
}),
..Default::default()
};
handler.msh_status_update(
&envelope2.encode_to_vec()[..],
Local::now().fixed_offset(),
None,
);
let node_infos = handler.node_infos();
assert_eq!(node_infos.len(), 1);
assert_eq!(node_infos[0].rssi_dbm, None);
}
}
5 changes: 5 additions & 0 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ impl MeshtasticRocStatus {
self.last_update = Some(Local::now().into());
}

pub fn clear_rssi_snr(&mut self) {
self.rssi_snr = None;
self.last_update = Some(Local::now().into());
}

pub fn punch(&mut self, punch: &SiPunch) {
self.last_punch = Some(punch.time);
self.codes.insert(punch.code);
Expand Down

0 comments on commit 44cd613

Please sign in to comment.