log when current_network_index is changed

This commit is contained in:
2026-02-01 16:43:45 +00:00
parent a729199926
commit f25a539084
+22 -20
View File
@@ -107,30 +107,32 @@ async fn ble_task<C: Controller, P: PacketPool>(mut runner: Runner<'_, C, P>) {
///
/// This function will handle the GATT events and process them.
/// This is how we interact with read and write requests.
async fn gatt_events_task<P: PacketPool>(_server: &Server<'_>, conn: &GattConnection<'_, '_, P>) -> Result<(), Error> {
// let level = server.battery_service.level;
async fn gatt_events_task<P: PacketPool>(server: &Server<'_>, conn: &GattConnection<'_, '_, P>) -> Result<(), Error> {
let current_index = server.wifi_provisioning_service.current_network_index;
let reason = loop {
match conn.next().await {
GattConnectionEvent::Disconnected { reason } => break reason,
GattConnectionEvent::Gatt { event } => {
// match &event {
// // are these clauses important? they don't do anything
// // except log
// GattEvent::Read(event) => {
// if event.handle() == level.handle {
// let value = server.get(&level);
// info!("[gatt] Read Event to Level Characteristic: {:?}", value);
// }
// }
// GattEvent::Write(event) => {
// if event.handle() == level.handle {
// info!("[gatt] Write Event to Level Characteristic: {:?}", event.data());
// }
// }
// _ => {}
// };
// This step is also performed at drop(), but writing it explicitly is necessary
// in order to ensure reply is sent.
match &event {
// // are these clauses important? they don't do anything
// // except log
// GattEvent::Read(event) => {
// if event.handle() == level.handle {
// let value = server.get(&level);
// info!("[gatt] Read Event to Level Characteristic: {:?}", value);
// }
// }
GattEvent::Write(event) => {
info!("[gatt] write handle {:?}", event.handle());
if event.handle() == current_index.handle {
info!("[gatt] switch current index: {:?}", event.data());
}
},
_ => {}
};
// This step is also performed at drop(), but writing
// it explicitly is necessary in order to ensure reply
// is sent.
match event.accept() {
Ok(reply) => reply.send().await,
Err(e) => warn!("[gatt] error sending response: {:?}", e),