update for beta universally
[framework/telephony/libslp-tapi.git] / src / test_apps / tapi_sat_test.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Kyeongchul Kim <kyeongchul.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <stdlib.h>
22 #include <pthread.h>     /* pthread functions and data structures */
23 #include <signal.h>
24 #include <stdio.h>
25 #include <errno.h>
26 #include <assert.h>
27 #include <glib.h>
28
29 #include "TelDefines.h"
30 #include "ITapiCall.h"
31 #include "ITapiSs.h"
32 #include "TapiCommon.h"
33 #include "TelSim.h"
34 #include "TelErr.h"
35 #include "TelSatEnvelope.h"
36 #include "TelSatObj.h"
37 #include "TelSatProactvCmd.h"
38 #include "ITapiSat.h"
39 #include "TelUtility_ext.h"
40 #include "TelUtility.h"
41
42
43 TS_UINT g_hCall;
44 TelTapiCallInfo_t g_info;
45
46 extern int EvtDeliveryHandle ;
47
48
49 /***************************/
50 int tapi_thread_id;
51
52 int error_code;
53 unsigned int curr_cmd = 0;
54
55 tapi_simatk_select_item_ind_data_t sel_item_data;
56 tapi_simatk_resp_data_t tr_data;
57
58 typedef struct
59 {
60         int group;
61         int type;
62         int len;
63         void *dst;
64 }data_t;
65
66 unsigned char *ptrEvnts[] = {
67 "Telephony.Sat.UI.DisplayText",
68 "Telephony.Sat.UI.GetInKey",
69 "Telephony.Sat.UI.GetInputKey",
70 "Telephony.Sat.UI.PlayTone",
71 "Telephony.Sat.UI.Refresh",
72 "Telephony.Sat.UI.SetUpMenu",
73 "Telephony.Sat.UI.SelectItem",
74 "Telephony.Sat.UI.SendSms",
75 "Telephony.Sat.UI.SendSs",
76 "Telephony.Sat.UI.SendUssd",
77 "Telephony.Sat.UI.SetupCall",
78 "Telephony.Sat.ProvideLocalInfo",
79 "Telephony.Sat.SetupEventList",
80 "Telephony.Sat.SetupIdelMode",
81 "Telephony.Sat.UI.SendDtmf",
82 "Telephony.Sat.Idle.LanguageNotification",
83 "Telephony.Sat.UI.LaunchBrowser",
84 "Telephony.Sat.UI.EndProacativeSession",
85 "Telephony.Sat.Call.CallControlCnf",
86 "Telephony.Sat.SMS.MoSmsControlCnf",
87 "Telephony.Sat.SMS.Refresh",
88 "Telephony.Sat.Phonebook.Refresh",
89 "Telephony.Sat.Idle.Refresh",
90 "Telephony.Sat.SMS.SendSms",
91 "Telephony.Sat.Call.SetupCall",
92 "Telephony.Sat.SS.SendSs",
93 "Telephony.Sat.USSD.SendUssd",
94 "Telephony.Sat.Idle.SetupText",
95 "Telephony.Sat.DTMF.SendDtmf",
96 "User.WapBrowser.ESimAtkOpenURL",
97 "Telephony.Sat.UI.CmdProcEnd",
98 "Telephony.Sat.MenuSelectionCnf",
99 "Telephony.Sat.EventDownloadCnf"
100 };
101
102
103
104 int
105 sat_util_pack_7bit( TS_BYTE* pOut, const char* szData, int in_len )
106 {
107         int i;
108         int pos;
109         int shift = 0;
110
111         for( pos = 0, i = 0; /*pos < out_len_max &&*/ i < in_len; pos++, i++ )
112         {
113                 /* pack the low bits */
114                 pOut[pos] = szData[i] >> shift;
115
116                 if ( i + 1 < in_len )
117                 {
118                         /* pack the high bits using the low bits of the next character */
119                         pOut[pos] |= szData[i+1] << ( 7 - shift );
120
121                         shift++;
122
123                         if( shift == 7 )
124                         {
125                                 shift = 0;
126                                 i++;
127                         }
128                 }
129         }
130
131         /* done */
132         return pos;
133 }
134
135
136
137 void
138 test_send_tr(unsigned char gen_resp)
139 {
140 //Send TR
141         int ret;
142         unsigned char input;
143
144         tr_data.tr_data.display_txt.result.general_result = gen_resp;
145         tr_data.tr_data.display_txt.result.me_problem = 0x00;
146
147         switch(gen_resp)
148                 {
149                         case 0x20:
150                         case 0x21:
151                         case 0x26:
152                         case 0x34:
153                         case 0x35:
154                         case 0x37:
155                         case 0x38:
156                         case 0x39:
157                         case 0x3a:
158                         case 0x3c:
159                         case 0x3d:
160                         {
161                                 char scabuf[5] = {0};
162                                 printf("additional response 0x00 ~ 0x0a:  0x\n");
163                                 ret = read(0, scabuf, sizeof(scabuf));
164                                 if (ret < 0)
165                                 {
166                                         if (errno == EINTR)
167                                                 perror("read(1)");
168                                         return -1;
169                                 }
170                                 else if (ret == 0)
171                                         return ret;
172
173                                 input = (scabuf[0] -'0' )<< 4;
174                                 input |= (scabuf[1]-'0')&0x0F;
175                                 if(input >= 0x00 && input <= 0x3F)
176                                 {
177                                         printf("additional response gen_resp 0x%x - add_resp 0x%x\n", gen_resp, input);
178                                         if(gen_resp == 0x39)
179                                         {
180                                                 if(curr_cmd == TAPI_EVENT_SAT_UI_SEND_SS_IND)
181                                                         tr_data.tr_data.send_ss.additional_cc_problem_info = input;
182                                                 else if(curr_cmd == TAPI_EVENT_SAT_UI_SEND_USSD_IND)
183                                                         tr_data.tr_data.send_ussd.additional_cc_problem_info = input;
184                                                 else
185                                                         tr_data.tr_data.display_txt.result.me_problem = input;
186                                         }
187                                         else if(gen_resp == 0x34)
188                                                 tr_data.tr_data.send_ss.additional_ss_problem_info = input;
189                                         else if(gen_resp == 0x37)
190                                                 tr_data.tr_data.send_ussd.additional_ussd_problem_info = input;
191                                         else
192                                                 tr_data.tr_data.display_txt.result.me_problem = input;
193                                 }
194
195                         }
196
197                         default:
198                                 break;
199                 }
200
201         printf(" [SAT] : test_send_tr ::: send TR. command_number=%d, type=0x%x\n",
202                                                                 tr_data.command_number, tr_data.command_type);
203         TelTapiSatSendUiUserConfirm(tr_data.command_number ,tr_data.command_type,SAT_ENGINE_USER_CONFIRM_YES,NULL,0);
204 }
205
206
207 /*
208 void
209 test_call_control(void)
210 {
211         tapi_call_setup_info_t call;
212         unsigned short error;
213         tapi_call_handle  call_handle;
214         unsigned char num_dial[] = "+01234567890123456789";
215
216         call.call_type = TAPI_CALL_TYPE_VOICE;
217         memcpy(call.number,num_dial, sizeof(num_dial));
218         call.identity_mode = 0x01;
219         tapi_call_setup(&call, call_handle, &error);
220 }
221 */
222
223 void
224 test_simatk_proactive_send_dtmf(tapi_simatk_send_dtmf_ind_data_t* tst_data)
225 {
226         int i;
227         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
228
229         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
230
231         printf(" [SAT] : alpha_id present?= %d,  alphaID: %s\n",tst_data->alpha_id.is_present, tst_data->alpha_id.string);
232
233         printf(" [SAT] : DTMF STRING: len = %d, USSD string = %s\n", tst_data->dtmf_string.string_length, tst_data->dtmf_string.dtmf_tone);
234
235         if(tst_data->icon_id.is_present)
236                 printf(" \n[SAT] : icon identifier: icon_id=%d, icon_qulaifier = 0x%x\n", tst_data->icon_id.icon_identifier, tst_data->icon_id.icon_qualifier);
237         else
238                 printf(" \n[SAT] : icon NOT present\n");
239
240         //Send TR
241         tr_data.command_number = tst_data->command_detail.command_number;
242         tr_data.command_type = tst_data->command_detail.command_type;
243 }
244
245 void
246 test_simatk_proactive_play_tone(tapi_simatk_play_tone_ind_data_t* tst_data)
247 {
248         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
249         printf(" [SAT] : command qulaifier: Vibrate_alert 0=optional, 1=required, %d\n", tst_data->command_detail.u.cmd_quali_play_tone.vibrate_alert);
250         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
251         printf(" [SAT] : alpha identifier: is_alpha_present=%d, rawdcs=0x%x, str_len=%d, string=%s\n", tst_data->alpha_id.is_present,
252                                 tst_data->alpha_id.dcs.raw_dcs, tst_data->alpha_id.string_len, tst_data->alpha_id.string);
253
254         printf(" [SAT] : TONE: requested tone - 0x%02x\n", tst_data->tone.type);
255         printf(" [SAT] : DURATION: interval=0x%x, time unit=0x%x\n",tst_data->duration.time_interval,tst_data->duration.time_unit);
256         printf(" [SAT] : icon: is_icon_present=%d, icon id: %d\n",tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
257
258         //Send TR
259         tr_data.command_number = tst_data->command_detail.command_number;
260         tr_data.command_type = tst_data->command_detail.command_type;
261 }
262
263 void
264 test_simatk_proactive_get_input(tapi_simatk_get_input_ind_data_t* tst_data)
265 {
266         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
267
268         printf(" [SAT] : command qualifier: is_using_alphabet_set (1=ys, 0=using digits) [%d]\n",tst_data->command_detail.u.cmd_quali_get_input.is_using_alphabet_set);
269
270         printf(" [SAT] : command qualifier: alpha_type = 0x%x, help info available? = %d\n",tst_data->command_detail.u.cmd_quali_get_input.alphabet_type, tst_data->command_detail.u.cmd_quali_get_input.is_help_info_available);
271
272         printf(" [SAT] : command qualifier: is_me_echo_user_input? [%d], unpacked data? [%d]\n",tst_data->command_detail.u.cmd_quali_get_input.is_me_echo_user_input, tst_data->command_detail.u.cmd_quali_get_input.is_user_input_unpacked_format);
273
274         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
275
276         printf(" [SAT] : text-dcs: compressed?=%d, alpha_format=0x%x\n",tst_data->text.dcs.is_compressed_format, tst_data->text.dcs.alphabet_format);
277
278         printf(" [SAT] : text: string_length=%d, string=%s\n",tst_data->text.string_length, tst_data->text.string);
279
280         printf(" [SAT] : text: response length: min =%d, max=%d\n",tst_data->response_length.min, tst_data->response_length.max);
281
282         printf(" [SAT] : icon: is_icon_present=%d, icon id: %d\n",tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
283
284         printf(" [SAT] : Default Text: string length=%d\n",tst_data->default_text.string_length);
285
286         printf(" [SAT] : Default Text: dcs=0x%02x, default string: %s\n",tst_data->default_text.dcs.alphabet_format, tst_data->default_text.string);
287
288         if(!tst_data->command_detail.u.cmd_quali_get_input.is_user_input_unpacked_format)
289                 tr_data.tr_data.get_input.text.dcs.alphabet_format = TAPI_SAT_ALPHABET_FROMAT_SMS_DEFAULT;
290         else
291                 tr_data.tr_data.get_input.text.dcs.alphabet_format = TAPI_SIMATK_ALPHABET_FROMAT_8BIT_DATA;
292         //Send TR
293         tr_data.command_number = tst_data->command_detail.command_number;
294         tr_data.command_type = tst_data->command_detail.command_type;
295
296                 if(tst_data->icon_id.is_present)
297                 tr_data.tr_data.get_input.result.general_result = TAPI_SAT_R_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED;
298         else
299                 tr_data.tr_data.get_input.result.general_result = 0x00;
300
301 }
302
303 void
304 test_simatk_proactive_get_inkey(tapi_simatk_get_inkey_ind_data_t* tst_data)
305 {
306         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
307
308         printf(" [SAT] : command qualifier: inkey_type 0== using character set, 1== yes/no type [%d]\n",tst_data->command_detail.u.cmd_quali_get_inkey.inkey_type);
309
310         printf(" [SAT] : command qualifier: use_alpha_set? [%d], is_help info available? [%d]\n",tst_data->command_detail.u.cmd_quali_get_inkey.is_using_alphabet_set, tst_data->command_detail.u.cmd_quali_get_inkey.is_help_info_available);
311
312         printf(" [SAT] : command qualifier: immideate response required? [%d], alphabet_type [%d]\n",tst_data->command_detail.u.cmd_quali_get_inkey.is_immediate_response_required, tst_data->command_detail.u.cmd_quali_get_inkey.alphabet_type);
313
314         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
315
316         printf(" [SAT] : text-dcs: compressed?=%d, alpha_format=0x%x, msg_class=0x%x, raw_dcs=%d\n",tst_data->text.dcs.is_compressed_format, tst_data->text.dcs.alphabet_format,tst_data->text.dcs.msg_class, tst_data->text.dcs.raw_dcs);
317
318         printf(" [SAT] : text: string_length=%d, string=%s\n",tst_data->text.string_length, tst_data->text.string);
319
320         printf(" [SAT] : icon: is_icon_present=%d\n",tst_data->icon_id.is_present);
321
322         printf(" [SAT] : DURATION: interval=0x%x, time unit=0x%x\n",tst_data->duration.time_interval,tst_data->duration.time_unit);
323
324         //Send TR
325         tr_data.command_number = tst_data->command_detail.command_number;
326         tr_data.command_type = tst_data->command_detail.command_type;
327
328         if(tst_data->icon_id.is_present)
329                 tr_data.tr_data.get_inkey.result.general_result = TAPI_SAT_R_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED;
330         else
331                 tr_data.tr_data.get_inkey.result.general_result = 0x00;
332 }
333
334
335
336 void
337 test_simatk_event_download(tapi_simatk_event_download_type_t event)
338 {
339         TelSatkEventDownloadData_t evt_dl;
340         int requestId = -1;
341
342         memset(&evt_dl, 0x00, sizeof(TelSatkEventDownloadData_t));
343
344         printf(" [SAT] : EVENT DOWNLOAD\n");
345
346         switch(event)
347         {
348                 case TAPI_EVENT_SAT_DW_TYPE_IDLE_SCREEN_AVAILABLE:
349                         evt_dl.event_download_type = TAPI_EVENT_SAT_DW_TYPE_IDLE_SCREEN_AVAILABLE;
350                         break;
351
352                 case TAPI_EVENT_SAT_DW_TYPE_USER_ACTIVITY:
353                         evt_dl.event_download_type = TAPI_EVENT_SAT_DW_TYPE_USER_ACTIVITY;
354                         break;
355
356                 case TAPI_EVENT_SAT_DW_TYPE_LANGUAGE_SELECTION:
357                         {
358                                 char scabuf[5] = {0};
359                                 int ret = 0;
360
361                                 printf(" en: english\n");
362                                 printf(" de: german\n");
363                                 ret = read(0, scabuf, sizeof(scabuf));
364                                 if (ret < 0)
365                                 {
366                                         if (errno == EINTR)
367                                                 perror("read(1)");
368                                         return -1;
369                                 }
370                                 else if (ret == 0)
371                                         return ret;
372
373                                 if(strncmp(scabuf, "en", 2) == 0)
374                                         evt_dl.u.language_selection_event_req_Data.language = TAPI_SAT_LP_ENGLISH;
375                                 else
376                                         evt_dl.u.language_selection_event_req_Data.language = TAPI_SAT_LP_GERMAN;
377
378                         evt_dl.event_download_type = TAPI_EVENT_SAT_DW_TYPE_LANGUAGE_SELECTION;
379                         }
380                         break;
381
382                 case TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION:
383                         evt_dl.event_download_type = TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION;
384                         evt_dl.u.browser_termination_event_req_Data.browser_termination_cause = TAPI_SAT_BROWSER_TERMINATED_BY_USER;
385                         break;
386
387                 default:
388                         break;
389         }
390         TelTapiSatEventDownloadEnvelope(&evt_dl, &requestId);
391 }
392
393 void
394 test_simatk_proactive_lang_noti(tapi_simatk_language_notification_ind_data_t* tst_data)
395 {
396         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
397
398         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
399
400         printf(" [SAT] : command qualifier: language specified? = %d\n",tst_data->command_detail.u.cmd_quali_language_notification.bSpecificLanguageNotification);
401
402         if(tst_data->command_detail.u.cmd_quali_language_notification.bSpecificLanguageNotification)
403                 printf(" [SAT] : command qualifier: language  = %d\n",tst_data->language.language);
404
405         //Send TR
406         tr_data.command_number = tst_data->command_detail.command_number;
407         tr_data.command_type = tst_data->command_detail.command_type;
408
409 }
410
411 void
412 test_simatk_proactive_provide_local_info(tapi_simatk_provide_local_info_ind_data_t* tst_data)
413 {
414
415         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
416
417         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
418
419         printf(" [SAT] : command qualifier: requested info = 0x%02x\n",tst_data->command_detail.u.cmd_quali_provide_local_info);
420
421         //Send TR
422         tr_data.command_number = tst_data->command_detail.command_number;
423         tr_data.command_type = tst_data->command_detail.command_type;
424         //tr_data.tr_data.provide_loc_info.other_info = TRUE;
425         tr_data.tr_data.provide_loc_info.info_type = tst_data->command_detail.u.cmd_quali_provide_local_info;
426
427         if(tst_data->command_detail.u.cmd_quali_provide_local_info == TAPI_SIMATK_CMD_QUALI_PROVIDE_LANGUAGE_SETTING)
428         {
429                 tr_data.tr_data.provide_loc_info.u.language_info.language = TAPI_SIMATK_LP_ENGLISH;
430         }
431         else if(tst_data->command_detail.u.cmd_quali_provide_local_info == TAPI_SIMATK_CMD_QUALI_PROVIDE_DATE_TIME_AND_TIME_ZONE)
432         {
433                 tr_data.tr_data.provide_loc_info.u.time_zone_info.year = 0x80;
434                 tr_data.tr_data.provide_loc_info.u.time_zone_info.month = 0x50;
435                 tr_data.tr_data.provide_loc_info.u.time_zone_info.day = 0x70;
436                 tr_data.tr_data.provide_loc_info.u.time_zone_info.hour = 0x41;
437                 tr_data.tr_data.provide_loc_info.u.time_zone_info.minute = 0x80;
438                 tr_data.tr_data.provide_loc_info.u.time_zone_info.second = 0x71;
439                 tr_data.tr_data.provide_loc_info.u.time_zone_info.time_zone = 0xFF;
440         }
441 }
442
443 void
444 test_simatk_proactive_setup_idle_mode_text(tapi_simatk_setup_idle_mode_text_ind_data_t* tst_data)
445 {
446
447         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
448
449         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
450
451         printf(" [SAT] : text-dcs: compressed?=%d, alpha_format=0x%x, msg_class=0x%x, raw_dcs=%d\n",tst_data->text.dcs.is_compressed_format, tst_data->text.dcs.alphabet_format,tst_data->text.dcs.msg_class, tst_data->text.dcs.raw_dcs);
452
453         printf(" [SAT] : text: string_length=%d, string=%s\n",tst_data->text.string_length, tst_data->text.string);
454
455         printf(" [SAT] : icon: is_icon_present=%d\n",tst_data->icon_id.is_present);
456
457         //Send TR
458         tr_data.command_number = tst_data->command_detail.command_number;
459         tr_data.command_type = tst_data->command_detail.command_type;
460 }
461
462 void
463 test_simatk_proactive_display_text(tapi_simatk_display_text_ind_data_t* tst_data)
464 {
465
466         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
467
468         printf(" [SAT] : command qualifier: clear=%d, priority=%d\n",tst_data->command_detail.u.cmd_quali_display_text.msg_clear,tst_data->command_detail.u.cmd_quali_display_text.msg_priority);
469
470         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
471
472         printf(" [SAT] : text-dcs: compressed?=%d, alpha_format=0x%x, msg_class=0x%x, raw_dcs=%d\n",tst_data->text.dcs.is_compressed_format, tst_data->text.dcs.alphabet_format,tst_data->text.dcs.msg_class, tst_data->text.dcs.raw_dcs);
473
474         printf(" [SAT] : text: string_length=%d, string=%s\n",tst_data->text.string_length, tst_data->text.string);
475
476         printf(" [SAT] : icon: is_icon_present=%d\n",tst_data->icon_id.is_present);
477
478         printf(" [SAT] : DURATION: interval=0x%x, time unit=0x%x\n",tst_data->duration.time_interval,tst_data->duration.time_unit);
479
480
481         //Send TR
482         tr_data.command_number = tst_data->command_detail.command_number;
483         tr_data.command_type = tst_data->command_detail.command_type;
484 /*      tr_data.tr_data.display_txt.result.general_result = TAPI_SIMATK_R_SUCCESS;
485         tr_data.tr_data.display_txt.result.me_problem = 0x00;
486         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
487                                                                 tr_data.command_number, tr_data.command_type,
488                                                                 tr_data.tr_data.display_txt.result.general_result);
489         tapi_simatk_send_terminal_response(&tr_data);*/
490
491 }
492
493 void
494 test_simatk_send_menu_select_env(TS_BOOL help)
495 {
496         TelSatMenuSelectionReqInfo_t env_data;
497         char str[5] = {0,0};
498         int item;
499         char scabuf[5] = {0};
500         int ret;
501         int requestId = -1;
502
503         ret = read(0, scabuf, sizeof(scabuf));
504         if (ret < 0)
505         {
506                 if (errno == EINTR)
507                         perror("read(1)");
508                 return -1;
509         }
510         else if (ret == 0)
511                 return ret;
512
513         memcpy(str, scabuf, (strlen(scabuf)-1));
514
515                 item = atoi(str);
516
517         env_data.item_identifier = item;
518         env_data.is_help_requested = help;
519         printf(" [SAT] : test_simatk_send_menu_select_env ::: MENU SELECT item_id= 0x%x, HELP?=%s\n",
520                                                                 env_data.item_identifier,(env_data.is_help_requested)?"Reqd":"NOT Reqd");
521         TelTapiSatMenuSelectionEnvelope(&env_data, &requestId);
522 }
523
524 void
525 test_simatk_proactive_refresh(tapi_simatk_refresh_ind_data_t* tst_data)
526 {
527         int i;
528         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
529
530         printf(" [SAT] : command qualifier: REFRESH MODE=%d\n",tst_data->command_detail.u.cmd_quali_refresh);
531
532         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
533
534         printf(" [SAT] : File Count=%d\n", tst_data->file_list.file_count);
535
536         printf(" [SAT] : file ids:");
537         for(i=0; i<tst_data->file_list.file_count;i++)
538                 printf("\tfile_#[%d] = 0x%04x",i,tst_data->file_list.file_id[i]);
539
540         printf(" \n");
541
542
543         //Send TR
544         tr_data.command_number = tst_data->command_detail.command_number;
545         tr_data.command_type = tst_data->command_detail.command_type;
546         /*tr_data.tr_data.refresh.result.general_result = TAPI_SIMATK_R_SUCCESS;
547         tr_data.tr_data.refresh.result.me_problem = 0x00;
548         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
549                                                                 tr_data.command_number, tr_data.command_type,
550                                                                 tr_data.tr_data.refresh.result.general_result);
551         tapi_simatk_send_terminal_response(&tr_data);*/
552 }
553
554
555 test_simatk_proactive_setup_menu(tapi_simatk_setup_menu_ind_data_t* tst_data)
556 {
557         int i;
558         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
559
560         printf(" [SAT] : command qualifier: selection_pref=%d, help_info=%d\n",tst_data->command_detail.u.cmd_quali_setup_menu.selection_preference,tst_data->command_detail.u.cmd_quali_setup_menu.is_help_info_available);
561
562         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
563
564         printf(" [SAT] : alpha identifier: is_alpha_present=%d, rawdcs=0x%x, str_len=%d, string=%s\n", tst_data->alpha_id.is_present,
565                                 tst_data->alpha_id.dcs.raw_dcs, tst_data->alpha_id.string_len, tst_data->alpha_id.string);
566
567         printf(" [SAT] : items NAI: list count=%d \n [SAT] : items NAI:",tst_data->item_next_action_ind_list.list_count);
568         for(i=0; i<tst_data->item_next_action_ind_list.list_count;i++)
569                 printf("\tnai_ind[%d] = 0x%02x",i, tst_data->item_next_action_ind_list.list[i]);
570
571         printf(" \n[SAT] : icon identifier: is icon present = %d\n",tst_data->icon_id.is_present);
572
573         printf(" [SAT] : setup menu: menu_count = %d\n",tst_data->menu_item_count);
574         for(i=0;i<tst_data->menu_item_count;i++)
575                 printf("\tmenu_item[%d]= %s, [menu_item_id = %d]\n",i, tst_data->menu_item[i].text, tst_data->menu_item[i].item_id);
576
577         //Send TR
578         tr_data.command_number = tst_data->command_detail.command_number;
579         tr_data.command_type = tst_data->command_detail.command_type;
580         /*tr_data.tr_data.setup_menu.result.general_result = TAPI_SIMATK_R_SUCCESS;
581         tr_data.tr_data.setup_menu.result.me_problem = 0x00;
582         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
583                                                                 tr_data.command_number, tr_data.command_type,
584                                                                 tr_data.tr_data.setup_menu.result.general_result);
585         tapi_simatk_send_terminal_response(&tr_data);*/
586 }
587
588 void
589 test_simatk_proactive_send_sms(tapi_simatk_send_sms_ind_data_t* tst_data)
590 {
591         int i;
592         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
593
594         printf(" [SAT] : send sms :is_packing_by ME rquired%d\n",tst_data->command_detail.u.cmd_quali_send_sms.is_packing_by_me_required);
595
596         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
597
598         printf(" [SAT] : send sms: alpha_id present?= %d,  icon present? = %d, icon_id=%d\n",tst_data->alpha_id.is_present, tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
599
600         printf(" [SAT] : send sms: ALPHA Len = %d, Alpha ID: %s\n",tst_data->alpha_id.string_len, tst_data->alpha_id.string);
601         printf(" [SAT] : send sms ADDRESS: ton=0x%x, npi=0x%x\n",tst_data->address.ton,tst_data->address.npi);
602
603         printf(" [SAT] : send sms ADDRESS: len = %d, dialling Number = %s\n", tst_data->address.dialling_number_length, tst_data->address.dialling_number);
604
605         printf(" [SAT] : send sms TPDU: len = %d, tpdu_data:\n",tst_data->sms_tpdu.data_length);
606         for(i=0;i<tst_data->sms_tpdu.data_length;i++)
607                 printf("\t0x%02x",tst_data->sms_tpdu.data[i]);
608         printf("\n");
609
610
611         //Send TR
612         tr_data.command_number = tst_data->command_detail.command_number;
613         tr_data.command_type = tst_data->command_detail.command_type;
614         /*tr_data.tr_data.setup_event_list.result.general_result = TAPI_SIMATK_R_SUCCESS;
615         tr_data.tr_data.setup_event_list.result.me_problem = 0x00;
616         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
617                                                                 tr_data.command_number, tr_data.command_type,
618                                                                 tr_data.tr_data.setup_event_list.result.general_result);
619         tapi_simatk_send_terminal_response(&tr_data);*/
620 }
621
622 void
623 test_simatk_proactive_setup_evt_list(tapi_simatk_setup_event_list_ind_data_t* tst_data)
624 {
625
626         int i;
627         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
628
629         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
630
631         printf(" [SAT] : setup menu: setup event count = %d\n",tst_data->event_list.event_list_count);
632         for(i=0;i<tst_data->event_list.event_list_count;i++)
633                 printf("\t#[%d], [event = 0x%02x]\n",i+1, tst_data->event_list.list[i]);
634
635         //Send TR
636         tr_data.command_number = tst_data->command_detail.command_number;
637         tr_data.command_type = tst_data->command_detail.command_type;
638         /*tr_data.tr_data.setup_event_list.result.general_result = TAPI_SIMATK_R_SUCCESS;
639         tr_data.tr_data.setup_event_list.result.me_problem = 0x00;
640         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
641                                                                 tr_data.command_number, tr_data.command_type,
642                                                                 tr_data.tr_data.setup_event_list.result.general_result);
643         tapi_simatk_send_terminal_response(&tr_data);*/
644 }
645
646 void
647 test_simatk_proactive_send_ussd(tapi_simatk_send_ussd_ind_data_t* tst_data)
648 {
649         int i;
650         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
651
652         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
653
654         printf(" [SAT] : alpha_id present?= %d,  alphaID: %s\n",tst_data->alpha_id.is_present, tst_data->alpha_id.string);
655
656 //      printf(" [SAT] : USSD STRING - DCS: alpha format=0x%x, compressed format?=0x%x\n",tst_data->ussd_string.dcs.alphabet_format,tst_data->ussd_string.dcs.is_compressed_format);
657
658         printf(" [SAT] : USSD STRING - DCS: Raw DCS =0x%x\n",tst_data->ussd_string.raw_dcs);
659
660         printf(" [SAT] : USSD STRING: len = %d, USSD string = \n", tst_data->ussd_string.ussd_string_length);
661
662         for(i=0;i<tst_data->ussd_string.ussd_string_length;i++)
663                 printf(" 0x%02x\t",tst_data->ussd_string.ussd_string[i]);
664
665         printf(" \n[SAT] : icon identifier: is icon present = %d, icon_id=%d\n",tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
666
667         //Send TR
668         tr_data.command_number = tst_data->command_detail.command_number;
669         tr_data.command_type = tst_data->command_detail.command_type;
670 }
671
672 void
673 test_simatk_proactive_send_ss(tapi_simatk_send_ss_ind_data_t* tst_data)
674 {
675         int i;
676         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
677
678         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
679
680         printf(" [SAT] : alpha_id present?= %d,  alphaID: %s\n",tst_data->alpha_id.is_present, tst_data->alpha_id.string);
681
682         printf(" [SAT] : SS STRING: ton=0x%x, npi=0x%x\n",tst_data->ss_string.ton,tst_data->ss_string.npi);
683
684         printf(" [SAT] : SS STRING: len = %d, ss string = %s\n", tst_data->ss_string.string_length, tst_data->ss_string.string);
685
686         printf(" \n[SAT] : icon identifier: is icon present = %d, icon_id=%d\n",tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
687
688         //Send TR
689         tr_data.command_number = tst_data->command_detail.command_number;
690         tr_data.command_type = tst_data->command_detail.command_type;
691 }
692
693 void
694 test_simatk_proactive_setup_call(tapi_simatk_setup_call_ind_data_t* tst_data)
695 {
696         int i;
697         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
698
699         printf(" [SAT] : setup call :Qualifier = %d\n",tst_data->command_detail.u.cmd_quali_setup_call);
700
701         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
702
703         printf(" [SAT] : user confirmation phase: alpha_id present?= %d,  alphaID: %s\n",tst_data->user_confirm_phase_alpha_id.is_present, tst_data->user_confirm_phase_alpha_id.string);
704
705         printf(" [SAT] : ADDRESS: ton=0x%x, npi=0x%x\n",tst_data->address.ton,tst_data->address.npi);
706
707         printf(" [SAT] : ADDRESS: len = %d, dialling Number = %s\n", tst_data->address.dialling_number_length, tst_data->address.dialling_number);
708
709         printf(" [SAT] : SUB ADDRESS: len = %d, data:\n",tst_data->sub_address.sub_address_len);
710         for(i=0;i<tst_data->sub_address.sub_address_len;i++)
711                 printf("\t0x%02x",tst_data->sub_address.sub_address[i]);
712         printf("\n");
713
714         printf(" [SAT] : CCP: len = %d, data:\n",tst_data->ccp.data_length);
715         for(i=0;i<tst_data->ccp.data_length;i++)
716                 printf("\t0x%02x",tst_data->ccp.data[i]);
717         printf("\n");
718
719         printf(" [SAT] : DURATION: interval=0x%x, time unit=0x%x\n",tst_data->duration.time_interval,tst_data->duration.time_unit);
720
721         printf(" [SAT] : call setup phase: alpha_id present?= %d,  alphaID: %s\n",tst_data->call_setup_phase_alpha_id.is_present, tst_data->call_setup_phase_alpha_id.string);
722
723         printf(" \n[SAT] : user confirmation phase - icon identifier: is icon present = %d, icon_id=%d\n",tst_data->user_confirm_phase_icon_id.is_present, tst_data->user_confirm_phase_icon_id.icon_identifier);
724
725         printf(" \n[SAT] : call setup phase - icon identifier: is icon present = %d, icon_id=%d\n",tst_data->call_setup_phase_icon_id.is_present, tst_data->call_setup_phase_icon_id.icon_identifier);
726
727         //Send TR
728         tr_data.command_number = tst_data->command_detail.command_number;
729         tr_data.command_type = tst_data->command_detail.command_type;
730         /*tr_data.tr_data.setup_event_list.result.general_result = TAPI_SIMATK_R_SUCCESS;
731         tr_data.tr_data.setup_event_list.result.me_problem = 0x00;
732         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x\n",
733                                                                 tr_data.command_number, tr_data.command_type,
734                                                                 tr_data.tr_data.setup_event_list.result.general_result);
735         //tapi_simatk_send_terminal_response(&tr_data);*/
736 }
737
738 void
739 test_simatk_proactive_select_item_list(tapi_simatk_select_item_ind_data_t* tst_data)
740 {
741
742         int i;
743         printf(" [SAT] : command detail: command_num=%d, command_type=0x%x\n",tst_data->command_detail.command_number,tst_data->command_detail.command_type);
744
745         printf(" [SAT] : command qualifier: prez_type = %d, selection_pref=%d, help_info=%d\n",tst_data->command_detail.u.cmd_quali_select_item.presentation_type,
746                 tst_data->command_detail.u.cmd_quali_select_item.selection_preference,tst_data->command_detail.u.cmd_quali_select_item.is_help_info_available);
747
748         printf(" [SAT] : device identity: src=0x%x, dest=0x%x\n",tst_data->device_identities.source,tst_data->device_identities.destination);
749
750         printf(" [SAT] : alpha identifier: is_alpha_present=%d, rawdcs=0x%x, str_len=%d, string=%s\n", tst_data->alpha_id.is_present,
751                                 tst_data->alpha_id.dcs.raw_dcs, tst_data->alpha_id.string_len, tst_data->alpha_id.string);
752
753         printf(" [SAT] : items NAI: list count=%d \n [SAT] : items NAI:",tst_data->item_next_action_ind_list.list_count);
754         for(i=0; i<tst_data->item_next_action_ind_list.list_count;i++)
755                 printf("\tnai_ind[%d] = 0x%02x",i, tst_data->item_next_action_ind_list.list[i]);
756
757         printf(" \n[SAT] : DEFAULT ITEM = %d\n",tst_data->default_item_identifier);
758         printf(" \n[SAT] : icon identifier: is icon present = %d, icon_id=%d\n",tst_data->icon_id.is_present, tst_data->icon_id.icon_identifier);
759
760         printf(" [SAT] : setup menu: item_count = %d\n",tst_data->menu_item_count);
761         for(i=0;i<tst_data->menu_item_count;i++)
762                 printf("\tITEM#[%d]= %s, [item_id = %d]\n",i, tst_data->menu_item[i].text, tst_data->menu_item[i].item_id);
763
764         tr_data.command_number = tst_data->command_detail.command_number;
765         tr_data.command_type = tst_data->command_detail.command_type;
766         if(tst_data->command_detail.u.cmd_quali_select_item.is_help_info_available == TRUE)
767                 tr_data.tr_data.select_item.item_identifier = 0x01;
768 }
769
770 void
771 test_select_item_send_tr(void)
772 {
773         tapi_simatk_resp_data_t tr_data;
774         char str[5] = {0,0};
775         int item;
776         int ret;
777         //Send TR
778         //if(item_id > '0' && item_id <= '9')
779         {
780         char scabuf[5] = {0};
781                 ret = read(0, scabuf, sizeof(scabuf));
782                 if (ret < 0)
783                 {
784                         if (errno == EINTR)
785                                 perror("read(1)");
786                         return -1;
787                 }
788                 else if (ret == 0)
789                         return ret;
790                 memcpy(str, scabuf, (strlen(scabuf)));
791                 item = atoi(str);
792
793                 if(item == 0)
794                 {
795                         tr_data.tr_data.select_item.result.general_result = TAPI_SIMATK_R_PROACTIVE_SESSION_TERMINATED_BY_USER;
796                         tr_data.tr_data.select_item.other_info = FALSE;
797                 }
798         /*      else if(sel_item_data.menu_item_count <  item )
799                 {
800                         printf(" [SAT] : ***input should be between 1 & %d\n",sel_item_data.menu_item_count);
801                         tr_data.tr_data.select_item.result.general_result = TAPI_SIMATK_R_BACKWARD_MOVE_BY_USER;
802                         tr_data.tr_data.select_item.other_info = FALSE;
803
804                 }*/
805                 else
806                 {
807                         tr_data.tr_data.select_item.result.general_result = TAPI_SIMATK_R_SUCCESS;
808                         tr_data.tr_data.select_item.other_info = TRUE;
809                         tr_data.tr_data.select_item.item_identifier = (unsigned char)item;
810                 }
811         }
812         //else
813         //{
814         //      printf(" [SAT] : ***INCORRECT INPUT\n");
815         //              tr_data.tr_data.select_item.result.general_result = TAPI_SIMATK_R_PROACTIVE_SESSION_TERMINATED_BY_USER;
816         //              tr_data.tr_data.select_item.other_info = FALSE;
817         //}
818
819
820         tr_data.command_number = sel_item_data.command_detail.command_number;
821         tr_data.command_type = sel_item_data.command_detail.command_type;
822
823         tr_data.tr_data.select_item.result.me_problem = 0x00;
824
825         printf(" [SAT] : send TR. command_number=%d, type=0x%x, gen_result=0x%x, item_id=%d\n",
826                                                                 tr_data.command_number, tr_data.command_type,
827                                                                 tr_data.tr_data.select_item.result.general_result, item);
828         TelTapiSatSendUiUserConfirm(tr_data.command_number,tr_data.command_type,SAT_ENGINE_USER_CONFIRM_YES,&tr_data.tr_data.select_item.item_identifier,sizeof(TS_UINT8));
829 }
830
831 int isServerDied = 0;
832 /********************************************************************************/
833
834
835 int sat_read_key_input(void)
836 {
837         char ch;
838         int ret;
839         char callId=0;
840         unsigned short len;
841         char buf[256];
842         char dtmfStr[16] = "1000103001";
843         char normal[16] = "0103001";
844
845
846
847
848
849     ret = read(0, buf, sizeof(buf));
850     if (ret < 0) {
851       if (errno == EINTR)
852       perror("read(1)");
853       return -1;
854     } else if (ret == 0) return ret;
855
856
857         printf("\n q : quit \n");
858         if(curr_cmd == TAPI_EVENT_SAT_SELECT_ITEM_IND)
859                 printf(" si : select item terminal response \n");
860         if(curr_cmd == TAPI_EVENT_SAT_GET_INKEY_IND || curr_cmd == TAPI_EVENT_SAT_GET_INPUT_IND)
861         {
862                 printf(" \"inkey\" or \"input\" : get inkey/input response \n");
863                 printf(" \"tr\" : to send response other than success \n");
864         }
865         else if(curr_cmd != 0x00)
866                 printf(" tr :Send TR for the current command = 0x%x \n",curr_cmd);
867         printf(" smhelp :  envelope cmd help \n");
868         printf(" sm :  envelope cmd select menu \n");
869         printf(" ed: event download\n");
870         printf(" cc: MO call control\n");
871
872         printf("--SAT_key_in : %s\n", buf);
873
874         if(strncmp(buf, "q", 1) == 0){
875                 printf("### test program is terminated.\n");
876
877             return -1;
878       }
879
880         if(strncmp(buf, "tr", 2) == 0)
881         {
882                 char scabuf[5] = {0};
883                 unsigned char input=0x00;
884
885                 printf("general response 0x00 ~ 0x3d:  0x\n");
886
887                 ret = read(0, scabuf, sizeof(scabuf));
888                 if (ret < 0)
889                 {
890                         if (errno == EINTR)
891                                 perror("read(1)");
892                         return -1;
893                 }
894                 else if (ret == 0)
895                         return ret;
896
897                 input = (scabuf[0] -'0' )<< 4;
898                 input |= (scabuf[1]-'0')&0x0F;
899                 if(input >= 0x00 && input <= 0x3d)
900                         test_send_tr(input);
901                 else
902                         test_send_tr(0x00);
903         }
904
905
906         else if(strncmp(buf, "smhelp", 6) == 0)
907         {
908                 printf("\n select menu for help: \n");
909                 test_simatk_send_menu_select_env(TRUE);
910         }
911         else if(strncmp(buf, "sm", 2) == 0)
912         {
913                 printf("\n select menu: \n");
914                 test_simatk_send_menu_select_env(FALSE);
915         }
916
917         else if(strncmp(buf, "si", 2) == 0)
918         {
919                 printf("\n select item: \n");
920                 test_select_item_send_tr();
921         }
922         else if(strncmp(buf, "ed", 2) == 0)
923         {
924                 char scabuf[5] = {0};
925                 printf(" id : idle screen \n");
926                 printf(" ua :  user activity \n");
927                 printf(" ls: language selection\n");
928                 printf(" bt: browser termination\n");
929                 ret = read(0, scabuf, sizeof(scabuf));
930                 if (ret < 0)
931                 {
932                         if (errno == EINTR)
933                                 perror("read(1)");
934                         return -1;
935                 }
936                 else if (ret == 0)
937                         return ret;
938
939                 if(strncmp(scabuf, "id", 2) == 0)
940                         test_simatk_event_download(TAPI_SIMATK_EVENT_DW_TYPE_IDLE_SCREEN_AVAILABLE);
941                 else if(strncmp(scabuf, "ua", 2) == 0)
942                         test_simatk_event_download(TAPI_SIMATK_EVENT_DW_TYPE_USER_ACTIVITY);
943                 else if(strncmp(scabuf, "ls", 2) == 0)
944                         test_simatk_event_download(TAPI_SIMATK_EVENT_DW_TYPE_LANGUAGE_SELECTION);
945                 else if(strncmp(scabuf, "bt", 2) == 0)
946                         test_simatk_event_download(TAPI_SIMATK_EVENT_DW_TYPE_BROWSER_TERMINATION);
947                 else
948                         printf("no such event\n");
949
950         }
951         else if((strncmp(buf, "inkey", 5) == 0) ||(strncmp(buf, "input", 5) == 0))
952         {
953                 char scabuf[255] = {0};
954                 printf(" ONly one character for INKEY, between min and max for INPUT: \n");
955                 printf(" plz read the command qualifier and provide the input accordingly... \n");
956                 printf(" bk : backward move \n");
957                 printf(" end :  end proactive session \n");
958                 printf(" INKEY: y OR n: for yes or no input\n");
959                 printf(" input char/string:\n");
960
961                 ret = read(0, scabuf, sizeof(scabuf));
962                 if (ret < 0)
963                 {
964                         if (errno == EINTR)
965                                 perror("read(1)");
966                         return -1;
967                 }
968                 else if (ret == 0)
969                         return ret;
970
971                 if((strncmp(scabuf, "y", 1) == 0) || (strncmp(scabuf, "n", 1) == 0))
972                 {
973                         //tr_data.tr_data.get_inkey.result.general_result = 0x00;
974                         tr_data.tr_data.get_inkey.text.dcs.msg_class = TAPI_SIMATK_MSG_CLASS_RESERVED;
975                         tr_data.tr_data.get_inkey.text.dcs.alphabet_format = TAPI_SIMATK_ALPHABET_FROMAT_8BIT_DATA;
976                         tr_data.tr_data.get_inkey.text.string_length = 1;
977                         if(strncmp(scabuf, "y", 1) == 0)
978                                 tr_data.tr_data.get_inkey.text.string[0] = 0x01; //buf[0];
979                         else
980                                 tr_data.tr_data.get_inkey.text.string[0] = 0x00;
981                         tr_data.tr_data.get_inkey.text.string[1] = '\0';
982                         //test_send_tr(tr_data.tr_data.get_inkey.result.general_result);
983                 }
984                 else if(strncmp(scabuf, "bk", 2) == 0)
985                 {
986                         tr_data.tr_data.get_inkey.result.general_result = 0x11;
987                 }
988                 else if(strncmp(scabuf, "end", 3) == 0)
989                 {
990                         tr_data.tr_data.get_inkey.result.general_result = 0x10;
991                 }
992                 else
993                 {
994                         if(strncmp(buf, "inkey", 5) == 0)
995                         {
996                                 //tr_data.tr_data.get_inkey.result.general_result = 0x00;
997                                 tr_data.tr_data.get_inkey.text.dcs.msg_class = TAPI_SIMATK_MSG_CLASS_RESERVED;
998                                 tr_data.tr_data.get_inkey.text.dcs.alphabet_format = TAPI_SIMATK_ALPHABET_FROMAT_8BIT_DATA;
999                         tr_data.tr_data.get_inkey.text.string_length = 1;
1000                                 tr_data.tr_data.get_inkey.text.string[0] = scabuf[0]; //buf[0];
1001                         tr_data.tr_data.get_inkey.text.string[1] = '\0';
1002                 }
1003                         else
1004                         {
1005                                 int i=0;
1006
1007                                 //tr_data.tr_data.get_input.result.general_result = 0x00;
1008                                 tr_data.tr_data.get_input.text.dcs.msg_class = TAPI_SIMATK_MSG_CLASS_RESERVED;
1009                                 printf("inkey: input: %s\n",scabuf);
1010                                 while(scabuf[i] != 0xA)
1011                                 {
1012                                         //printf("%c\n",scabuf[i]);
1013                                         i++;
1014                                 }
1015                                 if(tr_data.tr_data.get_input.text.dcs.alphabet_format == TAPI_SIMATK_ALPHABET_FROMAT_SMS_DEFAULT)
1016                                 {
1017                                         tr_data.tr_data.get_input.text.string_length = (TS_UINT8)sat_util_pack_7bit(tr_data.tr_data.get_input.text.string, &scabuf[0], i );
1018                                 }
1019                                 else
1020                                 {
1021                                         tr_data.tr_data.get_input.text.string_length = i;
1022                                         memcpy(tr_data.tr_data.get_input.text.string, &scabuf[0], tr_data.tr_data.get_input.text.string_length);
1023                                 }
1024                         }
1025                 }
1026
1027                 test_send_tr(tr_data.tr_data.get_inkey.result.general_result);
1028         }
1029         else if(strncmp(buf, "cc", 2) == 0)
1030         {
1031                 char scabuf[25] = {0};
1032                 TelCallSetupParams_t si;
1033
1034                 memset(&si, 0, sizeof(si));
1035                 si.CallType=TAPI_CALL_TYPE_VOICE;
1036
1037                 printf("number to be dialled:\n");
1038
1039                 ret = read(0, scabuf, sizeof(scabuf));
1040                 if (ret < 0)
1041                 {
1042                         if (errno == EINTR)
1043                                 perror("read(1)");
1044                         return -1;
1045                 }
1046                 else if (ret == 0)
1047                         return ret;
1048
1049                 memcpy(si.szNumber, &scabuf, strlen(scabuf));
1050
1051                 si.IdentityMode = TAPI_CALL_IDENTITY_SHOW;              //default
1052
1053                 printf("send the call make message to server....%s", si.szNumber);
1054
1055                 //ret = tapi_call_setup(&si, &g_hCall);
1056
1057                 printf(" after calling tapi_call_setup : g_hCall - %d", g_hCall);
1058
1059                 printf(" Tapi return value is %d", ret);
1060
1061                 if(ret)
1062                 {
1063                         memcpy(&g_info.callNumber, si.szNumber, sizeof( si.szNumber));
1064                 }
1065         }
1066
1067         /*
1068         #if 0
1069         if(strncmp(buf, "prof", 4) == 0){
1070                 test_simatk_profile_download();
1071       } else if(strncmp(buf, "env", 3) == 0){
1072                 test_simatk_envelope_send();
1073       } else if(strncmp(buf, "ed", 2) == 0){
1074                 test_simatk_event_send();
1075       } else if(strncmp(buf, "sm", 2) == 0) {
1076                 scanf("%s", buf);
1077
1078                 sendEnvelopeCmd_SetupMenu(FALSE, atoi(buf));
1079         } else if(strncmp(buf, "si", 2) == 0) {
1080                 scanf("%s", buf);
1081
1082                 sendTerminalResponse_SelectItem(0x00, TRUE, atoi(buf), 0, NULL);
1083         }
1084
1085         #endif
1086         */
1087
1088         if(strncmp(buf, "menu", 4) == 0)
1089         {
1090                 printf("Finished Testing this module, Going back to Main Menu\n");
1091                 //call_test_exit();
1092                 return -1;
1093                 //exit(0);
1094         }
1095
1096         memset(buf, '\0', 256);
1097
1098     return 0;
1099 }
1100
1101
1102 /********************************************************************************/
1103 static int  app_callback(TelTapiEventClass_t eventClass, TelTapiEventType_t     eventType, /*length*/int  param1,/*pDate*/void * param2)
1104 {
1105         int i;
1106         //unsigned char *buf= (unsigned char*) param2;
1107
1108         //unsigned char *count = buf;
1109         int            loop_count;
1110
1111 printf("\n [SAT] app_callback( eventType=0x%02x) \n", eventType);
1112 #if 0
1113 printf("   eventClass: %d, eventType: %d[%02x], paramLength = %d\n", eventClass, eventType, eventType, param1);
1114
1115         for( i=0; i<param1; i++ ) printf("[%02x] ", buf[i]);
1116         printf("\n --------------- ------ \n");
1117
1118         #endif
1119
1120         switch(eventClass)
1121         {
1122                 case TAPI_EVENT_CLASS_SAT:
1123                         switch(eventType)
1124                         {
1125                                 case TAPI_EVENT_SAT_END_PROACTIVE_SESSION_IND:
1126                                         printf("[SAT]  TAPI_EVENT_SAT_END_PROACTIVE_SESSION_IND.\n");
1127                                         break;
1128
1129                                 case TAPI_EVENT_SAT_DISPLAY_TEXT_IND:
1130                                 {
1131                                         tapi_simatk_display_text_ind_data_t  tst_data;
1132                                         tapi_simatk_resp_data_t tr_data;
1133                                         curr_cmd = eventType;
1134
1135                                         printf(" [SAT] TAPI_EVENT_SAT_DISPLAY_TEXT_IND: \n");
1136                                         //test_display_text_data.data_len = param1;
1137                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_display_text_ind_data_t));
1138
1139                                         test_simatk_proactive_display_text(&tst_data);
1140
1141                                 }
1142                                         break;
1143
1144                                 case TAPI_EVENT_SAT_UI_SETUP_MENU_IND:
1145                                 {
1146                                         tapi_simatk_setup_menu_ind_data_t  tst_data;
1147                                         curr_cmd = eventType;
1148
1149                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SETUP_MENU_IND: \n");
1150                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_setup_menu_ind_data_t));
1151
1152                                         test_simatk_proactive_setup_menu(&tst_data);
1153                                 }
1154                                         break;
1155
1156                                 case TAPI_SIMATK_EVENT_SETUP_EVENT_LIST_IND:
1157                                 {
1158                                         tapi_simatk_setup_event_list_ind_data_t tst_data;
1159
1160                                         curr_cmd = eventType;
1161                                         printf(" [SAT] TAPI_SIMATK_EVENT_SETUP_EVENT_LIST_IND: \n");
1162                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_setup_event_list_ind_data_t));
1163
1164                                         test_simatk_proactive_setup_evt_list(&tst_data);
1165                                 }
1166                                         break;
1167
1168                                 case TAPI_EVENT_SAT_UI_REFRESH_IND:
1169                                 {
1170                                         tapi_simatk_refresh_ind_data_t tst_data;
1171
1172                                         curr_cmd = eventType;
1173                                         printf(" [SAT] TAPI_EVENT_SAT_UI_REFRESH_IND: \n");
1174                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_refresh_ind_data_t));
1175
1176                                         test_simatk_proactive_refresh(&tst_data);
1177                                 }
1178                                         break;
1179
1180                                 case TAPI_EVENT_SAT_SELECT_ITEM_IND:
1181                                 {
1182                                         printf(" [SAT] TAPI_EVENT_SAT_SELECT_ITEM_IND: \n");
1183                                         memcpy(&sel_item_data, param2, sizeof(tapi_simatk_select_item_ind_data_t));
1184                                         curr_cmd = eventType;
1185                                         test_simatk_proactive_select_item_list(&sel_item_data);
1186                                 }
1187                                         break;
1188
1189                                 case TAPI_EVENT_SAT_UI_SEND_SMS_IND:
1190                                 {
1191                                         tapi_simatk_send_sms_ind_data_t tst_data;
1192                                         curr_cmd = eventType;
1193                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SEND_SMS_IND: \n");
1194                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_send_sms_ind_data_t));
1195
1196                                         test_simatk_proactive_send_sms(&tst_data);
1197                                 }
1198                                         break;
1199
1200                                 case TAPI_EVENT_SAT_UI_SETUP_CALL_IND:
1201                                 {
1202                                         tapi_simatk_setup_call_ind_data_t tst_data;
1203                                         curr_cmd = eventType;
1204                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SETUP_CALL_IND: \n");
1205                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_setup_call_ind_data_t));
1206                                         test_simatk_proactive_setup_call(&tst_data);
1207                                 }
1208                                         break;
1209
1210                                 case TAPI_EVENT_SAT_UI_SEND_SS_IND:
1211                                 {
1212                                         tapi_simatk_send_ss_ind_data_t tst_data;
1213                                         curr_cmd = eventType;
1214                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SEND_SS_IND: \n");
1215                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_send_ss_ind_data_t));
1216                                         test_simatk_proactive_send_ss(&tst_data);
1217                                 }
1218                                         break;
1219
1220                                 case TAPI_EVENT_SAT_UI_SEND_USSD_IND:
1221                                 {
1222                                         tapi_simatk_send_ussd_ind_data_t tst_data;
1223                                         curr_cmd = eventType;
1224                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SEND_USSD_IND: \n");
1225                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_send_ussd_ind_data_t));
1226                                         test_simatk_proactive_send_ussd(&tst_data);
1227                                 }
1228                                         break;
1229
1230                                 case TAPI_EVENT_SAT_GET_INKEY_IND:
1231                                         {
1232                                         tapi_simatk_get_inkey_ind_data_t tst_data;
1233                                         curr_cmd = eventType;
1234                                         printf(" [SAT] TAPI_EVENT_SAT_GET_INKEY_IND: \n");
1235                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_get_inkey_ind_data_t));
1236                                         test_simatk_proactive_get_inkey(&tst_data);
1237                                         }
1238                                         break;
1239
1240                                 case TAPI_EVENT_SAT_GET_INPUT_IND:
1241                                         {
1242                                         tapi_simatk_get_input_ind_data_t tst_data;
1243                                         curr_cmd = eventType;
1244                                         printf(" [SAT] TAPI_EVENT_SAT_GET_INPUT_IND: \n");
1245                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_get_inkey_ind_data_t));
1246                                         test_simatk_proactive_get_input(&tst_data);
1247                                         }
1248                                         break;
1249
1250                                 case TAPI_EVENT_SAT_PLAY_TONE_IND :
1251                                         {
1252                                         tapi_simatk_play_tone_ind_data_t tst_data;
1253                                         curr_cmd = eventType;
1254                                         printf(" [SAT] TAPI_EVENT_SAT_PLAY_TONE_IND : \n");
1255                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_play_tone_ind_data_t));
1256                                         test_simatk_proactive_play_tone(&tst_data);
1257                                         }
1258                                         break;
1259
1260                                 case TAPI_EVENT_SAT_UI_SEND_DTMF_IND:
1261                                         {
1262                                         tapi_simatk_send_dtmf_ind_data_t tst_data;
1263                                         curr_cmd = eventType;
1264                                         printf(" [SAT] TAPI_EVENT_SAT_UI_SEND_DTMF_IND: \n");
1265                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_send_dtmf_ind_data_t));
1266                                         test_simatk_proactive_send_dtmf(&tst_data);
1267                                         }
1268                                         break;
1269
1270                                 case TAPI_EVENT_SAT_SETUP_IDLE_MODE_TEXT_IND:
1271                                 {
1272                                         tapi_simatk_setup_idle_mode_text_ind_data_t tst_data;
1273                                         curr_cmd = eventType;
1274                                         printf(" [SAT] TAPI_EVENT_SAT_SETUP_IDLE_MODE_TEXT_IND: \n");
1275                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_setup_idle_mode_text_ind_data_t));
1276                                         test_simatk_proactive_setup_idle_mode_text(&tst_data);
1277                                 }
1278                                         break;
1279
1280                                 case TAPI_EVENT_SAT_PROVIDE_LOCAL_INFO_IND:
1281                                 {
1282                                         tapi_simatk_provide_local_info_ind_data_t tst_data;
1283                                         curr_cmd = eventType;
1284                                         printf(" [SAT] TAPI_EVENT_SAT_PROVIDE_LOCAL_INFO_IND: \n");
1285                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_provide_local_info_ind_data_t));
1286                                         test_simatk_proactive_provide_local_info(&tst_data);
1287                                 }
1288
1289                                         break;
1290
1291                                 case TAPI_EVENT_SAT_LANGUAGE_NOTIFICATION_IND:
1292                                 {
1293                                         tapi_simatk_language_notification_ind_data_t tst_data;
1294                                         curr_cmd = eventType;
1295                                         printf(" [SAT] TAPI_EVENT_SAT_PROVIDE_LOCAL_INFO_IND: \n");
1296                                         memcpy(&tst_data, param2, sizeof(tapi_simatk_language_notification_ind_data_t));
1297                                         test_simatk_proactive_lang_noti(&tst_data);
1298                                 }
1299
1300                                         break;
1301
1302                                 case TAPI_EVENT_SAT_CALL_CONTROL_IND:
1303                                 {
1304                                         tapi_simatk_call_control_cnf_data_t cc_result;
1305                                         int i;
1306                                         memcpy(&cc_result, param2, sizeof(tapi_simatk_call_control_cnf_data_t));
1307                                         printf(" [SAT] TAPI_EVENT_SAT_CALL_CONTROL_IND: \n");
1308                                         curr_cmd = eventType;
1309
1310                                         printf(" [SAT] :  call type=0x%x, call control result: 0x%x\n",cc_result.call_type, cc_result.call_control_result);
1311
1312                                         printf(" [SAT] : alpha_present=%d, alpha_len=%d, alpha_text=%s\n",cc_result.alpha_identifier.is_present, cc_result.alpha_identifier.string_len, cc_result.alpha_identifier.string);
1313
1314                                         if(cc_result.call_control_result == SIMATK_CALL_CONTROL_R_ALLOWED_WITH_MOD)
1315                                         {
1316                                                 if(cc_result.call_type == TAPI_SIMATK_CALL_TYPE_MO_VOICE)
1317                                                 {
1318                                                         if(cc_result.u.voice_call_data.address.dialling_number_length > 0)
1319                                                         {
1320                                                                 printf(" [SAT] : TON = 0x%x, NPI = 0x%x\n",cc_result.u.voice_call_data.address.ton, cc_result.u.voice_call_data.address.npi);
1321                                                                 printf(" [SAT] : ADDRESS: len=%d, value =", cc_result.u.voice_call_data.address.dialling_number_length);
1322                                                                 for(i=0; i<cc_result.u.voice_call_data.address.dialling_number_length;i++)
1323                                                                         printf("\t0x%02x",cc_result.u.voice_call_data.address.dialling_number[i]);
1324                                                         }
1325
1326                                                         if(cc_result.u.voice_call_data.sub_address.sub_address_len > 0)
1327                                                         {
1328                                                                 printf(" [SAT] : SUBADDRESS: len=%d, value =", cc_result.u.voice_call_data.sub_address.sub_address_len);
1329                                                                 for(i=0; i<cc_result.u.voice_call_data.sub_address.sub_address_len;i++)
1330                                                                         printf("\t0x%02x",cc_result.u.voice_call_data.sub_address.sub_address[i]);
1331                                                         }
1332                                                         else
1333                                                                 printf(" [SAT] : SUBADDRESS NOT PRESENT ");
1334
1335                                                         printf(" [SAT] : BC REPEAT IND: %d", cc_result.u.voice_call_data.bc_repeat_indicator);
1336
1337                                                         if(cc_result.u.voice_call_data.ccp1.data_length > 0)
1338                                                         {
1339                                                                 printf(" [SAT] : CCP1: len=%d, value =", cc_result.u.voice_call_data.ccp1.data_length);
1340                                                                 for(i=0; i<cc_result.u.voice_call_data.ccp1.data_length;i++)
1341                                                                         printf("\t0x%02x",cc_result.u.voice_call_data.ccp1.data[i]);
1342                                                         }
1343                                                         else
1344                                                                 printf(" [SAT] : CCP1 NOT PRESENT ");
1345
1346                                                         if(cc_result.u.voice_call_data.ccp2.data_length > 0)
1347                                                         {
1348                                                                 printf(" [SAT] : CCP2: len=%d, value =", cc_result.u.voice_call_data.ccp2.data_length);
1349                                                                 for(i=0; i<cc_result.u.voice_call_data.ccp2.data_length;i++)
1350                                                                         printf("\t0x%02x",cc_result.u.voice_call_data.ccp2.data[i]);
1351                                                         }
1352                                                         else
1353                                                                 printf(" [SAT] : CCP2 NOT PRESENT ");
1354                                                 }
1355                                                 else
1356                                                 {
1357                                                         if(cc_result.u.ss_data.ss_string.string_length > 0)
1358                                                         {
1359                                                                 printf(" [SAT] : TON = 0x%x, NPI = 0x%x\n",cc_result.u.ss_data.ss_string.ton, cc_result.u.ss_data.ss_string.npi);
1360                                                                 printf(" [SAT] : ADDRESS: len=%d, value =", cc_result.u.ss_data.ss_string.string_length);
1361                                                                 for(i=0; i<cc_result.u.ss_data.ss_string.string_length;i++)
1362                                                                         printf("\t0x%02x",cc_result.u.ss_data.ss_string.string[i]);
1363                                                         }
1364
1365                                                         if(cc_result.u.ss_data.sub_address.sub_address_len > 0)
1366                                                         {
1367                                                                 printf(" [SAT] : SUBADDRESS: len=%d, value =", cc_result.u.ss_data.sub_address.sub_address_len);
1368                                                                 for(i=0; i<cc_result.u.ss_data.sub_address.sub_address_len;i++)
1369                                                                         printf("\t0x%02x",cc_result.u.ss_data.sub_address.sub_address[i]);
1370                                                         }
1371                                                         else
1372                                                                 printf(" [SAT] : SUBADDRESS NOT PRESENT ");
1373
1374                                                         printf(" [SAT] : BC REPEAT IND: %d", cc_result.u.ss_data.bc_repeat_indicator);
1375
1376                                                         if(cc_result.u.ss_data.ccp1.data_length > 0)
1377                                                         {
1378                                                                 printf(" [SAT] : CCP1: len=%d, value =", cc_result.u.ss_data.ccp1.data_length);
1379                                                                 for(i=0; i<cc_result.u.ss_data.ccp1.data_length;i++)
1380                                                                         printf("\t0x%02x",cc_result.u.ss_data.ccp1.data[i]);
1381                                                         }
1382                                                         else
1383                                                                 printf(" [SAT] : CCP1 NOT PRESENT ");
1384
1385                                                         if(cc_result.u.ss_data.ccp2.data_length > 0)
1386                                                         {
1387                                                                 printf(" [SAT] : CCP2: len=%d, value =", cc_result.u.ss_data.ccp2.data_length);
1388                                                                 for(i=0; i<cc_result.u.ss_data.ccp2.data_length;i++)
1389                                                                         printf("\t0x%02x",cc_result.u.ss_data.ccp2.data[i]);
1390                                                         }
1391                                                         else
1392                                                                 printf(" [SAT] : CCP2 NOT PRESENT ");
1393                                                 }
1394                                         }
1395                                 }
1396                                         break;
1397                                 case TAPI_EVENT_SAT_MO_SMS_CONTROL_IND:
1398                                 {
1399                                         tapi_simatk_call_control_cnf_data_t sm_result;
1400                                         int i;
1401
1402                                         memcpy(&sm_result, param2, sizeof(tapi_simatk_call_control_cnf_data_t));
1403                                         printf(" [SAT] TAPI_EVENT_SAT_MO_SMS_CONTROL_IND: \n");
1404                                         curr_cmd = eventType;
1405
1406                                         printf(" [SAT] :  call type=0x%x, MO SM control result: 0x%x\n",sm_result.call_type, sm_result.call_control_result);
1407
1408                                         printf(" [SAT] : alpha_present=%d, alpha_len=%d, alpha_text=%s\n",sm_result.alpha_identifier.is_present, sm_result.alpha_identifier.string_len, sm_result.alpha_identifier.string);
1409
1410                                         if(sm_result.u.sms_data.rp_dest_address.dialling_number_length > 0)
1411                                         {
1412                                                 printf(" [SAT] : TON = 0x%x, NPI = 0x%x\n",sm_result.u.sms_data.rp_dest_address.ton, sm_result.u.sms_data.rp_dest_address.npi);
1413
1414                                                 printf(" [SAT] :RPD ADDRESS: len=%d, value =", sm_result.u.sms_data.rp_dest_address.dialling_number_length);
1415                                                 for(i=0; i<sm_result.u.sms_data.rp_dest_address.dialling_number_length;i++)
1416                                                         printf("\t0x%02x",sm_result.u.sms_data.rp_dest_address.dialling_number[i]);
1417                                         }
1418                                         else
1419                                                 printf("RP Dest Address Not Present");
1420                                         printf(" \n");
1421
1422                                         if(sm_result.u.sms_data.tp_dest_address.dialling_number_length > 0)
1423                                         {
1424                                                 printf(" [SAT] : TON = 0x%x, NPI = 0x%x\n",sm_result.u.sms_data.tp_dest_address.ton, sm_result.u.sms_data.tp_dest_address.npi);
1425
1426                                                 printf(" [SAT] :TPD ADDRESS: len=%d, value =", sm_result.u.sms_data.tp_dest_address.dialling_number_length);
1427                                                 for(i=0; i<sm_result.u.sms_data.tp_dest_address.dialling_number_length;i++)
1428                                                         printf("\t0x%02x",sm_result.u.sms_data.tp_dest_address.dialling_number[i]);
1429                                         }
1430                                         else
1431                                                 printf("TP Dest Address Not Present");
1432                                         printf(" \n");
1433                                 }
1434                                         break;
1435
1436                                 default:
1437                                         break;
1438                                 }
1439
1440
1441                         break;
1442                 default:
1443                         printf(" NOT a simatk event\n");
1444                         break;
1445
1446         }
1447 printf("\n [SAT] end of app_callback(sat_test/main.c) \n");
1448
1449         return TRUE;
1450
1451 }
1452
1453
1454
1455
1456 /*****************************************************************/
1457
1458 void sat_select_loop(void)
1459 {
1460     int ret;
1461     fd_set readfds;
1462 //      fprintf(stderr,"sat Select Loop!\n");
1463
1464     while (1)
1465         {
1466                 FD_ZERO(&readfds);
1467                 FD_SET(0, &readfds);
1468
1469                  ret = select(0 + 1, &readfds, NULL, NULL, NULL);
1470                 if (ret)
1471                  {
1472                      if (FD_ISSET(0, &readfds))
1473                          {
1474                               if(sat_read_key_input()<0)
1475                                         break;
1476                         }
1477                 }
1478          }
1479 }
1480
1481 void tapi_sat_thread()
1482 {
1483     fprintf(stderr,"start tapi_sat_thread\n");
1484         sat_select_loop();
1485         fprintf (stderr, " sat exited\n");
1486         pthread_exit(NULL);
1487 }
1488
1489 bool on_simatk_event_received (EvtSysEventSourceId_t src_id, const char* noti_id, GArray* parameters, void* local_data)
1490 {
1491         EvtSysEventProperty_t* e;
1492         int len;
1493         int reqid;
1494         int status;
1495         int group, type;
1496
1497         /*      Number of params must be 5      */
1498         assert(parameters->len == 5);
1499
1500         /*      First param is  tapi event group   */
1501         e = &g_array_index (parameters, EvtSysEventProperty_t, 0);
1502         assert(e->type ==  DBUS_TYPE_INT32);
1503         group = e->value.i;
1504         printf("received group is :%d\n", group);
1505
1506         /*      First param is  tapi event type   */
1507         e = &g_array_index (parameters, EvtSysEventProperty_t, 1);
1508         assert(e->type ==  DBUS_TYPE_INT32);
1509         type = e->value.i;
1510         printf("received event type is :%d\n", type);
1511
1512         e = &g_array_index (parameters, EvtSysEventProperty_t, 2);
1513         assert(e->type ==  DBUS_TYPE_INT32);
1514         reqid = e->value.i;
1515         printf("received Request ID is :%d\n", reqid);
1516
1517         e = &g_array_index (parameters, EvtSysEventProperty_t, 3);
1518         assert(e->type ==  DBUS_TYPE_INT32);
1519         status = e->value.i;
1520         printf("received STATUS is :%d\n", status);
1521
1522         /*      over allocate this after receiving the len  */
1523         unsigned char *data;
1524         unsigned char *result;
1525         size_t  out_len;
1526
1527         /*      Get the tapi event data  here   */
1528         e = &g_array_index (parameters, EvtSysEventProperty_t, 4);
1529         assert(e->type == DBUS_TYPE_STRING);
1530
1531         data = e->value.i;
1532
1533         len = strlen(data);
1534
1535         printf("Decoding..\n");
1536
1537         result = TAPI_BASE64_DECODE(data, len, &out_len);
1538
1539         app_callback(group, type, len, result);
1540         /*      clean the buffer        */
1541 //      memset(result2, NULL,  (sdata->len*2));
1542
1543         /* We've done with this notificaiton */
1544         return true;
1545
1546 }
1547
1548
1549 int sat_test_subscribe_tapi_events(void)
1550 {
1551
1552         //GMainLoop *mainloop;
1553         data_t sdata;
1554         noti_subscription_id_t subscription_id;
1555         int count = 0;
1556
1557         /*
1558         fprintf(stderr, " GMAIN LOOP\n");
1559
1560         if (! noti_init(&error_code))
1561         {
1562                 fprintf(stderr, "Error x_noti_init():%#X \n", error_code);
1563                 return -1;
1564         }
1565         printf("receive_tapi_event: noti init success\n");
1566
1567         */
1568         for(count =0;count<sizeof(ptrEvnts)/sizeof(*ptrEvnts);count++)
1569         {
1570                 error_code = EvtSysEventSubscribe (
1571                                                                                         EvtDeliveryHandle,
1572                                                                                         ptrEvnts[count],                                /* notification ID */
1573                                                                                         NULL,                                           /*      filter expression       */
1574                                                                                         on_simatk_event_received,               /* notification handler */
1575                                                                                         (void *)&sdata,                         /* local data */
1576                                                                                         &subscription_id                        /* subscription ID */
1577                                                                                 );
1578                 if (error_code )
1579                 {
1580                         fprintf(stderr, "Error x_noti_set_cb():%#X \n", error_code);
1581                 }
1582                 else
1583                         fprintf(stderr, "SIMATK-not subscribe ok for [%d]\n", count);
1584
1585 #if 0
1586
1587                 if (! noti_subscribe (
1588                                 ptrEvnts[count],                                /* notification ID */
1589                                 NULL,                                           /*      filter expression       */
1590                                 on_simatk_event_received,               /* notification handler */
1591                                 (void *)&sdata,                         /* local data */
1592                                 &subscription_id,                               /* subscription ID */
1593                                 &error_code))
1594                 {
1595                         fprintf(stderr, "Error x_noti_set_cb():%#X \n", error_code);
1596                 }
1597                 else
1598                         fprintf(stderr, "SIMATK-not subscribe ok for [%d]\n", count);
1599
1600 #endif
1601         }
1602
1603 /*
1604         printf("receive_tapi_event: noti subscribe is success\n");
1605
1606         mainloop = g_main_loop_new (NULL, FALSE);
1607
1608         g_main_loop_run (mainloop);
1609
1610         printf("receive_tapi_event: finish\n");
1611 */
1612         return 0;
1613
1614
1615 }
1616
1617
1618 int sat_main(int argc, char *argv[])
1619 {
1620         int ret=0;
1621         pthread_t sat_thread_id;
1622
1623         printf("\n\n\n ===== SAT TEST main* =====\n");
1624
1625         //ret=get_handle();
1626         //fprintf(stderr,"out of get handle\n");
1627
1628         ret = pthread_create(&sat_thread_id, NULL, &tapi_sat_thread, NULL);
1629
1630         if(ret != 0)
1631         {
1632                 fprintf(stderr, "Thread for TAPI Events Failed\n");
1633         }
1634
1635         sat_test_subscribe_tapi_events();
1636
1637         pthread_join(sat_thread_id, NULL);
1638
1639 }
1640