blob: 1b8df360e8bb1812c99df2e79310f191d77b6018 [file] [log] [blame]
dburgessb3a0ca42011-10-12 07:44:40 +00001/*
2* Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
3* Copyright 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
27
28#include "Transceiver.h"
kurtis.heimerl67e3d5a2011-11-26 03:19:13 +000029#include "radioDevice.h"
dburgessb3a0ca42011-10-12 07:44:40 +000030#include "DummyLoad.h"
31
32#include <time.h>
33#include <signal.h>
34
35#include <GSMCommon.h>
36#include <Logger.h>
37#include <Configuration.h>
38
kurtis.heimerl67e3d5a2011-11-26 03:19:13 +000039#ifdef RESAMPLE
40 #define DEVICERATE 400e3
41#else
42 #define DEVICERATE 1625e3/6
43#endif
44
dburgessb3a0ca42011-10-12 07:44:40 +000045using namespace std;
46
47ConfigurationTable gConfig("/etc/OpenBTS/OpenBTS.db");
48
49
50volatile bool gbShutdown = false;
51static void ctrlCHandler(int signo)
52{
53 cout << "Received shutdown signal" << endl;;
54 gbShutdown = true;
55}
56
57
58int main(int argc, char *argv[])
59{
60 if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR )
61 {
62 cerr << "Couldn't install signal handler for SIGINT" << endl;
63 exit(1);
64 }
65
66 if ( signal( SIGTERM, ctrlCHandler ) == SIG_ERR )
67 {
68 cerr << "Couldn't install signal handler for SIGTERM" << endl;
69 exit(1);
70 }
71 // Configure logger.
72 gLogInit("transceiver",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7);
73
74 int numARFCN=1;
75
76 LOG(NOTICE) << "starting transceiver with " << numARFCN << " ARFCNs (argc=" << argc << ")";
77
78 srandom(time(NULL));
79
80 int mOversamplingRate = numARFCN/2 + numARFCN;
kurtis.heimerl67e3d5a2011-11-26 03:19:13 +000081 RadioDevice *usrp = RadioDevice::make(DEVICERATE);
82 if (!usrp->open()) {
kurtis.heimerle3320322011-11-28 06:26:08 +000083 LOG(ALERT) << "Transceiver exiting..." << std::endl;
kurtis.heimerl67e3d5a2011-11-26 03:19:13 +000084 return EXIT_FAILURE;
85 }
dburgessb3a0ca42011-10-12 07:44:40 +000086
87 RadioInterface* radio = new RadioInterface(usrp,3,SAMPSPERSYM,mOversamplingRate,false);
kurtis.heimerld3d4af32011-11-26 03:19:16 +000088 Transceiver *trx = new Transceiver(5700,"127.0.0.1",SAMPSPERSYM,GSM::Time(3,0),radio);
dburgessb3a0ca42011-10-12 07:44:40 +000089 trx->receiveFIFO(radio->receiveFIFO());
90/*
91 signalVector *gsmPulse = generateGSMPulse(2,1);
92 BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000";
93 BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[0]),normalBurstSeg);
94 signalVector *modBurst = modulateBurst(normalBurst,*gsmPulse,8,1);
95 signalVector *modBurst9 = modulateBurst(normalBurst,*gsmPulse,9,1);
96 signalVector *interpolationFilter = createLPF(0.6/mOversamplingRate,6*mOversamplingRate,1);
97 signalVector totalBurst1(*modBurst,*modBurst9);
98 signalVector totalBurst2(*modBurst,*modBurst);
99 signalVector totalBurst(totalBurst1,totalBurst2);
100 scaleVector(totalBurst,usrp->fullScaleInputValue());
101 double beaconFreq = -1.0*(numARFCN-1)*200e3;
102 signalVector finalVec(625*mOversamplingRate);
103 for (int j = 0; j < numARFCN; j++) {
104 signalVector *frequencyShifter = new signalVector(625*mOversamplingRate);
105 frequencyShifter->fill(1.0);
106 frequencyShift(frequencyShifter,frequencyShifter,2.0*M_PI*(beaconFreq+j*400e3)/(1625.0e3/6.0*mOversamplingRate));
107 signalVector *interpVec = polyphaseResampleVector(totalBurst,mOversamplingRate,1,interpolationFilter);
108 multVector(*interpVec,*frequencyShifter);
109 addVector(finalVec,*interpVec);
110 }
111 signalVector::iterator itr = finalVec.begin();
112 short finalVecShort[2*finalVec.size()];
113 short *shortItr = finalVecShort;
114 while (itr < finalVec.end()) {
115 *shortItr++ = (short) (itr->real());
116 *shortItr++ = (short) (itr->imag());
117 itr++;
118 }
119 usrp->loadBurst(finalVecShort,finalVec.size());
120*/
121 trx->start();
122 //int i = 0;
123 while(!gbShutdown) { sleep(1); }//i++; if (i==60) break;}
124
125 cout << "Shutting down transceiver..." << endl;
126
127// trx->stop();
128 delete trx;
129// delete radio;
130}