From c8590bf4a41783890447f8a61dd128ab7a29970a Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 18 Oct 2026 05:15:13 -0700 Subject: [PATCH] ble.py - put back fancy history package --- api/ble.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/api/ble.py b/api/ble.py index b5f8c62..f8b0992 100644 --- a/api/ble.py +++ b/api/ble.py @@ -292,7 +292,8 @@ def test(test_count = 0, bt_usb_id = None) -> None: passed_list = [] # History buffer - keep the last N snapshots (N=5) print("Creating mac_history variable") - mac_history = [] + from collections import deque + mac_history = deque(maxlen=5) print("Done") prev_list_snapshot = None print("Just before the loop") @@ -306,13 +307,13 @@ def test(test_count = 0, bt_usb_id = None) -> None: else: # List changed - reset mac_history print("List changed - reset mac_history") - mac_history = [] + mac_history.clear() mac_history.append(passed_list) - # if len(mac_history) == 5 and all(lst == mac_history[0] for lst in mac_history): - # log.warning(f"Last 5 tests have been identical, resetting adapter") - # reset_adapter() - # mac_history = [] - # prev_list_snapshot = current_list + if len(mac_history) == 5 and all(lst == mac_history[0] for lst in mac_history): + log.warning(f"Last 5 tests have been identical, resetting adapter") + reset_adapter() + mac_history.clear() + prev_list_snapshot = current_list log.info(f" Test run: {test_count} - loop {test_loop_count} start. Initializing run...") test_run_results = sensor_data_query(test_list)