| 103 | } |
| 104 | |
| 105 | int scanDirection(RAD1Device *rad, TIMESTAMP ×tamp, GSM::GSMBand band, int startARFCN, int stopARFCN, |
| 106 | FrequencyConverter arfcnToFreqKHz, SpectrumMap::LinkDirection linkDir, SpectrumMap &spectrumMap) |
| 107 | { |
| 108 | list<ARFCNVector> results; |
| 109 | float integrationTime = ((float)gConfig.getNum("PowerScanner.IntegrationTime"))/1000.0F; |
| 110 | |
| 111 | float startFreq = arfcnToFreqKHz(band, startARFCN) * 1000.0F; |
| 112 | rad->setRxFreq(startFreq); |
| 113 | |
| 114 | rad->updateAlignment(40000); |
| 115 | rad->updateAlignment(41000); |
| 116 | |
| 117 | rad->setRxGain(gConfig.getNum("PowerScanner.RxGain")); |
| 118 | |
| 119 | for (unsigned ARFCN=startARFCN; ARFCN <= stopARFCN; ARFCN++) { |
| 120 | float currFreq = arfcnToFreqKHz(band, ARFCN) * 1000.0F; |
| 121 | double sum = 0.0; |
| 122 | double num = 0.0; |
| 123 | rad->setRxFreq(currFreq); |
| 124 | |
| 125 | while (num < integrationTime*270833.33) { |
| 126 | short readBuf[512*2]; |
| 127 | bool underrun; |
| 128 | int rd = rad->readSamples(readBuf,512,&underrun,timestamp); |
| 129 | if (rd) { |
| 130 | for (int i = 0; i < rd; i++) { |
| 131 | uint32_t *wordPtr = (uint32_t *) &readBuf[2*i]; |
| 132 | *wordPtr = usrp_to_host_u32(*wordPtr); |
| 133 | sum += (readBuf[2*i+1]*readBuf[2*i+1] + readBuf[2*i]*readBuf[2*i]); |
| 134 | num += 1.0; |
| 135 | } |
| 136 | } |
| 137 | timestamp += rd; |
| 138 | } |
| 139 | |
| 140 | double currPower = sum/num; |
| 141 | // HACK |
| 142 | printf("At freq %f (ARFCN %5d), the average power is %10.2f\n",currFreq,ARFCN,currPower); |
| 143 | ARFCNVector res(currPower,ARFCN, currFreq, linkDir); |
| 144 | results.push_back(res); |
| 145 | } |
| 146 | |
| 147 | for (list<ARFCNVector>::iterator rp=results.begin(); rp!=results.end(); ++rp) { |
| 148 | double currPower = rp->power(); |
| 149 | unsigned ARFCN = rp->ARFCN(); |
| 150 | float freq = rp->frequency(); |
| 151 | SpectrumMap::LinkDirection linkDir = rp->linkDirection(); |
| 152 | |
| 153 | if (currPower==0.0) continue; |
| 154 | |
| 155 | double dBm = 10.0F*log10(currPower) + gConfig.getNum("PowerScanner.dBmOffset"); |
| 156 | spectrumMap.power(band,ARFCN,freq,linkDir,dBm); |
| 157 | } |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | ConfigurationKeyMap getAllConfigurationKeys() |
no test coverage detected