Add experimental HDS Tasmota grinder TCP mode#82
Conversation
tadelv
left a comment
There was a problem hiding this comment.
Looks solid as a DRAFT and the feature is off by default, so no blocker. Verified clean: no grinder code runs off the loop/core-0 (no AsyncTCP/BLE/USB task touch, no FreeRTOS task spawned), TCP input parsing is bounded (no overflow path), MAC-as-identity/validation scope is correctly documented as trusted-WLAN-only, tare-aware + zero-exit guard + grind-confirmation correctly handle the ADS1232 ramp blip-to-zero (the PR #71 calibration lesson), and the deep-sleep teardown chain flushes grinder settings before esp32_sleep().
MAJOR to resolve before this leaves DRAFT:
WiFi.setSleep(false)+esp_wifi_set_ps(WIFI_PS_NONE)for the entire grinding session (grinder_runtime_low_latency.h:49-50, alsogrinder_discovery.h:79-80). This is the CLAUDE.md #2 WiFi/BLE coexistence footgun — it directly contradicts the explicit comment inwifi_setup.cpp::connectToWifi("Intentionally not calling WiFi.setSleep(false)"). If low-latency grinder TCP genuinely requiresWIFI_PS_NONE, that needs a maintainer decision and a CLAUDE.md carve-out, and concurrent grinder + BLE use should be gated (right now nothing stops both being active).
Minor:
- New globals outside
include/parameter.h:b_buttonChordSuppressUntilRelease(hds.ino:27),b_grinderMenuDirectEntry(menu.h:217),grinderSettings/grinderRuntime(grinder_runtime.h:112-113). No cross-task access so no thread risk, but CLAUDE.md says globals belong inparameter.hfor discoverability. - Forcing WiFi-on-boot is a one-way ratchet:
grinderOnwritesb_wifiOnBoot=trueto EEPROM butgrinderOffdoesn't restore prior state. Once grinder is enabled, WiFi-on-boot stays on even after grinder is disabled. Probably intentional, but it's an undocumented user-facing side effect — document or restore. - 12s blocking discovery poll (
delay(250)loop ingrinderEnsureWifiReadyForDiscovery). Acceptable since it's menu-initiated, just noting it blocksprocessWsPendingCmds/ WS drain during that window.
Suggestion (separate from this PR): test_grinder_tcp_contract.py is static source-string matching. As the grinder protocol/state-machine grows, pulling it into pure host-compilable units with real unit tests would catch behavior regressions the grep tests can't — especially for the cutoff/arming/zero-exit logic where the interesting bugs live.
Summary
Notes