Skip to content
Snippets Groups Projects
Commit bbf5eb79 authored by Stephen D's avatar Stephen D
Browse files

print rssi

parent 82bc3c41
No related branches found
No related tags found
No related merge requests found
...@@ -119,7 +119,7 @@ pub async fn packet_handler( ...@@ -119,7 +119,7 @@ pub async fn packet_handler(
.context("Packet receive channel died")?; .context("Packet receive channel died")?;
let mut buf = [0; MAX_PACKET_LEN]; let mut buf = [0; MAX_PACKET_LEN];
if let Ok(mut packet) = attempt_decode(&packet, &mut buf) { if let Ok(mut packet) = attempt_decode(&packet, &mut buf, rssi) {
let mut buf2 = [0; MAX_PACKET_LEN]; let mut buf2 = [0; MAX_PACKET_LEN];
let mut internet_packet = packet.clone_backing(&mut buf2); let mut internet_packet = packet.clone_backing(&mut buf2);
match append_internet_to_packet_route(&callsign, ssid, rssi, &mut internet_packet) { match append_internet_to_packet_route(&callsign, ssid, rssi, &mut internet_packet) {
...@@ -250,7 +250,7 @@ pub async fn felinet_receive_once( ...@@ -250,7 +250,7 @@ pub async fn felinet_receive_once(
.and_then(|_| Packet::semi_decode(buf).ok()) .and_then(|_| Packet::semi_decode(buf).ok())
{ {
if pkt.should_digipeat(callsign, ssid).is_ok() { if pkt.should_digipeat(callsign, ssid).is_ok() {
print_packet(&pkt, false); print_packet(&pkt, None);
let mut buf2 = [0; MAX_PACKET_LEN]; let mut buf2 = [0; MAX_PACKET_LEN];
let mut data = Buffer::new_empty(&mut buf2); let mut data = Buffer::new_empty(&mut buf2);
......
...@@ -6,15 +6,20 @@ use ham_cats::{ ...@@ -6,15 +6,20 @@ use ham_cats::{
whisker::{Route, RouteIdentity, RouteNode}, whisker::{Route, RouteIdentity, RouteNode},
}; };
pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, is_rf: bool) { pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, rssi: Option<f64>) {
let color = if is_rf { println!();
println!("----- RF -----");
Color::Green let color = match rssi {
} else { Some(rssi) => {
println!("--- FELINET ---"); println!("----- RF [{rssi} dBm] -----");
Color::Green
}
None => {
println!("--- FELINET ---");
Color::Magenta Color::Magenta
}
}; };
if let Some(ident) = pkt.identification() { if let Some(ident) = pkt.identification() {
...@@ -35,7 +40,11 @@ pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, is_rf: bool) { ...@@ -35,7 +40,11 @@ pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, is_rf: bool) {
let s = if ident.is_future() { "*" } else { "" }; let s = if ident.is_future() { "*" } else { "" };
let rc = ident.callsign(); let rc = ident.callsign();
let rs = ident.ssid(); let rs = ident.ssid();
format!("{rc}-{rs}{s}") let rssi = match ident.rssi() {
Some(x) => format!("[{x:.1} dbm]"),
None => "".to_string(),
};
format!("{rc}-{rs}{s} {rssi}")
} }
}) })
.collect::<Vec<String>>() .collect::<Vec<String>>()
...@@ -62,17 +71,17 @@ pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, is_rf: bool) { ...@@ -62,17 +71,17 @@ pub fn print_packet(pkt: &Packet<MAX_PACKET_LEN>, is_rf: bool) {
gps.heading() gps.heading()
); );
} }
println!();
} }
pub fn attempt_decode<'a>( pub fn attempt_decode<'a>(
packet: &[u8], packet: &[u8],
buf: &'a mut [u8; MAX_PACKET_LEN], buf: &'a mut [u8; MAX_PACKET_LEN],
rssi: f64,
) -> anyhow::Result<Packet<'a, MAX_PACKET_LEN>> { ) -> anyhow::Result<Packet<'a, MAX_PACKET_LEN>> {
let packet: Packet<MAX_PACKET_LEN> = let packet: Packet<MAX_PACKET_LEN> =
Packet::fully_decode(packet, buf).map_err(|e| anyhow!("Could not decode packet: {e:?}"))?; Packet::fully_decode(packet, buf).map_err(|e| anyhow!("Could not decode packet: {e:?}"))?;
print_packet(&packet, true); print_packet(&packet, Some(rssi));
Ok(packet) Ok(packet)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment