77#include < Arduino.h>
88#include < functional>
99
10- /* *
11- * Display-side protocol facade.
12- *
13- * Owns a BLE client transport + Endpoint and exposes semantic send methods and
14- * typed response callbacks. The connect sequence is asynchronous: the link is
15- * established via connectToServer(), and the controller's SystemInfo arrives as
16- * a pushed message (onSystemInfo) which is when capability-dependent setup
17- * should run.
18- */
10+ // Display-side protocol facade: owns transport + Endpoint, exposes semantic sends and typed response callbacks.
11+ // Connecting is async: capability-dependent setup belongs in onSystemInfo, pushed by the controller after connect.
1912class GaggiMateClient {
2013 public:
2114 using ConnectionCallback = std::function<void (bool connected)>;
@@ -43,19 +36,18 @@ class GaggiMateClient {
4336 bool isConnected () const { return _endpoint.isConnected (); }
4437 void disconnect () { _transport.disconnect (); }
4538
46- // BLE round-trip latency (ms) measured by the reliability layer (send -> ACK).
47- // EWMA-smoothed; refreshed at least every ~2s by the keep-alive ping plus on
48- // every control update. hasLatency() is false until the first ACK of a link.
39+ // Forget the paired controller so the display can pair to a different one.
40+ void clearBonds () { _transport.clearBonds (); }
41+
42+ // EWMA-smoothed send->ACK round-trip (ms); hasLatency() is false until the first ACK of a link.
4943 uint32_t getLatencyMs () const { return _endpoint.latencyMs (); }
5044 uint32_t getLastLatencyMs () const { return _endpoint.lastLatencyMs (); }
5145 bool hasLatency () const { return _endpoint.hasLatency (); }
5246
53- // Tight connection interval (responsive control) while active; relaxed when
54- // idle to give the shared radio back to Wi-Fi.
47+ // Tight connection interval while active; relaxed when idle to give the shared radio back to Wi-Fi.
5548 void setLowLatency (bool active) { _transport.setLowLatency (active); }
5649
57- // Native NimBLE client handle, used by ControllerOTA / status RSSI (OTA uses
58- // its own BLE service, independent of this protocol).
50+ // Native NimBLE client handle for ControllerOTA / status RSSI (OTA uses its own BLE service).
5951 NimBLEClient *getClient () const { return _transport.getNativeClient (); }
6052
6153 // Build a payload without sending (compose your own batch, then send()).
@@ -69,8 +61,7 @@ class GaggiMateClient {
6961 gm::Payload buildAutotune (uint32_t testTime, uint32_t samples, uint32_t heaterWattage);
7062 gm::Payload buildPressureScale (float scale);
7163 gm::Payload buildTare ();
72- // Pack channel/brightness pairs into one LedControl payload; entries beyond
73- // the schema's per-message cap (LedControl.channels max_count) are dropped.
64+ // Pack channel/brightness pairs into one LedControl payload; entries beyond the schema's max_count are dropped.
7465 gm::Payload buildLedControl (const LedChannelCommand *channels, size_t count);
7566
7667 // Commands (display -> controller)
@@ -85,17 +76,14 @@ class GaggiMateClient {
8576 void sendPressureScale (float scale);
8677 void sendThermostatControl (float boilerLowPass, float groupLowPass);
8778 void tare ();
88- // Drive several LED channels in one message (avoids per-channel sends that
89- // the outbound queue would coalesce down to a single channel).
79+ // Drive several LED channels in one message; per-channel sends would coalesce down to a single channel.
9080 void sendLedControl (const LedChannelCommand *channels, size_t count);
9181
92- // Send a pre-built payload / batch of payloads (one frame). Compose batches
93- // from build*() helpers -- e.g. the display's delta-based control update.
82+ // Send a pre-built payload / batch of payloads (one frame), composed from the build*() helpers.
9483 void send (const gm::Payload &payload) { _endpoint.send (payload); }
9584 void sendBatch (const gm::Payload *payloads, size_t count) { _endpoint.sendBatch (payloads, count); }
9685
97- // Fired when the connected controller is missing the framed-comms
98- // characteristics (old / incompatible firmware); link is kept for OTA.
86+ // Fired when the controller lacks the framed-comms characteristics (old firmware); link is kept for OTA.
9987 void onIncompatibleController (IncompatibleCallback cb) { _incompatibleCb = std::move (cb); }
10088
10189 // Response registrations (controller -> display)
0 commit comments