node-red-contrib-jacdac
Advanced tools
Comparing version 1.0.10 to 1.0.11
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.connectNode = exports.bus = void 0; | ||
exports.connectNode = exports.connectStatus = exports.bus = void 0; | ||
const jacdac_ts_1 = require("jacdac-ts"); | ||
@@ -8,7 +8,3 @@ const opts = jacdac_ts_1.createNodeUSBOptions(); | ||
exports.bus = new jacdac_ts_1.JDBus([transport]); | ||
function connectNode(node, registerDevice) { | ||
const registerAllDevices = () => { | ||
for (const dev of exports.bus.devices({ ignoreSelf: true })) | ||
registerDevice(dev); | ||
}; | ||
function connectStatus(node) { | ||
const updateStatus = () => { | ||
@@ -19,10 +15,18 @@ node.log(`connection: ${exports.bus.connected ? "connected" : "disconnected"}`); | ||
}; | ||
exports.bus.on(jacdac_ts_1.DEVICE_ANNOUNCE, registerDevice); | ||
exports.bus.on(jacdac_ts_1.CONNECT, registerAllDevices); | ||
exports.bus.on(jacdac_ts_1.CONNECTION_STATE, updateStatus); | ||
registerAllDevices(); | ||
updateStatus(); | ||
exports.bus.connect(); | ||
} | ||
exports.connectStatus = connectStatus; | ||
function connectNode(node, registerDevice) { | ||
const registerAllDevices = () => { | ||
for (const dev of exports.bus.devices({ ignoreSelf: true })) | ||
registerDevice(dev); | ||
}; | ||
exports.bus.on(jacdac_ts_1.DEVICE_ANNOUNCE, registerDevice); | ||
exports.bus.on(jacdac_ts_1.CONNECT, registerAllDevices); | ||
registerAllDevices(); | ||
connectStatus(node); | ||
} | ||
exports.connectNode = connectNode; | ||
//# sourceMappingURL=bus.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createRegisterFilter = exports.createEventFilter = exports.createServiceFilter = exports.createDeviceFilter = void 0; | ||
exports.createCommandFilter = exports.createRegisterFilter = exports.createEventFilter = exports.createServiceFilter = exports.createDeviceFilter = void 0; | ||
const jacdac_ts_1 = require("jacdac-ts"); | ||
@@ -43,2 +43,13 @@ const bus_1 = require("./bus"); | ||
exports.createRegisterFilter = createRegisterFilter; | ||
function createCommandFilter(options) { | ||
const { command } = options; | ||
return (srv) => { | ||
const { specification } = srv; | ||
const code = parseInt(command, 16); | ||
return specification === null || specification === void 0 ? void 0 : specification.packets.find(pkt => pkt.kind === "command" && | ||
(pkt.name.toLocaleLowerCase() === command.toLocaleLowerCase()) | ||
|| pkt.identifier === code); | ||
}; | ||
} | ||
exports.createCommandFilter = createCommandFilter; | ||
//# sourceMappingURL=filters.js.map |
{ | ||
"name": "node-red-contrib-jacdac", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Microsoft Jacdac for node-red", | ||
@@ -29,7 +29,8 @@ "keywords": [ | ||
"jacdac-report": "./dist/nodes/jacdac-report/jacdac-report.js", | ||
"jacdac-event": "./dist/nodes/jacdac-event/jacdac-event.js" | ||
"jacdac-event": "./dist/nodes/jacdac-event/jacdac-event.js", | ||
"jacdac-command": "./dist/nodes/jacdac-command/jacdac-command.js" | ||
} | ||
}, | ||
"dependencies": { | ||
"jacdac-ts": "^1.13.18", | ||
"jacdac-ts": "^1.13.21", | ||
"webusb": "^2.2.0" | ||
@@ -36,0 +37,0 @@ }, |
@@ -28,4 +28,9 @@ # Node-RED Jacdac Node | ||
* go to https://makecode.microbit.org/beta#pub:github:microsoft/pxt-jacdac/devices/microbit | ||
* go to https://makecode.microbit.org/beta | ||
* create a new project | ||
* click on the project settings, ``Extensions`` | ||
* search for https://github.com/microsoft/pxt-jacdac/devices/microbit and import it | ||
* use the blocks under ``Servers`` to start which sensor you want | ||
* download to your micro:bit V2 | ||
* enjoy data! | ||
@@ -39,5 +44,5 @@ ## Nodes | ||
### jacdac-read | ||
### jacdac-report | ||
This node listens for [Jacdac reading](https://microsoft.github.io/jacdac-docs/reference/protocol#registers) and send them in the payload. | ||
This node reads [Jacdac registers](https://microsoft.github.io/jacdac-docs/reference/protocol#registers) and send them in the payload. | ||
You can browse the [services specification catalog](https://microsoft.github.io/jacdac-docs/services/) to discover which registers are avilable are available. | ||
@@ -48,2 +53,9 @@ | ||
### jacdac-command | ||
This node sends [Jacdac commands](https://microsoft.github.io/jacdac-docs/reference/protocol/#commands) | ||
to services. The results of command can be inferred from the content of the registers. | ||
You can browse the [services specification catalog](https://microsoft.github.io/jacdac-docs/services/) to discover which commands are available and how their payload should be formatted. | ||
## Developer section | ||
@@ -50,0 +62,0 @@ ### Adding Nodes |
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
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
367182
34
221
126
Updatedjacdac-ts@^1.13.21