From 87fdceb963a3257cb26614772764d45e5cde664a Mon Sep 17 00:00:00 2001 From: taks <857tn859@gmail.com> Date: Fri, 20 Oct 2023 10:26:52 +0900 Subject: [PATCH] Add on_disconnect callback to server example. --- examples/ble_secure_server.rs | 7 +++++++ examples/ble_server.rs | 3 +++ 2 files changed, 10 insertions(+) diff --git a/examples/ble_secure_server.rs b/examples/ble_secure_server.rs index dd34684..aaba994 100644 --- a/examples/ble_secure_server.rs +++ b/examples/ble_secure_server.rs @@ -19,6 +19,13 @@ fn main() { .set_io_cap(SecurityIOCap::DisplayOnly); let server = device.get_server(); + server.on_connect(|server, desc| { + ::log::info!("Client connected"); + }); + server.on_disconnect(|desc, reason| { + ::log::info!("Client disconnected ({:X})", reason); + }); + let service = server.create_service(BleUuid::Uuid16(0xABCD)); let non_secure_characteristic = service diff --git a/examples/ble_server.rs b/examples/ble_server.rs index cfcc720..f87a629 100644 --- a/examples/ble_server.rs +++ b/examples/ble_server.rs @@ -25,6 +25,9 @@ fn main() { ::log::info!("Multi-connect support: start advertising"); ble_device.get_advertising().start().unwrap(); }); + server.on_disconnect(|desc, reason| { + ::log::info!("Client disconnected ({:X})", reason); + }); let service = server.create_service(uuid128!("fafafafa-fafa-fafa-fafa-fafafafafafa")); // A static characteristic.