Skip to content

Commit

Permalink
Use no-cca for Acknowledgement frames
Browse files Browse the repository at this point in the history
  • Loading branch information
blueluna committed Jan 5, 2024
1 parent 4935ba4 commit 3092a56
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions psila-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,18 @@ where

/// Push a packet onto the queue
fn queue_packet_from_buffer(&mut self, length: usize) -> Result<(), Error> {
self.queue_packet_from_buffer_no_cca(length, false)
}

/// Push a packet onto the queue
fn queue_packet_from_buffer_no_cca(&mut self, length: usize, no_cca: bool) -> Result<(), Error> {
assert!(length < PACKET_BUFFER_MAX);
const NO_CCA_MARKER: u8 = 0x80;
let marker = if no_cca { NO_CCA_MARKER } else { 0u8 };
let grant_size = length + 1;
match self.tx_queue.grant_exact(grant_size) {
Ok(mut grant) => {
grant[0] = length as u8;
grant[0] = (length as u8) | marker;
grant[1..].copy_from_slice(&self.buffer.borrow()[..length]);
grant.commit(grant_size);
Ok(())
Expand All @@ -212,7 +219,7 @@ where
false,
&mut self.buffer.borrow_mut()[..],
)?;
self.queue_packet_from_buffer(packet_length)?;
self.queue_packet_from_buffer_no_cca(packet_length, true)?;
}
Ok(true)
}
Expand Down

0 comments on commit 3092a56

Please sign in to comment.