blob: 32661f41a1a6f7a07a7c237b5ad1812c15423671 [file] [log] [blame]
dburgessb3a0ca42011-10-12 07:44:40 +00001/*
2* Copyright 2011 Free Software Foundation, Inc.
3* Copyright 2008, 2010 Kestrel Signal Processing, 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/*
27Contributors:
28Harvind S. Samra, hssamra@kestrelsp.com
29*/
30
31
32#include "sigProcLib.h"
33//#include "radioInterface.h"
34#include <Logger.h>
35#include <Configuration.h>
Alexander Chemerisd734e2d2013-06-16 14:30:58 +040036#include <GSMCommon.h>
dburgessb3a0ca42011-10-12 07:44:40 +000037
38using namespace std;
Alexander Chemerisd734e2d2013-06-16 14:30:58 +040039using namespace GSM;
dburgessb3a0ca42011-10-12 07:44:40 +000040
41ConfigurationTable gConfig;
42
43int main(int argc, char **argv) {
44
45 gLogInit("sigProcLibTest","DEBUG");
46
47 int samplesPerSymbol = 1;
48
49 int TSC = 2;
50
51 sigProcLibSetup(samplesPerSymbol);
52
dburgessb3a0ca42011-10-12 07:44:40 +000053 BitVector RACHBurstStart = "01010101";
54 BitVector RACHBurstRest = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
55
56 BitVector RACHBurst(BitVector(RACHBurstStart,gRACHSynchSequence),RACHBurstRest);
57
58
59 signalVector *RACHSeq = modulateBurst(RACHBurst,
dburgessb3a0ca42011-10-12 07:44:40 +000060 9,
61 samplesPerSymbol);
62
dburgessb3a0ca42011-10-12 07:44:40 +000063 complex a; float t;
64 detectRACHBurst(*RACHSeq, 5, samplesPerSymbol,&a,&t);
65
66 //cout << *RACHSeq << endl;
67 //signalVector *autocorr = correlate(RACHSeq,RACHSeq,NULL,NO_DELAY);
68
69 //cout << *autocorr;
70
71 //exit(1);
72
73
74 /*signalVector x(6500);
75 x.fill(1.0);
76
77 frequencyShift(&x,&x,0.48*M_PI);
78
79 signalVector *y = polyphaseResampleVector(x,96,65,NULL);
80
81 cout << *y << endl;
82
83 exit(1);*/
84
85 //CommSig normalBurstSeg = "0000000000000000000000000000000000000000000000000000000000000";
86
87 BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000";
88
89 BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[TSC]),normalBurstSeg);
90
Thomas Tsou3eaae802013-08-20 19:31:14 -040091 generateMidamble(samplesPerSymbol,TSC);
dburgessb3a0ca42011-10-12 07:44:40 +000092
Thomas Tsou3eaae802013-08-20 19:31:14 -040093 signalVector *modBurst = modulateBurst(normalBurst,0,samplesPerSymbol);
dburgessb3a0ca42011-10-12 07:44:40 +000094
95
96 //delayVector(*rsVector2,6.932);
97
98 complex ampl = 1;
99 float TOA = 0;
100
101 //modBurst = rsVector2;
102 //delayVector(*modBurst,0.8);
103
104 /*
105 signalVector channelResponse(4);
106 signalVector::iterator c=channelResponse.begin();
107 *c = (complex) 9000.0; c++;
108 *c = (complex) 0.4*9000.0; c++; c++;
109 *c = (complex) -1.2*0;
110
111 signalVector *guhBurst = convolve(modBurst,&channelResponse,NULL,NO_DELAY);
112 delete modBurst; modBurst = guhBurst;
113 */
114
115 signalVector *chanResp;
116 /*
117 double noisePwr = 0.001/sqrtf(2);
118 signalVector *noise = gaussianNoise(modBurst->size(),noisePwr);
119 */
120 float chanRespOffset;
121 analyzeTrafficBurst(*modBurst,TSC,8.0,samplesPerSymbol,&ampl,&TOA,1,true,&chanResp,&chanRespOffset);
122 //addVector(*modBurst,*noise);
123
124 cout << "ampl:" << ampl << endl;
125 cout << "TOA: " << TOA << endl;
126 //cout << "chanResp: " << *chanResp << endl;
Thomas Tsou3eaae802013-08-20 19:31:14 -0400127 SoftVector *demodBurst = demodulateBurst(*modBurst,samplesPerSymbol,(complex) ampl, TOA);
dburgessb3a0ca42011-10-12 07:44:40 +0000128
129 cout << *demodBurst << endl;
130
131 /*
132 COUT("chanResp: " << *chanResp);
133
134 signalVector *w,*b;
135 designDFE(*chanResp,1.0/noisePwr,7,&w,&b);
136 COUT("w: " << *w);
137 COUT("b: " << *b);
138
139
140 SoftSig *DFEBurst = equalizeBurst(*modBurst,TOA-chanRespOffset,samplesPerSymbol,*w,*b);
141 COUT("DFEBurst: " << *DFEBurst);
142
143 delete gsmPulse;
144 delete RACHSeq;
145 delete modBurst;
146 delete sendLPF;
147 delete rcvLPF;
148 delete rsVector;
149 //delete rsVector2;
150 delete autocorr;
151 delete chanResp;
152 delete noise;
153 delete demodBurst;
154 delete w;
155 delete b;
156 delete DFEBurst;
157 */
158
159 sigProcLibDestroy();
160
161}