Once you have connected to a BLE device peripheral, you need to discover its characteristics to be able to read and write them. You do that by using QLowEnergyController
. Let's take a look at what QLowEnergyController
is.
QLowEnergyController
is the central place to access BLE devices both local and remote.
The local QLowEnergyController
can be created by using the static QLowEnergyController::createPeripheral(QObject *parent)
function.
Creating a QLowEnergyController
object that represents the remote device is done by calling the static class QLowEnergyController::createCentral
using the QBluetoothDeviceInfo
object that you receive when you discover remote devices.
The QLowEnergyController
object has several signals:
discoveryFinished
serviceDiscovered
connected
disconnected
Connect to the connected
signal and start connecting by calling connectToDevice()
:
SomeClass::newDevice(const QBluetoothDeviceInfo &device) { QLowEnergyController...