fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/32541 )
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 --- M src/osmo-bsc/bsc_vty.c M src/osmo-bsc/bts.c M src/osmo-bsc/bts_ctrl.c 3 files changed, 31 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/41/32541/1
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index f1bd7c4..34676a2 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -1426,18 +1426,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 a6fc4a4..4a27c55 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -981,6 +981,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 a971fab..5ac1e0d 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");