diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/src/bin/ble_bas_peripheral.rs | 28 | ||||
-rw-r--r-- | examples/src/bin/ble_peripheral_onoff.rs | 7 |
2 files changed, 19 insertions, 16 deletions
diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs index 511513b..e3e6233 100644 --- a/examples/src/bin/ble_bas_peripheral.rs +++ b/examples/src/bin/ble_bas_peripheral.rs @@ -32,7 +32,13 @@ struct BatteryService { #[nrf_softdevice::gatt_service(uuid = "9e7312e0-2354-11eb-9f10-fbc30a62cf38")] struct FooService { - #[characteristic(uuid = "9e7312e0-2354-11eb-9f10-fbc30a63cf38", read, write, notify)] + #[characteristic( + uuid = "9e7312e0-2354-11eb-9f10-fbc30a63cf38", + read, + write, + notify, + indicate + )] foo: u16, } @@ -70,11 +76,8 @@ async fn bluetooth_task(sd: &'static Softdevice) { // Run the GATT server on the connection. This returns when the connection gets disconnected. let res = gatt_server::run(&conn, &server, |e| match e { ServerEvent::Bas(e) => match e { - BatteryServiceEvent::BatteryLevelNotificationsEnabled => { - info!("battery notifications enabled") - } - BatteryServiceEvent::BatteryLevelNotificationsDisabled => { - info!("battery notifications disabled") + BatteryServiceEvent::BatteryLevelCccdWrite { notifications } => { + info!("battery notifications: {}", notifications) } }, ServerEvent::Foo(e) => match e { @@ -84,11 +87,14 @@ async fn bluetooth_task(sd: &'static Softdevice) { info!("send notification error: {:?}", e); } } - FooServiceEvent::FooNotificationsEnabled => { - info!("foo notifications enabled") - } - FooServiceEvent::FooNotificationsDisabled => { - info!("foo notifications disabled") + FooServiceEvent::FooCccdWrite { + indications, + notifications, + } => { + info!( + "foo indications: {}, notifications: {}", + indications, notifications + ) } }, }) diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 067f1d4..32eac93 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -68,11 +68,8 @@ async fn run_bluetooth(sd: &'static Softdevice, server: &Server) { info!("send notification error: {:?}", e); } } - ServerEvent::Foo(FooServiceEvent::FooNotificationsEnabled) => { - info!("notifications enabled") - } - ServerEvent::Foo(FooServiceEvent::FooNotificationsDisabled) => { - info!("notifications disabled") + ServerEvent::Foo(FooServiceEvent::FooCccdWrite { notifications }) => { + info!("foo notifications: {}", notifications) } }) .await; |