Open ouinouin opened 3 years ago
I apologize I was not notified that you made this report
I dont have this particular BT adapter; I'll see if I can pick one up to test with
Getting a similar error with my 16s JBD 100A bms with Bluetooth module.
$ sudo hcitool lescan
LE Scan ...
CC:18:5C:C9:FB:8F (unknown)
A4:C1:37:00:29:64 xiaoxiang BMS
...
$ ./jbdtool -t bt:A4:C1:37:00:29:64 -d 9
main.c(861) main: transport: 0x7ffed36705, target: 0x7ffed36708
main.c(887) main: transport: bt
module.c(51) mybmm_load_module: NOT found.
module.c(72) mybmm_load_module: init: 0x555f057ae0
module.c(79) mybmm_load_module: adding module: bt
main.c(890) main: tp: 0x555f073c68
module.c(45) mybmm_load_module: mp->name: bt, mp->type: 2
module.c(51) mybmm_load_module: NOT found.
module.c(72) mybmm_load_module: init: 0x555f04bdb0
module.c(79) mybmm_load_module: adding module: jbd
main.c(893) main: cp: 0x555f073ab0
jbd.c(416) jbd_new: transport: bt
jbd.c(425) jbd_new: pp->target: A4:C1:37:00:29:64, pp->opts:
bt.c(48) bt_new: target: A4:C1:37:00:29:64, topts:
bt.c(61) bt_new: target: A4:C1:37:00:29:64, topts:
main.c(905) main: charge: -1, discharge: -1
main.c(928) main: reset: 0
main.c(944) main: mqtt: (nil)
main.c(994) main: outfp: 0x5584e802a0
jbd.c(436) jbd_open: opening...
bt.c(86) bt_open: connecting to: A4:C1:37:00:29:64
error: Fail to connect to the bluetooth device.
Using latest gattlib.
Also getting the above error on debian bullseye amd64. Is there a fix/workaround for this problem?
Debian bullseye: root@rpi4-8gb:/home/pi/gattlib/build/examples/ble_scan# ./ble_scan Discovered B0:7E:11:F9:BC:C1 - 'ID92931903101926 ' Discovered A4:C1:38:8E:76:3A - 'LH-SP20S005'
root@rpi4-8gb:/home/pi/jbdtool# ./jbdtool -t bt:A4:C1:38:8E:76:3A -d 3 main.c(861) main: transport: 0x7fd355679b, target: 0x7fd355679e main.c(887) main: transport: bt module.c(51) mybmm_load_module: NOT found. module.c(72) mybmm_load_module: init: 0x555e927ae0 module.c(79) mybmm_load_module: adding module: bt main.c(890) main: tp: 0x555e943c68 module.c(45) mybmm_load_module: mp->name: bt, mp->type: 2 module.c(51) mybmm_load_module: NOT found. module.c(72) mybmm_load_module: init: 0x555e91bdb0 module.c(79) mybmm_load_module: adding module: jbd main.c(893) main: cp: 0x555e943ab0 jbd.c(416) jbd_new: transport: bt jbd.c(425) jbd_new: pp->target: A4:C1:38:8E:76:3A, pp->opts: main.c(905) main: charge: -1, discharge: -1 main.c(928) main: reset: 0 main.c(944) main: mqtt: (nil) main.c(994) main: outfp: 0x55750152a0 jbd.c(436) jbd_open: opening... bt.c(86) bt_open: connecting to: A4:C1:38:8E:76:3A error: Fail to connect to the bluetooth device.
I just got a JBD bluetooth adapter so I'll finally be able to test using it.
I know for a fact it works with one of these:
Give me a few days to mess with it.
Also, I dont use blutooth at all on the JBDs in my powerwall - all of my packs use a Wifi adapter:
https://diysolarforum.com/threads/jbd-bms-wi-fi-module.17252/
@sshoecraft thank you for looking into this! If you need someone to test stuff, let me know.
Any update on this? I get the same connection error using BT.
Couldn't get this to work, spend too much time on it already. However, for what its worth, this did work for me:
Install https://github.com/Jakeler/ble-serial with pip install ble-serial. Run ble-scan to identify BMS:
$ ble-scan
Started BLE scan
A4:C1:38:19:9A:A2 (RSSI=-54): 16S10AH-LIGHT
A4:C1:38:F0:86:0D (RSSI=-91): 16S20AH50A
then run:
$ ble-serial -d A4:C1:38:F0:86:0D
Should get the following output:
21:34:19.750 | INFO | linux_pty.py: Slave created on /tmp/ttyBLE -> /dev/pts/0
21:34:19.750 | INFO | ble_interface.py: Receiver set up
21:34:19.913 | INFO | ble_interface.py: Trying to connect with A4:C1:38:F0:86:0D: 16S20AH50A
21:34:22.252 | INFO | ble_interface.py: Device A4:C1:38:F0:86:0D connected
21:34:22.253 | INFO | ble_interface.py: Found write characteristic 0000ff02-0000-1000-8000-00805f9b34fb (H. 20)
21:34:22.253 | INFO | ble_interface.py: Found notify characteristic 0000ff01-0000-1000-8000-00805f9b34fb (H. 16)
21:34:22.622 | INFO | main.py: Running main loop!
Now you can use jbdtool to connect to the serial port mentioned:
jbdtool -t serial:/dev/pts/0
Voltage 53.400
Current 0.000
DesignCapacity 20.000
RemainingCapacity 19.990
PercentCapacity 100
CycleCount 14
Probes 3
Strings 16
Temps 19.0,19.0,19.1
Cells 3.337,3.336,3.336,3.337,3.341,3.338,3.339,3.337,3.339,3.335,3.339,3.337,3.339,3.337,3.339,3.335
Balance 0000000000000000
CellTotal 53.401
CellMin 3.335
CellMax 3.341
CellDiff 0.006
CellAvg 3.338
DeviceName SP20S020A-L16S-50A-50A-B-U
ManufactureDate 20211101
Version 12.9
FET Charge,Discharge
ok now thats cool. I'll check out ble-serial!
I finally got a JBD BT adapter and will start testing it in the next couple of weeks.
I can confirm, that the solution from @mav- with https://github.com/Jakeler/ble-serial works fine. builtin bt support with libgatt does not work for me , i get the same error as posted above (debian 12 amd64).
But with ble-serial i am fine :)
Hi, trying to run the code after compiling against latest pull of libgatt, no success. have the same issue on ubuntu and on debian buster :
despite being able to scan and see the JBD device :