aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-31 20:56:18 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-08-21 16:25:07 +0200
commitb1ceb403630d093c364736def15b7c9f48f6fed0 (patch)
tree7ccf4227e0d4e9cd101ff8f971045ef2c97e8aa4 /src
parent3ecb2bb60472ea291a5f13b4babe6fd9a7fba028 (diff)
sysmobts: Read the model number and trx once from the device
Use it for the ipaccess-find response and for the sysmobts classification code. This can be used by the vty in a second.
Diffstat (limited to 'src')
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr.c44
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c17
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.h3
3 files changed, 43 insertions, 21 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
index 2864ec9b..eb15c63f 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -44,11 +44,44 @@
#include "misc/sysmobts_nl.h"
#include "misc/sysmobts_par.h"
+static int bts_type;
+static int trx_number;
+
static int no_eeprom_write = 0;
static int daemonize = 0;
static const char *cfgfile = "sysmobts-mgr.cfg";
void *tall_mgr_ctx;
+
+static int classify_bts(void)
+{
+ int rc;
+
+ rc = sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &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);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to get the trx number.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int is_sbts2050(void)
+{
+ return bts_type == 2050;
+}
+
+int is_sbts2050_trx(int trx)
+{
+ return trx_number == trx;
+}
+
static struct osmo_timer_list temp_timer;
static void check_temp_timer_cb(void *unused)
{
@@ -221,7 +254,6 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd,
if (!fetched_info) {
uint8_t mac[6];
- int val;
/* fetch the MAC */
sysmobts_par_get_buf(SYSMOBTS_PAR_MAC, mac, sizeof(mac));
@@ -230,18 +262,16 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd,
mac[3], mac[4], mac[5]);
/* fetch the model and trx number */
- sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val);
- switch(val) {
+ switch(bts_type) {
case 0:
case 0xffff:
case 1002:
model_name = "sysmoBTS 1002";
break;
case 2050:
- sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val);
- if (val == 0)
+ if (trx_number == 0)
model_name = "sysmoBTS 2050 (master)";
- else if (val == 1)
+ else if (trx_number == 1)
model_name = "sysmoBTS 2050 (slave)";
else
model_name = "sysmoBTS 2050 (unknown)";
@@ -322,6 +352,8 @@ int main(int argc, char **argv)
msgb_set_talloc_ctx(tall_msgb_ctx);
mgr_log_init();
+ if (classify_bts() != 0)
+ exit(2);
osmo_init_ignore_signals();
signal(SIGINT, &signal_handler);
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
index e5a2c800..3d1db152 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_2050.c
@@ -313,23 +313,10 @@ static void check_uctemp_timer_cb(void *data)
void sbts2050_uc_initialize(void)
{
- int val;
-
- if (sysmobts_par_get_int(SYSMOBTS_PAR_MODEL_NR, &val) < 0) {
- LOGP(DTEMP, LOGL_ERROR,
- "Failed to get Model number\n");
- return;
- }
-
- if (val != 2050)
- return;
-
- if (sysmobts_par_get_int(SYSMOBTS_PAR_TRX_NR, &val) < 0) {
- LOGP(DTEMP, LOGL_ERROR, "Failed to get the TRX number\n");
+ if (!is_sbts2050())
return;
- }
- if (val != 0)
+ if (!is_sbts2050_trx(0))
return;
ucontrol0.fd = osmo_serial_init(ucontrol0.path, 115200);
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.h b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
index f3b85c2c..baa39889 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.h
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.h
@@ -43,6 +43,9 @@ enum sysmobts_firmware_type {
int sysmobts_firmware_reload(enum sysmobts_firmware_type type);
+int is_sbts2050(void);
+int is_sbts2050_trx(int);
+
void sbts2050_uc_check_temp(int *temp_pa, int *temp_board);
void sbts2050_uc_set_power(int pmaster, int pslave, int ppa);
int sbts2050_uc_get_status(enum sbts2050_status_rqt status);