aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/utils.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-06-20 17:18:38 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-06-24 08:17:12 +0200
commitf169a75fc41c2474bb0602d5f6b6401213f03633 (patch)
tree84917f00cda01e84bf5ee476accbd5e230c52293 /src/osmo-bts-sysmo/utils.c
parent43b4176f0e0e4d1e73463e9ff21a69e6e2848215 (diff)
sysmobts: Introduce an auto-band config to ease DCS/DCS, PCS/PCS changes
During development one switches from GSM900 to GSM1800 and GSM850 to GSM1900. This commit attempts to make this switch more easy. GSM1800 and GSM1900 have overlapping ARFCNs. This means that the mapping from bands to arfcn is not injective. Because of that I removed the code to deduce the band from the ARFCN. This was done in commit 8c3d807b3fc785ffb18aeb97355150c92221e8a0. The auto-band option allows to move between GSM900/GSM1800 and GSM850/GSM1900. Add a simple testcase with these auto-band configurations.
Diffstat (limited to 'src/osmo-bts-sysmo/utils.c')
-rw-r--r--src/osmo-bts-sysmo/utils.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c
new file mode 100644
index 00000000..d3ee872c
--- /dev/null
+++ b/src/osmo-bts-sysmo/utils.c
@@ -0,0 +1,87 @@
+/*
+ * Helper utilities that are used in OML
+ *
+ * (C) 2011 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2013 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "utils.h"
+
+#include <osmo-bts/bts.h>
+
+#include "femtobts.h"
+
+static int band_osmo2femto(enum gsm_band osmo_band)
+{
+ switch (osmo_band) {
+ case GSM_BAND_850:
+ return GsmL1_FreqBand_850;
+ case GSM_BAND_900:
+ return GsmL1_FreqBand_900;
+ case GSM_BAND_1800:
+ return GsmL1_FreqBand_1800;
+ case GSM_BAND_1900:
+ return GsmL1_FreqBand_1900;
+ default:
+ return -1;
+ }
+}
+
+/**
+ * Select the band that matches the ARFCN. In general the ARFCNs
+ * for GSM1800 and GSM1900 overlap and one needs to specify the
+ * rightband. When moving between GSM900/GSM1800 and GSM850/1900
+ * modifying the BTS configuration is a bit annoying. The auto-band
+ * configuration allows to ease with this transition.
+ */
+int sysmobts_select_femto_band(struct gsm_bts *bts, uint16_t arfcn)
+{
+ enum gsm_band band;
+ struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
+
+ if (!btsb->auto_band)
+ return band_osmo2femto(bts->band);
+
+ /*
+ * We need to check what will happen now.
+ */
+ band = gsm_arfcn2band(arfcn);
+
+ /* if we are already on the right band return */
+ if (band == bts->band)
+ return band_osmo2femto(bts->band);
+
+ /* Check if it is GSM1800/GSM1900 */
+ if (band == GSM_BAND_1800 && bts->band == GSM_BAND_1900)
+ return band_osmo2femto(bts->band);
+
+ /*
+ * Now to the actual autobauding. We just want DCS/DCS and
+ * PCS/PCS for PCS we check for 850/1800 though
+ */
+ if ((band == GSM_BAND_900 && bts->band == GSM_BAND_1800)
+ || (band == GSM_BAND_1800 && bts->band == GSM_BAND_900)
+ || (band == GSM_BAND_850 && bts->band == GSM_BAND_1900))
+ return band_osmo2femto(band);
+ if (band == GSM_BAND_1800 && bts->band == GSM_BAND_850)
+ return band_osmo2femto(GSM_BAND_1900);
+
+ /* give up */
+ return -1;
+}