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,57 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// ApplicationStatus.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_APPLICATION_STATUS
|
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 _ApplicationStatus_H
|
29
|
+
#define _ApplicationStatus_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
/** \brief Implements COMMAND_CLASS_APPLICATION_STATUS (0x22), a Z-Wave device command class.
|
36
|
+
*/
|
37
|
+
class ApplicationStatus: public CommandClass
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ApplicationStatus( _homeId, _nodeId ); }
|
41
|
+
virtual ~ApplicationStatus(){}
|
42
|
+
|
43
|
+
static uint8 const StaticGetCommandClassId(){ return 0x22; }
|
44
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_APPLICATION_STATUS"; }
|
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
|
+
ApplicationStatus( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
53
|
+
};
|
54
|
+
|
55
|
+
} // namespace OpenZWave
|
56
|
+
|
57
|
+
#endif
|
@@ -0,0 +1,385 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Association.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_ASSOCIATION
|
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 "tinyxml.h"
|
29
|
+
#include "CommandClasses.h"
|
30
|
+
#include "Association.h"
|
31
|
+
#include "Defs.h"
|
32
|
+
#include "Msg.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Node.h"
|
35
|
+
#include "Group.h"
|
36
|
+
#include "Log.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum AssociationCmd
|
41
|
+
{
|
42
|
+
AssociationCmd_Set = 0x01,
|
43
|
+
AssociationCmd_Get = 0x02,
|
44
|
+
AssociationCmd_Report = 0x03,
|
45
|
+
AssociationCmd_Remove = 0x04,
|
46
|
+
AssociationCmd_GroupingsGet = 0x05,
|
47
|
+
AssociationCmd_GroupingsReport = 0x06
|
48
|
+
};
|
49
|
+
|
50
|
+
|
51
|
+
//-----------------------------------------------------------------------------
|
52
|
+
// <Association::Association>
|
53
|
+
// Constructor
|
54
|
+
//-----------------------------------------------------------------------------
|
55
|
+
Association::Association
|
56
|
+
(
|
57
|
+
uint32 const _homeId,
|
58
|
+
uint8 const _nodeId
|
59
|
+
):
|
60
|
+
CommandClass( _homeId, _nodeId ),
|
61
|
+
m_queryAll(false),
|
62
|
+
m_numGroups(0)
|
63
|
+
{
|
64
|
+
SetStaticRequest( StaticRequest_Values );
|
65
|
+
}
|
66
|
+
|
67
|
+
//-----------------------------------------------------------------------------
|
68
|
+
// <Association::ReadXML>
|
69
|
+
// Read the saved association data
|
70
|
+
//-----------------------------------------------------------------------------
|
71
|
+
void Association::ReadXML
|
72
|
+
(
|
73
|
+
TiXmlElement const* _ccElement
|
74
|
+
)
|
75
|
+
{
|
76
|
+
CommandClass::ReadXML( _ccElement );
|
77
|
+
|
78
|
+
if( Node* node = GetNodeUnsafe() )
|
79
|
+
{
|
80
|
+
TiXmlElement const* associationsElement = _ccElement->FirstChildElement();
|
81
|
+
while( associationsElement )
|
82
|
+
{
|
83
|
+
char const* str = associationsElement->Value();
|
84
|
+
if( str && !strcmp( str, "Associations" ) )
|
85
|
+
{
|
86
|
+
int intVal;
|
87
|
+
if( TIXML_SUCCESS == associationsElement->QueryIntAttribute( "num_groups", &intVal ) )
|
88
|
+
{
|
89
|
+
m_numGroups = (uint8)intVal;
|
90
|
+
}
|
91
|
+
|
92
|
+
TiXmlElement const* groupElement = associationsElement->FirstChildElement();
|
93
|
+
while( groupElement )
|
94
|
+
{
|
95
|
+
Group* group = new Group( GetHomeId(), GetNodeId(), groupElement );
|
96
|
+
node->AddGroup( group );
|
97
|
+
|
98
|
+
groupElement = groupElement->NextSiblingElement();
|
99
|
+
}
|
100
|
+
|
101
|
+
break;
|
102
|
+
}
|
103
|
+
|
104
|
+
associationsElement = associationsElement->NextSiblingElement();
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
//-----------------------------------------------------------------------------
|
110
|
+
// <Association::WriteXML>
|
111
|
+
// Save the association data
|
112
|
+
//-----------------------------------------------------------------------------
|
113
|
+
void Association::WriteXML
|
114
|
+
(
|
115
|
+
TiXmlElement* _ccElement
|
116
|
+
)
|
117
|
+
{
|
118
|
+
CommandClass::WriteXML( _ccElement );
|
119
|
+
|
120
|
+
if( Node* node = GetNodeUnsafe() )
|
121
|
+
{
|
122
|
+
TiXmlElement* associationsElement = new TiXmlElement( "Associations" );
|
123
|
+
|
124
|
+
char str[8];
|
125
|
+
snprintf( str, 8, "%d", m_numGroups );
|
126
|
+
associationsElement->SetAttribute( "num_groups", str );
|
127
|
+
|
128
|
+
_ccElement->LinkEndChild( associationsElement );
|
129
|
+
node->WriteGroups( associationsElement );
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
//-----------------------------------------------------------------------------
|
134
|
+
// <Association::RequestState>
|
135
|
+
// Nothing to do for Association
|
136
|
+
//-----------------------------------------------------------------------------
|
137
|
+
bool Association::RequestState
|
138
|
+
(
|
139
|
+
uint32 const _requestFlags,
|
140
|
+
uint8 const _instance,
|
141
|
+
Driver::MsgQueue const _queue
|
142
|
+
)
|
143
|
+
{
|
144
|
+
if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) )
|
145
|
+
{
|
146
|
+
// Request the supported group info
|
147
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
148
|
+
}
|
149
|
+
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
//-----------------------------------------------------------------------------
|
154
|
+
// <Association::RequestValue>
|
155
|
+
// Nothing to do for Association
|
156
|
+
//-----------------------------------------------------------------------------
|
157
|
+
bool Association::RequestValue
|
158
|
+
(
|
159
|
+
uint32 const _requestFlags,
|
160
|
+
uint8 const _dummy1, // = 0 (not used)
|
161
|
+
uint8 const _instance,
|
162
|
+
Driver::MsgQueue const _queue
|
163
|
+
)
|
164
|
+
{
|
165
|
+
if( _instance != 1 )
|
166
|
+
{
|
167
|
+
// This command class doesn't work with multiple instances
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
|
171
|
+
// Request the supported group info
|
172
|
+
Msg* msg = new Msg( "Get Association Groupings", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
173
|
+
msg->Append( GetNodeId() );
|
174
|
+
msg->Append( 2 );
|
175
|
+
msg->Append( GetCommandClassId() );
|
176
|
+
msg->Append( AssociationCmd_GroupingsGet );
|
177
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
178
|
+
GetDriver()->SendMsg( msg, _queue );
|
179
|
+
return true;
|
180
|
+
}
|
181
|
+
|
182
|
+
//-----------------------------------------------------------------------------
|
183
|
+
// <Association::RequestAllGroups>
|
184
|
+
// Request the contents of each group in turn
|
185
|
+
//-----------------------------------------------------------------------------
|
186
|
+
void Association::RequestAllGroups
|
187
|
+
(
|
188
|
+
uint32 const _requestFlags
|
189
|
+
)
|
190
|
+
{
|
191
|
+
m_queryAll = true;
|
192
|
+
|
193
|
+
// Request the contents of the individual groups in turn.
|
194
|
+
if( m_numGroups == 0xff )
|
195
|
+
{
|
196
|
+
// We start with group 255, and will then move to group 1, 2 etc and stop when we find a group with a maxAssociations of zero.
|
197
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is 255, which requires special case handling.", GetNodeId() );
|
198
|
+
QueryGroup( 0xff, _requestFlags );
|
199
|
+
}
|
200
|
+
else
|
201
|
+
{
|
202
|
+
// We start with group 1, and will then move to group 2, 3 etc and stop when the group index is greater than m_numGroups.
|
203
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is %d.", GetNodeId(), m_numGroups );
|
204
|
+
QueryGroup( 1, _requestFlags );
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
//-----------------------------------------------------------------------------
|
209
|
+
// <Association::HandleMsg>
|
210
|
+
// Handle a message from the Z-Wave network
|
211
|
+
//-----------------------------------------------------------------------------
|
212
|
+
bool Association::HandleMsg
|
213
|
+
(
|
214
|
+
uint8 const* _data,
|
215
|
+
uint32 const _length,
|
216
|
+
uint32 const _instance // = 1
|
217
|
+
)
|
218
|
+
{
|
219
|
+
bool handled = false;
|
220
|
+
uint32 i;
|
221
|
+
|
222
|
+
if( Node* node = GetNodeUnsafe() )
|
223
|
+
{
|
224
|
+
if( AssociationCmd_GroupingsReport == (AssociationCmd)_data[0] )
|
225
|
+
{
|
226
|
+
// Retrieve the number of groups this device supports.
|
227
|
+
// The groups will be queried with the session data.
|
228
|
+
m_numGroups = _data[1];
|
229
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Association Groupings report from node %d. Number of groups is %d", GetNodeId(), m_numGroups );
|
230
|
+
ClearStaticRequest( StaticRequest_Values );
|
231
|
+
handled = true;
|
232
|
+
}
|
233
|
+
else if( AssociationCmd_Report == (AssociationCmd)_data[0] )
|
234
|
+
{
|
235
|
+
// Get the group info
|
236
|
+
uint8 groupIdx = _data[1];
|
237
|
+
uint8 maxAssociations = _data[2]; // If the maxAssociations is zero, this is not a supported group.
|
238
|
+
uint8 numReportsToFollow = _data[3]; // If a device supports a lot of associations, they may come in more than one message.
|
239
|
+
|
240
|
+
if( maxAssociations )
|
241
|
+
{
|
242
|
+
if( _length >= 5 )
|
243
|
+
{
|
244
|
+
uint8 numAssociations = _length - 5;
|
245
|
+
|
246
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received Association report from node %d, group %d, containing %d associations", GetNodeId(), groupIdx, numAssociations );
|
247
|
+
if( numAssociations )
|
248
|
+
{
|
249
|
+
Log::Write( LogLevel_Info, GetNodeId(), " The group contains:" );
|
250
|
+
for( i=0; i<numAssociations; ++i )
|
251
|
+
{
|
252
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Node %d", _data[i+4] );
|
253
|
+
m_pendingMembers.push_back( _data[i+4] );
|
254
|
+
}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
if( numReportsToFollow )
|
259
|
+
{
|
260
|
+
// We're expecting more reports for this group
|
261
|
+
Log::Write( LogLevel_Info, GetNodeId(), "%d more association reports expected for node %d, group %d", numReportsToFollow, GetNodeId(), groupIdx );
|
262
|
+
return true;
|
263
|
+
}
|
264
|
+
else
|
265
|
+
{
|
266
|
+
// No more reports to come for this group, so we can apply the pending list
|
267
|
+
Group* group = node->GetGroup( groupIdx );
|
268
|
+
if( NULL == group )
|
269
|
+
{
|
270
|
+
// Group has not been created yet
|
271
|
+
group = new Group( GetHomeId(), GetNodeId(), groupIdx, maxAssociations );
|
272
|
+
node->AddGroup( group );
|
273
|
+
}
|
274
|
+
|
275
|
+
// Update the group with its new contents
|
276
|
+
group->OnGroupChanged( m_pendingMembers );
|
277
|
+
m_pendingMembers.clear();
|
278
|
+
}
|
279
|
+
}
|
280
|
+
else
|
281
|
+
{
|
282
|
+
// maxAssociations is zero, so we've reached the end of the query process
|
283
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Max associations for node %d, group %d is zero. Querying associations for this node is complete.", GetNodeId(), groupIdx );
|
284
|
+
node->AutoAssociate();
|
285
|
+
m_queryAll = false;
|
286
|
+
}
|
287
|
+
|
288
|
+
if( m_queryAll )
|
289
|
+
{
|
290
|
+
// Work out which is the next group we will query.
|
291
|
+
// If we are currently on group 255, the next group will be 1.
|
292
|
+
uint8 nextGroup = groupIdx + 1;
|
293
|
+
if( !nextGroup )
|
294
|
+
{
|
295
|
+
nextGroup = 1;
|
296
|
+
}
|
297
|
+
|
298
|
+
if( nextGroup <= m_numGroups )
|
299
|
+
{
|
300
|
+
// Query the next group
|
301
|
+
QueryGroup( nextGroup, RequestFlag_LowPriority );
|
302
|
+
}
|
303
|
+
else
|
304
|
+
{
|
305
|
+
// We're all done
|
306
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Querying associations for node %d is complete.", GetNodeId() );
|
307
|
+
node->AutoAssociate();
|
308
|
+
m_queryAll = false;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
handled = true;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
return handled;
|
317
|
+
}
|
318
|
+
|
319
|
+
//-----------------------------------------------------------------------------
|
320
|
+
// <Association::QueryGroup>
|
321
|
+
// Request details of an association group
|
322
|
+
//-----------------------------------------------------------------------------
|
323
|
+
void Association::QueryGroup
|
324
|
+
(
|
325
|
+
uint8 _groupIdx,
|
326
|
+
uint32 const _requestFlags
|
327
|
+
)
|
328
|
+
{
|
329
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Get Associations for group %d of node %d", _groupIdx, GetNodeId() );
|
330
|
+
Msg* msg = new Msg( "Get Associations", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
331
|
+
msg->Append( GetNodeId() );
|
332
|
+
msg->Append( 3 );
|
333
|
+
msg->Append( GetCommandClassId() );
|
334
|
+
msg->Append( AssociationCmd_Get );
|
335
|
+
msg->Append( _groupIdx );
|
336
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
337
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
338
|
+
}
|
339
|
+
|
340
|
+
//-----------------------------------------------------------------------------
|
341
|
+
// <Association::Set>
|
342
|
+
// Add an association between devices
|
343
|
+
//-----------------------------------------------------------------------------
|
344
|
+
void Association::Set
|
345
|
+
(
|
346
|
+
uint8 _groupIdx,
|
347
|
+
uint8 _targetNodeId
|
348
|
+
)
|
349
|
+
{
|
350
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Association::Set - Adding node %d to group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() );
|
351
|
+
|
352
|
+
Msg* msg = new Msg( "Association Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
353
|
+
msg->Append( GetNodeId() );
|
354
|
+
msg->Append( 4 );
|
355
|
+
msg->Append( GetCommandClassId() );
|
356
|
+
msg->Append( AssociationCmd_Set );
|
357
|
+
msg->Append( _groupIdx );
|
358
|
+
msg->Append( _targetNodeId );
|
359
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
360
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
361
|
+
}
|
362
|
+
|
363
|
+
//-----------------------------------------------------------------------------
|
364
|
+
// <Association::Remove>
|
365
|
+
// Remove an association between devices
|
366
|
+
//-----------------------------------------------------------------------------
|
367
|
+
void Association::Remove
|
368
|
+
(
|
369
|
+
uint8 _groupIdx,
|
370
|
+
uint8 _targetNodeId
|
371
|
+
)
|
372
|
+
{
|
373
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Association::Remove - Removing node %d from group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() );
|
374
|
+
|
375
|
+
Msg* msg = new Msg( "Association Remove", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
|
376
|
+
msg->Append( GetNodeId() );
|
377
|
+
msg->Append( 4 );
|
378
|
+
msg->Append( GetCommandClassId() );
|
379
|
+
msg->Append( AssociationCmd_Remove );
|
380
|
+
msg->Append( _groupIdx );
|
381
|
+
msg->Append( _targetNodeId );
|
382
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
383
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
384
|
+
}
|
385
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Association.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_ASSOCIATION
|
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 _Association_H
|
29
|
+
#define _Association_H
|
30
|
+
|
31
|
+
#include <vector>
|
32
|
+
#include "CommandClass.h"
|
33
|
+
|
34
|
+
namespace OpenZWave
|
35
|
+
{
|
36
|
+
/** \brief Implements COMMAND_CLASS_ASSOCIATION (0x85), a Z-Wave device command class.
|
37
|
+
*/
|
38
|
+
class Association: public CommandClass
|
39
|
+
{
|
40
|
+
public:
|
41
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Association( _homeId, _nodeId ); }
|
42
|
+
virtual ~Association(){}
|
43
|
+
|
44
|
+
static uint8 const StaticGetCommandClassId(){ return 0x85; }
|
45
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_ASSOCIATION"; }
|
46
|
+
|
47
|
+
// From CommandClass
|
48
|
+
virtual void ReadXML( TiXmlElement const* _ccElement );
|
49
|
+
virtual void WriteXML( TiXmlElement* _ccElement );
|
50
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
51
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
52
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
53
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
54
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
55
|
+
|
56
|
+
void RequestAllGroups( uint32 const _requestFlags );
|
57
|
+
void Set( uint8 const _group, uint8 const _nodeId );
|
58
|
+
void Remove( uint8 const _group, uint8 const _nodeId );
|
59
|
+
|
60
|
+
private:
|
61
|
+
Association( uint32 const _homeId, uint8 const _nodeId );
|
62
|
+
void QueryGroup( uint8 _groupIdx, uint32 const _requestFlags );
|
63
|
+
void AutoAssociate();
|
64
|
+
|
65
|
+
bool m_queryAll; // When true, once a group has been queried, we request the next one.
|
66
|
+
uint8 m_numGroups; // Number of groups supported by the device. 255 is reported by certain manufacturers and requires special handling.
|
67
|
+
vector<uint8> m_pendingMembers; // Used to build a list of group members from multiple reports
|
68
|
+
};
|
69
|
+
|
70
|
+
} // namespace OpenZWave
|
71
|
+
|
72
|
+
#endif
|
73
|
+
|