blob: aed8aadf6bffc10623054e8cb42166018b5d821c [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#include "lynq_qser_network.h"
2#include "mbtk_type.h"
3#include "mbtk_ril_api.h"
4#include "mbtk_log.h"
5
6#include <stdio.h>
7#include <stdlib.h>
8
9#define QSER_RESULT_SUCCESS 0
10#define QSER_RESULT_FAIL -1
11
12static mbtk_ril_handle* qser_info_handle;
13static const uint qser_h_nw = 0x5F6F7F8F;
14
15static uint64_t tmp_mode = 0xFF;
16
17typedef struct
18{
19 QSER_NW_RxMsgHandlerFunc_t handlerPtr;
20 void* contextPtr;
21} lynq_cust_cb_func;
22
23static lynq_cust_cb_func lynq_func_cb_handle;
24
25static int roaming_pref = 1; // Open roaming for default.
26
27typedef enum {
28 RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
29 RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
30} RIL_RadioTechnologyFamily;
31
32
33typedef struct
34{
35 uint8 *lynq_operator_l;
36 uint8 *lynq_operator_s;
37 uint32 lynq_mcc_mnc;
38} lynq_operator_mcc_mnc_t;
39
40static lynq_operator_mcc_mnc_t lynq_operator_mcc_mnc[] =
41{
42 {(uint8*)"China Mobile",(uint8*)"CMCC",46000},
43 {(uint8*)"China Unicom",(uint8*)"CU",46001},
44 {(uint8*)"China Mobile",(uint8*)"CMCC",46002},
45 {(uint8*)"China Telecom",(uint8*)"CT",46003},
46 {(uint8*)"China Mobile",(uint8*)"CMCC",46004},
47 {(uint8*)"China Telecom",(uint8*)"CT",46005},
48 {(uint8*)"China Unicom",(uint8*)"CU",46006},
49 {(uint8*)"China Mobile",(uint8*)"CMCC",46007},
50 {(uint8*)"China Mobile",(uint8*)"CMCC",46008},
51 {(uint8*)"China Unicom",(uint8*)"CU",46009},
52 {(uint8*)"China Telecom",(uint8*)"CT",46011}
53};
54
55#if 0
56//T106的实现
57/*Used to wait for an update signal*/
58int lynq_wait_signalchanges(int *handle)
59{
60 LYDBGLOG("start wait signalchanges info");
61 if(NULL == handle)
62 {
63 LYERRLOG("illegal input");
64 return LYNQ_E_PARAMETER_ANONALY;
65 }
66 wait_urc_signal_changes();
67 LYDBGLOG("get signalchanges");
68 *handle = s_module_wait_urc_id;
69 return RESULT_OK;
70}
71
72bool is_support_urc(int urc_id)
73{
74 switch(urc_id)
75 {
76 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
77 case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:
78 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
79 case RIL_UNSOL_SIGNAL_STRENGTH:
80 return true;
81 default:
82 return false;
83 }
84}
85
86/*Used to get urc info*/
87int lynq_get_urc_info(const int handle,signalStrength_t *solSigStren,int *slot_id)
88{
89 if(g_module_init_flag != MODULE_RUNNING)
90 {
91 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
92 return -1;
93 }
94 LYDBGLOG("start get urc info");
95 if(is_support_urc(handle)==false)
96 {
97 LYINFLOG("invalid handle!!!");
98 return -1;
99 }
100 if((handle ==RIL_UNSOL_SIGNAL_STRENGTH && NULL == solSigStren) ||
101 (handle !=RIL_UNSOL_SIGNAL_STRENGTH && NULL == slot_id))
102 {
103 LYINFLOG("incoming solSigStren or slot_id is NULL!!!");
104 return -1;
105 }
106 switch(handle)
107 {
108 case RIL_UNSOL_SIGNAL_STRENGTH: //1009
109 {
110 LYDBGLOG("get state update to signal info");
111 solSigStren->gw_sig_valid = s_network_urc_solSigStren.gw_sig_valid;
112 solSigStren->rssi = s_network_urc_solSigStren.rssi;
113 solSigStren->wcdma_signalstrength = s_network_urc_solSigStren.wcdma_signalstrength;
114 solSigStren->wcdma_sig_valid = s_network_urc_solSigStren.wcdma_sig_valid;
115 solSigStren->rscp = s_network_urc_solSigStren.rscp;
116 solSigStren->ecno = s_network_urc_solSigStren.ecno;
117 solSigStren->lte_signalstrength = s_network_urc_solSigStren.lte_signalstrength;
118 solSigStren->lte_sig_valid = s_network_urc_solSigStren.lte_sig_valid;
119 solSigStren->rsrp = s_network_urc_solSigStren.rsrp;
120 solSigStren->rsrq = s_network_urc_solSigStren.rsrq;
121 solSigStren->rssnr = s_network_urc_solSigStren.rssnr;
122 solSigStren->nr_sig_valid = s_network_urc_solSigStren.nr_sig_valid;
123 solSigStren->ssRsrp = s_network_urc_solSigStren.ssRsrp;
124 solSigStren->ssRsrq = s_network_urc_solSigStren.ssRsrq;
125 solSigStren->ssSinr = s_network_urc_solSigStren.ssSinr;
126 solSigStren->csiRsrp = s_network_urc_solSigStren.csiRsrp;
127 solSigStren->csiRsrq = s_network_urc_solSigStren.csiRsrq;
128 solSigStren->csiSinr = s_network_urc_solSigStren.csiSinr;
129 break;
130 }
131 default:
132 {
133 *slot_id = s_module_urc_slot_id;
134 LYINFLOG("slot_id = %d",s_module_urc_slot_id);
135 }
136 }
137 return 0;
138}
139
140
141void urc_msg_process_voice_reg()
142{
143 if(s_handlerPtr != NULL)
144 {
145 s_handlerPtr(g_nw_val,NW_IND_VOICE_REG_EVENT_IND_FLAG,NULL,0,s_contextPtr);
146 }
147}
148
149void urc_msg_process_data_reg()
150{
151 if(s_handlerPtr != NULL)
152 {
153 s_handlerPtr(g_nw_val,NW_IND_DATA_REG_EVENT_IND_FLAG,NULL,0,s_contextPtr);
154 }
155}
156
157void urc_msg_process_ims_reg()
158{
159 if(s_handlerPtr != NULL)
160 {
161 s_handlerPtr(g_nw_val,NW_IND_IMS_REG_EVENT_IND_FLAG,NULL,0,s_contextPtr);
162 }
163}
164
165void *new_network_thread_recv(void *context)
166{
167 int handle = -1;
168 uint32_t ind_flag = 0;
169
170 while (1)
171 {
172 lynq_wait_signalchanges(&handle);
173
174 switch(handle)
175 {
176 case 1002: //RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
177 {
178 urc_msg_process_voice_reg();
179
180 break;
181 }
182 case 3015://RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:
183 {
184 urc_msg_process_data_reg();
185 break;
186 }
187 case 1009://RIL_UNSOL_SIGNAL_STRENGTH:
188 {
189 urc_msg_process_signal_strength();
190 break;
191 }
192 case 1037://RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
193 {
194 urc_msg_process_ims_reg();
195 break;
196 }
197 }
198 }
199 return NULL;
200}
201
202void urc_msg_process_signal_strength()
203{
204 signalStrength_t signalstrength;
205 int slot_id;
206
207 int ret = lynq_get_urc_info(1009,&signalstrength,&slot_id);
208 if (ret == 0)
209 {
210 QSER_NW_SINGNAL_EVENT_IND_T msg_buf;
211 msg_buf.gsm_sig_info_valid = signalstrength.gw_sig_valid;
212 msg_buf.gsm_sig_info.rssi = signalstrength.rssi;
213 msg_buf.wcdma_sig_info_valid = signalstrength.wcdma_sig_valid;
214 msg_buf.wcdma_sig_info.rssi = signalstrength.rscp;
215 msg_buf.wcdma_sig_info.ecio = signalstrength.ecno;
216 msg_buf.tdscdma_sig_info_valid = 0;
217 msg_buf.lte_sig_info_valid = signalstrength.lte_sig_valid;
218 msg_buf.lte_sig_info.rssi = -125;
219 msg_buf.lte_sig_info.rsrp = signalstrength.rsrp;
220 msg_buf.lte_sig_info.rsrq = signalstrength.rsrq;
221 msg_buf.lte_sig_info.snr = signalstrength.rssnr;
222 msg_buf.cdma_sig_info_valid = 0;
223 msg_buf.hdr_sig_info_valid = 0;
224 msg_buf.nr_sig_info_valid = signalstrength.nr_sig_valid;
225 msg_buf.nr_sig_info.ssRsrp = signalstrength.ssRsrp;
226 msg_buf.nr_sig_info.ssRsrq = signalstrength.ssRsrq;
227 msg_buf.nr_sig_info.ssSinr = signalstrength.ssSinr;
228 msg_buf.nr_sig_info.csiRsrp = signalstrength.csiRsrp;
229 msg_buf.nr_sig_info.csiRsrq = signalstrength.csiRsrq;
230 msg_buf.nr_sig_info.csiSinr = signalstrength.csiSinr;
231 void *ind_msg_buf= &msg_buf;
232 if(s_handlerPtr!=NULL)
233 {
234 s_handlerPtr(g_nw_val,NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG,ind_msg_buf,sizeof (msg_buf) ,s_contextPtr);
235 }
236 }
237}
238
239#endif
240
241static int8_t rssi_convert_to_dBm(uint8 rssi)
242{
243 if(rssi <= 31)
244 {
245 return rssi * 2 - 113;
246 }
247 else
248 {
249 return -125;
250 }
251}
252
253static int16_t rsrp_convert_to_dBm(uint8 rsrp)
254{
255 if(rsrp <= 96)
256 {
257 return rsrp - 140;
258 }
259 else
260 {
261 return -44;
262 }
263}
264
265static int16_t rsrq_convert_to_dB(uint8 rsrq)
266{
267 if(rsrq >= 1 && rsrq <= 34)
268 {
269 return (rsrq + 1) / 2 - 20;
270 }
271 else
272 {
273 return -20;
274 }
275}
276
277static int16_t ecno_convert_to_dB(uint8 ecno)
278{
279 if(ecno >= 48)
280 {
281 return 0;
282 }
283 else if(ecno == 255)
284 {
285 return 255;
286 }
287 else
288 {
289 return 48 - ecno;
290 }
291}
292
293void qser_signal_state_change_cb(const void* data, int data_len)
294{
295 /*
296 data_signal[0] = signal.type;
297 data_signal[1] = signal.rssi;
298 data_signal[2] = signal.rxlev;
299 data_signal[3] = signal.ber;
300 data_signal[4] = signal.rscp;
301 data_signal[5] = signal.ecno;
302 data_signal[6] = signal.rsrq;
303 data_signal[7] = signal.rsrp;
304 */
305 if(data && data_len == 8)
306 {
307 uint8 *net_data = (uint8*)data;
308 mbtk_radio_technology_enum type = (mbtk_radio_technology_enum)net_data[0];
309
310 QSER_NW_SINGNAL_EVENT_IND_T signal_msg_buf;
311 memset(&signal_msg_buf, 0x0, sizeof(QSER_NW_SINGNAL_EVENT_IND_T));
312
313 signal_msg_buf.gsm_sig_info_valid = FALSE;
314 signal_msg_buf.lte_sig_info_valid = FALSE;
315 signal_msg_buf.wcdma_sig_info_valid = FALSE;
316 signal_msg_buf.tdscdma_sig_info_valid = FALSE;
317 signal_msg_buf.cdma_sig_info_valid = FALSE;
318 signal_msg_buf.hdr_sig_info_valid = FALSE;
319 signal_msg_buf.nr_sig_info_valid = FALSE;
320
321 if(type == MBTK_RADIO_TECH_GSM || type == MBTK_RADIO_TECH_GSM_COMPACT || \
322 type == MBTK_RADIO_TECH_GSM_EGPRS) //GSM
323 {
324 signal_msg_buf.gsm_sig_info_valid = TRUE;
325 signal_msg_buf.gsm_sig_info.rssi = rssi_convert_to_dBm(net_data[1]);
326 }
327 else if(type == MBTK_RADIO_TECH_E_UTRAN) //LTE
328 {
329 signal_msg_buf.lte_sig_info_valid = TRUE;
330 signal_msg_buf.lte_sig_info.rssi = rssi_convert_to_dBm(net_data[1]);
331 signal_msg_buf.lte_sig_info.rsrp = rsrp_convert_to_dBm(net_data[7]);
332 signal_msg_buf.lte_sig_info.rsrq = rsrq_convert_to_dB(net_data[6]);
333 signal_msg_buf.lte_sig_info.snr = 0x7FFF;//(当前mbtk没有该参数)
334 }
335 else if (type == MBTK_RADIO_TECH_UTRAN || type == MBTK_RADIO_TECH_UTRAN_HSDPA || \
336 type == MBTK_RADIO_TECH_UTRAN_HSUPA || type == MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA || \
337 type == MBTK_RADIO_TECH_UTRAN_HSPA )//WCDMA
338 {
339 signal_msg_buf.wcdma_sig_info_valid = TRUE;
340 signal_msg_buf.wcdma_sig_info.rssi = rssi_convert_to_dBm(net_data[1]);
341 signal_msg_buf.wcdma_sig_info.ecio = ecno_convert_to_dB(net_data[5]);
342 }
343
344 if(lynq_func_cb_handle.handlerPtr != NULL)
345 {
346 lynq_func_cb_handle.handlerPtr(qser_h_nw, NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG, (void *)&signal_msg_buf, sizeof(QSER_NW_SINGNAL_EVENT_IND_T), lynq_func_cb_handle.contextPtr);
347 lynq_func_cb_handle.handlerPtr(qser_h_nw, NW_IND_VOICE_REG_EVENT_IND_FLAG, NULL, 0, lynq_func_cb_handle.contextPtr);
348 lynq_func_cb_handle.handlerPtr(qser_h_nw, NW_IND_DATA_REG_EVENT_IND_FLAG, NULL, 0, lynq_func_cb_handle.contextPtr);
349 lynq_func_cb_handle.handlerPtr(qser_h_nw, NW_IND_IMS_REG_EVENT_IND_FLAG, NULL, 0, lynq_func_cb_handle.contextPtr);
350 }
351 }
352 else
353 {
354 LOGD("qser_nw_state_change_cb : NULL");
355 }
356
357}
358
359static uint8 lynq_net_pre_change(bool mbtk_2_lynq,int net_mode)
360{
361 uint8 mbtk_net_pre = 0xFF;
362
363#if 0
364 此参数表在别处使用
365 E_QSER_NW_RADIO_TECH_TD_SCDMA = 1, Y3 1
366 E_QSER_NW_RADIO_TECH_GSM = 2, /**< GSM; only supports voice. */ YL2 0
367 E_QSER_NW_RADIO_TECH_HSPAP = 3, /**< HSPA+. */ 3 1
368 E_QSER_NW_RADIO_TECH_LTE = 4, /**< LTE. */ 4 5
369 E_QSER_NW_RADIO_TECH_EHRPD = 5, /**< EHRPD. */ 3 1
370 E_QSER_NW_RADIO_TECH_EVDO_B = 6, /**< EVDO B. */ D3 1
371 E_QSER_NW_RADIO_TECH_HSPA = 7, /**< HSPA. */ 3 1
372 E_QSER_NW_RADIO_TECH_HSUPA = 8, /**< HSUPA. */ 3.5 1
373 E_QSER_NW_RADIO_TECH_HSDPA = 9, /**< HSDPA. */ 3.5 1
374 E_QSER_NW_RADIO_TECH_EVDO_A = 10, /**< EVDO A. */ D3 1
375 E_QSER_NW_RADIO_TECH_EVDO_0 = 11, /**< EVDO 0. */ D3 1
376 E_QSER_NW_RADIO_TECH_1xRTT = 12, /**< 1xRTT. */ 2 0
377 E_QSER_NW_RADIO_TECH_IS95B = 13, /**< IS95B. */ 3 0
378 E_QSER_NW_RADIO_TECH_IS95A = 14, /**< IS95A. */ 3 0
379 E_QSER_NW_RADIO_TECH_UMTS = 15, /**< UMTS. */ L3 1
380 E_QSER_NW_RADIO_TECH_EDGE = 16, /**< EDGE. */ 2.75 0
381 E_QSER_NW_RADIO_TECH_GPRS = 17, /**< GPRS. */ 2.5 0
382 E_QSER_NW_RADIO_TECH_NONE = 18 /**< No technology selected. */
383#endif
384 /*
385 0 : GSM only
386 1 : UMTS only
387 2 : GSM/UMTS(auto)
388 3 : GSM/UMTS(GSM preferred)
389 4 : GSM/UMTS(UMTS preferred)
390 5 : LTE only
391 6 : GSM/LTE(auto)
392 7 : GSM/LTE(GSM preferred)
393 8 : GSM/LTE(LTE preferred)
394 9 : UMTS/LTE(auto)
395 10 : UMTS/LTE(UMTS preferred)
396 11 : UMTS/LTE(LTE preferred)
397 12 : GSM/UMTS/LTE(auto)
398 13 : GSM/UMTS/LTE(GSM preferred)
399 14 : GSM/UMTS/LTE(UMTS preferred)
400 15 : GSM/UMTS/LTE(LTE preferred)
401 */
402
403 if(mbtk_2_lynq)
404 {
405 switch(net_mode)
406 {
407 //使用之前set的tmp_mode的值来进行回显get
408 case QSER_NW_MODE_GSM:
409 mbtk_net_pre = QSER_NW_MODE_GSM;
410 break;
411 case QSER_NW_MODE_WCDMA:
412 mbtk_net_pre = QSER_NW_MODE_WCDMA;
413 break;
414 case QSER_NW_MODE_CDMA:
415 mbtk_net_pre = QSER_NW_MODE_CDMA;
416 break;
417 case QSER_NW_MODE_EVDO:
418 mbtk_net_pre = QSER_NW_MODE_EVDO;
419 break;
420 case QSER_NW_MODE_LTE:
421 mbtk_net_pre = QSER_NW_MODE_LTE;
422 break;
423 case QSER_NW_MODE_TDSCDMA:
424 mbtk_net_pre = QSER_NW_MODE_TDSCDMA;
425 break;
426 default:
427 mbtk_net_pre = 0xFF;
428 break;
429 }
430 }
431 else
432 {
433 if(QSER_NW_MODE_GSM == net_mode)
434 {
435 mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
436 }
437 else if(QSER_NW_MODE_WCDMA == net_mode)
438 {
439 mbtk_net_pre = MBTK_NET_PREF_UMTS_ONLY;
440 }
441 else if(QSER_NW_MODE_LTE == net_mode)
442 {
443 mbtk_net_pre = MBTK_NET_PREF_LTE_ONLY;
444 }
445 else if((QSER_NW_MODE_GSM | QSER_NW_MODE_WCDMA) == net_mode)
446 {
447 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
448 }
449 else if((QSER_NW_MODE_WCDMA | QSER_NW_MODE_LTE) == net_mode)
450 {
451 mbtk_net_pre = MBTK_NET_PREF_UMTS_LTE_LTE_PREF;
452 }
453 else if((QSER_NW_MODE_GSM | QSER_NW_MODE_LTE) == net_mode)
454 {
455 mbtk_net_pre = MBTK_NET_PREF_GSM_LTE_LTE_PREF;
456 }
457 else if((QSER_NW_MODE_GSM | QSER_NW_MODE_WCDMA | QSER_NW_MODE_LTE) == net_mode)
458 {
459 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;
460 }
461 else
462 {
463 mbtk_net_pre = 0xFF;
464 }
465 }
466 return mbtk_net_pre;
467}
468
469int qser_nw_client_init(nw_client_handle_type *ph_nw)
470{
471 //UNUSED(ph_voice);
472 if(ph_nw == NULL)
473 {
474 LOGE("[qser_nw] ph_nw is NULL.");
475 return QSER_RESULT_FAIL;
476 }
477
478 if(NULL == qser_info_handle)
479 {
480 qser_info_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
481 if(NULL == qser_info_handle)
482 {
483 LOGE("[qser_nw] qser_info_handle get fail.");
484 return QSER_RESULT_FAIL;
485 }
486 }
487 else
488 {
489 LOGE("[qser_nw] qser_info_handle has init.");
490 *ph_nw = qser_h_nw;
491 return QSER_RESULT_FAIL;
492 }
493 *ph_nw = qser_h_nw;
494
495 LOGE("[qser_nw] qser_info_handle get success.");
496
497
498 return QSER_RESULT_SUCCESS;
499
500}
501
502
503int qser_nw_client_deinit(nw_client_handle_type h_nw)
504{
505 if(h_nw != qser_h_nw)
506 {
507 LOGE("[qser_nw] h_nw is error.");
508 return QSER_RESULT_FAIL;
509 }
510
511 if(qser_info_handle)
512 {
513 int ret = mbtk_ril_close(MBTK_AT_PORT_DEF);;
514 if(ret)
515 {
516 LOGE("[qser_nw] mbtk_info_handle_free() fail.");
517 return QSER_RESULT_FAIL;
518 }
519 else
520 {
521 qser_info_handle = NULL;
522 lynq_func_cb_handle.handlerPtr = NULL;
523 }
524 }
525 else
526 {
527 LOGE("[qser_nw] handle not inited.");
528 return QSER_RESULT_FAIL;
529 }
530
531 return QSER_RESULT_SUCCESS;
532}
533
534
535int qser_nw_set_config(nw_client_handle_type h_nw,QSER_NW_CONFIG_INFO_T *pt_info)
536{
537 if(h_nw != qser_h_nw)
538 {
539 LOGE("[qser_nw] h_nw is error.");
540 return QSER_RESULT_FAIL;
541 }
542
543 if(qser_info_handle == NULL)
544 {
545 LOGE("qser_info_handle == NULL.");
546 return -1;
547 }
548
549 if(pt_info == NULL)
550 {
551 LOGE("pt_info == NULL.");
552 return -1;
553 }
554
555 roaming_pref = pt_info->roaming_pref;
556
557 mbtk_band_info_t band;
558 memset(&band, 0, sizeof(mbtk_band_info_t));
559 tmp_mode = pt_info->preferred_nw_mode;//临时保存一下原本的mode
560
561 //printf("tmp_mode = [%llu]",tmp_mode);
562 band.net_pref = lynq_net_pre_change(FALSE, pt_info->preferred_nw_mode);
563 LOGI("band.net_pref = [%d] ",band.net_pref);
564
565 if(band.net_pref == 0xFF)
566 {
567 LOGE("lynq_net_pre_change() fail.");
568 return -1;
569 }
570
571 if(mbtk_current_band_set(qser_info_handle, &band))
572 {
573 return -1;
574 }
575
576 return 0;
577}
578
579int qser_nw_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info)
580{
581 if(h_nw != qser_h_nw)
582 {
583 LOGE("[qser_nw] h_nw is error.");
584 return QSER_RESULT_FAIL;
585 }
586
587 if(qser_info_handle == NULL)
588 {
589 LOGE("qser_info_handle == NULL.");
590 return -1;
591 }
592
593 if(pt_info == NULL)
594 {
595 LOGE("pt_info == NULL.");
596 return -1;
597 }
598
599 char OperatorFN[128];
600 char OperatorSH[128];
601 char MccMnc[128];
602 mbtk_net_info_t net;
603 if(!mbtk_net_sel_mode_get(qser_info_handle, &net) && net.plmn > 0)
604 {
605 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
606 int i = 0;
607 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
608 {
609 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
610 break;
611 i++;
612 }
613
614 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
615 {
616 strcpy(OperatorFN, "UNKNOWN");
617 strcpy(OperatorSH, "UNKNOWN");
618 sprintf(MccMnc, "%d", net.plmn);
619 }
620 else
621 {
622 strcpy(OperatorFN, (char*)lynq_operator_mcc_mnc[i].lynq_operator_l);
623 strcpy(OperatorSH, (char*)lynq_operator_mcc_mnc[i].lynq_operator_s);
624 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
625 }
626 memset(pt_info->long_eons,0,128);
627 memcpy(pt_info->long_eons,lynq_operator_mcc_mnc[i].lynq_operator_l,strlen((char*)lynq_operator_mcc_mnc[i].lynq_operator_l));
628 memset(pt_info->short_eons,0,128);
629 memcpy(pt_info->short_eons,lynq_operator_mcc_mnc[i].lynq_operator_s,strlen((char*)lynq_operator_mcc_mnc[i].lynq_operator_s));
630 memset(pt_info->mcc,0,4);
631 memset(pt_info->mnc,0,4);
632 sprintf(pt_info->mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
633 sprintf(pt_info->mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
634 //pt_info->act;
635 return 0;
636 }
637
638 return -1;
639}
640
641int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info)
642{
643 if(h_nw != qser_h_nw)
644 {
645 LOGE("[qser_nw] h_nw is error.");
646 return QSER_RESULT_FAIL;
647 }
648
649 if(qser_info_handle == NULL)
650 {
651 LOGE("qser_info_handle == NULL.");
652 return -1;
653 }
654
655 if(pt_info == NULL)
656 {
657 LOGE("pt_info == NULL.");
658 return -1;
659 }
660
661 /*VOICE/DATA/IMS*/
662 mbtk_net_reg_info_t reg;
663 int err = mbtk_net_reg_get(qser_info_handle, &reg);
664 if(err)
665 {
666 LOGE("mbtk_net_reg_get fail.");
667 return -1;
668 }
669 else
670 {
671 memset(pt_info, 0x0, sizeof(QSER_NW_REG_STATUS_INFO_T));
672
673
674 char OperatorFN[128];
675 char OperatorSH[128];
676 char MccMnc[128];
677 mbtk_net_info_t net;
678 if(!mbtk_net_sel_mode_get(qser_info_handle, &net) && net.plmn > 0)
679 {
680 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
681 int i = 0;
682 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
683 {
684 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
685 break;
686 i++;
687 }
688
689 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
690 {
691 strcpy(OperatorFN, "UNKNOWN");
692 strcpy(OperatorSH, "UNKNOWN");
693 sprintf(MccMnc, "%d", net.plmn);
694 }
695 else
696 {
697 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
698 }
699 sprintf(pt_info->data_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
700 sprintf(pt_info->data_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
701 sprintf(pt_info->voice_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
702 sprintf(pt_info->voice_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
703 //pt_info->act;
704 }
705
706 //暂时未知是否其他也被使用,现根据ql模块的传输情况,
707 //只配置3gpp,涉及call,data状态没有对应的匹配的就没有赋值
708
709 pt_info->voice_registration_valid = TRUE;
710 pt_info->voice_registration.deny_reason = 0;
711 pt_info->voice_registration.roaming = 0;
712 pt_info->voice_registration.tech_domain = 0;
713
714
715 pt_info->data_registration_valid = TRUE;
716 pt_info->data_registration.deny_reason = 0;
717 pt_info->data_registration.roaming = 0;
718 pt_info->data_registration.tech_domain = 0;
719
720 if (reg.call_state == 1 || reg.call_state == 5)
721 {
722 pt_info->voice_registration.registration_state = E_QSER_NW_SERVICE_FULL;
723 }
724 else if (reg.call_state == 0 || reg.call_state == 2 || reg.call_state == 3 || reg.call_state == 4)
725 {
726 pt_info->voice_registration.registration_state = E_QSER_NW_SERVICE_NONE;
727 }
728
729 if (reg.data_state == 1 || reg.data_state == 5)
730 {
731 pt_info->data_registration.registration_state = E_QSER_NW_SERVICE_FULL;
732 }
733 else if (reg.data_state == 0 || reg.data_state == 2 || reg.data_state == 3 || reg.data_state == 4)
734 {
735 pt_info->data_registration.registration_state = E_QSER_NW_SERVICE_NONE;
736 }
737
738
739 pt_info->voice_registration_details_3gpp_valid = TRUE;
740 pt_info->voice_registration_details_3gpp.lac = reg.lac;
741 pt_info->voice_registration_details_3gpp.cid = reg.ci;
742 //补位填0 or 1
743 pt_info->voice_registration_details_3gpp.tech_domain = 1;
744 pt_info->voice_registration_details_3gpp.roaming = 0;
745 pt_info->voice_registration_details_3gpp.forbidden = 0;
746 pt_info->voice_registration_details_3gpp.psc = 0;
747 pt_info->voice_registration_details_3gpp.tac = 0;
748
749 pt_info->data_registration_details_3gpp_valid = TRUE;
750 pt_info->data_registration_details_3gpp.lac = reg.lac;
751 pt_info->data_registration_details_3gpp.cid = reg.ci;
752 //补位填0 or 1
753 pt_info->data_registration_details_3gpp.tech_domain = 1;
754 pt_info->data_registration_details_3gpp.roaming = 0;
755 pt_info->data_registration_details_3gpp.forbidden = 0;
756 pt_info->data_registration_details_3gpp.psc = 0;
757 pt_info->data_registration_details_3gpp.tac = 0;
758
759
760 pt_info->voice_registration_details_3gpp2_valid = FALSE;
761 //pt_info->voice_registration_details_3gpp2
762
763 pt_info->data_registration_details_3gpp2_valid = FALSE;
764 //pt_info->data_registration_details_3gpp2
765
766
767 switch(reg.type)
768 {
769 case MBTK_RADIO_TECH_GSM:
770 case MBTK_RADIO_TECH_GSM_COMPACT:
771 case MBTK_RADIO_TECH_GSM_EGPRS:
772 case MBTK_RADIO_TECH_UTRAN_HSPA:
773 {
774 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_HSPA;
775 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_HSPA;
776 pt_info->data_registration.radio_tech = E_QSER_NW_RADIO_TECH_HSPA;
777 pt_info->voice_registration.radio_tech = E_QSER_NW_RADIO_TECH_HSPA;
778 break;
779 }
780 case MBTK_RADIO_TECH_UTRAN:
781 case MBTK_RADIO_TECH_UTRAN_HSDPA:
782 case MBTK_RADIO_TECH_UTRAN_HSUPA:
783 case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
784 {
785 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
786 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
787 pt_info->data_registration.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
788 pt_info->voice_registration.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
789 break;
790 }
791 case MBTK_RADIO_TECH_E_UTRAN:
792 {
793 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
794 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
795 pt_info->data_registration.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
796 pt_info->voice_registration.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
797 break;
798 }
799 default:
800 {
801 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
802 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
803 pt_info->data_registration.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
804 pt_info->voice_registration.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
805 pt_info->data_registration.registration_state = E_QSER_NW_SERVICE_NONE;
806 pt_info->voice_registration.registration_state = E_QSER_NW_SERVICE_NONE;
807 break;
808 }
809 }
810 }
811
812 return 0;
813}
814
815int qser_nw_get_signal_strength(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
816{
817 if(h_nw != qser_h_nw)
818 {
819 LOGE("[qser_nw] h_nw is error.");
820 return QSER_RESULT_FAIL;
821 }
822
823 if(qser_info_handle == NULL)
824 {
825 LOGE("qser_info_handle == NULL.");
826 return -1;
827 }
828
829 if(pt_info == NULL)
830 {
831 LOGE("pt_info == NULL.");
832 return -1;
833 }
834
835 int ret;
836 mbtk_signal_info_t signal;
837 ret = mbtk_net_signal_get(qser_info_handle, &signal);
838 if(ret != 0) {
839 LOGE("mbtk_net_signal_get fail.");
840 return -1;
841 }
842 else
843 {
844 memset(pt_info, 0x0, sizeof(QSER_NW_SIGNAL_STRENGTH_INFO_T));
845 if(signal.type == MBTK_RADIO_TECH_GSM || signal.type == MBTK_RADIO_TECH_GSM_COMPACT || \
846 signal.type == MBTK_RADIO_TECH_GSM_EGPRS) //GSM
847 {
848 pt_info->gsm_sig_info_valid = TRUE;
849 pt_info->gsm_sig_info.rssi = rssi_convert_to_dBm(signal.rssi);
850 }
851 else if(signal.type == MBTK_RADIO_TECH_E_UTRAN) //LTE
852 {
853 pt_info->lte_sig_info_valid = TRUE;
854 pt_info->lte_sig_info.rsrp = rsrp_convert_to_dBm(signal.rsrp);
855 pt_info->lte_sig_info.rsrq = rsrq_convert_to_dB(signal.rsrq);
856 pt_info->lte_sig_info.snr = 0x7FFF;//->MBTK接口无该参数(对应参数为rssnr,该值INT_MAX:0x7FFFFFFFF表示无效值),写死值为0x7FFFFFFFF
857 pt_info->lte_sig_info.rssi = rssi_convert_to_dBm(signal.rssi);
858 }
859 else if (signal.type == MBTK_RADIO_TECH_UTRAN || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA || \
860 signal.type == MBTK_RADIO_TECH_UTRAN_HSUPA || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA || \
861 signal.type == MBTK_RADIO_TECH_UTRAN_HSPA )//WCDMA
862 {
863 pt_info->wcdma_sig_info_valid = TRUE;
864 pt_info->wcdma_sig_info.rssi = rssi_convert_to_dBm(signal.rssi);
865 pt_info->wcdma_sig_info.ecio = ecno_convert_to_dB(signal.ecno);
866 }
867 else
868 {
869 return -1;
870 }
871 /*
872 pt_info->gsm_sig_info_valid = 1//signal.gw_sig_valid;
873 pt_info->gsm_sig_info.rssi = signal.rssi;//signal.rssi-110;
874 pt_info->wcdma_sig_info_valid = 1//signal.wcdma_sig_valid;
875 pt_info->wcdma_sig_info.rssi = signal.rscp;//signal.wcdma_signalstrength-110;
876 pt_info->wcdma_sig_info.ecio = //signal.ecno/5;
877 pt_info->tdscdma_sig_info_valid = 0;
878 pt_info->lte_sig_info_valid = 1//signal.lte_sig_valid;
879 pt_info->lte_sig_info.rssi = -125;//signal.lte_signalstrength-110;
880 pt_info->lte_sig_info.rsrp = signal.rsrp;//signal.rsrp*(-1);
881 pt_info->lte_sig_info.rsrq = signal.rsrq;//signal.rsrq*(-1);
882 pt_info->lte_sig_info.snr = 0x7FFFFFFFF;//signal.rssnr;
883 pt_info->cdma_sig_info_valid = 0;
884 pt_info->hdr_sig_info_valid = 0;
885 //mbtk 无nr
886 pt_info->nr_sig_info_valid = 0//signal.nr_sig_valid;
887 pt_info->nr_sig_info.ssRsrp = 0//signal.ssRsrp;
888 pt_info->nr_sig_info.ssRsrq = 0//signal.ssRsrq;
889 pt_info->nr_sig_info.ssSinr = 0//signal.ssSinr;
890 pt_info->nr_sig_info.csiRsrp = 0//signal.csiRsrp;
891 pt_info->nr_sig_info.csiRsrq = 0//signal.csiRsrq;
892 pt_info->nr_sig_info.csiSinr = 0//signal.csiSinr;
893 */
894 }
895
896 return 0;
897}
898
899int qser_nw_add_rx_msg_handler (nw_client_handle_type h_nw, QSER_NW_RxMsgHandlerFunc_t handlerPtr, void* contextPtr)
900{
901 if(h_nw != qser_h_nw)
902 {
903 LOGE("[qser_nw] h_nw is error.");
904 return QSER_RESULT_FAIL;
905 }
906
907 if(qser_info_handle == NULL)
908 {
909 LOGE("qser_info_handle == NULL.");
910 return -1;
911 }
912
913 lynq_func_cb_handle.handlerPtr = handlerPtr;
914 lynq_func_cb_handle.contextPtr = contextPtr;
915
916 mbtk_signal_state_change_cb_reg(qser_signal_state_change_cb);
917
918 return 0;
919}
920
921int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
922{
923 if(h_nw != qser_h_nw)
924 {
925 LOGE("[qser_nw] h_nw is error.");
926 return QSER_RESULT_FAIL;
927 }
928
929 if (pt_info == NULL)
930 {
931 LOGE("QSER_NW_OOS_CONFIG_INFO_T NULL");
932 return -1;
933 }
934
935 uint32 oosPhase_0, oosPhase_1, oosPhase_2;
936 char tmp_type;
937 mbtk_ril_oos_info_t oos_info;
938
939 memset(&oos_info, 0x00, sizeof(mbtk_ril_oos_info_t));
940
941
942 tmp_type = pt_info->type;
943
944 if (tmp_type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
945 {//如果没有配置对应的值,例如,10,20
946 //oosPhase_2这个位置没有配置,则使用默认值20,既不限制次数的5s进行一次扫描
947 //同理oosPhase_0,oosPhase_1这个位置没有配置,则使用默认值5,10,既限制次数5次的5s,10s进行一次扫描
948 //输入多少配置多少,可以缺省使用默认值
949 if (pt_info->u.full_band_scan_info.t_min < 0 || pt_info->u.full_band_scan_info.t_step < 0 || pt_info->u.full_band_scan_info.t_max < 0)
950 {
951 LOGE("qser_nw_set_oos_config set time < 0 ");
952 return -1;
953 }
954 else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && pt_info->u.full_band_scan_info.t_step == 0 && pt_info->u.full_band_scan_info.t_max == 0)
955 {
956 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
957 oos_info.state = 1;
958 oos_info.oosPhase[0] = oosPhase_0;
959 }
960 else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && (pt_info->u.full_band_scan_info.t_step > 0 && pt_info->u.full_band_scan_info.t_step <= 255) && pt_info->u.full_band_scan_info.t_max == 0)
961 {
962 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
963 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
964 oos_info.state = 1;
965 oos_info.oosPhase[0] = oosPhase_0;
966 oos_info.oosPhase[1] = oosPhase_1;
967 }
968 else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && (pt_info->u.full_band_scan_info.t_step > 0 && pt_info->u.full_band_scan_info.t_step <= 255) && (pt_info->u.full_band_scan_info.t_max > 0 && pt_info->u.full_band_scan_info.t_max <= 255))
969 {
970 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
971 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
972 oosPhase_2 = pt_info->u.full_band_scan_info.t_max;
973 oos_info.state = 1;
974 oos_info.oosPhase[0] = oosPhase_0;
975 oos_info.oosPhase[1] = oosPhase_1;
976 oos_info.oosPhase[2] = oosPhase_2;
977 }
978 else if (pt_info->u.full_band_scan_info.t_min == 0 && pt_info->u.full_band_scan_info.t_step == 0 && pt_info->u.full_band_scan_info.t_max == 0)
979 {
980 oos_info.state = 0;
981 }
982 else
983 {
984 LOGE("qser_nw_set_oos_config set Format err");
985 return -1;
986 }
987
988 int err = mbtk_oos_set(qser_info_handle, &oos_info);
989 if (err != 0)
990 {
991 LOGE("qser_nw_set_oos_config mbtk_oos_set err");
992 return -1;
993 }
994 }
995 else if (tmp_type == QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
996 {
997 LOGE("Not currently supported");
998 return -1;
999 }
1000 else
1001 {
1002 LOGE("type is error");
1003 return -1;
1004 }
1005
1006 return 0;
1007}
1008
1009int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
1010{
1011 if(h_nw != qser_h_nw)
1012 {
1013 LOGE("[qser_nw] h_nw is error.");
1014 return QSER_RESULT_FAIL;
1015 }
1016
1017 if (pt_info == NULL)
1018 {
1019 LOGE("QSER_NW_OOS_CONFIG_INFO_T NULL");
1020 return -1;
1021 }
1022
1023 mbtk_ril_oos_info_t oos_info;
1024// uint32 oosPhase_0, oosPhase_1, oosPhase_2;
1025// char cmd[100] = {0};
1026
1027 memset(&oos_info, 0x00, sizeof(mbtk_ril_oos_info_t));
1028
1029 int err = mbtk_oos_get(qser_info_handle, &oos_info);
1030 if (err != 0)
1031 {
1032 LOGE("qser_nw_get_oos_config mbtk_oos_get err ");
1033 return -1;
1034 }
1035/*
1036 printf("oos_info.mode =[%d] \n",oos_info.mode);
1037 printf("oos_info.1 =[%d] \n",oos_info.oosPhase[0]);
1038 printf("oos_info.2 =[%d] \n",oos_info.oosPhase[1]);
1039 printf("oos_info.3 =[%d] \n",oos_info.oosPhase[2]);
1040*/
1041 if(oos_info.state == 0)//关闭状态
1042 {
1043 pt_info->u.full_band_scan_info.t_min = 0;
1044 pt_info->u.full_band_scan_info.t_step = 0;
1045 pt_info->u.full_band_scan_info.t_max = 0;
1046 }
1047 else
1048 {
1049 pt_info->u.full_band_scan_info.t_min = (int)oos_info.oosPhase[0];
1050 pt_info->u.full_band_scan_info.t_step = (int)oos_info.oosPhase[1];
1051 pt_info->u.full_band_scan_info.t_max = (int)oos_info.oosPhase[2];
1052 }
1053 pt_info->type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;
1054
1055
1056 if (pt_info == NULL)
1057 {
1058 LOGE("qser_nw_get_oos_config pt_info is null ");
1059 return -1;
1060 }
1061
1062 return 0;
1063}
1064
1065int qser_nw_set_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode)
1066{
1067 //UNUSED(h_nw);
1068 //UNUSED(rf_mode);
1069 int ret;
1070
1071 if(h_nw != qser_h_nw)
1072 {
1073 LOGE("[qser_nw] h_nw is error.");
1074 return QSER_RESULT_FAIL;
1075 }
1076
1077 if(qser_info_handle == NULL)
1078 {
1079 LOGE("qser_info_handle == NULL.");
1080 return -1;
1081 }
1082
1083/*
1084 if (rf_mode == 4)
1085 {
1086 printf("Flight Mode no Support Now\n");
1087 return -1;
1088 }
1089*/
1090 if (rf_mode != 4 && rf_mode != 0 && rf_mode != 1)
1091 {
1092 LOGE("mode is error!");
1093 return -1;
1094 }
1095
1096 ret = mbtk_radio_state_set(qser_info_handle, rf_mode, 0);
1097
1098 //ret = mbtk_radio_state_set(qser_info_handle, rf_mode);
1099 if (ret != 0)
1100 {
1101 LOGE("mbtk_radio_state_set fail.");
1102 return -1;
1103 }
1104 else
1105 {
1106 LOGI("qser_nw_set_rf_mode is success\n");
1107 }
1108
1109 return 0;
1110}
1111
1112int qser_nw_get_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T *rf_mode)
1113{
1114 //UNUSED(h_nw);
1115 //UNUSED(rf_mode);
1116 int ret;
1117 mbtk_radio_state_enum tmp_rf;
1118
1119 if(h_nw != qser_h_nw)
1120 {
1121 LOGE("[qser_nw] h_nw is error.");
1122 return QSER_RESULT_FAIL;
1123 }
1124
1125 if(qser_info_handle == NULL)
1126 {
1127 LOGE("qser_info_handle == NULL.");
1128 return -1;
1129 }
1130
1131 ret = mbtk_radio_state_get(qser_info_handle, &tmp_rf);
1132
1133 //ret = mbtk_radio_state_get(qser_info_handle, &tmp_rf);
1134 if (ret != 0)
1135 {
1136 LOGE("mbtk_radio_state_get fail.");
1137 return -1;
1138 }
1139 else
1140 {
1141 LOGI("qser_nw_get_rf_mode is success\n");
1142 *rf_mode = tmp_rf;
1143 }
1144
1145
1146 return 0;
1147}
1148
1149int qser_nw_set_ims_enable(nw_client_handle_type h_nw, E_QSER_NW_IMS_MODE_TYPE_T ims_mode)
1150{
1151 int ret = 0;
1152
1153 if(h_nw != qser_h_nw)
1154 {
1155 LOGE("[qser_nw] h_nw is error.");
1156 return QSER_RESULT_FAIL;
1157 }
1158
1159 if(qser_info_handle == NULL)
1160 {
1161 LOGE("qser_info_handle == NULL.");
1162 return -1;
1163 }
1164
1165 ret = mbtk_volte_state_set(qser_info_handle, ims_mode);
1166 if (ret != 0)
1167 {
1168 LOGE("mbtk_net_ims_set fail.");
1169 return -1;
1170 }
1171
1172 return 0;
1173}
1174
1175int qser_nw_get_ims_reg_status(nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info)
1176{
1177 int ret = 0;
1178 int tmp_pt;
1179
1180 if(h_nw != qser_h_nw)
1181 {
1182 LOGE("[qser_nw] h_nw is error.");
1183 return QSER_RESULT_FAIL;
1184 }
1185
1186 if(qser_info_handle == NULL)
1187 {
1188 LOGE("qser_info_handle == NULL.");
1189 return -1;
1190 }
1191
1192 ret = mbtk_volte_state_get(qser_info_handle, &tmp_pt);
1193 if (ret != 0)
1194 {
1195 LOGE("mbtk_net_ims_get fail.");
1196 return -1;
1197 }
1198
1199 if (tmp_pt == 0)
1200 pt_info->registration_state = E_QSER_NW_IMS_SERVICE_NONE;
1201 else if (tmp_pt == 1)
1202 pt_info->registration_state = E_QSER_NW_IMS_SERVICE_REGISTERED;
1203 else
1204 {
1205 LOGE("mbtk_net_ims_get value error fail.");
1206 return -1;
1207 }
1208
1209 return 0;
1210}
1211
1212