blob: ae8dcd72df7f979eba8ca06c4557a9ee634737b7 [file] [log] [blame]
b.liufd87baf2024-11-15 15:30:38 +08001/*
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-------- -------- -------------------------------------------------------
192024/11/04 LiuBin Initial version
20
21******************************************************************************/
b.liu15f456b2024-10-31 20:16:06 +080022#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
41static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
42
b.liub171c9a2024-11-12 19:23:29 +080043void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
b.liu15f456b2024-10-31 20:16:06 +080044
b.liub171c9a2024-11-12 19:23:29 +080045static int cfg_ecalldata_get(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
b.liueea595d2024-11-05 19:52:10 +080046{
47 ATResponse *response = NULL;
b.liu62240ee2024-11-07 17:52:45 +080048// char *tmp_ptr = NULL;
b.liueea595d2024-11-05 19:52:10 +080049 int tmp_int;
50 char cmd[100] = {0};
51 int err = 0;
52
53 snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type);
b.liub171c9a2024-11-12 19:23:29 +080054 err = at_send_command_singleline(port, cmd, "*ECALLDATA:", &response);
b.liueea595d2024-11-05 19:52:10 +080055
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;
89exit:
90 at_response_free(response);
91 return err;
92}
93
b.liub171c9a2024-11-12 19:23:29 +080094static int cfg_ecalldata_set(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
b.liueea595d2024-11-05 19:52:10 +080095{
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.liub171c9a2024-11-12 19:23:29 +0800101 err = at_send_command(port, cmd, &response);
b.liueea595d2024-11-05 19:52:10 +0800102 if (err < 0 || response->success == 0){
103 *cme_err = at_get_cme_error(response);
104 goto exit;
105 }
106
107 goto exit;
108exit:
109 at_response_free(response);
110 return err;
111}
112
b.liub171c9a2024-11-12 19:23:29 +0800113static int cfg_ecalltimer_set(ATPortType_enum port, const char* type, uint32 value, int *cme_err)
b.liueea595d2024-11-05 19:52:10 +0800114{
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.liub171c9a2024-11-12 19:23:29 +0800120 err = at_send_command(port, cmd, &response);
b.liueea595d2024-11-05 19:52:10 +0800121 if (err < 0 || response->success == 0){
122 *cme_err = at_get_cme_error(response);
123 goto exit;
124 }
125
126 goto exit;
127exit:
128 at_response_free(response);
129 return err;
130}
131
b.liub171c9a2024-11-12 19:23:29 +0800132static int req_ecall_msdcfg(ATPortType_enum port, mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800133{
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.liub171c9a2024-11-12 19:23:29 +0800137 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800138 if (err < 0 || response->success == 0){
139 *cme_err = at_get_cme_error(response);
140 goto exit;
141 }
142
143exit:
144 at_response_free(response);
145 return err;
146}
147
b.liub171c9a2024-11-12 19:23:29 +0800148static int req_ecall_msdgen(ATPortType_enum port, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800149{
150 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800151 int err = at_send_command(port, "AT*ECALLMSDGEN", &response);
b.liu15f456b2024-10-31 20:16:06 +0800152 if (err < 0 || response->success == 0){
153 *cme_err = at_get_cme_error(response);
154 goto exit;
155 }
156
157exit:
158 at_response_free(response);
159 return err;
160}
161
b.liub171c9a2024-11-12 19:23:29 +0800162static int req_ecall_msd_set(ATPortType_enum port, const uint8 *msd, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800163{
164 ATResponse *response = NULL;
165 char cmd[1024] = {0};
166 sprintf(cmd, "AT*ECALLMSD=\"%s\"", msd);
b.liub171c9a2024-11-12 19:23:29 +0800167 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800168 if (err < 0 || response->success == 0){
169 *cme_err = at_get_cme_error(response);
170 goto exit;
171 }
172
173exit:
174 at_response_free(response);
175 return err;
176}
177
b.liub171c9a2024-11-12 19:23:29 +0800178static int req_ecall_msd_get(ATPortType_enum port, uint8 *msd, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800179{
180 ATResponse *response = NULL;
181 char *tmp_ptr = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800182 int err = at_send_command_singleline(port, "AT*ECALLMSD?", "*ECALLMSD:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800183
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;
207exit:
208 at_response_free(response);
209 return err;
210}
211
b.liub171c9a2024-11-12 19:23:29 +0800212static int req_ecall_push(ATPortType_enum port, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800213{
214 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800215 int err = at_send_command(port, "AT*ECALLPUSH", &response);
b.liu15f456b2024-10-31 20:16:06 +0800216 if (err < 0 || response->success == 0){
217 *cme_err = at_get_cme_error(response);
218 goto exit;
219 }
220
221exit:
222 at_response_free(response);
223 return err;
224}
225
226/*
227AT*ECALLONLY?
228*ECALLONLY: 0,0,18981911691,18981911691
229
230OK
231
232*/
b.liub171c9a2024-11-12 19:23:29 +0800233static int req_ecall_only_get(ATPortType_enum port, mbtk_ecall_only_info_t *only_info, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800234{
235 ATResponse *response = NULL;
236 char *tmp_ptr = NULL;
237 int tmp_int;
b.liub171c9a2024-11-12 19:23:29 +0800238 int err = at_send_command_singleline(port, "AT*ECALLONLY?", "*ECALLONLY:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800239
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;
287exit:
288 at_response_free(response);
289 return err;
290}
291
292/*
293AT*ECALLONLY?
294*ECALLONLY: 0,0,18981911691,18981911691
295
296OK
297
298*/
b.liub171c9a2024-11-12 19:23:29 +0800299static int req_ecall_only_set(ATPortType_enum port, const mbtk_ecall_only_info_t *only_info, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800300{
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.liub171c9a2024-11-12 19:23:29 +0800304 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800305 if (err < 0 || response->success == 0){
306 *cme_err = at_get_cme_error(response);
307 goto exit;
308 }
309
310exit:
311 at_response_free(response);
312 return err;
313}
314
315/*
316AT*ECALLREG=0/1
317
318*/
b.liub171c9a2024-11-12 19:23:29 +0800319static int req_ecall_reg_set(ATPortType_enum port, uint8 reg, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800320{
321 ATResponse *response = NULL;
322 char cmd[30] = {0};
323 sprintf(cmd, "AT*ECALLREG=%d", reg);
b.liub171c9a2024-11-12 19:23:29 +0800324 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800325 if (err < 0 || response->success == 0){
326 *cme_err = at_get_cme_error(response);
327 goto exit;
328 }
329
330exit:
331 at_response_free(response);
332 return err;
333}
334
335/*
336AT+CECALL?
337+CECALL: 4
338
339OK
340
341*/
b.liub171c9a2024-11-12 19:23:29 +0800342static int req_ecall_dial_state_get(ATPortType_enum port, mbtk_ecall_dial_type_enum *type, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800343{
344 ATResponse *response = NULL;
345 int tmp_int;
b.liub171c9a2024-11-12 19:23:29 +0800346 int err = at_send_command_singleline(port, "AT+CECALL?", "+CECALL:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800347
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;
368exit:
369 at_response_free(response);
370 return err;
371}
372
373/*
374AT+CECALL=<ecalltype>
375OK
376*/
b.liub171c9a2024-11-12 19:23:29 +0800377static int req_ecall_dial_start(ATPortType_enum port, mbtk_ecall_dial_type_enum type, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800378{
379 ATResponse *response = NULL;
380 char cmd[1024] = {0};
381 sprintf(cmd, "AT+CECALL=%d", type);
b.liub171c9a2024-11-12 19:23:29 +0800382 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800383 if (err < 0 || response->success == 0){
384 *cme_err = at_get_cme_error(response);
385 goto exit;
386 }
387
388exit:
389 at_response_free(response);
390 return err;
391}
392
393
394/*
395AT*ECALLMODE?
396*ECALLMODE: "ERA"
397
398OK
399
400*/
b.liub171c9a2024-11-12 19:23:29 +0800401static int req_ecall_mode_get(ATPortType_enum port, mbtk_ecall_mode_type_enum *mode, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800402{
403 ATResponse *response = NULL;
404 char *tmp_ptr = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800405 int err = at_send_command_singleline(port, "AT*ECALLMODE?", "*ECALLMODE:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800406
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;
438exit:
439 at_response_free(response);
440 return err;
441}
442
443/*
444AT*ECALLMODE="ERA"
445OK
446
447*/
b.liub171c9a2024-11-12 19:23:29 +0800448static int req_ecall_mode_set(ATPortType_enum port, mbtk_ecall_mode_type_enum mode, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800449{
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.liub171c9a2024-11-12 19:23:29 +0800457 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800458 if (err < 0 || response->success == 0){
459 *cme_err = at_get_cme_error(response);
460 goto exit;
461 }
462
463 ecall_mode = mode;
464
465exit:
466 at_response_free(response);
467 return err;
468}
469
470/*
471AT*ECALLDATA=5,2
472*ECALLDATA: 5,2,250
473
474OK
475
476AT*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
479OK
480
481*/
b.liub171c9a2024-11-12 19:23:29 +0800482static int req_ecall_cfg_get(ATPortType_enum port, uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800483{
484 ATResponse *response = NULL;
485 char *tmp_ptr = NULL;
b.liu62240ee2024-11-07 17:52:45 +0800486// int tmp_int;
b.liu15f456b2024-10-31 20:16:06 +0800487 int err = 0;
488
489 cfg->type = type;
b.liu15f456b2024-10-31 20:16:06 +0800490
b.liueea595d2024-11-05 19:52:10 +0800491 if(type & MBTK_ECALL_CFG_T3) {
b.liub171c9a2024-11-12 19:23:29 +0800492 if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
b.liueea595d2024-11-05 19:52:10 +0800493 || *cme_err != MBTK_RIL_ERR_CME_NON)
494 {
495 goto exit;
496 }
b.liu9d0a70f2024-11-06 11:26:17 +0800497 cfg->data_valid[MBTK_ECALL_CFG_ITEM_T3] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800498 }
499
b.liueea595d2024-11-05 19:52:10 +0800500 if(type & MBTK_ECALL_CFG_T5) {
b.liub171c9a2024-11-12 19:23:29 +0800501 if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
b.liueea595d2024-11-05 19:52:10 +0800502 || *cme_err != MBTK_RIL_ERR_CME_NON)
503 {
504 goto exit;
505 }
b.liu9d0a70f2024-11-06 11:26:17 +0800506 cfg->data_valid[MBTK_ECALL_CFG_ITEM_T5] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800507 }
508
b.liueea595d2024-11-05 19:52:10 +0800509 if(type & MBTK_ECALL_CFG_T6) {
b.liub171c9a2024-11-12 19:23:29 +0800510 if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
b.liueea595d2024-11-05 19:52:10 +0800511 || *cme_err != MBTK_RIL_ERR_CME_NON)
512 {
513 goto exit;
514 }
b.liu9d0a70f2024-11-06 11:26:17 +0800515 cfg->data_valid[MBTK_ECALL_CFG_ITEM_T6] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800516 }
517
b.liueea595d2024-11-05 19:52:10 +0800518 if(type & MBTK_ECALL_CFG_T7) {
b.liub171c9a2024-11-12 19:23:29 +0800519 if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
b.liueea595d2024-11-05 19:52:10 +0800520 || *cme_err != MBTK_RIL_ERR_CME_NON)
521 {
522 goto exit;
523 }
b.liu9d0a70f2024-11-06 11:26:17 +0800524 cfg->data_valid[MBTK_ECALL_CFG_ITEM_T7] = (uint8)1;
b.liueea595d2024-11-05 19:52:10 +0800525 }
526
527 if(type & MBTK_ECALL_CFG_TH) {
b.liub171c9a2024-11-12 19:23:29 +0800528 if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
b.liueea595d2024-11-05 19:52:10 +0800529 || *cme_err != MBTK_RIL_ERR_CME_NON)
530 {
531 goto exit;
532 }
b.liu9d0a70f2024-11-06 11:26:17 +0800533 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TH] = (uint8)1;
b.liueea595d2024-11-05 19:52:10 +0800534 }
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.liub171c9a2024-11-12 19:23:29 +0800539 err = at_send_command_singleline(port, "AT*ECALLTIMER?", "*ECALLTIMER:", &response);
b.liueea595d2024-11-05 19:52:10 +0800540 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.liu15f456b2024-10-31 20:16:06 +0800547 if (err < 0)
548 {
549 goto exit;
550 }
551
b.liu15f456b2024-10-31 20:16:06 +0800552 // *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.liueea595d2024-11-05 19:52:10 +0800564 if(type & MBTK_ECALL_CFG_TIMER_CALLBACK)
b.liu15f456b2024-10-31 20:16:06 +0800565 {
b.liueea595d2024-11-05 19:52:10 +0800566 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.liu9d0a70f2024-11-06 11:26:17 +0800569 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800570 }
b.liueea595d2024-11-05 19:52:10 +0800571 }
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.liu9d0a70f2024-11-06 11:26:17 +0800578 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800579 }
b.liueea595d2024-11-05 19:52:10 +0800580 }
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.liu9d0a70f2024-11-06 11:26:17 +0800587 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800588 }
b.liueea595d2024-11-05 19:52:10 +0800589 }
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.liu9d0a70f2024-11-06 11:26:17 +0800596 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800597 }
b.liueea595d2024-11-05 19:52:10 +0800598 }
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.liu9d0a70f2024-11-06 11:26:17 +0800605 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800606 }
b.liueea595d2024-11-05 19:52:10 +0800607 }
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.liu9d0a70f2024-11-06 11:26:17 +0800614 cfg->data_valid[MBTK_ECALL_CFG_ITEM_TIMER_SMS] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800615 }
b.liueea595d2024-11-05 19:52:10 +0800616 }
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.liu9d0a70f2024-11-06 11:26:17 +0800622 cfg->data_valid[MBTK_ECALL_CFG_ITEM_REDIALCNT] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800623 }
b.liueea595d2024-11-05 19:52:10 +0800624 }
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.liu9d0a70f2024-11-06 11:26:17 +0800630 cfg->data_valid[MBTK_ECALL_CFG_ITEM_SMSPROCESS] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800631 }
b.liueea595d2024-11-05 19:52:10 +0800632 }
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.liu9d0a70f2024-11-06 11:26:17 +0800638 cfg->data_valid[MBTK_ECALL_CFG_ITEM_SMSMSDCNT] = (uint8)1;
b.liu15f456b2024-10-31 20:16:06 +0800639 }
b.liu15f456b2024-10-31 20:16:06 +0800640 }
641 }
642
643 goto exit;
644exit:
645 at_response_free(response);
646 return err;
647}
648
649/*
650AT*ECALLDATA=5,2,250
651OK
652
653AT*ECALLTIMER=dereg,300
654OK
655*/
b.liub171c9a2024-11-12 19:23:29 +0800656static int req_ecall_cfg_set(ATPortType_enum port, const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800657{
b.liu15f456b2024-10-31 20:16:06 +0800658 int err = 0;
b.liu15f456b2024-10-31 20:16:06 +0800659 if(ecall_mode == MBTK_ECALL_MODE_TYPE_EU) {
b.liueea595d2024-11-05 19:52:10 +0800660 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.liu15f456b2024-10-31 20:16:06 +0800665 LOGW("No support for EU.");
666 return -1;
667 }
668 }
669
b.liueea595d2024-11-05 19:52:10 +0800670 if(cfg_info->type & MBTK_ECALL_CFG_T3) {
b.liub171c9a2024-11-12 19:23:29 +0800671 if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800672 || *cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800673 {
b.liu15f456b2024-10-31 20:16:06 +0800674 goto exit;
b.liueea595d2024-11-05 19:52:10 +0800675 }
b.liu15f456b2024-10-31 20:16:06 +0800676 }
677
b.liueea595d2024-11-05 19:52:10 +0800678 if(cfg_info->type & MBTK_ECALL_CFG_T5) {
b.liub171c9a2024-11-12 19:23:29 +0800679 if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800680 || *cme_err != MBTK_RIL_ERR_CME_NON)
681 {
682 goto exit;
683 }
684 }
685
686 if(cfg_info->type & MBTK_ECALL_CFG_T6) {
b.liub171c9a2024-11-12 19:23:29 +0800687 if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800688 || *cme_err != MBTK_RIL_ERR_CME_NON)
689 {
690 goto exit;
691 }
692 }
693
694 if(cfg_info->type & MBTK_ECALL_CFG_T7) {
b.liub171c9a2024-11-12 19:23:29 +0800695 if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800696 || *cme_err != MBTK_RIL_ERR_CME_NON)
697 {
698 goto exit;
699 }
700 }
701
702 if(cfg_info->type & MBTK_ECALL_CFG_TH) {
b.liub171c9a2024-11-12 19:23:29 +0800703 if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800704 || *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.liub171c9a2024-11-12 19:23:29 +0800712 if(cfg_ecalltimer_set(port, "callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800713 || *cme_err != MBTK_RIL_ERR_CME_NON) {
714 goto exit;
715 }
716 }
717 if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CLEARDOWN)
718 {
b.liub171c9a2024-11-12 19:23:29 +0800719 if(cfg_ecalltimer_set(port, "cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800720 || *cme_err != MBTK_RIL_ERR_CME_NON) {
721 goto exit;
722 }
723 }
b.liu942ef782025-02-07 13:24:30 +0800724
725 if(cfg_info->type & MBTK_ECALL_CFG_TIMER_DEREG)
b.liueea595d2024-11-05 19:52:10 +0800726 {
b.liub171c9a2024-11-12 19:23:29 +0800727 if(cfg_ecalltimer_set(port, "dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800728 || *cme_err != MBTK_RIL_ERR_CME_NON) {
729 goto exit;
730 }
731 }
b.liu942ef782025-02-07 13:24:30 +0800732 if(cfg_info->type & MBTK_ECALL_CFG_TIMER_DIAL)
b.liueea595d2024-11-05 19:52:10 +0800733 {
b.liub171c9a2024-11-12 19:23:29 +0800734 if(cfg_ecalltimer_set(port, "dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800735 || *cme_err != MBTK_RIL_ERR_CME_NON) {
736 goto exit;
737 }
738 }
b.liu942ef782025-02-07 13:24:30 +0800739 if(cfg_info->type & MBTK_ECALL_CFG_TIMER_REDIAL)
b.liueea595d2024-11-05 19:52:10 +0800740 {
b.liub171c9a2024-11-12 19:23:29 +0800741 if(cfg_ecalltimer_set(port, "redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800742 || *cme_err != MBTK_RIL_ERR_CME_NON) {
743 goto exit;
744 }
745 }
b.liu942ef782025-02-07 13:24:30 +0800746 if(cfg_info->type & MBTK_ECALL_CFG_TIMER_SMS)
b.liueea595d2024-11-05 19:52:10 +0800747 {
b.liub171c9a2024-11-12 19:23:29 +0800748 if(cfg_ecalltimer_set(port, "sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
b.liueea595d2024-11-05 19:52:10 +0800749 || *cme_err != MBTK_RIL_ERR_CME_NON) {
750 goto exit;
751 }
752 }
b.liu942ef782025-02-07 13:24:30 +0800753 if(cfg_info->type & MBTK_ECALL_CFG_REDIALCNT)
b.liueea595d2024-11-05 19:52:10 +0800754 {
b.liub171c9a2024-11-12 19:23:29 +0800755 if(cfg_ecalltimer_set(port, "redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800756 || *cme_err != MBTK_RIL_ERR_CME_NON) {
757 goto exit;
758 }
759 }
b.liu942ef782025-02-07 13:24:30 +0800760 if(cfg_info->type & MBTK_ECALL_CFG_SMSPROCESS)
b.liueea595d2024-11-05 19:52:10 +0800761 {
b.liub171c9a2024-11-12 19:23:29 +0800762 if(cfg_ecalltimer_set(port, "smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800763 || *cme_err != MBTK_RIL_ERR_CME_NON) {
764 goto exit;
765 }
766 }
b.liu942ef782025-02-07 13:24:30 +0800767 if(cfg_info->type & MBTK_ECALL_CFG_SMSMSDCNT)
b.liueea595d2024-11-05 19:52:10 +0800768 {
b.liub171c9a2024-11-12 19:23:29 +0800769 if(cfg_ecalltimer_set(port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800770 || *cme_err != MBTK_RIL_ERR_CME_NON) {
771 goto exit;
772 }
b.liu15f456b2024-10-31 20:16:06 +0800773 }
774
775exit:
b.liu15f456b2024-10-31 20:16:06 +0800776 return err;
777}
778
779/*
780AT*ECALLMUTESPK=1
781OK
782
783*/
b.liub171c9a2024-11-12 19:23:29 +0800784static int req_ecall_spkmute_set(ATPortType_enum port, int mute, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800785{
786 ATResponse *response = NULL;
787 char cmd[100] = {0};
788 sprintf(cmd, "AT*ECALLMUTESPK=%d", mute);
b.liub171c9a2024-11-12 19:23:29 +0800789 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800790 if (err < 0 || response->success == 0){
791 *cme_err = at_get_cme_error(response);
792 goto exit;
793 }
794
795exit:
796 at_response_free(response);
797 return err;
798}
799
800
801/*
802AT*ECALLSMSNUM?
803*ECALLSMSNUM: "18981991452"
804
805OK
806
807*/
b.liub171c9a2024-11-12 19:23:29 +0800808static int req_ecall_sms_num_get(ATPortType_enum port, uint8 *number, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800809{
810 ATResponse *response = NULL;
811 char *tmp_ptr = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800812 int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800813
814 if (err < 0 || response->success == 0 || !response->p_intermediates){
815 *cme_err = at_get_cme_error(response);
816 goto exit;
817 }
818
819 char *line = response->p_intermediates->line;
820 err = at_tok_start(&line);
821 if (err < 0)
822 {
823 goto exit;
824 }
825
826 err = at_tok_nextstr(&line, &tmp_ptr);
827 if (err < 0)
828 {
829 goto exit;
830 }
831
832 if(tmp_ptr && strlen(tmp_ptr) > 0) {
833 memcpy(number, tmp_ptr, strlen(tmp_ptr));
834 }
835
836 goto exit;
837exit:
838 at_response_free(response);
839 return err;
840}
841
842/*
843AT*ECALLSMSNUM=18981991452
844OK
845
846*/
b.liub171c9a2024-11-12 19:23:29 +0800847static int req_ecall_sms_num_set(ATPortType_enum port, const uint8 *number, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800848{
849 ATResponse *response = NULL;
850 char cmd[100] = {0};
851 sprintf(cmd, "AT*ECALLSMSNUM=%s", number);
b.liub171c9a2024-11-12 19:23:29 +0800852 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800853 if (err < 0 || response->success == 0){
854 *cme_err = at_get_cme_error(response);
855 goto exit;
856 }
857
858exit:
859 at_response_free(response);
860 return err;
861}
862
863/*
864AT*AUDGAIN=8,1 // Set Rx voice gain = 8dB
865OK
866
867*/
b.liub171c9a2024-11-12 19:23:29 +0800868static int req_ecall_gain_set(ATPortType_enum port, mbtk_ecall_gain_info_t *gain, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800869{
870 ATResponse *response = NULL;
871 char cmd[100] = {0};
872 sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode);
b.liub171c9a2024-11-12 19:23:29 +0800873 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800874 if (err < 0 || response->success == 0){
875 *cme_err = at_get_cme_error(response);
876 goto exit;
877 }
878
879exit:
880 at_response_free(response);
881 return err;
882}
883
884//void net_list_free(void *data);
885// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
886// Otherwise, do not call pack_error_send().
887mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
888{
889 mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
890 int cme_err = MBTK_RIL_ERR_CME_NON;
891 switch(pack->msg_id)
892 {
893 case RIL_MSG_ID_ECALL_MSDCFG: // mbtk_ecall_msd_cfg_info_t
894 {
895 if(pack->data_len == 0 || pack->data == NULL)
896 {
897 err = MBTK_RIL_ERR_UNSUPPORTED;
898 }
899 else // Set
900 {
901 mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +0800902 if(req_ecall_msdcfg(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800903 {
904 if(cme_err != MBTK_RIL_ERR_CME_NON) {
905 err = MBTK_RIL_ERR_CME + cme_err;
906 } else {
907 err = MBTK_RIL_ERR_UNKNOWN;
908 }
909 LOG("AT*ECALLMSDCFG fail.");
910 }
911 else
912 {
b.liub171c9a2024-11-12 19:23:29 +0800913 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +0800914 }
915 }
916 break;
917 }
918 case RIL_MSG_ID_ECALL_MSDGEN:
919 {
920 if(pack->data_len == 0 || pack->data == NULL)
921 {
b.liub171c9a2024-11-12 19:23:29 +0800922 if(req_ecall_msdgen(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800923 {
924 if(cme_err != MBTK_RIL_ERR_CME_NON) {
925 err = MBTK_RIL_ERR_CME + cme_err;
926 } else {
927 err = MBTK_RIL_ERR_UNKNOWN;
928 }
929 LOG("AT*ECALLMSDGEN fail.");
930 }
931 else
932 {
b.liub171c9a2024-11-12 19:23:29 +0800933 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +0800934 }
935 }
936 else // Set
937 {
938 err = MBTK_RIL_ERR_UNSUPPORTED;
939 }
940 break;
941 }
942 case RIL_MSG_ID_ECALL_MSD: // uint8[]
943 {
944 uint8 msd[MBTK_ECALL_MSD_LEN_MAX];
945 memset(msd, 0, sizeof(msd));
946 if(pack->data_len == 0 || pack->data == NULL)
947 {
b.liub171c9a2024-11-12 19:23:29 +0800948 if(req_ecall_msd_get(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800949 {
950 if(cme_err != MBTK_RIL_ERR_CME_NON) {
951 err = MBTK_RIL_ERR_CME + cme_err;
952 } else {
953 err = MBTK_RIL_ERR_UNKNOWN;
954 }
955 LOG("Get MSD fail.");
956 }
957 else
958 {
b.liub171c9a2024-11-12 19:23:29 +0800959 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
b.liu15f456b2024-10-31 20:16:06 +0800960 }
961 }
962 else // Set
963 {
964 memcpy(msd, pack->data, pack->data_len);
b.liub171c9a2024-11-12 19:23:29 +0800965 if(req_ecall_msd_set(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800966 {
967 if(cme_err != MBTK_RIL_ERR_CME_NON) {
968 err = MBTK_RIL_ERR_CME + cme_err;
969 } else {
970 err = MBTK_RIL_ERR_UNKNOWN;
971 }
972 LOG("AT*ECALLMSD fail.");
973 }
974 else
975 {
b.liub171c9a2024-11-12 19:23:29 +0800976 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +0800977 }
978 }
979 break;
980 }
981 case RIL_MSG_ID_ECALL_PUSH:
982 {
983 if(pack->data_len == 0 || pack->data == NULL)
984 {
b.liub171c9a2024-11-12 19:23:29 +0800985 if(req_ecall_push(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800986 {
987 if(cme_err != MBTK_RIL_ERR_CME_NON) {
988 err = MBTK_RIL_ERR_CME + cme_err;
989 } else {
990 err = MBTK_RIL_ERR_UNKNOWN;
991 }
992 LOG("AT*ECALLPUSH fail.");
993 }
994 else
995 {
b.liub171c9a2024-11-12 19:23:29 +0800996 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +0800997 }
998 }
999 else // Set
1000 {
1001 err = MBTK_RIL_ERR_UNSUPPORTED;
1002 }
1003 break;
1004 }
1005 case RIL_MSG_ID_ECALL_ONLY: // mbtk_ecall_only_info_t
1006 {
1007 if(pack->data_len == 0 || pack->data == NULL)
1008 {
1009 mbtk_ecall_only_info_t only_info;
1010 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
b.liub171c9a2024-11-12 19:23:29 +08001011 if(req_ecall_only_get(cli_info->port, &only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001012 {
1013 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1014 err = MBTK_RIL_ERR_CME + cme_err;
1015 } else {
1016 err = MBTK_RIL_ERR_UNKNOWN;
1017 }
1018 LOG("Get ecall only mode fail.");
1019 }
1020 else
1021 {
b.liub171c9a2024-11-12 19:23:29 +08001022 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.liu15f456b2024-10-31 20:16:06 +08001023 }
1024 }
1025 else // Set
1026 {
1027 mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +08001028 if(req_ecall_only_set(cli_info->port, only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001029 {
1030 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1031 err = MBTK_RIL_ERR_CME + cme_err;
1032 } else {
1033 err = MBTK_RIL_ERR_UNKNOWN;
1034 }
1035 LOG("AT*ECALLONLY fail.");
1036 }
1037 else
1038 {
b.liub171c9a2024-11-12 19:23:29 +08001039 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001040 }
1041 }
1042 break;
1043 }
1044 case RIL_MSG_ID_ECALL_REG: // reg <uint8>
1045 {
1046 if(pack->data_len == 0 || pack->data == NULL)
1047 {
1048 err = MBTK_RIL_ERR_UNSUPPORTED;
1049 }
1050 else
1051 {
1052 uint8 reg = pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001053 if(req_ecall_reg_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001054 {
1055 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1056 err = MBTK_RIL_ERR_CME + cme_err;
1057 } else {
1058 err = MBTK_RIL_ERR_UNKNOWN;
1059 }
1060 LOG("ecall reg(%d) fail.", reg);
1061 }
1062 else
1063 {
b.liub171c9a2024-11-12 19:23:29 +08001064 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001065 }
1066 }
1067 break;
1068 }
1069 case RIL_MSG_ID_ECALL_DIAL: // mbtk_ecall_dial_type_enum
1070 {
1071 if(pack->data_len == 0 || pack->data == NULL)
1072 {
1073 mbtk_ecall_dial_type_enum type;
b.liub171c9a2024-11-12 19:23:29 +08001074 if(req_ecall_dial_state_get(cli_info->port, &type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001075 {
1076 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1077 err = MBTK_RIL_ERR_CME + cme_err;
1078 } else {
1079 err = MBTK_RIL_ERR_UNKNOWN;
1080 }
1081 LOG("Get ecall type fail.");
1082 }
1083 else
1084 {
b.liub171c9a2024-11-12 19:23:29 +08001085 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
b.liu15f456b2024-10-31 20:16:06 +08001086 }
1087 }
1088 else
1089 {
1090 mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001091 if(req_ecall_dial_start(cli_info->port, type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001092 {
1093 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1094 err = MBTK_RIL_ERR_CME + cme_err;
1095 } else {
1096 err = MBTK_RIL_ERR_UNKNOWN;
1097 }
1098 LOG("Start ecall %d fail.", type);
1099 }
1100 else
1101 {
b.liub171c9a2024-11-12 19:23:29 +08001102 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001103 }
1104 }
1105 break;
1106 }
1107 case RIL_MSG_ID_ECALL_MODE: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
1108 {
1109 if(pack->data_len == 0 || pack->data == NULL)
1110 {
1111 mbtk_ecall_mode_type_enum mode;
b.liub171c9a2024-11-12 19:23:29 +08001112 if(req_ecall_mode_get(cli_info->port, &mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001113 {
1114 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1115 err = MBTK_RIL_ERR_CME + cme_err;
1116 } else {
1117 err = MBTK_RIL_ERR_UNKNOWN;
1118 }
1119 LOG("Get ecall mode fail.");
1120 }
1121 else
1122 {
b.liub171c9a2024-11-12 19:23:29 +08001123 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
b.liu15f456b2024-10-31 20:16:06 +08001124 }
1125 }
1126 else
1127 {
1128 mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001129 if(req_ecall_mode_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001130 {
1131 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1132 err = MBTK_RIL_ERR_CME + cme_err;
1133 } else {
1134 err = MBTK_RIL_ERR_UNKNOWN;
1135 }
1136 LOG("Set ecall mode %d fail.", mode);
1137 }
1138 else
1139 {
b.liub171c9a2024-11-12 19:23:29 +08001140 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001141 }
1142 }
1143 break;
1144 }
1145 case RIL_MSG_ID_ECALL_CFG: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
1146 {
1147 if(pack->data_len == 0 || pack->data == NULL)
1148 {
1149 err = MBTK_RIL_ERR_UNSUPPORTED;
1150 }
1151 else
1152 {
1153 if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set
1154 mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data;
b.liub171c9a2024-11-12 19:23:29 +08001155 if(req_ecall_cfg_set(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001156 {
1157 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1158 err = MBTK_RIL_ERR_CME + cme_err;
1159 } else {
1160 err = MBTK_RIL_ERR_UNKNOWN;
1161 }
b.liueea595d2024-11-05 19:52:10 +08001162 LOG("Set ecall config[%x] fail.", cfg_info->type);
b.liu15f456b2024-10-31 20:16:06 +08001163 }
1164 else
1165 {
b.liub171c9a2024-11-12 19:23:29 +08001166 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001167 }
1168 } else { // Get
1169 mbtk_ecall_cfg_info_t cfg_info;
1170 memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t));
b.liueea595d2024-11-05 19:52:10 +08001171 uint32 *type = (uint32*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +08001172 if(req_ecall_cfg_get(cli_info->port, *type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001173 {
1174 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1175 err = MBTK_RIL_ERR_CME + cme_err;
1176 } else {
1177 err = MBTK_RIL_ERR_UNKNOWN;
1178 }
b.liueea595d2024-11-05 19:52:10 +08001179 LOG("Get ecall config[%x] fail.", *type);
b.liu15f456b2024-10-31 20:16:06 +08001180 }
1181 else
1182 {
b.liub171c9a2024-11-12 19:23:29 +08001183 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.liu15f456b2024-10-31 20:16:06 +08001184 }
1185 }
1186 }
1187 break;
1188 }
1189 case RIL_MSG_ID_ECALL_SMS_NUM: // uint8[]
1190 {
1191 uint8 number[RIL_MAX_NUMBER_LEN];
1192 memset(number, 0, sizeof(number));
1193 if(pack->data_len == 0 || pack->data == NULL)
1194 {
b.liub171c9a2024-11-12 19:23:29 +08001195 if(req_ecall_sms_num_get(cli_info->port, number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001196 {
1197 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1198 err = MBTK_RIL_ERR_CME + cme_err;
1199 } else {
1200 err = MBTK_RIL_ERR_UNKNOWN;
1201 }
1202 LOG("Get ecall sms number fail.");
1203 }
1204 else
1205 {
b.liub171c9a2024-11-12 19:23:29 +08001206 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
b.liu15f456b2024-10-31 20:16:06 +08001207 }
1208 }
1209 else // Set
1210 {
1211 memcpy(number, pack->data, pack->data_len);
b.liub171c9a2024-11-12 19:23:29 +08001212 if(req_ecall_sms_num_set(cli_info->port, number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001213 {
1214 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1215 err = MBTK_RIL_ERR_CME + cme_err;
1216 } else {
1217 err = MBTK_RIL_ERR_UNKNOWN;
1218 }
1219 LOG("Set ecall sms number fail.");
1220 }
1221 else
1222 {
b.liub171c9a2024-11-12 19:23:29 +08001223 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001224 }
1225 }
1226 break;
1227 }
1228 case RIL_MSG_ID_ECALL_MUTESPK:
1229 {
1230 if(pack->data_len == 0 || pack->data == NULL)
1231 {
1232 err = MBTK_RIL_ERR_UNSUPPORTED;
1233 }
1234 else // Set mute state.
1235 {
1236 uint8 mute = pack->data[0];
1237 if(pack->data_len != sizeof(uint8) || (mute != 0 && mute != 1))
1238 {
1239 err = MBTK_RIL_ERR_REQ_PARAMETER;
1240 LOG("Set spk mute parameter error.");
1241 break;
1242 }
1243
b.liub171c9a2024-11-12 19:23:29 +08001244 if(req_ecall_spkmute_set(cli_info->port, mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001245 {
1246 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1247 err = MBTK_RIL_ERR_CME + cme_err;
1248 } else {
1249 err = MBTK_RIL_ERR_UNKNOWN;
1250 }
1251 LOG("Set spk mute state fail.");
1252 }
1253 else
1254 {
b.liub171c9a2024-11-12 19:23:29 +08001255 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001256 }
1257 }
1258 break;
1259 }
1260 case RIL_MSG_ID_ECALL_DSP_GAIN: // mbtk_ecall_gain_info_t
1261 {
1262 if(pack->data_len == 0 || pack->data == NULL)
1263 {
1264 err = MBTK_RIL_ERR_UNSUPPORTED;
1265 }
1266 else // Set
1267 {
1268 mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
b.liub171c9a2024-11-12 19:23:29 +08001269 if(req_ecall_gain_set(cli_info->port, gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +08001270 {
1271 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1272 err = MBTK_RIL_ERR_CME + cme_err;
1273 } else {
1274 err = MBTK_RIL_ERR_UNKNOWN;
1275 }
1276 LOGE("Set ecall gain fail.");
1277 }
1278 else
1279 {
b.liub171c9a2024-11-12 19:23:29 +08001280 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu15f456b2024-10-31 20:16:06 +08001281 }
1282 }
1283 break;
1284 }
1285 default:
1286 {
1287 err = MBTK_RIL_ERR_REQ_UNKNOWN;
1288 LOG("Unknown request : %s", id2str(pack->msg_id));
1289 break;
1290 }
1291 }
1292
1293 return err;
1294}
1295
1296
1297