ble.py - add history try block

This commit is contained in:
matt committed 2026-10-18 05:19:23 -07:00
1 parent 2469338298
commit eb1ec71499
1 file changed
+20 -17
+20 -17
View File
@@ -296,23 +296,26 @@ def test(test_count = 0, bt_usb_id = None) -> None:
print("Done") print("Done")
prev_list_snapshot = None prev_list_snapshot = None
print("Just before the loop") print("Just before the loop")
while not test_result: try:
# Check if the failed list has been the same for 5 loops while not test_result:
print("Check if the failed list has been the same for 5 loops") # Check if the failed list has been the same for 5 loops
if prev_list_snapshot is not None and passed_list == prev_list_snapshot: print("Check if the failed list has been the same for 5 loops")
# List unchanged - add to mac_history if prev_list_snapshot is not None and passed_list == prev_list_snapshot:
print("List unchanged - add to mac_history") # List unchanged - add to mac_history
mac_history.append(passed_list) print("List unchanged - add to mac_history")
else: mac_history.append(passed_list)
# List changed - reset mac_history else:
print("List changed - reset mac_history") # List changed - reset mac_history
mac_history = [] print("List changed - reset mac_history")
mac_history.append(passed_list) mac_history = []
if len(mac_history) == 5 and all(lst == mac_history[0] for lst in mac_history): mac_history.append(passed_list)
log.warning(f"Last 5 tests have been identical, resetting adapter") if len(mac_history) == 5 and all(lst == mac_history[0] for lst in mac_history):
reset_adapter() log.warning(f"Last 5 tests have been identical, resetting adapter")
mac_history = [] reset_adapter()
prev_list_snapshot = current_list mac_history = []
prev_list_snapshot = current_list
except Exception as e:
log.error(f"Something went wrong in the history loop - {e}")
log.info(f" Test run: {test_count} - loop {test_loop_count} start. Initializing run...") log.info(f" Test run: {test_count} - loop {test_loop_count} start. Initializing run...")
test_run_results = sensor_data_query(test_list) test_run_results = sensor_data_query(test_list)