Skip to content

Commit

Permalink
improved reinstall and disable script
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Sep 5, 2023
1 parent b07cf18 commit b2b465e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Changed: For BMS_TYPE now multiple BMS can be specified by @mr-manuel
* Changed: Improved battery error handling on connection loss by @mr-manuel
* Changed: Improved battery voltage handling in linear absorption mode by @ogurevich
* Changed: Improved driver disable script by @md-manuel
* Changed: Improved driver reinstall when multiple Bluetooth BMS are enabled by @mr-manuel
* Changed: Improved Jkbms_Ble driver by @seidler2547 & @mr-manuel
* Changed: LLT/JBD - Fix cycle capacity with https://github.com/Louisvdw/dbus-serialbattery/pull/762 by @idstein
Expand Down
14 changes: 11 additions & 3 deletions etc/dbus-serialbattery/disable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ bash /opt/victronenergy/swupdate-scripts/remount-rw.sh

# remove driver from serial starter
rm -f /data/conf/serial-starter.d/dbus-serialbattery.conf
# remove serial-starter.d if empty
rmdir /data/conf/serial-starter.d >/dev/null 2>&1
# kill serial starter, to reload changes
pkill -f "/opt/victronenergy/serial-starter/serial-starter.sh"

Expand All @@ -16,14 +18,20 @@ rm -rf /service/dbus-serialbattery.*
rm -rf /service/dbus-blebattery.*

# kill driver, if running
pkill -f "dbus-serialbattery"
pkill -f "dbus-blebattery"
# serial
pkill -f "supervise dbus-serialbattery.*"
pkill -f "multilog .* /var/log/dbus-serialbattery.*"
pkill -f "python .*/dbus-serialbattery.py /dev/tty.*"
# bluetooth
pkill -f "supervise dbus-blebattery.*"
pkill -f "multilog .* /var/log/dbus-blebattery.*"
pkill -f "python .*/dbus-serialbattery.py .*_Ble"

# remove install script from rc.local
sed -i "/bash \/data\/etc\/dbus-serialbattery\/reinstall-local.sh/d" /data/rc.local

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1


### needed for upgrading from older versions | start ###
Expand Down
19 changes: 15 additions & 4 deletions etc/dbus-serialbattery/reinstall-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ if [ ! -f "$filename" ]; then
fi

# kill driver, if running. It gets restarted by the service daemon
pkill -f "supervise dbus-serialbattery.*"
pkill -f "multilog .* /var/log/dbus-serialbattery.*"
pkill -f "python .*/dbus-serialbattery.py /dev/tty.*"


Expand Down Expand Up @@ -168,22 +170,31 @@ if [ "$length" -gt 0 ]; then
echo "Found $length Bluetooth BMS in the config file!"
echo

/etc/init.d/bluetooth stop
echo

# install required packages
# TO DO: Check first if packages are already installed
echo "Installing required packages to use Bluetooth connection..."

opkg update
opkg install python3-misc python3-pip
pip3 install bleak
# pip3 install bleak==0.20.2

echo
pip3 install bleak==0.20.2
# pip3 install bleak==0.21.0

echo
pip3 install dbus-fast==1.87.0
# pip3 install dbus-fast==1.87.3
# pip3 install dbus-fast==1.87.4

echo "done."
echo

/etc/init.d/bluetooth start
echo

# function to install ble battery
install_blebattery_service() {
if [ -z "$1" ]; then
Expand Down Expand Up @@ -253,12 +264,12 @@ if [ "$length" -gt 0 ]; then
# grep -qxF "5 0,12 * * * /etc/init.d/bluetooth restart" /var/spool/cron/root || echo "5 0,12 * * * /etc/init.d/bluetooth restart" >> /var/spool/cron/root

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1

else

# remove cronjob
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root
sed -i "/5 0,12 \* \* \* \/etc\/init.d\/bluetooth restart/d" /var/spool/cron/root >/dev/null 2>&1

echo
echo "No Bluetooth battery configuration found in \"/data/etc/dbus-serialbattery/config.ini\"."
Expand Down
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_list_from_config(


# Constants
DRIVER_VERSION = "1.0.20230904dev"
DRIVER_VERSION = "1.0.20230905dev"
zero_char = chr(48)
degree_sign = "\N{DEGREE SIGN}"

Expand Down

0 comments on commit b2b465e

Please sign in to comment.