Skip to content

Commit

Permalink
clear characteristic cccd value when disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
fabik111 committed Dec 9, 2024
1 parent 30e2cac commit 2355c4d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,22 @@ bool ATTClass::disconnect()

numDisconnects++;

BLEDevice bleDevice(_peers[i].addressType, _peers[i].address);

// clear CCCD values on disconnect
for (uint16_t att = 0; att < GATT.attributeCount(); att++) {
BLELocalAttribute* attribute = GATT.attribute(att);

if (attribute->type() == BLETypeCharacteristic) {
BLELocalCharacteristic* characteristic = (BLELocalCharacteristic*)attribute;

characteristic->writeCccdValue(bleDevice, 0x0000);
}
}

_longWriteHandle = 0x0000;
_longWriteValueLength = 0;

_peers[i].connectionHandle = 0xffff;
_peers[i].role = 0x00;
_peers[i].addressType = 0x00;
Expand Down

0 comments on commit 2355c4d

Please sign in to comment.