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