From a85cdcc6b9c38b6c01fc2af99c470fb014d436b6 Mon Sep 17 00:00:00 2001 From: Patrick McNeill Date: Tue, 6 Jan 2015 20:52:08 -0500 Subject: [PATCH 1/2] Instance control of switches --- src/openzwave.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/openzwave.cc b/src/openzwave.cc index 0939480..f5a2bec 100644 --- a/src/openzwave.cc +++ b/src/openzwave.cc @@ -601,7 +601,7 @@ Handle OZW::SetName(const Arguments& args) /* * Switch a COMMAND_CLASS_SWITCH_BINARY on/off */ -void set_switch(uint8_t nodeid, bool state) +void set_switch(uint8_t nodeid, bool state, uint8_t instance) { NodeInfo *node; std::list::iterator vit; @@ -609,8 +609,10 @@ void set_switch(uint8_t nodeid, bool state) if ((node = get_node_info(nodeid))) { for (vit = node->values.begin(); vit != node->values.end(); ++vit) { if ((*vit).GetCommandClassId() == 0x25) { - OpenZWave::Manager::Get()->SetValue(*vit, state); - break; + if ( ! instance || (*vit).GetInstance() == instance ) { + OpenZWave::Manager::Get()->SetValue(*vit, state); + break; + } } } } @@ -620,7 +622,13 @@ Handle OZW::SwitchOn(const Arguments& args) HandleScope scope; uint8_t nodeid = args[0]->ToNumber()->Value(); - set_switch(nodeid, true); + uint8_t instance = 0; + + if ( args.Length() > 1 ) { + instance = args[1]->ToNumber()->Value(); + } + + set_switch(nodeid, true, instance); return scope.Close(Undefined()); } @@ -629,7 +637,13 @@ Handle OZW::SwitchOff(const Arguments& args) HandleScope scope; uint8_t nodeid = args[0]->ToNumber()->Value(); - set_switch(nodeid, false); + uint8_t instance = 0; + + if ( args.Length() > 1 ) { + instance = args[1]->ToNumber()->Value(); + } + + set_switch(nodeid, false, instance); return scope.Close(Undefined()); } From 1a8ad9efc089e20246b8d5ec3fbe2781d81da90c Mon Sep 17 00:00:00 2001 From: Patrick McNeill Date: Fri, 13 Feb 2015 16:30:01 -0500 Subject: [PATCH 2/2] Uses shared openzwave --- binding.gyp | 13 ------------- src/openzwave.cc | 10 +++++----- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/binding.gyp b/binding.gyp index 626a88e..8a9b3c0 100644 --- a/binding.gyp +++ b/binding.gyp @@ -4,19 +4,6 @@ "target_name": "openzwave", "sources": [ "src/openzwave.cc" - ], - "include_dirs": [ - "deps/open-zwave/cpp/src" - "deps/open-zwave/cpp/hidapi/hidapi", - "deps/open-zwave/cpp/src", - "deps/open-zwave/cpp/src/command_classes", - "deps/open-zwave/cpp/src/platform", - "deps/open-zwave/cpp/src/platform/unix", - "deps/open-zwave/cpp/src/value_classes", - "deps/open-zwave/cpp/tinyxml" - ], - "dependencies": [ - "deps/open-zwave/libopenzwave.gyp:libopenzwave" ] } ] diff --git a/src/openzwave.cc b/src/openzwave.cc index f5a2bec..6355d46 100644 --- a/src/openzwave.cc +++ b/src/openzwave.cc @@ -22,11 +22,11 @@ #include #include -#include "Manager.h" -#include "Node.h" -#include "Notification.h" -#include "Options.h" -#include "Value.h" +#include +#include +#include +#include +#include using namespace v8; using namespace node;