FactoryModeNFC.c
34.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* FactoryModeSrc.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file is Factory Mode NFC
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
******************************************************************************/
#include "MMI_features.h"
#ifdef __MMI_FACTORY_MODE__
#ifdef __MMI_FM_NFC_SUPPORT__
/*****************************************************************************
* Include Files
*****************************************************************************/
#include "MMIDataType.h"
#include "kal_general_types.h"
#include "GlobalResDef.h"
#include "custom_events_notify.h"
#include "MenuCuiGprot.h"
#include "inlineCuiGprot.h"
#include "wgui_categories_util.h"
#include "wgui_categories_popup.h"
#include "wgui_categories_text_viewer.h"
#include "AlertScreen.h"
#include "MMI_common_app_trc.h"
#include "mmi_rp_app_factorymode_def.h"
#include "FactoryModeGProt.h"
#include "FactoryModeConfig.h"
#include "FactoryModeProt.h"
#include "FactoryModeNFC.h"
/*****************************************************************************
* Define
*****************************************************************************/
/*****************************************************************************
* typedef enum/struct/...
*****************************************************************************/
/*****************************************************************************
* global val / function
*****************************************************************************/
extern MMI_ID g_fm_gourp_id;
extern mmi_fm_item_cntxt_struct *g_fm_contxt;
/*****************************************************************************
* static function
*****************************************************************************/
typedef struct
{
MMI_ID title_id;
MMI_BOOL is_show_stop;
}mmi_fm_nfc_progress_param_struct;
static mmi_fm_nfc_struct g_fm_nfc;
static mmi_fm_nfc_struct *g_fm_nfc_p = &g_fm_nfc;
static MMI_RET mmi_fm_nfc_proc(mmi_event_struct *param);
static void mmi_fm_nfc_select_hdlr(cui_menu_event_struct * evt);
static void mmi_fm_nfc_show_progress(MMI_STR_ID title_id, MMI_BOOL is_show_stop);
static MMI_RET mmi_fm_nfc_show_progress_scr_proc(mmi_event_struct *param);
static void mmi_fm_nfc_genaral_test_req(U32 msg_id);
static void mmi_fm_nfc_genaral_rsp(nfc_script_response *rsp);
static void mmi_fm_nfc_tag_uid_rw_req(void);
static void mmi_fm_nfc_tag_uid_rw_rsp(void *rsp);
static void mmi_fm_nfc_stop_req(void);
static void mmi_fm_nfc_req(nfc_msg_struct *newmsg);
static U8 mmi_fm_nfc_rsp(void *param);
static void mmi_fm_nfc_int_to_hex_string(WCHAR* buf, U32 len, U16 value);
static MMI_RET mmi_fm_nfc_tag_uid_show_scrn_proc(mmi_event_struct *param);
static void mmi_fm_nfc_card_mode(void);
static MMI_RET mmi_fm_nfc_card_mode_inline_proc(mmi_event_struct *param);
static void mmi_fm_nfc_card_mode_req(U32 opt);
static void mmi_fm_nfc_rd_atenna_req(void);
static void mmi_fm_nfc_exit_fm_req(void);
/*--------------- trace config --------------------------------------------*/
#define MMI_FM_NFC_TRACE(num, p1, p2,p3) MMI_FM_TRACE((MMI_FM_TRC_INFO,TRC_MMI_FM_NFC_PARAMS,num, p1, p2, p3))
#define MMI_FM_NFC_TRACE_0(num) MMI_FM_NFC_TRACE(num, 0, 0, 0)
#define MMI_FM_NFC_TRACE_1(num, p1) MMI_FM_NFC_TRACE(num, p1, 0, 0)
#define MMI_FM_NFC_TRACE_2(num, p1,p2) MMI_FM_NFC_TRACE(num, p1, p2, 0)
#define MMI_EM_NFC_TRACE_3 MMI_FM_NFC_TRACE
typedef enum
{
MMI_FM_NFC_TRC_REQ = 10000,
MMI_FM_NFC_TRC_RSP,
MMI_FM_NFC_TRC_TAG_UID_RSP,
MMI_FM_NFC_TRC_NUM_MAX
}mmi_fm_nfc_trc_num_enum;
/*---------------- trace config end --------------------------------------- */
/*only used for test by myself*/
//#define __MMI_FM_NFC_TEST__
#ifdef __MMI_FM_NFC_TEST__
static U32 mmi_fm_nfc_ut_test(void *param)
{
static U32 buf[100];
nfc_msg_struct *msg_rsp = (nfc_msg_struct *)buf;
nfc_script_response *scrip_rsp = (nfc_script_response *)(msg_rsp + 1);
mmi_fm_nfc_rsp(msg_rsp);
return 0;
}
#endif
#define MMI_FM_NFC_INLINE_CAP (CUI_INLINE_ITEM_ID_BASE + 1)
#define MMI_FM_NFC_INLINE_SEL (CUI_INLINE_ITEM_ID_BASE + 2)
static const cui_inline_item_caption_struct g_mmi_fm_nfc_card_mode_opt_cap =
{
STR_ID_FM_NFC_CARD_MODE_OPT
};
static const U16 g_mmi_fm_nfc_card_mode_opt_str[2] =
{
STR_ID_FM_NFC_CARD_MODE_OPT_SWP,
STR_ID_FM_NFC_CARD_MODE_OPT_NFC_WI
};
static const cui_inline_item_select_struct g_mmi_fm_nfc_card_mode_opt_select =
{
2,
0,
g_mmi_fm_nfc_card_mode_opt_str
};
static const cui_inline_set_item_struct g_mmi_em_nfc_card_mode_inline[2] =
{
{MMI_FM_NFC_INLINE_CAP, CUI_INLINE_ITEM_TYPE_CAPTION, 0, (void*)&g_mmi_fm_nfc_card_mode_opt_cap},
#ifdef __TOPWELL_MMI_INLINE_TO_LEFT_SCREEN__
{MMI_FM_NFC_INLINE_SEL, CUI_INLINE_ITEM_TYPE_SELECT |CUI_INLINE_ITEM_FULL_WIDTH, 0, (void*)&g_mmi_fm_nfc_card_mode_opt_select}
#else
{MMI_FM_NFC_INLINE_SEL, CUI_INLINE_ITEM_TYPE_SELECT, 0, (void*)&g_mmi_fm_nfc_card_mode_opt_select}
#endif
};
static const cui_inline_struct g_mmi_em_nfc_se_scrn =
{
sizeof(g_mmi_em_nfc_card_mode_inline) / sizeof (cui_inline_set_item_struct),
STR_ID_FM_NFC_CARD_MODE,
0,
CUI_INLINE_SCREEN_LOOP|CUI_INLINE_SCREEN_DISABLE_DONE,
0,
(const cui_inline_set_item_struct*)g_mmi_em_nfc_card_mode_inline
};
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_entry
* DESCRIPTION
* mmi_fm_nfc_entry
* PARAMETERS
* void
* RETURNS
* MMI_RET
*****************************************************************************/
extern mmi_fm_item_cntxt_struct *g_fm_contxt;
void mmi_fm_nfc_entry(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MMI_ID group_id;
MMI_ID cui_id;
mmi_fm_item_cntxt_struct *fm_context = g_fm_contxt; //mmi_fm_get_context();
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_FM_ASSERT(fm_context);
g_fm_nfc_p = &(fm_context->nfc);
#ifdef __MMI_FM_NFC_TEST__
mmi_frm_set_protocol_event_handler(MSG_ID_NFC_TEST_RSP, (PsIntFuncPtr)mmi_fm_nfc_ut_test, MMI_FALSE);
#else
mmi_frm_set_protocol_event_handler(MSG_ID_NFC_TEST_RSP, (PsIntFuncPtr)mmi_fm_nfc_rsp, MMI_FALSE);
#endif
if (!mmi_frm_group_is_present(GRP_ID_FM_ROOT))
{
mmi_frm_group_create(GRP_ID_ROOT, GRP_ID_FM_ROOT, 0, 0);
mmi_frm_group_enter(GRP_ID_FM_ROOT, MMI_FRM_NODE_SMART_CLOSE_FLAG);
}
group_id = mmi_frm_group_create(GRP_ID_FM_ROOT,
GRP_ID_FM_NFC,
mmi_fm_nfc_proc,
0);
mmi_frm_group_enter(group_id, MMI_FRM_NODE_SMART_CLOSE_FLAG);
cui_id = cui_menu_create(group_id,
CUI_MENU_SRC_TYPE_RESOURCE,
CUI_MENU_TYPE_APPSUB,
MENU_ID_FM_NFC,
MMI_TRUE,
0);
#if defined(__COSMOS_MMI_PACKAGE__)
SetKeyHandler(mmi_frm_scrn_close_active_id, KEY_BACK, KEY_EVENT_UP);
#endif /*__COSMOS_MMI_PACKAGE__*/
cui_menu_run(cui_id);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_proc
* DESCRIPTION
* mmi_fm_nfc_proc
* PARAMETERS
* param [IN]
* RETURNS
* MMI_RET
*****************************************************************************/
static MMI_RET mmi_fm_nfc_proc(mmi_event_struct *param)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
cui_menu_event_struct *evt = (cui_menu_event_struct *)param;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (param->evt_id)
{
case EVT_ID_CUI_MENU_LIST_ENTRY:
cui_menu_set_currlist_flags(evt->sender_id, CUI_MENU_NORMAL_LIST_WITH_NUMBERED_ICONS);
break;
case EVT_ID_CUI_MENU_ITEM_SELECT:
mmi_fm_nfc_select_hdlr(evt);
break;
case EVT_ID_CUI_MENU_CLOSE_REQUEST:
cui_menu_close(evt->sender_id);
break;
case EVT_ID_GROUP_DEINIT:
mmi_fm_nfc_exit_fm_req();
mmi_frm_set_protocol_event_handler(MSG_ID_NFC_TEST_RSP, NULL, MMI_FALSE);
g_fm_nfc_p = 0;
break;
default:
break;
}
return MMI_RET_OK;
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_select_hdlr
* DESCRIPTION
* mmi_fm_nfc_select_hdlr
* PARAMETERS
* evt [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_select_hdlr(cui_menu_event_struct * evt)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (evt->highlighted_menu_id)
{
case MENU_ID_FM_NFC_SWP_SELF_TEST:
mmi_fm_nfc_genaral_test_req(MSG_ID_NFC_SWP_SELF_TEST_REQ);
break;
case MENU_ID_FM_NFC_CANT_TEST:
mmi_fm_nfc_rd_atenna_req();
// mmi_fm_nfc_genaral_test_req(MSG_ID_NFC_ANTENNA_SELF_TEST_REQ);
break;
case MENU_ID_FM_NFC_TAG_UID_RW:
mmi_fm_nfc_tag_uid_rw_req();
break;
case MENU_ID_FM_NFC_CARD_MODE:
mmi_fm_nfc_card_mode();
break;
default:
break;
}
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_show_progress
* DESCRIPTION
* mmi_fm_nfc_show_progress
* PARAMETERS
* str_id [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_show_progress(MMI_STR_ID title_id, MMI_BOOL is_show_stop)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_fm_nfc_progress_param_struct *params;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
params = OslMalloc(sizeof(mmi_fm_nfc_progress_param_struct));
params->is_show_stop = is_show_stop;
params->title_id = title_id;
mmi_frm_scrn_create(GRP_ID_FM_NFC, SCR_ID_FM_NFC_SHOW_PROGRESS,mmi_fm_nfc_show_progress_scr_proc, (void*)params);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_show_progress_scr_proc
* DESCRIPTION
* mmi_fm_nfc_show_progress_scr_proc
* PARAMETERS
* param [IN]
* RETURNS
* void
*****************************************************************************/
static MMI_RET mmi_fm_nfc_show_progress_scr_proc(mmi_event_struct *param)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_fm_nfc_progress_param_struct *pp = (mmi_fm_nfc_progress_param_struct *)(param->user_data);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (param->evt_id)
{
case EVT_ID_SCRN_INIT:
mmi_frm_scrn_set_attribute(GRP_ID_FM_NFC, SCR_ID_FM_NFC_SHOW_PROGRESS, MMI_SCRN_ATTRIB_SMALL_SCRN);
break;
case EVT_ID_SCRN_DEINIT:
if (pp)
{
OslMfree(pp);
}
break;
case EVT_ID_SCRN_ACTIVE:
{
ShowCategory66Screen(
(U16)pp->title_id,
0,
0,
0,
(pp->is_show_stop ? STR_GLOBAL_STOP : 0),
0,
(PU8) get_string(STR_GLOBAL_PLEASE_WAIT),
mmi_get_event_based_image(MMI_EVENT_PROGRESS),
NULL);
break;
}
case EVT_ID_SCRN_GOBACK_IN_END_KEY:
return MMI_RET_KEY_HANDLED;
case EVT_ID_WGUI_RSK_CLICK:
{
if (pp->is_show_stop)
{
mmi_fm_nfc_stop_req();
}
return MMI_RET_KEY_HANDLED;
}
default:
break;
}
return MMI_RET_OK;
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_genaral_test_req
* DESCRIPTION
* mmi_fm_nfc_genaral_test_req
* PARAMETERS
* msg_id [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_genaral_test_req(U32 msg_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
nfc_script_request *nfc_script;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct) + sizeof(nfc_script_request));
newmsg->msg_type = msg_id;
newmsg->msg_length = sizeof(nfc_script_request);
nfc_script = (nfc_script_request *)((U8*)&(newmsg->msg_length) + 4);
nfc_script->type = 1;
nfc_script->action = 1;
mmi_fm_nfc_req(newmsg);
mmi_fm_nfc_show_progress(STR_ID_FM_NFC_TESTING, MMI_FALSE);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_genaral_rsp
* DESCRIPTION
* mmi_fm_nfc_genaral_rsp
* PARAMETERS
* rsp [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_genaral_rsp(nfc_script_response *rsp)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (rsp->result == MTK_NFC_SUCCESS)
{
/*success*/
mmi_popup_display_ext(STR_ID_FM_NFC_PASS, MMI_EVENT_SUCCESS, NULL);
}
else
{
mmi_popup_display_ext(STR_ID_FM_NFC_FAILED, MMI_EVENT_FAILURE, NULL);
}
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_tag_uid_rw_req
* DESCRIPTION
* mmi_fm_nfc_tag_uid_rw_req
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_tag_uid_rw_req(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
nfc_script_uid_request *uid_script;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct) + sizeof(nfc_script_uid_request));
newmsg->msg_type = MSG_ID_NFC_TAG_UID_RW_REQ;
newmsg->msg_length = sizeof(nfc_script_uid_request);
uid_script = (nfc_script_uid_request *)((U8*)&(newmsg->msg_length) + 4);
uid_script->type = 1;
uid_script->action = 1;
uid_script ->uid_length = 0;
uid_script->data[0] = 0;
mmi_fm_nfc_req(newmsg);
mmi_fm_nfc_show_progress(STR_ID_FM_NFC_TESTING, MMI_TRUE);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_tag_uid_rw_rsp
* DESCRIPTION
* mmi_fm_nfc_tag_uid_rw_rsp
* PARAMETERS
* rsp [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_tag_uid_rw_rsp(void *rsp)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_script_uid_response * uid_rsp = (nfc_script_uid_response *)rsp;
U32 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_FM_NFC_TRACE_2(MMI_FM_NFC_TRC_TAG_UID_RSP, uid_rsp->result, uid_rsp->uid_length);
if (uid_rsp->result == MTK_NFC_SUCCESS)
{
/*success*/
memset(g_fm_nfc_p->buf, 0, sizeof(g_fm_nfc_p->buf));
g_fm_nfc_p->buf[0] = '0';
g_fm_nfc_p->buf[1] = 'X';
for ( i = 0; i < uid_rsp->uid_length && i < MAX_UID_DATA_LEN; i++)
{
mmi_fm_nfc_int_to_hex_string(g_fm_nfc_p->buf + 2 + i * MMI_FM_NFC_UID_ELEMENT_LEN,
MMI_FM_NFC_UID_ELEMENT_LEN,
uid_rsp->data[i]);
}
mmi_frm_scrn_create(GRP_ID_FM_NFC,
SCR_ID_FM_NFC_SHOW_UID,
mmi_fm_nfc_tag_uid_show_scrn_proc,
g_fm_nfc_p);
}
else
{
mmi_popup_display_ext(STR_ID_FM_NFC_FAILED, MMI_EVENT_FAILURE, NULL);
}
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_stop_req
* DESCRIPTION
* tell MOD_NFC_APP to Stop Test
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_stop_req(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct));
newmsg->msg_type = MSG_ID_NFC_STOP_TEST_REQ;
newmsg->msg_length = 0;
mmi_fm_nfc_req(newmsg);
mmi_frm_scrn_close(GRP_ID_FM_NFC,SCR_ID_FM_NFC_SHOW_PROGRESS);
mmi_fm_nfc_show_progress(STR_ID_FM_NFC_STOPING, MMI_FALSE);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_int_to_hex_string
* DESCRIPTION
* translate a int number to hex string
* PARAMETERS
* buf [IN] where to save string
* len [IN] the length of buf, if buflen < string len, only save the buflen
* value [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_int_to_hex_string(WCHAR* buf, U32 len, U16 value)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 i, temp;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0; i< len; i++)
{
temp = value % 16;
if (temp < 10)
{
buf[len - i - 1] = temp + '0';
}
else
{
buf[len - i - 1] = temp - 10 + 'A';
}
value /= 16;
}
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_tag_uid_show_scrn_proc
* DESCRIPTION
* show uid screen proc function
* PARAMETERS
* param [IN]
* RETURNS
* void
*****************************************************************************/
static MMI_RET mmi_fm_nfc_tag_uid_show_scrn_proc(mmi_event_struct *param)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (param->evt_id)
{
case EVT_ID_SCRN_ACTIVE:
{
nfc_script_uid_response *rsp = (nfc_script_uid_response *)param->user_data;
mmi_frm_scrn_active_evt_struct *evt = (mmi_frm_scrn_active_evt_struct *)param;
ShowCategory78Screen(STR_ID_FM_NFC_TAG_UID_RW,
0,
0,
0,
STR_GLOBAL_BACK,
0,
0,
(U8*)g_fm_nfc_p->buf,
(S32)UID_DATA_LEN * 5,
evt->gui_buffer);
break;
}
case EVT_ID_SCRN_GOBACK_IN_END_KEY:
break;
default:
break;
}
return MMI_RET_OK;
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_req
* DESCRIPTION
* send nfc request to MOD_NFC_APP
* PARAMETERS
* newmsg [IN]
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_req(nfc_msg_struct * newmsg)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_FM_NFC_TRACE_1(MMI_FM_NFC_TRC_REQ, newmsg->msg_type);
mmi_frm_send_ilm(MOD_NFC, MSG_ID_NFC_TEST_REQ, (oslParaType*)newmsg, NULL);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_card_mode
* DESCRIPTION
* entry nfc card mode test
* PARAMETERS
* void
* RETURNS
* MMI_RET
*****************************************************************************/
static void mmi_fm_nfc_card_mode(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MMI_ID group_id;
MMI_ID inline_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
group_id = mmi_frm_group_create_ex(GRP_ID_FM_NFC,
GRP_ID_AUTO_GEN,
mmi_fm_nfc_card_mode_inline_proc,
0,
MMI_FRM_NODE_SMART_CLOSE_FLAG);
inline_id = cui_inline_create(group_id, &g_mmi_em_nfc_se_scrn);
cui_inline_run(inline_id);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_card_mode_inline_proc
* DESCRIPTION
* nfc card mode inline cui proc
* PARAMETERS
* param
* RETURNS
* MMI_RET
*****************************************************************************/
static MMI_RET mmi_fm_nfc_card_mode_inline_proc(mmi_event_struct *param)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
cui_event_inline_common_struct *evt = (cui_event_inline_common_struct *)param;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (param->evt_id)
{
case EVT_ID_CUI_INLINE_ABORT:
cui_inline_close(evt->sender_id);
break;
case EVT_ID_CUI_INLINE_SUBMIT:
{
U32 opt = 0;
cui_inline_get_value(evt->sender_id, MMI_FM_NFC_INLINE_SEL, &opt);
mmi_fm_nfc_card_mode_req(opt + 1);
cui_inline_close(evt->sender_id);
break;
}
default:
break;
}
return MMI_RET_OK;
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_card_mode_req
* DESCRIPTION
* nfc card mode req
* PARAMETERS
* opt [IN] 1 ->"SWP", 2 -> "NFC-WI"
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_card_mode_req(U32 opt)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
nfc_script_request *nfc_script;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct) + sizeof(nfc_script_request));
newmsg->msg_type = MSG_ID_NFC_CARD_MODE_TEST_REQ;
newmsg->msg_length = sizeof(nfc_script_request);
nfc_script = (nfc_script_request *)(newmsg + 1);
nfc_script->type = opt;
nfc_script->action = 1;
mmi_fm_nfc_req(newmsg);
mmi_fm_nfc_show_progress(STR_ID_FM_NFC_TESTING, MMI_FALSE);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_rd_atenna_req
* DESCRIPTION
* nfc atenna request
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_rd_atenna_req(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
nfc_antenna_request *req;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct) + sizeof(nfc_antenna_request));
newmsg->msg_type = MSG_ID_NFC_ANTENNA_SELF_TEST_REQ;
newmsg->msg_length = sizeof(nfc_antenna_request);
req = (nfc_antenna_request *)((newmsg + 1));
req->action = 1;
mmi_fm_nfc_req(newmsg);
mmi_fm_nfc_show_progress(STR_ID_FM_NFC_TESTING, MMI_FALSE);
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_rsp
* DESCRIPTION
* nfc response handler
* PARAMETERS
* param [IN]
* RETURNS
* U8
*****************************************************************************/
static U8 mmi_fm_nfc_rsp(void *param)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *rsp = (nfc_msg_struct *)param;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (rsp)
{
MMI_FM_NFC_TRACE_2(MMI_FM_NFC_TRC_RSP, MMI_TRUE, rsp->msg_type);
switch (rsp->msg_type)
{
case MSG_ID_NFC_P2P_MODE_TEST_RSP:
case MSG_ID_NFC_SWP_SELF_TEST_RSP:
case MSG_ID_NFC_ANTENNA_SELF_TEST_RSP:
case MSG_ID_NFC_CARD_MODE_TEST_RSP:
mmi_fm_nfc_genaral_rsp((nfc_script_response *)(rsp + 1));
mmi_frm_scrn_close(GRP_ID_FM_NFC,SCR_ID_FM_NFC_SHOW_PROGRESS);
break;
case MSG_ID_NFC_TAG_UID_RW_RSP:
mmi_fm_nfc_tag_uid_rw_rsp((nfc_script_uid_response*)(rsp+1));
mmi_frm_scrn_close(GRP_ID_FM_NFC,SCR_ID_FM_NFC_SHOW_PROGRESS);
break;
case MSG_ID_NFC_STOP_TEST_RSP:
mmi_frm_scrn_close(GRP_ID_FM_NFC,SCR_ID_FM_NFC_SHOW_PROGRESS);
break;
default:
break;
}
}
else
{
MMI_FM_NFC_TRACE_1(MMI_FM_NFC_TRC_RSP, MMI_FALSE);
mmi_popup_display_ext(STR_ID_FM_NFC_FAILED, MMI_EVENT_FAILURE, NULL);
}
return 0;
}
/*****************************************************************************
* FUNCTION
* mmi_fm_nfc_exit_fm_req
* DESCRIPTION
* when fm nfc exit, send exit message to NFC driver
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
static void mmi_fm_nfc_exit_fm_req(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
nfc_msg_struct *newmsg;
nfc_exit_request *req;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
newmsg = OslConstructDataPtr(sizeof(nfc_msg_struct) + sizeof(nfc_exit_request));
newmsg->msg_type = MSG_ID_NFC_EXIT_EMFM;
newmsg->msg_length = sizeof(nfc_exit_request);
req = (nfc_exit_request *)((newmsg + 1));
req->type = 2;
mmi_fm_nfc_req(newmsg);
}
#endif /*__MMI_FM_NFC_SUPPORT__*/
#endif /* __MMI_FACTORY_MODE__ */