-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransmit.py
56 lines (46 loc) · 1.75 KB
/
transmit.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
51
52
53
54
55
56
#!/usr/bin/which python3
from pyflipper.pyflipper import PyFlipper
import argparse
import time
from pathlib import Path
with open('.flipper', 'r') as file:
flippername = file.read().strip()
modem = f"/dev/tty.usbmodemflip_{flippername}1"
parser = argparse.ArgumentParser(description='Transmit file using Flipper Zero.')
parser.add_argument('--modem', type=str, default=modem, help='Modem device path')
parser.add_argument('--path', type=str, default="/ext/subghz/rgb/", help='Output file path')
parser.add_argument('--file', type=str, default="output.sub", help='Output file name')
parser.add_argument('--count', type=int, default=2, help='Number of times to transmit')
parser.add_argument('--upload', action='store_true', help='Flag to upload the file')
parser.add_argument('--notransmit', action='store_false', help='Disable transmitting')
args = parser.parse_args()
modem = args.modem
outputpath = args.path + args.file
count = args.count
transmit = not args.notransmit
upload = args.upload
#helper to make working with captures mildly easier
if (Path("captures") / args.file).is_file():
prefix = "captures/"
else:
prefix = ""
with open(prefix + args.file, 'r') as file:
header = file.read()
flipper = PyFlipper(com=modem)
if upload:
try:
# In case the file doesn't exist
print("Removing...")
flipper.storage.remove(file=outputpath)
except:
pass
print(f"Uploading to {outputpath}...")
flipper.storage.write.start(outputpath)
time.sleep(1)
flipper.storage.write.send(header)
time.sleep(1)
flipper.storage.write.stop()
time.sleep(1)
if transmit and ".sub" in args.file:
print(f"Transmitting {outputpath}...")
flipper._serial_wrapper.send(f"subghz tx_from_file {outputpath} {count} 0")