Add incoming call functionality
Add categories to AlertNotification Add new alert notification screens bases Add Incoming Call Add Modal Add event to AlertNotification Co-authored-by: Robin Karlsson <robin.karlsson@protonmail.com>
This commit is contained in:

committed by
petter

parent
7e27bc8733
commit
10ba20876f
@@ -83,4 +83,4 @@ namespace Pinetime {
|
||||
bool isDescriptorFound = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ using namespace Pinetime::Controllers;
|
||||
|
||||
constexpr ble_uuid16_t AlertNotificationService::ansUuid;
|
||||
constexpr ble_uuid16_t AlertNotificationService::ansCharUuid;
|
||||
constexpr ble_uuid16_t AlertNotificationService::ansEventUuid;
|
||||
|
||||
|
||||
int AlertNotificationCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
@@ -33,6 +34,13 @@ AlertNotificationService::AlertNotificationService ( System::SystemTask& systemT
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_WRITE
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &ansEventUuid,
|
||||
.access_cb = AlertNotificationCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||
.val_handle = &eventHandle
|
||||
},
|
||||
{
|
||||
0
|
||||
}
|
||||
@@ -61,14 +69,36 @@ 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];
|
||||
|
||||
NotificationManager::Notification notif;
|
||||
os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data());
|
||||
os_mbuf_copydata(ctxt->om, 0, 1, category);
|
||||
notif.message[messageSize-1] = '\0';
|
||||
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
|
||||
notificationManager.Push(std::move(notif));
|
||||
Pinetime::System::SystemTask::Messages event = Pinetime::System::SystemTask::Messages::OnNewNotification;
|
||||
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
|
||||
switch(*category) {
|
||||
case (uint8_t) 0x05:
|
||||
notif.category = Pinetime::Controllers::NotificationManager::Categories::IncomingCall;
|
||||
event = Pinetime::System::SystemTask::Messages::OnNewCall;
|
||||
break;
|
||||
}
|
||||
|
||||
notificationManager.Push(std::move(notif));
|
||||
systemTask.PushMessage(event);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AlertNotificationService::event(char event) {
|
||||
auto *om = ble_hs_mbuf_from_flat(&event, 1);
|
||||
|
||||
uint16_t connectionHandle = systemTask.nimble().connHandle();
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
||||
}
|
||||
|
@@ -24,10 +24,28 @@ namespace Pinetime {
|
||||
int OnAlert(uint16_t conn_handle, uint16_t attr_handle,
|
||||
struct ble_gatt_access_ctxt *ctxt);
|
||||
|
||||
void event(char event);
|
||||
|
||||
static const char EVENT_HANG_UP_CALL = 0x00;
|
||||
static const char EVENT_ANSWER_CALL = 0x01;
|
||||
|
||||
|
||||
private:
|
||||
static const char ALERT_UNKNOWN = 0x01;
|
||||
static const char ALERT_SIMPLE_ALERT = 0x02;
|
||||
static const char ALERT_EMAIL = 0x03;
|
||||
static const char ALERT_NEWS = 0x04;
|
||||
static const char ALERT_INCOMING_CALL = 0x05;
|
||||
static const char ALERT_MISSED_CALL = 0x06;
|
||||
static const char ALERT_SMS = 0x07;
|
||||
static const char ALERT_VOICE_MAIL = 0x08;
|
||||
static const char ALERT_SCHEDULE = 0x09;
|
||||
static const char ALERT_HIGH_PRIORITY_ALERT = 0x0a;
|
||||
static const char ALERT_INSTANT_MESSAGE = 0x0b;
|
||||
|
||||
static constexpr uint16_t ansId {0x1811};
|
||||
static constexpr uint16_t ansCharId {0x2a46};
|
||||
static constexpr uint16_t ansEventCharId = {0x2a47};
|
||||
|
||||
static constexpr ble_uuid16_t ansUuid {
|
||||
.u { .type = BLE_UUID_TYPE_16 },
|
||||
@@ -39,11 +57,18 @@ namespace Pinetime {
|
||||
.value = ansCharId
|
||||
};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[2];
|
||||
static constexpr ble_uuid16_t ansEventUuid {
|
||||
.u { .type = BLE_UUID_TYPE_16 },
|
||||
.value = ansEventCharId
|
||||
};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[3];
|
||||
struct ble_gatt_svc_def serviceDefinition[2];
|
||||
|
||||
Pinetime::System::SystemTask &systemTask;
|
||||
NotificationManager ¬ificationManager;
|
||||
|
||||
uint16_t eventHandle;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -58,6 +58,7 @@ namespace Pinetime {
|
||||
|
||||
Pinetime::Controllers::MusicService& music() {return musicService;};
|
||||
Pinetime::Controllers::NavigationService& navigation() {return navService;};
|
||||
Pinetime::Controllers::AlertNotificationService& alertService() {return anService;};
|
||||
|
||||
uint16_t connHandle();
|
||||
|
||||
|
Reference in New Issue
Block a user