bjoernQ / bleps

A toy-level BLE peripheral stack
MIT License
55 stars 18 forks source link

async friendly HciConnection trait + async friendly HciConnector implementation #21

Closed brandonros closed 1 year ago

brandonros commented 1 year ago

I'm not sure this is needed?

struct AsyncBleConnector {}

impl AsyncBleConnector {
    pub fn new() -> AsyncBleConnector {
        return AsyncBleConnector {};
    }
}

#[derive(Debug)]
pub enum BleConnectorError {
    Unknown,
}

impl embedded_io_async::Error for BleConnectorError {
    fn kind(&self) -> embedded_io_async::ErrorKind {
        embedded_io_async::ErrorKind::Other
    }
}

impl embedded_io_async::ErrorType for AsyncBleConnector {
    type Error = BleConnectorError;
}

impl embedded_io_async::Read for AsyncBleConnector {
    async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
        Ok(0)
    }
}

impl embedded_io_async::Write for AsyncBleConnector {
    async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
        Ok(0)
    }
}

I have this in my own crate and it seems to plug into bleps::asynch::Ble without issue