async fn read<'a>(
            &self,
            rx: &'a mut [u8],
        ) -> Result<ControllerToHostPacket<'a>, Self::Error> {
            loop {
                if !have_hci_read_data() {
                    HciReadyEventFuture.await;
                }

                // Workaround for borrow checker.
                // Safety: we only return a reference to x once, if parsing is successful.
                let rx =
                    unsafe { &mut *core::ptr::slice_from_raw_parts_mut(rx.as_mut_ptr(), rx.len()) };

                let len = crate::ble::read_next(rx);
                if let Some(packet) = parse_hci(&rx[..len])? {
                    return Ok(packet);
                }
            }
        }
Read a complete HCI packet into the rx buffer
esp-wifi/src/ble/controller/mod.rs