diff --git a/public-trunk/Transceiver/Transceiver.cpp b/public-trunk/Transceiver/Transceiver.cpp index fe0487f..bb2649e 100644 --- a/public-trunk/Transceiver/Transceiver.cpp +++ b/public-trunk/Transceiver/Transceiver.cpp @@ -61,6 +61,9 @@ Transceiver::Transceiver(int wBasePort, LOG(DEBUG) << "gsmPulse: " << *gsmPulse; sigProcLibSetup(mSamplesPerSymbol); + txFullScale = mRadioInterface->fullScaleInputValue(); + rxFullScale = mRadioInterface->fullScaleOutputValue(); + // initialize filler tables with dummy bursts, initialize other per-timeslot variables for (int i = 0; i < 8; i++) { signalVector* modBurst = modulateBurst(gDummyBurst,*gsmPulse, @@ -484,6 +487,22 @@ void Transceiver::driveControl() } } } + else if (strcmp(command,"SETRXGAIN")==0) { + //set expected maximum time-of-arrival + int newGain; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&newGain); + newGain = mRadioInterface->setRxGain(newGain); + sprintf(response,"RSP SETRXGAIN 0 %d",newGain); + } + else if (strcmp(command,"NOISELEV")==0) { + if (mOn) { + sprintf(response,"RSP NOISELEV 0 %d", + (int) round(20.0*log10(rxFullScale/mEnergyThreshold))); + } + else { + sprintf(response,"RSP NOISELEV 1 0"); + } + } else if (strcmp(command,"SETPOWER")==0) { // set output power in dB int dbPwr; @@ -492,6 +511,7 @@ void Transceiver::driveControl() sprintf(response,"RSP SETPOWER 1 %d",dbPwr); else { mPower = dbPwr; + mRadioInterface->setPowerAttenuation(dbPwr); sprintf(response,"RSP SETPOWER 0 %d",dbPwr); } } diff --git a/public-trunk/Transceiver/Transceiver.h b/public-trunk/Transceiver/Transceiver.h index c37bd88..827ed92 100644 --- a/public-trunk/Transceiver/Transceiver.h +++ b/public-trunk/Transceiver/Transceiver.h @@ -68,6 +68,8 @@ private: GSM::Time mLastClockUpdateTime; ///< last time clock update was sent up to core RadioInterface *mRadioInterface; ///< associated radioInterface object + double txFullScale; ///< full scale input to radio + double rxFullScale; ///< full scale output to radio /** Codes for burst types of received bursts*/ typedef enum { diff --git a/public-trunk/Transceiver/radioInterface.cpp b/public-trunk/Transceiver/radioInterface.cpp index e999c5e..5c6483a 100644 --- a/public-trunk/Transceiver/radioInterface.cpp +++ b/public-trunk/Transceiver/radioInterface.cpp @@ -72,6 +72,19 @@ RadioInterface::~RadioInterface(void) { mReceiveFIFO.clear(); } +double RadioInterface::fullScaleInputValue(void) { + return usrp->fullScaleInputValue(); +} + +double RadioInterface::fullScaleOutputValue(void) { + return usrp->fullScaleOutputValue(); +} + +void RadioInterface::setPowerAttenuation(double atten) +{ + usrp->setTxGain(usrp->maxTxGain() - atten); +} + short *RadioInterface::USRPifyVector(signalVector &wVector) { @@ -276,6 +289,22 @@ bool RadioInterface::tuneRx(double freq) return usrp->setRxFreq(freq); } +double RadioInterface::setRxGain(double dB) +{ + if (usrp) + return usrp->setRxGain(dB); + else + return -1; +} + +double RadioInterface::getRxGain(void) +{ + if (usrp) + return usrp->getRxGain(); + else + return -1; +} + void RadioInterface::start() { LOG(INFO) << "starting radio interface..."; diff --git a/public-trunk/Transceiver/radioInterface.h b/public-trunk/Transceiver/radioInterface.h index 78b17a0..94d0166 100644 --- a/public-trunk/Transceiver/radioInterface.h +++ b/public-trunk/Transceiver/radioInterface.h @@ -189,10 +189,11 @@ public: /** set receive frequency */ bool tuneRx(double freq); - /** set thread priority */ - void setPriority() { usrp->setPriority(); } + /** set receive gain */ + double setRxGain(double dB); -protected: + /** get receive gain */ + double getRxGain(void); /** drive transmission of GSM bursts */ void driveTransmitRadio(); @@ -200,6 +201,19 @@ protected: /** drive reception of GSM bursts */ void driveReceiveRadio(); + void setPowerAttenuation(double atten); + + /** returns the full-scale transmit amplitude **/ + double fullScaleInputValue(); + + /** returns the full-scale receive amplitude **/ + double fullScaleOutputValue(); + + /** set thread priority */ + void setPriority() { usrp->setPriority(); } + +protected: + /** drive synchronization of Tx/Rx of USRP */ void alignRadio();