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
|
+
// Protection.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_PROTECTION
|
6
|
+
//
|
7
|
+
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
|
8
|
+
//
|
9
|
+
// SOFTWARE NOTICE AND LICENSE
|
10
|
+
//
|
11
|
+
// This file is part of OpenZWave.
|
12
|
+
//
|
13
|
+
// OpenZWave is free software: you can redistribute it and/or modify
|
14
|
+
// it under the terms of the GNU Lesser General Public License as published
|
15
|
+
// by the Free Software Foundation, either version 3 of the License,
|
16
|
+
// or (at your option) any later version.
|
17
|
+
//
|
18
|
+
// OpenZWave is distributed in the hope that it will be useful,
|
19
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
// GNU Lesser General Public License for more details.
|
22
|
+
//
|
23
|
+
// You should have received a copy of the GNU Lesser General Public License
|
24
|
+
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
//
|
26
|
+
//-----------------------------------------------------------------------------
|
27
|
+
|
28
|
+
#ifndef _Protection_H
|
29
|
+
#define _Protection_H
|
30
|
+
|
31
|
+
#include "CommandClass.h"
|
32
|
+
|
33
|
+
namespace OpenZWave
|
34
|
+
{
|
35
|
+
class ValueList;
|
36
|
+
|
37
|
+
/** \brief Implements COMMAND_CLASS_PROTECTION (0x75), a Z-Wave device command class.
|
38
|
+
*/
|
39
|
+
class Protection: public CommandClass
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
enum ProtectionEnum
|
43
|
+
{
|
44
|
+
Protection_Unprotected = 0,
|
45
|
+
Protection_Sequence,
|
46
|
+
Protection_NOP
|
47
|
+
};
|
48
|
+
|
49
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new Protection( _homeId, _nodeId ); }
|
50
|
+
virtual ~Protection(){}
|
51
|
+
|
52
|
+
static uint8 const StaticGetCommandClassId(){ return 0x75; }
|
53
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_PROTECTION"; }
|
54
|
+
|
55
|
+
// From CommandClass
|
56
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
57
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
|
58
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
59
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
60
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
61
|
+
virtual bool SetValue( Value const& _value );
|
62
|
+
|
63
|
+
protected:
|
64
|
+
virtual void CreateVars( uint8 const _instance );
|
65
|
+
|
66
|
+
private:
|
67
|
+
Protection( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
|
68
|
+
};
|
69
|
+
|
70
|
+
} // namespace OpenZWave
|
71
|
+
|
72
|
+
#endif
|
73
|
+
|
@@ -0,0 +1,208 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorAlarm.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_ALARM
|
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 "SensorAlarm.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Node.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueByte.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum SensorAlarmCmd
|
41
|
+
{
|
42
|
+
SensorAlarmCmd_Get = 0x01,
|
43
|
+
SensorAlarmCmd_Report = 0x02,
|
44
|
+
SensorAlarmCmd_SupportedGet = 0x03,
|
45
|
+
SensorAlarmCmd_SupportedReport = 0x04
|
46
|
+
};
|
47
|
+
|
48
|
+
static char const* c_alarmTypeName[] =
|
49
|
+
{
|
50
|
+
"General",
|
51
|
+
"Smoke",
|
52
|
+
"Carbon Monoxide",
|
53
|
+
"Carbon Dioxide",
|
54
|
+
"Heat",
|
55
|
+
"Flood"
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
//-----------------------------------------------------------------------------
|
60
|
+
// <SensorAlarm::SensorAlarm>
|
61
|
+
// Constructor
|
62
|
+
//-----------------------------------------------------------------------------
|
63
|
+
SensorAlarm::SensorAlarm
|
64
|
+
(
|
65
|
+
uint32 const _homeId,
|
66
|
+
uint8 const _nodeId
|
67
|
+
):
|
68
|
+
CommandClass( _homeId, _nodeId )
|
69
|
+
{
|
70
|
+
SetStaticRequest( StaticRequest_Values );
|
71
|
+
}
|
72
|
+
|
73
|
+
//-----------------------------------------------------------------------------
|
74
|
+
// <SensorAlarm::RequestState>
|
75
|
+
// Get the static thermostat setpoint details from the device
|
76
|
+
//-----------------------------------------------------------------------------
|
77
|
+
bool SensorAlarm::RequestState
|
78
|
+
(
|
79
|
+
uint32 const _requestFlags,
|
80
|
+
uint8 const _instance,
|
81
|
+
Driver::MsgQueue const _queue
|
82
|
+
)
|
83
|
+
{
|
84
|
+
bool requests = false;
|
85
|
+
if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) )
|
86
|
+
{
|
87
|
+
requests = RequestValue( _requestFlags, 0xff, _instance, _queue );
|
88
|
+
}
|
89
|
+
|
90
|
+
if( _requestFlags & RequestFlag_Dynamic )
|
91
|
+
{
|
92
|
+
for( uint8 i=0; i<SensorAlarm_Count; ++i )
|
93
|
+
{
|
94
|
+
Value* value = GetValue( 1, i );
|
95
|
+
if( value != NULL )
|
96
|
+
{
|
97
|
+
value->Release();
|
98
|
+
// There is a value for this alarm type, so request it
|
99
|
+
requests |= RequestValue( _requestFlags, i, _instance, _queue );
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
return requests;
|
105
|
+
}
|
106
|
+
|
107
|
+
//-----------------------------------------------------------------------------
|
108
|
+
// <SensorAlarm::RequestValue>
|
109
|
+
// Get the sensor alarm details from the device
|
110
|
+
//-----------------------------------------------------------------------------
|
111
|
+
bool SensorAlarm::RequestValue
|
112
|
+
(
|
113
|
+
uint32 const _requestFlags,
|
114
|
+
uint8 const _alarmType,
|
115
|
+
uint8 const _instance,
|
116
|
+
Driver::MsgQueue const _queue
|
117
|
+
)
|
118
|
+
{
|
119
|
+
if( _alarmType == 0xff )
|
120
|
+
{
|
121
|
+
// Request the supported alarm types
|
122
|
+
Msg* msg = new Msg( "Request Supported Alarm Types", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
123
|
+
msg->SetInstance( this, _instance );
|
124
|
+
msg->Append( GetNodeId() );
|
125
|
+
msg->Append( 2 );
|
126
|
+
msg->Append( GetCommandClassId() );
|
127
|
+
msg->Append( SensorAlarmCmd_SupportedGet );
|
128
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
129
|
+
GetDriver()->SendMsg( msg, _queue );
|
130
|
+
}
|
131
|
+
else
|
132
|
+
{
|
133
|
+
// Request the alarm state
|
134
|
+
Msg* msg = new Msg( "Request alarm state", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
|
135
|
+
msg->SetInstance( this, _instance );
|
136
|
+
msg->Append( GetNodeId() );
|
137
|
+
msg->Append( 3 );
|
138
|
+
msg->Append( GetCommandClassId() );
|
139
|
+
msg->Append( SensorAlarmCmd_Get );
|
140
|
+
msg->Append( _alarmType );
|
141
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
142
|
+
GetDriver()->SendMsg( msg, _queue );
|
143
|
+
}
|
144
|
+
return true;
|
145
|
+
}
|
146
|
+
|
147
|
+
//-----------------------------------------------------------------------------
|
148
|
+
// <SensorAlarm::HandleMsg>
|
149
|
+
// Handle a message from the Z-Wave network
|
150
|
+
//-----------------------------------------------------------------------------
|
151
|
+
bool SensorAlarm::HandleMsg
|
152
|
+
(
|
153
|
+
uint8 const* _data,
|
154
|
+
uint32 const _length,
|
155
|
+
uint32 const _instance // = 1
|
156
|
+
)
|
157
|
+
{
|
158
|
+
if( SensorAlarmCmd_Report == (SensorAlarmCmd)_data[0] )
|
159
|
+
{
|
160
|
+
// We have received an alarm state report from the Z-Wave device
|
161
|
+
if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, _data[2] ) ) )
|
162
|
+
{
|
163
|
+
uint8 sourceNodeId = _data[1];
|
164
|
+
uint8 state = _data[3];
|
165
|
+
// uint16 time = (((uint16)_data[4])<<8) | (uint16)_data[5]; Don't know what to do with this yet.
|
166
|
+
|
167
|
+
value->OnValueRefreshed( state );
|
168
|
+
value->Release();
|
169
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received alarm state report from node %d: %s = %d", sourceNodeId, value->GetLabel().c_str(), state );
|
170
|
+
}
|
171
|
+
|
172
|
+
return true;
|
173
|
+
}
|
174
|
+
|
175
|
+
if( SensorAlarmCmd_SupportedReport == (SensorAlarmCmd)_data[0] )
|
176
|
+
{
|
177
|
+
if( Node* node = GetNodeUnsafe() )
|
178
|
+
{
|
179
|
+
// We have received the supported alarm types from the Z-Wave device
|
180
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received supported alarm types" );
|
181
|
+
|
182
|
+
// Parse the data for the supported alarm types
|
183
|
+
uint8 numBytes = _data[1];
|
184
|
+
for( uint32 i=0; i<numBytes; ++i )
|
185
|
+
{
|
186
|
+
for( int32 bit=0; bit<8; ++bit )
|
187
|
+
{
|
188
|
+
if( ( _data[i+2] & (1<<bit) ) != 0 )
|
189
|
+
{
|
190
|
+
// Add supported setpoint
|
191
|
+
int32 index = (int32)(i<<3) + bit;
|
192
|
+
if( index < SensorAlarm_Count )
|
193
|
+
{
|
194
|
+
node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, index, c_alarmTypeName[index], "", true, false, 0, 0 );
|
195
|
+
Log::Write( LogLevel_Info, GetNodeId(), " Added alarm type: %s", c_alarmTypeName[index] );
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
ClearStaticRequest( StaticRequest_Values );
|
203
|
+
return true;
|
204
|
+
}
|
205
|
+
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorAlarm.h
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_ALARM
|
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 _SensorAlarm_H
|
29
|
+
#define _SensorAlarm_H
|
30
|
+
|
31
|
+
#include <vector>
|
32
|
+
#include <string>
|
33
|
+
#include "CommandClass.h"
|
34
|
+
|
35
|
+
namespace OpenZWave
|
36
|
+
{
|
37
|
+
class ValueByte;
|
38
|
+
|
39
|
+
/** \brief Implements COMMAND_CLASS_SENSOR_ALARM (0x9c), a Z-Wave device command class.
|
40
|
+
*/
|
41
|
+
class SensorAlarm: public CommandClass
|
42
|
+
{
|
43
|
+
public:
|
44
|
+
static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new SensorAlarm( _homeId, _nodeId ); }
|
45
|
+
virtual ~SensorAlarm(){}
|
46
|
+
|
47
|
+
static uint8 const StaticGetCommandClassId(){ return 0x9c; }
|
48
|
+
static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_SENSOR_ALARM"; }
|
49
|
+
|
50
|
+
// From CommandClass
|
51
|
+
virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
|
52
|
+
virtual bool RequestValue( uint32 const _requestFlags, uint8 const _alarmType, uint8 const _dummy, Driver::MsgQueue const _queue );
|
53
|
+
virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
|
54
|
+
virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
|
55
|
+
virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
|
56
|
+
|
57
|
+
private:
|
58
|
+
SensorAlarm( uint32 const _homeId, uint8 const _nodeId );
|
59
|
+
|
60
|
+
enum
|
61
|
+
{
|
62
|
+
SensorAlarm_General = 0,
|
63
|
+
SensorAlarm_Smoke,
|
64
|
+
SensorAlarm_CarbonMonoxide,
|
65
|
+
SensorAlarm_CarbonDioxide,
|
66
|
+
SensorAlarm_Heat,
|
67
|
+
SensorAlarm_Flood,
|
68
|
+
SensorAlarm_Count
|
69
|
+
};
|
70
|
+
};
|
71
|
+
|
72
|
+
} // namespace OpenZWave
|
73
|
+
|
74
|
+
#endif
|
75
|
+
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
//-----------------------------------------------------------------------------
|
2
|
+
//
|
3
|
+
// SensorBinary.cpp
|
4
|
+
//
|
5
|
+
// Implementation of the Z-Wave COMMAND_CLASS_SENSOR_BINARY
|
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 "SensorBinary.h"
|
30
|
+
#include "Defs.h"
|
31
|
+
#include "Msg.h"
|
32
|
+
#include "Node.h"
|
33
|
+
#include "Driver.h"
|
34
|
+
#include "Log.h"
|
35
|
+
|
36
|
+
#include "ValueBool.h"
|
37
|
+
|
38
|
+
using namespace OpenZWave;
|
39
|
+
|
40
|
+
enum SensorBinaryCmd
|
41
|
+
{
|
42
|
+
SensorBinaryCmd_Get = 0x02,
|
43
|
+
SensorBinaryCmd_Report = 0x03
|
44
|
+
};
|
45
|
+
|
46
|
+
//-----------------------------------------------------------------------------
|
47
|
+
// <SensorBinary::RequestState>
|
48
|
+
// Request current state from the device
|
49
|
+
//-----------------------------------------------------------------------------
|
50
|
+
bool SensorBinary::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
|
+
// <SensorBinary::RequestValue>
|
67
|
+
// Request current value from the device
|
68
|
+
//-----------------------------------------------------------------------------
|
69
|
+
bool SensorBinary::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( "SensorBinaryCmd_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( SensorBinaryCmd_Get );
|
83
|
+
msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
|
84
|
+
GetDriver()->SendMsg( msg, _queue );
|
85
|
+
return true;
|
86
|
+
}
|
87
|
+
|
88
|
+
//-----------------------------------------------------------------------------
|
89
|
+
// <SensorBinary::HandleMsg>
|
90
|
+
// Handle a message from the Z-Wave network
|
91
|
+
//-----------------------------------------------------------------------------
|
92
|
+
bool SensorBinary::HandleMsg
|
93
|
+
(
|
94
|
+
uint8 const* _data,
|
95
|
+
uint32 const _length,
|
96
|
+
uint32 const _instance // = 1
|
97
|
+
)
|
98
|
+
{
|
99
|
+
if (SensorBinaryCmd_Report == (SensorBinaryCmd)_data[0])
|
100
|
+
{
|
101
|
+
Log::Write( LogLevel_Info, GetNodeId(), "Received SensorBinary report: State=%s", _data[1] ? "On" : "Off" );
|
102
|
+
|
103
|
+
if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, 0 ) ) )
|
104
|
+
{
|
105
|
+
value->OnValueRefreshed( _data[1] != 0 );
|
106
|
+
value->Release();
|
107
|
+
}
|
108
|
+
return true;
|
109
|
+
}
|
110
|
+
|
111
|
+
return false;
|
112
|
+
}
|
113
|
+
|
114
|
+
//-----------------------------------------------------------------------------
|
115
|
+
// <SensorBinary::CreateVars>
|
116
|
+
// Create the values managed by this command class
|
117
|
+
//-----------------------------------------------------------------------------
|
118
|
+
void SensorBinary::CreateVars
|
119
|
+
(
|
120
|
+
uint8 const _instance
|
121
|
+
)
|
122
|
+
{
|
123
|
+
if( Node* node = GetNodeUnsafe() )
|
124
|
+
{
|
125
|
+
node->CreateValueBool( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Sensor", "", true, false, false, 0 );
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|