Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove scan for devices #695

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 2 additions & 51 deletions etc/dbus-serialbattery/bms/jkbms_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,58 +28,9 @@ def test_connection(self):
# The result or call should be unique to this BMS. Battery name or version, etc.
# Return True if success, False for failure

# check if device with given mac is found, otherwise abort

logger.info("Test of Jkbms_Ble at " + self.jk.address)
try:
loop = asyncio.get_event_loop()
t = loop.create_task(BleakScanner.discover())
devices = loop.run_until_complete(t)
except BleakError as err:
logger.error(str(err))
return False
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
return False

found = False
for d in devices:
if d.address == self.jk.address:
found = True
if not found:
logger.error("No Jkbms_Ble found at " + self.jk.address)
return False

"""
# before indipended service, has to be checked

logger.info("test of jkbmsble")
tries = 0
while True:
try:
loop = asyncio.get_event_loop()
t = loop.create_task(
BleakScanner.find_device_by_address(self.jk.address)
)
device = loop.run_until_complete(t)

if device is None:
logger.info("jkbmsble not found")
if tries > 2:
return False
else:
# device found, exit loop and continue test
break
except BleakError as e:
if tries > 2:
return False
# recover from error if tries left
logger.error(str(e))
self.reset_bluetooth()
tries += 1
"""

# device was found, presumeably a jkbms so start scraping

# start scraping
self.jk.start_scraping()
tries = 1

Expand Down