blob: 7b5eb9f4c782034ff291f3da1fe066bffb4146d4 [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"
4
5#include <stdio.h>
6#include <stdlib.h>
7
8mbtk_info_handle_t* lynq_nw_info_handle = NULL;
9uint64_t tmp_mode = 0xFF;
10
11nw_client_handle_type g_nw_val = -1;
12
r.xiaoe73f8702024-01-06 01:40:03 -080013typedef struct
14{
15 QSER_NW_RxMsgHandlerFunc_t handlerPtr;
16 void* contextPtr;
17} lynq_cust_cb_func;
18
19static lynq_cust_cb_func lynq_func_cb_handle;
20
21static int roaming_pref = 1; // Open roaming for default.
22
23typedef enum {
24 RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
25 RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
26} RIL_RadioTechnologyFamily;
27
28
29typedef struct
30{
31 uint8 *lynq_operator_l;
32 uint8 *lynq_operator_s;
33 uint32 lynq_mcc_mnc;
34} lynq_operator_mcc_mnc_t;
35
36static lynq_operator_mcc_mnc_t lynq_operator_mcc_mnc[] =
37{
38 {"China Mobile","CMCC",46000},
39 {"China Unicom","CU",46001},
40 {"China Mobile","CMCC",46002},
41 {"China Telecom","CT",46003},
42 {"China Mobile","CMCC",46004},
43 {"China Telecom","CT",46005},
44 {"China Unicom","CU",46006},
45 {"China Mobile","CMCC",46007},
46 {"China Mobile","CMCC",46008},
47 {"China Unicom","CU",46009},
48 {"China Telecom","CT",46011}
49};
50
51void lynq_nw_state_change_cb(const void* data, int data_len)
52{
r.xiaocfd7c682024-01-22 03:59:46 -080053
54/*
r.xiaoe73f8702024-01-06 01:40:03 -080055 uint8 *net_data = NULL;
56
57 net_data = (uint8*)data;
r.xiaoe73f8702024-01-06 01:40:03 -080058
r.xiaocfd7c682024-01-22 03:59:46 -080059 if(data && data_len > 0)
r.xiaoe73f8702024-01-06 01:40:03 -080060 {
r.xiaocfd7c682024-01-22 03:59:46 -080061 if(*net_data == 0)
62 { // CS
63 printf("CS:act=%d, mode=%d\n", *(net_data + 1), *(net_data + 2));
64 }
65 else
66 { // PS
67 printf("PS[%s]:act=%d, mode=%d\n", *(net_data + 3) == 0 ? "GSM/WCDMA" : "LTE", *(net_data + 1), *(net_data + 2));
68 }
r.xiaoe73f8702024-01-06 01:40:03 -080069 }
70 else
71 {
r.xiaocfd7c682024-01-22 03:59:46 -080072 printf("NET_CB : NULL");
r.xiaoe73f8702024-01-06 01:40:03 -080073 }
r.xiaoe73f8702024-01-06 01:40:03 -080074*/
75
r.xiaocfd7c682024-01-22 03:59:46 -080076 if(lynq_func_cb_handle.handlerPtr != NULL)//数据原样输出
r.xiaoe73f8702024-01-06 01:40:03 -080077 {
r.xiaocfd7c682024-01-22 03:59:46 -080078 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 -080079 }
80}
81
82
83static uint8 lynq_net_pre_change(bool mbtk_2_lynq,int net_mode)
84{
85 uint8 mbtk_net_pre = 0xFF;
86
87#if 0
88 此参数表在别处使用
89 E_QSER_NW_RADIO_TECH_TD_SCDMA = 1, Y3 1
90 E_QSER_NW_RADIO_TECH_GSM = 2, /**< GSM; only supports voice. */ YL2 0
91 E_QSER_NW_RADIO_TECH_HSPAP = 3, /**< HSPA+. */ 3 1
92 E_QSER_NW_RADIO_TECH_LTE = 4, /**< LTE. */ 4 5
93 E_QSER_NW_RADIO_TECH_EHRPD = 5, /**< EHRPD. */ 3 1
94 E_QSER_NW_RADIO_TECH_EVDO_B = 6, /**< EVDO B. */ D3 1
95 E_QSER_NW_RADIO_TECH_HSPA = 7, /**< HSPA. */ 3 1
96 E_QSER_NW_RADIO_TECH_HSUPA = 8, /**< HSUPA. */ 3.5 1
97 E_QSER_NW_RADIO_TECH_HSDPA = 9, /**< HSDPA. */ 3.5 1
98 E_QSER_NW_RADIO_TECH_EVDO_A = 10, /**< EVDO A. */ D3 1
99 E_QSER_NW_RADIO_TECH_EVDO_0 = 11, /**< EVDO 0. */ D3 1
100 E_QSER_NW_RADIO_TECH_1xRTT = 12, /**< 1xRTT. */ 2 0
101 E_QSER_NW_RADIO_TECH_IS95B = 13, /**< IS95B. */ 3 0
102 E_QSER_NW_RADIO_TECH_IS95A = 14, /**< IS95A. */ 3 0
103 E_QSER_NW_RADIO_TECH_UMTS = 15, /**< UMTS. */ L3 1
104 E_QSER_NW_RADIO_TECH_EDGE = 16, /**< EDGE. */ 2.75 0
105 E_QSER_NW_RADIO_TECH_GPRS = 17, /**< GPRS. */ 2.5 0
106 E_QSER_NW_RADIO_TECH_NONE = 18 /**< No technology selected. */
107#endif
108 /*
109 0 : GSM only
110 1 : UMTS only
111 2 : GSM/UMTS(auto)
112 3 : GSM/UMTS(GSM preferred)
113 4 : GSM/UMTS(UMTS preferred)
114 5 : LTE only
115 6 : GSM/LTE(auto)
116 7 : GSM/LTE(GSM preferred)
117 8 : GSM/LTE(LTE preferred)
118 9 : UMTS/LTE(auto)
119 10 : UMTS/LTE(UMTS preferred)
120 11 : UMTS/LTE(LTE preferred)
121 12 : GSM/UMTS/LTE(auto)
122 13 : GSM/UMTS/LTE(GSM preferred)
123 14 : GSM/UMTS/LTE(UMTS preferred)
124 15 : GSM/UMTS/LTE(LTE preferred)
125 */
126
127 if(mbtk_2_lynq) {
128 switch(net_mode)
129 {
130 //使用之前set的tmp_mode的值来进行回显get
131 case QSER_NW_MODE_GSM:
132 mbtk_net_pre = QSER_NW_MODE_GSM;
133 break;
134 case QSER_NW_MODE_WCDMA:
135 mbtk_net_pre = QSER_NW_MODE_WCDMA;
136 break;
137 case QSER_NW_MODE_CDMA:
138 mbtk_net_pre = QSER_NW_MODE_CDMA;
139 break;
140 case QSER_NW_MODE_EVDO:
141 mbtk_net_pre = QSER_NW_MODE_EVDO;
142 break;
143 case QSER_NW_MODE_LTE:
144 mbtk_net_pre = QSER_NW_MODE_LTE;
145 break;
146 case QSER_NW_MODE_TDSCDMA:
147 mbtk_net_pre = QSER_NW_MODE_TDSCDMA;
148 break;
149 default:
150 mbtk_net_pre = 0xFF;
151 break;
152 }
153 } else {
154 switch(net_mode)
155 {
r.xiaocfd7c682024-01-22 03:59:46 -0800156 //只做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 -0800157 case QSER_NW_MODE_GSM:
158 mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
159 break;
160 case QSER_NW_MODE_WCDMA:
161 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
162 break;
163 case QSER_NW_MODE_CDMA:
164 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
165 break;
166 case QSER_NW_MODE_EVDO:
167 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
168 break;
169 case QSER_NW_MODE_LTE:
170 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;
171 break;
172 case QSER_NW_MODE_TDSCDMA:
173 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
174 break;
175 default:
176 mbtk_net_pre = 0xFF;
177 break;
178 }
179 }
180 return mbtk_net_pre;
181}
b.liu5fa9e772023-11-23 18:00:55 +0800182
183int qser_nw_client_init(nw_client_handle_type *ph_nw)
184{
r.xiaoe73f8702024-01-06 01:40:03 -0800185 //UNUSED(ph_nw);
b.liu5fa9e772023-11-23 18:00:55 +0800186
r.xiaoe73f8702024-01-06 01:40:03 -0800187 if(lynq_nw_info_handle == NULL)
188 {
189 lynq_nw_info_handle = mbtk_info_handle_get();
190 if(lynq_nw_info_handle)
191 {
192 printf("creat lynq_nw_info_handle is success\n");
193 *ph_nw = lynq_nw_info_handle->client_fd;
194 g_nw_val = lynq_nw_info_handle->client_fd;
195 }
196 else
197 {
198 printf("creat lynq_nw_info_handle is fail\n");
199 return -1;
200 }
201 }
202
b.liu5fa9e772023-11-23 18:00:55 +0800203 return 0;
204}
205
206int qser_nw_client_deinit(nw_client_handle_type h_nw)
207{
r.xiaoe73f8702024-01-06 01:40:03 -0800208 //UNUSED(h_nw);
209 if (h_nw != g_nw_val || g_nw_val == -1)
210 {
211 printf("handle NULL\n");
212 return -1;
213 }
214
215 if(lynq_nw_info_handle)
216 {
217 mbtk_info_handle_free(&lynq_nw_info_handle);
218 }
219 else
220 {
221 printf("deinit lynq_nw_info_handle is fail\n");
222 return -1;
223 }
b.liu5fa9e772023-11-23 18:00:55 +0800224
225 return 0;
226}
227
228int qser_nw_set_config(nw_client_handle_type h_nw,QSER_NW_CONFIG_INFO_T *pt_info)
229{
r.xiaoe73f8702024-01-06 01:40:03 -0800230 //UNUSED(h_nw);
231 //UNUSED(pt_info);
232 if (h_nw != g_nw_val || g_nw_val == -1)
233 {
234 printf("handle NULL\n");
235 return -1;
236 }
237
238 if(lynq_nw_info_handle == NULL)
239 {
240 printf("lynq_nw_info_handle == NULL.\n");
241 return -1;
242 }
243
244 if(pt_info == NULL)
245 {
246 printf("pt_info == NULL.\n");
247 return -1;
248 }
249
250 roaming_pref = pt_info->roaming_pref;
251
252 mbtk_band_info_t band;
253 memset(&band, 0, sizeof(mbtk_band_info_t));
254 tmp_mode = pt_info->preferred_nw_mode;//临时保存一下原本的mode
255
256 //printf("tmp_mode = [%llu]",tmp_mode);
257 band.net_pref = lynq_net_pre_change(FALSE, pt_info->preferred_nw_mode);
258 printf("band.net_pref = [%d]\n",band.net_pref);
259
260 if(band.net_pref == 0xFF)
261 {
262 LOGE("lynq_net_pre_change() fail.");
263 return -1;
264 }
265
266 if(mbtk_current_band_set(lynq_nw_info_handle, &band))
267 {
268 return -1;
269 }
b.liu5fa9e772023-11-23 18:00:55 +0800270
271 return 0;
272}
273
274int qser_nw_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info)
275{
r.xiaoe73f8702024-01-06 01:40:03 -0800276 //UNUSED(h_nw);
277 //UNUSED(pt_info);
278 if (h_nw != g_nw_val || g_nw_val == -1)
279 {
280 printf("handle NULL\n");
281 return -1;
282 }
b.liu5fa9e772023-11-23 18:00:55 +0800283
r.xiaoe73f8702024-01-06 01:40:03 -0800284 if(lynq_nw_info_handle == NULL)
285 {
286 printf("lynq_nw_info_handle == NULL.\n");
287 return -1;
288 }
289
290 if(pt_info == NULL)
291 {
292 printf("pt_info == NULL.\n");
293 return -1;
294 }
295
296 char OperatorFN[128];
297 char OperatorSH[128];
298 char MccMnc[128];
299 mbtk_net_info_t net;
300 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
301 {
302 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
303 int i = 0;
304 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
305 {
306 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
307 break;
308 i++;
309 }
310
311 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
312 {
313 strcpy(OperatorFN, "UNKNOWN");
314 strcpy(OperatorSH, "UNKNOWN");
315 sprintf(MccMnc, "%d", net.plmn);
316 }
317 else
318 {
319 strcpy(OperatorFN, lynq_operator_mcc_mnc[i].lynq_operator_l);
320 strcpy(OperatorSH, lynq_operator_mcc_mnc[i].lynq_operator_s);
321 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
322 }
323 memset(pt_info->long_eons,0,128);
324 memcpy(pt_info->long_eons,lynq_operator_mcc_mnc[i].lynq_operator_l,strlen(lynq_operator_mcc_mnc[i].lynq_operator_l));
325 memset(pt_info->short_eons,0,128);
326 memcpy(pt_info->short_eons,lynq_operator_mcc_mnc[i].lynq_operator_s,strlen(lynq_operator_mcc_mnc[i].lynq_operator_s));
327 memset(pt_info->mcc,0,4);
328 memset(pt_info->mnc,0,4);
329 sprintf(pt_info->mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
330 sprintf(pt_info->mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
331 //pt_info->act;
332 return 0;
333 }
334
335 return -1;
b.liu5fa9e772023-11-23 18:00:55 +0800336}
337
338int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info)
339{
r.xiaoe73f8702024-01-06 01:40:03 -0800340 //UNUSED(h_nw);
341 //UNUSED(pt_info);
342 if (h_nw != g_nw_val || g_nw_val == -1)
343 {
344 printf("handle NULL\n");
345 return -1;
346 }
347
348 if(lynq_nw_info_handle == NULL)
349 {
350 printf("lynq_nw_info_handle == NULL.\n");
351 return -1;
352 }
353
354 if(pt_info == NULL)
355 {
356 printf("pt_info == NULL.\n");
357 return -1;
358 }
359
360 /*VOICE/DATA/IMS*/
361 mbtk_net_reg_info_t reg;
362 int err = mbtk_net_reg_get(lynq_nw_info_handle, &reg);
363 if(err)
364 {
365 LOGE("mbtk_net_reg_get fail.");
366 return -1;
367 }
368 else
369 {
370 memset(pt_info, 0x0, sizeof(QSER_NW_REG_STATUS_INFO_T));
371
372
373 char OperatorFN[128];
374 char OperatorSH[128];
375 char MccMnc[128];
376 mbtk_net_info_t net;
377 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
378 {
379 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
380 int i = 0;
381 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
382 {
383 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
384 break;
385 i++;
386 }
387
388 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
389 {
390 strcpy(OperatorFN, "UNKNOWN");
391 strcpy(OperatorSH, "UNKNOWN");
392 sprintf(MccMnc, "%d", net.plmn);
393 }
394 else
395 {
396 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
397 }
398 sprintf(pt_info->data_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
399 sprintf(pt_info->data_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
400 sprintf(pt_info->voice_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
401 sprintf(pt_info->voice_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
402 //pt_info->act;
403 }
404
405 //暂时未知是否其他也被使用,现根据ql模块的传输情况,
406 //只配置3gpp,涉及call,data状态没有对应的匹配的就没有赋值
407
408 pt_info->voice_registration_valid = FALSE;
409 //pt_info->voice_registration
410
411 pt_info->data_registration_valid = FALSE;
412 //pt_info->data_registration
413
414 pt_info->voice_registration_details_3gpp_valid = TRUE;
415 pt_info->voice_registration_details_3gpp.lac = reg.lac;
416 pt_info->voice_registration_details_3gpp.cid = reg.ci;
417 //补位填0 or 1
418 pt_info->voice_registration_details_3gpp.tech_domain = 1;
419 pt_info->voice_registration_details_3gpp.roaming = 0;
420 pt_info->voice_registration_details_3gpp.forbidden = 0;
421 pt_info->voice_registration_details_3gpp.psc = 0;
422 pt_info->voice_registration_details_3gpp.tac = 0;
423
424 pt_info->data_registration_details_3gpp_valid = TRUE;
425 pt_info->data_registration_details_3gpp.lac = reg.lac;
426 pt_info->data_registration_details_3gpp.cid = reg.ci;
427 //补位填0 or 1
428 pt_info->data_registration_details_3gpp.tech_domain = 1;
429 pt_info->data_registration_details_3gpp.roaming = 0;
430 pt_info->data_registration_details_3gpp.forbidden = 0;
431 pt_info->data_registration_details_3gpp.psc = 0;
432 pt_info->data_registration_details_3gpp.tac = 0;
433
434
435 pt_info->voice_registration_details_3gpp2_valid = FALSE;
436 //pt_info->voice_registration_details_3gpp2
437
438 pt_info->data_registration_details_3gpp2_valid = FALSE;
439 //pt_info->data_registration_details_3gpp2
440
441
442 switch(reg.type)
443 {
444 case MBTK_RADIO_TECH_GSM:
445 case MBTK_RADIO_TECH_GSM_COMPACT:
446 case MBTK_RADIO_TECH_GSM_EGPRS:
447 case MBTK_RADIO_TECH_UTRAN_HSPA:
448 {
449 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GPRS;
450 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GSM;
451 break;
452 }
453 case MBTK_RADIO_TECH_UTRAN:
454 case MBTK_RADIO_TECH_UTRAN_HSDPA:
455 case MBTK_RADIO_TECH_UTRAN_HSUPA:
456 case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
457 {
458 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
459 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
460 break;
461 }
462 case MBTK_RADIO_TECH_E_UTRAN:
463 {
464 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
465 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
466 break;
467 }
468 default:
469 {
470 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
471 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
472 break;
473 }
474 }
475 }
b.liu5fa9e772023-11-23 18:00:55 +0800476
477 return 0;
478}
479
480int qser_nw_get_signal_strength(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
481{
r.xiaoe73f8702024-01-06 01:40:03 -0800482 //UNUSED(h_nw);
483 //UNUSED(pt_info);
484 if (h_nw != g_nw_val || g_nw_val == -1)
485 {
486 printf("handle NULL\n");
487 return -1;
488 }
489
490 if(lynq_nw_info_handle == NULL)
491 {
492 printf("lynq_nw_info_handle == NULL.\n");
493 return -1;
494 }
495
496 if(pt_info == NULL)
497 {
498 printf("pt_info == NULL.\n");
499 return -1;
500 }
501
502 int ret;
503 mbtk_signal_info_t signal;
504 ret = mbtk_net_signal_get(lynq_nw_info_handle, &signal);
505 if(ret != 0) {
506 LOGE("mbtk_net_signal_get fail.");
507 return -1;
508 }
509 else
510 {
511 memset(pt_info, 0x0, sizeof(QSER_NW_SIGNAL_STRENGTH_INFO_T));
512 if(signal.type == MBTK_RADIO_TECH_GSM || signal.type == MBTK_RADIO_TECH_GSM_COMPACT || \
513 signal.type == MBTK_RADIO_TECH_GSM_EGPRS) //GSM
514 {
515 pt_info->gsm_sig_info_valid = TRUE;
516 pt_info->gsm_sig_info.rssi = signal.rssi;
517 }
518 else if(signal.type == MBTK_RADIO_TECH_E_UTRAN) //LTE
519 {
520 pt_info->lte_sig_info_valid = TRUE;
521 pt_info->lte_sig_info.rsrp = signal.rsrp;
522 pt_info->lte_sig_info.rsrq = signal.rsrq;
523 pt_info->lte_sig_info.snr = 0; //->MBTK接口无该参数,写死值为0
524 pt_info->lte_sig_info.rssi = signal.rssi;
525 }
526 else if (signal.type == MBTK_RADIO_TECH_UTRAN || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA || \
527 signal.type == MBTK_RADIO_TECH_UTRAN_HSUPA || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA || \
528 signal.type == MBTK_RADIO_TECH_UTRAN_HSPA )//WCDMA
529 {
530 pt_info->wcdma_sig_info_valid = TRUE;
531 pt_info->wcdma_sig_info.rssi = signal.rssi;
532 pt_info->wcdma_sig_info.ecio = 0; //->MBTK接口无该参数,写死值为0
533 }
534 else
535 {
536 return -1;
537 }
538 }
b.liu5fa9e772023-11-23 18:00:55 +0800539
540 return 0;
541}
542
b.liu4e243dc2023-11-27 11:20:00 +0800543int 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 +0800544{
r.xiaoe73f8702024-01-06 01:40:03 -0800545 //UNUSED(h_nw);
546 //UNUSED(handlerPtr);
547 //UNUSED(contextPtr);
548
549 if (h_nw != g_nw_val || g_nw_val == -1)
550 {
551 printf("handle NULL\n");
552 return -1;
553 }
554
555 if(lynq_nw_info_handle == NULL)
556 {
557 printf("lynq_nw_info_handle == NULL.\n");
558 return -1;
559 }
560
561 lynq_func_cb_handle.handlerPtr = handlerPtr;
562 lynq_func_cb_handle.contextPtr = contextPtr;
563
564 mbtk_net_state_change_cb_reg(lynq_nw_info_handle, lynq_nw_state_change_cb);
b.liu5fa9e772023-11-23 18:00:55 +0800565
566 return 0;
567}
568
569int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
570{
r.xiaocfd7c682024-01-22 03:59:46 -0800571 //UNUSED(h_nw);
572 //UNUSED(pt_info);
573 if (h_nw != g_nw_val || g_nw_val == -1)
574 {
575 printf("handle NULL\n");
576 return -1;
577 }
578
579 if (pt_info == NULL)
580 {
581 printf("QSER_NW_OOS_CONFIG_INFO_T NULL\n");
582 return -1;
583 }
584
585 uint32 oosPhase_0, oosPhase_1, oosPhase_2;
586 char tmp_type;
587 mbtk_oos_info oos_info;
588
589 memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
590
591
592 tmp_type = pt_info->type;
593
594 if (tmp_type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
595 {//如果没有配置对应的值,例如,10,20
596 //oosPhase_2这个位置没有配置,则使用默认值20,既不限制次数的5s进行一次扫描
597 //同理oosPhase_0,oosPhase_1这个位置没有配置,则使用默认值5,10,既限制次数5次的5s,10s进行一次扫描
598 //输入多少配置多少,可以缺省使用默认值
599 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)
600 {
601 printf("qser_nw_set_oos_config set time < 0 \n");
602 return -1;
603 }
604 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)
605 {
606 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
607 oos_info.mode = 1;
608 oos_info.oosPhase[0] = oosPhase_0;
609 }
610 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)
611 {
612 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
613 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
614 oos_info.mode = 1;
615 oos_info.oosPhase[0] = oosPhase_0;
616 oos_info.oosPhase[1] = oosPhase_1;
617 }
618 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))
619 {
620 oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
621 oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
622 oosPhase_2 = pt_info->u.full_band_scan_info.t_max;
623 oos_info.mode = 1;
624 oos_info.oosPhase[0] = oosPhase_0;
625 oos_info.oosPhase[1] = oosPhase_1;
626 oos_info.oosPhase[2] = oosPhase_2;
627 }
628 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)
629 {
630 oos_info.mode = 0;
631 }
632 else
633 {
634 printf("qser_nw_set_oos_config set Format err\n");
635 return -1;
636 }
637
638 int err = mbtk_oos_set(lynq_nw_info_handle, &oos_info);
639 if (err != 0)
640 {
641 printf("qser_nw_set_oos_config mbtk_oos_set err \n");
642 return -1;
643 }
644 }
645 else if (tmp_type == QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
646 {
647 printf("Not currently supported\n");
648 return -1;
649 }
650 else
651 {
652 printf("type is error\n");
653 return -1;
654 }
b.liu5fa9e772023-11-23 18:00:55 +0800655
656 return 0;
657}
658
659int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
660{
r.xiaocfd7c682024-01-22 03:59:46 -0800661 //UNUSED(h_nw);
662 //UNUSED(pt_info);
663 if (h_nw != g_nw_val || g_nw_val == -1)
664 {
665 printf("handle NULL\n");
666 return -1;
667 }
668
669 mbtk_oos_info oos_info;
670 uint32 oosPhase_0, oosPhase_1, oosPhase_2;
671 char cmd[100] = {0};
672
673 memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
674
675 int err = mbtk_oos_get(lynq_nw_info_handle, &oos_info);
676 if (err != 0)
677 {
678 printf("qser_nw_get_oos_config mbtk_oos_get err \n");
679 return -1;
680 }
681
682 printf("oos_info.mode =[%d] \n",oos_info.mode);
683 printf("oos_info.1 =[%d] \n",oos_info.oosPhase[0]);
684 printf("oos_info.2 =[%d] \n",oos_info.oosPhase[1]);
685 printf("oos_info.3 =[%d] \n",oos_info.oosPhase[2]);
686
687 if(oos_info.mode == 0)//关闭状态
688 {
689 pt_info->u.full_band_scan_info.t_min = 0;
690 pt_info->u.full_band_scan_info.t_step = 0;
691 pt_info->u.full_band_scan_info.t_max = 0;
692 }
693 else
694 {
695 pt_info->u.full_band_scan_info.t_min = (int)oos_info.oosPhase[0];
696 pt_info->u.full_band_scan_info.t_step = (int)oos_info.oosPhase[1];
697 pt_info->u.full_band_scan_info.t_max = (int)oos_info.oosPhase[2];
698 }
699 pt_info->type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;
700
701
702 if (pt_info == NULL)
703 {
704 printf("qser_nw_get_oos_config pt_info is null \n");
705 return -1;
706 }
b.liu5fa9e772023-11-23 18:00:55 +0800707
708 return 0;
r.xiaoe73f8702024-01-06 01:40:03 -0800709}
710
711int qser_nw_set_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode)
712{
713 //UNUSED(h_nw);
714 //UNUSED(rf_mode);
715 int ret;
r.xiaocfd7c682024-01-22 03:59:46 -0800716 mbtk_modem_info_t info;
r.xiaoe73f8702024-01-06 01:40:03 -0800717
718 if (h_nw != g_nw_val || g_nw_val == -1)
719 {
720 printf("handle NULL\n");
721 return -1;
722 }
723
724 if(lynq_nw_info_handle == NULL)
725 {
726 printf("lynq_nw_info_handle == NULL.\n");
727 return -1;
728 }
729
r.xiaocfd7c682024-01-22 03:59:46 -0800730/*
r.xiaoe73f8702024-01-06 01:40:03 -0800731 if (rf_mode == 4)
732 {
733 printf("Flight Mode no Support Now\n");
734 return -1;
735 }
r.xiaocfd7c682024-01-22 03:59:46 -0800736*/
737 if (rf_mode != 4 && rf_mode != 0 && rf_mode != 1)
738 {
739 printf("mode is error!\n");
740 return -1;
741 }
r.xiaoe73f8702024-01-06 01:40:03 -0800742
r.xiaocfd7c682024-01-22 03:59:46 -0800743 info.fun = rf_mode;
744 info.rst = 0;
745 ret = mbtk_set_modem_fun(lynq_nw_info_handle, &info);
746
747 //ret = mbtk_radio_state_set(lynq_nw_info_handle, rf_mode);
r.xiaoe73f8702024-01-06 01:40:03 -0800748 if (ret != 0)
749 {
750 LOGE("mbtk_radio_state_set fail.");
751 return -1;
752 }
753 else
754 {
755 printf("qser_nw_set_rf_mode is success\n");
756 }
757
758 return 0;
759}
760
761int qser_nw_get_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T *rf_mode)
762{
763 //UNUSED(h_nw);
764 //UNUSED(rf_mode);
765 int ret;
766 int tmp_rf;
767
768 if (h_nw != g_nw_val || g_nw_val == -1)
769 {
770 printf("handle NULL\n");
771 return -1;
772 }
773
774 if(lynq_nw_info_handle == NULL)
775 {
776 printf("lynq_nw_info_handle == NULL.\n");
777 return -1;
778 }
779
r.xiaocfd7c682024-01-22 03:59:46 -0800780 ret = mbtk_get_modem_fun(lynq_nw_info_handle, &tmp_rf);
781
782 //ret = mbtk_radio_state_get(lynq_nw_info_handle, &tmp_rf);
r.xiaoe73f8702024-01-06 01:40:03 -0800783 if (ret != 0)
784 {
785 LOGE("mbtk_radio_state_get fail.");
786 return -1;
787 }
788 else
789 {
790 printf("qser_nw_get_rf_mode is success\n");
791 *rf_mode = tmp_rf;
792 }
793
794
795 return 0;
796}
797
798