Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QBluetoothRfcommSerialPort Class Reference
[QtBluetoothModule]

The QBluetoothRfcommSerialPort class represents a RFCOMM serial port device. More...

    #include <QBluetoothRfcommSerialPort>

Inherits QObject.

Public Types

  • enum Error { NoError, SocketNotConnected, ConnectionFailed, ConnectionCancelled, CreationError }
  • enum Flag { KeepAlive }
  • flags Flags

Public Functions

  • 29 public functions inherited from QObject

Signals

Static Public Members

  • 4 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public type inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QBluetoothRfcommSerialPort class represents a RFCOMM serial port device.

This class enables conversion of RFCOMM sockets into serial tty devices. The class can be used in two major ways, by adapting an existing connected RFCOMM socket or by using the connect() function to establish a client connection to a remote device and adapt the resulting connection to a tty device.

The resulting tty device can be used by other applications like a regular serial tty device.

    // Adapt a connected RFCOMM socket into a serial tty device

    if (rfcommSocket->state() != QBluetoothRfcommSocket::ConnectedState) {
        // Bail out
        return;
    }

    QBluetoothRfcommSerialPort *serial =
        new QBluetoothRfcommSerialPort(rfcommSocket);

    if (serial->id() == -1) {
        // Error creating serial port
        return;
    }

    rfcommSocket->close();

    // Use serial port
    openSerialPort(serial->device());

See also QBluetoothRfcommSocket and QSerialIODevice.


Member Type Documentation

enum QBluetoothRfcommSerialPort::Error

Defines errors that could occur in QBluetoothRfcommSerialPort

ConstantValueDescription
QBluetoothRfcommSerialPort::NoError0No error has occurred.
QBluetoothRfcommSerialPort::SocketNotConnected1The given socket is not connected.
QBluetoothRfcommSerialPort::ConnectionFailed2Could not connect to the remote device.
QBluetoothRfcommSerialPort::ConnectionCancelled3Connection has been cancelled.
QBluetoothRfcommSerialPort::CreationError4Could not create the serial port device.

enum QBluetoothRfcommSerialPort::Flag
flags QBluetoothRfcommSerialPort::Flags

Defines flags that alter the behavior of the QBluetoothRfcommSerialPort

ConstantValueDescription
QBluetoothRfcommSerialPort::KeepAlive0x01Deleting the serial port object will not necessarily shut down the serial port. The serial port will be kept open until all open handles (file descriptors) to the serial port are closed. You can use the release() method to forcibly delete a serial port.

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.


Member Function Documentation

QBluetoothRfcommSerialPort::QBluetoothRfcommSerialPort ( QObject * parent = 0 )

Constructs a new RFCOMM serial port object. The parent is passed to the QObject constructor.

QBluetoothRfcommSerialPort::QBluetoothRfcommSerialPort ( QBluetoothRfcommSocket * socket, QBluetoothRfcommSerialPort::Flags deviceFlags = 0, QObject * parent = 0 )

Converts a connected RFCOMM socket to an RFCOMM serial port.

This constructor is useful in situations where you already have a connected RFCOMM socket and wish to convert it to a serial port. This is true of connections returned by QBluetoothRfcommServer::nextPendingConnection() or RFCOMM socket connections which require non-blocking connections.

Note: The caller should call QBluetoothRfcommSocket::close() on socket immediately after calling this constructor. Before the created QBluetoothRfcommSerialPort device can be used, the socket should be closed. The deviceFlags parameter holds the optional flags that modify the serial port behavior.

In case the device could not be created or an error occurred, the id() method will return -1. The caller should check the return value of id() before using the serial port device.

See also id().

QBluetoothRfcommSerialPort::~QBluetoothRfcommSerialPort ()

Destroys a Bluetooth serial port object. If the instance is managing a serial port, disconnect() will be called first.

bool QBluetoothRfcommSerialPort::connect ( const QBluetoothAddress & local, const QBluetoothAddress & remote, int channel )

This method tries to establish a connection to the remote device with address remote on channel. The local device is given by local. This method will return true if the request could be started, and false otherwise. The connected() signal will be sent once the operation completes.

You can cancel the connection process at any time by calling disconnect(). If the process is cancelled, the error() signal will be sent with the QBluetoothRfcommSerialPort::ConnectionCancelled error set.

See also error() and connected().

void QBluetoothRfcommSerialPort::connected ( const QString & device )   [signal]

This signal is emitted whenever the RFCOMM serial port is connected. The device parameter holds the device name of the created serial port.

See also connect().

QString QBluetoothRfcommSerialPort::device () const

Returns the RFCOMM tty device which is being managed by the current instance of this class. If the instance is not managing a device, an empty string is returned.

See also id().

bool QBluetoothRfcommSerialPort::disconnect ()

Returns true if able to disconnects the serial port; otherwise returns false. The underlying device will be removed unless the QBluetoothRfcommSerialPort::KeepAlive flag is set. The disconnected() signal will be sent once the disconnection is complete.

See also disconnected().

void QBluetoothRfcommSerialPort::disconnected ()   [signal]

This signal is emitted whenever the RFCOMM serial port is disconnected.

See also disconnect().

QBluetoothRfcommSerialPort::Error QBluetoothRfcommSerialPort::error () const

Returns the last error that has occurred.

See also errorString().

void QBluetoothRfcommSerialPort::error ( QBluetoothRfcommSerialPort::Error err )   [signal]

This is an overloaded member function, provided for convenience.

This signal is emitted whenever an error occurs. The err parameter holds the error that has occurred.

See also connect().

QString QBluetoothRfcommSerialPort::errorString () const

Returns the human readable form of the last error that has occurred.

See also error().

QBluetoothRfcommSerialPort::Flags QBluetoothRfcommSerialPort::flags () const

Returns the flags that the serial port has been opened with.

int QBluetoothRfcommSerialPort::id () const

Returns the device id of the associated RFCOMM device. If no device is found, returns -1. The device id is usually in the range of 0-31.

See also device().

QList<int> QBluetoothRfcommSerialPort::listDevices ()   [static]

Returns a list of all RFCOMM device bindings.

See also releaseDevice().

QList<int> QBluetoothRfcommSerialPort::listDevices ( const QBluetoothLocalDevice & local )   [static]

This is an overloaded member function, provided for convenience.

Returns a list of all RFCOMM devices for a particular Bluetooth adapter given by local.

See also releaseDevice().

QBluetoothAddress QBluetoothRfcommSerialPort::localAddress () const

Returns the address of the local device. If the socket is not currently connected, returns QBluetoothAddress::invalid.

See also remoteAddress().

bool QBluetoothRfcommSerialPort::releaseDevice ( int id )   [static]

Returns true if able to release the RFCOMM device with id; otherwise returns false.

See also listDevices().

QBluetoothAddress QBluetoothRfcommSerialPort::remoteAddress () const

Returns the address of the remote device. If the socket is not currently connected, returns QBluetoothAddress::invalid.

See also localAddress() and remoteChannel().

int QBluetoothRfcommSerialPort::remoteChannel () const

Returns the RFCOMM channel of the remote device. If the socket is not currently connected, returns -1.

See also remoteAddress().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 59
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Construire l'avenir : (ré-)introduction aux composants de Qt Quick

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 qtextended4.4
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 !
 
 
 
 
Partenaires

Hébergement Web