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

Commit 257b9ba9 authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I122f110d,If7820cec

* changes:
  Add stub for rusty-gd facade service
  A few minor cleanups to hci facades
parents bf79aa5a b615cb1b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
rust_binary {
    name: "rusty_bluetooth_stack_with_facade",
    crate_name: "rusty_bt_stack_with_facade",
    srcs: ["src/main.rs"],
    edition: "2018",
    rustlibs: [
      "libclap",
    ],
    host_supported: true,
}
+38 −0
Original line number Diff line number Diff line
//! Starts the facade services that allow us to test the Bluetooth stack

#[macro_use]
extern crate clap;
use clap::{App, Arg};

fn main() {
    let matches = App::new("rusty_bluetooth_stack_with_facade")
        .about("The bluetooth stack, with testing facades enabled and exposed via gRPC.")
        .arg(
            Arg::with_name("root-server-port")
                .long("root-server-port")
                .default_value("8897")
                .takes_value(true),
        )
        .arg(
            Arg::with_name("grpc-port")
                .long("grpc-port")
                .default_value("8899")
                .takes_value(true),
        )
        .arg(
            Arg::with_name("signal-port")
                .long("signal-port")
                .default_value("8895")
                .takes_value(true),
        )
        .get_matches();

    let root_server_port = value_t!(matches, "root-server-port", u16).unwrap();
    let grpc_port = value_t!(matches, "grpc-port", u16).unwrap();
    let signal_port = value_t!(matches, "signal-port", u16).unwrap();

    println!(
        "root server port: {}, grpc port: {}, signal port {}",
        root_server_port, grpc_port, signal_port
    );
}
+2 −8
Original line number Diff line number Diff line
@@ -7,9 +7,7 @@ use futures::executor::block_on;
use grpcio::*;
use hal::rootcanal_hal::{RootcanalConfig, RootcanalHal};
use hci::facade::hci_facade_server::HciLayerFacadeService;
use hci::facade::protos::hci_layer_facade_grpc;
use hci::Hci;
use hci_layer_facade_grpc::create_hci_layer_facade;

use std::io::{self, Read};
use std::sync::Arc;
@@ -19,14 +17,10 @@ use tokio::runtime::Runtime;

async fn async_main(rt: Arc<Runtime>) -> Result<()> {
    let env = Arc::new(Environment::new(2));
    let rootcanal_config = RootcanalConfig::new(6402, "127.0.0.1");
    let hal_exports = RootcanalHal::start(rootcanal_config.clone(), Arc::clone(&rt)).await.unwrap();
    let hal_exports = RootcanalHal::start(RootcanalConfig::new(6402, "127.0.0.1"), Arc::clone(&rt)).await.unwrap();
    let hci_exports = Hci::start(hal_exports, Arc::clone(&rt));
    let mut server = ServerBuilder::new(env)
        .register_service(create_hci_layer_facade(HciLayerFacadeService::new(
            hci_exports,
            Arc::clone(&rt),
        )))
        .register_service(HciLayerFacadeService::create(hci_exports, Arc::clone(&rt)))
        .bind("0.0.0.0", 8999)
        .build()
        .unwrap();
+3 −2
Original line number Diff line number Diff line
@@ -22,11 +22,12 @@ pub struct HciLayerFacadeService {
use super::protos::empty::Empty;
use super::protos::facade::*;
use super::protos::hci_layer_facade_grpc::HciLayerFacade;
use crate::facade::protos::hci_layer_facade_grpc::create_hci_layer_facade;

impl HciLayerFacadeService {
    /// Create a new instance of HCI layer facade service
    pub fn new(hci_exports: HciExports, rt: Arc<Runtime>) -> Self {
        Self { hci_exports, rt }
    pub fn create(hci_exports: HciExports, rt: Arc<Runtime>) -> grpcio::Service {
        create_hci_layer_facade(Self { hci_exports, rt })
    }
}