Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/NimBLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,23 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
}

peerInfo.m_desc = event->disconnect.conn;

// Notify characteristics that the client has unsubscribed.
// This ensures onSubscribe callbacks are called with subValue=0
// so applications can clean up their subscription state.
for (const auto& svc : pServer->m_svcVec) {
for (const auto& chr : svc->getCharacteristics()) {
auto subscribers = chr->getSubscribers();
for (const auto& entry : subscribers) {
if (entry.getConnHandle() == event->disconnect.conn.conn_handle &&
(entry.isSubNotify() || entry.isSubIndicate())) {
chr->processSubRequest(peerInfo, 0);
break;
}
}
}
}

pServer->m_pServerCallbacks->onDisconnect(pServer, peerInfo, event->disconnect.reason);
# if !MYNEWT_VAL(BLE_EXT_ADV)
if (pServer->m_advertiseOnDisconnect) {
Expand Down