2020-04-28 17:31:58 +00:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <array>
|
2020-11-15 14:05:51 +00:00
|
|
|
#define min // workaround: nimble's min/max macros conflict with libstdc++
|
|
|
|
#define max
|
2020-04-28 17:31:58 +00:00
|
|
|
#include <host/ble_gap.h>
|
2020-11-15 14:05:51 +00:00
|
|
|
#undef max
|
|
|
|
#undef min
|
2020-04-28 17:31:58 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-11-15 14:05:51 +00:00
|
|
|
|
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
}
|
2020-04-28 17:31:58 +00:00
|
|
|
namespace Controllers {
|
2020-11-15 14:05:51 +00:00
|
|
|
class NotificationManager;
|
|
|
|
|
2020-04-28 17:31:58 +00:00
|
|
|
class AlertNotificationService {
|
|
|
|
public:
|
|
|
|
AlertNotificationService(Pinetime::System::SystemTask &systemTask,
|
|
|
|
Pinetime::Controllers::NotificationManager ¬ificationManager);
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
int OnAlert(uint16_t conn_handle, uint16_t attr_handle,
|
|
|
|
struct ble_gatt_access_ctxt *ctxt);
|
|
|
|
|
2020-10-27 18:51:06 +00:00
|
|
|
void event(char event);
|
|
|
|
|
|
|
|
static const char EVENT_HANG_UP_CALL = 0x00;
|
|
|
|
static const char EVENT_ANSWER_CALL = 0x01;
|
|
|
|
|
2020-04-28 17:31:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-10-27 18:51:06 +00:00
|
|
|
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;
|
|
|
|
|
2020-04-28 17:31:58 +00:00
|
|
|
static constexpr uint16_t ansId {0x1811};
|
|
|
|
static constexpr uint16_t ansCharId {0x2a46};
|
2020-10-27 18:51:06 +00:00
|
|
|
static constexpr uint16_t ansEventCharId = {0x2a47};
|
2020-04-28 17:31:58 +00:00
|
|
|
|
|
|
|
static constexpr ble_uuid16_t ansUuid {
|
|
|
|
.u { .type = BLE_UUID_TYPE_16 },
|
|
|
|
.value = ansId
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr ble_uuid16_t ansCharUuid {
|
|
|
|
.u { .type = BLE_UUID_TYPE_16 },
|
|
|
|
.value = ansCharId
|
|
|
|
};
|
|
|
|
|
2020-10-27 18:51:06 +00:00
|
|
|
static constexpr ble_uuid16_t ansEventUuid {
|
|
|
|
.u { .type = BLE_UUID_TYPE_16 },
|
|
|
|
.value = ansEventCharId
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ble_gatt_chr_def characteristicDefinition[3];
|
2020-04-28 17:31:58 +00:00
|
|
|
struct ble_gatt_svc_def serviceDefinition[2];
|
|
|
|
|
2020-10-21 15:31:56 +00:00
|
|
|
Pinetime::System::SystemTask &systemTask;
|
|
|
|
NotificationManager ¬ificationManager;
|
2020-10-27 18:51:06 +00:00
|
|
|
|
|
|
|
uint16_t eventHandle;
|
2020-04-28 17:31:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|