b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * MBTK Basic AT Process. |
| 3 | * |
| 4 | * Author : lb |
| 5 | * Date : 2021/11/5 10:14:32 |
| 6 | * |
| 7 | */ |
| 8 | #include "mbtk_at.h" |
| 9 | #include "mbtk_device_info.h" |
| 10 | #include "mbtk/mbtk_type.h" |
| 11 | #include "mbtk/mbtk_device.h" |
| 12 | #include <dlfcn.h> |
| 13 | |
| 14 | //#include <sys/statfs.h> |
| 15 | #include <sys/vfs.h> |
| 16 | #include <errno.h> |
| 17 | #include <linux/magic.h> |
| 18 | #include <time.h> |
| 19 | #include <sys/time.h> |
| 20 | #include <signal.h> |
| 21 | #include <pthread.h> |
| 22 | #include <time.h> |
| 23 | #include <sys/time.h> |
| 24 | #include <cutils/properties.h> |
| 25 | #include "configwrapper.h" |
| 26 | #include<linux/msg.h> |
| 27 | |
| 28 | //#include "gps.h" |
| 29 | #include "atcmdsvr_ubus.h" |
| 30 | |
| 31 | #define MAX_GPIO_TEST_NUM 60 |
| 32 | |
| 33 | typedef int (*mbtk_dev_info_read_func)(mbtk_device_info_item_enum, void *, int); |
| 34 | |
| 35 | #define MBTK_LIB_PATH "/lib/libmbtk_lib.so" |
| 36 | const struct blobmsg_policy gps_user_cb_policy1[] = { |
| 37 | [0] = { |
| 38 | .name = "event", |
| 39 | .type = BLOBMSG_TYPE_INT32, |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | bool mbtk_urc_enable = TRUE; |
| 44 | |
| 45 | int mbtk_at_loopback(int type); |
| 46 | int mbtk_at_play(const char *args); |
| 47 | int mbtk_at_rec(const char *args); |
| 48 | |
| 49 | typedef struct |
| 50 | { |
| 51 | int gpio; |
| 52 | bool busy; |
| 53 | bool state; |
| 54 | } mbtk_gpio_state_t; |
| 55 | |
| 56 | static bool gpio_test_usable = true; |
| 57 | |
| 58 | static mbtk_gpio_state_t gpio_pins[] = |
| 59 | { |
| 60 | {22, FALSE, FALSE}, // IN |
| 61 | {33,FALSE,FALSE}, |
| 62 | {35,FALSE,FALSE}, |
| 63 | {36,FALSE,FALSE}, |
| 64 | {34,FALSE,FALSE}, |
| 65 | {21,FALSE,FALSE}, |
| 66 | {4,FALSE,FALSE}, |
| 67 | {123,FALSE,FALSE}, |
| 68 | {20,FALSE,FALSE}, |
| 69 | {43,FALSE,FALSE}, |
| 70 | {13,FALSE,FALSE}, |
| 71 | // {12,FALSE,FALSE}, |
| 72 | {14,FALSE,FALSE}, |
| 73 | {118,FALSE,FALSE}, |
| 74 | // {19,FALSE,FALSE}, |
| 75 | {120,FALSE,FALSE}, |
| 76 | {49,FALSE,FALSE}, |
| 77 | {50,FALSE,FALSE}, |
| 78 | {32,FALSE,FALSE}, |
| 79 | {31,FALSE,FALSE}, |
| 80 | {51,FALSE,FALSE}, |
| 81 | // {23,FALSE,FALSE}, |
| 82 | {24,FALSE,FALSE}, |
| 83 | {52,FALSE,FALSE}, |
| 84 | {27,FALSE,FALSE}, |
| 85 | {28,FALSE,FALSE}, |
| 86 | {26,FALSE,FALSE}, |
| 87 | {25,FALSE,FALSE}, |
| 88 | {5,FALSE,FALSE}, |
| 89 | {0,FALSE,FALSE}, |
| 90 | {1,FALSE,FALSE}, |
| 91 | {2,FALSE,FALSE}, |
| 92 | {3,FALSE,FALSE}, |
| 93 | {6,FALSE,FALSE}, |
| 94 | {7,FALSE,FALSE}, |
| 95 | {15,FALSE,FALSE}, |
| 96 | {18,FALSE,FALSE}, |
| 97 | {16,FALSE,FALSE}, |
| 98 | {17,FALSE,FALSE}, |
| 99 | {54,FALSE,FALSE}, |
| 100 | {53,FALSE,FALSE}, |
| 101 | {48,FALSE,FALSE}, |
| 102 | {55,FALSE,FALSE}, |
| 103 | {58,FALSE,FALSE}, |
| 104 | {57,FALSE,FALSE}, |
| 105 | {29,FALSE,FALSE}, |
| 106 | {30,FALSE,FALSE}, |
| 107 | {99,FALSE,FALSE}, |
| 108 | {126,FALSE,FALSE}, |
| 109 | {125,FALSE,FALSE}, |
| 110 | {56,FALSE,FALSE}, |
| 111 | {59,FALSE,FALSE}, |
| 112 | {117,FALSE,FALSE}, |
| 113 | // {122,FALSE,FALSE} |
| 114 | }; |
| 115 | |
| 116 | int gpio_register_auto_test_out(int *result); |
| 117 | |
| 118 | #define MBTK_GPIO_NUM (sizeof(gpio_pins)/sizeof(mbtk_gpio_state_t)) |
| 119 | |
| 120 | static bool dev_info_inited = FALSE; |
| 121 | static mbtk_device_info_basic_t info_basic; |
| 122 | static mbtk_device_info_modem_t info_modem; |
| 123 | |
| 124 | static int dev_info_get() |
| 125 | { |
| 126 | if(dev_info_inited) { |
| 127 | return 0; |
| 128 | } |
| 129 | void *handle = dlopen(MBTK_LIB_PATH , RTLD_LAZY); |
| 130 | if(handle == NULL) |
| 131 | { |
| 132 | DBGMSG(MBTK_AT, "dlopen() %s fail : %d", MBTK_LIB_PATH, errno); |
| 133 | return -1; |
| 134 | } |
| 135 | |
| 136 | mbtk_dev_info_read_func dev_info_read = (mbtk_dev_info_read_func)dlsym(handle, "mbtk_dev_info_read"); |
| 137 | if(dev_info_read == NULL) |
| 138 | { |
| 139 | DBGMSG(MBTK_AT, "dlsym(mbtk_dev_info_read) fail : %d", errno); |
| 140 | return -1; |
| 141 | } |
| 142 | |
| 143 | memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t)); |
| 144 | memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t)); |
| 145 | |
| 146 | // mbtk_dev_info_read() |
| 147 | int result = dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t)); |
| 148 | if(result) { |
| 149 | DBGMSG(MBTK_AT, "mbtk_dev_info_read(BASIC) fail."); |
| 150 | return -1; |
| 151 | } |
| 152 | |
| 153 | result = dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &info_modem, sizeof(mbtk_device_info_modem_t)); |
| 154 | if(result) { |
| 155 | DBGMSG(MBTK_AT, "mbtk_dev_info_read(MODEM) fail."); |
| 156 | return -1; |
| 157 | } |
| 158 | |
| 159 | dev_info_inited = TRUE; |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | static char* band_area_2_str(mbtk_modem_band_area_enum band_area) |
| 164 | { |
| 165 | switch(band_area) { |
| 166 | case MBTK_MODEM_BAND_AREA_CN: |
| 167 | return "CN"; |
| 168 | case MBTK_MODEM_BAND_AREA_EU: |
| 169 | return "EU"; |
| 170 | case MBTK_MODEM_BAND_AREA_SA: |
| 171 | return "SA"; |
| 172 | default: |
| 173 | return "DEF"; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | static int gpio_export(void) |
| 178 | { |
| 179 | int index=0; |
| 180 | int file=-1; |
| 181 | int result =-1; |
| 182 | char pin_index_buffer[5]= {0}; |
| 183 | |
| 184 | for(index = 0; index < MBTK_GPIO_NUM; index++) |
| 185 | { |
| 186 | file = open("/sys/class/gpio/export",O_WRONLY); |
| 187 | if(file == -1) |
| 188 | { |
| 189 | LOG("Open gpio export file fail."); |
| 190 | return -1; |
| 191 | } |
| 192 | |
| 193 | memset(pin_index_buffer,0,5); |
| 194 | sprintf(pin_index_buffer,"%d",gpio_pins[index].gpio); |
| 195 | result = write(file,pin_index_buffer,strlen(pin_index_buffer)); |
| 196 | if(result < 0) |
| 197 | { |
| 198 | LOG("Gpio[%d] export fail.", gpio_pins[index].gpio); |
| 199 | gpio_pins[index].busy = TRUE; |
| 200 | } |
| 201 | close(file); |
| 202 | } |
| 203 | |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | static int gpio_unexport(void) |
| 208 | { |
| 209 | int index=0; |
| 210 | int file=-1; |
| 211 | int result =-1; |
| 212 | char pin_index_buffer[5]= {0}; |
| 213 | |
| 214 | for(index = 0; index < MBTK_GPIO_NUM; index++) |
| 215 | { |
| 216 | if(!gpio_pins[index].busy) |
| 217 | { |
| 218 | file = open("/sys/class/gpio/unexport",O_WRONLY); |
| 219 | if(file == -1) |
| 220 | { |
| 221 | LOG("Open gpio unexport file fail."); |
| 222 | return -1; |
| 223 | } |
| 224 | |
| 225 | memset(pin_index_buffer,0,5); |
| 226 | sprintf(pin_index_buffer,"%d",gpio_pins[index].gpio); |
| 227 | result=write(file,pin_index_buffer,strlen(pin_index_buffer)); |
| 228 | if(result < 0) |
| 229 | { |
| 230 | close(file); |
| 231 | LOG("Gpio[%d] unexport fail.",gpio_pins[index].gpio); |
| 232 | return -1; |
| 233 | } |
| 234 | close(file); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | static int gpio_direct_set(char *value,int gpio) |
| 242 | { |
| 243 | char buffer[50]= {0}; |
| 244 | int file =-1; |
| 245 | int result =-1; |
| 246 | |
| 247 | memset(buffer,0,50); |
| 248 | sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio); |
| 249 | file = open(buffer, O_WRONLY); |
| 250 | if(file == -1) |
| 251 | { |
| 252 | LOG("Open gpio[%d] direct fail.", gpio); |
| 253 | return -1; |
| 254 | } |
| 255 | |
| 256 | result = write(file,value,strlen(value)); |
| 257 | if(result != strlen(value)) |
| 258 | { |
| 259 | LOG("Set gpio[%d] direct fail.", gpio); |
| 260 | close(file); |
| 261 | return -1; |
| 262 | } |
| 263 | close(file); |
| 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | static int gpio_value_get(int gpio) |
| 269 | { |
| 270 | char buffer[50]; |
| 271 | char path[10]; |
| 272 | int file =-1; |
| 273 | int result =-1; |
| 274 | int value; |
| 275 | |
| 276 | memset(path,0,50); |
| 277 | memset(buffer,0,10); |
| 278 | sprintf(path,"/sys/class/gpio/gpio%d/value", gpio); |
| 279 | file = open(path,O_RDONLY); |
| 280 | if(file == -1) |
| 281 | { |
| 282 | LOG("Open gpio[%d] fail.", gpio); |
| 283 | return -1; |
| 284 | } |
| 285 | result = read(file,buffer,5); |
| 286 | if(result <= 0) |
| 287 | { |
| 288 | LOG("Get gpio[%d] value fail", gpio); |
| 289 | close(file); |
| 290 | return -1; |
| 291 | } |
| 292 | close(file); |
| 293 | value = atoi(buffer); |
| 294 | return value; |
| 295 | } |
| 296 | |
| 297 | static int gpio_value_set(int value, int gpio) |
| 298 | { |
| 299 | char buffer[50]= {0}; |
| 300 | int file =-1; |
| 301 | int result =-1; |
| 302 | |
| 303 | memset(buffer,0,50); |
| 304 | sprintf(buffer,"/sys/class/gpio/gpio%d/value", gpio); |
| 305 | file = open(buffer,O_WRONLY); |
| 306 | if(file == -1) |
| 307 | { |
| 308 | LOG("Open gpio[%d] value fail.", gpio); |
| 309 | return -1; |
| 310 | } |
| 311 | if(value == 0) { |
| 312 | result = write(file,"0",1); |
| 313 | } else { |
| 314 | result = write(file,"1",1); |
| 315 | } |
| 316 | if(result != 1) |
| 317 | { |
| 318 | LOG("Set gpio[%d] value fail.", gpio); |
| 319 | close(file); |
| 320 | return -1; |
| 321 | } |
| 322 | close(file); |
| 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | //type:0 value 0 |
| 328 | //type:1 value 1 |
| 329 | //type:2 direction "out" |
| 330 | //type:3 direction "in" |
| 331 | |
| 332 | static int one_gpio_export(int gpio, int type) |
| 333 | { |
| 334 | int index=0; |
| 335 | int file=-1; |
| 336 | int file1=-1; |
| 337 | int result =-1; |
| 338 | char pin_index_buffer[5]= {0}; |
| 339 | char buffer[50]= {0}; |
| 340 | int ret =0; |
| 341 | |
| 342 | file = open("/sys/class/gpio/export",O_WRONLY); |
| 343 | if(file == -1) |
| 344 | { |
| 345 | LOG("Open gpio export file fail."); |
| 346 | return -1; |
| 347 | } |
| 348 | |
| 349 | memset(buffer,0,50); |
| 350 | sprintf(buffer,"/sys/class/gpio/gpio%d", gpio); |
| 351 | file1 = open(buffer,O_RDONLY); |
| 352 | if(file1 != -1) |
| 353 | { |
| 354 | //file is created |
| 355 | } |
| 356 | else{ // create gpio |
| 357 | memset(pin_index_buffer,0,5); |
| 358 | sprintf(pin_index_buffer,"%d",gpio); |
| 359 | result = write(file,pin_index_buffer,strlen(pin_index_buffer)); |
| 360 | if(result < 0) |
| 361 | { |
| 362 | ATRESP(IND_REQ_HANDLE , ATCI_RESULT_CODE_NULL, 0, "Gpio export fail"); |
| 363 | LOG("Gpio[%d] export fail.", gpio); |
| 364 | return -1; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | close(file); |
| 369 | |
| 370 | |
| 371 | switch(type) |
| 372 | { |
| 373 | case 0 : |
| 374 | { |
| 375 | ret = gpio_value_set(0, gpio); |
| 376 | break; |
| 377 | } |
| 378 | case 1: |
| 379 | { |
| 380 | ret = gpio_value_set(1, gpio); |
| 381 | break; |
| 382 | } |
| 383 | case 2: |
| 384 | { |
| 385 | ret = gpio_direct_set("out", gpio); |
| 386 | break; |
| 387 | } |
| 388 | case 3: |
| 389 | { |
| 390 | ret = gpio_direct_set("in", gpio); |
| 391 | break; |
| 392 | } |
| 393 | default: |
| 394 | { |
| 395 | break; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | |
| 400 | return ret; |
| 401 | } |
| 402 | |
| 403 | |
| 404 | static int gpio_test(void) |
| 405 | { |
| 406 | int index = 0; |
| 407 | int fail_count = 0; |
| 408 | gpio_export(); |
| 409 | |
| 410 | gpio_direct_set("in", gpio_pins[0].gpio); |
| 411 | //set all gpio low level start |
| 412 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 413 | { |
| 414 | if(!gpio_pins[index].busy) |
| 415 | { |
| 416 | gpio_direct_set("out", gpio_pins[index].gpio); |
| 417 | gpio_value_set(0, gpio_pins[index].gpio); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | if(gpio_value_get(gpio_pins[0].gpio) != 0) |
| 422 | { |
| 423 | LOG("gpio_test set all gpio level[%d] fail", gpio_pins[0].gpio); |
| 424 | gpio_unexport(); |
| 425 | return -1; |
| 426 | } |
| 427 | //set all gpio low level end |
| 428 | |
| 429 | #if 1 |
| 430 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 431 | { |
| 432 | if(!gpio_pins[index].busy) |
| 433 | { |
| 434 | gpio_value_set(1, gpio_pins[index].gpio); |
| 435 | if(gpio_value_get(gpio_pins[index].gpio) == 1 && gpio_value_get(gpio_pins[0].gpio) == 1) |
| 436 | { |
| 437 | gpio_pins[index].state = TRUE; |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | LOG("gpio[%d] input not match output level [1]", gpio_pins[index].gpio); |
| 442 | gpio_pins[index].state = FALSE; |
| 443 | fail_count++; |
| 444 | continue; |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | if(fail_count > 0) { |
| 450 | gpio_unexport(); |
| 451 | return fail_count; |
| 452 | } |
| 453 | |
| 454 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 455 | { |
| 456 | if(!gpio_pins[index].busy) |
| 457 | { |
| 458 | gpio_value_set(0, gpio_pins[index].gpio); |
| 459 | if(gpio_value_get(gpio_pins[index].gpio) == 0 && gpio_value_get(gpio_pins[0].gpio) == 0) |
| 460 | { |
| 461 | gpio_pins[index].state = TRUE; |
| 462 | } |
| 463 | else |
| 464 | { |
| 465 | LOG("gpio[%d] input not match output level [0]", gpio_pins[index].gpio); |
| 466 | gpio_pins[index].state = FALSE; |
| 467 | fail_count++; |
| 468 | continue; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | gpio_unexport(); |
| 474 | #endif |
| 475 | return fail_count; |
| 476 | } |
| 477 | |
| 478 | static int gpio_test2(void) |
| 479 | { |
| 480 | int index=0; |
| 481 | int value=0; |
| 482 | int fail_count = 0; |
| 483 | //export all test gpio |
| 484 | gpio_export(); |
| 485 | |
| 486 | |
| 487 | //set main control gpio in |
| 488 | gpio_direct_set("in", gpio_pins[0].gpio); |
| 489 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 490 | { |
| 491 | gpio_direct_set("out",gpio_pins[index].gpio); |
| 492 | gpio_value_set(1, gpio_pins[index].gpio); |
| 493 | } |
| 494 | |
| 495 | if(gpio_value_get(gpio_pins[0].gpio) != 1) |
| 496 | { |
| 497 | LOG("gpio_test set all gpio level[%d] fail", gpio_pins[0].gpio); |
| 498 | gpio_unexport(); |
| 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | //set all gpio value as 0 |
| 503 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 504 | { |
| 505 | gpio_value_set(0, gpio_pins[index].gpio); |
| 506 | } |
| 507 | |
| 508 | //set gpio direct in except main control gpio |
| 509 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 510 | { |
| 511 | gpio_direct_set("in",gpio_pins[index].gpio); |
| 512 | } |
| 513 | |
| 514 | //set main control gpio out |
| 515 | gpio_direct_set("out",gpio_pins[0].gpio); |
| 516 | gpio_value_set(1,gpio_pins[0].gpio); |
| 517 | for(index = 1; index < MBTK_GPIO_NUM; index++) |
| 518 | { |
| 519 | value = -1; |
| 520 | value=gpio_value_get(gpio_pins[index].gpio); |
| 521 | if(1==value) |
| 522 | { |
| 523 | gpio_pins[index].state = TRUE; |
| 524 | } |
| 525 | else |
| 526 | { |
| 527 | LOG("gpio[%d] input not match output level [0]", gpio_pins[index].gpio); |
| 528 | gpio_pins[index].state = FALSE; |
| 529 | fail_count++; |
| 530 | continue; |
| 531 | } |
| 532 | } |
| 533 | //unexport gpio |
| 534 | gpio_unexport(); |
| 535 | |
| 536 | return fail_count; |
| 537 | //set main |
| 538 | } |
| 539 | |
| 540 | |
| 541 | uint64 partion_space_get(const char *path) |
| 542 | { |
| 543 | unsigned long long totle = 0; |
| 544 | unsigned long long blocksize = 0; |
| 545 | struct statfs diskInfo; |
| 546 | |
| 547 | if(path == NULL){ |
| 548 | return 0; |
| 549 | } |
| 550 | memset(&diskInfo, 0, sizeof(diskInfo)); |
| 551 | |
| 552 | if(statfs(path, &diskInfo)){ |
| 553 | LOG("statfs() fail - %d.", errno); |
| 554 | return 0; |
| 555 | } |
| 556 | blocksize = diskInfo.f_bsize; |
| 557 | LOG("path=%s [totle=%lld MB] :f_type= %lld, f_bsize=%lld, f_blocks=%lld, f_bfree=%lld, f_bavail%lld\n", path,totle, |
| 558 | diskInfo.f_type, diskInfo.f_bsize,diskInfo.f_blocks,diskInfo.f_bfree, diskInfo.f_bavail); |
| 559 | |
| 560 | // MSDOS_SUPER_MAGIC 0x4d44 |
| 561 | if((diskInfo.f_type & 0x0ffff) == MSDOS_SUPER_MAGIC) { |
| 562 | totle = (diskInfo.f_blocks * blocksize) >> 20; |
| 563 | return totle; |
| 564 | } else { |
| 565 | LOG("Unknow fs type : %x", diskInfo.f_type); |
| 566 | return 0; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | static unsigned int shell_at_handle; |
| 571 | static void shell_cb_func(char *buf,int buf_size) |
| 572 | { |
| 573 | if(buf && buf_size > 0) |
| 574 | { |
| 575 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 576 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "+MSHELL: %d\r\n%s\r\n", |
| 577 | buf_size, buf); |
| 578 | //MBTK_FUNC(log_hex)("+MSHELL", buf, buf_size); |
| 579 | ATRESP(shell_at_handle, ATCI_RESULT_CODE_NULL, 0, resp_buf); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | int metis_strptime(char *str_time) |
| 584 | { |
| 585 | struct tm stm; |
| 586 | char dateTime[30]; |
| 587 | struct timeval tv; |
| 588 | if( strptime(str_time, "%Y-%m-%d %H:%M:%S",&stm) != NULL) |
| 589 | { |
| 590 | printf("success\n"); |
| 591 | } |
| 592 | else{ |
| 593 | printf("error\n"); |
| 594 | return -1; |
| 595 | } |
| 596 | |
| 597 | // printf("设置系统时间前的时间是:\n"); |
| 598 | // system("date"); |
| 599 | time_t _t = mktime(&stm); |
| 600 | // stime(&_t); |
| 601 | tv.tv_sec = _t; |
| 602 | // tv.tv_usec = USEC(pnew_time_packet->transmit_timestamp.fine); |
| 603 | settimeofday(&tv, NULL); |
| 604 | |
| 605 | printf("设置系统时间HOU的时间是:\n"); |
| 606 | // system("date"); |
| 607 | |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | extern int mbtk_time_type; |
| 612 | |
| 613 | #if 0 |
| 614 | static void gpio_timer_alrm_func(int signo) |
| 615 | { |
| 616 | LOG("TIMEOUT : %d", signo); |
| 617 | if(SIGALRM == signo) { |
| 618 | gpio_test_usable = true; |
| 619 | LOG("gpio_test_usable has reset to true."); |
| 620 | } |
| 621 | } |
| 622 | #else |
| 623 | static void* gpio_thread_func(void *arg) |
| 624 | { |
| 625 | sleep(1); |
| 626 | gpio_test_usable = true; |
| 627 | LOG("gpio_test_usable has reset to true."); |
| 628 | return NULL; |
| 629 | } |
| 630 | #endif |
| 631 | #ifdef MBTK_DATA_MODE_SUPPORT |
| 632 | static void data_mode_callback_cb(const char *data, int data_len) |
| 633 | { |
| 634 | LOG("DATA - %d:%s", data_len, data); |
| 635 | } |
| 636 | #endif |
| 637 | |
| 638 | utlReturnCode_T MBTK_AT_MTEST_PROCESS(const utlAtParameterOp_T op, |
| 639 | const char *command_name_p, |
| 640 | const utlAtParameterValue_P2c parameter_values_p, |
| 641 | const size_t num_parameters, |
| 642 | const char *info_text_p, |
| 643 | unsigned int *xid_p, |
| 644 | void *arg_p) |
| 645 | { |
| 646 | UNUSEDPARAM(command_name_p); |
| 647 | UNUSEDPARAM(num_parameters); |
| 648 | UNUSEDPARAM(info_text_p); |
| 649 | |
| 650 | utlReturnCode_T ret = utlSUCCESS; |
| 651 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 652 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 653 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 654 | unsigned int svc_id = 0; |
| 655 | *xid_p = At_handle; |
| 656 | |
| 657 | const static int arg2_len_max = 10; |
| 658 | static int arg1 = 0; |
| 659 | static char arg2[MBTK_AT_RESP_LEN_MAX]; |
| 660 | |
| 661 | LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 662 | |
| 663 | switch(op) |
| 664 | { |
| 665 | case TEL_EXT_GET_CMD : |
| 666 | { |
| 667 | sprintf(resp_buf, "%s : %d,\"%s\"\r\n", command_name_p, arg1, arg2); |
| 668 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 669 | break; |
| 670 | } |
| 671 | case TEL_EXT_SET_CMD : |
| 672 | { |
| 673 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0)) |
| 674 | { |
| 675 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 676 | break; |
| 677 | } |
| 678 | |
| 679 | int len = 0; |
| 680 | memset(arg2, 0x0, MBTK_AT_RESP_LEN_MAX); |
| 681 | if(!getExtString(parameter_values_p, 1, arg2, arg2_len_max, &len, "test")) |
| 682 | { |
| 683 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 684 | break; |
| 685 | } |
| 686 | |
| 687 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 688 | break; |
| 689 | } |
| 690 | case TEL_EXT_ACTION_CMD : |
| 691 | { |
| 692 | // ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK"); |
| 693 | #ifdef MBTK_DATA_MODE_SUPPORT |
| 694 | ret = mbtk_data_mode_enter(sAtp_index, data_mode_callback_cb); |
| 695 | #else |
| 696 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK"); |
| 697 | #endif |
| 698 | break; |
| 699 | } |
| 700 | |
| 701 | default: |
| 702 | { |
| 703 | break; |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | return ret; |
| 708 | |
| 709 | } |
| 710 | |
| 711 | |
| 712 | utlReturnCode_T MBTK_AT_MINFO_PROCESS(const utlAtParameterOp_T op, |
| 713 | const char *command_name_p, |
| 714 | const utlAtParameterValue_P2c parameter_values_p, |
| 715 | const size_t num_parameters, |
| 716 | const char *info_text_p, |
| 717 | unsigned int *xid_p, |
| 718 | void *arg_p) |
| 719 | { |
| 720 | UNUSEDPARAM(command_name_p); |
| 721 | UNUSEDPARAM(num_parameters); |
| 722 | UNUSEDPARAM(info_text_p); |
| 723 | |
| 724 | utlReturnCode_T ret = utlFAILED; |
| 725 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 726 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 727 | *xid_p = at_handle; |
| 728 | |
| 729 | LOG("%s enter with command_op [%s]", command_name_p, op2str(op)); |
| 730 | |
| 731 | switch(op) |
| 732 | { |
| 733 | case TEL_EXT_ACTION_CMD : |
| 734 | { |
| 735 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 736 | if(!dev_info_get()) { |
| 737 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, |
| 738 | "Revision:%s\r\n" |
| 739 | "Custom_Model:%s\r\n" |
| 740 | "Module_Type:%s\r\n", |
| 741 | strlen(info_basic.revision_out) > 0 ? info_basic.revision_out: "Unknown", |
| 742 | strlen(info_basic.project_cust) > 0 ? info_basic.project_cust: "Unknown", |
| 743 | band_area_2_str(info_modem.band_area)); |
| 744 | } else { |
| 745 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, |
| 746 | "Revision:%s\r\n" |
| 747 | "Custom_Model:%s\r\n" |
| 748 | "Module_Type:%s\r\n", |
| 749 | "Unknown", "Unknown", "Unknown"); |
| 750 | } |
| 751 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 752 | break; |
| 753 | } |
| 754 | default: |
| 755 | { |
| 756 | break; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | return ret; |
| 761 | } |
| 762 | |
| 763 | utlReturnCode_T MBTK_AT_SYSTIME_PROCESS(const utlAtParameterOp_T op, |
| 764 | const char *command_name_p, |
| 765 | const utlAtParameterValue_P2c parameter_values_p, |
| 766 | const size_t num_parameters, |
| 767 | const char *info_text_p, |
| 768 | unsigned int *xid_p, |
| 769 | void *arg_p) |
| 770 | { |
| 771 | UNUSEDPARAM(command_name_p); |
| 772 | UNUSEDPARAM(num_parameters); |
| 773 | UNUSEDPARAM(info_text_p); |
| 774 | |
| 775 | utlReturnCode_T ret = utlSUCCESS; |
| 776 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 777 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 778 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 779 | unsigned int svc_id = 0; |
| 780 | *xid_p = At_handle; |
| 781 | |
| 782 | const static int arg2_len_max = 10; |
| 783 | static int arg1 = 0; |
| 784 | |
| 785 | printf("MBTK_AT_SYSTIME_PROCESS enter with command_op [%s]", op2str(op)); |
| 786 | |
| 787 | switch(op) |
| 788 | { |
| 789 | case TEL_EXT_GET_CMD : |
| 790 | { |
| 791 | char time_type[10] = {0}; |
| 792 | property_get("persist.mbtk.time_type", time_type, "0"); |
| 793 | mbtk_time_type = atoi(time_type); |
| 794 | sprintf(resp_buf, "%s: %d\r\n", command_name_p, mbtk_time_type); |
| 795 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 796 | break; |
| 797 | } |
| 798 | case TEL_EXT_SET_CMD : |
| 799 | { |
| 800 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 2, 0)) |
| 801 | { |
| 802 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 803 | break; |
| 804 | } |
| 805 | |
| 806 | if(num_parameters > 1) { |
| 807 | const static int cmd_len_max = MBTK_AT_RESP_LEN_MAX; |
| 808 | static char time_str[MBTK_AT_RESP_LEN_MAX]; |
| 809 | int len = 0; |
| 810 | memset(time_str, 0x0, MBTK_AT_RESP_LEN_MAX); |
| 811 | if(!getExtString(parameter_values_p, 1, time_str, cmd_len_max, &len, "")) |
| 812 | { |
| 813 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 814 | LOG("Get CMD Fail."); |
| 815 | break; |
| 816 | } |
| 817 | |
| 818 | if(strlen(time_str) > 0) |
| 819 | { |
| 820 | ret = metis_strptime(time_str); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | mbtk_time_type = arg1; |
| 825 | char type_str[10] = {0}; |
| 826 | sprintf(type_str, "%d", mbtk_time_type); |
| 827 | property_set("persist.mbtk.time_type", type_str); |
| 828 | if(ret < 0) |
| 829 | { |
| 830 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 835 | } |
| 836 | |
| 837 | break; |
| 838 | } |
| 839 | default: |
| 840 | { |
| 841 | break; |
| 842 | } |
| 843 | } |
| 844 | return ret; |
| 845 | } |
| 846 | |
| 847 | utlReturnCode_T MBTK_AT_MTESTF_PROCESS(const utlAtParameterOp_T op, |
| 848 | const char *command_name_p, |
| 849 | const utlAtParameterValue_P2c parameter_values_p, |
| 850 | const size_t num_parameters, |
| 851 | const char *info_text_p, |
| 852 | unsigned int *xid_p, |
| 853 | void *arg_p) |
| 854 | { |
| 855 | UNUSEDPARAM(command_name_p); |
| 856 | UNUSEDPARAM(num_parameters); |
| 857 | UNUSEDPARAM(info_text_p); |
| 858 | |
| 859 | utlReturnCode_T ret = utlSUCCESS; |
| 860 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 861 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 862 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 863 | unsigned int svc_id = 0; |
| 864 | *xid_p = At_handle; |
| 865 | |
| 866 | const static int arg2_len_max = 10; |
| 867 | static int arg1 = 0; |
| 868 | static char arg2[MBTK_AT_RESP_LEN_MAX]; |
| 869 | |
| 870 | LOG("MBTK_AT_MTESTF_PROCESS enter with command_op [%s]", op2str(op)); |
| 871 | |
| 872 | switch(op) |
| 873 | { |
| 874 | case TEL_EXT_GET_CMD : |
| 875 | { |
| 876 | sprintf(resp_buf, "%s : %d,\"%s\"\r\n", command_name_p, arg1, arg2); |
| 877 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 878 | break; |
| 879 | } |
| 880 | case TEL_EXT_SET_CMD : |
| 881 | { |
| 882 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0)) |
| 883 | { |
| 884 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 885 | break; |
| 886 | } |
| 887 | |
| 888 | int len = 0; |
| 889 | memset(arg2, 0x0, MBTK_AT_RESP_LEN_MAX); |
| 890 | if(!getExtString(parameter_values_p, 1, arg2, arg2_len_max, &len, "test")) |
| 891 | { |
| 892 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 893 | break; |
| 894 | } |
| 895 | |
| 896 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 897 | break; |
| 898 | } |
| 899 | case TEL_EXT_TEST_CMD : |
| 900 | { |
| 901 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "+MTESTF=(0,1),\"\""); |
| 902 | break; |
| 903 | } |
| 904 | case TEL_EXT_ACTION_CMD : |
| 905 | { |
| 906 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK"); |
| 907 | break; |
| 908 | } |
| 909 | |
| 910 | default: |
| 911 | { |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | return ret; |
| 917 | |
| 918 | } |
| 919 | |
| 920 | |
| 921 | utlReturnCode_T MBTK_AT_MSHELL_PROCESS(const utlAtParameterOp_T op, |
| 922 | const char *command_name_p, |
| 923 | const utlAtParameterValue_P2c parameter_values_p, |
| 924 | const size_t num_parameters, |
| 925 | const char *info_text_p, |
| 926 | unsigned int *xid_p, |
| 927 | void *arg_p) |
| 928 | { |
| 929 | UNUSEDPARAM(command_name_p); |
| 930 | UNUSEDPARAM(num_parameters); |
| 931 | UNUSEDPARAM(info_text_p); |
| 932 | |
| 933 | utlReturnCode_T ret = utlFAILED; |
| 934 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 935 | shell_at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 936 | *xid_p = shell_at_handle; |
| 937 | |
| 938 | LOG("MBTK_AT_MSHELL_PROCESS enter with command_op [%s]", op2str(op)); |
| 939 | |
| 940 | switch(op) |
| 941 | { |
| 942 | case TEL_EXT_SET_CMD : |
| 943 | { |
| 944 | const static int cmd_len_max = MBTK_AT_RESP_LEN_MAX; |
| 945 | static char cmd[MBTK_AT_RESP_LEN_MAX]; |
| 946 | int len = 0; |
| 947 | memset(cmd, 0x0, MBTK_AT_RESP_LEN_MAX); |
| 948 | if(!getExtString(parameter_values_p, 0, cmd, cmd_len_max, &len, "")) |
| 949 | { |
| 950 | ret = ATRESP(shell_at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 951 | LOG("Get CMD Fail."); |
| 952 | break; |
| 953 | } |
| 954 | |
| 955 | //if(strlen(cmd) > 0 && mbtk_cmd_line_ex(cmd, shell_cb_func)) |
| 956 | if(strlen(cmd) > 0 && MBTK_FUNC(mbtk_cmd_line_ex)(cmd, shell_cb_func)) |
| 957 | { |
| 958 | ret = ATRESP(shell_at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 959 | } |
| 960 | else |
| 961 | { |
| 962 | LOG("CMD length error."); |
| 963 | break; |
| 964 | } |
| 965 | break; |
| 966 | } |
| 967 | default: |
| 968 | { |
| 969 | break; |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | return ret; |
| 974 | |
| 975 | } |
| 976 | |
| 977 | utlReturnCode_T MBTK_AT_ISLKVRSCAN_PROCESS(const utlAtParameterOp_T op, |
| 978 | const char *command_name_p, |
| 979 | const utlAtParameterValue_P2c parameter_values_p, |
| 980 | const size_t num_parameters, |
| 981 | const char *info_text_p, |
| 982 | unsigned int *xid_p, |
| 983 | void *arg_p) |
| 984 | { |
| 985 | UNUSEDPARAM(command_name_p); |
| 986 | UNUSEDPARAM(num_parameters); |
| 987 | UNUSEDPARAM(info_text_p); |
| 988 | |
| 989 | utlReturnCode_T ret = utlFAILED; |
| 990 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 991 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 992 | *xid_p = at_handle; |
| 993 | |
| 994 | LOG("MBTK_AT_ISLKVRSCAN_PROCESS enter with command_op [%s]", op2str(op)); |
| 995 | |
| 996 | #ifndef MBTK_BUILD_TIME |
| 997 | #define MBTK_BUILD_TIME "Unknown" |
| 998 | #endif |
| 999 | |
| 1000 | switch(op) |
| 1001 | { |
| 1002 | case TEL_EXT_ACTION_CMD : |
| 1003 | { |
| 1004 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1005 | if(!dev_info_get()) { |
| 1006 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Version: %s\r\nBuild time: %s\r\n", |
| 1007 | strlen(info_basic.revision_out) > 0 ? info_basic.revision_out: "Unknown", |
| 1008 | strlen(info_basic.build_time) > 0 ? info_basic.build_time: "Unknown"); |
| 1009 | } else { |
| 1010 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Version: %s\r\nBuild time: %s\r\n", |
| 1011 | "Unknown", "Unknown"); |
| 1012 | } |
| 1013 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1014 | break; |
| 1015 | } |
| 1016 | default: |
| 1017 | { |
| 1018 | break; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | return ret; |
| 1023 | |
| 1024 | } |
| 1025 | |
| 1026 | utlReturnCode_T MBTK_AT_SDTEST_PROCESS(const utlAtParameterOp_T op, |
| 1027 | const char *command_name_p, |
| 1028 | const utlAtParameterValue_P2c parameter_values_p, |
| 1029 | const size_t num_parameters, |
| 1030 | const char *info_text_p, |
| 1031 | unsigned int *xid_p, |
| 1032 | void *arg_p) |
| 1033 | { |
| 1034 | UNUSEDPARAM(command_name_p); |
| 1035 | UNUSEDPARAM(num_parameters); |
| 1036 | UNUSEDPARAM(info_text_p); |
| 1037 | |
| 1038 | utlReturnCode_T ret = utlFAILED; |
| 1039 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1040 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1041 | *xid_p = at_handle; |
| 1042 | |
| 1043 | LOG("%s enter with command_op [%s]", command_name_p, op2str(op)); |
| 1044 | |
| 1045 | switch(op) |
| 1046 | { |
| 1047 | case TEL_EXT_ACTION_CMD : |
| 1048 | { |
| 1049 | // SDVOLUME:xxxMB |
| 1050 | // OK |
| 1051 | // /mnt/mmcblk0p1 |
| 1052 | #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108) || defined(MBTK_PROJECT_L509) || defined(MBTK_PROJECT_L508)) |
| 1053 | int i =0 ; |
| 1054 | uint64 size = 0; |
| 1055 | for(i = 0; i < 3; i++) |
| 1056 | { |
| 1057 | if(i == 0) |
| 1058 | { |
| 1059 | size = partion_space_get("/sdcard"); |
| 1060 | } |
| 1061 | else if(i == 1) |
| 1062 | { |
| 1063 | size = partion_space_get("/system/etc/www/webdav/sdcard"); |
| 1064 | } |
| 1065 | else |
| 1066 | { |
| 1067 | system("mkfs.vfat -F 32 /dev/mmcblk0"); |
| 1068 | system("mount -t vfat /dev/mmcblk0 /mnt"); |
| 1069 | size = partion_space_get("/mnt"); |
| 1070 | } |
| 1071 | |
| 1072 | if(size > 0) |
| 1073 | { |
| 1074 | LOG("[SDTEST] i = %d, size = %d", i, size); |
| 1075 | break; |
| 1076 | } |
| 1077 | |
| 1078 | size = 0; |
| 1079 | } |
| 1080 | #else |
| 1081 | uint64 size = partion_space_get("/mnt/mmcblk0p1"); |
| 1082 | #endif |
| 1083 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1084 | if(size > 0) { |
| 1085 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "SDVOLUME:%lldMB\r\n", size); |
| 1086 | } else { |
| 1087 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "SDVOLUME:0MB\r\n"); |
| 1088 | } |
| 1089 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1090 | break; |
| 1091 | } |
| 1092 | default: |
| 1093 | { |
| 1094 | break; |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | return ret; |
| 1099 | } |
| 1100 | |
| 1101 | |
| 1102 | utlReturnCode_T MBTK_AT_SPKTEST_PROCESS(const utlAtParameterOp_T op, |
| 1103 | const char *command_name_p, |
| 1104 | const utlAtParameterValue_P2c parameter_values_p, |
| 1105 | const size_t num_parameters, |
| 1106 | const char *info_text_p, |
| 1107 | unsigned int *xid_p, |
| 1108 | void *arg_p) |
| 1109 | { |
| 1110 | UNUSEDPARAM(command_name_p); |
| 1111 | UNUSEDPARAM(num_parameters); |
| 1112 | UNUSEDPARAM(info_text_p); |
| 1113 | |
| 1114 | utlReturnCode_T ret = utlFAILED; |
| 1115 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1116 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1117 | *xid_p = at_handle; |
| 1118 | |
| 1119 | LOG("MBTK_AT_SPKTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1120 | |
| 1121 | switch(op) |
| 1122 | { |
| 1123 | case TEL_EXT_ACTION_CMD : |
| 1124 | { |
| 1125 | // SDVOLUME:MB |
| 1126 | // OK |
| 1127 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1128 | |
| 1129 | mbtk_at_play(NULL); |
| 1130 | |
| 1131 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio spk test.\r\nBuild time: %s\r\n", |
| 1132 | MBTK_BUILD_TIME); |
| 1133 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1134 | |
| 1135 | break; |
| 1136 | } |
| 1137 | default: |
| 1138 | { |
| 1139 | break; |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | return ret; |
| 1144 | } |
| 1145 | |
| 1146 | utlReturnCode_T MBTK_AT_MICTEST_PROCESS(const utlAtParameterOp_T op, |
| 1147 | const char *command_name_p, |
| 1148 | const utlAtParameterValue_P2c parameter_values_p, |
| 1149 | const size_t num_parameters, |
| 1150 | const char *info_text_p, |
| 1151 | unsigned int *xid_p, |
| 1152 | void *arg_p) |
| 1153 | { |
| 1154 | UNUSEDPARAM(command_name_p); |
| 1155 | UNUSEDPARAM(num_parameters); |
| 1156 | UNUSEDPARAM(info_text_p); |
| 1157 | |
| 1158 | utlReturnCode_T ret = utlFAILED; |
| 1159 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1160 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1161 | *xid_p = at_handle; |
| 1162 | |
| 1163 | LOG("MBTK_AT_MICTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1164 | |
| 1165 | switch(op) |
| 1166 | { |
| 1167 | case TEL_EXT_ACTION_CMD : |
| 1168 | { |
| 1169 | // SDVOLUME:MB |
| 1170 | // OK |
| 1171 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1172 | |
| 1173 | mbtk_at_rec(NULL); |
| 1174 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio record test.\r\nBuild time: %s\r\n", |
| 1175 | MBTK_BUILD_TIME); |
| 1176 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1177 | break; |
| 1178 | } |
| 1179 | default: |
| 1180 | { |
| 1181 | break; |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | return ret; |
| 1186 | } |
| 1187 | |
| 1188 | utlReturnCode_T MBTK_AT_REVTEST_PROCESS(const utlAtParameterOp_T op, |
| 1189 | const char *command_name_p, |
| 1190 | const utlAtParameterValue_P2c parameter_values_p, |
| 1191 | const size_t num_parameters, |
| 1192 | const char *info_text_p, |
| 1193 | unsigned int *xid_p, |
| 1194 | void *arg_p) |
| 1195 | { |
| 1196 | UNUSEDPARAM(command_name_p); |
| 1197 | UNUSEDPARAM(num_parameters); |
| 1198 | UNUSEDPARAM(info_text_p); |
| 1199 | |
| 1200 | utlReturnCode_T ret = utlFAILED; |
| 1201 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1202 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1203 | *xid_p = at_handle; |
| 1204 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1205 | int arg1 = 0; |
| 1206 | |
| 1207 | static bool loopback_running = FALSE; |
| 1208 | |
| 1209 | LOG("MBTK_AT_REVTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1210 | |
| 1211 | switch(op) |
| 1212 | { |
| 1213 | case TEL_EXT_GET_CMD : |
| 1214 | { |
| 1215 | sprintf(resp_buf, "%s : %d\r\n", command_name_p, arg1); |
| 1216 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1217 | break; |
| 1218 | } |
| 1219 | case TEL_EXT_SET_CMD : |
| 1220 | { |
| 1221 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0)) |
| 1222 | { |
| 1223 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1224 | break; |
| 1225 | } |
| 1226 | #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108)) |
| 1227 | if(arg1 == 1) |
| 1228 | { |
| 1229 | system("ubus call audio_if loopback_enable '{\"param0\":1}'"); |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | system("ubus call audio_if loopback_disable"); |
| 1234 | } |
| 1235 | #else |
| 1236 | LOG("MBTK_AT_REVTEST_PROCESS arg1 [%d]", arg1); |
| 1237 | mbtk_at_loopback(arg1); |
| 1238 | //sprintf(resp_buf, "%s : ,\"%s\"\r\n", command_name_p, "TEL_EXT_SET_CMD"); |
| 1239 | #endif |
| 1240 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1241 | break; |
| 1242 | } |
| 1243 | case TEL_EXT_ACTION_CMD : |
| 1244 | { |
| 1245 | if(!loopback_running) { |
| 1246 | #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108)) |
| 1247 | system("ubus call audio_if loopback_enable '{\"param0\":1}'"); |
| 1248 | #else |
| 1249 | mbtk_at_loopback(1); |
| 1250 | #endif |
| 1251 | loopback_running = TRUE; |
| 1252 | } else { |
| 1253 | #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108)) |
| 1254 | system("ubus call audio_if loopback_disable"); |
| 1255 | #else |
| 1256 | mbtk_at_loopback(0); |
| 1257 | #endif |
| 1258 | loopback_running = FALSE; |
| 1259 | } |
| 1260 | //snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio loopback test.\r\nBuild time: %s\r\n", |
| 1261 | // MBTK_BUILD_TIME); |
| 1262 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1263 | break; |
| 1264 | } |
| 1265 | default: |
| 1266 | { |
| 1267 | break; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | return ret; |
| 1272 | } |
| 1273 | |
| 1274 | utlReturnCode_T MBTK_AT_GPIOTEST_PROCESS(const utlAtParameterOp_T op, |
| 1275 | const char *command_name_p, |
| 1276 | const utlAtParameterValue_P2c parameter_values_p, |
| 1277 | const size_t num_parameters, |
| 1278 | const char *info_text_p, |
| 1279 | unsigned int *xid_p, |
| 1280 | void *arg_p) |
| 1281 | { |
| 1282 | UNUSEDPARAM(command_name_p); |
| 1283 | UNUSEDPARAM(num_parameters); |
| 1284 | UNUSEDPARAM(info_text_p); |
| 1285 | |
| 1286 | utlReturnCode_T ret = utlFAILED; |
| 1287 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1288 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1289 | int gnss_support = 0; |
| 1290 | *xid_p = at_handle; |
| 1291 | |
| 1292 | LOG("MBTK_AT_GPIOTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1293 | |
| 1294 | switch(op) |
| 1295 | { |
| 1296 | case TEL_EXT_SET_CMD : |
| 1297 | { |
| 1298 | if(!getExtValue(parameter_values_p, 0, &gnss_support, 0, 1, 0)) |
| 1299 | { |
| 1300 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1301 | break; |
| 1302 | } |
| 1303 | } |
| 1304 | case TEL_EXT_ACTION_CMD : |
| 1305 | { |
| 1306 | if(gpio_test_usable) { |
| 1307 | gpio_test_usable = false; |
| 1308 | } else { // GPIO test is busy. |
| 1309 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_SUPPRESS, 0, NULL); |
| 1310 | break; |
| 1311 | } |
| 1312 | |
| 1313 | #if 1 |
| 1314 | int test_result[MAX_GPIO_TEST_NUM]; |
| 1315 | memset(test_result,0,sizeof(test_result)); |
| 1316 | int result = mbtk_at_gpio((bool)gnss_support, test_result); |
| 1317 | if(result < 0) |
| 1318 | { |
| 1319 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "GPIO TEST FAIL\r\n"); |
| 1320 | } |
| 1321 | else if(result == 0) { |
| 1322 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "ALL GPIO TEST PASS\r\n"); |
| 1323 | } |
| 1324 | else |
| 1325 | { |
| 1326 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1327 | int index; |
| 1328 | sprintf(resp_buf, "GPIOTEST Fail %02d PINs:", result); |
| 1329 | for(index = 0; index < result &&index < MAX_GPIO_TEST_NUM; index++) |
| 1330 | { |
| 1331 | sprintf(resp_buf + strlen(resp_buf), "%03d,", test_result[index]); |
| 1332 | } |
| 1333 | resp_buf[strlen(resp_buf) - 1] = '\r'; |
| 1334 | resp_buf[strlen(resp_buf)] = '\n'; |
| 1335 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1336 | } |
| 1337 | #else |
| 1338 | int fail_count = gpio_test(); |
| 1339 | if(fail_count < 0) { |
| 1340 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "GPIO TEST FAIL\r\n"); |
| 1341 | } else if(fail_count == 0){ |
| 1342 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "ALL GPIO TEST PASS\r\n"); |
| 1343 | } else { |
| 1344 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1345 | int index; |
| 1346 | sprintf(resp_buf, "GPIOTEST Fail %02d PINs:", fail_count); |
| 1347 | for(index = 0; index < MBTK_GPIO_NUM; index++) |
| 1348 | { |
| 1349 | if(!gpio_pins[index].state) { |
| 1350 | sprintf(resp_buf + strlen(resp_buf), "%03d,", gpio_pins[index].gpio); |
| 1351 | } |
| 1352 | } |
| 1353 | resp_buf[strlen(resp_buf) - 1] = '\r'; |
| 1354 | resp_buf[strlen(resp_buf)] = '\n'; |
| 1355 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1356 | } |
| 1357 | #endif |
| 1358 | |
| 1359 | // Set gpio_test_usable to true after 1s. |
| 1360 | #if 0 |
| 1361 | signal(SIGALRM, gpio_timer_alrm_func); |
| 1362 | struct itimerval val; |
| 1363 | // Only time |
| 1364 | val.it_interval.tv_sec = 0; |
| 1365 | val.it_interval.tv_usec = 0; |
| 1366 | // Time |
| 1367 | val.it_value.tv_sec = 1; |
| 1368 | val.it_value.tv_usec = 0; |
| 1369 | if (setitimer(ITIMER_REAL, &val, NULL) == -1) |
| 1370 | { |
| 1371 | LOG("setitimer fail.[errno - %d]",errno); |
| 1372 | } |
| 1373 | #else |
| 1374 | pthread_t gpio_thread_id; |
| 1375 | if (pthread_create(&gpio_thread_id, NULL, gpio_thread_func, NULL) != 0) |
| 1376 | { |
| 1377 | LOG("%s errno: %d (%s)",__func__, errno, strerror(errno)); |
| 1378 | } |
| 1379 | #endif |
| 1380 | break; |
| 1381 | } |
| 1382 | default: |
| 1383 | { |
| 1384 | break; |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | return ret; |
| 1389 | } |
| 1390 | |
| 1391 | utlReturnCode_T MBTK_AT_ADCGETV_PROCESS(const utlAtParameterOp_T op, |
| 1392 | const char *command_name_p, |
| 1393 | const utlAtParameterValue_P2c parameter_values_p, |
| 1394 | const size_t num_parameters, |
| 1395 | const char *info_text_p, |
| 1396 | unsigned int *xid_p, |
| 1397 | void *arg_p) |
| 1398 | { |
| 1399 | UNUSEDPARAM(command_name_p); |
| 1400 | UNUSEDPARAM(num_parameters); |
| 1401 | UNUSEDPARAM(info_text_p); |
| 1402 | |
| 1403 | utlReturnCode_T ret = utlFAILED; |
| 1404 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1405 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1406 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1407 | int arg1 = 0; |
| 1408 | *xid_p = at_handle; |
| 1409 | |
| 1410 | LOG("MBTK_AT_ADCGETV_PROCESS enter with command_op [%s]", op2str(op)); |
| 1411 | |
| 1412 | switch(op) |
| 1413 | { |
| 1414 | case TEL_EXT_ACTION_CMD : |
| 1415 | { |
| 1416 | // SDVOLUME:MB |
| 1417 | // OK |
| 1418 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "ADC Version: %s\r\nBuild time: %s\r\n", |
| 1419 | MBTK_DEVICES_REVISION, MBTK_BUILD_TIME); |
| 1420 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1421 | break; |
| 1422 | } |
| 1423 | case TEL_EXT_SET_CMD : |
| 1424 | { |
| 1425 | int adc_ret; |
| 1426 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 2, 0)) |
| 1427 | { |
| 1428 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1429 | break; |
| 1430 | } |
| 1431 | adc_ret = mbtk_at_adc(arg1); |
| 1432 | LOG("MBTK_AT_ADC_PROCESS adc [%d]", adc_ret); |
| 1433 | sprintf(resp_buf, "%s:%d,%d\r\n", command_name_p, arg1, adc_ret); |
| 1434 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1435 | break; |
| 1436 | } |
| 1437 | default: |
| 1438 | { |
| 1439 | break; |
| 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | return ret; |
| 1444 | } |
| 1445 | |
| 1446 | utlReturnCode_T MBTK_AT_RGMIITEST_PROCESS(const utlAtParameterOp_T op, |
| 1447 | const char *command_name_p, |
| 1448 | const utlAtParameterValue_P2c parameter_values_p, |
| 1449 | const size_t num_parameters, |
| 1450 | const char *info_text_p, |
| 1451 | unsigned int *xid_p, |
| 1452 | void *arg_p) |
| 1453 | { |
| 1454 | UNUSEDPARAM(command_name_p); |
| 1455 | UNUSEDPARAM(num_parameters); |
| 1456 | UNUSEDPARAM(info_text_p); |
| 1457 | |
| 1458 | utlReturnCode_T ret = utlFAILED; |
| 1459 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1460 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1461 | *xid_p = at_handle; |
| 1462 | |
| 1463 | LOG("MBTK_AT_RGMIITEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1464 | |
| 1465 | switch(op) |
| 1466 | { |
| 1467 | case TEL_EXT_ACTION_CMD : |
| 1468 | { |
| 1469 | #if defined(MBTK_PROJECT_T108) |
| 1470 | int result = -1; |
| 1471 | int rgmii_test_num = 0; |
| 1472 | char buf[50] = {0}; |
| 1473 | static char rgmii_flag = 0; |
| 1474 | //mbtk_mdio("eth0", 0, 0x9800, 0xc834); |
| 1475 | //mbtk_mdio("eth0", 0, 0x0, 0xa000); |
| 1476 | for(rgmii_test_num = 0; rgmii_test_num < 3; rgmii_test_num++) |
| 1477 | { |
| 1478 | if(!rgmii_flag) |
| 1479 | { |
| 1480 | system("/bin/mbtk_mdio eth0 0x9800 0xc834"); |
| 1481 | system("/bin/mbtk_mdio eth0 0x0 0xa000"); |
| 1482 | } |
| 1483 | result = mbtk_rgmii_loopback(); |
| 1484 | if(result < 0) |
| 1485 | { |
| 1486 | // |
| 1487 | } |
| 1488 | else |
| 1489 | { |
| 1490 | memcpy(buf, "+RGMIITEST: phy loopback ok", strlen("+RGMIITEST: phy loopback ok")); |
| 1491 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, buf); |
| 1492 | rgmii_flag = 1; |
| 1493 | break; |
| 1494 | } |
| 1495 | } |
| 1496 | |
| 1497 | if(result < 0) |
| 1498 | { |
| 1499 | memcpy(buf, "+RGMIITEST: phy loopback fail", strlen("+RGMIITEST: phy loopback fail")); |
| 1500 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, buf); |
| 1501 | } |
| 1502 | break; |
| 1503 | #endif |
| 1504 | } |
| 1505 | default: |
| 1506 | { |
| 1507 | ret = ATRESP( at_handle, ATCI_RESULT_CODE_CME_ERROR, CME_OPERATION_NOT_SUPPORTED, NULL); |
| 1508 | break; |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | return ret; |
| 1513 | } |
| 1514 | |
| 1515 | utlReturnCode_T MBTK_AT_MGPSC_PROCESS(const utlAtParameterOp_T op, |
| 1516 | const char *command_name_p, |
| 1517 | const utlAtParameterValue_P2c parameter_values_p, |
| 1518 | const size_t num_parameters, |
| 1519 | const char *info_text_p, |
| 1520 | unsigned int *xid_p, |
| 1521 | void *arg_p) |
| 1522 | { |
| 1523 | UNUSEDPARAM(command_name_p); |
| 1524 | UNUSEDPARAM(num_parameters); |
| 1525 | UNUSEDPARAM(info_text_p); |
| 1526 | |
| 1527 | utlReturnCode_T ret = utlFAILED; |
| 1528 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1529 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1530 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1531 | int arg1 = 0; |
| 1532 | *xid_p = at_handle; |
| 1533 | |
| 1534 | LOG("MBTK_AT_MGPSC_PROCESS enter with command_op [%s]", op2str(op)); |
| 1535 | |
| 1536 | switch(op) |
| 1537 | { |
| 1538 | case TEL_EXT_SET_CMD : |
| 1539 | { |
| 1540 | int gnss_ret; |
| 1541 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 11, 0)) |
| 1542 | { |
| 1543 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1544 | break; |
| 1545 | } |
| 1546 | #if 1 |
| 1547 | if (arg1 == 5 || arg1 == 1 || arg1 ==0) |
| 1548 | { |
| 1549 | if (1 == arg1) |
| 1550 | { |
| 1551 | gnss_ret = mbtk_mgpsc_set(arg1); |
| 1552 | if (gnss_ret < 0) |
| 1553 | { |
| 1554 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: init fail.\r\n"); |
| 1555 | } |
| 1556 | else |
| 1557 | { |
| 1558 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "+GPS: init success.\r\n"); |
| 1559 | } |
| 1560 | } |
| 1561 | else if (arg1 == 5) |
| 1562 | { |
| 1563 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1564 | } |
| 1565 | else |
| 1566 | { |
| 1567 | gnss_ret = mbtk_mgpsc_set(arg1); |
| 1568 | if (gnss_ret < 0) |
| 1569 | { |
| 1570 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: deinit fail.\r\n"); |
| 1571 | } |
| 1572 | else |
| 1573 | { |
| 1574 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "+GPS: deinit success.\r\n"); |
| 1575 | } } |
| 1576 | } |
| 1577 | else |
| 1578 | { |
| 1579 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1580 | break; |
| 1581 | } |
| 1582 | #else |
| 1583 | if(1 == arg1 || 11 == arg1 || 10 == arg1 || 9 == arg1) |
| 1584 | gnss_ret = MBTK_FUNC(mbtk_at_gnss)(arg1, at_gnss_handler_function); |
| 1585 | else if (6 == arg1) |
| 1586 | gnss_ret = at_gnss_firmware_update(); |
| 1587 | else |
| 1588 | gnss_ret = MBTK_FUNC(mbtk_at_gnss)(arg1, NULL); |
| 1589 | |
| 1590 | LOG("%s gnss [%d]", __FUNCTION__, gnss_ret); |
| 1591 | sprintf(resp_buf, "%s:%d,%d\r\n", command_name_p, arg1, gnss_ret); |
| 1592 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1593 | #endif |
| 1594 | |
| 1595 | break; |
| 1596 | } |
| 1597 | default: |
| 1598 | { |
| 1599 | break; |
| 1600 | } |
| 1601 | } |
| 1602 | |
| 1603 | return ret; |
| 1604 | } |
| 1605 | |
| 1606 | utlReturnCode_T MBTK_AT_CGNETLED_PROCESS(const utlAtParameterOp_T op, |
| 1607 | const char *command_name_p, |
| 1608 | const utlAtParameterValue_P2c parameter_values_p, |
| 1609 | const size_t num_parameters, |
| 1610 | const char *info_text_p, |
| 1611 | unsigned int *xid_p, |
| 1612 | void *arg_p) |
| 1613 | { |
| 1614 | UNUSEDPARAM(command_name_p); |
| 1615 | UNUSEDPARAM(num_parameters); |
| 1616 | UNUSEDPARAM(info_text_p); |
| 1617 | |
| 1618 | utlReturnCode_T ret = utlFAILED; |
| 1619 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1620 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1621 | *xid_p = at_handle; |
| 1622 | |
| 1623 | LOG("MBTK_AT_CGNETLED_PROCESS enter with command_op [%s]", op2str(op)); |
| 1624 | switch(op) |
| 1625 | { |
| 1626 | case TEL_EXT_SET_CMD : |
| 1627 | { |
| 1628 | int led_switch; |
| 1629 | if(!getExtValue(parameter_values_p, 0, &led_switch, 0, 1, 0)) |
| 1630 | { |
| 1631 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1632 | break; |
| 1633 | } |
| 1634 | |
| 1635 | if(led_switch == 0 || led_switch == 1) { |
| 1636 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1637 | } |
| 1638 | break; |
| 1639 | } |
| 1640 | default: |
| 1641 | { |
| 1642 | break; |
| 1643 | } |
| 1644 | } |
| 1645 | |
| 1646 | return ret; |
| 1647 | } |
| 1648 | |
| 1649 | utlReturnCode_T MBTK_AT_SYSSLEEP_PROCESS(const utlAtParameterOp_T op, |
| 1650 | const char *command_name_p, |
| 1651 | const utlAtParameterValue_P2c parameter_values_p, |
| 1652 | const size_t num_parameters, |
| 1653 | const char *info_text_p, |
| 1654 | unsigned int *xid_p, |
| 1655 | void *arg_p) |
| 1656 | { |
| 1657 | UNUSEDPARAM(command_name_p); |
| 1658 | UNUSEDPARAM(num_parameters); |
| 1659 | UNUSEDPARAM(info_text_p); |
| 1660 | |
| 1661 | utlReturnCode_T ret = utlFAILED; |
| 1662 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1663 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1664 | *xid_p = at_handle; |
| 1665 | |
| 1666 | TelAtParserID origParserId = *(TelAtParserID *)arg_p; |
| 1667 | |
| 1668 | LOG("MBTK_AT_SYSSLEEP_PROCESS enter with command_op [%s]", op2str(op)); |
| 1669 | switch(op) |
| 1670 | { |
| 1671 | case TEL_EXT_SET_CMD: |
| 1672 | case TEL_EXT_ACTION_CMD: |
| 1673 | { |
| 1674 | // [ -e /sys/class/devfreq/devfreq-ddr/polling_interval ] && { |
| 1675 | // echo 50 > /sys/class/devfreq/devfreq-ddr/polling_interval |
| 1676 | // } |
| 1677 | |
| 1678 | // [ -e /sys/power/autosleep ] && { |
| 1679 | // echo booting 8000000000 > /sys/power/wake_lock |
| 1680 | // echo mem > /sys/power/autosleep |
| 1681 | // } |
| 1682 | |
| 1683 | //close GPS set gpio 21/118: out / 0 |
| 1684 | int result = -1; |
| 1685 | result = mbtk_system_sleep(); |
| 1686 | if(result != 0) |
| 1687 | { |
| 1688 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1689 | } |
| 1690 | else |
| 1691 | { |
| 1692 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1693 | } |
| 1694 | #if 0 |
| 1695 | int ubus_ret = 0; |
| 1696 | ubus_ret = invoke_reply_data_cb(origParserId, "gps", "gnss_deinit", NULL, (ubus_data_handler_t *)gps_usr_callback_hdl, &at_handle, 4000); |
| 1697 | if(ubus_ret < 0) |
| 1698 | { |
| 1699 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_SUPPRESS, 0, "BUSY"); |
| 1700 | break; |
| 1701 | } |
| 1702 | else if(ubus_ret > 0) |
| 1703 | { |
| 1704 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1705 | break; |
| 1706 | } |
| 1707 | #ifdef MBTK_PROJECT_L508 |
| 1708 | system("echo 0 > /sys/class/gpio/gpio119/value"); |
| 1709 | #else |
| 1710 | #ifdef MBTK_PROJECT_PN1803 |
| 1711 | system("echo 0 > /sys/class/gpio/gpio119/value"); |
| 1712 | #else |
| 1713 | #ifdef MBTK_PROJECT_L509 |
| 1714 | system("echo 0 > /sys/class/gpio/gpio120/value"); |
| 1715 | #endif |
| 1716 | #endif |
| 1717 | #endif |
| 1718 | |
| 1719 | #ifdef MBTK_PROJECT_L508_X6 |
| 1720 | //close Ldo6 |
| 1721 | system("i2cset -y -f 2 0x31 0x18 0x0f"); |
| 1722 | //GPS_WAKE_HOST to GPIO |
| 1723 | system("hwacc w 0xd401e198 0x1040"); |
| 1724 | //HOST_WAKE_GPS to GPIO |
| 1725 | //system("hwacc w 0xd401e0c0 0x1040"); |
| 1726 | //gpio34 to GPIO |
| 1727 | #if 1 |
| 1728 | system("hwacc w 0xd401e164 0x1040"); |
| 1729 | system("hwacc w 0xd401e166 0x1040"); |
| 1730 | system("hwacc w 0xd401e1b4 0x1040"); |
| 1731 | |
| 1732 | system("hwacc w 0xd401e2ec 0xa441"); |
| 1733 | system("hwacc w 0xd401e2f0 0xa441"); |
| 1734 | system("hwacc w 0xd401e2f4 0xa441"); |
| 1735 | system("hwacc w 0xd401e2f8 0xa441"); |
| 1736 | system("hwacc w 0xd401e2fc 0xa441"); |
| 1737 | system("hwacc w 0xd401e300 0xa441"); |
| 1738 | |
| 1739 | if(one_gpio_export(117, 2)) |
| 1740 | { |
| 1741 | LOG("GPIO SET ERROR."); |
| 1742 | } |
| 1743 | if(one_gpio_export(117, 0)) |
| 1744 | { |
| 1745 | LOG("GPIO SET ERROR."); |
| 1746 | } |
| 1747 | if(one_gpio_export(119, 2)) |
| 1748 | { |
| 1749 | LOG("GPIO SET ERROR."); |
| 1750 | } |
| 1751 | if(one_gpio_export(119, 0)) |
| 1752 | { |
| 1753 | LOG("GPIO SET ERROR."); |
| 1754 | } |
| 1755 | |
| 1756 | |
| 1757 | if(one_gpio_export(127, 2)) |
| 1758 | { |
| 1759 | LOG("GPIO SET ERROR."); |
| 1760 | } |
| 1761 | if(one_gpio_export(127, 0)) |
| 1762 | { |
| 1763 | LOG("GPIO SET ERROR."); |
| 1764 | } |
| 1765 | if(one_gpio_export(34, 2)) |
| 1766 | { |
| 1767 | LOG("GPIO SET ERROR."); |
| 1768 | } |
| 1769 | if(one_gpio_export(34, 0)) |
| 1770 | { |
| 1771 | LOG("GPIO SET ERROR."); |
| 1772 | } |
| 1773 | if(one_gpio_export(33, 2)) |
| 1774 | { |
| 1775 | LOG("GPIO SET ERROR."); |
| 1776 | } |
| 1777 | if(one_gpio_export(33, 0)) |
| 1778 | { |
| 1779 | LOG("GPIO SET ERROR."); |
| 1780 | } |
| 1781 | if(one_gpio_export(54, 2)) |
| 1782 | { |
| 1783 | LOG("GPIO SET ERROR."); |
| 1784 | } |
| 1785 | if(one_gpio_export(54, 0)) |
| 1786 | { |
| 1787 | LOG("GPIO SET ERROR."); |
| 1788 | } |
| 1789 | |
| 1790 | #endif |
| 1791 | #endif |
| 1792 | |
| 1793 | #ifdef MBTK_PROJECT_T108 |
| 1794 | |
| 1795 | #else |
| 1796 | if(one_gpio_export(21, 2)) |
| 1797 | { |
| 1798 | LOG("GPIO SET ERROR."); |
| 1799 | } |
| 1800 | if(one_gpio_export(21, 0)) |
| 1801 | { |
| 1802 | LOG("GPIO SET ERROR."); |
| 1803 | } |
| 1804 | if(one_gpio_export(118, 2)) |
| 1805 | { |
| 1806 | LOG("GPIO SET ERROR."); |
| 1807 | } |
| 1808 | if(one_gpio_export(118, 0)) |
| 1809 | { |
| 1810 | LOG("GPIO SET ERROR."); |
| 1811 | } |
| 1812 | #endif |
| 1813 | // echo off > /sys/devices/mbtk-dev-op.10/gps_power && echo mem > /sys/power/autosleep |
| 1814 | // echo 1 > /sys/devices/asr-rfkill.0/pwr_ctrl && sleep 2 && echo 0 > /sys/devices/asr-rfkill.0/pwr_ctrl |
| 1815 | |
| 1816 | if(!access("/sys/power/autosleep", W_OK)) |
| 1817 | system("echo mem > /sys/power/autosleep"); |
| 1818 | else |
| 1819 | LOG("/sys/power/autosleep can not write."); |
| 1820 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1821 | #endif |
| 1822 | break; |
| 1823 | } |
| 1824 | default: |
| 1825 | { |
| 1826 | break; |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | return ret; |
| 1831 | } |
| 1832 | |
| 1833 | static int port_config(mbtk_port_type_enum type, mbtk_port_mode_enum mode) { |
| 1834 | |
| 1835 | char type_buff[32] = {0}; |
| 1836 | char mode_buff[32] = {0}; |
| 1837 | switch(type) |
| 1838 | { |
| 1839 | case MBTK_PORT_TYPE_UART1: |
| 1840 | strcpy(type_buff, "persist.mbtk.dev_ttyS1"); |
| 1841 | break; |
| 1842 | case MBTK_PORT_TYPE_USB1: |
| 1843 | strcpy(type_buff, "persist.mbtk.dev_ttyGS0"); |
| 1844 | break; |
| 1845 | case MBTK_PORT_TYPE_USB2: |
| 1846 | strcpy(type_buff, "persist.mbtk.dev_ttymodem0"); |
| 1847 | break; |
| 1848 | default: |
| 1849 | return -1; |
| 1850 | } |
| 1851 | switch(mode) |
| 1852 | { |
| 1853 | case MBTK_PORT_MODE_AT: |
| 1854 | strcpy(mode_buff, "at"); |
| 1855 | break; |
| 1856 | case MBTK_PORT_MODE_ADB: |
| 1857 | strcpy(mode_buff, "adb"); |
| 1858 | break; |
| 1859 | case MBTK_PORT_MODE_CUSTOM: |
| 1860 | strcpy(mode_buff, "custom"); |
| 1861 | break; |
| 1862 | default: |
| 1863 | return -1; |
| 1864 | } |
| 1865 | return property_set(type_buff, mode_buff); |
| 1866 | } |
| 1867 | |
| 1868 | utlReturnCode_T MBTK_AT_MPORTCFG_PROCESS(const utlAtParameterOp_T op, |
| 1869 | const char *command_name_p, |
| 1870 | const utlAtParameterValue_P2c parameter_values_p, |
| 1871 | const size_t num_parameters, |
| 1872 | const char *info_text_p, |
| 1873 | unsigned int *xid_p, |
| 1874 | void *arg_p) |
| 1875 | { |
| 1876 | UNUSEDPARAM(command_name_p); |
| 1877 | UNUSEDPARAM(num_parameters); |
| 1878 | UNUSEDPARAM(info_text_p); |
| 1879 | |
| 1880 | utlReturnCode_T ret = utlFAILED; |
| 1881 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1882 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1883 | *xid_p = at_handle; |
| 1884 | char resp_buf[1024] = {0}; |
| 1885 | |
| 1886 | LOG("MBTK_AT_MPORTCFG_PROCESS enter with command_op [%s]", op2str(op)); |
| 1887 | switch(op) |
| 1888 | { |
| 1889 | case TEL_EXT_SET_CMD: |
| 1890 | { |
| 1891 | int arg; |
| 1892 | if(!getExtValue(parameter_values_p, 0, &arg, 0, 2, 0)) |
| 1893 | { |
| 1894 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1895 | break; |
| 1896 | } |
| 1897 | mbtk_port_type_enum type = (mbtk_port_type_enum)arg; |
| 1898 | if(!getExtValue(parameter_values_p, 1, &arg, 0, 2, 0)) |
| 1899 | { |
| 1900 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1901 | break; |
| 1902 | } |
| 1903 | mbtk_port_mode_enum mode = (mbtk_port_mode_enum)arg; |
| 1904 | |
| 1905 | if(port_config(type, mode)) { |
| 1906 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1907 | } else { |
| 1908 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1909 | } |
| 1910 | |
| 1911 | break; |
| 1912 | } |
| 1913 | case TEL_EXT_GET_CMD : |
| 1914 | { |
| 1915 | int len = 0; |
| 1916 | char port_config[32] = {0}; |
| 1917 | property_get("persist.mbtk.dev_ttyS1", port_config, "at"); |
| 1918 | if(!strcmp(port_config, "adb")) { |
| 1919 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_ADB); |
| 1920 | } else if(!strcmp(port_config, "custom")) { |
| 1921 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_CUSTOM); |
| 1922 | } else { |
| 1923 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_AT); |
| 1924 | } |
| 1925 | |
| 1926 | memset(port_config, 0, 32); |
| 1927 | property_get("persist.mbtk.dev_ttyGS0", port_config, "at"); |
| 1928 | if(!strcmp(port_config, "adb")) { |
| 1929 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_ADB); |
| 1930 | } else if(!strcmp(port_config, "custom")) { |
| 1931 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_CUSTOM); |
| 1932 | } else { |
| 1933 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_AT); |
| 1934 | } |
| 1935 | |
| 1936 | memset(port_config, 0, 32); |
| 1937 | property_get("persist.mbtk.dev_ttymodem0", port_config, "at"); |
| 1938 | if(!strcmp(port_config, "adb")) { |
| 1939 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_ADB); |
| 1940 | } else if(!strcmp(port_config, "custom")) { |
| 1941 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_CUSTOM); |
| 1942 | } else { |
| 1943 | len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_AT); |
| 1944 | } |
| 1945 | |
| 1946 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1947 | break; |
| 1948 | } |
| 1949 | default: |
| 1950 | { |
| 1951 | break; |
| 1952 | } |
| 1953 | } |
| 1954 | |
| 1955 | return ret; |
| 1956 | } |
| 1957 | |
| 1958 | utlReturnCode_T MBTK_AT_MURCECHO_PROCESS(const utlAtParameterOp_T op, |
| 1959 | const char *command_name_p, |
| 1960 | const utlAtParameterValue_P2c parameter_values_p, |
| 1961 | const size_t num_parameters, |
| 1962 | const char *info_text_p, |
| 1963 | unsigned int *xid_p, |
| 1964 | void *arg_p) |
| 1965 | { |
| 1966 | UNUSEDPARAM(command_name_p); |
| 1967 | UNUSEDPARAM(num_parameters); |
| 1968 | UNUSEDPARAM(info_text_p); |
| 1969 | |
| 1970 | utlReturnCode_T ret = utlFAILED; |
| 1971 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 1972 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 1973 | *xid_p = At_handle; |
| 1974 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 1975 | |
| 1976 | static int arg1 = 0; |
| 1977 | |
| 1978 | LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 1979 | |
| 1980 | switch(op) |
| 1981 | { |
| 1982 | case TEL_EXT_GET_CMD : |
| 1983 | { |
| 1984 | sprintf(resp_buf, "%s : %d\r\n", command_name_p, mbtk_urc_enable); |
| 1985 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 1986 | break; |
| 1987 | } |
| 1988 | case TEL_EXT_SET_CMD : |
| 1989 | { |
| 1990 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0)) |
| 1991 | { |
| 1992 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 1993 | break; |
| 1994 | } |
| 1995 | |
| 1996 | mbtk_urc_enable = (bool)arg1; |
| 1997 | |
| 1998 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 1999 | break; |
| 2000 | } |
| 2001 | default: |
| 2002 | { |
| 2003 | break; |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | return ret; |
| 2008 | } |
| 2009 | |
| 2010 | RETURNCODE_T MBTK_AT_READVER_PROCESS( const utlAtParameterOp_T op, |
| 2011 | const char *command_name_p, |
| 2012 | const utlAtParameterValue_P2c parameter_values_p, |
| 2013 | const size_t num_parameters, |
| 2014 | const char *info_text_p, |
| 2015 | unsigned int *xid_p, |
| 2016 | void *arg_p) |
| 2017 | { |
| 2018 | |
| 2019 | UNUSEDPARAM(command_name_p); |
| 2020 | UNUSEDPARAM(parameter_values_p); |
| 2021 | UNUSEDPARAM(num_parameters); |
| 2022 | UNUSEDPARAM(info_text_p); |
| 2023 | |
| 2024 | /* |
| 2025 | * Put parser index into the variable |
| 2026 | */ |
| 2027 | RETURNCODE_T rc = INITIAL_RETURN_CODE; |
| 2028 | CiReturnCode ret = CIRC_FAIL; |
| 2029 | UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p); |
| 2030 | |
| 2031 | *xid_p = atHandle; |
| 2032 | // DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle); |
| 2033 | |
| 2034 | /* |
| 2035 | * process operation |
| 2036 | */ |
| 2037 | switch ( op ) |
| 2038 | { |
| 2039 | case TEL_EXT_ACTION_CMD: /* AT*READVER */ |
| 2040 | { |
| 2041 | char tmpBuf[512]; |
| 2042 | #if 0 |
| 2043 | sprintf(tmpBuf, "*READVER: \r\nrelease_version:%s\r\nrelease_time:%s\r\n", SYSTEM_RELEASE_NAME, SYSTEM_RELEASE_CREATION_DATE); |
| 2044 | #else |
| 2045 | { |
| 2046 | char rel_version[128] = {0}; |
| 2047 | char sdk[64] = {0}; |
| 2048 | char rel_date[64] = {0}; |
| 2049 | char dsp_version[128]={0}; |
| 2050 | char dsp_date[64]={0}; |
| 2051 | char rf_version[128] = {0}; |
| 2052 | int num = 0; |
| 2053 | |
| 2054 | char internalRevisionId[400 + 1] = {0}; |
| 2055 | char buildTimeStr[100 + 1] = {0}; |
| 2056 | |
| 2057 | //GetDspFWVersionAndDate(dsp_version1,dsp_date1); |
| 2058 | //p_string = GetRFBinFWVersion(); |
| 2059 | //p_string2 = GetRFBinFWDate(); |
| 2060 | property_get("dev.cp.rel.revision", rel_version, "NULL"); |
| 2061 | property_get("dev.cp.dsp.revision", dsp_version, "NULL"); |
| 2062 | property_get("dev.cp.rf.revision", rf_version, "NULL"); |
| 2063 | property_get("dev.cp.rel.time", rel_date, "NULL"); |
| 2064 | property_get("dev.cp.dsp.time", dsp_date, "NULL"); |
| 2065 | |
| 2066 | #if 1 |
| 2067 | if(strncmp(rel_version, "NULL", strlen("NULL")) != 0) |
| 2068 | { |
| 2069 | char *p1 = NULL; |
| 2070 | p1 = strstr(rel_version, "SDK"); |
| 2071 | if(p1 != NULL) |
| 2072 | { |
| 2073 | memcpy(sdk, p1, strlen(p1)); |
| 2074 | p1 = strstr(sdk, "_"); |
| 2075 | if(p1 != NULL) |
| 2076 | { |
| 2077 | *p1 = '\0'; |
| 2078 | } |
| 2079 | } |
| 2080 | else |
| 2081 | { |
| 2082 | strcpy(sdk, "NULL"); |
| 2083 | } |
| 2084 | } |
| 2085 | else |
| 2086 | { |
| 2087 | strcpy(sdk, "NULL"); |
| 2088 | } |
| 2089 | #endif |
| 2090 | |
| 2091 | sprintf(tmpBuf, "*READVER: \r\nRelease_Version: %s (SDK %s)\r\nRelease_Time: %s\r\n(DSP: %s %s)\r\n(RF: %s %s)\r\n(HW: %s by %s)\r\n", |
| 2092 | rel_version,sdk,rel_date, |
| 2093 | dsp_version,dsp_date, |
| 2094 | rf_version,"NULL", |
| 2095 | "NULL","NULL"); |
| 2096 | } |
| 2097 | #endif |
| 2098 | ret = ATRESP( atHandle, ATCI_RESULT_CODE_OK, 0, tmpBuf); |
| 2099 | break; |
| 2100 | } |
| 2101 | |
| 2102 | |
| 2103 | default: |
| 2104 | ret = ATRESP( atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_OPERATION_NOT_SUPPORTED, NULL ); |
| 2105 | break; |
| 2106 | } |
| 2107 | |
| 2108 | |
| 2109 | rc = HANDLE_RETURN_VALUE(ret); |
| 2110 | return(rc); |
| 2111 | } |
| 2112 | |
| 2113 | utlReturnCode_T MBTK_AT_CGDRT_PROCESS(const utlAtParameterOp_T op, |
| 2114 | const char *command_name_p, |
| 2115 | const utlAtParameterValue_P2c parameter_values_p, |
| 2116 | const size_t num_parameters, |
| 2117 | const char *info_text_p, |
| 2118 | unsigned int *xid_p, |
| 2119 | void *arg_p) |
| 2120 | { |
| 2121 | UNUSEDPARAM(command_name_p); |
| 2122 | UNUSEDPARAM(num_parameters); |
| 2123 | UNUSEDPARAM(info_text_p); |
| 2124 | |
| 2125 | utlReturnCode_T ret = utlFAILED; |
| 2126 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 2127 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 2128 | *xid_p = At_handle; |
| 2129 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 2130 | |
| 2131 | static int mode = 0; |
| 2132 | static int cert = 0; |
| 2133 | |
| 2134 | LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 2135 | |
| 2136 | switch(op) |
| 2137 | { |
| 2138 | case TEL_EXT_GET_CMD : |
| 2139 | { |
| 2140 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 2141 | break; |
| 2142 | } |
| 2143 | case TEL_EXT_SET_CMD : |
| 2144 | { |
| 2145 | if(!getExtValue(parameter_values_p, 0, &mode, 0, 139, 0)) |
| 2146 | { |
| 2147 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2148 | break; |
| 2149 | } |
| 2150 | |
| 2151 | if(!getExtValue(parameter_values_p, 1, &cert, 0, 1, 0)) |
| 2152 | { |
| 2153 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2154 | break; |
| 2155 | } |
| 2156 | |
| 2157 | |
| 2158 | if(cert) //out |
| 2159 | { |
| 2160 | ret = one_gpio_export(mode, 2); |
| 2161 | } |
| 2162 | else //in |
| 2163 | { |
| 2164 | ret = one_gpio_export(mode, 3); |
| 2165 | } |
| 2166 | |
| 2167 | |
| 2168 | if(ret) |
| 2169 | { |
| 2170 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2171 | } |
| 2172 | else |
| 2173 | { |
| 2174 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 2175 | } |
| 2176 | |
| 2177 | break; |
| 2178 | } |
| 2179 | default: |
| 2180 | { |
| 2181 | break; |
| 2182 | } |
| 2183 | } |
| 2184 | |
| 2185 | return ret; |
| 2186 | } |
| 2187 | |
| 2188 | utlReturnCode_T MBTK_AT_CGSETV_PROCESS(const utlAtParameterOp_T op, |
| 2189 | const char *command_name_p, |
| 2190 | const utlAtParameterValue_P2c parameter_values_p, |
| 2191 | const size_t num_parameters, |
| 2192 | const char *info_text_p, |
| 2193 | unsigned int *xid_p, |
| 2194 | void *arg_p) |
| 2195 | { |
| 2196 | UNUSEDPARAM(command_name_p); |
| 2197 | UNUSEDPARAM(num_parameters); |
| 2198 | UNUSEDPARAM(info_text_p); |
| 2199 | |
| 2200 | utlReturnCode_T ret = utlFAILED; |
| 2201 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 2202 | unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index); |
| 2203 | *xid_p = At_handle; |
| 2204 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 2205 | |
| 2206 | static int mode = 0; |
| 2207 | static int cert = 0; |
| 2208 | |
| 2209 | LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op)); |
| 2210 | |
| 2211 | switch(op) |
| 2212 | { |
| 2213 | case TEL_EXT_SET_CMD : |
| 2214 | { |
| 2215 | if(!getExtValue(parameter_values_p, 0, &mode, 0, 139, 0)) |
| 2216 | { |
| 2217 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2218 | break; |
| 2219 | } |
| 2220 | |
| 2221 | if(!getExtValue(parameter_values_p, 1, &cert, 0, 1, 0)) |
| 2222 | { |
| 2223 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2224 | break; |
| 2225 | } |
| 2226 | |
| 2227 | if(cert) //hight |
| 2228 | { |
| 2229 | ret = one_gpio_export(mode, 1); |
| 2230 | } |
| 2231 | else //low |
| 2232 | { |
| 2233 | ret = one_gpio_export(mode, 0); |
| 2234 | } |
| 2235 | |
| 2236 | |
| 2237 | if(ret) |
| 2238 | { |
| 2239 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2240 | } |
| 2241 | else |
| 2242 | { |
| 2243 | ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 2244 | } |
| 2245 | |
| 2246 | break; |
| 2247 | } |
| 2248 | default: |
| 2249 | { |
| 2250 | break; |
| 2251 | } |
| 2252 | } |
| 2253 | |
| 2254 | return ret; |
| 2255 | } |
| 2256 | |
| 2257 | |
| 2258 | utlReturnCode_T MBTK_AT_MDUMP_PROCESS(const utlAtParameterOp_T op, |
| 2259 | const char *command_name_p, |
| 2260 | const utlAtParameterValue_P2c parameter_values_p, |
| 2261 | const size_t num_parameters, |
| 2262 | const char *info_text_p, |
| 2263 | unsigned int *xid_p, |
| 2264 | void *arg_p) |
| 2265 | { |
| 2266 | UNUSEDPARAM(command_name_p); |
| 2267 | UNUSEDPARAM(num_parameters); |
| 2268 | UNUSEDPARAM(info_text_p); |
| 2269 | |
| 2270 | utlReturnCode_T ret = utlFAILED; |
| 2271 | TelAtParserID sAtp_index = *(TelAtParserID *)arg_p; |
| 2272 | unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index); |
| 2273 | char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0}; |
| 2274 | int arg1 = 0; |
| 2275 | *xid_p = at_handle; |
| 2276 | |
| 2277 | LOG("MBTK_AT_MDUMP_PROCESS enter with command_op [%s]", op2str(op)); |
| 2278 | |
| 2279 | switch(op) |
| 2280 | { |
| 2281 | case TEL_EXT_GET_CMD : |
| 2282 | { |
| 2283 | char dump[10]; |
| 2284 | memset(dump, 0, 10); |
| 2285 | property_get("persist.mbtk.dump", dump, "0"); |
| 2286 | snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "+MDUMP: %d\r\n", atoi(dump)); |
| 2287 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf); |
| 2288 | break; |
| 2289 | } |
| 2290 | case TEL_EXT_SET_CMD : |
| 2291 | { |
| 2292 | int adc_ret; |
| 2293 | if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0)) |
| 2294 | { |
| 2295 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2296 | break; |
| 2297 | } |
| 2298 | char dump[10]; |
| 2299 | memset(dump, 0, 10); |
| 2300 | if(arg1 == 1) { |
| 2301 | memcpy(dump, "1", 1); |
| 2302 | } else { |
| 2303 | memcpy(dump, "0", 1); |
| 2304 | } |
| 2305 | if(property_set("persist.mbtk.dump", dump)) |
| 2306 | { |
| 2307 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL); |
| 2308 | } else { |
| 2309 | ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL); |
| 2310 | } |
| 2311 | break; |
| 2312 | } |
| 2313 | default: |
| 2314 | { |
| 2315 | break; |
| 2316 | } |
| 2317 | } |
| 2318 | |
| 2319 | return ret; |
| 2320 | } |
| 2321 | |
| 2322 | |