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.
This commit is contained in:
h2zero 2022-01-13 08:57:50 -07:00
parent 0957d7f6ad
commit fac16f2428

View file

@ -973,10 +973,10 @@ uint16_t NimBLEClient::getMTU() {
NIMBLE_LOGD(LOG_TAG, "Got Notification for characteristic %s", NIMBLE_LOGD(LOG_TAG, "Got Notification for characteristic %s",
(*characteristic)->toString().c_str()); (*characteristic)->toString().c_str());
uint32_t data_len = OS_MBUF_PKTLEN(event->notify_rx.om);
time_t t = time(nullptr); time_t t = time(nullptr);
ble_npl_hw_enter_critical(); ble_npl_hw_enter_critical();
(*characteristic)->m_value = std::string((char *)event->notify_rx.om->om_data, (*characteristic)->m_value = std::string((char *)event->notify_rx.om->om_data, data_len);
event->notify_rx.om->om_len);
(*characteristic)->m_timestamp = t; (*characteristic)->m_timestamp = t;
ble_npl_hw_exit_critical(0); 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", NIMBLE_LOGD(LOG_TAG, "Invoking callback for notification on characteristic %s",
(*characteristic)->toString().c_str()); (*characteristic)->toString().c_str());
(*characteristic)->m_notifyCallback(*characteristic, event->notify_rx.om->om_data, (*characteristic)->m_notifyCallback(*characteristic, event->notify_rx.om->om_data,
event->notify_rx.om->om_len, data_len, !event->notify_rx.indication);
!event->notify_rx.indication);
} }
break; break;
} }