FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/sms/sms_time.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-F&D (8411) | |
4 | Modul : SMS_TIME | |
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 Modul defines the timer handling functions | |
18 | for the component SMS of the mobile station | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef SMS_TIM_C | |
23 #define SMS_TIM_C | |
24 | |
25 #include "config.h" | |
26 #include "fixedconf.h" | |
27 #include "condat-features.h" | |
28 | |
29 #define ENTITY_SMS | |
30 | |
31 /*==== INCLUDES ===================================================*/ | |
32 | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stddef.h> | |
36 #include "typedefs.h" | |
37 #include "pcm.h" | |
38 #include "vsi.h" | |
39 #include "custom.h" | |
40 #include "gsm.h" | |
41 #include "message.h" | |
42 #include "ccdapi.h" | |
43 #include "prim.h" | |
44 #include "cus_sms.h" | |
45 #include "cnf_sms.h" | |
46 #include "mon_sms.h" | |
47 #include "pei.h" | |
48 #include "tok.h" | |
49 #include "sms.h" | |
50 #include "sms_em.h" | |
51 | |
52 /*==== EXPORT ======================================================*/ | |
53 | |
54 /*==== PRIVAT ======================================================*/ | |
55 | |
56 /*==== VARIABLES ===================================================*/ | |
57 | |
58 /*==== FUNCTIONS ===================================================*/ | |
59 | |
60 /* | |
61 +--------------------------------------------------------------------+ | |
62 | PROJECT : GSM-PS (6147) MODULE : SMS_TIM | | |
63 | STATE : code ROUTINE : tim_exec_timeout | | |
64 +--------------------------------------------------------------------+ | |
65 | |
66 PURPOSE : execute timeout | |
67 | |
68 */ | |
69 | |
70 GLOBAL void tim_exec_timeout (USHORT index) | |
71 { | |
72 GET_INSTANCE_DATA; | |
73 USHORT timer; | |
74 int instance; | |
75 | |
76 /* TRACE_FUNCTION ("tim_exec_timeout()"); */ | |
77 | |
78 timer = index / MAX_SMS_CALLS; | |
79 instance = index % MAX_SMS_CALLS; | |
80 sms_data->inst = (UBYTE)instance; | |
81 | |
82 if (timer < MAX_SMS_TIMER) | |
83 { | |
84 | |
85 /* Implements Measure#36 */ | |
86 #ifdef NCONFIG | |
87 /* partab is not defined when NCONFIG is defined */ | |
88 TRACE_EVENT_P1 ("Expired TIMER: timer %d", timer); | |
89 #else /* not NCONFIG */ | |
90 #ifdef OPTION_TIMER | |
91 TRACE_EVENT_P1 ("Expired TIMER %s", partab[timer].keyword); | |
92 #endif | |
93 #endif /* NCONFIG */ | |
94 | |
95 sms_data->data[instance].t_running[timer] = FALSE; | |
96 | |
97 switch (timer) | |
98 { | |
99 case TC1M: | |
100 tim_tc1m (); | |
101 break; | |
102 case TR1M: | |
103 tim_tr1m (); | |
104 break; | |
105 case TR2M: | |
106 tim_tr2m (); | |
107 break; | |
108 case TRAM: | |
109 tim_tram (); | |
110 break; | |
111 case TLCT: | |
112 tim_tlct (); | |
113 break; | |
114 case TMMS: | |
115 tim_tmms (); | |
116 break; | |
117 default: /* Not reached */ | |
118 break; | |
119 } | |
120 } | |
121 } | |
122 | |
123 | |
124 /* | |
125 +--------------------------------------------------------------------+ | |
126 | PROJECT : GSM-PS (6147) MODULE : SMS_TIM | | |
127 | STATE : code ROUTINE : tim_stop_timer | | |
128 +--------------------------------------------------------------------+ | |
129 | |
130 PURPOSE : stop timer | |
131 | |
132 */ | |
133 | |
134 GLOBAL void tim_stop_timer (USHORT index) | |
135 { | |
136 GET_INSTANCE_DATA; | |
137 USHORT timer; | |
138 USHORT instance; | |
139 | |
140 /* TRACE_FUNCTION ("tim_stop_timer()"); */ | |
141 | |
142 timer = index / MAX_SMS_CALLS; | |
143 instance = index % MAX_SMS_CALLS; | |
144 | |
145 /* Implements Measure#36 */ | |
146 #ifdef NCONFIG | |
147 /* partab is not defined when NCONFIG is defined */ | |
148 TRACE_EVENT_P1 ("Stop TIMER: timer %d", timer); | |
149 #else /* not NCONFIG */ | |
150 #ifdef OPTION_TIMER | |
151 TRACE_EVENT_P1 ("Stop TIMER %s", partab[timer].keyword); | |
152 #endif | |
153 #endif /* NCONFIG */ | |
154 | |
155 sms_data->data[instance].t_running[timer] = FALSE; | |
156 TIMER_STOP (sms_handle, index); | |
157 } | |
158 | |
159 /* | |
160 +--------------------------------------------------------------------+ | |
161 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
162 | STATE : code ROUTINE : tim_start_timer | | |
163 +--------------------------------------------------------------------+ | |
164 | |
165 PURPOSE : start timer | |
166 | |
167 */ | |
168 | |
169 GLOBAL void tim_start_timer (USHORT index, T_TIME value) | |
170 { | |
171 GET_INSTANCE_DATA; | |
172 USHORT timer; | |
173 USHORT instance; | |
174 | |
175 /* TRACE_FUNCTION ("tim_start_timer()"); */ | |
176 | |
177 timer = index / MAX_SMS_CALLS; | |
178 instance = index % MAX_SMS_CALLS; | |
179 | |
180 /* Implements Measure#36 */ | |
181 #ifdef NCONFIG | |
182 /* partab is not defined when NCONFIG is defined */ | |
183 TRACE_EVENT_P1 ("Start TIMER: timer %d", timer); | |
184 #else /* not NCONFIG */ | |
185 #ifdef OPTION_TIMER | |
186 TRACE_EVENT_P1 ("Start TIMER %s", partab[timer].keyword); | |
187 #endif | |
188 #endif /* NCONFIG */ | |
189 | |
190 sms_data->data[instance].t_running[timer] = TRUE; | |
191 TIMER_START (sms_handle, index, value); | |
192 } | |
193 | |
194 /* | |
195 +--------------------------------------------------------------------+ | |
196 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
197 | STATE : code ROUTINE : tim_tc1m | | |
198 +--------------------------------------------------------------------+ | |
199 | |
200 PURPOSE : Timeout of timer TC1M | |
201 | |
202 */ | |
203 | |
204 GLOBAL void tim_tc1m (void) | |
205 { | |
206 GET_INSTANCE_DATA; | |
207 | |
208 TRACE_FUNCTION ("tim_tc1m()"); | |
209 | |
210 SMS_EM_TIMEOUT_TC1M; | |
211 | |
212 if (sms_data) /*lint !e774 always True*/ | |
213 { | |
214 switch (SMS_INST_GET_STATE (STATE_CP)) | |
215 { | |
216 case CP_WAIT_FOR_ACK: | |
217 #if defined (GPRS) | |
218 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
219 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
220 #endif | |
221 { | |
222 if (SMS_RETX(sms_data) >= MAX_RETRANS) | |
223 { | |
224 cp_send_release_req (SMS_INST.ti); | |
225 | |
226 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
227 | |
228 SMS_INST.r_flag = FALSE; | |
229 | |
230 rl_error_ind (SMS_CAUSE_NET_TIMEOUT); | |
231 | |
232 /*FREE_SMS_INSTANCE (SMS_INST.ti);*/ | |
233 break; | |
234 } | |
235 else | |
236 { | |
237 #if defined (GPRS) | |
238 if (SMS_INST.downlink NEQ SMS_DOWNLINK_LL) | |
239 { | |
240 #endif | |
241 USHORT bsize_message = D_SDU_OFF (SMS_DATA_REQ(sms_data))+ | |
242 D_SDU_LEN (SMS_DATA_REQ(sms_data)); | |
243 PALLOC_SDU (data_req, MMSMS_DATA_REQ, bsize_message ); | |
244 | |
245 SMS_SDU_COPY (data_req, SMS_DATA_REQ(sms_data), MMSMS_DATA_REQ); | |
246 TRACE_BINDUMP(sms_handle, | |
247 TC_USER4, | |
248 "U_CP_DATA", | |
249 (&(data_req->sdu.buf[0]) + ((data_req->sdu.o_buf >> 3) -1)), | |
250 ((data_req->sdu.l_buf >> 3) + 1)); | |
251 PSENDX (MM, data_req); | |
252 | |
253 #if defined (GPRS) | |
254 } | |
255 else | |
256 { | |
257 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
258 { | |
259 /* | |
260 * retransmit on downlink LL | |
261 */ | |
262 cp_send_data_gsms (); | |
263 | |
264 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY; | |
265 } | |
266 else | |
267 { | |
268 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
269 } | |
270 } | |
271 #endif /* GPRS */ | |
272 SMS_RETX(sms_data)++; | |
273 /* | |
274 * start timer TC1M | |
275 */ | |
276 sms_timer_start(TC1M); | |
277 break; | |
278 } | |
279 } | |
280 } | |
281 } | |
282 } | |
283 | |
284 /* | |
285 +--------------------------------------------------------------------+ | |
286 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
287 | STATE : code ROUTINE : tim_tr1m | | |
288 +--------------------------------------------------------------------+ | |
289 | |
290 PURPOSE : Timeout of timer TR1M | |
291 | |
292 */ | |
293 | |
294 GLOBAL void tim_tr1m (void) | |
295 { | |
296 GET_INSTANCE_DATA; | |
297 | |
298 TRACE_FUNCTION ("tim_tr1m()"); | |
299 | |
300 SMS_EM_TIMEOUT_TR1M; | |
301 | |
302 if (sms_data) /*lint !e774 always True*/ | |
303 { | |
304 switch (SMS_INST_GET_STATE (STATE_RL)) | |
305 { | |
306 case RL_ESTABLISH: | |
307 | |
308 TRACE_FUNCTION ("tim_tr1m: RL_ESTABLISH"); | |
309 sms_data->data[INST_MO].ti = sms_data->timer_ti; | |
310 /* | |
311 * RL state transition | |
312 */ | |
313 SMS_INST_SET_STATE (STATE_RL, RL_IDLE); | |
314 /* | |
315 * CP_ABORT_REQ | |
316 */ | |
317 cp_abort_req(); | |
318 /* | |
319 * TL_TIMEOUT_IND | |
320 */ | |
321 tl_timeout_ind (TR1M); | |
322 break; | |
323 | |
324 case RL_WAIT_FOR_ACK: | |
325 | |
326 TRACE_FUNCTION ("tim_tr1m: RL_WAIT_FOR_ACK"); | |
327 /* | |
328 * RL state transition | |
329 */ | |
330 SMS_INST_SET_STATE (STATE_RL, RL_IDLE); | |
331 /* | |
332 * CP_ABORT_REQ | |
333 */ | |
334 cp_abort_req (); | |
335 /* | |
336 * TL_TIMEOUT_IND | |
337 */ | |
338 tl_timeout_ind (TR1M); | |
339 | |
340 break; | |
341 | |
342 case RL_WAIT_FOR_SMMA_ACK: | |
343 TRACE_FUNCTION ("tim_tr1m: RL_WAIT_FOR_SMMA_ACK"); | |
344 | |
345 if (SMS_INST.retrans) | |
346 { | |
347 SMS_INST.retrans = FALSE; | |
348 /* | |
349 * RL state transition RL_IDLE | |
350 */ | |
351 SMS_INST_SET_STATE (STATE_RL, RL_IDLE); | |
352 /* | |
353 * TL_REPORT_IND => | |
354 */ | |
355 tl_report_ind (NULL, SMS_CAUSE_NET_TIMEOUT); | |
356 /* | |
357 * SIM_UPDATE_REQ => | |
358 */ | |
359 tl_sms_memo_exceeded (TRUE); | |
360 | |
361 } | |
362 else | |
363 { | |
364 SMS_INST.retrans = TRUE; | |
365 /* | |
366 * RL state transition RL_WAIT_FOR_RETRANS_TIMER | |
367 */ | |
368 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_RETRANS_TIMER); | |
369 /* | |
370 * start timer TRAM | |
371 */ | |
372 sms_timer_start(TRAM); | |
373 /* | |
374 * CP_RELEASE_REQ => | |
375 */ | |
376 TRACE_EVENT("CP_RELEASE_REQ_19"); | |
377 cp_release_req (SMS_INST.ti); | |
378 } | |
379 | |
380 break; | |
381 } | |
382 } | |
383 } | |
384 | |
385 /* | |
386 +--------------------------------------------------------------------+ | |
387 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
388 | STATE : code ROUTINE : tim_tr2m | | |
389 +--------------------------------------------------------------------+ | |
390 | |
391 PURPOSE : Timeout of timer TR2M | |
392 | |
393 */ | |
394 | |
395 GLOBAL void tim_tr2m (void) | |
396 { | |
397 GET_INSTANCE_DATA; | |
398 | |
399 TRACE_FUNCTION ("tim_tr2m"); | |
400 | |
401 SMS_EM_TIMEOUT_TR2M; | |
402 | |
403 if (sms_data) /*lint !e774 always True*/ | |
404 { | |
405 switch (SMS_INST_GET_STATE (STATE_RL)) | |
406 { | |
407 case RL_WAIT_FOR_SEND_ACK: | |
408 /* | |
409 * RP_ERROR => | |
410 */ | |
411 rl_report_req_error (SMS_RP_CS_PROTOCOL_ERROR, NULL); | |
412 /* | |
413 * TL_REPORT_IND => | |
414 */ | |
415 tl_report_ind (NULL, SMS_CAUSE_NET_TIMEOUT); | |
416 /* | |
417 * RL state transition RL_IDLE | |
418 */ | |
419 SMS_INST_SET_STATE (STATE_RL, RL_IDLE); | |
420 break; | |
421 | |
422 default: | |
423 break; | |
424 } | |
425 } | |
426 } | |
427 | |
428 /* | |
429 +--------------------------------------------------------------------+ | |
430 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
431 | STATE : code ROUTINE : tim_tram | | |
432 +--------------------------------------------------------------------+ | |
433 | |
434 PURPOSE : Timeout of timer TRAM | |
435 | |
436 */ | |
437 | |
438 GLOBAL void tim_tram (void) | |
439 { | |
440 GET_INSTANCE_DATA; | |
441 | |
442 TRACE_FUNCTION ("tim_tram"); | |
443 | |
444 if (sms_data) /*lint !e774 always True*/ | |
445 { | |
446 switch (SMS_INST_GET_STATE (STATE_RL)) | |
447 { | |
448 case RL_WAIT_FOR_RETRANS_TIMER: | |
449 /* | |
450 * RL state transition RL_IDLE | |
451 */ | |
452 SMS_INST_SET_STATE (STATE_RL, RL_IDLE); | |
453 /* | |
454 * TL_TIMEOUT_IND | |
455 */ | |
456 tl_timeout_ind (TRAM); | |
457 break; | |
458 default: | |
459 TRACE_ERROR("TRAM expired in wrong state!"); | |
460 } | |
461 } | |
462 } | |
463 | |
464 /* | |
465 +--------------------------------------------------------------------+ | |
466 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
467 | STATE : code ROUTINE : tim_tlct | | |
468 +--------------------------------------------------------------------+ | |
469 | |
470 PURPOSE : Timeout of timer TLCT - concatenation supervision timer | |
471 | |
472 */ | |
473 | |
474 GLOBAL void tim_tlct (void) | |
475 { | |
476 GET_INSTANCE_DATA; | |
477 | |
478 TRACE_FUNCTION ("tim_tlct()"); | |
479 | |
480 switch (SMS_INST_GET_STATE (STATE_TL)) | |
481 { | |
482 default: | |
483 | |
484 TRACE_ERROR("Timer TLCT in wrong state"); | |
485 | |
486 case TL_SEND_CONTD: | |
487 /* | |
488 * reset concatenation | |
489 */ | |
490 sms_data->concat_cntrl.concatenation = FALSE; | |
491 sms_data->concat_cntrl.release_pending = FALSE; | |
492 /* | |
493 * clean up instance | |
494 */ | |
495 if (SMS_SDU(sms_data) NEQ NULL) | |
496 { | |
497 MFREE (SMS_SDU(sms_data)); | |
498 SMS_SDU(sms_data) = NULL; | |
499 } | |
500 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST; | |
501 /* | |
502 * TL State Transition TL_IDLE | |
503 */ | |
504 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
505 /* | |
506 * RL_RELEASE_REQ ==> | |
507 */ | |
508 rl_release_req(SMS_INST.ti); | |
509 break; | |
510 | |
511 } | |
512 | |
513 } | |
514 | |
515 /* | |
516 +--------------------------------------------------------------------+ | |
517 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
518 | STATE : code ROUTINE : tim_tmms | | |
519 +--------------------------------------------------------------------+ | |
520 | |
521 PURPOSE : Timeout of timer TMMS - More Message Send timer | |
522 | |
523 */ | |
524 GLOBAL void tim_tmms(void) | |
525 { | |
526 | |
527 GET_INSTANCE_DATA; | |
528 | |
529 TRACE_FUNCTION ("tim_tmms()"); | |
530 | |
531 switch (SMS_INST_GET_STATE (STATE_TL)) | |
532 { | |
533 default: | |
534 | |
535 TRACE_ERROR("Timer TMMS in wrong state"); | |
536 | |
537 case TL_SEND_CONTD: | |
538 | |
539 if(CMMS_ACTIVE) | |
540 { | |
541 sms_data->cmms_release_pending = FALSE; | |
542 } | |
543 /* | |
544 * Send the Primitive MNSMS_REPORT_IND to ACI | |
545 */ | |
546 tl_mnsms_cmms_end_ind(); | |
547 /* | |
548 * TL State Transition TL_IDLE | |
549 */ | |
550 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
551 /* | |
552 * RL_RELEASE_REQ ==> | |
553 */ | |
554 rl_release_req(SMS_INST.ti); | |
555 break; | |
556 } | |
557 } | |
558 | |
559 | |
560 /* | |
561 +--------------------------------------------------------------------+ | |
562 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
563 | STATE : code ROUTINE : sms_timer_start | | |
564 +--------------------------------------------------------------------+ | |
565 | |
566 PURPOSE : start sms timer | |
567 | |
568 */ | |
569 GLOBAL void sms_timer_start (USHORT id) | |
570 { | |
571 GET_INSTANCE_DATA; | |
572 T_TIME value; | |
573 | |
574 value = sms_data->timer_values[id]; | |
575 | |
576 tim_start_timer (((USHORT)(id*MAX_SMS_CALLS+sms_data->inst)), value); | |
577 } | |
578 | |
579 /* | |
580 +--------------------------------------------------------------------+ | |
581 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
582 | STATE : code ROUTINE : sms_timer_stop | | |
583 +--------------------------------------------------------------------+ | |
584 | |
585 PURPOSE : stop sms timer | |
586 | |
587 */ | |
588 GLOBAL void sms_timer_stop (USHORT id) | |
589 { | |
590 GET_INSTANCE_DATA; | |
591 tim_stop_timer (((USHORT)(id*MAX_SMS_CALLS+sms_data->inst))); | |
592 } | |
593 | |
594 /* | |
595 +--------------------------------------------------------------------+ | |
596 | PROJECT : GSM-PS (8410) MODULE : SMS_TIM | | |
597 | STATE : code ROUTINE : sms_timer_check | | |
598 +--------------------------------------------------------------------+ | |
599 | |
600 PURPOSE : check sms timer whether currently running | |
601 returns TRUE if given timer running | |
602 | |
603 */ | |
604 GLOBAL BOOL sms_timer_check (USHORT id) | |
605 { | |
606 GET_INSTANCE_DATA; | |
607 TRACE_FUNCTION ("sms_timer_check()"); | |
608 | |
609 return (SMS_INST.t_running[id]); | |
610 } | |
611 | |
612 #endif /* #ifndef SMS_TIM_C */ |