BluetoothServer.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_BT_SERVER_H_
00018 #define _OASYS_BT_SERVER_H_
00019 
00020 #include <config.h> 
00021 #ifdef OASYS_BLUETOOTH_ENABLED
00022 
00023 #include "BluetoothSocket.h"
00024 #include "../thread/Thread.h"
00025 
00026 namespace oasys {
00027 
00033 class BluetoothServer : public BluetoothSocket {
00034 public:
00035     BluetoothServer(int socktype, BluetoothSocket::proto_t proto,
00036              char* logbase = "/btserver");
00037 
00039 
00040     int listen();
00041     int accept(int *fd, bdaddr_t *addr, u_int8_t *channel);
00043 
00050     int timeout_accept(int *fd, bdaddr_t *addr, u_int8_t *channel,
00051                        int timeout_ms);
00052 };
00053 
00061 class BluetoothServerThread : public BluetoothServer, public Thread {
00062 public:
00063     BluetoothServerThread(int socktype, BluetoothSocket::proto_t proto,
00064                           const char* name,
00065                           char* logbase = "/btserver", int flags = 0,
00066                           int accept_timeout = -1)
00067         : BluetoothServer(socktype,proto,logbase), Thread(name,flags),
00068           accept_timeout_(accept_timeout)
00069     {
00070     }
00071     
00076     virtual void accepted(int fd, bdaddr_t addr, u_int8_t channel) = 0;
00077 
00087     void run();
00088 
00099     int bind_listen_start(bdaddr_t local_addr, u_int8_t local_channel);
00100 protected:
00105     int accept_timeout_;
00106 };
00107 
00108 } // namespace oasys
00109                         
00110 #endif /* OASYS_BLUETOOTH_ENABLED */
00111 #endif /* _OASYS_BT_SERVER_H_ */

Generated on Thu Jun 7 16:56:48 2007 for DTN Reference Implementation by  doxygen 1.5.1