6#include <QtCore/QLoggingCategory>
8#include <QtBluetooth/QBluetoothLocalDevice>
9#include <QtBluetooth/QLowEnergyCharacteristicData>
10#include <QtBluetooth/QLowEnergyDescriptorData>
11#include <QtBluetooth/QLowEnergyServiceData>
28#if defined(QT_WINRT_BLUETOOTH) || defined(Q_OS_DARWIN)
35 bool adapterFound =
false;
56 errorString = QLowEnergyController::tr(
"Remote device cannot be found");
59 errorString = QLowEnergyController::tr(
"Cannot find local adapter");
62 errorString = QLowEnergyController::tr(
"Error occurred during connection I/O");
65 errorString = QLowEnergyController::tr(
"Error occurred trying to connect to remote device.");
68 errorString = QLowEnergyController::tr(
"Error occurred trying to start advertising");
71 errorString = QLowEnergyController::tr(
"Remote device closed the connection");
74 errorString = QLowEnergyController::tr(
"Failed to authorize on the remote device");
77 errorString = QLowEnergyController::tr(
"Missing permissions error");
80 errorString = QLowEnergyController::tr(
"Error reading RSSI value");
86 errorString = QLowEnergyController::tr(
"Unknown Error");
90 emit q->errorOccurred(newError);
96 qCDebug(QT_BT) <<
"QLowEnergyControllerPrivate setting state to" <<
newState;
117 for (
auto service:
values)
118 if (service->startHandle <=
handle && handle <= service->endHandle)
132 if (service.isNull())
135 if (service->characteristicList.isEmpty())
139 if (service->characteristicList.contains(
handle))
144 std::sort(charHandles.
begin(), charHandles.
end());
167 d_ptr->characteristicList[matchingChar.attributeHandle()];
183 if (!service.isNull()) {
185 if (charIt != service->characteristicList.end()) {
208 if (!service.isNull()) {
210 if (charIt != service->characteristicList.end()) {
233 service->setController(
nullptr);
236 service->setController(
nullptr);
251 servicePrivate->setController(
this);
253 servicePrivate->uuid = service.uuid();
258 servicePrivate->includedServices << includedService->serviceUuid();
271 charData.
uuid = cd.uuid();
273 charData.
value = cd.value();
277 descData.
uuid = dd.uuid();
278 descData.
value = dd.value();
281 servicePrivate->characteristicList.insert(declHandle, charData);
285 if (handleOverflow) {
286 qCWarning(QT_BT) <<
"Not enough attribute handles left to create this service";
292 qCWarning(QT_BT) <<
"Overriding existing local service with uuid"
293 << servicePrivate->uuid;
295 this->
localServices.insert(servicePrivate->uuid, servicePrivate);
303 qCWarning(QT_BT,
"This platform does not support reading RSSI");
309#include "moc_qlowenergycontrollerbase_p.cpp"
static QList< QBluetoothHostInfo > allDevices()
Returns a list of all available local Bluetooth devices.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
bool isValid() const
Returns true if the QLowEnergyCharacteristic object is valid, otherwise returns false.
QLowEnergyCharacteristic characteristicForHandle(QLowEnergyHandle handle)
Returns a valid characteristic if the given handle is the handle of the characteristic itself or one ...
QSharedPointer< QLowEnergyServicePrivate > serviceForHandle(QLowEnergyHandle handle)
void invalidateServices()
virtual ~QLowEnergyControllerPrivate()
quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated descriptor value.
QLowEnergyDescriptor descriptorForHandle(QLowEnergyHandle handle)
Returns a valid descriptor if handle belongs to a descriptor; otherwise an invalid one.
ServiceDataMap localServices
ServiceDataMap serviceList
bool isValidLocalAdapter()
QLowEnergyController::Error error
void setError(QLowEnergyController::Error newError)
QLowEnergyController::Role role
QLowEnergyHandle lastLocalHandle
quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated characteristic value.
QBluetoothAddress localAdapter
virtual void addToGenericAttributeList(const QLowEnergyServiceData &service, QLowEnergyHandle startHandle)=0
virtual QLowEnergyService * addServiceHelper(const QLowEnergyServiceData &service)
QLowEnergyController::ControllerState state
QBluetoothAddress remoteDevice
void setState(QLowEnergyController::ControllerState newState)
ControllerState
Indicates the state of the controller object.
Error
Indicates all possible error conditions found during the controller's existence.
@ UnknownRemoteDeviceError
@ InvalidBluetoothAdapterError
@ MissingPermissionsError
The QLowEnergyDescriptorData class is used to create GATT service data. \inmodule QtBluetooth.
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
QScopedPointer< QObjectData > d_ptr
static QSharedPointer create(Args &&...arguments)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
QT_BEGIN_NAMESPACE typedef QMap< QBluetoothUuid, QSharedPointer< QLowEnergyServicePrivate > > ServiceDataMap
GLenum GLsizei GLsizei GLint * values
[15]
GLuint64 GLenum void * handle
GLdouble GLdouble GLdouble GLdouble q
QFileInfo info(fileName)
[8]
QHash< QLowEnergyHandle, DescData > descriptorList
QLowEnergyHandle valueHandle
QLowEnergyCharacteristic::PropertyTypes properties