18#ifndef NIMBLE_CPP_SCAN_H_
19#define NIMBLE_CPP_SCAN_H_
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
24# include "NimBLEAdvertisedDevice.h"
25# include "NimBLEUtils.h"
27# if defined(CONFIG_NIMBLE_CPP_IDF)
28# include "host/ble_gap.h"
30# include "nimble/nimble/host/include/host/ble_gap.h"
54 std::vector<NimBLEAdvertisedDevice*>::const_iterator
begin()
const;
55 std::vector<NimBLEAdvertisedDevice*>::const_iterator
end()
const;
59 std::vector<NimBLEAdvertisedDevice*> m_deviceVec;
69 bool start(uint32_t duration,
bool isContinue =
false,
bool restart =
true);
86# if CONFIG_BT_NIMBLE_EXT_ADV
87 enum Phy { SCAN_1M = 0x01, SCAN_CODED = 0x02, SCAN_ALL = 0x03 };
97 static int handleGapEvent(ble_gap_event* event,
void* arg);
101 ble_gap_disc_params m_scanParams;
104 uint8_t m_maxResults;
106# if CONFIG_BT_NIMBLE_EXT_ADV
107 uint8_t m_phy{SCAN_ALL};
108 uint16_t m_period{0};
A BLE device address.
Definition NimBLEAddress.h:41
A representation of a BLE advertised device found by a scan.
Definition NimBLEAdvertisedDevice.h:45
A model of a BLE Device from which all the BLE roles are created.
Definition NimBLEDevice.h:109
A callback handler for callbacks associated device scanning.
Definition NimBLEScan.h:115
virtual void onDiscovered(const NimBLEAdvertisedDevice *advertisedDevice)
Called when a new device is discovered, before the scan result is received (if applicable).
Definition NimBLEScan.cpp:538
virtual void onScanEnd(const NimBLEScanResults &scanResults, int reason)
Called when a scan operation ends.
Definition NimBLEScan.cpp:546
virtual void onResult(const NimBLEAdvertisedDevice *advertisedDevice)
Called when a new scan result is complete, including scan response data (if applicable).
Definition NimBLEScan.cpp:542
Perform and manage BLE scans.
Definition NimBLEScan.h:67
void setWindow(uint16_t windowMs)
Set the window to actively scan.
Definition NimBLEScan.cpp:257
void setPhy(Phy phyMask)
Set the PHYs to scan.
Definition NimBLEScan.cpp:276
NimBLEScanResults getResults()
Get the results of the scan.
Definition NimBLEScan.cpp:463
void setScanCallbacks(NimBLEScanCallbacks *pScanCallbacks, bool wantDuplicates=false)
Set the call backs to be invoked.
Definition NimBLEScan.cpp:234
void setFilterPolicy(uint8_t filter)
Sets the scan filter policy.
Definition NimBLEScan.cpp:216
void setInterval(uint16_t intervalMs)
Set the interval to scan.
Definition NimBLEScan.cpp:249
void erase(const NimBLEAddress &address)
Delete peer device from the scan results vector.
Definition NimBLEScan.cpp:398
bool stop()
Stop an in progress scan.
Definition NimBLEScan.cpp:373
void setLimitedOnly(bool enabled)
Set whether or not the BLE controller only reports scan results from devices advertising in limited d...
Definition NimBLEScan.cpp:194
void setActiveScan(bool active)
Should we perform an active or passive scan? The default is a passive scan. An active scan means that...
Definition NimBLEScan.cpp:171
void setPeriod(uint32_t periodMs)
Set the extended scanning period.
Definition NimBLEScan.cpp:287
void setDuplicateFilter(uint8_t enabled)
Set whether or not the BLE controller should only report results from devices it has not already seen...
Definition NimBLEScan.cpp:185
void setMaxResults(uint8_t maxResults)
Sets the max number of results to store.
Definition NimBLEScan.cpp:225
bool isScanning()
Get the status of the scanner.
Definition NimBLEScan.cpp:265
bool start(uint32_t duration, bool isContinue=false, bool restart=true)
Start scanning.
Definition NimBLEScan.cpp:300
void clearResults()
Clear the stored results of the scan.
Definition NimBLEScan.cpp:470
A class that contains and operates on the results of a BLE scan.
Definition NimBLEScan.h:48
std::vector< NimBLEAdvertisedDevice * >::const_iterator end() const
Get iterator to the end of the vector of advertised device pointers.
Definition NimBLEScan.cpp:516
int getCount() const
Get the count of devices found in the last scan.
Definition NimBLEScan.cpp:490
std::vector< NimBLEAdvertisedDevice * >::const_iterator begin() const
Get iterator to the beginning of the vector of advertised device pointers.
Definition NimBLEScan.cpp:508
const NimBLEAdvertisedDevice * getDevice(uint32_t idx) const
Return the specified device at the given index. The index should be between 0 and getCount()-1.
Definition NimBLEScan.cpp:500
void dump() const
Dump the scan results to the log.
Definition NimBLEScan.cpp:480
A structure to hold data for a task that is waiting for a response.
Definition NimBLEUtils.h:32