OpenZWave Library  1.6.770
HidController.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // HidController.h
4 //
5 // Cross-platform HID port handler
6 //
7 // Copyright (c) 2010 Jason Frazier <frazierjason@gmail.com>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27 
28 #ifndef _HidController_H
29 #define _HidController_H
30 
31 #include <string>
32 #include "Defs.h"
33 #include "platform/Controller.h"
34 
35 #ifdef USE_HID
36 
37 struct hid_device_;
38 
39 typedef struct hid_device_ hid_device;
40 
41 namespace OpenZWave
42 {
43  namespace Internal
44  {
45  namespace Platform
46  {
47 
48  class Driver;
49  class Msg;
50  class Thread;
51  class Event;
52 
56  class HidController: public Controller
57  {
58  public:
63  HidController();
64 
69  virtual ~HidController();
70 
77  bool SetVendorId( uint32 const _vendorId );
78 
85  bool SetProductId( uint32 const _productId );
86 
93  bool SetSerialNumber( string const& _serialNumber );
94 
102  bool Open( string const& _hidControllerName );
103 
110  bool Close();
111 
120  uint32 Write( uint8* _buffer, uint32 _length );
121 
122  private:
123  bool Init( uint32 const _attempts );
124  void Read();
125 
126  // helpers for internal use only
127 
135  int GetFeatureReport( uint32 _length, uint8 _reportId, uint8* _buffer );
136 
143  int SendFeatureReport( uint32 _length, const uint8* _data );
144 
145  static void ThreadEntryPoint( Event* _exitEvent, void* _context );
146  void ThreadProc( Event* _exitEvent );
147 
148  hid_device* m_hHidController;
149  Thread* m_thread;
150  uint32 m_vendorId;
151  uint32 m_productId;
152  string m_serialNumber;
153  string m_hidControllerName;
154  bool m_bOpen;
155  };
156  } // namespace Platform
157  } // namespace Internal
158 } // namespace OpenZWave
159 
160 #endif
161 
162 #endif //_HidController_H
163 
Definition: Bitfield.cpp:30
unsigned int uint32
Definition: Defs.h:91
unsigned char uint8
Definition: Defs.h:85