diff cmu200/band.c @ 2:e2db512abbee

fc-cmu200d: band and ARFCN tables implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 May 2017 06:37:56 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmu200/band.c	Sun May 21 06:37:56 2017 +0000
@@ -0,0 +1,65 @@
+/*
+ * Our band and ARFCN tables and lookup code live here.
+ */
+
+#include <string.h>
+#include <strings.h>
+#include "band.h"
+#include "secaddr.h"
+
+struct arfcn_range band850_arfcn_range =     {128,  251,  824200,  869200};
+struct arfcn_range band900_arfcn_range =     {  0,  124,  890000,  935000};
+struct arfcn_range band900_arfcn_range_ext = {975, 1023,  880200,  925200};
+struct arfcn_range band1800_arfcn_range =    {512,  885, 1710200, 1805200};
+struct arfcn_range band1900_arfcn_range =    {512,  810, 1850200, 1930200};
+
+struct band supported_bands[] = {
+	{"850",  SECADDR_GSM850MS_NSIG,  &band850_arfcn_range,  0},
+	{"900",  SECADDR_GSM900MS_NSIG,  &band900_arfcn_range,
+					 &band900_arfcn_range_ext},
+	{"1800", SECADDR_GSM1800MS_NSIG, &band1800_arfcn_range, 0},
+	{"1900", SECADDR_GSM1900MS_NSIG, &band1900_arfcn_range, 0},
+	{0,	 0,			 0,			0}
+};
+
+struct band *current_band;
+
+find_named_band(srchname)
+	char *srchname;
+{
+	struct band *band;
+
+	for (band = supported_bands; band->name; band++)
+		if (!strcmp(band->name, srchname))
+			break;
+	if (!band->name)
+		return(-1);
+	current_band = band;
+	return(0);
+}
+
+check_arfcn_range(range, arfcn, ulp, dlp)
+	struct arfcn_range *range;
+	unsigned arfcn, *ulp, *dlp;
+{
+	if (arfcn < range->min)
+		return(-1);
+	if (arfcn > range->max)
+		return(-1);
+	if (ulp)
+		*ulp = range->ul_khz + (arfcn - range->min) * 200;
+	if (dlp)
+		*dlp = range->dl_khz + (arfcn - range->min) * 200;
+	return(0);
+}
+
+verify_arfcn(arfcn, ulp, dlp)
+	unsigned arfcn, *ulp, *dlp;
+{
+	if (!check_arfcn_range(current_band->arfcn_range, arfcn, ulp, dlp))
+		return(0);
+	if (current_band->arfcn_range_ext &&
+	    !check_arfcn_range(current_band->arfcn_range_ext, arfcn, ulp, dlp))
+		return(0);
+	return(-1);
+}