|
22 | 22 |
|
23 | 23 | #include "GAP.h"
|
24 | 24 |
|
25 |
| -#define GAP_MAX_DISCOVERED_QUEUE_SIZE 5 |
| 25 | +#define GAP_MAX_DISCOVERED_QUEUE_SIZE 32 |
26 | 26 |
|
27 | 27 | #define GAP_ADV_IND (0x00)
|
28 | 28 | #define GAP_ADV_SCAN_IND (0x02)
|
@@ -86,8 +86,14 @@ int GAPClass::scan(bool withDuplicates)
|
86 | 86 | {
|
87 | 87 | HCI.leSetScanEnable(false, true);
|
88 | 88 |
|
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) { |
91 | 97 | return false;
|
92 | 98 | }
|
93 | 99 |
|
@@ -216,8 +222,10 @@ void GAPClass::handleLeAdvertisingReport(uint8_t type, uint8_t addressType, uint
|
216 | 222 |
|
217 | 223 | if (discoveredDevice == NULL) {
|
218 | 224 | if (_discoveredDevices.size() >= GAP_MAX_DISCOVERED_QUEUE_SIZE) {
|
219 |
| - // drop |
220 |
| - return; |
| 225 | + BLEDevice* device_first = _discoveredDevices.remove(0); |
| 226 | + if (device_first != NULL) { |
| 227 | + delete device_first; |
| 228 | + } |
221 | 229 | }
|
222 | 230 |
|
223 | 231 | discoveredDevice = new BLEDevice(addressType, address);
|
|
0 commit comments