OpenZWave Library  1.7.0
Supervision.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Supervision.h
4 //
5 // Implementation of the Z-Wave COMMAND_CLASS_SUPERVISION
6 //
7 // Copyright (c) 2020 Mark Ruys <mark@paracas.nl>
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 _Supervision_H
29 #define _Supervision_H
30 
31 #include <deque>
32 
34 
35 namespace OpenZWave
36 {
37  namespace Internal
38  {
39  namespace CC
40  {
44  class Supervision: public CommandClass
45  {
46  public:
48  {
51  };
53  {
56  };
58  {
63  };
64 
65  static CommandClass* Create(uint32 const _homeId, uint8 const _nodeId)
66  {
67  return new Supervision(_homeId, _nodeId);
68  }
69  virtual ~Supervision()
70  {
71  }
72 
74  {
75  return 0x6c;
76  }
77  static string const StaticGetCommandClassName()
78  {
79  return "COMMAND_CLASS_SUPERVISION";
80  }
81 
82  uint8 CreateSupervisionSession(uint8 _command_class_id, uint8 _index);
83  static uint8 const StaticNoSessionId()
84  {
85  return 0xff; // As sessions are only 5 bits, this value will never match
86  }
87  uint32 GetSupervisionIndex(uint8 _session_id);
88  static uint32 const StaticNoIndex()
89  {
90  return 0xffff; // As indices are max 16 bits, this value will never match
91  }
92 
93  // From CommandClass
94  virtual uint8 const GetCommandClassId() const override
95  {
96  return StaticGetCommandClassId();
97  }
98  virtual string const GetCommandClassName() const override
99  {
100  return StaticGetCommandClassName();
101  }
102  virtual bool HandleIncomingMsg(uint8 const* _data, uint32 const _length, uint32 const _instance = 1) override;
103  virtual bool HandleMsg(uint8 const* _data, uint32 const _length, uint32 const _instance = 1) override;
104 
105  private:
106  Supervision(uint32 const _homeId, uint8 const _nodeId) :
107  CommandClass(_homeId, _nodeId),
108  m_last_session_id{StaticNoSessionId()}
109  {
110  }
111 
112  struct s_Session {
113  uint8 session_id;
114  uint8 command_class_id;
115  uint8 index;
116  };
117  std::deque<s_Session> m_sessions;
118  uint8 m_last_session_id;
119 
120  void HandleSupervisionReport(uint8 const* _data, uint32 const _length, uint32 const _instance);
121  };
122  } // namespace CC
123  } // namespace Internal
124 } // namespace OpenZWave
125 
126 #endif
127 
Definition: Bitfield.cpp:30
Base class for all Z-Wave command classes.
Definition: CommandClass.h:60
virtual string const GetCommandClassName() const override
Definition: Supervision.h:98
virtual bool HandleIncomingMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1) override
Definition: Supervision.cpp:138
uint8 CreateSupervisionSession(uint8 _command_class_id, uint8 _index)
Definition: Supervision.cpp:44
static uint32 const StaticNoIndex()
Definition: Supervision.h:88
unsigned int uint32
Definition: Defs.h:91
uint32 GetSupervisionIndex(uint8 _session_id)
Definition: Supervision.cpp:64
Implements COMMAND_CLASS_SUPERVISION (0x6c), a Z-Wave device command class.
Definition: Supervision.h:44
virtual uint8 const GetCommandClassId() const override
Definition: Supervision.h:94
static CommandClass * Create(uint32 const _homeId, uint8 const _nodeId)
Definition: Supervision.h:65
virtual bool HandleMsg(uint8 const *_data, uint32 const _length, uint32 const _instance=1) override
Definition: Supervision.cpp:147
static uint8 const StaticGetCommandClassId()
Definition: Supervision.h:73
static uint8 const StaticNoSessionId()
Definition: Supervision.h:83
virtual ~Supervision()
Definition: Supervision.h:69
static string const StaticGetCommandClassName()
Definition: Supervision.h:77
SupervisionStatus
Definition: Supervision.h:57
SupervisionCmd
Definition: Supervision.h:47
SupervisionMoreStatusUpdates
Definition: Supervision.h:52
unsigned char uint8
Definition: Defs.h:85