Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
direct_bt::SMPHandler Class Reference

A thread safe SMP handler associated to one device via one L2CAP connection. More...

#include <SMPHandler.hpp>

Collaboration diagram for direct_bt::SMPHandler:

Public Types

enum class  Defaults : int32_t { MIN_SMP_MTU = 23 , LE_SECURE_SMP_MTU = 65 , SMP_MTU_BUFFER_SZ = 128 }
 
typedef jau::nsize_t size_type
 
typedef jau::function< void(const SMPPDUMsg &)> SMPSecurityReqCallback
 
typedef jau::cow_darray< SMPSecurityReqCallback, size_typeSMPSecurityReqCallbackList
 

Public Member Functions

 SMPHandler (const SMPHandler &)=delete
 
 SMPHandler (const std::shared_ptr< BTDevice > &device) noexcept
 
 ~SMPHandler () noexcept
 Destructor closing this instance including L2CAP channel, see disconnect(). More...
 
void addSMPSecurityReqCallback (const SMPSecurityReqCallback &l)
 
bool disconnect (const bool disconnectDevice, const bool ioErrorCause) noexcept
 Disconnect this GATTHandler and optionally the associated device. More...
 
bool establishSecurity (const BTSecurityLevel sec_level)
 If sec_level > BTSecurityLevel::UNSET, change security level per L2CAP connection. More...
 
std::shared_ptr< BTDevicegetDeviceChecked () const
 
std::shared_ptr< BTDevicegetDeviceUnchecked () const noexcept
 
std::string getStateString () const noexcept
 
bool hasIOError () const noexcept
 
bool isConnected () const noexcept
 
void operator= (const SMPHandler &)=delete
 
size_type removeSMPSecurityReqCallback (const SMPSecurityReqCallback &l)
 

Static Public Member Functions

static constexpr int number (const Defaults d)
 

Static Public Attributes

static bool IS_SUPPORTED_BY_OS = SMP_SUPPORTED_BY_OS ? true : false
 Linux/BlueZ prohibits access to the existing SMP implementation via L2CAP (socket). More...
 

Detailed Description

A thread safe SMP handler associated to one device via one L2CAP connection.

Implementation utilizes a lock free ringbuffer receiving data within its separate thread.

Controlling Environment variables, see SMPEnv.

See

Definition at line 163 of file SMPHandler.hpp.

Member Typedef Documentation

◆ SMPSecurityReqCallback

Definition at line 181 of file SMPHandler.hpp.

◆ size_type

Definition at line 182 of file SMPHandler.hpp.

◆ SMPSecurityReqCallbackList

Definition at line 183 of file SMPHandler.hpp.

Member Enumeration Documentation

◆ Defaults

enum class direct_bt::SMPHandler::Defaults : int32_t
strong
Enumerator
MIN_SMP_MTU 
LE_SECURE_SMP_MTU 
SMP_MTU_BUFFER_SZ 

Definition at line 170 of file SMPHandler.hpp.

Constructor & Destructor Documentation

◆ SMPHandler() [1/2]

SMPHandler::SMPHandler ( const std::shared_ptr< BTDevice > &  device)
noexcept

Definition at line 169 of file SMPHandler.cpp.

◆ SMPHandler() [2/2]

direct_bt::SMPHandler::SMPHandler ( const SMPHandler )
delete

◆ ~SMPHandler()

SMPHandler::~SMPHandler ( )
noexcept

Destructor closing this instance including L2CAP channel, see disconnect().

Definition at line 199 of file SMPHandler.cpp.

Member Function Documentation

◆ number()

static constexpr int direct_bt::SMPHandler::number ( const Defaults  d)
inlinestaticconstexpr

Definition at line 179 of file SMPHandler.hpp.

◆ operator=()

void direct_bt::SMPHandler::operator= ( const SMPHandler )
delete

◆ getDeviceUnchecked()

std::shared_ptr< BTDevice > direct_bt::SMPHandler::getDeviceUnchecked ( ) const
inlinenoexcept

Definition at line 225 of file SMPHandler.hpp.

◆ getDeviceChecked()

std::shared_ptr< BTDevice > SMPHandler::getDeviceChecked ( ) const

Definition at line 73 of file SMPHandler.cpp.

◆ isConnected()

bool direct_bt::SMPHandler::isConnected ( ) const
inlinenoexcept

Definition at line 228 of file SMPHandler.hpp.

◆ hasIOError()

bool direct_bt::SMPHandler::hasIOError ( ) const
inlinenoexcept

Definition at line 229 of file SMPHandler.hpp.

◆ getStateString()

std::string direct_bt::SMPHandler::getStateString ( ) const
inlinenoexcept

Definition at line 230 of file SMPHandler.hpp.

◆ establishSecurity()

bool SMPHandler::establishSecurity ( const BTSecurityLevel  sec_level)

If sec_level > BTSecurityLevel::UNSET, change security level per L2CAP connection.

Parameters
sec_levelsec_level < BTSecurityLevel::NONE will not set security level and returns false.
Returns
true if a security level > BTSecurityLevel::UNSET has been set successfully, false if no security level has been set or if it failed.

Definition at line 204 of file SMPHandler.cpp.

◆ disconnect()

bool SMPHandler::disconnect ( const bool  disconnectDevice,
const bool  ioErrorCause 
)
noexcept

Disconnect this GATTHandler and optionally the associated device.

Parameters
disconnectDeviceif true, associated device will also be disconnected, otherwise not.
ioErrorCauseif true, reason for disconnection is an IO error
Returns
true if successful, otherwise false

Definition at line 211 of file SMPHandler.cpp.

Here is the caller graph for this function:

◆ addSMPSecurityReqCallback()

void SMPHandler::addSMPSecurityReqCallback ( const SMPSecurityReqCallback l)

Definition at line 311 of file SMPHandler.cpp.

◆ removeSMPSecurityReqCallback()

SMPHandler::size_type SMPHandler::removeSMPSecurityReqCallback ( const SMPSecurityReqCallback l)

Definition at line 314 of file SMPHandler.cpp.

Member Data Documentation

◆ IS_SUPPORTED_BY_OS

bool SMPHandler::IS_SUPPORTED_BY_OS = SMP_SUPPORTED_BY_OS ? true : false
static

Linux/BlueZ prohibits access to the existing SMP implementation via L2CAP (socket).

Definition at line 168 of file SMPHandler.hpp.


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