Notifications (#3002)

This commit is contained in:
Totoo
2026-02-19 14:33:01 +01:00
committed by GitHub
parent 77f747aab2
commit 6498f5a1b2
27 changed files with 424 additions and 70 deletions
+30
View File
@@ -154,6 +154,7 @@ class Message {
MorseTXkey = 96,
StreamTXConfiguration = 97,
RTTYData = 98,
NotificationData = 99,
MAX
};
@@ -1793,4 +1794,33 @@ class RTTYDataMessage : public Message {
static constexpr uint16_t max_len = 490;
};
class NotificationDataMessage : public Message {
public:
constexpr NotificationDataMessage(const char* source_app, const char* title, const char* message, uint8_t icon = 0, uint16_t timeout = 10000)
: Message{ID::NotificationData},
icon(icon),
timeout(timeout) {
if (source_app) {
size_t len = std::min(strlen(source_app), (size_t)19);
memcpy(this->source_app, source_app, len);
this->source_app[len] = '\0';
}
if (title) {
size_t len = std::min(strlen(title), (size_t)49);
memcpy(this->title, title, len);
this->title[len] = '\0';
}
if (message) {
size_t len = std::min(strlen(message), (size_t)299);
memcpy(this->message, message, len);
this->message[len] = '\0';
}
}
char source_app[20]{0}; // source application name, null-terminated, max 19 chars + null
char title[50]{0}; // title, null-terminated, max 49 chars + null
char message[300]{0}; // message, null-terminated, max 299 chars + null
uint8_t icon = 0;
uint16_t timeout = 10000;
};
#endif /*__MESSAGE_H__*/