Skip to content

Commit 07d249a

Browse files
committed
Fix BLE scanning block after few minutes
1 parent dd56eb7 commit 07d249a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/utility/GAP.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "GAP.h"
2424

25-
#define GAP_MAX_DISCOVERED_QUEUE_SIZE 5
25+
#define GAP_MAX_DISCOVERED_QUEUE_SIZE 32
2626

2727
#define GAP_ADV_IND (0x00)
2828
#define GAP_ADV_SCAN_IND (0x02)
@@ -86,8 +86,14 @@ int GAPClass::scan(bool withDuplicates)
8686
{
8787
HCI.leSetScanEnable(false, true);
8888

89-
// active scan, 10 ms scan interval (N * 0.625), 10 ms scan window (N * 0.625), public own address type, no filter
90-
if (HCI.leSetScanParameters(0x01, 0x0010, 0x0010, 0x00, 0x00) != 0) {
89+
// active scan, 20 ms scan interval (N * 0.625), 20 ms scan window (N * 0.625), public own address type, no filter
90+
/*
91+
Warning (from BLUETOOTH SPECIFICATION 5.x):
92+
- scan interval: mandatory range from 0x0012 to 0x1000; only even values are valid
93+
- scan window: mandatory range from 0x0011 to 0x1000
94+
- The scan window can only be less than or equal to the scan interval
95+
*/
96+
if (HCI.leSetScanParameters(0x01, 0x0020, 0x0020, 0x00, 0x00) != 0) {
9197
return false;
9298
}
9399

@@ -216,8 +222,11 @@ void GAPClass::handleLeAdvertisingReport(uint8_t type, uint8_t addressType, uint
216222

217223
if (discoveredDevice == NULL) {
218224
if (_discoveredDevices.size() >= GAP_MAX_DISCOVERED_QUEUE_SIZE) {
219-
// drop
220-
return;
225+
// delete data in first list posistion
226+
BLEDevice* device_first = _discoveredDevices.remove(0);
227+
if (device_first != NULL) {
228+
delete device_first;
229+
}
221230
}
222231

223232
discoveredDevice = new BLEDevice(addressType, address);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy