-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreality_manager.py
43 lines (33 loc) · 1.29 KB
/
reality_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Import needed modules
import cflib.crtp
def scan_for_drones(gui):
"""
Scan for available drones.
All channels from 0 to 125 will be scanned for addresses ranging from 0xE7E7E7E7E0 to 0xE7E7E7E7EF.
:param gui: GUI instance to update progress bar and store found drones.
"""
# Create list of addresses to scan for
address_list = []
for i in range(0x0, 0x10):
address_list.append(0xE7E7E7E7E0 + i)
# Create variable to store progress of task: 0 == not started & 1 == done
progress = 0
# Scan every channel for every address and add to the list of found drones
for address in address_list:
print("Start scanning for address: " + hex(address))
# Refresh the progress bar
progress += 1/17
gui.update_progress_scan(progress, str(hex(address)))
# Store found drones in a temporary list
scan_results = cflib.crtp.scan_interfaces(address=address)
# Append found drones to the final list
for drone in scan_results:
# The scanner does not append the address if it is the default one 0xE7E7E7E7E7, so we manually add it
if address == 0xe7e7e7e7e7:
drone[0] = drone[0] + "/E7E7E7E7E7"
# Add drone to store of GUI
gui.add_to_drone_store([drone[0]])
# Final update of progress bar
gui.update_progress_scan(1, "Done.")
# Update connect button
gui.update_connect_button()