SDK  23.9.2
For IoT System Software Development
Public Member Functions | List of all members
BLEScan Class Reference

Perform and manage BLE scans. More...

#include <BLEScan.hpp>

Public Member Functions

void setActiveScan (bool active)
 Should we perform an active or passive scan? The default is a passive scan. An active scan means that we will wish a scan response. More...
 
void setAdvertisedDeviceCallbacks (BLEAdvertisedDeviceCallbacks *pAdvertisedDeviceCallbacks, bool wantDuplicates=false)
 Set the call backs to be invoked. More...
 
void setInterval (uint16_t intervalMSecs)
 Set the interval to scan. More...
 
void setWindow (uint16_t windowMSecs)
 Set the window to actively scan. More...
 
bool start (uint32_t duration, void(*scanCompleteCB)(BLEScanResults), bool is_continue=false, uint8_t maxNumDevices=0)
 Start scanning. More...
 
BLEScanResults start (uint32_t duration, bool is_continue=false, uint8_t maxNumDevices=0)
 Start scanning and block until scanning has been completed. More...
 
void stop ()
 Stop an in progress scan. More...
 
void erase (BLEAddress address)
 
BLEScanResults getResults ()
 Get scan results.
 
void clearResults ()
 

Detailed Description

Perform and manage BLE scans.

Scanning is associated with a BLE client that is attempting to locate BLE servers.

Member Function Documentation

◆ setActiveScan()

void BLEScan::setActiveScan ( bool  active)

Should we perform an active or passive scan? The default is a passive scan. An active scan means that we will wish a scan response.

Parameters
[in]activeIf true, we perform an active scan otherwise a passive scan.
Returns
N/A.

◆ setAdvertisedDeviceCallbacks()

void BLEScan::setAdvertisedDeviceCallbacks ( BLEAdvertisedDeviceCallbacks pAdvertisedDeviceCallbacks,
bool  wantDuplicates = false 
)

Set the call backs to be invoked.

Parameters
[in]pAdvertisedDeviceCallbacksCall backs to be invoked.
[in]wantDuplicatesTrue if we wish to be called back with duplicates. Default is false.
39  {
40  m_wantDuplicates = wantDuplicates;
41  m_pAdvertisedDeviceCallbacks = pAdvertisedDeviceCallbacks;
42 } // setAdvertisedDeviceCallbacks

◆ setInterval()

void BLEScan::setInterval ( uint16_t  intervalMSecs)

Set the interval to scan.

Parameters
[in]Theinterval in msecs.

◆ setWindow()

void BLEScan::setWindow ( uint16_t  windowMSecs)

Set the window to actively scan.

Parameters
[in]windowMSecsHow long to actively scan.

◆ start() [1/2]

BLEScanResults BLEScan::start ( uint32_t  duration,
bool  is_continue = false,
uint8_t  maxNumDevices = 0 
)

Start scanning and block until scanning has been completed.

Parameters
[in]durationThe duration in seconds for which to scan.
[in]is_continueare we continue scan (true) or we want to clear stored devices (false)
[in]maxNumDevicesThe maximum device number of scan result. If the number of scanned devices reaches maxNumDevices, the scan is stopped and scanCompleteCB is called directly. If 0 (default), there is no limit.
Returns
The BLEScanResults.
45  {
46  if(start(duration, nullptr, is_continue, maxNumDevices)) {
47  m_spinlockScanEnd.wait(); // Wait for the semaphore to release.
48  }
49  return m_scanResults;
50 } // start

◆ start() [2/2]

bool BLEScan::start ( uint32_t  duration,
void(*)(BLEScanResults scanCompleteCB,
bool  is_continue = false,
uint8_t  maxNumDevices = 0 
)

Start scanning.

Parameters
[in]durationThe duration in seconds for which to scan.
[in]scanCompleteCBA function to be called when scanning has completed.
[in]is_continueare we continue scan (true) or we want to clear stored devices (false)
[in]maxNumDevicesThe maximum device number of scan result. If the number of scanned devices reaches maxNumDevices, the scan is stopped and scanCompleteCB is called directly. If 0 (default), there is no limit.
Returns
True if scan started or false if there was an error.

◆ stop()

void BLEScan::stop ( )

Stop an in progress scan.

Returns
N/A.

The documentation for this class was generated from the following files:
BLEScan::start
bool start(uint32_t duration, void(*scanCompleteCB)(BLEScanResults), bool is_continue=false, uint8_t maxNumDevices=0)
Start scanning.