Louisvdw / dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
MIT License
541 stars 165 forks source link

JKBMS BLE - Cerbo GX do not connect #909

Closed Honusnap closed 9 months ago

Honusnap commented 10 months ago

Cerbo GX do not conenct to the JKbms bluetooth

Hi all, Roughly what i did :

wget the install package then used 1 (last version install : was yesterday : 07/01/2024, did not checked the version), was not working so tried those commands (among others) pip3 install dbus-fast==1.94.1 pip3 install bleak==0.21.0 I then tried nightly >Master install .. nothing better (dbus-serialbattery v1.0.20231117dev)

I've seen many post on bluetooth problems, i''ve tried many solution and still have not solved my problem With bluetoothctl, i disconnected, removed, paired unpaired ... the JKbms MAC. => No success

Here is something that seems abnormal :

[bluetooth]# pair 3C:A5:50:81:D7:C6 Attempting to pair with 3C:A5:50:81:D7:C6 [CHG] Device 3C:A5:50:81:D7:C6 Connected: yes Request passkey [agent] Enter passkey (number in 0-999999): 123456 [CHG] Device 3C:A5:50:81:D7:C6 Paired: yes Pairing successful [JK-B1A24S15P]# info 3C:A5:50:81:D7:C6 Device 3C:A5:50:81:D7:C6 (public) Name: JK-B1A24S15P Alias: JK-B1A24S15P Paired: yes Trusted: no Blocked: no Connected: yes LegacyPairing: no UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Unknown (0000ffe0-0000-1000-8000-00805f9b34fb) ManufacturerData Key: 0xfad6 ManufacturerData Value: 88 a0 3c a5 50 81 d7 c6 ..<.P... AdvertisingFlags: 06 .

Then some second after, without having done ANY other action on the device :

[JK-B1A24S15P]# info 3C:A5:50:81:D7:C6 Device 3C:A5:50:81:D7:C6 (public) Name: JK-B1A24S15P Alias: JK-B1A24S15P Paired: no Trusted: no Blocked: no Connected: yes LegacyPairing: no UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Unknown (0000ffe0-0000-1000-8000-00805f9b34fb) ManufacturerData Key: 0xfad6 ManufacturerData Value: 88 a0 3c a5 50 81 d7 c6 ..<.P... AdvertisingFlags: 06

bluetoothctl is very active and verbose, is there something else running, a service or whatever else running that is messing with Ble configuration ? Why is the succesfull pairing disepearing ? The pairing code is : 123456 and pairing work normally on my phone.

Driver version

v1.0.20231117dev

Venus OS device type

Cerbo GX

Venus OS version

3.13

BMS type

JKBMS / Heltec BMS

Cell count

16

Battery count

1

Connection type

Please select

Config file

[DEFAULT]

; If you want to add custom values/settings, then check the values/settings you want to change in "config.default.ini"
; and insert them below to persist future driver updates.

; Example (remove the semicolon ";" to uncomment and activate the value/setting):

MAX_BATTERY_CHARGE_CURRENT = 100.0
MAX_BATTERY_DISCHARGE_CURRENT = 150.0

; --------- Cell Voltages ---------
; Description: Cell min/max voltages which are used to calculate the min/max battery voltage
; Example: 16 cells * 3.45V/cell = 55.2V max charge voltage. 16 cells * 2.90V = 46.4V min discharge voltage
MIN_CELL_VOLTAGE   = 2.900
; Max voltage can seen as absorption voltage
MAX_CELL_VOLTAGE   = 3.410
FLOAT_CELL_VOLTAGE = 3.375

; BMS Type
BMS_TYPE = Jkbms <= Tried with or without it => No change
BLUETOOTH_BMS = Jkbms_Ble 3C:A5:50:81:D7:C6

Relevant log output

For info, i got the same error message then many others on the driver side : 

2024-01-08 13:34:15.695188500 connect and scrape on address: 3C:A5:50:81:D7:C6
2024-01-08 13:34:15.695190500 btloop
2024-01-08 13:34:15.695192500 reconnect
2024-01-08 13:34:15.695193500 Exiting bt-loop
2024-01-08 13:34:16.041020500 Missing device address argument
2024-01-08 13:34:17.168915500 INFO:SerialBattery:Starting dbus-serialbattery
2024-01-08 13:34:17.170339500 INFO:SerialBattery:dbus-serialbattery v1.0.20230531
2024-01-08 13:34:17.622122500 INFO:SerialBattery:Init of Jkbms_Ble at 3C:A5:50:81:D7:C6
2024-01-08 13:34:17.622850500 INFO:SerialBattery:Test of Jkbms_Ble at 3C:A5:50:81:D7:C6
**2024-01-08 13:34:32.707628500 ERROR:SerialBattery:ERROR >>> No battery connection at Jkbms_Ble**
2024-01-08 13:34:32.707946500

And it repeat indefinitly

Maybe this log have some more details :

2024-01-08 13:54:48.310432500 Device 3C:A5:50:81:D7:C6 (public)
2024-01-08 13:54:48.310441500   Alias: JK-B1A24S15P
2024-01-08 13:54:48.310443500   Paired: no
2024-01-08 13:54:48.310444500   Trusted: no
2024-01-08 13:54:48.310446500   Blocked: no
2024-01-08 13:54:48.310447500   Connected: no
2024-01-08 13:54:48.310448500   LegacyPairing: no
2024-01-08 13:54:48.310450500   RSSI: -70
2024-01-08 13:54:48.313333500
2024-01-08 13:55:24.967798500 *** CCGX booted (0) ***
2024-01-08 13:56:25.791002500
2024-01-08 13:56:25.791013500 INFO:Bluetooth details
2024-01-08 13:56:25.862864500 Attempting to disconnect from 3C:A5:50:81:D7:C6
2024-01-08 13:56:25.862872500 Successful disconnected
2024-01-08 13:56:31.020148500 Device 3C:A5:50:81:D7:C6 (public)
2024-01-08 13:56:31.020156500   Alias: JK-B1A24S15P
2024-01-08 13:56:31.020158500   Paired: no
2024-01-08 13:56:31.020159500   Trusted: no
2024-01-08 13:56:31.020160500   Blocked: no
2024-01-08 13:56:31.020161500   Connected: no
2024-01-08 13:56:31.020163500   LegacyPairing: no
2024-01-08 13:56:31.020164500   RSSI: -70
2024-01-08 13:56:31.022342500
2024-01-08 13:56:35.818949500 INFO:SerialBattery:
2024-01-08 13:56:35.819710500 INFO:SerialBattery:Starting dbus-serialbattery
2024-01-08 13:56:35.820961500 INFO:SerialBattery:dbus-serialbattery v1.0.20231117dev
2024-01-08 13:56:36.819611500 INFO:SerialBattery:Init of Jkbms_Ble at 3C:A5:50:81:D7:C6
2024-01-08 13:56:36.825585500 INFO:SerialBattery:Test of Jkbms_Ble at 3C:A5:50:81:D7:C6
2024-01-08 13:56:40.161765500 INFO:SerialBattery:--> asy_connect_and_scrape(): error while connecting to bt: Characteristic with UUID 00002a24-0000-1000-8000-00805f9b34fb could not be found!
2024-01-08 13:56:42.636459500 INFO:SerialBattery:--> asy_connect_and_scrape(): Exit
2024-01-08 13:56:46.369345500 ERROR:SerialBattery:No BMS found at 3C:A5:50:81:D7:C6
2024-01-08 13:56:46.370091500 ERROR:SerialBattery:ERROR >>> No battery connection at Jkbms_Ble

Any other information that may be helpful

No response

Honusnap commented 10 months ago

Hello,

jkbms.prn.py line 443 : client = BleakClient(self.address)

https://bleak.readthedocs.io/en/latest/api/client.html _"Although example code frequently initializes BleakClient with a Bluetooth address for simplicity, it is not recommended to do so for more complex use cases. There are several known issues with providing a Bluetooth address as the address_or_bledevice argument."

Could it be the source of the problem ? I added the debug display in configf.ini,

BleakClient(self.address) with 3C:A5:50:81:D7:C6 => seems to fail bluetoothctl connect 3C:A5:50:81:D7:C6 => work

2024-01-09 14:23:56.716399500 INFO:SerialBattery: 2024-01-09 14:23:56.717421500 INFO:SerialBattery:Starting dbus-serialbattery 2024-01-09 14:23:56.723321500 INFO:SerialBattery:dbus-serialbattery v1.0.2023111 7dev 2024-01-09 14:23:57.739998500 INFO:SerialBattery:Init of Jkbms_Ble at 3C:A5:50:8 1:D7:C6 2024-01-09 14:23:57.741599500 INFO:SerialBattery:Test of Jkbms_Ble at 3C:A5:50:8 1:D7:C6 2024-01-09 14:23:57.761070500 DEBUG:SerialBattery:scraping thread started -> mai n thread id: 3069358096 scraping thread: 3051500640 2024-01-09 14:23:57.763839500 DEBUG:SerialBattery:--> asy_connect_and_scrape(): Connect and scrape on address: 3C:A5:50:81:D7:C6 2024-01-09 14:23:58.479539500 DEBUG:SerialBattery:--> asy_connect_and_scrape(): btloop 2024-01-09 14:23:58.480246500 DEBUG:SerialBattery:--> asy_connect_and_scrape(): reconnect 2024-01-09 14:24:05.824580500 INFO:SerialBattery:--> asy_connect_and_scrape(): error while connecting to bt: Characteristic with UUID 00002a24-0000-1000-8000-00805f9b34fb could not be found! 2024-01-09 14:24:08.245174500 INFO:SerialBattery:--> asy_connect_and_scrape(): Exit 2024-01-09 14:24:08.282880500 ERROR:SerialBattery:No BMS found at 3C:A5:50:81:D7:C6 2024-01-09 14:24:08.283620500 ERROR:SerialBattery:ERROR >>> No battery connection at Jkbms_Ble

https://copyprogramming.com/howto/unable-to-readspecific-characteristic-from-ble-device-with-python

Honusnap commented 10 months ago

Hello All, I Swapped the JKbms for an other more recent one .. AND ... it work with this newer one.

mr-manuel commented 9 months ago

Eventually try to set the passkey for the connection to 1234.

Honusnap commented 9 months ago

As i know, we can't change the bluetooth key, but we can change the password key that's been used in the application for advanced parameters. This password key is the same and different then "1234" in both of my BMS, old BMS do not work, new one does.

But i wIll try to changed the password to 1234 on the old BMS when i'll hook it up to a pack i'm building, thanks.