b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <errno.h> |
| 5 | #include <sys/socket.h> |
| 6 | #include <sys/un.h> |
| 7 | #include <netinet/in.h> |
| 8 | #include <pthread.h> |
| 9 | #include <sys/epoll.h> |
| 10 | #include <fcntl.h> |
| 11 | #include <signal.h> |
| 12 | |
| 13 | #include "mbtk_type.h" |
| 14 | #include "mbtk_ril.h" |
| 15 | #include "atchannel.h" |
| 16 | #include "at_tok.h" |
| 17 | #include "mbtk_utils.h" |
| 18 | #include "ril_info.h" |
| 19 | |
| 20 | void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len); |
| 21 | |
| 22 | /* |
| 23 | AT+CMGF? |
| 24 | +CMGF: 0 |
| 25 | |
| 26 | OK |
| 27 | |
| 28 | */ |
| 29 | static int req_cmgf_get(int *state, int *cme_err) |
| 30 | { |
| 31 | ATResponse *response = NULL; |
| 32 | char *tmp_ptr = NULL; |
| 33 | int err = at_send_command_singleline("AT+CMGF?", "", &response); |
| 34 | |
| 35 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 36 | *cme_err = at_get_cme_error(response); |
| 37 | goto exit; |
| 38 | } |
| 39 | |
| 40 | char *line = response->p_intermediates->line; |
| 41 | printf("req_cmgf_get() ---line:%s\n", line); |
| 42 | char* ptr = strstr(line, "+CMGF: "); |
| 43 | printf("req_cmgf_get() ---ptr:%s\n",ptr); |
| 44 | if(ptr) |
| 45 | { |
| 46 | *state = atoi(ptr + strlen("+CMGF: ")); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | err = -1; |
| 51 | } |
| 52 | exit: |
| 53 | at_response_free(response); |
| 54 | return err; |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | AT+CMGF=0" |
| 59 | or |
| 60 | AT+CMGF=1" |
| 61 | |
| 62 | OK |
| 63 | */ |
| 64 | static int req_cmgf_set(int state, int *cme_err) |
| 65 | { |
| 66 | printf("req_cmgf_set()-------------start\n"); |
| 67 | printf("state:%d\n",state); |
| 68 | ATResponse *response = NULL; |
| 69 | char cmd[30] = {0}; |
| 70 | if(state) |
| 71 | { |
| 72 | strcpy(cmd, "AT+CMGF=1"); |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | strcpy(cmd, "AT+CMGF=0"); |
| 77 | } |
| 78 | |
| 79 | printf("req_cmgf_set()----cmd:%s\n", cmd); |
| 80 | int err = at_send_command(cmd, &response); |
| 81 | |
| 82 | if (err < 0 || response->success == 0) { |
| 83 | *cme_err = at_get_cme_error(response); |
| 84 | goto exit; |
| 85 | } |
| 86 | |
| 87 | err = 0; |
| 88 | exit: |
| 89 | at_response_free(response); |
| 90 | return err; |
| 91 | } |
| 92 | |
| 93 | /*set AT+CNMI=1,2*/ |
| 94 | static int req_cnmi_set(int *cme_err) |
| 95 | { |
| 96 | printf("req_cnmi_set()-------------start3\n"); |
| 97 | ATResponse *response = NULL; |
| 98 | char cmd[30] = {0}; |
| 99 | |
| 100 | strcpy(cmd, "AT+CNMI=1,2"); |
| 101 | |
| 102 | printf("req_cnmi_set()----cmd:%s\n", cmd); |
| 103 | int err = at_send_command(cmd, &response); |
| 104 | |
| 105 | if (err < 0 || response->success == 0) { |
| 106 | printf("err:%d, response->success:%d \n", err, response->success); |
| 107 | *cme_err = at_get_cme_error(response); |
| 108 | goto exit; |
| 109 | } |
| 110 | |
| 111 | err = 0; |
| 112 | exit: |
| 113 | at_response_free(response); |
| 114 | printf("exit,err:%d\n", err); |
| 115 | return err; |
| 116 | } |
| 117 | |
| 118 | /* |
| 119 | AT+CPMS? |
| 120 | |
| 121 | +CPMS: "SM",15,50,"SM",15,50,"SM",15,50 |
| 122 | |
| 123 | OK |
| 124 | |
| 125 | */ |
| 126 | static int req_cpms_get(char *reg, int *cme_err) |
| 127 | { |
| 128 | printf("req_cpms_get------------start(3)\n"); |
| 129 | ATResponse *response = NULL; |
| 130 | char *tmp_ptr = NULL; |
| 131 | int err = at_send_command_singleline("AT+CPMS?", "", &response); |
| 132 | |
| 133 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 134 | *cme_err = at_get_cme_error(response); |
| 135 | goto exit; |
| 136 | } |
| 137 | |
| 138 | ATLine* lines_ptr = response->p_intermediates; |
| 139 | char *line = NULL; |
| 140 | int len = 0; |
| 141 | while(lines_ptr) |
| 142 | { |
| 143 | line = lines_ptr->line; |
| 144 | if(line ==NULL) |
| 145 | { |
| 146 | printf("line is null----------------------\n"); |
| 147 | } |
| 148 | |
| 149 | printf("-----------line:%s, strlen:%d, len:%d----------\n", line, strlen(line), len); |
| 150 | memcpy(reg+len, line, strlen(line)); |
| 151 | len += strlen(line); |
| 152 | lines_ptr = lines_ptr->p_next; |
| 153 | } |
| 154 | |
| 155 | printf("cpms_get()------reg:%s\n", reg); |
| 156 | |
| 157 | exit: |
| 158 | at_response_free(response); |
| 159 | return err; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | |
| 164 | /* |
| 165 | AT+CPMS=<mem1>[,<mem2>[,<mem3>]] |
| 166 | AT+CPMS="ME","ME","ME" |
| 167 | |
| 168 | +CPMS: 14,50,14,50,14,50 |
| 169 | |
| 170 | OK |
| 171 | |
| 172 | */ |
| 173 | static int req_cpms_set(const char *mem, char *reg, int len, int *cme_err) |
| 174 | { |
| 175 | printf("req_cpms_set(2)----------------start\n"); |
| 176 | printf("mem:%s\n", mem); |
| 177 | ATResponse *response = NULL; |
| 178 | char cmd[30] = {0}; |
| 179 | int err = 0; |
| 180 | char data[20] = {0}; |
| 181 | |
| 182 | if(mem != NULL) |
| 183 | { |
| 184 | memcpy(data, mem, len); |
| 185 | sprintf(cmd, "AT+CPMS=%s", data); |
| 186 | } |
| 187 | else{ |
| 188 | printf("mem is null\n"); |
| 189 | } |
| 190 | |
| 191 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 192 | |
| 193 | if(strlen(cmd) > 8) |
| 194 | { |
| 195 | err = at_send_command_multiline(cmd, "+CPMS:", &response); |
| 196 | if (err < 0 || response->success == 0){ |
| 197 | *cme_err = at_get_cme_error(response); |
| 198 | goto exit; |
| 199 | } |
| 200 | |
| 201 | char *line = response->p_intermediates->line; |
| 202 | printf("line:%s, len:%d\n", line, strlen(line)); |
| 203 | |
| 204 | memcpy(reg, line, strlen(line)); |
| 205 | |
| 206 | printf("cpms_reg:%s\n", reg); |
| 207 | } |
| 208 | err = 0; |
| 209 | exit: |
| 210 | printf("goto exit do"); |
| 211 | at_response_free(response); |
| 212 | return err; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | if PDU mode (+CMGF=0): |
| 217 | AT+CMGS=<length><CR> |
| 218 | PDU is given<ctrl-Z/ESC> |
| 219 | if text mode (+CMGF=1): |
| 220 | AT+CMGS=<da>[,<toda>]<CR> |
| 221 | text is entered<ctrl-Z/ESC> |
| 222 | |
| 223 | AT+CMGS=15775690697,hello world |
| 224 | |
| 225 | |
| 226 | */ |
| 227 | static int req_cmgs_set(char *cmgs, char *reg, int len, int *cme_err) |
| 228 | { |
| 229 | printf("req_cmgs_set()----------------start\n"); |
| 230 | printf("cmgs:%s\n", cmgs); |
| 231 | ATResponse *response = NULL; |
| 232 | char cmd[30] = {0}; |
| 233 | char data[218] = {0}; |
| 234 | char pnum[20] = {0}; |
| 235 | char *ptr = cmgs; |
| 236 | int err = 0; |
| 237 | int data_len = 0; |
| 238 | |
| 239 | char *src = strstr(cmgs, ","); |
| 240 | if(src != NULL) |
| 241 | { |
| 242 | //LOG("[XIAORUI]req_cmgs_set()----------------src=%s",src); |
| 243 | //LOG("[XIAORUI]req_cmgs_set()----------------ptr=%s",ptr); |
| 244 | memcpy(pnum, ptr, src - ptr); |
| 245 | //LOG("[XIAORUI]req_cmgs_set()----------------pnum=%s",pnum); |
| 246 | src++; |
| 247 | int data_len = 0; |
| 248 | data_len = len - (src - ptr); |
| 249 | memcpy(data, src, data_len); |
| 250 | //LOG("[XIAORUI]req_cmgs_set()----------------data %s",data); |
| 251 | } |
| 252 | |
| 253 | sprintf(cmd, "AT+CMGS=%s", pnum); |
| 254 | LOG("cmd:%s,data:%s---------", cmd,data); |
| 255 | |
| 256 | if(strlen(cmd) > 0) |
| 257 | { |
| 258 | int err = at_send_command_sms(cmd, data, "+CMGS: ", &response); |
| 259 | printf("err:%d, response:%d\n", err, response->success); |
| 260 | |
| 261 | if (err < 0 || response->success == 0) { |
| 262 | *cme_err = at_get_cme_error(response); |
| 263 | goto exit; |
| 264 | } |
| 265 | char *line; |
| 266 | line = response->p_intermediates->line; |
| 267 | memcpy(reg, line, strlen(line)); |
| 268 | printf("line:%s\n", line); |
| 269 | |
| 270 | } |
| 271 | err = 0; |
| 272 | exit: |
| 273 | at_response_free(response); |
| 274 | return err; |
| 275 | } |
| 276 | |
| 277 | static int req_cmgw_set(char *cmgw,int len, int *cme_err) |
| 278 | { |
| 279 | printf("req_cmgw_set()----------------start\n"); |
| 280 | printf("cmgw:%s\n", cmgw); |
| 281 | ATResponse *response = NULL; |
| 282 | char cmd[30] = {0}; |
| 283 | char data[218] = {0}; |
| 284 | char pnum[13] = {0}; |
| 285 | char *ptr = cmgw; |
| 286 | int err = 0; |
| 287 | |
| 288 | char *src = strstr(cmgw, ","); |
| 289 | if(src != NULL) |
| 290 | { |
| 291 | memcpy(pnum, ptr, src - ptr); |
| 292 | src++; |
| 293 | int data_len = 0; |
| 294 | data_len = len - (src - ptr); |
| 295 | memcpy(data, src, data_len); |
| 296 | } |
| 297 | |
| 298 | sprintf(cmd, "AT+CMGW=%s", pnum); |
| 299 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 300 | |
| 301 | if(strlen(cmd) > 0) |
| 302 | { |
| 303 | int err = at_send_command_sms(cmd, data, "+CMGW: ", &response); |
| 304 | printf("err:%d, response:%d\n", err, response->success); |
| 305 | |
| 306 | if (err < 0 || response->success == 0) { |
| 307 | *cme_err = at_get_cme_error(response); |
| 308 | goto exit; |
| 309 | } |
| 310 | char *line; |
| 311 | line = response->p_intermediates->line; |
| 312 | printf("line:%s\n", line); |
| 313 | } |
| 314 | err = 0; |
| 315 | exit: |
| 316 | at_response_free(response); |
| 317 | return err; |
| 318 | } |
| 319 | |
| 320 | /* |
| 321 | AT+CMGD=25 |
| 322 | OK |
| 323 | |
| 324 | +MMSG: 1, 0 |
| 325 | */ |
| 326 | static int req_cmgd_set(char *cmgd, int len, int *cme_err) |
| 327 | { |
| 328 | printf("0req_cmgd_set()--------------start\n"); |
| 329 | printf("cmgd:%s\n", cmgd); |
| 330 | ATResponse *response = NULL; |
| 331 | char cmd[30] = {0}; |
| 332 | char data[218] = {0}; |
| 333 | char pnum[13] = {0}; |
| 334 | char *ptr = cmgd; |
| 335 | int err = 0; |
| 336 | |
| 337 | memcpy(data, cmgd, len ); |
| 338 | sprintf(cmd, "AT+CMGD=%s", data); |
| 339 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 340 | |
| 341 | if(strlen(cmd) > 0) |
| 342 | { |
| 343 | int err = at_send_command(cmd, &response); |
| 344 | if (err < 0 || response->success == 0) { |
| 345 | *cme_err = at_get_cme_error(response); |
| 346 | goto exit; |
| 347 | } |
| 348 | |
| 349 | // Format problem caused the crash |
| 350 | // char *line; |
| 351 | // line = response->p_intermediates->line; |
| 352 | // printf("line:%s\n", line); |
| 353 | } |
| 354 | err = 0; |
| 355 | exit: |
| 356 | at_response_free(response); |
| 357 | return err; |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | AT+CMGD=? |
| 362 | |
| 363 | +CMGD: (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37),(0-4) |
| 364 | |
| 365 | OK |
| 366 | |
| 367 | */ |
| 368 | static int req_cmgd_get(char *reg, int *cme_err) |
| 369 | { |
| 370 | ATResponse *response = NULL; |
| 371 | char *tmp_ptr = NULL; |
| 372 | int err = at_send_command_singleline("AT+CMGD=?", "+CMGD:", &response); |
| 373 | |
| 374 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 375 | *cme_err = at_get_cme_error(response); |
| 376 | goto exit; |
| 377 | } |
| 378 | |
| 379 | char *line = response->p_intermediates->line; |
| 380 | |
| 381 | const char* start = strchr(line, '('); |
| 382 | const char* end = strchr(line, ')'); |
| 383 | |
| 384 | if (start && end && end > start) |
| 385 | { |
| 386 | int len_t = end - start - 1; |
| 387 | char substr_t[len_t + 1]; |
| 388 | |
| 389 | strncpy(substr_t, start + 1, len_t); |
| 390 | substr_t[len_t] = '\0'; |
| 391 | strncpy(reg, substr_t, len_t); |
| 392 | } |
| 393 | else |
| 394 | { |
| 395 | strcpy(reg, ""); |
| 396 | } |
| 397 | |
| 398 | exit: |
| 399 | at_response_free(response); |
| 400 | return err; |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /* |
| 405 | AT+CMGL="ALL" |
| 406 | |
| 407 | +CMGL: 1,"REC READ","10658678",,"22.11.14 10:41:44 GMT+8" |
| 408 | |
| 409 | 56DB5DDD62 |
| 410 | |
| 411 | +CMGL: 2,"STO UNSENT","18927467953" |
| 412 | hello world |
| 413 | |
| 414 | */ |
| 415 | |
| 416 | static int req_cmgl_set(const char *cmgl, char *reg, int len, int *cme_err) |
| 417 | { |
| 418 | printf("req_cmgl_set(2)-----------------start\n"); |
| 419 | printf("cmgl:%s\n", cmgl); |
| 420 | ATResponse *response = NULL; |
| 421 | char cmd[30] = {0}; |
| 422 | char data[218] = {0}; |
| 423 | char index_data[256] = {0}; |
| 424 | int s_index = 0, g_index = 0; |
| 425 | bool index_flag = false; |
| 426 | char *ptr_index = index_data; |
| 427 | char phone[50]; |
| 428 | char number[5] = {0}; |
| 429 | int err = 0; |
| 430 | |
| 431 | memcpy(data, cmgl, len); |
| 432 | |
| 433 | char *ptr1 = data; |
| 434 | char *ptr2 = strstr(data, ","); |
| 435 | if(ptr2 != NULL) |
| 436 | { |
| 437 | memcpy(number,ptr1, ptr2-ptr1 ); |
| 438 | s_index = atoi(number); |
| 439 | if(s_index == 0) |
| 440 | { |
| 441 | index_flag = TRUE; |
| 442 | memcpy(ptr_index, "+CMGL:", strlen("+CMGL:")); |
| 443 | } |
| 444 | memset(number, 0, sizeof(number)); |
| 445 | ptr2++; |
| 446 | }else{ |
| 447 | printf("cmgl set data is error\n eg:index,data\n"); |
| 448 | return -1; |
| 449 | } |
| 450 | |
| 451 | sprintf(cmd, "AT+CMGL=%s", ptr2); |
| 452 | printf("cmd:%s\n", cmd); |
| 453 | |
| 454 | ptr1 = NULL; |
| 455 | ptr2 = NULL; |
| 456 | |
| 457 | if(strlen(cmd) > 0) |
| 458 | { |
| 459 | err = at_send_command_multiline(cmd, "", &response); |
| 460 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 461 | *cme_err = at_get_cme_error(response); |
| 462 | printf("at_send_command_multiline() is err-----------------\n"); |
| 463 | goto exit; |
| 464 | } |
| 465 | |
| 466 | ATLine* lines_ptr = response->p_intermediates; |
| 467 | char *line = NULL; |
| 468 | int reg_len = 0; |
| 469 | bool flag = false; |
| 470 | while(lines_ptr) |
| 471 | { |
| 472 | line = lines_ptr->line; |
| 473 | if(line ==NULL) |
| 474 | { |
| 475 | printf("line is null----------------------\n"); |
| 476 | } |
| 477 | |
| 478 | printf("-----line:%s\n", line); |
| 479 | if(!flag) |
| 480 | { |
| 481 | ptr1 = strstr(line, "+CMGL: "); |
| 482 | if(ptr1 != NULL) |
| 483 | { |
| 484 | ptr1 += 7; |
| 485 | ptr2 = strstr(line, ","); |
| 486 | memcpy(number,ptr1, ptr2-ptr1 ); |
| 487 | printf("number:%s, ptr1:%s, ptr2:%s\n", number, ptr1, ptr2); |
| 488 | g_index = atoi(number); |
| 489 | if(index_flag) |
| 490 | { |
| 491 | sprintf(ptr_index+strlen(ptr_index), "%d,", g_index); |
| 492 | } |
| 493 | } |
| 494 | //if( g_index == s_index) |
| 495 | if( g_index == s_index && !index_flag) |
| 496 | { |
| 497 | printf("g_index == s_index, g_index:%d,s_index:%d\n", g_index, s_index); |
| 498 | flag = true; |
| 499 | } |
| 500 | } |
| 501 | if(flag && reg_len <=1024) |
| 502 | { |
| 503 | memcpy(reg+reg_len, line, strlen(line)); |
| 504 | printf("-----memcpy------reg:%s----------\n", reg); |
| 505 | printf("len:%d\n", reg_len); |
| 506 | reg_len += strlen(line); |
| 507 | } |
| 508 | |
| 509 | lines_ptr = lines_ptr->p_next; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | if(index_flag) |
| 514 | { |
| 515 | memset(reg, 0, sizeof(reg)); |
| 516 | memcpy(reg, ptr_index, strlen(ptr_index) ); |
| 517 | } |
| 518 | err = 0; |
| 519 | exit: |
| 520 | at_response_free(response); |
| 521 | printf("req_cmgl_set()-----------------end\n"); |
| 522 | return err; |
| 523 | } |
| 524 | |
| 525 | /* |
| 526 | at+csca? |
| 527 | +CSCA: "+8613800280500",145 |
| 528 | OK |
| 529 | */ |
| 530 | static int req_csca_get(char *req, int *cme_err) |
| 531 | { |
| 532 | ATResponse *response = NULL; |
| 533 | char *tmp_ptr = NULL; |
| 534 | int err = at_send_command_singleline("AT+CSCA?", "", &response); |
| 535 | |
| 536 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 537 | *cme_err = at_get_cme_error(response); |
| 538 | goto exit; |
| 539 | } |
| 540 | |
| 541 | char *line = response->p_intermediates->line; |
| 542 | printf("req_csca_get() ---line:%s\n", line); |
| 543 | char* ptr = strstr(line, "+CSCA: "); |
| 544 | printf("req_csca_get() ---ptr:%s\n",ptr); |
| 545 | if(ptr) |
| 546 | { |
| 547 | memcpy(req, line, strlen(line)); |
| 548 | printf("err:%d, req:%s\n", err, req); |
| 549 | err = 0; |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | err = -1; |
| 554 | } |
| 555 | |
| 556 | exit: |
| 557 | at_response_free(response); |
| 558 | return err; |
| 559 | } |
| 560 | |
| 561 | static int req_csca_set(char *csca, int len, int *cme_err) |
| 562 | { |
| 563 | printf("req_csca_set()--------------start\n"); |
| 564 | printf("csca:%s\n", csca); |
| 565 | ATResponse *response = NULL; |
| 566 | char cmd[30] = {0}; |
| 567 | char data[218] = {0}; |
| 568 | char pnum[13] = {0}; |
| 569 | char *ptr = csca; |
| 570 | int err = 0; |
| 571 | |
| 572 | memcpy(data, csca, len); |
| 573 | sprintf(cmd, "AT+CSCA=%s", data); |
| 574 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 575 | |
| 576 | if(strlen(cmd) > 0) |
| 577 | { |
| 578 | int err = at_send_command(cmd, &response); |
| 579 | if (err < 0 || response->success == 0) { |
| 580 | *cme_err = at_get_cme_error(response); |
| 581 | goto exit; |
| 582 | } |
| 583 | |
| 584 | // char *line; |
| 585 | // line = response->p_intermediates->line; |
| 586 | // printf("line:%s\n", line); |
| 587 | } |
| 588 | err = 0; |
| 589 | exit: |
| 590 | at_response_free(response); |
| 591 | return err; |
| 592 | } |
| 593 | |
| 594 | static int req_csmp_set(char *csmp, int len, int *cme_err) |
| 595 | { |
| 596 | printf("req_csmp_set()-------------------start\n"); |
| 597 | printf("csmp:%s\n", csmp); |
| 598 | ATResponse *response = NULL; |
| 599 | char cmd[30] = {0}; |
| 600 | char data[218] = {0}; |
| 601 | char pnum[13] = {0}; |
| 602 | char *ptr = csmp; |
| 603 | int err = 0; |
| 604 | |
| 605 | memcpy(data, csmp, len); |
| 606 | sprintf(cmd, "AT+CSMP=%s", data); |
| 607 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 608 | |
| 609 | if(strlen(cmd) > 0) |
| 610 | { |
| 611 | int err = at_send_command(cmd, &response); |
| 612 | if (err < 0 || response->success == 0) { |
| 613 | *cme_err = at_get_cme_error(response); |
| 614 | goto exit; |
| 615 | } |
| 616 | |
| 617 | char *line; |
| 618 | line = response->p_intermediates->line; |
| 619 | printf("line:%s\n", line); |
| 620 | } |
| 621 | err = 0; |
| 622 | exit: |
| 623 | at_response_free(response); |
| 624 | return err; |
| 625 | } |
| 626 | |
| 627 | static int req_cscb_set(char *cscb,int len, int *cme_err) |
| 628 | { |
| 629 | printf("req_cscb_set()----------------start\n"); |
| 630 | printf("cscb:%s\n", cscb); |
| 631 | ATResponse *response = NULL; |
| 632 | char cmd[30] = {0}; |
| 633 | char data[218] = {0}; |
| 634 | char pnum[13] = {0}; |
| 635 | char *ptr = cscb; |
| 636 | int err = 0; |
| 637 | |
| 638 | memcpy(data, cscb, len); |
| 639 | sprintf(cmd, "AT+CSCB=%s", cscb); |
| 640 | printf("cmd:%s,data:%s---------\n", cmd,data); |
| 641 | |
| 642 | if(strlen(cmd) > 0) |
| 643 | { |
| 644 | int err = at_send_command(cmd, &response); |
| 645 | if (err < 0 || response->success == 0) { |
| 646 | *cme_err = at_get_cme_error(response); |
| 647 | goto exit; |
| 648 | } |
| 649 | |
| 650 | char *line; |
| 651 | line = response->p_intermediates->line; |
| 652 | printf("line:%s\n", line); |
| 653 | } |
| 654 | err = 0; |
| 655 | exit: |
| 656 | at_response_free(response); |
| 657 | return err; |
| 658 | } |
| 659 | |
| 660 | /* |
| 661 | AT+CMSS=13 |
| 662 | +CMSS: 81 |
| 663 | OK |
| 664 | */ |
| 665 | static int req_cmss_set(const char *cmss, char *reg, int len, int *cme_err) |
| 666 | { |
| 667 | printf("req_cmss_set()----------------start\n"); |
| 668 | printf("cmss:%s\n", cmss); |
| 669 | ATResponse *response = NULL; |
| 670 | char cmd[30] = {0}; |
| 671 | char data[20] = {0}; |
| 672 | int err = 0; |
| 673 | |
| 674 | if(cmss != NULL) |
| 675 | { |
| 676 | memcpy(data, cmss, len); |
| 677 | sprintf(cmd, "AT+CMSS=%s", data); |
| 678 | // sprintf(cmd, "AT+CMSS=%d", 8); |
| 679 | } |
| 680 | else{ |
| 681 | printf("mem is null\n"); |
| 682 | } |
| 683 | |
| 684 | printf("cmss. cmd:%s\n", cmd); |
| 685 | |
| 686 | if(strlen(cmd) > 8) |
| 687 | { |
| 688 | err = at_send_command_multiline(cmd, "+CMSS:", &response); |
| 689 | if (err < 0 || response->success == 0){ |
| 690 | *cme_err = at_get_cme_error(response); |
| 691 | goto exit; |
| 692 | } |
| 693 | |
| 694 | char *line = response->p_intermediates->line; |
| 695 | printf("line:%s\n", line); |
| 696 | |
| 697 | char *tmp_str = NULL; |
| 698 | err = at_tok_nextstr(&line, &tmp_str); // phone_number |
| 699 | if (err < 0) |
| 700 | { |
| 701 | goto exit; |
| 702 | } |
| 703 | memcpy(reg, tmp_str, strlen(tmp_str)); |
| 704 | printf("cmss_reg:%s\n", reg); |
| 705 | /* |
| 706 | int err = at_send_command(cmd, &response); |
| 707 | |
| 708 | if (err < 0 || response->success == 0) { |
| 709 | *cme_err = at_get_cme_error(response); |
| 710 | goto exit; |
| 711 | } |
| 712 | |
| 713 | char *line; |
| 714 | line = response->p_intermediates->line; |
| 715 | printf("line:%s\n", line); |
| 716 | */ |
| 717 | } |
| 718 | err = 0; |
| 719 | exit: |
| 720 | at_response_free(response); |
| 721 | return err; |
| 722 | } |
| 723 | |
| 724 | |
| 725 | /* |
| 726 | AT+CMGR=1 |
| 727 | +CMGR: "REC READ","10658678",,"22.11.14 10:41:44 GMT+8" |
| 728 | |
| 729 | 56DB5DDD624B673A62A5FF039003003400310034003500340035003F0073003D0037003800680061006C00450066 |
| 730 | |
| 731 | OK |
| 732 | */ |
| 733 | static int req_cmgr_set(int index, char *reg, int *cme_err) |
| 734 | { |
| 735 | printf("0req_cmgr_set()-------------------start\n"); |
| 736 | printf("index:%d\n", index); |
| 737 | ATResponse *response = NULL; |
| 738 | char cmd[30] = {0}; |
| 739 | int err = 0; |
| 740 | sprintf(cmd, "AT+CMGR=%d", index); |
| 741 | |
| 742 | printf("req_cmgr_set()----cmd:%s\n", cmd); |
| 743 | |
| 744 | if(strlen(cmd) > 0) |
| 745 | { |
| 746 | err = at_send_command_multiline(cmd, "", &response); |
| 747 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 748 | *cme_err = at_get_cme_error(response); |
| 749 | printf("at_send_command_multiline() is err-----------------\n"); |
| 750 | goto exit; |
| 751 | } |
| 752 | |
| 753 | ATLine* lines_ptr = response->p_intermediates; |
| 754 | char *line = NULL; |
| 755 | int reg_len = 0; |
| 756 | while(lines_ptr) |
| 757 | { |
| 758 | line = lines_ptr->line; |
| 759 | if(line ==NULL) |
| 760 | { |
| 761 | printf("line is null----------------------\n"); |
| 762 | } |
| 763 | |
| 764 | if(reg_len > 0) |
| 765 | { |
| 766 | memcpy(reg+reg_len, "\r\n", strlen("\r\n")); |
| 767 | reg_len += strlen("\r\n"); |
| 768 | } |
| 769 | memcpy(reg+reg_len, line, strlen(line)); |
| 770 | printf("-----memcpy------reg:%s----------\n", reg); |
| 771 | printf("len:%d\n", reg_len); |
| 772 | reg_len += strlen(line); |
| 773 | lines_ptr = lines_ptr->p_next; |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | err = 0; |
| 778 | exit: |
| 779 | at_response_free(response); |
| 780 | return err; |
| 781 | } |
| 782 | |
| 783 | |
| 784 | //void net_list_free(void *data); |
| 785 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 786 | // Otherwise, do not call pack_error_send(). |
| 787 | mbtk_ril_err_enum sms_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack) |
| 788 | { |
| 789 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS; |
| 790 | int cme_err = MBTK_RIL_ERR_CME_NON; |
| 791 | switch(pack->msg_id) |
| 792 | { |
| 793 | case RIL_MSG_ID_SMS_CMGF: |
| 794 | { |
| 795 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 796 | { |
| 797 | int state; |
| 798 | if(req_cmgf_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 799 | { |
| 800 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 801 | err = MBTK_RIL_ERR_CME + cme_err; |
| 802 | } else { |
| 803 | err = MBTK_RIL_ERR_UNKNOWN; |
| 804 | } |
| 805 | LOG("Get SMS CMGF fail."); |
| 806 | } |
| 807 | else |
| 808 | { |
| 809 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8)); |
| 810 | } |
| 811 | } |
| 812 | else // Set VoLTE state. |
| 813 | { |
| 814 | uint8 mode = *(pack->data); |
| 815 | if(pack->data_len != sizeof(uint8) || (mode != 0 && mode != 1)) |
| 816 | { |
| 817 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 818 | LOG("Set SMS CMGF parameter error."); |
| 819 | break; |
| 820 | } |
| 821 | |
| 822 | if(req_cmgf_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 823 | { |
| 824 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 825 | err = MBTK_RIL_ERR_CME + cme_err; |
| 826 | } else { |
| 827 | err = MBTK_RIL_ERR_UNKNOWN; |
| 828 | } |
| 829 | LOG("Set SMS CMGF fail."); |
| 830 | } |
| 831 | else |
| 832 | { |
| 833 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 834 | } |
| 835 | } |
| 836 | break; |
| 837 | } |
| 838 | case RIL_MSG_ID_SMS_CNMI: |
| 839 | { |
| 840 | if(pack->data_len == 0 || pack->data == NULL) // SET at+cnmi=1,2. |
| 841 | { |
| 842 | int state; |
| 843 | if(req_cnmi_set(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 844 | { |
| 845 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 846 | err = MBTK_RIL_ERR_CME + cme_err; |
| 847 | } else { |
| 848 | err = MBTK_RIL_ERR_UNKNOWN; |
| 849 | } |
| 850 | LOG("set sms cnmi fail."); |
| 851 | } |
| 852 | else |
| 853 | { |
| 854 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 855 | } |
| 856 | } |
| 857 | break; |
| 858 | } |
| 859 | case RIL_MSG_ID_SMS_CPMS: |
| 860 | { |
| 861 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 862 | { |
| 863 | char reg[100] = {0}; |
| 864 | if(req_cpms_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 865 | { |
| 866 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 867 | err = MBTK_RIL_ERR_CME + cme_err; |
| 868 | } else { |
| 869 | err = MBTK_RIL_ERR_UNKNOWN; |
| 870 | } |
| 871 | LOG("Get SMS CMGF fail."); |
| 872 | } |
| 873 | else |
| 874 | { |
| 875 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
| 876 | } |
| 877 | } |
| 878 | else // Set VoLTE state. |
| 879 | { |
| 880 | char *mem = (char*)(pack->data); |
| 881 | int len = pack->data_len; |
| 882 | char reg[100] = {0}; |
| 883 | LOGD("mem:%s, len:%d", pack->data, pack->data_len); |
| 884 | |
| 885 | if(req_cpms_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 886 | { |
| 887 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 888 | err = MBTK_RIL_ERR_CME + cme_err; |
| 889 | } else { |
| 890 | err = MBTK_RIL_ERR_UNKNOWN; |
| 891 | } |
| 892 | LOG("Set SMS CMGF fail."); |
| 893 | } |
| 894 | else |
| 895 | { |
| 896 | LOGD("cpms_set success, reg:%s", reg); |
| 897 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
| 898 | } |
| 899 | } |
| 900 | break; |
| 901 | } |
| 902 | case RIL_MSG_ID_SMS_CMGS: |
| 903 | { |
| 904 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 905 | { |
| 906 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 907 | } |
| 908 | else // Set VoLTE state. |
| 909 | { |
| 910 | char *cmgs = (char*)pack->data; |
| 911 | int len = pack->data_len; |
| 912 | char reg[50] ={0}; |
| 913 | LOGD("mbtk_sms,cmgs:%s,len:%d", cmgs, len); |
| 914 | |
| 915 | if(req_cmgs_set(cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 916 | { |
| 917 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 918 | err = MBTK_RIL_ERR_CME + cme_err; |
| 919 | } else { |
| 920 | err = MBTK_RIL_ERR_UNKNOWN; |
| 921 | } |
| 922 | LOG("Set SMS CMGF fail."); |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
| 927 | } |
| 928 | } |
| 929 | break; |
| 930 | } |
| 931 | case RIL_MSG_ID_SMS_CMSS: |
| 932 | { |
| 933 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 934 | { |
| 935 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 936 | } |
| 937 | else // Set VoLTE state. |
| 938 | { |
| 939 | char *cmss = (char*)pack->data; |
| 940 | int len = pack->data_len; |
| 941 | char reg[128] = {0}; |
| 942 | LOGD("mbtk_sms,cmgs:%s, len:%d", cmss, len); |
| 943 | |
| 944 | if(req_cmss_set(cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 945 | { |
| 946 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 947 | err = MBTK_RIL_ERR_CME + cme_err; |
| 948 | } else { |
| 949 | err = MBTK_RIL_ERR_UNKNOWN; |
| 950 | } |
| 951 | LOG("Set SMS CMGF fail."); |
| 952 | } |
| 953 | else |
| 954 | { |
| 955 | LOGD("req_cmss_set success, reg:%s", reg); |
| 956 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 957 | } |
| 958 | } |
| 959 | break; |
| 960 | } |
| 961 | case RIL_MSG_ID_SMS_CMGR: |
| 962 | { |
| 963 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 964 | { |
| 965 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 966 | } |
| 967 | else // Set VoLTE state. |
| 968 | { |
| 969 | uint8 index = *(pack->data); |
| 970 | char reg[1024] = {0}; |
| 971 | if(pack->data_len != sizeof(uint8) ) |
| 972 | { |
| 973 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 974 | LOG("Set SMS CMGF parameter error."); |
| 975 | break; |
| 976 | } |
| 977 | |
| 978 | if(req_cmgr_set(index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 979 | { |
| 980 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 981 | err = MBTK_RIL_ERR_CME + cme_err; |
| 982 | } else { |
| 983 | err = MBTK_RIL_ERR_UNKNOWN; |
| 984 | } |
| 985 | LOG("Set SMS CMGF fail."); |
| 986 | } |
| 987 | else |
| 988 | { |
| 989 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
| 990 | } |
| 991 | } |
| 992 | break; |
| 993 | } |
| 994 | case RIL_MSG_ID_SMS_CMGW: |
| 995 | { |
| 996 | if(pack->data_len == 0 || pack->data == NULL) // +CMGW=<oa/da>[,<tooa/toda>[,<stat>]]<CR> |
| 997 | { |
| 998 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 999 | } |
| 1000 | else // Set cmgw data. |
| 1001 | { |
| 1002 | char *cmgw = (char*)pack->data; |
| 1003 | int len = pack->data_len; |
| 1004 | LOGD("mbtk_sms,cmgw:%s,len:%d", cmgw, len); |
| 1005 | |
| 1006 | if(req_cmgw_set(cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1007 | { |
| 1008 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1009 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1010 | } else { |
| 1011 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1012 | } |
| 1013 | LOG("Set SMS CMGF fail."); |
| 1014 | } |
| 1015 | else |
| 1016 | { |
| 1017 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1018 | } |
| 1019 | } |
| 1020 | break; |
| 1021 | } |
| 1022 | case RIL_MSG_ID_SMS_CMGD: |
| 1023 | { |
| 1024 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 1025 | { |
| 1026 | char reg[1024] = {0}; |
| 1027 | if(req_cmgd_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1028 | { |
| 1029 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1030 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1031 | } else { |
| 1032 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1033 | } |
| 1034 | LOG("Get SMS CMGD fail."); |
| 1035 | } |
| 1036 | else |
| 1037 | { |
| 1038 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg)); |
| 1039 | } |
| 1040 | } |
| 1041 | else // Set VoLTE state. |
| 1042 | { |
| 1043 | char *cmgd = (char*)pack->data; |
| 1044 | int len = pack->data_len; |
| 1045 | LOGD("mbtk_sms,cmgs:%s,len:%d", cmgd, len); |
| 1046 | |
| 1047 | if(req_cmgd_set(cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1048 | { |
| 1049 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1050 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1051 | } else { |
| 1052 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1053 | } |
| 1054 | LOG("Set SMS CMGF fail."); |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1059 | } |
| 1060 | |
| 1061 | } |
| 1062 | break; |
| 1063 | } |
| 1064 | case RIL_MSG_ID_SMS_CMGL: |
| 1065 | { |
| 1066 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 1067 | { |
| 1068 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1069 | } |
| 1070 | else // Set VoLTE state. |
| 1071 | { |
| 1072 | char *cmgl = (char*)pack->data; |
| 1073 | int len = pack->data_len; |
| 1074 | char reg[5*1024] = {0}; |
| 1075 | char reg1[1024+1] = {0}; |
| 1076 | |
| 1077 | if(req_cmgl_set(cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1078 | { |
| 1079 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1080 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1081 | } else { |
| 1082 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1083 | } |
| 1084 | LOG("Set SMS CMGF fail."); |
| 1085 | } |
| 1086 | else |
| 1087 | { |
| 1088 | memcpy(reg1, reg, 1024); |
| 1089 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1)); |
| 1090 | } |
| 1091 | } |
| 1092 | break; |
| 1093 | } |
| 1094 | case RIL_MSG_ID_SMS_CSCA: |
| 1095 | { |
| 1096 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 1097 | { |
| 1098 | char csca[50]={0}; |
| 1099 | if(req_csca_get(csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1100 | { |
| 1101 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1102 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1103 | } else { |
| 1104 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1105 | } |
| 1106 | LOG("Get SMS CSCA fail."); |
| 1107 | } |
| 1108 | else |
| 1109 | { |
| 1110 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca)); |
| 1111 | } |
| 1112 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1113 | } |
| 1114 | else // Set VoLTE state. |
| 1115 | { |
| 1116 | char *csca = (char*)pack->data; |
| 1117 | int len = pack->data_len; |
| 1118 | |
| 1119 | if(req_csca_set(csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1120 | { |
| 1121 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1122 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1123 | } else { |
| 1124 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1125 | } |
| 1126 | LOG("Set SMS CMGF fail."); |
| 1127 | } |
| 1128 | else |
| 1129 | { |
| 1130 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1131 | } |
| 1132 | } |
| 1133 | break; |
| 1134 | } |
| 1135 | case RIL_MSG_ID_SMS_CSMP: |
| 1136 | { |
| 1137 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 1138 | { |
| 1139 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1140 | } |
| 1141 | else // Set VoLTE state. |
| 1142 | { |
| 1143 | char *csmp = (char*)pack->data; |
| 1144 | int len = pack->data_len; |
| 1145 | |
| 1146 | if(req_csmp_set(csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1147 | { |
| 1148 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1149 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1150 | } else { |
| 1151 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1152 | } |
| 1153 | LOG("Set SMS CMGF fail."); |
| 1154 | } |
| 1155 | else |
| 1156 | { |
| 1157 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1158 | } |
| 1159 | } |
| 1160 | break; |
| 1161 | } |
| 1162 | case RIL_MSG_ID_SMS_CSCB: |
| 1163 | { |
| 1164 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 1165 | { |
| 1166 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1167 | } |
| 1168 | else // Set VoLTE state. |
| 1169 | { |
| 1170 | char *cscb = (char*)pack->data; |
| 1171 | int len = pack->data_len; |
| 1172 | |
| 1173 | if(req_cscb_set(cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1174 | { |
| 1175 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1176 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1177 | } else { |
| 1178 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1179 | } |
| 1180 | LOG("Set SMS CMGF fail."); |
| 1181 | } |
| 1182 | else |
| 1183 | { |
| 1184 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1185 | } |
| 1186 | } |
| 1187 | break; |
| 1188 | } |
| 1189 | default: |
| 1190 | { |
| 1191 | err = MBTK_RIL_ERR_REQ_UNKNOWN; |
| 1192 | LOG("Unknown request : %s", id2str(pack->msg_id)); |
| 1193 | break; |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | return err; |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | |