From 254075320646dfc41b7d39a04a5f20bdf18860dc Mon Sep 17 00:00:00 2001 From: Marvo2011 Date: Wed, 13 Dec 2023 13:35:06 +0100 Subject: [PATCH 1/3] Add setting and install logic for usb bluetooth module --- CHANGELOG.md | 1 + etc/dbus-serialbattery/config.default.ini | 8 ++++++++ etc/dbus-serialbattery/reinstall-local.sh | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 300e1a32..6a9d68cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ * Added: The device instance does not change anymore when you plug the BMS into another USB port. Fixed https://github.com/Louisvdw/dbus-serialbattery/issues/718 by @mr-manuel * Added: Use current average of the last 300 cycles for time to go and time to SoC calculation by @mr-manuel * Added: Validate current, voltage, capacity and SoC for all BMS. This prevents that a device, which is no BMS, is detected as BMS. Fixes also https://github.com/Louisvdw/dbus-serialbattery/issues/479 by @mr-manuel +* Added: Setting and install logic for usb bluetooth module by @Marvo2011 * Changed: `VOLTAGE_DROP` now behaves differently. Before it reduced the voltage for the check, now the voltage for the charger is increased in order to get the target voltage on the BMS by @mr-manuel * Changed: Daly BMS - Fix readsentence by @transistorgit * Changed: Daly BMS - Fixed https://github.com/Louisvdw/dbus-serialbattery/issues/837 by @mr-manuel diff --git a/etc/dbus-serialbattery/config.default.ini b/etc/dbus-serialbattery/config.default.ini index af546e91..5794adc7 100644 --- a/etc/dbus-serialbattery/config.default.ini +++ b/etc/dbus-serialbattery/config.default.ini @@ -54,6 +54,14 @@ SOC_RESET_AFTER_DAYS = ; BLUETOOTH_BMS = Jkbms_Ble C8:47:8C:00:00:00, Jkbms_Ble C8:47:8C:00:00:11, Jkbms_Ble C8:47:8C:00:00:22 BLUETOOTH_BMS = +; --------- Bluetooth use USB --------- +; Description: Some users reported issues to the built in bluetooth module, you can try to fix it with an USB +; module. After a change you have to run reinstall-local.sh and to manual reboot the device! +; The usb bluetooth module must have BLE support (bluetooth version >= 4.0) +; False: Use the built in bluetooth module +; True: Disable built in bluetooth module and try to use USB module +BLUETOOTH_USE_USB = False + ; --------- CAN BMS --------- ; Description: Specify the CAN port(s) where the BMS is connected to. Leave empty to disable ; -- Available CAN BMS: diff --git a/etc/dbus-serialbattery/reinstall-local.sh b/etc/dbus-serialbattery/reinstall-local.sh index ffb4b25a..20f8d215 100755 --- a/etc/dbus-serialbattery/reinstall-local.sh +++ b/etc/dbus-serialbattery/reinstall-local.sh @@ -131,6 +131,22 @@ pkill -f "python .*/dbus-serialbattery.py /dev/tty.*" ### BLUETOOTH PART | START ### +# get bluetooth mode integrated/usb +bluetooth_use_usb=$(awk -F "=" '/^BLUETOOTH_USE_USB/ {print $2}' /data/etc/dbus-serialbattery/config.ini) + +# replace dtoverlay in /u-boot/config.txt this needs a reboot! +if [[ $bluetooth_use_usb == *"True"* ]]; then + if grep -q -r "miniuart-bt" /u-boot/config.txt; then + sed -i 's/miniuart-bt/disable-bt/g' /u-boot/config.txt + echo "ATTENTION! You have changed the bluetooth mode to USB! THIS NEEDS A MANUAL REBOOT!" + fi +elif [[ $bluetooth_use_usb == *"False"* ]]; then + if grep -q -r "disable-bt" /u-boot/config.txt; then + sed -i 's/disable-bt/miniuart-bt/g' /u-boot/config.txt + echo "ATTENTION! You have changed the bluetooth mode to built in module! THIS NEEDS A MANUAL REBOOT!" + fi +fi + # get BMS list from config file bluetooth_bms=$(awk -F "=" '/^BLUETOOTH_BMS/ {print $2}' /data/etc/dbus-serialbattery/config.ini) #echo $bluetooth_bms From f557815758c271de34bf30deae12dc7473d9c94a Mon Sep 17 00:00:00 2001 From: Marvo2011 Date: Sun, 17 Dec 2023 16:45:14 +0100 Subject: [PATCH 2/3] Add bluetooth device note to config.default.ini --- etc/dbus-serialbattery/config.default.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/dbus-serialbattery/config.default.ini b/etc/dbus-serialbattery/config.default.ini index 5794adc7..0cf567b6 100644 --- a/etc/dbus-serialbattery/config.default.ini +++ b/etc/dbus-serialbattery/config.default.ini @@ -58,6 +58,7 @@ BLUETOOTH_BMS = ; Description: Some users reported issues to the built in bluetooth module, you can try to fix it with an USB ; module. After a change you have to run reinstall-local.sh and to manual reboot the device! ; The usb bluetooth module must have BLE support (bluetooth version >= 4.0) +; Other bluetooth devices such as Ruvi tags not tested yet. ; False: Use the built in bluetooth module ; True: Disable built in bluetooth module and try to use USB module BLUETOOTH_USE_USB = False From 27276d53d82f7d7e33b600edb73772cbaa568323 Mon Sep 17 00:00:00 2001 From: Marvo2011 Date: Sun, 17 Dec 2023 16:47:22 +0100 Subject: [PATCH 3/3] Fix typo in bluetooth note in config.default.ini --- etc/dbus-serialbattery/config.default.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/dbus-serialbattery/config.default.ini b/etc/dbus-serialbattery/config.default.ini index 0cf567b6..cd62d6e2 100644 --- a/etc/dbus-serialbattery/config.default.ini +++ b/etc/dbus-serialbattery/config.default.ini @@ -58,7 +58,7 @@ BLUETOOTH_BMS = ; Description: Some users reported issues to the built in bluetooth module, you can try to fix it with an USB ; module. After a change you have to run reinstall-local.sh and to manual reboot the device! ; The usb bluetooth module must have BLE support (bluetooth version >= 4.0) -; Other bluetooth devices such as Ruvi tags not tested yet. +; Other bluetooth devices such as Ruuvi tags not tested yet. ; False: Use the built in bluetooth module ; True: Disable built in bluetooth module and try to use USB module BLUETOOTH_USE_USB = False