| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#include <stdlib.h> |
| 27 |
#include <unistd.h> |
| 28 |
#include <errno.h> |
| 29 |
#include <stdint.h> |
| 30 |
#include <ctype.h> |
| 31 |
#include <string.h> |
| 32 |
#include <sys/socket.h> |
| 33 |
#include <netinet/in.h> |
| 34 |
#include <arpa/inet.h> |
| 35 |
#include <inttypes.h> |
| 36 |
|
| 37 |
#include <osmocom/vty/vty.h> |
| 38 |
#include <osmocom/vty/command.h> |
| 39 |
#include <osmocom/vty/misc.h> |
| 40 |
|
| 41 |
#include <osmo-bts/logging.h> |
| 42 |
|
| 43 |
#include "lc15bts_misc.h" |
| 44 |
#include "lc15bts_mgr.h" |
| 45 |
#include "lc15bts_temp.h" |
| 46 |
#include "lc15bts_power.h" |
| 47 |
#include "lc15bts_led.h" |
| 48 |
#include "btsconfig.h" |
| 49 |
|
| 50 |
static struct lc15bts_mgr_instance *s_mgr; |
| 51 |
|
| 52 |
static const char copyright[] = |
| 53 |
"(C) 2012 by Harald Welte <[email protected]>\r\n" |
| 54 |
"(C) 2014 by Holger Hans Peter Freyther\r\n" |
| 55 |
"(C) 2015 by Yves Godin <[email protected]>\r\n" |
| 56 |
"License AGPLv3+: GNU AGPL version 2 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n" |
| 57 |
"This is free software: you are free to change and redistribute it.\r\n" |
| 58 |
"There is NO WARRANTY, to the extent permitted by law.\r\n"; |
| 59 |
|
| 60 |
static int go_to_parent(struct vty *vty) |
| 61 |
{ |
| 62 |
switch (vty->node) { |
| 63 |
case MGR_NODE: |
| 64 |
vty->node = CONFIG_NODE; |
| 65 |
break; |
| 66 |
case ACT_NORM_NODE: |
| 67 |
case ACT_WARN_NODE: |
| 68 |
case ACT_CRIT_NODE: |
| 69 |
case LIMIT_SUPPLY_TEMP_NODE: |
| 70 |
case LIMIT_SOC_NODE: |
| 71 |
case LIMIT_FPGA_NODE: |
| 72 |
case LIMIT_RMSDET_NODE: |
| 73 |
case LIMIT_OCXO_NODE: |
| 74 |
case LIMIT_TX0_TEMP_NODE: |
| 75 |
case LIMIT_TX1_TEMP_NODE: |
| 76 |
case LIMIT_PA0_TEMP_NODE: |
| 77 |
case LIMIT_PA1_TEMP_NODE: |
| 78 |
case LIMIT_SUPPLY_VOLT_NODE: |
| 79 |
case LIMIT_TX0_VSWR_NODE: |
| 80 |
case LIMIT_TX1_VSWR_NODE: |
| 81 |
case LIMIT_SUPPLY_PWR_NODE: |
| 82 |
case LIMIT_PA0_PWR_NODE: |
| 83 |
case LIMIT_PA1_PWR_NODE: |
| 84 |
vty->node = MGR_NODE; |
| 85 |
break; |
| 86 |
default: |
| 87 |
vty->node = CONFIG_NODE; |
| 88 |
} |
| 89 |
return vty->node; |
| 90 |
} |
| 91 |
|
| 92 |
static struct vty_app_info vty_info = { |
| 93 |
.name = "lc15bts-mgr", |
| 94 |
.version = PACKAGE_VERSION, |
| 95 |
.go_parent_cb = go_to_parent, |
| 96 |
.copyright = copyright, |
| 97 |
}; |
| 98 |
|
| 99 |
|
| 100 |
#define MGR_STR "Configure lc15bts-mgr\n" |
| 101 |
|
| 102 |
static struct cmd_node mgr_node = { |
| 103 |
MGR_NODE, |
| 104 |
"%s(lc15bts-mgr)# ", |
| 105 |
1, |
| 106 |
}; |
| 107 |
|
| 108 |
static struct cmd_node act_norm_node = { |
| 109 |
ACT_NORM_NODE, |
| 110 |
"%s(actions-normal)# ", |
| 111 |
1, |
| 112 |
}; |
| 113 |
|
| 114 |
static struct cmd_node act_warn_node = { |
| 115 |
ACT_WARN_NODE, |
| 116 |
"%s(actions-warn)# ", |
| 117 |
1, |
| 118 |
}; |
| 119 |
|
| 120 |
static struct cmd_node act_crit_node = { |
| 121 |
ACT_CRIT_NODE, |
| 122 |
"%s(actions-critical)# ", |
| 123 |
1, |
| 124 |
}; |
| 125 |
|
| 126 |
static struct cmd_node limit_supply_temp_node = { |
| 127 |
LIMIT_SUPPLY_TEMP_NODE, |
| 128 |
"%s(limit-supply-temp)# ", |
| 129 |
1, |
| 130 |
}; |
| 131 |
|
| 132 |
static struct cmd_node limit_soc_node = { |
| 133 |
LIMIT_SOC_NODE, |
| 134 |
"%s(limit-soc)# ", |
| 135 |
1, |
| 136 |
}; |
| 137 |
|
| 138 |
static struct cmd_node limit_fpga_node = { |
| 139 |
LIMIT_FPGA_NODE, |
| 140 |
"%s(limit-fpga)# ", |
| 141 |
1, |
| 142 |
}; |
| 143 |
|
| 144 |
static struct cmd_node limit_rmsdet_node = { |
| 145 |
LIMIT_RMSDET_NODE, |
| 146 |
"%s(limit-rmsdet)# ", |
| 147 |
1, |
| 148 |
}; |
| 149 |
|
| 150 |
static struct cmd_node limit_ocxo_node = { |
| 151 |
LIMIT_OCXO_NODE, |
| 152 |
"%s(limit-ocxo)# ", |
| 153 |
1, |
| 154 |
}; |
| 155 |
|
| 156 |
static struct cmd_node limit_tx0_temp_node = { |
| 157 |
LIMIT_TX0_TEMP_NODE, |
| 158 |
"%s(limit-tx0-temp)# ", |
| 159 |
1, |
| 160 |
}; |
| 161 |
static struct cmd_node limit_tx1_temp_node = { |
| 162 |
LIMIT_TX1_TEMP_NODE, |
| 163 |
"%s(limit-tx1-temp)# ", |
| 164 |
1, |
| 165 |
}; |
| 166 |
static struct cmd_node limit_pa0_temp_node = { |
| 167 |
LIMIT_PA0_TEMP_NODE, |
| 168 |
"%s(limit-pa0-temp)# ", |
| 169 |
1, |
| 170 |
}; |
| 171 |
static struct cmd_node limit_pa1_temp_node = { |
| 172 |
LIMIT_PA1_TEMP_NODE, |
| 173 |
"%s(limit-pa1-temp)# ", |
| 174 |
1, |
| 175 |
}; |
| 176 |
static struct cmd_node limit_supply_volt_node = { |
| 177 |
LIMIT_SUPPLY_VOLT_NODE, |
| 178 |
"%s(limit-supply-volt)# ", |
| 179 |
1, |
| 180 |
}; |
| 181 |
static struct cmd_node limit_tx0_vswr_node = { |
| 182 |
LIMIT_TX0_VSWR_NODE, |
| 183 |
"%s(limit-tx0-vswr)# ", |
| 184 |
1, |
| 185 |
}; |
| 186 |
static struct cmd_node limit_tx1_vswr_node = { |
| 187 |
LIMIT_TX1_VSWR_NODE, |
| 188 |
"%s(limit-tx1-vswr)# ", |
| 189 |
1, |
| 190 |
}; |
| 191 |
static struct cmd_node limit_supply_pwr_node = { |
| 192 |
LIMIT_SUPPLY_PWR_NODE, |
| 193 |
"%s(limit-supply-pwr)# ", |
| 194 |
1, |
| 195 |
}; |
| 196 |
static struct cmd_node limit_pa0_pwr_node = { |
| 197 |
LIMIT_PA0_PWR_NODE, |
| 198 |
"%s(limit-pa0-pwr)# ", |
| 199 |
1, |
| 200 |
}; |
| 201 |
static struct cmd_node limit_pa1_pwr_node = { |
| 202 |
LIMIT_PA1_PWR_NODE, |
| 203 |
"%s(limit-pa1-pwr)# ", |
| 204 |
1, |
| 205 |
}; |
| 206 |
|
| 207 |
static struct cmd_node limit_gps_fix_node = { |
| 208 |
LIMIT_GPS_FIX_NODE, |
| 209 |
"%s(limit-gps-fix)# ", |
| 210 |
1, |
| 211 |
}; |
| 212 |
|
| 213 |
DEFUN(cfg_mgr, cfg_mgr_cmd, |
| 214 |
"lc15bts-mgr", |
| 215 |
MGR_STR) |
| 216 |
{ |
| 217 |
vty->node = MGR_NODE; |
| 218 |
return CMD_SUCCESS; |
| 219 |
} |
| 220 |
|
| 221 |
static void write_volt_limit(struct vty *vty, const char *name, |
| 222 |
struct lc15bts_volt_limit *limit) |
| 223 |
{ |
| 224 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 225 |
vty_out(vty, " threshold warning min %d%s", |
| 226 |
limit->thresh_warn_min, VTY_NEWLINE); |
| 227 |
vty_out(vty, " threshold critical min %d%s", |
| 228 |
limit->thresh_crit_min, VTY_NEWLINE); |
| 229 |
} |
| 230 |
|
| 231 |
static void write_vswr_limit(struct vty *vty, const char *name, |
| 232 |
struct lc15bts_vswr_limit *limit) |
| 233 |
{ |
| 234 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 235 |
vty_out(vty, " threshold warning max %d%s", |
| 236 |
limit->thresh_warn_max, VTY_NEWLINE); |
| 237 |
} |
| 238 |
|
| 239 |
static void write_pwr_limit(struct vty *vty, const char *name, |
| 240 |
struct lc15bts_pwr_limit *limit) |
| 241 |
{ |
| 242 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 243 |
vty_out(vty, " threshold warning max %d%s", |
| 244 |
limit->thresh_warn_max, VTY_NEWLINE); |
| 245 |
vty_out(vty, " threshold critical max %d%s", |
| 246 |
limit->thresh_crit_max, VTY_NEWLINE); |
| 247 |
} |
| 248 |
|
| 249 |
static void write_norm_action(struct vty *vty, const char *name, int actions) |
| 250 |
{ |
| 251 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 252 |
vty_out(vty, " %spa0-on%s", |
| 253 |
(actions & SENSOR_ACT_NORM_PA0_ON) ? "" : "no ", VTY_NEWLINE); |
| 254 |
vty_out(vty, " %spa1-on%s", |
| 255 |
(actions & SENSOR_ACT_NORM_PA1_ON) ? "" : "no ", VTY_NEWLINE); |
| 256 |
vty_out(vty, " %sbts-service-on%s", |
| 257 |
(actions & SENSOR_ACT_NORM_BTS_SRV_ON) ? "" : "no ", VTY_NEWLINE); |
| 258 |
} |
| 259 |
|
| 260 |
static void write_action(struct vty *vty, const char *name, int actions) |
| 261 |
{ |
| 262 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 263 |
vty_out(vty, " %spa0-off%s", |
| 264 |
(actions & SENSOR_ACT_PA0_OFF) ? "" : "no ", VTY_NEWLINE); |
| 265 |
vty_out(vty, " %spa1-off%s", |
| 266 |
(actions & SENSOR_ACT_PA1_OFF) ? "" : "no ", VTY_NEWLINE); |
| 267 |
vty_out(vty, " %sbts-service-off%s", |
| 268 |
(actions & SENSOR_ACT_BTS_SRV_OFF) ? "" : "no ", VTY_NEWLINE); |
| 269 |
} |
| 270 |
|
| 271 |
static int config_write_mgr(struct vty *vty) |
| 272 |
{ |
| 273 |
vty_out(vty, "lc15bts-mgr%s", VTY_NEWLINE); |
| 274 |
|
| 275 |
write_volt_limit(vty, "limits supply_volt", &s_mgr->volt.supply_volt_limit); |
| 276 |
write_pwr_limit(vty, "limits supply_pwr", &s_mgr->pwr.supply_pwr_limit); |
| 277 |
write_vswr_limit(vty, "limits tx0_vswr", &s_mgr->vswr.tx0_vswr_limit); |
| 278 |
write_vswr_limit(vty, "limits tx1_vswr", &s_mgr->vswr.tx1_vswr_limit); |
| 279 |
|
| 280 |
write_norm_action(vty, "actions normal", s_mgr->state.action_norm); |
| 281 |
write_action(vty, "actions warn", s_mgr->state.action_warn); |
| 282 |
write_action(vty, "actions critical", s_mgr->state.action_crit); |
| 283 |
|
| 284 |
return CMD_SUCCESS; |
| 285 |
} |
| 286 |
|
| 287 |
static int config_write_dummy(struct vty *vty) |
| 288 |
{ |
| 289 |
return CMD_SUCCESS; |
| 290 |
} |
| 291 |
|
| 292 |
#define CFG_LIMIT_TEMP(name, expl, switch_to, variable) \ |
| 293 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 294 |
"limits " #name, \ |
| 295 |
"Configure Limits\n" expl) \ |
| 296 |
{ \ |
| 297 |
vty->node = switch_to; \ |
| 298 |
vty->index = &s_mgr->temp.variable; \ |
| 299 |
return CMD_SUCCESS; \ |
| 300 |
} |
| 301 |
|
| 302 |
CFG_LIMIT_TEMP(supply_temp, "SUPPLY TEMP\n", LIMIT_SUPPLY_TEMP_NODE, supply_temp_limit) |
| 303 |
CFG_LIMIT_TEMP(soc_temp, "SOC TEMP\n", LIMIT_SOC_NODE, soc_temp_limit) |
| 304 |
CFG_LIMIT_TEMP(fpga_temp, "FPGA TEMP\n", LIMIT_FPGA_NODE, fpga_temp_limit) |
| 305 |
CFG_LIMIT_TEMP(rmsdet_temp, "RMSDET TEMP\n", LIMIT_RMSDET_NODE, rmsdet_temp_limit) |
| 306 |
CFG_LIMIT_TEMP(ocxo_temp, "OCXO TEMP\n", LIMIT_OCXO_NODE, ocxo_temp_limit) |
| 307 |
CFG_LIMIT_TEMP(tx0_temp, "TX0 TEMP\n", LIMIT_TX0_TEMP_NODE, tx0_temp_limit) |
| 308 |
CFG_LIMIT_TEMP(tx1_temp, "TX1 TEMP\n", LIMIT_TX1_TEMP_NODE, tx1_temp_limit) |
| 309 |
CFG_LIMIT_TEMP(pa0_temp, "PA0 TEMP\n", LIMIT_PA0_TEMP_NODE, pa0_temp_limit) |
| 310 |
CFG_LIMIT_TEMP(pa1_temp, "PA1 TEMP\n", LIMIT_PA1_TEMP_NODE, pa1_temp_limit) |
| 311 |
#undef CFG_LIMIT_TEMP |
| 312 |
|
| 313 |
#define CFG_LIMIT_VOLT(name, expl, switch_to, variable) \ |
| 314 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 315 |
"limits " #name, \ |
| 316 |
"Configure Limits\n" expl) \ |
| 317 |
{ \ |
| 318 |
vty->node = switch_to; \ |
| 319 |
vty->index = &s_mgr->volt.variable; \ |
| 320 |
return CMD_SUCCESS; \ |
| 321 |
} |
| 322 |
|
| 323 |
CFG_LIMIT_VOLT(supply_volt, "SUPPLY VOLT\n", LIMIT_SUPPLY_VOLT_NODE, supply_volt_limit) |
| 324 |
#undef CFG_LIMIT_VOLT |
| 325 |
|
| 326 |
#define CFG_LIMIT_VSWR(name, expl, switch_to, variable) \ |
| 327 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 328 |
"limits " #name, \ |
| 329 |
"Configure Limits\n" expl) \ |
| 330 |
{ \ |
| 331 |
vty->node = switch_to; \ |
| 332 |
vty->index = &s_mgr->vswr.variable; \ |
| 333 |
return CMD_SUCCESS; \ |
| 334 |
} |
| 335 |
|
| 336 |
CFG_LIMIT_VSWR(tx0_vswr, "TX0 VSWR\n", LIMIT_TX0_VSWR_NODE, tx0_vswr_limit) |
| 337 |
CFG_LIMIT_VSWR(tx1_vswr, "TX1 VSWR\n", LIMIT_TX1_VSWR_NODE, tx1_vswr_limit) |
| 338 |
#undef CFG_LIMIT_VSWR |
| 339 |
|
| 340 |
#define CFG_LIMIT_PWR(name, expl, switch_to, variable) \ |
| 341 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 342 |
"limits " #name, \ |
| 343 |
"Configure Limits\n" expl) \ |
| 344 |
{ \ |
| 345 |
vty->node = switch_to; \ |
| 346 |
vty->index = &s_mgr->pwr.variable; \ |
| 347 |
return CMD_SUCCESS; \ |
| 348 |
} |
| 349 |
|
| 350 |
CFG_LIMIT_PWR(supply_pwr, "SUPPLY PWR\n", LIMIT_SUPPLY_PWR_NODE, supply_pwr_limit) |
| 351 |
CFG_LIMIT_PWR(pa0_pwr, "PA0 PWR\n", LIMIT_PA0_PWR_NODE, pa0_pwr_limit) |
| 352 |
CFG_LIMIT_PWR(pa1_pwr, "PA1 PWR\n", LIMIT_PA1_PWR_NODE, pa1_pwr_limit) |
| 353 |
#undef CFG_LIMIT_PWR |
| 354 |
|
| 355 |
#define CFG_LIMIT_GPS_FIX(name, expl, switch_to, variable) \ |
| 356 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 357 |
"limits " #name, \ |
| 358 |
"Configure Limits\n" expl) \ |
| 359 |
{ \ |
| 360 |
vty->node = switch_to; \ |
| 361 |
vty->index = &s_mgr->gps.variable; \ |
| 362 |
return CMD_SUCCESS; \ |
| 363 |
} |
| 364 |
|
| 365 |
CFG_LIMIT_GPS_FIX(gps_fix, "GPS FIX\n", LIMIT_GPS_FIX_NODE, gps_fix_limit) |
| 366 |
#undef CFG_LIMIT_GPS_FIX |
| 367 |
|
| 368 |
DEFUN(cfg_limit_volt_warn_min, cfg_thresh_volt_warn_min_cmd, |
| 369 |
"threshold warning min <0-48000>", |
| 370 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 371 |
{ |
| 372 |
struct lc15bts_volt_limit *limit = vty->index; |
| 373 |
limit->thresh_warn_min = atoi(argv[0]); |
| 374 |
return CMD_SUCCESS; |
| 375 |
} |
| 376 |
|
| 377 |
DEFUN(cfg_limit_volt_crit_min, cfg_thresh_volt_crit_min_cmd, |
| 378 |
"threshold critical min <0-48000>", |
| 379 |
"Threshold to reach\n" "Critical level\n" "Range\n") |
| 380 |
{ |
| 381 |
struct lc15bts_volt_limit *limit = vty->index; |
| 382 |
limit->thresh_crit_min = atoi(argv[0]); |
| 383 |
return CMD_SUCCESS; |
| 384 |
} |
| 385 |
|
| 386 |
DEFUN(cfg_limit_vswr_warn_max, cfg_thresh_vswr_warn_max_cmd, |
| 387 |
"threshold warning max <1000-200000>", |
| 388 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 389 |
{ |
| 390 |
struct lc15bts_vswr_limit *limit = vty->index; |
| 391 |
limit->thresh_warn_max = atoi(argv[0]); |
| 392 |
return CMD_SUCCESS; |
| 393 |
} |
| 394 |
|
| 395 |
DEFUN(cfg_limit_vswr_crit_max, cfg_thresh_vswr_crit_max_cmd, |
| 396 |
"threshold critical max <1000-200000>", |
| 397 |
"Threshold to reach\n" "Critical level\n" "Range\n") |
| 398 |
{ |
| 399 |
struct lc15bts_vswr_limit *limit = vty->index; |
| 400 |
limit->thresh_crit_max = atoi(argv[0]); |
| 401 |
return CMD_SUCCESS; |
| 402 |
} |
| 403 |
|
| 404 |
DEFUN(cfg_limit_pwr_warn_max, cfg_thresh_pwr_warn_max_cmd, |
| 405 |
"threshold warning max <0-200>", |
| 406 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 407 |
{ |
| 408 |
struct lc15bts_pwr_limit *limit = vty->index; |
| 409 |
limit->thresh_warn_max = atoi(argv[0]); |
| 410 |
return CMD_SUCCESS; |
| 411 |
} |
| 412 |
|
| 413 |
DEFUN(cfg_limit_pwr_crit_max, cfg_thresh_pwr_crit_max_cmd, |
| 414 |
"threshold critical max <0-200>", |
| 415 |
"Threshold to reach\n" "Critical level\n" "Range\n") |
| 416 |
{ |
| 417 |
struct lc15bts_pwr_limit *limit = vty->index; |
| 418 |
limit->thresh_crit_max = atoi(argv[0]); |
| 419 |
return CMD_SUCCESS; |
| 420 |
} |
| 421 |
|
| 422 |
#define CFG_ACTION(name, expl, switch_to, variable) \ |
| 423 |
DEFUN(cfg_action_##name, cfg_action_##name##_cmd, \ |
| 424 |
"actions " #name, \ |
| 425 |
"Configure Actions\n" expl) \ |
| 426 |
{ \ |
| 427 |
vty->node = switch_to; \ |
| 428 |
vty->index = &s_mgr->state.variable; \ |
| 429 |
return CMD_SUCCESS; \ |
| 430 |
} |
| 431 |
CFG_ACTION(normal, "Normal Actions\n", ACT_NORM_NODE, action_norm) |
| 432 |
CFG_ACTION(warn, "Warning Actions\n", ACT_WARN_NODE, action_warn) |
| 433 |
CFG_ACTION(critical, "Critical Actions\n", ACT_CRIT_NODE, action_crit) |
| 434 |
#undef CFG_ACTION |
| 435 |
|
| 436 |
DEFUN(cfg_action_pa0_on, cfg_action_pa0_on_cmd, |
| 437 |
"pa0-on", |
| 438 |
"Switch the Power Amplifier #0 on\n") |
| 439 |
{ |
| 440 |
int *action = vty->index; |
| 441 |
*action |= SENSOR_ACT_NORM_PA0_ON; |
| 442 |
return CMD_SUCCESS; |
| 443 |
} |
| 444 |
|
| 445 |
DEFUN(cfg_no_action_pa0_on, cfg_no_action_pa0_on_cmd, |
| 446 |
"no pa0-on", |
| 447 |
NO_STR "Switch the Power Amplifieri #0 on\n") |
| 448 |
{ |
| 449 |
int *action = vty->index; |
| 450 |
*action &= ~SENSOR_ACT_NORM_PA0_ON; |
| 451 |
return CMD_SUCCESS; |
| 452 |
} |
| 453 |
|
| 454 |
DEFUN(cfg_action_pa1_on, cfg_action_pa1_on_cmd, |
| 455 |
"pa1-on", |
| 456 |
"Switch the Power Amplifier #1 on\n") |
| 457 |
{ |
| 458 |
int *action = vty->index; |
| 459 |
*action |= SENSOR_ACT_NORM_PA1_ON; |
| 460 |
return CMD_SUCCESS; |
| 461 |
} |
| 462 |
|
| 463 |
DEFUN(cfg_no_action_pa1_on, cfg_no_action_pa1_on_cmd, |
| 464 |
"no pa1-on", |
| 465 |
NO_STR "Switch the Power Amplifieri #1 on\n") |
| 466 |
{ |
| 467 |
int *action = vty->index; |
| 468 |
*action &= ~SENSOR_ACT_NORM_PA1_ON; |
| 469 |
return CMD_SUCCESS; |
| 470 |
} |
| 471 |
|
| 472 |
DEFUN(cfg_action_bts_srv_on, cfg_action_bts_srv_on_cmd, |
| 473 |
"bts-service-on", |
| 474 |
"Start the systemd lc15bts.service\n") |
| 475 |
{ |
| 476 |
int *action = vty->index; |
| 477 |
*action |= SENSOR_ACT_NORM_BTS_SRV_ON; |
| 478 |
return CMD_SUCCESS; |
| 479 |
} |
| 480 |
|
| 481 |
DEFUN(cfg_no_action_bts_srv_on, cfg_no_action_bts_srv_on_cmd, |
| 482 |
"no bts-service-on", |
| 483 |
NO_STR "Start the systemd lc15bts.service\n") |
| 484 |
{ |
| 485 |
int *action = vty->index; |
| 486 |
*action &= ~SENSOR_ACT_NORM_BTS_SRV_ON; |
| 487 |
return CMD_SUCCESS; |
| 488 |
} |
| 489 |
|
| 490 |
DEFUN(cfg_action_pa0_off, cfg_action_pa0_off_cmd, |
| 491 |
"pa0-off", |
| 492 |
"Switch the Power Amplifier #0 off\n") |
| 493 |
{ |
| 494 |
int *action = vty->index; |
| 495 |
*action |= SENSOR_ACT_PA0_OFF; |
| 496 |
return CMD_SUCCESS; |
| 497 |
} |
| 498 |
|
| 499 |
DEFUN(cfg_no_action_pa0_off, cfg_no_action_pa0_off_cmd, |
| 500 |
"no pa0-off", |
| 501 |
NO_STR "Do not switch off the Power Amplifier #0\n") |
| 502 |
{ |
| 503 |
int *action = vty->index; |
| 504 |
*action &= ~SENSOR_ACT_PA0_OFF; |
| 505 |
return CMD_SUCCESS; |
| 506 |
} |
| 507 |
|
| 508 |
DEFUN(cfg_action_pa1_off, cfg_action_pa1_off_cmd, |
| 509 |
"pa1-off", |
| 510 |
"Switch the Power Amplifier #1 off\n") |
| 511 |
{ |
| 512 |
int *action = vty->index; |
| 513 |
*action |= SENSOR_ACT_PA1_OFF; |
| 514 |
return CMD_SUCCESS; |
| 515 |
} |
| 516 |
|
| 517 |
DEFUN(cfg_no_action_pa1_off, cfg_no_action_pa1_off_cmd, |
| 518 |
"no pa1-off", |
| 519 |
NO_STR "Do not switch off the Power Amplifier #1\n") |
| 520 |
{ |
| 521 |
int *action = vty->index; |
| 522 |
*action &= ~SENSOR_ACT_PA1_OFF; |
| 523 |
return CMD_SUCCESS; |
| 524 |
} |
| 525 |
|
| 526 |
DEFUN(cfg_action_bts_srv_off, cfg_action_bts_srv_off_cmd, |
| 527 |
"bts-service-off", |
| 528 |
"Stop the systemd lc15bts.service\n") |
| 529 |
{ |
| 530 |
int *action = vty->index; |
| 531 |
*action |= SENSOR_ACT_BTS_SRV_OFF; |
| 532 |
return CMD_SUCCESS; |
| 533 |
} |
| 534 |
|
| 535 |
DEFUN(cfg_no_action_bts_srv_off, cfg_no_action_bts_srv_off_cmd, |
| 536 |
"no bts-service-off", |
| 537 |
NO_STR "Stop the systemd lc15bts.service\n") |
| 538 |
{ |
| 539 |
int *action = vty->index; |
| 540 |
*action &= ~SENSOR_ACT_BTS_SRV_OFF; |
| 541 |
return CMD_SUCCESS; |
| 542 |
} |
| 543 |
|
| 544 |
DEFUN(show_mgr, show_mgr_cmd, "show manager", |
| 545 |
SHOW_STR "Display information about the manager") |
| 546 |
{ |
| 547 |
int temp, volt, current, power, vswr; |
| 548 |
vty_out(vty, "Warning alarm flags: 0x%08x%s", |
| 549 |
s_mgr->lc15bts_ctrl.warn_flags, VTY_NEWLINE); |
| 550 |
vty_out(vty, "Critical alarm flags: 0x%08x%s", |
| 551 |
s_mgr->lc15bts_ctrl.crit_flags, VTY_NEWLINE); |
| 552 |
vty_out(vty, "Preventive action retried: %d%s", |
| 553 |
s_mgr->alarms.preventive_retry, VTY_NEWLINE); |
| 554 |
vty_out(vty, "Temperature control state: %s%s", |
| 555 |
lc15bts_mgr_sensor_get_state(s_mgr->state.state), VTY_NEWLINE); |
| 556 |
vty_out(vty, "Current Temperatures%s", VTY_NEWLINE); |
| 557 |
lc15bts_temp_get(LC15BTS_TEMP_SUPPLY, &temp); |
| 558 |
vty_out(vty, " Main Supply : %4.2f Celsius%s", |
| 559 |
temp/ 1000.0f, |
| 560 |
VTY_NEWLINE); |
| 561 |
lc15bts_temp_get(LC15BTS_TEMP_SOC, &temp); |
| 562 |
vty_out(vty, " SoC : %4.2f Celsius%s", |
| 563 |
temp / 1000.0f, |
| 564 |
VTY_NEWLINE); |
| 565 |
lc15bts_temp_get(LC15BTS_TEMP_FPGA, &temp); |
| 566 |
vty_out(vty, " FPGA : %4.2f Celsius%s", |
| 567 |
temp / 1000.0f, |
| 568 |
VTY_NEWLINE); |
| 569 |
lc15bts_temp_get(LC15BTS_TEMP_RMSDET, &temp); |
| 570 |
vty_out(vty, " RMSDet : %4.2f Celsius%s", |
| 571 |
temp / 1000.0f, |
| 572 |
VTY_NEWLINE); |
| 573 |
lc15bts_temp_get(LC15BTS_TEMP_OCXO, &temp); |
| 574 |
vty_out(vty, " OCXO : %4.2f Celsius%s", |
| 575 |
temp / 1000.0f, |
| 576 |
VTY_NEWLINE); |
| 577 |
lc15bts_temp_get(LC15BTS_TEMP_TX0, &temp); |
| 578 |
vty_out(vty, " TX 0 : %4.2f Celsius%s", |
| 579 |
temp / 1000.0f, |
| 580 |
VTY_NEWLINE); |
| 581 |
lc15bts_temp_get(LC15BTS_TEMP_TX1, &temp); |
| 582 |
vty_out(vty, " TX 1 : %4.2f Celsius%s", |
| 583 |
temp / 1000.0f, |
| 584 |
VTY_NEWLINE); |
| 585 |
lc15bts_temp_get(LC15BTS_TEMP_PA0, &temp); |
| 586 |
vty_out(vty, " Power Amp #0: %4.2f Celsius%s", |
| 587 |
temp / 1000.0f, |
| 588 |
VTY_NEWLINE); |
| 589 |
lc15bts_temp_get(LC15BTS_TEMP_PA1, &temp); |
| 590 |
vty_out(vty, " Power Amp #1: %4.2f Celsius%s", |
| 591 |
temp / 1000.0f, |
| 592 |
VTY_NEWLINE); |
| 593 |
|
| 594 |
vty_out(vty, "Power Status%s", VTY_NEWLINE); |
| 595 |
lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, |
| 596 |
LC15BTS_POWER_VOLTAGE, &volt); |
| 597 |
lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, |
| 598 |
LC15BTS_POWER_CURRENT, ¤t); |
| 599 |
lc15bts_power_sensor_get(LC15BTS_POWER_SUPPLY, |
| 600 |
LC15BTS_POWER_POWER, &power); |
| 601 |
vty_out(vty, " Main Supply : ON [%6.2f Vdc, %4.2f A, %6.2f W]%s", |
| 602 |
volt /1000.0f, |
| 603 |
current /1000.0f, |
| 604 |
power /1000000.0f, |
| 605 |
VTY_NEWLINE); |
| 606 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA0, |
| 607 |
LC15BTS_POWER_VOLTAGE, &volt); |
| 608 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA0, |
| 609 |
LC15BTS_POWER_CURRENT, ¤t); |
| 610 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA0, |
| 611 |
LC15BTS_POWER_POWER, &power); |
| 612 |
vty_out(vty, " Power Amp #0: %s [%6.2f Vdc, %4.2f A, %6.2f W]%s", |
| 613 |
lc15bts_power_get(LC15BTS_POWER_PA0) ? "ON " : "OFF", |
| 614 |
volt /1000.0f, |
| 615 |
current /1000.0f, |
| 616 |
power /1000000.0f, |
| 617 |
VTY_NEWLINE); |
| 618 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA1, |
| 619 |
LC15BTS_POWER_VOLTAGE, &volt); |
| 620 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA1, |
| 621 |
LC15BTS_POWER_CURRENT, ¤t); |
| 622 |
lc15bts_power_sensor_get(LC15BTS_POWER_PA1, |
| 623 |
LC15BTS_POWER_POWER, &power); |
| 624 |
vty_out(vty, " Power Amp #1: %s [%6.2f Vdc, %4.2f A, %6.2f W]%s", |
| 625 |
lc15bts_power_get(LC15BTS_POWER_PA1) ? "ON " : "OFF", |
| 626 |
volt /1000.0f, |
| 627 |
current /1000.0f, |
| 628 |
power /1000000.0f, |
| 629 |
VTY_NEWLINE); |
| 630 |
vty_out(vty, "VSWR Status%s", VTY_NEWLINE); |
| 631 |
lc15bts_vswr_get(LC15BTS_VSWR_TX0, &vswr); |
| 632 |
vty_out(vty, " VSWR TX 0: %f %s", |
| 633 |
vswr / 1000.0f, |
| 634 |
VTY_NEWLINE); |
| 635 |
lc15bts_vswr_get(LC15BTS_VSWR_TX1, &vswr); |
| 636 |
vty_out(vty, " VSWR TX 1: %f %s", |
| 637 |
vswr / 1000.0f, |
| 638 |
VTY_NEWLINE); |
| 639 |
|
| 640 |
return CMD_SUCCESS; |
| 641 |
} |
| 642 |
|
| 643 |
DEFUN(show_thresh, show_thresh_cmd, "show thresholds", |
| 644 |
SHOW_STR "Display information about the thresholds") |
| 645 |
{ |
| 646 |
vty_out(vty, "Temperature limits (Celsius)%s", VTY_NEWLINE); |
| 647 |
vty_out(vty, " Main supply%s", VTY_NEWLINE); |
| 648 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.supply_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 649 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 650 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 651 |
vty_out(vty, " SoC%s", VTY_NEWLINE); |
| 652 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.soc_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 653 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.soc_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 654 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.soc_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 655 |
vty_out(vty, " FPGA%s", VTY_NEWLINE); |
| 656 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.fpga_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 657 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.fpga_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 658 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.fpga_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 659 |
vty_out(vty, " RMSDet%s", VTY_NEWLINE); |
| 660 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 661 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 662 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 663 |
vty_out(vty, " OCXO%s", VTY_NEWLINE); |
| 664 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 665 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 666 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 667 |
vty_out(vty, " TX0%s", VTY_NEWLINE); |
| 668 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.tx0_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 669 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.tx0_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 670 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.tx0_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 671 |
vty_out(vty, " TX1%s", VTY_NEWLINE); |
| 672 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.tx1_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 673 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.tx1_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 674 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.tx1_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 675 |
vty_out(vty, " PA0%s", VTY_NEWLINE); |
| 676 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.pa0_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 677 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.pa0_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 678 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.pa0_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 679 |
vty_out(vty, " PA1%s", VTY_NEWLINE); |
| 680 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.pa1_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 681 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.pa1_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 682 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.pa1_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 683 |
vty_out(vty, "Power limits%s", VTY_NEWLINE); |
| 684 |
vty_out(vty, " Main supply (mV)%s", VTY_NEWLINE); |
| 685 |
vty_out(vty, " Critical max : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_max, VTY_NEWLINE); |
| 686 |
vty_out(vty, " Warning max : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_max, VTY_NEWLINE); |
| 687 |
vty_out(vty, " Warning min : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_min, VTY_NEWLINE); |
| 688 |
vty_out(vty, " Critical min : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_min, VTY_NEWLINE); |
| 689 |
vty_out(vty, " Main supply power (W)%s", VTY_NEWLINE); |
| 690 |
vty_out(vty, " Critical max : %d%s",s_mgr->pwr.supply_pwr_limit.thresh_crit_max, VTY_NEWLINE); |
| 691 |
vty_out(vty, " Warning max : %d%s",s_mgr->pwr.supply_pwr_limit.thresh_warn_max, VTY_NEWLINE); |
| 692 |
vty_out(vty, " PA0 power (W)%s", VTY_NEWLINE); |
| 693 |
vty_out(vty, " Critical max : %d%s",s_mgr->pwr.pa0_pwr_limit.thresh_crit_max, VTY_NEWLINE); |
| 694 |
vty_out(vty, " Warning max : %d%s",s_mgr->pwr.pa0_pwr_limit.thresh_warn_max, VTY_NEWLINE); |
| 695 |
vty_out(vty, " PA1 power (W)%s", VTY_NEWLINE); |
| 696 |
vty_out(vty, " Critical max : %d%s",s_mgr->pwr.pa1_pwr_limit.thresh_crit_max, VTY_NEWLINE); |
| 697 |
vty_out(vty, " Warning max : %d%s",s_mgr->pwr.pa1_pwr_limit.thresh_warn_max, VTY_NEWLINE); |
| 698 |
vty_out(vty, "VSWR limits%s", VTY_NEWLINE); |
| 699 |
vty_out(vty, " TX0%s", VTY_NEWLINE); |
| 700 |
vty_out(vty, " Critical max : %d%s",s_mgr->vswr.tx0_vswr_limit.thresh_crit_max, VTY_NEWLINE); |
| 701 |
vty_out(vty, " Warning max : %d%s",s_mgr->vswr.tx0_vswr_limit.thresh_warn_max, VTY_NEWLINE); |
| 702 |
vty_out(vty, " TX1%s", VTY_NEWLINE); |
| 703 |
vty_out(vty, " Critical max : %d%s",s_mgr->vswr.tx1_vswr_limit.thresh_crit_max, VTY_NEWLINE); |
| 704 |
vty_out(vty, " Warning max : %d%s",s_mgr->vswr.tx1_vswr_limit.thresh_warn_max, VTY_NEWLINE); |
| 705 |
vty_out(vty, "Days since last GPS 3D fix%s", VTY_NEWLINE); |
| 706 |
vty_out(vty, " Warning max : %d%s",s_mgr->gps.gps_fix_limit.thresh_warn_max, VTY_NEWLINE); |
| 707 |
|
| 708 |
return CMD_SUCCESS; |
| 709 |
} |
| 710 |
|
| 711 |
DEFUN(calibrate_clock, calibrate_clock_cmd, |
| 712 |
"calibrate clock", |
| 713 |
"Calibration commands\n" |
| 714 |
"Calibrate clock against GPS PPS\n") |
| 715 |
{ |
| 716 |
if (lc15bts_mgr_calib_run(s_mgr) < 0) { |
| 717 |
vty_out(vty, "%%Failed to start calibration.%s", VTY_NEWLINE); |
| 718 |
return CMD_WARNING; |
| 719 |
} |
| 720 |
return CMD_SUCCESS; |
| 721 |
} |
| 722 |
|
| 723 |
DEFUN(set_led_pattern, set_led_pattern_cmd, |
| 724 |
"set led pattern <0-255>", |
| 725 |
"Set LED pattern\n" |
| 726 |
"Set LED pattern for debugging purpose only. This pattern will be overridden after 60 seconds by LED pattern of actual system state\n") |
| 727 |
{ |
| 728 |
int pattern_id = atoi(argv[0]); |
| 729 |
|
| 730 |
if ((pattern_id < 0) || (pattern_id > BLINK_PATTERN_MAX_ITEM)) { |
| 731 |
vty_out(vty, "%%Invalid LED pattern ID. It must be in range of %d..%d %s", 0, BLINK_PATTERN_MAX_ITEM - 1, VTY_NEWLINE); |
| 732 |
return CMD_WARNING; |
| 733 |
} |
| 734 |
|
| 735 |
led_set(s_mgr, pattern_id); |
| 736 |
return CMD_SUCCESS; |
| 737 |
} |
| 738 |
|
| 739 |
DEFUN(force_mgr_state, force_mgr_state_cmd, |
| 740 |
"force manager state <0-255>", |
| 741 |
"Force BTS manager state\n" |
| 742 |
"Force BTS manager state for debugging purpose only\n") |
| 743 |
{ |
| 744 |
int state = atoi(argv[0]); |
| 745 |
|
| 746 |
if ((state < 0) || (state > STATE_CRITICAL)) { |
| 747 |
vty_out(vty, "%%Invalid BTS manager state. It must be in range of %d..%d %s", 0, STATE_CRITICAL, VTY_NEWLINE); |
| 748 |
return CMD_WARNING; |
| 749 |
} |
| 750 |
|
| 751 |
s_mgr->state.state = state; |
| 752 |
return CMD_SUCCESS; |
| 753 |
} |
| 754 |
|
| 755 |
#define LIMIT_TEMP(name, limit, expl, variable, criticity, min_max) \ |
| 756 |
DEFUN(limit_temp_##name##_##variable, limit_temp_##name##_##variable##_cmd, \ |
| 757 |
"limit temp " #name " " #criticity " " #min_max " <-200-200>", \ |
| 758 |
"Limit to reach\n" expl) \ |
| 759 |
{ \ |
| 760 |
s_mgr->temp.limit.variable = atoi(argv[0]); \ |
| 761 |
return CMD_SUCCESS; \ |
| 762 |
} |
| 763 |
|
| 764 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_warn_max, warning, max) |
| 765 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_crit_max, critical, max) |
| 766 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_warn_min, warning, min) |
| 767 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_warn_max, warning, max) |
| 768 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_crit_max, critical, max) |
| 769 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_warn_min, warning, min) |
| 770 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_warn_max, warning, max) |
| 771 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_crit_max, critical, max) |
| 772 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_warn_min, warning, min) |
| 773 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_warn_max, warning, max) |
| 774 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_crit_max, critical, max) |
| 775 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_warn_min, warning, min) |
| 776 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_warn_max, warning, max) |
| 777 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_crit_max, critical, max) |
| 778 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_warn_min, warning, min) |
| 779 |
LIMIT_TEMP(tx0, tx0_temp_limit, "TX0 TEMP\n", thresh_warn_max, warning, max) |
| 780 |
LIMIT_TEMP(tx0, tx0_temp_limit, "TX0 TEMP\n", thresh_crit_max, critical, max) |
| 781 |
LIMIT_TEMP(tx0, tx0_temp_limit, "TX0 TEMP\n", thresh_warn_min, warning, min) |
| 782 |
LIMIT_TEMP(tx1, tx1_temp_limit, "TX1 TEMP\n", thresh_warn_max, warning, max) |
| 783 |
LIMIT_TEMP(tx1, tx1_temp_limit, "TX1 TEMP\n", thresh_crit_max, critical, max) |
| 784 |
LIMIT_TEMP(tx1, tx1_temp_limit, "TX1 TEMP\n", thresh_warn_min, warning, min) |
| 785 |
LIMIT_TEMP(pa0, pa0_temp_limit, "PA0 TEMP\n", thresh_warn_max, warning, max) |
| 786 |
LIMIT_TEMP(pa0, pa0_temp_limit, "PA0 TEMP\n", thresh_crit_max, critical, max) |
| 787 |
LIMIT_TEMP(pa0, pa0_temp_limit, "PA0 TEMP\n", thresh_warn_min, warning, min) |
| 788 |
LIMIT_TEMP(pa1, pa1_temp_limit, "PA1 TEMP\n", thresh_warn_max, warning, max) |
| 789 |
LIMIT_TEMP(pa1, pa1_temp_limit, "PA1 TEMP\n", thresh_crit_max, critical, max) |
| 790 |
LIMIT_TEMP(pa1, pa1_temp_limit, "PA1 TEMP\n", thresh_warn_min, warning, min) |
| 791 |
#undef LIMIT_TEMP |
| 792 |
|
| 793 |
#define LIMIT_VOLT(name, limit, expl, variable, criticity, min_max) \ |
| 794 |
DEFUN(limit_volt_##name##_##variable, limit_volt_##name##_##variable##_cmd, \ |
| 795 |
"limit " #name " " #criticity " " #min_max " <0-48000>", \ |
| 796 |
"Limit to reach\n" expl) \ |
| 797 |
{ \ |
| 798 |
s_mgr->volt.limit.variable = atoi(argv[0]); \ |
| 799 |
return CMD_SUCCESS; \ |
| 800 |
} |
| 801 |
|
| 802 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_warn_max, warning, max) |
| 803 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_crit_max, critical, max) |
| 804 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_warn_min, warning, min) |
| 805 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_crit_min, critical, min) |
| 806 |
#undef LIMIT_VOLT |
| 807 |
|
| 808 |
#define LIMIT_PWR(name, limit, expl, variable, criticity, min_max) \ |
| 809 |
DEFUN(limit_pwr_##name##_##variable, limit_pwr_##name##_##variable##_cmd, \ |
| 810 |
"limit power " #name " " #criticity " " #min_max " <0-200>", \ |
| 811 |
"Limit to reach\n" expl) \ |
| 812 |
{ \ |
| 813 |
s_mgr->pwr.limit.variable = atoi(argv[0]); \ |
| 814 |
return CMD_SUCCESS; \ |
| 815 |
} |
| 816 |
|
| 817 |
LIMIT_PWR(supply, supply_pwr_limit, "SUPPLY PWR\n", thresh_warn_max, warning, max) |
| 818 |
LIMIT_PWR(supply, supply_pwr_limit, "SUPPLY PWR\n", thresh_crit_max, critical, max) |
| 819 |
LIMIT_PWR(pa0, pa0_pwr_limit, "PA0 PWR\n", thresh_warn_max, warning, max) |
| 820 |
LIMIT_PWR(pa0, pa0_pwr_limit, "PA0 PWR\n", thresh_crit_max, critical, max) |
| 821 |
LIMIT_PWR(pa1, pa1_pwr_limit, "PA1 PWR\n", thresh_warn_max, warning, max) |
| 822 |
LIMIT_PWR(pa1, pa1_pwr_limit, "PA1 PWR\n", thresh_crit_max, critical, max) |
| 823 |
#undef LIMIT_PWR |
| 824 |
|
| 825 |
#define LIMIT_VSWR(name, limit, expl, variable, criticity, min_max) \ |
| 826 |
DEFUN(limit_vswr_##name##_##variable, limit_vswr_##name##_##variable##_cmd, \ |
| 827 |
"limit vswr " #name " " #criticity " " #min_max " <1000-200000>", \ |
| 828 |
"Limit to reach\n" expl) \ |
| 829 |
{ \ |
| 830 |
s_mgr->vswr.limit.variable = atoi(argv[0]); \ |
| 831 |
return CMD_SUCCESS; \ |
| 832 |
} |
| 833 |
|
| 834 |
LIMIT_VSWR(tx0, tx0_vswr_limit, "TX0 VSWR\n", thresh_warn_max, warning, max) |
| 835 |
LIMIT_VSWR(tx0, tx0_vswr_limit, "TX0 VSWR\n", thresh_crit_max, critical, max) |
| 836 |
LIMIT_VSWR(tx1, tx1_vswr_limit, "TX1 VSWR\n", thresh_warn_max, warning, max) |
| 837 |
LIMIT_VSWR(tx1, tx1_vswr_limit, "TX1 VSWR\n", thresh_crit_max, critical, max) |
| 838 |
#undef LIMIT_VSWR |
| 839 |
|
| 840 |
#define LIMIT_GPSFIX(limit, expl, variable, criticity, min_max) \ |
| 841 |
DEFUN(limit_gpsfix_##variable, limit_gpsfix_##variable##_cmd, \ |
| 842 |
"limit gpsfix " #criticity " " #min_max " <0-365>", \ |
| 843 |
"Limit to reach\n" expl) \ |
| 844 |
{ \ |
| 845 |
s_mgr->gps.limit.variable = atoi(argv[0]); \ |
| 846 |
return CMD_SUCCESS; \ |
| 847 |
} |
| 848 |
|
| 849 |
LIMIT_GPSFIX(gps_fix_limit, "GPS FIX\n", thresh_warn_max, warning, max) |
| 850 |
#undef LIMIT_GPSFIX |
| 851 |
|
| 852 |
static void register_limit(int limit, uint32_t unit) |
| 853 |
{ |
| 854 |
switch (unit) { |
| 855 |
case MGR_LIMIT_TYPE_VOLT: |
| 856 |
install_element(limit, &cfg_thresh_volt_warn_min_cmd); |
| 857 |
install_element(limit, &cfg_thresh_volt_crit_min_cmd); |
| 858 |
break; |
| 859 |
case MGR_LIMIT_TYPE_VSWR: |
| 860 |
install_element(limit, &cfg_thresh_vswr_warn_max_cmd); |
| 861 |
install_element(limit, &cfg_thresh_vswr_crit_max_cmd); |
| 862 |
break; |
| 863 |
case MGR_LIMIT_TYPE_PWR: |
| 864 |
install_element(limit, &cfg_thresh_pwr_warn_max_cmd); |
| 865 |
install_element(limit, &cfg_thresh_pwr_crit_max_cmd); |
| 866 |
break; |
| 867 |
default: |
| 868 |
break; |
| 869 |
} |
| 870 |
} |
| 871 |
|
| 872 |
static void register_normal_action(int act) |
| 873 |
{ |
| 874 |
install_element(act, &cfg_action_pa0_on_cmd); |
| 875 |
install_element(act, &cfg_no_action_pa0_on_cmd); |
| 876 |
install_element(act, &cfg_action_pa1_on_cmd); |
| 877 |
install_element(act, &cfg_no_action_pa1_on_cmd); |
| 878 |
install_element(act, &cfg_action_bts_srv_on_cmd); |
| 879 |
install_element(act, &cfg_no_action_bts_srv_on_cmd); |
| 880 |
} |
| 881 |
|
| 882 |
static void register_action(int act) |
| 883 |
{ |
| 884 |
install_element(act, &cfg_action_pa0_off_cmd); |
| 885 |
install_element(act, &cfg_no_action_pa0_off_cmd); |
| 886 |
install_element(act, &cfg_action_pa1_off_cmd); |
| 887 |
install_element(act, &cfg_no_action_pa1_off_cmd); |
| 888 |
install_element(act, &cfg_action_bts_srv_off_cmd); |
| 889 |
install_element(act, &cfg_no_action_bts_srv_off_cmd); |
| 890 |
} |
| 891 |
|
| 892 |
static void register_hidden_commands() |
| 893 |
{ |
| 894 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_warn_max_cmd); |
| 895 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_crit_max_cmd); |
| 896 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_warn_min_cmd); |
| 897 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_warn_max_cmd); |
| 898 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_crit_max_cmd); |
| 899 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_warn_min_cmd); |
| 900 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_warn_max_cmd); |
| 901 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_crit_max_cmd); |
| 902 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_warn_min_cmd); |
| 903 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_warn_max_cmd); |
| 904 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_crit_max_cmd); |
| 905 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_warn_min_cmd); |
| 906 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_warn_max_cmd); |
| 907 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_crit_max_cmd); |
| 908 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_warn_min_cmd); |
| 909 |
install_element(ENABLE_NODE, &limit_temp_tx0_thresh_warn_max_cmd); |
| 910 |
install_element(ENABLE_NODE, &limit_temp_tx0_thresh_crit_max_cmd); |
| 911 |
install_element(ENABLE_NODE, &limit_temp_tx0_thresh_warn_min_cmd); |
| 912 |
install_element(ENABLE_NODE, &limit_temp_tx1_thresh_warn_max_cmd); |
| 913 |
install_element(ENABLE_NODE, &limit_temp_tx1_thresh_crit_max_cmd); |
| 914 |
install_element(ENABLE_NODE, &limit_temp_tx1_thresh_warn_min_cmd); |
| 915 |
install_element(ENABLE_NODE, &limit_temp_pa0_thresh_warn_max_cmd); |
| 916 |
install_element(ENABLE_NODE, &limit_temp_pa0_thresh_crit_max_cmd); |
| 917 |
install_element(ENABLE_NODE, &limit_temp_pa0_thresh_warn_min_cmd); |
| 918 |
install_element(ENABLE_NODE, &limit_temp_pa1_thresh_warn_max_cmd); |
| 919 |
install_element(ENABLE_NODE, &limit_temp_pa1_thresh_crit_max_cmd); |
| 920 |
install_element(ENABLE_NODE, &limit_temp_pa1_thresh_warn_min_cmd); |
| 921 |
|
| 922 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_warn_max_cmd); |
| 923 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_crit_max_cmd); |
| 924 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_warn_min_cmd); |
| 925 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_crit_min_cmd); |
| 926 |
|
| 927 |
install_element(ENABLE_NODE, &limit_pwr_supply_thresh_warn_max_cmd); |
| 928 |
install_element(ENABLE_NODE, &limit_pwr_supply_thresh_crit_max_cmd); |
| 929 |
install_element(ENABLE_NODE, &limit_pwr_pa0_thresh_warn_max_cmd); |
| 930 |
install_element(ENABLE_NODE, &limit_pwr_pa0_thresh_crit_max_cmd); |
| 931 |
install_element(ENABLE_NODE, &limit_pwr_pa1_thresh_warn_max_cmd); |
| 932 |
install_element(ENABLE_NODE, &limit_pwr_pa1_thresh_crit_max_cmd); |
| 933 |
|
| 934 |
install_element(ENABLE_NODE, &limit_vswr_tx0_thresh_warn_max_cmd); |
| 935 |
install_element(ENABLE_NODE, &limit_vswr_tx0_thresh_crit_max_cmd); |
| 936 |
install_element(ENABLE_NODE, &limit_vswr_tx1_thresh_warn_max_cmd); |
| 937 |
install_element(ENABLE_NODE, &limit_vswr_tx1_thresh_crit_max_cmd); |
| 938 |
|
| 939 |
install_element(ENABLE_NODE, &limit_gpsfix_thresh_warn_max_cmd); |
| 940 |
} |
| 941 |
|
| 942 |
int lc15bts_mgr_vty_init(void) |
| 943 |
{ |
| 944 |
vty_init(&vty_info); |
| 945 |
|
| 946 |
install_element_ve(&show_mgr_cmd); |
| 947 |
install_element_ve(&show_thresh_cmd); |
| 948 |
|
| 949 |
install_element(ENABLE_NODE, &calibrate_clock_cmd); |
| 950 |
|
| 951 |
install_node(&mgr_node, config_write_mgr); |
| 952 |
install_element(CONFIG_NODE, &cfg_mgr_cmd); |
| 953 |
|
| 954 |
|
| 955 |
install_node(&limit_supply_temp_node, config_write_dummy); |
| 956 |
install_element(MGR_NODE, &cfg_limit_supply_temp_cmd); |
| 957 |
|
| 958 |
install_node(&limit_soc_node, config_write_dummy); |
| 959 |
install_element(MGR_NODE, &cfg_limit_soc_temp_cmd); |
| 960 |
|
| 961 |
install_node(&limit_fpga_node, config_write_dummy); |
| 962 |
install_element(MGR_NODE, &cfg_limit_fpga_temp_cmd); |
| 963 |
|
| 964 |
install_node(&limit_rmsdet_node, config_write_dummy); |
| 965 |
install_element(MGR_NODE, &cfg_limit_rmsdet_temp_cmd); |
| 966 |
|
| 967 |
install_node(&limit_ocxo_node, config_write_dummy); |
| 968 |
install_element(MGR_NODE, &cfg_limit_ocxo_temp_cmd); |
| 969 |
|
| 970 |
install_node(&limit_tx0_temp_node, config_write_dummy); |
| 971 |
install_element(MGR_NODE, &cfg_limit_tx0_temp_cmd); |
| 972 |
|
| 973 |
install_node(&limit_tx1_temp_node, config_write_dummy); |
| 974 |
install_element(MGR_NODE, &cfg_limit_tx1_temp_cmd); |
| 975 |
|
| 976 |
install_node(&limit_pa0_temp_node, config_write_dummy); |
| 977 |
install_element(MGR_NODE, &cfg_limit_pa0_temp_cmd); |
| 978 |
|
| 979 |
install_node(&limit_pa1_temp_node, config_write_dummy); |
| 980 |
install_element(MGR_NODE, &cfg_limit_pa1_temp_cmd); |
| 981 |
|
| 982 |
install_node(&limit_supply_volt_node, config_write_dummy); |
| 983 |
install_element(MGR_NODE, &cfg_limit_supply_volt_cmd); |
| 984 |
register_limit(LIMIT_SUPPLY_VOLT_NODE, MGR_LIMIT_TYPE_VOLT); |
| 985 |
|
| 986 |
install_node(&limit_tx0_vswr_node, config_write_dummy); |
| 987 |
install_element(MGR_NODE, &cfg_limit_tx0_vswr_cmd); |
| 988 |
register_limit(LIMIT_TX0_VSWR_NODE, MGR_LIMIT_TYPE_VSWR); |
| 989 |
|
| 990 |
install_node(&limit_tx1_vswr_node, config_write_dummy); |
| 991 |
install_element(MGR_NODE, &cfg_limit_tx1_vswr_cmd); |
| 992 |
register_limit(LIMIT_TX1_VSWR_NODE, MGR_LIMIT_TYPE_VSWR); |
| 993 |
|
| 994 |
install_node(&limit_supply_pwr_node, config_write_dummy); |
| 995 |
install_element(MGR_NODE, &cfg_limit_supply_pwr_cmd); |
| 996 |
register_limit(LIMIT_SUPPLY_PWR_NODE, MGR_LIMIT_TYPE_PWR); |
| 997 |
|
| 998 |
install_node(&limit_pa0_pwr_node, config_write_dummy); |
| 999 |
install_element(MGR_NODE, &cfg_limit_pa0_pwr_cmd); |
| 1000 |
register_limit(LIMIT_PA0_PWR_NODE, MGR_LIMIT_TYPE_PWR); |
| 1001 |
|
| 1002 |
install_node(&limit_pa1_pwr_node, config_write_dummy); |
| 1003 |
install_element(MGR_NODE, &cfg_limit_pa1_pwr_cmd); |
| 1004 |
register_limit(LIMIT_PA1_PWR_NODE, MGR_LIMIT_TYPE_PWR); |
| 1005 |
|
| 1006 |
install_node(&limit_gps_fix_node, config_write_dummy); |
| 1007 |
install_element(MGR_NODE, &cfg_limit_gps_fix_cmd); |
| 1008 |
|
| 1009 |
|
| 1010 |
install_node(&act_norm_node, config_write_dummy); |
| 1011 |
install_element(MGR_NODE, &cfg_action_normal_cmd); |
| 1012 |
register_normal_action(ACT_NORM_NODE); |
| 1013 |
|
| 1014 |
|
| 1015 |
install_node(&act_warn_node, config_write_dummy); |
| 1016 |
install_element(MGR_NODE, &cfg_action_warn_cmd); |
| 1017 |
register_action(ACT_WARN_NODE); |
| 1018 |
|
| 1019 |
install_node(&act_crit_node, config_write_dummy); |
| 1020 |
install_element(MGR_NODE, &cfg_action_critical_cmd); |
| 1021 |
register_action(ACT_CRIT_NODE); |
| 1022 |
|
| 1023 |
|
| 1024 |
install_element_ve(&set_led_pattern_cmd); |
| 1025 |
install_element_ve(&force_mgr_state_cmd); |
| 1026 |
|
| 1027 |
register_hidden_commands(); |
| 1028 |
|
| 1029 |
return 0; |
| 1030 |
} |
| 1031 |
|
| 1032 |
int lc15bts_mgr_parse_config(struct lc15bts_mgr_instance *manager) |
| 1033 |
{ |
| 1034 |
int rc; |
| 1035 |
|
| 1036 |
s_mgr = manager; |
| 1037 |
rc = vty_read_config_file(s_mgr->config_file, NULL); |
| 1038 |
if (rc < 0) { |
| 1039 |
fprintf(stderr, "Failed to parse the config file: '%s'\n", |
| 1040 |
s_mgr->config_file); |
| 1041 |
return rc; |
| 1042 |
} |
| 1043 |
|
| 1044 |
return 0; |
| 1045 |
} |