ansible4ozw 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/lib/ansible.rb
CHANGED
|
@@ -22,20 +22,23 @@ for more information on the LGPL, see:
|
|
|
22
22
|
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
|
23
23
|
=end
|
|
24
24
|
|
|
25
|
+
# ruby core
|
|
25
26
|
require "rubygems"
|
|
26
27
|
require "bundler/setup"
|
|
27
|
-
require '
|
|
28
|
+
require 'onstomp'
|
|
29
|
+
require 'thrift'
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
require '
|
|
31
|
-
|
|
31
|
+
# ansible core
|
|
32
|
+
require 'ansible/config'
|
|
33
|
+
# note: I would like to convert this to ansible/device
|
|
34
|
+
require 'ansible/ansible_device'
|
|
35
|
+
require 'ansible/transceiver'
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
require '
|
|
35
|
-
require '
|
|
36
|
-
|
|
37
|
-
require 'ansible_device'
|
|
37
|
+
# ansible extensions
|
|
38
|
+
require 'ansible/knx'
|
|
39
|
+
require 'ansible/zwave'
|
|
38
40
|
|
|
41
|
+
# include all
|
|
39
42
|
include Ansible
|
|
40
43
|
include Ansible::ZWave
|
|
41
44
|
include Ansible::KNX
|
data/lib/ansible/config.rb
CHANGED
|
@@ -27,9 +27,13 @@ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
|
|
27
27
|
#
|
|
28
28
|
|
|
29
29
|
module Ansible
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
def self.root
|
|
32
|
+
File.expand_path '../..', __FILE__
|
|
33
|
+
end
|
|
34
|
+
|
|
31
35
|
# STOMP Server URL
|
|
32
|
-
STOMP_URL = 'stomp://
|
|
36
|
+
STOMP_URL = 'stomp://localhost'
|
|
33
37
|
|
|
34
38
|
#
|
|
35
39
|
# KNX subsystem configuration
|
|
@@ -73,8 +77,7 @@ module Ansible
|
|
|
73
77
|
|
|
74
78
|
#################
|
|
75
79
|
# OpenZWave Thrift Server URL
|
|
76
|
-
THRIFT_URL = 'thrift://
|
|
77
|
-
#THRIFT_URL = 'thrift://192.168.0.100'
|
|
80
|
+
THRIFT_URL = 'thrift://localhost'
|
|
78
81
|
|
|
79
82
|
ThriftPort = 9090
|
|
80
83
|
|
|
@@ -87,6 +90,6 @@ end
|
|
|
87
90
|
module OpenZWave
|
|
88
91
|
|
|
89
92
|
# path to OpenZWave source
|
|
90
|
-
OZW_SRC = "
|
|
93
|
+
OZW_SRC = "#{Ansible.root}/ansible/zwave/openzwave/src"
|
|
91
94
|
|
|
92
95
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
data/lib/ansible/knx.rb
ADDED
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'bindata'
|
|
2
|
+
|
|
3
|
+
class DPT10 < BinData::Record
|
|
4
|
+
bit3 :dayofweek, {
|
|
5
|
+
:display_name => "Day of week",
|
|
6
|
+
:range => 0..7, :enc => {
|
|
7
|
+
0 => "(no day set)",
|
|
8
|
+
1 => "Monday",
|
|
9
|
+
2 => "Tuesday",
|
|
10
|
+
3 => "Wednesday",
|
|
11
|
+
4 => "Thursday",
|
|
12
|
+
5 => "Friday",
|
|
13
|
+
6 => "Saturday",
|
|
14
|
+
7 => "Sunday"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
bit5 :hour, {
|
|
18
|
+
:display_name => "Hour", :range => 0..23
|
|
19
|
+
}
|
|
20
|
+
#
|
|
21
|
+
bit2 :unused1
|
|
22
|
+
bit6 :minutes, {
|
|
23
|
+
:display_name => "Minutes", :range => 0..59
|
|
24
|
+
}
|
|
25
|
+
#
|
|
26
|
+
bit2 :unused2
|
|
27
|
+
bit6 :seconds, {
|
|
28
|
+
:display_name => "Seconds", :range => 0..59
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
[
|
|
32
|
+
[0x8e, 0x21, 0x00]
|
|
33
|
+
].each {|arr|
|
|
34
|
+
f = DPT10.read(arr.pack('C*'))
|
|
35
|
+
puts arr.inspect + " ==> " + f.inspect
|
|
36
|
+
# f.data = -10
|
|
37
|
+
# puts "after set() ==> " + f.inspect + " serialized as " + f.to_binary_s.unpack("H*").join('0x')
|
|
38
|
+
#f.dayofweek.get_parameter(:range)
|
|
39
|
+
}
|
|
40
|
+
=begin
|
|
41
|
+
[
|
|
42
|
+
# DPT11.001 date
|
|
43
|
+
[0x17, 0x01, 0x0C] # 23/Jan/2012
|
|
44
|
+
].each {|arr|
|
|
45
|
+
=end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'bindata'
|
|
2
|
+
|
|
3
|
+
class DPT9_Float < BinData::Primitive
|
|
4
|
+
endian :big
|
|
5
|
+
#
|
|
6
|
+
bit1 :sign, :display_name => "Sign"
|
|
7
|
+
bit4 :exp, :display_name => "Exponent"
|
|
8
|
+
bit11 :mant, :display_name => "Mantissa"
|
|
9
|
+
#
|
|
10
|
+
def get
|
|
11
|
+
#puts "get, sign=#{sign} exp=#{exp} mant=#{mant}"
|
|
12
|
+
mantissa = (self.sign==1) ? ~(self.mant^2047) : self.mant
|
|
13
|
+
return Math.ldexp((0.01*mantissa), self.exp)
|
|
14
|
+
end
|
|
15
|
+
#
|
|
16
|
+
def set(v)
|
|
17
|
+
mantissa, exponent = Math.frexp(v)
|
|
18
|
+
#puts "#{self}.set(#{v}) with initial mantissa=#{mantissa}, exponent=#{exponent}"
|
|
19
|
+
# find the minimum exponent that will upsize the normalized mantissa (0,5 to 1 range)
|
|
20
|
+
# in order to fit in 11 bits (-2048..2047)
|
|
21
|
+
max_mantissa = 0
|
|
22
|
+
minimum_exp = exponent.downto(0).find{ | e |
|
|
23
|
+
max_mantissa = Math.ldexp(100*mantissa, e).to_i
|
|
24
|
+
max_mantissa.between?(-2048, 2047)
|
|
25
|
+
}
|
|
26
|
+
self.sign = (mantissa < 0) ? 1 : 0
|
|
27
|
+
self.mant = (mantissa < 0) ? ~(max_mantissa^2047) : max_mantissa
|
|
28
|
+
self.exp = exponent - minimum_exp
|
|
29
|
+
#puts "... set(#{v}) finished: sign=#{sign}, mantissa=#{mant}, exponent=#{exp}"
|
|
30
|
+
end # set
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class DPT9 < BinData::Record
|
|
34
|
+
dpt9_float :data
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
#forward test (raw data to float)
|
|
39
|
+
DPT9.read([0x03, 0xe8].pack('C*')).data => 10,
|
|
40
|
+
DPT9.read([0x84, 0x18].pack('C*')).data => -10,
|
|
41
|
+
DPT9.read([0x0D, 0xDC].pack('C*')).data => 30,
|
|
42
|
+
DPT9.read([0x8a, 0x24].pack('C*')).data => -30,
|
|
43
|
+
DPT9.read([0x5c, 0xc4].pack('C*')).data => 24980..25000,
|
|
44
|
+
DPT9.read([0xdb, 0x3c].pack('C*')).data => -25000..-24980,
|
|
45
|
+
#backward test (float to raw data)
|
|
46
|
+
"----" => "----",
|
|
47
|
+
DPT9_Float.new(-30).to_binary_s.unpack("C*") => [0x8a, 0x24]
|
|
48
|
+
}.each {|arr, test|
|
|
49
|
+
#f = DPT9.read(arr.pack('C*'))
|
|
50
|
+
puts arr.inspect + " ==> " + test.inspect + " \t TEST: " + (test === arr ? 'ok':'FAIL')
|
|
51
|
+
# f.data = -30
|
|
52
|
+
# puts "after set() ==> " + f.inspect + " serialized as " + f.to_binary_s.unpack('B*').join(' ') + " (0x" + f.to_binary_s.unpack("H*").join('') + ")"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
data/lib/ansible/transceiver.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'ansible/zwave/zwave_transceiver'
|
|
@@ -22,8 +22,6 @@ for more information on the LGPL, see:
|
|
|
22
22
|
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
|
|
23
23
|
=end
|
|
24
24
|
|
|
25
|
-
require 'config'
|
|
26
|
-
|
|
27
25
|
# a generic Rexegp to parse C/C++ enums, must substitute %s in-place with enumeration name
|
|
28
26
|
ENUM_RE = %q(.*
|
|
29
27
|
enum \s* %s \s*
|
|
@@ -72,9 +70,7 @@ module OpenZWave
|
|
|
72
70
|
ControllerStates = parse_ozw_headers( File.join(OZW_SRC, "Driver.h"), "ControllerState" )
|
|
73
71
|
ValueGenres = parse_ozw_headers( File.join(OZW_SRC, "value_classes", "ValueID.h"), "ValueGenre" )
|
|
74
72
|
ValueTypes = parse_ozw_headers( File.join(OZW_SRC, "value_classes", "ValueID.h"), "ValueType" )
|
|
75
|
-
|
|
73
|
+
|
|
76
74
|
end
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
#CommandClassesByID defined in zwave_command_classes.rb
|
|
80
|
-
|
|
76
|
+
# CommandClassesByID defined in zwave_command_classes.rb
|
|
File without changes
|
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
//-----------------------------------------------------------------------------
|
|
2
|
+
//
|
|
3
|
+
// Driver.h
|
|
4
|
+
//
|
|
5
|
+
// Communicates with a Z-Wave network
|
|
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 _Driver_H
|
|
29
|
+
#define _Driver_H
|
|
30
|
+
|
|
31
|
+
#include <string>
|
|
32
|
+
#include <map>
|
|
33
|
+
#include <list>
|
|
34
|
+
|
|
35
|
+
#include "Defs.h"
|
|
36
|
+
#include "ValueID.h"
|
|
37
|
+
#include "Node.h"
|
|
38
|
+
#include "TimeStamp.h"
|
|
39
|
+
|
|
40
|
+
namespace OpenZWave
|
|
41
|
+
{
|
|
42
|
+
class Msg;
|
|
43
|
+
class Value;
|
|
44
|
+
class Event;
|
|
45
|
+
class Mutex;
|
|
46
|
+
class Controller;
|
|
47
|
+
class Thread;
|
|
48
|
+
class ControllerReplication;
|
|
49
|
+
class Notification;
|
|
50
|
+
|
|
51
|
+
/** \brief The Driver class handles communication between OpenZWave
|
|
52
|
+
* and a device attached via a serial port (typically a controller).
|
|
53
|
+
*/
|
|
54
|
+
class Driver
|
|
55
|
+
{
|
|
56
|
+
friend class Manager;
|
|
57
|
+
friend class Node;
|
|
58
|
+
friend class Group;
|
|
59
|
+
friend class CommandClass;
|
|
60
|
+
friend class Value;
|
|
61
|
+
friend class ValueStore;
|
|
62
|
+
friend class ValueButton;
|
|
63
|
+
friend class Association;
|
|
64
|
+
friend class Basic;
|
|
65
|
+
friend class ManufacturerSpecific;
|
|
66
|
+
friend class NodeNaming;
|
|
67
|
+
friend class WakeUp;
|
|
68
|
+
|
|
69
|
+
//-----------------------------------------------------------------------------
|
|
70
|
+
// Controller Interfaces
|
|
71
|
+
//-----------------------------------------------------------------------------
|
|
72
|
+
public:
|
|
73
|
+
enum ControllerInterface
|
|
74
|
+
{
|
|
75
|
+
ControllerInterface_Serial = 0,
|
|
76
|
+
ControllerInterface_Hid
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//-----------------------------------------------------------------------------
|
|
80
|
+
// Construction / Destruction
|
|
81
|
+
//-----------------------------------------------------------------------------
|
|
82
|
+
private:
|
|
83
|
+
/**
|
|
84
|
+
* Creates threads, events and initializes member variables and the node array.
|
|
85
|
+
*/
|
|
86
|
+
Driver( string const& _controllerPath, ControllerInterface const& _interface );
|
|
87
|
+
/** Sets "exit" flags and stops the three background threads (pollThread, serialThread
|
|
88
|
+
* and driverThread). Then clears out the send queue and node array. Notifies
|
|
89
|
+
* watchers and exits.
|
|
90
|
+
*/
|
|
91
|
+
virtual ~Driver();
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Start the driverThread
|
|
95
|
+
*/
|
|
96
|
+
void Start();
|
|
97
|
+
/**
|
|
98
|
+
* Entry point for driverThread
|
|
99
|
+
*/
|
|
100
|
+
static void DriverThreadEntryPoint( Event* _exitEvent, void* _context );
|
|
101
|
+
/**
|
|
102
|
+
* ThreadProc for driverThread. This is where all the "action" takes place.
|
|
103
|
+
* <p>
|
|
104
|
+
* First, the thread is initialized by calling Init(). If Init() fails, it will be retried
|
|
105
|
+
* every 5 seconds for the first two minutes and every 30 seconds thereafter.
|
|
106
|
+
* <p>
|
|
107
|
+
* After the thread is successfully initialized, the thread enters a loop with the
|
|
108
|
+
* following elements:
|
|
109
|
+
* - Confirm that m_exit is still false (or exit from the thread if it is true)
|
|
110
|
+
* - Call ReadMsg() to consume any available messages from the controller
|
|
111
|
+
* - Call NotifyWatchers() to send any pending notifications
|
|
112
|
+
* - If the thread is not waiting for an ACK, a callback or a message reply, send [any][the next] queued message[s]
|
|
113
|
+
* - If there was no message read or sent (workDone=false), sleep for 5 seconds. If nothing happened
|
|
114
|
+
* within this time frame and something was expected (ACK, callback or reply), retrieve the
|
|
115
|
+
* last message from the send queue and examine GetSendAttempts(). If greater than 2, give up
|
|
116
|
+
* and remove the message from the queue. Otherwise, resend the message.
|
|
117
|
+
* - If something did happen [reset m_wakeEvent]
|
|
118
|
+
*/
|
|
119
|
+
void DriverThreadProc( Event* _exitEvent );
|
|
120
|
+
/**
|
|
121
|
+
* Initialize the controller. Open the specified serial port, start the serialThread
|
|
122
|
+
* and pollThread, then send a NAK to the device [presumably to flush it].
|
|
123
|
+
* <p>
|
|
124
|
+
* Then queue the commands to retrieve the Z-Wave interface:
|
|
125
|
+
* - Get version
|
|
126
|
+
* - Get home and node IDs
|
|
127
|
+
* - Get controller capabilities
|
|
128
|
+
* - Get serial API capabilties
|
|
129
|
+
* - [Get SUC node ID]
|
|
130
|
+
* - Get init data [identifying the nodes on the network]
|
|
131
|
+
* Init() will return false if the serial port could not be opened.
|
|
132
|
+
*/
|
|
133
|
+
bool Init( uint32 _attempts );
|
|
134
|
+
|
|
135
|
+
Thread* m_driverThread; /**< Thread for reading from the Z-Wave controller, and for creating and managing the other threads for sending, polling etc. */
|
|
136
|
+
bool m_exit; /**< Flag that is set when the application is exiting. */
|
|
137
|
+
bool m_init; /**< Set to true once the driver has been initialised */
|
|
138
|
+
bool m_awakeNodesQueried; /**< Set to true once the driver has polled all awake nodes */
|
|
139
|
+
bool m_allNodesQueried; /**< Set to true once the driver has polled all nodes */
|
|
140
|
+
bool m_notifytransactions;
|
|
141
|
+
TimeStamp m_startTime; /**< Time this driver started (for log report purposes) */
|
|
142
|
+
|
|
143
|
+
//-----------------------------------------------------------------------------
|
|
144
|
+
// Configuration
|
|
145
|
+
//-----------------------------------------------------------------------------
|
|
146
|
+
private:
|
|
147
|
+
void RequestConfig(); // Get the network configuration from the Z-Wave network
|
|
148
|
+
bool ReadConfig(); // Read the configuration from a file
|
|
149
|
+
void WriteConfig(); // Save the configuration to a file
|
|
150
|
+
|
|
151
|
+
//-----------------------------------------------------------------------------
|
|
152
|
+
// Controller
|
|
153
|
+
//-----------------------------------------------------------------------------
|
|
154
|
+
private:
|
|
155
|
+
// Controller Capabilities (return in FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES)
|
|
156
|
+
enum
|
|
157
|
+
{
|
|
158
|
+
ControllerCaps_Secondary = 0x01, /**< The controller is a secondary. */
|
|
159
|
+
ControllerCaps_OnOtherNetwork = 0x02, /**< The controller is not using its default HomeID. */
|
|
160
|
+
ControllerCaps_SIS = 0x04, /**< There is a SUC ID Server on the network. */
|
|
161
|
+
ControllerCaps_RealPrimary = 0x08, /**< Controller was the primary before the SIS was added. */
|
|
162
|
+
ControllerCaps_SUC = 0x10 /**< Controller is a static update controller. */
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Init Capabilities (return in FUNC_ID_SERIAL_API_GET_INIT_DATA)
|
|
166
|
+
enum
|
|
167
|
+
{
|
|
168
|
+
InitCaps_Slave = 0x01, /**< */
|
|
169
|
+
InitCaps_TimerSupport = 0x02, /**< Controller supports timers. */
|
|
170
|
+
InitCaps_Secondary = 0x04, /**< Controller is a secondary. */
|
|
171
|
+
InitCaps_SUC = 0x08, /**< Controller is a static update controller. */
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
bool IsPrimaryController()const{ return ((m_initCaps & InitCaps_Secondary) == 0); }
|
|
175
|
+
bool IsStaticUpdateController()const{ return ((m_initCaps & InitCaps_SUC) != 0); }
|
|
176
|
+
bool IsBridgeController()const{ return (m_libraryType == 7); }
|
|
177
|
+
bool IsInclusionController()const{ return ((m_controllerCaps & ControllerCaps_SIS) != 0); }
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
uint32 GetHomeId()const{ return m_homeId; }
|
|
181
|
+
uint8 GetNodeId()const{ return m_nodeId; }
|
|
182
|
+
uint16 GetManufacturerId()const{ return m_manufacturerId; }
|
|
183
|
+
uint16 GetProductType()const{ return m_productType; }
|
|
184
|
+
uint16 GetProductId()const{ return m_productId; }
|
|
185
|
+
string GetControllerPath()const{ return m_controllerPath; }
|
|
186
|
+
string GetLibraryVersion()const{ return m_libraryVersion; }
|
|
187
|
+
string GetLibraryTypeName()const{ return m_libraryTypeName; }
|
|
188
|
+
int32 GetSendQueueCount()const
|
|
189
|
+
{
|
|
190
|
+
int32 count = 0;
|
|
191
|
+
for( int32 i=0; i<MsgQueue_Count; ++i )
|
|
192
|
+
{
|
|
193
|
+
count += m_msgQueue[i].size();
|
|
194
|
+
}
|
|
195
|
+
return count;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* A version of GetNode that does not have the protective "lock" and "release" requirement.
|
|
200
|
+
* This function can be used within driverThread, which "knows" that the node will not be
|
|
201
|
+
* changed or deleted while it is being used.
|
|
202
|
+
* \param _nodeId The nodeId (index into the node array) identifying the node to be returned
|
|
203
|
+
* \return
|
|
204
|
+
* A pointer to the specified node (if it exists) or NULL if not.
|
|
205
|
+
* \see GetNode
|
|
206
|
+
*/
|
|
207
|
+
Node* GetNodeUnsafe( uint8 _nodeId );
|
|
208
|
+
/**
|
|
209
|
+
* Locks the node array and returns the specified node (if it exists). If a node is returned,
|
|
210
|
+
* the lock must be released after the node has been processed via a call to ReleaseNodes().
|
|
211
|
+
* If the node specified by _nodeId does not exist, the lock is released and NULL is returned.
|
|
212
|
+
* \param _nodeId The nodeId (index into the node array) identifying the node to be returned
|
|
213
|
+
* \return
|
|
214
|
+
* A pointer to the specified node (if it exists) or NULL if not.
|
|
215
|
+
* \see LockNodes, ReleaseNodes
|
|
216
|
+
*/
|
|
217
|
+
Node* GetNode( uint8 _nodeId );
|
|
218
|
+
/**
|
|
219
|
+
* Lock the nodes so no other thread can modify them.
|
|
220
|
+
*/
|
|
221
|
+
void LockNodes();
|
|
222
|
+
/**
|
|
223
|
+
* Release the lock on the nodes so other threads can modify them.
|
|
224
|
+
*/
|
|
225
|
+
void ReleaseNodes();
|
|
226
|
+
|
|
227
|
+
ControllerInterface m_controllerInterfaceType; // Specifies the controller's hardware interface
|
|
228
|
+
string m_controllerPath; // name or path used to open the controller hardware.
|
|
229
|
+
Controller* m_controller; // Handles communications with the controller hardware.
|
|
230
|
+
uint32 m_homeId; // Home ID of the Z-Wave controller. Not valid until the DriverReady notification has been received.
|
|
231
|
+
|
|
232
|
+
string m_libraryVersion; // Verison of the Z-Wave Library used by the controller.
|
|
233
|
+
string m_libraryTypeName; // Name describing the library type.
|
|
234
|
+
uint8 m_libraryType; // Type of library used by the controller.
|
|
235
|
+
|
|
236
|
+
uint16 m_manufacturerId;
|
|
237
|
+
uint16 m_productType;
|
|
238
|
+
uint16 m_productId;
|
|
239
|
+
uint8 m_apiMask[32];
|
|
240
|
+
|
|
241
|
+
uint8 m_initVersion; // Version of the Serial API used by the controller.
|
|
242
|
+
uint8 m_initCaps; // Set of flags indicating the serial API capabilities (See IsSlave, HasTimerSupport, IsPrimaryController and IsStaticUpdateController above).
|
|
243
|
+
uint8 m_controllerCaps; // Set of flags indicating the controller's capabilities (See IsInclusionController above).
|
|
244
|
+
uint8 m_nodeId; // Z-Wave Controller's own node ID.
|
|
245
|
+
Node* m_nodes[256]; // Array containing all the node objects.
|
|
246
|
+
Mutex* m_nodeMutex; // Serializes access to node data
|
|
247
|
+
|
|
248
|
+
ControllerReplication* m_controllerReplication; // Controller replication is handled separately from the other command classes, due to older hand-held controllers using invalid node IDs.
|
|
249
|
+
|
|
250
|
+
//-----------------------------------------------------------------------------
|
|
251
|
+
// Sending Z-Wave messages
|
|
252
|
+
//-----------------------------------------------------------------------------
|
|
253
|
+
public:
|
|
254
|
+
enum MsgQueue
|
|
255
|
+
{
|
|
256
|
+
MsgQueue_Command = 0,
|
|
257
|
+
MsgQueue_WakeUp,
|
|
258
|
+
MsgQueue_Send,
|
|
259
|
+
MsgQueue_Query,
|
|
260
|
+
MsgQueue_Poll,
|
|
261
|
+
MsgQueue_Count // Number of message queues
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
void SendMsg( Msg* _msg, MsgQueue const _queue );
|
|
265
|
+
|
|
266
|
+
private:
|
|
267
|
+
/**
|
|
268
|
+
* If there are messages in the send queue (m_sendQueue), gets the next message in the
|
|
269
|
+
* queue and writes it to the serial port. In sending the message, SendMsg also initializes
|
|
270
|
+
* variables tracking the message's callback ID (m_expectedCallbackId), expected reply
|
|
271
|
+
* (m_expectedReply) and expected command class ID (m_expectedCommandClassId). It also
|
|
272
|
+
* sets m_waitingForAck to true and increments the message's send attempts counter.
|
|
273
|
+
* <p>
|
|
274
|
+
* If there are no messages in the send queue, then SendMsg checks the query queue to
|
|
275
|
+
* see if there are any outstanding queries that can be processed (target node not asleep).
|
|
276
|
+
* If so, it retrieves the Node object that needs to be queried and calls that node's
|
|
277
|
+
* AdvanceQueries member function. If this call results in all of the node's queries to be
|
|
278
|
+
* completed, SendMsg will remove the node query item from the query queue.
|
|
279
|
+
* \return TRUE if data was written, FALSE if not
|
|
280
|
+
* \see Msg, m_sendQueue, m_expectedCallbackId, m_expectedReply, m_expectedCommandClassId,
|
|
281
|
+
* m_waitingForAck, Msg::GetSendAttempts, Node::AdvanceQueries, GetCurrentNodeQuery,
|
|
282
|
+
* RemoveNodeQuery, Node::AllQueriesCompleted
|
|
283
|
+
*/
|
|
284
|
+
bool WriteNextMsg( MsgQueue const _queue ); // Extracts the first message from the queue, and makes it the current one.
|
|
285
|
+
bool WriteMsg( string const str); // Sends the current message to the Z-Wave network
|
|
286
|
+
void RemoveCurrentMsg(); // Deletes the current message and cleans up the callback etc states
|
|
287
|
+
bool MoveMessagesToWakeUpQueue( uint8 const _targetNodeId ); // If a node does not respond, and is of a type that can sleep, this method is used to move all its pending messages to another queue ready for when it mext wakes up.
|
|
288
|
+
bool IsControllerCommand( uint8 const _command ); // identify controller commands
|
|
289
|
+
bool IsExpectedReply( uint8 const _nodeId ); // Determine if reply message is the one we are expecting
|
|
290
|
+
void SendQueryStageComplete( uint8 const _nodeId, Node::QueryStage const _stage, MsgQueue const _queue );
|
|
291
|
+
void CheckCompletedNodeQueries(); // Send notifications if all awake and/or sleeping nodes have completed their queries
|
|
292
|
+
|
|
293
|
+
// Requests to be sent to nodes are assigned to one of five queues.
|
|
294
|
+
// From highest to lowest priority, these are
|
|
295
|
+
//
|
|
296
|
+
// 1) The command queue, for controller commands. This is the highest
|
|
297
|
+
// priority send queue, because the controller command processes are not
|
|
298
|
+
// permitted to be interupted by other requests.
|
|
299
|
+
//
|
|
300
|
+
// 2) The wakeup queue. This holds messages that have been held for a
|
|
301
|
+
// sleeping device that has now woken up. These gwt a high priority
|
|
302
|
+
// because such devices do not stay awake for very long.
|
|
303
|
+
//
|
|
304
|
+
// 3) The send queue. This is for normal messages, usually triggered by
|
|
305
|
+
// a user interaction with the application.
|
|
306
|
+
//
|
|
307
|
+
// 4) The query queue. For node query messages sent when a new node is
|
|
308
|
+
// discovered. The query process generates a large number of requests,
|
|
309
|
+
// so the query queue has a low priority to avoid making the system
|
|
310
|
+
// unresponsive.
|
|
311
|
+
//
|
|
312
|
+
// 5) The poll queue. Requests to devices that need their state polling
|
|
313
|
+
// at regular intervals. These are of the lowest priority, and are only
|
|
314
|
+
// sent when nothing else is going on
|
|
315
|
+
enum MsgQueueCmd
|
|
316
|
+
{
|
|
317
|
+
MsgQueueCmd_SendMsg = 0,
|
|
318
|
+
MsgQueueCmd_QueryStageComplete
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
class MsgQueueItem
|
|
322
|
+
{
|
|
323
|
+
public:
|
|
324
|
+
bool operator == ( MsgQueueItem const& _other )const
|
|
325
|
+
{
|
|
326
|
+
if( _other.m_command == m_command )
|
|
327
|
+
{
|
|
328
|
+
if( m_command == MsgQueueCmd_SendMsg )
|
|
329
|
+
{
|
|
330
|
+
return( (*_other.m_msg) == (*m_msg) );
|
|
331
|
+
}
|
|
332
|
+
else
|
|
333
|
+
{
|
|
334
|
+
return( (_other.m_nodeId == m_nodeId) && (_other.m_queryStage == m_queryStage) );
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
MsgQueueCmd m_command;
|
|
342
|
+
Msg* m_msg;
|
|
343
|
+
uint8 m_nodeId;
|
|
344
|
+
Node::QueryStage m_queryStage;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
list<MsgQueueItem> m_msgQueue[MsgQueue_Count];
|
|
348
|
+
Event* m_queueEvent[MsgQueue_Count]; // Events for each queue, which are signalled when the queue is not empty
|
|
349
|
+
Mutex* m_sendMutex; // Serialize access to the queues
|
|
350
|
+
Msg* m_currentMsg;
|
|
351
|
+
TimeStamp m_resendTimeStamp;
|
|
352
|
+
|
|
353
|
+
//-----------------------------------------------------------------------------
|
|
354
|
+
// Receiving Z-Wave messages
|
|
355
|
+
//-----------------------------------------------------------------------------
|
|
356
|
+
private:
|
|
357
|
+
bool ReadMsg();
|
|
358
|
+
void ProcessMsg( uint8* _data );
|
|
359
|
+
|
|
360
|
+
void HandleGetVersionResponse( uint8* _data );
|
|
361
|
+
void HandleGetControllerCapabilitiesResponse( uint8* _data );
|
|
362
|
+
void HandleGetSerialAPICapabilitiesResponse( uint8* _data );
|
|
363
|
+
void HandleSerialAPISoftResetResponse( uint8* _data );
|
|
364
|
+
void HandleEnableSUCResponse( uint8* _data );
|
|
365
|
+
void HandleSetSUCNodeIdResponse( uint8* _data );
|
|
366
|
+
void HandleGetSUCNodeIdResponse( uint8* _data );
|
|
367
|
+
void HandleMemoryGetIdResponse( uint8* _data );
|
|
368
|
+
/**
|
|
369
|
+
* Process a response to a FUNC_ID_SERIAL_API_GET_INIT_DATA request.
|
|
370
|
+
* <p>
|
|
371
|
+
* The response message contains a bitmap identifying which of the 232 possible nodes
|
|
372
|
+
* in the network are actually present. These bitmap values are compared with the
|
|
373
|
+
* node map (read in from zwcfg_0x[homeid].xml) to see if the node has already been registered
|
|
374
|
+
* by the OpenZWave library. If it has (the log will show it as "Known") and this is
|
|
375
|
+
* the first time this message was sent (m_init is false), then AddNodeQuery() is called
|
|
376
|
+
* to retrieve its current state. If this is a "New" node to OpenZWave, then InitNode()
|
|
377
|
+
* is called.
|
|
378
|
+
* \see AddNodeQuery, InitNode, GetNode, ReleaseNodes
|
|
379
|
+
*/
|
|
380
|
+
void HandleSerialAPIGetInitDataResponse( uint8* _data );
|
|
381
|
+
void HandleGetNodeProtocolInfoResponse( uint8* _data );
|
|
382
|
+
bool HandleRemoveFailedNodeResponse( uint8* _data );
|
|
383
|
+
void HandleIsFailedNodeResponse( uint8* _data );
|
|
384
|
+
bool HandleReplaceFailedNodeResponse( uint8* _data );
|
|
385
|
+
bool HandleAssignReturnRouteResponse( uint8* _data );
|
|
386
|
+
bool HandleDeleteReturnRouteResponse( uint8* _data );
|
|
387
|
+
void HandleSendDataResponse( uint8* _data, bool _replication );
|
|
388
|
+
bool HandleNetworkUpdateResponse( uint8* _data );
|
|
389
|
+
void HandleGetRoutingInfoResponse( uint8* _data );
|
|
390
|
+
|
|
391
|
+
void HandleSendDataRequest( uint8* _data, bool _replication );
|
|
392
|
+
void HandleAddNodeToNetworkRequest( uint8* _data );
|
|
393
|
+
void HandleCreateNewPrimaryRequest( uint8* _data );
|
|
394
|
+
void HandleControllerChangeRequest( uint8* _data );
|
|
395
|
+
void HandleSetLearnModeRequest( uint8* _data );
|
|
396
|
+
void HandleRemoveFailedNodeRequest( uint8* _data );
|
|
397
|
+
void HandleReplaceFailedNodeRequest( uint8* _data );
|
|
398
|
+
void HandleRemoveNodeFromNetworkRequest( uint8* _data );
|
|
399
|
+
void HandleApplicationCommandHandlerRequest( uint8* _data );
|
|
400
|
+
void HandlePromiscuousApplicationCommandHandlerRequest( uint8* _data );
|
|
401
|
+
void HandleAssignReturnRouteRequest( uint8* _data );
|
|
402
|
+
void HandleDeleteReturnRouteRequest( uint8* _data );
|
|
403
|
+
void HandleNodeNeighborUpdateRequest( uint8* _data );
|
|
404
|
+
void HandleNetworkUpdateRequest( uint8* _data );
|
|
405
|
+
bool HandleApplicationUpdateRequest( uint8* _data );
|
|
406
|
+
bool HandleRfPowerLevelSetResponse( uint8* _data );
|
|
407
|
+
bool HandleSerialApiSetTimeoutsResponse( uint8* _data );
|
|
408
|
+
bool HandleMemoryGetByteResponse( uint8* _data );
|
|
409
|
+
bool HandleReadMemoryResponse( uint8* _data );
|
|
410
|
+
void HandleGetVirtualNodesResponse( uint8* _data );
|
|
411
|
+
bool HandleSetSlaveLearnModeResponse( uint8* _data );
|
|
412
|
+
void HandleSetSlaveLearnModeRequest( uint8* _data );
|
|
413
|
+
bool HandleSendSlaveNodeInfoResponse( uint8* _data );
|
|
414
|
+
void HandleSendSlaveNodeInfoRequest( uint8* _data );
|
|
415
|
+
void HandleApplicationSlaveCommandRequest( uint8* _data );
|
|
416
|
+
|
|
417
|
+
void CommonAddNodeStatusRequestHandler( uint8 _funcId, uint8* _data );
|
|
418
|
+
|
|
419
|
+
bool m_waitingForAck; // True when we are waiting for an ACK from the dongle
|
|
420
|
+
uint8 m_expectedCallbackId; // If non-zero, we wait for a message with this callback Id
|
|
421
|
+
uint8 m_expectedReply; // If non-zero, we wait for a message with this function Id
|
|
422
|
+
uint8 m_expectedCommandClassId; // If the expected reply is FUNC_ID_APPLICATION_COMMAND_HANDLER, this value stores the command class we're waiting to hear from
|
|
423
|
+
uint8 m_expectedNodeId; // If we are waiting for a FUNC_ID_APPLICATION_COMMAND_HANDLER, make sure we only accept it from this node.
|
|
424
|
+
|
|
425
|
+
//-----------------------------------------------------------------------------
|
|
426
|
+
// Polling Z-Wave devices
|
|
427
|
+
//-----------------------------------------------------------------------------
|
|
428
|
+
private:
|
|
429
|
+
int32 GetPollInterval(){ return m_pollInterval ; }
|
|
430
|
+
void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls ){ m_pollInterval = _milliseconds; m_bIntervalBetweenPolls = _bIntervalBetweenPolls; }
|
|
431
|
+
bool EnablePoll( ValueID _valueId, uint8 _intensity = 1 );
|
|
432
|
+
bool DisablePoll( ValueID _valueId );
|
|
433
|
+
bool isPolled( ValueID _valueId );
|
|
434
|
+
void SetPollIntensity( ValueID _valueId, uint8 _intensity );
|
|
435
|
+
static void PollThreadEntryPoint( Event* _exitEvent, void* _context );
|
|
436
|
+
void PollThreadProc( Event* _exitEvent );
|
|
437
|
+
|
|
438
|
+
Thread* m_pollThread; // Thread for polling devices on the Z-Wave network
|
|
439
|
+
struct PollEntry
|
|
440
|
+
{
|
|
441
|
+
ValueID m_id;
|
|
442
|
+
uint8 m_pollCounter;
|
|
443
|
+
};
|
|
444
|
+
list<PollEntry> m_pollList; // List of nodes that need to be polled
|
|
445
|
+
Mutex* m_pollMutex; // Serialize access to the polling list
|
|
446
|
+
int32 m_pollInterval; // Time interval during which all nodes must be polled
|
|
447
|
+
bool m_bIntervalBetweenPolls; // if true, the library intersperses m_pollInterval between polls; if false, the library attempts to complete all polls within m_pollInterval
|
|
448
|
+
|
|
449
|
+
//-----------------------------------------------------------------------------
|
|
450
|
+
// Retrieving Node information
|
|
451
|
+
//-----------------------------------------------------------------------------
|
|
452
|
+
public:
|
|
453
|
+
uint8 GetNodeNumber( Msg const* _msg )const
|
|
454
|
+
{
|
|
455
|
+
if( _msg == NULL )
|
|
456
|
+
{
|
|
457
|
+
return 0;
|
|
458
|
+
}
|
|
459
|
+
else
|
|
460
|
+
{
|
|
461
|
+
return _msg->GetTargetNodeId();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
private:
|
|
465
|
+
/**
|
|
466
|
+
* Creates a new Node object (deleting any previous Node object with the same nodeId) and
|
|
467
|
+
* queues a full query of the node's parameters (starting at the beginning of the query
|
|
468
|
+
* stages--Node::QueryStage_None). This function will send Notification::Type_NodeAdded
|
|
469
|
+
* and Notification::Type_NodeRemoved messages to identify these modifications.
|
|
470
|
+
* \param _nodeId The node ID of the node to create and query.
|
|
471
|
+
* \see Notification::Type_NodeAdded, Notification::Type_NodeRemoved, Node::QueryStage_None,
|
|
472
|
+
*/
|
|
473
|
+
void InitNode( uint8 const _nodeId );
|
|
474
|
+
|
|
475
|
+
void InitAllNodes(); // Delete all nodes and fetch the data from the Z-Wave network again.
|
|
476
|
+
|
|
477
|
+
bool IsNodeListeningDevice( uint8 const _nodeId );
|
|
478
|
+
bool IsNodeFrequentListeningDevice( uint8 const _nodeId );
|
|
479
|
+
bool IsNodeBeamingDevice( uint8 const _nodeId );
|
|
480
|
+
bool IsNodeRoutingDevice( uint8 const _nodeId );
|
|
481
|
+
bool IsNodeSecurityDevice( uint8 const _nodeId );
|
|
482
|
+
uint32 GetNodeMaxBaudRate( uint8 const _nodeId );
|
|
483
|
+
uint8 GetNodeVersion( uint8 const _nodeId );
|
|
484
|
+
uint8 GetNodeSecurity( uint8 const _nodeId );
|
|
485
|
+
uint8 GetNodeBasic( uint8 const _nodeId );
|
|
486
|
+
uint8 GetNodeGeneric( uint8 const _nodeId );
|
|
487
|
+
uint8 GetNodeSpecific( uint8 const _nodeId );
|
|
488
|
+
string GetNodeType( uint8 const _nodeId );
|
|
489
|
+
uint32 GetNodeNeighbors( uint8 const _nodeId, uint8** o_neighbors );
|
|
490
|
+
|
|
491
|
+
string GetNodeManufacturerName( uint8 const _nodeId );
|
|
492
|
+
string GetNodeProductName( uint8 const _nodeId );
|
|
493
|
+
string GetNodeName( uint8 const _nodeId );
|
|
494
|
+
string GetNodeLocation( uint8 const _nodeId );
|
|
495
|
+
|
|
496
|
+
string GetNodeManufacturerId( uint8 const _nodeId );
|
|
497
|
+
string GetNodeProductType( uint8 const _nodeId );
|
|
498
|
+
string GetNodeProductId( uint8 const _nodeId );
|
|
499
|
+
void SetNodeManufacturerName( uint8 const _nodeId, string const& _manufacturerName );
|
|
500
|
+
void SetNodeProductName( uint8 const _nodeId, string const& _productName );
|
|
501
|
+
void SetNodeName( uint8 const _nodeId, string const& _nodeName );
|
|
502
|
+
void SetNodeLocation( uint8 const _nodeId, string const& _location );
|
|
503
|
+
void SetNodeLevel( uint8 const _nodeId, uint8 const _level );
|
|
504
|
+
void SetNodeOn( uint8 const _nodeId );
|
|
505
|
+
void SetNodeOff( uint8 const _nodeId );
|
|
506
|
+
|
|
507
|
+
Value* GetValue( ValueID const& _id );
|
|
508
|
+
|
|
509
|
+
bool IsAPICallSupported( uint8 const _apinum )const{ return (( m_apiMask[( _apinum - 1 ) >> 3] & ( 1 << (( _apinum - 1 ) & 0x07 ))) != 0 ); }
|
|
510
|
+
void SetAPICall( uint8 const _apinum, bool _toSet )
|
|
511
|
+
{
|
|
512
|
+
if( _toSet )
|
|
513
|
+
{
|
|
514
|
+
m_apiMask[( _apinum - 1 ) >> 3] |= ( 1 << (( _apinum - 1 ) & 0x07 ));
|
|
515
|
+
}
|
|
516
|
+
else
|
|
517
|
+
{
|
|
518
|
+
m_apiMask[( _apinum - 1 ) >> 3] &= ~( 1 << (( _apinum - 1 ) & 0x07 ));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
uint8 NodeFromMessage( uint8 const* buffer );
|
|
522
|
+
|
|
523
|
+
//-----------------------------------------------------------------------------
|
|
524
|
+
// Controller commands
|
|
525
|
+
//-----------------------------------------------------------------------------
|
|
526
|
+
public:
|
|
527
|
+
/**
|
|
528
|
+
* Controller Commands.
|
|
529
|
+
* Commands to be used with the BeginControllerCommand method.
|
|
530
|
+
* \see Manager::BeginControllerCommand
|
|
531
|
+
*/
|
|
532
|
+
enum ControllerCommand
|
|
533
|
+
{
|
|
534
|
+
ControllerCommand_None = 0, /**< No command. */
|
|
535
|
+
ControllerCommand_AddController, /**< Add a new controller to the Z-Wave network. The new controller will be a secondary. */
|
|
536
|
+
ControllerCommand_AddDevice, /**< Add a new device (but not a controller) to the Z-Wave network. */
|
|
537
|
+
ControllerCommand_CreateNewPrimary, /**< Add a new controller to the Z-Wave network. The new controller will be the primary, and the current primary will become a secondary controller. */
|
|
538
|
+
ControllerCommand_ReceiveConfiguration, /**< Receive Z-Wave network configuration information from another controller. */
|
|
539
|
+
ControllerCommand_RemoveController, /**< Remove a controller from the Z-Wave network. */
|
|
540
|
+
ControllerCommand_RemoveDevice, /**< Remove a new device (but not a controller) from the Z-Wave network. */
|
|
541
|
+
ControllerCommand_RemoveFailedNode, /**< Move a node to the controller's failed nodes list. This command will only work if the node cannot respond. */
|
|
542
|
+
ControllerCommand_HasNodeFailed, /**< Check whether a node is in the controller's failed nodes list. */
|
|
543
|
+
ControllerCommand_ReplaceFailedNode, /**< Replace a non-responding node with another. The node must be in the controller's list of failed nodes for this command to succeed. */
|
|
544
|
+
ControllerCommand_TransferPrimaryRole, /**< Make a different controller the primary. */
|
|
545
|
+
ControllerCommand_RequestNetworkUpdate, /**< Request network information from the SUC/SIS. */
|
|
546
|
+
ControllerCommand_RequestNodeNeighborUpdate, /**< Get a node to rebuild its neighbour list. This method also does ControllerCommand_RequestNodeNeighbors */
|
|
547
|
+
ControllerCommand_AssignReturnRoute, /**< Assign a network return routes to a device. */
|
|
548
|
+
ControllerCommand_DeleteAllReturnRoutes, /**< Delete all return routes from a device. */
|
|
549
|
+
ControllerCommand_CreateButton, /**< Create an id that tracks handheld button presses */
|
|
550
|
+
ControllerCommand_DeleteButton /**< Delete id that tracks handheld button presses */
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Controller States.
|
|
555
|
+
* States reported via the callback handler passed into the BeginControllerCommand method.
|
|
556
|
+
* \see Manager::BeginControllerCommand
|
|
557
|
+
*/
|
|
558
|
+
enum ControllerState
|
|
559
|
+
{
|
|
560
|
+
ControllerState_Normal = 0, /**< No command in progress. */
|
|
561
|
+
ControllerState_Waiting, /**< Controller is waiting for a user action. */
|
|
562
|
+
ControllerState_InProgress, /**< The controller is communicating with the other device to carry out the command. */
|
|
563
|
+
ControllerState_Completed, /**< The command has completed successfully. */
|
|
564
|
+
ControllerState_Failed, /**< The command has failed. */
|
|
565
|
+
ControllerState_NodeOK, /**< Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node is OK. */
|
|
566
|
+
ControllerState_NodeFailed /**< Used only with ControllerCommand_HasNodeFailed to indicate that the controller thinks the node has failed. */
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
typedef void (*pfnControllerCallback_t)( ControllerState _state, void* _context );
|
|
570
|
+
|
|
571
|
+
private:
|
|
572
|
+
// The public interface is provided via the wrappers in the Manager class
|
|
573
|
+
void ResetController();
|
|
574
|
+
void SoftReset();
|
|
575
|
+
void RequestNodeNeighbors( uint8 const _nodeId, uint32 const _requestFlags );
|
|
576
|
+
|
|
577
|
+
bool BeginControllerCommand( ControllerCommand _command, pfnControllerCallback_t _callback, void* _context, bool _highPower, uint8 _nodeId, uint8 _arg );
|
|
578
|
+
bool CancelControllerCommand();
|
|
579
|
+
|
|
580
|
+
ControllerState m_controllerState;
|
|
581
|
+
ControllerCommand m_controllerCommand;
|
|
582
|
+
pfnControllerCallback_t m_controllerCallback;
|
|
583
|
+
void* m_controllerCallbackContext;
|
|
584
|
+
bool m_controllerAdded;
|
|
585
|
+
uint8 m_controllerCommandNode;
|
|
586
|
+
uint8 m_controllerCommandArg;
|
|
587
|
+
|
|
588
|
+
uint8 m_SUCNode;
|
|
589
|
+
|
|
590
|
+
//-----------------------------------------------------------------------------
|
|
591
|
+
// Virtual Node commands
|
|
592
|
+
//-----------------------------------------------------------------------------
|
|
593
|
+
public:
|
|
594
|
+
/**
|
|
595
|
+
* Virtual Node Commands.
|
|
596
|
+
* Commands to be used with virtual nodes.
|
|
597
|
+
*/
|
|
598
|
+
private:
|
|
599
|
+
uint32 GetVirtualNeighbors( uint8** o_neighbors );
|
|
600
|
+
void RequestVirtualNeighbors( MsgQueue const _queue );
|
|
601
|
+
bool IsVirtualNode( uint8 const _nodeId )const{ return (( m_virtualNeighbors[( _nodeId - 1 ) >> 3] & 1 << (( _nodeId - 1 ) & 0x07 )) != 0 ); }
|
|
602
|
+
void SendVirtualNodeInfo( uint8 const _fromNodeId, uint8 const _ToNodeId );
|
|
603
|
+
void SendSlaveLearnModeOff();
|
|
604
|
+
void SaveButtons();
|
|
605
|
+
void ReadButtons( uint8 const _nodeId );
|
|
606
|
+
|
|
607
|
+
bool m_virtualNeighborsReceived;
|
|
608
|
+
uint8 m_virtualNeighbors[NUM_NODE_BITFIELD_BYTES]; // Bitmask containing virtual neighbors
|
|
609
|
+
|
|
610
|
+
//-----------------------------------------------------------------------------
|
|
611
|
+
// SwitchAll
|
|
612
|
+
//-----------------------------------------------------------------------------
|
|
613
|
+
private:
|
|
614
|
+
// The public interface is provided via the wrappers in the Manager class
|
|
615
|
+
void SwitchAllOn();
|
|
616
|
+
void SwitchAllOff();
|
|
617
|
+
|
|
618
|
+
//-----------------------------------------------------------------------------
|
|
619
|
+
// Configuration Parameters (wrappers for the Node methods)
|
|
620
|
+
//-----------------------------------------------------------------------------
|
|
621
|
+
private:
|
|
622
|
+
// The public interface is provided via the wrappers in the Manager class
|
|
623
|
+
bool SetConfigParam( uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size );
|
|
624
|
+
void RequestConfigParam( uint8 const _nodeId, uint8 const _param );
|
|
625
|
+
|
|
626
|
+
//-----------------------------------------------------------------------------
|
|
627
|
+
// Groups (wrappers for the Node methods)
|
|
628
|
+
//-----------------------------------------------------------------------------
|
|
629
|
+
private:
|
|
630
|
+
// The public interface is provided via the wrappers in the Manager class
|
|
631
|
+
uint8 GetNumGroups( uint8 const _nodeId );
|
|
632
|
+
uint32 GetAssociations( uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations );
|
|
633
|
+
uint8 GetMaxAssociations( uint8 const _nodeId, uint8 const _groupIdx );
|
|
634
|
+
string GetGroupLabel( uint8 const _nodeId, uint8 const _groupIdx );
|
|
635
|
+
void AddAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId );
|
|
636
|
+
void RemoveAssociation( uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId );
|
|
637
|
+
|
|
638
|
+
//-----------------------------------------------------------------------------
|
|
639
|
+
// Notifications
|
|
640
|
+
//-----------------------------------------------------------------------------
|
|
641
|
+
private:
|
|
642
|
+
void QueueNotification( Notification* _notification ); // Adds a notification to the list. Notifications are queued until a point in the thread where we know we do not have any nodes locked.
|
|
643
|
+
void NotifyWatchers(); // Passes the notifications to all the registered watcher callbacks in turn.
|
|
644
|
+
|
|
645
|
+
list<Notification*> m_notifications;
|
|
646
|
+
Event* m_notificationsEvent;
|
|
647
|
+
|
|
648
|
+
//-----------------------------------------------------------------------------
|
|
649
|
+
// Statistics
|
|
650
|
+
//-----------------------------------------------------------------------------
|
|
651
|
+
public:
|
|
652
|
+
struct DriverData
|
|
653
|
+
{
|
|
654
|
+
uint32 s_SOFCnt; // Number of SOF bytes received
|
|
655
|
+
uint32 s_ACKWaiting; // Number of unsolicited messages while waiting for an ACK
|
|
656
|
+
uint32 s_readAborts; // Number of times read were aborted due to timeouts
|
|
657
|
+
uint32 s_badChecksum; // Number of bad checksums
|
|
658
|
+
uint32 s_readCnt; // Number of messages successfully read
|
|
659
|
+
uint32 s_writeCnt; // Number of messages successfully sent
|
|
660
|
+
uint32 s_CANCnt; // Number of CAN bytes received
|
|
661
|
+
uint32 s_NAKCnt; // Number of NAK bytes received
|
|
662
|
+
uint32 s_ACKCnt; // Number of ACK bytes received
|
|
663
|
+
uint32 s_OOFCnt; // Number of bytes out of framing
|
|
664
|
+
uint32 s_dropped; // Number of messages dropped & not delivered
|
|
665
|
+
uint32 s_retries; // Number of messages retransmitted
|
|
666
|
+
uint32 s_controllerReadCnt; // Number of controller messages read
|
|
667
|
+
uint32 s_controllerWriteCnt;// Number of controller messages sent
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
void LogDriverStatistics();
|
|
671
|
+
|
|
672
|
+
private:
|
|
673
|
+
void GetDriverStatistics( DriverData* _data );
|
|
674
|
+
|
|
675
|
+
uint32 m_SOFCnt; // Number of SOF bytes received
|
|
676
|
+
uint32 m_ACKWaiting; // Number of unsolcited messages while waiting for an ACK
|
|
677
|
+
uint32 m_readAborts; // Number of times read were aborted due to timeouts
|
|
678
|
+
uint32 m_badChecksum; // Number of bad checksums
|
|
679
|
+
uint32 m_readCnt; // Number of messages successfully read
|
|
680
|
+
uint32 m_writeCnt; // Number of messages successfully sent
|
|
681
|
+
uint32 m_CANCnt; // Number of CAN bytes received
|
|
682
|
+
uint32 m_NAKCnt; // Number of NAK bytes received
|
|
683
|
+
uint32 m_ACKCnt; // Number of ACK bytes received
|
|
684
|
+
uint32 m_OOFCnt; // Number of bytes out of framing
|
|
685
|
+
uint32 m_dropped; // Number of messages dropped & not delivered
|
|
686
|
+
uint32 m_retries; // Number of retransmitted messages
|
|
687
|
+
uint32 m_controllerReadCnt; // Number of messages read from controller
|
|
688
|
+
uint32 m_controllerWriteCnt;// Number of messages written to the controller
|
|
689
|
+
//time_t m_commandStart; // Start time of last command
|
|
690
|
+
//time_t m_timeoutLost; // Cumulative time lost to timeouts
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
} // namespace OpenZWave
|
|
694
|
+
|
|
695
|
+
#endif // _Driver_H
|