Skip to content

Clear characteristic cccd value when disconnect #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
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
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 @@

numDisconnects++;

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

Check warning on line 556 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L556

Added line #L556 was not covered by tests

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

Check warning on line 560 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L559-L560

Added lines #L559 - L560 were not covered by tests

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

Check warning on line 563 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L562-L563

Added lines #L562 - L563 were not covered by tests

characteristic->writeCccdValue(bleDevice, 0x0000);

Check warning on line 565 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L565

Added line #L565 was not covered by tests
}
}

_longWriteHandle = 0x0000;
_longWriteValueLength = 0;

Check warning on line 570 in src/utility/ATT.cpp

View check run for this annotation

Codecov / codecov/patch

src/utility/ATT.cpp#L569-L570

Added lines #L569 - L570 were not covered by tests

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