diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2023-04-28 02:35:16 +0700 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2023-04-30 14:50:23 +0700 |
commit | 143c6bef8ae4cbb9b1c1eff72798151ebd1a127e (patch) | |
tree | c906d2f9f1b4bc213c3c9e2a906ca9a1b0ffac5f | |
parent | c77700e2ff02de4ee1ea953e825a727641d10164 (diff) |
gsm_bts_send_c0_power_red(): check if BTS is online first2023q1
... 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)
-rw-r--r-- | src/osmo-bsc/bsc_vty.c | 12 | ||||
-rw-r--r-- | src/osmo-bsc/bts.c | 2 | ||||
-rw-r--r-- | src/osmo-bsc/bts_ctrl.c | 12 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index cc9de74e9..f89ff54de 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -1419,18 +1419,22 @@ DEFUN(bts_c0_power_red, } 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 585eb99ae..35e869378 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -978,6 +978,8 @@ int gsm_bts_set_system_infos(struct gsm_bts *bts) /* 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 4b4b1fbf4..543ebdf63 100644 --- a/src/osmo-bsc/bts_ctrl.c +++ b/src/osmo-bsc/bts_ctrl.c @@ -497,15 +497,19 @@ static int set_bts_c0_power_red(struct ctrl_cmd *cmd, void *data) 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"); |