From 08126d181a494e80bdd0e495f157445e15cfeb23 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 12 Jan 2024 07:01:43 +0100 Subject: [PATCH 1/6] fix: use released version for stm32wb-hci --- embassy-stm32-wpan/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 143eea019..ef85ecac8 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml @@ -29,7 +29,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 } From 883b923fafc41a23c2ae7a3d26b93992e2726523 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 12 Jan 2024 08:33:37 +0100 Subject: [PATCH 2/6] fix: update after api change --- examples/stm32wb/src/bin/eddystone_beacon.rs | 8 +++---- examples/stm32wb/src/bin/gatt_server.rs | 25 ++++++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) 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..0dfe0ed09 100644 --- a/examples/stm32wb/src/bin/gatt_server.rs +++ b/examples/stm32wb/src/bin/gatt_server.rs @@ -12,17 +12,17 @@ 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::{self, command::VendorReturnParameters, AttributeHandle, VendorEvent}; use embassy_stm32_wpan::hci::{BdAddr, Event}; use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; use embassy_stm32_wpan::sub::ble::Ble; @@ -190,11 +190,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 +206,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 +333,7 @@ async fn gatt_add_service(ble_subsystem: &mut Ble, uuid: Uuid) -> Result Date: Fri, 12 Jan 2024 09:17:26 +0100 Subject: [PATCH 3/6] docs: add readme --- embassy-stm32-wpan/Cargo.toml | 5 +++++ embassy-stm32-wpan/src/lib.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index ef85ecac8..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/" 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; From a40186f3cb96feab245f5682311bb72e24b67e83 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 12 Jan 2024 09:21:51 +0100 Subject: [PATCH 4/6] fix: add missing file --- embassy-stm32-wpan/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 embassy-stm32-wpan/README.md 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). From f23182a71009a2655fdeba1ea98b9e1db9dd15cc Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 12 Jan 2024 09:22:16 +0100 Subject: [PATCH 5/6] fix: rustfmt --- examples/stm32wb/src/bin/gatt_server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs index 0dfe0ed09..3b50d6c31 100644 --- a/examples/stm32wb/src/bin/gatt_server.rs +++ b/examples/stm32wb/src/bin/gatt_server.rs @@ -22,7 +22,8 @@ use embassy_stm32_wpan::hci::vendor::command::gatt::{ WriteResponseParameters, }; use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; -use embassy_stm32_wpan::hci::vendor::event::{self, command::VendorReturnParameters, AttributeHandle, VendorEvent}; +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; From 7728c95584bb049b64507c458ba47455d4633396 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 12 Jan 2024 09:28:54 +0100 Subject: [PATCH 6/6] fix changed import paths --- tests/stm32/src/bin/wpan_ble.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index ff838471b..82a540d45 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs @@ -15,11 +15,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::sub::mm;