|
MoSync 3.0.1
|
Can connect to a Bluetooth service by UUID. Works mostly like a Connection, except the connect() method is different. More...
#include <MAUtil/BluetoothConnection.h>
Public Member Functions | |
| BluetoothConnection (ConnectionListener *listener) | |
| virtual | ~BluetoothConnection () |
| int | connect (const MABtAddr &address, const MAUUID &uuid) |
| int | connect (const char *url) |
| void | close () |
| void | write (const void *src, int len) |
| void | writeFromData (MAHandle data, int offset, int len) |
| void | recv (void *dst, int maxlen) |
| void | recvToData (MAHandle data, int offset, int maxlen) |
| void | read (void *dst, int len) |
| void | readToData (MAHandle data, int offset, int len) |
| void | setListener (ConnectionListener *listener) |
| bool | isOpen () const |
| int | getAddr (MAConnAddr *dst) |
Protected Member Functions | |
| void | recvMem (int prevRes) |
| void | recvData (int prevRes) |
| virtual void | connEvent (const MAConnEventData &data) |
Protected Attributes | |
| MAHandle | mConn |
| ConnectionListener * | mListener |
| int | mRemain |
| byte * | mDst |
| MAHandle | mData |
| int | mOffset |
| void(Connection::* | mRecv )(int prevRes) |
Can connect to a Bluetooth service by UUID. Works mostly like a Connection, except the connect() method is different.
This class wraps the special behaviour of the Android platform, which does not currently support Bluetooth service discovery.
| listener | Will receive events from this Connection. |
| virtual MAUtil::BluetoothConnection::~BluetoothConnection | ( | ) | [virtual] |
Closes the connection, if open.
| int MAUtil::BluetoothConnection::connect | ( | const MABtAddr & | address, |
| const MAUUID & | uuid | ||
| ) |
Asynchronously opens a connection using a Bluetooth address and UUID.
Service discovery is performed. If a service is found, a connection is opened.
This function returns immediately. If the connect operation could be started, the return value will be > 0, and connectFinished() of the ConnectionListener associated with this Connection will be called when the operation is finished.
If the connect operation could NOT be started, the return value will be a CONNERR code < 0, and connectFinished() will not be called.
connectFinished() may use CONNERR_NOTFOUND to indicate that the requested service could not be found.
| address | Address to the remote device. |
| uuid | The UUID of the service you wish to connect to. |
| int MAUtil::BluetoothConnection::connect | ( | const char * | url | ) |
Asynchronously opens a connection using a URL that specifies a Bluetooth address and a service UUID.
Service discovery is performed. If a service is found, a connection is opened.
This function returns immediately. If the connect operation could be started, the return value will be > 0, and connectFinished() of the ConnectionListener associated with this Connection will be called when the operation is finished.
If the connect operation could NOT be started, the return value will be a CONNERR code < 0, and connectFinished() will not be called.
connectFinished() may use CONNERR_NOTFOUND to indicate that the requested service could not be found.
| url | Has the format: "btspp://<6 byte hex Bluetooth address>:<16 byte hex UUID>" Example: "btspp://38E7D8C7605E:DCBDB690C17111DF851A0800200C9A66" |
Reimplemented from MAUtil::Connection.
| void MAUtil::BluetoothConnection::close | ( | ) |
Closes the connection, if open. Frees all resources allocated by this object. Allows this Connection object to be reused for further connections.
Reimplemented from MAUtil::Connection.
| void MAUtil::Connection::write | ( | const void * | src, |
| int | len | ||
| ) | [inherited] |
Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.
| void MAUtil::Connection::writeFromData | ( | MAHandle | data, |
| int | offset, | ||
| int | len | ||
| ) | [inherited] |
Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.
| void MAUtil::Connection::recv | ( | void * | dst, |
| int | maxlen | ||
| ) | [inherited] |
Reads between 1 and maxlen bytes to dst. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete. Use this function when you don't care how much data you get, as long as you get something.
| void MAUtil::Connection::recvToData | ( | MAHandle | data, |
| int | offset, | ||
| int | maxlen | ||
| ) | [inherited] |
Reads between 1 and maxlen bytes to data, starting at offset. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete.
| void MAUtil::Connection::read | ( | void * | dst, |
| int | len | ||
| ) | [inherited] |
Reads exactly len bytes to dst. Causes ConnectionListener::connReadFinished() to be called when the operation is complete. Use this function when you know exactly how much data you want, and are not interested in anything less.
| void MAUtil::Connection::readToData | ( | MAHandle | data, |
| int | offset, | ||
| int | len | ||
| ) | [inherited] |
Reads exactly len bytes to data, starting at offset. Causes ConnectionListener::connReadFinished() to be called when the operation is complete.
| void MAUtil::Connection::setListener | ( | ConnectionListener * | listener | ) | [inherited] |
Replaces the listener for this object.
| bool MAUtil::Connection::isOpen | ( | ) | const [inherited] |
Returns true if the connection is open, false otherwise. The connection is considered open even during the connect() operation.
| int MAUtil::Connection::getAddr | ( | MAConnAddr * | dst | ) | [inherited] |
Retrieves the remote address of this connection.
| void MAUtil::Connection::recvMem | ( | int | prevRes | ) | [protected, inherited] |
| void MAUtil::Connection::recvData | ( | int | prevRes | ) | [protected, inherited] |
| virtual void MAUtil::Connection::connEvent | ( | const MAConnEventData & | data | ) | [protected, virtual, inherited] |
Implements MAUtil::ConnListener.
Reimplemented in MAUtil::HttpConnection.
MAHandle MAUtil::Connection::mConn [protected, inherited] |
ConnectionListener* MAUtil::Connection::mListener [protected, inherited] |
int MAUtil::Connection::mRemain [protected, inherited] |
byte* MAUtil::Connection::mDst [protected, inherited] |
MAHandle MAUtil::Connection::mData [protected, inherited] |
int MAUtil::Connection::mOffset [protected, inherited] |
void(Connection::* MAUtil::Connection::mRecv)(int prevRes) [protected, inherited] |