Bluetooth.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Baylor University
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 }; // struct Bluetooth
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 } // namespace oasys
00089 
00090 #endif /* OASYS_BLUETOOTH_ENABLED */
00091 #endif /* _OASYS_BT_H_ */

Generated on Sat Sep 8 08:36:15 2007 for DTN Reference Implementation by  doxygen 1.5.3