feat(peripheral-demo): add Edge App for peripheral integration#719
feat(peripheral-demo): add Edge App for peripheral integration#719nicomiguelino wants to merge 55 commits intomasterfrom
Conversation
- Add `peripheral-integration-poc` Edge App displaying live sensor data - Add `startPeripheralMockServer()` to dev-server plugin (WebSocket on port 9010) - Inject `screenly.peripherals.subscribe()` IIFE into generated `screenly.js` - Add `PeripheralEvent` and `ScreenlyPeripherals` types to edge-apps-library - Add `ws` and `@types/ws` as dev dependencies to edge-apps-library - Add `POC.md` documenting the protocol, API design, and rationale Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Reviewer Guide 🔍(Review updated until commit ab7323a)Here are some key observations to aid the review process:
|
|
@514sid, this PR is a proof of concept. Please check the TL;DR comment in this PR for reference. |
PR Code Suggestions ✨Latest suggestions up to ab7323a Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 157b403
Suggestions up to commit 2b6f1a8
|
- Reformat multi-property CSS transition to multi-line style - Wrap long TypeScript lines for better readability - Update screenshots for all supported resolutions
- Add eslint-disable comments for max-lines and max-lines-per-function - Reformat long lines and type definitions to satisfy Prettier
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace `PeripheralEvent` with `PeripheralReading` and `PeripheralSnapshot` types - Aggregate all `source_channel_get_state` responses into a single snapshot before notifying subscribers - Update snapshot on each `source_channel_event` push and re-notify with full state - Add `_timestamp`, `_id`, and `_uptime` metadata fields to snapshot - Update `main.ts` to consume `PeripheralSnapshot` in the subscribe callback - Update `POC.md` TL;DR and types section to reflect new snapshot shape Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add spaces around dashes in table separator rows to comply with MD060 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `peripheral-integration-poc` Edge App showing live sensor data - Add `startPeripheralMockServer()` to dev-server with Octo-Avenger protocol - Expose `screenly.peripherals.watchState(cb)` with lazy WebSocket connection - Add `PeripheralReading` and `ScreenlyPeripherals` types to edge-apps-library Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Port multi-screen app from embedded-world-demo-app reference - Includes public clock, operator dashboard, and maintenance views - Add role-based screen switching with welcome overlay and auto-logout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `peripherals.ts` that calls `watchState` and feeds ambient temperature into state - Register `initPeripherals` in `main.ts` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add authenticate() with hardcoded operator/maintenance card IDs - Handle secure_card_id readings in peripherals to trigger screen switch - Export showWelcomeThenSwitch for use outside screen module - Use fixed mock card IDs (DEADBEEF/CAFEBABE) instead of random hex - Increase dev server push interval from 3s to 5s Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Switch push format from source_channel_event to edge_app_source_state - Send full state snapshot on identification and every 5 seconds - Add humidity and air_pressure mock channels - Add server-side generateUlid() and buildStateSnapshot() helpers - Change PeripheralReading.timestamp from ISO string to epoch ms - Simplify screenly.js client by removing fetchInitialSnapshot and normalizeEvent - Update POC.md to reflect new schema and wire format Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nicomiguelino
left a comment
There was a problem hiding this comment.
Don't forget to remove edge-apps/peripheral-integration-poc/ afterwards. We don't need it anymore.
- Remove peripheral-integration-poc as it has been superseded by peripheral-integration-demo - Move Peripheral API docs to peripheral-integration-demo README Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ttings - Update Peripheral API code snippet to reflect actual usage in the app - Remove stale `message` setting from configuration table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `PeripheralStateMessage` type matching the Octo-Avenger wire shape - Update `watchState` signature to pass `PeripheralStateMessage` instead of `PeripheralReading[]` - Update `notifySubscribers` in dev-server to wrap readings in the wire envelope - Update `peripherals.ts` and README to reflect the new callback shape Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ation - Add `register(edgeAppId)` to `ScreenlyPeripherals` and IIFE — sends registration after identification ACK - Add `screenly_edge_app_id` to `ScreenlyObject` type - Call `register()` from `peripherals.ts` before `watchState`, falling back to a generated ULID - Fix `generateUlid()` to produce correct 26-char ULIDs using Crockford's Base32 alphabet - Mock server silently accepts `edge_app_registration` (fire-and-forget) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
edge-apps/peripheral-integration-demo/src/features/peripherals.ts
Outdated
Show resolved
Hide resolved
edge-apps/peripheral-integration-demo/src/features/peripherals.ts
Outdated
Show resolved
Hide resolved
…positives - Replace numeric `assetsInlineLimit` with a function - Font files (woff2, ttf, otf, eot) are never inlined as base64 - All other assets (e.g. images) still inline if under 7 MB
- Add Authentication and Dashboards categories to screenly.yml - Add Authentication and Dashboards categories to screenly_qc.yml
- Change top bar title to lowercase - Adjust spacing in public screen layout - Modify padding for public clock section - Reorganize secure access and safety carousel cards
…ient - Remove `identified` flag — PI no longer sends identification ACK - Remove identification response handler from `onmessage` - Send registration immediately on `open` instead of waiting for ACK
…tion - Remove identification handshake from client — init is now connect + register only - Remove identification handler and `identified` flag from dev server mock - Push initial state snapshot on connection instead of after identification - Drop `identified` guard from periodic state push interval
- Rename `PeripheralState` to `SourceChannelStateReport` - Rename `PeripheralStateMessage` to `EdgeAppSourceState` - Update all references in peripherals client and demo app
… clarity - Extract `send` into a top-level `sendMessage` that throws on failure - Add JSDoc to `sendMessage` and `notifySubscribers` - Add inline comment explaining the `notifySubscribers` call site - Log a warning instead of silently dropping malformed JSON frames - Remove `[screenly]` prefix from WebSocket error log message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Edge Apps never receive raw `downstream_node_event` messages - The hardware integration service handles the ACK back to the driver internally and transforms the event into `source_channel_loss` or `source_channel_resume` before forwarding to Edge Apps Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename `SourceChannelStateReport` back to `PeripheralState` - Rename `EdgeAppSourceState` back to `PeripheralStateMessage` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove @import 'tailwindcss' to fix rendering on QtWebEngine (Pi 4) - Replace Tailwind utility classes in index.html with semantic CSS classes - Add layout classes: main-content, screen, card-stack, card-header, operator-grid, progress-row - Add JS-toggled utilities: .hidden and .opacity-0 - Inline padding-block on .public-clock, transition on #safety-text Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ate card mappings - Add Blob message handling in peripheral client to support binary WebSocket data - Update card-to-role mapping with actual NFC card UIDs (uhtzBg, gj-6XA) - Remove obsolete code comments Made-with: Cursor
…temperature updates - Track previous screen state to only restart timer on screen changes - Prevent continuous temperature updates from resetting the countdown - Fixes timer jumping from 59 to 51 and back on Raspberry Pi Made-with: Cursor
… to extend session - Export restartLogoutTimer from timer module - Call restartLogoutTimer when valid card scanned on same screen - Allows users to extend session by re-scanning their card Made-with: Cursor
…ate.ts - Update MOCK_CARD_UIDS to match the card mappings in authenticate.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…operator and maintenance - Add isTransitioning flag to block screen visibility updates during role switch - Keep all screens hidden while welcome overlay and preload are in progress - Prevents temperature updates from briefly showing previous role's UI on Pi Made-with: Cursor
…maintenance view - Map Hardware enum to display-friendly format (e.g. Raspberry Pi, Screenly Player Max) - Fixes hardware name showing as RaspberryPi without space Made-with: Cursor
Summary
peripheral-integration-demoEdge App demonstrating multi-screen role-based display (public, operator, maintenance) driven by live peripheral datacreatePeripheralClient()toedge-apps-library— a WebSocket client that connects to the hardware integration service and delivers sensor state viawatchState(callback)startPeripheralMockServer()to the Vite dev-server plugin, simulating the peripheral WebSocket protocol on port 9010 for local developmentSourceChannelStateReportandEdgeAppSourceStatetypes toedge-apps-libraryNotes
register()orwatchState()is first called, so existing apps in dev mode are unaffectedScreenshots