Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Typedefs | Functions | Variables
direct_bt::BTDeviceRegistry Namespace Reference

Application toolkit providing BT device registration of processed and awaited devices. More...

Classes

struct  DeviceID
 Specifies unique device identities, using BDAddressAndType as key. More...
 
struct  DeviceQuery
 Specifies devices queries to act upon. More...
 

Typedefs

typedef bool(* DeviceQueryMatchFunc) (const EUI48 &address, const std::string &name, const DeviceQuery &q)
 Function for user defined BTDeviceRegistry::DeviceQuery matching criteria and algorithm. More...
 

Functions

void addToProcessedDevices (const BDAddressAndType &a, const std::string &n) noexcept
 
void addToWaitForDevices (const std::string &addrOrNameSub) noexcept
 
bool areAllDevicesProcessed () noexcept
 Returns true if all addToWaitForDevices() awaited devices have been addToProcessedDevices() processed. More...
 
bool areAllDevicesProcessed (DeviceQueryMatchFunc m) noexcept
 Returns true if all addToWaitForDevices() awaited devices have been addToProcessedDevices() processed. More...
 
void clearProcessedDevices () noexcept
 Clears internal list. More...
 
void clearWaitForDevices () noexcept
 Clears internal list. More...
 
size_t getProcessedDeviceCount () noexcept
 
jau::darray< DeviceIDgetProcessedDevices () noexcept
 Returns a copy of the current collection of processed DeviceID. More...
 
std::string getProcessedDevicesString () noexcept
 
jau::darray< DeviceQuery > & getWaitForDevices () noexcept
 Returns the reference of the current list of DeviceQuery, not a copy. More...
 
size_t getWaitForDevicesCount () noexcept
 
std::string getWaitForDevicesString () noexcept
 
bool isDeviceProcessed (const BDAddressAndType &a) noexcept
 
bool isWaitingForAnyDevice () noexcept
 
bool isWaitingForDevice (const EUI48 &address, const std::string &name) noexcept
 Returns true if the given address and/or name matches any of the BTDeviceRegistry::addToWaitForDevices() awaited devices. More...
 
bool isWaitingForDevice (const EUI48 &address, const std::string &name, DeviceQueryMatchFunc m) noexcept
 Returns true if the given address and/or name matches any of the BTDeviceRegistry::addToWaitForDevices() awaited devices. More...
 
bool operator!= (const DeviceID &lhs, const DeviceID &rhs) noexcept
 
bool operator== (const DeviceID &lhs, const DeviceID &rhs) noexcept
 

Variables

static std::unordered_set< DeviceIDdevicesProcessed
 
static std::recursive_mutex mtx_devicesProcessed
 
static jau::darray< DeviceQuerywaitForDevices
 

Detailed Description

Application toolkit providing BT device registration of processed and awaited devices.

The latter on a pattern matching basis, i.e. EUI48Sub or name-sub.

Typedef Documentation

◆ DeviceQueryMatchFunc

typedef bool(* direct_bt::BTDeviceRegistry::DeviceQueryMatchFunc) (const EUI48 &address, const std::string &name, const DeviceQuery &q)

Function for user defined BTDeviceRegistry::DeviceQuery matching criteria and algorithm.

Return true if the given address and/or name matches with the BTDeviceRegistry::DeviceQuery::addressSub and/or BTDeviceRegistry::DeviceQuery::nameSub.

Example (lambda):

   [](const EUI48& a, const std::string& n, const DeviceQuery& q)->bool {
      return q.isEUI48Sub() ? a.contains(q.addressSub) : n.find(q.nameSub) != std::string::npos;
   });

Definition at line 165 of file BTDeviceRegistry.hpp.

Function Documentation

◆ addToWaitForDevices()

void direct_bt::BTDeviceRegistry::addToWaitForDevices ( const std::string &  addrOrNameSub)
noexcept
Examples
dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 43 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ isWaitingForAnyDevice()

bool direct_bt::BTDeviceRegistry::isWaitingForAnyDevice ( )
noexcept
Examples
dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 53 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getWaitForDevicesCount()

size_t direct_bt::BTDeviceRegistry::getWaitForDevicesCount ( )
noexcept
Examples
dbt_scanner10.cpp.

Definition at line 56 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getWaitForDevicesString()

std::string direct_bt::BTDeviceRegistry::getWaitForDevicesString ( )
noexcept
Examples
dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 59 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getWaitForDevices()

jau::darray< DeviceQuery > & direct_bt::BTDeviceRegistry::getWaitForDevices ( )
noexcept

Returns the reference of the current list of DeviceQuery, not a copy.

Definition at line 70 of file BTDeviceRegistry.cpp.

◆ clearWaitForDevices()

void direct_bt::BTDeviceRegistry::clearWaitForDevices ( )
noexcept

Clears internal list.

Definition at line 73 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ operator==()

bool direct_bt::BTDeviceRegistry::operator== ( const DeviceID lhs,
const DeviceID rhs 
)
inlinenoexcept

Implementation simply tests the BDAddressAndType fields for equality, name is ignored.

Definition at line 125 of file BTDeviceRegistry.hpp.

◆ operator!=()

bool direct_bt::BTDeviceRegistry::operator!= ( const DeviceID lhs,
const DeviceID rhs 
)
inlinenoexcept

Definition at line 131 of file BTDeviceRegistry.hpp.

◆ addToProcessedDevices()

void direct_bt::BTDeviceRegistry::addToProcessedDevices ( const BDAddressAndType a,
const std::string &  n 
)
noexcept
Examples
dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 77 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ isDeviceProcessed()

bool direct_bt::BTDeviceRegistry::isDeviceProcessed ( const BDAddressAndType a)
noexcept
Examples
dbt_scanner10.cpp.

Definition at line 81 of file BTDeviceRegistry.cpp.

◆ getProcessedDeviceCount()

size_t direct_bt::BTDeviceRegistry::getProcessedDeviceCount ( )
noexcept
Examples
dbt_scanner10.cpp.

Definition at line 85 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getProcessedDevicesString()

std::string direct_bt::BTDeviceRegistry::getProcessedDevicesString ( )
noexcept
Examples
dbt_scanner10.cpp.

Definition at line 89 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getProcessedDevices()

jau::darray< DeviceID > direct_bt::BTDeviceRegistry::getProcessedDevices ( )
noexcept

Returns a copy of the current collection of processed DeviceID.

Definition at line 103 of file BTDeviceRegistry.cpp.

◆ clearProcessedDevices()

void direct_bt::BTDeviceRegistry::clearProcessedDevices ( )
noexcept

Clears internal list.

Definition at line 115 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ isWaitingForDevice() [1/2]

bool direct_bt::BTDeviceRegistry::isWaitingForDevice ( const EUI48 address,
const std::string &  name,
DeviceQueryMatchFunc  m 
)
noexcept

Returns true if the given address and/or name matches any of the BTDeviceRegistry::addToWaitForDevices() awaited devices.

Matching criteria and algorithm is defined by the given BTDeviceRegistry::DeviceQueryMatchFunc.

See also
BTDeviceRegistry::isWaitingForDevice()
Examples
dbt_repeater00.cpp, and dbt_scanner10.cpp.

Definition at line 120 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ isWaitingForDevice() [2/2]

bool direct_bt::BTDeviceRegistry::isWaitingForDevice ( const EUI48 address,
const std::string &  name 
)
inlinenoexcept

Returns true if the given address and/or name matches any of the BTDeviceRegistry::addToWaitForDevices() awaited devices.

Matching criteria is either the awaited device's BTDeviceRegistry::DeviceQuery::addressSub or BTDeviceRegistry::DeviceQuery::nameSub, whichever is set.

Matching algorithm is a simple contains pattern match, i.e. the given address or name contains the corresponding BTDeviceRegistry::DeviceQuery element.

See also
BTDeviceRegistry::isWaitingForDevice()

Definition at line 190 of file BTDeviceRegistry.hpp.

◆ areAllDevicesProcessed() [1/2]

bool direct_bt::BTDeviceRegistry::areAllDevicesProcessed ( DeviceQueryMatchFunc  m)
noexcept

Returns true if all addToWaitForDevices() awaited devices have been addToProcessedDevices() processed.

Matching criteria and algorithm is defined by the given BTDeviceRegistry::DeviceQueryMatchFunc.

See also
BTDeviceRegistry::areAllDevicesProcessed()
Examples
dbt_scanner10.cpp.

Definition at line 126 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ areAllDevicesProcessed() [2/2]

bool direct_bt::BTDeviceRegistry::areAllDevicesProcessed ( )
inlinenoexcept

Returns true if all addToWaitForDevices() awaited devices have been addToProcessedDevices() processed.

Matching criteria is either the awaited device's BTDeviceRegistry::DeviceQuery::addressSub or BTDeviceRegistry::DeviceQuery::nameSub, whichever is set.

Matching algorithm is a simple contains pattern match, i.e. the processed BTDeviceRegistry::DeviceID contains one element of BTDeviceRegistry::DeviceQuery.

See also
BTDeviceRegistry::areAllDevicesProcessed()

Definition at line 219 of file BTDeviceRegistry.hpp.

Variable Documentation

◆ waitForDevices

jau::darray<DeviceQuery> direct_bt::BTDeviceRegistry::waitForDevices
static

Definition at line 38 of file BTDeviceRegistry.cpp.

◆ devicesProcessed

std::unordered_set<DeviceID> direct_bt::BTDeviceRegistry::devicesProcessed
static

Definition at line 40 of file BTDeviceRegistry.cpp.

◆ mtx_devicesProcessed

std::recursive_mutex direct_bt::BTDeviceRegistry::mtx_devicesProcessed
static

Definition at line 41 of file BTDeviceRegistry.cpp.