possible notification fix

Signed-off-by: thatscringebro <thatscringebro@tutanota.com>
This commit is contained in:
thatscringebro 2025-05-02 15:55:05 -04:00
parent abe0e23cae
commit 164ddd94ee

View File

@ -9,6 +9,33 @@ const BATTERY_LEVEL_UUID: Uuid = uuid!("00002a19-0000-1000-8000-00805f9b34fb");
const HEART_RATE_UUID: Uuid = uuid!("00002a37-0000-1000-8000-00805f9b34fb");
const NOTIFICATION_UUID: Uuid = uuid!("00002a37-0000-1000-8000-00805f9b34fb");
pub enum NotificationCategory {
SimpleAlert,
Email,
News,
CallNotification,
MissedCall,
SMS,
Voicemail,
Schedule,
HighPrioritizedAlert,
InstantMessage,
}
pub struct Notification {
category: NotificationCategory,
title: String,
body: String,
}
impl Notification {
fn new(category: NotificationCategory, title: String, body: String) -> Notification {
return Self {
category: category,
title: title,
body: body,
};
}
}
pub async fn find_infinitime(adapter: &Adapter) -> Option<Peripheral> {
for p in adapter.peripherals().await.unwrap() {
if p.properties()
@ -47,13 +74,18 @@ pub async fn get_heart_rate(infinitime: &Peripheral) -> String {
let rate = data[1];
return rate.to_string();
}
pub async fn send_notification(infinitime: &Peripheral) {
pub async fn send_notification(infinitime: &Peripheral, notification: Notification) {
let chars = infinitime.characteristics();
let cmd_char = chars.iter().find(|c| c.uuid == NOTIFICATION_UUID).unwrap();
infinitime
.write(
cmd_char,
"\\x00\\x01\\x00Test Title\\x00Test Body".as_bytes(),
&[
&[0, 1],
notification.title.as_bytes(),
notification.body.as_bytes(),
]
.join(&0),
WriteType::WithoutResponse,
)
.await