Add Refresh (r) option to scan Bluetooth again
This commit is contained in:
1 parent
97441a6aa6
commit
8d93763141
1 file changed
+25
-8
+25
-8
@@ -117,9 +117,11 @@ class MeshtasticCLI:
|
|||||||
"""Prompt user to select and connect to a radio"""
|
"""Prompt user to select and connect to a radio"""
|
||||||
while True:
|
while True:
|
||||||
try:
|
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':
|
if choice.lower() == 'q':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
elif choice.lower() == 'r':
|
||||||
|
return None # Signal to refresh scan
|
||||||
|
|
||||||
idx = int(choice) - 1
|
idx = int(choice) - 1
|
||||||
if 0 <= idx < len(devices):
|
if 0 <= idx < len(devices):
|
||||||
@@ -338,14 +340,29 @@ class MeshtasticCLI:
|
|||||||
"""Main program flow"""
|
"""Main program flow"""
|
||||||
self.setup_exit_handler()
|
self.setup_exit_handler()
|
||||||
|
|
||||||
# Step 1: Scan for radios
|
# Step 1: Scan for radios with refresh option
|
||||||
devices = self.scan_radios()
|
while True:
|
||||||
if not devices:
|
devices = self.scan_radios()
|
||||||
return
|
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
|
# Step 2: Connect to radio with refresh option
|
||||||
if not self.connect_radio(devices):
|
connection_result = self.connect_radio(devices)
|
||||||
return
|
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
|
# Setup packet callback using the correct method
|
||||||
print("Setting up message listener...")
|
print("Setting up message listener...")
|
||||||
|
|||||||
Reference in new issue
Block a user