diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 143eea019..4f53a400a 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml @@ -3,6 +3,11 @@ name = "embassy-stm32-wpan" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0" +description = "Async STM32 WPAN stack for embedded devices in Rust." +keywords = ["embedded", "async", "stm32", "ble", "wpan"] +categories = ["embedded", "hardware-support", "no-std", "asynchronous"] +repository = "https://github.com/embassy-rs/embassy" +documentation = "https://docs.embassy.dev/embassy-stm32-wpan" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-wpan-v$VERSION/embassy-stm32-wpan/src/" @@ -29,7 +34,7 @@ aligned = "0.4.1" bit_field = "0.10.2" stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] } -stm32wb-hci = { git = "https://github.com/Dirbaio/stm32wb-hci", rev = "0aff47e009c30c5fc5d520672625173d75f7505c", optional = true } +stm32wb-hci = { version = "0.17.0", optional = true } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } bitflags = { version = "2.3.3", optional = true } diff --git a/embassy-stm32-wpan/README.md b/embassy-stm32-wpan/README.md new file mode 100644 index 000000000..b1a2cec55 --- /dev/null +++ b/embassy-stm32-wpan/README.md @@ -0,0 +1,13 @@ +# embassy-stm32-wpan + +Async WPAN (short range wireless) on STM32WB families. + +## Features + +- Rust interface to the WPAN stack running on the STM32WB co-processor . +- Controller trait implementation for the [stm32wb-hci](https://crates.io/crates/stm32wb-hci) crate. +- Embassy-net driver implementation for 802.15.4 MAC. + +## Examples + +See the [stm32wb examples](https://github.com/embassy-rs/embassy/tree/main/examples/stm32wb). diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index a5dbb7420..f9560d235 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] #![allow(async_fn_in_trait)] +#![doc = include_str!("../README.md")] +// #![warn(missing_docs)] // This must go FIRST so that all the other modules see its macros. mod fmt; diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs index cf9a5aa28..d3b3c15ca 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs @@ -11,11 +11,9 @@ use embassy_stm32::rcc::WPAN_DEFAULT; use embassy_stm32_wpan::hci::host::uart::UartHci; use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; use embassy_stm32_wpan::hci::types::AdvertisingType; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ - AdvertisingDataType, DiscoverableParameters, GapCommands, Role, -}; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; +use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; +use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; +use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; use embassy_stm32_wpan::hci::BdAddr; use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; use embassy_stm32_wpan::TlMbox; diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs index 5ce620350..3b50d6c31 100644 --- a/examples/stm32wb/src/bin/gatt_server.rs +++ b/examples/stm32wb/src/bin/gatt_server.rs @@ -12,17 +12,18 @@ use embassy_stm32_wpan::hci::event::command::{CommandComplete, ReturnParameters} use embassy_stm32_wpan::hci::host::uart::{Packet, UartHci}; use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; use embassy_stm32_wpan::hci::types::AdvertisingType; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ +use embassy_stm32_wpan::hci::vendor::command::gap::{ AddressType, AuthenticationRequirements, DiscoverableParameters, GapCommands, IoCapability, LocalName, Pin, Role, SecureConnectionSupport, }; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::{ +use embassy_stm32_wpan::hci::vendor::command::gatt::{ AddCharacteristicParameters, AddServiceParameters, CharacteristicEvent, CharacteristicPermission, CharacteristicProperty, EncryptionKeySize, GattCommands, ServiceType, UpdateCharacteristicValueParameters, Uuid, WriteResponseParameters, }; -use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; -use embassy_stm32_wpan::hci::vendor::stm32wb::event::{self, AttributeHandle, Stm32Wb5xEvent}; +use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; +use embassy_stm32_wpan::hci::vendor::event::command::VendorReturnParameters; +use embassy_stm32_wpan::hci::vendor::event::{self, AttributeHandle, VendorEvent}; use embassy_stm32_wpan::hci::{BdAddr, Event}; use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; use embassy_stm32_wpan::sub::ble::Ble; @@ -190,11 +191,11 @@ async fn main(_spawner: Spawner) { mbox.ble_subsystem.set_discoverable(&discovery_params).await.unwrap(); } Event::Vendor(vendor_event) => match vendor_event { - Stm32Wb5xEvent::AttReadPermitRequest(read_req) => { + VendorEvent::AttReadPermitRequest(read_req) => { defmt::info!("read request received {}, allowing", read_req); mbox.ble_subsystem.allow_read(read_req.conn_handle).await } - Stm32Wb5xEvent::AttWritePermitRequest(write_req) => { + VendorEvent::AttWritePermitRequest(write_req) => { defmt::info!("write request received {}, allowing", write_req); mbox.ble_subsystem .write_response(&WriteResponseParameters { @@ -206,7 +207,7 @@ async fn main(_spawner: Spawner) { .await .unwrap() } - Stm32Wb5xEvent::GattAttributeModified(attribute) => { + VendorEvent::GattAttributeModified(attribute) => { defmt::info!("{}", ble_context); if attribute.attr_handle.0 == ble_context.chars.notify.0 + 2 { if attribute.data()[0] == 0x01 { @@ -333,7 +334,7 @@ async fn gatt_add_service(ble_subsystem: &mut Ble, uuid: Uuid) -> Result