From fac16f24281c4abc01f925f93f9362b22eb222f7 Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 13 Jan 2022 08:57:50 -0700 Subject: [PATCH] Fix long data notifications. The notification data when received was using an incorrect length value and would cut off long values, this has now been corrected. --- src/NimBLEClient.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 536626f..f5a1685 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -973,10 +973,10 @@ uint16_t NimBLEClient::getMTU() { NIMBLE_LOGD(LOG_TAG, "Got Notification for characteristic %s", (*characteristic)->toString().c_str()); + uint32_t data_len = OS_MBUF_PKTLEN(event->notify_rx.om); time_t t = time(nullptr); ble_npl_hw_enter_critical(); - (*characteristic)->m_value = std::string((char *)event->notify_rx.om->om_data, - event->notify_rx.om->om_len); + (*characteristic)->m_value = std::string((char *)event->notify_rx.om->om_data, data_len); (*characteristic)->m_timestamp = t; ble_npl_hw_exit_critical(0); @@ -984,8 +984,7 @@ uint16_t NimBLEClient::getMTU() { NIMBLE_LOGD(LOG_TAG, "Invoking callback for notification on characteristic %s", (*characteristic)->toString().c_str()); (*characteristic)->m_notifyCallback(*characteristic, event->notify_rx.om->om_data, - event->notify_rx.om->om_len, - !event->notify_rx.indication); + data_len, !event->notify_rx.indication); } break; }