aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/bts_ctrl_commands.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2014-08-24 10:44:31 +0200
committerHarald Welte <laforge@gnumonks.org>2014-08-24 16:42:02 +0200
commitd9a2aa8d9909d93d96e421c7cb727932445fa8ab (patch)
treea5d58e1a563ed7feb35ce7bc7d973f0e4038686e /src/common/bts_ctrl_commands.c
parente43feaf231e08f108aafa26a7829820fad3447cb (diff)
add control interface to common BTS (for thermal attenuation)
Using this control interface, an external program can request attentuation of the transmitter for thermal management reasons. The external application doesn't have to know anthing about the actual transmit power, but it can just configure a certian value of milli-dB (1/10000 bel) and update (increase/decrease) that value depending on the thermal environment.
Diffstat (limited to 'src/common/bts_ctrl_commands.c')
-rw-r--r--src/common/bts_ctrl_commands.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/common/bts_ctrl_commands.c b/src/common/bts_ctrl_commands.c
new file mode 100644
index 00000000..6d223ff7
--- /dev/null
+++ b/src/common/bts_ctrl_commands.c
@@ -0,0 +1,78 @@
+/* Control Interface for osmo-bts */
+
+/* (C) 2014 by Harald Welte <laforge@gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include <osmocom/ctrl/control_cmd.h>
+
+#include <osmo-bts/logging.h>
+#include <osmo-bts/gsm_data.h>
+#include <osmo-bts/tx_power.h>
+
+CTRL_CMD_DEFINE(therm_att, "thermal-attenuation");
+static int get_therm_att(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts_trx *trx = cmd->node;
+ struct trx_power_params *tpp = &trx->power_params;
+
+ cmd->reply = talloc_asprintf(cmd, "%d", tpp->thermal_attenuation_mdB);
+
+ return CTRL_CMD_REPLY;
+}
+
+static int set_therm_att(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts_trx *trx = cmd->node;
+ struct trx_power_params *tpp = &trx->power_params;
+ int val = atoi(cmd->value);
+
+ printf("set_therm_att(trx=%p, tpp=%p)\n", trx, tpp);
+
+ tpp->thermal_attenuation_mdB = val;
+
+ power_ramp_start(trx, tpp->p_total_cur_mdBm, 0);
+
+ return get_therm_att(cmd, data);
+}
+
+static int verify_therm_att(struct ctrl_cmd *cmd, const char *value, void *data)
+{
+ int val = atoi(value);
+
+ /* permit between 0 to 40 dB attenuation */
+ if (val < 0 || val > to_mdB(40))
+ return 1;
+
+ return 0;
+}
+
+
+int bts_ctrl_cmds_install(struct gsm_bts *bts)
+{
+ int rc = 0;
+
+ rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_therm_att);
+
+ return rc;
+}