Skip to content

vesmart-server disconnects ALL BLE devices on ALL adapters when keepalive timer fires #1587

@cgoudie

Description

@cgoudie

Summary

The vesmart-server service (/opt/victronenergy/vesmart-server/) disconnects all BLE devices known to BlueZ when its internal 60-second keepalive timer expires — regardless of which adapter the devices are connected to, and regardless of whether the devices are VE.Smart Networking participants.

This makes it impossible to maintain persistent BLE connections to third-party devices (e.g., BLE battery management systems) on a Cerbo GX, even when using a separate USB Bluetooth adapter (hci1).

Environment

  • Device: Cerbo GX
  • Venus OS: v3.x (observed on current firmware)
  • vesmart-server version: 0.5.9 (/opt/victronenergy/vesmart-server/vesmart_server.py)
  • Bluetooth adapters: Built-in hci0 + USB dongle hci1

Root Cause

The keepalive timer in /opt/victronenergy/vesmart-server/gattserver.py fires every 60 seconds when no VE.Smart device has written to the GATT service. When it fires, the timeout handler:

  1. Calls bluezutils.get_devices(self.bus) — which returns all devices across all adapters
  2. Iterates through every device and calls device_interface.Disconnect() on each one

There is no filtering by:

  • Adapter — devices on hci1 are disconnected even though vesmart-server was started with -i hci0
  • Device type — non-VE.Smart devices (BMS units, sensors, etc.) are disconnected even though they never interacted with the VE.Smart GATT service

How to Reproduce

  1. Connect any BLE device to the Cerbo GX on any adapter (including a USB adapter on hci1)
  2. Ensure no VE.Smart devices are connected (so the keepalive timer is never reset)
  3. Monitor with dbus-monitor --system filtering for org.bluez.Device1.Disconnect
  4. After exactly 60 seconds, observe the Disconnect() call being made on your device by the vesmart_server.py process

Confirmed via btmon traces showing Disconnect Complete events with reason Connection Terminated By Local Host at exactly 60-second intervals, and via dbus-monitor tracing the D-Bus Disconnect() calls back to the vesmart_server.py PID.

Expected Behavior

vesmart-server should only disconnect devices that it is managing — i.e., devices that have connected to and are participating in the VE.Smart Networking GATT service. Devices that were connected by other processes (other Venus OS services, third-party drivers, etc.) should not be affected by the VE.Smart keepalive lifecycle.

Non-VE.Smart devices, and devices on other adapters, should never be touched.

Impact

This bug affects anyone running persistent BLE connections alongside vesmart-server, including:

  • Third-party BLE battery management systems (via projects like dbus-serialbattery)
  • BLE sensors connected through a secondary adapter
  • Any future Venus OS feature that maintains long-lived BLE connections

The current workaround is to disable vesmart-server entirely, which also disables Victron Connect BLE access and VE.Smart Networking.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions