aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-11-17 18:54:52 -0500
committerThomas Tsou <tom@tsou.cc>2013-11-17 18:57:45 -0500
commit4de70be9a6d9ed4ed379168196aad745b9ef4257 (patch)
tree9c148359e0a2f9f127a4c53e1d35b3ca90d95aec
parentfb827d04ba211313d471ac8fba8715a492e483cb (diff)
Transceiver52M: Remove database configuration file requirement
We don't require any parameters stored in the configuration table, so don't bother with the existence of the persistent database file. This also removes an unnecessary step during initial setup since relevant parameters can be configured from the command line. Signed-off-by: Thomas Tsou <tom@tsou.cc>
-rw-r--r--Transceiver52M/osmo-trx.cpp45
1 files changed, 14 insertions, 31 deletions
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 3135dc6..98112bb 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -32,8 +32,6 @@
#include <Logger.h>
#include <Configuration.h>
-#define CONFIGDB "/etc/OpenBTS/OpenBTS.db"
-
/* Samples-per-symbol for downlink path
* 4 - Uses precision modulator (more computation, less distortion)
* 1 - Uses minimized modulator (less computation, more distortion)
@@ -71,71 +69,56 @@ struct trx_config {
bool diversity;
};
-ConfigurationTable gConfig(CONFIGDB);
+ConfigurationTable gConfig;
volatile bool gshutdown = false;
/* Run sanity check on configuration table
* The global table constructor cannot provide notification in the
- * event of failure. Make sure that we can open the database file,
+ * event of failure. Make sure that we can access the database,
* write to it, and that it contains the bare minimum required keys.
*/
-bool testConfig(const char *filename)
+bool testConfig()
{
- int rc, val = 9999;
- sqlite3 *db;
+ int val = 9999;
std::string test = "asldfkjsaldkf";
const char *key = "Log.Level";
- /* Try to open the database */
- rc = sqlite3_open(filename, &db);
- if (rc || !db) {
+ /* Attempt to query */
+ try {
+ gConfig.getStr(key);
+ } catch (...) {
std::cerr << std::endl;
- std::cerr << "Config: Database could not be opened - "
- << "check that database exists with read access"
+ std::cerr << "Config: Failed query required key " << key
<< std::endl;
return false;
- } else {
- sqlite3_close(db);
}
/* Attempt to set a test value in the global config */
if (!gConfig.set(test, val)) {
std::cerr << std::endl;
- std::cerr << "Config: Failed to set test key - "
- << "permission to write to database directory?"
- << std::endl;
+ std::cerr << "Config: Failed to set test key" << std::endl;
return false;
} else {
gConfig.remove(test);
}
- /* Attempt to query */
- try {
- gConfig.getStr(key);
- } catch (...) {
- std::cerr << std::endl;
- std::cerr << "Config: Failed query required key " << key
- << std::endl;
- return false;
- }
-
return true;
}
+
/* Setup configuration values
* Don't query the existence of the Log.Level because it's a
* mandatory value. That is, if it doesn't exist, the configuration
- * table will crash or will have already crashed. So we check for
- * it in the initial database sanity check. Everything else we can
- * survive without and use default values if the database entries
+ * table will crash or will have already crashed. Everything else we
+ * can survive without and use default values if the database entries
* are empty.
*/
bool trx_setup_config(struct trx_config *config)
{
std::string refstr, divstr;
- if (!testConfig(CONFIGDB))
+ if (!testConfig())
return false;
if (config->log_level == "")