b.liu | 15f456b | 2024-10-31 20:16:06 +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 | static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU; |
| 21 | |
| 22 | void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len); |
| 23 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 24 | static int cfg_ecalldata_get(mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err) |
| 25 | { |
| 26 | ATResponse *response = NULL; |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame^] | 27 | // char *tmp_ptr = NULL; |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 28 | int tmp_int; |
| 29 | char cmd[100] = {0}; |
| 30 | int err = 0; |
| 31 | |
| 32 | snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type); |
| 33 | err = at_send_command_singleline(cmd, "*ECALLDATA:", &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 | err = at_tok_start(&line); |
| 42 | if (err < 0) |
| 43 | { |
| 44 | goto exit; |
| 45 | } |
| 46 | |
| 47 | err = at_tok_nextint(&line, &tmp_int); |
| 48 | if (err < 0) |
| 49 | { |
| 50 | goto exit; |
| 51 | } |
| 52 | |
| 53 | err = at_tok_nextint(&line, &tmp_int); |
| 54 | if (err < 0) |
| 55 | { |
| 56 | goto exit; |
| 57 | } |
| 58 | |
| 59 | err = at_tok_nextint(&line, &tmp_int); |
| 60 | if (err < 0) |
| 61 | { |
| 62 | goto exit; |
| 63 | } |
| 64 | |
| 65 | *value = (uint32)(tmp_int * 20); // ms |
| 66 | |
| 67 | goto exit; |
| 68 | exit: |
| 69 | at_response_free(response); |
| 70 | return err; |
| 71 | } |
| 72 | |
| 73 | static int cfg_ecalldata_set(mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err) |
| 74 | { |
| 75 | ATResponse *response = NULL; |
| 76 | char cmd[100] = {0}; |
| 77 | int err = 0; |
| 78 | |
| 79 | snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d,%d", type, value / 20); |
| 80 | err = at_send_command(cmd, &response); |
| 81 | if (err < 0 || response->success == 0){ |
| 82 | *cme_err = at_get_cme_error(response); |
| 83 | goto exit; |
| 84 | } |
| 85 | |
| 86 | goto exit; |
| 87 | exit: |
| 88 | at_response_free(response); |
| 89 | return err; |
| 90 | } |
| 91 | |
| 92 | static int cfg_ecalltimer_set(const char* type, uint32 value, int *cme_err) |
| 93 | { |
| 94 | ATResponse *response = NULL; |
| 95 | char cmd[100] = {0}; |
| 96 | int err = 0; |
| 97 | |
| 98 | snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=%s,%d", type, value); |
| 99 | err = at_send_command(cmd, &response); |
| 100 | if (err < 0 || response->success == 0){ |
| 101 | *cme_err = at_get_cme_error(response); |
| 102 | goto exit; |
| 103 | } |
| 104 | |
| 105 | goto exit; |
| 106 | exit: |
| 107 | at_response_free(response); |
| 108 | return err; |
| 109 | } |
| 110 | |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 111 | static int req_ecall_msdcfg(mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err) |
| 112 | { |
| 113 | ATResponse *response = NULL; |
| 114 | char cmd[1024] = {0}; |
| 115 | sprintf(cmd, "AT*ECALLMSDCFG=%d,\"%s\",0", cfg_info->item_type, cfg_info->data); |
| 116 | int err = at_send_command(cmd, &response); |
| 117 | if (err < 0 || response->success == 0){ |
| 118 | *cme_err = at_get_cme_error(response); |
| 119 | goto exit; |
| 120 | } |
| 121 | |
| 122 | exit: |
| 123 | at_response_free(response); |
| 124 | return err; |
| 125 | } |
| 126 | |
| 127 | static int req_ecall_msdgen(int *cme_err) |
| 128 | { |
| 129 | ATResponse *response = NULL; |
| 130 | int err = at_send_command("AT*ECALLMSDGEN", &response); |
| 131 | if (err < 0 || response->success == 0){ |
| 132 | *cme_err = at_get_cme_error(response); |
| 133 | goto exit; |
| 134 | } |
| 135 | |
| 136 | exit: |
| 137 | at_response_free(response); |
| 138 | return err; |
| 139 | } |
| 140 | |
| 141 | static int req_ecall_msd_set(const uint8 *msd, int *cme_err) |
| 142 | { |
| 143 | ATResponse *response = NULL; |
| 144 | char cmd[1024] = {0}; |
| 145 | sprintf(cmd, "AT*ECALLMSD=\"%s\"", msd); |
| 146 | int err = at_send_command(cmd, &response); |
| 147 | if (err < 0 || response->success == 0){ |
| 148 | *cme_err = at_get_cme_error(response); |
| 149 | goto exit; |
| 150 | } |
| 151 | |
| 152 | exit: |
| 153 | at_response_free(response); |
| 154 | return err; |
| 155 | } |
| 156 | |
| 157 | static int req_ecall_msd_get(uint8 *msd, int *cme_err) |
| 158 | { |
| 159 | ATResponse *response = NULL; |
| 160 | char *tmp_ptr = NULL; |
| 161 | int err = at_send_command_singleline("AT*ECALLMSD?", "*ECALLMSD:", &response); |
| 162 | |
| 163 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 164 | *cme_err = at_get_cme_error(response); |
| 165 | goto exit; |
| 166 | } |
| 167 | |
| 168 | char *line = response->p_intermediates->line; |
| 169 | err = at_tok_start(&line); |
| 170 | if (err < 0) |
| 171 | { |
| 172 | goto exit; |
| 173 | } |
| 174 | |
| 175 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 176 | if (err < 0) |
| 177 | { |
| 178 | goto exit; |
| 179 | } |
| 180 | |
| 181 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 182 | memcpy(msd, tmp_ptr, strlen(tmp_ptr)); |
| 183 | } |
| 184 | |
| 185 | goto exit; |
| 186 | exit: |
| 187 | at_response_free(response); |
| 188 | return err; |
| 189 | } |
| 190 | |
| 191 | static int req_ecall_push(int *cme_err) |
| 192 | { |
| 193 | ATResponse *response = NULL; |
| 194 | int err = at_send_command("AT*ECALLPUSH", &response); |
| 195 | if (err < 0 || response->success == 0){ |
| 196 | *cme_err = at_get_cme_error(response); |
| 197 | goto exit; |
| 198 | } |
| 199 | |
| 200 | exit: |
| 201 | at_response_free(response); |
| 202 | return err; |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | AT*ECALLONLY? |
| 207 | *ECALLONLY: 0,0,18981911691,18981911691 |
| 208 | |
| 209 | OK |
| 210 | |
| 211 | */ |
| 212 | static int req_ecall_only_get(mbtk_ecall_only_info_t *only_info, int *cme_err) |
| 213 | { |
| 214 | ATResponse *response = NULL; |
| 215 | char *tmp_ptr = NULL; |
| 216 | int tmp_int; |
| 217 | int err = at_send_command_singleline("AT*ECALLONLY?", "*ECALLONLY:", &response); |
| 218 | |
| 219 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 220 | *cme_err = at_get_cme_error(response); |
| 221 | goto exit; |
| 222 | } |
| 223 | |
| 224 | char *line = response->p_intermediates->line; |
| 225 | err = at_tok_start(&line); |
| 226 | if (err < 0) |
| 227 | { |
| 228 | goto exit; |
| 229 | } |
| 230 | |
| 231 | err = at_tok_nextint(&line, &tmp_int); |
| 232 | if (err < 0) |
| 233 | { |
| 234 | goto exit; |
| 235 | } |
| 236 | only_info->active = (mbtk_ecall_only_type_enum)tmp_int; |
| 237 | |
| 238 | err = at_tok_nextint(&line, &tmp_int); |
| 239 | if (err < 0) |
| 240 | { |
| 241 | goto exit; |
| 242 | } |
| 243 | only_info->sim_type = (mbtk_ecall_sim_type_enum)tmp_int; |
| 244 | |
| 245 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 246 | if (err < 0) |
| 247 | { |
| 248 | goto exit; |
| 249 | } |
| 250 | |
| 251 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 252 | memcpy(only_info->test_num, tmp_ptr, strlen(tmp_ptr)); |
| 253 | } |
| 254 | |
| 255 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 256 | if (err < 0) |
| 257 | { |
| 258 | goto exit; |
| 259 | } |
| 260 | |
| 261 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 262 | memcpy(only_info->reconfig_num, tmp_ptr, strlen(tmp_ptr)); |
| 263 | } |
| 264 | |
| 265 | goto exit; |
| 266 | exit: |
| 267 | at_response_free(response); |
| 268 | return err; |
| 269 | } |
| 270 | |
| 271 | /* |
| 272 | AT*ECALLONLY? |
| 273 | *ECALLONLY: 0,0,18981911691,18981911691 |
| 274 | |
| 275 | OK |
| 276 | |
| 277 | */ |
| 278 | static int req_ecall_only_set(const mbtk_ecall_only_info_t *only_info, int *cme_err) |
| 279 | { |
| 280 | ATResponse *response = NULL; |
| 281 | char cmd[1024] = {0}; |
| 282 | sprintf(cmd, "AT*ECALLONLY=%d,%s,%s", only_info->active,only_info->test_num,only_info->reconfig_num); |
| 283 | int err = at_send_command(cmd, &response); |
| 284 | if (err < 0 || response->success == 0){ |
| 285 | *cme_err = at_get_cme_error(response); |
| 286 | goto exit; |
| 287 | } |
| 288 | |
| 289 | exit: |
| 290 | at_response_free(response); |
| 291 | return err; |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | AT*ECALLREG=0/1 |
| 296 | |
| 297 | */ |
| 298 | static int req_ecall_reg_set(uint8 reg, int *cme_err) |
| 299 | { |
| 300 | ATResponse *response = NULL; |
| 301 | char cmd[30] = {0}; |
| 302 | sprintf(cmd, "AT*ECALLREG=%d", reg); |
| 303 | int err = at_send_command(cmd, &response); |
| 304 | if (err < 0 || response->success == 0){ |
| 305 | *cme_err = at_get_cme_error(response); |
| 306 | goto exit; |
| 307 | } |
| 308 | |
| 309 | exit: |
| 310 | at_response_free(response); |
| 311 | return err; |
| 312 | } |
| 313 | |
| 314 | /* |
| 315 | AT+CECALL? |
| 316 | +CECALL: 4 |
| 317 | |
| 318 | OK |
| 319 | |
| 320 | */ |
| 321 | static int req_ecall_dial_state_get(mbtk_ecall_dial_type_enum *type, int *cme_err) |
| 322 | { |
| 323 | ATResponse *response = NULL; |
| 324 | int tmp_int; |
| 325 | int err = at_send_command_singleline("AT+CECALL?", "+CECALL:", &response); |
| 326 | |
| 327 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 328 | *cme_err = at_get_cme_error(response); |
| 329 | goto exit; |
| 330 | } |
| 331 | |
| 332 | char *line = response->p_intermediates->line; |
| 333 | err = at_tok_start(&line); |
| 334 | if (err < 0) |
| 335 | { |
| 336 | goto exit; |
| 337 | } |
| 338 | |
| 339 | err = at_tok_nextint(&line, &tmp_int); |
| 340 | if (err < 0) |
| 341 | { |
| 342 | goto exit; |
| 343 | } |
| 344 | *type = (mbtk_ecall_dial_type_enum)tmp_int; |
| 345 | |
| 346 | goto exit; |
| 347 | exit: |
| 348 | at_response_free(response); |
| 349 | return err; |
| 350 | } |
| 351 | |
| 352 | /* |
| 353 | AT+CECALL=<ecalltype> |
| 354 | OK |
| 355 | */ |
| 356 | static int req_ecall_dial_start(mbtk_ecall_dial_type_enum type, int *cme_err) |
| 357 | { |
| 358 | ATResponse *response = NULL; |
| 359 | char cmd[1024] = {0}; |
| 360 | sprintf(cmd, "AT+CECALL=%d", type); |
| 361 | int err = at_send_command(cmd, &response); |
| 362 | if (err < 0 || response->success == 0){ |
| 363 | *cme_err = at_get_cme_error(response); |
| 364 | goto exit; |
| 365 | } |
| 366 | |
| 367 | exit: |
| 368 | at_response_free(response); |
| 369 | return err; |
| 370 | } |
| 371 | |
| 372 | |
| 373 | /* |
| 374 | AT*ECALLMODE? |
| 375 | *ECALLMODE: "ERA" |
| 376 | |
| 377 | OK |
| 378 | |
| 379 | */ |
| 380 | static int req_ecall_mode_get(mbtk_ecall_mode_type_enum *mode, int *cme_err) |
| 381 | { |
| 382 | ATResponse *response = NULL; |
| 383 | char *tmp_ptr = NULL; |
| 384 | int err = at_send_command_singleline("AT*ECALLMODE?", "*ECALLMODE:", &response); |
| 385 | |
| 386 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 387 | *cme_err = at_get_cme_error(response); |
| 388 | goto exit; |
| 389 | } |
| 390 | |
| 391 | char *line = response->p_intermediates->line; |
| 392 | err = at_tok_start(&line); |
| 393 | if (err < 0) |
| 394 | { |
| 395 | goto exit; |
| 396 | } |
| 397 | |
| 398 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 399 | if (err < 0) |
| 400 | { |
| 401 | goto exit; |
| 402 | } |
| 403 | |
| 404 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 405 | if(strcmp(tmp_ptr, "ERA") == 0) { |
| 406 | *mode = MBTK_ECALL_MODE_TYPE_ERA; |
| 407 | } else { |
| 408 | *mode = MBTK_ECALL_MODE_TYPE_EU; |
| 409 | } |
| 410 | |
| 411 | ecall_mode = *mode; |
| 412 | } else { |
| 413 | err = -1; |
| 414 | } |
| 415 | |
| 416 | goto exit; |
| 417 | exit: |
| 418 | at_response_free(response); |
| 419 | return err; |
| 420 | } |
| 421 | |
| 422 | /* |
| 423 | AT*ECALLMODE="ERA" |
| 424 | OK |
| 425 | |
| 426 | */ |
| 427 | static int req_ecall_mode_set(mbtk_ecall_mode_type_enum mode, int *cme_err) |
| 428 | { |
| 429 | ATResponse *response = NULL; |
| 430 | char cmd[1024] = {0}; |
| 431 | if(mode == MBTK_ECALL_MODE_TYPE_EU) { |
| 432 | sprintf(cmd, "AT*ECALLMODE=\"EU\""); |
| 433 | } else { |
| 434 | sprintf(cmd, "AT*ECALLMODE=\"ERA\""); |
| 435 | } |
| 436 | int err = at_send_command(cmd, &response); |
| 437 | if (err < 0 || response->success == 0){ |
| 438 | *cme_err = at_get_cme_error(response); |
| 439 | goto exit; |
| 440 | } |
| 441 | |
| 442 | ecall_mode = mode; |
| 443 | |
| 444 | exit: |
| 445 | at_response_free(response); |
| 446 | return err; |
| 447 | } |
| 448 | |
| 449 | /* |
| 450 | AT*ECALLDATA=5,2 |
| 451 | *ECALLDATA: 5,2,250 |
| 452 | |
| 453 | OK |
| 454 | |
| 455 | AT*ECALLTIMER? |
| 456 | *ECALLTIMER: ERA mode, callback timer: 1200s, dial setup timer: 30s, NAD deregister timer: 7200s, cleardown timer: 3600s, redial attempts count: 10, redial wait timer: 30s, smsprocess: 1, SMS resend timer: 3600s, sms msd send count: 10. |
| 457 | |
| 458 | OK |
| 459 | |
| 460 | */ |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 461 | static int req_ecall_cfg_get(uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err) |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 462 | { |
| 463 | ATResponse *response = NULL; |
| 464 | char *tmp_ptr = NULL; |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame^] | 465 | // int tmp_int; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 466 | int err = 0; |
| 467 | |
| 468 | cfg->type = type; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 469 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 470 | if(type & MBTK_ECALL_CFG_T3) { |
| 471 | if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err) |
| 472 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 473 | { |
| 474 | goto exit; |
| 475 | } |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 476 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_T3] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 477 | } |
| 478 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 479 | if(type & MBTK_ECALL_CFG_T5) { |
| 480 | if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err) |
| 481 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 482 | { |
| 483 | goto exit; |
| 484 | } |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 485 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_T5] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 486 | } |
| 487 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 488 | if(type & MBTK_ECALL_CFG_T6) { |
| 489 | if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err) |
| 490 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 491 | { |
| 492 | goto exit; |
| 493 | } |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 494 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_T6] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 495 | } |
| 496 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 497 | if(type & MBTK_ECALL_CFG_T7) { |
| 498 | if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err) |
| 499 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 500 | { |
| 501 | goto exit; |
| 502 | } |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 503 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_T7] = (uint8)1; |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | if(type & MBTK_ECALL_CFG_TH) { |
| 507 | if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err) |
| 508 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 509 | { |
| 510 | goto exit; |
| 511 | } |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 512 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TH] = (uint8)1; |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | if(type & (MBTK_ECALL_CFG_TIMER_CALLBACK | MBTK_ECALL_CFG_TIMER_CLEARDOWN | MBTK_ECALL_CFG_TIMER_DEREG |
| 516 | | MBTK_ECALL_CFG_TIMER_DIAL | MBTK_ECALL_CFG_TIMER_REDIAL | MBTK_ECALL_CFG_TIMER_SMS |
| 517 | | MBTK_ECALL_CFG_REDIALCNT | MBTK_ECALL_CFG_SMSPROCESS | MBTK_ECALL_CFG_SMSMSDCNT)) { |
| 518 | err = at_send_command_singleline("AT*ECALLTIMER?", "*ECALLTIMER:", &response); |
| 519 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 520 | *cme_err = at_get_cme_error(response); |
| 521 | goto exit; |
| 522 | } |
| 523 | |
| 524 | char *line = response->p_intermediates->line; |
| 525 | err = at_tok_start(&line); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 526 | if (err < 0) |
| 527 | { |
| 528 | goto exit; |
| 529 | } |
| 530 | |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 531 | // *ECALLTIMER: ERA mode, callback timer: 1200s, |
| 532 | // dial setup timer: 30s, NAD deregister timer: 7200s, |
| 533 | // cleardown timer: 3600s, redial attempts count: 10, |
| 534 | // redial wait timer: 30s, smsprocess: 1, SMS resend timer: 3600s, |
| 535 | // sms msd send count: 10. |
| 536 | |
| 537 | if(strstr(line, "ERA mode") != NULL) { |
| 538 | ecall_mode = MBTK_ECALL_MODE_TYPE_ERA; |
| 539 | } else { |
| 540 | ecall_mode = MBTK_ECALL_MODE_TYPE_EU; |
| 541 | } |
| 542 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 543 | if(type & MBTK_ECALL_CFG_TIMER_CALLBACK) |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 544 | { |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 545 | if((tmp_ptr = strstr(line, "callback timer: ")) != NULL) { |
| 546 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] = (uint32)atoi(tmp_ptr + 16); // s |
| 547 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 548 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 549 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | if(type & MBTK_ECALL_CFG_TIMER_CLEARDOWN) |
| 553 | { |
| 554 | if((tmp_ptr = strstr(line, "cleardown timer: ")) != NULL) { |
| 555 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] = (uint32)atoi(tmp_ptr + 17); // s |
| 556 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 557 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 558 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | if(type & MBTK_ECALL_CFG_TIMER_DEREG) |
| 562 | { |
| 563 | if((tmp_ptr = strstr(line, "deregister timer: ")) != NULL) { |
| 564 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] = (uint32)atoi(tmp_ptr + 18); // s |
| 565 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 566 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 567 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | if(type & MBTK_ECALL_CFG_TIMER_DIAL) |
| 571 | { |
| 572 | if((tmp_ptr = strstr(line, "dial setup timer: ")) != NULL) { |
| 573 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = (uint32)atoi(tmp_ptr + 18); // s |
| 574 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 575 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 576 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | if(type & MBTK_ECALL_CFG_TIMER_REDIAL) |
| 580 | { |
| 581 | if((tmp_ptr = strstr(line, "redial wait timer: ")) != NULL) { |
| 582 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] = (uint32)atoi(tmp_ptr + 19); // s |
| 583 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 584 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 585 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | if(type & MBTK_ECALL_CFG_TIMER_SMS) |
| 589 | { |
| 590 | if((tmp_ptr = strstr(line, "SMS resend timer: ")) != NULL) { |
| 591 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] = (uint32)atoi(tmp_ptr + 18); |
| 592 | cfg->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] *= 1000; // s -> ms |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 593 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_SMS] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 594 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | if(type & MBTK_ECALL_CFG_REDIALCNT) |
| 598 | { |
| 599 | if((tmp_ptr = strstr(line, "redial attempts count: ")) != NULL) { |
| 600 | cfg->data[MBTK_ECALL_CFG_ITEM_REDIALCNT] = (uint32)atoi(tmp_ptr + 23); |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 601 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_REDIALCNT] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 602 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | if(type & MBTK_ECALL_CFG_SMSPROCESS) |
| 606 | { |
| 607 | if((tmp_ptr = strstr(line, "smsprocess: ")) != NULL) { |
| 608 | cfg->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS] = (uint32)atoi(tmp_ptr + 12); |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 609 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_SMSPROCESS] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 610 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | if(type & MBTK_ECALL_CFG_SMSMSDCNT) |
| 614 | { |
| 615 | if((tmp_ptr = strstr(line, "sms msd send count: ")) != NULL) { |
| 616 | cfg->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT] = (uint32)atoi(tmp_ptr + 20); |
b.liu | 9d0a70f | 2024-11-06 11:26:17 +0800 | [diff] [blame] | 617 | cfg->data_valid[MBTK_ECALL_CFG_ITEM_SMSMSDCNT] = (uint8)1; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 618 | } |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 619 | } |
| 620 | } |
| 621 | |
| 622 | goto exit; |
| 623 | exit: |
| 624 | at_response_free(response); |
| 625 | return err; |
| 626 | } |
| 627 | |
| 628 | /* |
| 629 | AT*ECALLDATA=5,2,250 |
| 630 | OK |
| 631 | |
| 632 | AT*ECALLTIMER=dereg,300 |
| 633 | OK |
| 634 | */ |
| 635 | static int req_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err) |
| 636 | { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 637 | int err = 0; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 638 | if(ecall_mode == MBTK_ECALL_MODE_TYPE_EU) { |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 639 | if((cfg_info->type & MBTK_ECALL_CFG_TIMER_REDIAL) |
| 640 | || (cfg_info->type & MBTK_ECALL_CFG_TIMER_SMS) |
| 641 | || (cfg_info->type & MBTK_ECALL_CFG_REDIALCNT) |
| 642 | || (cfg_info->type & MBTK_ECALL_CFG_SMSPROCESS) |
| 643 | || (cfg_info->type & MBTK_ECALL_CFG_SMSMSDCNT)){ |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 644 | LOGW("No support for EU."); |
| 645 | return -1; |
| 646 | } |
| 647 | } |
| 648 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 649 | if(cfg_info->type & MBTK_ECALL_CFG_T3) { |
| 650 | if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err) |
| 651 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 652 | { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 653 | goto exit; |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 654 | } |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 655 | } |
| 656 | |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 657 | if(cfg_info->type & MBTK_ECALL_CFG_T5) { |
| 658 | if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err) |
| 659 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 660 | { |
| 661 | goto exit; |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | if(cfg_info->type & MBTK_ECALL_CFG_T6) { |
| 666 | if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err) |
| 667 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 668 | { |
| 669 | goto exit; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | if(cfg_info->type & MBTK_ECALL_CFG_T7) { |
| 674 | if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err) |
| 675 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 676 | { |
| 677 | goto exit; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | if(cfg_info->type & MBTK_ECALL_CFG_TH) { |
| 682 | if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err) |
| 683 | || *cme_err != MBTK_RIL_ERR_CME_NON) |
| 684 | { |
| 685 | goto exit; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CALLBACK) |
| 690 | { |
| 691 | if(cfg_ecalltimer_set("callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err) |
| 692 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 693 | goto exit; |
| 694 | } |
| 695 | } |
| 696 | if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CLEARDOWN) |
| 697 | { |
| 698 | if(cfg_ecalltimer_set("cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err) |
| 699 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 700 | goto exit; |
| 701 | } |
| 702 | } |
| 703 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG) |
| 704 | { |
| 705 | if(cfg_ecalltimer_set("dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err) |
| 706 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 707 | goto exit; |
| 708 | } |
| 709 | } |
| 710 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL) |
| 711 | { |
| 712 | if(cfg_ecalltimer_set("dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err) |
| 713 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 714 | goto exit; |
| 715 | } |
| 716 | } |
| 717 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL) |
| 718 | { |
| 719 | if(cfg_ecalltimer_set("redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err) |
| 720 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 721 | goto exit; |
| 722 | } |
| 723 | } |
| 724 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS) |
| 725 | { |
| 726 | if(cfg_ecalltimer_set("sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err) |
| 727 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 728 | goto exit; |
| 729 | } |
| 730 | } |
| 731 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT) |
| 732 | { |
| 733 | if(cfg_ecalltimer_set("redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err) |
| 734 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 735 | goto exit; |
| 736 | } |
| 737 | } |
| 738 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS) |
| 739 | { |
| 740 | if(cfg_ecalltimer_set("smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err) |
| 741 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 742 | goto exit; |
| 743 | } |
| 744 | } |
| 745 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT) |
| 746 | { |
| 747 | if(cfg_ecalltimer_set("smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err) |
| 748 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 749 | goto exit; |
| 750 | } |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | exit: |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 754 | return err; |
| 755 | } |
| 756 | |
| 757 | /* |
| 758 | AT*ECALLMUTESPK=1 |
| 759 | OK |
| 760 | |
| 761 | */ |
| 762 | static int req_ecall_spkmute_set(int mute, int *cme_err) |
| 763 | { |
| 764 | ATResponse *response = NULL; |
| 765 | char cmd[100] = {0}; |
| 766 | sprintf(cmd, "AT*ECALLMUTESPK=%d", mute); |
| 767 | int err = at_send_command(cmd, &response); |
| 768 | if (err < 0 || response->success == 0){ |
| 769 | *cme_err = at_get_cme_error(response); |
| 770 | goto exit; |
| 771 | } |
| 772 | |
| 773 | exit: |
| 774 | at_response_free(response); |
| 775 | return err; |
| 776 | } |
| 777 | |
| 778 | |
| 779 | /* |
| 780 | AT*ECALLSMSNUM? |
| 781 | *ECALLSMSNUM: "18981991452" |
| 782 | |
| 783 | OK |
| 784 | |
| 785 | */ |
| 786 | static int req_ecall_sms_num_get(uint8 *number, int *cme_err) |
| 787 | { |
| 788 | ATResponse *response = NULL; |
| 789 | char *tmp_ptr = NULL; |
| 790 | int err = at_send_command_singleline("AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response); |
| 791 | |
| 792 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 793 | *cme_err = at_get_cme_error(response); |
| 794 | goto exit; |
| 795 | } |
| 796 | |
| 797 | char *line = response->p_intermediates->line; |
| 798 | err = at_tok_start(&line); |
| 799 | if (err < 0) |
| 800 | { |
| 801 | goto exit; |
| 802 | } |
| 803 | |
| 804 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 805 | if (err < 0) |
| 806 | { |
| 807 | goto exit; |
| 808 | } |
| 809 | |
| 810 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 811 | memcpy(number, tmp_ptr, strlen(tmp_ptr)); |
| 812 | } |
| 813 | |
| 814 | goto exit; |
| 815 | exit: |
| 816 | at_response_free(response); |
| 817 | return err; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | AT*ECALLSMSNUM=18981991452 |
| 822 | OK |
| 823 | |
| 824 | */ |
| 825 | static int req_ecall_sms_num_set(const uint8 *number, int *cme_err) |
| 826 | { |
| 827 | ATResponse *response = NULL; |
| 828 | char cmd[100] = {0}; |
| 829 | sprintf(cmd, "AT*ECALLSMSNUM=%s", number); |
| 830 | int err = at_send_command(cmd, &response); |
| 831 | if (err < 0 || response->success == 0){ |
| 832 | *cme_err = at_get_cme_error(response); |
| 833 | goto exit; |
| 834 | } |
| 835 | |
| 836 | exit: |
| 837 | at_response_free(response); |
| 838 | return err; |
| 839 | } |
| 840 | |
| 841 | /* |
| 842 | AT*AUDGAIN=8,1 // Set Rx voice gain = 8dB |
| 843 | OK |
| 844 | |
| 845 | */ |
| 846 | static int req_ecall_gain_set(mbtk_ecall_gain_info_t *gain, int *cme_err) |
| 847 | { |
| 848 | ATResponse *response = NULL; |
| 849 | char cmd[100] = {0}; |
| 850 | sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode); |
| 851 | int err = at_send_command(cmd, &response); |
| 852 | if (err < 0 || response->success == 0){ |
| 853 | *cme_err = at_get_cme_error(response); |
| 854 | goto exit; |
| 855 | } |
| 856 | |
| 857 | exit: |
| 858 | at_response_free(response); |
| 859 | return err; |
| 860 | } |
| 861 | |
| 862 | //void net_list_free(void *data); |
| 863 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 864 | // Otherwise, do not call pack_error_send(). |
| 865 | mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack) |
| 866 | { |
| 867 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS; |
| 868 | int cme_err = MBTK_RIL_ERR_CME_NON; |
| 869 | switch(pack->msg_id) |
| 870 | { |
| 871 | case RIL_MSG_ID_ECALL_MSDCFG: // mbtk_ecall_msd_cfg_info_t |
| 872 | { |
| 873 | if(pack->data_len == 0 || pack->data == NULL) |
| 874 | { |
| 875 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 876 | } |
| 877 | else // Set |
| 878 | { |
| 879 | mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data); |
| 880 | if(req_ecall_msdcfg(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 881 | { |
| 882 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 883 | err = MBTK_RIL_ERR_CME + cme_err; |
| 884 | } else { |
| 885 | err = MBTK_RIL_ERR_UNKNOWN; |
| 886 | } |
| 887 | LOG("AT*ECALLMSDCFG fail."); |
| 888 | } |
| 889 | else |
| 890 | { |
| 891 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 892 | } |
| 893 | } |
| 894 | break; |
| 895 | } |
| 896 | case RIL_MSG_ID_ECALL_MSDGEN: |
| 897 | { |
| 898 | if(pack->data_len == 0 || pack->data == NULL) |
| 899 | { |
| 900 | if(req_ecall_msdgen(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 901 | { |
| 902 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 903 | err = MBTK_RIL_ERR_CME + cme_err; |
| 904 | } else { |
| 905 | err = MBTK_RIL_ERR_UNKNOWN; |
| 906 | } |
| 907 | LOG("AT*ECALLMSDGEN fail."); |
| 908 | } |
| 909 | else |
| 910 | { |
| 911 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 912 | } |
| 913 | } |
| 914 | else // Set |
| 915 | { |
| 916 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 917 | } |
| 918 | break; |
| 919 | } |
| 920 | case RIL_MSG_ID_ECALL_MSD: // uint8[] |
| 921 | { |
| 922 | uint8 msd[MBTK_ECALL_MSD_LEN_MAX]; |
| 923 | memset(msd, 0, sizeof(msd)); |
| 924 | if(pack->data_len == 0 || pack->data == NULL) |
| 925 | { |
| 926 | if(req_ecall_msd_get(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 927 | { |
| 928 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 929 | err = MBTK_RIL_ERR_CME + cme_err; |
| 930 | } else { |
| 931 | err = MBTK_RIL_ERR_UNKNOWN; |
| 932 | } |
| 933 | LOG("Get MSD fail."); |
| 934 | } |
| 935 | else |
| 936 | { |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame^] | 937 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd)); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 938 | } |
| 939 | } |
| 940 | else // Set |
| 941 | { |
| 942 | memcpy(msd, pack->data, pack->data_len); |
| 943 | if(req_ecall_msd_set(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 944 | { |
| 945 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 946 | err = MBTK_RIL_ERR_CME + cme_err; |
| 947 | } else { |
| 948 | err = MBTK_RIL_ERR_UNKNOWN; |
| 949 | } |
| 950 | LOG("AT*ECALLMSD fail."); |
| 951 | } |
| 952 | else |
| 953 | { |
| 954 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 955 | } |
| 956 | } |
| 957 | break; |
| 958 | } |
| 959 | case RIL_MSG_ID_ECALL_PUSH: |
| 960 | { |
| 961 | if(pack->data_len == 0 || pack->data == NULL) |
| 962 | { |
| 963 | if(req_ecall_push(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 964 | { |
| 965 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 966 | err = MBTK_RIL_ERR_CME + cme_err; |
| 967 | } else { |
| 968 | err = MBTK_RIL_ERR_UNKNOWN; |
| 969 | } |
| 970 | LOG("AT*ECALLPUSH fail."); |
| 971 | } |
| 972 | else |
| 973 | { |
| 974 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 975 | } |
| 976 | } |
| 977 | else // Set |
| 978 | { |
| 979 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 980 | } |
| 981 | break; |
| 982 | } |
| 983 | case RIL_MSG_ID_ECALL_ONLY: // mbtk_ecall_only_info_t |
| 984 | { |
| 985 | if(pack->data_len == 0 || pack->data == NULL) |
| 986 | { |
| 987 | mbtk_ecall_only_info_t only_info; |
| 988 | memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t)); |
| 989 | if(req_ecall_only_get(&only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 990 | { |
| 991 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 992 | err = MBTK_RIL_ERR_CME + cme_err; |
| 993 | } else { |
| 994 | err = MBTK_RIL_ERR_UNKNOWN; |
| 995 | } |
| 996 | LOG("Get ecall only mode fail."); |
| 997 | } |
| 998 | else |
| 999 | { |
| 1000 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t)); |
| 1001 | } |
| 1002 | } |
| 1003 | else // Set |
| 1004 | { |
| 1005 | mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data); |
| 1006 | if(req_ecall_only_set(only_info, &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("AT*ECALLONLY 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_ECALL_REG: // reg <uint8> |
| 1023 | { |
| 1024 | if(pack->data_len == 0 || pack->data == NULL) |
| 1025 | { |
| 1026 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1027 | } |
| 1028 | else |
| 1029 | { |
| 1030 | uint8 reg = pack->data[0]; |
| 1031 | if(req_ecall_reg_set(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1032 | { |
| 1033 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1034 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1035 | } else { |
| 1036 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1037 | } |
| 1038 | LOG("ecall reg(%d) fail.", reg); |
| 1039 | } |
| 1040 | else |
| 1041 | { |
| 1042 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1043 | } |
| 1044 | } |
| 1045 | break; |
| 1046 | } |
| 1047 | case RIL_MSG_ID_ECALL_DIAL: // mbtk_ecall_dial_type_enum |
| 1048 | { |
| 1049 | if(pack->data_len == 0 || pack->data == NULL) |
| 1050 | { |
| 1051 | mbtk_ecall_dial_type_enum type; |
| 1052 | if(req_ecall_dial_state_get(&type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1053 | { |
| 1054 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1055 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1056 | } else { |
| 1057 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1058 | } |
| 1059 | LOG("Get ecall type fail."); |
| 1060 | } |
| 1061 | else |
| 1062 | { |
| 1063 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8)); |
| 1064 | } |
| 1065 | } |
| 1066 | else |
| 1067 | { |
| 1068 | mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0]; |
| 1069 | if(req_ecall_dial_start(type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1070 | { |
| 1071 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1072 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1073 | } else { |
| 1074 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1075 | } |
| 1076 | LOG("Start ecall %d fail.", type); |
| 1077 | } |
| 1078 | else |
| 1079 | { |
| 1080 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1081 | } |
| 1082 | } |
| 1083 | break; |
| 1084 | } |
| 1085 | case RIL_MSG_ID_ECALL_MODE: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t |
| 1086 | { |
| 1087 | if(pack->data_len == 0 || pack->data == NULL) |
| 1088 | { |
| 1089 | mbtk_ecall_mode_type_enum mode; |
| 1090 | if(req_ecall_mode_get(&mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1091 | { |
| 1092 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1093 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1094 | } else { |
| 1095 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1096 | } |
| 1097 | LOG("Get ecall mode fail."); |
| 1098 | } |
| 1099 | else |
| 1100 | { |
| 1101 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8)); |
| 1102 | } |
| 1103 | } |
| 1104 | else |
| 1105 | { |
| 1106 | mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0]; |
| 1107 | if(req_ecall_mode_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1108 | { |
| 1109 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1110 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1111 | } else { |
| 1112 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1113 | } |
| 1114 | LOG("Set ecall mode %d fail.", mode); |
| 1115 | } |
| 1116 | else |
| 1117 | { |
| 1118 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1119 | } |
| 1120 | } |
| 1121 | break; |
| 1122 | } |
| 1123 | case RIL_MSG_ID_ECALL_CFG: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t |
| 1124 | { |
| 1125 | if(pack->data_len == 0 || pack->data == NULL) |
| 1126 | { |
| 1127 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1128 | } |
| 1129 | else |
| 1130 | { |
| 1131 | if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set |
| 1132 | mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data; |
| 1133 | if(req_ecall_cfg_set(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1134 | { |
| 1135 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1136 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1137 | } else { |
| 1138 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1139 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1140 | LOG("Set ecall config[%x] fail.", cfg_info->type); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1141 | } |
| 1142 | else |
| 1143 | { |
| 1144 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1145 | } |
| 1146 | } else { // Get |
| 1147 | mbtk_ecall_cfg_info_t cfg_info; |
| 1148 | memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t)); |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1149 | uint32 *type = (uint32*)(pack->data); |
| 1150 | if(req_ecall_cfg_get(*type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1151 | { |
| 1152 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1153 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1154 | } else { |
| 1155 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1156 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1157 | LOG("Get ecall config[%x] fail.", *type); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1158 | } |
| 1159 | else |
| 1160 | { |
| 1161 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t)); |
| 1162 | } |
| 1163 | } |
| 1164 | } |
| 1165 | break; |
| 1166 | } |
| 1167 | case RIL_MSG_ID_ECALL_SMS_NUM: // uint8[] |
| 1168 | { |
| 1169 | uint8 number[RIL_MAX_NUMBER_LEN]; |
| 1170 | memset(number, 0, sizeof(number)); |
| 1171 | if(pack->data_len == 0 || pack->data == NULL) |
| 1172 | { |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame^] | 1173 | if(req_ecall_sms_num_get(number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON) |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 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("Get ecall sms number fail."); |
| 1181 | } |
| 1182 | else |
| 1183 | { |
b.liu | 62240ee | 2024-11-07 17:52:45 +0800 | [diff] [blame^] | 1184 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number)); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1185 | } |
| 1186 | } |
| 1187 | else // Set |
| 1188 | { |
| 1189 | memcpy(number, pack->data, pack->data_len); |
| 1190 | if(req_ecall_sms_num_set(number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1191 | { |
| 1192 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1193 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1194 | } else { |
| 1195 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1196 | } |
| 1197 | LOG("Set ecall sms number fail."); |
| 1198 | } |
| 1199 | else |
| 1200 | { |
| 1201 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1202 | } |
| 1203 | } |
| 1204 | break; |
| 1205 | } |
| 1206 | case RIL_MSG_ID_ECALL_MUTESPK: |
| 1207 | { |
| 1208 | if(pack->data_len == 0 || pack->data == NULL) |
| 1209 | { |
| 1210 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1211 | } |
| 1212 | else // Set mute state. |
| 1213 | { |
| 1214 | uint8 mute = pack->data[0]; |
| 1215 | if(pack->data_len != sizeof(uint8) || (mute != 0 && mute != 1)) |
| 1216 | { |
| 1217 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 1218 | LOG("Set spk mute parameter error."); |
| 1219 | break; |
| 1220 | } |
| 1221 | |
| 1222 | if(req_ecall_spkmute_set(mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1223 | { |
| 1224 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1225 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1226 | } else { |
| 1227 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1228 | } |
| 1229 | LOG("Set spk mute state fail."); |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1234 | } |
| 1235 | } |
| 1236 | break; |
| 1237 | } |
| 1238 | case RIL_MSG_ID_ECALL_DSP_GAIN: // mbtk_ecall_gain_info_t |
| 1239 | { |
| 1240 | if(pack->data_len == 0 || pack->data == NULL) |
| 1241 | { |
| 1242 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1243 | } |
| 1244 | else // Set |
| 1245 | { |
| 1246 | mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data; |
| 1247 | if(req_ecall_gain_set(gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON) |
| 1248 | { |
| 1249 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1250 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1251 | } else { |
| 1252 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1253 | } |
| 1254 | LOGE("Set ecall gain fail."); |
| 1255 | } |
| 1256 | else |
| 1257 | { |
| 1258 | ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0); |
| 1259 | } |
| 1260 | } |
| 1261 | break; |
| 1262 | } |
| 1263 | default: |
| 1264 | { |
| 1265 | err = MBTK_RIL_ERR_REQ_UNKNOWN; |
| 1266 | LOG("Unknown request : %s", id2str(pack->msg_id)); |
| 1267 | break; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | return err; |
| 1272 | } |
| 1273 | |
| 1274 | |
| 1275 | |