comparison src/aci2/aci/cmh_lcs.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_LCS
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 provides the set functions related to the
18 | protocol stack adapter for the location service.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_LCS_C
23 #define CMH_LCS_C
24 #endif
25
26 #ifdef FF_EOTD
27
28 #ifdef MFW
29 #define ENTITY_MFW
30 #else
31 #ifdef SMI
32 #define ENTITY_SMI
33 #else
34 #define ENTITY_ACI
35 #endif
36 #endif
37
38 #define ACI_MEMBER
39
40 /*==== INCLUDES ===================================================*/
41 #include "aci_all.h"
42 #include "aci_cmh.h"
43 #include "ati_cmd.h"
44 #include "aci_cmd.h"
45
46 #include "aci_mem.h"
47 #include "psa.h"
48 #include "cmh.h"
49 #include "psa_util.h"
50
51 #if defined(_TMS470)
52 #include "ffs/ffs.h"
53 #include "ffs_coat.h"
54 #endif
55
56 #include "aci.h"
57 #include "aci_lst.h"
58 #include "cmh_lc.h"
59 /* needed for CPS test */
60 #include "l4_tim.h"
61 /*==== CONSTANTS ==================================================*/
62 #define MAX_LC_CALLREF 5
63 #define CLPS_DEF_PER_UP_VALUE 0x000f
64 /*==== EXPORT =====================================================*/
65 EXTERN CHAR *parse(CHAR *b,CHAR *f, ...);
66 EXTERN T_ACI_LIST *ati_src_list;
67
68 #if defined(_TMS470)
69 EXTERN UBYTE search_tim_handl(void);
70 EXTERN U8 lc_cps_traces;
71 EXTERN U32 lc_msmsnr;
72 #endif
73 /*==== VARIABLES ==================================================*/
74 /*==== FUNCTIONS ==================================================*/
75 /*
76 +-------------------------------------------------------------------+
77 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
78 | ROUTINE : lc_callref_init |
79 +-------------------------------------------------------------------+
80
81 PURPOSE : search callreference for location service request
82 */
83 GLOBAL UBYTE lc_callref_init (void)
84 {
85 int i;
86 UBYTE tst_id;
87
88 for (i = 0; i <= MAX_LC_CALLREF; i++)
89 {
90 tst_id = (0x01 << i) & used_lc_callref;
91 if (!tst_id)
92 break;
93 }
94 if (tst_id)
95 return (0);
96 used_lc_callref |= (0x01 << i);
97 return (i);
98 }
99
100 #if defined(_TMS470)
101 LOCAL const char* lc_client_list[]=
102 {
103 {"/gsm/lc/01"},
104 {"/gsm/lc/02"},
105 {"/gsm/lc/03"},
106 {"/gsm/lc/04"},
107 {"/gsm/lc/05"}
108 };
109 #endif
110
111 #if defined(_TMS470)
112 /*
113 +-------------------------------------------------------------------+
114 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
115 | STATE : code ROUTINE : store_lc_flag_nvm |
116 +-------------------------------------------------------------------+
117
118 PURPOSE : This function stores the LC flag in NVM
119 */
120
121 T_ACI_RETURN store_lc_flag_nvm(BOOL lc_flag)
122 {
123 TRACE_FUNCTION ("store_lc_flag_nvm ()");
124
125 switch(FFS_mkdir("/gsm/lc"))
126 {/* create/check ffs directory for LC clients */
127 case EFFS_OK:
128 case EFFS_EXISTS:
129 break;
130 default:
131 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
132 return ( AT_FAIL );
133 }
134 if(FFS_fwrite("/gsm/lc/lc_flag",&location_service_flag, sizeof(BOOL)) NEQ EFFS_OK)
135 {
136 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
137 return ( AT_FAIL );
138 }
139 return AT_CMPL;
140 }
141
142 /*
143 +-------------------------------------------------------------------+
144 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
145 | STATE : code ROUTINE : store_lc_per_flag_nvm |
146 +-------------------------------------------------------------------+
147
148 PURPOSE : This function stores the LC periodic update flag in NVM
149 */
150
151 T_ACI_RETURN store_lc_per_flag_nvm(BOOL lc_per_flag)
152 {
153 TRACE_FUNCTION ("store_lc_per_flag_nvm ()");
154
155 switch(FFS_mkdir("/gsm/lc"))
156 {/* create/check ffs directory for LC clients */
157 case EFFS_OK:
158 case EFFS_EXISTS:
159 break;
160 default:
161 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
162 return ( AT_FAIL );
163 }
164 if(FFS_fwrite("/gsm/lc/lc_per_flag",&eotd_periodic_update_flag, sizeof(BOOL)) NEQ EFFS_OK)
165 {
166 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
167 return ( AT_FAIL );
168 }
169 return AT_CMPL;
170 }
171
172
173 /*
174 +-------------------------------------------------------------------+
175 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
176 | STATE : code ROUTINE : store_lc_clients_nvm |
177 +-------------------------------------------------------------------+
178
179 PURPOSE : This function stores the LC clients in FFS
180 */
181 T_ACI_RETURN store_lc_clients_nvm(void)
182 {
183 T_LOC_SERV_PARA *p_lsprm = 0;
184 T_LOC_SERV_CLIENT *p_client = 0;
185 char client_index;
186
187 TRACE_FUNCTION ("store_lc_clients_nvm ()");
188
189 p_lsprm = &locServPrm; /* global structure LC parameters */
190 p_client = p_lsprm->clients;
191 if(p_client NEQ NULL)
192 {
193 client_index = 0;
194 do
195 {
196 if(FFS_fwrite(lc_client_list[client_index],p_client, sizeof(*p_client)) NEQ EFFS_OK)
197 {
198 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
199 return ( AT_FAIL );
200 }
201 TRACE_EVENT_P1("store_lc_clients_nvm success index=%d", client_index);
202 client_index++;
203 p_client = p_client->next;
204 }
205 while(p_client NEQ NULL);
206 }
207 return ( AT_CMPL );
208 }
209
210 /*
211 +-------------------------------------------------------------------+
212 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
213 | STATE : code ROUTINE : remove_lc_clients_nvm |
214 +-------------------------------------------------------------------+
215
216 PURPOSE : This function removes the last LC client from FFS
217 */
218 T_ACI_RETURN remove_lc_clients_nvm(void)
219 {
220 T_LOC_SERV_PARA *p_lsprm = 0;
221 T_LOC_SERV_CLIENT *p_client = 0;
222 char client_index = 0;
223
224 TRACE_FUNCTION ("remove_lc_clients_nvm ()");
225
226 p_lsprm = &locServPrm; /* global structure LC parameters */
227 for (p_client = p_lsprm->clients; p_client NEQ NULL AND p_client->next NEQ NULL;)
228 {
229 client_index++;
230 p_client = p_client->next;
231 }
232
233 if(FFS_remove(lc_client_list[client_index]) NEQ EFFS_OK)
234 {
235 TRACE_EVENT("remove_lc_clients_nvm error");
236 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
237 return ( AT_FAIL );
238 }
239 TRACE_EVENT_P1("remove_lc_clients_nvm success index=%s", lc_client_list[client_index]);
240 return ( AT_CMPL );
241 }
242 #endif
243
244
245 /*
246 +-------------------------------------------------------------------+
247 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
248 | STATE : code ROUTINE : store_lc_clsa_addr_nvm |
249 +-------------------------------------------------------------------+
250
251 PURPOSE : This function stores the source and destination information
252 of +CLSA in NVM
253 */
254
255 T_ACI_RETURN store_lc_clsa_addr_nvm(T_LOC_MLC_ADDRESS *src_addr, T_LOC_MLC_ADDRESS *dest_addr)
256 {
257 TRACE_FUNCTION ("store_lc_clsa_addr_nvm ()");
258
259 #if defined(_TMS470)
260 switch(FFS_mkdir("/gsm/lc"))
261 {/* create/check ffs directory for LC clients */
262 case EFFS_OK:
263 case EFFS_EXISTS:
264 break;
265 default:
266 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
267 return ( AT_FAIL );
268 }
269 if(FFS_fwrite("/gsm/lc/lc_src_addr",src_addr, sizeof(T_LOC_MLC_ADDRESS)) NEQ EFFS_OK)
270 {
271 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
272 return ( AT_FAIL );
273 }
274 if(FFS_fwrite("/gsm/lc/lc_dest_addr",dest_addr, sizeof(T_LOC_MLC_ADDRESS)) NEQ EFFS_OK)
275 {
276 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
277 return ( AT_FAIL );
278 }
279 #endif
280 return AT_CMPL;
281 }
282
283 /*
284 +-------------------------------------------------------------------+
285 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
286 | STATE : code ROUTINE : sAT_PlusCLSA |
287 +-------------------------------------------------------------------+
288
289 PURPOSE : This is the functional counterpart of the +CLSA
290 AT command which is responsible for setting the
291 Service Mobile Location Center source and
292 destination address.
293
294 <mlcsc>: mobile location center source address
295 <mlcda>: mobile location center destination address
296 */
297 GLOBAL T_ACI_RETURN sAT_PlusCLSA ( T_ACI_CMD_SRC srcId,
298 CHAR* mlcsc,
299 CHAR* mlcda )
300 {
301 T_LOC_SERV_PARA *p_lsprm = 0;
302 char * rest_addr;
303
304 TRACE_FUNCTION ("sAT_PlusCLSA ()");
305 /*
306 *-----------------------------------------------------------------
307 * check command source
308 *-----------------------------------------------------------------
309 */
310 if(!cmh_IsVldCmdSrc (srcId))
311 {
312 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec);
313 return( AT_FAIL );
314 }
315
316 p_lsprm = &locServPrm; /* global structure LC parameters */
317 memset(p_lsprm->mlcsrc.address,0,MAX_SMS_ADDR_DIG);
318 memset(p_lsprm->mlcdest.address,0,MAX_SMS_ADDR_DIG);
319 /*
320 *-----------------------------------------------------------------
321 * check type of number of SMLC source address
322 *-----------------------------------------------------------------
323 */
324 rest_addr = mlcsc;
325 rest_addr = cmh_setToaDef (mlcsc, &p_lsprm -> mlcsrc.toa);
326 /*
327 *-----------------------------------------------------------------
328 * process the <mlcsc> parameter
329 *-----------------------------------------------------------------
330 */
331 if ( rest_addr NEQ NULL )
332 {
333 strncpy(p_lsprm->mlcsrc.address,rest_addr,strlen(rest_addr));
334 /*
335 *-----------------------------------------------------------------
336 * check type of number of SMLC destination address
337 *-----------------------------------------------------------------
338 */
339 rest_addr = mlcda;
340 rest_addr = cmh_setToaDef (mlcda, &p_lsprm -> mlcdest.toa);
341 /*
342 *-----------------------------------------------------------------
343 * process the <mlcda> parameter
344 *-----------------------------------------------------------------
345 */
346 if ( rest_addr NEQ NULL )
347 {
348 strncpy(p_lsprm->mlcdest.address,rest_addr,strlen(rest_addr));
349 store_lc_clsa_addr_nvm(&p_lsprm->mlcsrc,&p_lsprm->mlcdest);
350 }
351 else
352 {
353 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
354 return ( AT_FAIL );
355 }
356 return ( AT_CMPL );
357 }
358 else
359 {
360 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
361 return ( AT_FAIL );
362 }
363 }
364 /*
365 +-------------------------------------------------------------------+
366 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
367 | STATE : code ROUTINE : sAT_PlusCLOM |
368 +-------------------------------------------------------------------+
369
370 PURPOSE : This is the functional counterpart of the +CLOM
371 AT command which is responsible for handling of feature
372 flag LC and LC clients
373
374 <clomset>: settings of CLOM
375 <lc_clientId>: client identifier
376 */
377 GLOBAL T_ACI_RETURN sAT_PlusCLOM ( T_ACI_CMD_SRC srcId,
378 CHAR clomset,
379 CHAR* lc_clientId )
380 {
381 T_LOC_SERV_PARA *p_lsprm = 0;
382 T_LOC_SERV_CLIENT *p_client = 0;
383 T_LOC_SERV_CLIENT *p_client_curr = 0;
384 T_LOC_SERV_CLIENT *p_client_prev = 0;
385 T_LOC_SERV_CLIENT *p_client_new = 0;
386 T_LOC_SERV_CLIENT *p_client_next = 0;
387 char * rest_addr = 0;
388 char client_index,clom_flag;
389 T_ACI_TOA toa_clId;
390
391 TRACE_FUNCTION ("sAT_PlusCLOM ()");
392
393 /*-----------------------------------------------------------------
394 * check command source
395 *-----------------------------------------------------------------
396 */
397 if(!cmh_IsVldCmdSrc (srcId))
398 {
399 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
400 return( AT_FAIL );
401 }
402 p_lsprm = &locServPrm; /* global structure LC parameters */
403 TRACE_EVENT_P4("num_client=%d location_service_flag=%d eotd_periodic_update_flag=%d clients=%08x",
404 p_lsprm->numb_lc_clients,
405 location_service_flag,
406 eotd_periodic_update_flag,
407 p_lsprm->clients);
408 TRACE_EVENT_P6("SC_sAdddr=%s ton=%d npi=%d SC_dAddr=%s",
409 p_lsprm->mlcsrc.address, p_lsprm->mlcsrc.toa.ton, p_lsprm->mlcsrc.toa.npi,
410 p_lsprm->mlcdest.address, p_lsprm->mlcdest.toa.ton, p_lsprm->mlcdest.toa.npi);
411
412 switch(clomset)
413 {
414 case CLOM_LCS_UNKNOWN: /* missing CLOM setting */
415 clom_flag = FALSE;
416 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
417 return( AT_FAIL );
418 case CLOM_LCS_NO_ACT: /* LCS not active for certain client id or for all clients */
419 if(*lc_clientId EQ '0') /* setting is valid for all LCS clients */
420 {/* switch OFF E-OTD feature flag */
421 location_service_flag = LOCATION_SERVICE_OFF;
422 clom_flag = TRUE;
423 /* switch OFF E-OTD of each client id */
424 if(p_lsprm->numb_lc_clients >0)
425 {
426 p_client = p_lsprm->clients;
427 if(p_client EQ NULL)
428 {
429 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
430 return ( AT_FAIL );
431 }
432 do
433 {
434 p_client->client_status = CLIENT_NO_ACTIVE;
435 p_client = p_client->next;
436 }
437 while(p_client NEQ NULL);
438 }
439 }
440 else
441 {
442 /* look for client entry in list and reset client id status */
443 if(p_lsprm->numb_lc_clients >0)
444 {
445 /* check type of delivered client id */
446 memset(&toa_clId,0,sizeof(T_ACI_TOA));
447 rest_addr = lc_clientId;
448 rest_addr = cmh_setToaDef (lc_clientId, &toa_clId);
449 clom_flag = FALSE;
450 p_client = p_lsprm->clients;
451 if(p_client EQ NULL)
452 {
453 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
454 return ( AT_FAIL );
455 }
456 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
457 {
458 if(!strcmp(p_client->client_id.address,rest_addr))
459 {
460 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
461 {
462 p_client->client_status = CLIENT_NO_ACTIVE;
463 clom_flag = TRUE;
464 }
465 }
466 if(!p_client->next)
467 break;
468 p_client = p_client->next;
469 }
470 if(clom_flag EQ FALSE)
471 {
472 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
473 return ( AT_FAIL );
474 }
475 }
476 else
477 { /* there are not LCS clients in the list */
478 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
479 return ( AT_FAIL );
480 }
481 }
482 #if defined(_TMS470)
483 if(clom_flag EQ TRUE)
484 {/* store all clients and lc flag */
485 store_lc_flag_nvm(location_service_flag);
486 store_lc_clients_nvm();
487 }
488 #endif
489 return(AT_CMPL);
490 case CLOM_LCS_ACT:
491 if(*lc_clientId EQ '1')
492 {
493 /* switch ON E-OTD feature flag */
494 location_service_flag = LOCATION_SERVICE_ON;
495 clom_flag = TRUE;
496 /* switch ON E-OTD of each client id */
497 if(p_lsprm->numb_lc_clients >0)
498 {
499 p_client = p_lsprm->clients;
500 if(p_client EQ NULL)
501 {
502 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
503 return ( AT_FAIL );
504 }
505 do
506 {
507 p_client->client_status = CLIENT_ACTIVE;
508 p_client = p_client->next;
509 }
510 while(p_client NEQ NULL);
511 }
512 }
513 else
514 {
515 /* look for client entry in list and activate client id status */
516 if(p_lsprm->numb_lc_clients >0)
517 {
518 /* check type of delivered client id */
519 memset(&toa_clId,0,sizeof(T_ACI_TOA));
520 rest_addr = lc_clientId;
521 rest_addr = cmh_setToaDef (lc_clientId, &toa_clId);
522 clom_flag = FALSE;
523 p_client = p_lsprm->clients;
524 if(p_client EQ NULL)
525 {
526 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
527 return ( AT_FAIL );
528 }
529 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
530 {
531 if(!strcmp(p_client->client_id.address,rest_addr))
532 {
533 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
534 {
535 p_client->client_status = CLIENT_ACTIVE;
536 clom_flag = TRUE;
537 }
538 }
539 if(!p_client->next)
540 break;
541 p_client = p_client->next;
542 }
543 if(clom_flag EQ FALSE)
544 {
545 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
546 return ( AT_FAIL );
547 }
548 }
549 else
550 { /* there are not LCS clients in the list */
551 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
552 return ( AT_FAIL );
553 }
554 }
555 #if defined(_TMS470)
556 if(clom_flag EQ TRUE)
557 {/* store all clients and lc flag */
558 store_lc_flag_nvm(location_service_flag);
559 store_lc_clients_nvm();
560 }
561 #endif
562 return(AT_CMPL);
563 case CLOM_LCS_CLIENT_DEL:
564 /* look for client entry in list and reset client id status */
565 clom_flag = FALSE;
566 if(p_lsprm->numb_lc_clients >0)
567 {
568 /* check type of delivered client id */
569 memset(&toa_clId,0,sizeof(T_ACI_TOA));
570 rest_addr = lc_clientId;
571 rest_addr = cmh_setToaDef (lc_clientId, &toa_clId);
572
573 if(p_lsprm->clients EQ NULL)
574 {
575 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
576 return ( AT_FAIL );
577 }
578 p_client_curr = p_lsprm->clients;
579 p_client_prev = NULL;
580
581 while(p_client_curr NEQ NULL)
582 {
583 if(!strcmp(p_client_curr->client_id.address,rest_addr))
584 {
585 if(toa_merge(toa_clId) EQ toa_merge(p_client_curr->client_id.toa))
586 {
587 p_lsprm->numb_lc_clients--;
588 clom_flag = TRUE;
589 break;
590 }
591 }
592 p_client_prev = p_client_curr;
593 p_client_curr = p_client_curr->next;
594 }
595 if(clom_flag EQ TRUE)
596 {
597 #if defined(_TMS470)
598 remove_lc_clients_nvm();
599 #endif
600 if (p_client_prev EQ NULL)
601 {/* first LC client should be removed */
602 if (p_client_curr->next EQ NULL)
603 {/* one element in list */
604 p_client_curr = NULL;
605 }
606 else
607 {/* overwrite LC client with the next LC client */
608 p_client_next = p_client_curr->next;
609 strncpy(p_client_curr->client_id.address,p_client_next->client_id.address,strlen(p_client_next->client_id.address));
610 p_client_curr->client_id.toa.ton = p_client_next->client_id.toa.ton;
611 p_client_curr->client_id.toa.npi = p_client_next->client_id.toa.npi;
612 p_client_curr->client_status = p_client_next->client_status;
613 p_client_curr->next = p_client_next->next;
614 ACI_MFREE (p_client_next);
615 #if defined(_TMS470)
616 store_lc_clients_nvm();
617 #endif
618 return(AT_CMPL);
619 }
620 }
621 else
622 {
623 if(p_client_curr->next NEQ NULL)
624 {
625 p_client_prev->next = p_client_curr->next;
626 }
627 ACI_MFREE (p_client_curr);
628 #if defined(_TMS470)
629 store_lc_clients_nvm();
630 #endif
631 return(AT_CMPL);
632 }
633 }
634 else
635 {
636 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
637 return ( AT_FAIL );
638 }
639 }
640 else
641 { /* there are not LCS clients in the list */
642 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
643 return ( AT_FAIL );
644 }
645 case CLOM_LCS_CLIENT_NEW:
646 /* look for client entries in list */
647 if(p_lsprm->numb_lc_clients < MAX_NUMB_LC_CLIENTS)
648 {
649 /* check type of delivered client id */
650 memset(&toa_clId,0,sizeof(T_ACI_TOA));
651 rest_addr = lc_clientId;
652 rest_addr = cmh_setToaDef (lc_clientId, &toa_clId);
653 p_lsprm->numb_lc_clients++;
654 ACI_MALLOC(p_client_new,sizeof(T_LOC_SERV_CLIENT));
655 memset(p_client_new,0,sizeof(T_LOC_SERV_CLIENT));
656 for(client_index=0;client_index<MAX_NUMB_LC_CLIENTS-1;client_index++)
657 {
658 if(p_lsprm->clients EQ NULL)
659 {/* create new LC client and activate */
660 p_lsprm->clients = p_client_new;
661 strncpy(p_lsprm->clients->client_id.address,rest_addr,strlen(rest_addr));
662 p_lsprm->clients->client_id.toa.ton = toa_clId.ton;
663 p_lsprm->clients->client_id.toa.npi = toa_clId.npi;
664 p_lsprm->clients->client_status = CLIENT_ACTIVE;
665 p_lsprm->clients->period_upd_status = PERIODIC_UP_NO_ACTIVE;
666 p_lsprm->clients->period_upd_value = CLPS_DEF_PER_UP_VALUE;/* default value 15 min */
667 p_lsprm->clients->notify = FALSE;
668 p_lsprm->clients->confirmation = FALSE;
669 p_lsprm->clients->period_upd_timer = 0; /* no timer entry */
670 p_lsprm->clients->lc_clientReference = -1;
671 p_lsprm->clients->next = NULL;
672 break;
673 }
674 else
675 {
676 p_client_curr = p_lsprm->clients;
677 while(p_client_curr->next)
678 {
679 p_client_curr = p_client_curr->next;
680 }
681 p_client_curr->next = p_client_new;
682 strncpy(p_client_curr->next->client_id.address,rest_addr,strlen(rest_addr));
683 p_client_curr->next->client_id.toa.ton = toa_clId.ton;
684 p_client_curr->next->client_id.toa.npi = toa_clId.npi;
685 p_client_curr->next->client_status = CLIENT_ACTIVE;
686 p_lsprm->clients->period_upd_status = PERIODIC_UP_NO_ACTIVE;
687 p_lsprm->clients->period_upd_value = CLPS_DEF_PER_UP_VALUE;/* default value 15 min */
688 p_lsprm->clients->notify = FALSE;
689 p_lsprm->clients->confirmation = FALSE;
690 p_lsprm->clients->period_upd_timer = 0; /* no timer entry */
691 p_lsprm->clients->lc_clientReference = -1;
692 p_client_curr->next->next = NULL;
693 break;
694 }
695 }
696 #if defined(_TMS470)
697 /* store all clients and lc flag */
698 store_lc_clients_nvm();
699 #endif
700 return(AT_CMPL);
701 }
702 else
703 { /* LCS clients list is full */
704 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
705 return ( AT_FAIL );
706 }
707 default:
708 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
709 return( AT_FAIL );
710 }
711 }
712
713 /*
714 +-------------------------------------------------------------------+
715 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
716 | STATE : code ROUTINE : cmhLC_posDataReq |
717 +-------------------------------------------------------------------+
718
719 PURPOSE : This function sends the primitive MNLC_SMS_MEAS_REQ
720
721 <client_id>: service id requesting position data
722 <lcCallRefId>: SMS reference ID
723 */
724 GLOBAL void cmhLC_posDataReq (char* clientId,
725 USHORT lcCallRefId)
726 {
727 char client_id_bcd[MAX_SMS_ADDR_DIG];
728 UBYTE max_bcd,max_packed_bcd;
729
730 TRACE_FUNCTION ("cmhLC_posDataReq ()");
731 {
732 PALLOC (mnlc_sms_meas_req, MNLC_SMS_MEAS_REQ);
733
734 mnlc_sms_meas_req->reference = lcCallRefId;
735 max_bcd =(UBYTE) utl_dialStr2BCD (clientId,(UBYTE *)client_id_bcd,(UBYTE)strlen(clientId));
736 max_packed_bcd =(UBYTE)cmh_packBCD(mnlc_sms_meas_req->called_party_bcd_num.bcd, (UBYTE *)client_id_bcd, (USHORT)max_bcd);
737 mnlc_sms_meas_req->called_party_bcd_num.number_length = max_packed_bcd;
738
739 PSENDX(LC,mnlc_sms_meas_req);
740 }
741 }
742
743 /*
744 +-------------------------------------------------------------------+
745 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
746 | STATE : code ROUTINE : sAT_PlusCLPS |
747 +-------------------------------------------------------------------+
748
749 PURPOSE : This is the functional counterpart of the +CLPS
750 AT command which is responsible for request the
751 position data of MS
752 <clpsset>: enabled/disabled feature Periodic Update Setting
753 <lc_clientId>: client address requesting position data
754 <cltimer>: periodic update value
755 */
756 GLOBAL T_ACI_RETURN sAT_PlusCLPS ( T_ACI_CMD_SRC srcId,
757 CHAR clpsset,
758 CHAR* lcclientId,
759 USHORT cltimer)
760 {
761 T_LOC_SERV_PARA *p_lsprm = 0;
762 T_LOC_SERV_CLIENT *p_client = 0;
763 char * rest_addr = 0;
764 char client_index,clps_flag;
765 T_ACI_TOA toa_clId;
766 USHORT lc_callref;
767 TRACE_FUNCTION ("sAT_PlusCLPS ()");
768
769 /*-----------------------------------------------------------------
770 * check command source
771 *-----------------------------------------------------------------
772 */
773 if(!cmh_IsVldCmdSrc (srcId))
774 {
775 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
776 return( AT_FAIL );
777 }
778 p_lsprm = &locServPrm; /* global structure LC parameters */
779 switch(clpsset)
780 {
781 case CLPS_LCS_UNKNOWN: /* missing CLPS setting */
782 clps_flag = FALSE;
783 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
784 return( AT_FAIL );
785 case CLPS_LCS_NO_ACT: /* Periodic Update not active for certain client id or for all clients */
786 if(*lcclientId EQ '0') /* setting is valid for all LCS clients */
787 {/* switch OFF periodic update feature flag */
788 eotd_periodic_update_flag = PERIODIC_UPDATE_OFF;
789 clps_flag = TRUE;
790 /* switch OFF periodic update of each client id */
791 if(p_lsprm->numb_lc_clients >0)
792 {
793 p_client = p_lsprm->clients;
794 if(p_client EQ NULL)
795 {
796 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec);
797 return ( AT_FAIL );
798 }
799 do
800 {
801 p_client->period_upd_status = PERIODIC_UP_NO_ACTIVE;
802 p_client->period_upd_value = CLPS_DEF_PER_UP_VALUE;
803 p_client = p_client->next;
804 }
805 while(p_client NEQ NULL);
806 }
807 }
808 else
809 {
810 /* look for client entry in list and reset client id status */
811 if(p_lsprm->numb_lc_clients >0)
812 {
813 /* check type of delivered client id */
814 memset(&toa_clId,0,sizeof(T_ACI_TOA));
815 rest_addr = lcclientId;
816 rest_addr = cmh_setToaDef (lcclientId, &toa_clId);
817 clps_flag = FALSE;
818 p_client = p_lsprm->clients;
819 if(p_client EQ NULL)
820 {
821 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
822 return ( AT_FAIL );
823 }
824 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
825 {
826 if(!strcmp(p_client->client_id.address,rest_addr))
827 {
828 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
829 {
830 p_client->period_upd_status = PERIODIC_UP_NO_ACTIVE;
831 p_client->period_upd_value = CLPS_DEF_PER_UP_VALUE;
832 clps_flag = TRUE;
833 }
834 }
835 if(!p_client->next)
836 break;
837 p_client = p_client->next;
838 }
839 if(clps_flag EQ FALSE)
840 {
841 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
842 return ( AT_FAIL );
843 }
844 }
845 else
846 { /* there are not LCS clients in the list */
847 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
848 return ( AT_FAIL );
849 }
850 }
851 #if defined(_TMS470)
852 if(clps_flag EQ TRUE)
853 {/* store all clients and lc flag */
854 store_lc_per_flag_nvm(eotd_periodic_update_flag);
855 store_lc_clients_nvm();
856 }
857 #endif
858 clps_flag = FALSE;
859 return(AT_CMPL);
860 case CLPS_LCS_ACT:
861 if(cltimer NEQ IMM_POS_DATA_REQ)
862 {
863 if(*lcclientId EQ '1')
864 {
865 /* switch ON E-OTD feature flag */
866 eotd_periodic_update_flag = PERIODIC_UPDATE_ON;
867 clps_flag = TRUE;
868 /* switch ON periodic update of each client id */
869 if(p_lsprm->numb_lc_clients >0)
870 {
871 p_client = p_lsprm->clients;
872 if(p_client EQ NULL)
873 {
874 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
875 return ( AT_FAIL );
876 }
877 do
878 {
879 p_client->period_upd_status = PERIODIC_UP_ACTIVE;
880 /* start position data request */
881 lc_callref = (USHORT)lc_callref_init();
882 if(!lc_callref)
883 {
884 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec);
885 return ( AT_FAIL );
886 }
887 p_client->lc_clientReference = lc_callref;
888 cmhLC_posDataReq (p_client->client_id.address, lc_callref);
889 p_client = p_client->next;
890 }
891 while(p_client NEQ NULL);
892 }
893 }
894 else
895 {
896 /* look for client entry in list and activate client id status */
897 if(p_lsprm->numb_lc_clients >0)
898 {
899 /* check type of delivered client id */
900 memset(&toa_clId,0,sizeof(T_ACI_TOA));
901 rest_addr = lcclientId;
902 rest_addr = cmh_setToaDef (lcclientId, &toa_clId);
903 clps_flag = FALSE;
904 p_client = p_lsprm->clients;
905 if(p_client EQ NULL)
906 {
907 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
908 return ( AT_FAIL );
909 }
910 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
911 {
912 if(!strcmp(p_client->client_id.address,rest_addr))
913 {
914 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
915 {
916 p_client->period_upd_status = PERIODIC_UP_ACTIVE;
917 if(cltimer<=120)
918 p_client->period_upd_value = cltimer;
919 else
920 {
921 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_IntervalNotSup);
922 return ( AT_FAIL );
923 }
924 clps_flag = TRUE;
925 /* start position data request */
926 lc_callref = (USHORT)lc_callref_init();
927 if(!lc_callref)
928 {
929 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
930 return ( AT_FAIL );
931 }
932 p_client->lc_clientReference = lc_callref;
933 cmhLC_posDataReq (p_client->client_id.address,lc_callref);
934 }
935 }
936 if(!p_client->next)
937 break;
938 p_client = p_client->next;
939 }
940 if(clps_flag EQ FALSE)
941 {
942 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
943 return ( AT_FAIL );
944 }
945 }
946 else
947 { /* there are not LCS clients in the list */
948 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLPSClientNotRec );
949 return ( AT_FAIL );
950 }
951 }
952 if(clps_flag EQ TRUE)
953 { /* store all clients and lc flag */
954 #if defined(_TMS470)
955 store_lc_per_flag_nvm(eotd_periodic_update_flag);
956 store_lc_clients_nvm();
957 #endif
958 clps_flag = FALSE;
959 return ( AT_EXCT );
960 }
961 return(AT_CMPL); /* no position data request */
962 }
963 else /* immediately position data request (via CLSA, SMS) */
964 {
965 lc_callref = (USHORT)lc_callref_init();
966 if(!lc_callref)
967 {
968 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
969 return ( AT_FAIL );
970 }
971 p_lsprm->lc_callReference = lc_callref;
972 cmhLC_posDataReq (lcclientId,lc_callref);
973 return ( AT_EXCT );
974 }
975 default:
976 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
977 return ( AT_FAIL );
978 }
979 }
980
981
982 /*
983 +-------------------------------------------------------------------+
984 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
985 | STATE : code ROUTINE : sAT_PlusCLSR |
986 +-------------------------------------------------------------------+
987
988 PURPOSE : This is the functional counterpart of the +CLSR
989 AT command which is responsible for setting of privacy parameters,
990 request position data (not supported currently RM 10-25-02)
991 setup call (not supported currently RM 10-25-02)
992 <lcnotify>: enabled/disabled feature user notification
993 <lcconfirm>: enabled/disabled feature user confirmation
994 <lc_clientId>: client address requesting position data
995 */
996 GLOBAL T_ACI_RETURN sAT_PlusCLSR ( T_ACI_CMD_SRC srcId,
997 CHAR lcnotify,
998 CHAR lcconfirm,
999 CHAR* lcclientId)
1000
1001 {
1002 T_LOC_SERV_PARA *p_lsprm = 0;
1003 T_LOC_SERV_CLIENT *p_client = 0;
1004 char * rest_addr = 0;
1005 char client_index,clsr_flag;
1006 T_ACI_TOA toa_clId;
1007
1008 TRACE_FUNCTION ("sAT_PlusCLSR ()");
1009
1010 /*-----------------------------------------------------------------
1011 * check command source
1012 *-----------------------------------------------------------------
1013 */
1014 if(!cmh_IsVldCmdSrc (srcId))
1015 {
1016 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
1017 return( AT_FAIL );
1018 }
1019 p_lsprm = &locServPrm; /* global structure LC parameters */
1020 switch(lcnotify)
1021 {
1022 case CLRS_NO_USER_NOTIFY: /* state notify */
1023 /* look for client entry in list and reset client id status */
1024 if(p_lsprm->numb_lc_clients >0)
1025 {
1026 /* check type of delivered client id */
1027 memset(&toa_clId,0,sizeof(T_ACI_TOA));
1028 rest_addr = lcclientId;
1029 rest_addr = cmh_setToaDef (lcclientId, &toa_clId);
1030 clsr_flag = FALSE;
1031 p_client = p_lsprm->clients;
1032 if(p_client EQ NULL)
1033 {
1034 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec);
1035 return ( AT_FAIL );
1036 }
1037 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
1038 {
1039 if(!strcmp(p_client->client_id.address,rest_addr))
1040 {
1041 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
1042 {
1043 if(lcconfirm EQ CLRS_NO_USER_CONFIRM)
1044 {
1045 p_client->confirmation = p_client->notify = FALSE;
1046 clsr_flag = TRUE;
1047 }
1048 else if(lcconfirm EQ CLRS_USER_CONFIRM)
1049 {
1050 p_client->notify = FALSE;
1051 p_client->confirmation = TRUE;
1052 clsr_flag = TRUE;
1053 }
1054 else
1055 {
1056 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_UsConfReqTyNotRec );
1057 return( AT_FAIL );
1058 }
1059 }
1060 }
1061 if(!p_client->next)
1062 break;
1063 p_client = p_client->next;
1064 }
1065 if(clsr_flag EQ FALSE)
1066 {
1067 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec );
1068 return ( AT_FAIL );
1069 }
1070 }
1071 else
1072 { /* there are not LCS clients in the list */
1073 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec );
1074 return ( AT_FAIL );
1075 }
1076 break;
1077 case CLRS_USER_NOTIFY:
1078 /* look for client entry in list and reset client id status */
1079 if(p_lsprm->numb_lc_clients >0)
1080 {
1081 /* check type of delivered client id */
1082 memset(&toa_clId,0,sizeof(T_ACI_TOA));
1083 rest_addr = lcclientId;
1084 rest_addr = cmh_setToaDef (lcclientId, &toa_clId);
1085 clsr_flag = FALSE;
1086 p_client = p_lsprm->clients;
1087 if(p_client EQ NULL)
1088 {
1089 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec );
1090 return ( AT_FAIL );
1091 }
1092 for(client_index=0;client_index<p_lsprm->numb_lc_clients;client_index++)
1093 {
1094 if(!strcmp(p_client->client_id.address,rest_addr))
1095 {
1096 if(toa_merge(toa_clId) EQ toa_merge(p_client->client_id.toa))
1097 {
1098 if(lcconfirm EQ CLRS_NO_USER_CONFIRM)
1099 {
1100 p_client->confirmation = FALSE;
1101 p_client->notify = TRUE;
1102 clsr_flag = TRUE;
1103 }
1104 else if(lcconfirm EQ CLRS_USER_CONFIRM)
1105 {
1106 p_client->confirmation = p_client->notify = TRUE;
1107 clsr_flag = TRUE;
1108 }
1109 else
1110 {
1111 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_UsConfReqTyNotRec );
1112 return( AT_FAIL );
1113 }
1114 }
1115 }
1116 if(!p_client->next)
1117 break;
1118 p_client = p_client->next;
1119 }
1120 if(clsr_flag EQ FALSE)
1121 {
1122 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec );
1123 return ( AT_FAIL );
1124 }
1125 }
1126 else
1127 { /* there are not LCS clients in the list */
1128 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CLSRClientIdNotRec );
1129 return ( AT_FAIL );
1130 }
1131 break;
1132 case CLRS_NOTIFY_UNKNOWN: /* missing CLSR notify setting */
1133 default:
1134 clsr_flag = FALSE;
1135 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_LCS_CmdNotRec );
1136 return( AT_FAIL );
1137 }
1138 #if defined(_TMS470)
1139 if(clsr_flag EQ TRUE)
1140 {/* store all clients */
1141 store_lc_clients_nvm();
1142 clsr_flag = FALSE;
1143 }
1144 #endif
1145 return(AT_CMPL);
1146 }
1147
1148
1149 /*
1150 +-------------------------------------------------------------------+
1151 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
1152 | ROUTINE : cmhSMS_MEASdeliver |
1153 +-------------------------------------------------------------------+
1154
1155 PURPOSE : process delivered position data of LC
1156 */
1157 GLOBAL void cmhSMS_MEASdeliver ( UBYTE *lc_meas_buf)
1158 {
1159 T_ATI_SRC_PARAMS *src_params = find_element( ati_src_list, locServPrm.lc_src_id, search_ati_src_id);
1160
1161 TRACE_FUNCTION ("cmhSMS_MEASdeliver ()");
1162
1163 memset(&aci_lc_data.position_data,0,MAX_POSITION_DATA);
1164 aci_lc_data.pos_data_length = MAX_POSITION_DATA;
1165 memcpy(&aci_lc_data.position_data,lc_meas_buf,MAX_POSITION_DATA);
1166 rCI_PlusCLPS(locServPrm.lc_src_id, &aci_lc_data);
1167 if(src_params->curAtCmd EQ AT_CMD_CLPS)
1168 {
1169 srcId_cb = locServPrm.lc_src_id;
1170 rCI_OK(AT_CMD_CLPS);
1171 }
1172 }
1173
1174 /*
1175 +-------------------------------------------------------------------+
1176 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
1177 | ROUTINE : lclist_init |
1178 +-------------------------------------------------------------------+
1179
1180 PURPOSE : initialize LC parameter list
1181 */
1182 T_ACI_RETURN lclist_init (void)
1183 {
1184 T_LOC_SERV_PARA *lc_para = 0;
1185 T_LOC_SERV_CLIENT *p_client = 0;
1186 #if defined(_TMS470)
1187 T_LOC_SERV_CLIENT **p_client_chain;
1188 char client_index;
1189 T_LC_NVM_DATA lc_nvm_data;
1190 #endif
1191
1192 TRACE_FUNCTION ("lclist_init ()");
1193 lc_para = &locServPrm;
1194
1195 #if defined(_TMS470)
1196
1197 memset(&lc_nvm_data,0,sizeof(T_LC_NVM_DATA));
1198
1199 switch(FFS_mkdir("/gsm/lc"))
1200 {/* check ffs directory for LC clients and test conditions */
1201 case EFFS_EXISTS:
1202 if(FFS_fread("/gsm/lc/lc_flag",&location_service_flag, sizeof(BOOL)) NEQ sizeof(BOOL))
1203 {
1204 location_service_flag = FALSE;
1205 }
1206 if(FFS_fread("/gsm/lc/lc_per_flag",&eotd_periodic_update_flag, sizeof(BOOL)) NEQ sizeof(BOOL))
1207 {
1208 eotd_periodic_update_flag = FALSE;
1209 }
1210
1211 lc_para->lc_callReference = -1;
1212 if(FFS_fread("/gsm/lc/lc_src_addr",&lc_para->mlcsrc, sizeof(T_LOC_MLC_ADDRESS)) NEQ sizeof(T_LOC_MLC_ADDRESS))
1213 memset(&lc_para->mlcsrc,0,sizeof(T_LOC_MLC_ADDRESS));
1214
1215 if(FFS_fread("/gsm/lc/lc_dest_addr",&lc_para->mlcdest, sizeof(T_LOC_MLC_ADDRESS)) NEQ sizeof(T_LOC_MLC_ADDRESS))
1216 memset(&lc_para->mlcdest,0,sizeof(T_LOC_MLC_ADDRESS));
1217
1218 lc_para->numb_lc_clients = 0;
1219 lc_para->clients = NULL;
1220 p_client_chain = &lc_para->clients;
1221 for(client_index = 0; client_index<MAX_NUMB_LC_CLIENTS;client_index++)
1222 {
1223 ACI_MALLOC(p_client,sizeof(T_LOC_SERV_CLIENT));
1224 memset(p_client,0,sizeof(T_LOC_SERV_CLIENT));
1225 if(FFS_fread(lc_client_list[client_index],p_client, sizeof(T_LOC_SERV_CLIENT)) EQ sizeof(T_LOC_SERV_CLIENT))
1226 {
1227 lc_para->numb_lc_clients++;
1228 *p_client_chain = p_client;
1229 p_client_chain = &(p_client->next);
1230 }
1231 else
1232 {
1233 ACI_MFREE(p_client);
1234 break;
1235 }
1236 }
1237
1238 if(FFS_fread("/gsm/lc/lc_test",&lc_nvm_data, sizeof(lc_nvm_data)) NEQ sizeof(lc_nvm_data))
1239 {
1240 memset(&lc_nvm_data, 0, sizeof(lc_nvm_data));
1241 lc_nvm_data.sleep = TRUE; /* don't switch off any sleep mode */
1242 }
1243
1244 if (lc_nvm_data.cps_trace)
1245 {
1246 lc_cps_traces = TRUE;
1247 lc_msmsnr = 0;
1248 }
1249
1250 if (lc_nvm_data.eotd)
1251 v_eotd = TRUE;
1252
1253 if (lc_nvm_data.periodic AND eotd_periodic_update_flag EQ PERIODIC_UPDATE_ON )
1254 {
1255 ULONG timer = 0;
1256
1257 for(p_client = lc_para->clients; p_client NEQ NULL; p_client = p_client->next)
1258 {
1259 timer = p_client->period_upd_value*60*1000;/* sec */
1260 if (p_client->period_upd_timer EQ 0)
1261 p_client->period_upd_timer = search_tim_handl();
1262
1263 if(p_client->period_upd_timer NEQ 0 AND
1264 p_client->period_upd_status EQ PERIODIC_UP_ACTIVE)
1265 {
1266 TIMERSTART( timer, p_client->period_upd_timer);
1267 }
1268 }
1269 }
1270
1271 if (!lc_nvm_data.sleep)
1272 {
1273 /* definitions adopted from cst.h */
1274 #define NO_SLEEP 0
1275 #define ARMIO_CLK 0x0001
1276 #define UWIRE_CLK 0x0020
1277 #define SIM_CLK 0x0040
1278 #define UART_CLK 0x0400
1279
1280 power_down_config(NO_SLEEP, ARMIO_CLK | UWIRE_CLK | SIM_CLK | UART_CLK);
1281 }
1282 break;
1283 default:
1284 /* initialize list, no lc clients and no lc test conditions in ffs */
1285 memset(&lc_para->mlcsrc,0,sizeof(T_LOC_MLC_ADDRESS));
1286 memset(&lc_para->mlcdest,0,sizeof(T_LOC_MLC_ADDRESS));
1287 lc_para->lc_callReference = -1;
1288 location_service_flag = LOCATION_SERVICE_OFF;
1289 eotd_periodic_update_flag = PERIODIC_UPDATE_OFF;
1290 lc_para->numb_lc_clients = 0;
1291 lc_para->clients = NULL;
1292 break;
1293 }
1294 #else /* win32 */
1295 /* initialize list */
1296 memset(&lc_para->mlcsrc,0,sizeof(T_LOC_MLC_ADDRESS));
1297 memset(&lc_para->mlcdest,0,sizeof(T_LOC_MLC_ADDRESS));
1298 lc_para->lc_callReference = -1;
1299 location_service_flag = LOCATION_SERVICE_OFF;
1300 eotd_periodic_update_flag = PERIODIC_UPDATE_OFF;
1301 lc_para->numb_lc_clients = 0;
1302 lc_para->clients = NULL;
1303 #endif
1304
1305 return(AT_CMPL);
1306 }
1307
1308
1309 /*
1310 +-------------------------------------------------------------------+
1311 | PROJECT : GSM-PS (6147) MODULE : CMH_LCS |
1312 | ROUTINE : lclist_deinit |
1313 +-------------------------------------------------------------------+
1314
1315 PURPOSE : initialize LC parameter list
1316
1317 GLOBAL void lclist_deinit (void)
1318 {
1319 T_LOC_SERV_PARA *lc_para = 0;
1320
1321 TRACE_FUNCTION ("lclist_deinit ()");
1322
1323 lc_para = &locServPrm;
1324 location_service_flag = LOCATION_SERVICE_OFF;
1325 eotd_periodic_update_flag = PERIODIC_UPDATE_OFF;
1326 }*/
1327
1328 #endif /* FF_EOTD */
1329 /*==== EOF ========================================================*/
1330