Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
26 #ifndef L2CAP_COMM_HPP_
27 #define L2CAP_COMM_HPP_
126 static int l2cap_close_dev(
int dd);
133 std::recursive_mutex mtx_write;
135 std::atomic<int> socket_descriptor;
136 std::atomic<bool> is_open;
137 std::atomic<bool> has_ioerror;
138 std::atomic<bool> interrupt_flag;
139 std::atomic<pthread_t> tid_connect;
140 std::atomic<pthread_t> tid_read;
172 bool close() noexcept;
static constexpr int number(const Defaults d)
static std::string getStateString(bool isConnected, bool hasIOError)
L2CAPComm(const L2CAPComm &)=delete
static L2CAPEnv & get() noexcept
Base jau environment class, merely to tag all environment settings by inheritance and hence documenta...
L2CAP Singleton runtime environment properties.
BTSecurityLevel getBTSecurityLevel()
Fetches the current BlueZ's L2CAP socket BT_SECURITY sec_level.
~L2CAPComm() noexcept
Destructor closing the L2CAP channel, see disconnect().
const int32_t L2CAP_READER_POLL_TIMEOUT
L2CAP poll timeout for reading, defaults to 10s.
Read/Write L2CAP communication channel.
@ NONE
No encryption and no authentication.
@ L2CAP_CONNECT_MAX_RETRY
PRAGMA_DISABLE_WARNING_POP constexpr_cxx20 std::string to_string(const endian &v) noexcept
Return std::string representation of the given jau::endian.
BTSecurityLevel
Bluetooth Security Level.
std::string getStateString() const
const bool DEBUG_DATA
Debug all GATT Data communication.
L2CAPComm(const BDAddressAndType &adapterAddressAndType, const L2CAP_PSM psm, const L2CAP_CID cid)
Constructing a non connected L2CAP channel instance for the pre-defined PSM and CID.
jau::snsize_t read(uint8_t *buffer, const jau::nsize_t capacity)
Generic read, w/o locking suitable for a unique ringbuffer sink.
L2CAP_PSM
Protocol Service Multiplexers (PSM) Assigned numbers https://www.bluetooth.com/specifications/assigne...
jau::snsize_t write(const uint8_t *buffer, const jau::nsize_t length)
Generic write, locking mutex_write().
bool open(const BTDevice &device, const BTSecurityLevel sec_level=BTSecurityLevel::NONE)
Opens and connects the L2CAP channel, locking mutex_write().
int getSocketDescriptor() const noexcept
Return this L2CAP socket descriptor.
int_fast32_t snsize_t
Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
const int32_t L2CAP_RESTART_COUNT_ON_ERROR
Debugging facility: L2CAP restart count on transmission errors, defaults to 5 attempts.
void operator=(const L2CAPComm &)=delete
bool setBTSecurityLevel(const BTSecurityLevel sec_level)
If sec_level > BTSecurityLevel::UNSET, sets the BlueZ's L2CAP socket BT_SECURITY sec_level,...
Unique Bluetooth EUI48 address and BDAddressType tuple.
bool close() noexcept
Closing the L2CAP channel, locking mutex_write().
std::recursive_mutex & mutex_write()
Return the recursive write mutex for multithreading access.