| 1 | + | # -*- coding: utf-8 -*- |
| 2 | + | """flipper.ipynb |
| 3 | + | |
| 4 | + | Automatically generated by Colaboratory. |
| 5 | + | |
| 6 | + | Original file is located at |
| 7 | + | https://colab.research.google.com/drive/10iu3Fs4YzPETf4yz8ejyI8qCreLjiLNm |
| 8 | + | """ |
| 9 | + | |
| 10 | + | import pandas as pd |
| 11 | + | split = 500 # split files according to the keys count (each 1000 in one file) |
| 12 | + | case = 0 |
| 13 | + | |
| 14 | + | for x in range(0, 4096): # 12bit = 4096 possibilities |
| 15 | + | binary = "{0:012b}".format(x) #with leading zeros |
| 16 | + | cmd = ['-15078 ', '321 '] |
| 17 | + | for char in binary: |
| 18 | + | if char == "0": |
| 19 | + | cmd.append('-334 ') |
| 20 | + | cmd.append('667 ') |
| 21 | + | if char == "1": |
| 22 | + | cmd.append('-664 ') |
| 23 | + | cmd.append('343 ') |
| 24 | + | joined = "".join(cmd) |
| 25 | + | Multijoined = joined * 5 # number of repetition |
| 26 | + | command = 'RAW_Data: ' + Multijoined |
| 27 | + | padding = "RAW_Data: -50000 50000 " |
| 28 | + | |
| 29 | + | # split files according to the keys count (each 1000 in one file) |
| 30 | + | |
| 31 | + | if (x % split) == 0: |
| 32 | + | case += 1 |
| 33 | + | filecase = f'output{case}.sub' |
| 34 | + | with open(filecase, 'w') as f: |
| 35 | + | f.write("Filetype: Flipper SubGhz RAW File\nVersion: 1\nFrequency: 433920000\nPreset: FuriHalSubGhzPresetOok650Async\nProtocol: RAW\n") |
| 36 | + | |
| 37 | + | # write keys to sub file |
| 38 | + | def writing(raw, filename, pad): |
| 39 | + | with open(filename, 'a') as f: |
| 40 | + | f.write(raw) |
| 41 | + | f.write('\n') |
| 42 | + | f.write(pad) |
| 43 | + | f.write('\n') |
| 44 | + | |
| 45 | + | writing(command, filecase, padding) |