diff options
author | alexmoon <alex.r.moon@gmail.com> | 2022-07-13 07:59:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 07:59:32 -0400 |
commit | 29fce52109fcd12cda7767b546e43270b3217264 (patch) | |
tree | b3691429eef48000076d0c4c28ff769ab7497ea8 /examples/src/bin/ble_peripheral_onoff.rs | |
parent | 96dbdc838ac2d2a0997eebeda77cead2154d5d22 (diff) | |
parent | ea7a3908df6816225641da342de2466d91ff6f2b (diff) | |
download | nrf-softdevice-29fce52109fcd12cda7767b546e43270b3217264.zip |
Merge pull request #107 from alexmoon/gatt-service-builder
GATT service builder
Diffstat (limited to 'examples/src/bin/ble_peripheral_onoff.rs')
-rw-r--r-- | examples/src/bin/ble_peripheral_onoff.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 9fdc8c0..539b168 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -79,9 +79,7 @@ async fn run_bluetooth(sd: &'static Softdevice, server: &Server) { } #[embassy::task] -async fn bluetooth_task(sd: &'static Softdevice, button1: AnyPin, button2: AnyPin) { - let server: Server = unwrap!(gatt_server::register(sd)); - +async fn bluetooth_task(sd: &'static Softdevice, server: Server, button1: AnyPin, button2: AnyPin) { info!("Bluetooth is OFF"); info!("Press nrf52840-dk button 1 to enable, button 2 to disable"); @@ -170,8 +168,14 @@ fn main() -> ! { let sd = Softdevice::enable(&config); let executor = EXECUTOR.put(Executor::new()); - executor.run(|spawner| { + executor.run(move |spawner| { + let server = unwrap!(Server::new(sd)); unwrap!(spawner.spawn(softdevice_task(sd))); - unwrap!(spawner.spawn(bluetooth_task(sd, p.P0_11.degrade(), p.P0_12.degrade()))); + unwrap!(spawner.spawn(bluetooth_task( + sd, + server, + p.P0_11.degrade(), + p.P0_12.degrade() + ))); }); } |