Skip to content

fix: RS485 transparent pass-through + LuCI dark mode fixes#28

Open
weicheng04 wants to merge 3 commits into
Seeed-Studio:masterfrom
weicheng04:fix/rs485-transparent-and-dark-mode
Open

fix: RS485 transparent pass-through + LuCI dark mode fixes#28
weicheng04 wants to merge 3 commits into
Seeed-Studio:masterfrom
weicheng04:fix/rs485-transparent-and-dark-mode

Conversation

@weicheng04

@weicheng04 weicheng04 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Two independent fixes bundled in one PR (no file overlap between them).


1. RS485-MQTT transparent bridge (rs485-module, 5 files)

Problem: The previous implementation was not actually transparent — it broke binary data in three ways:

  • Uplink wrapped bytes in a JSON envelope {"data":"..."}, breaking Modbus RTU and other binary protocols.
  • String::from_utf8_lossy() replaced non-UTF-8 bytes with U+FFFD, and .trim() stripped whitespace from raw frames.
  • Downlink rejected any payload not shaped as {"data":"..."}, preventing binary clients from sending raw bytes.

Fix:

  • main.rs: publish / write_all raw byte slices directly, no JSON wrap.
  • Replace serde + serde_json deps with hex (used for log readability only).
  • Fix misleading ConnAck log ("Published [RS485->MQTT]" was logged on connect but nothing was actually published → changed to "MQTT connected, uplink ready on").
  • uci-defaults/73_rs485-module: rewrite to populate port1/port2/port3 per-port sections (previous code wrote flat mqtt.* / serial.* sections that nothing reads).
  • rs485-module.init: drop stale serial.enabled gate, start one transparent instance per port unless protocol_enabled=1.

2. LuCI dark mode fixes (luci-theme-sensecap + 6 luci-app-* JS, 11 files)

Problem: SenseCAP app JS injected hardcoded inline colors (background:#fff, color:#333, border:#ccc, etc.) in fixed-height log viewers, chart containers, and a Basic Station upload dropzone. Inline styles have CSS specificity 1000, so
dark.css selectors could not override them — leaving "white holes" when the browser switched to dark mode.

Fix:

  • Add 13 --sensecap-* CSS variables (light defaults in cascade.css/.less + dark overrides in dark.css/.less): log viewer bg/fg/border, chart bg/border, muted bg, dropzone border/hover-bg, muted/emphasis fg, divider, neutral button bg/hover.
  • Replace hardcoded colors in 7 JS files with var() references:
    • luci-app-rs485/.../rs485/log.js
    • luci-app-lora/.../lora/log.js
    • luci-app-lora/.../status/include/19_lora.js (chart container)
    • luci-app-lora/.../lora-platform/basicstation.js (dropzone stylesheet)
    • luci-app-ups/.../ups/log.js, ups/ups.js
    • luci-app-ota/.../system/ota.js
  • Basic Station .sfu-* stylesheet: brand green #8FC320 → reuse var(--primary).

Note: cascade.css / dark.css are LESS compilation outputs (Easy LESS VS Code plugin). Both .less source and .css artifact were updated in lockstep — the OpenWrt Makefile does not invoke lessc, so editing .less alone would have no
effect on the deployed artifact.


Test plan

  • Compile passes locally (openwrt-24.10, full make -j28)
  • All ipk installed on test container 10.0.0.160 via opkg install --force-reinstall
  • logread | grep RS485-MQTT shows new log line "MQTT connected, uplink ready on" (old build printed "Published [RS485->MQTT]")
  • CSS variables verified present in /www/luci-static/argon/css/{cascade,dark}.css on the container
  • var(--sensecap-*) references verified present in 6/7 JS files on the container
  • RS485 binary pass-through end-to-end test with real Modbus device (pending hardware)
  • Dark mode visual check on all 6 affected pages (in progress)

Known follow-ups (not in this PR)

  • luci-app-rs485 was skipped during deployment because the container had a newer luci feed version (26.146.42521~e3667f0 > our build 26.146.05840~441152d). The fix is in the source tree and will take effect after the next build with
    refreshed luci feed. As a workaround, rs485/log.js can be scp'd directly to /www/luci-static/resources/view/rs485/log.js.
  • chirpstack v4.15.0 main package fails to build due to an upstream rquickjs-sys 0.9.0 + system clang incompatibility (__gnuc_va_list not found); unrelated to this PR.
  • luci-theme-sensecap and luci-app-gateway both ship /usr/share/ucode/luci/template/themes/argon/sysauth.ut — packaging bug to be reported upstream.

Local builds clone OpenWrt 24.10 into openwrt/ for staging_dir/,
build_dir/, bin/ artifacts (~100MB+). Without .gitignore, an
accidental 'git add .' would commit all of it.
The previous implementation broke transparency in three ways:

- Uplink wrapped bytes in a JSON envelope {"data":"..."}, breaking
  binary protocols like Modbus RTU.
- String::from_utf8_lossy() replaced non-UTF-8 bytes with U+FFFD
  and .trim() stripped whitespace, corrupting raw frames.
- Downlink rejected any payload not shaped as {"data":"..."},
  preventing binary clients from sending raw bytes.

Changes:
- main.rs: publish/write_all raw byte slices directly (no JSON wrap);
  replace serde + serde_json deps with hex (log readability only);
  fix misleading ConnAck log ("Published" -> "uplink ready on").
- uci-defaults/73_rs485-module: rewrite to populate port1/2/3
  per-port sections (was dead code writing flat mqtt.*/serial.*
  sections that nothing reads).
- rs485-module.init: drop stale serial.enabled gate, start one
  transparent instance per port unless protocol_enabled=1.
- Makefile: update description (drop JSON mention).
SenseCAP app JS injected hardcoded inline colors (background:#fff,
color:#333, border:#ccc, etc.) in fixed-height log viewers, chart
containers, and a basicstation upload dropzone. Inline styles have
priority 1000 and could not be overridden by dark.css selectors,
leaving "white holes" when the browser switched to dark mode.

Changes:
- Add 13 --sensecap-* CSS variables (light defaults + dark overrides)
  to cascade.less/.css and dark.less/.css, covering: log viewer
  bg/fg/border, chart bg/border, muted bg, dropzone border/hover-bg,
  muted/emphasis fg, divider, neutral button bg/hover.
- Replace hardcoded colors in 7 JS files with var() references:
  rs485/log.js, lora/log.js, lora/status/include/19_lora.js,
  lora/lora-platform/basicstation.js, ups/log.js, ups/ups.js,
  system/ota.js.
- basicstation .sfu-* stylesheet: brand green #8FC320 -> var(--primary).

Note: cascade.css / dark.css are less compilation outputs (Easy LESS
VS Code plugin); both .less source and .css artifact updated in
lockstep since the OpenWrt build does not invoke lessc.
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