Skip to content

[codex] Add configurable autostart rocking#2

Draft
giezi wants to merge 4 commits into
owanvik:mainfrom
giezi:codex/persistent-autostart-rocking
Draft

[codex] Add configurable autostart rocking#2
giezi wants to merge 4 commits into
owanvik:mainfrom
giezi:codex/persistent-autostart-rocking

Conversation

@giezi
Copy link
Copy Markdown

@giezi giezi commented Apr 28, 2026

Summary

First, many thanks for the great project :) When you are on the go without your home WiFi, opening the web configuration to start rocking is not really an option. This feature solves that by adding a persisted web configuration for automatic rocking: users can enable autostart from the configuration page and choose the rocking intensity that should be used after a stroller BLE connect.

The implementation keeps the existing 30-minute auto-renew behavior, but makes startup more reliable for mobile/no-WiFi use cases: BLE now starts even when WiFi is unavailable, and autostart is sent only after the initial BLE reads and notification subscriptions have completed. Pending BLE writes are retried when NimBLE reports the GATT procedure is busy.

Changes

  • Add NVS-backed autostart settings with defaults: disabled and intensity 50.
  • Add an Automatic Rocking section to /config with enable and intensity controls.
  • Start the existing 30-minute auto-renew rocking flow after BLE setup completes when autostart is enabled.
  • Start BLE immediately instead of blocking the whole app until WiFi gets an IP address.
  • Defer web server and MQTT startup until WiFi is available.
  • Retry pending mode/rocking writes every 3 seconds when NimBLE reports the GATT procedure is busy.
  • Preserve the last locally written drive mode because the drive mode characteristic is write-only.
  • Update the dashboard to show Drive separately from Rocking (Off, On, Auto).

Root Cause

Autostart was previously tied to the BLE connect flow, but the app also waited indefinitely for WiFi before starting BLE at all. That meant automatic rocking could not work away from the configured WiFi network. During testing, sending the rocking command too early in the BLE setup could also be accepted by the stack but not result in stable rocking. Delaying autostart until after initial reads and subscriptions makes the command stick reliably.

Validation

  • Ran pio run successfully for seeed_xiao_esp32c6.
  • Flashed and tested on a Seeed XIAO ESP32-C6 with a reachable E-Priam stroller.
  • Confirmed BLE starts and scans even when WiFi is unavailable.
  • Confirmed autostart starts after BLE setup completes and uses the configured intensity.
  • Confirmed busy rock writes are retried and then succeed.
  • Observed stable rocking notifications with a decreasing timer after autostart.
  • Confirmed no private WiFi credentials are included in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant