b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame^] | 1 | /*-----------------------------------------------------------------------------------------------*/ |
| 2 | /** |
| 3 | @file ql_nw_test.c |
| 4 | @brief nw test module |
| 5 | */ |
| 6 | /*-----------------------------------------------------------------------------------------------*/ |
| 7 | |
| 8 | /*------------------------------------------------------------------------------------------------- |
| 9 | Copyright (c) 2024 mobiletek Wireless Solution, Co., Ltd. All Rights Reserved. |
| 10 | mobiletek Wireless Solution Proprietary and Confidential. |
| 11 | -------------------------------------------------------------------------------------------------*/ |
| 12 | |
| 13 | /*------------------------------------------------------------------------------------------------- |
| 14 | EDIT HISTORY |
| 15 | This section contains comments describing changes made to the file. |
| 16 | Notice that changes are listed in reverse chronological order. |
| 17 | $Header: $ |
| 18 | when who what, where, why |
| 19 | -------- --------- ----------------------------------------------------------------- |
| 20 | 20241022 yq.wang Created . |
| 21 | -------------------------------------------------------------------------------------------------*/ |
| 22 | |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <string.h> |
| 26 | #include <stdlib.h> |
| 27 | |
| 28 | #include "ql_test_utils.h" |
| 29 | #include "ql_type.h" |
| 30 | #include "ql_nw.h" |
| 31 | |
| 32 | |
| 33 | #if 0 |
| 34 | static int internal_nw_get_nas_rat(int radio, char* buf, int buf_len); |
| 35 | #endif |
| 36 | static int internal_nw_get_net_status(QL_NW_NETWORK_STATUS_TYPE_E net, char* buf, int buf_len); |
| 37 | static int internal_nw_get_radio_tech(QL_NW_RADIO_TECH_TYPE_E radio, char* buf, int buf_len); |
| 38 | static int internal_nw_get_tech_domain(QL_NW_TECH_DOMAIN_TYPE_E domain, char* buf, int buf_len); |
| 39 | static int internal_nw_get_signal_strength_level(QL_NW_SIGNAL_STRENGTH_LEVEL_E level, char* buf, int buf_len); |
| 40 | static void internal_nw_get_mcc_mnc_value(char *plmn, int plmn_len, unsigned short *mcc, unsigned short *mnc); |
| 41 | static void internal_nw_get_service_option(unsigned short so_mask, char *buf, int buf_len); |
| 42 | |
| 43 | /*-----------------------------------------------------------------------------------------------*/ |
| 44 | /** |
| 45 | @brief Read a uint32 value from stdin |
| 46 | @param[out] val, Return read data |
| 47 | @return |
| 48 | 0 - successful |
| 49 | 1 - read an enter |
| 50 | -1 - invalid input |
| 51 | */ |
| 52 | /*-----------------------------------------------------------------------------------------------*/ |
| 53 | int t_get_hex(uint32_t *val) |
| 54 | { |
| 55 | int dat; |
| 56 | char *ptr_end = NULL; |
| 57 | char buf[256] = {0}; |
| 58 | |
| 59 | if(fgets(buf, sizeof(buf)-1, stdin) == NULL) |
| 60 | { |
| 61 | return -1; |
| 62 | } |
| 63 | |
| 64 | if(0 == buf[0]) |
| 65 | { |
| 66 | return -1; |
| 67 | } |
| 68 | |
| 69 | if(buf[0] == '\n') |
| 70 | { |
| 71 | return 1; |
| 72 | } |
| 73 | |
| 74 | dat = strtol(buf, &ptr_end, 16); |
| 75 | if(ptr_end!=NULL && ptr_end[0]!='\n') |
| 76 | { |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | if(val) |
| 81 | { |
| 82 | val[0] = dat; |
| 83 | } |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | void nw_voice_reg_event_ind_cb(ql_nw_reg_status_info_t *ind) |
| 89 | { |
| 90 | char domain_info[16] = {0}; |
| 91 | char radio_info[16] = {0}; |
| 92 | char svc_opt[128] = {0}; |
| 93 | |
| 94 | if(ind == NULL) |
| 95 | { |
| 96 | printf("recv voice reg ind event, param is null\n"); |
| 97 | return; |
| 98 | } |
| 99 | printf("recv voice reg ind event, detail info:\n"); |
| 100 | |
| 101 | if(internal_nw_get_tech_domain(ind->tech_domain, domain_info, sizeof(domain_info)) == 0) |
| 102 | { |
| 103 | printf("\ttech_domain is unrecognized:%d, ", ind->tech_domain); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | printf("\ttech_domain = %s, ", domain_info); |
| 108 | } |
| 109 | |
| 110 | if(internal_nw_get_radio_tech(ind->radio_tech, radio_info, sizeof(radio_info)) == 0) |
| 111 | { |
| 112 | printf("radio_tech is unrecognized:%d, ", ind->radio_tech); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | printf("radio_tech = %s, ", radio_info); |
| 117 | } |
| 118 | |
| 119 | printf("roaming = %d, reg_status = %d, deny_reason = %d\n", |
| 120 | ind->roaming, ind->reg_state, ind->deny_reason); |
| 121 | |
| 122 | if(QL_NW_RADIO_TECH_NR5G != ind->radio_tech) |
| 123 | { |
| 124 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d, endc_available=%d\n", |
| 125 | ind->mcc, |
| 126 | ind->mnc, |
| 127 | ind->forbidden, |
| 128 | ind->cid, |
| 129 | ind->lac, |
| 130 | ind->psc, |
| 131 | ind->tac, |
| 132 | ind->endc_available); |
| 133 | |
| 134 | printf("\tinPRL=%d, css=%d, sid=%d, nid=%d, bsid=%d\n", |
| 135 | ind->inPRL, |
| 136 | ind->css, |
| 137 | ind->sid, |
| 138 | ind->nid, |
| 139 | ind->bsid); |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%llX, pci=%d, tac=%d\n", |
| 144 | ind->mcc, |
| 145 | ind->mnc, |
| 146 | ind->forbidden, |
| 147 | ind->nr5g_cid, |
| 148 | ind->nr5g_pci, |
| 149 | ind->nr5g_tac); |
| 150 | |
| 151 | internal_nw_get_service_option(ind->nr5g_svc_opt, svc_opt, sizeof(svc_opt)); |
| 152 | printf("\tsvc_opt(%d)=%s\n", ind->nr5g_svc_opt, svc_opt); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | #if 0 |
| 157 | void nw_data_reg_event_ind_cb(ql_nw_reg_status_info_t *ind) |
| 158 | { |
| 159 | char domain_info[16] = {0}; |
| 160 | char radio_info[16] = {0}; |
| 161 | char svc_opt[128] = {0}; |
| 162 | |
| 163 | if(ind == NULL) |
| 164 | { |
| 165 | printf("recv data reg ind event, param is null\n"); |
| 166 | return; |
| 167 | } |
| 168 | printf("recv data reg ind event, detail info:\n"); |
| 169 | |
| 170 | if(internal_nw_get_tech_domain(ind->tech_domain, domain_info, sizeof(domain_info)) == 0) |
| 171 | { |
| 172 | printf("\ttech_domain is unrecognized:%d, ", ind->tech_domain); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | printf("\ttech_domain = %s, ", domain_info); |
| 177 | } |
| 178 | |
| 179 | if(internal_nw_get_radio_tech(ind->radio_tech, radio_info, sizeof(radio_info)) == 0) |
| 180 | { |
| 181 | printf("radio_tech is unrecognized:%d, ", ind->radio_tech); |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | printf("radio_tech = %s, ", radio_info); |
| 186 | } |
| 187 | |
| 188 | printf("roaming = %d, reg_status = %d, deny_reason = %d\n", |
| 189 | ind->roaming, ind->reg_state, ind->deny_reason); |
| 190 | |
| 191 | if(QL_NW_RADIO_TECH_NR5G != ind->radio_tech) |
| 192 | { |
| 193 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d, endc_available=%d\n", |
| 194 | ind->mcc, |
| 195 | ind->mnc, |
| 196 | ind->forbidden, |
| 197 | ind->cid, |
| 198 | ind->lac, |
| 199 | ind->psc, |
| 200 | ind->tac, |
| 201 | ind->endc_available); |
| 202 | |
| 203 | printf("\tinPRL=%d, css=%d, sid=%d, nid=%d, bsid=%d\n", |
| 204 | ind->inPRL, |
| 205 | ind->css, |
| 206 | ind->sid, |
| 207 | ind->nid, |
| 208 | ind->bsid); |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%llX, pci=%d, tac=%d\n", |
| 213 | ind->mcc, |
| 214 | ind->mnc, |
| 215 | ind->forbidden, |
| 216 | ind->nr5g_cid, |
| 217 | ind->nr5g_pci, |
| 218 | ind->nr5g_tac); |
| 219 | |
| 220 | internal_nw_get_service_option(ind->nr5g_svc_opt, svc_opt, sizeof(svc_opt)); |
| 221 | printf("\tsvc_opt(%d)=%s\n", ind->nr5g_svc_opt, svc_opt); |
| 222 | } |
| 223 | } |
| 224 | #endif |
| 225 | |
| 226 | void nw_signal_strength_event_ind_cb(ql_nw_signal_strength_info_t *ind, QL_NW_SIGNAL_STRENGTH_LEVEL_E level) |
| 227 | { |
| 228 | char level_info[16] = {0}; |
| 229 | |
| 230 | if(ind == NULL) |
| 231 | { |
| 232 | printf("recv signal strength ind event, param is null\n"); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | printf("recv event indication : signal strength event\n"); |
| 237 | |
| 238 | if(ind->has_gsm) |
| 239 | { |
| 240 | printf("gsm_sig_info: rssi=%d\n", ind->gsm.rssi); |
| 241 | } |
| 242 | |
| 243 | if(ind->has_wcdma) |
| 244 | { |
| 245 | printf("wcdma_sig_info: rssi=%d, ecio=%d\n", |
| 246 | ind->wcdma.rssi, |
| 247 | ind->wcdma.ecio); |
| 248 | } |
| 249 | if(ind->has_tdscdma) |
| 250 | { |
| 251 | printf("tdscdma_sig_info: rssi=%d, rscp=%d, ecio=%d, sinr=%d\n", |
| 252 | ind->tdscdma.rssi, |
| 253 | ind->tdscdma.rscp, |
| 254 | ind->tdscdma.ecio, |
| 255 | ind->tdscdma.sinr); |
| 256 | } |
| 257 | if(ind->has_lte) |
| 258 | { |
| 259 | printf("lte_sig_info: rssi=%d, rsrq=%d, rsrp=%d, snr=%d\n", |
| 260 | ind->lte.rssi, |
| 261 | ind->lte.rsrq, |
| 262 | ind->lte.rsrp, |
| 263 | ind->lte.snr); |
| 264 | } |
| 265 | if(ind->has_nr5g) |
| 266 | { |
| 267 | printf("nr5g_sig_info: rsrp=%hd, rsrq=%hd, snr=%hd\n", |
| 268 | ind->nr5g.rsrp, |
| 269 | ind->nr5g.rsrq, |
| 270 | ind->nr5g.snr); |
| 271 | } |
| 272 | if(ind->has_cdma) |
| 273 | { |
| 274 | printf("cdma_sig_info: rssi=%d, ecio=%d\n", |
| 275 | ind->cdma.rssi, |
| 276 | ind->cdma.ecio); |
| 277 | } |
| 278 | if(ind->has_hdr) |
| 279 | { |
| 280 | printf("hdr_sig_info: rssi=%d, ecio=%d, sinr=%d, io=%d\n", |
| 281 | ind->hdr.rssi, |
| 282 | ind->hdr.ecio, |
| 283 | ind->hdr.sinr, |
| 284 | ind->hdr.io); |
| 285 | } |
| 286 | |
| 287 | if(internal_nw_get_signal_strength_level(level, level_info, sizeof(level_info)) == 0) |
| 288 | { |
| 289 | printf("signal strength level is %d, unrecognized\n", level); |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | printf("signal strength level is %s\n", level_info); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | #if 0 |
| 298 | void nw_cell_access_status_event_ind_cb(QL_NW_CELL_ACCESS_STATE_TYPE_E status) |
| 299 | { |
| 300 | printf("recv event indication : cell access status event\n"); |
| 301 | printf("status = %d\n", status); |
| 302 | } |
| 303 | |
| 304 | void nw_nitz_time_update_event_ind_cb(ql_nw_nitz_time_info_t *ind) |
| 305 | { |
| 306 | if(ind == NULL) |
| 307 | { |
| 308 | printf("recv nitz time update ind event, param is null\n"); |
| 309 | return; |
| 310 | } |
| 311 | printf("recv event indication : nitz time update event\n"); |
| 312 | printf("nitz_time=%s, abs_time=%lld, leap_sec=%d\n", |
| 313 | ind->nitz_time, ind->abs_time, ind->leap_sec); |
| 314 | } |
| 315 | |
| 316 | void nw_wea_alert_event_ind_cb(ql_nw_wea_alert_info_t *ind) |
| 317 | { |
| 318 | if(ind == NULL) |
| 319 | { |
| 320 | printf("recv wea alert ind event, param is null\n"); |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | printf("recv event indication : wea alert event, wea_alert_info_valid:[%d]\n", |
| 325 | ind->wea_alert_info_valid); |
| 326 | if(ind->wea_alert_info_valid) |
| 327 | { |
| 328 | printf("wea alert info:[%s] \n",ind->wea_alert_info); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | void nw_etws_alert_event_ind_cb(ql_nw_etws_alert_info_t *ind) |
| 333 | { |
| 334 | if(ind == NULL) |
| 335 | { |
| 336 | printf("recv etws alert ind event, param is null\n"); |
| 337 | return; |
| 338 | } |
| 339 | printf("recv event indication : etws alert event, etws_primary_info_valid:[%d] etws_secondary_info_valid:[%d]\n", |
| 340 | ind->etws_primary_info_valid, ind->etws_secondary_info_valid); |
| 341 | if(ind->etws_primary_info_valid) |
| 342 | { |
| 343 | printf("etws primary alert info:[%s] \n", ind->etws_primary_info); |
| 344 | } |
| 345 | if(ind->etws_secondary_info_valid) |
| 346 | { |
| 347 | printf("etws secondary alert info:[%s] \n", |
| 348 | ind->etws_secondary_info); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | void nw_network_scan_async_cb(int async_id, ql_nw_scan_result_list_info_t *info) |
| 353 | { |
| 354 | int i = 0; |
| 355 | char net_info[16] = {0}; |
| 356 | char radio_info[16] = {0}; |
| 357 | |
| 358 | printf("network scan async callback, async id is %d, list_len=%d, detail info:\n", async_id, info->entry_len); |
| 359 | for(i = 0; i < info->entry_len; i++) |
| 360 | { |
| 361 | memset(net_info, 0, sizeof(net_info)); |
| 362 | memset(radio_info, 0, sizeof(radio_info)); |
| 363 | printf("\t[%d]: long_eons=%s, short_eons=%s, mcc=%s, mnc=%s, ", |
| 364 | i, |
| 365 | info->entry[i].operator_name.long_eons, |
| 366 | info->entry[i].operator_name.short_eons, |
| 367 | info->entry[i].operator_name.mcc, |
| 368 | info->entry[i].operator_name.mnc); |
| 369 | |
| 370 | |
| 371 | if(internal_nw_get_net_status(info->entry[i].network_status, net_info, sizeof(net_info)) == 0) |
| 372 | { |
| 373 | printf("unrecognized network_status:%d, ", info->entry[i].network_status); |
| 374 | } |
| 375 | else |
| 376 | { |
| 377 | printf("network_status=%s, ", net_info); |
| 378 | } |
| 379 | |
| 380 | if(internal_nw_get_radio_tech(info->entry[i].rat, radio_info, sizeof(radio_info)) == 0) |
| 381 | { |
| 382 | printf("unrecognized rat:%d\n ", info->entry[i].rat); |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | printf("radio_tech=%s\n", radio_info); |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | #endif |
| 391 | |
| 392 | void nw_service_error_cb(int error) |
| 393 | { |
| 394 | printf("===== NW Service Abort =====\n"); |
| 395 | } |
| 396 | |
| 397 | void item_ql_nw_init(void) |
| 398 | { |
| 399 | int ret = 0; |
| 400 | |
| 401 | printf("Start to ql_nw_init: "); |
| 402 | ret = ql_nw_init(); |
| 403 | if(ret == QL_ERR_OK) |
| 404 | { |
| 405 | printf("nw init ok\n"); |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | printf("failed, ret=%d\n", ret); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | void item_ql_nw_deinit(void) |
| 414 | { |
| 415 | int ret = 0; |
| 416 | |
| 417 | printf("Start to ql_nw_deinit: "); |
| 418 | ret = ql_nw_deinit(); |
| 419 | if(ret == QL_ERR_OK) |
| 420 | { |
| 421 | printf("nw deinit ok\n"); |
| 422 | } |
| 423 | else |
| 424 | { |
| 425 | printf("failed, ret=%d\n", ret); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | #if 0 |
| 430 | void item_ql_nw_network_scan(void) |
| 431 | { |
| 432 | int ret; |
| 433 | int async_id = 0; |
| 434 | |
| 435 | ret = ql_nw_network_scan(&async_id, nw_network_scan_async_cb); |
| 436 | if(ret == QL_ERR_OK) |
| 437 | { |
| 438 | printf("async network scan succeed, token id is %d\n", async_id); |
| 439 | } |
| 440 | else |
| 441 | { |
| 442 | printf("async network scan failed, token id is %d, ret=%d", async_id, ret); |
| 443 | } |
| 444 | } |
| 445 | #endif |
| 446 | |
| 447 | void item_ql_nw_set_power_mode(void) |
| 448 | { |
| 449 | int ret; |
| 450 | uint32_t mode = 0; |
| 451 | |
| 452 | printf("please input power mode mask hex(VOICE | SMS | SIM | NETWORK | NORMAL): "); |
| 453 | ret = t_get_hex(&mode); |
| 454 | if(ret != 0) |
| 455 | { |
| 456 | printf("Invalid input\n"); |
| 457 | return; |
| 458 | } |
| 459 | ret = ql_nw_set_power_mode(mode); |
| 460 | printf("ql_nw_set_lower_power_mode ret = %d\n", ret); |
| 461 | } |
| 462 | |
| 463 | #if 0 |
| 464 | void item_ql_nw_set_pref_nwmode_roaming(void) |
| 465 | { |
| 466 | int ret; |
| 467 | uint32_t mask = 0; |
| 468 | ql_nw_pref_nwmode_roaming_info_t t_info; |
| 469 | |
| 470 | memset(&t_info, 0, sizeof(t_info)); |
| 471 | printf("please input config mask hex(TDSCDMA | LTE | EVDO | CDMA | WCDMA | GSM): "); |
| 472 | ret = t_get_hex(&mask); |
| 473 | if(ret != 0) |
| 474 | { |
| 475 | printf("Invalid input\n"); |
| 476 | return; |
| 477 | } |
| 478 | t_info.preferred_nw_mode = mask; |
| 479 | |
| 480 | #if 0 |
| 481 | printf("please input roaming pref(0:off 1:on): "); |
| 482 | ret = t_get_int((int *)&mask); |
| 483 | if(ret != 0) |
| 484 | { |
| 485 | printf("Invalid input\n"); |
| 486 | return; |
| 487 | } |
| 488 | |
| 489 | t_info.preferred_roaming = mask; |
| 490 | #endif |
| 491 | ret = ql_nw_set_pref_nwmode_roaming(&t_info); |
| 492 | printf("ql_nw_set_config ret = %d\n", ret); |
| 493 | } |
| 494 | |
| 495 | void item_ql_nw_get_pref_nwmode_roaming(void) |
| 496 | { |
| 497 | int ret; |
| 498 | ql_nw_pref_nwmode_roaming_info_t t_info; |
| 499 | |
| 500 | memset(&t_info, 0, sizeof(t_info)); |
| 501 | ret = ql_nw_get_pref_nwmode_roaming(&t_info); |
| 502 | #if 0 |
| 503 | printf("ql_nw_get_config ret = %d\npreferred_nw_mode=%#llx, preferred_roaming=%d\n", |
| 504 | ret, t_info.preferred_nw_mode, t_info.preferred_roaming); |
| 505 | #else |
| 506 | printf("ql_nw_get_config ret = %d\npreferred_nw_mode=%#llx\n", |
| 507 | ret, t_info.preferred_nw_mode); |
| 508 | #endif |
| 509 | } |
| 510 | |
| 511 | void item_ql_nw_get_mobile_operator_name(void) |
| 512 | { |
| 513 | int ret; |
| 514 | ql_nw_mobile_operator_name_info_t t_info; |
| 515 | |
| 516 | memset(&t_info, 0, sizeof(t_info)); |
| 517 | ret = ql_nw_get_mobile_operator_name(&t_info); |
| 518 | printf("ql_nw_get_operator_name ret = %d, long_eons=%s, short_eons=%s, mcc=%s, mnc=%s\n", |
| 519 | ret, |
| 520 | t_info.long_eons, |
| 521 | t_info.short_eons, |
| 522 | t_info.mcc, |
| 523 | t_info.mnc); |
| 524 | } |
| 525 | |
| 526 | void item_ql_nw_get_cell_info(void) |
| 527 | { |
| 528 | int i; |
| 529 | int ret; |
| 530 | unsigned short mcc; |
| 531 | unsigned short mnc; |
| 532 | ql_nw_cell_info_t t_info; |
| 533 | |
| 534 | memset(&t_info, 0, sizeof(t_info)); |
| 535 | ret = ql_nw_get_cell_info(&t_info); |
| 536 | printf("ql_nw_get_cell_info ret = %d, detail info:\n", ret); |
| 537 | |
| 538 | if(t_info.gsm_info_valid) |
| 539 | { |
| 540 | printf("gsm cell information:\n"); |
| 541 | for(i = 0; i < t_info.gsm_info_len; i++) |
| 542 | { |
| 543 | printf("\tcid=%d,plmn=0x%02x 0x%02x 0x%02x,lac=%d,arfcn=%d,bsic=%d,rssi=%d,", |
| 544 | t_info.gsm_info[i].cid, |
| 545 | t_info.gsm_info[i].plmn[0], |
| 546 | t_info.gsm_info[i].plmn[1], |
| 547 | t_info.gsm_info[i].plmn[2], |
| 548 | t_info.gsm_info[i].lac, |
| 549 | t_info.gsm_info[i].arfcn, |
| 550 | t_info.gsm_info[i].bsic, |
| 551 | t_info.gsm_info[i].rssi); |
| 552 | |
| 553 | internal_nw_get_mcc_mnc_value(t_info.gsm_info[i].plmn, 3, &mcc, &mnc); |
| 554 | printf("convert plmn to mcc=%d,mnc=%02d\n", mcc, mnc); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | if(t_info.umts_info_valid) |
| 559 | { |
| 560 | printf("umts cell information:\n"); |
| 561 | for(i = 0; i < t_info.umts_info_len; i++) |
| 562 | { |
| 563 | printf("\tcid=%d,lcid=%d,plmn=0x%02x 0x%02x 0x%02x,lac=%d,uarfcn=%d,psc=%d,rssi=%d,", |
| 564 | t_info.umts_info[i].cid, |
| 565 | t_info.umts_info[i].lcid, |
| 566 | t_info.umts_info[i].plmn[0], |
| 567 | t_info.umts_info[i].plmn[1], |
| 568 | t_info.umts_info[i].plmn[2], |
| 569 | t_info.umts_info[i].lac, |
| 570 | t_info.umts_info[i].uarfcn, |
| 571 | t_info.umts_info[i].psc, |
| 572 | t_info.umts_info[i].rssi); |
| 573 | internal_nw_get_mcc_mnc_value(t_info.umts_info[i].plmn, 3, &mcc, &mnc); |
| 574 | printf("convert plmn to mcc=%d,mnc=%02d\n", mcc, mnc); |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | if(t_info.lte_info_valid) |
| 579 | { |
| 580 | printf("lte cell information:\n"); |
| 581 | for(i = 0; i < t_info.lte_info_len; i++) |
| 582 | { |
| 583 | printf("\tcid=%d,plmn=0x%02x 0x%02x 0x%02x,tac=%d,pci=%d,earfcn=%d,rssi=%d,", |
| 584 | t_info.lte_info[i].cid, |
| 585 | t_info.lte_info[i].plmn[0], |
| 586 | t_info.lte_info[i].plmn[1], |
| 587 | t_info.lte_info[i].plmn[2], |
| 588 | t_info.lte_info[i].tac, |
| 589 | t_info.lte_info[i].pci, |
| 590 | t_info.lte_info[i].earfcn, |
| 591 | t_info.lte_info[i].rssi); |
| 592 | internal_nw_get_mcc_mnc_value(t_info.lte_info[i].plmn, 3, &mcc, &mnc); |
| 593 | printf("convert plmn to mcc=%d,mnc=%02d\n", mcc, mnc); |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | if(t_info.nr5g_info_valid) |
| 598 | { |
| 599 | printf("nr5g cell information:\n"); |
| 600 | printf("\tcid=%lld,plmn=0x%02x 0x%02x 0x%02x,tac=%d,pci=%d,arfcn=%d,rsrp=%d,rsrq=%d,snr=%d,", |
| 601 | t_info.nr5g_info.cid, |
| 602 | t_info.nr5g_info.plmn[0], |
| 603 | t_info.nr5g_info.plmn[1], |
| 604 | t_info.nr5g_info.plmn[2], |
| 605 | t_info.nr5g_info.tac, |
| 606 | t_info.nr5g_info.pci, |
| 607 | t_info.nr5g_info.arfcn, |
| 608 | t_info.nr5g_info.rsrp, |
| 609 | t_info.nr5g_info.rsrq, |
| 610 | t_info.nr5g_info.snr); |
| 611 | internal_nw_get_mcc_mnc_value(t_info.nr5g_info.plmn, 3, &mcc, &mnc); |
| 612 | printf("convert plmn to mcc=%d,mnc=%02d\n", mcc, mnc); |
| 613 | } |
| 614 | |
| 615 | if(t_info.cdma_info_valid) |
| 616 | { |
| 617 | printf("cdma cell information:\n"); |
| 618 | printf("\tsid=%d,nid=%d,bid=%d,refpn=%d,base_lat=%d,base_long=%d,rssi=%d\n", |
| 619 | t_info.cdma_info.sid, |
| 620 | t_info.cdma_info.nid, |
| 621 | t_info.cdma_info.bid, |
| 622 | t_info.cdma_info.refpn, |
| 623 | t_info.cdma_info.base_lat, |
| 624 | t_info.cdma_info.base_long, |
| 625 | t_info.cdma_info.rssi); |
| 626 | } |
| 627 | } |
| 628 | #endif |
| 629 | |
| 630 | void item_ql_nw_get_voice_reg_status(void) |
| 631 | { |
| 632 | int ret; |
| 633 | char domain_info[16] = {0}; |
| 634 | char radio_info[16] = {0}; |
| 635 | char svc_opt[128] = {0}; |
| 636 | ql_nw_reg_status_info_t t_info; |
| 637 | |
| 638 | memset(&t_info, 0, sizeof(t_info)); |
| 639 | ret = ql_nw_get_voice_reg_status(&t_info); |
| 640 | |
| 641 | printf("ql_nw_get_voice_reg_status ret = %d, detail info:\n", ret); |
| 642 | |
| 643 | if(internal_nw_get_tech_domain(t_info.tech_domain, domain_info, sizeof(domain_info)) == 0) |
| 644 | { |
| 645 | printf("\ttech_domain is unrecognized:%d, ", t_info.tech_domain); |
| 646 | } |
| 647 | else |
| 648 | { |
| 649 | printf("\ttech_domain = %s, ", domain_info); |
| 650 | } |
| 651 | |
| 652 | if(internal_nw_get_radio_tech(t_info.radio_tech, radio_info, sizeof(radio_info)) == 0) |
| 653 | { |
| 654 | printf("radio_tech is unrecognized:%d, ", t_info.radio_tech); |
| 655 | } |
| 656 | else |
| 657 | { |
| 658 | printf("radio_tech = %s, ", radio_info); |
| 659 | } |
| 660 | |
| 661 | printf("roaming = %d, reg_status = %d, deny_reason = %d\n", |
| 662 | t_info.roaming, t_info.reg_state, t_info.deny_reason); |
| 663 | |
| 664 | if(QL_NW_RADIO_TECH_NR5G != t_info.radio_tech) |
| 665 | { |
| 666 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d, endc_available=%d\n", |
| 667 | t_info.mcc, |
| 668 | t_info.mnc, |
| 669 | t_info.forbidden, |
| 670 | t_info.cid, |
| 671 | t_info.lac, |
| 672 | t_info.psc, |
| 673 | t_info.tac, |
| 674 | t_info.endc_available); |
| 675 | |
| 676 | printf("\tinPRL=%d, css=%d, sid=%d, nid=%d, bsid=%d\n", |
| 677 | t_info.inPRL, |
| 678 | t_info.css, |
| 679 | t_info.sid, |
| 680 | t_info.nid, |
| 681 | t_info.bsid); |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%llX, pci=%d, tac=%d\n", |
| 686 | t_info.mcc, |
| 687 | t_info.mnc, |
| 688 | t_info.forbidden, |
| 689 | t_info.nr5g_cid, |
| 690 | t_info.nr5g_pci, |
| 691 | t_info.nr5g_tac); |
| 692 | |
| 693 | internal_nw_get_service_option(t_info.nr5g_svc_opt, svc_opt, sizeof(svc_opt)); |
| 694 | printf("\tsvc_opt(%d)=%s\n", t_info.nr5g_svc_opt, svc_opt); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | void item_ql_nw_get_data_reg_status(void) |
| 699 | { |
| 700 | int ret; |
| 701 | char domain_info[16] = {0}; |
| 702 | char radio_info[16] = {0}; |
| 703 | char svc_opt[128] = {0}; |
| 704 | ql_nw_reg_status_info_t t_info; |
| 705 | |
| 706 | memset(&t_info, 0, sizeof(t_info)); |
| 707 | ret = ql_nw_get_data_reg_status(&t_info); |
| 708 | |
| 709 | printf("ql_nw_get_data_reg_status ret = %d, detail info:\n", ret); |
| 710 | |
| 711 | if(internal_nw_get_tech_domain(t_info.tech_domain, domain_info, sizeof(domain_info)) == 0) |
| 712 | { |
| 713 | printf("\ttech_domain is unrecognized:%d, ", t_info.tech_domain); |
| 714 | } |
| 715 | else |
| 716 | { |
| 717 | printf("\ttech_domain = %s, ", domain_info); |
| 718 | } |
| 719 | |
| 720 | if(internal_nw_get_radio_tech(t_info.radio_tech, radio_info, sizeof(radio_info)) == 0) |
| 721 | { |
| 722 | printf("radio_tech is unrecognized:%d, ", t_info.radio_tech); |
| 723 | } |
| 724 | else |
| 725 | { |
| 726 | printf("radio_tech = %s, ", radio_info); |
| 727 | } |
| 728 | |
| 729 | printf("roaming = %d, reg_status = %d, deny_reason = %d\n", |
| 730 | t_info.roaming, t_info.reg_state, t_info.deny_reason); |
| 731 | |
| 732 | if(QL_NW_RADIO_TECH_NR5G != t_info.radio_tech) |
| 733 | { |
| 734 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%X, lac=%d, psc=%d, endc_available=%d\n", |
| 735 | t_info.mcc, |
| 736 | t_info.mnc, |
| 737 | t_info.forbidden, |
| 738 | t_info.cid, |
| 739 | t_info.lac, |
| 740 | t_info.psc, |
| 741 | //t_info.tac, // tac not valid in item_ql_nw_get_data_reg_status ,use item_ql_nw_get_cell_info |
| 742 | t_info.endc_available); |
| 743 | |
| 744 | printf("\tinPRL=%d, css=%d, sid=%d, nid=%d, bsid=%d\n", |
| 745 | t_info.inPRL, |
| 746 | t_info.css, |
| 747 | t_info.sid, |
| 748 | t_info.nid, |
| 749 | t_info.bsid); |
| 750 | } |
| 751 | else |
| 752 | { |
| 753 | printf("\tmcc=%s, mnc=%s, forbidden=%d, cid=0x%llX, pci=%d, tac=%d\n", |
| 754 | t_info.mcc, |
| 755 | t_info.mnc, |
| 756 | t_info.forbidden, |
| 757 | t_info.nr5g_cid, |
| 758 | t_info.nr5g_pci, |
| 759 | t_info.nr5g_tac); |
| 760 | |
| 761 | internal_nw_get_service_option(t_info.nr5g_svc_opt, svc_opt, sizeof(svc_opt)); |
| 762 | printf("\tsvc_opt(%d)=%s\n", t_info.nr5g_svc_opt, svc_opt); |
| 763 | } |
| 764 | |
| 765 | } |
| 766 | |
| 767 | void item_ql_nw_get_signal_strength(void) |
| 768 | { |
| 769 | int ret; |
| 770 | char level_info[16] = {0}; |
| 771 | ql_nw_signal_strength_info_t info; |
| 772 | QL_NW_SIGNAL_STRENGTH_LEVEL_E level = QL_NW_SIGNAL_STRENGTH_LEVEL_NONE; |
| 773 | |
| 774 | memset(&info, 0, sizeof(info)); |
| 775 | ret = ql_nw_get_signal_strength(&info, &level); |
| 776 | if (QL_ERR_OK != ret) |
| 777 | { |
| 778 | printf("failed, ret = %d\n", ret); |
| 779 | return; |
| 780 | } |
| 781 | |
| 782 | if(info.has_gsm) |
| 783 | { |
| 784 | printf("gsm_sig_info: rssi=%hhd\n", info.gsm.rssi); |
| 785 | } |
| 786 | |
| 787 | if(info.has_wcdma) |
| 788 | { |
| 789 | printf("wcdma_sig_info: rssi=%hhd, ecio=%hd\n", |
| 790 | info.wcdma.rssi, |
| 791 | info.wcdma.ecio); |
| 792 | } |
| 793 | |
| 794 | if(info.has_tdscdma) |
| 795 | { |
| 796 | printf("tdscdma_sig_info: rssi=%hhd, rscp=%hhd, ecio=%hd, sinr=%hhd\n", |
| 797 | info.tdscdma.rssi, |
| 798 | info.tdscdma.rscp, |
| 799 | info.tdscdma.ecio, |
| 800 | info.tdscdma.sinr); |
| 801 | } |
| 802 | |
| 803 | if(info.has_lte) |
| 804 | { |
| 805 | printf("lte_sig_info: rssi=%hhd, rsrq=%hhd, rsrp=%hd, snr=%hd\n", |
| 806 | info.lte.rssi, |
| 807 | info.lte.rsrq, |
| 808 | info.lte.rsrp, |
| 809 | info.lte.snr); |
| 810 | } |
| 811 | |
| 812 | if(info.has_nr5g) |
| 813 | { |
| 814 | printf("nr5g_sig_info: rsrp=%hd, rsrq=%hd, snr=%hd\n", |
| 815 | info.nr5g.rsrp, |
| 816 | info.nr5g.rsrq, |
| 817 | info.nr5g.snr); |
| 818 | } |
| 819 | |
| 820 | if(info.has_cdma) |
| 821 | { |
| 822 | printf("cdma_sig_info: rssi=%hhd, ecio=%hd\n", |
| 823 | info.cdma.rssi, |
| 824 | info.cdma.ecio); |
| 825 | } |
| 826 | |
| 827 | if(info.has_hdr) |
| 828 | { |
| 829 | printf("hdr_sig_info: rssi=%hhd, ecio=%hd, sinr=%hd, io=%d\n", |
| 830 | info.hdr.rssi, |
| 831 | info.hdr.ecio, |
| 832 | info.hdr.sinr, |
| 833 | info.hdr.io); |
| 834 | } |
| 835 | |
| 836 | if(internal_nw_get_signal_strength_level(level, level_info, sizeof(level_info)) == 0) |
| 837 | { |
| 838 | printf("signal strength level is %d, unrecognized\n", level); |
| 839 | } |
| 840 | else |
| 841 | { |
| 842 | printf("signal strength level is %s\n", level_info); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | #if 0 |
| 847 | void item_ql_nw_get_cell_access_status(void) |
| 848 | { |
| 849 | int ret; |
| 850 | QL_NW_CELL_ACCESS_STATE_TYPE_E e_state; |
| 851 | |
| 852 | ret = ql_nw_get_cell_access_status(&e_state); |
| 853 | printf("ql_nw_get_cell_access_state ret = %d, e_state=%d\n", ret, e_state); |
| 854 | } |
| 855 | |
| 856 | void item_ql_nw_get_nitz_time_info(void) |
| 857 | { |
| 858 | int ret; |
| 859 | ql_nw_nitz_time_info_t t_info; |
| 860 | |
| 861 | memset(&t_info, 0, sizeof(t_info)); |
| 862 | ret = ql_nw_get_nitz_time_info(&t_info); |
| 863 | printf("ql_nw_get_nitz_time_info ret = %d\n nitz_time=%s, abs_time=%lld, leap_sec=%hhd\n", |
| 864 | ret, |
| 865 | t_info.nitz_time, |
| 866 | t_info.abs_time, |
| 867 | t_info.leap_sec); |
| 868 | } |
| 869 | #endif |
| 870 | |
| 871 | void item_ql_nw_set_voice_reg_ind_cb(void) |
| 872 | { |
| 873 | int ret = 0; |
| 874 | int reg_flag = 0; |
| 875 | |
| 876 | printf("please input voice reg option: (0: unreg, other: reg): "); |
| 877 | ret = t_get_int(®_flag); |
| 878 | if(ret != 0) |
| 879 | { |
| 880 | printf("Invalid input\n"); |
| 881 | return; |
| 882 | } |
| 883 | if(reg_flag) |
| 884 | { |
| 885 | ret = ql_nw_set_voice_reg_ind_cb(nw_voice_reg_event_ind_cb); |
| 886 | } |
| 887 | else |
| 888 | { |
| 889 | ret = ql_nw_set_voice_reg_ind_cb(NULL); |
| 890 | } |
| 891 | printf("ql_nw_reg_voice_reg_event ret = %d\n", ret); |
| 892 | } |
| 893 | |
| 894 | #if 0 |
| 895 | void item_ql_nw_set_data_reg_ind_cb(void) |
| 896 | { |
| 897 | int ret = 0; |
| 898 | int reg_flag = 0; |
| 899 | |
| 900 | printf("please input data reg option: (0: unreg, other: reg): "); |
| 901 | ret = t_get_int(®_flag); |
| 902 | if(ret != 0) |
| 903 | { |
| 904 | printf("Invalid input\n"); |
| 905 | return; |
| 906 | } |
| 907 | if(reg_flag) |
| 908 | { |
| 909 | ret = ql_nw_set_data_reg_ind_cb(nw_data_reg_event_ind_cb); |
| 910 | } |
| 911 | else |
| 912 | { |
| 913 | ret = ql_nw_set_data_reg_ind_cb(NULL); |
| 914 | } |
| 915 | printf("ql_nw_reg_data_reg_event ret = %d\n", ret); |
| 916 | } |
| 917 | #endif |
| 918 | |
| 919 | void item_ql_nw_set_signal_strength_chg_ind_cb(void) |
| 920 | { |
| 921 | int ret = 0; |
| 922 | int reg_flag = 0; |
| 923 | |
| 924 | printf("please input signal strength change reg option: (0: unreg, other: reg): "); |
| 925 | ret = t_get_int(®_flag); |
| 926 | if(ret != 0) |
| 927 | { |
| 928 | printf("Invalid input\n"); |
| 929 | return; |
| 930 | } |
| 931 | |
| 932 | if(reg_flag) |
| 933 | { |
| 934 | ret = ql_nw_set_signal_strength_ind_cb(nw_signal_strength_event_ind_cb); |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | ret = ql_nw_set_signal_strength_ind_cb(NULL); |
| 939 | } |
| 940 | printf("ql_nw_reg_signal_strength_chg_event ret = %d\n", ret); |
| 941 | } |
| 942 | |
| 943 | #if 0 |
| 944 | void item_ql_nw_set_cell_access_status_chg_ind_cb(void) |
| 945 | { |
| 946 | int ret = 0; |
| 947 | int reg_flag = 0; |
| 948 | |
| 949 | printf("please input cell access status change reg option: (0: unreg, other: reg): "); |
| 950 | ret = t_get_int(®_flag); |
| 951 | if(ret != 0) |
| 952 | { |
| 953 | printf("Invalid input\n"); |
| 954 | return; |
| 955 | } |
| 956 | |
| 957 | if(reg_flag) |
| 958 | { |
| 959 | ret = ql_nw_set_cell_access_status_ind_cb(nw_cell_access_status_event_ind_cb); |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | ret = ql_nw_set_cell_access_status_ind_cb(NULL); |
| 964 | } |
| 965 | printf("ql_nw_reg_cell_access_status_event ret = %d\n", ret); |
| 966 | } |
| 967 | |
| 968 | void item_ql_nw_set_nitz_time_update_ind_cb(void) |
| 969 | { |
| 970 | int ret = 0; |
| 971 | int reg_flag = 0; |
| 972 | |
| 973 | printf("please input nitz time update reg option: (0: unreg, other: reg): "); |
| 974 | ret = t_get_int(®_flag); |
| 975 | if(ret != 0) |
| 976 | { |
| 977 | printf("Invalid input\n"); |
| 978 | return; |
| 979 | } |
| 980 | |
| 981 | if(reg_flag) |
| 982 | { |
| 983 | ret = ql_nw_set_nitz_time_update_ind_cb(nw_nitz_time_update_event_ind_cb); |
| 984 | } |
| 985 | else |
| 986 | { |
| 987 | ret = ql_nw_set_nitz_time_update_ind_cb(NULL); |
| 988 | } |
| 989 | printf("ql_nw_reg_nitz_time_update_event ret = %d\n", ret); |
| 990 | } |
| 991 | |
| 992 | void item_ql_nw_set_wea_alert_ind_cb(void) |
| 993 | { |
| 994 | int ret = 0; |
| 995 | int reg_flag = 0; |
| 996 | |
| 997 | printf("please input wea alert reg option: (0: unreg, other: reg): "); |
| 998 | ret = t_get_int(®_flag); |
| 999 | if(ret != 0) |
| 1000 | { |
| 1001 | printf("Invalid input\n"); |
| 1002 | return; |
| 1003 | } |
| 1004 | |
| 1005 | if(reg_flag) |
| 1006 | { |
| 1007 | ret = ql_nw_set_wea_alert_ind_cb(nw_wea_alert_event_ind_cb); |
| 1008 | } |
| 1009 | else |
| 1010 | { |
| 1011 | ret = ql_nw_set_wea_alert_ind_cb(NULL); |
| 1012 | } |
| 1013 | printf("ql_nw_set_wea_alert_ind_cb ret = %d\n", ret); |
| 1014 | } |
| 1015 | |
| 1016 | void item_ql_nw_set_etws_alert_ind_cb(void) |
| 1017 | { |
| 1018 | int ret = 0; |
| 1019 | int reg_flag = 0; |
| 1020 | |
| 1021 | printf("please input etws alert reg option: (0: unreg, other: reg): "); |
| 1022 | ret = t_get_int(®_flag); |
| 1023 | if(ret != 0) |
| 1024 | { |
| 1025 | printf("Invalid input\n"); |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | if(reg_flag) |
| 1030 | { |
| 1031 | ret = ql_nw_set_etws_alert_ind_cb(nw_etws_alert_event_ind_cb); |
| 1032 | } |
| 1033 | else |
| 1034 | { |
| 1035 | ret = ql_nw_set_etws_alert_ind_cb(NULL); |
| 1036 | } |
| 1037 | printf("ql_nw_set_etws_alert_ind_cb ret = %d\n", ret); |
| 1038 | } |
| 1039 | #endif |
| 1040 | |
| 1041 | static void internal_nw_get_mcc_mnc_value(char *plmn, int plmn_len, unsigned short *mcc, unsigned short *mnc) |
| 1042 | { |
| 1043 | int mcc1 = 0, mcc2 = 0, mcc3 = 0; |
| 1044 | int mnc1 = 0, mnc2 = 0, mnc3 = 0; |
| 1045 | |
| 1046 | if(plmn_len < 3 || plmn == NULL) { |
| 1047 | printf("get mcc mnc from plmn fail, param is invalid\n"); |
| 1048 | return; |
| 1049 | } |
| 1050 | |
| 1051 | mcc1 = plmn[0] & 0X0F; |
| 1052 | mcc2 = plmn[0] >> 4; |
| 1053 | mcc3 = plmn[1] & 0x0F; |
| 1054 | |
| 1055 | mnc3 = plmn[1] >> 4; |
| 1056 | mnc2 = plmn[2] >> 4; |
| 1057 | mnc1 = plmn[2] & 0x0F; |
| 1058 | |
| 1059 | *mcc = mcc1 * 100 + mcc2 * 10 + mcc3; |
| 1060 | |
| 1061 | if(0X0F == mnc3) { |
| 1062 | *mnc = mnc1 * 10 + mnc2; |
| 1063 | } |
| 1064 | else { |
| 1065 | *mnc = mnc1 * 100 + mnc2 * 10 + mnc3; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | static int internal_nw_get_net_status(QL_NW_NETWORK_STATUS_TYPE_E net, char* buf, int buf_len) |
| 1070 | { |
| 1071 | int ret_val = 1; |
| 1072 | |
| 1073 | if(buf == NULL || buf_len < 2) |
| 1074 | { |
| 1075 | printf("param is valid\n"); |
| 1076 | return 0; |
| 1077 | } |
| 1078 | |
| 1079 | memset(buf, 0, buf_len); |
| 1080 | |
| 1081 | switch(net) |
| 1082 | { |
| 1083 | case QL_NW_NETWORK_STATUS_NONE: |
| 1084 | strncpy(buf, "NONE", buf_len - 1); |
| 1085 | buf[buf_len - 1] = '\0'; |
| 1086 | break; |
| 1087 | case QL_NW_NETWORK_STATUS_CURRENT_SERVING: |
| 1088 | strncpy(buf, "CURRENT_SERVING", buf_len - 1); |
| 1089 | buf[buf_len - 1] = '\0'; |
| 1090 | break; |
| 1091 | case QL_NW_NETWORK_STATUS_PREFERRED: |
| 1092 | strncpy(buf, "PREFERED", buf_len - 1); |
| 1093 | buf[buf_len - 1] = '\0'; |
| 1094 | break; |
| 1095 | case QL_NW_NETWORK_STATUS_NOT_PREFERRED: |
| 1096 | strncpy(buf, "NOT_PREFERRED", buf_len - 1); |
| 1097 | buf[buf_len - 1] = '\0'; |
| 1098 | break; |
| 1099 | case QL_NW_NETWORK_STATUS_AVAILABLE: |
| 1100 | strncpy(buf, "AVAILABLE", buf_len - 1); |
| 1101 | buf[buf_len - 1] = '\0'; |
| 1102 | break; |
| 1103 | case QL_NW_NETWORK_STATUS_FORBIDDEN: |
| 1104 | strncpy(buf, "FORBIDDEN", buf_len - 1); |
| 1105 | buf[buf_len - 1] = '\0'; |
| 1106 | break; |
| 1107 | default: |
| 1108 | ret_val = 0; |
| 1109 | break; |
| 1110 | } |
| 1111 | return ret_val; |
| 1112 | } |
| 1113 | |
| 1114 | #if 0 |
| 1115 | static int internal_nw_get_nas_rat(int radio, char* buf, int buf_len) |
| 1116 | { |
| 1117 | int ret_val = 1; |
| 1118 | |
| 1119 | if(buf == NULL || buf_len < 2) |
| 1120 | { |
| 1121 | printf("param is valid\n"); |
| 1122 | return 0; |
| 1123 | } |
| 1124 | |
| 1125 | memset(buf, 0, buf_len); |
| 1126 | |
| 1127 | switch(radio) |
| 1128 | { |
| 1129 | case 0: |
| 1130 | strncpy(buf, "UNKNOWN", buf_len - 1); |
| 1131 | buf[buf_len - 1] = '\0'; |
| 1132 | break; |
| 1133 | case 1: |
| 1134 | strncpy(buf, "GSM", buf_len - 1); |
| 1135 | buf[buf_len - 1] = '\0'; |
| 1136 | break; |
| 1137 | case 2: |
| 1138 | strncpy(buf, "WCDMA", buf_len - 1); |
| 1139 | buf[buf_len - 1] = '\0'; |
| 1140 | break; |
| 1141 | case 3: |
| 1142 | strncpy(buf, "TDSCDMA", buf_len - 1); |
| 1143 | buf[buf_len - 1] = '\0'; |
| 1144 | break; |
| 1145 | case 4: |
| 1146 | strncpy(buf, "LTE", buf_len - 1); |
| 1147 | buf[buf_len - 1] = '\0'; |
| 1148 | break; |
| 1149 | case 5: |
| 1150 | strncpy(buf, "NR5G", buf_len - 1); |
| 1151 | buf[buf_len - 1] = '\0'; |
| 1152 | break; |
| 1153 | case 6: |
| 1154 | strncpy(buf, "CDMA", buf_len - 1); |
| 1155 | buf[buf_len - 1] = '\0'; |
| 1156 | break; |
| 1157 | case 7: |
| 1158 | strncpy(buf, "HDR", buf_len - 1); |
| 1159 | buf[buf_len - 1] = '\0'; |
| 1160 | break; |
| 1161 | default: |
| 1162 | ret_val = 0; |
| 1163 | break; |
| 1164 | } |
| 1165 | return ret_val; |
| 1166 | } |
| 1167 | #endif |
| 1168 | |
| 1169 | static int internal_nw_get_radio_tech(QL_NW_RADIO_TECH_TYPE_E radio, char* buf, int buf_len) |
| 1170 | { |
| 1171 | int ret_val = 1; |
| 1172 | |
| 1173 | if(buf == NULL || buf_len < 2) |
| 1174 | { |
| 1175 | printf("param is valid\n"); |
| 1176 | return 0; |
| 1177 | } |
| 1178 | |
| 1179 | memset(buf, 0, buf_len); |
| 1180 | |
| 1181 | switch(radio) |
| 1182 | { |
| 1183 | case QL_NW_RADIO_TECH_TD_SCDMA: |
| 1184 | strncpy(buf, "TD_SCDMA", buf_len - 1); |
| 1185 | buf[buf_len - 1] = '\0'; |
| 1186 | break; |
| 1187 | case QL_NW_RADIO_TECH_GSM: |
| 1188 | strncpy(buf, "GSM", buf_len - 1); |
| 1189 | buf[buf_len - 1] = '\0'; |
| 1190 | break; |
| 1191 | case QL_NW_RADIO_TECH_HSPAP: |
| 1192 | strncpy(buf, "HSPAP", buf_len - 1); |
| 1193 | buf[buf_len - 1] = '\0'; |
| 1194 | break; |
| 1195 | case QL_NW_RADIO_TECH_LTE: |
| 1196 | strncpy(buf, "LTE", buf_len - 1); |
| 1197 | buf[buf_len - 1] = '\0'; |
| 1198 | break; |
| 1199 | case QL_NW_RADIO_TECH_EHRPD: |
| 1200 | strncpy(buf, "EHRPD", buf_len - 1); |
| 1201 | buf[buf_len - 1] = '\0'; |
| 1202 | break; |
| 1203 | case QL_NW_RADIO_TECH_EVDO_B: |
| 1204 | strncpy(buf, "EVDO_B", buf_len - 1); |
| 1205 | buf[buf_len - 1] = '\0'; |
| 1206 | break; |
| 1207 | case QL_NW_RADIO_TECH_HSPA: |
| 1208 | strncpy(buf, "HSPA", buf_len - 1); |
| 1209 | buf[buf_len - 1] = '\0'; |
| 1210 | break; |
| 1211 | case QL_NW_RADIO_TECH_HSUPA: |
| 1212 | strncpy(buf, "HSUPA", buf_len - 1); |
| 1213 | buf[buf_len - 1] = '\0'; |
| 1214 | break; |
| 1215 | case QL_NW_RADIO_TECH_HSDPA: |
| 1216 | strncpy(buf, "HSDPA", buf_len - 1); |
| 1217 | buf[buf_len - 1] = '\0'; |
| 1218 | break; |
| 1219 | case QL_NW_RADIO_TECH_EVDO_A: |
| 1220 | strncpy(buf, "EVDO_A", buf_len - 1); |
| 1221 | buf[buf_len - 1] = '\0'; |
| 1222 | break; |
| 1223 | case QL_NW_RADIO_TECH_EVDO_0: |
| 1224 | strncpy(buf, "EVDO_0", buf_len - 1); |
| 1225 | buf[buf_len - 1] = '\0'; |
| 1226 | break; |
| 1227 | case QL_NW_RADIO_TECH_1xRTT: |
| 1228 | strncpy(buf, "1xRTT", buf_len - 1); |
| 1229 | buf[buf_len - 1] = '\0'; |
| 1230 | break; |
| 1231 | case QL_NW_RADIO_TECH_IS95B: |
| 1232 | strncpy(buf, "IS95B", buf_len - 1); |
| 1233 | buf[buf_len - 1] = '\0'; |
| 1234 | break; |
| 1235 | case QL_NW_RADIO_TECH_IS95A: |
| 1236 | strncpy(buf, "IS95A", buf_len - 1); |
| 1237 | buf[buf_len - 1] = '\0'; |
| 1238 | break; |
| 1239 | case QL_NW_RADIO_TECH_UMTS: |
| 1240 | strncpy(buf, "UMTS", buf_len - 1); |
| 1241 | buf[buf_len - 1] = '\0'; |
| 1242 | break; |
| 1243 | case QL_NW_RADIO_TECH_EDGE: |
| 1244 | strncpy(buf, "EDGE", buf_len - 1); |
| 1245 | buf[buf_len - 1] = '\0'; |
| 1246 | break; |
| 1247 | case QL_NW_RADIO_TECH_GPRS: |
| 1248 | strncpy(buf, "GPRS", buf_len - 1); |
| 1249 | buf[buf_len - 1] = '\0'; |
| 1250 | break; |
| 1251 | case QL_NW_RADIO_TECH_NR5G: |
| 1252 | strncpy(buf, "NR5G", buf_len - 1); |
| 1253 | buf[buf_len - 1] = '\0'; |
| 1254 | break; |
| 1255 | case QL_NW_RADIO_TECH_NONE: |
| 1256 | strncpy(buf, "NONE", buf_len - 1); |
| 1257 | buf[buf_len - 1] = '\0'; |
| 1258 | break; |
| 1259 | default: |
| 1260 | ret_val = 0; |
| 1261 | break; |
| 1262 | } |
| 1263 | return ret_val; |
| 1264 | } |
| 1265 | |
| 1266 | static int internal_nw_get_tech_domain(QL_NW_TECH_DOMAIN_TYPE_E domain, char* buf, int buf_len) |
| 1267 | { |
| 1268 | int ret_val = 1; |
| 1269 | |
| 1270 | if(buf == NULL || buf_len < 2) |
| 1271 | { |
| 1272 | printf("param is valid\n"); |
| 1273 | return 0; |
| 1274 | } |
| 1275 | |
| 1276 | memset(buf, 0, buf_len); |
| 1277 | |
| 1278 | switch(domain) |
| 1279 | { |
| 1280 | case QL_NW_TECH_DOMAIN_NONE: |
| 1281 | strncpy(buf, "NONE", buf_len - 1); |
| 1282 | buf[buf_len - 1] = '\0'; |
| 1283 | break; |
| 1284 | case QL_NW_TECH_DOMAIN_3GPP: |
| 1285 | strncpy(buf, "3GPP", buf_len - 1); |
| 1286 | buf[buf_len - 1] = '\0'; |
| 1287 | break; |
| 1288 | case QL_NW_TECH_DOMAIN_3GPP2: |
| 1289 | strncpy(buf, "3GPP2", buf_len - 1); |
| 1290 | buf[buf_len - 1] = '\0'; |
| 1291 | break; |
| 1292 | default: |
| 1293 | ret_val = 0; |
| 1294 | break; |
| 1295 | } |
| 1296 | return ret_val; |
| 1297 | } |
| 1298 | |
| 1299 | static int internal_nw_get_signal_strength_level(QL_NW_SIGNAL_STRENGTH_LEVEL_E level, char* buf, int buf_len) |
| 1300 | { |
| 1301 | int ret_val = 1; |
| 1302 | |
| 1303 | if(buf == NULL || buf_len < 2) |
| 1304 | { |
| 1305 | printf("param is valid\n"); |
| 1306 | return 0; |
| 1307 | } |
| 1308 | |
| 1309 | memset(buf, 0, buf_len); |
| 1310 | |
| 1311 | switch(level) |
| 1312 | { |
| 1313 | case QL_NW_SIGNAL_STRENGTH_LEVEL_NONE: |
| 1314 | strncpy(buf, "UNKNOWN", buf_len - 1); |
| 1315 | buf[buf_len - 1] = '\0'; |
| 1316 | break; |
| 1317 | case QL_NW_SIGNAL_STRENGTH_LEVEL_POOR: |
| 1318 | strncpy(buf, "POOR", buf_len - 1); |
| 1319 | buf[buf_len - 1] = '\0'; |
| 1320 | break; |
| 1321 | case QL_NW_SIGNAL_STRENGTH_LEVEL_MODERATE: |
| 1322 | strncpy(buf, "MODERATE", buf_len - 1); |
| 1323 | buf[buf_len - 1] = '\0'; |
| 1324 | break; |
| 1325 | case QL_NW_SIGNAL_STRENGTH_LEVEL_GOOD: |
| 1326 | strncpy(buf, "GOOD", buf_len - 1); |
| 1327 | buf[buf_len - 1] = '\0'; |
| 1328 | break; |
| 1329 | case QL_NW_SIGNAL_STRENGTH_LEVEL_GREAT: |
| 1330 | strncpy(buf, "GREAT", buf_len - 1); |
| 1331 | buf[buf_len - 1] = '\0'; |
| 1332 | break; |
| 1333 | default: |
| 1334 | ret_val = 0; |
| 1335 | break; |
| 1336 | } |
| 1337 | return ret_val; |
| 1338 | } |
| 1339 | |
| 1340 | static void internal_nw_get_service_option(unsigned short so_mask, char *buf, int buf_len) |
| 1341 | { |
| 1342 | int remain_len = buf_len; |
| 1343 | |
| 1344 | if(NULL == buf || buf_len < 2) |
| 1345 | { |
| 1346 | printf("param is valid\n"); |
| 1347 | return; |
| 1348 | } |
| 1349 | memset(buf, 0, buf_len); |
| 1350 | |
| 1351 | if(so_mask & QL_NW_NR5G_SO_TDD) |
| 1352 | { |
| 1353 | if(remain_len > strlen("NR5G_TDD|") + 1) |
| 1354 | { |
| 1355 | strcat(buf + (buf_len - remain_len), "NR5G_TDD|"); |
| 1356 | remain_len = buf_len - strlen("NR5G_TDD|"); |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | if(so_mask & QL_NW_NR5G_SO_SUB6) |
| 1361 | { |
| 1362 | if(remain_len > strlen("NR5G_SUB6|") + 1) |
| 1363 | { |
| 1364 | strcat(buf + (buf_len - remain_len), "NR5G_SUB6|"); |
| 1365 | remain_len = buf_len - strlen("NR5G_SUB6|"); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | if(so_mask & QL_NW_NR5G_SO_MMWAVE) |
| 1370 | { |
| 1371 | if(remain_len > strlen("NR5G_MMWAVE|") + 1) |
| 1372 | { |
| 1373 | strcat(buf + (buf_len - remain_len), "NR5G_MMWAVE|"); |
| 1374 | remain_len = buf_len - strlen("NR5G_MMWAVE|"); |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | if(so_mask & QL_NW_NR5G_SO_NSA) |
| 1379 | { |
| 1380 | if(remain_len > strlen("NR5G_NSA|") + 1) |
| 1381 | { |
| 1382 | strcat(buf + (buf_len - remain_len), "NR5G_NSA|"); |
| 1383 | remain_len = buf_len - strlen("NR5G_NSA|"); |
| 1384 | } |
| 1385 | } |
| 1386 | |
| 1387 | if(so_mask & QL_NW_NR5G_SO_SA) |
| 1388 | { |
| 1389 | if(remain_len > strlen("NR5G_SA|") + 1) |
| 1390 | { |
| 1391 | strcat(buf + (buf_len - remain_len), "NR5G_SA|"); |
| 1392 | remain_len = buf_len - strlen("NR5G_SA|"); |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | if(strlen(buf) > 0) |
| 1397 | { |
| 1398 | buf[strlen(buf) - 1] = '\0'; |
| 1399 | } |
| 1400 | return; |
| 1401 | } |
| 1402 | |
| 1403 | #if 0 |
| 1404 | void item_ql_nw_wea_set_config(void) |
| 1405 | { |
| 1406 | int ret = 0; |
| 1407 | int choice = 0; |
| 1408 | int item = 0; |
| 1409 | ql_nw_wea_config_t config = {0}; |
| 1410 | |
| 1411 | printf("test ql_nw_wea_set_config: \n"); |
| 1412 | printf(" 1)Presidential_alert\n"); |
| 1413 | printf(" 2)Extreme_alert\n"); |
| 1414 | printf(" 3)Severe_alert\n"); |
| 1415 | printf(" 4)Amber_alert\n"); |
| 1416 | printf(" 5)PublicSafety_alert\n"); |
| 1417 | printf(" 6)StateLocalTest_alert\n"); |
| 1418 | printf(" 7)RMT_alert\n"); |
| 1419 | printf(" 8)Exercise_alert\n"); |
| 1420 | printf(" 9)CMSPDefined_alert\n"); |
| 1421 | printf("10)Spanish_alert\n"); |
| 1422 | printf("please enter item to config: "); |
| 1423 | ret = t_get_int(&choice); |
| 1424 | if(ret != 0) |
| 1425 | { |
| 1426 | printf("Invalid input\n"); |
| 1427 | return; |
| 1428 | } |
| 1429 | printf("\n"); |
| 1430 | |
| 1431 | switch (choice) |
| 1432 | { |
| 1433 | case 1: |
| 1434 | item |= QL_NW_WEA_CONFIG_PRESIDENTIAL_ALERT; |
| 1435 | printf("Presidential_alert: 0 - disable, 1 - enable:"); |
| 1436 | if(scanf("%hhu", &config.Presidential_alert) != 1) |
| 1437 | { |
| 1438 | printf("Invalid input\n"); |
| 1439 | return; |
| 1440 | } |
| 1441 | break; |
| 1442 | case 2: |
| 1443 | item |= QL_NW_WEA_CONFIG_EXTREME_ALERT; |
| 1444 | printf("Extreme_alert: 0 - disable, 1 - enable:"); |
| 1445 | if(scanf("%hhu", &config.Extreme_alert) != 1) |
| 1446 | { |
| 1447 | printf("Invalid input\n"); |
| 1448 | return; |
| 1449 | } |
| 1450 | break; |
| 1451 | case 3: |
| 1452 | item |= QL_NW_WEA_CONFIG_SEVERE_ALERT; |
| 1453 | printf("Severe_alert: 0 - disable, 1 - enable:"); |
| 1454 | if(scanf("%hhu", &config.Severe_alert) != 1) |
| 1455 | { |
| 1456 | printf("Invalid input\n"); |
| 1457 | return; |
| 1458 | } |
| 1459 | break; |
| 1460 | case 4: |
| 1461 | item |= QL_NW_WEA_CONFIG_AMBER_ALERT; |
| 1462 | printf("Amber_alert: 0 - disable, 1 - enable:"); |
| 1463 | if(scanf("%hhu", &config.Amber_alert) != 1) |
| 1464 | { |
| 1465 | printf("Invalid input\n"); |
| 1466 | return; |
| 1467 | } |
| 1468 | break; |
| 1469 | case 5: |
| 1470 | item |= QL_NW_WEA_CONFIG_PUBLIC_SAFETY_ALERT; |
| 1471 | printf("PublicSafety_alert: 0 - disable, 1 - enable:"); |
| 1472 | if(scanf("%hhu", &config.PublicSafety_alert) != 1) |
| 1473 | { |
| 1474 | printf("Invalid input\n"); |
| 1475 | return; |
| 1476 | } |
| 1477 | break; |
| 1478 | case 6: |
| 1479 | item |= QL_NW_WEA_CONFIG_STATE_LOCAL_TEST_ALERT; |
| 1480 | printf("StateLocalTest_alert: 0 - disable, 1 - enable:"); |
| 1481 | if(scanf("%hhu", &config.StateLocalTest_alert) != 1) |
| 1482 | { |
| 1483 | printf("Invalid input\n"); |
| 1484 | return; |
| 1485 | } |
| 1486 | break; |
| 1487 | case 7: |
| 1488 | item |= QL_NW_WEA_CONFIG_RMT_ALERT; |
| 1489 | printf("RMT_alert: 0 - disable, 1 - enable:"); |
| 1490 | if(scanf("%hhu", &config.RMT_alert) != 1) |
| 1491 | { |
| 1492 | printf("Invalid input\n"); |
| 1493 | return; |
| 1494 | } |
| 1495 | break; |
| 1496 | case 8: |
| 1497 | item |= QL_NW_WEA_CONFIG_EXERCISE_ALERT; |
| 1498 | printf("Exercise_alert: 0 - disable, 1 - enable:"); |
| 1499 | if(scanf("%hhu", &config.Exercise_alert) != 1) |
| 1500 | { |
| 1501 | printf("Invalid input\n"); |
| 1502 | return; |
| 1503 | } |
| 1504 | break; |
| 1505 | case 9: |
| 1506 | item |= QL_NW_WEA_CONFIG_CMSP_DEFINED_ALERT; |
| 1507 | printf("CMSPDefined_alert: 0 - disable, 1 - enable:"); |
| 1508 | if(scanf("%hhu", &config.CMSPDefined_alert) != 1) |
| 1509 | { |
| 1510 | printf("Invalid input\n"); |
| 1511 | return; |
| 1512 | } |
| 1513 | break; |
| 1514 | case 10: |
| 1515 | item |= QL_NW_WEA_CONFIG_SPANISH_ALERT; |
| 1516 | printf("Spanish_alert: 0 - disable, 1 - enable:"); |
| 1517 | if(scanf("%hhu", &config.Spanish_alert) != 1) |
| 1518 | { |
| 1519 | printf("Invalid input\n"); |
| 1520 | return; |
| 1521 | } |
| 1522 | break; |
| 1523 | default: |
| 1524 | printf("bad choice: %d\n", choice); |
| 1525 | return; |
| 1526 | } |
| 1527 | ret = getchar(); |
| 1528 | |
| 1529 | ret = ql_nw_set_wea_config(item, &config); |
| 1530 | if (ret == QL_ERR_OK) |
| 1531 | { |
| 1532 | printf("ok\n"); |
| 1533 | } |
| 1534 | else |
| 1535 | { |
| 1536 | printf("failed, ret = %d\n", ret); |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | void item_ql_nw_wea_get_config(void) |
| 1541 | { |
| 1542 | int ret = 0; |
| 1543 | ql_nw_wea_config_t config = {0}; |
| 1544 | |
| 1545 | printf("test ql_nw_get_wea_config: \n"); |
| 1546 | ret = ql_nw_get_wea_config(&config); |
| 1547 | if (ret == QL_ERR_OK) |
| 1548 | { |
| 1549 | printf("****** wea Config ******\n"); |
| 1550 | printf("Presidential_alert: %s\n", config.Presidential_alert ? "true" : "false"); |
| 1551 | printf("Extreme_alert: %s\n", config.Extreme_alert ? "true" : "false"); |
| 1552 | printf("Severe_alert: %s\n", config.Severe_alert ? "true" : "false"); |
| 1553 | printf("Amber_alert: %s\n", config.Amber_alert ? "true" : "false"); |
| 1554 | printf("PublicSafety_alert: %s\n", config.PublicSafety_alert ? "true" : "false"); |
| 1555 | printf("StateLocalTest_alert: %s\n", config.StateLocalTest_alert ? "true" : "false"); |
| 1556 | printf("RMT_alert: %s\n", config.RMT_alert ? "true" : "false"); |
| 1557 | printf("Exercise_alert: %s\n", config.Exercise_alert ? "true" : "false"); |
| 1558 | printf("CMSPDefined_alert: %s\n", config.CMSPDefined_alert ? "true" : "false"); |
| 1559 | printf("Spanish_alert: %s\n", config.Spanish_alert ? "true" : "false"); |
| 1560 | } |
| 1561 | else |
| 1562 | { |
| 1563 | printf("failed, ret = %d\n", ret); |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | void item_ql_nw_etws_set_config(void) |
| 1568 | { |
| 1569 | int ret = 0; |
| 1570 | int etws_enable = 0; |
| 1571 | |
| 1572 | printf("please input etws config (0: disable, 1: enable): "); |
| 1573 | ret = t_get_int(&etws_enable); |
| 1574 | if(ret != 0) |
| 1575 | { |
| 1576 | printf("Invalid input\n"); |
| 1577 | return; |
| 1578 | } |
| 1579 | |
| 1580 | ret = ql_nw_set_etws_config((unsigned char)etws_enable); |
| 1581 | printf("item_ql_nw_etws_set_config ret = %d\n", ret); |
| 1582 | } |
| 1583 | |
| 1584 | void item_ql_nw_etws_get_config(void) |
| 1585 | { |
| 1586 | int ret = 0; |
| 1587 | unsigned char etws_enable = 0; |
| 1588 | |
| 1589 | ret = ql_nw_get_etws_config(&etws_enable); |
| 1590 | printf("ql_nw_get_etws_config ret = %d \t etws_enable=%d\n", |
| 1591 | ret, etws_enable); |
| 1592 | } |
| 1593 | #endif |
| 1594 | |
| 1595 | void item_ql_nw_set_service_error_cb(void) |
| 1596 | { |
| 1597 | int ret = 0; |
| 1598 | |
| 1599 | ret = ql_nw_set_service_error_cb(nw_service_error_cb); |
| 1600 | if(ret != QL_ERR_OK) |
| 1601 | { |
| 1602 | printf("Failed to ql_nw_set_service_error_cb, ret=%d\n", ret); |
| 1603 | } |
| 1604 | else |
| 1605 | { |
| 1606 | printf("Sucessful\n"); |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | |
| 1611 | static t_item_t ql_nw_items[] = |
| 1612 | { |
| 1613 | |
| 1614 | {"ql_nw_init", item_ql_nw_init}, |
| 1615 | // {"ql_nw_network_scan", item_ql_nw_network_scan}, |
| 1616 | {"ql_nw_set_power_mode", item_ql_nw_set_power_mode}, |
| 1617 | // {"ql_nw_set_pref_nwmode_roaming", item_ql_nw_set_pref_nwmode_roaming}, |
| 1618 | // {"ql_nw_get_pref_nwmode_roaming", item_ql_nw_get_pref_nwmode_roaming}, |
| 1619 | // {"ql_nw_get_mobile_operator_name", item_ql_nw_get_mobile_operator_name}, |
| 1620 | // {"ql_nw_get_cell_info", item_ql_nw_get_cell_info}, |
| 1621 | {"ql_nw_get_voice_reg_status", item_ql_nw_get_voice_reg_status}, |
| 1622 | {"ql_nw_get_data_reg_status", item_ql_nw_get_data_reg_status}, |
| 1623 | {"ql_nw_get_signal_strength", item_ql_nw_get_signal_strength}, |
| 1624 | // {"ql_nw_get_cell_access_status", item_ql_nw_get_cell_access_status}, |
| 1625 | // {"ql_nw_get_nitz_time_info", item_ql_nw_get_nitz_time_info}, |
| 1626 | {"ql_nw_set_voice_reg_ind_cb", item_ql_nw_set_voice_reg_ind_cb}, |
| 1627 | // {"ql_nw_set_data_reg_ind_cb", item_ql_nw_set_data_reg_ind_cb}, |
| 1628 | {"ql_nw_set_signal_strength_chg_ind_cb", item_ql_nw_set_signal_strength_chg_ind_cb}, |
| 1629 | // {"ql_nw_set_cell_access_status_chg_ind_cb", item_ql_nw_set_cell_access_status_chg_ind_cb}, |
| 1630 | // {"ql_nw_set_nitz_time_update_ind_cb", item_ql_nw_set_nitz_time_update_ind_cb}, |
| 1631 | // {"ql_nw_set_wea_alert_ind_cb", item_ql_nw_set_wea_alert_ind_cb}, |
| 1632 | // {"ql_nw_wea_set_config", item_ql_nw_wea_set_config}, |
| 1633 | // {"ql_nw_wea_get_config", item_ql_nw_wea_get_config}, |
| 1634 | // {"ql_nw_set_etws_alert_ind_cb", item_ql_nw_set_etws_alert_ind_cb}, |
| 1635 | // {"ql_nw_etws_set_config", item_ql_nw_etws_set_config}, |
| 1636 | // {"ql_nw_etws_get_config", item_ql_nw_etws_get_config}, |
| 1637 | {"ql_nw_set_service_error_cb", item_ql_nw_set_service_error_cb}, |
| 1638 | {"ql_nw_deinit", item_ql_nw_deinit}, |
| 1639 | }; |
| 1640 | |
| 1641 | t_module_t ql_nw_module = |
| 1642 | { |
| 1643 | "nw", |
| 1644 | T_ARRAY_SIZE(ql_nw_items), |
| 1645 | ql_nw_items |
| 1646 | }; |
| 1647 | |
| 1648 | /*-----------------------------------------------------------------------------------------------*/ |
| 1649 | /** |
| 1650 | @brief Read a int value from stdin |
| 1651 | @param[out] val, Return read data |
| 1652 | @return |
| 1653 | 0 - successful |
| 1654 | 1 - read an enter |
| 1655 | -1 - invalid input |
| 1656 | */ |
| 1657 | /*-----------------------------------------------------------------------------------------------*/ |
| 1658 | int t_get_int(int *val) |
| 1659 | { |
| 1660 | int dat; |
| 1661 | char *ptr_end = NULL; |
| 1662 | char buf[256] = {0}; |
| 1663 | |
| 1664 | if(NULL == fgets(buf, sizeof(buf)-1, stdin)) |
| 1665 | { |
| 1666 | return -1; |
| 1667 | } |
| 1668 | #if 0 |
| 1669 | if(0 == buf[0]) |
| 1670 | { |
| 1671 | return -1; |
| 1672 | } |
| 1673 | #endif |
| 1674 | if(buf[0] == '\n') |
| 1675 | { |
| 1676 | return 1; |
| 1677 | } |
| 1678 | |
| 1679 | dat = strtol(buf, &ptr_end, 10); |
| 1680 | if(ptr_end!=NULL && ptr_end[0]!='\n') |
| 1681 | { |
| 1682 | return -1; |
| 1683 | } |
| 1684 | |
| 1685 | if(val) |
| 1686 | { |
| 1687 | val[0] = dat; |
| 1688 | } |
| 1689 | |
| 1690 | return 0; |
| 1691 | } |
| 1692 | |
| 1693 | void dump_items() |
| 1694 | { |
| 1695 | int i; |
| 1696 | |
| 1697 | printf("\n"); |
| 1698 | printf("The current module is: \n"); |
| 1699 | |
| 1700 | for(i=0; i< ql_nw_module.item_len; i++) |
| 1701 | { |
| 1702 | printf("%d\t%s\n", i, ql_nw_module.item_list[i].name); |
| 1703 | } |
| 1704 | printf("-1\texit\n"); |
| 1705 | } |
| 1706 | |
| 1707 | int main(int argc, char *argv[]) |
| 1708 | { |
| 1709 | int ret; |
| 1710 | int idx; |
| 1711 | |
| 1712 | dump_items(); |
| 1713 | |
| 1714 | while(1) |
| 1715 | { |
| 1716 | printf("Please enter your choice: "); |
| 1717 | ret = t_get_int(&idx); |
| 1718 | printf("\n"); |
| 1719 | if(ret < 0) |
| 1720 | { |
| 1721 | printf("Invalid input\n"); |
| 1722 | continue; |
| 1723 | } |
| 1724 | else if(ret == 1) |
| 1725 | { |
| 1726 | dump_items(); |
| 1727 | continue; |
| 1728 | } |
| 1729 | |
| 1730 | if(idx == -1) |
| 1731 | { |
| 1732 | break; |
| 1733 | } |
| 1734 | |
| 1735 | if(idx<0 || idx>=ql_nw_module.item_len) |
| 1736 | { |
| 1737 | printf("Not support idx: %d\n", idx); |
| 1738 | continue; |
| 1739 | } |
| 1740 | |
| 1741 | printf("->Item : %s\n", ql_nw_module.item_list[idx].name); |
| 1742 | ql_nw_module.item_list[idx].handle(); |
| 1743 | } |
| 1744 | |
| 1745 | return 0; |
| 1746 | } |
| 1747 | |