Skip to content

Commit c3128cd

Browse files
author
Cruz Monrreal
authored
Merge pull request #7981 from paul-szczepanek-arm/ondatasent
BLE: fix missing updates sent callback in GattServer using Cordio stack
2 parents 7bcb066 + 44d3504 commit c3128cd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioGattServer.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,22 +624,30 @@ ble_error_t GattServer::write(
624624
// successful
625625
uint16_t conn_id = 0;
626626
uint16_t conn_found = 0;
627+
size_t updates_sent = 0;
628+
627629
while((conn_found < DM_CONN_MAX) && (conn_id < CONNECTION_ID_LIMIT)) {
628630
if (DmConnInUse(conn_id) == true) {
629631
++conn_found;
630632
if (is_update_authorized(conn_id, att_handle)) {
631633
uint16_t cccd_config = AttsCccEnabled(conn_id, cccd_index);
632634
if (cccd_config & ATT_CLIENT_CFG_NOTIFY) {
633635
AttsHandleValueNtf(conn_id, att_handle, len, (uint8_t*)buffer);
636+
updates_sent++;
634637
}
635638
if (cccd_config & ATT_CLIENT_CFG_INDICATE) {
636639
AttsHandleValueInd(conn_id, att_handle, len, (uint8_t*)buffer);
640+
updates_sent++;
637641
}
638642
}
639643
}
640644
++conn_id;
641645
}
642646

647+
if (updates_sent) {
648+
handleDataSentEvent(updates_sent);
649+
}
650+
643651
return BLE_ERROR_NONE;
644652
}
645653

@@ -674,16 +682,24 @@ ble_error_t GattServer::write(
674682
}
675683

676684
// This characteristic has a CCCD attribute. Handle notifications and indications.
685+
size_t updates_sent = 0;
686+
677687
if (is_update_authorized(connection, att_handle)) {
678688
uint16_t cccEnabled = AttsCccEnabled(connection, cccd_index);
679689
if (cccEnabled & ATT_CLIENT_CFG_NOTIFY) {
680690
AttsHandleValueNtf(connection, att_handle, len, (uint8_t*)buffer);
691+
updates_sent++;
681692
}
682693
if (cccEnabled & ATT_CLIENT_CFG_INDICATE) {
683694
AttsHandleValueInd(connection, att_handle, len, (uint8_t*)buffer);
695+
updates_sent++;
684696
}
685697
}
686698

699+
if (updates_sent) {
700+
handleDataSentEvent(updates_sent);
701+
}
702+
687703
return BLE_ERROR_NONE;
688704
}
689705

0 commit comments

Comments
 (0)