Skip to content

Commit

Permalink
possible fix for LLT/JBS connection problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Sep 4, 2023
1 parent 048db0a commit 54055b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions etc/dbus-serialbattery/bms/lltjbd_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import atexit
import functools
import threading
import sys
from asyncio import CancelledError
from typing import Union, Optional
from utils import logger
Expand Down Expand Up @@ -55,8 +56,14 @@ async def bt_main_loop(self):
self.device = await BleakScanner.find_device_by_address(
self.address, cb=dict(use_bdaddr=True)
)
except Exception as e:
logger.error(">>> ERROR: Bluetooth stack failed.", e)

except Exception:
exception_type, exception_object, exception_traceback = sys.exc_info()
file = exception_traceback.tb_frame.f_code.co_filename
line = exception_traceback.tb_lineno
logger.error(
f"Exception occurred: {repr(exception_object)} of type {exception_type} in {file} line #{line}"
)
self.device = None
await asyncio.sleep(0.5)

Expand Down Expand Up @@ -173,8 +180,6 @@ def read_serial_data_llt(self, command):


if __name__ == "__main__":
import sys

bat = LltJbd_Ble("Foo", -1, sys.argv[1])
if not bat.test_connection():
logger.error(">>> ERROR: Unable to connect")
Expand Down
5 changes: 5 additions & 0 deletions etc/dbus-serialbattery/reinstall-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ if [ "$length" -gt 0 ]; then
opkg update
opkg install python3-misc python3-pip
pip3 install bleak
# pip3 install bleak==0.20.2
# pip3 install bleak==0.21.0
pip3 install dbus-fast==1.87.0
# pip3 install dbus-fast==1.87.3
# pip3 install dbus-fast==1.87.4

echo "done."
echo
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.20230902dev"
DRIVER_VERSION = "1.0.20230904dev"
zero_char = chr(48)
degree_sign = "\N{DEGREE SIGN}"

Expand Down

0 comments on commit 54055b1

Please sign in to comment.