OpenZWave Library  1.6.943
WakeUp.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // WakeUp.h
4 //
5 // Implementation of the Z-Wave COMMAND_CLASS_WAKE_UP
6 //
7 // Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
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 _WakeUp_H
29 #define _WakeUp_H
30 
31 #include <list>
33 #include "Driver.h"
34 #include "TimerThread.h"
35 
36 namespace OpenZWave
37 {
38 
39  namespace Internal
40  {
41  namespace Platform
42  {
43  class Mutex;
44  }
45  namespace CC
46  {
47 
51  class WakeUp: public CommandClass, private Timer
52  {
53  public:
54  static CommandClass* Create(uint32 const _homeId, uint8 const _nodeId)
55  {
56  return new WakeUp(_homeId, _nodeId);
57  }
58  virtual ~WakeUp();
59 
61  {
62  return 0x84;
63  }
64  static string const StaticGetCommandClassName()
65  {
66  return "COMMAND_CLASS_WAKE_UP";
67  }
68 
69  void Init(); // Starts the process of requesting node state from a sleeping device.
70  void QueueMsg(Driver::MsgQueueItem const& _item);
71 
73  void SendPending();
74 
76  void SendNoMoreInfo(uint32 id);
77 
78  bool IsAwake() const
79  {
80  return m_awake;
81  }
82  void SetAwake(bool _state);
84  {
85  m_pollRequired = true;
86  }
87 
88  // From CommandClass
89  virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue) override;
90  virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue) override;
91  virtual uint8 const GetCommandClassId() const override
92  {
93  return StaticGetCommandClassId();
94  }
95  virtual string const GetCommandClassName() const override
96  {
98  }
99  virtual bool HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _instance = 1) override;
100  virtual bool SetValue(Internal::VC::Value const& _value) override;
101  virtual void SetVersion(uint8 const _version) override;
102 
103  virtual uint8 GetMaxVersion() override
104  {
105  return 2;
106  }
107 
108  protected:
109  virtual void CreateVars(uint8 const _instance) override;
110 
111  private:
112  WakeUp(uint32 const _homeId, uint8 const _nodeId);
113 
114  Internal::Platform::Mutex* m_mutex; // Serialize access to the pending queue
115  list<Driver::MsgQueueItem> m_pendingQueue; // Messages waiting to be sent when the device wakes up
116  bool m_awake;
117  bool m_pollRequired;
118  };
119  } // namespace CC
120  } // namespace Internal
121 } // namespace OpenZWave
122 
123 #endif
124 
void SendNoMoreInfo(uint32 id)
Send a no more information message.
Definition: WakeUp.cpp:464
static uint8 const StaticGetCommandClassId()
Definition: WakeUp.h:60
Definition: Bitfield.cpp:30
MsgQueue
Definition: Driver.h:656
unsigned short uint16
Definition: Defs.h:88
bool IsAwake() const
Definition: WakeUp.h:78
virtual bool RequestValue(uint32 const _requestFlags, uint16 const _index, uint8 const _instance, Driver::MsgQueue const _queue) override
Definition: WakeUp.cpp:142
virtual string const GetCommandClassName() const override
Definition: WakeUp.h:95
virtual void SetVersion(uint8 const _version) override
Definition: WakeUp.cpp:303
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1) override
Definition: WakeUp.cpp:181
virtual bool SetValue(Internal::VC::Value const &_value) override
Definition: WakeUp.cpp:265
void QueueMsg(Driver::MsgQueueItem const &_item)
Definition: WakeUp.cpp:358
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: WakeUp.h:54
Base class for all Z-Wave command classes.
Definition: CommandClass.h:60
virtual uint8 const GetCommandClassId() const override
Definition: WakeUp.h:91
static string const StaticGetCommandClassName()
Definition: WakeUp.h:64
Implements COMMAND_CLASS_WAKE_UP (0x84), a Z-Wave device command class.
Definition: WakeUp.h:51
void Init()
Definition: WakeUp.cpp:101
virtual uint8 GetMaxVersion() override
Definition: WakeUp.h:103
void SendPending()
Send all pending messages followed by a no more information message.
Definition: WakeUp.cpp:401
unsigned int uint32
Definition: Defs.h:91
Timer SubClass for automatically registering/unregistering Timer Callbacks if the instance goes out o...
Definition: TimerThread.h:127
void SetAwake(bool _state)
Definition: WakeUp.cpp:313
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:44
virtual void CreateVars(uint8 const _instance) override
Definition: WakeUp.cpp:479
void SetPollRequired()
Definition: WakeUp.h:83
virtual ~WakeUp()
Definition: WakeUp.cpp:79
Base class for values associated with a node.
Definition: Value.h:53
virtual bool RequestState(uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue) override
Definition: WakeUp.cpp:116
unsigned char uint8
Definition: Defs.h:85