-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathat_qlinkdatanode.c
13415 lines (11060 loc) · 394 KB
/
at_qlinkdatanode.c
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
996
997
998
999
1000
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <pthread.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <poll.h> // poll
#include <sys/file.h> // flock
#include "common_qlinkdatanode.h"
#include "event_qlinkdatanode.h"
#include "at_rsp_qlinkdatanode.h"
#include "qmi_parser_qlinkdatanode.h"
#include "qmi_sender_qlinkdatanode.h"
#include "queue_qlinkdatanode.h"
#include "protocol_qlinkdatanode.h"
#include "feature_macro_qlinkdatanode.h"
#include "at_qlinkdatanode.h"
#include "socket_qlinkdatanode.h" // Udp_Config
#include "msq_qlinkdatanode.h"
#ifndef FEATURE_ENABLE_AT_qlinkdatanode_C_LOG
#define LOG print_to_null
#endif
#define CSQ_REPETITION_TIMES (10)
#define CGREG_REPETITION_TIMES (10)
#define CIPOPEN_REPETITION_TIMES (5)
/******************************External Functions*******************************/
extern void notify_UimSender(char opt);
extern void notify_NasSender(char opt);
extern void notify_DmsSender(char opt);
extern void notify_EvtLoop(const char msg);
extern void push_ChannelNum(const int chan_num);
extern void push_flow_state(const rsmp_state_s_type fs);
extern void push_thread_idx(const Thread_Idx_E_Type tid);
extern void msq_send_online_ind(void);
extern void msq_send_offline_ind(void);
extern void msq_send_pd_rsp(void);
extern void msq_send_custom_at_rsp(void);
extern void msq_send_pd_msg_to_srv(void);
extern void msq_send_qlinkdatanode_run_stat_ind(int evt);
extern void msq_send_imsi_ind(char opt);
extern void msq_send_dev_rst_req(int msg);
extern int gpio_set_value(const unsigned int gpio, const unsigned int value);
extern void gpio_mdmEmodem_startup(void);
extern void gpio_mdmEmodem_shutdown(void);
extern void gpio_mdmEmodem_shutdown_ext(void);
extern void gpio_mdmEmodem_pwr_sw_init(void);
extern void gpio_mdmEmodem_uart_keep_awake(void);
extern int gpio_mdmEmodem_check_if_awake(void);
extern int gpio_mdmEmodem_check_startup(void);
extern void gpio_mdmEmodem_reboot(void);
extern void gpio_mdmEmodem_restart_pwr_ctrl_oper(void);
extern void set_ChannelNum(const int val);
extern int get_ChannelNum(void);
extern Acq_Data_State get_acq_data_state(void);
extern int check_acq_data_state(Acq_Data_State state);
extern void clr_all_rsp_timers(void);
extern void clr_idle_timer(void);
extern void clr_ApduRsp_ext_timer(void);
extern void clr_ID_auth_rsp_timer(void);
extern void clr_remote_USIM_data_rsp_timer(void);
extern void clr_timeout_evt(Evt *tev);
extern void clr_power_down_notification_timer(void);
extern void clr_ate0_rsp_timer(void);
extern void clr_pdp_check_act_routine_timer(void);
extern int check_rsp_timers(void);
extern int check_pdp_act_check_routine_timer(void);
extern int check_idle_timer(void);
extern int check_apdu_rsp_timeout_ext_timer(void);
extern int check_id_auth_rsp_timeout_timer(void);
extern int check_remote_USIM_data_rsp_timeout_timer(void);
extern int check_custom_timer(void);
extern void queue_clr_apdu_node(void);
extern void queue_clr_stat_inf_node(void);
extern int queue_check_if_node_valid(void);
extern void sock_update_reg_urc_state(Reg_URC_State_E_Type state);
extern void print_fmt_data(char *str);
extern int proto_update_flow_state(rsmp_state_s_type state);
extern rsmp_protocol_type proto_get_req_cfg_data_type(rsmp_transmit_buffer_s_type *);
extern void get_dev_and_net_info_for_status_report_session(void);
extern void update_net_info(int tag, int opt1, int opt2, int opt3);
extern void net_info_processor(char pre_cond, Net_Info cur_ni);
extern int write_file(const char *path, unsigned int offset, char *data);
extern Thread_Idx_E_Type get_thread_idx(void);
extern void add_timer_mdmEmodem_idle_timeout(char opt);
extern void notify_RstMonitor(char msg);
/******************************External Variables*******************************/
extern rsmp_transmit_buffer_s_type g_rsmp_transmit_buffer[THD_IDX_MAX+1];
extern rsmp_recv_buffer_s_type g_rsmp_recv_buffer;
extern APDU_Setting APDU_setting;
extern bool isUimPwrDwnMssage;
#ifdef FEATURE_ENABLE_MDMEmodem_CUSTOMED_AT_CMD
extern Proc_Msg_At_Cmd_Cfg_S_Type proc_msg_at_config;
#endif
extern rsmp_control_block_type flow_info;
extern Dev_Info sim5360_dev_info;
extern Dev_Info rsmp_dev_info;
extern Net_Info rsmp_net_info;
extern bool isQueued;
extern bool isProcOfInitApp;
extern bool isOnlineMode;
extern bool isMdmEmodemRunning;
extern bool isMdmEmodemPwrDown;
extern bool isFTMPowerOffInd;
extern bool isPwrDwnRspAcq;
extern bool isWaitToPwrDwn;
extern bool isRstReqAcq;
extern bool isRegOffForPoorSig;
extern bool isMifiConnected;
extern bool isRegOn;
#ifdef FEATURE_ENABLE_TIMER_SYSTEM
extern bool isApduRspExtTimerExpired;
extern bool isIdAuthRspTimerExpired;
extern bool isRemoteUsimDataRspTimerExpired;
extern bool isPwrDwnNotificationTimerExpired;
extern bool isAte0RspTimerExpired;
#endif // FEATURE_ENABLE_TIMER_SYSTEM
extern bool isEnableManualApdu;
#ifdef FEATURE_ENABLE_MDMEmodem_CUSTOMED_AT_CMD
extern bool isMdmEmodemControledByYydaemon;
extern bool isYYDaemonNeedtoSendATCmd;
extern bool isFactoryWriteIMEI5360;
#endif //FEATURE_ENABLE_MDMEmodem_CUSTOMED_AT_CMD
extern bool PowerUpUsimAfterPowerDown;
extern bool PowerUpUsimAfterRecvingUrcRpt;
extern bool isNeedToSendOutReq0x65;
extern bool isATEvtAct;
extern bool isMdm9215CpinReady;
extern bool isSockListenerRecvPdpActMsg;
extern bool isCipsendFailedV01;
extern int ChannelNum;
#ifdef FEATURE_ENABLE_RWLOCK_CHAN_LCK
extern pthread_rwlock_t ChannelLock;
#else
extern pthread_mutex_t ChannelLock;
#endif
extern bool is1stRunOnMdmEmodem;
extern pthread_mutex_t i1r_mtx;
extern int EvtLoop_2_Listener_pipe[2];
extern pthread_mutex_t el_req_mtx;
extern pthread_cond_t el_req_cnd;
extern bool el_reqed;
extern bool isUimActed;
extern pthread_mutex_t act_uim_mtx;
extern pthread_cond_t act_uim_cond;
extern int dms_inf_acqed;
extern pthread_mutex_t acq_dms_inf_mtx;
extern pthread_cond_t acq_dms_inf_cnd;
extern bool isRstingUsim;
extern bool isUimRstOperCplt;
extern pthread_mutex_t rst_uim_mtx;
extern pthread_cond_t rst_uim_cond;
extern bool isUimPwrDwn;
extern int nas_inf_acqed;
extern pthread_mutex_t acq_nas_inf_mtx;
extern pthread_cond_t acq_nas_inf_cnd;
extern bool isUMTSOnlySet;
extern pthread_mutex_t evtloop_mtx;
extern pthread_mutex_t log_file_mtx;
extern char URC_special_mark_array[MAX_SPEC_URC_ARR_LEN];
extern int StatInfReqNum;
extern unsigned int StatInfMsgSn;
extern pthread_mutex_t apdu_sender_mtx;// 20160304 jackli
extern pthread_cond_t apdu_sender_cond;// 20160304 jackli
extern pthread_mutex_t apdu_mtx; // 20160304 jackli
extern bool isApduSentToMdm;// 20160304 jackli
extern int DMS_wr_fd;
extern int qlinkdatanode_run_stat;
#ifdef FEATURE_ENABLE_OUT_OF_TRAFFIC_AND_DATE_0206
extern int BaseTimeOutDate(void);
#endif
#ifdef FEATURE_ENABLE_OUT_OF_TRAFFIC_AND_DATE_0206
extern int msqSendToTrafficAndDateYydaemon(char versionf,long long fluRate);
#endif
#ifdef FEATURE_ENABLE_Emodem_SET_TIME_DEBUG
extern rsp_cclk_time_type rsp_Emodemcclk_ime;
#endif
/******************************Local Variables*******************************/
static const char *InitUnsols[] = {
"START",
"+CPIN: READY",
"OPL UPDATING",
"PNN UPDATING",
"SMS DONE",
"CALL READY",
"PB DONE"
};
static const int InitUnsolLen[] = {
sizeof("START"),
sizeof("+CPIN: READY"),
sizeof("OPL UPDATING"),
sizeof("PNN UPDATING"),
sizeof("SMS DONE"),
sizeof("CALL READY"),
sizeof("PB DONE")
};
static int timeoutCount = 0;
static int CSQCount = 0;
static int CGREGCount = 0;
static int CIPOPENCount = 0;
static const char PeerClosedUnsol[] = {"+CIPCLOSE: 0,1"};
static const char NetClosedUnsol[] = {"+CIPEVENT: NETWORK CLOSED UNEXPECTEDLY"};
static const char *ChkNetAT[] = {
"ATE0",
"AT+CSQ",
"AT+CGREG?",
"AT+CNMP?",
"AT+CNMP=2"
};
static const int ChkNetATLen[] = {
sizeof("ATE0"),
sizeof("AT+CSQ"),
sizeof("AT+CGREG?"),
sizeof("AT+CNMP?"),
sizeof("AT+CNMP=2")
};
static const char *ConfAT[] = {
"AT",
"AT+IFC=2,2",
"AT+IPR=460800",
"AT"
};
static const int ConfATLen[] = {
sizeof("AT"),
sizeof("AT+IFC=2,2"),
sizeof("AT+IPR=460800"),
sizeof("AT")
};
static char *AcqDataAT[] = {
"AT",
"AT+NETOPEN",
#ifdef FEATURE_ENABLE_EmodemUDP_DEBUGDEBUGDEBUG
"AT",
"AT+CIPCLOSE=",
#endif
"AT+CIPOPEN",
"AT+CIPSEND",
"AT+CGSN",
"AT+COPS=3,2",
"AT+COPS?",
#ifdef FEATURE_ENABLE_CPOL_CONFIG
"AT+CPOL=",
"AT+CPOL=",
#endif
#ifdef FEATURE_ENABLE_Emodem_SET_TIME_DEBUG
"AT+CCLK?",
#endif
"AT+CGREG=2",
"AT+CGREG?",
"AT+CGREG=0",
"AT+CATR=3",
"AT+CATR=0"
};
static char device_path[MAX_DEV_PATH_CHARS] = {'\0'};
//NOTE: At first, server_addr contains whole server address including port string.
// Then it will only contain server IP address.
static char ATBuf[AT_BUF_LEN];
static char *ATBufCur = ATBuf;
static char *line_head = ATBuf; //Add by rjf, not original
//Funtion:
//If mdmEmodem startup messages are all released by mdmEmodem(no matter received or not),
//it will be set false.
static bool isProcOfRecvInitInfo = true;
//Function:
//Once one piece of mdmEmodem startup messages have been caught by app, it will be set true.
static bool isInitInfoRecved = false;
static int isRetryToRecv = 0;
static int URC_header_len = 0;
// Recv beginning data and store them into recv_tmp_buf.
static char recv_tmp_buf[128];
static char URC_data[50];
static int URC_header_len_of_remote_UIM_data = 0;
//If a TCP URC header seperates apart to several lines, it will be used to store last recv_len value.
//It will be updated outside reader_recv_start().
static int last_recv_len = 0;
//Description:
//According to acq_data_state or suspend_state, it is for AT+CIPOPEN or AT+CIPCLOSE.
static bool isWaitRspError = false;
//Description:
//0x01: CIPERROR: 0,2 recved.
//0x02: CIPERROR: 0,4 recved.
//0x03: +IP ERROR: Network is already opened recved.
static char error_flag = 0x00;
#ifdef FEATURE_CONFIG_SIM5360
static bool isSIM5360BasicInfoAcqed = false;
static char *mfg_inf_buf = NULL;
static int mfg_inf_buf_offset = 0;
static bool isSIM5360PdpContextSet = false;
static bool isSIM5360PdpContAcqed = false;
static char *pdp_ctx_inf_buf = NULL;
static int pdp_ctx_inf_buf_offset = 0;
#endif // FEATURE_CONFIG_SIM5360
//Description:
// Mark if the rsp string "ERROR" found when "+NETCLOSE: 9" recved.
static bool isNetclose9Recved = false;
//Description:
// In acq_data_state of ACQ_DATA_STATE_CIPSEND_1, URC rpt "IPCLOSE: X" is recved. Then this bool var
// will be set true to wait for sebsequent URC rpt "+CIPERROR: Y" to avoid checking ChannelNum.
static bool isWaitForRptCIPERROR = false;
//Description:
// If this bool var is false, it doesn't mean the USIM of mdmEmodem is not available. It is applied for encountering the
// "+CGREG: 0" or "+CGREG: 2" when app is checking registration of mdmEmodem.
static bool isSIM5360CpinReady = false;
#ifdef FEATURE_ENABLE_MDMEmodem_REATTACH_ONCE_WHEN_REGISTRATION_FAILED
static bool isMdmEmodemReattachedWhenRegFailed = false;
#endif // FEATURE_ENABLE_MDMEmodem_REATTACH_ONCE_WHEN_REGISTRATION_FAILED
#ifdef FEATURE_ENABLE_qlinkdatanode_RUN_STAT_IND
//Description:
// If "AT+CSQ?" is executed and rssi of rsp is less than 4, app will send a notificaiton to
// process yy_daemon about it. And this var is to reduce redundant notifications to yy_daemon.
static bool isPoorSigNotified = false;
#endif
#ifdef FEATURE_ENHANCED_qlinkdatanode_RUN_STAT_IND
//Description:
// If "AT+CGREG?" is executed and reg stat of rsp is neither 1 nor 5, app will send a notificaiton to
// process yy_daemon about it. And this var is to reduce redundant notifications to yy_daemon.
static bool isNotRegNotified = false;
//Description:
// If "AT+NETOPEN" is executed and pdp is not activiated then, app will send a notificaiton to
// process yy_daemon about it. And this var is to reduce redundant notifications to yy_daemon.
static bool isPdpNotActNotified = false;
//Description:
// If "AT+CIPOPEN=..." is executed and serv conn is not built properly, app will send a notificaiton to
// process yy_daemon about it. And this var is to reduce redundant notifications to yy_daemon.
static bool isServDisconnNotified = false;
#endif
static pthread_mutex_t standby_switch_mtx = PTHREAD_MUTEX_INITIALIZER;
//Description:
//This is var is set true when no available SIM card for mdmEmodem.
bool isNotNeedIdleTimer = false;
#ifdef FEATURE_ENABLE_REQ_RETRAN_SYS_FOR_ID_AUTH_REJ
static int id_auth_req_retran_times = 0;
#endif
/******************************Global Variables*******************************/
unsigned char g_qlinkdatanode_run_status_01= 0x00;
unsigned char g_qlinkdatanode_run_status_02 = 0x00;
bool g_qlinkdatanode_run_status_03 = false;
bool g_disable_send_downloadSimcard_req = false;
int g_isEmodemcipopen_vaid = 0;
bool g_isEmodemipclose_report = false;
bool g_isat_command_AT = false;
// 20160928 by jackli
#ifdef FEATURE_ENABLE_EmodemUDP_LINK
static unsigned char g_EmodemUdpTcp_socket_linkCount = 2;
bool g_EmodemUdp_socket_link = false;
bool g_EmodemTcp_socket_link = false;
bool g_isip1_use = false;
bool g_isip2_use = false;
bool g_EmodemUdp_flag= false;
bool g_EmodemUdp_link_server_state = false;
bool g_enable_EmodemUdp_link = true;
bool g_enable_EmodemTCP_link = true;
static unsigned char g_enable_EmodemUdp_linkcount = 0;
char Udp_IP_addr[16]={0};
unsigned int udp_server_port = 0;
char Udp_IP_addr_default1[16]={0};
unsigned int udp_server_port_default1 = 0;
char Udp_IP_addr_default2[16]={0};
unsigned int udp_server_port_default2 = 0;
char Udp_IP_addr_default3[16]={0};
unsigned int udp_server_port_default3 = 0;
unsigned int tcp_server_port = 0;
char tcp_IP_addr[16]={0};
unsigned int tcp_server_port_2 = 0;
char tcp_IP_addr_2[16]={0};
unsigned int tcp_server_port_update = 0;
char tcp_IP_addr_update[16]={0};
unsigned char apnMessageBuff[200]={0};
unsigned char g_enable_TCP_IP01_linkcount = 0;
unsigned char g_enable_TCP_IP02_linkcount = 0;
bool g_IdcheckRspis_F3 = false;
#endif
#ifdef FEATURE_ENABLE_F9_CIPCLOSE
bool g_closesocket_F9 = false;
#endif
#ifdef FEATURE_ENABLE_EmodemUDP_DEBUGDEBUGDEBUG
// int g_Emodemcipopen_link_mode_udp = -1;
#endif
unsigned char g_record_ID_timeout_conut = 0;
#ifdef FEATURE_ENABLE_SFOTCARD_DEBUG_1229DEBUG
unsigned char g_SoftcardFlowState = SOFT_CARD_STATE_FLOW_DEFAULT;
char keybuf[8] = {0};
unsigned int g_randGetkey = 0;
char keybuf_des[8] = {0};
char server_des_ki[16] = {0};
char server_des_opc[16] = {0};
//char server_des_ki_backup[16] = {0};
#endif
unsigned char g_is7100modemstartfail = 0;
#ifdef FEATURE_ENABLE_CONTRL_EmodemREBOOT_0117DEBUG
unsigned char g_is7100modem_register_state = 0;
#endif
char RespArray[256] = {0};
char IP_addr[16]= {0};
int server_port = 0;
#ifdef FEATURE_ENABLE_TIMER_SYSTEM
Evt ate0_rsp_timeout_evt;
Evt ApduRsp_timeout_ext_evt;
Evt ID_auth_rsp_timeout_evt;
Evt remote_USIM_data_rsp_timeout_evt;
Evt power_down_notification_timeout_evt;
Evt Idle_Timer_evt;
Evt pdp_act_check_routine_evt;
Evt Custom_Timer_evt;
#endif //FEATURE_ENABLE_TIMER_SYSTEM
At_Config at_config =
{-1,
{NULL, NULL, -1, -1, false, {0, 0}, NULL, NULL},
#ifdef FEATURE_ENABLE_TIMER_SYSTEM
{NULL, NULL, -1, -1, false, {0, 0}, NULL, NULL},
#endif
{-1, "\0", "\0", -1, 0},
};
Chk_Net_State chk_net_state = CHK_NET_STATE_IDLE;
Conf_State uartconfig_state = CONF_STATE_IDLE;
Acq_Data_State acq_data_state = ACQ_DATA_STATE_IDLE;
pthread_mutex_t acq_data_state_mtx = PTHREAD_MUTEX_INITIALIZER;
Suspend_Mdm_State suspend_state = SUSPEND_STATE_IDLE;
#ifdef FEATURE_CONFIG_SIM5360
Acq_Mfg_Inf_State_E_Type acq_mfg_inf_state = ACQ_MFG_INF_STATE_IDLE;
Check_Pdp_Ctx_State_E_Type check_pdp_ctx_state = CHECK_PDP_CTX_STATE_MIN;
Set_Pdp_Ctx_State_E_Type set_pdp_ctx_state = SET_PDP_CTX_STATE_MIN;
#endif
//Description:
// Once "+IPCLOSE: 0,1" recved, it will be set true to control r_suspendMdmHdlr().
// It is for mdmEmodem.
bool isServConnClosed = false;
//Description:
//It is for 2nd-or-more-time ID auth msg.
bool isSendIdAfterAcqIMSI = false;
//Description:
// Each time wake up mdmEmodem and send out a dequeued req, it need to be after sending
// out ID auth msg to server. If such a dequeued req existed, isNeedToDequeueAfterIdAuth
// will be set true.
//bool isNeedToDequeueAfterIdAuth = false;
//Description:
// It tells app to upload status info to server.
bool isNeedToNotifyServCondVar = false;
//Description:
// It tells app to send ID authentication msg to server.
bool isNeedToSendIDMsg = false;
bool isWaitToSusp = false;
//Description:
//When app need to cancel the suspension of mdmEmodem, this bool var will be set true.
bool isTermSuspNow = false;
//Description:
//When app is trying to recover the server connection, like registration has fell off, ChannelNum equals
// 2 (i.e. The app is suspending mdmEmodem at this moment.). Then this bool var will be set true to help restore
//the server connection of mdmEmodem.
bool RcvrMdmEmodemConnWhenSuspTerm = false;
//Description:
//If mdmEmodem is at standby mode, the operation of waking up it and building up the server connection is called
//"Resume".
//If mdmEmodem is awake, the operation of restoring the server connection is called "Recover" (i.e. rcv.).
bool isWaitToRcvr = false;
//Description:
//Its typical operation is that terminate the current recovering process and start a new recovering process. (Because
//app encountered a registration fall during the go-to-terminate recovering process .)
bool isTermRcvrNow = false;
//Description:
//When app recved the inds of that reg is searching or sth, it needs to recover the serv conn of mdmEmodem. But at this moment,
//the isRegOffForPoorSig or some other related vars might not be set true. In order to recover the serv conn after the normal
//process of suspension, this bool var will be true. And it will be set false in r_suspendMdmHdlr when isRegOffForPoorSig equals
//true.
bool RcvrMdmEmodemConn = false;
#ifdef FEATURE_ENABLE_TIME_ZONE_IN_ID_CHECK
Time_Zone_S timezone_qlinkdatanode;
#endif
#ifdef FEATURE_ENABLE_LIMITFLU_FROM_SERVER
Flu_limit_control flucontrol_server;
#endif
#ifdef FEATURE_ENABLE_OUT_OF_TRAFFIC_AND_DATE_0206
trafficFromServercontrol trafficDataServer;
bool isBookMode= false;
bool isCancelRecoveryNet= false;
#endif
#ifdef FEATURE_ENABLE_STSRT_TEST_MODE
bool isTestMode= false;
bool isPdpActive= false;
#endif
//Description:
//No matter if APDU is cmd or rsp, if this var is defined, they will be all dumped.
//If APDU rsp timed out and APDU was sent out, recved 1 APDU rsp would be dumped.
//And this would be only one invalid APDU rsp after APDU rsp timed out.
bool isDumpApdu = false;
//Description:
//It is for the situation where ChannelNum is -1 or 4 in ApduRsp_timeout_ext_cb().
bool MdmEmodemIsRcvrWhenSetPd = false;
//Description:
//It is for syncing sock thread and at thread.
pthread_mutex_t pd_mtx = PTHREAD_MUTEX_INITIALIZER;
#ifdef FEATURE_ENABLE_3GONLY
bool isneedtoset3Gonly = false;
#endif
#ifdef FEATURE_ENABLE_4G3GAUTO_FOR_US
bool isneedtoset4G3Gauto = false;
#endif
unsigned int MdmEmodemCountryType = 0;
unsigned int MdmEmodemMCCMNC= 0;
#ifdef FEATURE_ENABLE_CPOL_CONFIG
unsigned char atCmdCpolbuf[100];
typedef struct{
char *psmcc;
char *psmnc;
char *pscountry;
unsigned char ucnet_quantity;
}ST_NET_TPYE;
typedef struct{
unsigned char cbit;
char *pcops;
}ST_EmodemDEFAULT_CONFIG;
ST_EmodemDEFAULT_CONFIG cops_Emodem_list[]={
{1,"20404"},{2,"26202"},{3,"23415"},{4,"50503"},{5,"20810"},
{6,"22210"},{7,"23201"},{8,"65501"},{9,"21401"},{10,"53001"},
{11,"22801"},{12,"27201"},{13,"310410"},{14,"45005"},{15,"46001"},
{16,"40420"},{17,"40411"},{18,"40427"},{19,"40405"},{20,"40446"},
{21,"40443"},{22,"40430"},{23,"26001"},{24,"44010"},{25,"20601"},
{26,"24201"},{27,"27077"},{28,"26801"},{29,"302220"},{30,"302610"},
{31,"60202"},{32,"24008"},{33,"23801"},{34,"52505"},{35,"52099"},
{36,"51011"},{37,"72405"},{38,"25001"},{39,"21670"},{40,"23003"},
{41,"28602"},{42,"63902"},{43,"24405"},{44,"20205"},{45,"50219"},
{46,"334020"},{47,"42501"},{48,"60402"},{49,"41302"},{50,"22601"},
{51,"27801"},{52,"722310"},{53,"Emodem2"},{54,"51503"},{55,"29340"},
{56,"71610"},{57,"21902"},{58,"23101"},{59,"42702"},{60,"41902"},
{61,"22005"},{62,"42602"},{63,"46692"},{64,"28401"},{65,"45205"},
{66,"748010"},{67,"714003"},{68,"27402"},{69,"27602"},{70,"42001"},
{71,"732123"},{72,"45403"},{73,"73001"},{74,"25501"},{75,"42403"},
};
ST_NET_TPYE snetconfig_Emodem[]={
{"457","03","Lao People's Democratic Republic",2},//Row Tier 1
{"457","08","Lao People's Democratic Republic",2},//RoW Tier 5
{"525","05","Singapore",3},// StarHub Preferred Partners
{"525","03","Singapore",3},// M1 Row Tier 1
{"525","01","Singapore",3},//SingTel RoW Tier 2
// {"310","470","Guam",3},//Row Tier 5
// {"310","140","Guam",3},//Row Tier 5
// {"310","370","Guam",3},//RoW Tier 5
{"454","03","Hong Kong",8},//Preferred Partners
{"454","04","Hong Kong",8},//Preferred Partners
{"454","16","Hong Kong",8},//Row Tier 1
{"454","19","Hong Kong",8},//RoW Tier 1
{"454","06","Hong Kong",8},//Row Tier 1
{"454","12","Hong Kong",8},//RoW Tier 2
{"454","00","Hong Kong",8},//Row Tier 5
{"454","10","Hong Kong",8},//RoW Tier 5
{"460","00","China",2},//Preferred Partners
{"460","01","China",2},//RoW Tier 1
{"286","02","Turkey",3},//Vodafone networks
{"286","03","Turkey",3},//RoW Tier 1
{"286","01","Turkey",3},//RoW Tier 3
{"250","01","Russian Federation",6},//Preferred Partners
{"250","02","Russian Federation",6},//Row Tier 3
{"250","99","Russian Federation",6},//Row Tier 5
{"250","35","Russian Federation",6},//Row Tier 5
{"250","03","Russian Federation",6},//Row Tier 5
{"250","39","Russian Federation",6},//RoW Tier 5
{"302","610","Canada",6},//Preferred Partners
{"302","720","Canada",6},//Preferred Partners
{"302","780","Canada",6},//Preferred Partners
{"302","220","Canada",6},//Preferred Partners
{"302","500","Canada",6},//RoW Tier 1
{"302","320","Canada",6},//Row Tier 5
/* {"310","380","United States",23},//Preferred Partners
{"310","410","United States",23},//Preferred Partners
{"310","260","United States",23},//Preferred Partners
{"310","160","United States",23},//Preferred Partners
{"310","200","United States",23},//Preferred Partners
{"310","610","United States",23},//Preferred Partners
{"310","210","United States",23},//Preferred Partners
{"310","220","United States",23},//Preferred Partners
{"310","230","United States",23},//Preferred Partners
{"310","240","United States",23},//Preferred Partners
{"310","250","United States",23},//Preferred Partners
{"310","270","United States",23},//Preferred Partners
{"310","490","United States",23},//Preferred Partners
{"310","420","United States",23},//RoW Tier 1
{"311","040","United States",23},//Row Tier 1
{"310","690","United States",23},//Row Tier 1
{"311","370","United States",23},//RoW Tier 3
{"310","050","United States",23},//RoW Tier 3
{"310","020","United States",23},//RoW Tier 3
{"310","450","United States",23},//Row Tier 3
{"310","720","United States",23},//Row Tier 5
{"311","530","United States",23},//Row Tier 5
{"311","330","United States",23},//Row Tier 5*/
{"530","01","New Zealand",2},//Vodafone networks
{"530","05","New Zealand",2},//RoW Tier 1
{"505","03","Australia",3},//Vodafone networks
{"505","02","Australia",3},//RoW Tier 2
{"505","01","Australia",3},//RoW Tier 5
/*{"572","01","Maldives",2},//Row Tier 5
{"472","02","Maldives",2},//RoW Tier 5*/
{"425","01","Israel",3},//RoW Tier 1
{"425","03","Israel",3},//RoW Tier 1
{"425","02","Israel",3},//RoW Tier 3
{"456","01","Cambodia",3},//RoW Tier 1
{"456","06","Cambodia",3},//RoW Tier 1
{"456","09","Cambodia",3},//RoW Tier 3
{"413","02","Sri Lanka",5},//Preferred Partners
{"413","03","Sri Lanka",5},//RoW Tier 2
{"413","05","Sri Lanka",5},//RoW Tier 5
{"413","08","Sri Lanka",5},//RoW Tier 5
{"413","01","Sri Lanka",5},//RoW Tier 5
{"452","02","Viet Nam",4},//Preferred Partners
{"452","05","Viet Nam",4},//RoW Tier 1
{"452","07","Viet Nam",4},//RoW Tier 5
{"452","04","Viet Nam",4},//RoW Tier 5
{"520","04","Thailand",4},//Preferred Partners
{"520","99","Thailand",4},//Preferred Partners
{"520","01","Thailand",4},//RoW Tier 3
{"520","03","Thailand",4},//RoW Tier 3
{"502","13","Malaysia",5},//Preferred Partners
{"502","19","Malaysia",5},//Preferred Partners
{"502","16","Malaysia",5},//RoW Tier 1
{"502","12","Malaysia",5},//RoW Tier 5
{"502","18","Malaysia",5},//RoW Tier 5
/* {"450","02","Korea, Republic Of",3},//RoW Tier 1
{"450","08","Korea, Republic Of",3},//RoW Tier 1
{"450","05","Korea, Republic Of",3},//RoW Tier 1*/
/* {"440","10","Japan",2},//Preferred Partners
{"440","20","Japan",2},//RoW Tier 1*/
{"455","00","Macau",3},//RoW Tier 1
{"455","03","Macau",3},//RoW Tier 5
{"455","01","Macau",3},//RoW Tier 5
{"466","92","Taiwan, Province of China",3},//Preferred Partners
{"466","01","Taiwan, Province of China",3},//RoW Tier 5
{"466","97","Taiwan, Province of China",3},//RoW Tier 5
#if 0
//AoZhou
{"505","03","Australia",3}, //Vodafone networks
{"505","02","Australia",3}, // Row Tier 2
{"505","01","Australia",3}, // Row Tier 5
#endif
/*******************************************Asian Start***********************************************/
//XiangGang
/*{"454","03","HongKong",6}, //preferred partners 3
{"454","04","HongKong",6}, //preferred partners Hutchison
{"454","06","HongKong",6},//Row Tier 1 SmarTone
{"454","19","HongKong",6},//Row Tier 1 PCCW
{"454","00","HongKong",6},//Row Tier 5 CSL
{"454","10","HongKong",6},//Row Tier 5 CSL*/
/*{"454","19","HongKong",6},//Row Tier 1 PCCW
{"454","06","HongKong",6},//Row Tier 1 SmarTone
{"454","04","HongKong",6}, //preferred partners Hutchison
{"454","00","HongKong",6},//Row Tier 5 CSL
{"454","10","HongKong",6},//Row Tier 5 CSL
{"454","03","HongKong",6}, //preferred partners 3 */
//YinNi
{"510","01","Indonesia",4},//Row Tier 2 Indosat
{"510","89","Indonesia",4},//Row Tier 1 3
{"510","11","Indonesia",4},//Row Tier 1 Excelcom
{"510","10","Indonesia",4},//Row Tier 5 Telkomsel
#if 0
//RiBen
{"440","10","Japan",2}, //preferred partners DoCoMo
{"440","21","Japan",2},//Row Tier 1 SoftBank
//AoMen
{"450","00","Macau",3},
{"450","01","Macau",3},
{"450","03","Macau",3},
//FeiLiBin
{"515","03","Philippines",3},//preferred partners SMART GOLD
{"515","02","Philippines",3},//Row Tier 2 Globe
{"515","05","Philippines",3},//Row Tier 5 Sun Cellular
//YinNi
{"510","89","Indonesia",4},//Row Tier 1 3
{"510","11","Indonesia",4},//Row Tier 1 Excelcom
{"510","01","Indonesia",4},//Row Tier 2 Indosat
{"510","10","Indonesia",4},//Row Tier 5 Telkomsel
//MaLaiXiYa
{"502","13","Malaysia",5},//preferred partners Celcom
{"502","19","Malaysia",5},//preferred partners Celcom
{"502","16","Malaysia",5},//Row Tier 1 DiGi
{"502","12","Malaysia",5},//Row Tier 5 Maxis-Mobile
{"502","18","Malaysia",5},//Row Tier 5 U-Mobile
//HanGuo
{"455","02","Korea",3}, //Row Tier 1 KT
{"455","05","Korea",3}, //Row Tier 1 SK
{"455","08","Korea",3},//Row Tier 1 KT
//MaErDaiFu
{"472","01","Maldives",2}, //Row Tier 5 DhiMobile
{"472","02","Maldives",2}, //Row Tier 5 Wataniya
//ZhongGuo
{"460","00","China",3},
{"460","01","China",3},
{"460","02","China",3},
#endif
#if 0
//YueNan
{"452","02","Viet Nam",4},//preferred partners VinaPhone
{"452","02","Viet Nam",4},//Row Tier 1 VietNaMobile
{"452","04","Viet Nam",4},//Row Tier 5 BeeLine
{"452","07","Viet Nam",4},//Row Tier 5 Viettel
//XinJiaPo
{"525","05","Singapore",3},//preferred partners Star Hub
{"525","03","Singapore",3},//Row Tier 1 M1
{"525","01","Singapore",3},//Row Tier 2 SingTel
//TaiWan
{"466","92","Taiwan",3},//preferred partners Chungwa
{"466","01","Taiwan",3},//Row Tier 5 Far EasTone
{"466","97","Taiwan",3},//Row Tier 5 TaiWan mobile
//TaiGuo
{"520","04","Thailand",4},//preferred partners RealFuture
{"520","99","Thailand",4},//preferred partners TrueMove
{"520","01","Thailand",4},//Row Tier 3 AIS
{"520","03","Thailand",4},//Row Tier 3 AIS
//TuErQi
{"286","02","TurKey",3},//Vodafone networks Vodafone
{"286","03","TurKey",3},//Row Tier 1 AVEA
{"286","01","TurKey",3},//Row Tier 3 TurKcell
/*******************************************Asian End***********************************************/
/******************************************Europe Start************************************************/
//YingGuo
{"234","15","United Kingdom",4},//Vodafone networks Vodafone
{"234","10","United Kingdom",4},//EU28+2 others O2
{"234","30","United Kingdom",4},//EU28+2 others T-Mobile
{"234","33","United Kingdom",4},//EU28+2 others Everything everywhere
//LuoMaNiYa
{"226","01","Romania",4},//Vodafone networks Vodafone
{"226","03","Romania",4},//EU28+2 others Cosmote
{"226","05","Romania",4},//EU28+2 others DigiMobil
{"234","10","Romania",4},//EU28+2 others Orange
//FaGuo
{"208","10","France",3},//preferred partners RealFuture
{"208","01","France",3},//EU28+2 others Orange
{"208","20","France",3},//EU28+2 others Bouygues
//BoLan
{"260","01","Poland",4},//preferred partners Plus
{"260","02","Poland",4},//EU28+2 others Era
{"260","03","Poland",4},//EU28+2 others Orange
{"260","06","Poland",4},//EU28+2 others Play
//RuiShi
{"228","01","Switzerland",3},//preferred partners Swisscom
{"228","03","Switzerland",3},//EU28+2 others Orange
{"228","02","Switzerland",3},//EU28+2 others Sunrise
//RuiDian
{"240","04","Sweden",3},//preferred partners Telenor
{"240","05","Sweden",3},//EU28+2 others Tele 2
{"240","01","Sweden",3},//EU28+2 others TeliaSonera
//YiDaLi
{"222","10","Italy",2},//Vodafone networks Vodafone
{"222","88","Italy",2},//EU28+2 others Wind
//Fan di gang
/*{"222","10","Vatican City",2},//Vodafone networks Vodafone
{"222","88","Vatican City",2},//EU28+2 others Wind*/
//
{"292","01","San Marino",1},//Row Tier 1 San Marino Telecom
//DeGuo
{"262","02","Germany",4},//Vodafone networks Vodafone
{"262","01","Germany",4},//EU28+2 others T-Mobile
{"262","03","Germany",4},//EU28+2 others E-Plus
{"262","07","Germany",4},//EU28+2 others O2