amaran-light-cli 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -17
- package/dist/__tests__/autoCct.test.js +35 -4
- package/dist/__tests__/autoCct.test.js.map +1 -1
- package/dist/__tests__/autoCctMaxLux.test.js +11 -9
- package/dist/__tests__/autoCctMaxLux.test.js.map +1 -1
- package/dist/__tests__/autostart.test.js +18 -0
- package/dist/__tests__/autostart.test.js.map +1 -1
- package/dist/__tests__/bleHttpControl.test.d.ts +2 -0
- package/dist/__tests__/bleHttpControl.test.d.ts.map +1 -0
- package/dist/__tests__/bleHttpControl.test.js +230 -0
- package/dist/__tests__/bleHttpControl.test.js.map +1 -0
- package/dist/__tests__/bleStack.test.d.ts +2 -0
- package/dist/__tests__/bleStack.test.d.ts.map +1 -0
- package/dist/__tests__/bleStack.test.js +1239 -0
- package/dist/__tests__/bleStack.test.js.map +1 -0
- package/dist/__tests__/cctUtil.test.js +11 -5
- package/dist/__tests__/cctUtil.test.js.map +1 -1
- package/dist/__tests__/circadianDashboardSettings.test.d.ts +2 -0
- package/dist/__tests__/circadianDashboardSettings.test.d.ts.map +1 -0
- package/dist/__tests__/circadianDashboardSettings.test.js +82 -0
- package/dist/__tests__/circadianDashboardSettings.test.js.map +1 -0
- package/dist/__tests__/circadianIsolation.test.d.ts +2 -0
- package/dist/__tests__/circadianIsolation.test.d.ts.map +1 -0
- package/dist/__tests__/circadianIsolation.test.js +30 -0
- package/dist/__tests__/circadianIsolation.test.js.map +1 -0
- package/dist/__tests__/cli.config.test.d.ts +2 -0
- package/dist/__tests__/cli.config.test.d.ts.map +1 -0
- package/dist/__tests__/cli.config.test.js +114 -0
- package/dist/__tests__/cli.config.test.js.map +1 -0
- package/dist/__tests__/cli.smoke.test.js +70 -17
- package/dist/__tests__/cli.smoke.test.js.map +1 -1
- package/dist/__tests__/currentCct.test.d.ts +2 -0
- package/dist/__tests__/currentCct.test.d.ts.map +1 -0
- package/dist/__tests__/currentCct.test.js +29 -0
- package/dist/__tests__/currentCct.test.js.map +1 -0
- package/dist/__tests__/dashboard.test.d.ts +2 -0
- package/dist/__tests__/dashboard.test.d.ts.map +1 -0
- package/dist/__tests__/dashboard.test.js +126 -0
- package/dist/__tests__/dashboard.test.js.map +1 -0
- package/dist/__tests__/daylightSimulationParseUtils.test.d.ts +2 -0
- package/dist/__tests__/daylightSimulationParseUtils.test.d.ts.map +1 -0
- package/dist/__tests__/daylightSimulationParseUtils.test.js +16 -0
- package/dist/__tests__/daylightSimulationParseUtils.test.js.map +1 -0
- package/dist/__tests__/desktopImport.test.d.ts +2 -0
- package/dist/__tests__/desktopImport.test.d.ts.map +1 -0
- package/dist/__tests__/desktopImport.test.js +234 -0
- package/dist/__tests__/desktopImport.test.js.map +1 -0
- package/dist/__tests__/lightControl.basic.test.d.ts +2 -0
- package/dist/__tests__/lightControl.basic.test.d.ts.map +1 -0
- package/dist/__tests__/lightControl.basic.test.js +119 -0
- package/dist/__tests__/lightControl.basic.test.js.map +1 -0
- package/dist/__tests__/lightControl.colorEffects.test.d.ts +2 -0
- package/dist/__tests__/lightControl.colorEffects.test.d.ts.map +1 -0
- package/dist/__tests__/lightControl.colorEffects.test.js +170 -0
- package/dist/__tests__/lightControl.colorEffects.test.js.map +1 -0
- package/dist/__tests__/lightControl.management.test.d.ts +2 -0
- package/dist/__tests__/lightControl.management.test.d.ts.map +1 -0
- package/dist/__tests__/lightControl.management.test.js +90 -0
- package/dist/__tests__/lightControl.management.test.js.map +1 -0
- package/dist/__tests__/lightControlTestUtils.d.ts +10 -0
- package/dist/__tests__/lightControlTestUtils.d.ts.map +1 -0
- package/dist/__tests__/lightControlTestUtils.js +57 -0
- package/dist/__tests__/lightControlTestUtils.js.map +1 -0
- package/dist/__tests__/maxLuxInterpolation.test.js +4 -2
- package/dist/__tests__/maxLuxInterpolation.test.js.map +1 -1
- package/dist/__tests__/meshConfiguration.test.d.ts +2 -0
- package/dist/__tests__/meshConfiguration.test.d.ts.map +1 -0
- package/dist/__tests__/meshConfiguration.test.js +78 -0
- package/dist/__tests__/meshConfiguration.test.js.map +1 -0
- package/dist/__tests__/nativeGroups.test.d.ts +2 -0
- package/dist/__tests__/nativeGroups.test.d.ts.map +1 -0
- package/dist/__tests__/nativeGroups.test.js +104 -0
- package/dist/__tests__/nativeGroups.test.js.map +1 -0
- package/dist/__tests__/packageExports.test.d.ts +2 -0
- package/dist/__tests__/packageExports.test.d.ts.map +1 -0
- package/dist/__tests__/packageExports.test.js +33 -0
- package/dist/__tests__/packageExports.test.js.map +1 -0
- package/dist/__tests__/programApi.test.d.ts +2 -0
- package/dist/__tests__/programApi.test.d.ts.map +1 -0
- package/dist/__tests__/programApi.test.js +73 -0
- package/dist/__tests__/programApi.test.js.map +1 -0
- package/dist/__tests__/programs.test.d.ts +2 -0
- package/dist/__tests__/programs.test.d.ts.map +1 -0
- package/dist/__tests__/programs.test.js +176 -0
- package/dist/__tests__/programs.test.js.map +1 -0
- package/dist/__tests__/scheduleMaker.test.d.ts +2 -0
- package/dist/__tests__/scheduleMaker.test.d.ts.map +1 -0
- package/dist/__tests__/scheduleMaker.test.js +25 -0
- package/dist/__tests__/scheduleMaker.test.js.map +1 -0
- package/dist/__tests__/simulateSchedule.test.js +7 -3
- package/dist/__tests__/simulateSchedule.test.js.map +1 -1
- package/dist/ble/async.d.ts +2 -0
- package/dist/ble/async.d.ts.map +1 -0
- package/dist/ble/async.js +15 -0
- package/dist/ble/async.js.map +1 -0
- package/dist/ble/colors.d.ts +5 -0
- package/dist/ble/colors.d.ts.map +1 -0
- package/dist/ble/colors.js +44 -0
- package/dist/ble/colors.js.map +1 -0
- package/dist/ble/configuration.d.ts +22 -0
- package/dist/ble/configuration.d.ts.map +1 -0
- package/dist/ble/configuration.js +122 -0
- package/dist/ble/configuration.js.map +1 -0
- package/dist/ble/controller.d.ts +118 -0
- package/dist/ble/controller.d.ts.map +1 -0
- package/dist/ble/controller.js +931 -0
- package/dist/ble/controller.js.map +1 -0
- package/dist/ble/crypto.d.ts +34 -0
- package/dist/ble/crypto.d.ts.map +1 -0
- package/dist/ble/crypto.js +178 -0
- package/dist/ble/crypto.js.map +1 -0
- package/dist/ble/daemon.d.ts +2 -0
- package/dist/ble/daemon.d.ts.map +1 -0
- package/dist/ble/daemon.js +76 -0
- package/dist/ble/daemon.js.map +1 -0
- package/dist/ble/dashboard.d.ts +331 -0
- package/dist/ble/dashboard.d.ts.map +1 -0
- package/dist/ble/dashboard.js +280 -0
- package/dist/ble/dashboard.js.map +1 -0
- package/dist/ble/desktop.d.ts +4 -0
- package/dist/ble/desktop.d.ts.map +1 -0
- package/dist/ble/desktop.js +33 -0
- package/dist/ble/desktop.js.map +1 -0
- package/dist/ble/desktopLibrary.d.ts +12 -0
- package/dist/ble/desktopLibrary.d.ts.map +1 -0
- package/dist/ble/desktopLibrary.js +346 -0
- package/dist/ble/desktopLibrary.js.map +1 -0
- package/dist/ble/effects.d.ts +34 -0
- package/dist/ble/effects.d.ts.map +1 -0
- package/dist/ble/effects.js +138 -0
- package/dist/ble/effects.js.map +1 -0
- package/dist/ble/fan.d.ts +244 -0
- package/dist/ble/fan.d.ts.map +1 -0
- package/dist/ble/fan.js +46 -0
- package/dist/ble/fan.js.map +1 -0
- package/dist/ble/library.d.ts +341 -0
- package/dist/ble/library.d.ts.map +1 -0
- package/dist/ble/library.js +201 -0
- package/dist/ble/library.js.map +1 -0
- package/dist/ble/media.d.ts +133 -0
- package/dist/ble/media.d.ts.map +1 -0
- package/dist/ble/media.js +186 -0
- package/dist/ble/media.js.map +1 -0
- package/dist/ble/nativeGroups.d.ts +22 -0
- package/dist/ble/nativeGroups.d.ts.map +1 -0
- package/dist/ble/nativeGroups.js +114 -0
- package/dist/ble/nativeGroups.js.map +1 -0
- package/dist/ble/packets.d.ts +3 -0
- package/dist/ble/packets.d.ts.map +1 -0
- package/dist/ble/packets.js +15 -0
- package/dist/ble/packets.js.map +1 -0
- package/dist/ble/programs.d.ts +318 -0
- package/dist/ble/programs.d.ts.map +1 -0
- package/dist/ble/programs.js +329 -0
- package/dist/ble/programs.js.map +1 -0
- package/dist/ble/provisioning.d.ts +13 -0
- package/dist/ble/provisioning.d.ts.map +1 -0
- package/dist/ble/provisioning.js +39 -0
- package/dist/ble/provisioning.js.map +1 -0
- package/dist/ble/server.d.ts +18 -0
- package/dist/ble/server.d.ts.map +1 -0
- package/dist/ble/server.js +548 -0
- package/dist/ble/server.js.map +1 -0
- package/dist/ble/service.d.ts +2 -0
- package/dist/ble/service.d.ts.map +1 -0
- package/dist/ble/service.js +77 -0
- package/dist/ble/service.js.map +1 -0
- package/dist/ble/settings.d.ts +18 -0
- package/dist/ble/settings.d.ts.map +1 -0
- package/dist/ble/settings.js +25 -0
- package/dist/ble/settings.js.map +1 -0
- package/dist/ble/setup.d.ts +2 -0
- package/dist/ble/setup.d.ts.map +1 -0
- package/dist/ble/setup.js +31 -0
- package/dist/ble/setup.js.map +1 -0
- package/dist/ble/storage.d.ts +94 -0
- package/dist/ble/storage.d.ts.map +1 -0
- package/dist/ble/storage.js +132 -0
- package/dist/ble/storage.js.map +1 -0
- package/dist/ble/telink.d.ts +63 -0
- package/dist/ble/telink.d.ts.map +1 -0
- package/dist/ble/telink.js +108 -0
- package/dist/ble/telink.js.map +1 -0
- package/dist/ble/transitions.d.ts +3 -0
- package/dist/ble/transitions.d.ts.map +1 -0
- package/dist/ble/transitions.js +28 -0
- package/dist/ble/transitions.js.map +1 -0
- package/dist/ble/transport.d.ts +48 -0
- package/dist/ble/transport.d.ts.map +1 -0
- package/dist/ble/transport.js +370 -0
- package/dist/ble/transport.js.map +1 -0
- package/dist/circadian.d.ts +19 -0
- package/dist/circadian.d.ts.map +1 -0
- package/dist/circadian.js +13 -0
- package/dist/circadian.js.map +1 -0
- package/dist/cli.d.ts +5 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +159 -33
- package/dist/cli.js.map +1 -1
- package/dist/commands/__tests__/integration.test.js +28 -0
- package/dist/commands/__tests__/integration.test.js.map +1 -1
- package/dist/commands/__tests__/newCommands.test.js +3 -4
- package/dist/commands/__tests__/newCommands.test.js.map +1 -1
- package/dist/commands/cmdUtils.d.ts +8 -2
- package/dist/commands/cmdUtils.d.ts.map +1 -1
- package/dist/commands/cmdUtils.js +40 -2
- package/dist/commands/cmdUtils.js.map +1 -1
- package/dist/commands/daylightSimulation/autoCct.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/autoCct.js +74 -172
- package/dist/commands/daylightSimulation/autoCct.js.map +1 -1
- package/dist/commands/daylightSimulation/graphSchedule.d.ts +1 -1
- package/dist/commands/daylightSimulation/graphSchedule.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/graphSchedule.js +2 -0
- package/dist/commands/daylightSimulation/graphSchedule.js.map +1 -1
- package/dist/commands/daylightSimulation/printSchedule.d.ts +1 -1
- package/dist/commands/daylightSimulation/printSchedule.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/printSchedule.js +4 -2
- package/dist/commands/daylightSimulation/printSchedule.js.map +1 -1
- package/dist/commands/daylightSimulation/service.d.ts +1 -1
- package/dist/commands/daylightSimulation/service.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/service.js +20 -10
- package/dist/commands/daylightSimulation/service.js.map +1 -1
- package/dist/commands/daylightSimulation/simulateSchedule.d.ts +1 -1
- package/dist/commands/daylightSimulation/simulateSchedule.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/simulateSchedule.js +31 -13
- package/dist/commands/daylightSimulation/simulateSchedule.js.map +1 -1
- package/dist/commands/daylightSimulation/weather.d.ts.map +1 -1
- package/dist/commands/daylightSimulation/weather.js +19 -4
- package/dist/commands/daylightSimulation/weather.js.map +1 -1
- package/dist/commands/deviceControl/ble.d.ts +4 -0
- package/dist/commands/deviceControl/ble.d.ts.map +1 -0
- package/dist/commands/deviceControl/ble.js +214 -0
- package/dist/commands/deviceControl/ble.js.map +1 -0
- package/dist/commands/deviceControl/cct.d.ts.map +1 -1
- package/dist/commands/deviceControl/cct.js +47 -19
- package/dist/commands/deviceControl/cct.js.map +1 -1
- package/dist/commands/deviceControl/color.d.ts.map +1 -1
- package/dist/commands/deviceControl/color.js +16 -12
- package/dist/commands/deviceControl/color.js.map +1 -1
- package/dist/commands/deviceControl/config.d.ts.map +1 -1
- package/dist/commands/deviceControl/config.js +94 -58
- package/dist/commands/deviceControl/config.js.map +1 -1
- package/dist/commands/deviceControl/{discover.d.ts → desktop.d.ts} +3 -2
- package/dist/commands/deviceControl/desktop.d.ts.map +1 -0
- package/dist/commands/deviceControl/desktop.js +66 -0
- package/dist/commands/deviceControl/desktop.js.map +1 -0
- package/dist/commands/deviceControl/effect.d.ts.map +1 -1
- package/dist/commands/deviceControl/effect.js +90 -159
- package/dist/commands/deviceControl/effect.js.map +1 -1
- package/dist/commands/deviceControl/fan.d.ts.map +1 -1
- package/dist/commands/deviceControl/fan.js +77 -95
- package/dist/commands/deviceControl/fan.js.map +1 -1
- package/dist/commands/deviceControl/group.d.ts.map +1 -1
- package/dist/commands/deviceControl/group.js +43 -6
- package/dist/commands/deviceControl/group.js.map +1 -1
- package/dist/commands/deviceControl/hsi.d.ts.map +1 -1
- package/dist/commands/deviceControl/hsi.js +6 -10
- package/dist/commands/deviceControl/hsi.js.map +1 -1
- package/dist/commands/deviceControl/info.d.ts.map +1 -1
- package/dist/commands/deviceControl/info.js +0 -50
- package/dist/commands/deviceControl/info.js.map +1 -1
- package/dist/commands/deviceControl/intensity.d.ts.map +1 -1
- package/dist/commands/deviceControl/intensity.js +38 -16
- package/dist/commands/deviceControl/intensity.js.map +1 -1
- package/dist/commands/deviceControl/list.d.ts.map +1 -1
- package/dist/commands/deviceControl/list.js +21 -15
- package/dist/commands/deviceControl/list.js.map +1 -1
- package/dist/commands/deviceControl/power.d.ts.map +1 -1
- package/dist/commands/deviceControl/power.js +19 -28
- package/dist/commands/deviceControl/power.js.map +1 -1
- package/dist/commands/deviceControl/preset.d.ts.map +1 -1
- package/dist/commands/deviceControl/preset.js +56 -19
- package/dist/commands/deviceControl/preset.js.map +1 -1
- package/dist/commands/deviceControl/program.d.ts +4 -0
- package/dist/commands/deviceControl/program.d.ts.map +1 -0
- package/dist/commands/deviceControl/program.js +199 -0
- package/dist/commands/deviceControl/program.js.map +1 -0
- package/dist/commands/deviceControl/quickshot.d.ts.map +1 -1
- package/dist/commands/deviceControl/quickshot.js +75 -13
- package/dist/commands/deviceControl/quickshot.js.map +1 -1
- package/dist/commands/deviceControl/scene.d.ts.map +1 -1
- package/dist/commands/deviceControl/scene.js +72 -9
- package/dist/commands/deviceControl/scene.js.map +1 -1
- package/dist/commands/deviceControl/status.d.ts.map +1 -1
- package/dist/commands/deviceControl/status.js +29 -6
- package/dist/commands/deviceControl/status.js.map +1 -1
- package/dist/commands/parseUtils.d.ts +6 -0
- package/dist/commands/parseUtils.d.ts.map +1 -0
- package/dist/commands/parseUtils.js +32 -0
- package/dist/commands/parseUtils.js.map +1 -0
- package/dist/commands-api.d.ts +28 -0
- package/dist/commands-api.d.ts.map +1 -0
- package/dist/commands-api.js +27 -0
- package/dist/commands-api.js.map +1 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +4 -2
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +165 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +125 -0
- package/dist/config.js.map +1 -0
- package/dist/daylightSimulation/cctUtil.d.ts.map +1 -1
- package/dist/daylightSimulation/cctUtil.js +23 -22
- package/dist/daylightSimulation/cctUtil.js.map +1 -1
- package/dist/daylightSimulation/constants.d.ts +10 -0
- package/dist/daylightSimulation/constants.d.ts.map +1 -1
- package/dist/daylightSimulation/constants.js +4 -0
- package/dist/daylightSimulation/constants.js.map +1 -1
- package/dist/daylightSimulation/currentCct.d.ts +42 -0
- package/dist/daylightSimulation/currentCct.d.ts.map +1 -0
- package/dist/daylightSimulation/currentCct.js +217 -0
- package/dist/daylightSimulation/currentCct.js.map +1 -0
- package/dist/daylightSimulation/curves/realistic.d.ts +6 -6
- package/dist/daylightSimulation/curves/realistic.d.ts.map +1 -1
- package/dist/daylightSimulation/curves/realistic.js +36 -6
- package/dist/daylightSimulation/curves/realistic.js.map +1 -1
- package/dist/daylightSimulation/dashboardSettings.d.ts +47 -0
- package/dist/daylightSimulation/dashboardSettings.d.ts.map +1 -0
- package/dist/daylightSimulation/dashboardSettings.js +95 -0
- package/dist/daylightSimulation/dashboardSettings.js.map +1 -0
- package/dist/daylightSimulation/dashboardStatus.d.ts +72 -0
- package/dist/daylightSimulation/dashboardStatus.d.ts.map +1 -0
- package/dist/daylightSimulation/dashboardStatus.js +191 -0
- package/dist/daylightSimulation/dashboardStatus.js.map +1 -0
- package/dist/daylightSimulation/mathUtil.d.ts.map +1 -1
- package/dist/daylightSimulation/mathUtil.js +6 -2
- package/dist/daylightSimulation/mathUtil.js.map +1 -1
- package/dist/daylightSimulation/parseUtils.d.ts +3 -0
- package/dist/daylightSimulation/parseUtils.d.ts.map +1 -0
- package/dist/daylightSimulation/parseUtils.js +25 -0
- package/dist/daylightSimulation/parseUtils.js.map +1 -0
- package/dist/daylightSimulation/scheduleMaker.d.ts +6 -2
- package/dist/daylightSimulation/scheduleMaker.d.ts.map +1 -1
- package/dist/daylightSimulation/scheduleMaker.js +9 -11
- package/dist/daylightSimulation/scheduleMaker.js.map +1 -1
- package/dist/daylightSimulation/types.d.ts +15 -2
- package/dist/daylightSimulation/types.d.ts.map +1 -1
- package/dist/daylightSimulation/types.js +0 -2
- package/dist/daylightSimulation/types.js.map +1 -1
- package/dist/daylightSimulation/weatherUtil.d.ts.map +1 -1
- package/dist/daylightSimulation/weatherUtil.js +31 -0
- package/dist/daylightSimulation/weatherUtil.js.map +1 -1
- package/dist/device-control.d.ts +8 -0
- package/dist/device-control.d.ts.map +1 -0
- package/dist/device-control.js +8 -0
- package/dist/device-control.js.map +1 -0
- package/dist/deviceControl/autostart.d.ts.map +1 -1
- package/dist/deviceControl/autostart.js +15 -16
- package/dist/deviceControl/autostart.js.map +1 -1
- package/dist/deviceControl/bleHttpControl.d.ts +129 -0
- package/dist/deviceControl/bleHttpControl.d.ts.map +1 -0
- package/dist/deviceControl/bleHttpControl.js +753 -0
- package/dist/deviceControl/bleHttpControl.js.map +1 -0
- package/dist/deviceControl/lightControl.d.ts +9 -68
- package/dist/deviceControl/lightControl.d.ts.map +1 -1
- package/dist/deviceControl/lightControl.js +25 -255
- package/dist/deviceControl/lightControl.js.map +1 -1
- package/dist/deviceControl/lightControlCommands.d.ts +68 -0
- package/dist/deviceControl/lightControlCommands.d.ts.map +1 -0
- package/dist/deviceControl/lightControlCommands.js +244 -0
- package/dist/deviceControl/lightControlCommands.js.map +1 -0
- package/dist/deviceControl/types.d.ts +83 -4
- package/dist/deviceControl/types.d.ts.map +1 -1
- package/dist/deviceControl/types.js +1 -0
- package/dist/deviceControl/types.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/test/MockLightServer.d.ts +1 -0
- package/dist/test/MockLightServer.d.ts.map +1 -1
- package/dist/test/MockLightServer.js +5 -0
- package/dist/test/MockLightServer.js.map +1 -1
- package/docs/CHANGELOG.md +171 -0
- package/docs/DIRECT_BLE.md +359 -0
- package/package.json +39 -8
- package/scripts/ble-cli-check.ts +129 -0
- package/scripts/ble-config-probe.ts +109 -0
- package/scripts/ble-effects-check.ts +82 -0
- package/scripts/ble-extended-probe.ts +44 -0
- package/scripts/ble-fan-check.ts +129 -0
- package/scripts/ble-feature-probe.ts +37 -0
- package/scripts/ble-followup-check.ts +165 -0
- package/scripts/ble-hardware-check.ts +99 -0
- package/scripts/ble-live-extended-check.ts +205 -0
- package/scripts/ble-non-ota-check.ts +193 -0
- package/scripts/ble-probe.ts +45 -0
- package/scripts/calibrate-webcam.ts +152 -0
- package/scripts/desktop-reference.ts +85 -0
- package/scripts/webcam.ts +129 -0
- package/dist/__tests__/lightControl.test.d.ts +0 -2
- package/dist/__tests__/lightControl.test.d.ts.map +0 -1
- package/dist/__tests__/lightControl.test.js +0 -424
- package/dist/__tests__/lightControl.test.js.map +0 -1
- package/dist/commands/deviceControl/discover.d.ts.map +0 -1
- package/dist/commands/deviceControl/discover.js +0 -29
- package/dist/commands/deviceControl/discover.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
+
import { MeshCrypto } from '../src/ble/crypto.js';
|
|
3
|
+
import { importMesh } from '../src/ble/setup.js';
|
|
4
|
+
import { loadMeshConfig, meshDirectory, SequenceStore } from '../src/ble/storage.js';
|
|
5
|
+
import { cctPacket, powerPacket } from '../src/ble/telink.js';
|
|
6
|
+
import { MeshTransport } from '../src/ble/transport.js';
|
|
7
|
+
import { captureWebcam } from './webcam.js';
|
|
8
|
+
|
|
9
|
+
if (process.argv[2] === 'import') {
|
|
10
|
+
importMesh(process.argv[3]);
|
|
11
|
+
} else {
|
|
12
|
+
const config = loadMeshConfig();
|
|
13
|
+
const crypto = new MeshCrypto(config.netKey, config.appKey);
|
|
14
|
+
const sequence = new SequenceStore(meshDirectory(), crypto.networkId.toString('hex'), config.source);
|
|
15
|
+
const transport = new MeshTransport(config, sequence, true);
|
|
16
|
+
try {
|
|
17
|
+
await transport.connect();
|
|
18
|
+
if (process.argv[2] === 'test-desk') {
|
|
19
|
+
const light = config.lights.find((entry) => entry.key === 'desk');
|
|
20
|
+
if (!light) throw new Error('Desk fixture not configured');
|
|
21
|
+
try {
|
|
22
|
+
await transport.send(light.address, cctPacket(3200, 10));
|
|
23
|
+
await delay(300);
|
|
24
|
+
await transport.send(light.address, powerPacket(true));
|
|
25
|
+
await delay(300);
|
|
26
|
+
console.log('ON state', await transport.readState(light.address));
|
|
27
|
+
console.log(captureWebcam(`ble-desk-on-${Date.now()}`));
|
|
28
|
+
} finally {
|
|
29
|
+
await transport.send(light.address, powerPacket(false));
|
|
30
|
+
await delay(300);
|
|
31
|
+
console.log('OFF state', await transport.readState(light.address));
|
|
32
|
+
}
|
|
33
|
+
console.log(captureWebcam(`ble-desk-off-${Date.now()}`));
|
|
34
|
+
} else {
|
|
35
|
+
for (const light of config.lights) {
|
|
36
|
+
console.log(light.name, await transport.readState(light.address));
|
|
37
|
+
console.log('Fan', await transport.readFan(light.address));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} finally {
|
|
41
|
+
await transport.disconnect();
|
|
42
|
+
sequence.close();
|
|
43
|
+
}
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { MeshCrypto } from '../src/ble/crypto.js';
|
|
4
|
+
import { loadMeshConfig, meshDirectory, SequenceStore } from '../src/ble/storage.js';
|
|
5
|
+
import { cctPacket, type FixtureState, powerPacket } from '../src/ble/telink.js';
|
|
6
|
+
import { MeshTransport } from '../src/ble/transport.js';
|
|
7
|
+
import { type CameraRegion, captureWebcam, imagePixels, regionsFile } from './webcam.js';
|
|
8
|
+
|
|
9
|
+
function locateLight(dark: Buffer, lit: Buffer, name: string): CameraRegion {
|
|
10
|
+
const width = 320;
|
|
11
|
+
const height = 180;
|
|
12
|
+
const mask = new Uint8Array(width * height);
|
|
13
|
+
for (let y = 1; y < height - 1; y++)
|
|
14
|
+
for (let x = 1; x < width - 1; x++) {
|
|
15
|
+
let bright = true;
|
|
16
|
+
for (let dy = -1; dy <= 1; dy++)
|
|
17
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
18
|
+
const offset = ((y + dy) * 4 * 1280 + (x + dx) * 4) * 3;
|
|
19
|
+
const light = (lit[offset] + lit[offset + 1] + lit[offset + 2]) / 3;
|
|
20
|
+
const before = (dark[offset] + dark[offset + 1] + dark[offset + 2]) / 3;
|
|
21
|
+
if (light < 248 || light - before < 65) bright = false;
|
|
22
|
+
}
|
|
23
|
+
if (bright) mask[y * width + x] = 1;
|
|
24
|
+
}
|
|
25
|
+
const candidates: { count: number; x: number; y: number; width: number; height: number }[] = [];
|
|
26
|
+
for (let start = 0; start < mask.length; start++) {
|
|
27
|
+
if (!mask[start]) continue;
|
|
28
|
+
const queue = [start];
|
|
29
|
+
mask[start] = 0;
|
|
30
|
+
let minX = width,
|
|
31
|
+
maxX = 0,
|
|
32
|
+
minY = height,
|
|
33
|
+
maxY = 0;
|
|
34
|
+
for (let i = 0; i < queue.length; i++) {
|
|
35
|
+
const index = queue[i],
|
|
36
|
+
x = index % width,
|
|
37
|
+
y = Math.floor(index / width);
|
|
38
|
+
minX = Math.min(minX, x);
|
|
39
|
+
maxX = Math.max(maxX, x);
|
|
40
|
+
minY = Math.min(minY, y);
|
|
41
|
+
maxY = Math.max(maxY, y);
|
|
42
|
+
for (const next of [
|
|
43
|
+
index - width,
|
|
44
|
+
index + width,
|
|
45
|
+
...(x > 0 ? [index - 1] : []),
|
|
46
|
+
...(x < width - 1 ? [index + 1] : []),
|
|
47
|
+
]) {
|
|
48
|
+
if (next >= 0 && next < mask.length && mask[next]) {
|
|
49
|
+
mask[next] = 0;
|
|
50
|
+
queue.push(next);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const w = maxX - minX + 1,
|
|
55
|
+
h = maxY - minY + 1;
|
|
56
|
+
if (queue.length >= 8 && w / h > 0.35 && w / h < 2.8 && w < 70 && h < 70) {
|
|
57
|
+
candidates.push({ count: queue.length, x: (minX + maxX) * 2, y: (minY + maxY) * 2, width: w * 4, height: h * 4 });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
candidates.sort((a, b) => b.count - a.count);
|
|
61
|
+
const best = candidates[0];
|
|
62
|
+
if (!best || (candidates[1] && candidates[1].count > best.count * 0.7))
|
|
63
|
+
throw new Error(`Cannot identify a unique emitting fixture for ${name}: ${JSON.stringify(candidates)}`);
|
|
64
|
+
const size = Math.max(8, Math.min(24, Math.floor(Math.min(best.width, best.height) / 2)));
|
|
65
|
+
return { name, x: Math.round(best.x - size / 2), y: Math.round(best.y - size / 2), width: size, height: size };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const config = loadMeshConfig();
|
|
69
|
+
if (process.argv.includes('--reuse')) {
|
|
70
|
+
const capture = readdirSync('artifacts/webcam')
|
|
71
|
+
.filter((name) => /^calibration-\d+-off\.png$/.test(name))
|
|
72
|
+
.sort()
|
|
73
|
+
.at(-1);
|
|
74
|
+
if (!capture) throw new Error('No saved calibration captures');
|
|
75
|
+
const prefix = `artifacts/webcam/${capture.replace(/-off\.png$/, '')}`;
|
|
76
|
+
const dark = imagePixels(`${prefix}-off.png`);
|
|
77
|
+
const regions = config.lights.map((light) => locateLight(dark, imagePixels(`${prefix}-${light.key}.png`), light.key));
|
|
78
|
+
writeFileSync(
|
|
79
|
+
regionsFile,
|
|
80
|
+
JSON.stringify(
|
|
81
|
+
{ cameraIndex: process.env.AMARAN_CAMERA_INDEX ?? '0', capturedAt: new Date().toISOString(), regions },
|
|
82
|
+
null,
|
|
83
|
+
2
|
|
84
|
+
),
|
|
85
|
+
{ mode: 0o600 }
|
|
86
|
+
);
|
|
87
|
+
console.log(prefix, regions);
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
const crypto = new MeshCrypto(config.netKey, config.appKey);
|
|
91
|
+
const sequence = new SequenceStore(meshDirectory(), crypto.networkId.toString('hex'), config.source);
|
|
92
|
+
const transport = new MeshTransport(config, sequence);
|
|
93
|
+
const original = new Map<number, FixtureState>();
|
|
94
|
+
const regions: CameraRegion[] = [];
|
|
95
|
+
const errors: unknown[] = [];
|
|
96
|
+
try {
|
|
97
|
+
await transport.connect();
|
|
98
|
+
for (const light of config.lights) {
|
|
99
|
+
const state = await transport.readState(light.address);
|
|
100
|
+
if (state.mode !== 'cct')
|
|
101
|
+
throw new Error('Camera calibration currently requires CCT mode so all settings can be restored');
|
|
102
|
+
original.set(light.address, state);
|
|
103
|
+
}
|
|
104
|
+
for (const light of config.lights) await transport.send(light.address, powerPacket(false));
|
|
105
|
+
await delay(300);
|
|
106
|
+
const stamp = Date.now();
|
|
107
|
+
const dark = imagePixels(captureWebcam(`calibration-${stamp}-off`));
|
|
108
|
+
for (const light of config.lights) {
|
|
109
|
+
await transport.send(light.address, cctPacket(3200, 10, 0));
|
|
110
|
+
await delay(300);
|
|
111
|
+
const frame = captureWebcam(`calibration-${stamp}-${light.key}`);
|
|
112
|
+
regions.push(locateLight(dark, imagePixels(frame), light.key));
|
|
113
|
+
await transport.send(light.address, powerPacket(false));
|
|
114
|
+
await delay(300);
|
|
115
|
+
}
|
|
116
|
+
writeFileSync(
|
|
117
|
+
regionsFile,
|
|
118
|
+
JSON.stringify(
|
|
119
|
+
{ cameraIndex: process.env.AMARAN_CAMERA_INDEX ?? '0', capturedAt: new Date().toISOString(), regions },
|
|
120
|
+
null,
|
|
121
|
+
2
|
|
122
|
+
),
|
|
123
|
+
{ mode: 0o600 }
|
|
124
|
+
);
|
|
125
|
+
console.log('Identified fixture regions:', regions);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
errors.push(error);
|
|
128
|
+
} finally {
|
|
129
|
+
for (const light of config.lights) {
|
|
130
|
+
const state = original.get(light.address);
|
|
131
|
+
if (!state) continue;
|
|
132
|
+
try {
|
|
133
|
+
await transport.send(light.address, cctPacket(state.cct ?? 3200, state.intensity, state.gm ?? 0));
|
|
134
|
+
await delay(200);
|
|
135
|
+
await transport.send(light.address, powerPacket(!state.sleep));
|
|
136
|
+
const actual = await transport.readState(light.address);
|
|
137
|
+
if (
|
|
138
|
+
actual.cct !== state.cct ||
|
|
139
|
+
actual.intensity !== state.intensity ||
|
|
140
|
+
actual.sleep !== state.sleep ||
|
|
141
|
+
(light.model === '150c' && actual.gm !== state.gm)
|
|
142
|
+
)
|
|
143
|
+
errors.push(new Error(`Failed to restore ${light.key}`));
|
|
144
|
+
} catch (error) {
|
|
145
|
+
errors.push(error);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
await transport.disconnect();
|
|
149
|
+
sequence.close();
|
|
150
|
+
}
|
|
151
|
+
if (errors.length) throw new AggregateError(errors, 'Camera calibration failed');
|
|
152
|
+
process.exit(0);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import WebSocket from 'ws';
|
|
4
|
+
import { captureWebcam } from './webcam.js';
|
|
5
|
+
|
|
6
|
+
const ws = new WebSocket(process.env.AMARAN_REFERENCE_WS ?? 'ws://127.0.0.1:12345');
|
|
7
|
+
const pending = new Map<string, { resolve: (value: unknown) => void; reject: (error: Error) => void }>();
|
|
8
|
+
ws.on('message', (raw) => {
|
|
9
|
+
const message = JSON.parse(raw.toString());
|
|
10
|
+
const key = `${message.request?.type}:${message.request?.node_id ?? ''}`;
|
|
11
|
+
const request = pending.get(key);
|
|
12
|
+
if (!request) return;
|
|
13
|
+
if (message.code !== 0) request.reject(new Error(message.message));
|
|
14
|
+
else request.resolve(message.data?.data ?? message.data);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
async function command(type: string, nodeId?: string, args?: Record<string, unknown>): Promise<unknown> {
|
|
18
|
+
const key = `${type}:${nodeId ?? ''}`;
|
|
19
|
+
if (pending.has(key)) throw new Error(`Concurrent duplicate command: ${key}`);
|
|
20
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
21
|
+
try {
|
|
22
|
+
return await new Promise((resolve, reject) => {
|
|
23
|
+
pending.set(key, { resolve, reject });
|
|
24
|
+
timer = setTimeout(() => reject(new Error(`Desktop response timeout: ${key}`)), 8000);
|
|
25
|
+
ws.send(JSON.stringify({ version: 1, client_id: 'hardware-reference', type, node_id: nodeId, args }));
|
|
26
|
+
});
|
|
27
|
+
} finally {
|
|
28
|
+
clearTimeout(timer);
|
|
29
|
+
pending.delete(key);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const fixtures = [
|
|
34
|
+
{ key: 'desk', nodeId: '400Q5-11B2F8' },
|
|
35
|
+
{ key: 'front', nodeId: '400Q5-119B16' },
|
|
36
|
+
{ key: 'back', nodeId: '400J5-F2C008' },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await new Promise<void>((resolve, reject) => {
|
|
41
|
+
const timeout = setTimeout(() => reject(new Error('Desktop connection timeout')), 8000);
|
|
42
|
+
ws.once('open', () => {
|
|
43
|
+
clearTimeout(timeout);
|
|
44
|
+
resolve();
|
|
45
|
+
});
|
|
46
|
+
ws.once('error', (error) => {
|
|
47
|
+
clearTimeout(timeout);
|
|
48
|
+
reject(error);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
mkdirSync('artifacts', { recursive: true });
|
|
52
|
+
const snapshot = [];
|
|
53
|
+
for (const fixture of fixtures) {
|
|
54
|
+
snapshot.push({
|
|
55
|
+
...fixture,
|
|
56
|
+
sleep: await command('get_sleep', fixture.nodeId),
|
|
57
|
+
intensity: await command('get_intensity', fixture.nodeId),
|
|
58
|
+
cct: await command('get_cct', fixture.nodeId),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
writeFileSync(`artifacts/desktop-state-${Date.now()}.json`, JSON.stringify(snapshot, null, 2), { mode: 0o600 });
|
|
62
|
+
console.log(JSON.stringify(snapshot, null, 2));
|
|
63
|
+
if (process.argv[2] === 'reference') {
|
|
64
|
+
const stamp = Date.now();
|
|
65
|
+
for (const fixture of fixtures) {
|
|
66
|
+
await command('set_intensity', fixture.nodeId, { intensity: 10 });
|
|
67
|
+
await command('set_sleep', fixture.nodeId, { sleep: true });
|
|
68
|
+
}
|
|
69
|
+
await delay(1000);
|
|
70
|
+
console.log(captureWebcam(`desktop-${stamp}-all-off`));
|
|
71
|
+
for (const fixture of fixtures) {
|
|
72
|
+
await command('set_cct', fixture.nodeId, { cct: 3200, intensity: 10 });
|
|
73
|
+
await command('set_sleep', fixture.nodeId, { sleep: false });
|
|
74
|
+
await delay(1000);
|
|
75
|
+
console.log(captureWebcam(`desktop-${stamp}-${fixture.key}-3200-1pct`));
|
|
76
|
+
await command('set_cct', fixture.nodeId, { cct: 6500, intensity: 10 });
|
|
77
|
+
await delay(1000);
|
|
78
|
+
console.log(captureWebcam(`desktop-${stamp}-${fixture.key}-6500-1pct`));
|
|
79
|
+
await command('set_sleep', fixture.nodeId, { sleep: true });
|
|
80
|
+
}
|
|
81
|
+
console.log('Reference complete. All fixtures left asleep at 1%; original state saved in artifacts.');
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
ws.close();
|
|
85
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export const RegionSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
name: z.string(),
|
|
10
|
+
x: z.number().int().min(0),
|
|
11
|
+
y: z.number().int().min(0),
|
|
12
|
+
width: z.number().int().positive(),
|
|
13
|
+
height: z.number().int().positive(),
|
|
14
|
+
})
|
|
15
|
+
.refine((r) => r.x + r.width <= 1280 && r.y + r.height <= 720, 'Camera ROI is outside the frame');
|
|
16
|
+
export type CameraRegion = z.infer<typeof RegionSchema>;
|
|
17
|
+
export const regionsFile = path.resolve('artifacts/webcam/regions.json');
|
|
18
|
+
|
|
19
|
+
export function imagePixels(filename: string): Buffer {
|
|
20
|
+
const pixels = execFileSync(
|
|
21
|
+
'ffmpeg',
|
|
22
|
+
['-hide_banner', '-loglevel', 'error', '-i', filename, '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-'],
|
|
23
|
+
{ timeout: 10_000, maxBuffer: 1280 * 720 * 3 + 1024 }
|
|
24
|
+
);
|
|
25
|
+
if (pixels.length !== 1280 * 720 * 3) throw new Error('Unexpected camera frame dimensions');
|
|
26
|
+
return pixels;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function measureRegion(rgb: Buffer, region: CameraRegion) {
|
|
30
|
+
const sum = [0, 0, 0];
|
|
31
|
+
let clipped = 0;
|
|
32
|
+
for (let y = region.y; y < region.y + region.height; y++) {
|
|
33
|
+
for (let x = region.x; x < region.x + region.width; x++) {
|
|
34
|
+
const offset = (y * 1280 + x) * 3;
|
|
35
|
+
for (let channel = 0; channel < 3; channel++) sum[channel] += rgb[offset + channel];
|
|
36
|
+
if (Math.max(rgb[offset], rgb[offset + 1], rgb[offset + 2]) >= 250) clipped++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const pixels = region.width * region.height;
|
|
40
|
+
const centerX = region.x + region.width / 2;
|
|
41
|
+
const centerY = region.y + region.height / 2;
|
|
42
|
+
const inner = Math.max(region.width, region.height);
|
|
43
|
+
const outer = inner * 2;
|
|
44
|
+
const halo = [0, 0, 0];
|
|
45
|
+
let haloPixels = 0;
|
|
46
|
+
// The directly facing emitter clips white; its surrounding halo retains color information.
|
|
47
|
+
for (let y = Math.max(0, Math.floor(centerY - outer)); y < Math.min(720, centerY + outer); y++) {
|
|
48
|
+
for (let x = Math.max(0, Math.floor(centerX - outer)); x < Math.min(1280, centerX + outer); x++) {
|
|
49
|
+
const radius = (x - centerX) ** 2 + (y - centerY) ** 2;
|
|
50
|
+
if (radius < inner ** 2 || radius > outer ** 2) continue;
|
|
51
|
+
const offset = (y * 1280 + x) * 3;
|
|
52
|
+
if (Math.min(rgb[offset], rgb[offset + 1], rgb[offset + 2]) >= 245) continue;
|
|
53
|
+
for (let channel = 0; channel < 3; channel++) halo[channel] += rgb[offset + channel];
|
|
54
|
+
haloPixels++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
...region,
|
|
59
|
+
rgb: sum.map((value) => value / pixels),
|
|
60
|
+
clippedFraction: clipped / pixels,
|
|
61
|
+
haloRgb: haloPixels ? halo.map((value) => value / haloPixels) : undefined,
|
|
62
|
+
haloPixels,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function captureWebcam(label: string): string {
|
|
67
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(label)) throw new Error('Camera label must contain only letters, numbers, - or _');
|
|
68
|
+
const directory = path.resolve('artifacts/webcam');
|
|
69
|
+
mkdirSync(directory, { recursive: true });
|
|
70
|
+
chmodSync(directory, 0o700);
|
|
71
|
+
const output = path.join(directory, `${label}.png`);
|
|
72
|
+
execFileSync(
|
|
73
|
+
'ffmpeg',
|
|
74
|
+
[
|
|
75
|
+
'-hide_banner',
|
|
76
|
+
'-loglevel',
|
|
77
|
+
'error',
|
|
78
|
+
'-f',
|
|
79
|
+
'avfoundation',
|
|
80
|
+
'-pixel_format',
|
|
81
|
+
'nv12',
|
|
82
|
+
'-framerate',
|
|
83
|
+
'30',
|
|
84
|
+
'-video_size',
|
|
85
|
+
'1280x720',
|
|
86
|
+
'-i',
|
|
87
|
+
`${process.env.AMARAN_CAMERA_INDEX ?? '0'}:none`,
|
|
88
|
+
'-vf',
|
|
89
|
+
"select='gte(t,3)'",
|
|
90
|
+
'-frames:v',
|
|
91
|
+
'1',
|
|
92
|
+
'-update',
|
|
93
|
+
'1',
|
|
94
|
+
'-n',
|
|
95
|
+
output,
|
|
96
|
+
],
|
|
97
|
+
{ timeout: 20_000, stdio: ['ignore', 'ignore', 'pipe'] }
|
|
98
|
+
);
|
|
99
|
+
chmodSync(output, 0o600);
|
|
100
|
+
const rgb = imagePixels(output);
|
|
101
|
+
const calibration = existsSync(regionsFile)
|
|
102
|
+
? z
|
|
103
|
+
.object({ cameraIndex: z.string(), regions: z.array(RegionSchema) })
|
|
104
|
+
.parse(JSON.parse(readFileSync(regionsFile, 'utf8')))
|
|
105
|
+
: undefined;
|
|
106
|
+
if (calibration && calibration.cameraIndex !== (process.env.AMARAN_CAMERA_INDEX ?? '0'))
|
|
107
|
+
throw new Error('Camera calibration belongs to a different camera');
|
|
108
|
+
const regions = (calibration?.regions ?? []).map((region) => measureRegion(rgb, region));
|
|
109
|
+
writeFileSync(
|
|
110
|
+
output.replace(/\.png$/, '.json'),
|
|
111
|
+
JSON.stringify(
|
|
112
|
+
{
|
|
113
|
+
capturedAt: new Date().toISOString(),
|
|
114
|
+
note: calibration
|
|
115
|
+
? 'Calibrated fixture ROIs; automatic exposure/white balance, not a lux or CCT meter. Recalibrate after moving equipment.'
|
|
116
|
+
: 'Uncalibrated: run scripts/calibrate-webcam.ts before optical assertions.',
|
|
117
|
+
regions,
|
|
118
|
+
},
|
|
119
|
+
null,
|
|
120
|
+
2
|
|
121
|
+
),
|
|
122
|
+
{ mode: 0o600 }
|
|
123
|
+
);
|
|
124
|
+
return output;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
128
|
+
console.log(captureWebcam(process.argv[2] ?? `capture-${Date.now()}`));
|
|
129
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lightControl.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/lightControl.test.ts"],"names":[],"mappings":""}
|