From b40299538a73d25d096d8f58f1468cd7f647a3f9 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 7 Jan 2024 17:43:05 +0100 Subject: Add first iteration of send page, and fake-radio --- src/radio.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/radio.rs') diff --git a/src/radio.rs b/src/radio.rs index 77f7c0f..239685f 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -20,14 +20,14 @@ pub const MAX_PACKET_LEN: usize = 8191; pub struct RadioManager { radio: Rf4463, - tx: Sender<(Vec, f64)>, - rx: Receiver>, + receive_queue: Sender<(Vec, f64)>, + transmit_queue: Receiver>, rx_buf: [u8; MAX_PACKET_LEN], temperature: Arc>, } impl RadioManager { - pub fn new(tx: Sender<(Vec, f64)>, rx: Receiver>) -> anyhow::Result { + pub fn new(receive_queue: Sender<(Vec, f64)>, transmit_queue: Receiver>) -> anyhow::Result { let spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 1_000_000, Mode::Mode0)?; let gpio = Gpio::new()?; let sdn = gpio.get(22)?.into_output(); @@ -44,8 +44,8 @@ impl RadioManager { Ok(Self { radio, - tx, - rx, + receive_queue, + transmit_queue, rx_buf, temperature, }) @@ -65,13 +65,13 @@ impl RadioManager { *self.temperature.lock().await = self.radio.get_temp()?; - match self.rx.try_recv() { + match self.transmit_queue.try_recv() { Ok(pkt) => { self.tx(&pkt).await?; } Err(TryRecvError::Empty) => {} Err(TryRecvError::Disconnected) => { - bail!("RX channel disconnected") + bail!("TX channel disconnected") } } @@ -101,11 +101,11 @@ impl RadioManager { .start_rx(None, false) .map_err(|e| anyhow!("{e}"))?; - self.tx + self.receive_queue .send((data.data().to_vec(), data.rssi())) .await .ok() - .context("TX channel died")?; + .context("RX channel died")?; } Ok(()) -- cgit v1.2.3