From e83df9ffb98981bad53cf077faa3cfde8f0eb5b1 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 6 Apr 2017 10:55:48 +0200 Subject: Use heartrate-game example for snippets in BTLE overview heartlistener example will be removed. Change-Id: Iaa5c5f629cf351b97c18f61b4fab2cbbd8d0744c Reviewed-by: Leena Miettinen Reviewed-by: Oliver Wolff Reviewed-by: Alex Blasche --- src/bluetooth/doc/src/bluetooth-le-overview.qdoc | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/bluetooth') diff --git a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc index a2fb10d9..a29f88d0 100644 --- a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc +++ b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc @@ -165,7 +165,7 @@ Low Energy devices. their services, as well as reading and writing data stored on the device. On the server side, it allows to set up services, advertise them, and get notified when the client writes characteristics. - The example code below is taken from the \l {heartlistener}{Heart Listener} and + The example code below is taken from the \l {heartrate-game}{Heart Rate Game} and \l {heartrate-server}{Heart Rate Server} examples. \section2 Establishing a Connection @@ -176,15 +176,15 @@ Low Energy devices. \l QBluetoothDeviceDiscoveryAgent class. We connect to its \l {QBluetoothDeviceDiscoveryAgent::deviceDiscovered()} signal and start the search with \l {QBluetoothDeviceDiscoveryAgent::start()}{start()}: - \snippet heartlistener/heartrate.cpp devicediscovery-1 - \snippet heartlistener/heartrate.cpp devicediscovery-2 + \snippet heartrate-game/devicefinder.cpp devicediscovery-1 + \snippet heartrate-game/devicefinder.cpp devicediscovery-2 Since we are only interested in Low Energy devices we filter the device type within the receiving slot. The device type can be ascertained using the \l QBluetoothDeviceInfo::coreConfigurations() flag: - \snippet heartlistener/heartrate.cpp devicediscovery-3 - \snippet heartlistener/heartrate.cpp devicediscovery-4 + \snippet heartrate-game/devicefinder.cpp devicediscovery-3 + \snippet heartrate-game/devicefinder.cpp devicediscovery-4 Once the address of the peripheral device is known we use the \l QLowEnergyController class. This class is the entry point for all Bluetooth Low Energy development. The constructor of the class @@ -192,20 +192,20 @@ Low Energy devices. directly connect to the device using \l {QLowEnergyController::connectToDevice()}{connectToDevice()}: - \snippet heartlistener/heartrate.cpp Connect signals + \snippet heartrate-game/devicehandler.cpp Connect-Signals-1 + \snippet heartrate-game/devicehandler.cpp Connect-Signals-2 \section2 Service Search - As soon as the connection is established we initiate the service discovery: - - \snippet heartlistener/heartrate.cpp Connecting to service + The above code snippet how the application initiates the service discovery once the connection has + been established. The \c serviceDiscovered() slot below is triggered as a result of the \l {QLowEnergyController::serviceDiscovered()} signal and provides an intermittent progress report. Since we are talking about the heart listener app which monitors HeartRate devices in the vicinity we ignore any service that is not of type \l QBluetoothUuid::HeartRate. - \snippet heartlistener/heartrate.cpp Filter HeartRate service 1 + \snippet heartrate-game/devicehandler.cpp Filter HeartRate service 1 Eventually the \l {QLowEnergyController::discoveryFinished()} signal is emitted to indicate the successful completion of the service discovery. Provided a HeartRate service was found, @@ -213,14 +213,14 @@ Low Energy devices. provides the required signals for update notifications and the discovery of service details is triggered using \l QLowEnergyService::discoverDetails(): - \snippet heartlistener/heartrate.cpp Filter HeartRate service 2 + \snippet heartrate-game/devicehandler.cpp Filter HeartRate service 2 During the detail search the service's \l {QLowEnergyService::state()}{state()} transitions from \l {QLowEnergyService::DiscoveryRequired}{DiscoveryRequired} to \l {QLowEnergyService::DiscoveringServices}{DiscoveringServices} and eventually ends with \l {QLowEnergyService::ServiceDiscovered}{ServiceDiscovered}: - \snippet heartlistener/heartrate.cpp Find HRM characteristic + \snippet heartrate-game/devicehandler.cpp Find HRM characteristic \section2 Interaction with the Peripheral Device @@ -235,8 +235,7 @@ Low Energy devices. Finally, we process the value of the HeartRate characteristic, as per Bluetooth Low Energy standard: - \snippet heartlistener/heartrate.cpp Reading value 1 - \snippet heartlistener/heartrate.cpp Reading value 2 + \snippet heartrate-game/devicehandler.cpp Reading value In general a characteristic value is a series of bytes. The precise interpretation of those bytes depends on the characteristic type and value structure. -- cgit v1.2.3