node-red-contrib-jacdac
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -11,2 +11,19 @@ "use strict"; | ||
const filterRegister = filters_1.createRegisterFilter(config); | ||
const sendRegister = (reg) => { | ||
const { service: srv } = reg; | ||
const { device: dev } = srv; | ||
this.send({ | ||
payload: { | ||
data: reg.objectValue, | ||
deviceShortId: dev.shortId, | ||
serviceIndex: srv.serviceIndex, | ||
serviceName: srv.name, | ||
registerName: reg.name, | ||
// low-level info | ||
deviceId: dev.deviceId, | ||
serviceClass: srv.serviceClass, | ||
registerCode: reg.code, | ||
} | ||
}); | ||
}; | ||
const { updates } = config; | ||
@@ -18,22 +35,9 @@ const reportEvent = updates ? jacdac_ts_1.REPORT_UPDATE : jacdac_ts_1.REPORT_RECEIVE; | ||
for (const srv of dev.services().filter(filterService)) { | ||
this.log(`scanning service ${srv.name}`); | ||
for (const reg of srv.registers().filter(filterRegister)) { | ||
this.log(`registering register ${reg}`); | ||
this.log(`registering register ${reg.name}`); | ||
// register this register will automatically | ||
// automatically have the bus | ||
// refresh its value | ||
reg.on(reportEvent, () => { | ||
this.send({ | ||
payload: { | ||
data: reg.objectValue, | ||
deviceShortId: dev.shortId, | ||
serviceIndex: srv.serviceIndex, | ||
serviceName: srv.name, | ||
registerName: reg.name, | ||
// low-level info | ||
deviceId: dev.deviceId, | ||
serviceClass: srv.serviceClass, | ||
registerCode: reg.code, | ||
} | ||
}); | ||
}); | ||
reg.on(reportEvent, sendRegister); | ||
} | ||
@@ -43,3 +47,2 @@ } | ||
}; | ||
// we need to make sure that devices are streaming | ||
bus_1.connectNode(this, registerDevice); | ||
@@ -46,0 +49,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createRegisterFilter = exports.createEventFilter = exports.createServiceFilter = exports.createDeviceFilter = void 0; | ||
const jacdac_ts_1 = require("jacdac-ts"); | ||
const bus_1 = require("./bus"); | ||
@@ -30,9 +31,14 @@ function createDeviceFilter(options) { | ||
exports.createEventFilter = createEventFilter; | ||
const defaultRegisters = [ | ||
jacdac_ts_1.SystemReg.Reading, | ||
jacdac_ts_1.SystemReg.Value, | ||
jacdac_ts_1.SystemReg.Intensity | ||
]; | ||
function createRegisterFilter(options) { | ||
const { register } = options; | ||
return (reg) => !register | ||
|| reg.code === parseInt(register, 16) | ||
|| (reg.name && reg.name.toLocaleLowerCase() === register.toLocaleLowerCase()); | ||
return (reg) => (!register && defaultRegisters.indexOf(reg.code) > -1) | ||
|| (register && reg.code === parseInt(register, 16)) | ||
|| (register && (reg.name && reg.name.toLocaleLowerCase() === register.toLocaleLowerCase())); | ||
} | ||
exports.createRegisterFilter = createRegisterFilter; | ||
//# sourceMappingURL=filters.js.map |
{ | ||
"name": "node-red-contrib-jacdac", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Microsoft Jacdac for node-red", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"dependencies": { | ||
"jacdac-ts": "^1.13.17", | ||
"jacdac-ts": "^1.13.18", | ||
"webusb": "^2.2.0" | ||
@@ -35,0 +35,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
358863
169
Updatedjacdac-ts@^1.13.18