From 5a0680655ff2908d689dd2bbd1ff23c282d3e769 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sat, 20 Jun 2015 01:38:47 +0300 Subject: Transceiver: Add support for OsmoBTS style handover. Signed-off-by: Tom Tsou --- Transceiver52M/Transceiver.cpp | 50 ++++++++++++++++++++++++++++++++++++++---- Transceiver52M/Transceiver.h | 1 + 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 63102a1..526153e 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -156,6 +156,11 @@ Transceiver::Transceiver(int wBasePort, { txFullScale = mRadioInterface->fullScaleInputValue(); rxFullScale = mRadioInterface->fullScaleOutputValue(); + + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) + mHandover[i][j] = false; + } } Transceiver::~Transceiver() @@ -463,9 +468,15 @@ void Transceiver::setModulus(size_t timeslot, size_t chan) Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime, size_t chan) { + static int tchh_subslot[26] = { 0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,1 }; + static int sdcch4_subslot[102] = { 3,3,3,3,0,0,2,2,2,2,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,2,2,2,2, + 3,3,3,3,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,2,2,2,2 }; + static int sdcch8_subslot[102] = { 5,5,5,5,6,6,6,6,7,7,7,7,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,0,0,0,0, + 1,1,1,1,2,2,2,2,3,3,3,3,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,4,4,4,4 }; TransceiverState *state = &mStates[chan]; unsigned burstTN = currTime.TN(); unsigned burstFN = currTime.FN(); + int subch; switch (state->chanType[burstTN]) { case NONE: @@ -475,16 +486,25 @@ Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime, return IDLE; break; case I: + // TODO: Are we expecting RACH on an IDLE frame? +/* if (burstFN % 26 == 25) + return IDLE;*/ + if (mHandover[burstTN][0]) + return RACH; return TSC; - /*if (burstFN % 26 == 25) - return IDLE; - else - return TSC;*/ break; case II: + subch = tchh_subslot[burstFN % 26]; + if (subch == 1) + return IDLE; + if (mHandover[burstTN][0]) + return RACH; return TSC; break; case III: + subch = tchh_subslot[burstFN % 26]; + if (mHandover[burstTN][subch]) + return RACH; return TSC; break; case IV: @@ -499,6 +519,8 @@ Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime, return RACH; else if ((mod51 == 45) || (mod51 == 46)) return RACH; + else if (mHandover[burstTN][sdcch4_subslot[burstFN % 102]]) + return RACH; else return TSC; break; @@ -506,6 +528,8 @@ Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime, case VII: if ((burstFN % 51 <= 14) && (burstFN % 51 >= 12)) return IDLE; + else if (mHandover[burstTN][sdcch8_subslot[burstFN % 102]]) + return RACH; else return TSC; break; @@ -782,6 +806,24 @@ void Transceiver::driveControl(size_t chan) sprintf(response,"RSP POWERON 1"); else sprintf(response,"RSP POWERON 0"); + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) + mHandover[i][j] = false; + } + } + else if (strcmp(command,"HANDOVER")==0){ + int ts=0,ss=0; + sscanf(buffer,"%3s %s %d %d",cmdcheck,command,&ts,&ss); + mHandover[ts][ss] = true; + LOG(WARNING) << "HANDOVER RACH at timeslot " << ts << " subslot " << ss; + sprintf(response,"RSP HANDOVER 0 %d %d",ts,ss); + } + else if (strcmp(command,"NOHANDOVER")==0){ + int ts=0,ss=0; + sscanf(buffer,"%3s %s %d %d",cmdcheck,command,&ts,&ss); + mHandover[ts][ss] = false; + LOG(WARNING) << "NOHANDOVER at timeslot " << ts << " subslot " << ss; + sprintf(response,"RSP NOHANDOVER 0 %d %d",ts,ss); } else if (strcmp(command,"SETMAXDLY")==0) { //set expected maximum time-of-arrival diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h index 4c9b829..bd8ec4f 100644 --- a/Transceiver52M/Transceiver.h +++ b/Transceiver52M/Transceiver.h @@ -228,6 +228,7 @@ private: size_t mChans; bool mOn; ///< flag to indicate that transceiver is powered on + bool mHandover[8][8]; ///< expect handover to the timeslot/subslot double mTxFreq; ///< the transmit frequency double mRxFreq; ///< the receive frequency unsigned mTSC; ///< the midamble sequence code -- cgit v1.2.3