comparison gsm-fw/g23m-gsm/sms/sms_csf.c @ 673:2f7df7a314f8

gsm-fw/g23m-gsm subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 28 Sep 2014 23:20:04 +0000
parents
children 3b690364119a
comparison
equal deleted inserted replaced
672:0dc6f9e8e980 673:2f7df7a314f8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : SMS_CSF
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 custom specific functions
18 | for the component SMS of the mobile station
19 |
20 | Use this module to integrate the entity
21 | in your target system !
22 +-----------------------------------------------------------------------------
23 */
24
25 #ifndef SMS_CSF_C
26 #define SMS_CSF_C
27
28 #define ENTITY_SMS
29
30 /*==== INCLUDES ===================================================*/
31
32 #include <string.h>
33 #include <stdlib.h>
34 #include <stddef.h>
35 #include "typedefs.h"
36 #include "pcm.h"
37 #include "vsi.h"
38 #include "custom.h"
39 #include "gsm.h"
40 #include "message.h"
41 #include "ccdapi.h"
42 #include "prim.h"
43 #include "cus_sms.h"
44 #include "cnf_sms.h"
45 #include "mon_sms.h"
46 #include "pei.h"
47 #include "tok.h"
48 #include "sms.h"
49
50 /*==== EXPORT =====================================================*/
51
52 /*==== PRIVAT =====================================================*/
53
54 /*==== VARIABLES ==================================================*/
55
56 /*==== FUNCTIONS ==================================================*/
57
58 /*
59 +--------------------------------------------------------------------+
60 | PROJECT : GSM-PS (8410) MODULE : SMS_CSF |
61 | STATE : code ROUTINE : csf_get_sms_instance |
62 +--------------------------------------------------------------------+
63
64 PURPOSE : Checks the transaction identitfier and sets the instance.
65
66 */
67
68 GLOBAL T_SMS_DATA* csf_get_sms_instance (UBYTE ti)
69 {
70 GET_INSTANCE_DATA;
71
72 TRACE_FUNCTION ("csf_get_sms_instance()");
73
74 if (ti < 8)
75 {
76 /*
77 * mobile originated transaction
78 */
79 sms_data->inst = INST_MO;
80
81 return sms_data;
82 }
83
84 if (ti >= 8)
85 {
86 /*
87 * mobile terminated transaction
88 */
89 if (sms_data->data[INST_MT].ti EQ ti)
90 {
91 sms_data->inst = INST_MT;
92
93 return sms_data;
94 }
95 else
96 return NULL;
97 }
98
99 return NULL;
100 }
101
102 /*
103 +--------------------------------------------------------------------+
104 | PROJECT : GSM-PS (8410) MODULE : SMS_CSF |
105 | STATE : code ROUTINE : csf_get_new_sms_instance |
106 +--------------------------------------------------------------------+
107
108 PURPOSE : Checks the transaction identitfier and sets the instance.
109
110 */
111 GLOBAL UBYTE csf_get_new_mo_ti()
112 {
113 T_SMS_DATA *sms_data = GET_INSTANCE(0);
114 UBYTE ti = sms_data->data[INST_MO].ti+1;
115 /*
116 * mobile originated transaction, valid ti has to be in set [0..6]
117 */
118 if (ti >= 7)
119 {
120 ti=0;
121 }
122 return ti;
123 }
124
125 GLOBAL T_SMS_DATA * csf_get_new_sms_instance (UBYTE ti)
126 {
127 T_SMS_DATA *sms_data = GET_INSTANCE(0);
128
129 TRACE_FUNCTION ("csf_get_new_sms_instance()");
130
131 if (ti < 8)
132 {
133 /*
134 * mobile originated transaction, valid ti has to be in set [0..6]
135 */
136 sms_data->inst = INST_MO;
137 // sms_data->data[INST_MO].ti++;
138 // if (sms_data->data[INST_MO].ti >= 7)
139 // sms_data->data[INST_MO].ti = 0;
140
141 return sms_data;
142 }
143
144 if (ti >= 8)
145 {
146 /*
147 * mobile terminated transaction
148 */
149 if (sms_data->data[INST_MT].ti EQ 0)
150 {
151 /*
152 * The mobile terminated part of SMS is IDLE
153 */
154 sms_data->inst = INST_MT;
155 sms_data->data[INST_MT].ti = ti;
156
157 return sms_data;
158 }
159 }
160
161 return NULL;
162 }
163
164 /*
165 +--------------------------------------------------------------------+
166 | PROJECT : GSM-PS (8410) MODULE : SMS_CSF |
167 | STATE : code ROUTINE : csf_free_sms_instance |
168 +--------------------------------------------------------------------+
169
170 PURPOSE : Checks the transaction identifier and frees the instance.
171
172 */
173
174 GLOBAL void csf_free_sms_instance (UBYTE ti)
175 {
176 T_SMS_DATA *sms_data = GET_INSTANCE(0);
177
178 TRACE_FUNCTION_P1 ("csf_free_sms_instance(TI=%u)", ti);
179
180 //#if defined (GPRS)
181 // SMS_INST.downlink = SMS_DOWNLINK_NONE;
182 //#endif
183
184 if (ti >= 8)
185 {
186 /*
187 * mobile terminated transaction
188 */
189 if (sms_data->data[INST_MT].ti EQ ti)
190 sms_data->data[INST_MT].ti = 0;
191
192 if (SMS_RP_RCVD(sms_data) NEQ NULL)
193 {
194 MFREE (SMS_RP_RCVD(sms_data));
195 SMS_RP_RCVD(sms_data) = NULL;
196 }
197 }
198 /* Commented out as this is used for
199 retransmission of the failed message
200 if (SMS_DATA_REQ(sms_data) NEQ NULL)
201 {
202 PFREE (SMS_DATA_REQ(sms_data));
203 SMS_DATA_REQ(sms_data) = NULL;
204 }
205 */
206 if (SMS_SDU(sms_data) NEQ NULL)
207 {
208 MFREE (SMS_SDU(sms_data));
209 SMS_SDU(sms_data) = NULL;
210 }
211 if (SMS_SIM_READ(sms_data) NEQ NULL)
212 {
213 PFREE (SMS_SIM_READ(sms_data));
214 SMS_SIM_READ(sms_data) = NULL;
215 }
216 }
217
218
219 #endif /* #ifndef SMS_CSF_C */