From 2d848a061e5dd82ca95d1e18e5f1a5f615653a6c Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 10 May 2017 15:56:22 +0200 Subject: Prepare for BTS attribute reporting via OML * move BTS model name resolution into separate function * add convenience wrappers for BTS type and number fo TRX and use then in L1 interface Change-Id: I4649100df8f1b8e095f210fc294567ba014c0b6a Related: OS#1614 --- src/osmo-bts-sysmo/l1_if.c | 4 ++-- src/osmo-bts-sysmo/misc/sysmobts_mgr.c | 4 ++-- src/osmo-bts-sysmo/misc/sysmobts_mgr_nl.c | 21 +-------------------- src/osmo-bts-sysmo/misc/sysmobts_par.c | 31 +++++++++++++++++++++++++++++++ src/osmo-bts-sysmo/misc/sysmobts_par.h | 4 +++- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 8eb6fcc6..85fa3d75 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -1553,7 +1553,7 @@ static int get_hwinfo_eeprom(struct femtol1_hdl *fl1h) eeprom_SysInfo_t sysinfo; int val, rc; - rc = sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val); + rc = sysmobts_get_type(&val); if (rc < 0) return rc; fl1h->hw_info.model_nr = val; @@ -1563,7 +1563,7 @@ static int get_hwinfo_eeprom(struct femtol1_hdl *fl1h) return rc; fl1h->hw_info.model_flags = val; - rc = sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val); + rc = sysmobts_get_trx(&val); if (rc < 0) return rc; fl1h->hw_info.trx_nr = val; diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index e9c59bca..6fadf0f6 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -90,13 +90,13 @@ static int classify_bts(void) { int rc; - rc = sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &bts_type); + rc = sysmobts_get_type(&bts_type); if (rc < 0) { fprintf(stderr, "Failed to get model number.\n"); return -1; } - rc = sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &trx_number); + rc = sysmobts_get_trx(&trx_number); if (rc < 0) { fprintf(stderr, "Failed to get the trx number.\n"); return -1; diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_nl.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_nl.c index f41bec23..48a03124 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_nl.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_nl.c @@ -108,26 +108,7 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd, snprintf(ser_str, sizeof(ser_str), "%d", serno); /* fetch the model and trx number */ - switch(sysmobts_bts_type()) { - case 0: - case 0xffff: - case 1002: - model_name = "sysmoBTS 1002"; - break; - case 2050: - if (sysmobts_trx_number() == 0) - model_name = "sysmoBTS 2050 (master)"; - else if (sysmobts_trx_number() == 1) - model_name = "sysmoBTS 2050 (slave)"; - else - model_name = "sysmoBTS 2050 (unknown)"; - break; - default: - model_name = "Unknown"; - break; - } - - + model_name = sysmobts_model(sysmobts_bts_type(), sysmobts_trx_number()); fetched_info = 1; } diff --git a/src/osmo-bts-sysmo/misc/sysmobts_par.c b/src/osmo-bts-sysmo/misc/sysmobts_par.c index 98fe02b5..de81fff5 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_par.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_par.c @@ -324,6 +324,37 @@ int sysmobts_par_get_net(struct sysmobts_net_cfg *cfg) return 0; } +int sysmobts_get_type(int *bts_type) +{ + return sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, bts_type); +} + +int sysmobts_get_trx(int *trx_number) +{ + return sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, trx_number); +} + +char *sysmobts_model(int bts_type, int trx_num) +{ + switch(bts_type) { + case 0: + case 0xffff: + case 1002: + return "sysmoBTS 1002"; + case 2050: + switch(trx_num) { + case 0: + return "sysmoBTS 2050 (master)"; + case 1: + return "sysmoBTS 2050 (slave)"; + default: + return "sysmoBTS 2050 (unknown)"; + } + default: + return "Unknown"; + } +} + int sysmobts_par_set_net(struct sysmobts_net_cfg *cfg) { struct sysmobts_eeprom *ee = get_eeprom(1); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_par.h b/src/osmo-bts-sysmo/misc/sysmobts_par.h index 5a603cc0..52bf67df 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_par.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_par.h @@ -30,7 +30,9 @@ int sysmobts_par_set_buf(enum sysmobts_par par, const uint8_t *buf, unsigned int size); int sysmobts_par_get_net(struct sysmobts_net_cfg *cfg); int sysmobts_par_set_net(struct sysmobts_net_cfg *cfg); - +int sysmobts_get_type(int *bts_type); +int sysmobts_get_trx(int *trx_number); +char *sysmobts_model(int bts_type, int trx_num); int sysmobts_par_is_int(enum sysmobts_par par); #endif -- cgit v1.2.3