blob: 98bf35912ab52edd349b9961be5c42196ed5dcfd [file] [log] [blame]
b.liu4e243dc2023-11-27 11:20:00 +08001#include "lynq_qser_network.h"
r.xiaoe73f8702024-01-06 01:40:03 -08002#include "mbtk_type.h"
3#include "mbtk_info_api.h"
r.xiaoba8483c2024-04-14 18:53:10 -07004#include "mbtk_log.h"
r.xiaoe73f8702024-01-06 01:40:03 -08005
6#include <stdio.h>
7#include <stdlib.h>
8
9mbtk_info_handle_t* lynq_nw_info_handle = NULL;
10uint64_t tmp_mode = 0xFF;
11
12nw_client_handle_type g_nw_val = -1;
13
r.xiaoe73f8702024-01-06 01:40:03 -080014typedef struct
15{
16 QSER_NW_RxMsgHandlerFunc_t handlerPtr;
17 void* contextPtr;
18} lynq_cust_cb_func;
19
20static lynq_cust_cb_func lynq_func_cb_handle;
21
22static int roaming_pref = 1; // Open roaming for default.
23
24typedef enum {
25 RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
26 RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
27} RIL_RadioTechnologyFamily;
28
29
30typedef struct
31{
32 uint8 *lynq_operator_l;
33 uint8 *lynq_operator_s;
34 uint32 lynq_mcc_mnc;
35} lynq_operator_mcc_mnc_t;
36
37static lynq_operator_mcc_mnc_t lynq_operator_mcc_mnc[] =
38{
39 {"China Mobile","CMCC",46000},
40 {"China Unicom","CU",46001},
41 {"China Mobile","CMCC",46002},
42 {"China Telecom","CT",46003},
43 {"China Mobile","CMCC",46004},
44 {"China Telecom","CT",46005},
45 {"China Unicom","CU",46006},
46 {"China Mobile","CMCC",46007},
47 {"China Mobile","CMCC",46008},
48 {"China Unicom","CU",46009},
49 {"China Telecom","CT",46011}
50};
51
52void lynq_nw_state_change_cb(const void* data, int data_len)
53{
r.xiaocfd7c682024-01-22 03:59:46 -080054
55/*
r.xiaoe73f8702024-01-06 01:40:03 -080056 uint8 *net_data = NULL;
57
58 net_data = (uint8*)data;
r.xiaoe73f8702024-01-06 01:40:03 -080059
r.xiaocfd7c682024-01-22 03:59:46 -080060 if(data && data_len > 0)
r.xiaoe73f8702024-01-06 01:40:03 -080061 {
r.xiaocfd7c682024-01-22 03:59:46 -080062 if(*net_data == 0)
63 { // CS
64 printf("CS:act=%d, mode=%d\n", *(net_data + 1), *(net_data + 2));
65 }
66 else
67 { // PS
68 printf("PS[%s]:act=%d, mode=%d\n", *(net_data + 3) == 0 ? "GSM/WCDMA" : "LTE", *(net_data + 1), *(net_data + 2));
69 }
r.xiaoe73f8702024-01-06 01:40:03 -080070 }
71 else
72 {
r.xiaocfd7c682024-01-22 03:59:46 -080073 printf("NET_CB : NULL");
r.xiaoe73f8702024-01-06 01:40:03 -080074 }
r.xiaoe73f8702024-01-06 01:40:03 -080075*/
76
r.xiaocfd7c682024-01-22 03:59:46 -080077 if(lynq_func_cb_handle.handlerPtr != NULL)//数据原样输出
r.xiaoe73f8702024-01-06 01:40:03 -080078 {
r.xiaocfd7c682024-01-22 03:59:46 -080079 lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_DATA_REG_EVENT_IND_FLAG, data, data_len, NULL);
r.xiaoe73f8702024-01-06 01:40:03 -080080 }
81}
82
83
84static uint8 lynq_net_pre_change(bool mbtk_2_lynq,int net_mode)
85{
86 uint8 mbtk_net_pre = 0xFF;
87
88#if 0
89 此参数表在别处使用
90 E_QSER_NW_RADIO_TECH_TD_SCDMA = 1, Y3 1
91 E_QSER_NW_RADIO_TECH_GSM = 2, /**< GSM; only supports voice. */ YL2 0
92 E_QSER_NW_RADIO_TECH_HSPAP = 3, /**< HSPA+. */ 3 1
93 E_QSER_NW_RADIO_TECH_LTE = 4, /**< LTE. */ 4 5
94 E_QSER_NW_RADIO_TECH_EHRPD = 5, /**< EHRPD. */ 3 1
95 E_QSER_NW_RADIO_TECH_EVDO_B = 6, /**< EVDO B. */ D3 1
96 E_QSER_NW_RADIO_TECH_HSPA = 7, /**< HSPA. */ 3 1
97 E_QSER_NW_RADIO_TECH_HSUPA = 8, /**< HSUPA. */ 3.5 1
98 E_QSER_NW_RADIO_TECH_HSDPA = 9, /**< HSDPA. */ 3.5 1
99 E_QSER_NW_RADIO_TECH_EVDO_A = 10, /**< EVDO A. */ D3 1
100 E_QSER_NW_RADIO_TECH_EVDO_0 = 11, /**< EVDO 0. */ D3 1
101 E_QSER_NW_RADIO_TECH_1xRTT = 12, /**< 1xRTT. */ 2 0
102 E_QSER_NW_RADIO_TECH_IS95B = 13, /**< IS95B. */ 3 0
103 E_QSER_NW_RADIO_TECH_IS95A = 14, /**< IS95A. */ 3 0
104 E_QSER_NW_RADIO_TECH_UMTS = 15, /**< UMTS. */ L3 1
105 E_QSER_NW_RADIO_TECH_EDGE = 16, /**< EDGE. */ 2.75 0
106 E_QSER_NW_RADIO_TECH_GPRS = 17, /**< GPRS. */ 2.5 0
107 E_QSER_NW_RADIO_TECH_NONE = 18 /**< No technology selected. */
108#endif
109 /*
110 0 : GSM only
111 1 : UMTS only
112 2 : GSM/UMTS(auto)
113 3 : GSM/UMTS(GSM preferred)
114 4 : GSM/UMTS(UMTS preferred)
115 5 : LTE only
116 6 : GSM/LTE(auto)
117 7 : GSM/LTE(GSM preferred)
118 8 : GSM/LTE(LTE preferred)
119 9 : UMTS/LTE(auto)
120 10 : UMTS/LTE(UMTS preferred)
121 11 : UMTS/LTE(LTE preferred)
122 12 : GSM/UMTS/LTE(auto)
123 13 : GSM/UMTS/LTE(GSM preferred)
124 14 : GSM/UMTS/LTE(UMTS preferred)
125 15 : GSM/UMTS/LTE(LTE preferred)
126 */
127
128 if(mbtk_2_lynq) {
129 switch(net_mode)
130 {
131 //使用之前set的tmp_mode的值来进行回显get
132 case QSER_NW_MODE_GSM:
133 mbtk_net_pre = QSER_NW_MODE_GSM;
134 break;
135 case QSER_NW_MODE_WCDMA:
136 mbtk_net_pre = QSER_NW_MODE_WCDMA;
137 break;
138 case QSER_NW_MODE_CDMA:
139 mbtk_net_pre = QSER_NW_MODE_CDMA;
140 break;
141 case QSER_NW_MODE_EVDO:
142 mbtk_net_pre = QSER_NW_MODE_EVDO;
143 break;
144 case QSER_NW_MODE_LTE:
145 mbtk_net_pre = QSER_NW_MODE_LTE;
146 break;
147 case QSER_NW_MODE_TDSCDMA:
148 mbtk_net_pre = QSER_NW_MODE_TDSCDMA;
149 break;
150 default:
151 mbtk_net_pre = 0xFF;
152 break;
153 }
154 } else {
155 switch(net_mode)
156 {
r.xiaocfd7c682024-01-22 03:59:46 -0800157 //只做234G的下配 MBTK_NET_PREF_GSM_ONLY/MBTK_NET_PREF_GSM_UMTS_UMTS_PREF/MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF
r.xiaoe73f8702024-01-06 01:40:03 -0800158 case QSER_NW_MODE_GSM:
159 mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
160 break;
161 case QSER_NW_MODE_WCDMA:
162 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
163 break;
164 case QSER_NW_MODE_CDMA:
165 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
166 break;
167 case QSER_NW_MODE_EVDO:
168 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
169 break;
170 case QSER_NW_MODE_LTE:
171 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;
172 break;
173 case QSER_NW_MODE_TDSCDMA:
174 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
175 break;
176 default:
177 mbtk_net_pre = 0xFF;
178 break;
179 }
180 }
181 return mbtk_net_pre;
182}
b.liu5fa9e772023-11-23 18:00:55 +0800183
184int qser_nw_client_init(nw_client_handle_type *ph_nw)
185{
r.xiaoe73f8702024-01-06 01:40:03 -0800186 //UNUSED(ph_nw);
b.liu5fa9e772023-11-23 18:00:55 +0800187
r.xiaoe73f8702024-01-06 01:40:03 -0800188 if(lynq_nw_info_handle == NULL)
189 {
190 lynq_nw_info_handle = mbtk_info_handle_get();
191 if(lynq_nw_info_handle)
192 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800193 LOGI("creat lynq_nw_info_handle is success");
r.xiaoe73f8702024-01-06 01:40:03 -0800194 *ph_nw = lynq_nw_info_handle->client_fd;
195 g_nw_val = lynq_nw_info_handle->client_fd;
196 }
197 else
198 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800199 LOGE("creat lynq_nw_info_handle is fail");
r.xiaoe73f8702024-01-06 01:40:03 -0800200 return -1;
201 }
202 }
203
b.liu5fa9e772023-11-23 18:00:55 +0800204 return 0;
205}
206
207int qser_nw_client_deinit(nw_client_handle_type h_nw)
208{
r.xiaoe73f8702024-01-06 01:40:03 -0800209 //UNUSED(h_nw);
210 if (h_nw != g_nw_val || g_nw_val == -1)
211 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800212 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800213 return -1;
214 }
215
216 if(lynq_nw_info_handle)
217 {
218 mbtk_info_handle_free(&lynq_nw_info_handle);
219 }
220 else
221 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800222 LOGE("deinit lynq_nw_info_handle is fail");
r.xiaoe73f8702024-01-06 01:40:03 -0800223 return -1;
224 }
b.liu5fa9e772023-11-23 18:00:55 +0800225
226 return 0;
227}
228
229int qser_nw_set_config(nw_client_handle_type h_nw,QSER_NW_CONFIG_INFO_T *pt_info)
230{
r.xiaoe73f8702024-01-06 01:40:03 -0800231 //UNUSED(h_nw);
232 //UNUSED(pt_info);
233 if (h_nw != g_nw_val || g_nw_val == -1)
234 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800235 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800236 return -1;
237 }
238
239 if(lynq_nw_info_handle == NULL)
240 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800241 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800242 return -1;
243 }
244
245 if(pt_info == NULL)
246 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800247 LOGE("pt_info == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800248 return -1;
249 }
250
251 roaming_pref = pt_info->roaming_pref;
252
253 mbtk_band_info_t band;
254 memset(&band, 0, sizeof(mbtk_band_info_t));
255 tmp_mode = pt_info->preferred_nw_mode;//临时保存一下原本的mode
256
257 //printf("tmp_mode = [%llu]",tmp_mode);
258 band.net_pref = lynq_net_pre_change(FALSE, pt_info->preferred_nw_mode);
r.xiaod9dd06e2024-02-02 04:17:52 -0800259 LOGI("band.net_pref = [%d] ",band.net_pref);
r.xiaoe73f8702024-01-06 01:40:03 -0800260
261 if(band.net_pref == 0xFF)
262 {
263 LOGE("lynq_net_pre_change() fail.");
264 return -1;
265 }
266
267 if(mbtk_current_band_set(lynq_nw_info_handle, &band))
268 {
269 return -1;
270 }
b.liu5fa9e772023-11-23 18:00:55 +0800271
272 return 0;
273}
274
275int qser_nw_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info)
276{
r.xiaoe73f8702024-01-06 01:40:03 -0800277 //UNUSED(h_nw);
278 //UNUSED(pt_info);
279 if (h_nw != g_nw_val || g_nw_val == -1)
280 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800281 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800282 return -1;
283 }
b.liu5fa9e772023-11-23 18:00:55 +0800284
r.xiaoe73f8702024-01-06 01:40:03 -0800285 if(lynq_nw_info_handle == NULL)
286 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800287 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800288 return -1;
289 }
290
291 if(pt_info == NULL)
292 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800293 LOGE("pt_info == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800294 return -1;
295 }
296
297 char OperatorFN[128];
298 char OperatorSH[128];
299 char MccMnc[128];
300 mbtk_net_info_t net;
301 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
302 {
303 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
304 int i = 0;
305 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
306 {
307 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
308 break;
309 i++;
310 }
311
312 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
313 {
314 strcpy(OperatorFN, "UNKNOWN");
315 strcpy(OperatorSH, "UNKNOWN");
316 sprintf(MccMnc, "%d", net.plmn);
317 }
318 else
319 {
320 strcpy(OperatorFN, lynq_operator_mcc_mnc[i].lynq_operator_l);
321 strcpy(OperatorSH, lynq_operator_mcc_mnc[i].lynq_operator_s);
322 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
323 }
324 memset(pt_info->long_eons,0,128);
325 memcpy(pt_info->long_eons,lynq_operator_mcc_mnc[i].lynq_operator_l,strlen(lynq_operator_mcc_mnc[i].lynq_operator_l));
326 memset(pt_info->short_eons,0,128);
327 memcpy(pt_info->short_eons,lynq_operator_mcc_mnc[i].lynq_operator_s,strlen(lynq_operator_mcc_mnc[i].lynq_operator_s));
328 memset(pt_info->mcc,0,4);
329 memset(pt_info->mnc,0,4);
330 sprintf(pt_info->mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
331 sprintf(pt_info->mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
332 //pt_info->act;
333 return 0;
334 }
335
336 return -1;
b.liu5fa9e772023-11-23 18:00:55 +0800337}
338
339int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info)
340{
r.xiaoe73f8702024-01-06 01:40:03 -0800341 //UNUSED(h_nw);
342 //UNUSED(pt_info);
343 if (h_nw != g_nw_val || g_nw_val == -1)
344 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800345 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800346 return -1;
347 }
348
349 if(lynq_nw_info_handle == NULL)
350 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800351 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800352 return -1;
353 }
354
355 if(pt_info == NULL)
356 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800357 LOGE("pt_info == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800358 return -1;
359 }
360
361 /*VOICE/DATA/IMS*/
362 mbtk_net_reg_info_t reg;
363 int err = mbtk_net_reg_get(lynq_nw_info_handle, &reg);
364 if(err)
365 {
366 LOGE("mbtk_net_reg_get fail.");
367 return -1;
368 }
369 else
370 {
371 memset(pt_info, 0x0, sizeof(QSER_NW_REG_STATUS_INFO_T));
372
373
374 char OperatorFN[128];
375 char OperatorSH[128];
376 char MccMnc[128];
377 mbtk_net_info_t net;
378 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
379 {
380 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
381 int i = 0;
382 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
383 {
384 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
385 break;
386 i++;
387 }
388
389 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
390 {
391 strcpy(OperatorFN, "UNKNOWN");
392 strcpy(OperatorSH, "UNKNOWN");
393 sprintf(MccMnc, "%d", net.plmn);
394 }
395 else
396 {
397 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
398 }
399 sprintf(pt_info->data_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
400 sprintf(pt_info->data_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
401 sprintf(pt_info->voice_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
402 sprintf(pt_info->voice_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
403 //pt_info->act;
404 }
405
406 //暂时未知是否其他也被使用,现根据ql模块的传输情况,
407 //只配置3gpp,涉及call,data状态没有对应的匹配的就没有赋值
408
409 pt_info->voice_registration_valid = FALSE;
410 //pt_info->voice_registration
411
412 pt_info->data_registration_valid = FALSE;
413 //pt_info->data_registration
414
415 pt_info->voice_registration_details_3gpp_valid = TRUE;
416 pt_info->voice_registration_details_3gpp.lac = reg.lac;
417 pt_info->voice_registration_details_3gpp.cid = reg.ci;
418 //补位填0 or 1
419 pt_info->voice_registration_details_3gpp.tech_domain = 1;
420 pt_info->voice_registration_details_3gpp.roaming = 0;
421 pt_info->voice_registration_details_3gpp.forbidden = 0;
422 pt_info->voice_registration_details_3gpp.psc = 0;
423 pt_info->voice_registration_details_3gpp.tac = 0;
424
425 pt_info->data_registration_details_3gpp_valid = TRUE;
426 pt_info->data_registration_details_3gpp.lac = reg.lac;
427 pt_info->data_registration_details_3gpp.cid = reg.ci;
428 //补位填0 or 1
429 pt_info->data_registration_details_3gpp.tech_domain = 1;
430 pt_info->data_registration_details_3gpp.roaming = 0;
431 pt_info->data_registration_details_3gpp.forbidden = 0;
432 pt_info->data_registration_details_3gpp.psc = 0;
433 pt_info->data_registration_details_3gpp.tac = 0;
434
435
436 pt_info->voice_registration_details_3gpp2_valid = FALSE;
437 //pt_info->voice_registration_details_3gpp2
438
439 pt_info->data_registration_details_3gpp2_valid = FALSE;
440 //pt_info->data_registration_details_3gpp2
441
442
443 switch(reg.type)
444 {
445 case MBTK_RADIO_TECH_GSM:
446 case MBTK_RADIO_TECH_GSM_COMPACT:
447 case MBTK_RADIO_TECH_GSM_EGPRS:
448 case MBTK_RADIO_TECH_UTRAN_HSPA:
449 {
450 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GPRS;
451 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GSM;
452 break;
453 }
454 case MBTK_RADIO_TECH_UTRAN:
455 case MBTK_RADIO_TECH_UTRAN_HSDPA:
456 case MBTK_RADIO_TECH_UTRAN_HSUPA:
457 case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
458 {
459 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
460 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
461 break;
462 }
463 case MBTK_RADIO_TECH_E_UTRAN:
464 {
465 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
466 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
467 break;
468 }
469 default:
470 {
471 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
472 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
473 break;
474 }
475 }
476 }
b.liu5fa9e772023-11-23 18:00:55 +0800477
478 return 0;
479}
480
481int qser_nw_get_signal_strength(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
482{
r.xiaoe73f8702024-01-06 01:40:03 -0800483 //UNUSED(h_nw);
484 //UNUSED(pt_info);
485 if (h_nw != g_nw_val || g_nw_val == -1)
486 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800487 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800488 return -1;
489 }
490
491 if(lynq_nw_info_handle == NULL)
492 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800493 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800494 return -1;
495 }
496
497 if(pt_info == NULL)
498 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800499 LOGE("pt_info == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800500 return -1;
501 }
502
503 int ret;
504 mbtk_signal_info_t signal;
505 ret = mbtk_net_signal_get(lynq_nw_info_handle, &signal);
506 if(ret != 0) {
507 LOGE("mbtk_net_signal_get fail.");
508 return -1;
509 }
510 else
511 {
512 memset(pt_info, 0x0, sizeof(QSER_NW_SIGNAL_STRENGTH_INFO_T));
513 if(signal.type == MBTK_RADIO_TECH_GSM || signal.type == MBTK_RADIO_TECH_GSM_COMPACT || \
514 signal.type == MBTK_RADIO_TECH_GSM_EGPRS) //GSM
515 {
516 pt_info->gsm_sig_info_valid = TRUE;
517 pt_info->gsm_sig_info.rssi = signal.rssi;
518 }
519 else if(signal.type == MBTK_RADIO_TECH_E_UTRAN) //LTE
520 {
521 pt_info->lte_sig_info_valid = TRUE;
522 pt_info->lte_sig_info.rsrp = signal.rsrp;
523 pt_info->lte_sig_info.rsrq = signal.rsrq;
524 pt_info->lte_sig_info.snr = 0; //->MBTK接口无该参数,写死值为0
525 pt_info->lte_sig_info.rssi = signal.rssi;
526 }
527 else if (signal.type == MBTK_RADIO_TECH_UTRAN || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA || \
528 signal.type == MBTK_RADIO_TECH_UTRAN_HSUPA || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA || \
529 signal.type == MBTK_RADIO_TECH_UTRAN_HSPA )//WCDMA
530 {
531 pt_info->wcdma_sig_info_valid = TRUE;
532 pt_info->wcdma_sig_info.rssi = signal.rssi;
533 pt_info->wcdma_sig_info.ecio = 0; //->MBTK接口无该参数,写死值为0
534 }
535 else
536 {
537 return -1;
538 }
539 }
b.liu5fa9e772023-11-23 18:00:55 +0800540
541 return 0;
542}
543
b.liu4e243dc2023-11-27 11:20:00 +0800544int qser_nw_add_rx_msg_handler (nw_client_handle_type h_nw, QSER_NW_RxMsgHandlerFunc_t handlerPtr, void* contextPtr)
b.liu5fa9e772023-11-23 18:00:55 +0800545{
r.xiaoe73f8702024-01-06 01:40:03 -0800546 //UNUSED(h_nw);
547 //UNUSED(handlerPtr);
548 //UNUSED(contextPtr);
549
550 if (h_nw != g_nw_val || g_nw_val == -1)
551 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800552 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800553 return -1;
554 }
555
556 if(lynq_nw_info_handle == NULL)
557 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800558 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800559 return -1;
560 }
561
562 lynq_func_cb_handle.handlerPtr = handlerPtr;
563 lynq_func_cb_handle.contextPtr = contextPtr;
564
565 mbtk_net_state_change_cb_reg(lynq_nw_info_handle, lynq_nw_state_change_cb);
b.liu5fa9e772023-11-23 18:00:55 +0800566
567 return 0;
568}
569
570int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
571{
r.xiaocfd7c682024-01-22 03:59:46 -0800572 //UNUSED(h_nw);
573 //UNUSED(pt_info);
574 if (h_nw != g_nw_val || g_nw_val == -1)
575 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800576 LOGE("handle NULL");
r.xiaocfd7c682024-01-22 03:59:46 -0800577 return -1;
578 }
579
580 if (pt_info == NULL)
581 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800582 LOGE("QSER_NW_OOS_CONFIG_INFO_T NULL");
r.xiaocfd7c682024-01-22 03:59:46 -0800583 return -1;
584 }
585
586 uint32 oosPhase_0, oosPhase_1, oosPhase_2;
587 char tmp_type;
588 mbtk_oos_info oos_info;
589
590 memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
591
592
593 tmp_type = pt_info->type;
594
595 if (tmp_type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
596 {//如果没有配置对应的值,例如,10,20
597 //oosPhase_2这个位置没有配置,则使用默认值20,既不限制次数的5s进行一次扫描
598 //同理oosPhase_0,oosPhase_1这个位置没有配置,则使用默认值5,10,既限制次数5次的5s,10s进行一次扫描
599 //输入多少配置多少,可以缺省使用默认值
600 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)
601 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800602 LOGE("qser_nw_set_oos_config set time < 0 ");
r.xiaocfd7c682024-01-22 03:59:46 -0800603 return -1;
604 }
605 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)
606 {
607 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
608 oos_info.mode = 1;
609 oos_info.oosPhase[0] = oosPhase_0;
610 }
611 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)
612 {
613 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
614 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
615 oos_info.mode = 1;
616 oos_info.oosPhase[0] = oosPhase_0;
617 oos_info.oosPhase[1] = oosPhase_1;
618 }
619 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))
620 {
621 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
622 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
623 oosPhase_2 = pt_info->u.full_band_scan_info.t_max;
624 oos_info.mode = 1;
625 oos_info.oosPhase[0] = oosPhase_0;
626 oos_info.oosPhase[1] = oosPhase_1;
627 oos_info.oosPhase[2] = oosPhase_2;
628 }
629 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)
630 {
631 oos_info.mode = 0;
632 }
633 else
634 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800635 LOGE("qser_nw_set_oos_config set Format err");
r.xiaocfd7c682024-01-22 03:59:46 -0800636 return -1;
637 }
638
639 int err = mbtk_oos_set(lynq_nw_info_handle, &oos_info);
640 if (err != 0)
641 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800642 LOGE("qser_nw_set_oos_config mbtk_oos_set err");
r.xiaocfd7c682024-01-22 03:59:46 -0800643 return -1;
644 }
645 }
646 else if (tmp_type == QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
647 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800648 LOGE("Not currently supported");
r.xiaocfd7c682024-01-22 03:59:46 -0800649 return -1;
650 }
651 else
652 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800653 LOGE("type is error");
r.xiaocfd7c682024-01-22 03:59:46 -0800654 return -1;
655 }
b.liu5fa9e772023-11-23 18:00:55 +0800656
657 return 0;
658}
659
660int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
661{
r.xiaocfd7c682024-01-22 03:59:46 -0800662 //UNUSED(h_nw);
663 //UNUSED(pt_info);
664 if (h_nw != g_nw_val || g_nw_val == -1)
665 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800666 LOGE("handle NULL");
r.xiaocfd7c682024-01-22 03:59:46 -0800667 return -1;
668 }
669
670 mbtk_oos_info oos_info;
671 uint32 oosPhase_0, oosPhase_1, oosPhase_2;
672 char cmd[100] = {0};
673
674 memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
675
676 int err = mbtk_oos_get(lynq_nw_info_handle, &oos_info);
677 if (err != 0)
678 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800679 LOGE("qser_nw_get_oos_config mbtk_oos_get err ");
r.xiaocfd7c682024-01-22 03:59:46 -0800680 return -1;
681 }
r.xiaoffbe6ce2024-01-22 19:01:01 -0800682/*
r.xiaocfd7c682024-01-22 03:59:46 -0800683 printf("oos_info.mode =[%d] \n",oos_info.mode);
684 printf("oos_info.1 =[%d] \n",oos_info.oosPhase[0]);
685 printf("oos_info.2 =[%d] \n",oos_info.oosPhase[1]);
686 printf("oos_info.3 =[%d] \n",oos_info.oosPhase[2]);
r.xiaoffbe6ce2024-01-22 19:01:01 -0800687*/
r.xiaocfd7c682024-01-22 03:59:46 -0800688 if(oos_info.mode == 0)//关闭状态
689 {
690 pt_info->u.full_band_scan_info.t_min = 0;
691 pt_info->u.full_band_scan_info.t_step = 0;
692 pt_info->u.full_band_scan_info.t_max = 0;
693 }
694 else
695 {
696 pt_info->u.full_band_scan_info.t_min = (int)oos_info.oosPhase[0];
697 pt_info->u.full_band_scan_info.t_step = (int)oos_info.oosPhase[1];
698 pt_info->u.full_band_scan_info.t_max = (int)oos_info.oosPhase[2];
699 }
700 pt_info->type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;
701
702
703 if (pt_info == NULL)
704 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800705 LOGE("qser_nw_get_oos_config pt_info is null ");
r.xiaocfd7c682024-01-22 03:59:46 -0800706 return -1;
707 }
b.liu5fa9e772023-11-23 18:00:55 +0800708
709 return 0;
r.xiaoe73f8702024-01-06 01:40:03 -0800710}
711
712int qser_nw_set_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode)
713{
714 //UNUSED(h_nw);
715 //UNUSED(rf_mode);
716 int ret;
r.xiaocfd7c682024-01-22 03:59:46 -0800717 mbtk_modem_info_t info;
r.xiaoe73f8702024-01-06 01:40:03 -0800718
719 if (h_nw != g_nw_val || g_nw_val == -1)
720 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800721 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800722 return -1;
723 }
724
725 if(lynq_nw_info_handle == NULL)
726 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800727 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800728 return -1;
729 }
730
r.xiaocfd7c682024-01-22 03:59:46 -0800731/*
r.xiaoe73f8702024-01-06 01:40:03 -0800732 if (rf_mode == 4)
733 {
734 printf("Flight Mode no Support Now\n");
735 return -1;
736 }
r.xiaocfd7c682024-01-22 03:59:46 -0800737*/
738 if (rf_mode != 4 && rf_mode != 0 && rf_mode != 1)
739 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800740 LOGE("mode is error!");
r.xiaocfd7c682024-01-22 03:59:46 -0800741 return -1;
742 }
r.xiaoe73f8702024-01-06 01:40:03 -0800743
r.xiaocfd7c682024-01-22 03:59:46 -0800744 info.fun = rf_mode;
745 info.rst = 0;
746 ret = mbtk_set_modem_fun(lynq_nw_info_handle, &info);
747
748 //ret = mbtk_radio_state_set(lynq_nw_info_handle, rf_mode);
r.xiaoe73f8702024-01-06 01:40:03 -0800749 if (ret != 0)
750 {
751 LOGE("mbtk_radio_state_set fail.");
752 return -1;
753 }
754 else
755 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800756 LOGI("qser_nw_set_rf_mode is success\n");
r.xiaoe73f8702024-01-06 01:40:03 -0800757 }
758
759 return 0;
760}
761
762int qser_nw_get_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T *rf_mode)
763{
764 //UNUSED(h_nw);
765 //UNUSED(rf_mode);
766 int ret;
767 int tmp_rf;
768
769 if (h_nw != g_nw_val || g_nw_val == -1)
770 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800771 LOGE("handle NULL");
r.xiaoe73f8702024-01-06 01:40:03 -0800772 return -1;
773 }
774
775 if(lynq_nw_info_handle == NULL)
776 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800777 LOGE("lynq_nw_info_handle == NULL.");
r.xiaoe73f8702024-01-06 01:40:03 -0800778 return -1;
779 }
780
r.xiaocfd7c682024-01-22 03:59:46 -0800781 ret = mbtk_get_modem_fun(lynq_nw_info_handle, &tmp_rf);
782
783 //ret = mbtk_radio_state_get(lynq_nw_info_handle, &tmp_rf);
r.xiaoe73f8702024-01-06 01:40:03 -0800784 if (ret != 0)
785 {
786 LOGE("mbtk_radio_state_get fail.");
787 return -1;
788 }
789 else
790 {
r.xiaod9dd06e2024-02-02 04:17:52 -0800791 LOGI("qser_nw_get_rf_mode is success\n");
r.xiaoe73f8702024-01-06 01:40:03 -0800792 *rf_mode = tmp_rf;
793 }
794
795
796 return 0;
797}
798
r.xiaoba8483c2024-04-14 18:53:10 -0700799int qser_nw_set_ims_enable(nw_client_handle_type h_nw, E_QSER_NW_IMS_MODE_TYPE_T ims_mode)
800{
801 int ret = 0;
802
803 if (h_nw != g_nw_val || g_nw_val == -1)
804 {
805 LOGE("handle NULL");
806 return -1;
807 }
808
809 if(lynq_nw_info_handle == NULL)
810 {
811 LOGE("lynq_nw_info_handle == NULL.");
812 return -1;
813 }
814
815 ret = mbtk_net_ims_set(lynq_nw_info_handle, ims_mode);
816 if (ret != 0)
817 {
818 LOGE("mbtk_net_ims_set fail.");
819 return -1;
820 }
821
822 return 0;
823}
824
825int qser_nw_get_ims_reg_status(nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info)
826{
827 int ret = 0;
828 int tmp_pt;
829
830 if (h_nw != g_nw_val || g_nw_val == -1)
831 {
832 LOGE("handle NULL");
833 return -1;
834 }
835
836 if(lynq_nw_info_handle == NULL)
837 {
838 LOGE("lynq_nw_info_handle == NULL.");
839 return -1;
840 }
841
842 ret = mbtk_net_ims_get(lynq_nw_info_handle, &tmp_pt);
843 if (ret != 0)
844 {
845 LOGE("mbtk_net_ims_get fail.");
846 return -1;
847 }
848
849 if (tmp_pt == 0)
850 pt_info->registration_state = E_QSER_NW_IMS_SERVICE_NONE;
851 else if (tmp_pt == 1)
852 pt_info->registration_state = E_QSER_NW_IMS_SERVICE_REGISTERED;
853 else
854 {
855 LOGE("mbtk_net_ims_get value error fail.");
856 return -1;
857 }
858
859 return 0;
860}
861
r.xiaoe73f8702024-01-06 01:40:03 -0800862