2 # -*- coding: utf-8 -*-
5 # Random burst (NB, FB, SB, AB) generator
7 # (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
23 from gsm_shared
import *
27 # GSM 05.02 Chapter 5.2.6 Dummy Burst
30 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0,
31 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0,
32 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
33 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0,
34 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0,
35 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0,
36 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1,
37 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1,
38 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
42 # Pick a random TSC for a given burst type
43 def get_rand_tsc(self
, bt
):
44 tsc_list
= filter(lambda seq
: seq
.bt
== bt
, list(TrainingSeqGMSK
))
45 tsc_list
= list(tsc_list
) # In Python 3 filter() returns an iterator
46 return random
.choice(tsc_list
)
48 # Generate a normal burst
49 def gen_nb(self
, tsc
= None):
56 buf
+= [random
.randint(0, 1) for _
in range(57)]
59 buf
.append(random
.randint(0, 1))
63 tsc
= self
.get_rand_tsc(BurstType
.NORMAL
)
67 buf
.append(random
.randint(0, 1))
70 buf
+= [random
.randint(0, 1) for _
in range(57)]
77 # Generate a frequency correction burst
79 return [0] * GMSK_BURST_LEN
81 # Generate a synchronization burst
82 def gen_sb(self
, tsc
= None):
89 buf
+= [random
.randint(0, 1) for _
in range(39)]
93 tsc
= self
.get_rand_tsc(BurstType
.SYNC
)
97 buf
+= [random
.randint(0, 1) for _
in range(39)]
104 # Generate a dummy burst
108 # Generate an access burst
109 def gen_ab(self
, tsc
= None):
117 tsc
= self
.get_rand_tsc(BurstType
.ACCESS
)
121 buf
+= [random
.randint(0, 1) for _
in range(36)]