comparison src/g23m-gsm/sms/sms_em.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Module defines the engineering mode (EM) device driver for the
18 | G23 protocol stack. This driver is used to control all engineering
19 | mode related functions.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef SMS_EM_C
24 #define SMS_EM_C
25
26 #define ENTITY_SMS
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include <stddef.h>
33 #include "typedefs.h"
34 #include "pcm.h"
35 #include "vsi.h"
36 #include "custom.h"
37 #include "gsm.h"
38 #include "message.h"
39 #include "ccdapi.h"
40 #include "prim.h"
41 #include "cus_sms.h"
42 #include "cnf_sms.h"
43 #include "mon_sms.h"
44 #include "pei.h"
45 #include "tok.h"
46 #include "sms.h"
47 #include "sms_em.h"
48
49 /*==== EXPORT =====================================================*/
50
51 /*==== PRIVAT =====================================================*/
52
53 /*==== VARIABLES ==================================================*/
54
55 #ifdef FF_EM_MODE
56 GLOBAL UBYTE em_sms_event_buffer[EM_SMS_BUFFER_SIZE];
57 GLOBAL UBYTE em_sms_buffer_write;
58
59 /* Event tracing flags for EM */
60 GLOBAL BOOL sms_v[EM_MAX_SMS_EVENTS];
61
62 static UBYTE em_sms_trace_occured;
63
64 GLOBAL UBYTE em_change_flag = 0;
65
66 #endif /* FF_EM_MODE */
67
68 /*==== FUNCTIONS ==================================================*/
69
70 #ifdef FF_EM_MODE
71 LOCAL UBYTE check_write_index (UBYTE n);
72
73 /*
74 +------------------------------------------------------------------------------
75 | Function : em_write_buffer_2
76 +------------------------------------------------------------------------------
77 | Description : Perform buffer check and store corresponding data in it.
78 |
79 | Parameters : Event number and length of data
80 |
81 | Return : TRUE/FALSE
82 |
83 +------------------------------------------------------------------------------
84 */
85
86 GLOBAL UBYTE em_write_buffer_2 (UBYTE event_no)
87 {
88 TRACE_FUNCTION ("sms_em_write_buffer_2()");
89
90 if(check_write_index(2)) { /* Check write index */
91 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
92 em_sms_event_buffer[em_sms_buffer_write++] = 0; /* Indicates the length of the data value */
93 return FALSE; /* Data is stored inside buffer, reset flag */
94 }
95 else
96 return TRUE; /* No more space inside buffer, serve flag next time */
97 }
98
99 /*
100 +------------------------------------------------------------------------------
101 | Function : em_write_buffer_3
102 +------------------------------------------------------------------------------
103 | Description : Perform buffer check and store corresponding data in it.
104 |
105 | Parameters : Event number, length of data and value
106 |
107 | Return : TRUE/FALSE
108 |
109 +------------------------------------------------------------------------------
110 */
111
112 GLOBAL UBYTE em_write_buffer_3 (UBYTE event_no, UBYTE value)
113 {
114 TRACE_FUNCTION ("sms_em_write_buffer_3()");
115
116 if(check_write_index(3)) { /* Check write index */
117 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
118 em_sms_event_buffer[em_sms_buffer_write++] = 1; /* Indicates the length of the data value */
119 em_sms_event_buffer[em_sms_buffer_write++] = value; /* Data to be stored */
120 return FALSE; /* Data is stored inside buffer, reset flag */
121 }
122 else
123 return TRUE; /* No more space inside buffer, serve flag next time */
124 }
125
126 /*
127 +------------------------------------------------------------------------------
128 | Function : em_write_buffer_3a
129 +------------------------------------------------------------------------------
130 | Description : Perform buffer check and store corresponding data in it.
131 |
132 | Parameters : Event number, length of data and value (USHORT)
133 |
134 | Return : TRUE/FALSE
135 |
136 +------------------------------------------------------------------------------
137 */
138
139 GLOBAL UBYTE em_write_buffer_3a (UBYTE event_no, USHORT value)
140 {
141 TRACE_FUNCTION ("sms_em_write_buffer_3a()");
142
143 if(check_write_index(4)) { /* Check write index */
144 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
145 em_sms_event_buffer[em_sms_buffer_write++] = 2; /* Indicates the length of the data value */
146 em_sms_event_buffer[em_sms_buffer_write++] = (UBYTE)(value >> 8); /* Data to be stored - MSB first */
147 em_sms_event_buffer[em_sms_buffer_write++] = (UBYTE)(value); /* LSB second */
148 return FALSE; /* Data is stored inside buffer, reset flag */
149 }
150 else
151 return TRUE; /* No more space inside buffer, serve flag next time */
152 }
153
154 /*
155 +------------------------------------------------------------------------------
156 | Function : em_write_buffer_4
157 +------------------------------------------------------------------------------
158 | Description : Perform buffer check and store corresponding data in it.
159 |
160 | Parameters : Event number, length of data, data value1 and value2
161 |
162 | Return : TRUE/FALSE
163 |
164 +------------------------------------------------------------------------------
165 */
166
167 GLOBAL UBYTE em_write_buffer_4 (UBYTE event_no, UBYTE value1, UBYTE value2)
168 {
169 TRACE_FUNCTION ("sms_em_write_buffer_4()");
170
171 if(check_write_index(4)) { /* Check write index */
172 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
173 em_sms_event_buffer[em_sms_buffer_write++] = 2; /* Indicates the length of the data value */
174 em_sms_event_buffer[em_sms_buffer_write++] = value1; /* Value 1 */
175 em_sms_event_buffer[em_sms_buffer_write++] = value2; /* Value 2 */
176 return FALSE; /* Data is stored inside buffer, reset flag */
177 }
178 else
179 return TRUE; /* No more space inside buffer, serve flag next time */
180 }
181
182 /*
183 +------------------------------------------------------------------------------
184 | Function : em_write_buffer_4a
185 +------------------------------------------------------------------------------
186 | Description : Perform buffer check and store corresponding data in it.
187 |
188 | Parameters : Event number, length of data, data value and cs (USHORT)
189 |
190 | Return : TRUE/FALSE
191 |
192 +------------------------------------------------------------------------------
193 */
194
195 GLOBAL UBYTE em_write_buffer_4a (UBYTE event_no, UBYTE value, USHORT cs)
196 {
197 TRACE_FUNCTION ("sms_em_write_buffer_4a()");
198
199 if(check_write_index(5)) { /* Check write index */
200 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
201 em_sms_event_buffer[em_sms_buffer_write++] = 3; /* Indicates the length of the data value */
202 em_sms_event_buffer[em_sms_buffer_write++] = value; /* Data */
203 em_sms_event_buffer[em_sms_buffer_write++] = (UBYTE)(cs >> 8); /* Data to be stored - MSB first */
204 em_sms_event_buffer[em_sms_buffer_write++] = (UBYTE)(cs); /* LSB second */
205 return FALSE; /* Data is stored inside buffer, reset flag */
206 }
207 else
208 return TRUE; /* No more space inside buffer, serve flag next time */
209 }
210
211 /*
212 +------------------------------------------------------------------------------
213 | Function : em_write_buffer_5
214 +------------------------------------------------------------------------------
215 | Description : Perform buffer check and store corresponding data in it.
216 |
217 | Parameters : Event number, length of data, data value1 and value2
218 |
219 | Return : TRUE/FALSE
220 |
221 +------------------------------------------------------------------------------
222 */
223
224 GLOBAL UBYTE em_write_buffer_5 (UBYTE event_no, UBYTE value1, UBYTE value2, UBYTE value3)
225 {
226 TRACE_FUNCTION ("sms_em_write_buffer_5()");
227
228 if(check_write_index(5)) { /* Check write index */
229 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
230 em_sms_event_buffer[em_sms_buffer_write++] = 3; /* Indicates the length of the data value */
231 em_sms_event_buffer[em_sms_buffer_write++] = value1; /* Value 1 */
232 em_sms_event_buffer[em_sms_buffer_write++] = value2; /* Value 2 */
233 em_sms_event_buffer[em_sms_buffer_write++] = value3; /* Value 3 */
234 return FALSE; /* Data is stored inside buffer, reset flag */
235 }
236 else
237 return TRUE; /* No more space inside buffer, serve flag next time */
238 }
239
240 /*
241 +------------------------------------------------------------------------------
242 | Function : em_write_buffer_6
243 +------------------------------------------------------------------------------
244 | Description : Perform buffer check and store corresponding data in it.
245 |
246 | Parameters : Event number, length of data, data value and cs (USHORT)
247 |
248 | Return : TRUE/FALSE
249 |
250 +------------------------------------------------------------------------------
251 */
252
253 GLOBAL UBYTE em_write_buffer_6 (UBYTE event_no, UBYTE value, UBYTE value1, UBYTE value2, UBYTE value3)
254 {
255 TRACE_FUNCTION ("sms_em_write_buffer_6()");
256
257 if(check_write_index(6)) { /* Check write index */
258 em_sms_event_buffer[em_sms_buffer_write++] = event_no; /* Event number */
259 em_sms_event_buffer[em_sms_buffer_write++] = 4; /* Indicates the length of the data value */
260 em_sms_event_buffer[em_sms_buffer_write++] = value; /* Data */
261 em_sms_event_buffer[em_sms_buffer_write++] = value1; /* Data 1 */
262 em_sms_event_buffer[em_sms_buffer_write++] = value2; /* Data 2 */
263 em_sms_event_buffer[em_sms_buffer_write++] = value3; /* Data 3 */
264 return FALSE; /* Data is stored inside buffer, reset flag */
265 }
266 else
267 return TRUE; /* No more space inside buffer, serve flag next time */
268 }
269 /*
270 +------------------------------------------------------------------------------
271 | Function : check_write_index
272 +------------------------------------------------------------------------------
273 | Description : Checks the write index inside the buffer. No reset when
274 | buffer is full.
275 |
276 | Parameters : Number of bytes to be stored in buffer
277 |
278 | Return : TRUE/FALSE
279 |
280 +------------------------------------------------------------------------------
281 */
282
283 LOCAL UBYTE check_write_index (UBYTE n)
284 {
285 TRACE_FUNCTION ("sms_check_write_index()");
286
287 if (em_sms_buffer_write + n < EM_SMS_BUFFER_SIZE)
288 {
289 /*
290 ACI is informed about the first event trace, used for later data processing.
291 */
292 if(em_sms_trace_occured == 0)
293 {
294 PALLOC(em_notification, EM_DATA_IND);
295 em_notification->entity = EM_SMS;
296 PSENDX(MMI, em_notification);
297 em_sms_trace_occured++;
298 }
299 return TRUE;
300 }
301 else
302 return FALSE;
303 }
304
305 /*
306 +------------------------------------------------------------------------------
307 | Function : em_init_sms_event_trace
308 +------------------------------------------------------------------------------
309 | Description : Initialize the event tracing flags for SMS
310 |
311 | Parameters :
312 |
313 | Return :
314 |
315 +------------------------------------------------------------------------------
316 */
317 GLOBAL void em_init_sms_event_trace(void)
318 {
319 UBYTE i;
320
321 TRACE_FUNCTION ("em_init_sms_event_trace()");
322
323 for(i=1; i<EM_MAX_SMS_EVENTS; i++)
324 sms_v[i] = 0;
325
326 em_sms_buffer_write = 0;
327 }
328
329 /*
330 +------------------------------------------------------------------------------
331 | Function : sms_em_sms_event_req
332 +------------------------------------------------------------------------------
333 | Description : Set the event tracing flags according the bitmask
334 |
335 | Parameters : Primitive - Bitmask
336 |
337 | Return :
338 |
339 +------------------------------------------------------------------------------
340 */
341
342 GLOBAL void sms_em_sms_event_req (T_EM_SMS_EVENT_REQ *em_sms_event_req)
343 {
344 UBYTE i;
345
346 TRACE_FUNCTION ("sms_em_sms_event_req()");
347 /*
348 * The event tracing flags are set according the bitmask. sms_v[i] are
349 * the flags belonging to the event number described in 8443.601
350 */
351 for(i=1; i<33; i++) {
352 sms_v[i] = ((em_sms_event_req->bitmask_sms_l & (0x01<<(i-1))) > 0) ? TRUE : FALSE;
353 }
354
355 for(i=33; i<(EM_MAX_SMS_EVENTS); i++) {
356 sms_v[i] = ((em_sms_event_req->bitmask_sms_h & (0x01<<(i-1))) > 0) ? TRUE : FALSE;
357 }
358
359 /*
360 A new event trace is generated therefor the flag is set to 0.
361 */
362 em_sms_trace_occured = 0;
363
364 PFREE(em_sms_event_req);
365 }
366 #endif /* FF_EM_MODE */
367
368 #endif /* SMS_EM_C */