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,66 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// NodeNaming.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_NODE_NAMING
|
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 _NodeNaming_H
|
29
|
+
#define _NodeNaming_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
/** \brief Implements COMMAND_CLASS_NODE_NAMING (0x77), a Z-Wave device command class.
|
36
|
+
*/
|
37
|
+
class NodeNaming: public CommandClass
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new NodeNaming( _homeId, _nodeId ); }
|
41
|
+
virtual ~NodeNaming(){}
|
42
|
+
|
43
|
+
static uint8 const StaticGetCommandClassId(){ return 0x77; }
|
44
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_NODE_NAMING"; }
|
45
|
+
|
46
|
+
// From CommandClass
|
47
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
48
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
49
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
50
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
51
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
52
|
+
|
53
|
+
void SetName( string const& _name );
|
54
|
+
void SetLocation( string const& _location );
|
55
|
+
|
56
|
+
private:
|
57
|
+
NodeNaming( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
58
|
+
|
59
|
+
string ExtractString( uint8 const* _data, uint32 const _length );
|
60
|
+
uint32 ConvertUFT16ToUTF8( uint16 _utf16, char* _buffer, uint32 pos );
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace OpenZWave
|
64
|
+
|
65
|
+
#endif
|
66
|
+
|
@@ -0,0 +1,157 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Powerlevel.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_POWERLEVEL
|
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 "Powerlevel.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Driver.h"
|
33
|
+
#include "Log.h"
|
34
|
+
|
35
|
+
using namespace OpenZWave;
|
36
|
+
|
37
|
+
enum PowerlevelCmd
|
38
|
+
{
|
39
|
+
PowerlevelCmd_Set = 0x01,
|
40
|
+
PowerlevelCmd_Get = 0x02,
|
41
|
+
PowerlevelCmd_Report = 0x03,
|
42
|
+
PowerlevelCmd_TestNodeSet = 0x04,
|
43
|
+
PowerlevelCmd_TestNodeGet = 0x05,
|
44
|
+
PowerlevelCmd_TestNodeReport = 0x06
|
45
|
+
};
|
46
|
+
|
47
|
+
static char const* c_powerLevelNames[] =
|
48
|
+
{
|
49
|
+
"Normal",
|
50
|
+
"-1dB",
|
51
|
+
"-2dB",
|
52
|
+
"-3dB",
|
53
|
+
"-4dB",
|
54
|
+
"-5dB",
|
55
|
+
"-6dB",
|
56
|
+
"-7dB",
|
57
|
+
"-8dB",
|
58
|
+
"-9dB"
|
59
|
+
};
|
60
|
+
|
61
|
+
static char const* c_powerLevelStatusNames[] =
|
62
|
+
{
|
63
|
+
"Failed",
|
64
|
+
"Success",
|
65
|
+
"In Progress"
|
66
|
+
};
|
67
|
+
|
68
|
+
|
69
|
+
//-----------------------------------------------------------------------------
|
70
|
+
// <Powerlevel::HandleMsg>
|
71
|
+
// Handle a message from the Z-Wave network
|
72
|
+
//-----------------------------------------------------------------------------
|
73
|
+
bool Powerlevel::HandleMsg
|
74
|
+
(
|
75
|
+
uint8 const* _data,
|
76
|
+
uint32 const _length,
|
77
|
+
uint32 const _instance // = 1
|
78
|
+
)
|
79
|
+
{
|
80
|
+
if( PowerlevelCmd_Report == (PowerlevelCmd)_data[0] )
|
81
|
+
{
|
82
|
+
PowerLevelEnum powerLevel = (PowerLevelEnum)_data[1];
|
83
|
+
uint8 timeout = _data[2];
|
84
|
+
|
85
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a PowerLevel report: PowerLevel=%s, Timeout=%d", c_powerLevelNames[powerLevel], timeout );
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
|
89
|
+
if( PowerlevelCmd_TestNodeReport == (PowerlevelCmd)_data[0] )
|
90
|
+
{
|
91
|
+
uint8 testNode = _data[1];
|
92
|
+
PowerLevelStatusEnum status = (PowerLevelStatusEnum)_data[2];
|
93
|
+
uint16 ackCount = (((uint16)_data[3])<<8) | (uint16)_data[4];
|
94
|
+
|
95
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a PowerLevel Test Node report: Test Node=%d, Status=%s, Test Frame ACK Count=%d", testNode, c_powerLevelStatusNames[status], ackCount );
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
//-----------------------------------------------------------------------------
|
102
|
+
// <Powerlevel::Set>
|
103
|
+
// Set the transmit power of a node for a specified time
|
104
|
+
//-----------------------------------------------------------------------------
|
105
|
+
void Powerlevel::Set
|
106
|
+
(
|
107
|
+
PowerLevelEnum _powerLevel,
|
108
|
+
uint8 _timeout
|
109
|
+
)
|
110
|
+
{
|
111
|
+
if( _powerLevel > PowerLevel_Minus9dB )
|
112
|
+
{
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Setting the power level to %s for %d seconds", c_powerLevelNames[_powerLevel], _timeout );
|
117
|
+
Msg* msg = new Msg( "PowerlevelCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
118
|
+
msg->Append( GetNodeId() );
|
119
|
+
msg->Append( 4 );
|
120
|
+
msg->Append( GetCommandClassId() );
|
121
|
+
msg->Append( PowerlevelCmd_Set );
|
122
|
+
msg->Append( (uint8)_powerLevel );
|
123
|
+
msg->Append( _timeout );
|
124
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
125
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
126
|
+
}
|
127
|
+
|
128
|
+
//-----------------------------------------------------------------------------
|
129
|
+
// <Powerlevel::Test>
|
130
|
+
// Test node to node communications
|
131
|
+
//-----------------------------------------------------------------------------
|
132
|
+
void Powerlevel::Test
|
133
|
+
(
|
134
|
+
uint8 _testNodeId,
|
135
|
+
PowerLevelEnum _powerLevel,
|
136
|
+
uint16 _numFrames
|
137
|
+
)
|
138
|
+
{
|
139
|
+
if( _powerLevel > PowerLevel_Minus9dB )
|
140
|
+
{
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
144
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Running a Power Level Test: Target Node = %d, Power Level = %s, Number of Frames = %d", _testNodeId, c_powerLevelNames[_powerLevel], _numFrames );
|
145
|
+
Msg* msg = new Msg( "PowerlevelCmd_TestNodeSet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
146
|
+
msg->Append( GetNodeId() );
|
147
|
+
msg->Append( 6 );
|
148
|
+
msg->Append( GetCommandClassId() );
|
149
|
+
msg->Append( PowerlevelCmd_TestNodeSet );
|
150
|
+
msg->Append( _testNodeId );
|
151
|
+
msg->Append( (uint8)_powerLevel );
|
152
|
+
msg->Append( (uint8)(_numFrames >> 8) );
|
153
|
+
msg->Append( (uint8)(_numFrames & 0x00ff) );
|
154
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
155
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
156
|
+
}
|
157
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Powerlevel.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_POWERLEVEL
|
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 _Powerlevel_H
|
29
|
+
#define _Powerlevel_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
/** \brief Implements COMMAND_CLASS_POWERLEVEL (0x73), a Z-Wave device command class.
|
36
|
+
*/
|
37
|
+
class Powerlevel: public CommandClass
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
enum PowerLevelEnum
|
41
|
+
{
|
42
|
+
PowerLevel_Normal = 0,
|
43
|
+
PowerLevel_Minus1dB,
|
44
|
+
PowerLevel_Minus2dB,
|
45
|
+
PowerLevel_Minus3dB,
|
46
|
+
PowerLevel_Minus4dB,
|
47
|
+
PowerLevel_Minus5dB,
|
48
|
+
PowerLevel_Minus6dB,
|
49
|
+
PowerLevel_Minus7dB,
|
50
|
+
PowerLevel_Minus8dB,
|
51
|
+
PowerLevel_Minus9dB
|
52
|
+
};
|
53
|
+
|
54
|
+
enum PowerLevelStatusEnum
|
55
|
+
{
|
56
|
+
PowerLevelStatus_Failed = 0,
|
57
|
+
PowerLevelStatus_Success,
|
58
|
+
PowerLevelStatus_InProgress
|
59
|
+
};
|
60
|
+
|
61
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Powerlevel( _homeId, _nodeId ); }
|
62
|
+
virtual ~Powerlevel(){}
|
63
|
+
|
64
|
+
static uint8 const StaticGetCommandClassId(){ return 0x73; }
|
65
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_POWERLEVEL"; }
|
66
|
+
|
67
|
+
void Set( PowerLevelEnum _powerLevel, uint8 _timeout );
|
68
|
+
void Test( uint8 _testNodeId, PowerLevelEnum _powerLevel, uint16 _numFrames );
|
69
|
+
|
70
|
+
// From CommandClass
|
71
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
72
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
73
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
74
|
+
|
75
|
+
private:
|
76
|
+
Powerlevel( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
77
|
+
};
|
78
|
+
|
79
|
+
} // namespace OpenZWave
|
80
|
+
|
81
|
+
#endif
|
82
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Proprietary.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_PROPRIETARY
|
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 "Proprietary.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Driver.h"
|
33
|
+
#include "Log.h"
|
34
|
+
|
35
|
+
using namespace OpenZWave;
|
36
|
+
|
37
|
+
enum ProprietaryCmd
|
38
|
+
{
|
39
|
+
ProprietaryCmd_Set = 0x01,
|
40
|
+
ProprietaryCmd_Get = 0x02,
|
41
|
+
ProprietaryCmd_Report = 0x03
|
42
|
+
};
|
43
|
+
|
44
|
+
|
45
|
+
//-----------------------------------------------------------------------------
|
46
|
+
// <Proprietary::HandleMsg>
|
47
|
+
// Handle a message from the Z-Wave network
|
48
|
+
//-----------------------------------------------------------------------------
|
49
|
+
bool Proprietary::HandleMsg
|
50
|
+
(
|
51
|
+
uint8 const* _data,
|
52
|
+
uint32 const _length,
|
53
|
+
uint32 const _instance // = 1
|
54
|
+
)
|
55
|
+
{
|
56
|
+
if (ProprietaryCmd_Report == (ProprietaryCmd)_data[0])
|
57
|
+
{
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Proprietary.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_PROPRIETARY
|
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 _Proprietary_H
|
29
|
+
#define _Proprietary_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
/** \brief Implements COMMAND_CLASS_PROPRIETARY (0x88), a Z-Wave device command class.
|
36
|
+
*/
|
37
|
+
class Proprietary: public CommandClass
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Proprietary( _homeId, _nodeId ); }
|
41
|
+
virtual ~Proprietary(){}
|
42
|
+
|
43
|
+
static uint8 const StaticGetCommandClassId(){ return 0x88; }
|
44
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_PROPRIETARY"; }
|
45
|
+
|
46
|
+
// From CommandClass
|
47
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
48
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
49
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
50
|
+
|
51
|
+
private:
|
52
|
+
Proprietary( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
53
|
+
};
|
54
|
+
|
55
|
+
} // namespace OpenZWave
|
56
|
+
|
57
|
+
#endif
|
58
|
+
|
@@ -0,0 +1,177 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Protection.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_PROTECTION
|
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 <vector>
|
29
|
+
|
30
|
+
#include "CommandClasses.h"
|
31
|
+
#include "Protection.h"
|
32
|
+
#include "Defs.h"
|
33
|
+
#include "Msg.h"
|
34
|
+
#include "Node.h"
|
35
|
+
#include "Driver.h"
|
36
|
+
#include "Log.h"
|
37
|
+
|
38
|
+
#include "ValueList.h"
|
39
|
+
|
40
|
+
using namespace OpenZWave;
|
41
|
+
|
42
|
+
enum ProtectionCmd
|
43
|
+
{
|
44
|
+
ProtectionCmd_Set = 0x01,
|
45
|
+
ProtectionCmd_Get = 0x02,
|
46
|
+
ProtectionCmd_Report = 0x03
|
47
|
+
};
|
48
|
+
|
49
|
+
static char const* c_protectionStateNames[] =
|
50
|
+
{
|
51
|
+
"Unprotected",
|
52
|
+
"Protection by Sequence",
|
53
|
+
"No Operation Possible"
|
54
|
+
};
|
55
|
+
|
56
|
+
//-----------------------------------------------------------------------------
|
57
|
+
// <Protection::RequestState>
|
58
|
+
// Request current state from the device
|
59
|
+
//-----------------------------------------------------------------------------
|
60
|
+
bool Protection::RequestState
|
61
|
+
(
|
62
|
+
uint32 const _requestFlags,
|
63
|
+
uint8 const _instance,
|
64
|
+
Driver::MsgQueue const _queue
|
65
|
+
)
|
66
|
+
{
|
67
|
+
if( _requestFlags & RequestFlag_Session )
|
68
|
+
{
|
69
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
70
|
+
}
|
71
|
+
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
//-----------------------------------------------------------------------------
|
76
|
+
// <Protection::RequestValue>
|
77
|
+
// Request current value from the device
|
78
|
+
//-----------------------------------------------------------------------------
|
79
|
+
bool Protection::RequestValue
|
80
|
+
(
|
81
|
+
uint32 const _requestFlags,
|
82
|
+
uint8 const _dummy1, // = 0 (not used)
|
83
|
+
uint8 const _instance,
|
84
|
+
Driver::MsgQueue const _queue
|
85
|
+
)
|
86
|
+
{
|
87
|
+
Msg* msg = new Msg( "ProtectionCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
88
|
+
msg->SetInstance( this, _instance );
|
89
|
+
msg->Append( GetNodeId() );
|
90
|
+
msg->Append( 2 );
|
91
|
+
msg->Append( GetCommandClassId() );
|
92
|
+
msg->Append( ProtectionCmd_Get );
|
93
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
94
|
+
GetDriver()->SendMsg( msg, _queue );
|
95
|
+
return true;
|
96
|
+
}
|
97
|
+
|
98
|
+
//-----------------------------------------------------------------------------
|
99
|
+
// <Protection::HandleMsg>
|
100
|
+
// Handle a message from the Z-Wave network
|
101
|
+
//-----------------------------------------------------------------------------
|
102
|
+
bool Protection::HandleMsg
|
103
|
+
(
|
104
|
+
uint8 const* _data,
|
105
|
+
uint32 const _length,
|
106
|
+
uint32 const _instance // = 1
|
107
|
+
)
|
108
|
+
{
|
109
|
+
if (ProtectionCmd_Report == (ProtectionCmd)_data[0])
|
110
|
+
{
|
111
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a Protection report: %s", c_protectionStateNames[_data[1]] );
|
112
|
+
if( ValueList* value = static_cast<ValueList*>( GetValue( _instance, 0 ) ) )
|
113
|
+
{
|
114
|
+
value->OnValueRefreshed( (int)_data[1] );
|
115
|
+
value->Release();
|
116
|
+
}
|
117
|
+
|
118
|
+
return true;
|
119
|
+
}
|
120
|
+
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
|
124
|
+
//-----------------------------------------------------------------------------
|
125
|
+
// <Protection::SetValue>
|
126
|
+
// Set the device's protection state
|
127
|
+
//-----------------------------------------------------------------------------
|
128
|
+
bool Protection::SetValue
|
129
|
+
(
|
130
|
+
Value const& _value
|
131
|
+
)
|
132
|
+
{
|
133
|
+
if( ValueID::ValueType_List == _value.GetID().GetType() )
|
134
|
+
{
|
135
|
+
ValueList const* value = static_cast<ValueList const*>(&_value);
|
136
|
+
ValueList::Item const& item = value->GetItem();
|
137
|
+
|
138
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Protection::Set - Setting protection state to '%s'", item.m_label.c_str() );
|
139
|
+
Msg* msg = new Msg( "Protection Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
140
|
+
msg->SetInstance( this, _value.GetID().GetInstance() );
|
141
|
+
msg->Append( GetNodeId() );
|
142
|
+
msg->Append( 3 );
|
143
|
+
msg->Append( GetCommandClassId() );
|
144
|
+
msg->Append( ProtectionCmd_Set );
|
145
|
+
msg->Append( (uint8)item.m_value );
|
146
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
147
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
|
154
|
+
//-----------------------------------------------------------------------------
|
155
|
+
// <Protection::CreateVars>
|
156
|
+
// Create the values managed by this command class
|
157
|
+
//-----------------------------------------------------------------------------
|
158
|
+
void Protection::CreateVars
|
159
|
+
(
|
160
|
+
uint8 const _instance
|
161
|
+
)
|
162
|
+
{
|
163
|
+
if( Node* node = GetNodeUnsafe() )
|
164
|
+
{
|
165
|
+
vector<ValueList::Item> items;
|
166
|
+
|
167
|
+
ValueList::Item item;
|
168
|
+
for( uint8 i=0; i<3; ++i )
|
169
|
+
{
|
170
|
+
item.m_label = c_protectionStateNames[i];
|
171
|
+
item.m_value = i;
|
172
|
+
items.push_back( item );
|
173
|
+
}
|
174
|
+
|
175
|
+
node->CreateValueList( ValueID::ValueGenre_System, GetCommandClassId(), _instance, 0, "Protection", "", false, false, 1, items, 0, 0 );
|
176
|
+
}
|
177
|
+
}
|