blob: 34f215f310ed92ce70a9fd0b8239d3082a7d476e [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
13
14typedef 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{
54 uint8 *net_data = NULL;
55
56 net_data = (uint8*)data;
57 log_hex(">>>data",data,data_len);
58
59 if (net_data == NULL)
60 {
61 LOG(">>>NO DATA");
62 }
63 else
64 {
r.xiao013d9122024-01-06 02:00:57 -080065 LOG(">>>net_data =[%0x]\n",net_data[2]);
r.xiaoe73f8702024-01-06 01:40:03 -080066 }
67
68/*
69 uint8 data[3];
70 data[0] = (uint8)MBTK_NET_CS_STATE;
71
72 net_data[0] = *(uint8 *)(data); //MBTK_NET_PS_STATE
73 net_data[1] = *(uint8 *)(data + sizeof(uint8)); //mbtk_net_reg_state_enum state Reg State
74 net_data[2] = *(uint8 *)(data + sizeof(uint8) + sizeof(uint8)); //act
75*/
76
77 if(roaming_pref == 0)
78 {
79 mbtk_modem_info_t info;
80 if(*net_data == 5)
81 {
82 info.fun=4;
83 }
84 else
85 info.fun=1;
86 info.rst=0;
87 mbtk_set_modem_fun(lynq_nw_info_handle, &info);
88 }
89
90 if(lynq_func_cb_handle.handlerPtr != NULL)
91 {
92 //lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_VOICE_REG_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
93 lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_DATA_REG_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
94 //lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
95 }
96}
97
98
99static uint8 lynq_net_pre_change(bool mbtk_2_lynq,int net_mode)
100{
101 uint8 mbtk_net_pre = 0xFF;
102
103#if 0
104 此参数表在别处使用
105 E_QSER_NW_RADIO_TECH_TD_SCDMA = 1, Y3 1
106 E_QSER_NW_RADIO_TECH_GSM = 2, /**< GSM; only supports voice. */ YL2 0
107 E_QSER_NW_RADIO_TECH_HSPAP = 3, /**< HSPA+. */ 3 1
108 E_QSER_NW_RADIO_TECH_LTE = 4, /**< LTE. */ 4 5
109 E_QSER_NW_RADIO_TECH_EHRPD = 5, /**< EHRPD. */ 3 1
110 E_QSER_NW_RADIO_TECH_EVDO_B = 6, /**< EVDO B. */ D3 1
111 E_QSER_NW_RADIO_TECH_HSPA = 7, /**< HSPA. */ 3 1
112 E_QSER_NW_RADIO_TECH_HSUPA = 8, /**< HSUPA. */ 3.5 1
113 E_QSER_NW_RADIO_TECH_HSDPA = 9, /**< HSDPA. */ 3.5 1
114 E_QSER_NW_RADIO_TECH_EVDO_A = 10, /**< EVDO A. */ D3 1
115 E_QSER_NW_RADIO_TECH_EVDO_0 = 11, /**< EVDO 0. */ D3 1
116 E_QSER_NW_RADIO_TECH_1xRTT = 12, /**< 1xRTT. */ 2 0
117 E_QSER_NW_RADIO_TECH_IS95B = 13, /**< IS95B. */ 3 0
118 E_QSER_NW_RADIO_TECH_IS95A = 14, /**< IS95A. */ 3 0
119 E_QSER_NW_RADIO_TECH_UMTS = 15, /**< UMTS. */ L3 1
120 E_QSER_NW_RADIO_TECH_EDGE = 16, /**< EDGE. */ 2.75 0
121 E_QSER_NW_RADIO_TECH_GPRS = 17, /**< GPRS. */ 2.5 0
122 E_QSER_NW_RADIO_TECH_NONE = 18 /**< No technology selected. */
123#endif
124 /*
125 0 : GSM only
126 1 : UMTS only
127 2 : GSM/UMTS(auto)
128 3 : GSM/UMTS(GSM preferred)
129 4 : GSM/UMTS(UMTS preferred)
130 5 : LTE only
131 6 : GSM/LTE(auto)
132 7 : GSM/LTE(GSM preferred)
133 8 : GSM/LTE(LTE preferred)
134 9 : UMTS/LTE(auto)
135 10 : UMTS/LTE(UMTS preferred)
136 11 : UMTS/LTE(LTE preferred)
137 12 : GSM/UMTS/LTE(auto)
138 13 : GSM/UMTS/LTE(GSM preferred)
139 14 : GSM/UMTS/LTE(UMTS preferred)
140 15 : GSM/UMTS/LTE(LTE preferred)
141 */
142
143 if(mbtk_2_lynq) {
144 switch(net_mode)
145 {
146 //使用之前set的tmp_mode的值来进行回显get
147 case QSER_NW_MODE_GSM:
148 mbtk_net_pre = QSER_NW_MODE_GSM;
149 break;
150 case QSER_NW_MODE_WCDMA:
151 mbtk_net_pre = QSER_NW_MODE_WCDMA;
152 break;
153 case QSER_NW_MODE_CDMA:
154 mbtk_net_pre = QSER_NW_MODE_CDMA;
155 break;
156 case QSER_NW_MODE_EVDO:
157 mbtk_net_pre = QSER_NW_MODE_EVDO;
158 break;
159 case QSER_NW_MODE_LTE:
160 mbtk_net_pre = QSER_NW_MODE_LTE;
161 break;
162 case QSER_NW_MODE_TDSCDMA:
163 mbtk_net_pre = QSER_NW_MODE_TDSCDMA;
164 break;
165 default:
166 mbtk_net_pre = 0xFF;
167 break;
168 }
169 } else {
170 switch(net_mode)
171 {
172 //只做234G的only下配 MBTK_NET_PREF_GSM_ONLY/MBTK_NET_PREF_UMTS_ONLY/MBTK_NET_PREF_LTE_ONLY
173 case QSER_NW_MODE_GSM:
174 mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
175 break;
176 case QSER_NW_MODE_WCDMA:
177 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
178 break;
179 case QSER_NW_MODE_CDMA:
180 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
181 break;
182 case QSER_NW_MODE_EVDO:
183 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
184 break;
185 case QSER_NW_MODE_LTE:
186 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;
187 break;
188 case QSER_NW_MODE_TDSCDMA:
189 mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
190 break;
191 default:
192 mbtk_net_pre = 0xFF;
193 break;
194 }
195 }
196 return mbtk_net_pre;
197}
b.liu5fa9e772023-11-23 18:00:55 +0800198
199int qser_nw_client_init(nw_client_handle_type *ph_nw)
200{
r.xiaoe73f8702024-01-06 01:40:03 -0800201 //UNUSED(ph_nw);
b.liu5fa9e772023-11-23 18:00:55 +0800202
r.xiaoe73f8702024-01-06 01:40:03 -0800203 if(lynq_nw_info_handle == NULL)
204 {
205 lynq_nw_info_handle = mbtk_info_handle_get();
206 if(lynq_nw_info_handle)
207 {
208 printf("creat lynq_nw_info_handle is success\n");
209 *ph_nw = lynq_nw_info_handle->client_fd;
210 g_nw_val = lynq_nw_info_handle->client_fd;
211 }
212 else
213 {
214 printf("creat lynq_nw_info_handle is fail\n");
215 return -1;
216 }
217 }
218
b.liu5fa9e772023-11-23 18:00:55 +0800219 return 0;
220}
221
222int qser_nw_client_deinit(nw_client_handle_type h_nw)
223{
r.xiaoe73f8702024-01-06 01:40:03 -0800224 //UNUSED(h_nw);
225 if (h_nw != g_nw_val || g_nw_val == -1)
226 {
227 printf("handle NULL\n");
228 return -1;
229 }
230
231 if(lynq_nw_info_handle)
232 {
233 mbtk_info_handle_free(&lynq_nw_info_handle);
234 }
235 else
236 {
237 printf("deinit lynq_nw_info_handle is fail\n");
238 return -1;
239 }
b.liu5fa9e772023-11-23 18:00:55 +0800240
241 return 0;
242}
243
244int qser_nw_set_config(nw_client_handle_type h_nw,QSER_NW_CONFIG_INFO_T *pt_info)
245{
r.xiaoe73f8702024-01-06 01:40:03 -0800246 //UNUSED(h_nw);
247 //UNUSED(pt_info);
248 if (h_nw != g_nw_val || g_nw_val == -1)
249 {
250 printf("handle NULL\n");
251 return -1;
252 }
253
254 if(lynq_nw_info_handle == NULL)
255 {
256 printf("lynq_nw_info_handle == NULL.\n");
257 return -1;
258 }
259
260 if(pt_info == NULL)
261 {
262 printf("pt_info == NULL.\n");
263 return -1;
264 }
265
266 roaming_pref = pt_info->roaming_pref;
267
268 mbtk_band_info_t band;
269 memset(&band, 0, sizeof(mbtk_band_info_t));
270 tmp_mode = pt_info->preferred_nw_mode;//临时保存一下原本的mode
271
272 //printf("tmp_mode = [%llu]",tmp_mode);
273 band.net_pref = lynq_net_pre_change(FALSE, pt_info->preferred_nw_mode);
274 printf("band.net_pref = [%d]\n",band.net_pref);
275
276 if(band.net_pref == 0xFF)
277 {
278 LOGE("lynq_net_pre_change() fail.");
279 return -1;
280 }
281
282 if(mbtk_current_band_set(lynq_nw_info_handle, &band))
283 {
284 return -1;
285 }
b.liu5fa9e772023-11-23 18:00:55 +0800286
287 return 0;
288}
289
290int qser_nw_get_operator_name(nw_client_handle_type h_nw, QSER_NW_OPERATOR_NAME_INFO_T *pt_info)
291{
r.xiaoe73f8702024-01-06 01:40:03 -0800292 //UNUSED(h_nw);
293 //UNUSED(pt_info);
294 if (h_nw != g_nw_val || g_nw_val == -1)
295 {
296 printf("handle NULL\n");
297 return -1;
298 }
b.liu5fa9e772023-11-23 18:00:55 +0800299
r.xiaoe73f8702024-01-06 01:40:03 -0800300 if(lynq_nw_info_handle == NULL)
301 {
302 printf("lynq_nw_info_handle == NULL.\n");
303 return -1;
304 }
305
306 if(pt_info == NULL)
307 {
308 printf("pt_info == NULL.\n");
309 return -1;
310 }
311
312 char OperatorFN[128];
313 char OperatorSH[128];
314 char MccMnc[128];
315 mbtk_net_info_t net;
316 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
317 {
318 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
319 int i = 0;
320 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
321 {
322 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
323 break;
324 i++;
325 }
326
327 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
328 {
329 strcpy(OperatorFN, "UNKNOWN");
330 strcpy(OperatorSH, "UNKNOWN");
331 sprintf(MccMnc, "%d", net.plmn);
332 }
333 else
334 {
335 strcpy(OperatorFN, lynq_operator_mcc_mnc[i].lynq_operator_l);
336 strcpy(OperatorSH, lynq_operator_mcc_mnc[i].lynq_operator_s);
337 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
338 }
339 memset(pt_info->long_eons,0,128);
340 memcpy(pt_info->long_eons,lynq_operator_mcc_mnc[i].lynq_operator_l,strlen(lynq_operator_mcc_mnc[i].lynq_operator_l));
341 memset(pt_info->short_eons,0,128);
342 memcpy(pt_info->short_eons,lynq_operator_mcc_mnc[i].lynq_operator_s,strlen(lynq_operator_mcc_mnc[i].lynq_operator_s));
343 memset(pt_info->mcc,0,4);
344 memset(pt_info->mnc,0,4);
345 sprintf(pt_info->mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
346 sprintf(pt_info->mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
347 //pt_info->act;
348 return 0;
349 }
350
351 return -1;
b.liu5fa9e772023-11-23 18:00:55 +0800352}
353
354int qser_nw_get_reg_status(nw_client_handle_type h_nw, QSER_NW_REG_STATUS_INFO_T *pt_info)
355{
r.xiaoe73f8702024-01-06 01:40:03 -0800356 //UNUSED(h_nw);
357 //UNUSED(pt_info);
358 if (h_nw != g_nw_val || g_nw_val == -1)
359 {
360 printf("handle NULL\n");
361 return -1;
362 }
363
364 if(lynq_nw_info_handle == NULL)
365 {
366 printf("lynq_nw_info_handle == NULL.\n");
367 return -1;
368 }
369
370 if(pt_info == NULL)
371 {
372 printf("pt_info == NULL.\n");
373 return -1;
374 }
375
376 /*VOICE/DATA/IMS*/
377 mbtk_net_reg_info_t reg;
378 int err = mbtk_net_reg_get(lynq_nw_info_handle, &reg);
379 if(err)
380 {
381 LOGE("mbtk_net_reg_get fail.");
382 return -1;
383 }
384 else
385 {
386 memset(pt_info, 0x0, sizeof(QSER_NW_REG_STATUS_INFO_T));
387
388
389 char OperatorFN[128];
390 char OperatorSH[128];
391 char MccMnc[128];
392 mbtk_net_info_t net;
393 if(!mbtk_net_sel_mode_get(lynq_nw_info_handle, &net) && net.plmn > 0)
394 {
395 // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
396 int i = 0;
397 while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
398 {
399 if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
400 break;
401 i++;
402 }
403
404 if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
405 {
406 strcpy(OperatorFN, "UNKNOWN");
407 strcpy(OperatorSH, "UNKNOWN");
408 sprintf(MccMnc, "%d", net.plmn);
409 }
410 else
411 {
412 sprintf(MccMnc, "%d", lynq_operator_mcc_mnc[i].lynq_mcc_mnc);
413 }
414 sprintf(pt_info->data_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
415 sprintf(pt_info->data_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
416 sprintf(pt_info->voice_registration_details_3gpp.mcc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
417 sprintf(pt_info->voice_registration_details_3gpp.mnc, "%d", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
418 //pt_info->act;
419 }
420
421 //暂时未知是否其他也被使用,现根据ql模块的传输情况,
422 //只配置3gpp,涉及call,data状态没有对应的匹配的就没有赋值
423
424 pt_info->voice_registration_valid = FALSE;
425 //pt_info->voice_registration
426
427 pt_info->data_registration_valid = FALSE;
428 //pt_info->data_registration
429
430 pt_info->voice_registration_details_3gpp_valid = TRUE;
431 pt_info->voice_registration_details_3gpp.lac = reg.lac;
432 pt_info->voice_registration_details_3gpp.cid = reg.ci;
433 //补位填0 or 1
434 pt_info->voice_registration_details_3gpp.tech_domain = 1;
435 pt_info->voice_registration_details_3gpp.roaming = 0;
436 pt_info->voice_registration_details_3gpp.forbidden = 0;
437 pt_info->voice_registration_details_3gpp.psc = 0;
438 pt_info->voice_registration_details_3gpp.tac = 0;
439
440 pt_info->data_registration_details_3gpp_valid = TRUE;
441 pt_info->data_registration_details_3gpp.lac = reg.lac;
442 pt_info->data_registration_details_3gpp.cid = reg.ci;
443 //补位填0 or 1
444 pt_info->data_registration_details_3gpp.tech_domain = 1;
445 pt_info->data_registration_details_3gpp.roaming = 0;
446 pt_info->data_registration_details_3gpp.forbidden = 0;
447 pt_info->data_registration_details_3gpp.psc = 0;
448 pt_info->data_registration_details_3gpp.tac = 0;
449
450
451 pt_info->voice_registration_details_3gpp2_valid = FALSE;
452 //pt_info->voice_registration_details_3gpp2
453
454 pt_info->data_registration_details_3gpp2_valid = FALSE;
455 //pt_info->data_registration_details_3gpp2
456
457
458 switch(reg.type)
459 {
460 case MBTK_RADIO_TECH_GSM:
461 case MBTK_RADIO_TECH_GSM_COMPACT:
462 case MBTK_RADIO_TECH_GSM_EGPRS:
463 case MBTK_RADIO_TECH_UTRAN_HSPA:
464 {
465 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GPRS;
466 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_GSM;
467 break;
468 }
469 case MBTK_RADIO_TECH_UTRAN:
470 case MBTK_RADIO_TECH_UTRAN_HSDPA:
471 case MBTK_RADIO_TECH_UTRAN_HSUPA:
472 case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
473 {
474 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
475 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_UMTS;
476 break;
477 }
478 case MBTK_RADIO_TECH_E_UTRAN:
479 {
480 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
481 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_LTE;
482 break;
483 }
484 default:
485 {
486 pt_info->data_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
487 pt_info->voice_registration_details_3gpp.radio_tech = E_QSER_NW_RADIO_TECH_NONE;
488 break;
489 }
490 }
491 }
b.liu5fa9e772023-11-23 18:00:55 +0800492
493 return 0;
494}
495
496int qser_nw_get_signal_strength(nw_client_handle_type h_nw,QSER_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
497{
r.xiaoe73f8702024-01-06 01:40:03 -0800498 //UNUSED(h_nw);
499 //UNUSED(pt_info);
500 if (h_nw != g_nw_val || g_nw_val == -1)
501 {
502 printf("handle NULL\n");
503 return -1;
504 }
505
506 if(lynq_nw_info_handle == NULL)
507 {
508 printf("lynq_nw_info_handle == NULL.\n");
509 return -1;
510 }
511
512 if(pt_info == NULL)
513 {
514 printf("pt_info == NULL.\n");
515 return -1;
516 }
517
518 int ret;
519 mbtk_signal_info_t signal;
520 ret = mbtk_net_signal_get(lynq_nw_info_handle, &signal);
521 if(ret != 0) {
522 LOGE("mbtk_net_signal_get fail.");
523 return -1;
524 }
525 else
526 {
527 memset(pt_info, 0x0, sizeof(QSER_NW_SIGNAL_STRENGTH_INFO_T));
528 if(signal.type == MBTK_RADIO_TECH_GSM || signal.type == MBTK_RADIO_TECH_GSM_COMPACT || \
529 signal.type == MBTK_RADIO_TECH_GSM_EGPRS) //GSM
530 {
531 pt_info->gsm_sig_info_valid = TRUE;
532 pt_info->gsm_sig_info.rssi = signal.rssi;
533 }
534 else if(signal.type == MBTK_RADIO_TECH_E_UTRAN) //LTE
535 {
536 pt_info->lte_sig_info_valid = TRUE;
537 pt_info->lte_sig_info.rsrp = signal.rsrp;
538 pt_info->lte_sig_info.rsrq = signal.rsrq;
539 pt_info->lte_sig_info.snr = 0; //->MBTK接口无该参数,写死值为0
540 pt_info->lte_sig_info.rssi = signal.rssi;
541 }
542 else if (signal.type == MBTK_RADIO_TECH_UTRAN || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA || \
543 signal.type == MBTK_RADIO_TECH_UTRAN_HSUPA || signal.type == MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA || \
544 signal.type == MBTK_RADIO_TECH_UTRAN_HSPA )//WCDMA
545 {
546 pt_info->wcdma_sig_info_valid = TRUE;
547 pt_info->wcdma_sig_info.rssi = signal.rssi;
548 pt_info->wcdma_sig_info.ecio = 0; //->MBTK接口无该参数,写死值为0
549 }
550 else
551 {
552 return -1;
553 }
554 }
b.liu5fa9e772023-11-23 18:00:55 +0800555
556 return 0;
557}
558
b.liu4e243dc2023-11-27 11:20:00 +0800559int 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 +0800560{
r.xiaoe73f8702024-01-06 01:40:03 -0800561 //UNUSED(h_nw);
562 //UNUSED(handlerPtr);
563 //UNUSED(contextPtr);
564
565 if (h_nw != g_nw_val || g_nw_val == -1)
566 {
567 printf("handle NULL\n");
568 return -1;
569 }
570
571 if(lynq_nw_info_handle == NULL)
572 {
573 printf("lynq_nw_info_handle == NULL.\n");
574 return -1;
575 }
576
577 lynq_func_cb_handle.handlerPtr = handlerPtr;
578 lynq_func_cb_handle.contextPtr = contextPtr;
579
580 mbtk_net_state_change_cb_reg(lynq_nw_info_handle, lynq_nw_state_change_cb);
b.liu5fa9e772023-11-23 18:00:55 +0800581
582 return 0;
583}
584
585int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
586{
587 UNUSED(h_nw);
588 UNUSED(pt_info);
589
590 return 0;
591}
592
593int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
594{
595 UNUSED(h_nw);
596 UNUSED(pt_info);
597
598 return 0;
r.xiaoe73f8702024-01-06 01:40:03 -0800599}
600
601int qser_nw_set_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode)
602{
603 //UNUSED(h_nw);
604 //UNUSED(rf_mode);
605 int ret;
606
607 if (h_nw != g_nw_val || g_nw_val == -1)
608 {
609 printf("handle NULL\n");
610 return -1;
611 }
612
613 if(lynq_nw_info_handle == NULL)
614 {
615 printf("lynq_nw_info_handle == NULL.\n");
616 return -1;
617 }
618
619 if (rf_mode == 4)
620 {
621 printf("Flight Mode no Support Now\n");
622 return -1;
623 }
624
625 ret = mbtk_radio_state_set(lynq_nw_info_handle, rf_mode);
626 if (ret != 0)
627 {
628 LOGE("mbtk_radio_state_set fail.");
629 return -1;
630 }
631 else
632 {
633 printf("qser_nw_set_rf_mode is success\n");
634 }
635
636 return 0;
637}
638
639int qser_nw_get_rf_mode (nw_client_handle_type h_nw, E_QSER_NW_RF_MODE_TYPE_T *rf_mode)
640{
641 //UNUSED(h_nw);
642 //UNUSED(rf_mode);
643 int ret;
644 int tmp_rf;
645
646 if (h_nw != g_nw_val || g_nw_val == -1)
647 {
648 printf("handle NULL\n");
649 return -1;
650 }
651
652 if(lynq_nw_info_handle == NULL)
653 {
654 printf("lynq_nw_info_handle == NULL.\n");
655 return -1;
656 }
657
658 ret = mbtk_radio_state_get(lynq_nw_info_handle, &tmp_rf);
659 if (ret != 0)
660 {
661 LOGE("mbtk_radio_state_get fail.");
662 return -1;
663 }
664 else
665 {
666 printf("qser_nw_get_rf_mode is success\n");
667 *rf_mode = tmp_rf;
668 }
669
670
671 return 0;
672}
673
674