summaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc/osmo_bsc_vty.c
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2012-05-14 18:43:23 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-01-15 16:53:51 +0100
commit7d109838650e1c1d234677efab6b8a426d287dec (patch)
treed381966e828737043493890fb2da342b525c3d29 /openbsc/src/osmo-bsc/osmo_bsc_vty.c
parent2a896070a744327968770d3f9c23e6e5410f6f57 (diff)
osmo-bsc: Add VTY command show position
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_vty.c')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index 8cd80f9..fb38848 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -24,6 +24,8 @@
#include <osmocom/core/talloc.h>
+#include <time.h>
+
#define IPA_STR "IP.ACCESS specific\n"
@@ -512,6 +514,45 @@ DEFUN(show_mscs,
return CMD_SUCCESS;
}
+DEFUN(show_pos,
+ show_pos_cmd,
+ "show position",
+ SHOW_STR "Position information of the BTS\n")
+{
+ struct gsm_bts *bts;
+ struct bts_location *curloc;
+ struct tm time;
+ char timestr[50];
+
+ llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+ if (llist_empty(&bts->loc_list)) {
+ vty_out(vty, "BTS Nr: %d position invalid%s", bts->nr,
+ VTY_NEWLINE);
+ continue;
+ }
+ curloc = llist_entry(bts->loc_list.next, struct bts_location, list);
+ if (gmtime_r(&curloc->tstamp, &time) == NULL) {
+ vty_out(vty, "Time conversion failed for BTS %d%s", bts->nr,
+ VTY_NEWLINE);
+ continue;
+ }
+ if (asctime_r(&time, timestr) == NULL) {
+ vty_out(vty, "Time conversion failed for BTS %d%s", bts->nr,
+ VTY_NEWLINE);
+ continue;
+ }
+ /* Last character in asctime is \n */
+ timestr[strlen(timestr)-1] = 0;
+
+ vty_out(vty, "BTS Nr: %d position: %s time: %s%s", bts->nr,
+ get_value_string(bts_loc_fix_names, curloc->valid), timestr,
+ VTY_NEWLINE);
+ vty_out(vty, " lat: %f lon: %f height: %f%s", curloc->lat, curloc->lon,
+ curloc->height, VTY_NEWLINE);
+ }
+ return CMD_SUCCESS;
+}
+
int bsc_vty_init_extra(void)
{
install_element(CONFIG_NODE, &cfg_net_msc_cmd);
@@ -551,6 +592,7 @@ int bsc_vty_init_extra(void)
install_element_ve(&show_statistics_cmd);
install_element_ve(&show_mscs_cmd);
+ install_element_ve(&show_pos_cmd);
return 0;
}