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,277 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // AssociationCommandConfiguration.cpp
4
+ //
5
+ // Implementation of the COMMAND_CLASS_ASSOCIATION_COMMAND_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 "AssociationCommandConfiguration.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Group.h"
34
+ #include "Driver.h"
35
+ #include "Log.h"
36
+ #include "ValueBool.h"
37
+ #include "ValueByte.h"
38
+ #include "ValueShort.h"
39
+
40
+ using namespace OpenZWave;
41
+
42
+ enum AssociationCommandConfigurationCmd
43
+ {
44
+ AssociationCommandConfigurationCmd_SupportedRecordsGet = 0x01,
45
+ AssociationCommandConfigurationCmd_SupportedRecordsReport = 0x02,
46
+ AssociationCommandConfigurationCmd_Set = 0x03,
47
+ AssociationCommandConfigurationCmd_Get = 0x04,
48
+ AssociationCommandConfigurationCmd_Report = 0x05
49
+ };
50
+
51
+ enum
52
+ {
53
+ AssociationCommandConfigurationIndex_MaxCommandLength = 0,
54
+ AssociationCommandConfigurationIndex_CommandsAreValues,
55
+ AssociationCommandConfigurationIndex_CommandsAreConfigurable,
56
+ AssociationCommandConfigurationIndex_NumFreeCommands,
57
+ AssociationCommandConfigurationIndex_MaxCommands
58
+ };
59
+
60
+
61
+ //-----------------------------------------------------------------------------
62
+ // <AssociationCommandConfiguration::RequestState>
63
+ // Request current state from the device
64
+ //-----------------------------------------------------------------------------
65
+ bool AssociationCommandConfiguration::RequestState
66
+ (
67
+ uint32 const _requestFlags,
68
+ uint8 const _instance,
69
+ Driver::MsgQueue const _queue
70
+ )
71
+ {
72
+ if( _requestFlags & RequestFlag_Session )
73
+ {
74
+ return RequestValue( _requestFlags, 0, _instance, _queue );
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
+ //-----------------------------------------------------------------------------
81
+ // <AssociationCommandConfiguration::RequestValue>
82
+ // Request current value from the device
83
+ //-----------------------------------------------------------------------------
84
+ bool AssociationCommandConfiguration::RequestValue
85
+ (
86
+ uint32 const _requestFlags,
87
+ uint8 const _dummy1, // = 0 (not used)
88
+ uint8 const _instance,
89
+ Driver::MsgQueue const _queue
90
+ )
91
+ {
92
+ if( _instance != 1 )
93
+ {
94
+ // This command class doesn't work with multiple instances
95
+ return false;
96
+ }
97
+
98
+ Msg* msg = new Msg( "AssociationCommandConfigurationCmd_SupportedRecordsGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
99
+ msg->Append( GetNodeId() );
100
+ msg->Append( 2 );
101
+ msg->Append( GetCommandClassId() );
102
+ msg->Append( AssociationCommandConfigurationCmd_SupportedRecordsGet );
103
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
104
+ GetDriver()->SendMsg( msg, _queue );
105
+ return true;
106
+ }
107
+
108
+ //-----------------------------------------------------------------------------
109
+ // <AssociationCommandConfiguration::RequestCommands>
110
+ // Request the command data
111
+ //-----------------------------------------------------------------------------
112
+ void AssociationCommandConfiguration::RequestCommands
113
+ (
114
+ uint8 const _groupIdx,
115
+ uint8 const _nodeId
116
+ )
117
+ {
118
+ Msg* msg = new Msg( "AssociationCommandConfigurationCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
119
+ msg->Append( GetNodeId() );
120
+ msg->Append( 4 );
121
+ msg->Append( GetCommandClassId() );
122
+ msg->Append( AssociationCommandConfigurationCmd_Get );
123
+ msg->Append( _groupIdx );
124
+ msg->Append( _nodeId );
125
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
126
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
127
+ }
128
+
129
+ //-----------------------------------------------------------------------------
130
+ // <AssociationCommandConfiguration::HandleMsg>
131
+ // Handle a message from the Z-Wave network
132
+ //-----------------------------------------------------------------------------
133
+ bool AssociationCommandConfiguration::HandleMsg
134
+ (
135
+ uint8 const* _data,
136
+ uint32 const _length,
137
+ uint32 const _instance // = 1
138
+ )
139
+ {
140
+ if (AssociationCommandConfigurationCmd_SupportedRecordsReport == (AssociationCommandConfigurationCmd)_data[0])
141
+ {
142
+ uint8 maxCommandLength = _data[1] >> 2;
143
+ bool commandsAreValues = ( (_data[1] & 0x02) != 0 );
144
+ bool commandsAreConfigurable = ( (_data[1] & 0x01) != 0 );
145
+ int16 numFreeCommands = (((int16)_data[2])<<16) | (int16)_data[3];
146
+ int16 maxCommands = (((int16)_data[4])<<16) | (int16)_data[5];
147
+
148
+ Log::Write( LogLevel_Info, GetNodeId(), "Received AssociationCommandConfiguration Supported Records Report:" );
149
+ Log::Write( LogLevel_Info, GetNodeId(), " Maximum command length = %d bytes", maxCommandLength );
150
+ Log::Write( LogLevel_Info, GetNodeId(), " Maximum number of commands = %d", maxCommands );
151
+ Log::Write( LogLevel_Info, GetNodeId(), " Number of free commands = %d", numFreeCommands );
152
+ Log::Write( LogLevel_Info, GetNodeId(), " Commands are %s and are %s", commandsAreValues ? "values" : "not values", commandsAreConfigurable ? "configurable" : "not configurable" );
153
+
154
+ ValueBool* valueBool;
155
+ ValueByte* valueByte;
156
+ ValueShort* valueShort;
157
+
158
+ if( (valueByte = static_cast<ValueByte*>( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommandLength ) )) )
159
+ {
160
+ valueByte->OnValueRefreshed( maxCommandLength );
161
+ valueByte->Release();
162
+ }
163
+
164
+ if( (valueBool = static_cast<ValueBool*>( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreValues ) )) )
165
+ {
166
+ valueBool->OnValueRefreshed( commandsAreValues );
167
+ valueBool->Release();
168
+ }
169
+
170
+ if( (valueBool = static_cast<ValueBool*>( GetValue( _instance, AssociationCommandConfigurationIndex_CommandsAreConfigurable ) )) )
171
+ {
172
+ valueBool->OnValueRefreshed( commandsAreConfigurable );
173
+ valueBool->Release();
174
+ }
175
+
176
+ if( (valueShort = static_cast<ValueShort*>( GetValue( _instance, AssociationCommandConfigurationIndex_NumFreeCommands ) )) )
177
+ {
178
+ valueShort->OnValueRefreshed( numFreeCommands );
179
+ valueShort->Release();
180
+ }
181
+
182
+ if( (valueShort = static_cast<ValueShort*>( GetValue( _instance, AssociationCommandConfigurationIndex_MaxCommands ) )) )
183
+ {
184
+ valueShort->OnValueRefreshed( maxCommands );
185
+ valueShort->Release();
186
+ }
187
+ return true;
188
+ }
189
+
190
+ if (AssociationCommandConfigurationCmd_Report == (AssociationCommandConfigurationCmd)_data[0])
191
+ {
192
+ uint8 groupIdx = _data[1];
193
+ uint8 nodeIdx = _data[2];
194
+ bool firstReports = ( ( _data[3] & 0x80 ) != 0 ); // True if this is the first message containing commands for this group and node.
195
+ uint8 numReports = _data[3] & 0x0f;
196
+
197
+ Log::Write( LogLevel_Info, GetNodeId(), "Received AssociationCommandConfiguration Report from:" );
198
+ Log::Write( LogLevel_Info, GetNodeId(), " Commands for node %d in group %d,", nodeIdx, groupIdx );
199
+
200
+ if( Node* node = GetNodeUnsafe() )
201
+ {
202
+ Group* group = node->GetGroup( groupIdx );
203
+ if( NULL == group )
204
+ {
205
+ if( firstReports )
206
+ {
207
+ // This is the first report message, so we should clear any existing command data
208
+ group->ClearCommands( nodeIdx );
209
+ }
210
+
211
+ uint8 const* start = &_data[4];
212
+
213
+ for( uint8 i=0; i<numReports; ++i )
214
+ {
215
+ uint8 length = start[0];
216
+ group->AddCommand( nodeIdx, length, start+1 );
217
+ start += length;
218
+ }
219
+ }
220
+ }
221
+
222
+ return true;
223
+ }
224
+ return false;
225
+ }
226
+
227
+ //-----------------------------------------------------------------------------
228
+ // <AssociationCommandConfiguration::CreateVars>
229
+ // Create the values managed by this command class
230
+ //-----------------------------------------------------------------------------
231
+ void AssociationCommandConfiguration::CreateVars
232
+ (
233
+ uint8 const _instance
234
+ )
235
+ {
236
+ if( Node* node = GetNodeUnsafe() )
237
+ {
238
+ node->CreateValueByte ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_MaxCommandLength, "Max Command Length", "", true, false, 0, 0 );
239
+ node->CreateValueBool ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_CommandsAreValues, "Commands are Values", "", true, false, false, 0 );
240
+ node->CreateValueBool ( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_CommandsAreConfigurable, "Commands are Configurable", "", true, false, false, 0 );
241
+ node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_NumFreeCommands, "Free Commands", "", true, false, 0, 0 );
242
+ node->CreateValueShort( ValueID::ValueGenre_System, GetCommandClassId(), _instance, AssociationCommandConfigurationIndex_MaxCommands, "Max Commands", "", true, false, 0, 0 );
243
+ }
244
+ }
245
+
246
+ //-----------------------------------------------------------------------------
247
+ // <AssociationCommandConfiguration::SetCommand>
248
+ // Set a command for the association
249
+ //-----------------------------------------------------------------------------
250
+ void AssociationCommandConfiguration::SetCommand
251
+ (
252
+ uint8 const _groupIdx,
253
+ uint8 const _nodeId,
254
+ uint8 const _length,
255
+ uint8 const* _data
256
+ )
257
+ {
258
+ Msg* msg = new Msg( "AssociationCommandConfigurationCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
259
+ msg->Append( GetNodeId() );
260
+ msg->Append( _length + 5 );
261
+ msg->Append( GetCommandClassId() );
262
+ msg->Append( AssociationCommandConfigurationCmd_Set );
263
+ msg->Append( _groupIdx );
264
+ msg->Append( _nodeId );
265
+ msg->Append( _length );
266
+
267
+ for( uint8 i=0; i<_length; ++i )
268
+ {
269
+ msg->Append( _data[i] );
270
+ }
271
+
272
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
273
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
274
+ }
275
+
276
+
277
+
@@ -0,0 +1,70 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // AssociationCommandConfiguration.h
4
+ //
5
+ // Implementation of the COMMAND_CLASS_ASSOCIATION_COMMAND_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 _AssociationCommandConfiguration_H
29
+ #define _AssociationCommandConfiguration_H
30
+
31
+ #include "CommandClass.h"
32
+ #include "ValueBool.h"
33
+ #include "ValueByte.h"
34
+ #include "ValueShort.h"
35
+
36
+
37
+ namespace OpenZWave
38
+ {
39
+ /** \brief Implements COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION (0x9b), a Z-Wave device command class.
40
+ */
41
+
42
+ class AssociationCommandConfiguration: public CommandClass
43
+ {
44
+ public:
45
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new AssociationCommandConfiguration( _homeId, _nodeId ); }
46
+ virtual ~AssociationCommandConfiguration(){}
47
+
48
+ static uint8 const StaticGetCommandClassId(){ return 0x9b; }
49
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION"; }
50
+
51
+ void RequestCommands( uint8 const _groupIdx, uint8 const _nodeId );
52
+ void SetCommand( uint8 const _groupIdx, uint8 const _nodeId, uint8 const _length, uint8 const* _data );
53
+
54
+ // From CommandClass
55
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
56
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
57
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
58
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
59
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
60
+
61
+ protected:
62
+ virtual void CreateVars( uint8 const _instance );
63
+
64
+ private:
65
+ AssociationCommandConfiguration( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
66
+ };
67
+
68
+ } // namespace OpenZWave
69
+
70
+ #endif
@@ -0,0 +1,212 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Basic.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_BASIC
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 "Basic.h"
30
+ #include "Association.h"
31
+ #include "Defs.h"
32
+ #include "Msg.h"
33
+ #include "Node.h"
34
+ #include "Driver.h"
35
+ #include "Notification.h"
36
+ #include "Log.h"
37
+
38
+ #include "ValueByte.h"
39
+
40
+ using namespace OpenZWave;
41
+
42
+ enum BasicCmd
43
+ {
44
+ BasicCmd_Set = 0x01,
45
+ BasicCmd_Get = 0x02,
46
+ BasicCmd_Report = 0x03
47
+ };
48
+
49
+ //-----------------------------------------------------------------------------
50
+ // <Basic::RequestState>
51
+ // Request current state from the device
52
+ //-----------------------------------------------------------------------------
53
+ bool Basic::RequestState
54
+ (
55
+ uint32 const _requestFlags,
56
+ uint8 const _instance,
57
+ Driver::MsgQueue const _queue
58
+ )
59
+ {
60
+ if( _requestFlags & RequestFlag_Dynamic )
61
+ {
62
+ return RequestValue( _requestFlags, 0, _instance, _queue );
63
+ }
64
+ return false;
65
+ }
66
+
67
+ //-----------------------------------------------------------------------------
68
+ // <Basic::RequestValue>
69
+ // Request current state from the device
70
+ //-----------------------------------------------------------------------------
71
+ bool Basic::RequestValue
72
+ (
73
+ uint32 const _requestFlags,
74
+ uint8 const _dummy1, // = 0 (not used)
75
+ uint8 const _instance,
76
+ Driver::MsgQueue const _queue
77
+ )
78
+ {
79
+ Msg* msg = new Msg( "BasicCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
80
+ msg->SetInstance( this, _instance );
81
+ msg->Append( GetNodeId() );
82
+ msg->Append( 2 );
83
+ msg->Append( GetCommandClassId() );
84
+ msg->Append( BasicCmd_Get );
85
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
86
+ GetDriver()->SendMsg( msg, _queue );
87
+ return true;
88
+ }
89
+
90
+ //-----------------------------------------------------------------------------
91
+ // <Basic::HandleMsg>
92
+ // Handle a message from the Z-Wave network
93
+ //-----------------------------------------------------------------------------
94
+ bool Basic::HandleMsg
95
+ (
96
+ uint8 const* _data,
97
+ uint32 const _length,
98
+ uint32 const _instance // = 1
99
+ )
100
+ {
101
+ if( BasicCmd_Report == (BasicCmd)_data[0] )
102
+ {
103
+ // Level
104
+ Log::Write( LogLevel_Info, GetNodeId(), "Received Basic report from node %d: level=%d", GetNodeId(), _data[1] );
105
+ if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
106
+ {
107
+ value->OnValueRefreshed( _data[1] );
108
+ value->Release();
109
+ }
110
+ return true;
111
+ }
112
+
113
+ if( BasicCmd_Set == (BasicCmd)_data[0] )
114
+ {
115
+ // Commmand received from the node. Handle as a notifcation event
116
+ Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Sending event notification.", GetNodeId(), _data[1] );
117
+
118
+ Notification* notification = new Notification( Notification::Type_NodeEvent );
119
+ notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() );
120
+ notification->SetEvent( _data[1] );
121
+ GetDriver()->QueueNotification( notification );
122
+ return true;
123
+ }
124
+
125
+ return false;
126
+ }
127
+
128
+ //-----------------------------------------------------------------------------
129
+ // <Basic::SetValue>
130
+ // Set a value on the Z-Wave device
131
+ //-----------------------------------------------------------------------------
132
+ bool Basic::SetValue
133
+ (
134
+ Value const& _value
135
+ )
136
+ {
137
+ if( ValueID::ValueType_Byte == _value.GetID().GetType() )
138
+ {
139
+ ValueByte const* value = static_cast<ValueByte const*>(&_value);
140
+
141
+ Log::Write( LogLevel_Info, GetNodeId(), "Basic::Set - Setting node %d to level %d", GetNodeId(), value->GetValue() );
142
+ Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
143
+ msg->SetInstance( this, _value.GetID().GetInstance() );
144
+ msg->Append( GetNodeId() );
145
+ msg->Append( 3 );
146
+ msg->Append( GetCommandClassId() );
147
+ msg->Append( BasicCmd_Set );
148
+ msg->Append( value->GetValue() );
149
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
150
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
151
+ return true;
152
+ }
153
+
154
+ return false;
155
+ }
156
+
157
+ //-----------------------------------------------------------------------------
158
+ // <Basic::CreateVars>
159
+ // Create the values managed by this command class
160
+ //-----------------------------------------------------------------------------
161
+ void Basic::CreateVars
162
+ (
163
+ uint8 const _instance
164
+ )
165
+ {
166
+ if( Node* node = GetNodeUnsafe() )
167
+ {
168
+ node->CreateValueByte( ValueID::ValueGenre_Basic, GetCommandClassId(), _instance, 0, "Basic", "", false, false, 0, 0 );
169
+ }
170
+ }
171
+
172
+ //-----------------------------------------------------------------------------
173
+ // <Basic::Set>
174
+ // Helper method to set the level
175
+ //-----------------------------------------------------------------------------
176
+ void Basic::Set
177
+ (
178
+ uint8 const _level
179
+ )
180
+ {
181
+ // This may look like a long winded way to do this, but
182
+ // it ensures that all the proper notifications get sent.
183
+ if( ValueByte* value = static_cast<ValueByte*>( GetValue( 1, 0 ) ) )
184
+ {
185
+ value->Set( _level );
186
+ value->Release();
187
+ }
188
+ }
189
+
190
+ //-----------------------------------------------------------------------------
191
+ // <Basic::SetMapping>
192
+ // Map COMMAND_CLASS_BASIC messages to another command class
193
+ //-----------------------------------------------------------------------------
194
+ bool Basic::SetMapping
195
+ (
196
+ uint8 const _commandClassId
197
+ )
198
+ {
199
+ bool res = false;
200
+
201
+ if( Node const* node = GetNodeUnsafe() )
202
+ {
203
+ if( CommandClass* cc = node->GetCommandClass( _commandClassId ) )
204
+ {
205
+ Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will be mapped to %s", cc->GetCommandClassName().c_str() );
206
+ m_mapping = _commandClassId;
207
+ res = true;
208
+ }
209
+ }
210
+
211
+ return res;
212
+ }