5#include <QtBluetooth/QBluetoothLocalDevice>
7#include <QtCore/QCoreApplication>
8#include <QtCore/QDebug>
10#include <QtCore/QObject>
11#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
12#include <QtBluetooth/QBluetoothServiceDiscoveryAgent>
14#include <QtBluetooth/QLowEnergyController>
15#include <QtBluetooth/QLowEnergyService>
16#include <QtBluetooth/QLowEnergyCharacteristic>
76 discoveryAgent->
start();
84 qDebug() <<
"Found new device:" <<
device.name() <<
'(' <<
device.address().toString() <<
')';
98 discoveryAgent->
start();
106 qDebug() <<
"Found new service:" << service.serviceName()
107 <<
'(' << service.device().address().toString() <<
')';
131 first->discoverDetails();
150 service->discoverDetails();
191#include "doc_src_qtbluetooth.moc"
IOBluetoothDevice * device
void enableCharNotifications()
void characteristicChanged(const QLowEnergyCharacteristic &, const QByteArray &)
[service_discovery]
void startDeviceDiscovery()
[device_discovery]
void serviceDiscovered(const QBluetoothServiceInfo &service)
void deviceDiscovered(const QBluetoothDeviceInfo &device)
void startServiceDiscovery()
[device_discovery]
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
void start()
Starts Bluetooth device discovery, if it is not already started.
void start(DiscoveryMode mode=MinimalDiscovery)
Starts service discovery.
@ ClientCharacteristicConfiguration
static QByteArray fromHex(const QByteArray &hexEncoded)
Returns a decoded copy of the hex encoded array hexEncoded.
QLowEnergyDescriptor descriptor(const QBluetoothUuid &uuid) const
Returns the descriptor for uuid or an invalid \l QLowEnergyDescriptor instance.
bool isValid() const
Returns true if the QLowEnergyCharacteristic object is valid, otherwise returns false.
void connectToDevice()
Connects to the remote Bluetooth Low Energy device.
static QLowEnergyController * createCentral(const QBluetoothDeviceInfo &remoteDevice, QObject *parent=nullptr)
Returns a new object of this class that is in the \l CentralRole and has the parent object parent.
QLowEnergyService * createServiceObject(const QBluetoothUuid &service, QObject *parent=nullptr)
Creates an instance of the service represented by serviceUuid.
bool isValid() const
Returns true if the QLowEnergyDescriptor object is valid, otherwise returns false.
@ RemoteServiceDiscovering
QLowEnergyService::ServiceState state() const
Returns the current state of the service.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
QApplication app(argc, argv)
[0]