matanp has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/35747?usp=email )


Change subject: ctrl: Add ms power
......................................................................

ctrl: Add ms power

Change-Id: I6f556b66011be6126d6bac31a14101ba37f81cc4
---
M include/osmocom/bsc/ctrl.h
M src/osmo-bsc/Makefile.am
M src/osmo-bsc/bsc_ctrl_lookup.c
M src/osmo-bsc/bts_trx_ts_ctrl.c
A src/osmo-bsc/bts_trx_ts_lchan_ctrl.c
5 files changed, 101 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/47/35747/1

diff --git a/include/osmocom/bsc/ctrl.h b/include/osmocom/bsc/ctrl.h
index 0d6c8a0..86eb3b1 100644
--- a/include/osmocom/bsc/ctrl.h
+++ b/include/osmocom/bsc/ctrl.h
@@ -12,6 +12,7 @@
 int bsc_bts_ctrl_cmds_install(void);
 int bsc_bts_trx_ctrl_cmds_install(void);
 int bsc_bts_trx_ts_ctrl_cmds_install(void);
+int bsc_bts_trx_ts_lchan_ctrl_cmds_install(void);
 void ctrl_generate_bts_location_state_trap(struct gsm_bts *bts, struct 
bsc_msc_data *msc);
 void osmo_bsc_send_trap(struct ctrl_cmd *cmd, struct bsc_msc_data *msc_data);

diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index e577c95..1026523 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -47,6 +47,7 @@
        bts_trx.c \
        bts_trx_ctrl.c \
        bts_trx_ts_ctrl.c \
+       bts_trx_ts_lchan_ctrl.c \
        bts_ericsson_rbs2000.c \
        bts_init.c \
        bts_ipaccess_nanobts.c \
diff --git a/src/osmo-bsc/bsc_ctrl_lookup.c b/src/osmo-bsc/bsc_ctrl_lookup.c
index 145cda3..cf1d284 100644
--- a/src/osmo-bsc/bsc_ctrl_lookup.c
+++ b/src/osmo-bsc/bsc_ctrl_lookup.c
@@ -43,6 +43,7 @@
        struct gsm_bts *bts = NULL;
        struct gsm_bts_trx *trx = NULL;
        struct gsm_bts_trx_ts *ts = NULL;
+       struct gsm_lchan *lchan = NULL;
        struct bsc_msc_data *msc = NULL;
        char *token = vector_slot(vline, *i);
        long num;
@@ -89,6 +90,20 @@
                        goto err_missing;
                *node_data = ts;
                *node_type = CTRL_NODE_TS;
+       } else if (!strcmp(token, "lchan")) {
+               if (*node_type != CTRL_NODE_TS || !*node_data)
+                       goto err_missing;
+               ts = *node_data;
+               (*i)++;
+               if (!ctrl_parse_get_num(vline, *i, &num))
+                       goto err_index;
+
+               if ((num >= 0) && (num < ts->max_primary_lchans))
+                       lchan = &ts->lchan[num];
+               if (!lchan)
+                       goto err_missing;
+               *node_data = lchan;
+               *node_type = CTRL_NODE_LCHAN;
        } else if (!strcmp(token, "msc")) {
                if (*node_type != CTRL_NODE_ROOT || !net)
                        goto err_missing;
diff --git a/src/osmo-bsc/bts_trx_ts_ctrl.c b/src/osmo-bsc/bts_trx_ts_ctrl.c
index 079b9b3..4921a8c 100644
--- a/src/osmo-bsc/bts_trx_ts_ctrl.c
+++ b/src/osmo-bsc/bts_trx_ts_ctrl.c
@@ -104,5 +104,7 @@
        rc |= ctrl_cmd_install(CTRL_NODE_TS, &cmd_ts_hopping_arfcn_add);
        rc |= ctrl_cmd_install(CTRL_NODE_TS, &cmd_ts_hopping_arfcn_del);

+       rc |= bsc_bts_trx_ts_lchan_ctrl_cmds_install();
+
        return rc;
 }
diff --git a/src/osmo-bsc/bts_trx_ts_lchan_ctrl.c 
b/src/osmo-bsc/bts_trx_ts_lchan_ctrl.c
new file mode 100644
index 0000000..4b8e74f
--- /dev/null
+++ b/src/osmo-bsc/bts_trx_ts_lchan_ctrl.c
@@ -0,0 +1,73 @@
+/*
+ * (C) 2013-2015 by Holger Hans Peter Freyther
+ * (C) 2013-2022 by sysmocom s.f.m.c. GmbH
+ *
+ * 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 Affero 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 <osmocom/ctrl/control_cmd.h>
+
+#include <osmocom/bsc/ctrl.h>
+#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/system_information.h>
+#include <osmocom/bsc/abis_rsl.h>
+
+static int verify_lchan_ms_power(struct ctrl_cmd *cmd, const char *value, void 
*_data)
+{
+       int ms_power = atoi(cmd->value);
+
+       if (ms_power < 0 || ms_power > 40) {
+               cmd->reply = "Value is out of range";
+               return 1;
+       }
+
+       return 0;
+}
+
+static int get_lchan_ms_power(struct ctrl_cmd *cmd, void *data)
+{
+       struct gsm_lchan *lchan = cmd->node;
+
+       cmd->reply = talloc_asprintf(cmd, "%u", 
ms_pwr_dbm(lchan->ts->trx->bts->band, atoi(cmd->value)));
+       if (!cmd->reply) {
+               cmd->reply = "OOM";
+               return CTRL_CMD_ERROR;
+       }
+
+       return CTRL_CMD_REPLY;
+}
+
+static int set_lchan_ms_power(struct ctrl_cmd *cmd, void *data)
+{
+       struct gsm_lchan *lchan = cmd->node;
+
+       lchan->ms_power = ms_pwr_ctl_lvl(lchan->ts->trx->bts->band, 
atoi(cmd->value));
+       rsl_chan_ms_power_ctrl(lchan);
+       cmd->reply = "OK";
+       return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE(lchan_ms_power, "ms-power");
+
+int bsc_bts_trx_ts_lchan_ctrl_cmds_install(void)
+{
+       int rc = 0;
+
+       rc |= ctrl_cmd_install(CTRL_NODE_LCHAN, &cmd_lchan_ms_power);
+
+       return rc;
+}

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35747?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I6f556b66011be6126d6bac31a14101ba37f81cc4
Gerrit-Change-Number: 35747
Gerrit-PatchSet: 1
Gerrit-Owner: matanp <[email protected]>
Gerrit-MessageType: newchange

Reply via email to