C++ Pixels Library For Windows
Enable communications with Pixels dice using Bluetooth Low Energy.
Loading...
Searching...
No Matches
Systemic::BluetoothLE::Scanner Class Referencefinal

Implements scanning of Bluetooth Low Energy (BLE) peripherals. It stores and notifies of discovered peripherals with ScannedPeripheral objects. More...

#include <Scanner.h>

Public Member Functions

 Scanner (std::function< void(std::shared_ptr< const ScannedPeripheral >)> peripheralDiscovered, std::vector< winrt::guid > services=std::vector< winrt::guid >{})
 Initializes a new instance of Scanner and immediately starts scanning for BLE peripherals. More...
 
void copyDiscoveredPeripherals (std::vector< std::shared_ptr< const ScannedPeripheral > > &outDiscoveredPeripherals)
 Copy the discovered peripherals to the given std::vector. More...
 
 ~Scanner ()
 Stops the scan and destroys the Scanner instance.
 

Detailed Description

Implements scanning of Bluetooth Low Energy (BLE) peripherals. It stores and notifies of discovered peripherals with ScannedPeripheral objects.

The Scanner class internally stores a WinRT's BluetoothLEAdvertisementWatcher object.

See also
https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.advertisement.bluetoothleadvertisementwatcher

Constructor & Destructor Documentation

◆ Scanner()

Systemic::BluetoothLE::Scanner::Scanner ( std::function< void(std::shared_ptr< const ScannedPeripheral >)>  peripheralDiscovered,
std::vector< winrt::guid >  services = std::vector<winrt::guid>{} 
)

Initializes a new instance of Scanner and immediately starts scanning for BLE peripherals.

Parameters
peripheralDiscoveredCalled for each received advertisement packet.
When receiving a scan response, the advertisement data is combined with the data from the last DiscoveredPeripheral instance created for the same peripheral before being passed to this callback.
servicesList of services UUIDs that the peripheral should advertise, may be empty.

Member Function Documentation

◆ copyDiscoveredPeripherals()

void Systemic::BluetoothLE::Scanner::copyDiscoveredPeripherals ( std::vector< std::shared_ptr< const ScannedPeripheral > > &  outDiscoveredPeripherals)

Copy the discovered peripherals to the given std::vector.

Peripherals are copied in no particular order, which may vary from one call to another.

Parameters
outDiscoveredPeripheralsA std::vector to which the discovered peripherals are copied (appended).

The documentation for this class was generated from the following file: