Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/accelerometer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ embassy-time = { version = "0.4", default-features = false, features = ["defmt-t
cortex-m-rt = "0.7"

cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
defmt = "0.3.10"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
defmt = "1.0.1"
defmt-rtt = "1"
panic-probe = { version = "1", features = ["print-defmt"] }

[profile.release]
debug = 2
6 changes: 3 additions & 3 deletions examples/ble-nrf-softdevice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ heapless = "0.8"
cortex-m-rt = "0.7"
static_cell = "2"

defmt = "0.3.10"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
defmt = "1.0.1"
defmt-rtt = "1"
panic-probe = { version = "1", features = ["print-defmt"] }

[profile.release]
debug = 2
Expand Down
9 changes: 3 additions & 6 deletions examples/ble-trouble/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ microbit-bsp = { path = "../../", features = ["trouble"]}
futures = { version = "0.3", default-features = false, features = ["async-await"]}
trouble-host = { version = "0.1.0", features = ["defmt", "gatt", "peripheral"] }

defmt = "0.3.10"
defmt-rtt = "0.4.0"
defmt = "1.0.1"
defmt-rtt = "1"

cortex-m = { version = "0.7.6" }
cortex-m-rt = "0.7.5"
panic-probe = { version = "0.3", features = ["print-defmt"] }
panic-probe = { version = "1", features = ["print-defmt"] }
static_cell = "2"

[profile.release]
debug = 2

[patch.crates-io]
trouble-host = { version = "0.1.0", git = "https://github.com/embassy-rs/trouble.git", rev = "7700932050221fa68a274fe713f7d1eb3d477ea2" }
35 changes: 16 additions & 19 deletions examples/ble-trouble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ where

let app_task = async {
loop {
match advertise("Trouble Example", &mut peripheral).await {
match advertise("Trouble Example", &mut peripheral, &server).await {
Ok(conn) => {
connection_task(&server, conn).await;
connection_task(&server, &conn).await;
}
Err(e) => {
let e = defmt::Debug2Format(&e);
Expand All @@ -96,15 +96,16 @@ async fn ble_task<C: Controller>(mut runner: Runner<'_, C>) -> Result<(), BleHos


/// Create an advertiser to use to connect to a BLE Central, and wait for it to connect.
async fn advertise<'a, C: Controller>(
async fn advertise<'a, 'b, C: Controller>(
name: &'a str,
peripheral: &mut Peripheral<'a, C>,
) -> Result<Connection<'a>, BleHostError<C::Error>> {
server: &'b Server<'_>,
) -> Result<GattConnection<'a, 'b>, BleHostError<C::Error>> {
let mut advertiser_data = [0; 31];
AdStructure::encode_slice(
&[
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
AdStructure::ServiceUuids16(&[Uuid::Uuid16([0x0f, 0x18])]),
AdStructure::ServiceUuids16(&[[0x0f, 0x18]]),
AdStructure::CompleteLocalName(name.as_bytes()),
],
&mut advertiser_data[..],
Expand All @@ -119,36 +120,32 @@ async fn advertise<'a, C: Controller>(
)
.await?;
info!("[adv] advertising");
let conn = advertiser.accept().await?;
let conn = advertiser.accept().await?.with_attribute_server(server)?;
info!("[adv] connection established");
Ok(conn)
}

/// This function will handle the GATT events and process them.
/// This is how we interact with read and write requests.
async fn connection_task(server: &Server<'_>, conn: Connection<'_>) {
async fn connection_task(server: &Server<'_>, conn: &GattConnection<'_, '_>) {
let level = server.battery_service.level;
unwrap!(level.set(server, &42));
loop {
match conn.next().await {
ConnectionEvent::Disconnected { reason } => {
GattConnectionEvent::Disconnected { reason } => {
info!("[gatt] disconnected: {:?}", reason);
break;
}
ConnectionEvent::Gatt { data } => {
match data.process(server).await {
// Server processing emits
Ok(Some(event)) => {
if let Ok(reply) = event.accept() {
reply.send().await;
}
}
Ok(_) => {}
Err(e) => {
warn!("[gatt] error processing event: {:?}", e);
GattConnectionEvent::Gatt { event } => match event {
// Server processing emits
Ok(event) => {
if let Ok(reply) = event.accept() {
reply.send().await;
}
}
Err(e) => warn!("[gatt] error processing event: {:?}", e),
}
_ => (),
}
}
info!("[gatt] task finished");
Expand Down
6 changes: 3 additions & 3 deletions examples/display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ embassy-time = { version = "0.4.0", default-features = false, features = ["defmt
cortex-m-rt = "0.7"

cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
defmt = "0.3.10"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
defmt = "1.0.1"
defmt-rtt = "1"
panic-probe = { version = "1", features = ["print-defmt"] }

[profile.release]
debug = 2
6 changes: 3 additions & 3 deletions examples/speaker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ embassy-time = { version = "0.4", default-features = false, features = ["defmt-t
cortex-m-rt = "0.7"

cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
defmt = "0.3.10"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
defmt = "1.0.1"
defmt-rtt = "1"
panic-probe = { version = "1", features = ["print-defmt"] }

[profile.release]
debug = 2
Loading