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.
|
S16 | getRSSI (void) |
| Get RSSI (Received Signal Strength Indicator).
|
U32 | send (U8 *data, U32 length) |
| Send data to the connected device.
|
U32 | send (const void *data, U32 offset, U32 length) |
| (RECOMMENDED TO USE) Send data to the connected device.
|
U32 | receive (U8 *data, U32 length) const |
| Receive data from the connected device.
|
U32 | receive (void *data, U32 offset, U32 length) const |
| (RECOMMENDED TO USE) 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_TX_DATA_LENGTH = BT_MAX_TX_BUF_SIZE |
| Maximum length of data in byte to send (= 256 bytes).
|
static const U32 | MAX_BT_RX_DATA_LENGTH = BT_MAX_RX_BUF_SIZE |
| Maximum length of data in byte to receive (= 128 bytes).
|
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
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:
- -
Destructor.
Close the existing connection.
- Parameters:
-
- Returns:
- -
Member Function Documentation
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:
- -
Get the Bluetooth Device Address of the device.
- Parameters:
-
address | Bluetooth Device Address (7bytes hex array data) |
- Returns:
- true:succeeded/false:failed
Get the friendly name of the device.
- Parameters:
-
name | Friendly name (max. 16 characters) |
- Returns:
- true:succeeded/false:failed
Get RSSI (Received Signal Strength Indicator).
- Parameters:
-
- Returns:
- RSSI -1 to 255. Higher value means the link quality is better. -1 means Bluetooth is not connected.
Get connection status.
- Parameters:
-
- Returns:
- true:connected/false:not connected
Receive data from the connected device.
- Parameters:
-
data | Data to be received |
length | Length of data in bytes to be received Note that maximum length of data in bytes is MAX_BT_RX_DATA_LENGTH - 2 bytes |
- Returns:
- Length of received data in bytes.
(RECOMMENDED TO USE) Receive data from the connected device.
Note that this API receives data as it is. It means that no addtional data (number of data) is added, so it is good to be used for user designed protocol.
- Parameters:
-
data | Data buffer to receive |
offset | Data buffer offset in bytes |
length | Length of data in bytes to be received. Note that maximum length of data in bytes is MAX_BT_RX_DATA_LENGTH |
- Returns:
- Length of received data in bytes
Send data to the connected device.
- Parameters:
-
data | Data buffer to send |
length | Length of data in bytes to be sent. Note that maximum length of data in bytes is MAX_BT_TX_DATA_LENGTH - 2 bytes |
- Returns:
- Length of sent data in bytes.
(RECOMMENDED TO USE) Send data to the connected device.
Note that this API sends data as it is. It means that no addtional data (number of data) is added, so it is good to be used for user designed protocol.
- Parameters:
-
data | Data buffer to send |
offset | Data buffer offset in bytes |
length | Length of data in bytes to be sent. Note that maximum length of data in bytes is MAX_BT_TX_DATA_LENGTH |
- Returns:
- Length of sent data in bytes
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:
- -
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
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
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
The documentation for this class was generated from the following file: