Skip to content

Deno Server Doesn't Know if Bat Signal was Raised #2

@its-all-waves

Description

@its-all-waves

This issue is part of the Below C Level Hacktivity - 25.11.04 (Issue #5).

Issue

Arduino Cloud uses a "fire and forget" model for communicating Cloud Variable changes. Specifically, when the Deno Server sets its Cloud Variable bat_signal, it has no way of knowing if Bat Signal actually powered on its projector. The effect of this is that the Deno Server updates its local batSignal.bat_signal, which it shares with the frontend via an SSE stream, regardless of the state of Bat Signal. Bat Signal could be fully powered off, and the frontend will still act as if Bat Signal has powered on its projector.

Hint

Implement some kind of acknowledgement using synced Cloud Variables. (There are more direct means of doing this with an upgraded Arduino account (webhooks and triggers), but we won't go there, for now.)

Possible Fix

Add a boolean did_bat_signal_turn_on var to both Things and sync these cloud vars. The flow should look like this:

  • Ding Dong button pressed on frontend
  • Deno Server sets only its Cloud Variable bat_signal = true (not its local batSignal.bat_signal, which is referenced when streaming state to the frontend)
  • Bat Signal receives bat_signal = true, sets did_bat_signal_turn_on = true
  • Deno Server receives did_bat_signal_turn_on = true, THEN sets local batSignal.bat_signal = true, broadcasts to clients, and sets did_bat_signal_turn_on = false
  • Bat Signal receives did_bat_signal_turn_on = false, so it can acknowledge the next request

Context

Only one user at a time can operate the Ding Dong button on the frontend. The button is disabled if is_bat_signal_busy (on), or is_someone_coming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions