Skip to content

Commit

Permalink
Update to bt-hci main and adopt to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Mar 29, 2024
1 parent 3c00a81 commit 44edf79
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions examples/nrf-sdc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ embassy-futures = { git = "https://github.com/embassy-rs/embassy.git", branch =
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
nrf-sdc = { git = "https://github.com/alexmoon/nrf-sdc.git", branch = "update-api" }
nrf-mpsl = { git = "https://github.com/alexmoon/nrf-sdc.git", branch = "update-api" }
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "serial-controller" }
nrf-sdc = { git = "https://github.com/alexmoon/nrf-sdc.git", branch = "main" }
nrf-mpsl = { git = "https://github.com/alexmoon/nrf-sdc.git", branch = "main" }
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "main" }

#embassy-executor = {path = "../../../embassy/embassy-executor"}
#embassy-nrf = {path = "../../../embassy/embassy-nrf"}
Expand Down
2 changes: 1 addition & 1 deletion examples/serial-hci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bt-hci = { version = "0.1.0", default-features = false, features = ["log"] }
trouble-host = { version = "0.1.0", path = "../../host", features = ["log"] }

[patch.crates-io]
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "serial-controller" }
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "main" }
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
#embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
#bt-hci = { path = "../../../bt-hci" }
8 changes: 4 additions & 4 deletions examples/serial-hci/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use with any serial HCI
use bt_hci::driver::HciController;
use bt_hci::serial::SerialHciDriver;
use bt_hci::controller::ExternalController;
use bt_hci::transport::SerialTransport;
use embassy_futures::join::join3;
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use log::*;
Expand Down Expand Up @@ -56,8 +56,8 @@ async fn main() {
let reader = embedded_io_adapters::tokio_1::FromTokio::new(reader);
let writer = embedded_io_adapters::tokio_1::FromTokio::new(writer);

let driver: SerialHciDriver<NoopRawMutex, _, _> = SerialHciDriver::new(reader, writer);
let controller: HciController<_, 10> = HciController::new(driver);
let driver: SerialTransport<NoopRawMutex, _, _> = SerialTransport::new(reader, writer);
let controller: ExternalController<_, 10> = ExternalController::new(driver);
static HOST_RESOURCES: StaticCell<HostResources<NoopRawMutex, 4, 32, 27>> = StaticCell::new();
let host_resources = HOST_RESOURCES.init(HostResources::new(PacketQos::None));

Expand Down
2 changes: 1 addition & 1 deletion host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ defmt = {version = "0.3", optional = true }
defmt = [ "dep:defmt" ]

[patch.crates-io]
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "serial-controller" }
bt-hci = { git = "https://github.com/alexmoon/bt-hci.git", branch = "main" }
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", branch = "main" }
5 changes: 3 additions & 2 deletions host/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ use bt_hci::cmd::le::{
};
use bt_hci::cmd::link_control::{Disconnect, DisconnectParams};
use bt_hci::cmd::{AsyncCmd, SyncCmd};
use bt_hci::controller::Controller;
use bt_hci::controller::{ControllerCmdAsync, ControllerCmdSync};
use bt_hci::data::{AclBroadcastFlag, AclPacket, AclPacketBoundary};
use bt_hci::event::le::LeEvent;
use bt_hci::event::Event;
use bt_hci::param::{BdAddr, ConnHandle, DisconnectReason, EventMask};
use bt_hci::{Controller, ControllerToHostPacket};
use bt_hci::{ControllerCmdAsync, ControllerCmdSync};
use bt_hci::ControllerToHostPacket;
use embassy_futures::select::{select, Either};
use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::channel::Channel;
Expand Down
2 changes: 1 addition & 1 deletion host/src/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::{
task::{Context, Poll},
};

use bt_hci::{param::ConnHandle, Controller};
use bt_hci::{controller::Controller, param::ConnHandle};
use embassy_sync::{
blocking_mutex::{raw::RawMutex, Mutex},
channel::{Channel, DynamicReceiver},
Expand Down
2 changes: 1 addition & 1 deletion host/src/gatt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::cursor::WriteCursor;
use crate::packet_pool::{AllocId, DynamicPacketPool};
use crate::pdu::Pdu;
use crate::{AdapterError, Error};
use bt_hci::controller::Controller;
use bt_hci::param::ConnHandle;
use bt_hci::Controller;
use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::channel::DynamicReceiver;

Expand Down
2 changes: 1 addition & 1 deletion host/src/l2cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::cursor::{ReadCursor, WriteCursor};
use crate::packet_pool::{AllocId, DynamicPacketPool};
use crate::pdu::Pdu;
use crate::{AdapterError, Error};
use bt_hci::controller::Controller;
use bt_hci::data::AclPacket;
use bt_hci::param::ConnHandle;
use bt_hci::Controller;
use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::channel::DynamicReceiver;

Expand Down
8 changes: 4 additions & 4 deletions host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ impl From<FromHciBytesError> for Error {
}
}

impl<E> From<bt_hci::CmdError<E>> for AdapterError<E> {
fn from(error: bt_hci::CmdError<E>) -> Self {
impl<E> From<bt_hci::controller::CmdError<E>> for AdapterError<E> {
fn from(error: bt_hci::controller::CmdError<E>) -> Self {
match error {
bt_hci::CmdError::Param(p) => Self::Adapter(Error::HciEncode(p)),
bt_hci::CmdError::Controller(p) => Self::Controller(p),
bt_hci::controller::CmdError::Hci(p) => Self::Adapter(Error::HciEncode(p)),
bt_hci::controller::CmdError::Io(p) => Self::Controller(p),
}
}
}
Expand Down

0 comments on commit 44edf79

Please sign in to comment.