Add Refresh (r) option to scan Bluetooth again

This commit is contained in:
justin committed 2026-01-26 14:40:42 -07:00
1 parent 97441a6aa6
commit 8d93763141
1 file changed
+21 -4
+21 -4
View File
@@ -117,9 +117,11 @@ class MeshtasticCLI:
"""Prompt user to select and connect to a radio"""
while True:
try:
choice = input("\nEnter number to connect (or 'q' to quit): ").strip()
choice = input("\nEnter number to connect (or 'q' to quit, 'r' to refresh): ").strip()
if choice.lower() == 'q':
sys.exit(0)
elif choice.lower() == 'r':
return None # Signal to refresh scan
idx = int(choice) - 1
if 0 <= idx < len(devices):
@@ -338,13 +340,28 @@ class MeshtasticCLI:
"""Main program flow"""
self.setup_exit_handler()
# Step 1: Scan for radios
# Step 1: Scan for radios with refresh option
while True:
devices = self.scan_radios()
if not devices:
print("\nNo devices found. Press Enter to scan again, or 'q' to quit: ", end='')
choice = input().strip().lower()
if choice == 'q':
return
continue
# Step 2: Connect to radio
if not self.connect_radio(devices):
# Step 2: Connect to radio with refresh option
connection_result = self.connect_radio(devices)
if connection_result is None:
# User selected 'r' to refresh
continue
elif connection_result:
break # Successfully connected
else:
# Connection failed
print("\nConnection failed. Press Enter to try again, or 'q' to quit: ", end='')
choice = input().strip().lower()
if choice == 'q':
return
# Setup packet callback using the correct method