2020-04-28 13:31:58 -04:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <array>
|
2020-11-15 09:05:51 -05:00
|
|
|
#define min // workaround: nimble's min/max macros conflict with libstdc++
|
|
|
|
#define max
|
2020-04-28 13:31:58 -04:00
|
|
|
#include <host/ble_gap.h>
|
2020-11-15 09:05:51 -05:00
|
|
|
#undef max
|
|
|
|
#undef min
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
// 00020001-78fc-48fe-8e23-433b3a1942d0
|
|
|
|
#define NOTIFICATION_EVENT_SERVICE_UUID_BASE \
|
|
|
|
{ 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x01, 0x00, 0x02, 0x00 }
|
2021-01-08 08:21:52 -05:00
|
|
|
|
2020-04-28 13:31:58 -04:00
|
|
|
namespace Pinetime {
|
2020-11-15 09:05:51 -05:00
|
|
|
|
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
}
|
2020-04-28 13:31:58 -04:00
|
|
|
namespace Controllers {
|
2020-11-15 09:05:51 -05:00
|
|
|
class NotificationManager;
|
|
|
|
|
2020-04-28 13:31:58 -04:00
|
|
|
class AlertNotificationService {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
AlertNotificationService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager);
|
|
|
|
void Init();
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
int OnAlert(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt);
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
void AcceptIncomingCall();
|
|
|
|
void RejectIncomingCall();
|
|
|
|
void MuteIncomingCall();
|
2020-10-27 14:51:06 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
enum class IncomingCallResponses : uint8_t { Reject = 0x00, Answer = 0x01, Mute = 0x02 };
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-04-18 13:28:14 -04:00
|
|
|
enum class Categories : uint8_t {
|
|
|
|
SimpleAlert = 0x00,
|
|
|
|
Email = 0x01,
|
|
|
|
News = 0x02,
|
|
|
|
Call = 0x03,
|
|
|
|
MissedCall = 0x04,
|
|
|
|
MmsSms = 0x05,
|
|
|
|
VoiceMail = 0x06,
|
|
|
|
Schedule = 0x07,
|
|
|
|
HighPrioritizedAlert = 0x08,
|
|
|
|
InstantMessage = 0x09,
|
|
|
|
All = 0xff
|
|
|
|
};
|
2020-10-27 14:51:06 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
static constexpr uint16_t ansId {0x1811};
|
|
|
|
static constexpr uint16_t ansCharId {0x2a46};
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
static constexpr ble_uuid16_t ansUuid {.u {.type = BLE_UUID_TYPE_16}, .value = ansId};
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
static constexpr ble_uuid16_t ansCharUuid {.u {.type = BLE_UUID_TYPE_16}, .value = ansCharId};
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
static constexpr ble_uuid128_t notificationEventUuid {.u {.type = BLE_UUID_TYPE_128}, .value = NOTIFICATION_EVENT_SERVICE_UUID_BASE};
|
2020-10-27 14:51:06 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
struct ble_gatt_chr_def characteristicDefinition[3];
|
|
|
|
struct ble_gatt_svc_def serviceDefinition[2];
|
2020-04-28 13:31:58 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
|
|
|
NotificationManager& notificationManager;
|
2020-10-27 14:51:06 -04:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
uint16_t eventHandle;
|
2020-04-28 13:31:58 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|