Alexander Chemeris | 040b305 | 2013-06-16 14:29:54 +0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 29 | using namespace GSM; |
| 30 | using namespace std; |
| 31 | |
| 32 | |
| 33 | const 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 Tsou | d325343 | 2016-03-06 03:08:01 -0800 | [diff] [blame] | 44 | const 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 Chemeris | 040b305 | 2013-06-16 14:29:54 +0400 | [diff] [blame] | 55 | const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000"); |
| 56 | |
| 57 | const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000"); |
| 58 | |
Alexander Chemeris | 5efe050 | 2016-03-23 17:06:32 +0300 | [diff] [blame] | 59 | // |-head-||---------midamble----------------------||--------------data----------------||t| |
| 60 | const BitVector GSM::gRACHBurst("0011101001001011011111111001100110101010001111000110111101111110000111001001010110011000"); |
| 61 | |
Alexander Chemeris | 040b305 | 2013-06-16 14:29:54 +0400 | [diff] [blame] | 62 | |
| 63 | int32_t GSM::FNDelta(int32_t v1, int32_t v2) |
| 64 | { |
| 65 | static const int32_t halfModulus = gHyperframe/2; |
| 66 | int32_t delta = v1-v2; |
| 67 | if (delta>=halfModulus) delta -= gHyperframe; |
| 68 | else if (delta<-halfModulus) delta += gHyperframe; |
| 69 | return (int32_t) delta; |
| 70 | } |
| 71 | |
| 72 | int GSM::FNCompare(int32_t v1, int32_t v2) |
| 73 | { |
| 74 | int32_t delta = FNDelta(v1,v2); |
| 75 | if (delta>0) return 1; |
| 76 | if (delta<0) return -1; |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | ostream& GSM::operator<<(ostream& os, const Time& t) |
| 84 | { |
| 85 | os << t.TN() << ":" << t.FN(); |
| 86 | return os; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | // vim: ts=4 sw=4 |