@edgeflowjs/device-sim
v0.2.2
Published
Simulator for development and tests. Implements `DeviceAdapter` with injectable events.
Readme
@edgeflowjs/device-sim
Simulator for development and tests. Implements DeviceAdapter with injectable events.
Install
pnpm add @edgeflowjs/device-simExports
createSimDevice— Create simulatorsimBusSubscribe— Subscribe to device eventsSimDevice— Type (DeviceAdapter + simulator methods)
Usage
import { createSimDevice, simBusSubscribe } from "@edgeflowjs/device-sim";
const device = createSimDevice();
device.setNetworkOnline(true);
device.injectSerial("/dev/ttyUSB0", "QR:123456");
device.setGpio(17, true);
const value = device.getGpio(17);
simBusSubscribe((evt) => {
if (evt.type === "device.serial.received") console.log(evt.payload);
});