b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <stdint.h> |
| 5 | #include <ctype.h> |
| 6 | |
| 7 | #include "ql_type.h" |
| 8 | #include "ql_ms_voice.h" |
| 9 | #include "ql_ecall.h" |
| 10 | #include "mbtk_utils.h" |
| 11 | |
| 12 | typedef void (*item_handler_f)(void); |
| 13 | |
| 14 | typedef struct |
| 15 | { |
| 16 | const char *name; |
| 17 | item_handler_f handle; |
| 18 | } t_item_t; |
| 19 | |
| 20 | void item_ql_ecall_set_test_number(void) |
| 21 | { |
| 22 | int ret = 0; |
| 23 | int sim_id; |
| 24 | |
| 25 | char test_number[QL_VOICE_MAX_PHONE_NUMBER]; |
| 26 | |
| 27 | printf("test ql_voice_ecall_set_test_number: "); |
| 28 | |
| 29 | printf("please enter test number: "); |
| 30 | char* find = NULL; |
| 31 | |
| 32 | if(NULL == fgets(test_number, QL_VOICE_MAX_PHONE_NUMBER-1, stdin)) |
| 33 | return; |
| 34 | find = strchr(test_number, '\n'); |
| 35 | if(find) |
| 36 | { |
| 37 | *find = '\0'; |
| 38 | } |
| 39 | |
| 40 | printf("please enter the sim_id: "); |
| 41 | |
| 42 | if(1 != scanf("%u", &sim_id)) |
| 43 | return; |
| 44 | getchar(); |
| 45 | printf("sim_id is %u\n", sim_id); |
| 46 | |
| 47 | ret = ql_ecall_set_test_number(sim_id, test_number); |
| 48 | |
| 49 | if (ret == QL_ERR_OK) |
| 50 | { |
| 51 | printf("ok\n"); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | printf("failed, ret = %d\n", ret); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | void item_ql_ecall_reset_ivs(void) |
| 60 | { |
| 61 | int ret = 0; |
| 62 | int sim_id; |
| 63 | |
| 64 | printf("please enter the sim_id: "); |
| 65 | |
| 66 | if(1 != scanf("%u", &sim_id)) |
| 67 | return; |
| 68 | getchar(); |
| 69 | printf("sim_id is %u\n", sim_id); |
| 70 | |
| 71 | ret = ql_ecall_reset_ivs(sim_id); |
| 72 | if (ret == QL_ERR_OK) |
| 73 | { |
| 74 | printf("ok\n"); |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | printf("failed, ret = %d\n", ret); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void fast_ecall_dial(void){ |
| 83 | int ret = 0, v = 0; |
| 84 | ql_voice_ecall_info_t *p_info = NULL; |
| 85 | char *find = NULL; |
| 86 | uint32_t id; |
| 87 | int sim_id; |
| 88 | |
| 89 | p_info = (ql_voice_ecall_info_t *)calloc(1, sizeof(*p_info)); |
| 90 | if (NULL == p_info) |
| 91 | { |
| 92 | printf("run out of memory\n"); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | printf("please enter the sim_id: "); |
| 97 | if(1 != scanf("%d", &sim_id)) |
| 98 | return; |
| 99 | getchar(); |
| 100 | |
| 101 | if(!QL_IS_SIM_VALID(sim_id)) |
| 102 | { |
| 103 | printf("invalid sim_id\n"); |
| 104 | free(p_info); |
| 105 | p_info = NULL; |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | printf("sim_id is %d\n", sim_id); |
| 110 | |
| 111 | printf("example MSD: 01 04 a9 81 d5 49 70 d6 5c 35 97 ca 04 20 c4 14 60 " |
| 112 | "0b be 5f 7e b1 4b a6 ee 10 4f c5 27 03 c1 80 q\n"); |
| 113 | printf("please enter MSD(at most 140 hex), end with 'q': "); |
| 114 | while (1 == scanf("%x", &v)) |
| 115 | { |
| 116 | p_info->msd[p_info->msd_len++] = v; |
| 117 | } |
| 118 | getchar(); // read `q' |
| 119 | getchar(); // read '\n' |
| 120 | |
| 121 | printf("MSD ========["); |
| 122 | for(v = 0; v < p_info->msd_len; v ++) |
| 123 | { |
| 124 | printf("%02x ", p_info->msd[v]); |
| 125 | } |
| 126 | printf("]\n"); |
| 127 | |
| 128 | if (p_info->msd_len > QL_VOICE_MAX_ECALL_MSD) |
| 129 | { |
| 130 | printf("MSD too long\n"); |
| 131 | free(p_info); |
| 132 | p_info = NULL; |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | printf("please enter eCall type(1 - test, 2 - emergency, 3 - reconfig): "); |
| 137 | if(1 != scanf("%d", (int *)&p_info->type)) |
| 138 | return; |
| 139 | getchar(); |
| 140 | |
| 141 | printf("please enter test number(emergency ecall should be empty): "); |
| 142 | find = NULL; |
| 143 | if(NULL == fgets(p_info->test_number, sizeof(p_info->test_number)-1, stdin)) |
| 144 | return; |
| 145 | find = strchr(p_info->test_number, '\n'); |
| 146 | if(find) |
| 147 | { |
| 148 | *find = '\0'; |
| 149 | } |
| 150 | |
| 151 | printf("how to trigger eCall(0 - manual, 1 - auto): "); |
| 152 | if(1 != scanf("%d", &p_info->auto_trigger)) |
| 153 | return; |
| 154 | getchar(); |
| 155 | |
| 156 | ret = ql_ecall_dial(sim_id, p_info, &id); |
| 157 | if (ret == QL_ERR_OK) |
| 158 | { |
| 159 | printf("ok, call_id is %u\n", id); |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | printf("failed, ret = %d\n", ret); |
| 164 | } |
| 165 | |
| 166 | free(p_info); |
| 167 | p_info = NULL; |
| 168 | } |
| 169 | |
| 170 | void item_ql_ecall_dial(void) |
| 171 | { |
| 172 | printf("test ql_voice_ecall_dial: \n"); |
| 173 | printf("Is fast ecall? (1 - yes, other - wrong): "); |
| 174 | int is_fast; |
| 175 | scanf("%d", &is_fast); |
| 176 | getchar(); |
| 177 | |
| 178 | if(is_fast == 1){ |
| 179 | printf("Dialling fast ecall\n"); |
| 180 | fast_ecall_dial(); |
| 181 | }else{ |
| 182 | printf("Wrong arguments\n"); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void item_ql_ecall_hangup(void) |
| 187 | { |
| 188 | int ret = 0; |
| 189 | // int sim_id; |
| 190 | |
| 191 | printf("test ql_voice_ecall_hangup: \n"); |
| 192 | ret = ql_ecall_hangup(); |
| 193 | if (ret == QL_ERR_OK) |
| 194 | { |
| 195 | printf("ok\n"); |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | printf("failed, ret = %d\n", ret); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | void item_ql_ecall_update_msd_raw(void) |
| 204 | { |
| 205 | int ret = 0, v = 0; |
| 206 | uint32_t msd_len = 0; |
| 207 | char msd[QL_VOICE_MAX_ECALL_MSD] = {0}; |
| 208 | |
| 209 | printf("test ql_voice_ecall_update_msd: \n"); |
| 210 | printf("example MSD: 01 04 a9 81 d5 49 70 d6 5c 35 97 ca 04 20 c4 14 60 " |
| 211 | "0b be 5f 7e b1 4b a6 ee 10 4f c5 27 03 c1 80 q\n"); |
| 212 | printf("please enter MSD(at most 140 hex), end with 'q': "); |
| 213 | while (1 == scanf("%x", &v)) |
| 214 | { |
| 215 | if(msd_len >= QL_VOICE_MAX_ECALL_MSD) |
| 216 | { |
| 217 | printf("MSD too long\n"); |
| 218 | int c; |
| 219 | while ((c = getchar()) != '\n' && c != EOF) { } |
| 220 | return; |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | msd[msd_len++] = v; |
| 225 | } |
| 226 | } |
| 227 | getchar(); // read `q' |
| 228 | getchar(); // read '\n' |
| 229 | |
| 230 | ret = ql_ecall_update_msd_raw((uint8_t *)msd, msd_len); |
| 231 | if (ret == QL_ERR_OK) |
| 232 | { |
| 233 | printf("ok\n"); |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | printf("failed, ret = %d\n", ret); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | void item_ql_ecall_push_msd(void) |
| 242 | { |
| 243 | int ret = 0; |
| 244 | |
| 245 | printf("test ql_voice_ecall_push_msd: \n"); |
| 246 | ret = ql_ecall_push_msd(); |
| 247 | if (ret == QL_ERR_OK) |
| 248 | { |
| 249 | printf("sql_ecall_push_msd OK\n"); |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | printf("failed, ret = %d\n", ret); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | static void ecall_user_ind_callback(int ind, void *userdata) |
| 258 | { |
| 259 | printf("\n****** eCall indication Received ******\n"); |
| 260 | printf("ecall_indication: %d - ", ind); |
| 261 | |
| 262 | switch(ind){ |
| 263 | case QL_ECALL_EVENT_SENDING_START: |
| 264 | printf("QL_ECALL_EVENT_SENDING_START\n"); |
| 265 | break; |
| 266 | case QL_ECALL_EVENT_SENDING_MSD: |
| 267 | printf("QL_ECALL_EVENT_SENDING_MSD\n"); |
| 268 | break; |
| 269 | case QL_ECALL_EVENT_LLACK_RECEIVED: |
| 270 | printf("QL_ECALL_EVENT_LLACK_RECEIVED\n"); |
| 271 | break; |
| 272 | case QL_ECALL_EVENT_ALLACK_POSITIVE_RECEIVED: |
| 273 | printf("QL_ECALL_EVENT_ALLACK_POSITIVE_RECEIVED\n"); |
| 274 | break; |
| 275 | case QL_ECALL_EVENT_ALLACK_CLEARDOWN_RECEIVED: |
| 276 | printf("QL_ECALL_EVENT_ALLACK_CLEARDOWN_RECEIVED\n"); |
| 277 | break; |
| 278 | case QL_ECALL_EVENT_ACTIVE: |
| 279 | printf("QL_ECALL_EVENT_ACTIVE\n"); |
| 280 | break; |
| 281 | case QL_ECALL_EVENT_DISCONNECTED: |
| 282 | printf("QL_ECALL_EVENT_DISCONNECTED\n"); |
| 283 | break; |
| 284 | case QL_ECALL_EVENT_ABNORMAL_HANGUP: |
| 285 | printf("QL_ECALL_EVENT_ABNORMAL_HANGUP\n"); |
| 286 | break; |
| 287 | case QL_ECALL_EVENT_ONLY_DEREGISTRATION: |
| 288 | printf("QL_ECALL_EVENT_ONLY_DEREGISTRATION\n"); |
| 289 | break; |
| 290 | case QL_ECALL_EVENT_MAY_DEREGISTRATION: |
| 291 | printf("QL_ECALL_EVENT_MAY_DEREGISTRATION\n"); |
| 292 | break; |
| 293 | case QL_ECALL_EVENT_PSAP_CALLBACK_START: |
| 294 | printf("QL_ECALL_EVENT_PSAP_CALLBACK_START\n"); |
| 295 | break; |
| 296 | case QL_ECALL_EVENT_T2_TIMEOUT: |
| 297 | printf("QL_ECALL_EVENT_T2_TIMEOUT\n"); |
| 298 | break; |
| 299 | case QL_ECALL_EVENT_T5_TIMEOUT: |
| 300 | printf("QL_ECALL_EVENT_T5_TIMEOUT\n"); |
| 301 | break; |
| 302 | case QL_ECALL_EVENT_T6_TIMEOUT: |
| 303 | printf("QL_ECALL_EVENT_T6_TIMEOUT\n"); |
| 304 | break; |
| 305 | case QL_ECALL_EVENT_T7_TIMEOUT: |
| 306 | printf("QL_ECALL_EVENT_T7_TIMEOUT\n"); |
| 307 | break; |
| 308 | case QL_ECALL_EVENT_ECALL_STARTED: |
| 309 | printf("QL_ECALL_EVENT_ECALL_STARTED\n"); |
| 310 | break; |
| 311 | case QL_ECALL_EVENT_INCOMING_CALL: |
| 312 | printf("QL_ECALL_EVENT_INCOMING_CALL\n"); |
| 313 | break; |
| 314 | case QL_ECALL_EVENT_DIAL_DURATION_TIMEOUT: |
| 315 | printf("QL_ECALL_EVENT_DIAL_DURATION_TIMEOUT\n"); |
| 316 | break; |
| 317 | case QL_ECALL_EVENT_INTERVAL_TIMEOUT: |
| 318 | printf("QL_ECALL_EVENT_INTERVAL_TIMEOUT\n"); |
| 319 | break; |
| 320 | case QL_ECALL_EVENT_AUTO_ANSWER_TIMEOUT: |
| 321 | printf("QL_ECALL_EVENT_AUTO_ANSWER_TIMEOUT\n"); |
| 322 | break; |
| 323 | default: |
| 324 | printf("UNKNOWN\n"); |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | void item_ql_ecall_init(void) |
| 330 | { |
| 331 | int ret = 0; |
| 332 | |
| 333 | printf("test ql_ecall_init: "); |
| 334 | ret = ql_ecall_init(); |
| 335 | if(ret == QL_ERR_OK) |
| 336 | { |
| 337 | printf("ok\n"); |
| 338 | } |
| 339 | else |
| 340 | { |
| 341 | printf("failed, ret = %d\n", ret); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | void item_ql_ecall_deinit(void) |
| 346 | { |
| 347 | int ret = 0; |
| 348 | |
| 349 | printf("test ql_ecall_deinit: "); |
| 350 | ret = ql_ecall_deinit(); |
| 351 | if (ret == QL_ERR_OK) |
| 352 | { |
| 353 | printf("ok\n"); |
| 354 | } |
| 355 | else |
| 356 | { |
| 357 | printf("failed, ret = %d\n", ret); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | void item_ql_ecall_set_user_ind_cb(void) |
| 362 | { |
| 363 | ql_ecall_set_user_ind_cb(ecall_user_ind_callback, NULL); |
| 364 | } |
| 365 | |
| 366 | void item_ql_ecall_set_msd_version(void) |
| 367 | { |
| 368 | int ret = 0; |
| 369 | uint8_t index=0; |
| 370 | |
| 371 | printf("ecall MSD version(1-ASN1_ECALL_MSD_VERSION_1; 2-ASN1_ECALL_MSD_VERSION_2): \n"); |
| 372 | scanf("%hhd", &index); |
| 373 | getchar(); |
| 374 | |
| 375 | if (1 == index) |
| 376 | { |
| 377 | ret = ql_ecall_set_msd_version(ASN1_ECALL_MSD_VERSION_1); |
| 378 | printf(" ql_ecall_get_msd_version ret = %d\n", ret); |
| 379 | } |
| 380 | else if(2 == index) |
| 381 | { |
| 382 | ret = ql_ecall_set_msd_version(ASN1_ECALL_MSD_VERSION_2); |
| 383 | printf(" ql_ecall_get_msd_version ret = %d\n", ret); |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | printf(" This version is not surport.\n"); |
| 388 | } |
| 389 | |
| 390 | } |
| 391 | |
| 392 | void item_ql_ecall_get_msd_version(void) |
| 393 | { |
| 394 | uint8_t msdVersion = 0; |
| 395 | |
| 396 | ql_ecall_get_msd_version(&msdVersion); |
| 397 | |
| 398 | if(msdVersion == ASN1_ECALL_MSD_VERSION_1)//unsupported |
| 399 | { |
| 400 | printf("MSD version is set to ASN1_ECALL_MSD_VERSION_1.\n"); |
| 401 | } |
| 402 | else if (msdVersion == ASN1_ECALL_MSD_VERSION_2)//supported |
| 403 | { |
| 404 | printf("MSD version is set to ASN1_ECALL_MSD_VERSION_2.\n"); |
| 405 | } |
| 406 | else |
| 407 | { |
| 408 | printf(" This version is not surport.\n"); |
| 409 | } |
| 410 | |
| 411 | } |
| 412 | |
| 413 | void item_ql_ecall_set_system_type(void) |
| 414 | { |
| 415 | int ret = 0; |
| 416 | uint8_t index=0; |
| 417 | |
| 418 | printf("ecall system type(0-ECALL_SYSTEM_STD_PAN_EUROPEAN; 1-ECALL_SYSTEM_STD_ERA_GLONASS): \n"); |
| 419 | scanf("%hhd", &index); |
| 420 | getchar(); |
| 421 | |
| 422 | if (0 == index) |
| 423 | { |
| 424 | ret = ql_ecall_set_system_std(ECALL_SYSTEM_STD_PAN_EUROPEAN); |
| 425 | printf(" ql_ecall_set_system_std ret = %d\n", ret); |
| 426 | } |
| 427 | else if(1 == index) |
| 428 | { |
| 429 | ret = ql_ecall_set_system_std(ECALL_SYSTEM_STD_ERA_GLONASS); |
| 430 | printf(" ql_ecall_set_system_std ret = %d\n", ret); |
| 431 | } |
| 432 | else |
| 433 | { |
| 434 | printf(" This version is not surport.\n"); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | void item_ql_ecall_get_system_type(void) |
| 439 | { |
| 440 | ECALL_SYSTEM_STD_E system_std; |
| 441 | ql_ecall_get_system_std(&system_std); |
| 442 | if(system_std == ECALL_SYSTEM_STD_PAN_EUROPEAN) |
| 443 | { |
| 444 | printf("Ecall system type set to ECALL_SYSTEM_STD_PAN_EUROPEAN.\n"); |
| 445 | } |
| 446 | else if (system_std == ECALL_SYSTEM_STD_ERA_GLONASS) |
| 447 | { |
| 448 | printf("Ecall system type set to ECALL_SYSTEM_STD_ERA_GLONASS.\n"); |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | printf("Ecall system type set to unsupported value.\n"); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | void item_ql_ecall_set_msd_vehicle_type(void) |
| 457 | { |
| 458 | int ret = 0; |
| 459 | uint8_t index=0; |
| 460 | |
| 461 | printf("Please input VehicleType:\n"); |
| 462 | printf("MSD_VEHICLE_PASSENGER_M1=1\n"); |
| 463 | printf("MSD_VEHICLE_BUS_M2=2\n"); |
| 464 | printf("MSD_VEHICLE_BUS_M3=3\n"); |
| 465 | printf("MSD_VEHICLE_COMMERCIAL_N1=4\n"); |
| 466 | printf("MSD_VEHICLE_HEAVY_N2=5\n"); |
| 467 | printf("MSD_VEHICLE_HEAVY_N3=6\n"); |
| 468 | printf("MSD_VEHICLE_MOTORCYCLE_L1E=7\n"); |
| 469 | printf("MSD_VEHICLE_MOTORCYCLE_L2E=8\n"); |
| 470 | printf("MSD_VEHICLE_MOTORCYCLE_L3E=9\n"); |
| 471 | printf("MSD_VEHICLE_MOTORCYCLE_L4E=10\n"); |
| 472 | printf("MSD_VEHICLE_MOTORCYCLE_L5E=11\n"); |
| 473 | printf("MSD_VEHICLE_MOTORCYCLE_L6E=12\n"); |
| 474 | printf("MSD_VEHICLE_MOTORCYCLE_L7E=13\n"); |
| 475 | |
| 476 | scanf("%hhd", &index); |
| 477 | getchar(); |
| 478 | |
| 479 | ret = ql_ecall_set_msd_vehicle_type(index); |
| 480 | printf(" ql_ecall_set_msd_vehicle_type ret = %d\n", ret); |
| 481 | |
| 482 | } |
| 483 | |
| 484 | void item_ql_ecall_get_msd_vehicle_type(void) |
| 485 | { |
| 486 | uint8_t vehicleType = 0; |
| 487 | ql_ecall_get_msd_vehicle_type(&vehicleType); |
| 488 | printf("VehicalType is set to: %u\n", vehicleType); |
| 489 | |
| 490 | } |
| 491 | |
| 492 | void item_ql_ecall_set_msd_position(void) |
| 493 | { |
| 494 | int ret = 0; |
| 495 | int32_t latitude, longitude, direction = 0; |
| 496 | |
| 497 | printf("Please input latitude(example:+48898064):\n"); |
| 498 | scanf("%d", &latitude); |
| 499 | getchar(); |
| 500 | |
| 501 | printf("Please input longitude(example:+2218092):\n"); |
| 502 | scanf("%d", &longitude); |
| 503 | getchar(); |
| 504 | |
| 505 | printf("Please input direction(example:0):\n"); |
| 506 | scanf("%d", &direction); |
| 507 | getchar(); |
| 508 | |
| 509 | ret = ql_ecall_set_msd_position(true, latitude, longitude, direction); |
| 510 | printf(" ql_ecall_set_msd_position ret = %d\n", ret); |
| 511 | } |
| 512 | |
| 513 | void item_ql_ecall_set_msd_position1(void) |
| 514 | { |
| 515 | int ret = 0; |
| 516 | int32_t latitudeDeltaN1, longitudeDeltaN1 = 0; |
| 517 | |
| 518 | printf("Please input latitudeDeltaN1(-512 ~ 511):\n"); |
| 519 | scanf("%d", &latitudeDeltaN1); |
| 520 | getchar(); |
| 521 | |
| 522 | printf("Please input longitudeDeltaN1(-512 ~ 511):\n"); |
| 523 | scanf("%d", &longitudeDeltaN1); |
| 524 | getchar(); |
| 525 | |
| 526 | ret = ql_ecall_set_msd_position_n1(latitudeDeltaN1, longitudeDeltaN1); |
| 527 | printf(" ql_ecall_set_msd_position_n1 ret = %d\n", ret); |
| 528 | } |
| 529 | |
| 530 | void item_ql_ecall_set_msd_position2(void) |
| 531 | { |
| 532 | int ret = 0; |
| 533 | int32_t latitudeDeltaN2, longitudeDeltaN2 = 0; |
| 534 | |
| 535 | printf("Please input latitudeDeltaN2(-512 ~ 511):\n"); |
| 536 | scanf("%d", &latitudeDeltaN2); |
| 537 | getchar(); |
| 538 | |
| 539 | printf("Please input longitudeDeltaN2(-512 ~ 511):\n"); |
| 540 | scanf("%d", &longitudeDeltaN2); |
| 541 | getchar(); |
| 542 | |
| 543 | ret = ql_ecall_set_msd_position_n2(latitudeDeltaN2, longitudeDeltaN2); |
| 544 | printf(" ql_ecall_set_msd_position_n2 ret = %d\n", ret); |
| 545 | } |
| 546 | |
| 547 | void item_ql_ecall_set_number_of_passengers(void) |
| 548 | { |
| 549 | // int ret = 0; |
| 550 | uint8_t numberOfPassengers=0; |
| 551 | |
| 552 | printf("Please input msd numberOfPassengers:\n"); |
| 553 | if(1 != scanf("%hhd", &numberOfPassengers)) |
| 554 | return; |
| 555 | getchar(); |
| 556 | |
| 557 | ql_ecall_set_msd_passengers_count(numberOfPassengers); |
| 558 | } |
| 559 | |
| 560 | void item_ql_ecall_set_msd_propulsion_type(void) |
| 561 | { |
| 562 | // int ret = 0; |
| 563 | uint8_t propulsionType = 0; |
| 564 | |
| 565 | printf("Please input vehicle propulsion type:\n"); |
| 566 | printf("ECALL_MSD_PROPULSION_TYPE_GASOLINE=0x1\n"); |
| 567 | printf("ECALL_MSD_PROPULSION_TYPE_DIESEL=0x2\n"); |
| 568 | printf("ECALL_MSD_PROPULSION_TYPE_NATURALGAS=0x4\n"); |
| 569 | printf("ECALL_MSD_PROPULSION_TYPE_PROPANE=0x8\n"); |
| 570 | printf("ECALL_MSD_PROPULSION_TYPE_ELECTRIC=0x10\n"); |
| 571 | printf("ECALL_MSD_PROPULSION_TYPE_HYDROGEN=0x20\n"); |
| 572 | printf("ECALL_MSD_PROPULSION_TYPE_OTHER=0x40\n"); |
| 573 | |
| 574 | scanf("%hhx", &propulsionType); |
| 575 | getchar(); |
| 576 | |
| 577 | ql_ecall_set_msd_propulsion_type(propulsionType); |
| 578 | } |
| 579 | |
| 580 | void item_ql_ecall_get_msd_propulsion_type(void) |
| 581 | { |
| 582 | uint8_t propulsionType = 0; |
| 583 | |
| 584 | ql_ecall_get_msd_propulsion_type(&propulsionType); |
| 585 | |
| 586 | printf("PropulsionType set to: 0x%x\n", propulsionType); |
| 587 | |
| 588 | } |
| 589 | |
| 590 | void item_ql_ecall_get_msd_call_type(void) |
| 591 | { |
| 592 | |
| 593 | bool type; |
| 594 | ql_ecall_get_msd_call_type(&type); |
| 595 | |
| 596 | printf(" item_ql_ecall_get_msd_call_type type = %s\n", type ? "Test" : "Emergency" ); |
| 597 | } |
| 598 | |
| 599 | void item_ql_ecall_set_msd_call_type(void) |
| 600 | { |
| 601 | uint8_t index = 0; |
| 602 | printf("Input call type: Test(0) Emergency(1)\n"); |
| 603 | scanf("%hhd", &index); |
| 604 | getchar(); |
| 605 | |
| 606 | ql_ecall_set_msd_call_type(index == 0); |
| 607 | |
| 608 | printf(" ql_ecall_set_msd_call_type type = %d\n", index); |
| 609 | } |
| 610 | |
| 611 | |
| 612 | void item_ql_ecall_set_msd_vin(void) |
| 613 | { |
| 614 | int ret = 0; |
| 615 | uint8_t index = 0; |
| 616 | msd_Vin_t vin = {0}; |
| 617 | char* find = NULL; |
| 618 | char vin_str[QL_ECALL_MAX_VIN]; |
| 619 | |
| 620 | printf("Input: default(0) other(1)\n"); |
| 621 | scanf("%hhd", &index); |
| 622 | getchar(); |
| 623 | if(index) |
| 624 | { |
| 625 | printf("Please insert VIN:\n"); |
| 626 | fgets(vin_str, QL_ECALL_MAX_VIN-1, stdin); |
| 627 | find = strchr(vin_str, '\n'); |
| 628 | if(find) |
| 629 | { |
| 630 | *find = '\0'; |
| 631 | } |
| 632 | // example 1: WM9VDSVDSYA123456 |
| 633 | // example 2: 4Y1SL65848Z411439 |
| 634 | // example 3: VF37BRFVE12345678 |
| 635 | memcpy(&vin.isowmi, vin_str,3); |
| 636 | memcpy(&vin.isovds, (vin_str+3),6); |
| 637 | memcpy(&vin.isovisModelyear, (vin_str+9) ,1); |
| 638 | memcpy(&vin.isovisSeqPlant, (vin_str+10) ,7); |
| 639 | printf("isowmi:%s isovds:%s isovisModelyear:%s,isovisSeqPlant:%s\n",vin.isowmi,vin.isovds,vin.isovisModelyear,vin.isovisSeqPlant); |
| 640 | } |
| 641 | else |
| 642 | { |
| 643 | memcpy(&vin.isowmi,"WM9",3); |
| 644 | memcpy(&vin.isovds,"VDSVDS",6); |
| 645 | memcpy(&vin.isovisModelyear,"Y",1); |
| 646 | memcpy(&vin.isovisSeqPlant,"A123456",7); |
| 647 | printf("isowmi:%s isovds:%s isovisModelyear:%s,isovisSeqPlant:%s\n",vin.isowmi,vin.isovds,vin.isovisModelyear,vin.isovisSeqPlant); |
| 648 | } |
| 649 | |
| 650 | ret = ql_ecall_set_msd_vin(vin); |
| 651 | printf(" ql_ecall_set_msd_vin ret = %d\n", ret); |
| 652 | } |
| 653 | |
| 654 | void item_ql_ecall_get_msd_vin(void) |
| 655 | { |
| 656 | int ret = 0; |
| 657 | msd_Vin_t vin; |
| 658 | char vin_str[QL_ECALL_MAX_VIN]; |
| 659 | |
| 660 | ret = ql_ecall_get_msd_vin(&vin); |
| 661 | if(0<strlen(vin.isowmi)&&0<strlen(vin.isovds)&&0<strlen(vin.isovisModelyear)&&0<strlen(vin.isovisSeqPlant)) |
| 662 | { |
| 663 | sprintf(vin_str,"%s%s%s%s",vin.isowmi,vin.isovds,vin.isovisModelyear,vin.isovisSeqPlant); |
| 664 | } |
| 665 | else |
| 666 | { |
| 667 | printf(" vin is NULL\n"); |
| 668 | return; |
| 669 | } |
| 670 | printf(" ql_ecall_get_msd_vin ret = %d\n", ret); |
| 671 | |
| 672 | printf("VIN=%s\n",vin_str); |
| 673 | } |
| 674 | |
| 675 | void item_ql_ecall_set_msd_tx_mode(void) |
| 676 | { |
| 677 | int ret = 0; |
| 678 | uint8_t index = 0; |
| 679 | |
| 680 | printf("Please choose MSD Tx Mode: PULL(0) PUSH(1)\n"); |
| 681 | scanf("%hhd", &index); |
| 682 | getchar(); |
| 683 | |
| 684 | if(index == 0) |
| 685 | { |
| 686 | ret = ql_ecall_set_msd_tx_mode(QL_ECALL_TX_MODE_PULL); |
| 687 | printf(" ql_ecall_set_msd_tx_mode ret = %d\n", ret); |
| 688 | } |
| 689 | else if(index == 1) |
| 690 | { |
| 691 | ret = ql_ecall_set_msd_tx_mode(QL_ECALL_TX_MODE_PUSH); |
| 692 | printf(" ql_ecall_set_msd_tx_mode ret = %d\n", ret); |
| 693 | } |
| 694 | else |
| 695 | { |
| 696 | printf("Unsupported MSD transmission mode.\n"); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | void item_ql_ecall_get_msd_tx_mode(void) |
| 701 | { |
| 702 | QL_ECALL_MSD_TX_MODE_E tx_mode; |
| 703 | |
| 704 | ql_ecall_get_msd_tx_mode(&tx_mode); |
| 705 | if(tx_mode == QL_ECALL_TX_MODE_PULL) |
| 706 | { |
| 707 | printf("MSD Transmission mode is set to QL_ECALL_TX_MODE_PULL\n"); |
| 708 | } |
| 709 | else if (tx_mode == QL_ECALL_TX_MODE_PUSH) |
| 710 | { |
| 711 | printf("MSD Transmission mode is set to QL_ECALL_TX_MODE_PUSH\n"); |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | void item_ql_ecall_start_test(void) |
| 716 | { |
| 717 | int ret = 0; |
| 718 | int sim_id; |
| 719 | |
| 720 | printf("please enter the sim_id: "); |
| 721 | ret = scanf("%d", &sim_id); |
| 722 | getchar(); |
| 723 | |
| 724 | if(!QL_IS_SIM_VALID(sim_id)) |
| 725 | { |
| 726 | printf("invalid sim_id\n"); |
| 727 | return; |
| 728 | } |
| 729 | |
| 730 | ret = ql_ecall_start_test(sim_id); |
| 731 | printf(" ql_ecall_start_test ret = %d\n", ret); |
| 732 | } |
| 733 | |
| 734 | void item_ql_ecall_start_manual(void) |
| 735 | { |
| 736 | int ret = 0; |
| 737 | int sim_id; |
| 738 | |
| 739 | printf("please enter the sim_id: "); |
| 740 | ret = scanf("%d", &sim_id); |
| 741 | getchar(); |
| 742 | |
| 743 | if(!QL_IS_SIM_VALID(sim_id)) |
| 744 | { |
| 745 | printf("invalid sim_id\n"); |
| 746 | return; |
| 747 | } |
| 748 | |
| 749 | ret = ql_ecall_start_manual(sim_id); |
| 750 | printf(" ql_ecall_start_manual ret = %d\n", ret); |
| 751 | } |
| 752 | |
| 753 | void item_ql_ecall_start_automatic(void) |
| 754 | { |
| 755 | int ret = 0; |
| 756 | int sim_id; |
| 757 | |
| 758 | printf("please enter the sim_id: "); |
| 759 | ret = scanf("%d", &sim_id); |
| 760 | getchar(); |
| 761 | |
| 762 | if(!QL_IS_SIM_VALID(sim_id)) |
| 763 | { |
| 764 | printf("invalid sim_id\n"); |
| 765 | return; |
| 766 | } |
| 767 | |
| 768 | ret = ql_ecall_start_automatic(sim_id); |
| 769 | printf(" ql_ecall_start_automatic ret = %d\n", ret); |
| 770 | } |
| 771 | |
| 772 | void item_ql_ecall_terminate_nw_registration(void) |
| 773 | { |
| 774 | int ret; |
| 775 | |
| 776 | ret = ql_ecall_terminate_nw_registration(); |
| 777 | if(ret == QL_ERR_OK) |
| 778 | { |
| 779 | printf("ok\n"); |
| 780 | } |
| 781 | else |
| 782 | { |
| 783 | printf("failed, ret = %d\n", ret); |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | void item_ql_ecall_set_interval_between_attempts(void) |
| 788 | { |
| 789 | uint16_t interval = 0; |
| 790 | |
| 791 | printf("Please input interval between attempts in seconds:\n"); |
| 792 | scanf("%hd", &interval); |
| 793 | getchar(); |
| 794 | |
| 795 | ql_ecall_set_interval_between_dial_attempts(interval); |
| 796 | } |
| 797 | |
| 798 | void item_ql_ecall_get_interval_between_attempts(void) |
| 799 | { |
| 800 | uint16_t interval = 0; |
| 801 | ql_ecall_get_interval_between_dial_attempts(&interval); |
| 802 | |
| 803 | printf("Interval between attempts is set to %hd seconds:\n", interval); |
| 804 | |
| 805 | } |
| 806 | |
| 807 | void item_ql_ecall_update_msd (void) |
| 808 | { |
| 809 | int ret = 0; |
| 810 | ret = ql_ecall_update_msd(); |
| 811 | if (ret == QL_ERR_OK) |
| 812 | { |
| 813 | printf("ok\n"); |
| 814 | } |
| 815 | else |
| 816 | { |
| 817 | printf("failed, ret = %d\n", ret); |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | void item_ql_ecall_set_config_info(void) |
| 822 | { |
| 823 | ql_ecall_config_t ecall_context_info; |
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 824 | memset(&ecall_context_info, 0, sizeof(ql_ecall_config_t)); |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 825 | |
| 826 | printf("Whether the time of T5 timer is valid(0:no, 1:yes):\n"); |
| 827 | scanf("%hhd", &ecall_context_info.t5_timeout_ms_valid); |
| 828 | getchar(); |
| 829 | if(ecall_context_info.t5_timeout_ms_valid) |
| 830 | { |
| 831 | printf("please input the time of T5 timer(example:5000ms):\n"); |
| 832 | scanf("%hd", &ecall_context_info.t5_timeout_ms); |
| 833 | getchar(); |
| 834 | } |
| 835 | |
| 836 | printf("Whether the time of T6 timer is valid(0:no, 1:yes):\n"); |
| 837 | scanf("%hhd", &ecall_context_info.t6_timeout_ms_valid); |
| 838 | getchar(); |
| 839 | if(ecall_context_info.t6_timeout_ms_valid) |
| 840 | { |
| 841 | printf("please input the time of T6 timer(example:5000ms):\n"); |
| 842 | scanf("%hd", &ecall_context_info.t6_timeout_ms); |
| 843 | getchar(); |
| 844 | } |
| 845 | |
| 846 | printf("Whether the time of T7 timer is valid(0:no, 1:yes):\n"); |
| 847 | scanf("%hhd", &ecall_context_info.t7_timeout_ms_valid); |
| 848 | getchar(); |
| 849 | if(ecall_context_info.t7_timeout_ms_valid) |
| 850 | { |
| 851 | printf("please input the time of T7 timer(example:20000ms):\n"); |
| 852 | scanf("%hd", &ecall_context_info.t7_timeout_ms); |
| 853 | getchar(); |
| 854 | } |
| 855 | |
| 856 | printf("Whether the time of auto answer timer is valid(0:no, 1:yes):\n"); |
| 857 | scanf("%hhd", &ecall_context_info.autoAnswer_timeout_ms_valid); |
| 858 | getchar(); |
| 859 | if(ecall_context_info.autoAnswer_timeout_ms_valid) |
| 860 | { |
| 861 | printf("please input the time of auto answer timer(example:3600000ms):\n"); |
| 862 | scanf("%d", &ecall_context_info.autoAnswer_timeout_ms); |
| 863 | getchar(); |
| 864 | } |
| 865 | |
| 866 | printf("Whether the time of dialDurationTimer is valid(0:no, 1:yes):\n"); |
| 867 | scanf("%hhd", &ecall_context_info.dialDurationTimer_timout_ms_valid); |
| 868 | getchar(); |
| 869 | if(ecall_context_info.dialDurationTimer_timout_ms_valid) |
| 870 | { |
| 871 | printf("please input the time of dialDurationTimer(example:120000ms):\n"); |
| 872 | scanf("%d", &ecall_context_info.dialDurationTimer_timout_ms); |
| 873 | getchar(); |
| 874 | } |
| 875 | |
| 876 | printf("(Not supported)Whether the maxDialAttempts is valid(0:no, 1:yes):\n"); |
| 877 | scanf("%hhd", &ecall_context_info.maxDialAttempts_valid); |
| 878 | getchar(); |
| 879 | if(ecall_context_info.maxDialAttempts_valid) |
| 880 | { |
| 881 | printf("please input maxDialAttempts:\n"); |
| 882 | scanf("%d", &ecall_context_info.maxDialAttempts); |
| 883 | getchar(); |
| 884 | } |
| 885 | |
| 886 | printf("(Not supported)Whether the intervalBetweenAttempts is valid(0:no, 1:yes):\n"); |
| 887 | scanf("%hhd", &ecall_context_info.intervalBetweenAttempts_valid); |
| 888 | getchar(); |
| 889 | if(ecall_context_info.intervalBetweenAttempts_valid) |
| 890 | { |
| 891 | printf("please input intervalBetweenAttempts(example:30s):\n"); |
| 892 | scanf("%hd", &ecall_context_info.intervalBetweenAttempts); |
| 893 | getchar(); |
| 894 | } |
| 895 | |
| 896 | printf("(Not supported)Whether the resetEcallSessionMode is valid(0:no, 1:yes):\n"); |
| 897 | scanf("%hhd", &ecall_context_info.resetEcallSessionMode_valid); |
| 898 | getchar(); |
| 899 | if(ecall_context_info.resetEcallSessionMode_valid) |
| 900 | { |
| 901 | printf("please input resetEcallSessionMode(example: 1,autoanswer):\n"); |
| 902 | scanf("%hhd", &ecall_context_info.resetEcallSessionMode); |
| 903 | getchar(); |
| 904 | } |
| 905 | |
| 906 | ql_ecall_set_config_info(ecall_context_info); |
| 907 | printf("ok!\n"); |
| 908 | } |
| 909 | |
| 910 | void item_ql_ecall_get_config_info(void) |
| 911 | { |
| 912 | ql_ecall_config_t ecall_context_info; |
| 913 | |
| 914 | ql_ecall_get_config_info(&ecall_context_info); |
| 915 | |
| 916 | printf("ok!\n"); |
| 917 | printf("the time of T5 timer is %hd\n", ecall_context_info.t5_timeout_ms); |
| 918 | printf("the time of T6 timer is %hd\n", ecall_context_info.t6_timeout_ms); |
| 919 | printf("the time of T7 timer is %hd\n", ecall_context_info.t7_timeout_ms); |
| 920 | printf("the time of dialDurationTimer is %d\n", ecall_context_info.dialDurationTimer_timout_ms); |
| 921 | printf("the maximum redial attempts is %d\n", ecall_context_info.maxDialAttempts); |
| 922 | //printf("the interval value between dial attempts is %hd\n", ecall_context_info.intervalBetweenAttempts); |
| 923 | } |
| 924 | |
| 925 | void item_ql_ecall_set_ecall_only_mode(void) |
| 926 | { |
| 927 | int ret = 0; |
| 928 | int ecall_only_value = 0; |
| 929 | |
| 930 | printf("ecall set ecall only mode(0:disable,1:enable): \n"); |
| 931 | scanf("%d", &ecall_only_value); |
| 932 | getchar(); |
| 933 | |
| 934 | ret = ql_ecall_set_ecall_only_mode(ecall_only_value); |
| 935 | printf(" ql_ecall_set_ecall_only_mode ret = %d\n", ret); |
| 936 | } |
| 937 | |
| 938 | static t_item_t ql_ecall_items[] = |
| 939 | { |
| 940 | {"ql_ecall_init", item_ql_ecall_init}, |
| 941 | {"ql_ecall_dial", item_ql_ecall_dial}, |
| 942 | {"ql_ecall_start_test", item_ql_ecall_start_test}, |
| 943 | {"ql_ecall_start_manual", item_ql_ecall_start_manual}, |
| 944 | {"ql_ecall_start_automatic", item_ql_ecall_start_automatic}, |
| 945 | {"ql_ecall_hangup", item_ql_ecall_hangup}, |
| 946 | {"ql_ecall_set_user_ind_cb", item_ql_ecall_set_user_ind_cb}, |
| 947 | {"ql_voice_ecall_set_test_number", item_ql_ecall_set_test_number}, |
| 948 | {"ql_ecall_set_system_type", item_ql_ecall_set_system_type}, |
| 949 | {"ql_ecall_get_system_type", item_ql_ecall_get_system_type}, |
| 950 | {"ql_ecall_update_msd_raw", item_ql_ecall_update_msd_raw}, |
| 951 | {"ql_ecall_push_msd", item_ql_ecall_push_msd}, |
| 952 | {"ql_voice_ecall_reset_ivs", item_ql_ecall_reset_ivs}, |
| 953 | {"ql_ecall_set_msd_call_type", item_ql_ecall_set_msd_call_type}, |
| 954 | {"ql_ecall_get_msd_call_type", item_ql_ecall_get_msd_call_type}, |
| 955 | {"ql_ecall_set_msd_vin", item_ql_ecall_set_msd_vin}, |
| 956 | {"ql_ecall_get_msd_vin", item_ql_ecall_get_msd_vin}, |
| 957 | {"ql_ecall_set_msd_version", item_ql_ecall_set_msd_version}, |
| 958 | {"ql_ecall_get_msd_version", item_ql_ecall_get_msd_version}, |
| 959 | {"ql_ecall_set_msd_tx_mode", item_ql_ecall_set_msd_tx_mode}, |
| 960 | {"ql_ecall_get_msd_tx_mode", item_ql_ecall_get_msd_tx_mode}, |
| 961 | {"ql_ecall_set_msd_position", item_ql_ecall_set_msd_position}, |
| 962 | {"ql_ecall_set_msd_position1", item_ql_ecall_set_msd_position1}, |
| 963 | {"ql_ecall_set_msd_position2", item_ql_ecall_set_msd_position2}, |
| 964 | {"ql_ecall_set_msd_vehicle_type", item_ql_ecall_set_msd_vehicle_type}, |
| 965 | {"ql_ecall_get_msd_vehicle_type", item_ql_ecall_get_msd_vehicle_type}, |
| 966 | {"ql_ecall_set_number_of_passengers", item_ql_ecall_set_number_of_passengers}, |
| 967 | {"ql_ecall_set_msd_propulsion_type", item_ql_ecall_set_msd_propulsion_type}, |
| 968 | {"ql_ecall_get_msd_propulsion_type", item_ql_ecall_get_msd_propulsion_type}, |
| 969 | {"ql_ecall_terminate_nw_registration", item_ql_ecall_terminate_nw_registration}, |
| 970 | {"ql_ecall_set_interval_between_attempts", item_ql_ecall_set_interval_between_attempts}, |
| 971 | {"ql_ecall_get_interval_between_attempts", item_ql_ecall_get_interval_between_attempts}, |
| 972 | {"ql_ecall_update_msd", item_ql_ecall_update_msd}, |
| 973 | {"ql_ecall_set_config_info", item_ql_ecall_set_config_info}, |
| 974 | {"ql_ecall_get_config_info", item_ql_ecall_get_config_info}, |
| 975 | {"ql_ecall_set_ecall_only_mode", item_ql_ecall_set_ecall_only_mode}, |
| 976 | {"ql_ecall_deinit", item_ql_ecall_deinit} |
| 977 | }; |
| 978 | |
| 979 | static void help() |
| 980 | { |
| 981 | int i = 0; |
| 982 | printf("Test Items:\n"); |
| 983 | while(i < ARRAY_SIZE(ql_ecall_items)) { |
| 984 | printf("%d : %s\n", i, ql_ecall_items[i].name); |
| 985 | i++; |
| 986 | } |
| 987 | printf(":"); |
| 988 | } |
| 989 | |
| 990 | int main(int argc, char *argv[]) |
| 991 | { |
| 992 | char cmd[1024]; |
| 993 | help(); |
| 994 | while(1) |
| 995 | { |
| 996 | memset(cmd, 0, sizeof(cmd)); |
| 997 | if(fgets(cmd, sizeof(cmd), stdin)) |
| 998 | { |
| 999 | char *ptr = cmd + strlen(cmd) - 1; |
| 1000 | while(ptr >= cmd && (*ptr == '\r' || *ptr == '\n')) |
| 1001 | { |
| 1002 | *ptr-- = '\0'; |
| 1003 | } |
| 1004 | |
| 1005 | if(strlen(cmd) > 0) { |
| 1006 | if(isdigit(cmd[0])) { |
| 1007 | int item = atoi(cmd); |
| 1008 | if(item >= 0 && item < ARRAY_SIZE(ql_ecall_items)) { |
| 1009 | ql_ecall_items[item].handle(); |
| 1010 | } |
| 1011 | } |
| 1012 | else if(!strcasecmp(cmd, "h")) { |
| 1013 | help(); |
| 1014 | } |
| 1015 | else if(!strcasecmp(cmd, "q")) { |
| 1016 | break; |
| 1017 | } |
| 1018 | } |
| 1019 | else { |
| 1020 | printf("\n"); |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | return 0; |
| 1025 | } |
| 1026 | |