Skip to content

Commit ec4e64c

Browse files
committed
Fix characteristic value unable to be updated in callback
1 parent 8abb4d5 commit ec4e64c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/NimBLEServer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,9 @@ int NimBLEServer::handleGattEvent(uint16_t connHandle, uint16_t attrHandle, ble_
611611
NIMBLE_LOGD(LOG_TAG,
612612
"Gatt %s event",
613613
(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) ? "Read" : "Write");
614-
auto pAtt = static_cast<NimBLELocalValueAttribute*>(arg);
615-
auto val = pAtt->getAttVal();
614+
auto pAtt = static_cast<NimBLELocalValueAttribute*>(arg);
615+
const NimBLEAttValue& val = pAtt->getAttVal();
616+
616617
NimBLEConnInfo peerInfo{};
617618
ble_gap_conn_find(connHandle, &peerInfo.m_desc);
618619

@@ -623,7 +624,7 @@ int NimBLEServer::handleGattEvent(uint16_t connHandle, uint16_t attrHandle, ble_
623624
if (connHandle != BLE_HS_CONN_HANDLE_NONE) {
624625
// If the packet header is only 8 bytes then this is a follow up of a long read
625626
// so we don't want to call the onRead() callback again.
626-
if (ctxt->om->om_pkthdr_len > 8 || pAtt->getAttVal().size() <= (ble_att_mtu(connHandle) - 3)) {
627+
if (ctxt->om->om_pkthdr_len > 8 || val.size() <= (ble_att_mtu(connHandle) - 3)) {
627628
pAtt->readEvent(peerInfo);
628629
}
629630
}

0 commit comments

Comments
 (0)