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,73 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// Meter.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_METER
|
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 _Meter_H
|
29
|
+
#define _Meter_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueDecimal;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_METER (0x32), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class Meter: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Meter( _homeId, _nodeId ); }
|
43
|
+
virtual ~Meter(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x32; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_METER"; }
|
47
|
+
|
48
|
+
// From CommandClass
|
49
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
50
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
51
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
52
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
53
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
54
|
+
virtual bool SetValue( Value const& _value );
|
55
|
+
virtual uint8 GetMaxVersion(){ return 3; }
|
56
|
+
|
57
|
+
protected:
|
58
|
+
virtual void CreateVars( uint8 const _instance );
|
59
|
+
|
60
|
+
private:
|
61
|
+
Meter( uint32 const _homeId, uint8 const _nodeId );
|
62
|
+
|
63
|
+
bool HandleSupportedReport( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
64
|
+
bool HandleReport( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
65
|
+
|
66
|
+
uint32 m_scale;
|
67
|
+
};
|
68
|
+
|
69
|
+
} // namespace OpenZWave
|
70
|
+
|
71
|
+
|
72
|
+
#endif
|
73
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// MeterPulse.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_METER_PULSE
|
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 "MeterPulse.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Node.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueInt.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum MeterPulseCmd
|
41
|
+
{
|
42
|
+
MeterPulseCmd_Get = 0x04,
|
43
|
+
MeterPulseCmd_Report = 0x05
|
44
|
+
};
|
45
|
+
|
46
|
+
//-----------------------------------------------------------------------------
|
47
|
+
// <MeterPulse::RequestState>
|
48
|
+
// Request current state from the device
|
49
|
+
//-----------------------------------------------------------------------------
|
50
|
+
bool MeterPulse::RequestState
|
51
|
+
(
|
52
|
+
uint32 const _requestFlags,
|
53
|
+
uint8 const _instance,
|
54
|
+
Driver::MsgQueue const _queue
|
55
|
+
)
|
56
|
+
{
|
57
|
+
if( _requestFlags & RequestFlag_Dynamic )
|
58
|
+
{
|
59
|
+
return RequestValue( _requestFlags, 0, _instance, _queue );
|
60
|
+
}
|
61
|
+
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
|
65
|
+
//-----------------------------------------------------------------------------
|
66
|
+
// <MeterPulse::RequestValue>
|
67
|
+
// Request current value from the device
|
68
|
+
//-----------------------------------------------------------------------------
|
69
|
+
bool MeterPulse::RequestValue
|
70
|
+
(
|
71
|
+
uint32 const _requestFlags,
|
72
|
+
uint8 const _dummy1, // = 0 (not used)
|
73
|
+
uint8 const _instance,
|
74
|
+
Driver::MsgQueue const _queue
|
75
|
+
)
|
76
|
+
{
|
77
|
+
Msg* msg = new Msg( "MeterPulseCmd_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
78
|
+
msg->SetInstance( this, _instance );
|
79
|
+
msg->Append( GetNodeId() );
|
80
|
+
msg->Append( 2 );
|
81
|
+
msg->Append( GetCommandClassId() );
|
82
|
+
msg->Append( MeterPulseCmd_Get );
|
83
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
84
|
+
GetDriver()->SendMsg( msg, _queue );
|
85
|
+
return true;
|
86
|
+
}
|
87
|
+
|
88
|
+
//-----------------------------------------------------------------------------
|
89
|
+
// <MeterPulse::HandleMsg>
|
90
|
+
// Handle a message from the Z-Wave network
|
91
|
+
//-----------------------------------------------------------------------------
|
92
|
+
bool MeterPulse::HandleMsg
|
93
|
+
(
|
94
|
+
uint8 const* _data,
|
95
|
+
uint32 const _length,
|
96
|
+
uint32 const _instance // = 1
|
97
|
+
)
|
98
|
+
{
|
99
|
+
if( MeterPulseCmd_Report == (MeterPulseCmd)_data[0] )
|
100
|
+
{
|
101
|
+
int32 count = 0;
|
102
|
+
for( uint8 i=0; i<4; ++i )
|
103
|
+
{
|
104
|
+
count <<= 8;
|
105
|
+
count |= (uint32)_data[i+1];
|
106
|
+
}
|
107
|
+
|
108
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a meter pulse count: Count=%d", count );
|
109
|
+
if( ValueInt* value = static_cast<ValueInt*>( GetValue( _instance, 0 ) ) )
|
110
|
+
{
|
111
|
+
value->OnValueRefreshed( count );
|
112
|
+
value->Release();
|
113
|
+
}
|
114
|
+
|
115
|
+
return true;
|
116
|
+
}
|
117
|
+
|
118
|
+
return false;
|
119
|
+
}
|
120
|
+
|
121
|
+
//-----------------------------------------------------------------------------
|
122
|
+
// <MeterPulse::CreateVars>
|
123
|
+
// Create the values managed by this command class
|
124
|
+
//-----------------------------------------------------------------------------
|
125
|
+
void MeterPulse::CreateVars
|
126
|
+
(
|
127
|
+
uint8 const _instance
|
128
|
+
)
|
129
|
+
{
|
130
|
+
if( Node* node = GetNodeUnsafe() )
|
131
|
+
{
|
132
|
+
node->CreateValueInt( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Count", "", true, false, 0, 0 );
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// MeterPulse.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_METER_PULSE
|
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 _MeterPulse_H
|
29
|
+
#define _MeterPulse_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueInt;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_METER_PULSE (0x35), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class MeterPulse: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MeterPulse( _homeId, _nodeId ); }
|
43
|
+
virtual ~MeterPulse(){}
|
44
|
+
|
45
|
+
static uint8 const StaticGetCommandClassId(){ return 0x35; }
|
46
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_METER_PULSE"; }
|
47
|
+
|
48
|
+
// From CommandClass
|
49
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
50
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
51
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
52
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
53
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
54
|
+
|
55
|
+
protected:
|
56
|
+
virtual void CreateVars( uint8 const _instance );
|
57
|
+
|
58
|
+
private:
|
59
|
+
MeterPulse( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
60
|
+
};
|
61
|
+
|
62
|
+
} // namespace OpenZWave
|
63
|
+
|
64
|
+
#endif
|
65
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// MultiCmd.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_MULTI_CMD
|
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 "MultiCmd.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Node.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
using namespace OpenZWave;
|
37
|
+
|
38
|
+
|
39
|
+
//-----------------------------------------------------------------------------
|
40
|
+
// <MultiCmd::HandleMsg>
|
41
|
+
// Handle a message from the Z-Wave network
|
42
|
+
//-----------------------------------------------------------------------------
|
43
|
+
bool MultiCmd::HandleMsg
|
44
|
+
(
|
45
|
+
uint8 const* _data,
|
46
|
+
uint32 const _length,
|
47
|
+
uint32 const _instance // = 1
|
48
|
+
)
|
49
|
+
{
|
50
|
+
if( MultiCmdCmd_Encap == (MultiCmdCmd)_data[0] )
|
51
|
+
{
|
52
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received encapsulated multi-command from node %d", GetNodeId() );
|
53
|
+
|
54
|
+
if( Node const* node = GetNodeUnsafe() )
|
55
|
+
{
|
56
|
+
// Iterate over commands
|
57
|
+
uint8 base = 2;
|
58
|
+
for( uint8 i=0; i<_data[1]; ++i )
|
59
|
+
{
|
60
|
+
uint8 length = _data[base];
|
61
|
+
uint8 commandClassId = _data[base+1];
|
62
|
+
|
63
|
+
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
|
64
|
+
{
|
65
|
+
pCommandClass->HandleMsg( &_data[base+2], length-1 );
|
66
|
+
}
|
67
|
+
|
68
|
+
base += (length + 1);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
Log::Write( LogLevel_Info, GetNodeId(), "End of encapsulated multi-command from node %d", GetNodeId() );
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// MultiCmd.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_MULTI_CMD
|
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 _MultiCmd_H
|
29
|
+
#define _MultiCmd_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
/** \brief Implements COMMAND_CLASS_MULTI_CMD (0x8f), a Z-Wave device command class.
|
36
|
+
*/
|
37
|
+
class MultiCmd: public CommandClass
|
38
|
+
{
|
39
|
+
public:
|
40
|
+
enum MultiCmdCmd
|
41
|
+
{
|
42
|
+
MultiCmdCmd_Encap = 0x01
|
43
|
+
};
|
44
|
+
|
45
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new MultiCmd( _homeId, _nodeId ); }
|
46
|
+
virtual ~MultiCmd(){}
|
47
|
+
|
48
|
+
static uint8 const StaticGetCommandClassId(){ return 0x8f; }
|
49
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_MULTI_CMD"; }
|
50
|
+
|
51
|
+
// From CommandClass
|
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
|
+
private:
|
57
|
+
MultiCmd( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
58
|
+
};
|
59
|
+
|
60
|
+
} // namespace OpenZWave
|
61
|
+
|
62
|
+
#endif
|
63
|
+
|
@@ -0,0 +1,568 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// MultiInstance.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_MULTI_INSTANCE
|
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 "MultiInstance.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
|
+
// Reduced set of Generic Device classes sorted to reduce
|
39
|
+
// the likely number of calls to MultiChannelCmd_EndPointFind.
|
40
|
+
uint8 const c_genericClass[] =
|
41
|
+
{
|
42
|
+
0x21, // Multilevel Sensor
|
43
|
+
0x20, // Binary Sensor
|
44
|
+
0x31, // Meter
|
45
|
+
0x08, // Thermostat
|
46
|
+
0x11, // Multilevel Switch
|
47
|
+
0x10, // Binary Switch
|
48
|
+
0x12, // Remote Switch
|
49
|
+
0xa1, // Alarm Sensor
|
50
|
+
0x16, // Ventilation
|
51
|
+
0x30, // Pulse Meter
|
52
|
+
0x40, // Entry Control
|
53
|
+
0x13, // Toggle Switch
|
54
|
+
0x03, // AV Control Point
|
55
|
+
0x04, // Display
|
56
|
+
0x00 // End of list
|
57
|
+
};
|
58
|
+
|
59
|
+
char const* c_genericClassName[] =
|
60
|
+
{
|
61
|
+
"Multilevel Sensor",
|
62
|
+
"Binary Sensor",
|
63
|
+
"Meter",
|
64
|
+
"Thermostat",
|
65
|
+
"Multilevel Switch",
|
66
|
+
"Binary Switch",
|
67
|
+
"Remote Switch",
|
68
|
+
"Alarm Sensor",
|
69
|
+
"Ventilation",
|
70
|
+
"Pulse Meter",
|
71
|
+
"Entry Control",
|
72
|
+
"Toggle Switch",
|
73
|
+
"AV Control Point",
|
74
|
+
"Display"
|
75
|
+
};
|
76
|
+
|
77
|
+
//-----------------------------------------------------------------------------
|
78
|
+
// <MultiInstance::MultiInstance>
|
79
|
+
// Constructor
|
80
|
+
//-----------------------------------------------------------------------------
|
81
|
+
MultiInstance::MultiInstance
|
82
|
+
(
|
83
|
+
uint32 const _homeId,
|
84
|
+
uint8 const _nodeId
|
85
|
+
):
|
86
|
+
CommandClass( _homeId, _nodeId ),
|
87
|
+
m_numEndpoints( 0 )
|
88
|
+
{
|
89
|
+
}
|
90
|
+
|
91
|
+
//-----------------------------------------------------------------------------
|
92
|
+
// <MultiInstance::RequestInstances>
|
93
|
+
// Request number of instances of the specified command class from the device
|
94
|
+
//-----------------------------------------------------------------------------
|
95
|
+
bool MultiInstance::RequestInstances
|
96
|
+
(
|
97
|
+
)
|
98
|
+
{
|
99
|
+
bool res = false;
|
100
|
+
|
101
|
+
if( GetVersion() == 1 )
|
102
|
+
{
|
103
|
+
if( Node* node = GetNodeUnsafe() )
|
104
|
+
{
|
105
|
+
// MULTI_INSTANCE
|
106
|
+
char str[128];
|
107
|
+
for( map<uint8,CommandClass*>::const_iterator it = node->m_commandClassMap.begin(); it != node->m_commandClassMap.end(); ++it )
|
108
|
+
{
|
109
|
+
CommandClass* cc = it->second;
|
110
|
+
if( cc->HasStaticRequest( StaticRequest_Instances ) )
|
111
|
+
{
|
112
|
+
snprintf( str, sizeof( str ), "MultiInstanceCmd_Get for %s", cc->GetCommandClassName().c_str() );
|
113
|
+
|
114
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
115
|
+
msg->Append( GetNodeId() );
|
116
|
+
msg->Append( 3 );
|
117
|
+
msg->Append( GetCommandClassId() );
|
118
|
+
msg->Append( MultiInstanceCmd_Get );
|
119
|
+
msg->Append( cc->GetCommandClassId() );
|
120
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
121
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Query );
|
122
|
+
res = true;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
else
|
128
|
+
{
|
129
|
+
// MULTI_CHANNEL
|
130
|
+
char str[128];
|
131
|
+
snprintf( str, sizeof( str ), "MultiChannelCmd_EndPointGet for node %d", GetNodeId() );
|
132
|
+
|
133
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
134
|
+
msg->Append( GetNodeId() );
|
135
|
+
msg->Append( 2 );
|
136
|
+
msg->Append( GetCommandClassId() );
|
137
|
+
msg->Append( MultiChannelCmd_EndPointGet );
|
138
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
139
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Query );
|
140
|
+
res = true;
|
141
|
+
}
|
142
|
+
|
143
|
+
return res;
|
144
|
+
}
|
145
|
+
|
146
|
+
//-----------------------------------------------------------------------------
|
147
|
+
// <MultiInstance::HandleMsg>
|
148
|
+
// Handle a message from the Z-Wave network
|
149
|
+
//-----------------------------------------------------------------------------
|
150
|
+
bool MultiInstance::HandleMsg
|
151
|
+
(
|
152
|
+
uint8 const* _data,
|
153
|
+
uint32 const _length,
|
154
|
+
uint32 const _instance // = 1
|
155
|
+
)
|
156
|
+
{
|
157
|
+
bool handled = false;
|
158
|
+
Node* node = GetNodeUnsafe();
|
159
|
+
if( node != NULL )
|
160
|
+
{
|
161
|
+
handled = true;
|
162
|
+
switch( (MultiInstanceCmd)_data[0] )
|
163
|
+
{
|
164
|
+
case MultiInstanceCmd_Report:
|
165
|
+
{
|
166
|
+
HandleMultiInstanceReport( _data, _length );
|
167
|
+
break;
|
168
|
+
}
|
169
|
+
case MultiInstanceCmd_Encap:
|
170
|
+
{
|
171
|
+
HandleMultiInstanceEncap( _data, _length );
|
172
|
+
break;
|
173
|
+
}
|
174
|
+
case MultiChannelCmd_EndPointReport:
|
175
|
+
{
|
176
|
+
HandleMultiChannelEndPointReport( _data, _length );
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
case MultiChannelCmd_CapabilityReport:
|
180
|
+
{
|
181
|
+
HandleMultiChannelCapabilityReport( _data, _length );
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
case MultiChannelCmd_EndPointFindReport:
|
185
|
+
{
|
186
|
+
HandleMultiChannelEndPointFindReport( _data, _length );
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
case MultiChannelCmd_Encap:
|
190
|
+
{
|
191
|
+
HandleMultiChannelEncap( _data, _length );
|
192
|
+
break;
|
193
|
+
}
|
194
|
+
default:
|
195
|
+
{
|
196
|
+
handled = false;
|
197
|
+
break;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
return handled;
|
203
|
+
}
|
204
|
+
|
205
|
+
//-----------------------------------------------------------------------------
|
206
|
+
// <MultiInstance::HandleMultiInstanceReport>
|
207
|
+
// Handle a message from the Z-Wave network
|
208
|
+
//-----------------------------------------------------------------------------
|
209
|
+
void MultiInstance::HandleMultiInstanceReport
|
210
|
+
(
|
211
|
+
uint8 const* _data,
|
212
|
+
uint32 const _length
|
213
|
+
)
|
214
|
+
{
|
215
|
+
if( Node* node = GetNodeUnsafe() )
|
216
|
+
{
|
217
|
+
uint8 commandClassId = _data[1];
|
218
|
+
uint8 instances = _data[2];
|
219
|
+
if( GetVersion() > 1 )
|
220
|
+
{
|
221
|
+
instances &= 0x7f;
|
222
|
+
}
|
223
|
+
|
224
|
+
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
|
225
|
+
{
|
226
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received MultiInstanceReport from node %d for %s: Number of instances = %d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), instances );
|
227
|
+
pCommandClass->SetInstances( instances );
|
228
|
+
pCommandClass->ClearStaticRequest( StaticRequest_Instances );
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
//-----------------------------------------------------------------------------
|
234
|
+
// <MultiInstance::HandleMultiInstanceEncap>
|
235
|
+
// Handle a message from the Z-Wave network
|
236
|
+
//-----------------------------------------------------------------------------
|
237
|
+
void MultiInstance::HandleMultiInstanceEncap
|
238
|
+
(
|
239
|
+
uint8 const* _data,
|
240
|
+
uint32 const _length
|
241
|
+
)
|
242
|
+
{
|
243
|
+
if( Node* node = GetNodeUnsafe() )
|
244
|
+
{
|
245
|
+
uint8 instance = _data[1];
|
246
|
+
if( GetVersion() > 1 )
|
247
|
+
{
|
248
|
+
instance &= 0x7f;
|
249
|
+
}
|
250
|
+
uint8 commandClassId = _data[2];
|
251
|
+
|
252
|
+
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
|
253
|
+
{
|
254
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiInstanceEncap from node %d, instance %d, for Command Class %s", GetNodeId(), instance, pCommandClass->GetCommandClassName().c_str() );
|
255
|
+
pCommandClass->HandleMsg( &_data[3], _length-3, instance );
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
|
260
|
+
//-----------------------------------------------------------------------------
|
261
|
+
// <MultiInstance::HandleMultiChannelEndPointReport>
|
262
|
+
// Handle a message from the Z-Wave network
|
263
|
+
//-----------------------------------------------------------------------------
|
264
|
+
void MultiInstance::HandleMultiChannelEndPointReport
|
265
|
+
(
|
266
|
+
uint8 const* _data,
|
267
|
+
uint32 const _length
|
268
|
+
)
|
269
|
+
{
|
270
|
+
if( m_numEndpoints != 0 )
|
271
|
+
{
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
|
275
|
+
m_numEndPointsCanChange = (( _data[1] & 0x80 ) != 0 ); // Number of endpoints can change.
|
276
|
+
m_endPointsAreSameClass = (( _data[1] & 0x40 ) != 0 ); // All endpoints are the same command class.
|
277
|
+
m_numEndpoints = _data[2] & 0x7f;
|
278
|
+
|
279
|
+
if( m_endPointsAreSameClass )
|
280
|
+
{
|
281
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. All %d endpoints are the same.", GetNodeId(), m_numEndpoints );
|
282
|
+
|
283
|
+
// Send a single capability request to endpoint 1 (since all classes are the same)
|
284
|
+
char str[128];
|
285
|
+
snprintf( str, sizeof( str ), "MultiChannelCmd_CapabilityGet for endpoint 1" );
|
286
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
287
|
+
msg->Append( GetNodeId() );
|
288
|
+
msg->Append( 3 );
|
289
|
+
msg->Append( GetCommandClassId() );
|
290
|
+
msg->Append( MultiChannelCmd_CapabilityGet );
|
291
|
+
msg->Append( 1 );
|
292
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
293
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
294
|
+
}
|
295
|
+
else
|
296
|
+
{
|
297
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. Endpoints are not all the same.", GetNodeId() );
|
298
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Starting search for endpoints by generic class..." );
|
299
|
+
|
300
|
+
// This is where things get really ugly. We need to get the capabilities of each
|
301
|
+
// endpoint, but we only know how many there are, not which indices they
|
302
|
+
// are at. We will first try to use MultiChannelCmd_EndPointFind to get
|
303
|
+
// lists of indices. We have to specify a generic device class in the find,
|
304
|
+
// so we try generic classes in an order likely to find the endpoints the quickest.
|
305
|
+
m_endPointFindIndex = 0;
|
306
|
+
m_numEndPointsFound = 0;
|
307
|
+
|
308
|
+
char str[128];
|
309
|
+
snprintf( str, 128, "MultiChannelCmd_EndPointFind for generic device class 0x%.2x (%s)", c_genericClass[m_endPointFindIndex], c_genericClassName[m_endPointFindIndex] );
|
310
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
311
|
+
msg->Append( GetNodeId() );
|
312
|
+
msg->Append( 4 );
|
313
|
+
msg->Append( GetCommandClassId() );
|
314
|
+
msg->Append( MultiChannelCmd_EndPointFind );
|
315
|
+
msg->Append( c_genericClass[m_endPointFindIndex] ); // Generic device class
|
316
|
+
msg->Append( 0xff ); // Any specific device class
|
317
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
318
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
//-----------------------------------------------------------------------------
|
323
|
+
// <MultiInstance::HandleMultiChannelCapabilityReport>
|
324
|
+
// Handle a message from the Z-Wave network
|
325
|
+
//-----------------------------------------------------------------------------
|
326
|
+
void MultiInstance::HandleMultiChannelCapabilityReport
|
327
|
+
(
|
328
|
+
uint8 const* _data,
|
329
|
+
uint32 const _length
|
330
|
+
)
|
331
|
+
{
|
332
|
+
if( Node* node = GetNodeUnsafe() )
|
333
|
+
{
|
334
|
+
uint8 endPoint = _data[1] & 0x7f;
|
335
|
+
bool dynamic = ((_data[1] & 0x80)!=0);
|
336
|
+
|
337
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelCapabilityReport from node %d for endpoint %d", GetNodeId(), endPoint );
|
338
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Endpoint is%sdynamic, and is a %s", dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() );
|
339
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Command classes supported by the endpoint are:" );
|
340
|
+
|
341
|
+
// Store the command classes for later use
|
342
|
+
bool afterMark = false;
|
343
|
+
m_endPointCommandClasses.clear();
|
344
|
+
uint8 numCommandClasses = _length - 5;
|
345
|
+
for( uint8 i=0; i<numCommandClasses; ++i )
|
346
|
+
{
|
347
|
+
uint8 commandClassId = _data[i+4];
|
348
|
+
if( commandClassId == 0xef )
|
349
|
+
{
|
350
|
+
afterMark = true;
|
351
|
+
continue;
|
352
|
+
}
|
353
|
+
|
354
|
+
m_endPointCommandClasses.insert( commandClassId );
|
355
|
+
|
356
|
+
// Ensure the node supports this command class
|
357
|
+
CommandClass* cc = node->GetCommandClass( commandClassId );
|
358
|
+
if( !cc )
|
359
|
+
{
|
360
|
+
cc = node->AddCommandClass( commandClassId );
|
361
|
+
if( cc && afterMark )
|
362
|
+
{
|
363
|
+
cc->SetAfterMark();
|
364
|
+
}
|
365
|
+
}
|
366
|
+
if( cc )
|
367
|
+
{
|
368
|
+
Log::Write( LogLevel_Info, GetNodeId(), " %s", cc->GetCommandClassName().c_str() );
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
if( ( endPoint == 1 ) && m_endPointsAreSameClass )
|
373
|
+
{
|
374
|
+
Log::Write( LogLevel_Info, GetNodeId(), "All endpoints in this device are the same as endpoint 1. Searching for the other endpoints..." );
|
375
|
+
|
376
|
+
// All end points have the same command classes.
|
377
|
+
// We just need to find them...
|
378
|
+
if (node->MultiEndPointFindSupported()) {
|
379
|
+
char str[128];
|
380
|
+
snprintf( str, sizeof( str ), "MultiChannelCmd_EndPointFind for generic device class 0x%.2x", _data[2] );
|
381
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
382
|
+
msg->Append( GetNodeId() );
|
383
|
+
msg->Append( 4 );
|
384
|
+
msg->Append( GetCommandClassId() );
|
385
|
+
msg->Append( MultiChannelCmd_EndPointFind );
|
386
|
+
msg->Append( _data[2] ); // Generic device class
|
387
|
+
msg->Append( 0xff ); // Any specific device class
|
388
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
389
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
390
|
+
} else {
|
391
|
+
// no way to find them, assume they are in ascending order
|
392
|
+
for( uint8 endPoint=1; endPoint<=m_numEndpoints; ++endPoint )
|
393
|
+
{
|
394
|
+
// Use the stored command class list to set up the endpoint.
|
395
|
+
for( set<uint8>::iterator it=m_endPointCommandClasses.begin(); it!=m_endPointCommandClasses.end(); ++it )
|
396
|
+
{
|
397
|
+
uint8 commandClassId = *it;
|
398
|
+
CommandClass* cc = node->GetCommandClass( commandClassId );
|
399
|
+
if( cc )
|
400
|
+
{
|
401
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Endpoint %d: Adding %s", endPoint, cc->GetCommandClassName().c_str() );
|
402
|
+
cc->SetInstance( endPoint );
|
403
|
+
}
|
404
|
+
}
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
else
|
409
|
+
{
|
410
|
+
// Create instances (endpoints) for each command class in the list
|
411
|
+
for( set<uint8>::iterator it=m_endPointCommandClasses.begin(); it!=m_endPointCommandClasses.end(); ++it )
|
412
|
+
{
|
413
|
+
uint8 commandClassId = *it;
|
414
|
+
CommandClass* cc = node->GetCommandClass( commandClassId );
|
415
|
+
if( cc )
|
416
|
+
{
|
417
|
+
cc->SetInstance( endPoint );
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
//-----------------------------------------------------------------------------
|
425
|
+
// <MultiInstance::HandleMultiChannelEndPointFindReport>
|
426
|
+
// Handle a message from the Z-Wave network
|
427
|
+
//-----------------------------------------------------------------------------
|
428
|
+
void MultiInstance::HandleMultiChannelEndPointFindReport
|
429
|
+
(
|
430
|
+
uint8 const* _data,
|
431
|
+
uint32 const _length
|
432
|
+
)
|
433
|
+
{
|
434
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointFindReport from node %d", GetNodeId() );
|
435
|
+
uint8 numEndPoints = _length - 5;
|
436
|
+
for( uint8 i=0; i<numEndPoints; ++i )
|
437
|
+
{
|
438
|
+
uint8 endPoint = _data[i+4] & 0x7f;
|
439
|
+
|
440
|
+
if( m_endPointsAreSameClass )
|
441
|
+
{
|
442
|
+
// Use the stored command class list to set up the endpoint.
|
443
|
+
if( Node* node = GetNodeUnsafe() )
|
444
|
+
{
|
445
|
+
for( set<uint8>::iterator it=m_endPointCommandClasses.begin(); it!=m_endPointCommandClasses.end(); ++it )
|
446
|
+
{
|
447
|
+
uint8 commandClassId = *it;
|
448
|
+
CommandClass* cc = node->GetCommandClass( commandClassId );
|
449
|
+
if( cc )
|
450
|
+
{
|
451
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Endpoint %d: Adding %s", endPoint, cc->GetCommandClassName().c_str() );
|
452
|
+
cc->SetInstance( endPoint );
|
453
|
+
}
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
else
|
458
|
+
{
|
459
|
+
// Endpoints are different, so request the capabilities
|
460
|
+
char str[128];
|
461
|
+
snprintf( str, 128, "MultiChannelCmd_CapabilityGet for node %d, endpoint %d", GetNodeId(), endPoint );
|
462
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
463
|
+
msg->Append( GetNodeId() );
|
464
|
+
msg->Append( 3 );
|
465
|
+
msg->Append( GetCommandClassId() );
|
466
|
+
msg->Append( MultiChannelCmd_CapabilityGet );
|
467
|
+
msg->Append( endPoint );
|
468
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
469
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
m_numEndPointsFound += numEndPoints;
|
474
|
+
if( !m_endPointsAreSameClass )
|
475
|
+
{
|
476
|
+
if( _data[1] == 0 )
|
477
|
+
{
|
478
|
+
// No more reports to follow this one, so we can continue the search.
|
479
|
+
if( m_numEndPointsFound < numEndPoints )
|
480
|
+
{
|
481
|
+
// We have not yet found all the endpoints, so move to the next generic class request
|
482
|
+
++m_endPointFindIndex;
|
483
|
+
if( c_genericClass[m_endPointFindIndex] > 0 )
|
484
|
+
{
|
485
|
+
char str[128];
|
486
|
+
snprintf( str, 128, "MultiChannelCmd_EndPointFind for generic device class 0x%.2x (%s)", c_genericClass[m_endPointFindIndex], c_genericClassName[m_endPointFindIndex] );
|
487
|
+
Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
488
|
+
msg->Append( GetNodeId() );
|
489
|
+
msg->Append( 4 );
|
490
|
+
msg->Append( GetCommandClassId() );
|
491
|
+
msg->Append( MultiChannelCmd_EndPointFind );
|
492
|
+
msg->Append( c_genericClass[m_endPointFindIndex] ); // Generic device class
|
493
|
+
msg->Append( 0xff ); // Any specific device class
|
494
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
495
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
}
|
500
|
+
}
|
501
|
+
|
502
|
+
//-----------------------------------------------------------------------------
|
503
|
+
// <MultiInstance::HandleMultiChannelEncap>
|
504
|
+
// Handle a message from the Z-Wave network
|
505
|
+
//-----------------------------------------------------------------------------
|
506
|
+
void MultiInstance::HandleMultiChannelEncap
|
507
|
+
(
|
508
|
+
uint8 const* _data,
|
509
|
+
uint32 const _length
|
510
|
+
)
|
511
|
+
{
|
512
|
+
if( Node* node = GetNodeUnsafe() )
|
513
|
+
{
|
514
|
+
uint8 endPoint = _data[1] & 0x7f;
|
515
|
+
uint8 commandClassId = _data[3];
|
516
|
+
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
|
517
|
+
{
|
518
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() );
|
519
|
+
pCommandClass->HandleMsg( &_data[4], _length-4, endPoint );
|
520
|
+
}
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
//-----------------------------------------------------------------------------
|
525
|
+
// <MultiInstance::SendEncap>
|
526
|
+
// Send a message encasulated in a MultiInstance/MultiChannel command
|
527
|
+
//-----------------------------------------------------------------------------
|
528
|
+
void MultiInstance::SendEncap
|
529
|
+
(
|
530
|
+
uint8 const* _data,
|
531
|
+
uint32 const _length,
|
532
|
+
uint32 const _instance,
|
533
|
+
uint32 const _requestFlags
|
534
|
+
)
|
535
|
+
{
|
536
|
+
char str[128];
|
537
|
+
Msg* msg;
|
538
|
+
if( GetVersion() == 1 )
|
539
|
+
{
|
540
|
+
// MultiInstance
|
541
|
+
snprintf( str, sizeof( str ), "MultiInstanceCmd_Encap (Instance=%d)", _instance );
|
542
|
+
msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
543
|
+
msg->Append( GetNodeId() );
|
544
|
+
msg->Append( 3+_length );
|
545
|
+
msg->Append( GetCommandClassId() );
|
546
|
+
msg->Append( MultiInstanceCmd_Encap );
|
547
|
+
}
|
548
|
+
else
|
549
|
+
{
|
550
|
+
// MultiChannel
|
551
|
+
snprintf( str, sizeof( str ), "MultiChannelCmd_Encap (Instance=%d)", _instance );
|
552
|
+
msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
553
|
+
msg->Append( GetNodeId() );
|
554
|
+
msg->Append( 4+_length );
|
555
|
+
msg->Append( GetCommandClassId() );
|
556
|
+
msg->Append( MultiChannelCmd_Encap );
|
557
|
+
msg->Append( 0 );
|
558
|
+
}
|
559
|
+
|
560
|
+
msg->Append( _instance );
|
561
|
+
for( uint8 i=0; i<_length; ++i )
|
562
|
+
{
|
563
|
+
msg->Append( _data[i] );
|
564
|
+
}
|
565
|
+
|
566
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
567
|
+
GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
|
568
|
+
}
|