pub use bt_hci;
use esp_hal::efuse::{self, InterfaceMacAddress};
use esp_hal::peripherals::BT;
use esp_radio::ble::controller::BleConnector;
pub use trouble_host;
use trouble_host::prelude::{Address, ExternalController};
pub const COMMAND_SLOTS: usize = 20;
pub type Controller = ExternalController<BleConnector<'static>, COMMAND_SLOTS>;
pub type InitError = esp_radio::ble::controller::BleInitError;
pub fn controller(bt: BT<'static>) -> Result<Controller, InitError> {
Ok(ExternalController::new(BleConnector::new(
bt,
Default::default(),
)?))
}
pub fn address() -> Address {
let mac = efuse::interface_mac_address(InterfaceMacAddress::Bluetooth);
let mut le = [0u8; 6];
for (dst, src) in le.iter_mut().zip(mac.as_bytes().iter().rev()) {
*dst = *src; }
le[5] |= 0xC0;
Address::random(le)
}