blob: 5e9e4aedfacb037c7663cd84f1d19178ad3400bf [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*
Pau Espin Pedrol21d03d32019-07-22 12:05:52 +02005* SPDX-License-Identifier: AGPL-3.0+
6*
Alexander Chemeris040b3052013-06-16 14:29:54 +04007* This software is distributed under the terms of the GNU Affero Public License.
8* See the COPYING file in the main directory for details.
9*
10* This use of this software may be subject to additional restrictions.
11* See the LEGAL file in the main directory for details.
12
13 This program is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Affero General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Affero General Public License for more details.
22
23 You should have received a copy of the GNU Affero General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
25
26*/
27
28
29#include "GSMCommon.h"
30
31using namespace GSM;
32using namespace std;
33
34
35const BitVector GSM::gTrainingSequence[] = {
36 BitVector("00100101110000100010010111"),
37 BitVector("00101101110111100010110111"),
38 BitVector("01000011101110100100001110"),
39 BitVector("01000111101101000100011110"),
40 BitVector("00011010111001000001101011"),
41 BitVector("01001110101100000100111010"),
42 BitVector("10100111110110001010011111"),
43 BitVector("11101111000100101110111100"),
44};
45
Tom Tsoud3253432016-03-06 03:08:01 -080046const BitVector GSM::gEdgeTrainingSequence[] = {
47 BitVector("111111001111111001111001001001111111111111001111111111001111111001111001001001"),
48 BitVector("111111001111001001111001001001111001001001001111111111001111001001111001001001"),
49 BitVector("111001111111111111001001001111001001001111001111111001111111111111001001001111"),
50 BitVector("111001111111111001001001001111001001111001111111111001111111111001001001001111"),
51 BitVector("111111111001001111001111001001001111111001111111111111111001001111001111001001"),
52 BitVector("111001111111001001001111001111001001111111111111111001111111001001001111001111"),
53 BitVector("001111001111111001001001001001111001001111111111001111001111111001001001001001"),
54 BitVector("001001001111001001001001111111111001111111001111001001001111001001001001111111"),
55};
56
Alexander Chemeris040b3052013-06-16 14:29:54 +040057const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000");
58
Vadim Yanitskiya79bc702018-10-17 11:01:58 +020059/* 3GPP TS 05.02, section 5.2.7 "Access burst (AB)", synch. sequence bits */
60const BitVector GSM::gRACHSynchSequenceTS0("01001011011111111001100110101010001111000"); /* GSM, GMSK (default) */
61const BitVector GSM::gRACHSynchSequenceTS1("01010100111110001000011000101111001001101"); /* EGPRS, 8-PSK */
62const BitVector GSM::gRACHSynchSequenceTS2("11101111001001110101011000001101101110111"); /* EGPRS, GMSK */
Alexander Chemeris040b3052013-06-16 14:29:54 +040063
Alexander Chemeris5efe0502016-03-23 17:06:32 +030064// |-head-||---------midamble----------------------||--------------data----------------||t|
65const BitVector GSM::gRACHBurst("0011101001001011011111111001100110101010001111000110111101111110000111001001010110011000");
66
Alexander Chemeris040b3052013-06-16 14:29:54 +040067
68int32_t GSM::FNDelta(int32_t v1, int32_t v2)
69{
70 static const int32_t halfModulus = gHyperframe/2;
71 int32_t delta = v1-v2;
72 if (delta>=halfModulus) delta -= gHyperframe;
73 else if (delta<-halfModulus) delta += gHyperframe;
74 return (int32_t) delta;
75}
76
77int GSM::FNCompare(int32_t v1, int32_t v2)
78{
79 int32_t delta = FNDelta(v1,v2);
80 if (delta>0) return 1;
81 if (delta<0) return -1;
82 return 0;
83}
84
85
86
87
88ostream& GSM::operator<<(ostream& os, const Time& t)
89{
90 os << t.TN() << ":" << t.FN();
91 return os;
92}
93
94
95// vim: ts=4 sw=4