47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
/* Builds a payload with the REAL writer from src/pkjs/index.js and prints it as hex. */
|
|
const path = require("path");
|
|
global.Pebble = { addEventListener() {} };
|
|
global.localStorage = { getItem: () => null, setItem() {} };
|
|
global.XMLHttpRequest = function () {};
|
|
const writer = require(path.join(__dirname, "..", "src", "pkjs", "index.js"));
|
|
|
|
const plan = {
|
|
positions_available: true,
|
|
unplaced: [{ name: "Bibi", initial: "B", color: "#AA00FF" }],
|
|
};
|
|
const level = {
|
|
name: "Ground",
|
|
rooms: [
|
|
{
|
|
name: "Kitchen",
|
|
ha_area_id: "kitchen",
|
|
points: [[0, 0], [0.5, 0], [0.5, 0.5], [0, 0.5]],
|
|
targets: [],
|
|
occupants: [
|
|
{ id: 1, name: "Amir", initial: "A", color: "#FF0000", position: { x: 0.25, y: 0.25 } },
|
|
],
|
|
},
|
|
{
|
|
// A radar target and nobody named. This must read as OCCUPIED even though HA
|
|
// never reports the area: somebody is in there, and a positive detection
|
|
// outranks "no area data".
|
|
name: "Loggia",
|
|
ha_area_id: null,
|
|
points: [[0.6, 0], [1, 0], [1, 0.4], [0.6, 0.4]],
|
|
targets: [{ x: 0.8, y: 0.2 }],
|
|
occupants: [],
|
|
},
|
|
{
|
|
// Genuinely unknown: drawn, no area, nothing detected. The third state.
|
|
name: "Store",
|
|
ha_area_id: null,
|
|
points: [[0.6, 0.6], [1, 0.6], [1, 1], [0.6, 1]],
|
|
targets: [],
|
|
occupants: [],
|
|
},
|
|
],
|
|
};
|
|
|
|
const bytes = writer.build(plan, level, false, 16);
|
|
process.stdout.write(bytes.map((b) => b.toString(16).padStart(2, "0")).join(" "));
|