summaryrefslogtreecommitdiff
path: root/examples/src/bin/ble_bas_central.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2020-11-10 14:15:39 +0100
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2020-11-10 14:15:39 +0100
commit1c15bd7677a77ba8a453ac3723d0153b0120d473 (patch)
tree100329b88906a9da4c232f592460c8cb2935a9e5 /examples/src/bin/ble_bas_central.rs
parent3dffe02f75a691ed56579c28f83cc9ff405f01bf (diff)
downloadnrf-softdevice-1c15bd7677a77ba8a453ac3723d0153b0120d473.zip
update examples to anyfmt
Diffstat (limited to 'examples/src/bin/ble_bas_central.rs')
-rw-r--r--examples/src/bin/ble_bas_central.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/examples/src/bin/ble_bas_central.rs b/examples/src/bin/ble_bas_central.rs
index 6d1b83c..38ef609 100644
--- a/examples/src/bin/ble_bas_central.rs
+++ b/examples/src/bin/ble_bas_central.rs
@@ -6,6 +6,7 @@
mod example_common;
use example_common::*;
+use anyfmt::{panic, *};
use core::mem;
use cortex_m_rt::entry;
use defmt::info;
@@ -35,28 +36,21 @@ async fn ble_central_task(sd: &'static Softdevice, config: central::Config) {
0x06, 0x6b, 0x71, 0x2c, 0xf5, 0xc0,
])];
- let conn = central::connect(sd, addrs, config)
- .await
- .dexpect(intern!("connect"));
+ let conn = unwrap!(central::connect(sd, addrs, config).await);
info!("connected");
- let client: BatteryServiceClient = gatt_client::discover(&conn)
- .await
- .dexpect(intern!("discover"));
+ let client: BatteryServiceClient = unwrap!(gatt_client::discover(&conn).await);
// Read
- let val = client.battery_level_read().await.dexpect(intern!("read"));
+ let val = unwrap!(client.battery_level_read().await);
info!("read battery level: {:u8}", val);
// Write, set it to 42
- client
- .battery_level_write(42)
- .await
- .dexpect(intern!("write"));
+ unwrap!(client.battery_level_write(42).await);
info!("Wrote battery level!");
// Read to check it's changed
- let val = client.battery_level_read().await.dexpect(intern!("read"));
+ let val = unwrap!(client.battery_level_read().await);
info!("read battery level: {:u8}", val);
}
@@ -102,10 +96,8 @@ fn main() -> ! {
let sd = Softdevice::enable(sdp, &config);
let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- executor.spawn(softdevice_task(sd)).dewrap();
- executor
- .spawn(ble_central_task(sd, central::Config::default()))
- .dewrap();
+ unwrap!(executor.spawn(softdevice_task(sd)));
+ unwrap!(executor.spawn(ble_central_task(sd, central::Config::default())));
loop {
executor.run();