Skip to content

Commit 17d5356

Browse files
Merge pull request #4800 from Nodraak/fix/4799_ble_infinite_calling_loop
Fix infinite calling loop
2 parents ea12d69 + 2a39019 commit 17d5356

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

features/FEATURE_BLE/ble/GapAdvertisingData.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,20 @@ class GapAdvertisingData
357357
* Where the first element is the length of the field.
358358
*/
359359
const uint8_t* findField(DataType_t type) const {
360-
return findField(type);
360+
/* Scan through advertisement data */
361+
for (uint8_t idx = 0; idx < _payloadLen; ) {
362+
uint8_t fieldType = _payload[idx + 1];
363+
364+
if (fieldType == type) {
365+
return &_payload[idx];
366+
}
367+
368+
/* Advance to next field */
369+
idx += _payload[idx] + 1;
370+
}
371+
372+
/* Field not found */
373+
return NULL;
361374
}
362375

363376
private:
@@ -408,20 +421,7 @@ class GapAdvertisingData
408421
* otherwise. Where the first element is the length of the field.
409422
*/
410423
uint8_t* findField(DataType_t type) {
411-
/* Scan through advertisement data */
412-
for (uint8_t idx = 0; idx < _payloadLen; ) {
413-
uint8_t fieldType = _payload[idx + 1];
414-
415-
if (fieldType == type) {
416-
return &_payload[idx];
417-
}
418-
419-
/* Advance to next field */
420-
idx += _payload[idx] + 1;
421-
}
422-
423-
/* Field not found */
424-
return NULL;
424+
return const_cast<uint8_t*>(static_cast<const GapAdvertisingData*>(this)->findField(type));
425425
}
426426

427427
/**

0 commit comments

Comments
 (0)