possible notification fix
Signed-off-by: thatscringebro <thatscringebro@tutanota.com>
This commit is contained in:
parent
abe0e23cae
commit
164ddd94ee
36
src/lib.rs
36
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 HEART_RATE_UUID: Uuid = uuid!("00002a37-0000-1000-8000-00805f9b34fb");
|
||||||
const NOTIFICATION_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> {
|
pub async fn find_infinitime(adapter: &Adapter) -> Option<Peripheral> {
|
||||||
for p in adapter.peripherals().await.unwrap() {
|
for p in adapter.peripherals().await.unwrap() {
|
||||||
if p.properties()
|
if p.properties()
|
||||||
@ -47,13 +74,18 @@ pub async fn get_heart_rate(infinitime: &Peripheral) -> String {
|
|||||||
let rate = data[1];
|
let rate = data[1];
|
||||||
return rate.to_string();
|
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 chars = infinitime.characteristics();
|
||||||
let cmd_char = chars.iter().find(|c| c.uuid == NOTIFICATION_UUID).unwrap();
|
let cmd_char = chars.iter().find(|c| c.uuid == NOTIFICATION_UUID).unwrap();
|
||||||
infinitime
|
infinitime
|
||||||
.write(
|
.write(
|
||||||
cmd_char,
|
cmd_char,
|
||||||
"\\x00\\x01\\x00Test Title\\x00Test Body".as_bytes(),
|
&[
|
||||||
|
&[0, 1],
|
||||||
|
notification.title.as_bytes(),
|
||||||
|
notification.body.as_bytes(),
|
||||||
|
]
|
||||||
|
.join(&0),
|
||||||
WriteType::WithoutResponse,
|
WriteType::WithoutResponse,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user