blob: a9e2bb11534d90394e49debd786af6c27b607bd7 [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");
Eric935c8cb2022-06-06 00:48:09 +020058const BitVector GSM::gDummyBurstTSC("01110001011100010111000101");
Alexander Chemeris040b3052013-06-16 14:29:54 +040059
Vadim Yanitskiya79bc702018-10-17 11:01:58 +020060/* 3GPP TS 05.02, section 5.2.7 "Access burst (AB)", synch. sequence bits */
61const BitVector GSM::gRACHSynchSequenceTS0("01001011011111111001100110101010001111000"); /* GSM, GMSK (default) */
62const BitVector GSM::gRACHSynchSequenceTS1("01010100111110001000011000101111001001101"); /* EGPRS, 8-PSK */
63const BitVector GSM::gRACHSynchSequenceTS2("11101111001001110101011000001101101110111"); /* EGPRS, GMSK */
Alexander Chemeris040b3052013-06-16 14:29:54 +040064
Eric Wildd40300e2022-05-07 15:36:47 +020065const BitVector GSM::gSCHSynchSequence("1011100101100010000001000000111100101101010001010111011000011011");
66
Alexander Chemeris5efe0502016-03-23 17:06:32 +030067// |-head-||---------midamble----------------------||--------------data----------------||t|
68const BitVector GSM::gRACHBurst("0011101001001011011111111001100110101010001111000110111101111110000111001001010110011000");
69
Alexander Chemeris040b3052013-06-16 14:29:54 +040070
71int32_t GSM::FNDelta(int32_t v1, int32_t v2)
72{
73 static const int32_t halfModulus = gHyperframe/2;
74 int32_t delta = v1-v2;
75 if (delta>=halfModulus) delta -= gHyperframe;
76 else if (delta<-halfModulus) delta += gHyperframe;
77 return (int32_t) delta;
78}
79
80int GSM::FNCompare(int32_t v1, int32_t v2)
81{
82 int32_t delta = FNDelta(v1,v2);
83 if (delta>0) return 1;
84 if (delta<0) return -1;
85 return 0;
86}
87
88
89
90
91ostream& GSM::operator<<(ostream& os, const Time& t)
92{
93 os << t.TN() << ":" << t.FN();
94 return os;
95}
96
97
98// vim: ts=4 sw=4