From 164ddd94eeb16333718b8c429223a88d4b362c36 Mon Sep 17 00:00:00 2001 From: thatscringebro Date: Fri, 2 May 2025 15:55:05 -0400 Subject: [PATCH] possible notification fix Signed-off-by: thatscringebro --- src/lib.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index be58d7e..a4c465f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { 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