summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/doc/src/bluetooth-overview.qdoc
diff options
context:
space:
mode:
authorNedim Hadzic <nhadzic@blackberry.com>2014-04-09 12:11:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-09 12:33:14 +0200
commit8cb4522fe47c895e1b20a0ff04227a65f759972b (patch)
treee2ce5c8b8751315db13dd7ce11fac5d88d153c46 /src/bluetooth/doc/src/bluetooth-overview.qdoc
parentec4aa0bcb592e9668b0767906157a1a51915d76c (diff)
Documentation for Bluetooth overview updated
After recent changes to the BLE API, overview documentation was not updated. Change-Id: I897d135e999968f47f89ea94475c9d484794c059 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/doc/src/bluetooth-overview.qdoc')
-rw-r--r--src/bluetooth/doc/src/bluetooth-overview.qdoc71
1 files changed, 14 insertions, 57 deletions
diff --git a/src/bluetooth/doc/src/bluetooth-overview.qdoc b/src/bluetooth/doc/src/bluetooth-overview.qdoc
index bc8a9543..8842f483 100644
--- a/src/bluetooth/doc/src/bluetooth-overview.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-overview.qdoc
@@ -138,72 +138,29 @@
To be able to get and read characteristics, it is required to connect to the LE device service.
- \code
- QObject::connect(m_serviceDiscoveryAgent, SIGNAL(serviceDiscovered(const QLowEnergyServiceInfo&)),
- this, SLOT(addLowEnergyService(const QLowEnergyServiceInfo&)));
- QObject::connect(m_serviceDiscoveryAgent, SIGNAL(finished()), this, SLOT(serviceScanDone()));
- m_serviceDiscoveryAgent->setRemoteAddress(device.address());
- m_serviceDiscoveryAgent->start();
- lowEnergyController = new QLowEnergyController();
- QObject::connect(lowEnergyController, SIGNAL(connected(QLowEnergyServiceInfo)),
- this, SLOT(serviceConnected(QLowEnergyServiceInfo)));
- QObject::connect(lowEnergyController, SIGNAL(error(QLowEnergyServiceInfo)),
- this, SLOT(errorReceived(QLowEnergyServiceInfo)));
- QObject::connect(lowEnergyController, SIGNAL(valueChanged(QLowEnergyCharacteristicInfo)),
- this, SLOT(receiveMeasurement(QLowEnergyCharacteristicInfo)));
- QObject::connect(lowEnergyController, SIGNAL(disconnected(QLowEnergyServiceInfo)),
- this, SLOT(serviceDisconnected(QLowEnergyServiceInfo)));
-
- \endcode
+ \snippet heartlistener/heartrate.cpp Connect signals
We start a service discovery with a \l QBluetoothServiceDiscoveryAgent class and connect its
- signal \l serviceDiscovered(QLowEnergyServiceInfo) to our slot
- \l addLowEnergyService(QLowEnergyServiceInfo). This way, it is possible to store all LE services
- or connect to the desired one. \l QLowEnergyController is used for connecting to service,
- receiving emitted errors from the service and disconnecting from the service.
+ signal \l serviceDiscovered(QLowEnergyServiceInfo) to the slot in the application.
+ This way, it is possible to store all LE services or connect to the desired one.
+ \l QLowEnergyController is used for connecting to service, emitting values,
+ receiving emitted errors from the service and characteristics, and disconnecting from the service.
Even though it is possible to connect to an LE service before the service scan is done,
it is advisable to do it after the service scan is done.
- \code
- void serviceScanDone()
- {
- lowEnergyController->connectToService(wantedLowEnergyService);
- }
- \endcode
-
- Here, the \c wantedLowEnergyService can be one service or you can pick more or all services
- to connect. Some LE devices, become available one or two seconds after service scan.
-
- \code
- void serviceConnected(const QLowEnergyServiceInfo &leService)
- {
- QList<QLowEnergyCharacteristicInfo> lowEnergyCharacteristics = leService.getCharacteristics();
- for (int i = 0; i<lowEnergyCharacteristics.size(); i++) {
- QLowEnergyCharacteristicInfo wantedCharacteristic =
- QLowEnergyCharacteristicInfo(lowEnergyCharacteristics.at(i));
- lowEnergyController->enableNotifications(wantedCharacteristic);
- }
- }
- \endcode
-
- In the code example above all characteristics will be enabled for the notifications, but not
- all of them have that option as explained in \l QLowEnergyController documentation. It is possible
- to select only one characteristic, for instance \l QBluetoothUuid::HeartRateMeasurement.
-
- Finally, to receive updates, the receiveMeasurement(QLowEnergyCharacteristicInfo) slot was defined.
-
- \code
- void HeartRate::receiveMeasurement(const QLowEnergyCharacteristicInfo &characteristic)
- {
- wantedCharacteristic = QLowEnergyCharacteristicInfo(characteristic);
- wantedCharacteristic.value();
- }
- \endcode
+ \snippet heartlistener/heartrate.cpp Connecting to service
+
+ In the code example above, the wanted characteristics will be enabled for the notifications, but not
+ all of them have that option as explained in \l QLowEnergyController documentation. In this case,
+ it was a characteristic \l QBluetoothUuid::HeartRateMeasurement.
+
+ Finally, to receive updates, we defined the slot where we read the emitted value.
+
+ \snippet heartlistener/heartrate.cpp Reading value
The returned value is the hexadecimal value. The procedure of reading and converting hexadecimal
value properly depends on the BLE devices that is sending updates since every device has a different
value structure.
-
*/