FreeCalypso > hg > fc-rfcal-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:698602bbd120 | 2:e2db512abbee |
---|---|
1 /* | |
2 * Our band and ARFCN tables and lookup code live here. | |
3 */ | |
4 | |
5 #include <string.h> | |
6 #include <strings.h> | |
7 #include "band.h" | |
8 #include "secaddr.h" | |
9 | |
10 struct arfcn_range band850_arfcn_range = {128, 251, 824200, 869200}; | |
11 struct arfcn_range band900_arfcn_range = { 0, 124, 890000, 935000}; | |
12 struct arfcn_range band900_arfcn_range_ext = {975, 1023, 880200, 925200}; | |
13 struct arfcn_range band1800_arfcn_range = {512, 885, 1710200, 1805200}; | |
14 struct arfcn_range band1900_arfcn_range = {512, 810, 1850200, 1930200}; | |
15 | |
16 struct band supported_bands[] = { | |
17 {"850", SECADDR_GSM850MS_NSIG, &band850_arfcn_range, 0}, | |
18 {"900", SECADDR_GSM900MS_NSIG, &band900_arfcn_range, | |
19 &band900_arfcn_range_ext}, | |
20 {"1800", SECADDR_GSM1800MS_NSIG, &band1800_arfcn_range, 0}, | |
21 {"1900", SECADDR_GSM1900MS_NSIG, &band1900_arfcn_range, 0}, | |
22 {0, 0, 0, 0} | |
23 }; | |
24 | |
25 struct band *current_band; | |
26 | |
27 find_named_band(srchname) | |
28 char *srchname; | |
29 { | |
30 struct band *band; | |
31 | |
32 for (band = supported_bands; band->name; band++) | |
33 if (!strcmp(band->name, srchname)) | |
34 break; | |
35 if (!band->name) | |
36 return(-1); | |
37 current_band = band; | |
38 return(0); | |
39 } | |
40 | |
41 check_arfcn_range(range, arfcn, ulp, dlp) | |
42 struct arfcn_range *range; | |
43 unsigned arfcn, *ulp, *dlp; | |
44 { | |
45 if (arfcn < range->min) | |
46 return(-1); | |
47 if (arfcn > range->max) | |
48 return(-1); | |
49 if (ulp) | |
50 *ulp = range->ul_khz + (arfcn - range->min) * 200; | |
51 if (dlp) | |
52 *dlp = range->dl_khz + (arfcn - range->min) * 200; | |
53 return(0); | |
54 } | |
55 | |
56 verify_arfcn(arfcn, ulp, dlp) | |
57 unsigned arfcn, *ulp, *dlp; | |
58 { | |
59 if (!check_arfcn_range(current_band->arfcn_range, arfcn, ulp, dlp)) | |
60 return(0); | |
61 if (current_band->arfcn_range_ext && | |
62 !check_arfcn_range(current_band->arfcn_range_ext, arfcn, ulp, dlp)) | |
63 return(0); | |
64 return(-1); | |
65 } |