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

tx garbage at the start of a packet burst to give the AGC time to calibrate

parent ba9fbb33
No related branches found
No related tags found
No related merge requests found
Pipeline #2065 failed
......@@ -23,6 +23,7 @@ mod app {
use ringbuffer::{ConstGenericRingBuffer, RingBuffer, RingBufferRead, RingBufferWrite};
use crate::packet::Packet;
use crate::packet::PACKET_LEN;
// in # packets
const BUFFER_LEN: usize = 50;
......@@ -139,14 +140,28 @@ mod app {
#[idle(local=[radio], shared=[tx_buf, radio_temp])]
fn idle(mut ctx: idle::Context) -> ! {
let mut i = 0;
let mut iterations_since_last_packet = 0;
loop {
if let Some(mut pkt) = ctx.shared.tx_buf.lock(|buf| buf.dequeue()) {
if iterations_since_last_packet >= 1000 {
// if we haven't transmitted in a while, the receiver's AGC is going to be messed up
// send 5 packets just so it can calibrate before we actually send it
for _ in 0..5 {
const GARBAGE: [u8; PACKET_LEN] = [0x00; PACKET_LEN];
ctx.local.radio.tx(&mut GARBAGE.clone()).unwrap();
}
}
ctx.local.radio.tx(&mut pkt.data).unwrap();
iterations_since_last_packet = 0;
} else {
iterations_since_last_packet += 1;
}
i += 1;
// get temp every 500 packets, or whenever when idle TODO
// get temp every 500 packets, or whenever when idle
if i >= 500 {
i = 0;
......
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