Skip to content

Commit f6b7952

Browse files
authored
Merge pull request #211 from Lukas-kV/master
fix of bad indexing in ATTClass::handleNotifyOrInd which affected BLE…
2 parents 236aeda + b155246 commit f6b7952

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/utility/ATT.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,14 +1359,14 @@ void ATTClass::handleNotifyOrInd(uint16_t connectionHandle, uint8_t opcode, uint
13591359
uint16_t handle;
13601360
} *handleNotifyOrInd = (HandleNotifyOrInd*)data;
13611361

1362-
uint8_t handle = handleNotifyOrInd->handle;
1362+
uint16_t handle = handleNotifyOrInd->handle;
13631363

1364-
for (int i = 0; i < ATT_MAX_PEERS; i++) {
1365-
if (_peers[i].connectionHandle != connectionHandle) {
1364+
for (int peer = 0; peer < ATT_MAX_PEERS; peer++) {
1365+
if (_peers[peer].connectionHandle != connectionHandle) {
13661366
continue;
13671367
}
13681368

1369-
BLERemoteDevice* device = _peers[i].device;
1369+
BLERemoteDevice* device = _peers[peer].device;
13701370

13711371
if (!device) {
13721372
break;
@@ -1384,7 +1384,7 @@ void ATTClass::handleNotifyOrInd(uint16_t connectionHandle, uint8_t opcode, uint
13841384
BLERemoteCharacteristic* c = s->characteristic(j);
13851385

13861386
if (c->valueHandle() == handle) {
1387-
c->writeValue(BLEDevice(_peers[i].addressType, _peers[i].address), &data[2], dlen - 2);
1387+
c->writeValue(BLEDevice(_peers[peer].addressType, _peers[peer].address), &data[2], dlen - 2);
13881388
}
13891389
}
13901390

0 commit comments

Comments
 (0)