alert-me/display/src/ble/gatt.rs

25 lines
706 B
Rust
Raw Normal View History

2024-05-20 09:18:17 +00:00
use crate::ble::battery_service::BatteryService;
use crate::ble::battery_service::BatteryServiceEvent;
use defmt::info;
use nrf_softdevice::ble::gatt_server;
use nrf_softdevice::ble::Connection;
use nrf_softdevice::ble::DisconnectedError;
#[nrf_softdevice::gatt_server]
pub struct Server {
pub bas: BatteryService,
}
pub async fn run(conn: &Connection, server: &Server) -> DisconnectedError {
info!("gatt started");
gatt_server::run(conn, server, |e| match e {
ServerEvent::Bas(e) => match e {
BatteryServiceEvent::BatteryLevelCccdWrite { notifications } => {
info!("battery notifications: {}", notifications)
}
},
})
.await
}