Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0533b91 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-gd: start controller module

only a few calls to start, more to come

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: I91e6a21f4d15e67c5ad7b917cd31d419bf86ebe9
parent 5e1addfa
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
//! Loads info from the controller at startup

use crate::HciExports;
use bt_packets::hci::{
    Enable, ErrorCode, LeSetEventMaskBuilder, SetEventMaskBuilder, WriteSimplePairingModeBuilder, WriteLeHostSupportBuilder
};
use gddi::{module, provides, Stoppable};

module! {
    controller_module,
    providers {
        ControllerExports => provide_controller,
    },
}

macro_rules! assert_success {
    ($hci:ident.send($builder:expr)) => {
        assert!($hci.send($builder.build()).await.get_status() == ErrorCode::Success);
    };
}

#[provides]
async fn provide_controller(mut hci: HciExports) -> ControllerExports {
    assert_success!(hci.send(LeSetEventMaskBuilder {
        le_event_mask: 0x0000000000021e7f
    }));
    assert_success!(hci.send(SetEventMaskBuilder {
        event_mask: 0x3dbfffffffffffff
    }));
    assert_success!(hci.send(WriteSimplePairingModeBuilder {
        simple_pairing_mode: Enable::Enabled
    }));
    assert_success!(hci.send(WriteLeHostSupportBuilder {
        le_supported_host: Enable::Enabled
    }));

    ControllerExports {}
}

/// Controller interface
#[derive(Clone, Stoppable)]
pub struct ControllerExports {}
+3 −1
Original line number Diff line number Diff line
@@ -2,9 +2,10 @@

/// HCI errors
pub mod error;

/// HCI layer facade service
pub mod facade;
/// HCI controller info
pub mod controller;

use bt_common::time::Alarm;
use bt_hal::HalExports;
@@ -30,6 +31,7 @@ module! {
    hci_module,
    submodules {
        facade::facade_module,
        controller::controller_module,
    },
    providers {
        HciExports => provide_hci,