mirror of
https://github.com/RangeNetworks/openbts.git
synced 2025-10-22 23:32:00 +00:00
fix botched merge of new power logic and command
This commit is contained in:
@@ -1304,8 +1304,42 @@ static CLIStatus chans(int argc, char **argv, ostream& os)
|
||||
#endif
|
||||
|
||||
|
||||
const char *powerHelp = "[atten] -- report or set current output power attentuation.";
|
||||
|
||||
static bool powerCheckAttenValidity(const char *configOptionName,int atten, ostream&os)
|
||||
{
|
||||
if (atten < 0) {
|
||||
os << "power value(s) are attenuation and must not be negative"<<endl;
|
||||
return false;
|
||||
}
|
||||
if (!gConfig.isValidValue(configOptionName, atten)) {
|
||||
os << "Invalid new value for atten. It must be in range (";
|
||||
os << gConfig.mSchema[configOptionName].getValidValues() << ")" << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static CLIStatus powerCommand(int argc, char **argv, ostream& os)
|
||||
{
|
||||
if (argc>3) { return BAD_NUM_ARGS; }
|
||||
|
||||
if (argc > 1) {
|
||||
int min = atoi(argv[1]);
|
||||
int max = min;
|
||||
|
||||
if (!powerCheckAttenValidity("GSM.Radio.PowerManager.MinAttenDB", min, os)) { return BAD_VALUE; }
|
||||
if (!powerCheckAttenValidity("GSM.Radio.PowerManager.MaxAttenDB", max, os)) { return BAD_VALUE; }
|
||||
|
||||
gConfig.set("GSM.Radio.PowerManager.MinAttenDB",min);
|
||||
gConfig.set("GSM.Radio.PowerManager.MaxAttenDB",max);
|
||||
|
||||
gPowerManager.pmSetAtten(min);
|
||||
}
|
||||
|
||||
os << "current downlink power " << gPowerManager.power() << " dB wrt full scale" << endl;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static CLIStatus rxgain(int argc, char** argv, ostream& os)
|
||||
@@ -1586,7 +1620,7 @@ void Parser::addCommands()
|
||||
addCommand("stats", stats,"[patt] OR clear -- print all, or selected, performance counters, OR clear all counters.");
|
||||
addCommand("handover", handover,handoverHelp);
|
||||
addCommand("memstat", memStat, "-- internal testing command: print memory use stats.");
|
||||
|
||||
addCommand("power", powerCommand, powerHelp);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,6 +105,7 @@ void GSMConfig::gsmStart()
|
||||
// Start gprs.
|
||||
GPRS::gprsStart();
|
||||
}
|
||||
gPowerManager.pmStart();
|
||||
// Do not call this until the paging channels are installed.
|
||||
PagerStart();
|
||||
|
||||
|
@@ -13,4 +13,43 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "PowerManager.h"
|
||||
#include <Logger.h>
|
||||
#include <OpenBTSConfig.h>
|
||||
#include <GSMConfig.h>
|
||||
#include <TRXManager.h>
|
||||
#include <ControlCommon.h>
|
||||
|
||||
#define LOG_GROUP LogGroup::GSM // Can set Log.Level.GSM for debugging
|
||||
|
||||
extern TransceiverManager gTRX;
|
||||
|
||||
namespace GSM {
|
||||
|
||||
PowerManager gPowerManager;
|
||||
|
||||
|
||||
void PowerManager::pmSetAttenDirect(int atten)
|
||||
{
|
||||
mRadio->setPower(atten);
|
||||
mAtten = atten;
|
||||
LOG(INFO) << "setting power to -" << mAtten << " dB at uptime="<<gBTS.uptime();
|
||||
}
|
||||
|
||||
void PowerManager::pmSetAtten(int atten)
|
||||
{
|
||||
if (atten != mAtten) { pmSetAttenDirect(atten); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PowerManager::pmStart()
|
||||
{
|
||||
LOG(INFO);
|
||||
mRadio = gTRX.ARFCN(0);
|
||||
pmSetAttenDirect(gConfig.getNum("GSM.Radio.PowerManager.MaxAttenDB"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// vim: ts=4 sw=4
|
||||
|
@@ -15,6 +15,43 @@
|
||||
|
||||
#ifndef __POWER_CONTROL__
|
||||
#define __POWER_CONTROL__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <Timeval.h>
|
||||
#include <Threads.h>
|
||||
|
||||
// forward declaration
|
||||
//class Timeval;
|
||||
|
||||
// Make it all inline for now - no change to automake
|
||||
|
||||
class ARFCNManager;
|
||||
|
||||
|
||||
namespace GSM {
|
||||
|
||||
|
||||
class PowerManager {
|
||||
|
||||
private:
|
||||
ARFCNManager* mRadio;
|
||||
volatile int mAtten; ///< current attenuation.
|
||||
void pmSetAttenDirect(int atten);
|
||||
|
||||
public:
|
||||
PowerManager() : mAtten(-9999) {}
|
||||
void pmStart();
|
||||
void pmSetAtten(int atten);
|
||||
int power() { return -mAtten; }
|
||||
};
|
||||
|
||||
extern PowerManager gPowerManager;
|
||||
|
||||
|
||||
} // namespace GSM
|
||||
|
||||
|
||||
#endif // __POWER_CONTROL__
|
||||
|
||||
// vim: ts=4 sw=4
|
||||
|
Reference in New Issue
Block a user