dburgess | b3a0ca4 | 2011-10-12 07:44:40 +0000 | [diff] [blame] | 1 | /* |
| 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" |
| 29 | #include "USRPDevice.h" |
| 30 | #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 | |
| 39 | using namespace std; |
| 40 | |
| 41 | ConfigurationTable gConfig("/etc/OpenBTS/OpenBTS.db"); |
| 42 | |
| 43 | |
| 44 | volatile bool gbShutdown = false; |
| 45 | static void ctrlCHandler(int signo) |
| 46 | { |
| 47 | cout << "Received shutdown signal" << endl;; |
| 48 | gbShutdown = true; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | int main(int argc, char *argv[]) |
| 53 | { |
| 54 | if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR ) |
| 55 | { |
| 56 | cerr << "Couldn't install signal handler for SIGINT" << endl; |
| 57 | exit(1); |
| 58 | } |
| 59 | |
| 60 | if ( signal( SIGTERM, ctrlCHandler ) == SIG_ERR ) |
| 61 | { |
| 62 | cerr << "Couldn't install signal handler for SIGTERM" << endl; |
| 63 | exit(1); |
| 64 | } |
| 65 | // Configure logger. |
| 66 | gLogInit("transceiver",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7); |
| 67 | |
| 68 | int numARFCN=1; |
| 69 | |
| 70 | LOG(NOTICE) << "starting transceiver with " << numARFCN << " ARFCNs (argc=" << argc << ")"; |
| 71 | |
| 72 | srandom(time(NULL)); |
| 73 | |
| 74 | int mOversamplingRate = numARFCN/2 + numARFCN; |
| 75 | //DYNDevice *usrp = new DYNDevice(mOversamplingRate*1625.0e3/6.0); |
| 76 | USRPDevice *usrp = new USRPDevice(mOversamplingRate*1625.0e3/6.0); |
| 77 | //DummyLoad *usrp = new DummyLoad(mOversamplingRate*1625.0e3/6.0); |
| 78 | usrp->make(); |
| 79 | |
| 80 | RadioInterface* radio = new RadioInterface(usrp,3,SAMPSPERSYM,mOversamplingRate,false); |
| 81 | Transceiver *trx = new Transceiver(5700,"127.0.0.1",SAMPSPERSYM,GSM::Time(2,0),radio); |
| 82 | trx->receiveFIFO(radio->receiveFIFO()); |
| 83 | /* |
| 84 | signalVector *gsmPulse = generateGSMPulse(2,1); |
| 85 | BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000"; |
| 86 | BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[0]),normalBurstSeg); |
| 87 | signalVector *modBurst = modulateBurst(normalBurst,*gsmPulse,8,1); |
| 88 | signalVector *modBurst9 = modulateBurst(normalBurst,*gsmPulse,9,1); |
| 89 | signalVector *interpolationFilter = createLPF(0.6/mOversamplingRate,6*mOversamplingRate,1); |
| 90 | signalVector totalBurst1(*modBurst,*modBurst9); |
| 91 | signalVector totalBurst2(*modBurst,*modBurst); |
| 92 | signalVector totalBurst(totalBurst1,totalBurst2); |
| 93 | scaleVector(totalBurst,usrp->fullScaleInputValue()); |
| 94 | double beaconFreq = -1.0*(numARFCN-1)*200e3; |
| 95 | signalVector finalVec(625*mOversamplingRate); |
| 96 | for (int j = 0; j < numARFCN; j++) { |
| 97 | signalVector *frequencyShifter = new signalVector(625*mOversamplingRate); |
| 98 | frequencyShifter->fill(1.0); |
| 99 | frequencyShift(frequencyShifter,frequencyShifter,2.0*M_PI*(beaconFreq+j*400e3)/(1625.0e3/6.0*mOversamplingRate)); |
| 100 | signalVector *interpVec = polyphaseResampleVector(totalBurst,mOversamplingRate,1,interpolationFilter); |
| 101 | multVector(*interpVec,*frequencyShifter); |
| 102 | addVector(finalVec,*interpVec); |
| 103 | } |
| 104 | signalVector::iterator itr = finalVec.begin(); |
| 105 | short finalVecShort[2*finalVec.size()]; |
| 106 | short *shortItr = finalVecShort; |
| 107 | while (itr < finalVec.end()) { |
| 108 | *shortItr++ = (short) (itr->real()); |
| 109 | *shortItr++ = (short) (itr->imag()); |
| 110 | itr++; |
| 111 | } |
| 112 | usrp->loadBurst(finalVecShort,finalVec.size()); |
| 113 | */ |
| 114 | trx->start(); |
| 115 | //int i = 0; |
| 116 | while(!gbShutdown) { sleep(1); }//i++; if (i==60) break;} |
| 117 | |
| 118 | cout << "Shutting down transceiver..." << endl; |
| 119 | |
| 120 | // trx->stop(); |
| 121 | delete trx; |
| 122 | // delete radio; |
| 123 | } |