-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_fq_hop_v202.py
31 lines (26 loc) · 1.02 KB
/
gen_fq_hop_v202.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
freq_hopping = [
[ 0x27, 0x1B, 0x39, 0x28, 0x24, 0x22, 0x2E, 0x36,
0x19, 0x21, 0x29, 0x14, 0x1E, 0x12, 0x2D, 0x18 ], # 00
[ 0x2E, 0x33, 0x25, 0x38, 0x19, 0x12, 0x18, 0x16,
0x2A, 0x1C, 0x1F, 0x37, 0x2F, 0x23, 0x34, 0x10 ], # 01
[ 0x11, 0x1A, 0x35, 0x24, 0x28, 0x18, 0x25, 0x2A,
0x32, 0x2C, 0x14, 0x27, 0x36, 0x34, 0x1C, 0x17 ], # 02
[ 0x22, 0x27, 0x17, 0x39, 0x34, 0x28, 0x2B, 0x1D,
0x18, 0x2A, 0x21, 0x38, 0x10, 0x26, 0x20, 0x1F ] # 03
]
def gen_fh(tx_id):
sum = tx_id[0] + tx_id[1] + tx_id[2]
# Base row is defined by lowest 2 bits
fh_row = freq_hopping[sum & 0x03]
# Higher 3 bits define increment to corresponding row
increment = (sum & 0x1e) >> 2
rf_channels = []
for i in range(16):
val = fh_row[i] + increment
# Strange avoidance of channels divisible by 16
if val & 0x0f: val -= 3
rf_channels.append(val)
return rf_channels
def main():
print " ".join(map(lambda x: "%02x" % x, gen_fh([0x43, 0x3A, 0x01])))
main()