blob: 3b5331f2aee24aa01c7bbaaff21662dd6b6c02a8 [file] [log] [blame]
Alexander Chemeris040b3052013-06-16 14:29:54 +04001/*
2* Copyright 2008 Free Software Foundation, Inc.
3* Copyright 2011 Range Networks, Inc.
4*
5* This software is distributed under the terms of the GNU Affero Public License.
6* See the COPYING file in the main directory for details.
7*
8* This use of this software may be subject to additional restrictions.
9* See the LEGAL file in the main directory for details.
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU Affero General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
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 Affero General Public License for more details.
20
21 You should have received a copy of the GNU Affero General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24*/
25
26
27#include "GSMCommon.h"
28
29using namespace GSM;
30using namespace std;
31
32
33const BitVector GSM::gTrainingSequence[] = {
34 BitVector("00100101110000100010010111"),
35 BitVector("00101101110111100010110111"),
36 BitVector("01000011101110100100001110"),
37 BitVector("01000111101101000100011110"),
38 BitVector("00011010111001000001101011"),
39 BitVector("01001110101100000100111010"),
40 BitVector("10100111110110001010011111"),
41 BitVector("11101111000100101110111100"),
42};
43
Tom Tsoud3253432016-03-06 03:08:01 -080044const BitVector GSM::gEdgeTrainingSequence[] = {
45 BitVector("111111001111111001111001001001111111111111001111111111001111111001111001001001"),
46 BitVector("111111001111001001111001001001111001001001001111111111001111001001111001001001"),
47 BitVector("111001111111111111001001001111001001001111001111111001111111111111001001001111"),
48 BitVector("111001111111111001001001001111001001111001111111111001111111111001001001001111"),
49 BitVector("111111111001001111001111001001001111111001111111111111111001001111001111001001"),
50 BitVector("111001111111001001001111001111001001111111111111111001111111001001001111001111"),
51 BitVector("001111001111111001001001001001111001001111111111001111001111111001001001001001"),
52 BitVector("001001001111001001001001111111111001111111001111001001001111001001001001111111"),
53};
54
Alexander Chemeris040b3052013-06-16 14:29:54 +040055const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000");
56
57const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000");
58
59
60int32_t GSM::FNDelta(int32_t v1, int32_t v2)
61{
62 static const int32_t halfModulus = gHyperframe/2;
63 int32_t delta = v1-v2;
64 if (delta>=halfModulus) delta -= gHyperframe;
65 else if (delta<-halfModulus) delta += gHyperframe;
66 return (int32_t) delta;
67}
68
69int GSM::FNCompare(int32_t v1, int32_t v2)
70{
71 int32_t delta = FNDelta(v1,v2);
72 if (delta>0) return 1;
73 if (delta<0) return -1;
74 return 0;
75}
76
77
78
79
80ostream& GSM::operator<<(ostream& os, const Time& t)
81{
82 os << t.TN() << ":" << t.FN();
83 return os;
84}
85
86
87// vim: ts=4 sw=4