aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ble/AlertNotificationClient.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-04-09 21:16:21 +0200
committerJean-François Milants <jf@codingfield.com>2021-04-09 21:16:21 +0200
commit15b3b8e282dd5b2132b0095716cd9d88740d4579 (patch)
treec26870103f8baaa933399cfb86cca25aa7e60d8b /src/components/ble/AlertNotificationClient.cpp
parent9ac4be8b759bb2cedeb999ce5e87d983261beded (diff)
parent57b4c3f0edc6acfa31bd2160abdcd6091920ba63 (diff)
Merge branch 'develop' into motion-sensor
# Conflicts: # src/CMakeLists.txt # src/displayapp/Apps.h # src/displayapp/DisplayApp.cpp # src/displayapp/DisplayApp.h # src/displayapp/lv_pinetime_theme.c # src/displayapp/screens/ApplicationList.cpp # src/drivers/TwiMaster.cpp # src/systemtask/SystemTask.h
Diffstat (limited to 'src/components/ble/AlertNotificationClient.cpp')
-rw-r--r--src/components/ble/AlertNotificationClient.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp
index e7a18626..9efede39 100644
--- a/src/components/ble/AlertNotificationClient.cpp
+++ b/src/components/ble/AlertNotificationClient.cpp
@@ -158,13 +158,17 @@ void AlertNotificationClient::OnNotification(ble_gap_event *event) {
const auto maxMessageSize{NotificationManager::MaximumMessageSize()};
const auto maxBufferSize{maxMessageSize + headerSize};
- const auto dbgPacketLen = OS_MBUF_PKTLEN(event->notify_rx.om);
- size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize);
+ // Ignore notifications with empty message
+ const auto packetLen = OS_MBUF_PKTLEN(event->notify_rx.om);
+ if(packetLen <= headerSize) return;
+
+ size_t bufferSize = std::min(packetLen + stringTerminatorSize, maxBufferSize);
auto messageSize = std::min(maxMessageSize, (bufferSize - headerSize));
NotificationManager::Notification notif;
os_mbuf_copydata(event->notify_rx.om, headerSize, messageSize - 1, notif.message.data());
notif.message[messageSize - 1] = '\0';
+ notif.size = messageSize;
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));