summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/doc
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-03-14 11:16:27 +0100
committerAlex Blasche <alexander.blasche@digia.com>2014-03-14 11:16:27 +0100
commit83cd348bde8e856d2508c2514cd33a90e593461d (patch)
tree9dbd933129ef4a9e514218fc6177d775aa94c9db /src/bluetooth/doc
parent4439541b05ae88a30159a5597d40f569328783ca (diff)
parent40ac14e13b0aa07124c6ae9ef8eacfe6d8550684 (diff)
Merge branch 'dev' into btle
Conflicts: src/bluetooth/qbluetoothuuid.cpp tests/bttestui/btlocaldevice.cpp Change-Id: Id16ab93ec61361950669da7eb232769c5dc4644f
Diffstat (limited to 'src/bluetooth/doc')
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp78
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro43
-rw-r--r--src/bluetooth/doc/snippets/snippets.pro8
-rw-r--r--src/bluetooth/doc/src/bluetooth-cpp.qdoc2
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc7
-rw-r--r--src/bluetooth/doc/src/bluetooth-overview.qdoc28
-rw-r--r--src/bluetooth/doc/src/examples.qdoc2
7 files changed, 94 insertions, 74 deletions
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
index 56459e72..88520c35 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -39,13 +39,36 @@
****************************************************************************/
//! [include]
-#include <qbluetoothlocaldevice.h>
+#include <QtBluetooth/QBluetoothLocalDevice>
//! [include]
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+#include <QtCore/QObject>
+#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
+#include <QtBluetooth/QBluetoothTransferManager>
+#include <QtBluetooth/QBluetoothTransferRequest>
+#include <QtBluetooth/QBluetoothTransferReply>
//! [namespace]
QT_USE_NAMESPACE
//! [namespace]
+class MyClass : public QObject
+{
+ Q_OBJECT
+public:
+ MyClass() : QObject() {}
+ void localDevice();
+ void startDiscovery();
+ void objectPush();
+
+public slots:
+ void deviceDiscovered(const QBluetoothDeviceInfo &device);
+ void transferFinished(QBluetoothTransferReply* reply);
+};
+
+void MyClass::localDevice() {
//! [turningon]
QBluetoothLocalDevice localDevice;
QString localDeviceName;
@@ -60,20 +83,31 @@ if (localDevice.isValid()) {
localDeviceName = localDevice.name();
// Make it visible to others
- localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable)
+ localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
+
+ // Get connected devices
+ QList<QBluetoothAddress> remotes;
+ remotes = localDevice.connectedDevices();
}
//! [turningon]
+
+}
+
//! [discovery]
-// Create a discovery agent and connect to its signals
-QBluetoothDiscoveryAgent *discoveryAgent = new QBluetoothDiscoveryAgent(this);
-connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
- this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
+void MyClass::startDiscovery()
+{
-// Start a discovery
-discoveryAgent->start();
+ // Create a discovery agent and connect to its signals
+ QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
+ connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
+ this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
-...
+ // Start a discovery
+ discoveryAgent->start();
+
+ //...
+}
// In your local slot, read information about the found devices
void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
@@ -82,18 +116,36 @@ void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
}
//! [discovery]
+void MyClass::objectPush()
+{
//! [sendfile]
// Create a transfer manager
QBluetoothTransferManager *transferManager = new QBluetoothTransferManager(this);
// Create the transfer request and file to be sent
-QBluetoothTransferRequest request(device.address());
+QBluetoothAddress remoteAddress("00:11:22:33:44:55:66");
+QBluetoothTransferRequest request(remoteAddress);
QFile *file = new QFile("testfile.txt");
// Ask the transfer manager to send it
QBluetoothTransferReply *reply = transferManager->put(request, file);
// Connect to the reply's signals to be informed about the status and do cleanups when done
-connect(reply, SIGNAL(finished(QBluetoothTransferReply*)),
- this, SLOT(transferFinished(QBluetoothTransferReply*)));
+QObject::connect(reply, SIGNAL(finished(QBluetoothTransferReply*)),
+ this, SLOT(transferFinished(QBluetoothTransferReply*)));
//! [sendfile]
+}
+
+void MyClass::transferFinished(QBluetoothTransferReply* /*reply*/)
+{
+}
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+ MyClass cl;
+
+ return app.exec();
+}
+
+#include "doc_src_qtbluetooth.moc"
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro
deleted file mode 100644
index ca021b72..00000000
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#! [contacts project modification]
-QT += bluetooth
-#! [contacts project modification]
diff --git a/src/bluetooth/doc/snippets/snippets.pro b/src/bluetooth/doc/snippets/snippets.pro
new file mode 100644
index 00000000..f59983ee
--- /dev/null
+++ b/src/bluetooth/doc/snippets/snippets.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = bluetooth_cppsnippet
+QT = core
+#! [contacts project modification]
+QT += bluetooth
+#! [contacts project modification]
+
+SOURCES += doc_src_qtbluetooth.cpp
diff --git a/src/bluetooth/doc/src/bluetooth-cpp.qdoc b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
index 9bef246b..df18cc6a 100644
--- a/src/bluetooth/doc/src/bluetooth-cpp.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
@@ -42,6 +42,6 @@
To use the C++ library in your application, add the following configuration
option to your \c .pro file:
- \snippet doc_src_qtbluetooth.pro contacts project modification
+ \snippet snippets.pro contacts project modification
*/
diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc
index 32f6a787..e9575db1 100644
--- a/src/bluetooth/doc/src/bluetooth-index.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-index.qdoc
@@ -32,10 +32,11 @@
Bluetooth is a short-range (less than 100 meters) wireless technology. It
has a reasonably high data transfer rate of 2.1 Mbit/s, which makes it ideal
-for transferring data between devices.
+for transferring data between devices. Currently the API is supported on
+Linux (Bluez 4.x), Android and BlackBerry 10.
Bluetooth connectivity is based on basic device management, such as scanning
-for devices, gathering information about them, and exchaning data between
+for devices, gathering information about them, and exchanging data between
them.
\section1 Getting started
@@ -43,7 +44,7 @@ them.
To use the C++ library in your application, add the following configuration
option to your \c .pro file:
-\snippet doc_src_qtbluetooth.pro contacts project modification
+\snippet snippets.pro contacts project modification
To use the classes of the module in your application you need the following
import statement in your \c .qml file:
diff --git a/src/bluetooth/doc/src/bluetooth-overview.qdoc b/src/bluetooth/doc/src/bluetooth-overview.qdoc
index 4c12ecac..bc8a9543 100644
--- a/src/bluetooth/doc/src/bluetooth-overview.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-overview.qdoc
@@ -39,7 +39,7 @@
\list
\li Retrieve information about the local Bluetooth device.
\li Scan for other Bluetooth devices in range and retrieve information about them.
- \li Push files to remote devices using the OBEX Object Push Profile (OPP).
+ \li Push files to remote devices using the OBEX Object Push Profile (OPP)
\li Connect to remote devices through a RFCOMM channel using the Serial Port Profile (SPP).
\li Create a RFCOMM server that allows incoming connections using SPP.
\li Retrieve specification about Bluetooth Low Energy device.
@@ -47,6 +47,8 @@
\li Receive advertisement from Bluetooth Low Energy device.
\endlist
+ Note that the Object Push Profile is not supported on Android.
+
The following sections describe how to use the Qt Bluetooth C++ API classes
for the above use cases.
@@ -54,16 +56,16 @@
The Qt Bluetooth API has three main purposes. The first one is to
obtain local and remote device information. The first steps in retrieving device information is
- to check if Bluetooth is available on the device and read the local device address and name. The
- QBluetoothLocalDevice is the one to provide all of this information. Additionally you can use it
- to turn Bluetooth on and off and set the visibility on the device.
+ to check if Bluetooth is available on the device and read the local device address and name.
+ QBluetoothLocalDevice is the class that provides all of this information. Additionally you can use it
+ to turn Bluetooth on/off, set the visibility of the device and determine the current connections.
\snippet doc_src_qtbluetooth.cpp turningon
\section1 Scanning for Bluetooth Devices
Similar to the QBluetoothLocalDevice, the API offers QBluetoothDeviceInfo which provides
- that information for remote devices. Although you can just create QBluetoothDeviceInfo objects on
+ similar information for remote devices. Although you can just create QBluetoothDeviceInfo objects on
your own and fill them with data, the easier way is to use the QBluetoothDeviceDiscoveryAgent to
start an automated search for visible Bluetooth devices within the connectable range.
@@ -71,13 +73,13 @@
\section1 Pushing Files to Remote Devices
- Once the desired device is found, there are two main use cases provided by Qt Bluetooth. The
- simpler is to send files via the Obex Object Push Profile (OPP). As the name describes, this
+ Once the desired device was found, there are two main use cases provided by Qt Bluetooth. The
+ simpler one is to send files via the Obex Object Push Profile (OPP). As the name describes, this
profile can only push files from one device to another, but not pull files or browse the remote
file system. Because of this limitation, this profile does not require the two devices to be
paired before exchanging data. To push files to remote devices, create a
QBluetoothTransferRequest and ask the QBluetoothTransferManager to push the file contained in
- the request by calling the put() function.
+ the request by calling its \l {QBluetoothTransferManager::put()}{put()} function.
\snippet doc_src_qtbluetooth.cpp sendfile
@@ -88,21 +90,21 @@
be done by the Serial Port Profile (SPP). The Serial Port Profile emulates a serial connection
over the Bluetooth transport protocol RFCOMM.
- To be able to create SPP connections, you need to register a Server one one device by using
- QRfcommServer.
+ To be able to receive incoming SPP connections, you need to listen to incoming connections using
+ \l QBluetoothServer.
\snippet btchat/chatserver.cpp Create the server
Connect to this server from another device playing the client role by using a
- QBluetoothSocket.
+ QBluetoothSocket:
\snippet btchat/chatclient.cpp startClient
Using such a connection allows to exchange any form of data in both directions.
It is perfectly suited for gaming or for syncing the state between two instances of
an application on two devices. For more detailed descriptions on how to configure the server
- and client, please refer to the detailed description sections in the QRfcommServer and
- QBluetoothSocket classes. A good example to start with SPP is the \l{btchat}{Bluetooth Chat}
+ and client, please refer to the detailed description sections in the \l QBluetoothServer and
+ \l QBluetoothSocket classes. A good example to start with SPP is the \l{btchat}{Bluetooth Chat}
example.
\section1 Bluetooth Low Energy
diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc
index 3b9ea577..08759874 100644
--- a/src/bluetooth/doc/src/examples.qdoc
+++ b/src/bluetooth/doc/src/examples.qdoc
@@ -31,7 +31,7 @@
\title Qt Bluetooth Examples
\brief Examples for the Qt Bluetooth module.
- This is a variety of examples that cover the entire range of the the Qt
+ This is a variety of examples that cover the entire range of the Qt
Bluetooth API. You will find them in their own documentation but they are also
accessible from here.