Expand description
§embassy-net
embassy-net is a no-std no-alloc async network stack, designed for embedded systems.
It builds on smoltcp. It provides a higher-level and more opinionated
API. It glues together the components provided by smoltcp, handling the low-level details with defaults and
memory management designed to work well for embedded systems, aiming for a more “Just Works” experience.
§Features
- IPv4, IPv6
- Ethernet and bare-IP mediums.
- TCP, UDP, DNS, DHCPv4
- TCP sockets implement the
embedded-ioasync traits. - Multicast
See the smoltcp README for a detailed list of implemented and
unimplemented features of the network protocols.
§Hardware support
esp-wififor WiFi support on bare-metal ESP32 chips. Maintained by Espressif.cyw43for WiFi on CYW43xx chips, used in the Raspberry Pi Pico Wembassy-usbfor Ethernet-over-USB (CDC NCM) support.embassy-stm32for the builtin Ethernet MAC in all STM32 chips (STM32F1, STM32F2, STM32F4, STM32F7, STM32H7, STM32H5).embassy-net-wiznetfor Wiznet SPI Ethernet MAC+PHY chips (W5100S, W5500)embassy-net-esp-hostedfor using ESP32 chips with theesp-hostedfirmware as WiFi adapters for another non-ESP32 MCU.embassy-nrffor IEEE 802.15.4 support on nrf chips.
§Examples
- For usage with Embassy HALs and network chip drivers, search here for
ethorwifi. - The
esp-wifirepo has examples for use on bare-metal ESP32 chips. - For usage on
stdplatforms, see thestdexamples
§Adding support for new hardware
To add embassy-net support for new hardware (i.e. a new Ethernet or WiFi chip, or
an Ethernet/WiFi MCU peripheral), you have to implement the embassy-net-driver
traits.
Alternatively, embassy-net-driver-channel provides a higher-level API
to construct a driver that processes packets in its own background task and communicates with the embassy-net task via
packet queues for RX and TX.
Drivers should depend only on embassy-net-driver or embassy-net-driver-channel. Never on the main embassy-net crate.
This allows existing drivers to continue working for newer embassy-net major versions, without needing an update, if the driver
trait has not had breaking changes.
§Interoperability
This crate can run on any executor.
embassy-time is used for timekeeping and timeouts. You must
link an embassy-time driver in your project to use this crate.
§Feature flags
defmt— Enable defmtlog— Enable logpacket-trace— Trace all raw received and transmitted packets using defmt or log.
Many of the following feature flags are re-exports of smoltcp feature flags. See the smoltcp feature flag documentation for more details
icmp— Enable ICMP supportudp— Enable UDP supportraw— Enable Raw supporttcp— Enable TCP supportdns— Enable DNS supportmdns— Enable mDNS supportdhcpv4— Enable DHCPv4 supportdhcpv4-hostname— Enable DHCPv4 support with hostnameproto-ipv4— Enable IPv4 supportproto-ipv6— Enable IPv6 supportmedium-ethernet— Enable the Ethernet mediummedium-ip— Enable the IP mediummedium-ieee802154— Enable the IEEE 802.15.4 mediummulticast— Enable multicast support (for both ipv4 and/or ipv6 if enabled)std— Enable smoltcp std feature (necessary if using “managed” crate std feature)alloc— Enable smoltcp alloc feature (necessary if using “managed” crate alloc feature)
Re-exports§
pub use embassy_net_driver as driver;
Modules§
- dns
- DNS client compatible with the
embedded-nal-asynctraits. - icmp
- ICMP sockets.
- raw
- Raw sockets.
- tcp
- TCP sockets.
- udp
- UDP sockets.
Structs§
- Config
- Network stack configuration.
- Dhcp
Config - DHCP configuration.
- Ethernet
Address - A six-octet Ethernet II address.
- Ieee802154
Frame - A read/write wrapper around an IEEE 802.15.4 frame buffer.
- IpEndpoint
- An internet endpoint address.
- IpListen
Endpoint - An internet endpoint address for listening.
- Ipv4
Address - An IPv4 address.
- Ipv4
Cidr - A specification of an IPv4 CIDR block, containing an address and a variable-length subnet masking prefix length.
- Ipv6
Address - An IPv6 address.
- Ipv6
Cidr - A specification of an IPv6 CIDR block, containing an address and a variable-length subnet masking prefix length.
- Runner
- Network stack runner.
- Stack
- Network stack handle
- Stack
Resources - Memory resources needed for a network stack.
- Static
Config V4 - Static IP address configuration.
- Static
Config V6 - Static IPv6 address configuration
Enums§
- Config
V4 - Network stack IPv4 configuration.
- Config
V6 - Network stack IPv6 configuration.
- Hardware
Address - Representation of an hardware address, such as an Ethernet address or an IEEE802.15.4 address.
- Ieee802154
Address - A IEEE 802.15.4 address.
- IpAddress
- An internetworking address.
- IpCidr
- A specification of a CIDR block, containing an address and a variable-length subnet masking prefix length.
- Multicast
Error - Error type for
join_multicast_group,leave_multicast_group.
Constants§
Functions§
- new
- Create a new network stack.