Skip to content

Commit

Permalink
Concurrent commissioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Oct 5, 2024
1 parent 945e730 commit f39c387
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
8 changes: 5 additions & 3 deletions examples/light.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! An example utilizing the `WifiBleMatterStack` struct.
//! As the name suggests, this Matter stack assembly uses Wifi as the main transport,
//! and BLE for commissioning.
//! An example utilizing the `WifiMatterStack` struct.
//!
//! As the name suggests, this Matter stack assembly uses Wifi as the main transport
//! (and thus also BLE for commissioning).
//!
//! If you want to use Ethernet, utilize `EthMatterStack` instead.
//!
//! The example implements a fictitious Light device (an On-Off Matter cluster).
Expand Down
37 changes: 34 additions & 3 deletions src/wireless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rs_matter::utils::init::{init, Init};
use rs_matter::utils::select::Coalesce;
use traits::{
ConcurrencyMode, DisconnectedController, Thread, ThreadData, Wifi, WifiData, Wireless,
WirelessConfig, WirelessData,
WirelessConfig, WirelessData, NC,
};

use crate::netif::{Netif, NetifRun};
Expand Down Expand Up @@ -55,8 +55,12 @@ const MAX_WIRELESS_NETWORKS: usize = 2;
/// An implementation of the `Network` trait for a Matter stack running over
/// BLE during commissioning, and then over either WiFi or Thread when operating.
///
/// The supported commissioning is of the non-concurrent type (as per the Matter Core spec),
/// where the device - at any point in time - either runs Bluetooth or Wifi/Thread, but not both.
/// The supported commissioning is either concurrent or non-concurrent (as per the Matter Core spec),
/// where one over the other is decided compile-time with the concrete `WirelessConfig` type.
///
/// Non-concurrent commissioning means that the device - at any point in time - either runs Bluetooth
/// or Wifi/Thread, but not both.
///
/// This is done to save memory and to avoid the usage of BLE+Wifi/Thread co-exist drivers on
/// devices which share a single wireless radio for both BLE and Wifi/Thread.
pub struct WirelessBle<M, T, E = ()>
Expand Down Expand Up @@ -139,9 +143,36 @@ where
}
}

/// A type alias for a Matter stack running over Wifi (and BLE, during commissioning).
pub type WifiMatterStack<'a, M, E> = MatterStack<'a, WirelessBle<M, Wifi, E>>;

/// A type alias for a Matter stack running over Thread (and BLE, during commissioning).
pub type ThreadMatterStack<'a, M, E> = MatterStack<'a, WirelessBle<M, Thread, E>>;

/// A type alias for a Matter stack running over Wifi (and BLE, during commissioning).
///
/// Unlike `WifiMatterStack`, this type alias runs the commissioning in a non-concurrent mode,
/// where the device runs either BLE or Wifi, but not both at the same time.
///
/// This is useful for devices which share a single wireless radio for both BLE and Wifi
/// and do not have BLE+Wifi co-exist drivers, or just to save memory by only having one of
/// the stacks active at any point in time.
///
/// Note that Alexa does not (yet) work with non-concurrent commissioning.
pub type WifiNCMatterStack<'a, M, E> = MatterStack<'a, WirelessBle<M, Wifi<NC>, E>>;

/// A type alias for a Matter stack running over Thread (and BLE, during commissioning).
///
/// Unlike `ThreadMatterStack`, this type alias runs the commissioning in a non-concurrent mode,
/// where the device runs either BLE or Thread, but not both at the same time.
///
/// This is useful for devices which share a single wireless radio for both BLE and Thread
/// and do not have BLE+Thread co-exist drivers, or just to save memory by only having one of
/// the stacks active at any point in time.
///
/// Note that Alexa does not (yet) work with non-concurrent commissioning.
pub type ThreadNCMatterStack<'a, M, E> = MatterStack<'a, WirelessBle<M, Thread<NC>, E>>;

impl<'a, M, T, E> MatterStack<'a, WirelessBle<M, T, E>>
where
M: RawMutex + Send + Sync + 'static,
Expand Down

0 comments on commit f39c387

Please sign in to comment.