BluetoothSDP.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 #ifndef _OASYS_BTSDP_H_
00018 #define _OASYS_BTSDP_H_
00019 
00020 #include <config.h> 
00021 #ifdef OASYS_BLUETOOTH_ENABLED
00022 
00023 #include "../debug/Log.h"
00024 
00025 #include <stdio.h>
00026 #include <errno.h>
00027 #include <stdlib.h>
00028 
00029 #include <bluetooth/bluetooth.h>
00030 #include <bluetooth/sdp.h>
00031 #include <bluetooth/sdp_lib.h>
00032 
00033 // generated using uuidgen on Mac OS X ... a completely arbitrary number :)
00034 // maybe eventually register something with Bluetooth SIG?
00035 #define OASYS_BLUETOOTH_SDP_UUID { 0xDCA38352, 0xBF6011DA, \
00036                                    0xA23B0003, 0x931B7960 }
00037 
00038 namespace oasys {
00039 
00040 // for reference, from <bluetooth/sdp.h>
00041 #if 0
00042 
00043 typedef struct _sdp_list sdp_list_t;
00044 struct _sdp_list {
00045     sdp_list_t *next;
00046     void *data;
00047 };
00048 
00049 #endif
00050 
00055 class BluetoothServiceDiscoveryClient : public Logger
00056 {
00057 public:
00058     BluetoothServiceDiscoveryClient(const char*
00059                                     logpath="/dtn/cl/bt/sdp/client");
00060     virtual ~BluetoothServiceDiscoveryClient();
00061 
00062     bool is_dtn_router(bdaddr_t remote);
00063     void get_local_addr(bdaddr_t& addr) {
00064         bacpy(&addr,&local_addr_);
00065     }
00066 
00067     u_int8_t channel() { return channel_; }
00068     const std::string& remote_eid() { return remote_eid_; }
00069 
00070 protected:
00071     /* member data */
00072     bdaddr_t      remote_addr_;     /* physical address of device to query */
00073     bdaddr_t      local_addr_;      /* physical address of local adapter */
00074     std::string   remote_eid_;      /* EID of remote router */
00075     u_int8_t      channel_;         /* RFCOMM channel */
00076 };
00077 
00078 class BluetoothServiceRegistration : public Logger 
00079 {
00080 public:
00081 
00082 #define OASYS_BLUETOOTH_SDP_NAME "dtnd"
00083 
00084     BluetoothServiceRegistration(const char* name = OASYS_BLUETOOTH_SDP_NAME,
00085                                  const char* logpath = "/dtn/cl/bt/sdp/reg");
00086     virtual ~BluetoothServiceRegistration();
00087 
00088     bool success() {return status_;};
00089     void get_local_addr(bdaddr_t& addr) {
00090         bacpy(&addr,&local_addr_);
00091     }
00092 
00093 protected:
00094     bool register_service(const char *name);
00095 
00096     sdp_session_t* sess_;
00097     bool status_;
00098     bdaddr_t local_addr_;
00099 };
00100 
00101 } // namespace oasys
00102 
00103 #endif /* OASYS_BLUETOOTH_ENABLED */
00104 #endif /* _OASYS_BTSDP_H_ */

Generated on Thu Jun 7 12:54:25 2007 for DTN Reference Implementation by  doxygen 1.5.1