ECRobot C++ API for LEGO MINDSTORMS NXT
1.0.10
|
00001 // 00002 // Bluetooth.h 00003 // 00004 // Copyright 2009 by Takashi Chikamasa, Jon C. Martin and Robert W. Kramer 00005 // 00006 00007 #ifndef BLUETOOTH_H_ 00008 #define BLUETOOTH_H_ 00009 00010 00011 extern "C" 00012 { 00013 #include "ecrobot_interface.h" 00014 #include "rtoscalls.h" 00015 }; 00016 00017 namespace ecrobot 00018 { 00026 class Bluetooth 00027 { 00028 public: 00032 static const U32 MAX_BT_TX_DATA_LENGTH = BT_MAX_TX_BUF_SIZE; // defined in ecrobot_bluetooth.h 00033 00037 static const U32 MAX_BT_RX_DATA_LENGTH = BT_MAX_RX_BUF_SIZE; // defined in ecrobot_bluetooth.h 00038 00048 Bluetooth(void); 00049 00056 ~Bluetooth(void); 00057 00064 bool waitForConnection(const CHAR* passkey, U32 duration); 00065 00073 bool waitForConnection(const CHAR* passkey, const U8 address[7], U32 duration); 00074 00082 void cancelWaitForConnection(void); 00083 00089 bool getDeviceAddress(U8 address[7]) const; 00090 00096 bool getFriendlyName(CHAR* name) const; 00097 00104 bool setFriendlyName(const CHAR* name); 00105 00111 bool isConnected(void) const; 00112 00118 S16 getRSSI(void); 00119 00127 U32 send(U8* data, U32 length); 00128 00138 U32 send(const void* data, U32 offset, U32 length); 00139 00147 U32 receive(U8* data, U32 length) const; 00148 00158 U32 receive(void* data, U32 offset, U32 length) const; 00159 00168 void setFactorySettings(void); 00169 00170 private: 00171 bool mIsConnected; 00172 bool mCancelConnection; 00173 void close(void); 00174 }; 00175 } 00176 00177 #endif