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,83 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SwitchMultilevel.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_MULTILEVEL
|
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 _SwitchMultilevel_H
|
29
|
+
#define _SwitchMultilevel_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueBool;
|
36
|
+
class ValueButton;
|
37
|
+
class ValueByte;
|
38
|
+
|
39
|
+
/** \brief Implements COMMAND_CLASS_SWITCH_MULTILEVEL (0x26), a Z-Wave device command class.
|
40
|
+
*/
|
41
|
+
class SwitchMultilevel: public CommandClass
|
42
|
+
{
|
43
|
+
public:
|
44
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchMultilevel( _homeId, _nodeId ); }
|
45
|
+
virtual ~SwitchMultilevel(){}
|
46
|
+
|
47
|
+
static uint8 const StaticGetCommandClassId(){ return 0x26; }
|
48
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_MULTILEVEL"; }
|
49
|
+
|
50
|
+
// From CommandClass
|
51
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
52
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
53
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
54
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
55
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
56
|
+
virtual bool SetValue( Value const& _value );
|
57
|
+
virtual void SetVersion( uint8 const _version );
|
58
|
+
|
59
|
+
virtual uint8 GetMaxVersion(){ return 3; }
|
60
|
+
|
61
|
+
protected:
|
62
|
+
virtual void CreateVars( uint8 const _instance );
|
63
|
+
|
64
|
+
private:
|
65
|
+
enum SwitchMultilevelDirection
|
66
|
+
{
|
67
|
+
SwitchMultilevelDirection_Up = 0,
|
68
|
+
SwitchMultilevelDirection_Down,
|
69
|
+
SwitchMultilevelDirection_Inc,
|
70
|
+
SwitchMultilevelDirection_Dec
|
71
|
+
};
|
72
|
+
|
73
|
+
SwitchMultilevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
74
|
+
|
75
|
+
bool SetLevel( uint8 const _instance, uint8 const _level );
|
76
|
+
bool StartLevelChange( uint8 const _instance, SwitchMultilevelDirection const _direction );
|
77
|
+
bool StopLevelChange( uint8 const _instance );
|
78
|
+
};
|
79
|
+
|
80
|
+
} // namespace OpenZWave
|
81
|
+
|
82
|
+
#endif
|
83
|
+
|
@@ -0,0 +1,151 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SwitchToggleBinary.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_BINARY
|
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 "SwitchToggleBinary.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Driver.h"
|
33
|
+
#include "Node.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueBool.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum SwitchToggleBinaryCmd
|
41
|
+
{
|
42
|
+
SwitchToggleBinaryCmd_Set = 0x01,
|
43
|
+
SwitchToggleBinaryCmd_Get = 0x02,
|
44
|
+
SwitchToggleBinaryCmd_Report = 0x03
|
45
|
+
};
|
46
|
+
|
47
|
+
//-----------------------------------------------------------------------------
|
48
|
+
// <SwitchToggleBinary::RequestState>
|
49
|
+
// Request current state from the device
|
50
|
+
//-----------------------------------------------------------------------------
|
51
|
+
bool SwitchToggleBinary::RequestState
|
52
|
+
(
|
53
|
+
uint32 const _requestFlags,
|
54
|
+
uint8 const _instance,
|
55
|
+
Driver::MsgQueue const _queue
|
56
|
+
)
|
57
|
+
{
|
58
|
+
if( _requestFlags & RequestFlag_Dynamic )
|
59
|
+
{
|
60
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
61
|
+
}
|
62
|
+
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
|
66
|
+
//-----------------------------------------------------------------------------
|
67
|
+
// <SwitchToggleBinary::RequestValue>
|
68
|
+
// Request current value from the device
|
69
|
+
//-----------------------------------------------------------------------------
|
70
|
+
bool SwitchToggleBinary::RequestValue
|
71
|
+
(
|
72
|
+
uint32 const _requestFlags,
|
73
|
+
uint8 const _dummy1, // = 0 (not used)
|
74
|
+
uint8 const _instance,
|
75
|
+
Driver::MsgQueue const _queue
|
76
|
+
)
|
77
|
+
{
|
78
|
+
Msg* msg = new Msg( "SwitchToggleBinaryCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
79
|
+
msg->SetInstance( this, _instance );
|
80
|
+
msg->Append( GetNodeId() );
|
81
|
+
msg->Append( 2 );
|
82
|
+
msg->Append( GetCommandClassId() );
|
83
|
+
msg->Append( SwitchToggleBinaryCmd_Get );
|
84
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
85
|
+
GetDriver()->SendMsg( msg, _queue );
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
|
89
|
+
//-----------------------------------------------------------------------------
|
90
|
+
// <SwitchToggleBinary::HandleMsg>
|
91
|
+
// Handle a message from the Z-Wave network
|
92
|
+
//-----------------------------------------------------------------------------
|
93
|
+
bool SwitchToggleBinary::HandleMsg
|
94
|
+
(
|
95
|
+
uint8 const* _data,
|
96
|
+
uint32 const _length,
|
97
|
+
uint32 const _instance // = 1
|
98
|
+
)
|
99
|
+
{
|
100
|
+
if( SwitchToggleBinaryCmd_Report == (SwitchToggleBinaryCmd)_data[0] )
|
101
|
+
{
|
102
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchToggleBinary report: %s", _data[1] ? "On" : "Off" );
|
103
|
+
|
104
|
+
if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, 0 ) ) )
|
105
|
+
{
|
106
|
+
value->OnValueRefreshed( _data[1] != 0 );
|
107
|
+
value->Release();
|
108
|
+
}
|
109
|
+
return true;
|
110
|
+
}
|
111
|
+
|
112
|
+
return false;
|
113
|
+
}
|
114
|
+
|
115
|
+
//-----------------------------------------------------------------------------
|
116
|
+
// <SwitchToggleBinary::SetValue>
|
117
|
+
// Toggle the state of the switch
|
118
|
+
//-----------------------------------------------------------------------------
|
119
|
+
bool SwitchToggleBinary::SetValue
|
120
|
+
(
|
121
|
+
Value const& _value
|
122
|
+
)
|
123
|
+
{
|
124
|
+
Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleBinary::Set - Toggling the state" );
|
125
|
+
Msg* msg = new Msg( "SwitchToggleBinary Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
126
|
+
msg->SetInstance( this, _value.GetID().GetInstance() );
|
127
|
+
msg->Append( GetNodeId() );
|
128
|
+
msg->Append( 2 );
|
129
|
+
msg->Append( GetCommandClassId() );
|
130
|
+
msg->Append( SwitchToggleBinaryCmd_Set );
|
131
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
132
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
133
|
+
return true;
|
134
|
+
}
|
135
|
+
|
136
|
+
//-----------------------------------------------------------------------------
|
137
|
+
// <SwitchToggleBinary::CreateVars>
|
138
|
+
// Create the values managed by this command class
|
139
|
+
//-----------------------------------------------------------------------------
|
140
|
+
void SwitchToggleBinary::CreateVars
|
141
|
+
(
|
142
|
+
uint8 const _instance
|
143
|
+
)
|
144
|
+
{
|
145
|
+
if( Node* node = GetNodeUnsafe() )
|
146
|
+
{
|
147
|
+
node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Toggle Switch", "", false, false, false, 0 );
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SwitchToggleBinary.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_BINARY
|
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 _SwitchToggleBinary_H
|
29
|
+
#define _SwitchToggleBinary_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueBool;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_SWITCH_TOGGLE_BINARY (0x28), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class SwitchToggleBinary: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SwitchToggleBinary( _homeId, _nodeId ); }
|
43
|
+
virtual ~SwitchToggleBinary(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x28; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SWITCH_TOGGLE_BINARY"; }
|
47
|
+
|
48
|
+
// From CommandClass
|
49
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
50
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
51
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
52
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
53
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
54
|
+
virtual bool SetValue( Value const& _value );
|
55
|
+
|
56
|
+
protected:
|
57
|
+
virtual void CreateVars( uint8 const _instance );
|
58
|
+
|
59
|
+
private:
|
60
|
+
SwitchToggleBinary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace OpenZWave
|
64
|
+
|
65
|
+
#endif
|
66
|
+
|
@@ -0,0 +1,195 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SwitchToggleMultilevel.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SWITCH_TOGGLE_MULTILEVEL
|
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 "SwitchToggleMultilevel.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Driver.h"
|
33
|
+
#include "Node.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueByte.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum SwitchToggleMultilevelCmd
|
41
|
+
{
|
42
|
+
SwitchToggleMultilevelCmd_Set = 0x01,
|
43
|
+
SwitchToggleMultilevelCmd_Get = 0x02,
|
44
|
+
SwitchToggleMultilevelCmd_Report = 0x03,
|
45
|
+
SwitchToggleMultilevelCmd_StartLevelChange = 0x04,
|
46
|
+
SwitchToggleMultilevelCmd_StopLevelChange = 0x05
|
47
|
+
};
|
48
|
+
|
49
|
+
|
50
|
+
//-----------------------------------------------------------------------------
|
51
|
+
// <SwitchToggleMultilevel::RequestState>
|
52
|
+
// Request current state from the device
|
53
|
+
//-----------------------------------------------------------------------------
|
54
|
+
bool SwitchToggleMultilevel::RequestState
|
55
|
+
(
|
56
|
+
uint32 const _requestFlags,
|
57
|
+
uint8 const _instance,
|
58
|
+
Driver::MsgQueue const _queue
|
59
|
+
)
|
60
|
+
{
|
61
|
+
if( _requestFlags & RequestFlag_Dynamic )
|
62
|
+
{
|
63
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
64
|
+
}
|
65
|
+
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
|
69
|
+
//-----------------------------------------------------------------------------
|
70
|
+
// <SwitchToggleMultilevel::RequestValue>
|
71
|
+
// Request current value from the device
|
72
|
+
//-----------------------------------------------------------------------------
|
73
|
+
bool SwitchToggleMultilevel::RequestValue
|
74
|
+
(
|
75
|
+
uint32 const _requestFlags,
|
76
|
+
uint8 const _dummy1, // = 0 (not used)
|
77
|
+
uint8 const _instance,
|
78
|
+
Driver::MsgQueue const _queue
|
79
|
+
)
|
80
|
+
{
|
81
|
+
Msg* msg = new Msg( "SwitchToggleMultilevelCmd_StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
82
|
+
msg->SetInstance( this, _instance );
|
83
|
+
msg->Append( GetNodeId() );
|
84
|
+
msg->Append( 2 );
|
85
|
+
msg->Append( GetCommandClassId() );
|
86
|
+
msg->Append( SwitchToggleMultilevelCmd_Get );
|
87
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
88
|
+
GetDriver()->SendMsg( msg, _queue );
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
|
92
|
+
//-----------------------------------------------------------------------------
|
93
|
+
// <SwitchToggleMultilevel::HandleMsg>
|
94
|
+
// Handle a message from the Z-Wave network
|
95
|
+
//-----------------------------------------------------------------------------
|
96
|
+
bool SwitchToggleMultilevel::HandleMsg
|
97
|
+
(
|
98
|
+
uint8 const* _data,
|
99
|
+
uint32 const _length,
|
100
|
+
uint32 const _instance // = 1
|
101
|
+
)
|
102
|
+
{
|
103
|
+
if( SwitchToggleMultilevelCmd_Report == (SwitchToggleMultilevelCmd)_data[0] )
|
104
|
+
{
|
105
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchToggleMultiLevel report: level=%d", _data[1] );
|
106
|
+
|
107
|
+
if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
|
108
|
+
{
|
109
|
+
value->OnValueRefreshed( _data[1] );
|
110
|
+
value->Release();
|
111
|
+
}
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
|
115
|
+
return false;
|
116
|
+
}
|
117
|
+
|
118
|
+
//-----------------------------------------------------------------------------
|
119
|
+
// <SwitchToggleMultilevel::SetValue>
|
120
|
+
// Toggle the state of the switch
|
121
|
+
//-----------------------------------------------------------------------------
|
122
|
+
bool SwitchToggleMultilevel::SetValue
|
123
|
+
(
|
124
|
+
Value const& _value
|
125
|
+
)
|
126
|
+
{
|
127
|
+
Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleMultilevel::Set - Toggling the state" );
|
128
|
+
Msg* msg = new Msg( "SwitchToggleMultilevel Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
129
|
+
msg->SetInstance( this, _value.GetID().GetInstance() );
|
130
|
+
msg->Append( GetNodeId() );
|
131
|
+
msg->Append( 2 );
|
132
|
+
msg->Append( GetCommandClassId() );
|
133
|
+
msg->Append( SwitchToggleMultilevelCmd_Set );
|
134
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
135
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
136
|
+
return true;
|
137
|
+
}
|
138
|
+
|
139
|
+
//-----------------------------------------------------------------------------
|
140
|
+
// <SwitchToggleMultilevel::StartLevelChange>
|
141
|
+
// Start the level changing
|
142
|
+
//-----------------------------------------------------------------------------
|
143
|
+
void SwitchToggleMultilevel::StartLevelChange
|
144
|
+
(
|
145
|
+
SwitchToggleMultilevelDirection const _direction,
|
146
|
+
bool const _bIgnoreStartLevel,
|
147
|
+
bool const _bRollover
|
148
|
+
)
|
149
|
+
{
|
150
|
+
uint8 param = (uint8)_direction;
|
151
|
+
param |= ( _bIgnoreStartLevel ? 0x20 : 0x00 );
|
152
|
+
param |= ( _bRollover ? 0x80 : 0x00 );
|
153
|
+
|
154
|
+
Log::Write( LogLevel_Info, GetNodeId(), "SwitchMultilevel::StartLevelChange - Starting a level change, Direction=%d, IgnoreStartLevel=%s and rollover=%s", (_direction==SwitchToggleMultilevelDirection_Up) ? "Up" : "Down", _bIgnoreStartLevel ? "True" : "False", _bRollover ? "True" : "False" );
|
155
|
+
Msg* msg = new Msg( "SwitchMultilevel StartLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
156
|
+
msg->Append( GetNodeId() );
|
157
|
+
msg->Append( 3 );
|
158
|
+
msg->Append( GetCommandClassId() );
|
159
|
+
msg->Append( SwitchToggleMultilevelCmd_StartLevelChange );
|
160
|
+
msg->Append( param );
|
161
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
162
|
+
}
|
163
|
+
|
164
|
+
//-----------------------------------------------------------------------------
|
165
|
+
// <SwitchToggleMultilevel::StopLevelChange>
|
166
|
+
// Stop the level changing
|
167
|
+
//-----------------------------------------------------------------------------
|
168
|
+
void SwitchToggleMultilevel::StopLevelChange
|
169
|
+
(
|
170
|
+
)
|
171
|
+
{
|
172
|
+
Log::Write( LogLevel_Info, GetNodeId(), "SwitchToggleMultilevel::StopLevelChange - Stopping the level change" );
|
173
|
+
Msg* msg = new Msg( "SwitchToggleMultilevel StopLevelChange", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
174
|
+
msg->Append( GetNodeId() );
|
175
|
+
msg->Append( 2 );
|
176
|
+
msg->Append( GetCommandClassId() );
|
177
|
+
msg->Append( SwitchToggleMultilevelCmd_StopLevelChange );
|
178
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
179
|
+
}
|
180
|
+
|
181
|
+
//-----------------------------------------------------------------------------
|
182
|
+
// <SwitchToggleMultilevel::CreateVars>
|
183
|
+
// Create the values managed by this command class
|
184
|
+
//-----------------------------------------------------------------------------
|
185
|
+
void SwitchToggleMultilevel::CreateVars
|
186
|
+
(
|
187
|
+
uint8 const _instance
|
188
|
+
)
|
189
|
+
{
|
190
|
+
if( Node* node = GetNodeUnsafe() )
|
191
|
+
{
|
192
|
+
node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Level", "", false, false, 0, 0 );
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|