Repository navigation
Conversation
New xsns_119_jbd_bms_ble.ino talks to JBD/Xiaoxiang battery BMS units over BLE (via the existing xdrv_79 BLE stack), tracking up to 4 units in round-robin. Features: - Full parsing of basic/cell/version data, quiet-by-default console logging routed through the existing BLEDebug<index> level toggle. - Main-page web display with a device picker (add/remove by MAC) and a show/hide checkbox on the /ble config page. - Per-unit webhook (WebSend with all parsed fields) fired on fresh data via XdrvRulesProcess(0), since Tasmota Rules' DO clause only supports %value%/%VarN% - not cross-field references into the same JSON object - so a native webhook was needed for "notify on this unit's data" style automations. - Config (period, selected units, webhooks) persisted to /jbdbms.cfg across reboot via the filesystem API. xdrv_79 changes (needed by the driver above, no consumer besides it): - A write-repeat mechanism (op->writerepeat/writerepeatinterval): some BLE peripherals, including JBD BMS units, never notify off a single write but will if the same write is resent a few times on the same connection - resends while waiting for the notify timeout. - Multi-fragment notify assembly (op->notifyappend/notifyendbyte): JBD BMS responses can arrive as multiple BLE notify packets; this appends fragments into dataNotify until a JBD-protocol end byte (or declared payload length for 0xDD-framed packets) is seen, instead of only ever keeping the last fragment. - A few new per-operation knobs (writenoresponse, notifyresponse, readafterwrite, subscribedelay) and BLEOp param letters (x/y/z/d/q/i) to control them, plus matching JSON status fields. - Accessor functions (getSeenDeviceCount/getSeenDeviceInfo) for other drivers to read the BLE scan device list without touching the internal seenDevices vector/mutex directly - used by xsns_119 to build its device picker. - Routed a couple of existing hardcoded LOG_LEVEL_INFO calls through the existing BLELogLevel array for quiet-by-default logging, consistent with the rest of the driver. See JBD_BMS_BLE.md for commands, JSON fields, and Rules examples. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Hi, this functional not needed? |
|
It may be needed but I see a massive change in BLE driver code of which I currently cannot see it's impact. |
|
The +210/−18 in xdrv_79 looks large, but it is almost all opt-in fields on generic_sensor_t. Defaults keep the previous path, so MI32, EQ3 and existing BLEOp users do not take the new code unless a flag is set. The JBD driver is the first caller that sets them. The knobs themselves are not JBD-specific: they are generic per-operation controls, also available as optional BLEOp letters (x/y/z/d/q/i), so other awkward BLE devices can use them from the console or from another driver without a further change to xdrv_79. JBD/Xiaoxiang BMS cannot be driven with the current one-shot write + “keep the last notify fragment” model, and the same limits show up on other picky peripherals (write ignored unless resent, notify split across packets, Write Without Response only, subscribe that must be acknowledged, or a write dropped if it follows CCCD subscribe immediately). Three of those forced the driver changes:
getSeenDeviceCount() / getSeenDeviceInfo() are a mutex-protected read of the existing scan list, so another driver can build a “pick a visible device” UI without touching seenDevices. Scan itself is unchanged. JBD’s web picker is the first user; the accessors are general. Two spots do run for every notify/indicate operation:
Logging: new lines, and the old “op addr match but op is not waiting” message, go through BLELogLevel, which is zero-initialised (LOG_LEVEL_NONE) until BLEDebug is set. They stay quiet at the default log level. That particular message used to be LOG_LEVEL_ERROR; once fragments are assembled, a late packet after the operation completed is normal, so it is no longer an error. The “Show JBD in main web” checkbox is inside #ifdef USE_JBD_BMS_BLE and is not compiled into builds that do not enable the sensor. Advertisement parsing, MI32 and the BLEOp command syntax are untouched. The new letters are optional. |
Description:
New
xsns_119_jbd_bms_ble.inotalks to JBD/Xiaoxiang battery BMS units over BLE (via the existingxdrv_79BLE stack), tracking up to 4 units in round-robin. Features:BLEDebug<index>level toggle./bleconfig page.WebSendwith all parsed fields) fired on fresh data viaXdrvRulesProcess(0), since Tasmota Rules'DOclause only supports%value%/%VarN%- not cross-field references into the same JSON object - so a native webhook was needed for "notify on this unit's data" style automations./jbdbms.cfgacross reboot via the filesystem API.xdrv_79changes (needed by the driver above, no other consumer):op->writerepeat/writerepeatinterval): some BLE peripherals, including JBD BMS units, never notify off a single write but will if the same write is resent a few times on the same connection - resends while waiting for the notify timeout.op->notifyappend/notifyendbyte): JBD BMS responses can arrive as multiple BLE notify packets; this appends fragments intodataNotifyuntil a JBD-protocol end byte (or declared payload length for0xDD-framed packets) is seen, instead of only ever keeping the last fragment.writenoresponse,notifyresponse,readafterwrite,subscribedelay) andBLEOpparam letters (x/y/z/d/q/i) to control them, plus matching JSON status fields.getSeenDeviceCount/getSeenDeviceInfo) for other drivers to read the BLE scan device list without touching the internalseenDevicesvector/mutex directly - used byxsns_119to build its device picker.LOG_LEVEL_INFOcalls through the existingBLELogLevelarray for quiet-by-default logging, consistent with the rest of the driver.See JBD_BMS_BLE.md (included in this PR) for commands, JSON fields, and Rules examples.
Related issue (if applicable): none - new hardware support, no existing issue filed.
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass
🤖 Generated with Claude Code