6namespace ersa {
namespace protocols {
9inline uint32_t
readLe32(
const uint8_t* p) {
10 return uint32_t(p[0]) | (uint32_t(p[1]) << 8) |
11 (uint32_t(p[2]) << 16) | (uint32_t(p[3]) << 24);
15 for (
unsigned i = 0; i < 4; ++i) p[i] = uint8_t(value >> (8 * i));
35 void begin(uint32_t uid,
bool includeNegativeAction =
false) {
52 for (
unsigned i = 0; i < count; ++i) {
54 const uint8_t
id =
bytes_[pos];
55 const size_t len =
bytes_[pos + 1] | (size_t(
bytes_[pos + 2]) << 8);
56 const uint8_t expectedId = i == 0 ? 1 : (i == 1 ? 3 : 7);
62 memcpy(out,
bytes_ + pos, len);
73 static void request(uint32_t uid,
bool includeNegativeAction, uint8_t* out) {
76 out[5] = 1; out[6] = 31; out[7] = 0;
77 out[8] = 3; out[9] = 63; out[10] = 0;
78 if (includeNegativeAction) {
85 static void request(uint32_t uid, uint8_t (&out)[11]) {
97 if (c ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n')
continue;
98 normalized[n++] = (c >=
'A' && c <=
'Z') ?
char(c -
'A' +
'a') : c;
100 return strcmp(normalized,
"dismiss") == 0 || strcmp(normalized,
"clear") == 0;
137 bool action(uint32_t
id,
bool positive, uint8_t (&out)[6])
const {
138 if (!
ringing ||
id !=
uid || !(
flags & (positive ? 8 : 16)))
return false;
139 out[0] = 2;
writeLe32(out + 1,
uid); out[5] = positive ? 0 : 1;
Definition apple_notifications.h:26
Result feed(const uint8_t *data, size_t length)
Definition apple_notifications.h:44
uint32_t uid_
Definition apple_notifications.h:106
static void request(uint32_t uid, bool includeNegativeAction, uint8_t *out)
Definition apple_notifications.h:73
size_t size_
Definition apple_notifications.h:109
bool includeNegativeAction_
Definition apple_notifications.h:107
Result
Definition apple_notifications.h:29
uint8_t bytes_[140]
Definition apple_notifications.h:108
char negativeActionLabel[32]
Definition apple_notifications.h:104
void begin(uint32_t uid, bool includeNegativeAction=false)
Definition apple_notifications.h:35
static void request(uint32_t uid, uint8_t(&out)[11])
Definition apple_notifications.h:85
bool negativeActionIsDismissal() const
Definition apple_notifications.h:92
char title[32]
Definition apple_notifications.h:102
char message[64]
Definition apple_notifications.h:103
void writeLe32(uint8_t *p, uint32_t value)
Definition apple_notifications.h:14
uint32_t readLe32(const uint8_t *p)
Definition apple_notifications.h:9
Definition application.h:10
char data[MANIFEST_LIMIT]
Definition ota_service.cpp:33
size_t length
Definition ota_service.cpp:34
Definition apple_notifications.h:118
bool remove(uint32_t id)
Definition apple_notifications.h:128
uint8_t flags
Definition apple_notifications.h:122
void update(uint32_t id, uint8_t eventFlags)
Definition apple_notifications.h:126
bool action(uint32_t id, bool positive, uint8_t(&out)[6]) const
Definition apple_notifications.h:137
uint32_t uid
Definition apple_notifications.h:120
bool ringing
Definition apple_notifications.h:124