ecrobot::Bluetooth Class Reference
Bluetooth communication class.
More...
#include <Bluetooth.h>
List of all members.
Public Member Functions |
| Bluetooth (void) |
| Constructor.
|
| ~Bluetooth (void) |
| Destructor.
|
bool | waitForConnection (const CHAR *passkey, U32 duration) |
| Wait for a connection as a slave device.
|
bool | waitForConnection (const CHAR *passkey, const U8 address[7], U32 duration) |
| Wait for a connection as a master device.
|
void | cancelWaitForConnection (void) |
| Cancel of waiting for a connection.
|
bool | getDeviceAddress (U8 address[7]) const |
| Get the Bluetooth Device Address of the device.
|
bool | getFriendlyName (CHAR *name) const |
| Get the friendly name of the device.
|
bool | setFriendlyName (const CHAR *name) |
| Set the friendly name of the device.
|
bool | isConnected (void) const |
| Get connection status.
|
U32 | send (U8 *data, U32 length) |
| Send data to the connected device.
|
U32 | receive (U8 *data, U32 length) const |
| Receive data from the connected device.
|
void | setFactorySettings (void) |
| Reset all settings in the persistent settings in the BlueCore chip.
|
Static Public Attributes |
static const U32 | MAX_BT_DATA_LENGTH = 254 |
| Maximum length of data in byte for send/receive.
|
Detailed Description
Bluetooth communication class.
Note:
User specified friendly device name using setFriendlyName seems to be appeared in the Windows
Bluetooth device dialog only when NXT BIOS is used as the firmware (why?).
Constructor & Destructor Documentation
ecrobot::Bluetooth::Bluetooth |
( |
void |
|
) |
|
Constructor.
Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object. When the object is destructed while the system is shut down, Bluetooth is closed automatically.
- Parameters:
-
- Returns:
- -
ecrobot::Bluetooth::~Bluetooth |
( |
void |
|
) |
|
Destructor.
Close the existing connection.
- Parameters:
-
- Returns:
- -
Member Function Documentation
void ecrobot::Bluetooth::cancelWaitForConnection |
( |
void |
|
) |
|
Cancel of waiting for a connection.
This member function must be invoked from the 1msec interrupt hook function (i.e. user_1ms_isr_type2 for nxtOSEK)
to cancel of waiting for a connection. Otherwise, it does not work.
- Parameters:
-
- Returns:
- -
bool ecrobot::Bluetooth::getDeviceAddress |
( |
U8 |
address[7] |
) |
const |
Get the Bluetooth Device Address of the device.
- Parameters:
-
| address | Bluetooth Device Address (7bytes hex array data) |
- Returns:
- true:succeeded/false:failed
bool ecrobot::Bluetooth::getFriendlyName |
( |
CHAR * |
name |
) |
const |
Get the friendly name of the device.
- Parameters:
-
| name | Friendly name (max. 16 characters) |
- Returns:
- true:succeeded/false:failed
bool ecrobot::Bluetooth::isConnected |
( |
void |
|
) |
const |
Get connection status.
- Parameters:
-
- Returns:
- true:connected/false:not connected
U32 ecrobot::Bluetooth::receive |
( |
U8 * |
data, |
|
|
U32 |
length | |
|
) |
| | const |
Receive data from the connected device.
- Parameters:
-
| data | Data to be received |
| length | Length of data to be received (up to 254) |
- Returns:
- Length of received data.
U32 ecrobot::Bluetooth::send |
( |
U8 * |
data, |
|
|
U32 |
length | |
|
) |
| | |
Send data to the connected device.
- Parameters:
-
| data | Data to be sent |
| length | Length of data to be sent (up to 254) |
- Returns:
- Length of sent data.
void ecrobot::Bluetooth::setFactorySettings |
( |
void |
|
) |
|
Reset all settings in the persistent settings in the BlueCore chip.
The BlueCore chip should be restarted (remove the battery) after calling this function.
Otherwise old values can be floating around the BlueCore chip causing
unexpected behavior.
- Parameters:
-
- Returns:
- -
bool ecrobot::Bluetooth::setFriendlyName |
( |
const CHAR * |
name |
) |
|
Set the friendly name of the device.
While a connection is established, device name can't be changed.
- Parameters:
-
| name | Friendly name (max. 16 characters) |
- Returns:
- true:succeeded/false:failed
bool ecrobot::Bluetooth::waitForConnection |
( |
const CHAR * |
passkey, |
|
|
const U8 |
address[7], |
|
|
U32 |
duration | |
|
) |
| | |
Wait for a connection as a master device.
- Parameters:
-
| passkey | Bluetooth passkey (up to 16 characters. I.e. "1234") |
| address | Bluetooth Device Address to be connected (7bytes hex array data) |
| duration | Wait duration in msec (duration = 0 means wait forever) |
- Returns:
- true:connected/false:not connected
bool ecrobot::Bluetooth::waitForConnection |
( |
const CHAR * |
passkey, |
|
|
U32 |
duration | |
|
) |
| | |
Wait for a connection as a slave device.
- Parameters:
-
| passkey | Bluetooth passkey (up to 16 characters. I.e. "1234") |
| duration | Wait duration in msec (duration = 0 means wait forever) |
- Returns:
- true:connected/false:not connected
The documentation for this class was generated from the following file: