QBluetoothZero  2.0
QBtSerialPortServer Class Reference

#include <QBtSerialPortServer.h>

List of all members.

Public Types

enum  ErrorCode { ErrorAlreadyInUse, ErrorNotSupported, ErrorUnavailable, ErrorUndefinedError }

Public Slots

void startServer (const QBtUuid &serviceId, const QString &serviceName="My RFCOMM service")
void stopServer ()
void sendData (const QString &data)

Signals

void serverStarted ()
void serverStopped ()
void clientConnected (const QBtAddress &clientAddress)
void clientDisconnected ()
void dataSent ()
void dataReceived (const QString &data)
void error (QBtSerialPortServer::ErrorCode code)

Public Member Functions

 QBtSerialPortServer (QObject *parent)
 ~QBtSerialPortServer ()
bool isConnected ()
const QBtServicegetTransmittingServiceInfo () const

Protected Member Functions

void setTransmittingService (const QBtService &service)
void setConnectionStatus (bool connected)
void startAdvertisingService (const QBtService &service)
void stopAdvertisingService ()

Friends

class QBtSerialPortServerPrivate

Detailed Description

This class creates a Serial Port Server.

After instantiation user can call startServer(const QString&) to start the server and wait for a client to connect. From the serviceName argument user can specify the name of the RFCOMM service which is how the service will be identified by other devices. By default the name is MyRFCOMM.

If server is started successfully then serverStarted() signal is emitted.

When a remote client is connected to the local running server clientConnected(const QBtAddress &) is emitted and from that point and on the data transmittion can start.

To send data to the client use sendData(const QString &). If successfull dataSent() signal is emitted.

When data are received successfully from the remote client dataReceived(const QString &) signal is emitted.

If client disconnects, clientDisconnected() will be emitted and user must call startServer(const QString &) to initialize server again to be ready to accept new connection.

The connection to a client (if any) is closed when stopServer() is called along with the termination of advertising of the SPP service.

In case of an error error(QBtSerialPortServer::ErrorCode) is called.


Member Enumeration Documentation

Enumerator:
ErrorAlreadyInUse 
ErrorNotSupported 
ErrorUnavailable 
ErrorUndefinedError 

Constructor & Destructor Documentation

QBtSerialPortServer::QBtSerialPortServer ( QObject *  parent)
QBtSerialPortServer::~QBtSerialPortServer ( )

Member Function Documentation

void QBtSerialPortServer::clientConnected ( const QBtAddress clientAddress) [signal]

Emitted when a remote client is connected to the local running server.

void QBtSerialPortServer::clientDisconnected ( ) [signal]

Emitted when a remote client is disconnected either by a normal disconnection or by a problem to the connection (ex. loss of signal, power off bluetooth hardware device)

void QBtSerialPortServer::dataReceived ( const QString &  data) [signal]

Emitted when data are received successfully from the remote client.

void QBtSerialPortServer::dataSent ( ) [signal]

Emitted after calling sendData() function if data are send successfully to the remote client.

void QBtSerialPortServer::error ( QBtSerialPortServer::ErrorCode  code) [signal]

Emitted in case of error.

const QBtService& QBtSerialPortServer::getTransmittingServiceInfo ( ) const

If startServer() function is already called then using this function the user can acquire the information of the transmitting service that represents this server to the outside world.

bool QBtSerialPortServer::isConnected ( )

Get the status of the connection.

Returns:
true if connected.
void QBtSerialPortServer::sendData ( const QString &  data) [slot]

sendData()

If connected to a remote client, sends the data passed as argument to the client. If successfull, dataSent() signal is emitted.

Parameters:
dataThe data to be send.
void QBtSerialPortServer::serverStarted ( ) [signal]

Emitted when server is successfully started and ready to use.

void QBtSerialPortServer::serverStopped ( ) [signal]

Emitted when service advertising is terminated. If any client is connected the a clientDisconnected() signal will be emitted as well.

void QBtSerialPortServer::setConnectionStatus ( bool  connected) [protected]

Set the flag inside this object which represents the connection status. NOTE: This flag is updated automatically whenever the connection status changes.

void QBtSerialPortServer::setTransmittingService ( const QBtService service) [protected]
void QBtSerialPortServer::startAdvertisingService ( const QBtService service) [protected]

startAdvertisingService()

Initializes a new advertiser and starts the transmitting of the service passed as argument.

void QBtSerialPortServer::startServer ( const QBtUuid serviceId,
const QString &  serviceName = "My RFCOMM service" 
) [slot]
void QBtSerialPortServer::stopAdvertisingService ( ) [protected]

stopAdvertisingService()

Stops the transmittion of the service (if any)

void QBtSerialPortServer::stopServer ( ) [slot]

stopServer()

Stops the server, terminates the service transmittion and disconnects from any device connected


Friends And Related Function Documentation

friend class QBtSerialPortServerPrivate [friend]

The documentation for this class was generated from the following file: