Direct-BT  2.3.1
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 addToWaitForDevices (const std::string &addrOrNameSub) noexcept
 
bool isWaitingForAnyDevice () noexcept
 
size_t getWaitForDevicesCount () noexcept
 
std::string getWaitForDevicesString () noexcept
 
jau::darray< DeviceQuery > & getWaitForDevices () noexcept
 Returns the reference of the current list of DeviceQuery, not a copy. More...
 
void clearWaitForDevices () noexcept
 Clears internal list. More...
 
bool operator== (const DeviceID &lhs, const DeviceID &rhs) noexcept
 
bool operator!= (const DeviceID &lhs, const DeviceID &rhs) noexcept
 
void addToProcessedDevices (const BDAddressAndType &a, const std::string &n) noexcept
 
bool isDeviceProcessed (const BDAddressAndType &a) noexcept
 
size_t getProcessedDeviceCount () noexcept
 
std::string getProcessedDevicesString () noexcept
 
jau::darray< DeviceIDgetProcessedDevices () noexcept
 Returns a copy of the current collection of processed DeviceID. More...
 
void clearProcessedDevices () noexcept
 Clears internal list. More...
 
bool isWaitingForDevice (const EUI48 &address, const std::string &name, DeviceQueryMatchFunc m) noexcept
 Returns. More...
 
bool isWaitingForDevice (const EUI48 &address, const std::string &name) noexcept
 Returns. More...
 
bool areAllDevicesProcessed (DeviceQueryMatchFunc m) noexcept
 Returns. More...
 
bool areAllDevicesProcessed () noexcept
 Returns. More...
 
void addToProcessingDevices (const BDAddressAndType &a, const std::string &n) noexcept
 
bool removeFromProcessingDevices (const BDAddressAndType &a) noexcept
 
bool isDeviceProcessing (const BDAddressAndType &a) noexcept
 
size_t getProcessingDeviceCount () noexcept
 
jau::darray< DeviceIDgetProcessingDevices () noexcept
 Returns a copy of the current collection of processing DeviceID. More...
 
void clearProcessingDevices () noexcept
 Clears internal list. More...
 

Variables

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

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 160 of file BTDeviceRegistry.hpp.

Function Documentation

◆ addToProcessedDevices()

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

Definition at line 80 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ addToProcessingDevices()

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

Definition at line 145 of file BTDeviceRegistry.cpp.

◆ addToWaitForDevices()

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

Definition at line 46 of file BTDeviceRegistry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ areAllDevicesProcessed() [1/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 214 of file BTDeviceRegistry.hpp.

Here is the call graph for this function:

◆ areAllDevicesProcessed() [2/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:

◆ clearProcessedDevices()

void direct_bt::BTDeviceRegistry::clearProcessedDevices ( )
noexcept

Clears internal list.

Definition at line 115 of file BTDeviceRegistry.cpp.

◆ clearProcessingDevices()

void direct_bt::BTDeviceRegistry::clearProcessingDevices ( )
noexcept

Clears internal list.

Definition at line 178 of file BTDeviceRegistry.cpp.

◆ clearWaitForDevices()

void direct_bt::BTDeviceRegistry::clearWaitForDevices ( )
noexcept

Clears internal list.

Definition at line 76 of file BTDeviceRegistry.cpp.

◆ getProcessedDeviceCount()

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

Definition at line 88 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.

Here is the call graph for this function:

◆ getProcessedDevicesString()

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

Definition at line 92 of file BTDeviceRegistry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProcessingDeviceCount()

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

Definition at line 162 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getProcessingDevices()

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

Returns a copy of the current collection of processing DeviceID.

Definition at line 166 of file BTDeviceRegistry.cpp.

Here is the call 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 73 of file BTDeviceRegistry.cpp.

◆ getWaitForDevicesCount()

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

Definition at line 59 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

◆ getWaitForDevicesString()

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

Definition at line 62 of file BTDeviceRegistry.cpp.

Here is the call graph for this function:
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 84 of file BTDeviceRegistry.cpp.

◆ isDeviceProcessing()

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

Definition at line 158 of file BTDeviceRegistry.cpp.

◆ isWaitingForAnyDevice()

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

Definition at line 56 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 
)
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 185 of file BTDeviceRegistry.hpp.

Here is the call graph for this function:

◆ isWaitingForDevice() [2/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_scanner10.cpp.

Definition at line 120 of file BTDeviceRegistry.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

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

Definition at line 126 of file BTDeviceRegistry.hpp.

◆ 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 120 of file BTDeviceRegistry.hpp.

◆ removeFromProcessingDevices()

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

Definition at line 149 of file BTDeviceRegistry.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ devicesInProcessing

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

Definition at line 40 of file BTDeviceRegistry.cpp.

◆ devicesProcessed

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

Definition at line 43 of file BTDeviceRegistry.cpp.

◆ mtx_devicesProcessed

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

Definition at line 44 of file BTDeviceRegistry.cpp.

◆ mtx_devicesProcessing

std::recursive_mutex direct_bt::BTDeviceRegistry::mtx_devicesProcessing
static

Definition at line 41 of file BTDeviceRegistry.cpp.

◆ waitForDevices

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

Definition at line 38 of file BTDeviceRegistry.cpp.