00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _OASYS_BT_H_
00019 #define _OASYS_BT_H_
00020
00021 #include <config.h>
00022 #ifdef OASYS_BLUETOOTH_ENABLED
00023
00024 #include <fcntl.h>
00025 #include <stdlib.h>
00026 #include <sys/uio.h>
00027 #include <sys/socket.h>
00028
00029 #include <bluetooth/bluetooth.h>
00030 #include <bluetooth/hci.h>
00031 #include <bluetooth/hci_lib.h>
00032
00033 namespace oasys {
00034
00035 struct Bluetooth {
00036
00037 #ifndef HCIDEVNAMSIZ
00038 #define HCIDEVNAMSIZ 32
00039 #endif
00040
00042
00043 static int hci_devid(const char* hcidev,
00044 const char* log = NULL );
00045
00046 static int hci_inquiry(int dev_id, int len, int nrsp,
00047 const uint8_t *lap, inquiry_info **ii,
00048 long flags, const char* log = NULL );
00049
00050 static int hci_open_dev(int dev_id,
00051 const char* log = NULL );
00052
00053 static int hci_close_dev(int dd,
00054 const char* log = NULL );
00055
00056 static int hci_read_remote_name(int dd, const bdaddr_t *bdaddr,
00057 int len, char *name, int to,
00058 const char* log = NULL );
00059
00060 static void hci_get_bdaddr(bdaddr_t *bdaddr,
00061 const char *log = NULL);
00062
00063 static int hci_dev_up(int dd, const char *hcidev,
00064 const char *log = NULL);
00066
00067 static char * _batostr(const bdaddr_t *ba, char * str, size_t strsize = 18);
00068
00069 static bdaddr_t * strtoba(const char *str, bdaddr_t *addr);
00070
00071 static void baswap(bdaddr_t *dst, const bdaddr_t *src);
00072
00073 };
00074
00075 class Batostr {
00076 public:
00077 Batostr(bdaddr_t addr) { str_ = Bluetooth::_batostr(&addr,buf_,bufsize_); }
00078 ~Batostr() { buf_[0] = '\0'; }
00079 const char * buf() { return str_; }
00080 static const int bufsize_ = sizeof(":00:00:00:00:00:00");
00081 protected:
00082 char buf_[bufsize_];
00083 const char* str_;
00084 };
00085
00086 #define bd2str(addr) oasys::Batostr(addr).buf()
00087
00088 }
00089
00090 #endif
00091 #endif