From 826538e667cb916149113000e4ba48e37e289e1e Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 16 Oct 2026 21:30:43 -0700 Subject: [PATCH] test result summary at end --- api/ble.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/api/ble.py b/api/ble.py index 6302b7b..acc9c59 100644 --- a/api/ble.py +++ b/api/ble.py @@ -279,7 +279,12 @@ def test(test_count = 0) -> None: for sensor in sensors: temp_f = (sensor['temp'] * 1.80) + 32.0 print(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}") + result = { + "found_macs": found_macs, + "sensor_results": sensors + } test_result = True + return result else: print(f" Test run incomplete/failed, re-running, loop {test_loop_count}. Updating test list") for sensor in sensors: @@ -311,13 +316,38 @@ if __name__ == "__main__": sys.exit(1) test_count = 0 + test_results = [] print(f"Starting BLE Test for {count} iterations") while test_count < count: test_count = test_count + 1 + this_test_result = [] print(f"Starting test run {test_count} of {count}") try: - test(test_count) + test_label = f"Test {test_count} result" + this_test_result = { + "test_label": test_label, + "test_result": test(test_count) + } except Exception as e: print(f"Test failed brah - {e}") if "org.freedesktop.DBus.Error.AccessDenied" in e: reset_adapter() + test_results.append(this_test_result) + + print("Test run completed") + for test_result in test_results: + print(f"Test {test_result['test_label']}:") + parts: List[str] = [] + for reading in test_result['test_result']: + mac = reading.get("name", "") + temp = reading.get("temp", 0) + # Grab the last two octets of the MAC address + octets = mac.split(":")[-2:] + short_mac = ":".join(octets) + parts.append(f"{short_mac} - {temp:.1f}") + result_summary = " | ".join(parts) + print(result_summary) + +# Insert before the main guard + +