()
| 37 | |
| 38 | class SensingService { |
| 39 | constructor() { |
| 40 | /** @type {WebSocket|null} */ |
| 41 | this._ws = null; |
| 42 | this._listeners = new Set(); |
| 43 | this._stateListeners = new Set(); |
| 44 | this._reconnectAttempt = 0; |
| 45 | this._reconnectTimer = null; |
| 46 | this._simTimer = null; |
| 47 | // Connection state: disconnected | connecting | connected | reconnecting | simulated |
| 48 | this._state = 'disconnected'; |
| 49 | // Data-source label exposed to the UI: |
| 50 | // "live" — real ESP32 hardware connected |
| 51 | // "server-simulated" — server is running but using synthetic data (no hardware) |
| 52 | // "reconnecting" — WebSocket disconnected, retrying |
| 53 | // "simulated" — client-side fallback simulation (server unreachable) |
| 54 | this._dataSource = 'reconnecting'; |
| 55 | // The raw source string from the server (e.g. "esp32", "simulated", "simulate") |
| 56 | this._serverSource = null; |
| 57 | this._lastMessage = null; |
| 58 | |
| 59 | // Ring buffer of recent RSSI values for sparkline |
| 60 | this._rssiHistory = []; |
| 61 | this._maxHistory = 60; |
| 62 | } |
| 63 | |
| 64 | // ---- Public API -------------------------------------------------------- |
| 65 |
nothing calls this directly
no outgoing calls
no test coverage detected