2011-08-24 04:09:22 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-02-11 13:06:23 +00:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
2013-09-18 09:28:53 +00:00
|
|
|
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
2015-02-11 13:06:23 +00:00
|
|
|
** Contact: http://www.qt.io/licensing/
|
2011-08-24 04:09:22 +00:00
|
|
|
**
|
2011-10-19 15:53:02 +00:00
|
|
|
** This file is part of the QtBluetooth module of the Qt Toolkit.
|
2011-08-24 04:09:22 +00:00
|
|
|
**
|
2014-08-21 12:27:50 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL21$
|
2012-09-20 07:11:55 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-02-11 13:06:23 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
2012-09-20 07:11:55 +00:00
|
|
|
**
|
2011-08-24 04:09:22 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-20 07:11:55 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-08-21 12:27:50 +00:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-08-24 04:09:22 +00:00
|
|
|
**
|
2015-02-11 13:06:23 +00:00
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-08-24 04:09:22 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "qbluetoothsocket.h"
|
|
|
|
#include "qbluetoothsocket_p.h"
|
|
|
|
|
|
|
|
#include "qbluetoothdeviceinfo.h"
|
|
|
|
#include "qbluetoothserviceinfo.h"
|
|
|
|
#include "qbluetoothservicediscoveryagent.h"
|
|
|
|
|
|
|
|
|
2013-12-16 15:02:37 +00:00
|
|
|
#include <QtCore/QLoggingCategory>
|
2011-08-24 04:09:22 +00:00
|
|
|
#include <QSocketNotifier>
|
|
|
|
|
2013-09-05 11:32:00 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
2011-10-19 15:53:02 +00:00
|
|
|
|
2013-12-16 15:02:37 +00:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT)
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
/*!
|
|
|
|
\class QBluetoothSocket
|
2011-12-09 14:27:12 +00:00
|
|
|
\inmodule QtBluetooth
|
2012-09-25 14:24:31 +00:00
|
|
|
\brief The QBluetoothSocket class enables connection to a Bluetooth device
|
2013-08-02 16:09:20 +00:00
|
|
|
running a bluetooth server.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
2014-09-26 08:46:13 +00:00
|
|
|
\since 5.2
|
|
|
|
|
2013-09-18 15:23:16 +00:00
|
|
|
QBluetoothSocket supports two socket types, \l {QBluetoothServiceInfo::L2capProtocol}{L2CAP} and
|
|
|
|
\l {QBluetoothServiceInfo::RfcommProtocol}{RFCOMM}.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
2013-09-18 15:23:16 +00:00
|
|
|
\l {QBluetoothServiceInfo::L2capProtocol}{L2CAP} is a low level datagram-oriented Bluetooth socket.
|
2015-06-15 14:58:54 +00:00
|
|
|
Android does not support \l {QBluetoothServiceInfo::L2capProtocol}{L2CAP} for socket
|
2014-02-10 14:37:17 +00:00
|
|
|
connections.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
2013-09-18 15:23:16 +00:00
|
|
|
\l {QBluetoothServiceInfo::RfcommProtocol}{RFCOMM} is a reliable, stream-oriented socket. RFCOMM
|
2011-08-24 04:09:22 +00:00
|
|
|
sockets emulate an RS-232 serial port.
|
|
|
|
|
2012-02-28 15:54:20 +00:00
|
|
|
To create a connection to a Bluetooth service, create a socket of the appropriate type and call
|
2011-08-24 04:09:22 +00:00
|
|
|
connectToService() passing the Bluetooth address and port number. QBluetoothSocket will emit
|
|
|
|
the connected() signal when the connection is established.
|
|
|
|
|
2013-09-18 15:23:16 +00:00
|
|
|
If the \l {QBluetoothServiceInfo::Protocol}{Protocol} is not supported on a platform, calling
|
|
|
|
\l connectToService() will emit a \l {QBluetoothSocket::UnsupportedProtocolError}{UnsupportedProtocolError} error.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QBluetoothSocket::SocketState
|
|
|
|
|
|
|
|
This enum describes the state of the Bluetooth socket.
|
|
|
|
|
2012-02-28 15:54:20 +00:00
|
|
|
\value UnconnectedState Socket is not connected.
|
2011-08-24 04:09:22 +00:00
|
|
|
\value ServiceLookupState Socket is querying connection parameters.
|
|
|
|
\value ConnectingState Socket is attempting to connect to a device.
|
|
|
|
\value ConnectedState Socket is connected to a device.
|
2012-02-28 15:54:20 +00:00
|
|
|
\value BoundState Socket is bound to a local address and port.
|
2011-08-24 04:09:22 +00:00
|
|
|
\value ClosingState Socket is connected and will be closed once all pending data is
|
2012-02-28 15:54:20 +00:00
|
|
|
written to the socket.
|
2011-08-24 04:09:22 +00:00
|
|
|
\value ListeningState Socket is listening for incoming connections.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\enum QBluetoothSocket::SocketError
|
|
|
|
|
|
|
|
This enum describes Bluetooth socket error types.
|
|
|
|
|
|
|
|
\value UnknownSocketError An unknown error has occurred.
|
|
|
|
\value NoSocketError No error. Used for testing.
|
2013-09-16 19:44:40 +00:00
|
|
|
\value HostNotFoundError Could not find the remote host.
|
|
|
|
\value ServiceNotFoundError Could not find the service UUID on remote host.
|
2011-08-24 04:09:22 +00:00
|
|
|
\value NetworkError Attempt to read or write from socket returned an error
|
2013-09-18 15:23:16 +00:00
|
|
|
\value UnsupportedProtocolError The \l {QBluetoothServiceInfo::Protocol}{Protocol} is not
|
2013-09-18 09:28:53 +00:00
|
|
|
supported on this platform.
|
2014-02-10 14:37:17 +00:00
|
|
|
\value OperationError An operation was attempted while the socket was in a state
|
|
|
|
that did not permit it.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::connected()
|
|
|
|
|
|
|
|
This signal is emitted when a connection is established.
|
|
|
|
|
|
|
|
\sa QBluetoothSocket::ConnectedState, stateChanged()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::disconnected()
|
|
|
|
|
|
|
|
This signal is emitted when the socket is disconnected.
|
|
|
|
|
|
|
|
\sa QBluetoothSocket::UnconnectedState, stateChanged()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::error(QBluetoothSocket::SocketError error)
|
|
|
|
|
|
|
|
This signal is emitted when an \a error occurs.
|
|
|
|
|
|
|
|
\sa error()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QBluetoothSocket::stateChanged(QBluetoothSocket::SocketState state)
|
|
|
|
|
|
|
|
This signal is emitted when the socket state changes to \a state.
|
|
|
|
|
|
|
|
\sa connected(), disconnected(), state(), QBluetoothSocket::SocketState
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::abort()
|
|
|
|
|
|
|
|
Aborts the current connection and resets the socket. Unlike disconnectFromService(), this
|
|
|
|
function immediately closes the socket, discarding any pending data in the write buffer.
|
|
|
|
|
2014-10-10 08:57:37 +00:00
|
|
|
\note On Android, aborting the socket requires asynchronous interaction with Android threads.
|
|
|
|
Therefore the associated \l disconnected() and \l stateChanged() signals are delayed
|
|
|
|
until the threads have finished the closure.
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
\sa disconnectFromService(), close()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::close()
|
|
|
|
|
|
|
|
Disconnects the socket's connection with the device.
|
2014-10-10 08:57:37 +00:00
|
|
|
|
|
|
|
\note On Android, closing the socket requires asynchronous interaction with Android threads.
|
|
|
|
Therefore the associated \l disconnected() and \l stateChanged() signals are delayed
|
|
|
|
until the threads have finished the closure.
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void QBluetoothSocket::disconnectFromService()
|
|
|
|
|
|
|
|
Attempts to close the socket. If there is pending data waiting to be written QBluetoothSocket
|
|
|
|
will enter ClosingState and wait until all data has been written. Eventually, it will enter
|
|
|
|
UnconnectedState and emit the disconnected() signal.
|
|
|
|
|
|
|
|
\sa connectToService()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QString QBluetoothSocket::localName() const
|
|
|
|
|
|
|
|
Returns the name of the local device.
|
2014-01-27 16:23:47 +00:00
|
|
|
|
|
|
|
Although some platforms may differ the socket must generally be connected to guarantee
|
|
|
|
the return of a valid name. In particular, this is true when dealing with platforms
|
|
|
|
that support multiple local Bluetooth adapters.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QBluetoothAddress QBluetoothSocket::localAddress() const
|
|
|
|
|
|
|
|
Returns the address of the local device.
|
2014-01-27 16:23:47 +00:00
|
|
|
|
|
|
|
Although some platforms may differ the socket must generally be connected to guarantee
|
|
|
|
the return of a valid address. In particular, this is true when dealing with platforms
|
|
|
|
that support multiple local Bluetooth adapters.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn quint16 QBluetoothSocket::localPort() const
|
|
|
|
|
2012-02-28 15:54:20 +00:00
|
|
|
Returns the port number of the local socket if available, otherwise returns 0.
|
2014-01-27 16:23:47 +00:00
|
|
|
Although some platforms may differ the socket must generally be connected to guarantee
|
|
|
|
the return of a valid port number.
|
|
|
|
|
2015-06-15 14:58:54 +00:00
|
|
|
On Android and OS X, this feature is not supported and returns 0.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QString QBluetoothSocket::peerName() const
|
|
|
|
|
|
|
|
Returns the name of the peer device.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QBluetoothAddress QBluetoothSocket::peerAddress() const
|
|
|
|
|
|
|
|
Returns the address of the peer device.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn quint16 QBluetoothSocket::peerPort() const
|
|
|
|
|
2012-02-28 15:54:20 +00:00
|
|
|
Return the port number of the peer socket if available, otherwise returns 0.
|
2015-06-15 14:58:54 +00:00
|
|
|
On Android, this feature is not supported.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn qint64 QBluetoothSocket::readData(char *data, qint64 maxSize)
|
|
|
|
|
|
|
|
\reimp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn qint64 QBluetoothSocket::writeData(const char *data, qint64 maxSize)
|
|
|
|
|
|
|
|
\reimp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Constructs a Bluetooth socket of \a socketType type, with \a parent.
|
|
|
|
*/
|
2013-09-18 15:23:16 +00:00
|
|
|
QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent)
|
2011-08-24 04:09:22 +00:00
|
|
|
: QIODevice(parent), d_ptr(new QBluetoothSocketPrivate)
|
|
|
|
{
|
|
|
|
d_ptr->q_ptr = this;
|
|
|
|
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
d->ensureNativeSocket(socketType);
|
|
|
|
|
2014-10-10 12:41:59 +00:00
|
|
|
setOpenMode(QIODevice::NotOpen);
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Constructs a Bluetooth socket with \a parent.
|
|
|
|
*/
|
|
|
|
QBluetoothSocket::QBluetoothSocket(QObject *parent)
|
|
|
|
: QIODevice(parent), d_ptr(new QBluetoothSocketPrivate)
|
|
|
|
{
|
|
|
|
d_ptr->q_ptr = this;
|
2014-10-10 12:41:59 +00:00
|
|
|
setOpenMode(QIODevice::NotOpen);
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Destroys the Bluetooth socket.
|
|
|
|
*/
|
|
|
|
QBluetoothSocket::~QBluetoothSocket()
|
|
|
|
{
|
|
|
|
delete d_ptr;
|
|
|
|
d_ptr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\reimp
|
|
|
|
*/
|
|
|
|
bool QBluetoothSocket::isSequential() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the number of incoming bytes that are waiting to be read.
|
|
|
|
|
|
|
|
\sa bytesToWrite(), read()
|
|
|
|
*/
|
|
|
|
qint64 QBluetoothSocket::bytesAvailable() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return QIODevice::bytesAvailable() + d->bytesAvailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the number of bytes that are waiting to be written. The bytes are written when control
|
|
|
|
goes back to the event loop.
|
|
|
|
*/
|
|
|
|
qint64 QBluetoothSocket::bytesToWrite() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->txBuffer.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Attempts to connect to the service described by \a service.
|
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
The socket is opened in the given \a openMode. The \l socketType() may change
|
|
|
|
depending on the protocol required by \a service.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
The socket first enters ConnectingState and attempts to connect to the device providing
|
2011-08-24 04:09:22 +00:00
|
|
|
\a service. If a connection is established, QBluetoothSocket enters ConnectedState and
|
|
|
|
emits connected().
|
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
At any point, the socket can emit error() to signal that an error occurred.
|
2012-11-22 09:34:59 +00:00
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
Note that most platforms require a pairing prior to connecting to the remote device. Otherwise
|
|
|
|
the connection process may fail.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
\sa state(), disconnectFromService()
|
|
|
|
*/
|
|
|
|
void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, OpenMode openMode)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
2014-02-10 14:37:17 +00:00
|
|
|
|
2014-02-20 15:18:06 +00:00
|
|
|
if (state() != QBluetoothSocket::UnconnectedState && state() != QBluetoothSocket::ServiceLookupState) {
|
2014-02-10 14:37:17 +00:00
|
|
|
qCWarning(QT_BT) << "QBluetoothSocket::connectToService called on busy socket";
|
|
|
|
d->errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
|
|
|
setSocketError(QBluetoothSocket::OperationError);
|
|
|
|
return;
|
|
|
|
}
|
2015-06-15 14:58:54 +00:00
|
|
|
#if defined(QT_ANDROID_BLUETOOTH)
|
2014-02-10 14:37:17 +00:00
|
|
|
if (!d->ensureNativeSocket(service.socketProtocol())) {
|
2013-09-18 09:28:53 +00:00
|
|
|
d->errorString = tr("Socket type not supported");
|
2014-02-10 14:37:17 +00:00
|
|
|
setSocketError(QBluetoothSocket::UnsupportedProtocolError);
|
2013-09-18 09:28:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-22 09:34:59 +00:00
|
|
|
d->connectToService(service.device().address(), service.serviceUuid(), openMode);
|
|
|
|
#else
|
2011-08-24 04:09:22 +00:00
|
|
|
if (service.protocolServiceMultiplexer() > 0) {
|
2013-09-18 15:23:16 +00:00
|
|
|
if (!d->ensureNativeSocket(QBluetoothServiceInfo::L2capProtocol)) {
|
2014-01-28 09:13:28 +00:00
|
|
|
d->errorString = tr("Unknown socket error");
|
|
|
|
setSocketError(UnknownSocketError);
|
2011-08-24 04:09:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
d->connectToService(service.device().address(), service.protocolServiceMultiplexer(), openMode);
|
|
|
|
} else if (service.serverChannel() > 0) {
|
2013-09-18 15:23:16 +00:00
|
|
|
if (!d->ensureNativeSocket(QBluetoothServiceInfo::RfcommProtocol)) {
|
2014-01-28 09:13:28 +00:00
|
|
|
d->errorString = tr("Unknown socket error");
|
|
|
|
setSocketError(UnknownSocketError);
|
2011-08-24 04:09:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
d->connectToService(service.device().address(), service.serverChannel(), openMode);
|
|
|
|
} else {
|
|
|
|
// try doing service discovery to see if we can find the socket
|
|
|
|
if(service.serviceUuid().isNull()){
|
2013-12-16 15:02:37 +00:00
|
|
|
qCWarning(QT_BT) << "No port, no PSM, and no UUID provided, unable to connect";
|
2011-08-24 04:09:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-12-16 15:02:37 +00:00
|
|
|
qCDebug(QT_BT) << "Need a port/psm, doing discovery";
|
2011-08-24 04:09:22 +00:00
|
|
|
doDeviceDiscovery(service, openMode);
|
|
|
|
}
|
2012-11-22 09:34:59 +00:00
|
|
|
#endif
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Attempts to make a connection to the service identified by \a uuid on the device with address
|
|
|
|
\a address.
|
|
|
|
|
|
|
|
The socket is opened in the given \a openMode.
|
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
For BlueZ, the socket first enters the \l ServiceLookupState and queries the connection parameters for
|
2011-08-24 04:09:22 +00:00
|
|
|
\a uuid. If the service parameters are successfully retrieved the socket enters
|
|
|
|
ConnectingState, and attempts to connect to \a address. If a connection is established,
|
|
|
|
QBluetoothSocket enters Connected State and emits connected().
|
|
|
|
|
2015-06-15 14:58:54 +00:00
|
|
|
On Android, the service connection can directly be established
|
|
|
|
using the UUID of the remote service. Therefore the platforms does not require
|
2014-02-10 14:37:17 +00:00
|
|
|
the \l ServiceLookupState and \l socketType() is always set to
|
|
|
|
\l QBluetoothServiceInfo::RfcommProtocol.
|
2012-11-22 09:34:59 +00:00
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
At any point, the socket can emit error() to signal that an error occurred.
|
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
Note that most platforms require a pairing prior to connecting to the remote device. Otherwise
|
|
|
|
the connection process may fail.
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
\sa state(), disconnectFromService()
|
|
|
|
*/
|
|
|
|
void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, OpenMode openMode)
|
|
|
|
{
|
2012-11-22 09:34:59 +00:00
|
|
|
Q_D(QBluetoothSocket);
|
2014-02-10 14:37:17 +00:00
|
|
|
|
|
|
|
if (state() != QBluetoothSocket::UnconnectedState) {
|
|
|
|
qCWarning(QT_BT) << "QBluetoothSocket::connectToService called on busy socket";
|
|
|
|
d->errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
|
|
|
setSocketError(QBluetoothSocket::OperationError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-15 14:58:54 +00:00
|
|
|
#if defined(QT_ANDROID_BLUETOOTH)
|
2014-02-10 14:37:17 +00:00
|
|
|
if (!d->ensureNativeSocket(QBluetoothServiceInfo::RfcommProtocol)) {
|
2013-09-18 09:28:53 +00:00
|
|
|
d->errorString = tr("Socket type not supported");
|
2014-02-10 14:37:17 +00:00
|
|
|
setSocketError(QBluetoothSocket::UnsupportedProtocolError);
|
2013-09-18 09:28:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-22 09:34:59 +00:00
|
|
|
d->connectToService(address, uuid, openMode);
|
|
|
|
#else
|
2011-08-24 04:09:22 +00:00
|
|
|
QBluetoothServiceInfo service;
|
|
|
|
QBluetoothDeviceInfo device(address, QString(), QBluetoothDeviceInfo::MiscellaneousDevice);
|
|
|
|
service.setDevice(device);
|
|
|
|
service.setServiceUuid(uuid);
|
|
|
|
doDeviceDiscovery(service, openMode);
|
2012-11-22 09:34:59 +00:00
|
|
|
#endif
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Attempts to make a connection with \a address on the given \a port.
|
|
|
|
|
|
|
|
The socket is opened in the given \a openMode.
|
|
|
|
|
|
|
|
The socket first enters ConnectingState, and attempts to connect to \a address. If a
|
|
|
|
connection is established, QBluetoothSocket enters ConnectedState and emits connected().
|
|
|
|
|
|
|
|
At any point, the socket can emit error() to signal that an error occurred.
|
|
|
|
|
2015-06-15 14:58:54 +00:00
|
|
|
On Android, a connection to a service can not be established using a port. Calling this function
|
2013-09-16 19:44:40 +00:00
|
|
|
will emit a \l {QBluetoothSocket::ServiceNotFoundError}{ServiceNotFoundError}
|
2012-11-22 09:34:59 +00:00
|
|
|
|
2014-02-10 14:37:17 +00:00
|
|
|
Note that most platforms require a pairing prior to connecting to the remote device. Otherwise
|
|
|
|
the connection process may fail.
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
\sa state(), disconnectFromService()
|
|
|
|
*/
|
|
|
|
void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint16 port, OpenMode openMode)
|
|
|
|
{
|
2013-09-18 15:23:16 +00:00
|
|
|
Q_D(QBluetoothSocket);
|
2015-06-15 14:58:54 +00:00
|
|
|
#if defined(QT_ANDROID_BLUETOOTH)
|
2012-11-22 09:34:59 +00:00
|
|
|
Q_UNUSED(port);
|
|
|
|
Q_UNUSED(openMode);
|
|
|
|
Q_UNUSED(address);
|
2014-02-10 14:37:17 +00:00
|
|
|
d->errorString = tr("Connecting to port is not supported");
|
|
|
|
setSocketError(QBluetoothSocket::ServiceNotFoundError);
|
|
|
|
qCWarning(QT_BT) << "Connecting to port is not supported";
|
2012-11-22 09:34:59 +00:00
|
|
|
#else
|
2014-02-10 14:37:17 +00:00
|
|
|
if (state() != QBluetoothSocket::UnconnectedState) {
|
|
|
|
qCWarning(QT_BT) << "QBluetoothSocket::connectToService called on busy socket";
|
|
|
|
d->errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
|
|
|
setSocketError(QBluetoothSocket::OperationError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
setOpenMode(openMode);
|
|
|
|
d->connectToService(address, port, openMode);
|
2012-11-22 09:34:59 +00:00
|
|
|
#endif
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2014-02-10 14:37:17 +00:00
|
|
|
Returns the socket type. The socket automatically adjusts to the protocol
|
|
|
|
offered by the remote service.
|
|
|
|
|
2015-06-15 14:58:54 +00:00
|
|
|
Android only support \l{QBluetoothServiceInfo::RfcommProtocol}{RFCOMM}
|
2014-02-10 14:37:17 +00:00
|
|
|
based sockets.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
2013-09-18 15:23:16 +00:00
|
|
|
QBluetoothServiceInfo::Protocol QBluetoothSocket::socketType() const
|
2011-08-24 04:09:22 +00:00
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->socketType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the current state of the socket.
|
|
|
|
*/
|
|
|
|
QBluetoothSocket::SocketState QBluetoothSocket::state() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the last error.
|
|
|
|
*/
|
|
|
|
QBluetoothSocket::SocketError QBluetoothSocket::error() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->socketError;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns a user displayable text string for the error.
|
|
|
|
*/
|
|
|
|
QString QBluetoothSocket::errorString() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->errorString;
|
|
|
|
}
|
|
|
|
|
2015-06-19 12:25:54 +00:00
|
|
|
/*!
|
|
|
|
Sets the preferred security parameter for the connection attempt to
|
|
|
|
\a flags. This value is incorporated when calling \l connectToService().
|
|
|
|
Therefore it is required to reconnect to change this parameter for an
|
|
|
|
existing connection.
|
|
|
|
|
|
|
|
On Bluez this property is set to QBluetooth::Authorization by default.
|
|
|
|
|
|
|
|
On OS X, this value is ignored as the platform does not permit access
|
|
|
|
to the security parameter of the socket. By default the platform prefers
|
|
|
|
secure/encrypted connections though and therefore this function always
|
|
|
|
returns \l QBluetooth::Secure.
|
|
|
|
|
|
|
|
Android only supports two levels of security (secure and non-secure). If this flag is set to
|
|
|
|
\l QBluetooth::NoSecurity the socket object will not employ any authentication or encryption.
|
|
|
|
Any other security flag combination will trigger a secure Bluetooth connection.
|
|
|
|
This flag is set to \l QBluetooth::Secure by default.
|
|
|
|
|
|
|
|
\note A secure connection requires a pairing between the two devices. On
|
|
|
|
some platforms, the pairing is automatically initiated during the establishment
|
|
|
|
of the connection. Other platforms require the application to manually trigger
|
|
|
|
the pairing before attempting to connect.
|
|
|
|
|
|
|
|
\sa preferredSecurityFlags()
|
|
|
|
|
2015-09-15 13:30:01 +00:00
|
|
|
\since 5.6
|
2015-06-19 12:25:54 +00:00
|
|
|
*/
|
|
|
|
void QBluetoothSocket::setPreferredSecurityFlags(QBluetooth::SecurityFlags flags)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
if (d->secFlags != flags)
|
|
|
|
d->secFlags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the security parameters used for the initial connection
|
|
|
|
attempt.
|
|
|
|
|
|
|
|
The security parameters may be renegotiated between the two parties
|
|
|
|
during or after the connection has been established. If such a change happens
|
|
|
|
it is not reflected in the value of this flag.
|
|
|
|
|
|
|
|
On OS X, this flag is always set to \l QBluetooth::Secure.
|
|
|
|
|
|
|
|
\sa setPreferredSecurityFlags()
|
|
|
|
|
2015-09-15 13:30:01 +00:00
|
|
|
\since 5.6
|
2015-06-19 12:25:54 +00:00
|
|
|
*/
|
|
|
|
QBluetooth::SecurityFlags QBluetoothSocket::preferredSecurityFlags() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->secFlags;
|
|
|
|
}
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
/*!
|
|
|
|
Sets the socket state to \a state.
|
|
|
|
*/
|
|
|
|
void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
SocketState old = d->state;
|
|
|
|
d->state = state;
|
|
|
|
if(old != d->state)
|
|
|
|
emit stateChanged(state);
|
|
|
|
if(state == ListeningState){
|
|
|
|
// TODO: look at this, is this really correct?
|
|
|
|
// if we're a listening socket we can't handle connects?
|
|
|
|
if (d->readNotifier) {
|
|
|
|
d->readNotifier->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns true if you can read at least one line from the device
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool QBluetoothSocket::canReadLine() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->buffer.canReadLine() || QIODevice::canReadLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the type of error that last occurred to \a error_.
|
|
|
|
*/
|
|
|
|
void QBluetoothSocket::setSocketError(QBluetoothSocket::SocketError error_)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
d->socketError = error_;
|
|
|
|
emit error(error_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Start device discovery for \a service and open the socket with \a openMode. If the socket
|
2012-02-28 15:54:20 +00:00
|
|
|
is created with a service uuid device address, use service discovery to find the
|
2011-08-24 04:09:22 +00:00
|
|
|
port number to connect to.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, OpenMode openMode)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
|
2013-09-24 09:12:32 +00:00
|
|
|
setSocketState(QBluetoothSocket::ServiceLookupState);
|
2013-12-16 15:02:37 +00:00
|
|
|
qCDebug(QT_BT) << "Starting discovery";
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
if(d->discoveryAgent) {
|
2014-01-24 13:12:46 +00:00
|
|
|
d->discoveryAgent->stop();
|
2011-08-24 04:09:22 +00:00
|
|
|
delete d->discoveryAgent;
|
|
|
|
}
|
|
|
|
|
2014-01-24 13:12:46 +00:00
|
|
|
d->discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
|
|
|
|
d->discoveryAgent->setRemoteAddress(service.device().address());
|
2011-08-24 04:09:22 +00:00
|
|
|
|
2013-09-17 14:30:32 +00:00
|
|
|
//qDebug() << "Got agent";
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
connect(d->discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
|
|
|
|
connect(d->discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
|
|
|
|
|
|
|
|
d->openMode = openMode;
|
|
|
|
|
|
|
|
if(!service.serviceUuid().isNull())
|
|
|
|
d->discoveryAgent->setUuidFilter(service.serviceUuid());
|
|
|
|
|
|
|
|
if(!service.serviceClassUuids().isEmpty())
|
|
|
|
d->discoveryAgent->setUuidFilter(service.serviceClassUuids());
|
|
|
|
|
|
|
|
// we have to ID the service somehow
|
|
|
|
Q_ASSERT(!d->discoveryAgent->uuidFilter().isEmpty());
|
|
|
|
|
2013-12-16 15:02:37 +00:00
|
|
|
qCDebug(QT_BT) << "UUID filter" << d->discoveryAgent->uuidFilter();
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
d->discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QBluetoothSocket::serviceDiscovered(const QBluetoothServiceInfo &service)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
2013-12-16 15:02:37 +00:00
|
|
|
qCDebug(QT_BT) << "FOUND SERVICE!" << service;
|
2014-08-25 11:40:04 +00:00
|
|
|
if (service.protocolServiceMultiplexer() > 0 || service.serverChannel() > 0) {
|
2011-08-24 04:09:22 +00:00
|
|
|
connectToService(service, d->openMode);
|
|
|
|
d->discoveryAgent->deleteLater();
|
|
|
|
d->discoveryAgent = 0;
|
2014-08-25 11:40:04 +00:00
|
|
|
} else {
|
|
|
|
qCDebug(QT_BT) << "Could not find port/psm for potential remote service";
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QBluetoothSocket::discoveryFinished()
|
|
|
|
{
|
2013-12-16 15:02:37 +00:00
|
|
|
qCDebug(QT_BT) << "Socket discovery finished";
|
2011-08-24 04:09:22 +00:00
|
|
|
Q_D(QBluetoothSocket);
|
2013-12-16 15:02:37 +00:00
|
|
|
if (d->discoveryAgent){
|
|
|
|
qCDebug(QT_BT) << "Didn't find any";
|
2014-01-28 09:13:28 +00:00
|
|
|
d->errorString = tr("Service cannot be found");
|
|
|
|
setSocketError(ServiceNotFoundError);
|
2014-02-13 09:54:51 +00:00
|
|
|
setSocketState(QBluetoothSocket::UnconnectedState);
|
2011-08-24 04:09:22 +00:00
|
|
|
d->discoveryAgent->deleteLater();
|
|
|
|
d->discoveryAgent = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QBluetoothSocket::abort()
|
|
|
|
{
|
2014-02-10 14:37:17 +00:00
|
|
|
if (state() == UnconnectedState)
|
|
|
|
return;
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
Q_D(QBluetoothSocket);
|
2014-10-10 12:41:59 +00:00
|
|
|
setOpenMode(QIODevice::NotOpen);
|
2015-03-18 14:42:02 +00:00
|
|
|
|
|
|
|
if (state() == ServiceLookupState && d->discoveryAgent) {
|
|
|
|
d->discoveryAgent->disconnect();
|
|
|
|
d->discoveryAgent->stop();
|
|
|
|
d->discoveryAgent = 0;
|
|
|
|
}
|
|
|
|
|
2014-10-10 12:41:59 +00:00
|
|
|
setSocketState(ClosingState);
|
2011-08-24 04:09:22 +00:00
|
|
|
d->abort();
|
2014-04-14 18:03:42 +00:00
|
|
|
|
|
|
|
#ifndef QT_ANDROID_BLUETOOTH
|
|
|
|
//Android closes when the Java event loop comes around
|
2011-08-24 04:09:22 +00:00
|
|
|
setSocketState(QBluetoothSocket::UnconnectedState);
|
2014-04-14 18:03:42 +00:00
|
|
|
emit disconnected();
|
|
|
|
#endif
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QBluetoothSocket::disconnectFromService()
|
|
|
|
{
|
2014-02-10 14:37:17 +00:00
|
|
|
close();
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QBluetoothSocket::localName() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->localName();
|
|
|
|
}
|
|
|
|
|
|
|
|
QBluetoothAddress QBluetoothSocket::localAddress() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->localAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 QBluetoothSocket::localPort() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->localPort();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QBluetoothSocket::peerName() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->peerName();
|
|
|
|
}
|
|
|
|
|
|
|
|
QBluetoothAddress QBluetoothSocket::peerAddress() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->peerAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 QBluetoothSocket::peerPort() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->peerPort();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 QBluetoothSocket::writeData(const char *data, qint64 maxSize)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
2014-09-26 12:18:20 +00:00
|
|
|
|
|
|
|
if (!data || maxSize <= 0) {
|
|
|
|
d_ptr->errorString = tr("Invalid data/data size");
|
|
|
|
setSocketError(QBluetoothSocket::OperationError);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
return d->writeData(data, maxSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 QBluetoothSocket::readData(char *data, qint64 maxSize)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
return d->readData(data, maxSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QBluetoothSocket::close()
|
|
|
|
{
|
2014-02-10 14:37:17 +00:00
|
|
|
if (state() == UnconnectedState)
|
|
|
|
return;
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
Q_D(QBluetoothSocket);
|
2014-10-10 12:41:59 +00:00
|
|
|
setOpenMode(QIODevice::NotOpen);
|
2015-03-18 14:42:02 +00:00
|
|
|
|
|
|
|
if (state() == ServiceLookupState && d->discoveryAgent) {
|
|
|
|
d->discoveryAgent->disconnect();
|
|
|
|
d->discoveryAgent->stop();
|
|
|
|
d->discoveryAgent = 0;
|
|
|
|
}
|
|
|
|
|
2011-08-24 04:09:22 +00:00
|
|
|
setSocketState(ClosingState);
|
|
|
|
|
|
|
|
d->close();
|
|
|
|
|
2014-04-14 18:03:42 +00:00
|
|
|
#ifndef QT_ANDROID_BLUETOOTH
|
|
|
|
//Android closes when the Java event loop comes around
|
2011-08-24 04:09:22 +00:00
|
|
|
setSocketState(UnconnectedState);
|
2014-04-14 18:03:42 +00:00
|
|
|
emit disconnected();
|
|
|
|
#endif
|
2011-08-24 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2012-02-28 15:54:20 +00:00
|
|
|
Set the socket to use \a socketDescriptor with a type of \a socketType,
|
|
|
|
which is in state, \a socketState, and mode, \a openMode.
|
2011-08-24 04:09:22 +00:00
|
|
|
|
|
|
|
Returns true on success
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-09-18 15:23:16 +00:00
|
|
|
bool QBluetoothSocket::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
|
2011-08-24 04:09:22 +00:00
|
|
|
SocketState socketState, OpenMode openMode)
|
|
|
|
{
|
|
|
|
Q_D(QBluetoothSocket);
|
|
|
|
return d->setSocketDescriptor(socketDescriptor, socketType, socketState, openMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2012-02-28 15:54:20 +00:00
|
|
|
Returns the platform-specific socket descriptor, if available.
|
2014-02-26 13:31:25 +00:00
|
|
|
This function returns -1 if the descriptor is not available or an error has occurred.
|
2011-08-24 04:09:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
int QBluetoothSocket::socketDescriptor() const
|
|
|
|
{
|
|
|
|
Q_D(const QBluetoothSocket);
|
|
|
|
return d->socket;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
|
|
|
QDebug operator<<(QDebug debug, QBluetoothSocket::SocketError error)
|
|
|
|
{
|
|
|
|
switch (error) {
|
|
|
|
case QBluetoothSocket::UnknownSocketError:
|
|
|
|
debug << "QBluetoothSocket::UnknownSocketError";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::HostNotFoundError:
|
|
|
|
debug << "QBluetoothSocket::HostNotFoundError";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::ServiceNotFoundError:
|
|
|
|
debug << "QBluetoothSocket::ServiceNotFoundError";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::NetworkError:
|
|
|
|
debug << "QBluetoothSocket::NetworkError";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug << "QBluetoothSocket::SocketError(" << (int)error << ")";
|
|
|
|
}
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug debug, QBluetoothSocket::SocketState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case QBluetoothSocket::UnconnectedState:
|
|
|
|
debug << "QBluetoothSocket::UnconnectedState";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::ConnectingState:
|
|
|
|
debug << "QBluetoothSocket::ConnectingState";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::ConnectedState:
|
|
|
|
debug << "QBluetoothSocket::ConnectedState";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::BoundState:
|
|
|
|
debug << "QBluetoothSocket::BoundState";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::ClosingState:
|
|
|
|
debug << "QBluetoothSocket::ClosingState";
|
|
|
|
break;
|
|
|
|
case QBluetoothSocket::ListeningState:
|
|
|
|
debug << "QBluetoothSocket::ListeningState";
|
|
|
|
break;
|
2013-09-24 09:12:32 +00:00
|
|
|
case QBluetoothSocket::ServiceLookupState:
|
|
|
|
debug << "QBluetoothSocket::ServiceLookupState";
|
|
|
|
break;
|
2011-08-24 04:09:22 +00:00
|
|
|
default:
|
|
|
|
debug << "QBluetoothSocket::SocketState(" << (int)state << ")";
|
|
|
|
}
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "moc_qbluetoothsocket.cpp"
|
2011-10-19 15:53:02 +00:00
|
|
|
|
2013-09-05 11:32:00 +00:00
|
|
|
QT_END_NAMESPACE
|