-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #503 from mr-manuel/jkbms_ble
Some improvements and fixes (jkbms_ble)
- Loading branch information
Showing
10 changed files
with
122 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
#!/bin/sh | ||
|
||
# install required packages | ||
opkg update | ||
opkg install python3-misc python3-pip | ||
pip3 install bleak | ||
|
||
# install driver | ||
tar -zxf ./venus-data.tar.gz -C /data | ||
sh /data/etc/dbus-serialbattery/reinstalllocal.sh | ||
echo "make sure to disable Settings/Bluetooth in the Remote-Console to prevent reconnects every minute. In case of crash after ~12-16 hours disable raspberry pi 3 internal bluetooth via dtoverlay and use an external usb bluetooth-dongle" | ||
|
||
# setup cronjob to restart Bluetooth | ||
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 | ||
|
||
|
||
echo "Make sure to disable Settings -> Bluetooth in the Remote-Console to prevent reconnects every minute." | ||
echo "ATTENTION!" | ||
echo "- At the moment this driver needs a serial to USB adapter attached to start. The serial side hasn't to be connected anywhere." | ||
echo "- If you changed the default connection PIN of JKBMS, then you have to pair the JKBMS first using OS tools like the \"bluetoothctl\"." | ||
echo "See https://wiki.debian.org/BluetoothUser#Using_bluetoothctl for more details." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,74 @@ | ||
#!/bin/sh | ||
#backup old PageBattery.qml once. New firmware upgrade will remove the backup | ||
#!/bin/bash | ||
set -x | ||
|
||
# elaborate version string for better comparing | ||
# https://github.com/kwindrem/SetupHelper/blob/ebaa65fcf23e2bea6797f99c1c41174143c1153c/updateFileSets#L56-L81 | ||
function versionStringToNumber () | ||
{ | ||
local local p4="" ; local p5="" ; local p5="" | ||
local major=""; local minor="" | ||
|
||
# first character should be 'v' so first awk parameter will be empty and is not prited into the read command | ||
# | ||
# version number formats: v2.40, v2.40~6, v2.40-large-7, v2.40~6-large-7 | ||
# so we must adjust how we use paramters read from the version string | ||
# and parsed by awk | ||
# if no beta make sure release is greater than any beta (i.e., a beta portion of 999) | ||
|
||
read major minor p4 p5 p6 <<< $(echo $1 | awk -v FS='[v.~-]' '{print $2, $3, $4, $5, $6}') | ||
((versionNumber = major * 1000000000 + minor * 1000000)) | ||
if [ -z $p4 ] || [ $p4 = "large" ]; then | ||
((versionNumber += 999)) | ||
else | ||
((versionNumber += p4)) | ||
fi | ||
if [ ! -z $p4 ] && [ $p4 = "large" ]; then | ||
((versionNumber += p5 * 1000)) | ||
large=$p5 | ||
elif [ ! -z $p6 ]; then | ||
((versionNumber += p6 * 1000)) | ||
fi | ||
} | ||
|
||
# get current Venus OS version | ||
versionStringToNumber $(head -n 1 /opt/victronenergy/version) | ||
((venusVersionNumber = $versionNumber)) | ||
|
||
# revert to VisualItemModel, if before v3.00~14 (v3.00~14 uses VisibleItemModel) | ||
versionStringToNumber "v3.00~14" | ||
|
||
qmlDir="/data/etc/dbus-serialbattery/qml" | ||
|
||
if (( $venusVersionNumber < $versionNumber )); then | ||
echo "Venus OS $(head -n 1 /opt/victronenergy/version) is olter than v3.00~14. Replacing VisibleItemModel with VisualItemModel" | ||
fileList="$qmlDir/PageBattery.qml" | ||
fileList+=" $qmlDir/PageBatteryCellVoltages.qml" | ||
fileList+=" $qmlDir/PageBatterySetup.qml" | ||
fileList+=" $qmlDir/PageLynxIonIo.qml" | ||
for file in $fileList ; do | ||
sed -i -e 's/VisibleItemModel/VisualItemModel/' "$file" | ||
done | ||
fi | ||
|
||
|
||
# backup old PageBattery.qml once. New firmware upgrade will remove the backup | ||
if [ ! -f /opt/victronenergy/gui/qml/PageBattery.qml.backup ]; then | ||
cp /opt/victronenergy/gui/qml/PageBattery.qml /opt/victronenergy/gui/qml/PageBattery.qml.backup | ||
fi | ||
if [ ! -f /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup ]; then | ||
cp /opt/victronenergy/gui/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/PageLynxIonIo.qml.backup | ||
fi | ||
#copy new PageBattery.qml | ||
|
||
# copy new PageBattery.qml | ||
cp /data/etc/dbus-serialbattery/qml/PageBattery.qml /opt/victronenergy/gui/qml/ | ||
#copy new PageLynxIonIo.qml | ||
# copy new PageLynxIonIo.qml | ||
cp /data/etc/dbus-serialbattery/qml/PageLynxIonIo.qml /opt/victronenergy/gui/qml/ | ||
#copy new PageBatteryCellVoltages | ||
# copy new PageBatteryCellVoltages | ||
cp /data/etc/dbus-serialbattery/qml/PageBatteryCellVoltages.qml /opt/victronenergy/gui/qml/ | ||
cp /data/etc/dbus-serialbattery/qml/PageBatterySetup.qml /opt/victronenergy/gui/qml/ | ||
#stop gui | ||
# stop gui | ||
svc -d /service/gui | ||
#sleep 1 sec | ||
# sleep 1 sec | ||
sleep 1 | ||
#start gui | ||
# start gui | ||
svc -u /service/gui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
sh /data/etc/dbus-serialbattery/reinstalllocal.sh | ||
|
||
sh /data/etc/dbus-serialbattery/restartservice.sh | ||
|
||
/etc/init.d/bluetooth restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters