diff options
| author | xoviat <[email protected]> | 2023-07-15 19:02:04 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-07-15 19:02:04 -0500 |
| commit | 0b63af33135784c1410dc8667cfefbaa538a1f04 (patch) | |
| tree | d19c89092b928264ff627fc6d695c26f79d0553e | |
| parent | 25197308e3cd9694c37284b49ce1b482e22855ce (diff) | |
wpan: prepare net impl.
| -rw-r--r-- | embassy-net-driver/src/lib.rs | 3 | ||||
| -rw-r--r-- | embassy-net/Cargo.toml | 1 | ||||
| -rw-r--r-- | embassy-net/src/device.rs | 2 | ||||
| -rw-r--r-- | embassy-net/src/lib.rs | 13 | ||||
| -rw-r--r-- | embassy-stm32-wpan/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32wb/Cargo.toml | 3 |
6 files changed, 22 insertions, 3 deletions
diff --git a/embassy-net-driver/src/lib.rs b/embassy-net-driver/src/lib.rs index 4149bf4a4..09def20c4 100644 --- a/embassy-net-driver/src/lib.rs +++ b/embassy-net-driver/src/lib.rs | |||
| @@ -164,6 +164,9 @@ pub enum Medium { | |||
| 164 | /// | 164 | /// |
| 165 | /// Examples of devices of this type are the Linux `tun`, PPP interfaces, VPNs in tun (layer 3) mode. | 165 | /// Examples of devices of this type are the Linux `tun`, PPP interfaces, VPNs in tun (layer 3) mode. |
| 166 | Ip, | 166 | Ip, |
| 167 | |||
| 168 | /// IEEE 802_15_4 medium | ||
| 169 | Ieee802154, | ||
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | impl Default for Medium { | 172 | impl Default for Medium { |
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 6dc429ddc..9b6a11c16 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -37,6 +37,7 @@ proto-ipv4 = ["smoltcp/proto-ipv4"] | |||
| 37 | proto-ipv6 = ["smoltcp/proto-ipv6"] | 37 | proto-ipv6 = ["smoltcp/proto-ipv6"] |
| 38 | medium-ethernet = ["smoltcp/medium-ethernet"] | 38 | medium-ethernet = ["smoltcp/medium-ethernet"] |
| 39 | medium-ip = ["smoltcp/medium-ip"] | 39 | medium-ip = ["smoltcp/medium-ip"] |
| 40 | medium-ieee802154 = ["smoltcp/medium-ieee802154"] | ||
| 40 | igmp = ["smoltcp/proto-igmp"] | 41 | igmp = ["smoltcp/proto-igmp"] |
| 41 | 42 | ||
| 42 | [dependencies] | 43 | [dependencies] |
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs index 4513c86d3..d29ab8970 100644 --- a/embassy-net/src/device.rs +++ b/embassy-net/src/device.rs | |||
| @@ -51,6 +51,8 @@ where | |||
| 51 | Medium::Ethernet => phy::Medium::Ethernet, | 51 | Medium::Ethernet => phy::Medium::Ethernet, |
| 52 | #[cfg(feature = "medium-ip")] | 52 | #[cfg(feature = "medium-ip")] |
| 53 | Medium::Ip => phy::Medium::Ip, | 53 | Medium::Ip => phy::Medium::Ip, |
| 54 | #[cfg(feature = "medium-ieee802154")] | ||
| 55 | Medium::Ieee802154 => phy::Medium::Ieee802154, | ||
| 54 | #[allow(unreachable_patterns)] | 56 | #[allow(unreachable_patterns)] |
| 55 | _ => panic!( | 57 | _ => panic!( |
| 56 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", | 58 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", |
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 0d0a986f6..ad98d7f68 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -24,9 +24,11 @@ use embassy_net_driver::{Driver, LinkState, Medium}; | |||
| 24 | use embassy_sync::waitqueue::WakerRegistration; | 24 | use embassy_sync::waitqueue::WakerRegistration; |
| 25 | use embassy_time::{Instant, Timer}; | 25 | use embassy_time::{Instant, Timer}; |
| 26 | use futures::pin_mut; | 26 | use futures::pin_mut; |
| 27 | #[allow(unused_imports)] | ||
| 27 | use heapless::Vec; | 28 | use heapless::Vec; |
| 28 | #[cfg(feature = "igmp")] | 29 | #[cfg(feature = "igmp")] |
| 29 | pub use smoltcp::iface::MulticastError; | 30 | pub use smoltcp::iface::MulticastError; |
| 31 | #[allow(unused_imports)] | ||
| 30 | use smoltcp::iface::{Interface, SocketHandle, SocketSet, SocketStorage}; | 32 | use smoltcp::iface::{Interface, SocketHandle, SocketSet, SocketStorage}; |
| 31 | #[cfg(feature = "dhcpv4")] | 33 | #[cfg(feature = "dhcpv4")] |
| 32 | use smoltcp::socket::dhcpv4::{self, RetryConfig}; | 34 | use smoltcp::socket::dhcpv4::{self, RetryConfig}; |
| @@ -34,6 +36,8 @@ use smoltcp::socket::dhcpv4::{self, RetryConfig}; | |||
| 34 | pub use smoltcp::wire::IpListenEndpoint; | 36 | pub use smoltcp::wire::IpListenEndpoint; |
| 35 | #[cfg(feature = "medium-ethernet")] | 37 | #[cfg(feature = "medium-ethernet")] |
| 36 | pub use smoltcp::wire::{EthernetAddress, HardwareAddress}; | 38 | pub use smoltcp::wire::{EthernetAddress, HardwareAddress}; |
| 39 | #[cfg(feature = "medium-ieee802154")] | ||
| 40 | pub use smoltcp::wire::{HardwareAddress, Ieee802154Address}; | ||
| 37 | pub use smoltcp::wire::{IpAddress, IpCidr, IpEndpoint}; | 41 | pub use smoltcp::wire::{IpAddress, IpCidr, IpEndpoint}; |
| 38 | #[cfg(feature = "proto-ipv4")] | 42 | #[cfg(feature = "proto-ipv4")] |
| 39 | pub use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; | 43 | pub use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; |
| @@ -232,7 +236,7 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 232 | resources: &'static mut StackResources<SOCK>, | 236 | resources: &'static mut StackResources<SOCK>, |
| 233 | random_seed: u64, | 237 | random_seed: u64, |
| 234 | ) -> Self { | 238 | ) -> Self { |
| 235 | #[cfg(feature = "medium-ethernet")] | 239 | #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] |
| 236 | let medium = device.capabilities().medium; | 240 | let medium = device.capabilities().medium; |
| 237 | 241 | ||
| 238 | let hardware_addr = match medium { | 242 | let hardware_addr = match medium { |
| @@ -240,6 +244,8 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 240 | Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress(device.ethernet_address())), | 244 | Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress(device.ethernet_address())), |
| 241 | #[cfg(feature = "medium-ip")] | 245 | #[cfg(feature = "medium-ip")] |
| 242 | Medium::Ip => HardwareAddress::Ip, | 246 | Medium::Ip => HardwareAddress::Ip, |
| 247 | #[cfg(feature = "medium-ieee802154")] | ||
| 248 | Medium::Ieee802154 => HardwareAddress::Ieee802154(Ieee802154Address::Absent), | ||
| 243 | #[allow(unreachable_patterns)] | 249 | #[allow(unreachable_patterns)] |
| 244 | _ => panic!( | 250 | _ => panic!( |
| 245 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", | 251 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", |
| @@ -262,6 +268,7 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 262 | 268 | ||
| 263 | let next_local_port = (random_seed % (LOCAL_PORT_MAX - LOCAL_PORT_MIN) as u64) as u16 + LOCAL_PORT_MIN; | 269 | let next_local_port = (random_seed % (LOCAL_PORT_MAX - LOCAL_PORT_MIN) as u64) as u16 + LOCAL_PORT_MIN; |
| 264 | 270 | ||
| 271 | #[cfg_attr(feature = "medium-ieee802154", allow(unused_mut))] | ||
| 265 | let mut socket = SocketStack { | 272 | let mut socket = SocketStack { |
| 266 | sockets, | 273 | sockets, |
| 267 | iface, | 274 | iface, |
| @@ -269,6 +276,7 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 269 | next_local_port, | 276 | next_local_port, |
| 270 | }; | 277 | }; |
| 271 | 278 | ||
| 279 | #[cfg_attr(feature = "medium-ieee802154", allow(unused_mut))] | ||
| 272 | let mut inner = Inner { | 280 | let mut inner = Inner { |
| 273 | device, | 281 | device, |
| 274 | link_up: false, | 282 | link_up: false, |
| @@ -287,6 +295,9 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 287 | dns_waker: WakerRegistration::new(), | 295 | dns_waker: WakerRegistration::new(), |
| 288 | }; | 296 | }; |
| 289 | 297 | ||
| 298 | #[cfg(feature = "medium-ieee802154")] | ||
| 299 | let _ = config; | ||
| 300 | |||
| 290 | #[cfg(feature = "proto-ipv4")] | 301 | #[cfg(feature = "proto-ipv4")] |
| 291 | match config.ipv4 { | 302 | match config.ipv4 { |
| 292 | ConfigV4::Static(config) => { | 303 | ConfigV4::Static(config) => { |
diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 868bffe74..082d00f1c 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml | |||
| @@ -17,6 +17,7 @@ embassy-time = { version = "0.1.2", path = "../embassy-time", optional = true } | |||
| 17 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 17 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 18 | embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common" } | 18 | embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common" } |
| 19 | embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } | 19 | embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } |
| 20 | embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel", optional=true } | ||
| 20 | 21 | ||
| 21 | defmt = { version = "0.3", optional = true } | 22 | defmt = { version = "0.3", optional = true } |
| 22 | cortex-m = "0.7.6" | 23 | cortex-m = "0.7.6" |
| @@ -32,7 +33,7 @@ bitflags = { version = "2.3.3", optional = true } | |||
| 32 | defmt = ["dep:defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "stm32wb-hci?/defmt"] | 33 | defmt = ["dep:defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-common/defmt", "stm32wb-hci?/defmt"] |
| 33 | 34 | ||
| 34 | ble = ["dep:stm32wb-hci"] | 35 | ble = ["dep:stm32wb-hci"] |
| 35 | mac = ["dep:bitflags"] | 36 | mac = ["dep:bitflags", "dep:embassy-net-driver-channel"] |
| 36 | 37 | ||
| 37 | stm32wb10cc = [ "embassy-stm32/stm32wb10cc" ] | 38 | stm32wb10cc = [ "embassy-stm32/stm32wb10cc" ] |
| 38 | stm32wb15cc = [ "embassy-stm32/stm32wb15cc" ] | 39 | stm32wb15cc = [ "embassy-stm32/stm32wb15cc" ] |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index becf2d3fb..8585b99f9 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -10,6 +10,7 @@ embassy-executor = { version = "0.2.0", path = "../../embassy-executor", feature | |||
| 10 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } |
| 12 | embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } | 12 | embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } |
| 13 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "medium-ieee802154", "nightly"], optional=true } | ||
| 13 | 14 | ||
| 14 | defmt = "0.3" | 15 | defmt = "0.3" |
| 15 | defmt-rtt = "0.4" | 16 | defmt-rtt = "0.4" |
| @@ -24,7 +25,7 @@ heapless = { version = "0.7.5", default-features = false } | |||
| 24 | 25 | ||
| 25 | [features] | 26 | [features] |
| 26 | default = ["ble", "mac"] | 27 | default = ["ble", "mac"] |
| 27 | mac = ["embassy-stm32-wpan/mac"] | 28 | mac = ["embassy-stm32-wpan/mac", "dep:embassy-net"] |
| 28 | ble = ["embassy-stm32-wpan/ble"] | 29 | ble = ["embassy-stm32-wpan/ble"] |
| 29 | 30 | ||
| 30 | [[bin]] | 31 | [[bin]] |
