laforge
/
openbts-osmo
Archived
1
0
Fork 0

Stupid bug fixed - can't move stack variables initialization to a separate function.

This commit is contained in:
Alexander Chemeris 2010-11-23 09:08:47 +03:00 committed by Thomas Tsou
parent 1965ab4255
commit 08bdbb921c
1 changed files with 148 additions and 157 deletions

View File

@ -146,161 +146,6 @@ static void restartTransceiver()
} }
} }
static void startBTS()
{
cout << endl << "Starting the system..." << endl;
if (gConfig.defines("Control.TMSITable.SavePath")) {
gTMSITable.load(gConfig.getStr("Control.TMSITable.SavePath"));
}
LOG(ALARM) << "OpenBTS starting, ver " << VERSION << " build date " << __DATE__;
restartTransceiver();
// Start the SIP interface.
gSIPInterface.start();
// Start the transceiver interface.
// Sleep long enough for the USRP to bootload.
sleep(5);
gTRX.start();
// Set up the interface to the radio.
// Get a handle to the C0 transceiver interface.
ARFCNManager* radio = gTRX.ARFCN(0);
// Tuning.
// Make sure its off for tuning.
radio->powerOff();
// Set TSC same as BCC everywhere.
radio->setTSC(gBTS.BCC());
// Tune.
radio->tune(gConfig.getNum("GSM.ARFCN"));
// Turn on and power up.
radio->powerOn();
radio->setPower(gConfig.getNum("GSM.PowerManager.MinAttenDB"));
// Set maximum expected delay spread.
radio->setMaxDelay(gConfig.getNum("GSM.MaxExpectedDelaySpread"));
// Set Receiver Gain
radio->setRxGain(gConfig.getNum("GSM.RxGain"));
// C-V on C0T0
radio->setSlot(0,5);
// SCH
SCHL1FEC SCH;
SCH.downstream(radio);
SCH.open();
// FCCH
FCCHL1FEC FCCH;
FCCH.downstream(radio);
FCCH.open();
// BCCH
BCCHL1FEC BCCH;
BCCH.downstream(radio);
BCCH.open();
// RACH
RACHL1FEC RACH(gRACHC5Mapping);
RACH.downstream(radio);
RACH.open();
// CCCHs
CCCHLogicalChannel CCCH0(gCCCH_0Mapping);
CCCH0.downstream(radio);
CCCH0.open();
CCCHLogicalChannel CCCH1(gCCCH_1Mapping);
CCCH1.downstream(radio);
CCCH1.open();
CCCHLogicalChannel CCCH2(gCCCH_2Mapping);
CCCH2.downstream(radio);
CCCH2.open();
// use CCCHs as AGCHs
gBTS.addAGCH(&CCCH0);
gBTS.addAGCH(&CCCH1);
gBTS.addAGCH(&CCCH2);
// C-V C0T0 SDCCHs
SDCCHLogicalChannel C0T0SDCCH[4] = {
SDCCHLogicalChannel(0,gSDCCH_4_0),
SDCCHLogicalChannel(0,gSDCCH_4_1),
SDCCHLogicalChannel(0,gSDCCH_4_2),
SDCCHLogicalChannel(0,gSDCCH_4_3),
};
Thread C0T0SDCCHControlThread[4];
for (int i=0; i<4; i++) {
C0T0SDCCH[i].downstream(radio);
C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]);
C0T0SDCCH[i].open();
gBTS.addSDCCH(&C0T0SDCCH[i]);
}
// Count configured slots.
unsigned sCount = 1;
bool halfDuplex = gConfig.defines("GSM.HalfDuplex");
if (halfDuplex) { LOG(NOTICE) << "Configuring for half-duplex operation." ; }
else { LOG(NOTICE) << "Configuring for full-duplex operation."; }
if (halfDuplex) sCount++;
// Create C-VII slots.
for (int i=0; i<gConfig.getNum("GSM.NumC7s"); i++) {
gBTS.createCombinationVII(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
// Set up idle filling on C0 as needed.
while (sCount<8) {
gBTS.createCombination0(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
/*
Note: The number of different paging subchannels on
the CCCH is:
MAX(1,(3 - BS-AG-BLKS-RES)) * BS-PA-MFRMS
if CCCH-CONF = "001"
(9 - BS-AG-BLKS-RES) * BS-PA-MFRMS
for other values of CCCH-CONF
*/
// Set up the pager.
// Set up paging channels.
// HACK -- For now, use a single paging channel, since paging groups are broken.
gBTS.addPCH(&CCCH2);
// Be sure we are not over-reserving.
LOG_ASSERT(gConfig.getNum("GSM.PagingReservations")<gBTS.numAGCHs());
// OK, now it is safe to start the BTS.
gBTS.start();
LOG(INFO) << "system ready";
}
static void stopBTS()
{
if (!gBTS.hold()) {
exitBTS(0, cout);
}
if (sgTransceiverPid) kill(sgTransceiverPid, SIGKILL);
}
static void exitCLI() static void exitCLI()
{ {
if (sgCLIServerSock != NULL) { if (sgCLIServerSock != NULL) {
@ -506,7 +351,149 @@ int main(int argc, char *argv[])
cout << endl << endl << gOpenBTSWelcome << endl; cout << endl << endl << gOpenBTSWelcome << endl;
startBTS(); #if 1
cout << endl << "Starting the system..." << endl;
if (gConfig.defines("Control.TMSITable.SavePath")) {
gTMSITable.load(gConfig.getStr("Control.TMSITable.SavePath"));
}
LOG(ALARM) << "OpenBTS starting, ver " << VERSION << " build date " << __DATE__;
restartTransceiver();
// Start the SIP interface.
gSIPInterface.start();
// Start the transceiver interface.
// Sleep long enough for the USRP to bootload.
sleep(5);
gTRX.start();
// Set up the interface to the radio.
// Get a handle to the C0 transceiver interface.
ARFCNManager* radio = gTRX.ARFCN(0);
// Tuning.
// Make sure its off for tuning.
radio->powerOff();
// Set TSC same as BCC everywhere.
radio->setTSC(gBTS.BCC());
// Tune.
radio->tune(gConfig.getNum("GSM.ARFCN"));
// Turn on and power up.
radio->powerOn();
radio->setPower(gConfig.getNum("GSM.PowerManager.MinAttenDB"));
// Set maximum expected delay spread.
radio->setMaxDelay(gConfig.getNum("GSM.MaxExpectedDelaySpread"));
// Set Receiver Gain
radio->setRxGain(gConfig.getNum("GSM.RxGain"));
// C-V on C0T0
radio->setSlot(0,5);
// SCH
SCHL1FEC SCH;
SCH.downstream(radio);
SCH.open();
// FCCH
FCCHL1FEC FCCH;
FCCH.downstream(radio);
FCCH.open();
// BCCH
BCCHL1FEC BCCH;
BCCH.downstream(radio);
BCCH.open();
// RACH
RACHL1FEC RACH(gRACHC5Mapping);
RACH.downstream(radio);
RACH.open();
// CCCHs
CCCHLogicalChannel CCCH0(gCCCH_0Mapping);
CCCH0.downstream(radio);
CCCH0.open();
CCCHLogicalChannel CCCH1(gCCCH_1Mapping);
CCCH1.downstream(radio);
CCCH1.open();
CCCHLogicalChannel CCCH2(gCCCH_2Mapping);
CCCH2.downstream(radio);
CCCH2.open();
// use CCCHs as AGCHs
gBTS.addAGCH(&CCCH0);
gBTS.addAGCH(&CCCH1);
gBTS.addAGCH(&CCCH2);
// C-V C0T0 SDCCHs
SDCCHLogicalChannel C0T0SDCCH[4] = {
SDCCHLogicalChannel(0,gSDCCH_4_0),
SDCCHLogicalChannel(0,gSDCCH_4_1),
SDCCHLogicalChannel(0,gSDCCH_4_2),
SDCCHLogicalChannel(0,gSDCCH_4_3),
};
Thread C0T0SDCCHControlThread[4];
for (int i=0; i<4; i++) {
C0T0SDCCH[i].downstream(radio);
C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]);
C0T0SDCCH[i].open();
gBTS.addSDCCH(&C0T0SDCCH[i]);
}
// Count configured slots.
unsigned sCount = 1;
bool halfDuplex = gConfig.defines("GSM.HalfDuplex");
if (halfDuplex) { LOG(NOTICE) << "Configuring for half-duplex operation." ; }
else { LOG(NOTICE) << "Configuring for full-duplex operation."; }
if (halfDuplex) sCount++;
// Create C-VII slots.
for (int i=0; i<gConfig.getNum("GSM.NumC7s"); i++) {
gBTS.createCombinationVII(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
// Create C-I slots.
for (int i=0; i<gConfig.getNum("GSM.NumC1s"); i++) {
gBTS.createCombinationI(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
// Set up idle filling on C0 as needed.
while (sCount<8) {
gBTS.createCombination0(gTRX,sCount/8,sCount);
if (halfDuplex) sCount++;
sCount++;
}
/*
Note: The number of different paging subchannels on
the CCCH is:
MAX(1,(3 - BS-AG-BLKS-RES)) * BS-PA-MFRMS
if CCCH-CONF = "001"
(9 - BS-AG-BLKS-RES) * BS-PA-MFRMS
for other values of CCCH-CONF
*/
// Set up the pager.
// Set up paging channels.
// HACK -- For now, use a single paging channel, since paging groups are broken.
gBTS.addPCH(&CCCH2);
// Be sure we are not over-reserving.
LOG_ASSERT(gConfig.getNum("GSM.PagingReservations")<gBTS.numAGCHs());
// OK, now it is safe to start the BTS.
gBTS.start();
LOG(INFO) << "system ready";
#endif
if (strcasecmp(gConfig.getStr("CLI.Type"),"TCP") == 0) { if (strcasecmp(gConfig.getStr("CLI.Type"),"TCP") == 0) {
ConnectionServerSocketTCP serverSock(gConfig.getNum("CLI.TCP.Port"), ConnectionServerSocketTCP serverSock(gConfig.getNum("CLI.TCP.Port"),
@ -523,7 +510,11 @@ int main(int argc, char *argv[])
runCLI(&gParser); runCLI(&gParser);
} }
stopBTS(); if (!gBTS.hold()) {
exitBTS(0, cout);
}
if (sgTransceiverPid) kill(sgTransceiverPid, SIGKILL);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }