comparison g23m/condat/ms/src/mfw/CPHS_mod.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*-----------------------Include Files---------------------------------*/
2
3 #define ENTITY_MFW
4
5
6 #include <string.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <limits.h>
10
11 #if defined (NEW_FRAME)
12
13 #include "typedefs.h"
14 #include "vsi.h"
15 #include "pei.h"
16 #include "custom.h"
17 #include "gsm.h"
18
19 #else
20
21 #include "STDDEFS.H"
22 #include "custom.h"
23 #include "gsm.h"
24 #include "vsi.h"
25
26 #endif
27
28 #include "prim.h"
29 #ifndef PCM_2_FFS
30 #include "pcm.h"
31 #endif
32
33
34 #ifndef GPRS
35 #include "ffs/ffs.h"
36 #undef GPRS /* ffs.h anyhow defines GPRS: has to be undef ifndef GPRS */
37
38 #else /* GPRS */
39 #include "ffs/ffs.h"
40 #endif /* GPRS */
41
42 #ifndef PCM_2_FFS
43 #include "ffs_coat.h"
44 #endif
45
46 #ifdef SIM_TOOLKIT
47 //#include "mfw_sat.h"
48 #endif
49
50 #include "message.h"
51 #include "prim.h"
52 #include "aci_cmh.h"
53 #if defined (FAX_AND_DATA)
54 #include "aci_fd.h"
55 #endif
56
57 #ifdef GPRS
58 #include "gprs.h"
59 #endif
60 #include "dti_conn_mng.h"
61
62 #include "phb.h"
63 #include "psa.h"
64 #include "cmh.h"
65 #include "cmh_phb.h"
66 #include "psa.h"
67 #include "psa_sim.h"
68 #include "cus_aci.h"
69 #include "cmh_mm.h"
70 #include "cmh_sim.h"
71 #include "CPHS_mod.h"
72
73 /*--------------------- Constant definitions ---------------------------*/
74
75
76 #define MFW_INVALID_SIM_DATA 0xFF
77 #define MAX_CPHS_ENTRY 4
78 #define MAX_PCM_MAILBOX_LEN 10
79
80
81 #define NO_ALLOCATED 0
82 #define FALSE 0
83 #define TRUE 1
84 #define LONG_NAME 26
85 #define SHORT_NAME 10
86 #define SP_NAME 17
87 #define NUMERIC_LENGTH 6
88
89 #ifdef TI_PS_FFS_PHB
90 #define PHB_MAX_LEN MAX_PHB_NUM_LEN /* Phonebook number length + '\0' */
91 #else
92 //GW-SPR#762- 40 digit phonebook size.
93 #ifdef PHONEBOOK_EXTENSION
94 #define PHB_MAX_LEN 41 /* Phonebook number length + '\0' */
95 #else
96 #define PHB_MAX_LEN 21 /* Phonebook number length + '\0' */
97 #endif /* else, #ifdef PHONEBOOK_EXTENSION */
98 #endif /* else, #ifdef TI_PS_FFS_PHB */
99
100 /*--------------------- Types --------------------------------------*/
101 typedef enum /* numbering plan identifier */
102 {
103 CPHS_NPI_UNKNOWN,
104 CPHS_NPI_ISDN = 1,
105 CPHS_NPI_DATA = 3,
106 CPHS_NPI_TELEX = 4,
107 CPHS_NPI_NATIONAL = 8,
108 CPHS_NPI_PRIVATE = 9,
109 CPHS_NPI_M_ERMES = 10,
110 CPHS_NPI_M_CTS = 11
111 } T_PHB_NPI;
112
113 typedef enum /* type of number */
114 {
115 CPHS_TON_UNKNOWN,
116 CPHS_TON_INTERNATIONAL,
117 CPHS_TON_NATIONAL,
118 CPHS_TON_NET_SPECIFIC,
119 CPHS_TON_DED_ACCESS,
120 CPHS_TON_ALPHA_NUMERIC,
121 CPHS_TON_ABBREVIATED,
122 CPHS_TON_EXTENDED
123 } T_CPHS_PHB_TON;
124
125 typedef enum /* CPHS service */
126 {
127 CPHS_CSP = 1, /* customer service profile */
128 CPHS_SST, /* service string table */
129 CPHS_MB_NUMBER, /* mailbox numbers */
130 CHPS_NAME_SHORT, /* operator name shortform */
131 CHPS_INFO_NUMBERS /* information numbers */
132 } T_CPHS_SERVICE;
133
134 #define CPHS_SERVICE_TABLE 2 /* size of CPHS service table */
135 #define CPHS_INFO_SIZE 3 /* size of CPHS information field (6F16) */
136 #define CPHS_ONS_SIZE 20 /* size of operator name string (6F14) - read first 20 bytes only */
137 #define CPHS_ONSF_SIZE 10 /* size of operator name short form (6F18) */
138 #define CPHS_MIN_MBN_SIZE 14
139 #define CPHS_MBS_SIZE 2 /* size of voice message waiting flag (6F11) */
140 #define CPHS_CFF_SIZE 2 /* size of call forwarding flags (6F13) */
141 #define CPHS_ALS_SIZE 1 /* size of alternate line service (6F9F) */
142 #define CPHS_ALSS_SIZE 1 /* size of alternate line service status (6F92) */
143 #define CPHS_CSP_SIZE 20 /* size of customer service profile (6F15) */
144 #define CPHS_MIN_INS_SIZE 5
145
146 typedef struct {
147
148 T_CPHS_OPN opName;
149 T_CPHS_MAILBOX_NUM_LIST mbNum;
150 T_CPHS_LINE_IND mbStatus;
151 T_CPHS_LINE_IND dvStatus;
152 T_CPHS_ALS_INFO alsStatus;
153 T_CPHS_ALS_LINE Line1_desc;
154 T_CPHS_ALS_LINE Line2_desc;
155 T_CPHS_CSP csProfile;
156 T_CPHS_INFO_NUM_LIST* numList;
157 T_CPHS_INFO_NUM_ENTRY* infoEntry;
158 T_CPHS_ROAMING_IND roaming_ind;
159 UBYTE mbnData[40]; // it should be allocated dynamically.
160
161 UBYTE mbsData[CPHS_MBS_SIZE]; // it should be allocated dynamically.
162 UBYTE dvData[CPHS_CFF_SIZE]; // it should be allocated dynamically.
163
164 // T_CPHS_READ_SIM_ENTRY read_sim_entry;//MC
165
166 UBYTE cphsStatus;
167 UBYTE cphsPhase;
168 UBYTE cphsServTab[CPHS_SERVICE_TABLE];
169 UBYTE maxRec;
170
171 T_CPHS_MAILBOX_NUM_ENTRY MbnEntry;
172
173 T_CPHS_MAILBOX_NUM_ENTRY *vcEntry;
174 T_CPHS_SIMOP_STATUS simStatus;
175 UBYTE alsData;
176 UBYTE idxLevel;
177 UBYTE startIdx;
178 UBYTE cphsUpdate ;
179 ULONG cphsPrevRead;
180 T_CPHS_CB_FUNC InfoNumberListCB;
181 T_CPHS_CB_FUNC InfoNumberCB;
182 T_CPHS_CB_FUNC RefreshCB;
183 }T_CPHS_CACHED_DATA;
184
185
186 static T_CPHS_CACHED_DATA* cphs_data = NULL;
187
188 void Cphs_support_check (void);
189 UBYTE Cphs_ssc (UBYTE nr, UBYTE * serv_table);
190 void Cphs_update_info_cnf (SHORT errCode, UBYTE *data, UBYTE dataLen);
191 void Cphs_read_information(SHORT errCode, UBYTE *data, UBYTE dataLen);
192 void Cphs_read_csp(SHORT errCode, UBYTE *data, UBYTE dataLen);
193 void Cphs_read_cff(SHORT errCode, UBYTE *data, UBYTE dataLen);
194 void Cphs_read_mbs(SHORT errCode, UBYTE *data, UBYTE dataLen);
195 void Cphs_read_mbn(SHORT table_id);
196 void Cphs_read_onsf(SHORT errCode, UBYTE *data, UBYTE dataLen);
197 void Cphs_read_ons(SHORT errCode, UBYTE *data, UBYTE dataLen);
198 void Cphs_get_csp ();
199 void Cphs_get_mailbox (void);
200 void Cphs_read_sim_dat_cb(SHORT table_id);
201 BOOL Cphs_read_sim_dat(USHORT data_id, UBYTE len, UBYTE max_length);
202 T_CPHS_RET Cphs_set_divert_status (T_CPHS_FLAG_STATUS line1,
203 T_CPHS_FLAG_STATUS line2,
204 T_CPHS_FLAG_STATUS fax,
205 T_CPHS_FLAG_STATUS data);
206 T_CPHS_RET Cphs_set_mailbox_status (T_CPHS_FLAG_STATUS line1,
207 T_CPHS_FLAG_STATUS line2,
208 T_CPHS_FLAG_STATUS fax,
209 T_CPHS_FLAG_STATUS data);
210 void Cphs_operator_name (void);
211 void Cphs_get_mailbox_status ();
212 void Cphs_get_divert_status () ;
213
214
215 void Cphs_write_eeprom_mailbox(T_CPHS_MAILBOX_NUM_ENTRY *entry);
216 void Cphs_read_eeprom_mailbox(void);
217 void Cphs_build_mbn_data(UBYTE *data, UBYTE len);
218 void Cphs_req_info_num_read(UBYTE rcd_num, UBYTE dataLen);
219 void Cphs_get_info_num (UBYTE level, UBYTE startIndex);
220 void Cphs_read_info_num(SHORT table_id);
221 void Cphs_read_first_info_num(SHORT table_id);
222 void Cphs_read_sim_rcd_cb (SHORT table_id);
223 BOOL Cphs_read_sim_rcd(USHORT data_id, UBYTE rcd_num, UBYTE len);
224 void Cphs_select_info_num (UBYTE index) ;
225 void Cphs_write_sim_dat_cb(SHORT table_id);
226 BOOL Cphs_write_sim_dat(USHORT data_id, UBYTE *data, UBYTE length);
227 void Cphs_write_sim_rcd_cb (SHORT table_id);
228 BOOL Cphs_write_sim_rcd(USHORT data_id, UBYTE rcd_num,
229 UBYTE *data, UBYTE dataLen);
230 void Cphs_read_eeprom_als_desc();
231 void Cphs_write_eeprom_als_desc(T_CPHS_ALS_LINE* line);
232 T_CPHS_RET Cphs_write_eeprom_als(T_CPHS_ALS_INFO* info);
233 T_CPHS_RET Cphs_read_eeprom_als(T_CPHS_ALS_INFO* info);
234 void Cphs_get_als_info ();
235 T_CPHS_PHB_TON cvtTon(T_ACI_TOA_TON ton);
236 /* initializes CPHS module, reads CPHS data fields from SIM and caches */
237 /* the read data. */
238 #ifdef _TESTING__
239 T_CPHS_INFO_NUM_LIST num_list;
240 T_CPHS_INFO_NUM_ENTRY num_entry;
241
242
243 int Info_Numbers_Callback(T_CPHS_INFO_NUM_LIST* list, T_CPHS_INFO_NUM_ENTRY* entry)
244 { char debug[50];
245 TRACE_FUNCTION("Info_Numbers_Callback()");
246
247 if (list != NULL)
248 { sprintf(debug, "INFO_NUMLIST:%s, count:%d",(char*)list->entry[0].alpha.data, list->count);
249 TRACE_EVENT(debug);
250
251 }
252
253 if (entry != NULL)
254 {
255 sprintf(debug, "INFO_NUM:%s",(char*)entry->alpha.data);
256 TRACE_EVENT(debug);
257 }
258 if (list == NULL && entry == NULL)
259 TRACE_EVENT("REFRESH DONE!!!!");
260
261
262 }
263
264 void Cphs_reading_test()
265 { T_CPHS_ALS_INFO als_info;
266 T_CPHS_ALS_LINE als_line;
267 T_CPHS_INFO cphs_info;
268 T_CPHS_CSP cphs_csp;
269 T_CPHS_LINE_IND dv_ind;
270 T_CPHS_MAILBOX_NUM_LIST mb_nums;
271 T_CPHS_OPN op_name;
272 T_CPHS_ROAMING_IND roam_ind;
273
274 char debug[60];
275
276 //cphs_Init(Info_Numbers_Callback);
277 cphs_refresh(Info_Numbers_Callback);
278
279 //cphs_getInfoNumbers(&num_list,1,1, Info_Numbers_Callback);
280 /*cphs_getAlsInfo(&als_info);
281 sprintf(debug,"line:%d, locked:%d", als_info.line, als_info.locked);
282 TRACE_FUNCTION(debug);
283 als_line.line = CPHS_LINE_INDEX_LINE2;
284 cphs_getAlsLineDescr(&als_line);
285 sprintf(debug,"line:%d, desc:%0.22s", als_line.line, als_line.description.data);
286 TRACE_EVENT(debug);
287 cphs_getVoiceMessageInd(&dv_ind);
288 sprintf(debug, "VM result:%d, line1:%d, line2: %d", dv_ind.result, dv_ind.line1, dv_ind.line2);
289 TRACE_EVENT(debug);
290 cphs_getCPHSInfo(&cphs_info);
291 sprintf(debug, "Phase:%d InfoNum:%d, shortname:%d, mb:%d", cphs_info.phase, cphs_info.info_num, cphs_info.opn_short, cphs_info.mailbox_num);
292 TRACE_EVENT(debug);
293
294 cphs_getCSP(&cphs_csp);
295 sprintf(debug, "Result: %d, CSP:%x,%x,%x,%x,%x,%x", cphs_csp.result, cphs_csp.csp[0].services, cphs_csp.csp[1].services,
296 cphs_csp.csp[2].services, cphs_csp.csp[3].services, cphs_csp.csp[4].services, cphs_csp.csp[5].services);
297 TRACE_EVENT(debug);
298 //#ifdef FRED
299 cphs_getDivertCallInd(&dv_ind);
300 sprintf(debug, "Divert result: %d, line1:%d, line2:%d", dv_ind.result, dv_ind.line1, dv_ind.line2);
301 TRACE_EVENT(debug);
302
303 //#endif
304
305 cphs_getOPN(&op_name);
306 sprintf(debug, "res:%d long_name:%s, short_name%0.22s", op_name.result, op_name.long_name, op_name.short_name);
307 TRACE_EVENT(debug);
308
309 cphs_getRoamingInd(&roam_ind);
310 sprintf(debug, "Roaming ind: %d", roam_ind);
311 TRACE_EVENT(debug);
312
313 cphs_getMailboxNumbers(&mb_nums);
314
315 sprintf(debug, "MBN result: %d, count:%d, first:%0.22s",mb_nums.result, mb_nums.count, mb_nums.entries[0].number);
316 TRACE_EVENT(debug);*/
317
318
319 }
320
321
322 void Cphs_writing_test()
323 { T_CPHS_ALS_INFO als_info;
324 T_CPHS_ALS_LINE als_line;
325 T_CPHS_LINE_IND dv_ind;
326 T_CPHS_ROAMING_IND roam_ind;
327 char debug[50];
328
329
330
331 cphs_Init(Info_Numbers_Callback);
332 //cphs_refresh(Info_Numbers_Callback);
333
334 als_line.line = CPHS_LINE_INDEX_LINE2;
335 memcpy(als_line.description.data, (UBYTE*)"Second Line !!", 8);
336 als_line.description.len = 8;
337 cphs_setAlsLineDescr(als_line);
338
339 als_info.line = CPHS_LINE_INDEX_LINE2;
340 als_info.locked= CPHS_LINEFLAG_SET;
341 cphs_setAlsInfo(&als_info);
342 cphs_setDivertCallInd(CPHS_LINE_INDEX_LINE1, CPHS_LINEFLAG_NOT_SET);
343 cphs_setDivertCallInd(CPHS_LINE_INDEX_LINE2, CPHS_LINEFLAG_SET);
344
345 cphs_setVoiceMessageInd(CPHS_LINE_INDEX_LINE1, CPHS_LINEFLAG_NOT_SET);
346 cphs_setVoiceMessageInd(CPHS_LINE_INDEX_LINE2, CPHS_LINEFLAG_SET);
347
348 roam_ind = CPHS_ROAMING_OFF;
349 cphs_setRoamingInd(&roam_ind);
350
351 //cphs_selectInfoNumber(2, &num_entry, Info_Numbers_Callback);
352
353 }
354 #endif
355
356 /*
357 +--------------------------------------------------------------------+
358 | MODULE : CPHS standalone module |
359 | STATE : code ROUTINE : cphs_Init |
360 +--------------------------------------------------------------------+
361
362 */
363 T_CPHS_RET cphs_Init(T_CPHS_CB_FUNC callback)
364 { //check if already initilaised?
365 if (cphs_data)
366 return CPHS_IS_OK;
367 cphs_data = (T_CPHS_CACHED_DATA*)malloc(sizeof(T_CPHS_CACHED_DATA));
368 if (cphs_data)
369 { cphs_data->cphsStatus = CPHS_NOT_PRESENT;
370 cphs_data->simStatus = SIMOP_UNKNOWN;
371 cphs_data->cphsUpdate = FALSE;
372 cphs_data->cphsPrevRead = 0;
373 cphs_data->InfoNumberListCB = NULL;
374 cphs_data->InfoNumberCB = NULL;
375 Cphs_support_check();
376 cphs_refresh(callback);
377 return CPHS_IS_OK;
378 }
379 else
380 return CPHS_FAIL;
381 }
382
383
384
385 /*
386 +--------------------------------------------------------------------+
387 | MODULE : CPHS standalone module |
388 | STATE : code ROUTINE : cphs_refresh() |
389 +--------------------------------------------------------------------+
390
391
392 */
393
394 /* reads CPHS data fields from SIM and updates the cached CPHS data */
395 T_CPHS_RET cphs_refresh(T_CPHS_CB_FUNC callback)
396 { T_CPHS_RET res;
397
398 if (cphs_data EQ NULL)
399 { TRACE_EVENT("CPHS not initialised");
400 return CPHS_NOT_INIT;
401 }
402 //get call divert indicator
403 Cphs_get_divert_status ();
404 cphs_data->RefreshCB = callback; //set call back function
405 //get mailbox numbers
406 /*Cphs_get_mailbox ();
407 Cphs_operator_name ();
408 //get voice message indicator
409 Cphs_read_eeprom_als_desc();
410 //get als line description
411 Cphs_get_mailbox_status ();
412 //get CSP
413 Cphs_get_csp ();*/
414 }
415
416
417 /*
418 +--------------------------------------------------------------------+
419 | MODULE : CPHS standalone module |
420 | STATE : code ROUTINE : cphs_Exit() |
421 +--------------------------------------------------------------------+
422
423
424 */
425 /* de-initializes CPHS module */
426 T_CPHS_RET cphs_Exit()
427 { if (cphs_data EQ NULL)
428 return CPHS_NOT_INIT;
429
430 free(cphs_data);
431
432 return CPHS_IS_OK;
433 }
434
435 /*
436 +--------------------------------------------------------------------+
437 | MODULE : CPHS standalone module |
438 | STATE : code ROUTINE : cphs_getOPN |
439 +--------------------------------------------------------------------+
440
441
442 */
443 /* reads from SIM the operator long name and if available the short */
444 /* name, too */
445 T_CPHS_RET cphs_getOPN ( T_CPHS_OPN *opn )
446 { if (cphs_data EQ NULL)
447 return CPHS_NOT_INIT;
448 if (opn EQ NULL)
449 return CPHS_FAIL;
450 memcpy(opn, &cphs_data->opName, sizeof(T_CPHS_OPN));
451 return CPHS_IS_OK;
452 }
453 /*
454 +--------------------------------------------------------------------+
455 | MODULE : CPHS standalone module |
456 | STATE : code ROUTINE : cphs_getRoamingInd |
457 +--------------------------------------------------------------------+
458
459
460 */
461
462 /* checks if roaming is active */
463 T_CPHS_RET cphs_getRoamingInd ( T_CPHS_ROAMING_IND *indicator )
464 {
465 #ifndef NEPTUNE_BOARD
466 /*
467 T_ACI_COPS_MOD mode;
468 T_ACI_COPS_FRMT format;
469 CHAR oper[30];
470 T_OPER_NTRY* plmn_entry;
471 SHORT mccBuf, mncBuf;
472 char debug[50];
473 UBYTE numeric[8];
474 char ** end;
475 memset(oper, 0, 30);
476 */
477 #else
478 T_ACI_COPS_MOD mode;
479 T_ACI_COPS_FRMT format;
480 CHAR oper[30];
481 T_OPER_NTRY* plmn_entry;
482 SHORT mccBuf, mncBuf;
483 char debug[50];
484 UBYTE numeric[8];
485 char ** end;
486 memset(oper, 0, 30);
487 #endif
488
489 if (cphs_data EQ NULL)
490 return CPHS_NOT_INIT;
491 if (indicator EQ NULL)
492 return CPHS_FAIL;
493 #ifndef NEPTUNE_BOARD
494 *indicator = cphs_data->roaming_ind;
495 #else
496 memcpy(indicator, &cphs_data->roaming_ind, sizeof(T_CPHS_ROAMING_IND));
497 #endif
498 /*
499 qAT_PlusCOPS (CMD_SRC_NONE,&mode,&format,oper );
500 //get current MCC
501 if (format == COPS_FRMT_Long OR format == COPS_FRMT_Short)
502 { sAT_PlusCOPSE(oper, format, NULL, NULL, numeric);
503 // plmn_entry = cmhMM_FindName( oper, format );
504 numeric[3] = 0;//terminate string before MNC
505 plmn_entry->mcc = strtol((char*)numeric,end,16 );
506 }
507
508 if (format == COPS_FRMT_Numeric)
509 { //plmn_entry = cmhMM_FindNumeric( oper );
510 oper[3] = 0;
511 plmn_entry->mcc = strtol((char*)oper, end, 16);
512 }
513 //get "Home MCC"
514 cmhSIM_GetHomePLMN ( &mccBuf, &mncBuf );
515 //currently qAT_PlusCOPS is not returning the correct format
516 //cmhMM_FindName/Numeric rely on PCM which does not work
517 sprintf(debug, "Home MCC %d, current MCC %d COPS fmt:%d", plmn_entry->mcc, mccBuf, format);
518 TRACE_EVENT(debug);
519 if (plmn_entry->mcc == mccBuf)
520 *indicator = CPHS_ROAMING_OFF;
521 else
522 *indicator = CPHS_ROAMING_ON;
523 */
524
525 return CPHS_IS_OK;
526 }
527 /*
528 +--------------------------------------------------------------------+
529 | MODULE : CPHS standalone module |
530 | STATE : code ROUTINE : cphs_getVoiceMessageInd |
531 +--------------------------------------------------------------------+
532
533
534 */
535
536 /* reads from SIM if voice mails are waiting for the available lines */
537 /* (line1, line2, fax, data) */
538 T_CPHS_RET cphs_getVoiceMessageInd( T_CPHS_LINE_IND *indicator )
539 { if (cphs_data EQ NULL)
540 return CPHS_NOT_INIT;
541 if (indicator EQ NULL)
542 return CPHS_FAIL;
543 memcpy(indicator, &cphs_data->mbStatus, sizeof(T_CPHS_LINE_IND));
544 return CPHS_IS_OK;
545 }
546 /*
547 +--------------------------------------------------------------------+
548 | MODULE : CPHS standalone module |
549 | STATE : code ROUTINE : cphs_setVoiceMessageInd |
550 +--------------------------------------------------------------------+
551
552
553 */
554 /* sets on SIM the voice mail waiting flag for the given lines in the */
555 /* parameter line_mask. The bitmask will be created by oring the lines.*/
556 /* The bits for the lines are defined in T_CPHS_LINE_INDEX. */
557 T_CPHS_RET cphs_setVoiceMessageInd( UBYTE line_mask,
558 T_CPHS_FLAG_STATUS flag )
559 {
560 if (cphs_data EQ NULL)
561 return CPHS_NOT_INIT;
562
563 if (CPHS_LINE_INDEX_LINE1 & line_mask)
564 { cphs_data->mbStatus.line1 = flag;
565 TRACE_EVENT("Setting Line 1 VM");
566 Cphs_set_mailbox_status(flag,CPHS_FLAG_NOT_PRESENT ,CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT);
567 }
568
569 if (CPHS_LINE_INDEX_LINE2 & line_mask)
570 { TRACE_EVENT("SEtting line 2 VM");
571 cphs_data->mbStatus.line2 = flag;
572 Cphs_set_mailbox_status(CPHS_FLAG_NOT_PRESENT, flag,CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT);
573 }
574 if (CPHS_LINE_INDEX_FAX & line_mask)
575 { cphs_data->mbStatus.fax = flag;
576 Cphs_set_mailbox_status(CPHS_FLAG_NOT_PRESENT, CPHS_FLAG_NOT_PRESENT,flag,CPHS_FLAG_NOT_PRESENT);
577 }
578 if (CPHS_LINE_INDEX_DATA & line_mask)
579 { cphs_data->mbStatus.data = flag;
580 Cphs_set_mailbox_status(CPHS_FLAG_NOT_PRESENT, CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT,flag);
581 }
582
583
584
585 return CPHS_EXEC;
586 }
587 /*
588 +--------------------------------------------------------------------+
589 | MODULE : CPHS standalone module |
590 | STATE : code ROUTINE : cphs_getDivertCallInd |
591 +--------------------------------------------------------------------+
592 */
593
594
595 /* reads from SIMif calls shall be diverted for the available lines */
596 /* (line1, line2, fax, data) */
597 T_CPHS_RET cphs_getDivertCallInd (T_CPHS_LINE_IND *indicator )
598 {
599 if (cphs_data EQ NULL)
600 return CPHS_NOT_INIT;
601 if (ind EQ NULL)
602 return CPHS_FAIL;
603 memcpy(indicator, &cphs_data->dvStatus, sizeof(T_CPHS_LINE_IND));
604 return CPHS_IS_OK;
605 }
606 /*
607 +--------------------------------------------------------------------+
608 | MODULE : CPHS standalone module |
609 | STATE : code ROUTINE : cphs_setDivertCallInd |
610 +--------------------------------------------------------------------+
611 */
612 /* sets on SIM the divert call flag for the given lines in the */
613 /* parameter line_mask. The bitmask will be created by oring the lines.*/
614 /* The bits for the lines are defined in T_CPHS_LINE_INDEX. */
615 T_CPHS_RET cphs_setDivertCallInd ( UBYTE line_mask,
616 T_CPHS_FLAG_STATUS flag )
617 {
618 if (cphs_data EQ NULL)
619 return CPHS_NOT_INIT;
620
621 if (CPHS_LINE_INDEX_LINE1 & line_mask)
622 { cphs_data->dvStatus.line1 = flag;
623 TRACE_EVENT("Setting line 1 divert");
624 Cphs_set_divert_status(flag,CPHS_FLAG_NOT_PRESENT ,CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT);
625 }
626
627 if (CPHS_LINE_INDEX_LINE2 & line_mask)
628 { cphs_data->dvStatus.line2 = flag;
629 TRACE_EVENT("Setting line 2 divert");
630 Cphs_set_divert_status(CPHS_FLAG_NOT_PRESENT, flag,CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT);
631 }
632 if (CPHS_LINE_INDEX_FAX & line_mask)
633 { cphs_data->dvStatus.fax = flag;
634 Cphs_set_divert_status(CPHS_FLAG_NOT_PRESENT, CPHS_FLAG_NOT_PRESENT,flag,CPHS_FLAG_NOT_PRESENT);
635 }
636 if (CPHS_LINE_INDEX_DATA & line_mask)
637 { cphs_data->dvStatus.data = flag;
638 Cphs_set_divert_status(CPHS_FLAG_NOT_PRESENT, CPHS_FLAG_NOT_PRESENT,CPHS_FLAG_NOT_PRESENT,flag);
639 }
640
641 return CPHS_EXEC;
642
643 }
644
645 /*
646 +--------------------------------------------------------------------+
647 | MODULE : CPHS standalone module |
648 | STATE : code ROUTINE : cphs_getAlsInfo |
649 +--------------------------------------------------------------------+
650 */
651 /* reads from SIM the information of alternate line service */
652 /* ( selected line, alternate line service locked/unlocked) */
653 T_CPHS_RET cphs_getAlsInfo ( T_CPHS_ALS_INFO *info )
654 {
655 if (cphs_data EQ NULL)
656 return CPHS_NOT_INIT;
657 if (info EQ NULL)
658 return CPHS_FAIL;
659
660 //memcpy(info, &cphs_data->alsStatus, sizeof( T_CPHS_ALS_INFO));
661 Cphs_read_eeprom_als(info);
662 return CPHS_IS_OK;
663
664 }
665 /*
666 +--------------------------------------------------------------------+
667 | MODULE : CPHS standalone module |
668 | STATE : code ROUTINE : cphs_setAlsInfo|
669 +--------------------------------------------------------------------+
670 */
671 /* sets on SIM the informtion of alternate line service / selects the */
672 /* active line */
673 T_CPHS_RET cphs_setAlsInfo ( T_CPHS_ALS_INFO *info )
674 { if (cphs_data EQ NULL)
675 return CPHS_NOT_INIT;
676 if (info EQ NULL)
677 return CPHS_FAIL;
678 //memcpy(&cphs_data->alsStatus, info, sizeof(T_CPHS_ALS_INFO));
679 return Cphs_write_eeprom_als(info);
680 //return CPHS_EXEC;
681 }
682 /*
683 +--------------------------------------------------------------------+
684 | MODULE : CPHS standalone module |
685 | STATE : code ROUTINE : cphs_getAlsLineDescr |
686 +--------------------------------------------------------------------+
687 */
688 /* reads the (alpha)numeric description for the given line */
689 T_CPHS_RET cphs_getAlsLineDescr ( T_CPHS_ALS_LINE* line )
690 { if (cphs_data EQ NULL)
691 return CPHS_NOT_INIT;
692 if (line EQ NULL)
693 return CPHS_FAIL;
694 Cphs_read_eeprom_als_desc();
695 if (line->line EQ CPHS_LINE_INDEX_LINE1)
696 { memcpy(line,&cphs_data->Line1_desc, sizeof(T_CPHS_ALS_LINE));
697 return CPHS_IS_OK;
698 }
699
700 if (line->line EQ CPHS_LINE_INDEX_LINE2)
701 { memcpy( line, &cphs_data->Line2_desc,sizeof(T_CPHS_ALS_LINE));
702 return CPHS_IS_OK;
703 }
704
705 return CPHS_FAIL;
706 }
707 /*
708 +--------------------------------------------------------------------+
709 | MODULE : CPHS standalone module |
710 | STATE : code ROUTINE :cphs_setAlsLineDescr |
711 +--------------------------------------------------------------------+
712 */
713 /* sets a (alpha)numeric description for the given line */
714 T_CPHS_RET cphs_setAlsLineDescr ( T_CPHS_ALS_LINE line )
715
716 { if (cphs_data EQ NULL)
717 return CPHS_NOT_INIT;
718
719 if (line.line EQ CPHS_LINE_INDEX_LINE1)
720 { memcpy(&cphs_data->Line1_desc,&line, sizeof(T_CPHS_ALS_LINE));
721 Cphs_write_eeprom_als_desc(&cphs_data->Line1_desc);
722 return CPHS_IS_OK;
723 }
724
725 if (line.line EQ CPHS_LINE_INDEX_LINE2)
726 { memcpy(&cphs_data->Line2_desc, &line, sizeof(T_CPHS_ALS_LINE));
727 Cphs_write_eeprom_als_desc(&cphs_data->Line2_desc);
728 return CPHS_IS_OK;
729 }
730
731 return CPHS_FAIL;
732 }
733 /*
734 +--------------------------------------------------------------------+
735 | MODULE : CPHS standalone module |
736 | STATE : code ROUTINE : cphs_setRoamingInd |
737 +--------------------------------------------------------------------+
738
739 */
740 T_CPHS_RET cphs_setRoamingInd ( T_CPHS_ROAMING_IND* indicator )
741 { if (cphs_data EQ NULL)
742 return CPHS_NOT_INIT;
743
744 if (*indicator EQ CPHS_ROAMING_OFF OR *indicator EQ CPHS_ROAMING_ON)
745 { cphs_data->roaming_ind = *indicator;
746 return CPHS_IS_OK;
747 }
748 else
749 return CPHS_FAIL;
750 }
751 /*
752 +--------------------------------------------------------------------+
753 | MODULE : CPHS standalone module |
754 | STATE : code ROUTINE : cphs_checkEmergencyCall |
755 +--------------------------------------------------------------------+
756 */
757
758 /* check if the current call number(ASCII encoded) is an emergency number supported */
759 /* by CPHS. */
760 T_CPHS_RET cphs_checkEmergencyCall( char* num )
761 { char** end;
762
763
764 if (cphs_data EQ NULL)
765 return CPHS_NOT_INIT;
766
767 if (num EQ NULL)
768 return CPHS_FAIL;
769
770 if (strtol(num, end, 10)EQ CPHS_EMERGENCY_NUM_112 OR
771 strtol(num, end, 10)EQ CPHS_EMERGENCY_NUM_999)
772 return CPHS_IS_OK;
773 else
774 return CPHS_FAIL;
775 }
776
777 /*
778 +--------------------------------------------------------------------+
779 | MODULE : CPHS standalone module |
780 | STATE : code ROUTINE : cphs_getCPHSInfo |
781 +--------------------------------------------------------------------+
782 */
783 /* reads from SIM the phase of the SIM and which optional datafields */
784 /* are present in the SIM */
785 /* (operator name shortform, mailbox numbers, service string table, */
786 /* information numbers) */
787 T_CPHS_RET cphs_getCPHSInfo ( T_CPHS_INFO *info )
788 { if (cphs_data EQ NULL)
789 return CPHS_NOT_INIT;
790
791 if (info !=NULL)
792 {
793 info->phase = cphs_data->cphsPhase;
794 info->csp = Cphs_ssc(CPHS_CSP, cphs_data->cphsServTab);
795 info->mailbox_num = Cphs_ssc(CPHS_MB_NUMBER, cphs_data->cphsServTab);
796
797 if (cphs_data->cphsPhase EQ 1) /* phase 1 only */
798 info->sst = Cphs_ssc(CPHS_SST, cphs_data->cphsServTab);
799 else /* not support */
800 info->sst = NO_ALLOCATED;
801
802 if (cphs_data->cphsPhase EQ 2) /* phase 2 only */
803 {
804 info->opn_short = Cphs_ssc(CHPS_NAME_SHORT, cphs_data->cphsServTab);
805 info->info_num = Cphs_ssc(CHPS_INFO_NUMBERS, cphs_data->cphsServTab);
806 }
807 else /* not support */
808 {
809 info->opn_short = NO_ALLOCATED;
810 info->info_num = NO_ALLOCATED;
811 }
812 return CPHS_IS_OK;
813 }
814 return CPHS_FAIL;
815
816 }
817
818 /*
819 +--------------------------------------------------------------------+
820 | MODULE : CPHS standalone module |
821 | STATE : code ROUTINE : cphs_getCSP |
822 +--------------------------------------------------------------------+
823
824 */
825 /* reads all entries of the customer service profile and fills */
826 T_CPHS_RET cphs_getCSP ( T_CPHS_CSP *csp )
827 { if (cphs_data EQ NULL)
828 return CPHS_NOT_INIT;
829 if (csp EQ NULL)
830 return CPHS_FAIL;
831
832 memcpy(csp, &cphs_data->csProfile, sizeof(T_CPHS_CSP));
833 return CPHS_IS_OK;
834 }
835
836 /*
837 +--------------------------------------------------------------------+
838 | MODULE : CPHS standalone module |
839 | STATE : code ROUTINE : cphs_getMailboxNumbers |
840 +--------------------------------------------------------------------+
841 */
842 /* reads all mailbox numbers from the SIM fills all mailbox number */
843 /* entries in the mailbox number list */
844 T_CPHS_RET cphs_getMailboxNumbers ( T_CPHS_MAILBOX_NUM_LIST *nums )
845 {if (cphs_data EQ NULL)
846 return CPHS_NOT_INIT;
847 if (nums EQ NULL)
848 return CPHS_FAIL;
849
850 memcpy(nums, &cphs_data->mbNum, sizeof(T_CPHS_CSP));
851 return CPHS_IS_OK;
852 }
853 /*
854 +--------------------------------------------------------------------+
855 | MODULE : CPHS standalone module |
856 | STATE : code ROUTINE : cphs_getInfoNumbers|
857 +--------------------------------------------------------------------+
858
859 */
860
861
862 /* reads all information numbers from the SIM fills all information */
863 /* numbers into the array of pointers to information number lists down to the level specified */
864 //MC-Not sure about the format of this as current mfw_cphs code returns an information number list
865 //with only 4 entries
866 T_CPHS_RET cphs_getInfoNumbers ( T_CPHS_INFO_NUM_LIST *nums, UBYTE level, UBYTE start_index, T_CPHS_CB_FUNC callback)
867 { cphs_data->InfoNumberListCB = callback;
868 cphs_data->numList=nums;
869 Cphs_get_info_num(level, start_index);
870 }
871 /*
872 +--------------------------------------------------------------------+
873 | MODULE : CPHS standalone module |
874 | STATE : code ROUTINE : cphs_selectInfoNumber |
875 +--------------------------------------------------------------------+
876
877 PURPOSE : reads the information number entry given by level and index from
878 the SIM
879
880 */
881 T_CPHS_RET cphs_selectInfoNumber ( USHORT index,
882 T_CPHS_INFO_NUM_ENTRY *num, T_CPHS_CB_FUNC callback)
883 { cphs_data->InfoNumberCB = callback;
884 cphs_data->infoEntry= num;
885 Cphs_select_info_num(index);
886 //num = &cphs_data->infoEntry;
887
888 }
889
890
891
892
893 /*
894 +--------------------------------------------------------------------+
895 | MODULE : CPHS standalone module |
896 | STATE : code ROUTINE : Cphs_support_check |
897 +--------------------------------------------------------------------+
898
899 PURPOSE : Check whether CPHS is supported.
900
901 */
902
903 void Cphs_support_check (void)
904 {
905 TRACE_FUNCTION ("Cphs_support_check()");
906
907 /* Read CPHS information filed (6F16 - 3 bytes) from SIM card */
908 if (!Cphs_read_sim_dat(SIM_CPHS_CINF, NOT_PRESENT_8BIT, CPHS_INFO_SIZE))
909 {
910 /* Read failed */
911 cphs_data->cphsStatus = CPHS_NOT_PRESENT;
912
913 }
914 }
915
916
917
918 /*
919 +--------------------------------------------------------------------+
920 | MODULE : CPHS standalone module |
921 | STATE : code ROUTINE : Cphs_operator_name |
922 +--------------------------------------------------------------------+
923
924 PURPOSE : Request the network operator name
925
926 */
927
928 void Cphs_operator_name (void)
929 {
930 TRACE_FUNCTION ("Cphs_operator_name()");
931
932 /* Check CPHS support status */
933 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
934 return;
935
936 /* Read operator name sring */
937 if (!Cphs_read_sim_dat(SIM_CPHS_ONSTR, NOT_PRESENT_8BIT, CPHS_ONS_SIZE))
938 {
939 /* Read operator name sring failed */
940 cphs_data->opName.long_name.len = 0;
941
942 /* Read operator name shortform */
943 if ((cphs_data->cphsPhase NEQ 2) OR
944 (Cphs_ssc(CHPS_NAME_SHORT, cphs_data->cphsServTab) NEQ ALLOCATED_AND_ACTIVATED) OR
945 !Cphs_read_sim_dat(SIM_CPHS_ONSHF, NOT_PRESENT_8BIT, CPHS_ONSF_SIZE) )
946 {
947 /* Read operator name shortform failed.
948 */
949 cphs_data->opName.short_name.len = 0;
950 cphs_data->opName.result = SIMOP_READ_ERR;
951 }
952 }
953
954 }
955
956 /*
957 +-------------------------------------------------------------------------+
958 | MODULE : CPHS standalone module |
959 | STATE : code ROUTINE : Cphs_get_mailbox_status |
960 +-------------------------------------------------------------------------+
961
962 PURPOSE : get the voice message waiting flag
963
964 */
965
966 void Cphs_get_mailbox_status ()
967 {
968 TRACE_FUNCTION ("Cphs_get_mailbox_status()");
969
970 /* Check CPHS support status. */
971 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
972 return ;
973
974 /* Read voice message waiting flag.
975 When this reading failed, send event with "read error" parameter to MMI */
976 if (!Cphs_read_sim_dat(SIM_CPHS_VMW, NOT_PRESENT_8BIT, CPHS_MBS_SIZE))
977 {
978 cphs_data->mbStatus.result = SIMOP_READ_ERR;
979 TRACE_EVENT("Reading mailbox status failed");
980 }
981 }
982
983 /*
984 +------------------------------------------------------------------------+
985 | MODULE : CPHS standalone module |
986 | STATE : code ROUTINE : Cphs_get_divert_status |
987 +------------------------------------------------------------------------+
988
989 PURPOSE : Request the call forwarding flags
990
991 */
992
993 void Cphs_get_divert_status ()
994 {
995 TRACE_FUNCTION ("Cphs_get_divert_status()");
996
997 /* Check CPHS support status. */
998 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
999 return;
1000
1001 /* Read call forwarding flags.
1002 When this reading failed, send event with "read error" parameter to MMI */
1003 if (!Cphs_read_sim_dat(SIM_CPHS_CFF, NOT_PRESENT_8BIT, CPHS_CFF_SIZE))
1004 {
1005 cphs_data->dvStatus.result = SIMOP_READ_ERR;
1006
1007 }
1008
1009 }
1010
1011 /*
1012 +---------------------------------------------------------------------+
1013 | MODULE : CPHS standalone module |
1014 | STATE : code ROUTINE : Cphs_get_als_info |
1015 +---------------------------------------------------------------------+
1016
1017 PURPOSE : Request the Status of Alternate Line Service information
1018 (first read selected ALS line, dann status of this line).
1019 When the field does not exist in SIM, read it from EEPROM.
1020
1021 */
1022 //ATM, cannot get als lock status from SIM
1023 /*void Cphs_get_als_info ()
1024 {
1025 TRACE_EVENT ("Cphs_get_als_info()");
1026
1027 Cphs_read_eeprom_als();
1028
1029 }*/
1030
1031 /*
1032 +---------------------------------------------------------------------+
1033 | MODULE : CPHS standalone module |
1034 | STATE : code ROUTINE : Cphs_get_csp |
1035 +---------------------------------------------------------------------+
1036
1037 PURPOSE : Request the customer service profile
1038
1039 */
1040
1041 void Cphs_get_csp ()
1042 {
1043 UBYTE res;
1044
1045 TRACE_FUNCTION ("Cphs_get_csp()");
1046
1047 /* Check CPHS support status. */
1048 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
1049 return ;
1050
1051 /* check CPHS service table */
1052 res = Cphs_ssc(CPHS_CSP, cphs_data->cphsServTab);
1053 if ( res NEQ ALLOCATED_AND_ACTIVATED)
1054 return;
1055
1056 /* Read customer service profile.
1057 When this reading failed, send event with empty parameter array to MMI */
1058 if (!Cphs_read_sim_dat(SIM_CPHS_CSP, NOT_PRESENT_8BIT, CPHS_CSP_SIZE))
1059 {
1060 cphs_data->csProfile.result = SIMOP_READ_ERR;
1061 memset(cphs_data->csProfile.csp, 0, sizeof(cphs_data->csProfile.csp));
1062 }
1063 }
1064 /*
1065 +---------------------------------------------------------------------+
1066 | MODULE : CPHS standalone module |
1067 | STATE : code ROUTINE : Cphs_get_mailbox |
1068 +---------------------------------------------------------------------+
1069
1070 PURPOSE : Request the customer service profile
1071
1072 */
1073 void Cphs_get_mailbox (void)
1074 {
1075 TRACE_FUNCTION ("Cphs_get_mailbox()");
1076
1077 cphs_data->mbNum.count = 0;
1078
1079 /* Check CPHS support status.
1080 When CPHS is not support, read mailbox numbers from EEPROM */
1081 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
1082 {
1083 Cphs_read_eeprom_mailbox();
1084 return;
1085 }
1086
1087 /* Check CPHS service table.
1088 When CPHS is not support, read mailbox numbers from EEPROM */
1089 if (Cphs_ssc(CPHS_MB_NUMBER, cphs_data->cphsServTab) NEQ ALLOCATED_AND_ACTIVATED)
1090 {
1091 TRACE_EVENT("CPHS doesn't support mailbox");
1092 Cphs_read_eeprom_mailbox();
1093 return;
1094 }
1095
1096 /* Read mailbox numbers from SIM.
1097 When this reading failed, read mailbox numbers from EEPROM */
1098 //cphs_data->simStatus = SIMOP_UNKNOWN;
1099 if (!Cphs_read_sim_rcd(SIM_CPHS_MBXN, 1, 0)) /* read the first record */
1100 { TRACE_EVENT("Mailbox Sim read failed");
1101 Cphs_read_eeprom_mailbox();
1102 }
1103 }
1104
1105 /*
1106 +----------------------------------------------------------------------+
1107 | MODULE: CPHS standalone module |
1108 | STATE : code ROUTINE: Cphs_ssc |
1109 +----------------------------------------------------------------------+
1110
1111
1112 PURPOSE : Check CPHS service status.
1113
1114 */
1115
1116 UBYTE Cphs_ssc (UBYTE nr, UBYTE * serv_table)
1117 {
1118 UBYTE value;
1119
1120 TRACE_FUNCTION ("Cphs_ssc()");
1121
1122 serv_table = serv_table + (nr-1)/4;
1123 value = * serv_table;
1124
1125 value = value >> (((nr-1) & 3) * 2);
1126 value = value & 3;
1127
1128 return value;
1129 }
1130
1131 /*
1132 +------------------------------------------------------------------------+
1133 | MODULE : CPHS standalone module |
1134 | STATE : code ROUTINE : Cphs_set_mailbox_status|
1135 +------------------------------------------------------------------------+
1136
1137 PURPOSE : Set the mailbox status on each line
1138
1139 */
1140
1141 T_CPHS_RET Cphs_set_mailbox_status (T_CPHS_FLAG_STATUS line1,
1142 T_CPHS_FLAG_STATUS line2,
1143 T_CPHS_FLAG_STATUS fax,
1144 T_CPHS_FLAG_STATUS data)
1145 {
1146 UBYTE result;
1147 char debug[50];
1148
1149 TRACE_FUNCTION ("Cphs_set_mailbox_status()");
1150
1151 /* Check CPHS support status. */
1152 // if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
1153 // return CPHS_FAIL;
1154 sprintf(debug, "Original mailbox status: %x%x",cphs_data->mbsData[0],cphs_data->mbsData[1]);
1155 TRACE_EVENT(debug);
1156 /* Write status in buffer */
1157 if (line1 EQ CPHS_LINEFLAG_SET OR
1158 line1 ==CPHS_LINEFLAG_NOT_SET )
1159 { /* low Nibble */
1160 cphs_data->mbsData[0]&=0xF0; //get rid of low nibble
1161 cphs_data->mbsData[0] += (line1&0x0F);
1162 }
1163 /* else
1164 cphs_data->mbsData[0] |= 0x0F;*/
1165
1166 if (line2 EQ CPHS_LINEFLAG_SET OR
1167 line2 EQ CPHS_LINEFLAG_NOT_SET )
1168 { cphs_data->mbsData[0]&=0x0F; //get rid of high nibble
1169 cphs_data->mbsData[0] += (line2 << 4)&0xF0; /* high Nibble */
1170 }
1171 /* else
1172 cphs_data->mbsData[0] = 0xF0 | cphs_data->mbsData[0];*/
1173
1174 if (fax EQ CPHS_LINEFLAG_SET OR
1175 fax EQ CPHS_LINEFLAG_NOT_SET )
1176 {cphs_data->mbsData[1]&=0xF0; //get rid of low nibble
1177 cphs_data->mbsData[1] += fax&0x0F; /* low Nibble */
1178 }
1179 /* else
1180 cphs_data->mbsData[1] |= 0x0F;*/
1181
1182 if (data EQ CPHS_LINEFLAG_SET OR
1183 data EQ CPHS_LINEFLAG_NOT_SET )
1184 { cphs_data->mbsData[1]&=0x0F; //get rid of high nibble
1185 cphs_data->mbsData[1] += (data << 4)&0xF0; /* high Nibble */
1186 }
1187 /* else
1188 cphs_data->mbsData[1] = 0xF0 | cphs_data->mbsData[1];*/
1189
1190 sprintf(debug, "MBS Data:%x%x", cphs_data->mbsData[0], cphs_data->mbsData[1]);
1191 TRACE_EVENT(debug);
1192
1193 /* Read voice message waiting flag to determine the size */
1194 cphs_data->simStatus = SIMOP_WRITE_OK;
1195 if (!Cphs_read_sim_dat(SIM_CPHS_VMW, NOT_PRESENT_8BIT, CPHS_MBS_SIZE))
1196 //if (!Cphs_write_sim_dat(SIM_CPHS_VMW, cphs_data->mbsData, CPHS_MBS_SIZE))
1197 { TRACE_EVENT("Mailbox status SIM write failed");
1198 return CPHS_SIM_WRITE_ERROR;
1199 }
1200 }
1201
1202 /*
1203 +------------------------------------------------------------------------+
1204 | MODULE : CPHS standalone module |
1205 | STATE : code ROUTINE : Cphs_set_divert_status|
1206 +------------------------------------------------------------------------+
1207
1208 PURPOSE : Set the divert status on each line
1209
1210 */
1211
1212 T_CPHS_RET Cphs_set_divert_status (T_CPHS_FLAG_STATUS line1,
1213 T_CPHS_FLAG_STATUS line2,
1214 T_CPHS_FLAG_STATUS fax,
1215 T_CPHS_FLAG_STATUS data)
1216 {
1217 UBYTE result;
1218 char debug[50];
1219
1220 TRACE_FUNCTION ("Cphs_set_divert_status()");
1221
1222 /* Check CPHS support status. */
1223 // if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
1224 // return cphs_data->cphsStatus;
1225 sprintf(debug, "Original divert status: %x%x",cphs_data->dvData[0],cphs_data->dvData[1]);
1226 TRACE_EVENT(debug);
1227 /* Write status in buffer */
1228 if (line1 EQ CPHS_LINEFLAG_SET OR
1229 line1 EQ CPHS_LINEFLAG_NOT_SET )
1230 { cphs_data->dvData[0] &= 0xF0; //zero low nibble
1231 cphs_data->dvData[0] += line1&0x0F; /* low Nibble */
1232 }
1233 /*else
1234 cphs_data->dvData[0] |= 0x0F;*/
1235
1236 if (line2 EQ CPHS_LINEFLAG_SET OR
1237 line2 EQ CPHS_LINEFLAG_NOT_SET )
1238 {cphs_data->dvData[0] &= 0x0F; //zero high nibble
1239 cphs_data->dvData[0] += (line2 << 4)&0xF0; /* high Nibble */
1240 }
1241 /*else
1242 cphs_data->dvData[0] = 0xF0 | cphs_data->dvData[0];*/
1243
1244 if (fax EQ CPHS_LINEFLAG_SET OR
1245 fax EQ CPHS_LINEFLAG_NOT_SET )
1246 { cphs_data->dvData[0] &= 0xF0; //zero low nibble
1247 cphs_data->dvData[1] += fax&0x0F; /* low Nibble */
1248 }
1249 /* else
1250 cphs_data->dvData[1] |= 0x0F;*/
1251
1252 if (data EQ CPHS_LINEFLAG_SET OR
1253 data EQ CPHS_LINEFLAG_NOT_SET )
1254 { cphs_data->dvData[1] &= 0x0F; //zero high nibble
1255 cphs_data->dvData[1] += (data << 4)&0xF0; /* high Nibble */
1256 }
1257 /*else
1258 cphs_data->dvData[1] = 0xF0 | cphs_data->dvData[1];*/
1259 sprintf(debug, "Divert Data:%x%x", cphs_data->dvData[0], cphs_data->dvData[1]);
1260 TRACE_EVENT(debug);
1261 /* Read call forwarding flag to determine the size */
1262 cphs_data->simStatus = SIMOP_WRITE_OK;
1263 if (!Cphs_read_sim_dat(SIM_CPHS_CFF, NOT_PRESENT_8BIT, CPHS_CFF_SIZE))
1264 { TRACE_EVENT("Mailbox SIM write failed");
1265 return SIMOP_WRITE_ERR;
1266 //cphs_sign_exec(E_CPHS_SET_DV_STAT, &result);
1267 }
1268 /* PATCH VO 22.01.01 end */
1269 return cphs_data->cphsStatus;
1270 }
1271
1272 /*CPHS_RET cphs_set_als_status (T_CPHS_ALS_INFO status)
1273 {
1274 UBYTE result;
1275 //T_MFW_SIM_PIN_STATUS pinStatus;
1276
1277 //TRACE_EVENT ("cphs_set_als_status()");
1278
1279 /* check PIN 2 requirement */
1280 /*pinStatus.type = MFW_SIM_PIN2;
1281 sim_pin_status(&pinStatus);
1282 if (pinStatus.set NEQ MFW_SIM_NO_PIN)
1283 return MFW_SIM_PIN2_REQ;
1284
1285 /* check given parameter */
1286 /*if (status NEQ MFW_LINE_LOCKED AND
1287 status NEQ MFW_LINE_UNLOCKED )
1288 {
1289 result = MFW_SIMOP_WRITE_ERR;
1290 //cphs_sign_exec(E_CPHS_SET_ALS_STATUS, &result);
1291 return CPHS_ERR;
1292 }*/
1293
1294 /* cphs_data->alsData = (UBYTE)status.locked;*/
1295
1296 /* write lock status in EEPROM */
1297 //MC cphs_write_eeprom_alss(&result);
1298 //cphs_sign_exec(E_CPHS_SET_LINE, &result);
1299 // }
1300 /* return CPHS_IS_OK;
1301 }*/
1302
1303 /*
1304 +----------------------------------------------------------------------+
1305 | MODULE: CPHS standalone module |
1306 | STATE : code ROUTINE: Cphs_read_sim_dat |
1307 +----------------------------------------------------------------------+
1308
1309
1310 PURPOSE : Request to read SIM card.
1311
1312 */
1313
1314 BOOL Cphs_read_sim_dat(USHORT data_id, UBYTE len, UBYTE max_length)
1315 {
1316 T_ACI_RETURN res;
1317
1318 TRACE_FUNCTION ("Cphs_read_sim_dat()");
1319
1320 res = cmhSIM_ReadTranspEF ( CMD_SRC_NONE,
1321 AT_CMD_NONE,
1322 data_id,
1323 0,
1324 max_length,
1325 NULL,
1326 Cphs_read_sim_dat_cb);
1327 if (res NEQ AT_EXCT)
1328 return FALSE;
1329
1330 return TRUE;
1331 }
1332
1333 /*
1334 +----------------------------------------------------------------------+
1335 | MODULE: CPHS standalone module |
1336 | STATE : code ROUTINE: Cphs_read_sim_dat_cb |
1337 +----------------------------------------------------------------------+
1338
1339
1340 PURPOSE : Call back for SIM read.
1341
1342 */
1343
1344 void Cphs_read_sim_dat_cb(SHORT table_id)
1345 {
1346 UBYTE dataLen;
1347 UBYTE result;
1348
1349
1350 switch (simShrdPrm.atb[table_id].reqDataFld)
1351 {
1352 case SIM_CPHS_CINF: /* CPHS information */
1353 if (!cphs_data->cphsUpdate)
1354 Cphs_read_information(simShrdPrm.atb[table_id].errCode,
1355 simShrdPrm.atb[table_id].exchData,
1356 simShrdPrm.atb[table_id].dataLen);
1357 /*#ifdef SIM_TOOLKIT
1358 else
1359 Cphs_update_info_cnf(simShrdPrm.atb[table_id].errCode,
1360 simShrdPrm.atb[table_id].exchData,
1361 simShrdPrm.atb[table_id].dataLen);
1362 #endif*/
1363 break;
1364
1365 case SIM_CPHS_ONSTR: /* operator name string */
1366
1367 Cphs_read_ons(simShrdPrm.atb[table_id].errCode,
1368 simShrdPrm.atb[table_id].exchData,
1369 simShrdPrm.atb[table_id].dataLen);
1370 break;
1371
1372 case SIM_CPHS_ONSHF: /* operator name short form */
1373
1374 Cphs_read_onsf(simShrdPrm.atb[table_id].errCode,
1375 simShrdPrm.atb[table_id].exchData,
1376 simShrdPrm.atb[table_id].dataLen);
1377 Cphs_get_mailbox_status();//get next item
1378 break;
1379
1380 case SIM_CPHS_VMW: /* voice message waiting flag */
1381
1382 if (cphs_data->simStatus EQ SIMOP_WRITE_OK)
1383 {
1384 /* Determine the size of this field, and write the data.
1385 When the writing is not possible, write this voice
1386 message waiting flag in EEPROM. */
1387 cphs_data->simStatus = SIMOP_UNKNOWN;
1388 #ifdef FF_2TO1_PS
1389 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
1390 #else
1391 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
1392 #endif
1393 {
1394 dataLen = simShrdPrm.atb[table_id].dataLen;
1395 /* Write voice message waiting flag.
1396 When this writing failed, send event with "write error" parameter to MMI */
1397 if (!Cphs_write_sim_dat(SIM_CPHS_VMW, cphs_data->mbsData, dataLen))
1398 {
1399 cphs_data->mbStatus.result = SIMOP_WRITE_ERR;
1400
1401 cphs_data->mbStatus.line1 = CPHS_FLAG_NOT_PRESENT;
1402 cphs_data->mbStatus.line2 = CPHS_FLAG_NOT_PRESENT;
1403 cphs_data->mbStatus.fax = CPHS_FLAG_NOT_PRESENT;
1404 cphs_data->mbStatus.data = CPHS_FLAG_NOT_PRESENT;
1405 }
1406 }
1407 else
1408 {
1409 cphs_data->mbStatus.result = SIMOP_WRITE_ERR;
1410 //cphs_sign_exec(E_CPHS_SET_VC_STAT, &result);
1411 cphs_data->mbStatus.line1 = CPHS_FLAG_NOT_PRESENT;
1412 cphs_data->mbStatus.line2 = CPHS_FLAG_NOT_PRESENT;
1413 cphs_data->mbStatus.fax = CPHS_FLAG_NOT_PRESENT;
1414 cphs_data->mbStatus.data = CPHS_FLAG_NOT_PRESENT;
1415 }
1416 }
1417 else
1418 /* PATCH VO 22.01.01 end */
1419 {
1420 Cphs_read_mbs (simShrdPrm.atb[table_id].errCode,
1421 simShrdPrm.atb[table_id].exchData,
1422 simShrdPrm.atb[table_id].dataLen);
1423 Cphs_get_csp();
1424 }
1425 break;
1426
1427 case SIM_CPHS_CFF: /* call forwarding flag */
1428 /* PATCH VO 22.01.01 */
1429 if (cphs_data->simStatus EQ SIMOP_WRITE_OK)
1430 {
1431 /* Determine the size of this field, and write the data.
1432 When the writing is not possible, write this voice
1433 message waiting flag in EEPROM. */
1434 cphs_data->simStatus = SIMOP_UNKNOWN;
1435 #ifdef FF_2TO1_PS
1436 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
1437 #else
1438 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
1439 #endif
1440 {
1441 dataLen = simShrdPrm.atb[table_id].dataLen;
1442 /* Write call forwarding flag.
1443 When this writing failed, send event with "write error" parameter to MMI */
1444 if (!Cphs_write_sim_dat(SIM_CPHS_CFF, cphs_data->dvData, dataLen))
1445 { TRACE_EVENT("Divert write failed");
1446 cphs_data->dvStatus.result = SIMOP_WRITE_ERR;
1447 cphs_data->dvStatus.line1 = CPHS_FLAG_NOT_PRESENT;
1448 cphs_data->dvStatus.line2 = CPHS_FLAG_NOT_PRESENT;
1449 cphs_data->dvStatus.fax = CPHS_FLAG_NOT_PRESENT;
1450 cphs_data->dvStatus.data = CPHS_FLAG_NOT_PRESENT;
1451 }
1452 }
1453 else
1454 {TRACE_EVENT("Sim error while writing");
1455 cphs_data->dvStatus.result = SIMOP_WRITE_ERR;
1456 cphs_data->dvStatus.line1 = CPHS_FLAG_NOT_PRESENT;
1457 cphs_data->dvStatus.line2 = CPHS_FLAG_NOT_PRESENT;
1458 cphs_data->dvStatus.fax = CPHS_FLAG_NOT_PRESENT;
1459 cphs_data->dvStatus.data = CPHS_FLAG_NOT_PRESENT;
1460 }
1461 }
1462 else
1463 /* PATCH VO 22.01.01 end */
1464 {Cphs_get_mailbox();
1465 Cphs_read_cff (simShrdPrm.atb[table_id].errCode,
1466 simShrdPrm.atb[table_id].exchData,
1467 simShrdPrm.atb[table_id].dataLen);
1468 }
1469 break;
1470
1471
1472
1473 case SIM_CPHS_CSP: /* customer service profile */
1474 Cphs_read_csp (simShrdPrm.atb[table_id].errCode,
1475 simShrdPrm.atb[table_id].exchData,
1476 simShrdPrm.atb[table_id].dataLen);
1477 //All CPHS data fields have now been read
1478 //so call callback function to alert client layer
1479
1480 break;
1481
1482 default:
1483 break;
1484 }
1485 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1486 }
1487
1488 /*
1489 +----------------------------------------------------------------------+
1490 | MODULE: CPHS standalone module |
1491 | STATE : code ROUTINE: Cphs_read_sim_rcd |
1492 +----------------------------------------------------------------------+
1493
1494
1495 PURPOSE : Request to read SIM card.
1496
1497 */
1498
1499 BOOL Cphs_read_sim_rcd(USHORT data_id, UBYTE rcd_num, UBYTE len)
1500 {
1501 T_ACI_RETURN res;
1502 UBYTE dataLen;
1503
1504 TRACE_FUNCTION ("Cphs_read_sim_rcd()");
1505
1506 if (rcd_num EQ 1)
1507 dataLen = UCHAR_MAX;
1508 else
1509 dataLen = len;
1510
1511 res = cmhSIM_ReadRecordEF ( CMD_SRC_NONE,
1512 AT_CMD_NONE,
1513 data_id,
1514 rcd_num,
1515 dataLen,
1516 NULL,
1517 Cphs_read_sim_rcd_cb);
1518
1519 if (res NEQ AT_EXCT)
1520 return FALSE;
1521
1522 return TRUE;
1523 }
1524
1525 /*
1526 +----------------------------------------------------------------------+
1527 | MODULE: CPHS standalone module |
1528 | STATE : code ROUTINE: Cphs_read_sim_rcd_cb |
1529 +----------------------------------------------------------------------+
1530
1531
1532 PURPOSE : Request to read SIM card.
1533
1534 */
1535
1536 void Cphs_read_sim_rcd_cb (SHORT table_id)
1537 {
1538 UBYTE dataLen;
1539 char debug[25];
1540 sprintf(debug, "SIM Error code!!!%d", simShrdPrm.atb[table_id].errCode);
1541
1542 TRACE_FUNCTION ("Cphs_read_sim_rcd_cb()");
1543 TRACE_EVENT(debug);
1544
1545 switch (simShrdPrm.atb[table_id].reqDataFld)
1546 {
1547 case SIM_CPHS_MBXN: /* mailbox numbers */
1548 if (cphs_data->simStatus EQ SIMOP_WRITE_OK)
1549 {
1550 /* Determine the size of record, and write a new record.
1551 When the writing is not possible, write this mailbox
1552 number in EEPROM. */
1553 cphs_data->simStatus = SIMOP_UNKNOWN;
1554 #ifdef FF_2TO1_PS
1555 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
1556 #else
1557 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
1558 #endif
1559 {
1560 dataLen = simShrdPrm.atb[table_id].dataLen;
1561 /* allocate mbnData (sizeof(dataLen)) */
1562 Cphs_build_mbn_data(cphs_data->mbnData, dataLen);
1563 if (!Cphs_write_sim_rcd(SIM_CPHS_MBXN, cphs_data->vcEntry->index,
1564 cphs_data->mbnData, dataLen))
1565 Cphs_write_eeprom_mailbox(cphs_data->vcEntry);
1566 }
1567 else
1568 Cphs_write_eeprom_mailbox(cphs_data->vcEntry);
1569 }
1570 else
1571 Cphs_read_mbn(table_id);
1572
1573 break;
1574
1575 case SIM_CPHS_INFN: /* information numbers */
1576 if (simShrdPrm.atb[table_id].recNr EQ 1)
1577 {
1578
1579 if ((cphs_data->startIdx EQ 1) AND (cphs_data->simStatus EQ SIMOP_READ_OK))
1580 Cphs_read_info_num(table_id);
1581 else
1582
1583 Cphs_read_first_info_num(table_id);
1584 }
1585 else
1586 Cphs_read_info_num(table_id);
1587 break;
1588
1589 case SIM_CPHS_INFN2: /* information numbers 2 - 7F10 'EA01' selected if SIM_CPHS_INFN '6F19' isn't there*/
1590 if (simShrdPrm.atb[table_id].recNr EQ 1)
1591 {
1592
1593 if ((cphs_data->startIdx EQ 1) AND (cphs_data->simStatus EQ SIMOP_READ_OK))
1594 Cphs_read_info_num(table_id);
1595 else
1596 Cphs_read_first_info_num(table_id);
1597 }
1598 else
1599 Cphs_read_info_num(table_id);
1600 break;
1601
1602 default:
1603 break;
1604 }
1605 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1606 }
1607
1608 /*
1609 +----------------------------------------------------------------------+
1610 | MODULE: CPHS standalone module |
1611 | STATE : code ROUTINE: Cphs_write_sim_rcd |
1612 +----------------------------------------------------------------------+
1613
1614
1615 PURPOSE : Request to write SIM card.
1616
1617 */
1618
1619 BOOL Cphs_write_sim_rcd(USHORT data_id, UBYTE rcd_num,
1620 UBYTE *data, UBYTE dataLen)
1621 {
1622 T_ACI_RETURN res;
1623
1624 TRACE_FUNCTION ("Cphs_read_sim_rcd()");
1625
1626 res = cmhSIM_WriteRecordEF (CMD_SRC_NONE,
1627 AT_CMD_NONE,
1628 data_id,
1629 rcd_num,
1630 dataLen,
1631 data,
1632 Cphs_write_sim_rcd_cb);
1633
1634 if (res NEQ AT_EXCT)
1635 return FALSE;
1636
1637 return TRUE;
1638 }
1639
1640 /*
1641 +----------------------------------------------------------------------+
1642 | MODULE: CPHS standalone module |
1643 | STATE : code ROUTINE: Cphs_write_sim_rcd_cb |
1644 +----------------------------------------------------------------------+
1645
1646
1647 PURPOSE : callback of SIM card writing.
1648
1649 */
1650
1651 void Cphs_write_sim_rcd_cb (SHORT table_id)
1652 {
1653 UBYTE result;
1654 char debug[30];
1655 TRACE_FUNCTION ("Cphs_write_sim_rcd_cb()");
1656 sprintf(debug, "SIM Error code!!!%d", simShrdPrm.atb[table_id].errCode);
1657 TRACE_EVENT(debug);
1658 switch (simShrdPrm.atb[table_id].reqDataFld)
1659 {
1660 case SIM_CPHS_MBXN: /* mailbox numbers */
1661 #ifdef FF_2TO1_PS
1662 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
1663 #else
1664 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
1665 #endif
1666 {
1667 cphs_data->mbNum.result = SIMOP_WRITE_OK;
1668 //cphs_sign_exec(E_CPHS_SET_VC_NUM, &result);
1669 }
1670 else
1671 {
1672 Cphs_write_eeprom_mailbox(cphs_data->vcEntry);
1673 }
1674 break;
1675
1676 default:
1677 break;
1678 }
1679 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1680 }
1681
1682 /*
1683 +--------------------------------------------------------------------------+
1684 | MODULE : CPHS standalone module |
1685 | STATE : code ROUTINE : Cphs_read_first_info_num |
1686 +--------------------------------------------------------------------------+
1687
1688 PURPOSE : Read first record of information numbers
1689
1690 */
1691
1692 void Cphs_read_first_info_num(SHORT table_id)
1693 {
1694 //UBYTE* pData; /* points to data buffer */
1695 UBYTE dataLen;
1696
1697 TRACE_FUNCTION ("Cphs_read_first_info_num()");
1698
1699 #ifdef FF_2TO1_PS
1700 if ( simShrdPrm.atb[table_id].errCode NEQ CAUSE_SIM_NO_ERROR ) /* VO patch 040501 - remove dataLen and pData check */
1701 #else
1702 if ( simShrdPrm.atb[table_id].errCode NEQ SIM_NO_ERROR ) /* VO patch 040501 - remove dataLen and pData check */
1703 #endif
1704 {
1705 if (cphs_data->simStatus EQ SIMOP_READ_OK) /* Read entry of information numbers */
1706 {
1707 cphs_data->simStatus = SIMOP_UNKNOWN;
1708 cphs_data->infoEntry->result = SIMOP_READ_ERR;
1709 if (cphs_data->InfoNumberCB != NULL)
1710 (cphs_data->InfoNumberCB)(NULL, cphs_data->infoEntry);
1711
1712 }
1713 else
1714 {// if we are here then its possible the read of 7F20 6F19 failed.
1715 // so we must try reading 7F10 EA01 instead.
1716
1717 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN)
1718 {
1719 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN2, 1, 0))
1720 {
1721 cphs_data->infoEntry->result = SIMOP_READ_ERR;
1722 if (cphs_data->InfoNumberCB != NULL)
1723 (cphs_data->InfoNumberCB)(NULL, cphs_data->infoEntry);
1724 }
1725 else
1726 {
1727 cphs_data->cphsPrevRead = SIM_CPHS_INFN2;
1728 }
1729 }
1730 else
1731 { if (cphs_data->InfoNumberListCB != NULL)
1732 (cphs_data->InfoNumberListCB)(cphs_data->numList, NULL);
1733 }
1734 }
1735 }
1736 else
1737 {
1738 cphs_data->maxRec = simShrdPrm.atb[table_id].recMax;
1739 dataLen = simShrdPrm.atb[table_id].dataLen;
1740
1741 if (cphs_data->simStatus EQ SIMOP_READ_OK) /* Read entry of information numbers */
1742 {
1743 /* VO patch 040501 - add dataLen check: if (patch) else ... */
1744 if (dataLen < CPHS_MIN_INS_SIZE )
1745 {
1746 cphs_data->simStatus = SIMOP_UNKNOWN;
1747 cphs_data->infoEntry->result = SIMOP_READ_ERR;
1748 }
1749 else
1750 Cphs_req_info_num_read(cphs_data->startIdx, dataLen);
1751 }
1752 else /* Read list of information numbers */
1753 {
1754 /* VO patch 040501 - add dataLen check: if (patch) else ... */
1755 if (dataLen >= CPHS_MIN_INS_SIZE )
1756 {
1757 if (cphs_data->idxLevel EQ 1) /* read this entry */
1758 Cphs_read_info_num(table_id);
1759 else /* read the startIndex record */
1760 Cphs_req_info_num_read(cphs_data->startIdx, dataLen);
1761 }
1762 }
1763 }
1764 }
1765 T_PHB_NPI cvtNpi(T_ACI_TOA_NPI npi)
1766 {
1767 switch (npi)
1768 {
1769 case NPI_NotPresent:
1770 case NPI_Unknown: return CPHS_NPI_UNKNOWN;
1771 case NPI_IsdnTelephony: return CPHS_NPI_ISDN;
1772 case NPI_Data: return CPHS_NPI_DATA;
1773 case NPI_Telex: return CPHS_NPI_TELEX;
1774 case NPI_Private: return CPHS_NPI_PRIVATE;
1775 case NPI_National: return CPHS_NPI_NATIONAL;
1776 #ifdef FF_2TO1_PS
1777 case NPI_Ermes: return CPHS_NPI_M_ERMES;
1778 case NPI_Cts: return CPHS_NPI_M_CTS;
1779 #else
1780 case NPI_ERMES: return CPHS_NPI_M_ERMES;
1781 case NPI_CTS: return CPHS_NPI_M_CTS;
1782 #endif
1783 default: return npi;
1784 }
1785 }
1786 /*
1787 +---------------------------------------------------------------------+
1788 | MODULE : CPHS standalone module |
1789 | STATE : code ROUTINE : Cphs_read_info_num |
1790 +---------------------------------------------------------------------+
1791
1792 PURPOSE : Read first record of information numbers
1793
1794 */
1795
1796 void Cphs_read_info_num(SHORT table_id)
1797 {
1798 UBYTE* pData; /* points to data buffer */
1799 UBYTE dataLen;
1800 UBYTE alphaLen;
1801 UBYTE recNr;
1802 T_ACI_TOA type;
1803
1804 TRACE_FUNCTION ("Cphs_read_info_num()");
1805
1806 pData = simShrdPrm.atb[table_id].exchData;
1807 dataLen = simShrdPrm.atb[table_id].dataLen;
1808 recNr = simShrdPrm.atb[table_id].recNr;
1809
1810 #ifdef FF_2TO1_PS
1811 if ( simShrdPrm.atb[table_id].errCode NEQ CAUSE_SIM_NO_ERROR OR
1812 #else
1813 if ( simShrdPrm.atb[table_id].errCode NEQ SIM_NO_ERROR OR
1814 #endif
1815 pData EQ NULL OR
1816 dataLen < CPHS_MIN_INS_SIZE )
1817 {
1818 if (cphs_data->simStatus EQ SIMOP_READ_OK) /* Read entry of information numbers */
1819 {
1820 cphs_data->simStatus = SIMOP_UNKNOWN;
1821 cphs_data->infoEntry->result = SIMOP_READ_ERR;
1822 TRACE_EVENT("Info num read error");
1823 if (cphs_data->InfoNumberCB != NULL)
1824 (cphs_data->InfoNumberCB)(NULL, cphs_data->infoEntry);
1825
1826 }
1827 else
1828 {// if we are here then its possible the read of 7F20 6F19 failed.
1829 // so we must try reading 7F10 EA01 instead.
1830
1831 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN2)
1832 {
1833 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN2, 1, 0))
1834 {
1835 cphs_data->infoEntry->result = SIMOP_READ_ERR;
1836 if (cphs_data->InfoNumberCB != NULL)
1837 (cphs_data->InfoNumberCB)(NULL, cphs_data->infoEntry);
1838 }
1839 else
1840 {
1841 cphs_data->cphsPrevRead = SIM_CPHS_INFN2;
1842 }
1843 }
1844 else
1845 { if (cphs_data->InfoNumberListCB != NULL)
1846 (cphs_data->InfoNumberListCB)(cphs_data->numList, NULL);
1847 }
1848 }
1849 (cphs_data->InfoNumberListCB)(cphs_data->numList, NULL);
1850 }
1851 else
1852 {
1853 if (cphs_data->simStatus EQ SIMOP_READ_OK)
1854 {
1855 /* Read entry of information numbers */
1856 alphaLen = *pData;
1857 if (alphaLen)
1858 {
1859 /* copy/encode entry */
1860 cphs_data->infoEntry->index = recNr;
1861 cphs_data->infoEntry->entryStat = *(pData + 1);
1862
1863 cmhPHB_getMfwTagNt(pData + 2, alphaLen,
1864 cphs_data->infoEntry->alpha.data, &cphs_data->infoEntry->alpha.len);
1865
1866 pData += alphaLen + 2;
1867
1868 if (*pData NEQ 0xFF)
1869 {
1870 cmhPHB_getAdrStr ( (CHAR *)cphs_data->infoEntry->number,
1871 3, /* length of number */
1872 pData + 2,
1873 *pData );
1874 cmhPHB_toaDmrg ( *( pData + 1 ), &type );
1875 cphs_data->infoEntry->ton = cvtTon(type.ton);
1876 cphs_data->infoEntry->npi = cvtNpi(type.npi);
1877 cphs_data->infoEntry->entryStat = cphs_data->infoEntry->entryStat | 0x80;
1878 }
1879 else
1880 {
1881 cphs_data->infoEntry->number[0] = '\0';
1882 cphs_data->infoEntry->ton = CPHS_TON_UNKNOWN;
1883 cphs_data->infoEntry->npi = CPHS_NPI_UNKNOWN;
1884 }
1885 }
1886 cphs_data->infoEntry->result = SIMOP_READ_OK;
1887 if (cphs_data->InfoNumberCB != NULL)
1888 (cphs_data->InfoNumberCB)((T_CPHS_INFO_NUM_LIST*)NULL, cphs_data->infoEntry);
1889 return;
1890 }
1891
1892 else if ((*(pData + 1) & 0x0F) > cphs_data->idxLevel)
1893 {
1894 /* This is not wished index level. Read the next */
1895 recNr++;
1896 Cphs_req_info_num_read(recNr, dataLen);
1897 }
1898 else
1899 {
1900 /* This is the wished index level. Read it. */
1901 alphaLen = *pData;
1902 if (alphaLen) /* check alpha length */
1903 {
1904 /* copy/encode this entry in list */
1905 cphs_data->numList->level = cphs_data->idxLevel;
1906 cphs_data->numList->entry[cphs_data->numList->count].index = recNr;
1907 cphs_data->numList->entry[cphs_data->numList->count].entryStat = *(pData + 1) & 0x7F; /* set bit 8 to 0 */
1908
1909 cmhPHB_getMfwTagNt(pData + 2, alphaLen,
1910 cphs_data->numList->entry[cphs_data->numList->count].alpha.data,
1911 &cphs_data->numList->entry[cphs_data->numList->count].alpha.len);
1912
1913 pData += alphaLen + 2;
1914
1915 if (*pData NEQ 0xFF)
1916 {
1917 cphs_data->numList->entry[cphs_data->numList->count].entryStat = cphs_data->numList->entry[cphs_data->numList->count].entryStat | 0x80;
1918 }
1919 cphs_data->numList->count++;
1920 }
1921 recNr++;
1922 /* Read the next record */
1923 Cphs_req_info_num_read(recNr, dataLen);
1924 }
1925 }
1926 }
1927
1928
1929 /*
1930 +------------------------------------------------------------------------+
1931 | MODULE : CPHS standalone module |
1932 | STATE : code ROUTINE : Cphs_req_info_num_read |
1933 +------------------------------------------------------------------------+
1934
1935 PURPOSE : Read customer service profile
1936
1937 */
1938
1939 void Cphs_req_info_num_read(UBYTE rcd_num, UBYTE dataLen)
1940 {
1941 TRACE_FUNCTION ("Cphs_req_info_num_read()");
1942
1943 if (rcd_num > cphs_data->maxRec)
1944 { if (cphs_data->InfoNumberListCB != NULL)
1945 (cphs_data->InfoNumberListCB)(cphs_data->numList, (T_CPHS_INFO_NUM_ENTRY*) NULL);
1946
1947 return;
1948 }
1949 else
1950 {
1951 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN)
1952 {
1953 if (Cphs_read_sim_rcd(SIM_CPHS_INFN, rcd_num, dataLen))
1954 {
1955
1956 cphs_data->cphsPrevRead = SIM_CPHS_INFN;
1957 }
1958 }
1959 else
1960 {
1961 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN2)
1962 {
1963 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN2, rcd_num, dataLen))
1964 if (cphs_data->InfoNumberListCB != NULL)
1965 (cphs_data->InfoNumberListCB)(cphs_data->numList, (T_CPHS_INFO_NUM_ENTRY*) NULL);
1966 else
1967 {
1968 cphs_data->cphsPrevRead = SIM_CPHS_INFN2;
1969 }
1970 }
1971 }
1972 }
1973 }
1974
1975 /*
1976 +----------------------------------------------------------------------+
1977 | MODULE: CPHS standalone module |
1978 | STATE : code ROUTINE: Cphs_build_mbn_data |
1979 +----------------------------------------------------------------------+
1980
1981
1982 PURPOSE : Build mailbox number data in SIM format.
1983
1984 */
1985
1986 void Cphs_build_mbn_data(UBYTE *data, UBYTE len)
1987 {
1988 UBYTE alphaLen;
1989 UBYTE numLen;
1990 UBYTE *pNumber;
1991 UBYTE i, j;
1992
1993 TRACE_FUNCTION ("Cphs_build_mbn_data()");
1994
1995 memset(data, MFW_INVALID_SIM_DATA, len);
1996
1997 /* alpha data */
1998 if (len <= CPHS_MIN_MBN_SIZE)
1999 alphaLen = 0;
2000 else
2001 alphaLen = len - CPHS_MIN_MBN_SIZE;
2002 i = MINIMUM (alphaLen, cphs_data->vcEntry->alpha.len);
2003
2004 for ( j = 0; j < i; j++ )
2005 data[j] = cphs_data->vcEntry->alpha.data[j];
2006
2007 data += alphaLen;
2008
2009 /* number data and TON/NPI data */
2010 if ( cphs_data->vcEntry->number[0] EQ '+' )
2011 {
2012 cphs_data->vcEntry->ton = TON_International;
2013 pNumber = &cphs_data->vcEntry->number[1];
2014 }
2015 else
2016 pNumber = &cphs_data->vcEntry->number[0];
2017
2018 cmhPHB_getAdrBcd ( data + 2, &numLen,
2019 PHB_MAX_LEN, (CHAR *)pNumber );
2020 *data = numLen + 1;
2021 *(data + 1) = ((( cphs_data->vcEntry -> ton << 4 ) & 0xF0 ) + ( cphs_data->vcEntry -> npi & 0x0F )) | 0x80;
2022
2023 data += 12;
2024
2025 /* capability/configuration identifier data and EXT identifier data */
2026 *data = 0xFF;
2027 *(data + 1) = 0xFF;
2028 }
2029
2030 /*
2031 +--------------------------------------------------------------------------+
2032 | MODULE : CPHS standalone module |
2033 | STATE : code ROUTINE : Cphs_read_eeprom_mailbox |
2034 +--------------------------------------------------------------------------+
2035
2036 PURPOSE : Read mailbox number from EEPROM
2037
2038 */
2039
2040 void Cphs_read_eeprom_mailbox(void)
2041 {
2042 U8 version;
2043
2044 #ifdef PCM_2_FFS
2045 EF_MBN mbn;
2046 #else
2047 T_PSPDF_MBN mbn;
2048 #endif
2049
2050 T_ACI_TOA numTp;
2051 int i;
2052 USHORT max_rcd;
2053 TRACE_FUNCTION("Cphs_read_eeprom_mailbox()");
2054 for (i=0; i<MAX_CPHS_ENTRY; i++)
2055 {
2056 //switching from PCM to FFS
2057 #ifdef PCM_2_FFS
2058 if (ffs_fread("/Mailbox_no", &mbn, sizeof(mbn)) EQ EFFS_OK)
2059 #else
2060 if (FFS_fread("/Mailbox_no", &mbn, sizeof(mbn)) EQ EFFS_OK)
2061 #endif
2062 {
2063 if (mbn.len)
2064 {
2065 cphs_data->mbNum.entries[cphs_data->mbNum.count].index = i+1;
2066 cmhPHB_getAdrStr ( (char *)cphs_data->mbNum.entries[cphs_data->mbNum.count].number,
2067 PHB_MAX_LEN - 1, mbn.mbNum, mbn.len );
2068 cmhPHB_getMfwTagNt ( mbn.alphId, 10,
2069 cphs_data->mbNum.entries[cphs_data->mbNum.count].alpha.data,
2070 &cphs_data->mbNum.entries[cphs_data->mbNum.count].alpha.len );
2071 cmhPHB_toaDmrg ( mbn.numTp, &numTp );
2072 cphs_data->mbNum.entries[cphs_data->mbNum.count].ton = cvtTon(numTp.ton);
2073 cphs_data->mbNum.entries[cphs_data->mbNum.count].npi = cvtNpi(numTp.npi);
2074 cphs_data->mbNum.entries[cphs_data->mbNum.count].service = i;
2075 cphs_data->mbNum.count++;
2076 }
2077 }
2078 }
2079 }
2080
2081 /*
2082 +---------------------------------------------------------------------------+
2083 | MODULE : CPHS standalone module |
2084 | STATE : code ROUTINE : Cphs_write_eeprom_mailbox |
2085 +---------------------------------------------------------------------------+
2086
2087 PURPOSE : Write mailbox number in EEPROM
2088
2089 */
2090
2091 void Cphs_write_eeprom_mailbox(T_CPHS_MAILBOX_NUM_ENTRY *entry)
2092 {
2093 T_ACI_PB_TEXT text;
2094 UBYTE len;
2095
2096 #ifdef PCM_2_FFS
2097 EF_MBN mbn;
2098 #else
2099 T_PSPDF_MBN mbn;
2100 #endif
2101
2102 T_ACI_TOA type;
2103 UBYTE *pNumber;
2104 UBYTE result;
2105 UBYTE outLen;
2106 TRACE_FUNCTION("Cphs_write_eeprom_mailbox");
2107
2108 len = MINIMUM ( MAX_PCM_MAILBOX_LEN, entry->alpha.len);
2109 text.len = len;
2110 memcpy(text.data, entry->alpha.data, len);
2111 text.cs = CS_Sim;
2112 cmhPHB_getMfwTagSim ( &text, mbn.alphId, &outLen, MAX_PCM_MAILBOX_LEN );
2113
2114 if ( entry->number[0] EQ '+')
2115 {
2116 type.ton = TON_International;
2117 pNumber = &entry->number[1];
2118 }
2119 else
2120 {
2121 type.ton = entry->ton;
2122 pNumber = &entry->number[0];
2123 }
2124 type.npi = entry->npi;
2125 //MC- switching from PCM to FFS
2126 cmhPHB_toaMrg ( &type, &mbn.numTp );
2127
2128 cmhPHB_getAdrBcd ((UBYTE*) mbn.mbNum, &mbn.len,
2129 MAX_PCM_MAILBOX_LEN, (CHAR *)pNumber );
2130 mbn.len++;
2131
2132 //if (pcm_WriteRecord((UBYTE *)EF_MBN_ID, (USHORT)entry->index,
2133 // SIZE_EF_MBN, (UBYTE *)&mbn) EQ PCM_OK)
2134 // if (flash_write() EQ EFFS_OK)
2135 #ifdef PCM_2_FFS
2136 if (ffs_fwrite("/Mailbox_no", &mbn, sizeof(mbn)) EQ EFFS_OK)
2137 #else
2138 if (FFS_fwrite("/Mailbox_no", &mbn, sizeof(mbn)) EQ EFFS_OK)
2139 #endif
2140 cphs_data->mbNum.result = SIMOP_WRITE_OK;
2141 else
2142 cphs_data->mbNum.result = SIMOP_WRITE_ERR;
2143
2144 }
2145
2146
2147 /*
2148 +----------------------------------------------------------------------+
2149 | MODULE : CPHS standalone module |
2150 | STATE : code ROUTINE : Cphs_select_info_num |
2151 +----------------------------------------------------------------------+
2152
2153 PURPOSE : read a information number entry
2154
2155 */
2156
2157 void Cphs_select_info_num (UBYTE index)
2158 {
2159 TRACE_FUNCTION ("Cphs_select_info_num()");
2160
2161 /* check CPHS service table */
2162 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
2163 return ;
2164
2165 /* Read a information number entry.
2166 When this reading failed, send event with "read error" parameter to MMI */
2167 cphs_data->simStatus = SIMOP_READ_OK;
2168 cphs_data->startIdx = index;
2169
2170 // By now we know if 6F19 or EA01 are present for reading info. num entries from
2171 // So lets use this knowledge.
2172
2173 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN)
2174 {
2175 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN, 1, 0))
2176 {
2177 cphs_data->infoEntry->result = SIMOP_READ_ERR;
2178 //cphs_sign_exec(E_CPHS_GET_INFO_NUM, &infoEntry);
2179 (cphs_data->InfoNumberCB)((T_CPHS_INFO_NUM_LIST*) NULL, cphs_data->infoEntry);
2180 }
2181 else
2182 {
2183 cphs_data->cphsPrevRead = SIM_CPHS_INFN;
2184 }
2185 }
2186 else
2187 {
2188 if (cphs_data->cphsPrevRead EQ SIM_CPHS_INFN2)
2189 {
2190 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN2, 1, 0))
2191 {
2192 cphs_data->infoEntry->result = SIMOP_READ_ERR;
2193 //cphs_sign_exec(E_CPHS_GET_INFO_NUM, &infoEntry);
2194 (cphs_data->InfoNumberCB)((T_CPHS_INFO_NUM_LIST*)NULL, cphs_data->infoEntry);
2195 }
2196 else
2197 {
2198 cphs_data->cphsPrevRead = SIM_CPHS_INFN2;
2199 }
2200 }
2201 }
2202 }
2203
2204
2205
2206 /*
2207 +-----------------------------------------------------------------------+
2208 | MODULE : CPHS standalone module |
2209 | STATE : code ROUTINE : Cphs_read_ons |
2210 +-----------------------------------------------------------------------+
2211
2212 PURPOSE : Read operator name short form
2213
2214 */
2215
2216 void Cphs_read_ons(SHORT errCode, UBYTE *data, UBYTE dataLen)
2217 {
2218 UBYTE *ptr;
2219
2220 TRACE_FUNCTION ("Cphs_read_ons()");
2221
2222 ptr = data;
2223 #ifdef FF_2TO1_PS
2224 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2225 #else
2226 if ( errCode NEQ SIM_NO_ERROR OR
2227 #endif
2228 ptr EQ NULL OR
2229 // dataLen < MFW_CPHS_ONS_SIZE )
2230 dataLen <= 0 ) /* PATCH VO 22.01.01: not check a certain length */
2231 {
2232 cphs_data->opName.long_name.len = 0;
2233 }
2234 else
2235 {
2236 cmhPHB_getMfwTagNt(ptr, (UBYTE)MINIMUM(LONG_NAME, dataLen),
2237 cphs_data->opName.long_name.data, &cphs_data->opName.long_name.len);
2238 //cphs_data->opName.long_name.dcs = MFW_DCS_SIM;
2239
2240 /* Read operator name shortform */
2241 if ((cphs_data->cphsPhase NEQ 2) OR
2242 (Cphs_ssc(CHPS_NAME_SHORT, cphs_data->cphsServTab) NEQ ALLOCATED_AND_ACTIVATED) OR
2243 !Cphs_read_sim_dat(SIM_CPHS_ONSHF, NOT_PRESENT_8BIT, CPHS_ONSF_SIZE) )
2244 {
2245 cphs_data->opName.short_name.len = 0;
2246 }
2247 }
2248 }
2249
2250 /*
2251 +-----------------------------------------------------------------------+
2252 | MODULE : CPHS standalone module |
2253 | STATE : code ROUTINE : Cphs_read_onsf |
2254 +-----------------------------------------------------------------------+
2255
2256 PURPOSE : Read operator name short form
2257
2258 */
2259
2260 void Cphs_read_onsf(SHORT errCode, UBYTE *data, UBYTE dataLen)
2261 {
2262 UBYTE *ptr;
2263
2264 TRACE_FUNCTION ("Cphs_read_onsf()");
2265
2266 ptr = data;
2267 #ifdef FF_2TO1_PS
2268 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2269 #else
2270 if ( errCode NEQ SIM_NO_ERROR OR
2271 #endif
2272 ptr EQ NULL OR
2273 dataLen < CPHS_ONSF_SIZE )
2274 {
2275 cphs_data->opName.short_name.len = 0;
2276 }
2277 else
2278 {
2279 cmhPHB_getMfwTagNt(ptr, CPHS_ONSF_SIZE,
2280 cphs_data->opName.short_name.data, &cphs_data->opName.short_name.len);
2281 //cphs_data->opName.shortName.dcs = MFW_DCS_SIM;
2282 }
2283
2284 //cphs_sign_exec(E_CPHS_OP_NAME, &opName);
2285 }
2286
2287 /*
2288 +-----------------------------------------------------------------------+
2289 | MODULE : CPHS standalone module |
2290 | STATE : code ROUTINE : cvtTon |
2291 +-----------------------------------------------------------------------+
2292
2293 PURPOSE : Convert Type of Number
2294
2295 */
2296
2297
2298 T_CPHS_PHB_TON cvtTon(T_ACI_TOA_TON ton)
2299 {
2300 switch (ton)
2301 {
2302 case TON_NotPresent:
2303 case TON_Unknown: return CPHS_TON_UNKNOWN;
2304 case TON_International: return CPHS_TON_INTERNATIONAL;
2305 case TON_National: return CPHS_TON_NATIONAL;
2306 case TON_NetSpecific: return CPHS_TON_NET_SPECIFIC;
2307 case TON_DedAccess: return CPHS_TON_DED_ACCESS;
2308 case TON_Alphanumeric: return CPHS_TON_ALPHA_NUMERIC;
2309 case TON_Abbreviated: return CPHS_TON_ABBREVIATED;
2310 case TON_Extended: return CPHS_TON_EXTENDED;
2311 default: return ton;
2312 }
2313 }
2314 /*
2315 +-----------------------------------------------------------------------+
2316 | MODULE : CPHS standalone module |
2317 | STATE : code ROUTINE : cphs_read_mbn |
2318 +-----------------------------------------------------------------------+
2319
2320 PURPOSE : Read mailbox number into runtime variables
2321
2322 */
2323 void Cphs_read_mbn(SHORT table_id)
2324 {
2325 UBYTE* pData; /* points to data buffer */
2326 UBYTE alphaLen;
2327 UBYTE dataLen;
2328 UBYTE recNr;
2329 T_ACI_TOA type;
2330
2331 TRACE_FUNCTION ("Cphs_read_mbn()");
2332
2333 pData = simShrdPrm.atb[table_id].exchData;
2334 dataLen = simShrdPrm.atb[table_id].dataLen;
2335 recNr = simShrdPrm.atb[table_id].recNr;
2336
2337 #ifdef FF_2TO1_PS
2338 if ( simShrdPrm.atb[table_id].errCode NEQ CAUSE_SIM_NO_ERROR OR
2339 #else
2340 if ( simShrdPrm.atb[table_id].errCode NEQ SIM_NO_ERROR OR
2341 #endif
2342 pData EQ NULL OR
2343 dataLen < CPHS_MIN_MBN_SIZE )
2344 {//MC FFS ?
2345 /* if (recNr <= 1)
2346 {
2347 Cphs_read_eeprom_mailbox();
2348 return;
2349 }
2350 else
2351 cphs_sign_exec(E_CPHS_GET_VC_NUM, &mbNum);*/
2352 TRACE_EVENT("MB read error");
2353 return;
2354 }
2355 else /* no read error */
2356 {
2357 if (recNr EQ 1)
2358 {
2359 cphs_data->maxRec = simShrdPrm.atb[table_id].recMax;
2360 }
2361 alphaLen = dataLen - CPHS_MIN_MBN_SIZE;
2362
2363 /* Copy/encode data */
2364 if (*(pData + alphaLen + 2) NEQ 0xFF)
2365 {
2366 cphs_data->mbNum.entries[cphs_data->mbNum.count].index = recNr;
2367 cmhPHB_getMfwTagNt(pData, alphaLen,
2368 cphs_data->mbNum.entries[cphs_data->mbNum.count].alpha.data,
2369 &cphs_data->mbNum.entries[cphs_data->mbNum.count].alpha.len);
2370 pData += alphaLen;
2371
2372 cmhPHB_getAdrStr ( (CHAR *)cphs_data->mbNum.entries[cphs_data->mbNum.count].number,
2373 PHB_MAX_LEN - 1,
2374 pData + 2,
2375 *pData );
2376
2377 cmhPHB_toaDmrg ( *( pData + 1 ), &type );
2378 cphs_data->mbNum.entries[cphs_data->mbNum.count].ton = cvtTon(type.ton);
2379 cphs_data->mbNum.entries[cphs_data->mbNum.count].npi = cvtNpi(type.npi);
2380 pData += 12;
2381
2382 if ( *pData NEQ 0xFF )
2383 {
2384 /* read bearer capability EF */
2385 /* return; */
2386 }
2387 cphs_data->mbNum.count++;
2388 cphs_data->mbNum.result = SIMOP_READ_OK;
2389 }
2390 recNr++;
2391 if (recNr > cphs_data->maxRec)
2392 { TRACE_FUNCTION("got CPHS Mailbox nos");
2393 Cphs_operator_name();//get next CPHS item
2394 return;
2395
2396 }
2397 if (recNr <= cphs_data->maxRec)
2398 {
2399 /* Read the next entry */
2400 Cphs_read_sim_rcd(SIM_CPHS_MBXN, recNr, dataLen);
2401 }
2402
2403
2404 }
2405 }
2406
2407 /*
2408 +-----------------------------------------------------------------------+
2409 | MODULE : CPHS standalone module |
2410 | STATE : code ROUTINE : Cphs_read_mbs |
2411 +-----------------------------------------------------------------------+
2412
2413 PURPOSE : Read voice message waiting flag
2414
2415 */
2416
2417 void Cphs_read_mbs(SHORT errCode, UBYTE *data, UBYTE dataLen)
2418 {
2419 UBYTE *ptr;
2420 int i; /* PATCH VO 22.01.01 */
2421 char debug[50];
2422
2423 TRACE_FUNCTION ("Cphs_read_mbs()");
2424
2425 ptr = data;
2426 #ifdef FF_2TO1_PS
2427 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2428 #else
2429 if ( errCode NEQ SIM_NO_ERROR OR
2430 #endif
2431 ptr EQ NULL OR
2432 //dataLen < MFW_CPHS_MBS_SIZE )
2433 dataLen <= 0 ) /* PATCH VO 22.01.01: not check a certain length */
2434 {
2435 cphs_data->mbStatus.result = SIMOP_READ_ERR;
2436 }
2437 else
2438 {
2439 sprintf(debug, "Retrieved mailbox status: %x%x",ptr[0],ptr[1]);
2440 TRACE_EVENT(debug);
2441 memset(&cphs_data->mbStatus, CPHS_FLAG_NOT_PRESENT, sizeof(cphs_data->mbStatus));
2442 cphs_data->mbStatus.result = SIMOP_READ_OK;
2443 for (i=0; i<dataLen; i++)
2444 {
2445 switch (i)
2446 {
2447 case 0:
2448 cphs_data->mbStatus.line1 = ptr[i] & 0x0F/*0x01*/;
2449 cphs_data->mbStatus.line2 = ( ptr[i] >> 4 ) & 0x0F/*0x01*/;
2450 break;
2451 case 1:
2452 cphs_data->mbStatus.fax = ptr[i] & 0x0F/*0x01*/;
2453 cphs_data->mbStatus.data = ( ptr[i] >> 4 ) & 0x0F/*0x01*/;
2454 break;
2455 default:
2456 break;
2457 }
2458 }
2459 /* PATCH VO 22.01.01 END */
2460 //Not sure about this
2461 //memcpy(cphs_data->mbsData, ptr, CPHS_MBS_SIZE);
2462 }
2463 }
2464
2465 /*
2466 +-----------------------------------------------------------------------+
2467 | MODULE : CPHS standalone module |
2468 | STATE : code ROUTINE : Cphs_read_cff |
2469 +-----------------------------------------------------------------------+
2470
2471 PURPOSE : Read call forwarding flag
2472
2473 */
2474
2475 void Cphs_read_cff(SHORT errCode, UBYTE *data, UBYTE dataLen)
2476 {
2477 UBYTE *ptr;
2478 int i; /* PATCH VO 22.01.01 */
2479 char debug[50];
2480
2481 TRACE_EVENT ("Cphs_read_cff()");
2482
2483 ptr = data;
2484 #ifdef FF_2TO1_PS
2485 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2486 #else
2487 if ( errCode NEQ SIM_NO_ERROR OR
2488 #endif
2489 ptr EQ NULL OR
2490 //dataLen < MFW_CPHS_CFF_SIZE )
2491 dataLen <= 0 ) /* PATCH VO 22.01.01: not check a certain length */
2492 {
2493 cphs_data->dvStatus.result = SIMOP_READ_ERR;
2494 }
2495 else
2496 {
2497 sprintf(debug, "Retrieved divert status: %x%x",ptr[0],ptr[1]);
2498 TRACE_EVENT(debug);
2499 memset(&cphs_data->dvStatus, CPHS_FLAG_NOT_PRESENT, sizeof(cphs_data->dvStatus));
2500 cphs_data->dvStatus.result = SIMOP_READ_OK;
2501 for (i=0; i<dataLen; i++)
2502 {
2503 switch (i)
2504 {
2505 case 0:
2506 cphs_data->dvStatus.line1 = ptr[i] & /*0x0F*/0x01;
2507 cphs_data->dvStatus.line2 = ( ptr[i] >> 4 ) & /*0x0F*/0x01;
2508 break;
2509 case 1:
2510 cphs_data->dvStatus.fax = ptr[i] & /*0x0F*/0x01;
2511 cphs_data->dvStatus.data = ( ptr[i] >> 4 ) & /*0x0F*/0x01;
2512 break;
2513 default:
2514 break;
2515 }
2516 }
2517 /* PATCH VO 22.01.01 END */
2518 //not sure about this bit
2519 //memcpy(cphs_data->dvData, ptr, CPHS_CFF_SIZE);
2520 }
2521 }
2522
2523
2524
2525
2526 /*
2527 +-----------------------------------------------------------------------+
2528 | MODULE : CPHS standalone module |
2529 | STATE : code ROUTINE : Cphs_read_csp |
2530 +-----------------------------------------------------------------------+
2531
2532 PURPOSE : Read customer service profile
2533
2534 */
2535
2536 void Cphs_read_csp(SHORT errCode, UBYTE *data, UBYTE dataLen)
2537 {
2538 UBYTE *ptr;
2539 UBYTE flag;
2540 int i;
2541
2542 TRACE_FUNCTION ("Cphs_read_csp()");
2543
2544 ptr = data;
2545 #ifdef FF_2TO1_PS
2546 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2547 #else
2548 if ( errCode NEQ SIM_NO_ERROR OR
2549 #endif
2550 ptr EQ NULL OR
2551 // dataLen < MFW_CPHS_CSP_SIZE )
2552 dataLen <= 0 ) /* PATCH VO 22.01.01: not check a certain length */
2553 {
2554 if (cphs_data->simStatus EQ SIMOP_READ_OK) /* Used for read information numbers */
2555 {
2556 cphs_data->simStatus = SIMOP_UNKNOWN;
2557 //cphs_sign_exec(E_CPHS_GET_INFO_LIST, &numList);
2558 }
2559 else
2560 {
2561 cphs_data->csProfile.result = SIMOP_READ_ERR;
2562 memset(cphs_data->csProfile.csp, 0, sizeof(cphs_data->csProfile.csp));
2563 //cphs_sign_exec(E_CPHS_GET_CSP, &csProfile);
2564 if (cphs_data->RefreshCB != NULL)
2565 (cphs_data->RefreshCB)(NULL, NULL);
2566 }
2567 }
2568 else
2569 {
2570 if (cphs_data->simStatus EQ SIMOP_READ_OK) /* Used for read information numbers */
2571 {
2572 cphs_data->simStatus = SIMOP_UNKNOWN;
2573
2574 /* check the service group code */
2575 flag = 0;
2576 //for (i = 0; i < MFW_CPHS_CSP_SIZE; i += 2)
2577 for (i = 0; i < dataLen; i += 2) /* PATCH VO 22.01.01: use the actual length in the SIM card */
2578 {
2579 if (ptr[i] EQ 0xD5 AND ptr[i+1] EQ 0xFF)
2580 flag = 1;
2581 }
2582 if (!flag)
2583 {
2584 // cphs_sign_exec(E_CPHS_GET_INFO_LIST, &numList);
2585 return;
2586 }
2587
2588 /* Read the first information numbers record */
2589 if (!Cphs_read_sim_rcd(SIM_CPHS_INFN, 1, 0))
2590 { //cphs_sign_exec(E_CPHS_GET_INFO_LIST, &numList);
2591 TRACE_EVENT("Can't read info num rcd");
2592 return;
2593 }
2594
2595 else
2596 cphs_data->cphsPrevRead = SIM_CPHS_INFN;
2597 }
2598 else
2599 {
2600 cphs_data->csProfile.result = SIMOP_READ_OK;
2601 TRACE_EVENT("CPHS valid CSP");
2602 //memcpy(cphs_data->csProfile.csp, ptr, sizeof(cphs_data->csProfile.csp));
2603 for (i=0; i<(dataLen/2); i++)
2604 {
2605 cphs_data->csProfile.csp[i].group_code = ptr[2*i];
2606 cphs_data->csProfile.csp[i].services =ptr[2*i + 1];
2607 }
2608 if (cphs_data->RefreshCB != NULL)
2609 (cphs_data->RefreshCB)(NULL, NULL);
2610 // cphs_sign_exec(E_CPHS_GET_CSP, &cphs_data->csProfile);
2611 }
2612 }
2613 }
2614
2615 void Cphs_read_information(SHORT errCode, UBYTE *data, UBYTE dataLen)
2616 {
2617 UBYTE *ptr;
2618
2619 UBYTE len;
2620
2621
2622 TRACE_FUNCTION ("Cphs_read_information()");
2623
2624 ptr = data;
2625
2626 len = dataLen;
2627 memset(cphs_data->cphsServTab, 0, sizeof(cphs_data->cphsServTab));
2628 /* PATCH VO 22.01.01 END */
2629 #ifdef FF_2TO1_PS
2630 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2631 #else
2632 if ( errCode NEQ SIM_NO_ERROR OR
2633 #endif
2634 ptr EQ NULL OR
2635 //dataLen < MFW_CPHS_INFO_SIZE)
2636 dataLen <= 0) /* PATCH VO 22.01.01: not check a certain length */
2637 {
2638 cphs_data->cphsStatus = CPHS_NOT_PRESENT;
2639 //cphs_sign_exec(E_CPHS_IND, &cphsStatus);
2640 }
2641 else
2642 {
2643 cphs_data->cphsPhase = *ptr;
2644 len--;
2645 if (len > 0)
2646 {
2647 ptr++;
2648 memcpy (cphs_data->cphsServTab, ptr, MINIMUM(len, CPHS_SERVICE_TABLE));
2649 }
2650 /* PATCH VO 22.01.01 END */
2651 cphs_data->cphsStatus = CPHS_IS_OK;
2652 TRACE_EVENT("CPHS supported");
2653 //cphs_sign_exec(E_CPHS_IND, &cphsStatus);
2654 }
2655 }
2656 #ifdef FRED //commented this func out because of build problems
2657 #ifdef SIM_TOOLKIT
2658 /*
2659 +---------------------------------------------------------------------+
2660 | MODULE : CPHS standalone module |
2661 | STATE : code ROUTINE : Cphs_update_info_cnf |
2662 +---------------------------------------------------------------------+
2663
2664 PURPOSE : call back for SIM file read
2665
2666 */
2667
2668 void Cphs_update_info_cnf (SHORT errCode, UBYTE *data, UBYTE dataLen)
2669 {
2670 UBYTE *ptr;
2671
2672 TRACE_FUNCTION ("Cphs_update_info_cnf()");
2673
2674 cphs_data->cphsUpdate = FALSE; /* reset flag */
2675 ptr = data;
2676 #ifdef FF_2TO1_PS
2677 if ( errCode NEQ CAUSE_SIM_NO_ERROR OR
2678 #else
2679 if ( errCode NEQ SIM_NO_ERROR OR
2680 #endif
2681 ptr EQ NULL OR
2682 dataLen < CPHS_INFO_SIZE)
2683 {
2684 satUpdateFiles(TRUE, SIM_CPHS_CINF);
2685 }
2686 else
2687 {
2688 cphs_data->cphsPhase = *ptr;
2689 ptr++;
2690 memcpy (cphs_data->cphsServTab, ptr, CPHS_SERVICE_TABLE*sizeof(UBYTE));
2691 cphs_data->cphsStatus = CPHS_IS_OK;
2692 satUpdateFiles ( TRUE, SIM_CPHS_CINF );
2693 }
2694 }
2695 #endif
2696 #endif
2697 BOOL Cphs_write_sim_dat(USHORT data_id, UBYTE *data, UBYTE length)
2698 {
2699 T_ACI_RETURN res;
2700
2701 TRACE_FUNCTION ("Cphs_write_sim_dat()");
2702
2703 res = cmhSIM_WriteTranspEF (CMD_SRC_NONE,
2704 AT_CMD_NONE,
2705 data_id,
2706 0,
2707 length,
2708 data,
2709 Cphs_write_sim_dat_cb);
2710
2711 if (res NEQ AT_EXCT)
2712 return FALSE;
2713
2714 return TRUE;
2715 }
2716
2717 /*
2718 +----------------------------------------------------------------------+
2719 | MODULE: CPHS standalone module |
2720 | STATE : code ROUTINE: Cphs_write_sim_dat_cb |
2721 +----------------------------------------------------------------------+
2722
2723
2724 PURPOSE : callback of SIM card writing.
2725
2726 */
2727
2728 void Cphs_write_sim_dat_cb(SHORT table_id)
2729 {
2730 UBYTE result;
2731 char debug[30];
2732 TRACE_FUNCTION ("sim_write_sim_dat_cb()");
2733
2734
2735 sprintf(debug, "SIM Error code!!!%d", simShrdPrm.atb[table_id].errCode);
2736 TRACE_EVENT(debug);
2737 switch (simShrdPrm.atb[table_id].reqDataFld)
2738 {
2739 case SIM_CPHS_VMW: /* voice message waiting flag */
2740 #ifdef FF_2TO1_PS
2741 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
2742 #else
2743 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
2744 #endif
2745 {
2746 cphs_data->mbStatus.result = SIMOP_WRITE_OK;
2747
2748 }
2749 else
2750 {
2751 cphs_data->mbStatus.result = SIMOP_WRITE_ERR;
2752 }
2753 break;
2754
2755 case SIM_CPHS_CFF: /* call forwarding flag */
2756 #ifdef FF_2TO1_PS
2757 if ( simShrdPrm.atb[table_id].errCode EQ CAUSE_SIM_NO_ERROR )
2758 #else
2759 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
2760 #endif
2761 {
2762 cphs_data->dvStatus.result = SIMOP_WRITE_OK;
2763 TRACE_EVENT("Divert Write successful");
2764 }
2765 else
2766 {
2767 cphs_data->dvStatus.result = SIMOP_WRITE_ERR;
2768 TRACE_EVENT("Divert Write Failed");
2769 }
2770 break;
2771
2772 default:
2773 break;
2774 }
2775 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2776 }
2777
2778 /*
2779 +-----------------------------------------------------------------------+
2780 | MODULE : CPHS standalone module |
2781 | STATE : code ROUTINE : cphs_read_eeprom_als |
2782 +-----------------------------------------------------------------------+
2783
2784 PURPOSE : Read alternate line service information from EEPROM
2785
2786 */
2787
2788 T_CPHS_RET Cphs_read_eeprom_als(T_CPHS_ALS_INFO* info)
2789 { char read_result;
2790 char debug[50];
2791
2792 #ifdef PCM_2_FFS
2793 read_result =ffs_fread("/AlsInfo", info, sizeof(T_CPHS_ALS_INFO));
2794 #else
2795 read_result =FFS_fread("/AlsInfo", info, sizeof(T_CPHS_ALS_INFO));
2796 #endif
2797
2798 if (read_result == EFFS_OK)
2799 { info->result = SIMOP_READ_OK;
2800 return CPHS_IS_OK;
2801 }
2802 else
2803 { info->result = SIMOP_READ_ERR;
2804 sprintf(debug, "ALS info read error:%d", read_result);
2805 TRACE_EVENT(debug);
2806 return CPHS_SIM_READ_ERROR;
2807 }
2808 }
2809
2810 /*
2811 +-----------------------------------------------------------------------+
2812 | MODULE : CPHS standalone module |
2813 | STATE : code ROUTINE : cphs_write_eeprom_als |
2814 +-----------------------------------------------------------------------+
2815
2816 PURPOSE : Write selected alternate line/lock status in EEPROM
2817
2818 */
2819
2820 T_CPHS_RET Cphs_write_eeprom_als(T_CPHS_ALS_INFO* info)
2821 { char write_result;
2822 T_ACI_ALS_MOD alsMode;
2823 T_CPHS_RET return_result;
2824
2825 #ifdef PCM_2_FFS
2826 write_result =ffs_fwrite("/AlsInfo", info, sizeof(T_CPHS_ALS_INFO));
2827 #else
2828 write_result =FFS_fwrite("/AlsInfo", info, sizeof(T_CPHS_ALS_INFO));
2829 #endif
2830
2831 if (write_result >= EFFS_OK)
2832 { info->result = SIMOP_WRITE_OK;
2833 return_result = CPHS_IS_OK;
2834 TRACE_EVENT("ALS info write OK");
2835 }
2836 else
2837 { info->result = SIMOP_WRITE_ERR;
2838 return_result = CPHS_SIM_WRITE_ERROR;
2839 TRACE_EVENT("ALS info write error");
2840 }
2841
2842 if (cphs_data->alsStatus.line EQ CPHS_LINE_INDEX_LINE1)
2843 alsMode = ALS_MOD_SPEECH;
2844 if (cphs_data->alsStatus.line EQ CPHS_LINE_INDEX_LINE2)
2845 alsMode = ALS_MOD_AUX_SPEECH;
2846 sAT_PercentALS(CMD_SRC_LCL, alsMode);
2847 return return_result;
2848
2849 }
2850 /*
2851 +-----------------------------------------------------------------------+
2852 | MODULE : CPHS standalone module |
2853 | STATE : code ROUTINE : cphs_write_eeprom_als_desc |
2854 +-----------------------------------------------------------------------+
2855
2856 PURPOSE : Write ALS line description in EEPROM
2857
2858 */
2859 void Cphs_write_eeprom_als_desc(T_CPHS_ALS_LINE* line)
2860 { char write_result = -1;
2861 T_CPHS_ALS_LINE* desc;
2862 if (line->line EQ CPHS_LINE_INDEX_LINE1)
2863 { desc = &cphs_data->Line1_desc;
2864
2865 #ifdef PCM_2_FFS
2866 write_result =ffs_fwrite("/AlsDesc1", &cphs_data->Line1_desc, sizeof(cphs_data->Line1_desc));
2867 #else
2868 write_result =FFS_fwrite("/AlsDesc1", &cphs_data->Line1_desc, sizeof(cphs_data->Line1_desc));
2869 #endif
2870
2871 }
2872 if (line->line EQ CPHS_LINE_INDEX_LINE2)
2873 { desc = &cphs_data->Line2_desc;
2874 #ifdef PCM_2_FFS
2875 write_result =ffs_fwrite("/AlsDesc2", &cphs_data->Line2_desc, sizeof(cphs_data->Line1_desc));
2876 #else
2877 write_result =FFS_fwrite("/AlsDesc2", &cphs_data->Line2_desc, sizeof(cphs_data->Line1_desc));
2878 #endif
2879 }
2880
2881 if (write_result >= EFFS_OK)
2882 desc->result = SIMOP_WRITE_OK;
2883 else
2884 desc->result = SIMOP_WRITE_ERR;
2885 }
2886 /*
2887 +-----------------------------------------------------------------------+
2888 | MODULE : CPHS standalone module |
2889 | STATE : code ROUTINE : cphs_read_eeprom_als_desc |
2890 +-----------------------------------------------------------------------+
2891
2892 PURPOSE : read ALS line description from EEPROM
2893
2894 */
2895 void Cphs_read_eeprom_als_desc()
2896 { char read_result = -1;
2897 T_CPHS_ALS_LINE* desc;
2898
2899 #ifdef PCM_2_FFS
2900 read_result =ffs_fread("/AlsDesc1", &cphs_data->Line1_desc, sizeof(cphs_data->Line1_desc));
2901 #else
2902 read_result =FFS_fread("/AlsDesc1", &cphs_data->Line1_desc, sizeof(cphs_data->Line1_desc));
2903 #endif
2904 if (read_result >= EFFS_OK)
2905 cphs_data->Line1_desc.result = SIMOP_READ_OK;
2906 else
2907 cphs_data->Line1_desc.result = SIMOP_READ_ERR;
2908
2909
2910 #ifdef PCM_2_FFS
2911 read_result =ffs_fread("/AlsDesc2", &cphs_data->Line2_desc, sizeof(cphs_data->Line1_desc));
2912 #else
2913 read_result =FFS_fread("/AlsDesc2", &cphs_data->Line2_desc, sizeof(cphs_data->Line1_desc));
2914 #endif
2915 if (read_result EQ EFFS_OK)
2916 cphs_data->Line2_desc.result = SIMOP_READ_OK;
2917 else
2918 cphs_data->Line2_desc.result = SIMOP_READ_ERR;
2919
2920
2921 }
2922
2923 void Cphs_get_info_num (UBYTE level, UBYTE startIndex)
2924 {
2925 UBYTE res;
2926
2927 TRACE_FUNCTION ("cphs_get_info_num()");
2928
2929 /* check CPHS service table */
2930 if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
2931 return;
2932
2933 if (level < 1 OR
2934 startIndex < 1 )
2935 return;
2936
2937 /* check CPHS service table for customer service profile */
2938 /* res = Cphs_ssc(CPHS_CSP, cphs_data->cphsServTab);
2939 if ( res NEQ ALLOCATED_AND_ACTIVATED)
2940 return;*/
2941
2942 /* check CPHS service table for information numbers */
2943 /* res = Cphs_ssc(CHPS_INFO_NUMBERS, cphs_data->cphsServTab);
2944 if ( res NEQ ALLOCATED_AND_ACTIVATED)
2945 return;*/
2946
2947 /* Read customer service profile to check
2948 whether information numbers are supported. */
2949 cphs_data->numList->count = 0;
2950 cphs_data->idxLevel = level;
2951 cphs_data->startIdx = startIndex;
2952 cphs_data->simStatus = SIMOP_READ_OK;
2953 if (!Cphs_read_sim_dat(SIM_CPHS_CSP, NOT_PRESENT_8BIT, CPHS_CSP_SIZE))
2954 {
2955 cphs_data->simStatus = SIMOP_UNKNOWN;
2956 TRACE_EVENT("FAiled in reading CSP for Info nums");
2957 return;
2958 }
2959
2960 return;
2961 }
2962
2963
2964 /* checks the lock status of the given lock type. On successfull check */
2965 /* the status will be returned. If an error occured SIMLOCK_FAIL will */
2966 T_SIMLOCK_RET simlock_checkLock ( T_SIMLOCK_TYPE type )
2967 {
2968
2969 return SIMLOCK_FAIL;
2970 }
2971