diff options
author | Jean-François Milants <jf@codingfield.com> | 2021-04-09 21:16:21 +0200 |
---|---|---|
committer | Jean-François Milants <jf@codingfield.com> | 2021-04-09 21:16:21 +0200 |
commit | 15b3b8e282dd5b2132b0095716cd9d88740d4579 (patch) | |
tree | c26870103f8baaa933399cfb86cca25aa7e60d8b /src/components/ble/AlertNotificationService.cpp | |
parent | 9ac4be8b759bb2cedeb999ce5e87d983261beded (diff) | |
parent | 57b4c3f0edc6acfa31bd2160abdcd6091920ba63 (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/AlertNotificationService.cpp')
-rw-r--r-- | src/components/ble/AlertNotificationService.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp index 0639119c..d91e2090 100644 --- a/src/components/ble/AlertNotificationService.cpp +++ b/src/components/ble/AlertNotificationService.cpp @@ -66,8 +66,11 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle const auto maxMessageSize {NotificationManager::MaximumMessageSize()}; const auto maxBufferSize{maxMessageSize + headerSize}; - const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om); - size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize); + // Ignore notifications with empty message + const auto packetLen = OS_MBUF_PKTLEN(ctxt->om); + if(packetLen <= headerSize) return 0; + + size_t bufferSize = std::min(packetLen + stringTerminatorSize, maxBufferSize); auto messageSize = std::min(maxMessageSize, (bufferSize-headerSize)); Categories category; @@ -75,6 +78,7 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data()); os_mbuf_copydata(ctxt->om, 0, 1, &category); notif.message[messageSize-1] = '\0'; + notif.size = messageSize; // TODO convert all ANS categories to NotificationController categories switch(category) { |