summaryrefslogtreecommitdiff
path: root/src/components/ble/AlertNotificationService.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-01-24 17:22:39 +0100
committerJean-François Milants <jf@codingfield.com>2021-01-24 17:22:39 +0100
commit219bafb01ac11a2dc0591d37f00e1acc6d478b54 (patch)
treee0f0a1db0c060f36770aa7369b4f4f6e57141d01 /src/components/ble/AlertNotificationService.cpp
parent6d76dbc9117693cc611ba106d696222580dbdc95 (diff)
Handle call notification the same way than other notifications.
Display the call notifications in the Notification app, with buttons to accept/reject the call.
Diffstat (limited to 'src/components/ble/AlertNotificationService.cpp')
-rw-r--r--src/components/ble/AlertNotificationService.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp
index 88d2ea8a..5fb8338b 100644
--- a/src/components/ble/AlertNotificationService.cpp
+++ b/src/components/ble/AlertNotificationService.cpp
@@ -69,30 +69,46 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om);
size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize);
auto messageSize = std::min(maxMessageSize, (bufferSize-headerSize));
- uint8_t* category = new uint8_t[1];
+ Categories category;
NotificationManager::Notification notif;
os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data());
- os_mbuf_copydata(ctxt->om, 0, 1, category);
+ os_mbuf_copydata(ctxt->om, 0, 1, &category);
notif.message[messageSize-1] = '\0';
- notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
- Pinetime::System::SystemTask::Messages event = Pinetime::System::SystemTask::Messages::OnNewNotification;
- switch(*category) {
- case (uint8_t) ANS_TYPE_NOTIFICATION_CALL:
+ // TODO convert all ANS categories to NotificationController categories
+ switch(category) {
+ case Categories::Call:
notif.category = Pinetime::Controllers::NotificationManager::Categories::IncomingCall;
- event = Pinetime::System::SystemTask::Messages::OnNewCall;
+ break;
+ default:
+ notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
break;
}
+ auto event = Pinetime::System::SystemTask::Messages::OnNewNotification;
notificationManager.Push(std::move(notif));
systemTask.PushMessage(event);
}
return 0;
}
-void AlertNotificationService::event(char event) {
- auto *om = ble_hs_mbuf_from_flat(&event, 1);
+void AlertNotificationService::AcceptIncomingCall() {
+ auto response = IncomingCallResponses::Answer;
+ auto *om = ble_hs_mbuf_from_flat(&response, 1);
+
+ uint16_t connectionHandle = systemTask.nimble().connHandle();
+
+ if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
+ return;
+ }
+
+ ble_gattc_notify_custom(connectionHandle, eventHandle, om);
+}
+
+void AlertNotificationService::RejectIncomingCall() {
+ auto response = IncomingCallResponses::Reject;
+ auto *om = ble_hs_mbuf_from_flat(&response, 1);
uint16_t connectionHandle = systemTask.nimble().connHandle();