-
Notifications
You must be signed in to change notification settings - Fork 0
/
if820_enter_hci_download_mode.py
executable file
·50 lines (40 loc) · 1.53 KB
/
if820_enter_hci_download_mode.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
44
45
46
47
48
49
50
#!/usr/bin/env python3
import argparse
import logging
import sys
sys.path.append('./common_lib/libraries')
from If820Board import If820Board
if __name__ == '__main__':
"""Put a board into HCI download mode.
If there is more than one board the user will be prompted to select a board.
"""
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--connection',
type=str, default=str(), help="Optional: HCI COM port")
parser.add_argument('-d', '--debug', action='store_true',
help="Enable verbose debug messages")
logging.basicConfig(
format='%(asctime)s | %(levelname)s | %(message)s', level=logging.INFO)
args, unknown = parser.parse_known_args()
if args.debug:
logging.info("Debugging mode enabled")
logging.getLogger().setLevel(logging.DEBUG)
hci_port = args.connection
boards = If820Board.get_connected_boards()
if len(boards) == 0:
logging.error("No boards found")
exit(1)
choice = 0
if len(boards) > 1 and not hci_port:
print("Which board do you want to enter HCI download mode?")
for i, board in enumerate(boards):
print(f"{i}: {board.probe.id}")
choice = int(input("Enter the number of the board: "))
board = boards[choice]
res = board.enter_hci_download_mode(hci_port)
if res < 0:
exit(res)
if not hci_port:
hci_port = board.hci_port_name
logging.info(
f"Board {board.probe.id} [{hci_port}] entered HCI download mode")