Skip to content

Commit 80f9dbf

Browse files
committed
feat: Added getOzwVersion method
1 parent 4a09346 commit 80f9dbf

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

src/openzwave-driver.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ namespace OZW {
241241
);
242242
}
243243

244+
/* Get the version of Openzwave
245+
*/
246+
// ===================================================================
247+
NAN_METHOD(OZW::GetOzwVersion)
248+
// ===================================================================
249+
{
250+
Nan::HandleScope scope;
251+
::std::string version("");
252+
version = OpenZWave::Manager::getVersionAsString();
253+
//OZWManagerAssign(version, GetVersionAsString);
254+
info.GetReturnValue().Set(
255+
Nan::New<String>(
256+
version.c_str()
257+
).ToLocalChecked()
258+
);
259+
}
260+
244261
/* Get a string containing the Z-Wave API library type used by a
245262
* controller. The possible library types are:
246263
* Static Controller

src/openzwave.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ namespace OZW {
6969
Nan::SetPrototypeMethod(t, "isStaticUpdateController", OZW::IsStaticUpdateController); // ** new
7070
Nan::SetPrototypeMethod(t, "isBridgeController", OZW::IsBridgeController); // ** new
7171
Nan::SetPrototypeMethod(t, "getLibraryVersion", OZW::GetLibraryVersion); // ** new
72+
Nan::SetPrototypeMethod(t, "getOzwVersion", OZW::GetOzwVersion); // ** new
7273
Nan::SetPrototypeMethod(t, "getLibraryTypeName", OZW::GetLibraryTypeName); // ** new
7374
Nan::SetPrototypeMethod(t, "getSendQueueCount", OZW::GetSendQueueCount); // ** new
7475
Nan::SetPrototypeMethod(t, "connect", OZW::Connect);

src/openzwave.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace OZW {
6565
static NAN_METHOD(IsStaticUpdateController);
6666
static NAN_METHOD(IsBridgeController);
6767
static NAN_METHOD(GetLibraryVersion);
68+
static NAN_METHOD(GetOzwVersion);
6869
static NAN_METHOD(GetLibraryTypeName);
6970
static NAN_METHOD(GetSendQueueCount);
7071
static NAN_METHOD(Connect);

test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
*/
44

55
var OpenZWave = require('./lib/openzwave-shared.js');
6-
var os = require('os');
7-
86

97
// this test assumes no actual ZWave controller exists on the system
108
// and is just a rudimentary check that the driver can initialise itself.
11-
var zwave = new OpenZWave();
12-
13-
//console.log("WriteConfig:", typeof zwave.writeConfig === 'function');
9+
var zwave = new OpenZWave()
1410

11+
console.log("OPENZWAVE VERSION:", zwave.getOzwVersion())
1512

16-
zwave.on('ping', function() {
17-
console.log('driver is emitting events properly');
18-
process.exit();
19-
});
20-
console.log('Testing if OZW is emitting events properly');
21-
zwave.ping();
13+
zwave.on('ping', function () {
14+
console.log('driver is emitting events properly')
15+
process.exit()
16+
})
17+
console.log('Testing if OZW is emitting events properly')
18+
zwave.ping()
2219

23-
setTimeout(function() {
24-
console.log('timeout pinging the driver');
25-
process.exit(1);
26-
}, 1000);
20+
setTimeout(function () {
21+
console.log('timeout pinging the driver')
22+
process.exit(1)
23+
}, 1000)

0 commit comments

Comments
 (0)