From f28d722f54147119cab1ebf63b28e28ba204a588 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sat, 11 Jul 2015 12:51:37 -0400 Subject: radioInterface: HACK: placeholder for the diversity switching logic. --- Transceiver52M/Transceiver.cpp | 2 ++ Transceiver52M/radioInterface.cpp | 44 +++++++++++++++++++++++++++++++++++++++ Transceiver52M/radioInterface.h | 4 ++++ 3 files changed, 50 insertions(+) diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 1dc14bb..f66c7ae 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -682,6 +682,8 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, double &RSSI, bool &i GSM::Time time = radio_burst->getTime(); CorrType type = expectedCorrType(time, chan); + mRadioInterface->updateBurstRxParameters(time, chan); + /* Debug: dump bursts to disk */ /* bits 0-7 - chan 0 timeslots * bits 8-15 - chan 1 timeslots */ diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp index 14a4fc2..edebae2 100644 --- a/Transceiver52M/radioInterface.cpp +++ b/Transceiver52M/radioInterface.cpp @@ -25,6 +25,7 @@ #include "radioInterface.h" #include "Resampler.h" #include +#include extern "C" { #include "convert.h" @@ -190,6 +191,7 @@ bool RadioInterface::start() writeTimestamp = mRadio->initialWriteTimestamp(); readTimestamp = mRadio->initialReadTimestamp(); + configureTimestamp = readTimestamp; mRadio->updateAlignment(writeTimestamp-10000); mRadio->updateAlignment(writeTimestamp-10000); @@ -275,6 +277,8 @@ bool RadioInterface::driveReceiveRadio() * pattern of 157-156-156-156 symbols per timeslot */ while (recvSz > burstSize) { +// updateBurstRxParameters(); + for (size_t i = 0; i < mChans; i++) { burst = new radioVector(rcvClock, burstSize, head, mMIMO); @@ -294,6 +298,7 @@ bool RadioInterface::driveReceiveRadio() rcvClock.incTN(); readSz += burstSize; recvSz -= burstSize; + configureTimestamp += burstSize; tN = rcvClock.TN(); @@ -402,3 +407,42 @@ void RadioInterface::pushBuffer() writeTimestamp += num_sent; sendCursor = 0; } + +void RadioInterface::updateBurstRxParameters(const GSM::Time &gsmTime, size_t chan) +{ + if (chan != 0) return; + + TIMESTAMP curTs = mRadio->getCurrentTimestampRx(); + + // TODO: Choose a proper value + const int burstAdvance = 8*3; + + // Get TN of the burst to update + GSM::Time rcvClock = gsmTime; +// rcvClock.decTN(receiveOffset); + rcvClock.incTN(burstAdvance); + unsigned tN = rcvClock.TN(); + unsigned fN = rcvClock.FN(); + + const double symbolsPerSlot = gSlotLen + 8.25; + // TODO: Properly take into account 156/157 burst sizes + //const double burstSize = (symbolsPerSlot + (tN % 4 == 0)) * mSPSRx; + const TIMESTAMP burstTimestamp = configureTimestamp + symbolsPerSlot*mSPSRx*burstAdvance; + + LOG(INFO) << "chan=" << chan << " " << rcvClock << " current_rx_timestamp=" << curTs + << " configureTimestamp=" << configureTimestamp << " (" << std::setw(5) << int(configureTimestamp)-int(curTs) << ")" + << " burstTimestamp=" << burstTimestamp << " (" << std::setw(5) << int(burstTimestamp)-int(curTs) << ")"; + +// if (tN != 2 && tN != 3) + if (tN != 0) + return; + + // TODO: real decision making + bool diversity = false; +// mRadio->set_diversity(((fN%2==0) != (tN%2==0))?false:true, burstTimestamp, chan); +// if (tN==2) + diversity = (fN%2==0)?false:true; + LOG(INFO) << "chan=" << chan << " " << rcvClock << " diversity=" << diversity; + mRadio->set_diversity(diversity, burstTimestamp, chan); +// } +} diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h index b359cbd..182e188 100644 --- a/Transceiver52M/radioInterface.h +++ b/Transceiver52M/radioInterface.h @@ -52,6 +52,7 @@ protected: bool overrun; ///< indicates reads from USRP are too slow TIMESTAMP writeTimestamp; ///< sample timestamp of next packet written to USRP TIMESTAMP readTimestamp; ///< sample timestamp of next packet read from USRP + TIMESTAMP configureTimestamp; ///< sample timestamp of next burst to configure RadioClock mClock; ///< the basestation clock! @@ -135,6 +136,9 @@ public: /** get transport window type of attached device */ enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); } + /** update diversity switch and other reception of GSM bursts */ + void updateBurstRxParameters(const GSM::Time &gsmTime, size_t chan); + #if USRP1 protected: -- cgit v1.2.3