diff options
| author | Ulf Lilleengen <[email protected]> | 2024-01-12 08:33:35 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-12 08:33:35 +0000 |
| commit | 131ef00658903420fb08e4666c01d93c3b5fd943 (patch) | |
| tree | eb2f1d8fa6e5ac1ada73a97007285417195de349 | |
| parent | e5a51a1ad59cbac83315a9a25c4773ac84eb6819 (diff) | |
| parent | 7728c95584bb049b64507c458ba47455d4633396 (diff) | |
Merge pull request #2440 from embassy-rs/remove-git-dep
fix: use released version for stm32wb-hci
| -rw-r--r-- | embassy-stm32-wpan/Cargo.toml | 7 | ||||
| -rw-r--r-- | embassy-stm32-wpan/README.md | 13 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lib.rs | 2 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/eddystone_beacon.rs | 8 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/gatt_server.rs | 26 | ||||
| -rw-r--r-- | tests/stm32/src/bin/wpan_ble.rs | 8 |
6 files changed, 40 insertions, 24 deletions
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" | |||
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Async STM32 WPAN stack for embedded devices in Rust." | ||
| 7 | keywords = ["embedded", "async", "stm32", "ble", "wpan"] | ||
| 8 | categories = ["embedded", "hardware-support", "no-std", "asynchronous"] | ||
| 9 | repository = "https://github.com/embassy-rs/embassy" | ||
| 10 | documentation = "https://docs.embassy.dev/embassy-stm32-wpan" | ||
| 6 | 11 | ||
| 7 | [package.metadata.embassy_docs] | 12 | [package.metadata.embassy_docs] |
| 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-wpan-v$VERSION/embassy-stm32-wpan/src/" | 13 | 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" | |||
| 29 | 34 | ||
| 30 | bit_field = "0.10.2" | 35 | bit_field = "0.10.2" |
| 31 | stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] } | 36 | stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] } |
| 32 | stm32wb-hci = { git = "https://github.com/Dirbaio/stm32wb-hci", rev = "0aff47e009c30c5fc5d520672625173d75f7505c", optional = true } | 37 | stm32wb-hci = { version = "0.17.0", optional = true } |
| 33 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 38 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 34 | bitflags = { version = "2.3.3", optional = true } | 39 | bitflags = { version = "2.3.3", optional = true } |
| 35 | 40 | ||
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 @@ | |||
| 1 | # embassy-stm32-wpan | ||
| 2 | |||
| 3 | Async WPAN (short range wireless) on STM32WB families. | ||
| 4 | |||
| 5 | ## Features | ||
| 6 | |||
| 7 | - Rust interface to the WPAN stack running on the STM32WB co-processor . | ||
| 8 | - Controller trait implementation for the [stm32wb-hci](https://crates.io/crates/stm32wb-hci) crate. | ||
| 9 | - Embassy-net driver implementation for 802.15.4 MAC. | ||
| 10 | |||
| 11 | ## Examples | ||
| 12 | |||
| 13 | 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 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![doc = include_str!("../README.md")] | ||
| 4 | // #![warn(missing_docs)] | ||
| 3 | 5 | ||
| 4 | // This must go FIRST so that all the other modules see its macros. | 6 | // This must go FIRST so that all the other modules see its macros. |
| 5 | mod fmt; | 7 | 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; | |||
| 11 | use embassy_stm32_wpan::hci::host::uart::UartHci; | 11 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 12 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 12 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 13 | use embassy_stm32_wpan::hci::types::AdvertisingType; | 13 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 14 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ | 14 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; |
| 15 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 15 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; |
| 16 | }; | 16 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 17 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; | ||
| 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | ||
| 19 | use embassy_stm32_wpan::hci::BdAddr; | 17 | use embassy_stm32_wpan::hci::BdAddr; |
| 20 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 18 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 21 | use embassy_stm32_wpan::TlMbox; | 19 | 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} | |||
| 12 | use embassy_stm32_wpan::hci::host::uart::{Packet, UartHci}; | 12 | use embassy_stm32_wpan::hci::host::uart::{Packet, UartHci}; |
| 13 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 13 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 14 | use embassy_stm32_wpan::hci::types::AdvertisingType; | 14 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 15 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ | 15 | use embassy_stm32_wpan::hci::vendor::command::gap::{ |
| 16 | AddressType, AuthenticationRequirements, DiscoverableParameters, GapCommands, IoCapability, LocalName, Pin, Role, | 16 | AddressType, AuthenticationRequirements, DiscoverableParameters, GapCommands, IoCapability, LocalName, Pin, Role, |
| 17 | SecureConnectionSupport, | 17 | SecureConnectionSupport, |
| 18 | }; | 18 | }; |
| 19 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::{ | 19 | use embassy_stm32_wpan::hci::vendor::command::gatt::{ |
| 20 | AddCharacteristicParameters, AddServiceParameters, CharacteristicEvent, CharacteristicPermission, | 20 | AddCharacteristicParameters, AddServiceParameters, CharacteristicEvent, CharacteristicPermission, |
| 21 | CharacteristicProperty, EncryptionKeySize, GattCommands, ServiceType, UpdateCharacteristicValueParameters, Uuid, | 21 | CharacteristicProperty, EncryptionKeySize, GattCommands, ServiceType, UpdateCharacteristicValueParameters, Uuid, |
| 22 | WriteResponseParameters, | 22 | WriteResponseParameters, |
| 23 | }; | 23 | }; |
| 24 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | 24 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 25 | use embassy_stm32_wpan::hci::vendor::stm32wb::event::{self, AttributeHandle, Stm32Wb5xEvent}; | 25 | use embassy_stm32_wpan::hci::vendor::event::command::VendorReturnParameters; |
| 26 | use embassy_stm32_wpan::hci::vendor::event::{self, AttributeHandle, VendorEvent}; | ||
| 26 | use embassy_stm32_wpan::hci::{BdAddr, Event}; | 27 | use embassy_stm32_wpan::hci::{BdAddr, Event}; |
| 27 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 28 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 28 | use embassy_stm32_wpan::sub::ble::Ble; | 29 | use embassy_stm32_wpan::sub::ble::Ble; |
| @@ -190,11 +191,11 @@ async fn main(_spawner: Spawner) { | |||
| 190 | mbox.ble_subsystem.set_discoverable(&discovery_params).await.unwrap(); | 191 | mbox.ble_subsystem.set_discoverable(&discovery_params).await.unwrap(); |
| 191 | } | 192 | } |
| 192 | Event::Vendor(vendor_event) => match vendor_event { | 193 | Event::Vendor(vendor_event) => match vendor_event { |
| 193 | Stm32Wb5xEvent::AttReadPermitRequest(read_req) => { | 194 | VendorEvent::AttReadPermitRequest(read_req) => { |
| 194 | defmt::info!("read request received {}, allowing", read_req); | 195 | defmt::info!("read request received {}, allowing", read_req); |
| 195 | mbox.ble_subsystem.allow_read(read_req.conn_handle).await | 196 | mbox.ble_subsystem.allow_read(read_req.conn_handle).await |
| 196 | } | 197 | } |
| 197 | Stm32Wb5xEvent::AttWritePermitRequest(write_req) => { | 198 | VendorEvent::AttWritePermitRequest(write_req) => { |
| 198 | defmt::info!("write request received {}, allowing", write_req); | 199 | defmt::info!("write request received {}, allowing", write_req); |
| 199 | mbox.ble_subsystem | 200 | mbox.ble_subsystem |
| 200 | .write_response(&WriteResponseParameters { | 201 | .write_response(&WriteResponseParameters { |
| @@ -206,7 +207,7 @@ async fn main(_spawner: Spawner) { | |||
| 206 | .await | 207 | .await |
| 207 | .unwrap() | 208 | .unwrap() |
| 208 | } | 209 | } |
| 209 | Stm32Wb5xEvent::GattAttributeModified(attribute) => { | 210 | VendorEvent::GattAttributeModified(attribute) => { |
| 210 | defmt::info!("{}", ble_context); | 211 | defmt::info!("{}", ble_context); |
| 211 | if attribute.attr_handle.0 == ble_context.chars.notify.0 + 2 { | 212 | if attribute.attr_handle.0 == ble_context.chars.notify.0 + 2 { |
| 212 | if attribute.data()[0] == 0x01 { | 213 | if attribute.data()[0] == 0x01 { |
| @@ -333,7 +334,7 @@ async fn gatt_add_service(ble_subsystem: &mut Ble, uuid: Uuid) -> Result<Attribu | |||
| 333 | 334 | ||
| 334 | if let Ok(Packet::Event(Event::CommandComplete(CommandComplete { | 335 | if let Ok(Packet::Event(Event::CommandComplete(CommandComplete { |
| 335 | return_params: | 336 | return_params: |
| 336 | ReturnParameters::Vendor(event::command::ReturnParameters::GattAddService(event::command::GattService { | 337 | ReturnParameters::Vendor(VendorReturnParameters::GattAddService(event::command::GattService { |
| 337 | service_handle, | 338 | service_handle, |
| 338 | .. | 339 | .. |
| 339 | })), | 340 | })), |
| @@ -370,11 +371,10 @@ async fn gatt_add_char( | |||
| 370 | 371 | ||
| 371 | if let Ok(Packet::Event(Event::CommandComplete(CommandComplete { | 372 | if let Ok(Packet::Event(Event::CommandComplete(CommandComplete { |
| 372 | return_params: | 373 | return_params: |
| 373 | ReturnParameters::Vendor(event::command::ReturnParameters::GattAddCharacteristic( | 374 | ReturnParameters::Vendor(VendorReturnParameters::GattAddCharacteristic(event::command::GattCharacteristic { |
| 374 | event::command::GattCharacteristic { | 375 | characteristic_handle, |
| 375 | characteristic_handle, .. | 376 | .. |
| 376 | }, | 377 | })), |
| 377 | )), | ||
| 378 | .. | 378 | .. |
| 379 | }))) = response | 379 | }))) = response |
| 380 | { | 380 | { |
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; | |||
| 15 | use embassy_stm32_wpan::hci::host::uart::UartHci; | 15 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 16 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 16 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 17 | use embassy_stm32_wpan::hci::types::AdvertisingType; | 17 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ | 18 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; |
| 19 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 19 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; |
| 20 | }; | 20 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 21 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; | ||
| 22 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | ||
| 23 | use embassy_stm32_wpan::hci::BdAddr; | 21 | use embassy_stm32_wpan::hci::BdAddr; |
| 24 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 22 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 25 | use embassy_stm32_wpan::sub::mm; | 23 | use embassy_stm32_wpan::sub::mm; |
