QBluetoothSocket Class ReferenceThe QBluetoothSocket class provides a Bluetooth socket. More... #include <QBluetoothSocket> Inherits: QIODevice. This class was introduced in Qt Mobility 1.2. Public Types
Public Functions
Reimplemented Public Functions
Signals
Protected Functions
Reimplemented Protected Functions
Additional Inherited Members
Detailed DescriptionThe QBluetoothSocket class provides a Bluetooth socket. QBluetoothSocket supports two socket types, L2CAP and RFCOMM. L2CAP is a low level datagram-oriented Bluetooth socket. RFCOMM is a reliable, stream-oriented socket. RFCOMM sockets emulate an RS-232 serial port. To create a connection to a Bluetooth service create a socket of the appropriate type and call connectToService() passing the Bluetooth address and port number. QBluetoothSocket will emit the connected() signal when the connection is established. Member Type Documentation
|
Constant | Value | Description |
---|---|---|
QBluetoothSocket::UnknownSocketError | QAbstractSocket::UnknownSocketError | An unknown error has occurred. |
QBluetoothSocket::NoSocketError | -2 | No error. Used for testing. |
QBluetoothSocket::ConnectionRefusedError | QAbstractSocket::ConnectionRefusedError | Connection refused or device not available. |
QBluetoothSocket::RemoteHostClosedError | QAbstractSocket::RemoteHostClosedError | The remote host closed the socket |
QBluetoothSocket::HostNotFoundError | QAbstractSocket::HostNotFoundError | Could not find the remote host |
QBluetoothSocket::ServiceNotFoundError | QAbstractSocket::SocketAddressNotAvailableError | Could not find the service UUID on remote host |
QBluetoothSocket::NetworkError | QAbstractSocket::NetworkError | Attempt to read or write from socket returned an error |
This enum describes the state of the Bluetooth socket.
Constant | Value | Description |
---|---|---|
QBluetoothSocket::UnconnectedState | QAbstractSocket::UnconnectedState | Socket is not connected. |
QBluetoothSocket::ServiceLookupState | QAbstractSocket::HostLookupState | Socket is querying connection parameters. |
QBluetoothSocket::ConnectingState | QAbstractSocket::ConnectingState | Socket is attempting to connect to a device. |
QBluetoothSocket::ConnectedState | QAbstractSocket::ConnectedState | Socket is connected to a device. |
QBluetoothSocket::BoundState | QAbstractSocket::BoundState | 242.nmp.nokia.com _IceTransSocketUNIXConnect: Cannot connect to non-local host saisd Socket is bound to a local address and port. |
QBluetoothSocket::ClosingState | QAbstractSocket::ClosingState | Socket is connected and will be closed once all pending data is written to the socket. |
QBluetoothSocket::ListeningState | QAbstractSocket::ListeningState | Socket is listening for incoming connections. |
This enum describes the Bluetooth socket type.
Constant | Value | Description |
---|---|---|
QBluetoothSocket::UnknownSocketType | -1 | Unknown socket type. |
QBluetoothSocket::L2capSocket | 0 | L2CAP socket. |
QBluetoothSocket::RfcommSocket | 1 | RFCOMM socket. |
Constructs a Bluetooth socket of socketType type, with parent.
Constructs a Bluetooth socket with parent.
Destroys the Bluetooth socket.
Aborts the current connection and resets the socket. Unlike disconnectFromService(), this function immediately closes the socket, discarding any pending data in the write buffer.
See also disconnectFromService() and close().
Reimplemented from QIODevice::bytesAvailable().
Returns the number of incoming bytes that are waiting to be read.
See also bytesToWrite() and read().
Reimplemented from QIODevice::bytesToWrite().
Returns the number of bytes that are waiting to be written. The bytes are written when control goes back to the event loop.
Reimplemented from QIODevice::canReadLine().
Returns true if you can read at least one line from the device
Reimplemented from QIODevice::close().
Disconnects the socket's connection with the device.
Attempts to connect to the service described by service.
The socket is opened in the given openMode.
The socket first enters ConnectingState and attempts to connect to the device providing service. If a connection is established, QBluetoothSocket enters ConnectedState and emits connected().
At any point, the socket can emit error() to siganl that an error occurred.
See also state() and disconnectFromService().
Attempts to make a connection to the service identified by uuid on the device with address address.
The socket is opened in the given openMode.
The socket first enters the ServiceLookupState and queries the connection parameters for uuid. If the service parameters are successfully retrieved the socket enters ConnectingState, and attempts to connect to address. If a connection is established, QBluetoothSocket enters Connected State and emits connected().
At any point, the socket can emit error() to signal that an error occurred.
See also state() and disconnectFromService().
Attempts to make a connection with address on the given port.
The socket is opened in the given openMode.
The socket first enters ConnectingState, and attempts to connect to 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.
See also state() and disconnectFromService().
This signal is emitted when a connection is established.
See also QBluetoothSocket::ConnectedState and stateChanged().
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.
See also connectToService().
This signal is emitted when the socket is disconnected.
See also QBluetoothSocket::UnconnectedState and stateChanged().
Start device discovery for service and open the socket with openMode. If the socket is created with a service uuid device address we must use service discovery to find the port number to connect to.
Returns the last error.
This signal is emitted when an error occurs.
See also error().
Returns a user displayable text string for the error.
Reimplemented from QIODevice::isSequential().
Returns the address of the local device.
Returns the name of the local device.
Returns the port number of the local socket if available; otherwise returns 0.
Returns the address of the peer device.
Returns the name of the peer device.
Return the port number of the peer socket if available; otherwise returns 0.
Reimplemented from QIODevice::readData().
Set the socket to use socketDescriptor with a type of socketType which is in state socketState and mode openMode.
Returns true on success
See also socketDescriptor().
Sets the type of error that last occurred to error_.
Sets the socket state to state.
Returns the platform specific socket descriptor, if available
See also setSocketDescriptor().
Returns the socket type.
Returns the current state of the socket.
This signal is emitted when the socket state changes to state.
See also connected(), disconnected(), state(), and QBluetoothSocket::SocketState.
Reimplemented from QIODevice::writeData().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtmobility-1.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com