OpenZWave Library  1.2
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 
36 struct hid_device_;
37 
38 typedef struct hid_device_ hid_device;
39 
40 namespace OpenZWave
41 {
42  class Driver;
43  class Msg;
44  class Thread;
45  class Event;
46 
47  class HidController: public Controller
48  {
49  public:
54  HidController();
55 
60  virtual ~HidController();
61 
68  bool SetVendorId( uint32 const _vendorId );
69 
76  bool SetProductId( uint32 const _productId );
77 
84  bool SetSerialNumber( string const& _serialNumber );
85 
93  bool Open( string const& _hidControllerName );
94 
101  bool Close();
102 
111  uint32 Write( uint8* _buffer, uint32 _length );
112 
113  private:
114  bool Init( uint32 const _attempts );
115  void Read();
116 
117  // helpers for internal use only
118 
126  int GetFeatureReport( uint32 _length, uint8 _reportId, uint8* _buffer );
127 
134  int SendFeatureReport( uint32 _length, const uint8* _data );
135 
136  static void ThreadEntryPoint( Event* _exitEvent, void* _context );
137  void ThreadProc( Event* _exitEvent );
138 
139  hid_device* m_hHidController;
140  Thread* m_thread;
141  uint32 m_vendorId;
142  uint32 m_productId;
143  string m_serialNumber;
144  string m_hidControllerName;
145  bool m_bOpen;
146  };
147 
148 } // namespace OpenZWave
149 
150 #endif //_HidController_H
151 
uint32
unsigned int uint32
Definition: Defs.h:69
OpenZWave::HidController::Close
bool Close()
Definition: HidController.cpp:164
hid_device
struct hid_device_ hid_device
Definition: HidController.h:38
uint8
unsigned char uint8
Definition: Defs.h:63
OpenZWave::HidController::SetProductId
bool SetProductId(uint32 const _productId)
Definition: HidController.cpp:97
OpenZWave::HidController::SetVendorId
bool SetVendorId(uint32 const _vendorId)
Definition: HidController.cpp:79
OpenZWave::HidController::SetSerialNumber
bool SetSerialNumber(string const &_serialNumber)
Definition: HidController.cpp:115
Controller.h
OpenZWave::HidController::Write
uint32 Write(uint8 *_buffer, uint32 _length)
Definition: HidController.cpp:457
OpenZWave::HidController
Definition: HidController.h:47
OpenZWave::HidController::~HidController
virtual ~HidController()
Definition: HidController.cpp:69
OpenZWave::HidController::HidController
HidController()
Definition: HidController.cpp:52
OpenZWave::HidController::Open
bool Open(string const &_hidControllerName)
Definition: HidController.cpp:133
OpenZWave::Event
Platform-independent definition of event objects.
Definition: Event.h:39
OpenZWave::Controller
Definition: Controller.h:41
Defs.h
OpenZWave::Thread
Implements a platform-independent thread management class.
Definition: Thread.h:42
OpenZWave
Definition: Bitfield.h:34