#!/bin/sh # Round-trip the JS writer through the C reader. No Pebble SDK required — see # pebble_stub.h for what is stubbed and what that does and does not prove. set -eu cd "$(dirname "$0")" echo "--- generating a payload with the real JS writer ---" node make-payload.js > /tmp/pebble-payload.hex echo "--- compiling the C reader against the stub SDK ---" cc -std=c11 -I. -Wall -Wextra -Wno-unused-parameter -Wno-unused-function \ -o /tmp/wireformat_test wireformat_test.c echo "--- packing a toggles line with the real JS packer ---" node -e ' global.Pebble = { addEventListener() {} }; global.localStorage = { getItem: () => null, setItem() {} }; global.XMLHttpRequest = function () {}; const js = require("../src/pkjs/index.js"); process.stdout.write(js.packToggles([ { name: "Amir\u2019s desktop".replace("\u2019", "\x27"), on: true, detail: "Loggia" }, { name: "A very long client name that will not fit", on: false, detail: "Living room mic here" }, { name: "Weird | name", on: true, detail: "Desk" }, ])); ' > /tmp/pebble-toggles.txt echo "--- decoding ---" /tmp/wireformat_test /tmp/pebble-toggles.txt < /tmp/pebble-payload.hex