mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 14:53:03 +00:00
net: Add features for pool size and remove unwrap on smoltcp device
This commit is contained in:
parent
6cecc6d4b5
commit
3396a51938
@ -5,6 +5,7 @@ authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["pool-4"]
|
||||||
std = []
|
std = []
|
||||||
defmt-trace = []
|
defmt-trace = []
|
||||||
defmt-debug = []
|
defmt-debug = []
|
||||||
@ -17,6 +18,11 @@ dhcpv4 = ["medium-ethernet", "smoltcp/socket-dhcpv4"]
|
|||||||
medium-ethernet = ["smoltcp/medium-ethernet"]
|
medium-ethernet = ["smoltcp/medium-ethernet"]
|
||||||
medium-ip = ["smoltcp/medium-ip"]
|
medium-ip = ["smoltcp/medium-ip"]
|
||||||
|
|
||||||
|
pool-4 = []
|
||||||
|
pool-8 = []
|
||||||
|
pool-16 = []
|
||||||
|
pool-32 = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
defmt = { version = "0.2.0", optional = true }
|
defmt = { version = "0.2.0", optional = true }
|
||||||
|
@ -43,8 +43,8 @@ impl<'a> SmolDevice<'a> for DeviceAdapter {
|
|||||||
type TxToken = TxToken<'a>;
|
type TxToken = TxToken<'a>;
|
||||||
|
|
||||||
fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> {
|
fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> {
|
||||||
|
let tx_pkt = PacketBox::new(Packet::new())?;
|
||||||
let rx_pkt = self.device.receive()?;
|
let rx_pkt = self.device.receive()?;
|
||||||
let tx_pkt = PacketBox::new(Packet::new()).unwrap(); // TODO: not sure about unwrap
|
|
||||||
let rx_token = RxToken { pkt: rx_pkt };
|
let rx_token = RxToken { pkt: rx_pkt };
|
||||||
let tx_token = TxToken {
|
let tx_token = TxToken {
|
||||||
device: self.device,
|
device: self.device,
|
||||||
|
@ -4,8 +4,19 @@ use core::ops::{Deref, DerefMut, Range};
|
|||||||
use atomic_pool::{pool, Box};
|
use atomic_pool::{pool, Box};
|
||||||
|
|
||||||
pub const MTU: usize = 1516;
|
pub const MTU: usize = 1516;
|
||||||
|
|
||||||
|
#[cfg(feature = "pool-4")]
|
||||||
pub const PACKET_POOL_SIZE: usize = 4;
|
pub const PACKET_POOL_SIZE: usize = 4;
|
||||||
|
|
||||||
|
#[cfg(feature = "pool-8")]
|
||||||
|
pub const PACKET_POOL_SIZE: usize = 8;
|
||||||
|
|
||||||
|
#[cfg(feature = "pool-16")]
|
||||||
|
pub const PACKET_POOL_SIZE: usize = 16;
|
||||||
|
|
||||||
|
#[cfg(feature = "pool-32")]
|
||||||
|
pub const PACKET_POOL_SIZE: usize = 32;
|
||||||
|
|
||||||
pool!(pub PacketPool: [Packet; PACKET_POOL_SIZE]);
|
pool!(pub PacketPool: [Packet; PACKET_POOL_SIZE]);
|
||||||
pub type PacketBox = Box<PacketPool>;
|
pub type PacketBox = Box<PacketPool>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user