Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qlowenergycontroller_bluez.cpp File Reference
#include "lecmaccalculator_p.h"
#include "qlowenergycontroller_bluez_p.h"
#include "qbluetoothsocketbase_p.h"
#include "qbluetoothsocket_bluez_p.h"
#include "qleadvertiser_bluez_p.h"
#include "bluez/bluez_data_p.h"
#include "bluez/hcimanager_p.h"
#include "bluez/objectmanager_p.h"
#include "bluez/remotedevicemanager_p.h"
#include "bluez/bluez5_helper_p.h"
#include "bluez/bluetoothmanagement_p.h"
#include <QtCore/QFileInfo>
#include <QtCore/QLoggingCategory>
#include <QtCore/QSettings>
#include <QtCore/QTimer>
#include <QtBluetooth/QBluetoothLocalDevice>
#include <QtBluetooth/QBluetoothSocket>
#include <QtBluetooth/QLowEnergyCharacteristicData>
#include <QtBluetooth/QLowEnergyDescriptorData>
#include <QtBluetooth/QLowEnergyService>
#include <QtBluetooth/QLowEnergyServiceData>
#include <algorithm>
#include <climits>
#include <cstring>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include "moc_qlowenergycontroller_bluez_p.cpp"
+ Include dependency graph for qlowenergycontroller_bluez.cpp:

Go to the source code of this file.

Classes

class  ServerSocket
 

Macros

#define GATT_PRIMARY_SERVICE   quint16(0x2800)
 
#define GATT_SECONDARY_SERVICE   quint16(0x2801)
 
#define GATT_INCLUDED_SERVICE   quint16(0x2802)
 
#define GATT_CHARACTERISTIC   quint16(0x2803)
 
#define ERROR_RESPONSE_HEADER_SIZE   5
 
#define FIND_INFO_REQUEST_HEADER_SIZE   5
 
#define GRP_TYPE_REQ_HEADER_SIZE   7
 
#define READ_BY_TYPE_REQ_HEADER_SIZE   7
 
#define READ_REQUEST_HEADER_SIZE   3
 
#define READ_BLOB_REQUEST_HEADER_SIZE   5
 
#define WRITE_REQUEST_HEADER_SIZE   3
 
#define PREPARE_WRITE_HEADER_SIZE   5
 
#define EXECUTE_WRITE_HEADER_SIZE   2
 
#define MTU_EXCHANGE_HEADER_SIZE   3
 
#define APPEND_VALUE   true
 
#define NEW_VALUE   false
 

Functions

static void dumpErrorInformation (const QByteArray &response)
 
static int getUuidSize (const QBluetoothUuid &uuid)
 
template<typename T >
static void putDataAndIncrement (const T &src, char *&dst)
 
template<>
void putDataAndIncrement (const QBluetoothUuid &uuid, char *&dst)
 
template<>
void putDataAndIncrement (const QByteArray &value, char *&dst)
 
QLowEnergyHandle parseReadByTypeCharDiscovery (QLowEnergyServicePrivate::CharData *charData, const char *data, quint16 elementLength)
 
QLowEnergyHandle parseReadByTypeIncludeDiscovery (QList< QBluetoothUuid > *foundServices, const char *data, quint16 elementLength)
 
static bool isNotificationEnabled (quint16 clientConfigValue)
 
static bool isIndicationEnabled (quint16 clientConfigValue)
 
static QString nameOfRemoteCentral (const QBluetoothAddress &peerAddress)
 
static QByteArray uuidToByteArray (const QBluetoothUuid &uuid)
 

Variables

constexpr quint16 ATT_DEFAULT_LE_MTU = 23
 
constexpr quint16 ATT_MAX_LE_MTU = 0x200
 
const int maxPrepareQueueSize = 1024
 

Macro Definition Documentation

◆ APPEND_VALUE

#define APPEND_VALUE   true

Definition at line 56 of file qlowenergycontroller_bluez.cpp.

◆ ERROR_RESPONSE_HEADER_SIZE

#define ERROR_RESPONSE_HEADER_SIZE   5

Definition at line 45 of file qlowenergycontroller_bluez.cpp.

◆ EXECUTE_WRITE_HEADER_SIZE

#define EXECUTE_WRITE_HEADER_SIZE   2

Definition at line 53 of file qlowenergycontroller_bluez.cpp.

◆ FIND_INFO_REQUEST_HEADER_SIZE

#define FIND_INFO_REQUEST_HEADER_SIZE   5

Definition at line 46 of file qlowenergycontroller_bluez.cpp.

◆ GATT_CHARACTERISTIC

#define GATT_CHARACTERISTIC   quint16(0x2803)

Definition at line 42 of file qlowenergycontroller_bluez.cpp.

◆ GATT_INCLUDED_SERVICE

#define GATT_INCLUDED_SERVICE   quint16(0x2802)

Definition at line 41 of file qlowenergycontroller_bluez.cpp.

◆ GATT_PRIMARY_SERVICE

#define GATT_PRIMARY_SERVICE   quint16(0x2800)

Definition at line 39 of file qlowenergycontroller_bluez.cpp.

◆ GATT_SECONDARY_SERVICE

#define GATT_SECONDARY_SERVICE   quint16(0x2801)

Definition at line 40 of file qlowenergycontroller_bluez.cpp.

◆ GRP_TYPE_REQ_HEADER_SIZE

#define GRP_TYPE_REQ_HEADER_SIZE   7

Definition at line 47 of file qlowenergycontroller_bluez.cpp.

◆ MTU_EXCHANGE_HEADER_SIZE

#define MTU_EXCHANGE_HEADER_SIZE   3

Definition at line 54 of file qlowenergycontroller_bluez.cpp.

◆ NEW_VALUE

#define NEW_VALUE   false

Definition at line 57 of file qlowenergycontroller_bluez.cpp.

◆ PREPARE_WRITE_HEADER_SIZE

#define PREPARE_WRITE_HEADER_SIZE   5

Definition at line 52 of file qlowenergycontroller_bluez.cpp.

◆ READ_BLOB_REQUEST_HEADER_SIZE

#define READ_BLOB_REQUEST_HEADER_SIZE   5

Definition at line 50 of file qlowenergycontroller_bluez.cpp.

◆ READ_BY_TYPE_REQ_HEADER_SIZE

#define READ_BY_TYPE_REQ_HEADER_SIZE   7

Definition at line 48 of file qlowenergycontroller_bluez.cpp.

◆ READ_REQUEST_HEADER_SIZE

#define READ_REQUEST_HEADER_SIZE   3

Definition at line 49 of file qlowenergycontroller_bluez.cpp.

◆ WRITE_REQUEST_HEADER_SIZE

#define WRITE_REQUEST_HEADER_SIZE   3

Definition at line 51 of file qlowenergycontroller_bluez.cpp.

Function Documentation

◆ dumpErrorInformation()

◆ getUuidSize()

static int getUuidSize ( const QBluetoothUuid uuid)
static

Definition at line 131 of file qlowenergycontroller_bluez.cpp.

References QBluetoothUuid::minimumSize().

+ Here is the call graph for this function:

◆ isIndicationEnabled()

static bool isIndicationEnabled ( quint16  clientConfigValue)
static

Definition at line 2527 of file qlowenergycontroller_bluez.cpp.

◆ isNotificationEnabled()

static bool isNotificationEnabled ( quint16  clientConfigValue)
static

Definition at line 2526 of file qlowenergycontroller_bluez.cpp.

◆ nameOfRemoteCentral()

static QString nameOfRemoteCentral ( const QBluetoothAddress peerAddress)
static

Definition at line 2965 of file qlowenergycontroller_bluez.cpp.

References QMap< Key, T >::constBegin(), QMap< Key, T >::constEnd(), initializeBluez5(), it, manager, QStringLiteral, reply, QDBusConnection::systemBus(), QVariant::toString(), toString(), and QMap< Key, T >::value().

+ Here is the call graph for this function:

◆ parseReadByTypeCharDiscovery()

QLowEnergyHandle parseReadByTypeCharDiscovery ( QLowEnergyServicePrivate::CharData charData,
const char *  data,
quint16  elementLength 
)

Definition at line 900 of file qlowenergycontroller_bluez.cpp.

References bt_get_le16(), QUuid::fromBytes(), Qt::hex(), QSysInfo::LittleEndian, QLowEnergyServicePrivate::CharData::properties, Q_ASSERT, qCDebug, QUuid::toString(), QLowEnergyServicePrivate::CharData::uuid, and QLowEnergyServicePrivate::CharData::valueHandle.

+ Here is the call graph for this function:

◆ parseReadByTypeIncludeDiscovery()

QLowEnergyHandle parseReadByTypeIncludeDiscovery ( QList< QBluetoothUuid > *  foundServices,
const char *  data,
quint16  elementLength 
)

Definition at line 926 of file qlowenergycontroller_bluez.cpp.

References QList< T >::append(), bt_get_le16(), QUuid::fromBytes(), Qt::hex(), QSysInfo::LittleEndian, Q_ASSERT, and qCDebug.

+ Here is the call graph for this function:

◆ putDataAndIncrement() [1/3]

template<>
void putDataAndIncrement ( const QBluetoothUuid uuid,
char *&  dst 
)

Definition at line 141 of file qlowenergycontroller_bluez.cpp.

References QUuid::Id128Bytes::data, QSysInfo::LittleEndian, ok, putBtData(), QUuid::toBytes(), and QBluetoothUuid::toUInt16().

+ Here is the call graph for this function:

◆ putDataAndIncrement() [2/3]

template<>
void putDataAndIncrement ( const QByteArray value,
char *&  dst 
)

Definition at line 154 of file qlowenergycontroller_bluez.cpp.

◆ putDataAndIncrement() [3/3]

template<typename T >
static void putDataAndIncrement ( const T &  src,
char *&  dst 
)
static

Definition at line 136 of file qlowenergycontroller_bluez.cpp.

References putBtData().

Referenced by QLowEnergyControllerPrivateBluez::addToGenericAttributeList(), and uuidToByteArray().

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

◆ uuidToByteArray()

static QByteArray uuidToByteArray ( const QBluetoothUuid uuid)
static

Definition at line 3208 of file qlowenergycontroller_bluez.cpp.

References ba, QByteArray::constData(), QByteArray::data(), ptr(), putDataAndIncrement(), QByteArray::resize(), and Qt::Uninitialized.

Referenced by QLowEnergyControllerPrivateBluez::addToGenericAttributeList().

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

Variable Documentation

◆ ATT_DEFAULT_LE_MTU

constexpr quint16 ATT_DEFAULT_LE_MTU = 23
constexpr

Definition at line 36 of file qlowenergycontroller_bluez.cpp.

◆ ATT_MAX_LE_MTU

constexpr quint16 ATT_MAX_LE_MTU = 0x200
constexpr

Definition at line 37 of file qlowenergycontroller_bluez.cpp.

◆ maxPrepareQueueSize

const int maxPrepareQueueSize = 1024

Definition at line 65 of file qlowenergycontroller_bluez.cpp.