ble - fail test if over 100 loops

This commit is contained in:
matt committed 2026-10-23 00:33:57 -07:00
1 parent babf9eba9a
commit 0f6ddef87f
1 file changed
+21 -2
+21 -2
View File
@@ -299,6 +299,7 @@ def test_driver(test_count = 0, bt_usb_id = None):
if len(mac_history) == reset_retries and all(lst == mac_history[0] for lst in mac_history):
log.warning(f"Last {reset_retries} tests have been identical, resetting adapter")
reset_adapter()
rkill_bt()
mac_history = []
prev_list_snapshot = passed_list
@@ -323,12 +324,23 @@ def test_driver(test_count = 0, bt_usb_id = None):
test_complete = True
result = {
"found_macs": found_macs,
"sensor_results": sensors
"sensor_results": sensors,
"test_result": "complete"
}
return result
# If not, then re-scan the failed sensors
elif test_loop_count > 100:
log.error(f"Test has gone on too long, failing test, rfkill bluetooth, will begin next test run.")
rkill_bt()
test_complete = True
result = {
"found_macs": found_macs,
"sensor_results": sensors,
"test_result": "failed"
}
return result
else:
log.warning(f" Test run incomplete/failed, attempt {len(mac_history)} of {reset_retries}, re-running, loop {test_loop_count}. Updating test list.")
log.warning(f" Test run incomplete/failed, attempt {len(mac_history) + 1} of {reset_retries}, re-running, loop {test_loop_count}. Updating test list.")
print_sensor_data(sensors)
# here is where test_list might shrink
test_list = get_failed_macs(mac_list, passed_list)
@@ -370,6 +382,13 @@ def reset_adapter():
log.warning("Hmm, this shouldn't happen, the current_usb_id is blank 0_o")
log.info("Reset complete. ")
# this subroutine will rfkill the bluetooth
def rkill_bt():
log.info(subprocess.run(["rfkill", "block", "bluetooth"], capture_output=True, text=True, check=True).stdout.strip())
time.sleep(5)
log.info(subprocess.run(["rfkill", "unblock", "bluetooth"], capture_output=True, text=True, check=True).stdout.strip())
time.sleep(5)
# this restarts the bluetooth service
def restart_bt_service():
log.info("Resetting bluetooth.service...")