From 3934e9bef20c5c2ad393e20cfff3a5a1b0d24569 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 4 Apr 2021 15:19:37 +0200 Subject: Ignore notification with empty message. --- src/components/ble/AlertNotificationClient.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/components/ble/AlertNotificationClient.cpp') diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp index cfb3272d..9efede39 100644 --- a/src/components/ble/AlertNotificationClient.cpp +++ b/src/components/ble/AlertNotificationClient.cpp @@ -158,8 +158,11 @@ 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; -- cgit v1.2.3-70-g09d2