Skip to content

Merge cjkas upstream v3.0.13, bump to v3.2.0#1

Merged
shailensobhee merged 10 commits into
mainfrom
udpates_cjkas_20260424
Apr 25, 2026
Merged

Merge cjkas upstream v3.0.13, bump to v3.2.0#1
shailensobhee merged 10 commits into
mainfrom
udpates_cjkas_20260424

Conversation

@shailensobhee
Copy link
Copy Markdown
Owner

Summary

  • Merges 8 commits from cjkas/ESPSomfy-RTS up to upstream v3.0.13 (RTW decoder fix, /controller chunked streaming, login UX)
  • Bumps version to v3.2.0 across appversion, FW_VERSION, and asset cache-bust strings
  • Preserves all our HCSR04 distance-sensor work and shailensobhee SSDP branding

Upstream commits taken

26400c5 — Fix off-by-one bug in RTW protocol decoder

  • src/Somfy.cpp:177 — replaces special-case cmd = encKey == 133 ? My : (encKey - 133) with the symmetric inverse of the encoder (encKey - 132). Old formula decoded every non-My RTW command one slot too low (Up read as My, Down as MyUp).
  • src/Somfy.h:192 — adds uint8_t rawCmd to somfy_frame_t so the raw command nibble (decoded[1] >> 4) is preserved before any protocol-classification rewriting of cmd.
  • src/Somfy.cpp:164-165 — populate rawCmd in decodeFrame.
  • src/Somfy.cpp:4434-4437 — new ESP_LOGI on every valid RX showing ADDR / CMD / RAW_CMD / KEY / PROTO.
  • src/Somfy.cpp:4451 — emit rawCmd in the WebSocket frame event.
  • data-src/index.html:1030 — adds Raw header span to the frame log.
  • data-src/index.js:2956-2957 — render rawCmd as uppercase hex (0x{N}); blank if older firmware.
  • data-src/main.css:835-839 — sizes and centers the new column.

6365f16 — Memory-bounded streaming builder for /controller

  • src/WResp.h:55-60, src/WResp.cpp — new BufferedJsonFormatter subclass of JsonFormatter writing into a caller-supplied fixed buffer.
  • src/Web.cpp:428 — new ControllerChunker class owning a 3072-byte buffer; produces the /controller JSON one section at a time (HEADER → ROOMS → SHADES → GROUPS → REPEATERS → DONE).
  • src/Web.cpp:699-700handleController rewritten to drive the chunker via request->beginChunkedResponse(...). Eliminates the OOM that affected users with many shades/groups.

4f7fa73 — Login UX

  • data-src/login.html — wraps login in a real <form>; tags inputs with autocomplete="username" / "current-password" so password managers work.
  • data-src/index.js:1260-1262 — on successful login, store the credential via new PasswordCredential(...) + navigator.credentials.store(...) when the API is available.
  • appversion fetch is now properly awaited so the version string in the UI no longer flashes the placeholder.

Marker / merge commits

What we kept over upstream

  • FW_VERSION / appversion / cache-bust strings → v3.2.0 (intentionally ahead of upstream's v3.0.13)
  • src/ESPNetwork.cpp:323-332 SSDP fields → kept the shailensobhee branding from 74d126c (no conflict — upstream didn't touch those lines after our fork point)
  • Somfy noise-detection thresholds from 305a4b2 — unchanged (upstream only reworded the comment)

What was preserved on our side through the merge

  • Full HC-SR04 sensor stack: src/HCSR04.cpp/.h, HCSR04Settings on ConfigSettings, MQTT/SomfyController wiring, /hcsr04settings + /connecthcsr04 + /discovery routes, Sensors tab with live distance via WebSocket distance event

Conflict resolutions in merge commit 4969720

  • data-src/appversion, src/ConfigSettings.h, data-src/index.html (×2), data-src/index.js (×2): version-string conflicts — kept ours (re-bumped to v3.2.0 here)
  • src/Web.cpp include block: took both#include "HCSR04.h" (ours) plus #include <memory> (upstream needs it for std::make_shared<ControllerChunker> at Web.cpp:699)

Build status

  • Build: pio run -e esp32c6 succeeded — RAM 27.6%, Flash 38.9%
  • Flashed firmware + LittleFS to ESP32-C6 (XIAO), boots and serves UI

Test plan

  • Build for esp32c6 (no errors)
  • Flash firmware + filesystem
  • Web UI shows version v3.2.0
  • HC-SR04 distance live-updates every second on Sensors tab
  • Frame Log shows new Raw column populated with 0x{N} hex on Somfy RX
  • RTW remote (if available): non-My commands decode correctly (Up = Up, Down = Down, not the off-by-one mappings)
  • /controller endpoint loads (chunked streaming) with shades populated
  • Logout/login: browser offers to save credentials via PasswordCredential API
  • No regressions in shade control, groups, MQTT discovery

🤖 Generated with Claude Code

cjkas and others added 10 commits April 19, 2026 11:07
The RTW decoder formula encKey - 133 was off by one versus the
RTW encoder (which maps command N to encKey N + 132). This caused
every non-My RTW command to decode as the wrong button (e.g. Up
decoded as My, Down as MyUp). Also adds rawCmd diagnostic field to
received frames for protocol debugging.
Fix off-by-one bug in RTW protocol decoder.
…ayload one small unit at a time into a fixed 3KB buffer, so a chunked HTTP response can drain it as the TCP send window allows — no growing cbuf in the async response stream.
Memory-bounded streaming builder for /controller. Produces the JSON p…
fix the version number in UI. Enable the remember username/password functionality in browser.
# Conflicts:
#	data-src/appversion
#	data-src/index.html
#	data-src/index.js
#	src/ConfigSettings.h
#	src/Web.cpp
Marker bump alongside the upstream merge in 4969720, which pulled in
8 commits from https://github.com/cjkas/ESPSomfy-RTS up to upstream
v3.0.13. Detailed inventory of what was taken:

* 26400c5  Fix off-by-one bug in RTW protocol decoder
  src/Somfy.cpp:177 — replaces the special-case
    `cmd = encKey == 133 ? My : (encKey - 133)` with the symmetric
    inverse of the encoder (`encKey - 132`). The old formula
    decoded every non-My RTW command one slot too low (Up read as
    My, Down as MyUp, etc.).
  src/Somfy.h:192 — adds `uint8_t rawCmd` to somfy_frame_t so the
    raw command nibble (decoded[1] >> 4) is preserved before any
    protocol-classification rewriting of `cmd`.
  src/Somfy.cpp:164-165 — populate rawCmd in decodeFrame.
  src/Somfy.cpp:4434-4437 — new ESP_LOGI on every valid RX showing
    ADDR / CMD / RAW_CMD / KEY / PROTO for protocol debugging.
  src/Somfy.cpp:4451 — emit `rawCmd` in the WebSocket frame event.
  data-src/index.html:1030 — add "Raw" header span to frame log.
  data-src/index.js:2956-2957 — render rawCmd as uppercase hex
    (`0x{N}`) in the new column; blank if older firmware.
  data-src/main.css:835-839 — size and center the new column.

* 5c90715  Merge PR cjkas#24 (the merge of 26400c5 onto upstream main).

* f51e90b  chore: bump version to v3.0.12 (upstream marker only).

* 6365f16  Memory-bounded streaming builder for /controller
  src/WResp.h:55-60, src/WResp.cpp — new BufferedJsonFormatter
    subclass of JsonFormatter that writes into a caller-supplied
    fixed buffer with size tracking (`setBuffer`, `length`).
  src/Web.cpp:428 — new ControllerChunker class that owns a 3072
    byte buffer and produces the /controller JSON one section at
    a time across calls (HEADER → ROOMS → SHADES → GROUPS →
    REPEATERS → DONE), so the response can drain over the TCP
    send window without growing a heap cbuf.
  src/Web.cpp:699-700 — handleController rewritten to drive the
    chunker via `request->beginChunkedResponse(...)`. Eliminates
    the OOM that hit users with many shades/groups.

* 15e7dd1  Merge PR cjkas#25 (merge of 6365f16).

* 4f7fa73  Login UX
  data-src/login.html — wraps login in a real <form> and tags the
    inputs with `autocomplete="username"` / `"current-password"`
    so password managers and the browser key-fob UI work.
  data-src/index.js:1260-1262 — on successful login, store the
    credential via `new PasswordCredential(...)` +
    `navigator.credentials.store(...)` when the API is available.
  data-src/index.js / appversion — the appversion fetch is now
    properly awaited so the version string in the UI no longer
    flashes the placeholder.

* 6f856ff  Merge PR cjkas#26 (merge of 4f7fa73).

* 3ba27ad  chore: bump version to v3.0.13 (upstream marker only).

What we kept over upstream:
* FW_VERSION / appversion / cache-bust strings → v3.2.0 (this
  commit). Our fork is intentionally ahead of upstream's v3.0.13.
* src/ESPNetwork.cpp SSDP fields → kept the `shailensobhee`
  branding from 74d126c (upstream didn't touch those lines after
  our fork point, so no conflict).
* Somfy noise-detection thresholds from 305a4b2 — unchanged;
  upstream only reworded the comment.

What was preserved on our side through the merge:
* HC-SR04 sensor stack (src/HCSR04.cpp/.h, ConfigSettings.h
  HCSR04Settings, MQTT/SomfyController wiring, /hcsr04settings
  + /connecthcsr04 + /discovery routes, Sensors tab with live
  distance via WebSocket "distance" event).
* All HCSR04Settings fields on ConfigSettings remain.

Conflict resolutions in the merge commit (4969720):
* data-src/appversion, src/ConfigSettings.h, data-src/index.html
  (×2), data-src/index.js (×2): version-string conflicts — kept
  ours (now bumped again here to v3.2.0).
* src/Web.cpp include block: took both — `#include "HCSR04.h"`
  (ours) plus `#include <memory>` (upstream needs it for
  std::make_shared<ControllerChunker> at Web.cpp:699).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@shailensobhee shailensobhee merged commit e0de2c9 into main Apr 25, 2026
4 checks passed
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.

2 participants