use rs_matter_stack::matter::utils::init::{init, Init};
use rs_matter_stack::network::Embedding;
use rs_matter_stack::wireless::WirelessBle;
use rs_matter_stack::MatterStack;
use crate::ble::EspBtpGattContext;
#[cfg(all(
esp_idf_comp_openthread_enabled,
esp_idf_openthread_enabled,
esp_idf_soc_ieee802154_supported,
esp_idf_comp_vfs_enabled,
))]
pub use thread::*;
#[cfg(all(esp_idf_comp_esp_wifi_enabled, not(esp32h2)))]
pub use wifi::*;
#[cfg(all(
esp_idf_comp_openthread_enabled,
esp_idf_openthread_enabled,
esp_idf_soc_ieee802154_supported,
esp_idf_comp_vfs_enabled,
))]
mod thread;
#[cfg(all(esp_idf_comp_esp_wifi_enabled, not(esp32h2)))]
mod wifi;
pub type EspWirelessMatterStack<'a, const B: usize, T, E> =
MatterStack<'a, B, EspWirelessBle<T, E>>;
pub type EspWirelessBle<T, E> = WirelessBle<T, EspGatt<E>>;
pub struct EspGatt<E = ()> {
btp_gatt_context: EspBtpGattContext,
embedding: E,
}
impl<E> EspGatt<E>
where
E: Embedding,
{
#[allow(clippy::large_stack_frames)]
#[inline(always)]
const fn new() -> Self {
Self {
btp_gatt_context: EspBtpGattContext::new(),
embedding: E::INIT,
}
}
fn init() -> impl Init<Self> {
init!(Self {
btp_gatt_context <- EspBtpGattContext::init(),
embedding <- E::init(),
})
}
pub fn context(&self) -> &EspBtpGattContext {
&self.btp_gatt_context
}
pub fn embedding(&self) -> &E {
&self.embedding
}
}
impl<E> Embedding for EspGatt<E>
where
E: Embedding,
{
const INIT: Self = Self::new();
fn init() -> impl Init<Self> {
EspGatt::init()
}
}
#[cfg(esp_idf_bt_bluedroid_enabled)]
const GATTS_APP_ID: u16 = 0;