diff options
| author | JF <jf@codingfield.com> | 2020-10-22 08:43:42 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-10-22 08:43:42 (GMT) |
| commit | 07b6812f61cf5b7726fbf6015c2c60caa12c7f20 (patch) | |
| tree | 1dc7a0e6c2dbf9760437e61b38602f87a5537ec9 /src/components/ble/NotificationManager.cpp | |
| parent | cabf1168d429db84b0985e25881ead86d80dde3c (diff) | |
Notifications : Fix copy when the messages is spread across multiple os_mbuf.
Diffstat (limited to 'src/components/ble/NotificationManager.cpp')
| -rw-r--r-- | src/components/ble/NotificationManager.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp index 11555be..6771172 100644 --- a/src/components/ble/NotificationManager.cpp +++ b/src/components/ble/NotificationManager.cpp @@ -7,17 +7,10 @@ using namespace Pinetime::Controllers; constexpr uint8_t NotificationManager::MessageSize; -void NotificationManager::Push(Pinetime::Controllers::NotificationManager::Categories category, - const char *message, uint8_t currentMessageSize) { - // TODO handle edge cases on read/write index - auto checkedSize = std::min(currentMessageSize, MessageSize); - auto& notif = notifications[writeIndex]; - std::memcpy(notif.message.data(), message, checkedSize); - notif.message[checkedSize] = '\0'; - notif.category = category; +void NotificationManager::Push(NotificationManager::Notification &¬if) { notif.id = GetNextId(); notif.valid = true; - + notifications[writeIndex] = std::move(notif); writeIndex = (writeIndex + 1 < TotalNbNotifications) ? writeIndex + 1 : 0; if(!empty) readIndex = (readIndex + 1 < TotalNbNotifications) ? readIndex + 1 : 0; |
