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