diff options
-rw-r--r-- | Transceiver52M/Transceiver.cpp | 4 | ||||
-rw-r--r-- | Transceiver52M/sigProcLib.cpp | 32 |
2 files changed, 32 insertions, 4 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 27e9c12..46c7213 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -138,7 +138,7 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, complex amplitude = 0.0; float TOA = 0.0; float avgPwr = 0.0; - +#ifdef ENERGY_DETECT if (!energyDetect(*vectorBurst,20*mSPS,mEnergyThreshold,&avgPwr)) { LOG(DEBUG) << "Estimated Energy: " << sqrt(avgPwr) << ", at time " << rxBurst->getTime(); double framesElapsed = rxBurst->getTime()-prevFalseDetectionTime; @@ -153,7 +153,7 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, return NULL; } LOG(DEBUG) << "Estimated Energy: " << sqrt(avgPwr) << ", at time " << rxBurst->getTime(); - +#endif // run the proper correlator bool success = false; if (corrType == DriveLoop::TSC) { diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index bfcf5a4..b34c580 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -684,7 +684,26 @@ complex interpolatePoint(const signalVector &inSig, return pVal; } - +static complex fastPeakDetect(const signalVector &rxBurst, float *index) +{ + float val, max = 0.0f; + complex amp; + int _index = -1; + + for (int i = 0; i < rxBurst.size(); i++) { + val = rxBurst[i].norm2(); + if (val > max) { + max = val; + _index = i; + amp = rxBurst[i]; + } + } + + if (index) + *index = (float) _index; + + return amp; +} complex peakDetect(const signalVector &rxBurst, float *peakIndex, @@ -959,12 +978,16 @@ int detectRACHBurst(signalVector &rxBurst, return -1; } - _amp = peakDetect(corr, &_toa, NULL); + /* Perform fast peak detection (no interpolation) for initial gating */ + _amp = fastPeakDetect(corr, &_toa); + + /* Restrict peak-to-average calculations at the edges */ if ((_toa < 3) || (_toa > len - 3)) goto notfound; peak = corr.begin() + (int) rint(_toa); + /* Compute peak-to-average ratio. Reject if we don't have enough values */ for (int i = 2 * sps; i <= 5 * sps; i++) { if (peak - i >= corr.begin()) { avg += (peak - i)->norm2(); @@ -984,9 +1007,14 @@ int detectRACHBurst(signalVector &rxBurst, if (par < thresh) goto notfound; + /* Run the full peak detection to obtain when we have a burst */ + _amp = peakDetect(corr, &_toa, NULL); + /* Subtract forward tail bits from delay */ if (toa) *toa = _toa - 8 * sps; + + /* Normalize our channel gain */ if (amp) *amp = _amp / gRACHSequence->gain; |