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 | } |
| 724 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG) |
| 725 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 726 | 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] | 727 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 728 | goto exit; |
| 729 | } |
| 730 | } |
| 731 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL) |
| 732 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 733 | 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] | 734 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 735 | goto exit; |
| 736 | } |
| 737 | } |
| 738 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL) |
| 739 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 740 | 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] | 741 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 742 | goto exit; |
| 743 | } |
| 744 | } |
| 745 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS) |
| 746 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 747 | 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] | 748 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 749 | goto exit; |
| 750 | } |
| 751 | } |
| 752 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT) |
| 753 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 754 | 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] | 755 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 756 | goto exit; |
| 757 | } |
| 758 | } |
| 759 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS) |
| 760 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 761 | 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] | 762 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 763 | goto exit; |
| 764 | } |
| 765 | } |
| 766 | if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT) |
| 767 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 768 | 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] | 769 | || *cme_err != MBTK_RIL_ERR_CME_NON) { |
| 770 | goto exit; |
| 771 | } |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | exit: |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 775 | return err; |
| 776 | } |
| 777 | |
| 778 | /* |
| 779 | AT*ECALLMUTESPK=1 |
| 780 | OK |
| 781 | |
| 782 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 783 | 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] | 784 | { |
| 785 | ATResponse *response = NULL; |
| 786 | char cmd[100] = {0}; |
| 787 | sprintf(cmd, "AT*ECALLMUTESPK=%d", mute); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 788 | int err = at_send_command(port, cmd, &response); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 789 | if (err < 0 || response->success == 0){ |
| 790 | *cme_err = at_get_cme_error(response); |
| 791 | goto exit; |
| 792 | } |
| 793 | |
| 794 | exit: |
| 795 | at_response_free(response); |
| 796 | return err; |
| 797 | } |
| 798 | |
| 799 | |
| 800 | /* |
| 801 | AT*ECALLSMSNUM? |
| 802 | *ECALLSMSNUM: "18981991452" |
| 803 | |
| 804 | OK |
| 805 | |
| 806 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 807 | 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] | 808 | { |
| 809 | ATResponse *response = NULL; |
| 810 | char *tmp_ptr = NULL; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 811 | int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 812 | |
| 813 | if (err < 0 || response->success == 0 || !response->p_intermediates){ |
| 814 | *cme_err = at_get_cme_error(response); |
| 815 | goto exit; |
| 816 | } |
| 817 | |
| 818 | char *line = response->p_intermediates->line; |
| 819 | err = at_tok_start(&line); |
| 820 | if (err < 0) |
| 821 | { |
| 822 | goto exit; |
| 823 | } |
| 824 | |
| 825 | err = at_tok_nextstr(&line, &tmp_ptr); |
| 826 | if (err < 0) |
| 827 | { |
| 828 | goto exit; |
| 829 | } |
| 830 | |
| 831 | if(tmp_ptr && strlen(tmp_ptr) > 0) { |
| 832 | memcpy(number, tmp_ptr, strlen(tmp_ptr)); |
| 833 | } |
| 834 | |
| 835 | goto exit; |
| 836 | exit: |
| 837 | at_response_free(response); |
| 838 | return err; |
| 839 | } |
| 840 | |
| 841 | /* |
| 842 | AT*ECALLSMSNUM=18981991452 |
| 843 | OK |
| 844 | |
| 845 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 846 | 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] | 847 | { |
| 848 | ATResponse *response = NULL; |
| 849 | char cmd[100] = {0}; |
| 850 | sprintf(cmd, "AT*ECALLSMSNUM=%s", number); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 851 | int err = at_send_command(port, cmd, &response); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 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 | /* |
| 863 | AT*AUDGAIN=8,1 // Set Rx voice gain = 8dB |
| 864 | OK |
| 865 | |
| 866 | */ |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 867 | 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] | 868 | { |
| 869 | ATResponse *response = NULL; |
| 870 | char cmd[100] = {0}; |
| 871 | sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 872 | int err = at_send_command(port, cmd, &response); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 873 | if (err < 0 || response->success == 0){ |
| 874 | *cme_err = at_get_cme_error(response); |
| 875 | goto exit; |
| 876 | } |
| 877 | |
| 878 | exit: |
| 879 | at_response_free(response); |
| 880 | return err; |
| 881 | } |
| 882 | |
| 883 | //void net_list_free(void *data); |
| 884 | // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP. |
| 885 | // Otherwise, do not call pack_error_send(). |
| 886 | mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack) |
| 887 | { |
| 888 | mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS; |
| 889 | int cme_err = MBTK_RIL_ERR_CME_NON; |
| 890 | switch(pack->msg_id) |
| 891 | { |
| 892 | case RIL_MSG_ID_ECALL_MSDCFG: // mbtk_ecall_msd_cfg_info_t |
| 893 | { |
| 894 | if(pack->data_len == 0 || pack->data == NULL) |
| 895 | { |
| 896 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 897 | } |
| 898 | else // Set |
| 899 | { |
| 900 | 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] | 901 | 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] | 902 | { |
| 903 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 904 | err = MBTK_RIL_ERR_CME + cme_err; |
| 905 | } else { |
| 906 | err = MBTK_RIL_ERR_UNKNOWN; |
| 907 | } |
| 908 | LOG("AT*ECALLMSDCFG fail."); |
| 909 | } |
| 910 | else |
| 911 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 912 | 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] | 913 | } |
| 914 | } |
| 915 | break; |
| 916 | } |
| 917 | case RIL_MSG_ID_ECALL_MSDGEN: |
| 918 | { |
| 919 | if(pack->data_len == 0 || pack->data == NULL) |
| 920 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 921 | 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] | 922 | { |
| 923 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 924 | err = MBTK_RIL_ERR_CME + cme_err; |
| 925 | } else { |
| 926 | err = MBTK_RIL_ERR_UNKNOWN; |
| 927 | } |
| 928 | LOG("AT*ECALLMSDGEN fail."); |
| 929 | } |
| 930 | else |
| 931 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 932 | 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] | 933 | } |
| 934 | } |
| 935 | else // Set |
| 936 | { |
| 937 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 938 | } |
| 939 | break; |
| 940 | } |
| 941 | case RIL_MSG_ID_ECALL_MSD: // uint8[] |
| 942 | { |
| 943 | uint8 msd[MBTK_ECALL_MSD_LEN_MAX]; |
| 944 | memset(msd, 0, sizeof(msd)); |
| 945 | if(pack->data_len == 0 || pack->data == NULL) |
| 946 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 947 | 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] | 948 | { |
| 949 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 950 | err = MBTK_RIL_ERR_CME + cme_err; |
| 951 | } else { |
| 952 | err = MBTK_RIL_ERR_UNKNOWN; |
| 953 | } |
| 954 | LOG("Get MSD fail."); |
| 955 | } |
| 956 | else |
| 957 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 958 | 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] | 959 | } |
| 960 | } |
| 961 | else // Set |
| 962 | { |
| 963 | memcpy(msd, pack->data, pack->data_len); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 964 | 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] | 965 | { |
| 966 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 967 | err = MBTK_RIL_ERR_CME + cme_err; |
| 968 | } else { |
| 969 | err = MBTK_RIL_ERR_UNKNOWN; |
| 970 | } |
| 971 | LOG("AT*ECALLMSD fail."); |
| 972 | } |
| 973 | else |
| 974 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 975 | 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] | 976 | } |
| 977 | } |
| 978 | break; |
| 979 | } |
| 980 | case RIL_MSG_ID_ECALL_PUSH: |
| 981 | { |
| 982 | if(pack->data_len == 0 || pack->data == NULL) |
| 983 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 984 | 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] | 985 | { |
| 986 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 987 | err = MBTK_RIL_ERR_CME + cme_err; |
| 988 | } else { |
| 989 | err = MBTK_RIL_ERR_UNKNOWN; |
| 990 | } |
| 991 | LOG("AT*ECALLPUSH fail."); |
| 992 | } |
| 993 | else |
| 994 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 995 | 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] | 996 | } |
| 997 | } |
| 998 | else // Set |
| 999 | { |
| 1000 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1001 | } |
| 1002 | break; |
| 1003 | } |
| 1004 | case RIL_MSG_ID_ECALL_ONLY: // mbtk_ecall_only_info_t |
| 1005 | { |
| 1006 | if(pack->data_len == 0 || pack->data == NULL) |
| 1007 | { |
| 1008 | mbtk_ecall_only_info_t only_info; |
| 1009 | memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t)); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1010 | 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] | 1011 | { |
| 1012 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1013 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1014 | } else { |
| 1015 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1016 | } |
| 1017 | LOG("Get ecall only mode fail."); |
| 1018 | } |
| 1019 | else |
| 1020 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1021 | 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] | 1022 | } |
| 1023 | } |
| 1024 | else // Set |
| 1025 | { |
| 1026 | 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] | 1027 | 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] | 1028 | { |
| 1029 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1030 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1031 | } else { |
| 1032 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1033 | } |
| 1034 | LOG("AT*ECALLONLY fail."); |
| 1035 | } |
| 1036 | else |
| 1037 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1038 | 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] | 1039 | } |
| 1040 | } |
| 1041 | break; |
| 1042 | } |
| 1043 | case RIL_MSG_ID_ECALL_REG: // reg <uint8> |
| 1044 | { |
| 1045 | if(pack->data_len == 0 || pack->data == NULL) |
| 1046 | { |
| 1047 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1048 | } |
| 1049 | else |
| 1050 | { |
| 1051 | uint8 reg = pack->data[0]; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1052 | 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] | 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("ecall reg(%d) fail.", reg); |
| 1060 | } |
| 1061 | else |
| 1062 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1063 | 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] | 1064 | } |
| 1065 | } |
| 1066 | break; |
| 1067 | } |
| 1068 | case RIL_MSG_ID_ECALL_DIAL: // mbtk_ecall_dial_type_enum |
| 1069 | { |
| 1070 | if(pack->data_len == 0 || pack->data == NULL) |
| 1071 | { |
| 1072 | mbtk_ecall_dial_type_enum type; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1073 | 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] | 1074 | { |
| 1075 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1076 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1077 | } else { |
| 1078 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1079 | } |
| 1080 | LOG("Get ecall type fail."); |
| 1081 | } |
| 1082 | else |
| 1083 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1084 | 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] | 1085 | } |
| 1086 | } |
| 1087 | else |
| 1088 | { |
| 1089 | 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] | 1090 | 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] | 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("Start ecall %d fail.", type); |
| 1098 | } |
| 1099 | else |
| 1100 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1101 | 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] | 1102 | } |
| 1103 | } |
| 1104 | break; |
| 1105 | } |
| 1106 | case RIL_MSG_ID_ECALL_MODE: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t |
| 1107 | { |
| 1108 | if(pack->data_len == 0 || pack->data == NULL) |
| 1109 | { |
| 1110 | mbtk_ecall_mode_type_enum mode; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1111 | 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] | 1112 | { |
| 1113 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1114 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1115 | } else { |
| 1116 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1117 | } |
| 1118 | LOG("Get ecall mode fail."); |
| 1119 | } |
| 1120 | else |
| 1121 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1122 | 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] | 1123 | } |
| 1124 | } |
| 1125 | else |
| 1126 | { |
| 1127 | 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] | 1128 | 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] | 1129 | { |
| 1130 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1131 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1132 | } else { |
| 1133 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1134 | } |
| 1135 | LOG("Set ecall mode %d fail.", mode); |
| 1136 | } |
| 1137 | else |
| 1138 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1139 | 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] | 1140 | } |
| 1141 | } |
| 1142 | break; |
| 1143 | } |
| 1144 | case RIL_MSG_ID_ECALL_CFG: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t |
| 1145 | { |
| 1146 | if(pack->data_len == 0 || pack->data == NULL) |
| 1147 | { |
| 1148 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set |
| 1153 | 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] | 1154 | 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] | 1155 | { |
| 1156 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1157 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1158 | } else { |
| 1159 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1160 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1161 | LOG("Set ecall config[%x] fail.", cfg_info->type); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1162 | } |
| 1163 | else |
| 1164 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1165 | 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] | 1166 | } |
| 1167 | } else { // Get |
| 1168 | mbtk_ecall_cfg_info_t cfg_info; |
| 1169 | memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t)); |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1170 | uint32 *type = (uint32*)(pack->data); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1171 | 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] | 1172 | { |
| 1173 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1174 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1175 | } else { |
| 1176 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1177 | } |
b.liu | eea595d | 2024-11-05 19:52:10 +0800 | [diff] [blame] | 1178 | LOG("Get ecall config[%x] fail.", *type); |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 1179 | } |
| 1180 | else |
| 1181 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1182 | 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] | 1183 | } |
| 1184 | } |
| 1185 | } |
| 1186 | break; |
| 1187 | } |
| 1188 | case RIL_MSG_ID_ECALL_SMS_NUM: // uint8[] |
| 1189 | { |
| 1190 | uint8 number[RIL_MAX_NUMBER_LEN]; |
| 1191 | memset(number, 0, sizeof(number)); |
| 1192 | if(pack->data_len == 0 || pack->data == NULL) |
| 1193 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1194 | 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] | 1195 | { |
| 1196 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1197 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1198 | } else { |
| 1199 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1200 | } |
| 1201 | LOG("Get ecall sms number fail."); |
| 1202 | } |
| 1203 | else |
| 1204 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1205 | 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] | 1206 | } |
| 1207 | } |
| 1208 | else // Set |
| 1209 | { |
| 1210 | memcpy(number, pack->data, pack->data_len); |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1211 | 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] | 1212 | { |
| 1213 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1214 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1215 | } else { |
| 1216 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1217 | } |
| 1218 | LOG("Set ecall sms number fail."); |
| 1219 | } |
| 1220 | else |
| 1221 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1222 | 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] | 1223 | } |
| 1224 | } |
| 1225 | break; |
| 1226 | } |
| 1227 | case RIL_MSG_ID_ECALL_MUTESPK: |
| 1228 | { |
| 1229 | if(pack->data_len == 0 || pack->data == NULL) |
| 1230 | { |
| 1231 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1232 | } |
| 1233 | else // Set mute state. |
| 1234 | { |
| 1235 | uint8 mute = pack->data[0]; |
| 1236 | if(pack->data_len != sizeof(uint8) || (mute != 0 && mute != 1)) |
| 1237 | { |
| 1238 | err = MBTK_RIL_ERR_REQ_PARAMETER; |
| 1239 | LOG("Set spk mute parameter error."); |
| 1240 | break; |
| 1241 | } |
| 1242 | |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1243 | 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] | 1244 | { |
| 1245 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1246 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1247 | } else { |
| 1248 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1249 | } |
| 1250 | LOG("Set spk mute state fail."); |
| 1251 | } |
| 1252 | else |
| 1253 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1254 | 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] | 1255 | } |
| 1256 | } |
| 1257 | break; |
| 1258 | } |
| 1259 | case RIL_MSG_ID_ECALL_DSP_GAIN: // mbtk_ecall_gain_info_t |
| 1260 | { |
| 1261 | if(pack->data_len == 0 || pack->data == NULL) |
| 1262 | { |
| 1263 | err = MBTK_RIL_ERR_UNSUPPORTED; |
| 1264 | } |
| 1265 | else // Set |
| 1266 | { |
| 1267 | 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] | 1268 | 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] | 1269 | { |
| 1270 | if(cme_err != MBTK_RIL_ERR_CME_NON) { |
| 1271 | err = MBTK_RIL_ERR_CME + cme_err; |
| 1272 | } else { |
| 1273 | err = MBTK_RIL_ERR_UNKNOWN; |
| 1274 | } |
| 1275 | LOGE("Set ecall gain fail."); |
| 1276 | } |
| 1277 | else |
| 1278 | { |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 1279 | 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] | 1280 | } |
| 1281 | } |
| 1282 | break; |
| 1283 | } |
| 1284 | default: |
| 1285 | { |
| 1286 | err = MBTK_RIL_ERR_REQ_UNKNOWN; |
| 1287 | LOG("Unknown request : %s", id2str(pack->msg_id)); |
| 1288 | break; |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | return err; |
| 1293 | } |
| 1294 | |
| 1295 | |
| 1296 | |