feat(bms): discover JK batteries and integrate read-only telemetry scenes
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
# JK BMS · Bluetooth equipment integration
|
||||
|
||||
Owner scope: automatically show supported batteries below the onboard computer;
|
||||
read-only telemetry on Node, and a battery viewport with React overlays in Core.
|
||||
The battery settings, MOS switches, firmware and protection configuration are not
|
||||
operator actions of this plugin.
|
||||
|
||||
## Existing architecture and ownership
|
||||
|
||||
Read against live Ops on 2026-11-03: [Node requirements, MISSIONCOR-76](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-76),
|
||||
[USB-CAN, MISSIONCOR-90](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-90),
|
||||
[K1 discovery, MISSIONCOR-95](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-95),
|
||||
[X4, MISSIONCOR-77](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-77),
|
||||
[governance, MISSIONCOR-50](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-50).
|
||||
Battery findings and physical qualification belong to
|
||||
[MISSIONCOR-96](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-96).
|
||||
|
||||
The JK plugin owns BlueZ/protocol/compatibility. Node aggregates its versioned
|
||||
Unix-socket inventory into the existing Plugin SDK session contract. Core uses
|
||||
the paired Node channel and the existing sensor contribution registry. No new
|
||||
public port, SSH product transport, fleet root or desktop BLE owner is introduced.
|
||||
|
||||
## Discovery and supported profile
|
||||
|
||||
`plugins/jk-bms/runtime` is one unprivileged service. It scans powered LE adapters
|
||||
using its own BlueZ discovery leases; startup may enable an available adapter.
|
||||
It does not alter rfkill, reset USB, pair devices or cancel another client's lease.
|
||||
It never takes over an already connected peer. A 12-second discovery window is
|
||||
followed by bounded connection/read deadlines; failed attempts back off to 64 s.
|
||||
One connection is active at a time. After at most 120 s it returns to discovery
|
||||
to admit other batteries. At most eight distinct instances are retained.
|
||||
|
||||
Candidate evidence is the observed JK advertisement family: public address,
|
||||
`JK_` name prefix, manufacturer `0x0B65` with `88 a0` followed by that address.
|
||||
A name or FFE0 UUID by itself is insufficient. The stable ID hashes the public
|
||||
hardware address, independently of name, host, USB port or `hci` number. The
|
||||
strongest fresh adapter observation is selected for the next candidate. Distinct
|
||||
addresses remain distinct devices; discovery does not assign a nearby battery
|
||||
to a vehicle's power circuit or prove exclusive physical ownership.
|
||||
|
||||
Verification requires service FFE0 and characteristic FFE1 with notify and
|
||||
write-without-response, then a valid JK identity reply. The qualified telemetry
|
||||
layout is **JK_BD6A17S6P / firmware 11.47**. Other JK identities remain visible
|
||||
with unsupported compatibility, without requesting telemetry. This is not an
|
||||
assertion that all JK models, BLE address randomization or arbitrary BMS brands
|
||||
share one protocol. Additional profiles require evidence and regression fixtures.
|
||||
|
||||
The only vendor requests are the observed 20-byte 0x97 identity query and 0x96
|
||||
telemetry query. StartNotify/StopNotify use the standard temporary CCCD
|
||||
subscription. No parameter/settings command can be constructed. Replies require
|
||||
the 300-byte frame header/checksum; fragmented notifications are reassembled in
|
||||
a bounded buffer. Identity output uses a field allowlist because other offsets
|
||||
contain credentials. Unknown settings frames are discarded.
|
||||
|
||||
Protocol references inspected at fixed revisions: `patman15/aiobmsble`
|
||||
705ea1609243bc4bcda3584e556a92077d58b5e6 and `syssi/esphome-jk-bms`
|
||||
6b5a25aa43fb044c2a9592a5e87f06f8edc42554. Runtime does not install either project
|
||||
or download a moving upstream branch. The existing board/mac qualification is
|
||||
recorded separately in MISSIONCOR-96; synthetic tests are not radio acceptance.
|
||||
|
||||
## Lifecycle and storage
|
||||
|
||||
Only confirmed hardware identity is written under `/var/lib/mission-core-jk-bms`.
|
||||
On Node, samples stay in bounded RAM, expire after 300 s and reset daily UTC. A connection
|
||||
loss keeps the device and last sample, with `fresh=false`; a sample is current
|
||||
only within 12 s while streaming. Core strips measurements from durable fleet
|
||||
records and hydrates them from its bounded RAM cache. Core retains one latest snapshot per battery (at most 64 entries of 16 KiB) until the next UTC day, a Core restart, or 24 hours; null/disconnected updates do not erase it, and repeated or older observations cannot refresh its expiry. The browser retains the same UTC-day boundary and displays its original timestamp. Browser age checks cannot
|
||||
turn a disconnected or expired sample green. Reconnection changes link generation
|
||||
without remounting the viewer; restarting the service creates new SDK sessions.
|
||||
|
||||
The standard Node package includes the runtime, service account, systemd unit,
|
||||
BlueZ D-Bus policy and python3-dbus/BlueZ dependencies. Reboot needs no open UI or
|
||||
manual scan. The service has no root privileges, network namespace access,
|
||||
capabilities or raw device permissions. Rollback/removal stops and disables its
|
||||
unit; identity is retained. The first increment is packaged over qualified
|
||||
Node110 to preserve its other runtime payloads. A prepared Ubuntu24.04 amd64
|
||||
qualification is not a clean-image or multi-board physical acceptance.
|
||||
|
||||
## Product surface and scene profile
|
||||
|
||||
Placement approved by the owner: Fleet → vehicle → computer → battery row → eye.
|
||||
Node uses the existing modal with compact telemetry and cell voltages. Core opens
|
||||
a separate full equipment workspace with the same readout over the existing
|
||||
PlayCanvas renderer. Back and close return to the selected vehicle equipment.
|
||||
Expansion uses the same portal lifecycle as the Observatory, without a browser
|
||||
fullscreen permission or a second canvas.
|
||||
|
||||
The shared scene editor supplies materials, assignment, environment, light,
|
||||
grid, blur, textures, camera controls and JSON import/export. The same hierarchical object tree is used for the rover and battery, with search,
|
||||
selection of internal parts and per-object visibility. Select an object and a
|
||||
material, then use the arrow beside the material inspector close button to
|
||||
assign it. Whole palette tiles drag materials directly onto the picked mesh;
|
||||
dropping outside a real model object does nothing. Stable named object paths
|
||||
persist per-object assignments and visibility in the scene JSON. The pencil changes scene-edit mode; it is not a
|
||||
BMS settings action. In edit mode telemetry overlays clear the model workspace.
|
||||
|
||||
Battery profiles use IndexedDB `missioncore-battery-scenes`, keyed by stable
|
||||
device ID; JSON schema `missioncore.battery-scene/v1`, model `catl-r04/v1`.
|
||||
The first profile copies the selected vehicle's saved rover environment and
|
||||
camera preferences once. Subsequent edits, reset and import are separate from
|
||||
the rover. Each schema rejects the other model's JSON. Local save errors remain
|
||||
visible and export remains available. Settings contain no telemetry.
|
||||
|
||||
Geometry comes from the owner's `Cattle_Battery_Enclosure_R04.blend`, without
|
||||
saving the source. Thirteen cell bodies are retained; enclosure glass and print
|
||||
have separate materials. Engineering mesh parts are grouped into 50 render objects. Base, front, rear,
|
||||
top and both slotted side panels are separate objects, so one panel can use an
|
||||
independent transparent material. Old material-group assignments are retained;
|
||||
legacy visibility settings migrate to the split panels. The two continuous dielectric side backers are separate left/right objects; other dielectric supports retain their existing group. Old per-object assignments and visibility migrate to both side backers unless the child already has an explicit override.
|
||||
Dimensions and port geometry are a visual model, not newly verified hardware.
|
||||
The flowing cell shader uses **pack SOC**, not invented individual-cell SOC.
|
||||
During a temporary disconnect, the last valid SOC retains its exact gradient colours and emission; motion pauses at the last phase. Only absent/expired telemetry becomes neutral. Freshness remains explicit in the overlay; reduced-motion is respected.
|
||||
Individual voltages remain numerical. Calculated power is marked as calculated;
|
||||
configured capacity is not measured cell health. Unavailable temperature sensors
|
||||
remain unknown; protection bytes are labelled as raw rather than guessed alarms.
|
||||
|
||||
## Acceptance on 2026-11-03
|
||||
|
||||
Rover 006 was upgraded through the owner installer to Node `0.8.53-111`, release
|
||||
`d05c2fc96975277d1b3a34c3`. The installer completed in 25.926 s; Node and the BMS,
|
||||
K1, VESC, USB-CAN and RealSense services were active afterwards. The BMS service
|
||||
is enabled and runs without root. Existing X4 `0.1.3-30` was preserved. The
|
||||
installer's CAN observation was restored without motor commands.
|
||||
|
||||
The battery appeared automatically in the existing Core inventory. A 90.714 s
|
||||
read-only observation recorded 45 polls, four distinct fresh sample timestamps
|
||||
and recovery across four link generations with the same device ID. It also
|
||||
recorded disconnected/connect-failed periods: this is reconnection acceptance,
|
||||
not a continuous 90-second radio stream. A subsequent visible sample at
|
||||
15:40:26 UTC reported 82% SOC, 53.992 V, 13 cells, 9 mV spread and 170 cycles.
|
||||
|
||||
Core UI acceptance covered the actual R04 model, fresh/stale display, shared
|
||||
materials/environment/object inspectors, separate JSON import/export and local
|
||||
profile save/reopen. A battery-only exposure change survived reopen while rover
|
||||
exposure stayed unchanged; the test change was restored. Expand/restore and
|
||||
Escape with nested inspectors were also checked. The Node login page and its
|
||||
installed assets loaded through a temporary SSH forward, but the flat detail
|
||||
modal was not visually accepted remotely: it requires the board's local system
|
||||
login. No authentication guard was changed for that check.
|
||||
|
||||
Evidence is in `outputs/bms-integration-20261103/` (installer report, prepared-host
|
||||
qualification, live inventory summary and delivery report). The prepared
|
||||
Ubuntu 24.04 amd64 smoke check is not clean-image or second-board acceptance.
|
||||
Physical reboot acceptance, prolonged radio stability and exact cell SKU remain
|
||||
open. BMS settings, MOS controls, firmware and pairing were not changed.
|
||||
|
||||
## Shared object editor acceptance on 2026-11-03
|
||||
|
||||
The follow-up Core revision was checked in Chrome against the actual R04 and
|
||||
rover Observatory. The BMS eye replaces the equipment workspace; back restores
|
||||
the same selected vehicle. Edit mode opens the object hierarchy. An internal
|
||||
C07 cell and an individual side panel were selected through the tree. The
|
||||
material header arrow changed only the selected side; dragging a palette tile
|
||||
onto the front panel changed only that panel. JSON exports confirmed both object
|
||||
paths, persistence after reopen and no change after a drop onto empty sky.
|
||||
Import of the initial profile followed by re-export matched the initial JSON
|
||||
exactly, removing test assignments. Rover exposed the same tree and enabled
|
||||
assignment action without applying a test edit. Expanded/restore and Escape
|
||||
were checked. A final visual correction replaced long visibility labels with
|
||||
canonical eye buttons so tree names remain readable.
|
||||
|
||||
Validation: 1485 full unit tests, 48 focused tests after the navigation/portal
|
||||
follow-up, Core production/type build, shared UI type/build checks and registry
|
||||
validation. This Core-only follow-up did not install another Node release or
|
||||
change BMS configuration. Evidence: `outputs/bms-scene-editor-20261103/`.
|
||||
|
||||
|
||||
The follow-up editor refinement uses the canonical compact Tree in resizable
|
||||
inspectors. Picking geometry reveals the selected tree row and material; empty
|
||||
canvas clears selection. Cell, enclosure and electronics labels are separate
|
||||
objects. The cell material exposes two colour pairs (0%/100%), interpolated by
|
||||
pack SOC with configurable flowing emission. Scene document history supports
|
||||
Ctrl/Cmd+Z, redo, both keyboard layouts and gesture grouping without a fixed
|
||||
session step cap. Closing the scene releases history, preserving its saved
|
||||
profile. Canvas wheel events exclusively control orbit zoom and prevent browser
|
||||
default; other surfaces keep normal page scrolling. This same editor is used
|
||||
by the rover. Final validation: 1490 unit tests, 24 focused checks and production
|
||||
build; UI evidence and profile restore comparisons are consolidated in
|
||||
`outputs/bms-scene-editor-20261103/`.
|
||||
|
||||
|
||||
## Battery window composition
|
||||
|
||||
The device name follows the vehicle/platform in the ApplicationPanel title.
|
||||
One header owns back, full-window expand/restore, edit and close; the viewport
|
||||
contains only edit-mode scene tools. `ApplicationPanel allowFullscreen` moves
|
||||
the whole panel atomically and preserves modeless editor portals.
|
||||
|
||||
Telemetry overlays use canonical `GlassMaterialSurface context="scene"` (V4
|
||||
translucent material) with interactive hit areas. Wheel over a telemetry card
|
||||
scrolls the containing window; wheel over exposed canvas zooms the camera.
|
||||
Seven equal compact pack metrics occupy one top row; battery-state facts occupy the bottom of the viewport. Thirteen transparent interactive labels project onto actual cell geometry and show index plus measured voltage. BMS/connection and cell count/spread remain below the viewport.
|
||||
|
||||
Canonical `ResizableViewport` adjusts only height using either bottom corner
|
||||
or keyboard Up/Down (Shift accelerates). Corner indicators and hover surfaces are invisible; only the cursor changes. Keyboard focus remains visible. Resize preserves orbit position and focal length in CSS pixels, changing crop instead of refitting. Height is a separate local view
|
||||
preference under `missioncore.battery-view/v1:<device-id>`; it survives reopening
|
||||
and does not modify scene JSON, rover settings, telemetry or the BMS. The
|
||||
360–2160 px range bounds corrupt storage and accidental gestures. Storage
|
||||
failures are surfaced; longer views retain normal window scrolling.
|
||||
|
||||
|
||||
Camera pose is part of the shared scene JSON metadata (`camera`: pivot, distance,
|
||||
azimuth/elevation and referenceHeight). Completed gestures save locally;
|
||||
unmount flushes even an unfinished wheel gesture. Reopen and JSON import restore
|
||||
the pose. The projection reference height preserves apparent size across a
|
||||
viewport height change. Battery and rover poses remain independent.
|
||||
|
||||
Canonical ColorField now keeps incomplete HEX text locally. Deleting one or all
|
||||
digits works; a complete six-digit value applies live. Enter/blur normalizes a
|
||||
valid color or restores the last valid value; Escape cancels the draft. Scene
|
||||
undo synchronizes the field alongside all other controls.
|
||||
Reference in New Issue
Block a user