BluetoothInquiry.h

Go to the documentation of this file.
00001 #ifndef _OASYS_BT_INQUIRY_H_
00002 #define _OASYS_BT_INQUIRY_H_
00003 
00004 #include <config.h> 
00005 #ifdef OASYS_BLUETOOTH_ENABLED
00006 
00007 #include <bluetooth/bluetooth.h>
00008 #include <bluetooth/rfcomm.h>
00009 #include <bluetooth/hci.h> 
00010 
00011 #include "../debug/Log.h"
00012 
00013 namespace oasys {
00014 
00015 class BluetoothInquiryInfo {
00016 public:
00017     BluetoothInquiryInfo(char* name="", int name_len=248) 
00018         : name_(name),
00019           name_len_(name_len)
00020     {
00021         memset(&addr_,0,sizeof(addr_));
00022         name_ = new char[name_len_];
00023         memset(name_,0,name_len_);
00024     }
00025 
00026     BluetoothInquiryInfo(const BluetoothInquiryInfo& btc)
00027     { 
00028         memset(&addr_,0,sizeof(addr_));
00029         bacpy(&this->addr_,&btc.addr_);
00030 
00031         name_len_ = btc.name_len_;
00032         name_ = new char[name_len_];
00033         memset(name_,0,name_len_);
00034         strncpy(name_,btc.name_,name_len_);
00035     }
00036 
00037     ~BluetoothInquiryInfo()
00038     {
00039         delete [] name_;
00040     }
00041 
00042     char *name_;
00043     int name_len_;
00044     bdaddr_t addr_;
00045 };
00046 
00047 class BluetoothInquiry : public Logger {
00048 
00049 public:
00050     BluetoothInquiry(const char * logbase = "/btinquiry");
00051     ~BluetoothInquiry();
00052 
00053     /*
00054      * Set/get inquiry parameters
00055      */
00056     char * hci_device_name();
00057     void set_hci_device_name(char*);
00058 
00060     int num_responses();
00061     void set_numresponses(int);
00062 
00064     int length();
00065     void set_length(int);
00066 
00068     uint8_t* lap();
00069     void set_lap(uint8_t*);
00070 
00071     inquiry_info* info();
00072     void set_info(inquiry_info*);
00073     
00074     long flags();
00075     void set_flags(long);
00076     
00077     /*
00078      * Perform inquiry action
00079      */
00080     int inquire();
00081 
00082     /*
00083      * Set/get read_remote_name parameters
00084      */
00085     int timeout();
00086     void set_timeout(int);
00087 
00088     /*
00089      * Perform read_remote_name action
00090      */
00091     int first(BluetoothInquiryInfo& bti);
00092     int next(BluetoothInquiryInfo& bti);
00093 
00094 protected:
00095     void reset();  // performed internally between inquiries
00096 
00097     char *hci_device_name_;
00098     int hci_dev_;
00099     int num_responses_,num_responses_i_;
00100     int length_;
00101     uint8_t *lap_;
00102     inquiry_info *info_;
00103     long flags_;
00104     int timeout_;
00105 
00106     int fd_;
00107     int pos_;
00108 };
00109 
00110 }
00111 #endif // OASYS_BLUETOOTH_ENABLED
00112 #endif // _OASYS_BT_INQUIRY_H_

Generated on Fri Dec 22 14:47:57 2006 for DTN Reference Implementation by  doxygen 1.5.1