fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bsc/+/32559 )
Change subject: gsm_bts_send_c0_power_red(): check if BTS is online first
......................................................................
gsm_bts_send_c0_power_red(): check if BTS is online first
... and print a proper error message instead of "not supported". We
don't know for sure whether it's supported before the BTS is connected.
Change-Id: I080aa7ef331b76918ae48d555eea6e4290c57120
Related: SYS#6435
(cherry picked from commit ea3e3c258d15e43667ada6fbee914f5b2da03ae0)
---
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ctrl.c
3 files changed, 32 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/59/32559/1
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index cc9de74..f89ff54 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1419,18 +1419,22 @@
}
rc = gsm_bts_set_c0_power_red(bts, red);
- if (rc == -ENOTSUP) {
+ switch (rc) {
+ case 0: /* success */
+ return CMD_SUCCESS;
+ case -ENOTCONN:
+ vty_out(vty, "%% BTS%u is offline%s", bts_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ case -ENOTSUP:
vty_out(vty, "%% BCCH carrier power reduction operation mode "
"is not supported for BTS%u%s", bts_nr, VTY_NEWLINE);
return CMD_WARNING;
- } else if (rc != 0) {
+ default:
vty_out(vty, "%% Failed to %sable BCCH carrier power reduction "
"operation mode for BTS%u%s", red ? "en" : "dis",
bts_nr, VTY_NEWLINE);
return CMD_WARNING;
}
-
- return CMD_SUCCESS;
}
/* this command is now hidden, as it's a low-level debug hack, and people should
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 585eb99..35e8693 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -978,6 +978,8 @@
/* Send the given C0 power reduction value to the BTS */
int gsm_bts_send_c0_power_red(const struct gsm_bts *bts, const uint8_t red)
{
+ if (!bts_is_online(bts))
+ return -ENOTCONN;
if (!osmo_bts_has_feature(&bts->features, BTS_FEAT_BCCH_POWER_RED))
return -ENOTSUP;
if (bts->model->power_ctrl_send_c0_power_red == NULL)
diff --git a/src/osmo-bsc/bts_ctrl.c b/src/osmo-bsc/bts_ctrl.c
index 4b4b1fb..543ebdf 100644
--- a/src/osmo-bsc/bts_ctrl.c
+++ b/src/osmo-bsc/bts_ctrl.c
@@ -497,15 +497,19 @@
int rc;
rc = gsm_bts_set_c0_power_red(bts, red);
- if (rc == -ENOTSUP) {
+ switch (rc) {
+ case 0: /* success */
+ return get_bts_c0_power_red(cmd, data);
+ case -ENOTCONN:
+ cmd->reply = "BTS is offline";
+ return CTRL_CMD_ERROR;
+ case -ENOTSUP:
cmd->reply = "BCCH carrier power reduction is not supported";
return CTRL_CMD_ERROR;
- } else if (rc != 0) {
+ default:
cmd->reply = "Failed to enable BCCH carrier power reduction";
return CTRL_CMD_ERROR;
}
-
- return get_bts_c0_power_red(cmd, data);
}
CTRL_CMD_DEFINE(bts_c0_power_red, "c0-power-reduction");
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc/+/32559
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: 2023q1
Gerrit-Change-Id: I080aa7ef331b76918ae48d555eea6e4290c57120
Gerrit-Change-Number: 32559
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange