radioInterface: HACK: placeholder for the diversity switching logic.

This commit is contained in:
Alexander Chemeris 2015-07-11 12:51:37 -04:00
parent 1537d4b2d9
commit f28d722f54
3 changed files with 50 additions and 0 deletions

View File

@ -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 */

View File

@ -25,6 +25,7 @@
#include "radioInterface.h"
#include "Resampler.h"
#include <Logger.h>
#include <iomanip>
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);
// }
}

View File

@ -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: