From 1dd05cf35a8c5e3c2acfbc4e23e26d41ea4a9aa9 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Wed, 15 Mar 2017 23:23:36 +0300 Subject: sigProcLib: make energyDetect() simpler by returning actual energy. Change-Id: I9bf97f2dc03fea9bebcf43198dfb05f6e4694e9c --- Transceiver52M/Transceiver.cpp | 4 ++-- Transceiver52M/sigProcLib.cpp | 8 ++------ Transceiver52M/sigProcLib.h | 14 +++++--------- 3 files changed, 9 insertions(+), 17 deletions(-) (limited to 'Transceiver52M') diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index f156ad4..3df482f 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -606,7 +606,7 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, double &RSSI, bool &i { int rc; complex amp; - float toa, pow, max = -1.0, avg = 0.0; + float toa, max = -1.0, avg = 0.0; int max_i = -1; signalVector *burst; SoftVector *bits = NULL; @@ -641,7 +641,7 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, double &RSSI, bool &i /* Select the diversity channel with highest energy */ for (size_t i = 0; i < radio_burst->chans(); i++) { - energyDetect(*radio_burst->getVector(i), 20 * mSPSRx, 0.0, &pow); + float pow = energyDetect(*radio_burst->getVector(i), 20 * mSPSRx); if (pow > max) { max = pow; max_i = i; diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index c1cf12e..41b18cf 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -1721,10 +1721,7 @@ static float computePeakRatio(signalVector *corr, return (amp.abs()) / rms; } -bool energyDetect(signalVector &rxBurst, - unsigned windowLength, - float detectThreshold, - float *avgPwr) +float energyDetect(signalVector &rxBurst, unsigned windowLength) { signalVector::const_iterator windowItr = rxBurst.begin(); //+rxBurst.size()/2 - 5*windowLength/2; @@ -1735,8 +1732,7 @@ bool energyDetect(signalVector &rxBurst, energy += windowItr->norm2(); windowItr+=4; } - if (avgPwr) *avgPwr = energy/windowLength; - return (energy/windowLength > detectThreshold*detectThreshold); + return energy/windowLength; } /* diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h index 1b646cd..87c0229 100644 --- a/Transceiver52M/sigProcLib.h +++ b/Transceiver52M/sigProcLib.h @@ -176,17 +176,13 @@ void scaleVector(signalVector &x, complex scale); /** - Energy detector, checks to see if received burst energy is above a threshold. - @param rxBurst The received GSM burst of interest. + Rough energy estimator. + @param rxBurst A GSM burst. @param windowLength The number of burst samples used to compute burst energy - @param detectThreshold The detection threshold, a linear value. - @param avgPwr The average power of the received burst. - @return True if burst energy is above threshold. + @return The average power of the received burst. */ -bool energyDetect(signalVector &rxBurst, - unsigned windowLength, - float detectThreshold, - float *avgPwr = NULL); +float energyDetect(signalVector &rxBurst, + unsigned windowLength); /** RACH aka Access Burst correlator/detector. -- cgit v1.2.3