Fixes and improvements of layer23.
[osmocom-bb.git] / src / host / layer23 / src / support.c
1 /*
2  * (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
3  *
4  * All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  */
21
22 #include <stdio.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #include <osmocom/osmocom_data.h>
27
28 void gsm_support_init(struct osmocom_ms *ms)
29 {
30         struct gsm_support *s = &ms->support;
31         int i;
32
33         memset(s, 0, sizeof(*s));
34
35         /* rf power capability */
36         s->pwr_lev_900 = 3; /* CLASS 4: Handheld 2W */
37         s->pwr_lev_1800 = 0; /* CLASS 1: Handheld 1W */
38         /* controlled early classmark sending */
39         s->es_ind = 0; /* no */
40         /* revision level */
41         s->rev_lev = 1; /* phase 2 mobile station */
42         /* support of VGCS */
43         s->vgcs = 0; /* no */
44         /* support of VBS */
45         s->vbs = 0; /* no */
46         /* support of SMS */
47         s->sms_ptp = 1; /* yes */
48         /* screening indicator */
49         s->ss_ind = 1; /* phase 2 error handling */
50         /* pseudo synchronised capability */
51         s->ps_cap = 0; /* no */
52         /* CM service prompt */
53         s->cmsp = 0; /* no */
54         /* solsa support */
55         s->solsa = 0; /* no */
56         /* location service support */
57         s->lcsva = 0; /* no */
58         s->loc_serv = 0; /* no */
59         /* codec supprot */
60         s->a5_1 = 0; /* currently not */
61         s->a5_2 = 0;
62         s->a5_3 = 0;
63         s->a5_4 = 0;
64         s->a5_5 = 0;
65         s->a5_6 = 0;
66         s->a5_7 = 0;
67         /* radio support */
68         s->p_gsm = 0; /* P-GSM only */
69         s->e_gsm = 1; /* E-GSM */
70         s->r_gsm = 0; /* R-GSM only */
71         s->r_capa = 0;
72         s->low_capa = 4; /* p,e,r power class */
73         s->dcs_1800 = 0;
74         /* set supported frequencies */
75         if (s->e_gsm || s->r_gsm)
76                 s->freq_map[0] |= 1;
77         if (s->p_gsm || s->e_gsm || s->r_gsm)
78                 for(i = 1; i <= 124; i++)
79                         s->freq_map[i >> 3] |= (1 << (i & 7));
80         if (s->dcs_1800)
81                 for(i = 512; i <= 885; i++)
82                         s->freq_map[i >> 3] |= (1 << (i & 7));
83         if (s->e_gsm)
84                 for(i = 975; i <= 1023; i++)
85                         s->freq_map[i >> 3] |= (1 << (i & 7));
86         if (s->r_gsm)
87                 for(i = 955; i <= 1023; i++)
88                         s->freq_map[i >> 3] |= (1 << (i & 7));
89         s->dcs_capa = 1; /* dcs power class */
90         /* multi slot support */
91         s->ms_sup = 0; /* no */
92         /* ucs2 treatment */
93         s->ucs2_treat = 0; /* default */
94         /* support extended measurements */
95         s->ext_meas = 0; /* no */
96         /* support switched measurement capability */
97         s->meas_cap = 0; /* no */
98         //s->sms_val = ;
99         //s->sm_val = ;
100
101         /* IMEI */
102         sprintf(s->imei, "000000000000000");
103         sprintf(s->imeisv, "0000000000000000");
104
105         /* radio */
106         s->min_rxlev_db = -106;
107 }
108
109 /* (3.2.1) maximum channels to scan within each band */
110 struct gsm_support_scan_max gsm_sup_smax[] = {
111 #if 0
112         { 259, 293, 15, 0 },
113         { 360, 340, 15, 0 },
114         { 438, 511, 25, 0 },
115         { 128, 251, 30, 0 },
116         { 955, 124, 30, 0 },
117         { 512, 885, 40, 0 },
118 #else
119         { 955, 125, 1, 0 }, /* testing with maximum of one frequency */
120 #endif
121         { 0, 0, 0, 0 }
122 };
123
124