Skip to main content

NetworkProviderHal

Trait NetworkProviderHal 

Source
pub trait NetworkProviderHal {
    // Required method
    fn bring_up(
        &mut self,
    ) -> impl Future<Output = Result<Stack<'static>, HalError>>;
}
Expand description

A platform that can bring up a network interface.

This is the generic cut beneath crate::WifiHal: it says nothing about what radio (if any) is attached and only promises to hand back an embassy_net::Stack that is up and usable. Implementations may be backed by built-in WiFi, an externally connected module (SDIO/SPI/USB WiFi, ATWINC, cyw43, ESP-AT companion, CDC-NCM over USB), or a wired Ethernet PHY.

Transport-specific configuration happens through the extended trait for that transport (for WiFi, see crate::WifiHal::configure_ap). Call those configuration methods first, then Self::bring_up.

§Example

ⓘ
async fn start<N: NetworkProviderHal>(net: &mut N) -> Result<Stack<'static>, HalError> {
    net.bring_up().await
}

Required Methods§

Source

fn bring_up(&mut self) -> impl Future<Output = Result<Stack<'static>, HalError>>

Bring the network interface up and wait for the link to become ready.

Returns an embassy_net::Stack that is ready to open sockets on. Implementations typically spawn their driver tasks on the embassy executor during this call.

§Errors

Returns HalError::Wifi (or a future transport-specific variant) on link-up, DHCP, or driver-init failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§