use bt_hci::cmd::{AsyncCmd, SyncCmd};
use bt_hci::controller::{Controller, ControllerCmdAsync, ControllerCmdSync};
use bt_hci::data::IsoPacket;
use crate::host::BleHost;
use crate::{BleHostError, PacketPool};
pub struct Iso<'stack, C, P: PacketPool> {
host: BleHost<'stack, C, P>,
}
impl<'stack, C: Controller, P: PacketPool> Iso<'stack, C, P> {
pub(crate) fn new(host: BleHost<'stack, C, P>) -> Self {
Self { host }
}
pub async fn command<Cmd>(&self, cmd: Cmd) -> Result<Cmd::Return, BleHostError<C::Error>>
where
Cmd: SyncCmd,
C: ControllerCmdSync<Cmd>,
{
self.host.command(cmd).await
}
pub async fn command_async<Cmd>(&self, cmd: Cmd) -> Result<(), BleHostError<C::Error>>
where
Cmd: AsyncCmd,
C: ControllerCmdAsync<Cmd>,
{
self.host.async_command(cmd).await
}
pub async fn send(&self, packet: &IsoPacket<'_>) -> Result<(), C::Error> {
self.host.write_iso_data(packet).await
}
}