Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make node-openzwave-shared build on SmartOS #272

Merged
merged 2 commits into from
Mar 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
"src/utils.cc",
],
"conditions": [
['OS=="solaris"', {
"variables": {
"OZW_INC" : "<!(pkg-config --cflags-only-I libopenzwave | sed s/-I//g)",
"OZW_LIB_PATH" : "<!(pkg-config --variable=libdir libopenzwave)",
"OZW_GITVERSION" : "<!(pkg-config --variable=gitversion libopenzwave)",
"OZW_ETC" : "<!(pkg-config --variable=sysconfdir libopenzwave)",
"OZW_DOC" : "<!(pkg-config --variable=docdir libopenzwave)"
},
"defines": [
"OPENZWAVE_ETC=<(OZW_ETC)/config",
"OPENZWAVE_DOC=<!@(node -p -e \"'<(OZW_DOC)'.length ? '<(OZW_DOC)' : '/usr/local/share/doc/openzwave'\")",
"OPENZWAVE_SECURITY=<!@(find <(OZW_INC) -name ZWSecurity.h | wc -l)"
],
"cflags": [ "-Wno-ignored-qualifiers -Wno-write-strings -Wno-unknown-pragmas" ],
"link_settings": {
"libraries": [
"-R/opt/local/lib/", "-L/opt/local/lib/", "-lopenzwave"
]
},
"include_dirs": [
"<!(node -p -e \"require('path').dirname(require.resolve('nan'))\")",
'/opt/local/include/openzwave/',
'/opt/local/include/openzwave/value_classes/'
]
}],
['OS=="mac"', {
"variables": {
"OZW_INC" : "<!(pkg-config --cflags-only-I libopenzwave | sed s/-I//g)",
Expand All @@ -24,28 +49,28 @@
"OZW_ETC" : "<!(pkg-config --variable=sysconfdir libopenzwave)",
"OZW_DOC" : "<!(pkg-config --variable=docdir libopenzwave)"
},
"defines": [
"defines": [
"OPENZWAVE_ETC=<(OZW_ETC)/config",
"OPENZWAVE_DOC=<!@(node -p -e \"'<(OZW_DOC)'.length ? '<(OZW_DOC)' : '/usr/local/share/doc/openzwave'\")",
"OPENZWAVE_SECURITY=<!@(find <(OZW_INC) -name ZWSecurity.h | wc -l)"
],
],
"link_settings": {
"libraries": [
"-L/usr/local/lib/", "-lopenzwave"
]
},
"include_dirs": [
"<!(node -p -e \"require('path').dirname(require.resolve('nan'))\")",
'/usr/local/include/openzwave/',
'/usr/local/include/openzwave/value_classes/'
],
"include_dirs": [
"<!(node -p -e \"require('path').dirname(require.resolve('nan'))\")",
'/usr/local/include/openzwave/',
'/usr/local/include/openzwave/value_classes/'
],
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET':'10.9',
'OTHER_CFLAGS': [
'OTHER_CFLAGS': [
'-Wno-ignored-qualifiers -Wno-write-strings -Wno-unknown-pragmas'
]
}
}],
]
}
}],
["OS=='linux'", {
"variables": {
"NODE" : "<!(which node || which nodejs)",
Expand All @@ -54,11 +79,11 @@
"OZW_ETC" : "<!(<(NODE) -p \"require('./lib/ozwpaths.js').sysconfdir\")",
"OZW_DOC" : "<!(<(NODE) -p \"require('./lib/ozwpaths.js').docdir\")"
},
"defines": [
"defines": [
"OPENZWAVE_ETC=<!@(<(NODE) -p -e \"'<(OZW_ETC)'.length ? '<(OZW_ETC)' : '/usr/local/etc/openzwave'\")",
"OPENZWAVE_DOC=<!@(<(NODE) -p -e \"'<(OZW_DOC)'.length ? '<(OZW_DOC)' : '/usr/local/share/doc/openzwave'\")",
"OPENZWAVE_SECURITY=<!@(find <(OZW_INC) -name ZWSecurity.h | wc -l)"
],
],
"link_settings": {
"libraries": ["-lopenzwave"]
},
Expand Down
10 changes: 5 additions & 5 deletions src/callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ Nan::AsyncResource *resource;

// Message passing queue between OpenZWave callback and v8 async handler.
mutex zqueue_mutex;
std::queue<NotifInfo *> zqueue;
::std::queue<NotifInfo *> zqueue;

// Node state.
mutex znodes_mutex;
std::map<uint8_t, NodeInfo *> znodes;
::std::map<uint8_t, NodeInfo *> znodes;

mutex zscenes_mutex;
std::list<SceneInfo *> zscenes;
::std::list<SceneInfo *> zscenes;
/*
* OpenZWave callback, registered in Driver::AddWatcher.
* Just push onto queue and trigger the handler in v8 land.
Expand Down Expand Up @@ -115,7 +115,7 @@ void ozw_ctrlcmd_callback(Driver::ControllerState _state,
notif->event = _err;
notif->notification = _state;
notif->homeid = 0; // use as guard value for legacy mode
notif->help = std::string("Controller State: ")
notif->help = ::std::string("Controller State: ")
.append(getControllerStateAsStr(_state))
.append(", Error: ")
.append(getControllerErrorAsStr(_err));
Expand Down Expand Up @@ -179,7 +179,7 @@ void handleNotification(NotifInfo *notif)
case OpenZWave::Notification::Type_ValueRemoved: {
// ##################
OpenZWave::ValueID value = notif->values.front();
std::list<OpenZWave::ValueID>::iterator vit;
::std::list<OpenZWave::ValueID>::iterator vit;
if ((node = get_node_info(notif->nodeid))) {
for (vit = node->values.begin(); vit != node->values.end(); ++vit) {
if ((*vit) == notif->values.front()) {
Expand Down
16 changes: 8 additions & 8 deletions src/callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ namespace OZW {
uint8 buttonid;
uint8 sceneid;
uint8 notification;
std::list<OpenZWave::ValueID> values;
std::string help;
::std::list<OpenZWave::ValueID> values;
::std::string help;
} NotifInfo;

typedef struct {
uint32 homeid;
uint8 nodeid;
bool polled;
std::list<OpenZWave::ValueID> values;
::std::list<OpenZWave::ValueID> values;
} NodeInfo;

typedef struct {
uint32 sceneid;
std::string label;
std::list<OpenZWave::ValueID> values;
::std::string label;
::std::list<OpenZWave::ValueID> values;
} SceneInfo;

// OpenZWave callbacks
Expand Down Expand Up @@ -72,16 +72,16 @@ namespace OZW {
* Message passing queue between OpenZWave callback and v8 async handler.
*/
extern mutex zqueue_mutex;
extern std::queue<NotifInfo *> zqueue;
extern ::std::queue<NotifInfo *> zqueue;

/*
* Node state.
*/
extern mutex znodes_mutex;
extern std::map<uint8_t, NodeInfo *> znodes;
extern ::std::map<uint8_t, NodeInfo *> znodes;

extern mutex zscenes_mutex;
extern std::list<SceneInfo *> zscenes;
extern ::std::list<SceneInfo *> zscenes;

} // namespace OZW

Expand Down
76 changes: 38 additions & 38 deletions src/openzwave-driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace OZW {
Nan::HandleScope scope;
CheckMinArgs(1, "path");

std::string path(*Nan::Utf8String( info[0] ));
::std::string path(*Nan::Utf8String( info[0] ));

uv_async_init(uv_default_loop(), &async, async_cb_handler);

Expand All @@ -49,7 +49,7 @@ namespace OZW {
OpenZWave::Manager* mgr = OpenZWave::Manager::Get();
mgr->AddWatcher(ozw_watcher_callback, NULL);
mgr->AddDriver(path);
std::string version(OpenZWave::Manager::getVersionAsString());
::std::string version(OpenZWave::Manager::getVersionAsString());

Local < v8::Value > cbinfo[16];
cbinfo[0] = Nan::New<String>("connected").ToLocalChecked();
Expand All @@ -64,7 +64,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "path");
std::string path(*Nan::Utf8String( info[0] ));
::std::string path(*Nan::Utf8String( info[0] ));

OpenZWave::Manager::Get()->RemoveDriver(path);
OpenZWave::Manager::Get()->RemoveWatcher(ozw_watcher_callback, NULL);
Expand Down Expand Up @@ -100,8 +100,8 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
uint8 ctrlid = OpenZWave::Manager::Get()->GetControllerNodeId (homeid);
info.GetReturnValue().Set(
uint8 ctrlid = OpenZWave::Manager::Get()->GetControllerNodeId (homeid);
info.GetReturnValue().Set(
Nan::New<Integer>(ctrlid)
);
}
Expand All @@ -111,8 +111,8 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
uint8 sucid = OpenZWave::Manager::Get()->GetSUCNodeId (homeid);
info.GetReturnValue().Set(
uint8 sucid = OpenZWave::Manager::Get()->GetSUCNodeId (homeid);
info.GetReturnValue().Set(
Nan::New<Integer>(sucid)
);
}
Expand All @@ -127,8 +127,8 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
bool isprimary = OpenZWave::Manager::Get()->IsPrimaryController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(isprimary));
bool isprimary = OpenZWave::Manager::Get()->IsPrimaryController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(isprimary));
}

/* Query if the controller is a static update controller. A Static
Expand All @@ -141,8 +141,8 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
bool issuc = OpenZWave::Manager::Get()->IsStaticUpdateController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(issuc));
bool issuc = OpenZWave::Manager::Get()->IsStaticUpdateController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(issuc));
}

/* Query if the controller is using the bridge controller library.
Expand All @@ -154,47 +154,47 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
bool isbridge = OpenZWave::Manager::Get()->IsBridgeController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(isbridge));
bool isbridge = OpenZWave::Manager::Get()->IsBridgeController (homeid);
info.GetReturnValue().Set(Nan::New<Boolean>(isbridge));
}

/* Get the version of the Z-Wave API library used by a controller.
*/
// ===================================================================
/* Get the version of the Z-Wave API library used by a controller.
*/
// ===================================================================
NAN_METHOD(OZW::GetLibraryVersion)
// ===================================================================
{
Nan::HandleScope scope;
std::string libver = OpenZWave::Manager::Get()->GetLibraryVersion (homeid);
info.GetReturnValue().Set(
::std::string libver = OpenZWave::Manager::Get()->GetLibraryVersion (homeid);
info.GetReturnValue().Set(
Nan::New<String>(
libver.c_str()
).ToLocalChecked()
);
}

/* Get a string containing the Z-Wave API library type used by a
* controller. The possible library types are:
* Static Controller
* Controller
* Enhanced Slave
* Slave
* Installer
* Routing Slave
* Bridge Controller
* Device Under Test
*
* The controller should never return a slave library type. For a
* more efficient test of whether a controller is a Bridge Controller,
* use the IsBridgeController method.
*/
// ===================================================================
/* Get a string containing the Z-Wave API library type used by a
* controller. The possible library types are:
* Static Controller
* Controller
* Enhanced Slave
* Slave
* Installer
* Routing Slave
* Bridge Controller
* Device Under Test
*
* The controller should never return a slave library type. For a
* more efficient test of whether a controller is a Bridge Controller,
* use the IsBridgeController method.
*/
// ===================================================================
NAN_METHOD(OZW::GetLibraryTypeName)
// ===================================================================
{
Nan::HandleScope scope;
std::string libtype = OpenZWave::Manager::Get()->GetLibraryTypeName (homeid);
info.GetReturnValue().Set(
::std::string libtype = OpenZWave::Manager::Get()->GetLibraryTypeName (homeid);
info.GetReturnValue().Set(
Nan::New<String>(
libtype.c_str()
).ToLocalChecked()
Expand All @@ -206,8 +206,8 @@ namespace OZW {
// ===================================================================
{
Nan::HandleScope scope;
uint32 cnt = OpenZWave::Manager::Get()->GetSendQueueCount (homeid);
info.GetReturnValue().Set(Nan::New<Integer>(cnt));
uint32 cnt = OpenZWave::Manager::Get()->GetSendQueueCount (homeid);
info.GetReturnValue().Set(Nan::New<Integer>(cnt));
}

}
2 changes: 1 addition & 1 deletion src/openzwave-groups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace OZW {
uint8 nodeid = info[0]->Uint32Value();
uint8 groupidx = info[1]->Uint32Value();

std::string groupLabel = OpenZWave::Manager::Get()->GetGroupLabel(
::std::string groupLabel = OpenZWave::Manager::Get()->GetGroupLabel(
homeid, nodeid, groupidx
);

Expand Down
Loading