ansible4ozw 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/lib/ansible.rb +12 -9
  2. data/lib/ansible/ansible_device.rb +1 -1
  3. data/lib/ansible/ansible_value.rb +1 -1
  4. data/lib/ansible/config.rb +8 -5
  5. data/lib/ansible/devices.rb +1 -0
  6. data/lib/ansible/knx.rb +0 -0
  7. data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
  8. data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
  9. data/lib/ansible/transceiver.rb +0 -3
  10. data/lib/ansible/version.rb +3 -0
  11. data/lib/ansible/zwave.rb +1 -0
  12. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
  13. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
  14. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
  15. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
  16. data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
  17. data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
  18. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
  19. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
  20. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
  21. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
  22. data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
  23. data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
  24. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
  25. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
  26. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
  27. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
  28. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
  29. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
  30. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
  31. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
  32. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
  33. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
  34. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
  35. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
  36. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
  37. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
  38. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
  39. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
  40. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
  41. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
  42. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
  43. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
  44. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
  45. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
  46. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
  47. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
  48. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
  49. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
  50. data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
  51. data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
  52. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
  53. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
  54. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
  55. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
  56. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
  57. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
  58. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
  59. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
  60. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
  61. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
  62. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
  63. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
  64. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
  65. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
  66. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
  67. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
  68. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
  69. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
  70. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
  71. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
  72. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
  73. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
  74. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
  75. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
  76. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
  77. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
  78. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
  79. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
  80. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
  81. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
  82. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
  83. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
  84. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
  85. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
  86. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
  87. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
  88. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
  89. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
  90. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
  91. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
  92. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
  93. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
  94. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
  95. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
  96. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
  97. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
  98. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
  99. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
  100. data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
  101. data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
  102. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
  103. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
  104. data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
  105. data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
  106. data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
  107. data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
  108. data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
  109. data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
  110. data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
  111. data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
  112. data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
  113. data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
  114. data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
  115. data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
  116. data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
  117. data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
  118. data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
  119. data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
  120. data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
  121. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
  122. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
  123. data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
  124. data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
  125. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
  126. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
  127. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
  128. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
  129. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
  130. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
  131. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
  132. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
  133. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
  134. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
  135. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
  136. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
  137. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
  138. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
  139. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
  140. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
  141. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
  142. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
  143. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
  144. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
  145. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
  146. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
  147. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
  148. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
  149. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
  150. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
  151. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
  152. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
  153. data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
  154. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
  155. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
  156. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
  157. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
  158. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
  159. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
  160. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
  161. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
  162. data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
  163. data/lib/ansible/zwave/zwave_value.rb +6 -10
  164. metadata +159 -17
  165. data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,258 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Configuration.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CONFIGURATION
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 "Configuration.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Driver.h"
33
+ #include "Node.h"
34
+ #include "Log.h"
35
+ #include "ValueBool.h"
36
+ #include "ValueByte.h"
37
+ #include "ValueInt.h"
38
+ #include "ValueList.h"
39
+ #include "ValueShort.h"
40
+
41
+ using namespace OpenZWave;
42
+
43
+ enum ConfigurationCmd
44
+ {
45
+ ConfigurationCmd_Set = 0x04,
46
+ ConfigurationCmd_Get = 0x05,
47
+ ConfigurationCmd_Report = 0x06
48
+ };
49
+
50
+ //-----------------------------------------------------------------------------
51
+ // <Configuration::HandleMsg>
52
+ // Handle a message from the Z-Wave network
53
+ //-----------------------------------------------------------------------------
54
+ bool Configuration::HandleMsg
55
+ (
56
+ uint8 const* _data,
57
+ uint32 const _length,
58
+ uint32 const _instance // = 1
59
+ )
60
+ {
61
+ if (ConfigurationCmd_Report == (ConfigurationCmd)_data[0])
62
+ {
63
+ // Extract the parameter index and value
64
+ uint8 parameter = _data[1];
65
+ uint8 size = _data[2] & 0x07;
66
+ int32 paramValue = 0;
67
+ for( uint8 i=0; i<size; ++i )
68
+ {
69
+ paramValue <<= 8;
70
+ paramValue |= (int32)_data[i+3];
71
+ }
72
+
73
+ if ( Value* value = GetValue( 1, parameter ) )
74
+ {
75
+ switch ( value->GetID().GetType() )
76
+ {
77
+ case ValueID::ValueType_Bool:
78
+ {
79
+ ValueBool* valueBool = static_cast<ValueBool*>( value );
80
+ valueBool->OnValueRefreshed( paramValue != 0 );
81
+ break;
82
+ }
83
+ case ValueID::ValueType_Byte:
84
+ {
85
+ ValueByte* valueByte = static_cast<ValueByte*>( value );
86
+ valueByte->OnValueRefreshed( (uint8)paramValue );
87
+ break;
88
+ }
89
+ case ValueID::ValueType_Short:
90
+ {
91
+ ValueShort* valueShort = static_cast<ValueShort*>( value );
92
+ valueShort->OnValueRefreshed( (int16)paramValue );
93
+ break;
94
+ }
95
+ case ValueID::ValueType_Int:
96
+ {
97
+ ValueInt* valueInt = static_cast<ValueInt*>( value );
98
+ valueInt->OnValueRefreshed( paramValue );
99
+ break;
100
+ }
101
+ case ValueID::ValueType_List:
102
+ {
103
+ ValueList* valueList = static_cast<ValueList*>( value );
104
+ valueList->OnValueRefreshed( paramValue );
105
+ break;
106
+ }
107
+ default:
108
+ {
109
+ Log::Write( LogLevel_Info, GetNodeId(), "Invalid type (%d) for configuration parameter %d", value->GetID().GetType(), parameter );
110
+ }
111
+ }
112
+ value->Release();
113
+ }
114
+ else
115
+ {
116
+ char label[16];
117
+ snprintf( label, 16, "Parameter #%d", parameter );
118
+
119
+ // Create a new value
120
+ if( Node* node = GetNodeUnsafe() )
121
+ {
122
+ switch( size )
123
+ {
124
+ case 1:
125
+ {
126
+ node->CreateValueByte( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (uint8)paramValue, 0 );
127
+ break;
128
+ }
129
+ case 2:
130
+ {
131
+ node->CreateValueShort( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (int16)paramValue, 0 );
132
+ break;
133
+ }
134
+ case 4:
135
+ {
136
+ node->CreateValueInt( ValueID::ValueGenre_Config, GetCommandClassId(), _instance, parameter, label, "", false, false, (int32)paramValue, 0 );
137
+ break;
138
+ }
139
+ default:
140
+ {
141
+ Log::Write( LogLevel_Info, GetNodeId(), "Invalid size of %d bytes for configuration parameter %d", size, parameter );
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ Log::Write( LogLevel_Info, GetNodeId(), "Received Configuration report: Parameter=%d, Value=%d", parameter, paramValue );
148
+ return true;
149
+ }
150
+
151
+ return false;
152
+ }
153
+
154
+ //-----------------------------------------------------------------------------
155
+ // <Configuration::SetValue>
156
+ // Set a value in the Z-Wave device
157
+ //-----------------------------------------------------------------------------
158
+ bool Configuration::SetValue
159
+ (
160
+ Value const& _value
161
+ )
162
+ {
163
+ uint8 param = _value.GetID().GetIndex();
164
+ switch( _value.GetID().GetType() )
165
+ {
166
+ case ValueID::ValueType_Bool:
167
+ {
168
+ ValueBool const& valueBool = static_cast<ValueBool const&>( _value );
169
+ Set( param, (int32)valueBool.GetValue(), 1 );
170
+ return true;
171
+ }
172
+ case ValueID::ValueType_Byte:
173
+ {
174
+ ValueByte const& valueByte = static_cast<ValueByte const&>( _value );
175
+ Set( param, (int32)valueByte.GetValue(), 1 );
176
+ return true;
177
+ }
178
+ case ValueID::ValueType_Short:
179
+ {
180
+ ValueShort const& valueShort = static_cast<ValueShort const&>( _value );
181
+ Set( param, (int32)valueShort.GetValue(), 2 );
182
+ return true;
183
+ }
184
+ case ValueID::ValueType_Int:
185
+ {
186
+ ValueInt const& valueInt = static_cast<ValueInt const&>( _value );
187
+ Set( param, valueInt.GetValue(), 4 );
188
+ return true;
189
+ }
190
+ case ValueID::ValueType_List:
191
+ {
192
+ ValueList const& valueList = static_cast<ValueList const&>( _value );
193
+ Set( param, valueList.GetNewItem().m_value, valueList.GetSize() );
194
+ return true;
195
+ }
196
+ default:
197
+ {
198
+ }
199
+ }
200
+
201
+ Log::Write( LogLevel_Info, GetNodeId(), "Configuration::Set failed (bad value or value type) - Parameter=%d", param );
202
+ return false;
203
+ }
204
+
205
+ //-----------------------------------------------------------------------------
206
+ // <Configuration::RequestValue>
207
+ // Request current parameter value from the device
208
+ //-----------------------------------------------------------------------------
209
+ bool Configuration::RequestValue
210
+ (
211
+ uint32 const _requestFlags,
212
+ uint8 const _parameter // parameter number is encoded as the Index portion of ValueID
213
+ )
214
+ {
215
+ Msg* msg = new Msg( "ConfigurationCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
216
+ msg->Append( GetNodeId() );
217
+ msg->Append( 3 );
218
+ msg->Append( GetCommandClassId() );
219
+ msg->Append( ConfigurationCmd_Get );
220
+ msg->Append( _parameter );
221
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
222
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
223
+ return true;
224
+ }
225
+
226
+ //-----------------------------------------------------------------------------
227
+ // <Configuration::Set>
228
+ // Set the device's
229
+ //-----------------------------------------------------------------------------
230
+ void Configuration::Set
231
+ (
232
+ uint8 const _parameter,
233
+ int32 const _value,
234
+ uint8 const _size
235
+ )
236
+ {
237
+ Log::Write( LogLevel_Info, GetNodeId(), "Configuration::Set - Parameter=%d, Value=%d Size=%d", _parameter, _value, _size );
238
+
239
+ Msg* msg = new Msg( "ConfigurationCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
240
+ msg->Append( GetNodeId() );
241
+ msg->Append( 4 + _size );
242
+ msg->Append( GetCommandClassId() );
243
+ msg->Append( ConfigurationCmd_Set );
244
+ msg->Append( _parameter );
245
+ msg->Append( _size );
246
+ if( _size > 2 )
247
+ {
248
+ msg->Append( (uint8)(_value>>24) );
249
+ msg->Append( (uint8)(_value>>16) );
250
+ }
251
+ if( _size > 1 )
252
+ {
253
+ msg->Append( (uint8)(_value>>8) );
254
+ }
255
+ msg->Append( (uint8)_value );
256
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
257
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
258
+ }
@@ -0,0 +1,67 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Configuration.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CONFIGURATION
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 _Configuration_H
29
+ #define _Configuration_H
30
+
31
+ #include <list>
32
+ #include "CommandClass.h"
33
+
34
+ namespace OpenZWave
35
+ {
36
+ class Value;
37
+
38
+ /** \brief Implements COMMAND_CLASS_CONFIGURATION (x70), a Z-Wave device command class.
39
+ */
40
+ class Configuration: public CommandClass
41
+ {
42
+ friend class Node;
43
+
44
+ public:
45
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Configuration( _homeId, _nodeId ); }
46
+ virtual ~Configuration(){}
47
+
48
+ static uint8 const StaticGetCommandClassId(){ return 0x70; }
49
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CONFIGURATION"; }
50
+
51
+ bool RequestValue( uint32 const _requestFlags, uint8 const _parameter );
52
+ void Set( uint8 const _parameter, int32 const _value, uint8 const _size );
53
+
54
+ // From CommandClass
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
+ private:
61
+ Configuration( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
62
+ };
63
+
64
+ } // namespace OpenZWave
65
+
66
+ #endif
67
+
@@ -0,0 +1,142 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ControllerReplication.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CONTROLLER_REPLICATION
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 "ControllerReplication.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Driver.h"
33
+ #include "Node.h"
34
+ #include "Log.h"
35
+
36
+ using namespace OpenZWave;
37
+
38
+ //static enum ControllerReplicationCmd
39
+ //{
40
+ // CtrlReplicationTransferGroup = 0x31
41
+ // Sequence number: type=BYTE
42
+ // Group id: type=BYTE
43
+ // Node id: type=BYTE
44
+ // CtrlReplicationTransferGroupName = 0x32
45
+ // Sequence number: type=BYTE
46
+ // Group id: type=BYTE
47
+ // Group name: type=ARRAY
48
+ // CtrlReplicationTransferScene = 0x33
49
+ // Sequence number: type=BYTE
50
+ // Scene id: type=BYTE
51
+ // Node id: type=BYTE
52
+ // Level: type=BYTE
53
+ // CtrlReplicationTransferSceneName = 0x34
54
+ // Sequence number: type=BYTE
55
+ // Scene id: type=BYTE
56
+ // Scene name: type=ARRAY
57
+ //};
58
+
59
+ enum ControllerReplicationCmd
60
+ {
61
+ ControllerReplicationCmd_TransferGroup = 0x31,
62
+ ControllerReplicationCmd_TransferGroupName = 0x32,
63
+ ControllerReplicationCmd_TransferScene = 0x33,
64
+ ControllerReplicationCmd_TransferSceneName = 0x34
65
+ };
66
+
67
+
68
+ //-----------------------------------------------------------------------------
69
+ // <ControllerReplication::HandleMsg>
70
+ // Handle a message from the Z-Wave network
71
+ //-----------------------------------------------------------------------------
72
+ bool ControllerReplication::HandleMsg
73
+ (
74
+ uint8 const* _data,
75
+ uint32 const _length,
76
+ uint32 const _instance // = 1
77
+ )
78
+ {
79
+ // When creating replication messages, use FUNC_ID_ZW_SEND_REPLICATION_DATA instead of FUNC_ID_ZW_SEND_DATA
80
+ // e.g. Msg* msg = new Msg( "TransferGroup", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_REPLICATION_DATA, true, false );
81
+
82
+ switch( _data[0] )
83
+ {
84
+ case ControllerReplicationCmd_TransferGroup:
85
+ {
86
+ break;
87
+ }
88
+ case ControllerReplicationCmd_TransferGroupName:
89
+ {
90
+ break;
91
+ }
92
+ case ControllerReplicationCmd_TransferScene:
93
+ {
94
+ break;
95
+ }
96
+ case ControllerReplicationCmd_TransferSceneName:
97
+ {
98
+ break;
99
+ }
100
+ }
101
+
102
+ Msg* msg = new Msg( "ControllerReplication - Command Complete", GetNodeId(), REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false, false );
103
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
104
+ return true;
105
+ }
106
+
107
+ //-----------------------------------------------------------------------------
108
+ // <ControllerReplication::StartReplication>
109
+ // Set up the group and scene data to be sent to the other controller
110
+ //-----------------------------------------------------------------------------
111
+ void ControllerReplication::StartReplication
112
+ (
113
+ uint8 const _targetNodeId,
114
+ uint8 const _funcId
115
+ )
116
+ {
117
+ // Store the Z-Wave command we should use when replication has completed.
118
+ m_funcId = _funcId;
119
+
120
+ // Set up the groups and scenes to be sent
121
+ SendNextData( _targetNodeId );
122
+ }
123
+
124
+ //-----------------------------------------------------------------------------
125
+ // <ControllerReplication::SendNextData>
126
+ // Send the next block of replication data
127
+ //-----------------------------------------------------------------------------
128
+ void ControllerReplication::SendNextData
129
+ (
130
+ uint8 const _targetNodeId
131
+ )
132
+ {
133
+ // To do: Send scene and group data from the controller.
134
+ // It may well be that we never need to implement this - scenes will be handled
135
+ // by OpenZWave, not the Z-Wave scene classes, and PC controllers don't seem
136
+ // to hold any associations.
137
+
138
+ // For now, we stop the replication process.
139
+ Msg* msg = new Msg( "Replication Stop", 0xff, REQUEST, m_funcId, true );
140
+ msg->Append( ADD_NODE_STOP );
141
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
142
+ }