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
This commit is contained in:
Vadim Yanitskiy 2023-04-28 02:35:16 +07:00
parent 16922c5017
commit ea3e3c258d
3 changed files with 18 additions and 8 deletions

View File

@ -1426,18 +1426,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

View File

@ -981,6 +981,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)

View File

@ -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");