ansible4ozw 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ansible.rb +12 -9
- data/lib/ansible/ansible_device.rb +1 -1
- data/lib/ansible/ansible_value.rb +1 -1
- data/lib/ansible/config.rb +8 -5
- data/lib/ansible/devices.rb +1 -0
- data/lib/ansible/knx.rb +0 -0
- data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
- data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
- data/lib/ansible/transceiver.rb +0 -3
- data/lib/ansible/version.rb +3 -0
- data/lib/ansible/zwave.rb +1 -0
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
- data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
- data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
- data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
- data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
- data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
- data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
- data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
- data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
- data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
- data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
- data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
- data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
- data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
- data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
- data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
- data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
- data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
- data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
- data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
- data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
- data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
- data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
- data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
- data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
- data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
- data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
- data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
- data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
- data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
- data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
- data/lib/ansible/zwave/zwave_value.rb +6 -10
- metadata +159 -17
- data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,73 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// ThermostatSetpoint.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_SETPOINT
|
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 _ThermostatSetpoint_H
|
29
|
+
#define _ThermostatSetpoint_H
|
30
|
+
|
31
|
+
#include <vector>
|
32
|
+
#include <string>
|
33
|
+
#include "CommandClass.h"
|
34
|
+
|
35
|
+
namespace OpenZWave
|
36
|
+
{
|
37
|
+
class ValueDecimal;
|
38
|
+
|
39
|
+
/** \brief Implements COMMAND_CLASS_THERMOSTAT_SETPOINT (0x43), a Z-Wave device command class.
|
40
|
+
*/
|
41
|
+
class ThermostatSetpoint: public CommandClass
|
42
|
+
{
|
43
|
+
public:
|
44
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatSetpoint( _homeId, _nodeId ); }
|
45
|
+
virtual ~ThermostatSetpoint(){}
|
46
|
+
|
47
|
+
static uint8 const StaticGetCommandClassId(){ return 0x43; }
|
48
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_SETPOINT"; }
|
49
|
+
|
50
|
+
// From CommandClass
|
51
|
+
virtual void ReadXML( TiXmlElement const* _ccElement );
|
52
|
+
virtual void WriteXML( TiXmlElement* _ccElement );
|
53
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
54
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _setPointIndex, uint8 const _dummy, Driver::MsgQueue const _queue );
|
55
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
56
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
57
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
58
|
+
virtual bool SetValue( Value const& _value );
|
59
|
+
|
60
|
+
public:
|
61
|
+
virtual void CreateVars( uint8 const _instance, uint8 const _index );
|
62
|
+
|
63
|
+
private:
|
64
|
+
ThermostatSetpoint( uint32 const _homeId, uint8 const _nodeId );
|
65
|
+
uint8 m_setPointBase;
|
66
|
+
};
|
67
|
+
|
68
|
+
} // namespace OpenZWave
|
69
|
+
|
70
|
+
#endif
|
71
|
+
|
72
|
+
|
73
|
+
|
@@ -0,0 +1,255 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Version.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_VERSION
|
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
|
+
#include "CommandClasses.h"
|
29
|
+
#include "Version.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Driver.h"
|
33
|
+
#include "Node.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueString.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum VersionCmd
|
41
|
+
{
|
42
|
+
VersionCmd_Get = 0x11,
|
43
|
+
VersionCmd_Report = 0x12,
|
44
|
+
VersionCmd_CommandClassGet = 0x13,
|
45
|
+
VersionCmd_CommandClassReport = 0x14
|
46
|
+
};
|
47
|
+
|
48
|
+
enum
|
49
|
+
{
|
50
|
+
VersionIndex_Library = 0,
|
51
|
+
VersionIndex_Protocol,
|
52
|
+
VersionIndex_Application
|
53
|
+
};
|
54
|
+
|
55
|
+
//-----------------------------------------------------------------------------
|
56
|
+
// <Version::Version>
|
57
|
+
// Constructor
|
58
|
+
//-----------------------------------------------------------------------------
|
59
|
+
Version::Version
|
60
|
+
(
|
61
|
+
uint32 const _homeId,
|
62
|
+
uint8 const _nodeId
|
63
|
+
):
|
64
|
+
CommandClass( _homeId, _nodeId ), m_classGetSupported( true )
|
65
|
+
{
|
66
|
+
SetStaticRequest( StaticRequest_Values );
|
67
|
+
}
|
68
|
+
|
69
|
+
//-----------------------------------------------------------------------------
|
70
|
+
// <Version::ReadXML>
|
71
|
+
// Read configuration.
|
72
|
+
//-----------------------------------------------------------------------------
|
73
|
+
void Version::ReadXML
|
74
|
+
(
|
75
|
+
TiXmlElement const* _ccElement
|
76
|
+
)
|
77
|
+
{
|
78
|
+
CommandClass::ReadXML( _ccElement );
|
79
|
+
|
80
|
+
char const* str = _ccElement->Attribute("classgetsupported");
|
81
|
+
if( str )
|
82
|
+
{
|
83
|
+
m_classGetSupported = !strcmp( str, "true");
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
//-----------------------------------------------------------------------------
|
88
|
+
// <Version::WriteXML>
|
89
|
+
// Save changed configuration
|
90
|
+
//-----------------------------------------------------------------------------
|
91
|
+
void Version::WriteXML
|
92
|
+
(
|
93
|
+
TiXmlElement* _ccElement
|
94
|
+
)
|
95
|
+
{
|
96
|
+
CommandClass::WriteXML( _ccElement );
|
97
|
+
|
98
|
+
if( !m_classGetSupported )
|
99
|
+
{
|
100
|
+
_ccElement->SetAttribute( "classgetsupported", "false" );
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
//-----------------------------------------------------------------------------
|
105
|
+
// <Version::RequestState>
|
106
|
+
// Request current state from the device
|
107
|
+
//-----------------------------------------------------------------------------
|
108
|
+
bool Version::RequestState
|
109
|
+
(
|
110
|
+
uint32 const _requestFlags,
|
111
|
+
uint8 const _instance,
|
112
|
+
Driver::MsgQueue const _queue
|
113
|
+
)
|
114
|
+
{
|
115
|
+
if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) )
|
116
|
+
{
|
117
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
118
|
+
}
|
119
|
+
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
|
123
|
+
//-----------------------------------------------------------------------------
|
124
|
+
// <Version::RequestValue>
|
125
|
+
// Request current value from the device
|
126
|
+
//-----------------------------------------------------------------------------
|
127
|
+
bool Version::RequestValue
|
128
|
+
(
|
129
|
+
uint32 const _requestFlags,
|
130
|
+
uint8 const _dummy1, // = 0
|
131
|
+
uint8 const _instance,
|
132
|
+
Driver::MsgQueue const _queue
|
133
|
+
)
|
134
|
+
{
|
135
|
+
if( _instance != 1 )
|
136
|
+
{
|
137
|
+
// This command class doesn't work with multiple instances
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
|
141
|
+
Msg* msg = new Msg( "VersionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
142
|
+
msg->Append( GetNodeId() );
|
143
|
+
msg->Append( 2 );
|
144
|
+
msg->Append( GetCommandClassId() );
|
145
|
+
msg->Append( VersionCmd_Get );
|
146
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
147
|
+
GetDriver()->SendMsg( msg, _queue );
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
|
151
|
+
//-----------------------------------------------------------------------------
|
152
|
+
// <Version::HandleMsg>
|
153
|
+
// Handle a message from the Z-Wave network
|
154
|
+
//-----------------------------------------------------------------------------
|
155
|
+
bool Version::HandleMsg
|
156
|
+
(
|
157
|
+
uint8 const* _data,
|
158
|
+
uint32 const _length,
|
159
|
+
uint32 const _instance // = 1
|
160
|
+
)
|
161
|
+
{
|
162
|
+
if( Node* node = GetNodeUnsafe() )
|
163
|
+
{
|
164
|
+
if( VersionCmd_Report == (VersionCmd)_data[0] )
|
165
|
+
{
|
166
|
+
char library[8];
|
167
|
+
char protocol[16];
|
168
|
+
char application[16];
|
169
|
+
|
170
|
+
snprintf( library, sizeof(library), "%d", _data[1] );
|
171
|
+
snprintf( protocol, sizeof(protocol), "%d.%.2d", _data[2], _data[3] );
|
172
|
+
snprintf( application, sizeof(application), "%d.%.2d", _data[4], _data[5] );
|
173
|
+
|
174
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Version report from node %d: Library=%s, Protocol=%s, Application=%s", GetNodeId(), library, protocol, application );
|
175
|
+
ClearStaticRequest( StaticRequest_Values );
|
176
|
+
|
177
|
+
if( ValueString* libraryValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Library ) ) )
|
178
|
+
{
|
179
|
+
libraryValue->OnValueRefreshed( library );
|
180
|
+
libraryValue->Release();
|
181
|
+
}
|
182
|
+
if( ValueString* protocolValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Protocol ) ) )
|
183
|
+
{
|
184
|
+
protocolValue->OnValueRefreshed( protocol );
|
185
|
+
protocolValue->Release();
|
186
|
+
}
|
187
|
+
if( ValueString* applicationValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Application ) ) )
|
188
|
+
{
|
189
|
+
applicationValue->OnValueRefreshed( application );
|
190
|
+
applicationValue->Release();
|
191
|
+
}
|
192
|
+
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
|
196
|
+
if (VersionCmd_CommandClassReport == (VersionCmd)_data[0])
|
197
|
+
{
|
198
|
+
if( CommandClass* pCommandClass = node->GetCommandClass( _data[1] ) )
|
199
|
+
{
|
200
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Command Class Version report from node %d: CommandClass=%s, Version=%d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), _data[2] );
|
201
|
+
pCommandClass->ClearStaticRequest( StaticRequest_Version );
|
202
|
+
pCommandClass->SetVersion( _data[2] );
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
return true;
|
207
|
+
}
|
208
|
+
|
209
|
+
return false;
|
210
|
+
}
|
211
|
+
|
212
|
+
//-----------------------------------------------------------------------------
|
213
|
+
// <Version::RequestCommandClassVersion>
|
214
|
+
// Request the version of a command class used by the device
|
215
|
+
//-----------------------------------------------------------------------------
|
216
|
+
bool Version::RequestCommandClassVersion
|
217
|
+
(
|
218
|
+
CommandClass const* _commandClass
|
219
|
+
)
|
220
|
+
{
|
221
|
+
if( m_classGetSupported )
|
222
|
+
{
|
223
|
+
if( _commandClass->HasStaticRequest( StaticRequest_Version ) )
|
224
|
+
{
|
225
|
+
Msg* msg = new Msg( "VersionCmd_CommandClassGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
226
|
+
msg->Append( GetNodeId() );
|
227
|
+
msg->Append( 3 );
|
228
|
+
msg->Append( GetCommandClassId() );
|
229
|
+
msg->Append( VersionCmd_CommandClassGet );
|
230
|
+
msg->Append( _commandClass->GetCommandClassId() );
|
231
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
232
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
233
|
+
return true;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
return false;
|
238
|
+
}
|
239
|
+
|
240
|
+
//-----------------------------------------------------------------------------
|
241
|
+
// <Version::CreateVars>
|
242
|
+
// Create the values managed by this command class
|
243
|
+
//-----------------------------------------------------------------------------
|
244
|
+
void Version::CreateVars
|
245
|
+
(
|
246
|
+
uint8 const _instance
|
247
|
+
)
|
248
|
+
{
|
249
|
+
if( Node* node = GetNodeUnsafe() )
|
250
|
+
{
|
251
|
+
node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Library, "Library Version", "", true, false, "Unknown", 0 );
|
252
|
+
node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Protocol, "Protocol Version", "", true, false, "Unknown", 0 );
|
253
|
+
node->CreateValueString( ValueID::ValueGenre_System, GetCommandClassId(), _instance, VersionIndex_Application, "Application Version", "", true, false, "Unknown", 0 );
|
254
|
+
}
|
255
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Version.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_VERSION
|
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 _Version_H
|
29
|
+
#define _Version_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueString;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_VERSION (0x86), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class Version: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Version( _homeId, _nodeId ); }
|
43
|
+
virtual ~Version(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x86; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_VERSION"; }
|
47
|
+
|
48
|
+
bool RequestCommandClassVersion( CommandClass const* _commandClass );
|
49
|
+
|
50
|
+
// From CommandClass
|
51
|
+
virtual void ReadXML( TiXmlElement const* _ccElement );
|
52
|
+
virtual void WriteXML( TiXmlElement* _ccElement );
|
53
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
54
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
55
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
56
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
57
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
58
|
+
|
59
|
+
protected:
|
60
|
+
virtual void CreateVars( uint8 const _instance );
|
61
|
+
|
62
|
+
private:
|
63
|
+
Version( uint32 const _homeId, uint8 const _nodeId );
|
64
|
+
|
65
|
+
bool m_classGetSupported;
|
66
|
+
};
|
67
|
+
|
68
|
+
} // namespace OpenZWave
|
69
|
+
|
70
|
+
#endif
|
71
|
+
|
@@ -0,0 +1,391 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// WakeUp.cpp
|
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
|
+
#include "CommandClasses.h"
|
29
|
+
#include "WakeUp.h"
|
30
|
+
#include "MultiCmd.h"
|
31
|
+
#include "Defs.h"
|
32
|
+
#include "Msg.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Node.h"
|
35
|
+
#include "Log.h"
|
36
|
+
#include "Mutex.h"
|
37
|
+
#include "ValueInt.h"
|
38
|
+
|
39
|
+
using namespace OpenZWave;
|
40
|
+
|
41
|
+
enum WakeUpCmd
|
42
|
+
{
|
43
|
+
WakeUpCmd_IntervalSet = 0x04,
|
44
|
+
WakeUpCmd_IntervalGet = 0x05,
|
45
|
+
WakeUpCmd_IntervalReport = 0x06,
|
46
|
+
WakeUpCmd_Notification = 0x07,
|
47
|
+
WakeUpCmd_NoMoreInformation = 0x08
|
48
|
+
};
|
49
|
+
|
50
|
+
|
51
|
+
//-----------------------------------------------------------------------------
|
52
|
+
// <WakeUp::WakeUp>
|
53
|
+
// Constructor
|
54
|
+
//-----------------------------------------------------------------------------
|
55
|
+
WakeUp::WakeUp
|
56
|
+
(
|
57
|
+
uint32 const _homeId,
|
58
|
+
uint8 const _nodeId
|
59
|
+
):
|
60
|
+
CommandClass( _homeId, _nodeId ),
|
61
|
+
m_mutex( new Mutex() ),
|
62
|
+
m_awake( true ),
|
63
|
+
m_pollRequired( false ),
|
64
|
+
m_notification( false )
|
65
|
+
{
|
66
|
+
}
|
67
|
+
|
68
|
+
//-----------------------------------------------------------------------------
|
69
|
+
// <WakeUp::~WakeUp>
|
70
|
+
// Destructor
|
71
|
+
//-----------------------------------------------------------------------------
|
72
|
+
WakeUp::~WakeUp
|
73
|
+
(
|
74
|
+
)
|
75
|
+
{
|
76
|
+
m_mutex->Release();
|
77
|
+
while( !m_pendingQueue.empty() )
|
78
|
+
{
|
79
|
+
Driver::MsgQueueItem const& item = m_pendingQueue.front();
|
80
|
+
if( Driver::MsgQueueCmd_SendMsg == item.m_command )
|
81
|
+
{
|
82
|
+
delete item.m_msg;
|
83
|
+
}
|
84
|
+
m_pendingQueue.pop_front();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
//-----------------------------------------------------------------------------
|
89
|
+
// <WakeUp::Init>
|
90
|
+
// Starts the process of requesting node state from a sleeping device
|
91
|
+
//-----------------------------------------------------------------------------
|
92
|
+
void WakeUp::Init
|
93
|
+
(
|
94
|
+
)
|
95
|
+
{
|
96
|
+
// Request the wake up interval. When we receive the response, we
|
97
|
+
// can send a set interval message with the same interval, but with
|
98
|
+
// the target node id set to that of the controller. This will ensure
|
99
|
+
// that the controller will receive the wake-up notifications from
|
100
|
+
// the device. Once this is done, we can request the rest of the node
|
101
|
+
// state.
|
102
|
+
RequestState( CommandClass::RequestFlag_Session, 1, Driver::MsgQueue_Send );
|
103
|
+
}
|
104
|
+
|
105
|
+
//-----------------------------------------------------------------------------
|
106
|
+
// <WakeUp::RequestState>
|
107
|
+
// Nothing to do for wakeup
|
108
|
+
//-----------------------------------------------------------------------------
|
109
|
+
bool WakeUp::RequestState
|
110
|
+
(
|
111
|
+
uint32 const _requestFlags,
|
112
|
+
uint8 const _instance,
|
113
|
+
Driver::MsgQueue const _queue
|
114
|
+
)
|
115
|
+
{
|
116
|
+
if( _requestFlags & RequestFlag_Session )
|
117
|
+
{
|
118
|
+
Node* node = GetNodeUnsafe();
|
119
|
+
if( node != NULL && !node->IsController() )
|
120
|
+
{
|
121
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
|
128
|
+
//-----------------------------------------------------------------------------
|
129
|
+
// <WakeUp::RequestValue>
|
130
|
+
// Nothing to do for wakeup
|
131
|
+
//-----------------------------------------------------------------------------
|
132
|
+
bool WakeUp::RequestValue
|
133
|
+
(
|
134
|
+
uint32 const _requestFlags,
|
135
|
+
uint8 const _dummy1, // = 0
|
136
|
+
uint8 const _instance,
|
137
|
+
Driver::MsgQueue const _queue
|
138
|
+
)
|
139
|
+
{
|
140
|
+
if( _instance != 1 )
|
141
|
+
{
|
142
|
+
// This command class doesn't work with multiple instances
|
143
|
+
return false;
|
144
|
+
}
|
145
|
+
|
146
|
+
// We won't get a response until the device next wakes up
|
147
|
+
Msg* msg = new Msg( "WakeUpCmd_IntervalGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
148
|
+
msg->Append( GetNodeId() );
|
149
|
+
msg->Append( 2 );
|
150
|
+
msg->Append( GetCommandClassId() );
|
151
|
+
msg->Append( WakeUpCmd_IntervalGet );
|
152
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
153
|
+
GetDriver()->SendMsg( msg, _queue );
|
154
|
+
return true;
|
155
|
+
}
|
156
|
+
|
157
|
+
//-----------------------------------------------------------------------------
|
158
|
+
// <WakeUp::HandleMsg>
|
159
|
+
// Handle a message from the Z-Wave network
|
160
|
+
//-----------------------------------------------------------------------------
|
161
|
+
bool WakeUp::HandleMsg
|
162
|
+
(
|
163
|
+
uint8 const* _data,
|
164
|
+
uint32 const _length,
|
165
|
+
uint32 const _instance // = 1
|
166
|
+
)
|
167
|
+
{
|
168
|
+
if( WakeUpCmd_IntervalReport == (WakeUpCmd)_data[0] )
|
169
|
+
{
|
170
|
+
if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, 0 ) ) )
|
171
|
+
{
|
172
|
+
// some interval reports received are validly formatted (proper checksum, etc.) but only have length
|
173
|
+
// of 3 (0x84 (classid), 0x06 (IntervalReport), 0x00). Not sure what this means
|
174
|
+
if( _length < 6 )
|
175
|
+
{
|
176
|
+
Log::Write( LogLevel_Warning, "" );
|
177
|
+
Log::Write( LogLevel_Warning, GetNodeId(), "Unusual response: WakeUpCmd_IntervalReport with len = %d. Ignored.", _length );
|
178
|
+
value->Release();
|
179
|
+
return false;
|
180
|
+
}
|
181
|
+
|
182
|
+
uint32 interval = ((uint32)_data[1]) << 16;
|
183
|
+
interval |= (((uint32)_data[2]) << 8);
|
184
|
+
interval |= (uint32)_data[3];
|
185
|
+
|
186
|
+
uint8 targetNodeId = _data[4];
|
187
|
+
|
188
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval report from node %d: Interval=%d, Target Node=%d", GetNodeId(), interval, targetNodeId );
|
189
|
+
|
190
|
+
value->OnValueRefreshed( (int32)interval );
|
191
|
+
|
192
|
+
// Ensure that the target node for wake-up notifications is the controller
|
193
|
+
if( GetDriver()->GetNodeId() != targetNodeId )
|
194
|
+
{
|
195
|
+
SetValue( *value );
|
196
|
+
}
|
197
|
+
value->Release();
|
198
|
+
}
|
199
|
+
return true;
|
200
|
+
}
|
201
|
+
else if( WakeUpCmd_Notification == (WakeUpCmd)_data[0] )
|
202
|
+
{
|
203
|
+
// The device is awake.
|
204
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Notification from node %d", GetNodeId() );
|
205
|
+
m_notification = true;
|
206
|
+
SetAwake( true );
|
207
|
+
return true;
|
208
|
+
}
|
209
|
+
|
210
|
+
return false;
|
211
|
+
}
|
212
|
+
|
213
|
+
//-----------------------------------------------------------------------------
|
214
|
+
// <WakeUp::SetValue>
|
215
|
+
// Set the device's wakeup interval
|
216
|
+
//-----------------------------------------------------------------------------
|
217
|
+
bool WakeUp::SetValue
|
218
|
+
(
|
219
|
+
Value const& _value
|
220
|
+
)
|
221
|
+
{
|
222
|
+
if( ValueID::ValueType_Int == _value.GetID().GetType() )
|
223
|
+
{
|
224
|
+
ValueInt const* value = static_cast<ValueInt const*>(&_value);
|
225
|
+
|
226
|
+
Msg* msg = new Msg( "Wakeup Interval Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
227
|
+
msg->Append( GetNodeId() );
|
228
|
+
|
229
|
+
if( GetNodeUnsafe()->GetCommandClass( MultiCmd::StaticGetCommandClassId() ) )
|
230
|
+
{
|
231
|
+
msg->Append( 10 );
|
232
|
+
msg->Append( MultiCmd::StaticGetCommandClassId() );
|
233
|
+
msg->Append( MultiCmd::MultiCmdCmd_Encap );
|
234
|
+
msg->Append( 1 );
|
235
|
+
}
|
236
|
+
|
237
|
+
int32 interval = value->GetValue();
|
238
|
+
|
239
|
+
msg->Append( 6 ); // length of command bytes following
|
240
|
+
msg->Append( GetCommandClassId() );
|
241
|
+
msg->Append( WakeUpCmd_IntervalSet );
|
242
|
+
msg->Append( (uint8)(( interval >> 16 ) & 0xff) );
|
243
|
+
msg->Append( (uint8)(( interval >> 8 ) & 0xff) );
|
244
|
+
msg->Append( (uint8)( interval & 0xff ) );
|
245
|
+
msg->Append( GetDriver()->GetNodeId() );
|
246
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
247
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
248
|
+
return true;
|
249
|
+
}
|
250
|
+
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
|
254
|
+
//-----------------------------------------------------------------------------
|
255
|
+
// <WakeUp::SetAwake>
|
256
|
+
// Set whether the device is likely to be awake
|
257
|
+
//-----------------------------------------------------------------------------
|
258
|
+
void WakeUp::SetAwake
|
259
|
+
(
|
260
|
+
bool _state
|
261
|
+
)
|
262
|
+
{
|
263
|
+
if( m_awake != _state )
|
264
|
+
{
|
265
|
+
m_awake = _state;
|
266
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Node %d has been marked as %s", GetNodeId(), m_awake ? "awake" : "asleep" );
|
267
|
+
}
|
268
|
+
|
269
|
+
if( m_awake )
|
270
|
+
{
|
271
|
+
// If the device is marked for polling, request the current state
|
272
|
+
if( m_pollRequired )
|
273
|
+
{
|
274
|
+
if( Node* node = GetNodeUnsafe() )
|
275
|
+
{
|
276
|
+
node->SetQueryStage( Node::QueryStage_Dynamic );
|
277
|
+
}
|
278
|
+
m_pollRequired = false;
|
279
|
+
}
|
280
|
+
|
281
|
+
// Send all pending messages
|
282
|
+
SendPending();
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
//-----------------------------------------------------------------------------
|
287
|
+
// <WakeUp::QueueMsg>
|
288
|
+
// Add a Z-Wave message to the queue
|
289
|
+
//-----------------------------------------------------------------------------
|
290
|
+
void WakeUp::QueueMsg
|
291
|
+
(
|
292
|
+
Driver::MsgQueueItem const& _item
|
293
|
+
)
|
294
|
+
{
|
295
|
+
m_mutex->Lock();
|
296
|
+
|
297
|
+
// See if there is already a copy of this message in the queue. If so,
|
298
|
+
// we delete it. This is to prevent duplicates building up if the
|
299
|
+
// device does not wake up very often. Deleting the original and
|
300
|
+
// adding the copy to the end avoids problems with the order of
|
301
|
+
// commands such as on and off.
|
302
|
+
list<Driver::MsgQueueItem>::iterator it = m_pendingQueue.begin();
|
303
|
+
while( it != m_pendingQueue.end() )
|
304
|
+
{
|
305
|
+
Driver::MsgQueueItem const& item = *it;
|
306
|
+
if( item == _item )
|
307
|
+
{
|
308
|
+
// Duplicate found
|
309
|
+
if( Driver::MsgQueueCmd_SendMsg == item.m_command )
|
310
|
+
{
|
311
|
+
delete item.m_msg;
|
312
|
+
}
|
313
|
+
m_pendingQueue.erase( it++ );
|
314
|
+
}
|
315
|
+
else
|
316
|
+
{
|
317
|
+
++it;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
m_pendingQueue.push_back( _item );
|
321
|
+
m_mutex->Unlock();
|
322
|
+
}
|
323
|
+
|
324
|
+
//-----------------------------------------------------------------------------
|
325
|
+
// <WakeUp::SendPending>
|
326
|
+
// The device is awake, so send all the pending messages
|
327
|
+
//-----------------------------------------------------------------------------
|
328
|
+
void WakeUp::SendPending
|
329
|
+
(
|
330
|
+
)
|
331
|
+
{
|
332
|
+
m_awake = true;
|
333
|
+
|
334
|
+
m_mutex->Lock();
|
335
|
+
list<Driver::MsgQueueItem>::iterator it = m_pendingQueue.begin();
|
336
|
+
while( it != m_pendingQueue.end() )
|
337
|
+
{
|
338
|
+
Driver::MsgQueueItem const& item = *it;
|
339
|
+
if( Driver::MsgQueueCmd_SendMsg == item.m_command )
|
340
|
+
{
|
341
|
+
GetDriver()->SendMsg( item.m_msg, Driver::MsgQueue_WakeUp );
|
342
|
+
}
|
343
|
+
else if( Driver::MsgQueueCmd_QueryStageComplete == item.m_command )
|
344
|
+
{
|
345
|
+
GetDriver()->SendQueryStageComplete( item.m_nodeId, item.m_queryStage, Driver::MsgQueue_WakeUp );
|
346
|
+
}
|
347
|
+
it = m_pendingQueue.erase( it );
|
348
|
+
}
|
349
|
+
m_mutex->Unlock();
|
350
|
+
|
351
|
+
// Send the device back to sleep, unless we have outstanding queries.
|
352
|
+
bool sendToSleep = m_notification;
|
353
|
+
if( Node* node = GetNodeUnsafe() )
|
354
|
+
{
|
355
|
+
if( !node->AllQueriesCompleted() )
|
356
|
+
{
|
357
|
+
sendToSleep = false;
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
if( sendToSleep )
|
362
|
+
{
|
363
|
+
m_notification = false;
|
364
|
+
Msg* msg = new Msg( "Wakeup - No More Information (send to sleep)", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
365
|
+
msg->Append( GetNodeId() );
|
366
|
+
msg->Append( 2 );
|
367
|
+
msg->Append( GetCommandClassId() );
|
368
|
+
msg->Append( WakeUpCmd_NoMoreInformation );
|
369
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
370
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_WakeUp );
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
//-----------------------------------------------------------------------------
|
375
|
+
// <WakeUp::CreateVars>
|
376
|
+
// Create the values managed by this command class
|
377
|
+
//-----------------------------------------------------------------------------
|
378
|
+
void WakeUp::CreateVars
|
379
|
+
(
|
380
|
+
uint8 const _instance
|
381
|
+
)
|
382
|
+
{
|
383
|
+
if( Node* node = GetNodeUnsafe() )
|
384
|
+
{
|
385
|
+
if( !node->IsController() ) // We don't add the interval value for controllers, because they don't appear to ever wake up on their own.
|
386
|
+
{
|
387
|
+
node->CreateValueInt( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Wake-up Interval", "Seconds", false, false, 3600, 0 );
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|