liubin | 281ac46 | 2023-07-19 14:22:54 +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_info.h" |
| 15 | #include "atchannel.h" |
| 16 | #include "at_tok.h" |
| 17 | #include "mbtk_utils.h" |
| 18 | #include "info_data.h" |
| 19 | |
| 20 | void pack_rsp_send(int fd, int info_id, const void* data, int data_len); |
| 21 | |
| 22 | |
| 23 | /* |
| 24 | ATDXXXXXXX; |
| 25 | OK |
| 26 | |
| 27 | */ |
| 28 | static int req_call_start(char *phont_number, int *cme_err) |
| 29 | { |
| 30 | ATResponse *response = NULL; |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 31 | // int tmp_int; |
| 32 | // char *tmp_str = NULL; |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 33 | char cmd[100] = {0}; |
| 34 | sprintf(cmd, "ATD%s;", phont_number); |
| 35 | int err = at_send_command(cmd, &response); |
| 36 | if (err < 0 || response->success == 0){ |
| 37 | *cme_err = at_get_cme_error(response); |
| 38 | goto exit; |
| 39 | } |
| 40 | |
| 41 | exit: |
| 42 | at_response_free(response); |
| 43 | return err; |
| 44 | } |
| 45 | |
| 46 | /* |
| 47 | |
| 48 | AT+CHLD=2 |
| 49 | OK |
| 50 | |
| 51 | */ |
| 52 | static int req_answer_call(int *cme_err) |
| 53 | { |
| 54 | ATResponse *response = NULL; |
| 55 | int err = at_send_command("AT+CHLD=2", &response); |
| 56 | if (err < 0 || response->success == 0){ |
| 57 | *cme_err = at_get_cme_error(response); |
| 58 | goto exit; |
| 59 | } |
| 60 | |
| 61 | exit: |
| 62 | at_response_free(response); |
| 63 | return err; |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | ATH |
| 68 | OK |
| 69 | |
| 70 | */ |
| 71 | static int req_hangup_call(int *cme_err) |
| 72 | { |
| 73 | ATResponse *response = NULL; |
| 74 | int err = at_send_command("ATH", &response); |
| 75 | if (err < 0 || response->success == 0){ |
| 76 | *cme_err = at_get_cme_error(response); |
| 77 | goto exit; |
| 78 | } |
| 79 | |
| 80 | exit: |
| 81 | at_response_free(response); |
| 82 | return err; |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | AT+CHLD=1x |
| 87 | OK |
| 88 | |
| 89 | */ |
| 90 | static int req_hangup_a_call(int phone_id, int *cme_err) |
| 91 | { |
| 92 | ATResponse *response = NULL; |
| 93 | char cmd[100] = {0}; |
| 94 | sprintf(cmd, "AT+CHLD=1%d", phone_id); |
| 95 | int err = at_send_command(cmd, &response); |
| 96 | if (err < 0 || response->success == 0){ |
| 97 | *cme_err = at_get_cme_error(response); |
| 98 | goto exit; |
| 99 | } |
| 100 | |
| 101 | exit: |
| 102 | at_response_free(response); |
| 103 | return err; |
| 104 | } |
| 105 | |
| 106 | /* |
| 107 | AT+CHLD=0 |
| 108 | OK |
| 109 | |
| 110 | */ |
| 111 | static int req_hangup_waiting_or_background_call(int *cme_err) |
| 112 | { |
| 113 | ATResponse *response = NULL; |
| 114 | int err = at_send_command("AT+CHLD=0", &response); |
| 115 | if (err < 0 || response->success == 0){ |
| 116 | *cme_err = at_get_cme_error(response); |
| 117 | goto exit; |
| 118 | } |
| 119 | |
| 120 | exit: |
| 121 | at_response_free(response); |
| 122 | return err; |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | AT+CHLD=1 |
| 127 | OK |
| 128 | |
| 129 | */ |
| 130 | static int req_hangup_foreground_resume_background_call(int *cme_err) |
| 131 | { |
| 132 | ATResponse *response = NULL; |
| 133 | int err = at_send_command("AT+CHLD=1", &response); |
| 134 | if (err < 0 || response->success == 0){ |
| 135 | *cme_err = at_get_cme_error(response); |
| 136 | goto exit; |
| 137 | } |
| 138 | |
| 139 | exit: |
| 140 | at_response_free(response); |
| 141 | return err; |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | AT+CLCC |
| 146 | OK |
| 147 | |
| 148 | */ |
| 149 | static int req_waitin_call(mbtk_call_info_t *reg, int *cme_err) |
| 150 | { |
| 151 | ATResponse *response = NULL; |
| 152 | int tmp_int; |
| 153 | char *tmp_str = NULL; |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 154 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 155 | int err = at_send_command_multiline("AT+CLCC", "+CLCC:", &response); |
| 156 | if (err < 0 || response->success == 0){ |
| 157 | *cme_err = at_get_cme_error(response); |
| 158 | goto exit; |
| 159 | } |
| 160 | |
| 161 | if(response->success == 1 && !response->p_intermediates) |
| 162 | { |
| 163 | reg->call_wait = 0; |
| 164 | goto exit; |
| 165 | } |
| 166 | |
| 167 | reg->call_wait = 1; |
| 168 | char *line = response->p_intermediates->line; |
| 169 | err = at_tok_start(&line); |
| 170 | if (err < 0) |
| 171 | { |
| 172 | goto exit; |
| 173 | } |
| 174 | err = at_tok_nextint(&line, &tmp_int); // dir1 |
| 175 | if (err < 0) |
| 176 | { |
| 177 | goto exit; |
| 178 | } |
| 179 | reg->dir1 = (uint8)tmp_int; |
| 180 | err = at_tok_nextint(&line, &tmp_int);// dir |
| 181 | if (err < 0) |
| 182 | { |
| 183 | goto exit; |
| 184 | } |
| 185 | reg->dir = (uint8)tmp_int; |
| 186 | err = at_tok_nextint(&line, &tmp_int);// state |
| 187 | if (err < 0) |
| 188 | { |
| 189 | goto exit; |
| 190 | } |
| 191 | reg->state = (uint8)tmp_int; |
| 192 | err = at_tok_nextint(&line, &tmp_int);// mode |
| 193 | if (err < 0) |
| 194 | { |
| 195 | goto exit; |
| 196 | } |
| 197 | reg->mode = (uint8)tmp_int; |
| 198 | err = at_tok_nextint(&line, &tmp_int);// mpty |
| 199 | if (err < 0) |
| 200 | { |
| 201 | goto exit; |
| 202 | } |
| 203 | reg->mpty = (uint8)tmp_int; |
| 204 | err = at_tok_nextstr(&line, &tmp_str); // phone_number |
| 205 | if (err < 0) |
| 206 | { |
| 207 | goto exit; |
| 208 | } |
| 209 | memcpy(reg->phone_number, tmp_str, strlen(tmp_str)); |
| 210 | err = at_tok_nextint(&line, &tmp_int);// tpye |
| 211 | if (err < 0) |
| 212 | { |
| 213 | goto exit; |
| 214 | } |
| 215 | reg->type = (uint8)tmp_int; |
| 216 | |
| 217 | exit: |
| 218 | at_response_free(response); |
| 219 | return err; |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | AT+CMUT? |
| 224 | +CMUT: 0 |
| 225 | |
| 226 | OK |
| 227 | */ |
| 228 | static int req_mute_get(int *state, int *cme_err) |
| 229 | { |
| 230 | ATResponse *response = NULL; |
| 231 | int tmp_int; |
| 232 | int err = at_send_command_singleline("AT+CMUT?", "+CMUT:", &response); |
| 233 | |
| 234 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 235 | *cme_err = at_get_cme_error(response); |
| 236 | goto exit; |
| 237 | } |
| 238 | |
| 239 | char *line = response->p_intermediates->line; |
| 240 | err = at_tok_start(&line); |
| 241 | if (err < 0) |
| 242 | { |
| 243 | goto exit; |
| 244 | } |
| 245 | err = at_tok_nextint(&line, &tmp_int); |
| 246 | if (err < 0) |
| 247 | { |
| 248 | goto exit; |
| 249 | } |
| 250 | *state = tmp_int; |
| 251 | |
| 252 | exit: |
| 253 | at_response_free(response); |
| 254 | return err; |
| 255 | } |
| 256 | |
| 257 | /* |
| 258 | AT+CMUT=0; |
| 259 | OK |
| 260 | |
| 261 | */ |
| 262 | static int req_mute_set(int state, int *cme_err) |
| 263 | { |
| 264 | ATResponse *response = NULL; |
| 265 | char cmd[100] = {0}; |
| 266 | sprintf(cmd, "AT+CMUT=%d", state); |
| 267 | LOG("Set the mute command is = %s.\n", cmd); |
| 268 | int err = at_send_command(cmd, &response); |
| 269 | if (err < 0 || response->success == 0){ |
| 270 | *cme_err = at_get_cme_error(response); |
| 271 | goto exit; |
| 272 | } |
| 273 | |
| 274 | exit: |
| 275 | at_response_free(response); |
| 276 | return err; |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 | AT+VTS=0; //0, 1, ..., 9, A, B, C, D, *, # |
| 281 | OK |
| 282 | |
| 283 | */ |
| 284 | static int req_dtmf_set(mbtk_call_dtmf_info_t *state, int *cme_err) |
| 285 | { |
| 286 | ATResponse *response = NULL; |
| 287 | char cmd[100] = {0}; |
| 288 | sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration); |
| 289 | LOG("Set the DTMF command is = %s.\n", cmd); |
| 290 | int err = at_send_command(cmd, &response); |
| 291 | if (err < 0 || response->success == 0){ |
| 292 | *cme_err = at_get_cme_error(response); |
| 293 | goto exit; |
| 294 | } |
| 295 | |
| 296 | exit: |
| 297 | at_response_free(response); |
| 298 | return err; |
| 299 | } |
| 300 | |
liuyang | 98e6852 | 2024-11-20 19:16:34 +0800 | [diff] [blame^] | 301 | static int req_ceer_call(char *reg, int *cme_err) |
| 302 | { |
| 303 | ATResponse *response = NULL; |
| 304 | char *tmp_str = NULL; |
| 305 | |
| 306 | int err = at_send_command_singleline("AT+CEER", "+CEER:", &response); |
| 307 | |
| 308 | if (-6 == err) |
| 309 | { |
| 310 | err = 0; |
| 311 | memcpy(reg, "none", strlen("none")); |
| 312 | goto exit; |
| 313 | } |
| 314 | |
| 315 | if (err < 0 || response->success == 0) |
| 316 | { |
| 317 | *cme_err = at_get_cme_error(response); |
| 318 | goto exit; |
| 319 | } |
| 320 | |
| 321 | char *line = response->p_intermediates->line; |
| 322 | err = at_tok_start(&line); |
| 323 | if (err < 0) |
| 324 | { |
| 325 | goto exit; |
| 326 | } |
| 327 | |
| 328 | err = at_tok_nextstr(&line, &tmp_str); |
| 329 | |
| 330 | if (err < 0) |
| 331 | { |
| 332 | goto exit; |
| 333 | } |
| 334 | memcpy(reg, tmp_str, strlen(tmp_str)); |
| 335 | |
| 336 | LOG("req_ceer_call reg:%s", reg); |
| 337 | |
| 338 | exit: |
| 339 | at_response_free(response); |
| 340 | return err; |
| 341 | } |
| 342 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 343 | |
| 344 | //void net_list_free(void *data); |
| 345 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 346 | // Otherwise, do not call pack_error_send(). |
| 347 | mbtk_info_err_enum call_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack) |
| 348 | { |
| 349 | mbtk_info_err_enum err = MBTK_INFO_ERR_SUCCESS; |
| 350 | int cme_err = MBTK_INFO_ERR_CME_NON; |
| 351 | switch(pack->info_id) |
| 352 | { |
| 353 | case MBTK_INFO_ID_CALL_START_REQ: // <string> phone number |
| 354 | { |
| 355 | if(pack->data_len == 0 || pack->data == NULL) |
| 356 | { |
| 357 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 358 | } |
| 359 | else // Set |
| 360 | { |
| 361 | char *pn = (char*)(pack->data); |
| 362 | if(req_call_start(pn, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 363 | { |
| 364 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 365 | err = MBTK_INFO_ERR_CME + cme_err; |
| 366 | } else { |
| 367 | err = MBTK_INFO_ERR_UNKNOWN; |
| 368 | } |
| 369 | LOG("ATD fail."); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_START_RSP, NULL, 0); |
| 374 | } |
| 375 | } |
| 376 | break; |
| 377 | } |
| 378 | case MBTK_INFO_ID_CALL_ANSWER_REQ: |
| 379 | { |
| 380 | if(pack->data_len == 0 || pack->data == NULL) |
| 381 | { |
| 382 | if(req_answer_call(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 383 | { |
| 384 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 385 | err = MBTK_INFO_ERR_CME + cme_err; |
| 386 | } else { |
| 387 | err = MBTK_INFO_ERR_UNKNOWN; |
| 388 | } |
| 389 | LOG("Answer call fail."); |
| 390 | } |
| 391 | else |
| 392 | { |
| 393 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_ANSWER_RSP, NULL, 0); |
| 394 | } |
| 395 | } |
| 396 | else // Set |
| 397 | { |
| 398 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 399 | LOG("Answer call fail. NO DATA\n"); |
| 400 | } |
| 401 | break; |
| 402 | } |
| 403 | case MBTK_INFO_ID_CALL_HANGUP_REQ: |
| 404 | { |
| 405 | if(pack->data_len == 0 || pack->data == NULL) |
| 406 | { |
| 407 | if(req_hangup_call(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 408 | { |
| 409 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 410 | err = MBTK_INFO_ERR_CME + cme_err; |
| 411 | } else { |
| 412 | err = MBTK_INFO_ERR_UNKNOWN; |
| 413 | } |
| 414 | LOG("Hang up call fail."); |
| 415 | } |
| 416 | else |
| 417 | { |
| 418 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_HANGUP_RSP, NULL, 0); |
| 419 | } |
| 420 | } |
| 421 | else // Set |
| 422 | { |
| 423 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 424 | LOG("Hang up call fail."); |
| 425 | } |
| 426 | break; |
| 427 | } |
| 428 | case MBTK_INFO_ID_CALL_HANGUP_A_REQ: |
| 429 | { |
| 430 | if(pack->data_len == 0 || pack->data == NULL) |
| 431 | { |
| 432 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 433 | LOG("Hang up a call fail."); |
| 434 | } |
| 435 | else |
| 436 | { |
| 437 | uint8 phone_id = *(pack->data); |
| 438 | if(req_hangup_a_call(phone_id, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 439 | { |
| 440 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 441 | err = MBTK_INFO_ERR_CME + cme_err; |
| 442 | } else { |
| 443 | err = MBTK_INFO_ERR_UNKNOWN; |
| 444 | } |
| 445 | LOG("Hang up a call fail."); |
| 446 | } |
| 447 | else |
| 448 | { |
| 449 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_HANGUP_A_RSP, NULL, 0); |
| 450 | } |
| 451 | } |
| 452 | break; |
| 453 | } |
| 454 | case MBTK_INFO_ID_CALL_HANGUP_B_REQ: |
| 455 | { |
| 456 | if(pack->data_len == 0 || pack->data == NULL) |
| 457 | { |
| 458 | if(req_hangup_waiting_or_background_call(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 459 | { |
| 460 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 461 | err = MBTK_INFO_ERR_CME + cme_err; |
| 462 | } else { |
| 463 | err = MBTK_INFO_ERR_UNKNOWN; |
| 464 | } |
| 465 | LOG("Hang up waiting_or_background call fail."); |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_HANGUP_B_RSP, NULL, 0); |
| 470 | } |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 475 | LOG("Hang up waiting_or_background call fail."); |
| 476 | } |
| 477 | break; |
| 478 | } |
| 479 | case MBTK_INFO_ID_CALL_HANGUP_C_REQ: |
| 480 | { |
| 481 | if(pack->data_len == 0 || pack->data == NULL) |
| 482 | { |
| 483 | if(req_hangup_foreground_resume_background_call(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 484 | { |
| 485 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 486 | err = MBTK_INFO_ERR_CME + cme_err; |
| 487 | } else { |
| 488 | err = MBTK_INFO_ERR_UNKNOWN; |
| 489 | } |
| 490 | LOG("Hang up waiting_or_background call fail."); |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_HANGUP_C_RSP, NULL, 0); |
| 495 | } |
| 496 | } |
| 497 | else |
| 498 | { |
| 499 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 500 | LOG("Hang up waiting_or_background call fail."); |
| 501 | } |
| 502 | break; |
| 503 | } |
| 504 | case MBTK_INFO_ID_CALL_WAITIN_REQ: |
| 505 | { |
| 506 | if(pack->data_len == 0 || pack->data == NULL) |
| 507 | { |
| 508 | mbtk_call_info_t reg; |
| 509 | memset(®, 0, sizeof(mbtk_call_info_t)); |
| 510 | if(req_waitin_call(®, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 511 | { |
| 512 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 513 | err = MBTK_INFO_ERR_CME + cme_err; |
| 514 | } else { |
| 515 | err = MBTK_INFO_ERR_UNKNOWN; |
| 516 | } |
| 517 | LOG("Wait incoing call fail."); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_WAITIN_RSP, ®, sizeof(mbtk_call_info_t)); |
| 522 | } |
| 523 | } |
| 524 | else // Set |
| 525 | { |
| 526 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 527 | LOG("Wait incoing call fail."); |
| 528 | } |
| 529 | break; |
| 530 | } |
| 531 | case MBTK_INFO_ID_CALL_MUTE_REQ: |
| 532 | { |
| 533 | if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state. |
| 534 | { |
| 535 | int state; |
| 536 | if(req_mute_get(&state, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 537 | { |
| 538 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 539 | err = MBTK_INFO_ERR_CME + cme_err; |
| 540 | } else { |
| 541 | err = MBTK_INFO_ERR_UNKNOWN; |
| 542 | } |
| 543 | LOG("Get mute state fail."); |
| 544 | } |
| 545 | else |
| 546 | { |
| 547 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_MUTE_RSP, &state, sizeof(uint8)); |
| 548 | } |
| 549 | } |
| 550 | else // Set mute state. |
| 551 | { |
| 552 | uint8 on = *(pack->data); |
| 553 | if(pack->data_len != sizeof(uint8) || (on != 0 && on != 1)) |
| 554 | { |
| 555 | err = MBTK_INFO_ERR_REQ_PARAMETER; |
| 556 | LOG("Set mute parameter error."); |
| 557 | break; |
| 558 | } |
| 559 | |
| 560 | if(req_mute_set(on, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 561 | { |
| 562 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 563 | err = MBTK_INFO_ERR_CME + cme_err; |
| 564 | } else { |
| 565 | err = MBTK_INFO_ERR_UNKNOWN; |
| 566 | } |
| 567 | LOG("Set mute state fail."); |
| 568 | } |
| 569 | else |
| 570 | { |
| 571 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_MUTE_RSP, NULL, 0); |
| 572 | } |
| 573 | } |
| 574 | break; |
| 575 | } |
| 576 | case MBTK_INFO_ID_CALL_DTMF_REQ: |
liuyang | 98e6852 | 2024-11-20 19:16:34 +0800 | [diff] [blame^] | 577 | { |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 578 | if(pack->data_len == 0 || pack->data == NULL) |
| 579 | { |
| 580 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 581 | LOG("Wait incoing call fail."); |
| 582 | } |
| 583 | else // Set |
| 584 | { |
| 585 | mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data; |
| 586 | if(req_dtmf_set(reg, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 587 | { |
| 588 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 589 | err = MBTK_INFO_ERR_CME + cme_err; |
| 590 | } else { |
| 591 | err = MBTK_INFO_ERR_UNKNOWN; |
| 592 | } |
| 593 | LOG("Wait incoing call fail."); |
| 594 | } |
| 595 | else |
| 596 | { |
| 597 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_DTMF_RSP, NULL, 0); |
| 598 | } |
| 599 | } |
| 600 | break; |
liuyang | 98e6852 | 2024-11-20 19:16:34 +0800 | [diff] [blame^] | 601 | } |
| 602 | case MBTK_INFO_ID_CALL_CEER_REQ: |
| 603 | { |
| 604 | if(pack->data_len == 0 || pack->data == NULL) |
| 605 | { |
| 606 | char reg[128] = {0}; |
| 607 | memset(®, 0, 128); |
| 608 | if(req_ceer_call(reg, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON) |
| 609 | { |
| 610 | if(cme_err != MBTK_INFO_ERR_CME_NON) { |
| 611 | err = MBTK_INFO_ERR_CME + cme_err; |
| 612 | } else { |
| 613 | err = MBTK_INFO_ERR_UNKNOWN; |
| 614 | } |
| 615 | LOG("get ceer call fail."); |
| 616 | } |
| 617 | else |
| 618 | { |
| 619 | pack_rsp_send(cli_info->fd, MBTK_INFO_ID_CALL_CEER_RSP, ®, 128); |
| 620 | } |
| 621 | } |
| 622 | else // Set |
| 623 | { |
| 624 | err = MBTK_INFO_ERR_UNSUPPORTED; |
| 625 | LOG("get ceer call fail."); |
| 626 | } |
| 627 | break; |
| 628 | } |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 629 | default: |
| 630 | { |
| 631 | err = MBTK_INFO_ERR_REQ_UNKNOWN; |
| 632 | LOG("Unknown request : %s", id2str(pack->info_id)); |
| 633 | break; |
| 634 | } |
| 635 | } |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 636 | return err; |
| 637 | } |
| 638 | |