00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
00109
00110 #endif
00111 #endif