nidas  v1.2-1520
BluetoothRFCommSocketIODevice.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2010, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #include <nidas/Config.h>
28 
29 #ifdef HAVE_BLUETOOTH_RFCOMM_H
30 
31 #ifndef NIDAS_CORE_BLUETOOTHRFCOMMSOCKETIODEVICE_H
32 #define NIDAS_CORE_BLUETOOTHRFCOMMSOCKETIODEVICE_H
33 
35 #include "SocketIODevice.h"
36 
37 namespace nidas { namespace core {
38 
42 class BluetoothRFCommSocketIODevice : public SocketIODevice {
43 
44 public:
45 
50  BluetoothRFCommSocketIODevice();
51 
52  ~BluetoothRFCommSocketIODevice();
53 
57  void open(int flags)
59 
63  int getReadFd() const
64  {
65  if (_socket) return _socket->getFd();
66  return -1;
67  }
68 
72  int getWriteFd() const {
73  if (_socket) return _socket->getFd();
74  return -1;
75  }
76 
80  size_t read(void *buf, size_t len) throw(nidas::util::IOException)
81  {
82  return _socket->recv(buf,len);
83  }
84 
88  size_t read(void *buf, size_t len, int msecTimeout)
90 
94  size_t write(const void *buf, size_t len) throw(nidas::util::IOException)
95  {
96  return _socket->send(buf,len);
97  }
98 
102  void close() throw(nidas::util::IOException);
103 
104 
105 private:
106 
107  nidas::util::BluetoothRFCommSocket* _socket;
108 
110  BluetoothRFCommSocketIODevice(const BluetoothRFCommSocketIODevice &);
111 
113  BluetoothRFCommSocketIODevice& operator=(const BluetoothRFCommSocketIODevice &);
114 
115 };
116 
117 }} // namespace nidas namespace core
118 
119 #endif
120 #endif
int len
Definition: sing.cc:934
Definition: IOException.h:37
Definition: InvalidParameterException.h:35