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 5, 2024
1 parent 30e2cac commit d909b6c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 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 All @@ -566,6 +582,7 @@ bool ATTClass::disconnect()
_peers[i].device = NULL;
}


return (numDisconnects > 0);
}

Expand Down

0 comments on commit d909b6c

Please sign in to comment.