QBluetoothServer Class
The QBluetoothServer class uses the RFCOMM or L2cap protocol to communicate with a Bluetooth device. More...
Header: | #include <QBluetoothServer> |
qmake: | QT += bluetooth |
Since: | Qt 5.2 |
Inherits: | QObject |
This class was introduced in Qt 5.2.
Public Types
enum | Error { NoError, UnknownError, PoweredOffError, InputOutputError, ServiceAlreadyRegisteredError, UnsupportedProtocolError } |
Public Functions
QBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject *parent = nullptr) | |
virtual | ~QBluetoothServer() |
bool | isListening() const |
int | maxPendingConnections() const |
- 16 public functions inherited from QObject
Related Non-Members
typedef | QObjectList |
Macros
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Q_CLASSINFO(Name, Value) | |
Q_DISABLE_COPY(Class) | |
Q_DISABLE_COPY_MOVE(Class) | |
Q_DISABLE_MOVE(Class) | |
Q_EMIT | |
Q_ENUM(...) | |
Q_ENUM_NS(...) | |
Q_FLAG(...) | |
Q_FLAG_NS(...) | |
Q_GADGET | |
Q_INTERFACES(...) | |
Q_INVOKABLE | |
Q_NAMESPACE | |
Q_OBJECT | |
Q_PROPERTY(...) | |
Q_REVISION | |
Q_SET_OBJECT_NAME(Object) | |
Q_SIGNAL | |
Q_SIGNALS | |
Q_SLOT | |
Q_SLOTS |
Additional Inherited Members
- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 signal inherited from QObject
- 5 static public members inherited from QObject
- 8 protected functions inherited from QObject
Detailed Description
QBluetoothServer is used to implement Bluetooth services over RFCOMM or L2cap.
Start listening for incoming connections with listen(). Wait till the newConnection() signal is emitted when a new connection is established, and call nextPendingConnection() to get a QBluetoothSocket for the new connection.
To enable other devices to find your service, create a QBluetoothServiceInfo with the applicable attributes for your service and register it using QBluetoothServiceInfo::registerService(). Call serverPort() to get the channel number that is being used.
If the QBluetoothServiceInfo::Protocol is not supported by a platform, listen() will return false
. Android and WinRT only support RFCOMM for example.
On iOS, this class cannot be used because the platform does not expose an API which may permit access to QBluetoothServer related features.
See also QBluetoothServiceInfo and QBluetoothSocket.
Member Type Documentation
enum QBluetoothServer::Error
This enum describes Bluetooth server error types.
Constant | Value | Description |
---|---|---|
QBluetoothServer::NoError | 0 | No error. |
QBluetoothServer::UnknownError | 1 | An unknown error occurred. |
QBluetoothServer::PoweredOffError | 2 | The Bluetooth adapter is powered off. |
QBluetoothServer::InputOutputError | 3 | An input output error occurred. |
QBluetoothServer::ServiceAlreadyRegisteredError | 4 | The service or port was already registered |
QBluetoothServer::UnsupportedProtocolError | 5 | The Protocol is not supported on this platform. |
Member Function Documentation
QBluetoothServer::QBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject *parent = nullptr)
Constructs a bluetooth server with parent and serverType.
[virtual]
QBluetoothServer::~QBluetoothServer()
Destroys the bluetooth server.
bool QBluetoothServer::isListening() const
Returns true if the server is listening for incoming connections, otherwise false.
int QBluetoothServer::maxPendingConnections() const
Returns the maximum number of pending connections.
See also setMaxPendingConnections().