blob: a3ff510eddc6abafdfe707bba2c20854a90ef859 [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 }
724 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG)
725 {
b.liub171c9a2024-11-12 19:23:29 +0800726 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 +0800727 || *cme_err != MBTK_RIL_ERR_CME_NON) {
728 goto exit;
729 }
730 }
731 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL)
732 {
b.liub171c9a2024-11-12 19:23:29 +0800733 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 +0800734 || *cme_err != MBTK_RIL_ERR_CME_NON) {
735 goto exit;
736 }
737 }
738 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL)
739 {
b.liub171c9a2024-11-12 19:23:29 +0800740 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 +0800741 || *cme_err != MBTK_RIL_ERR_CME_NON) {
742 goto exit;
743 }
744 }
745 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS)
746 {
b.liub171c9a2024-11-12 19:23:29 +0800747 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 +0800748 || *cme_err != MBTK_RIL_ERR_CME_NON) {
749 goto exit;
750 }
751 }
752 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT)
753 {
b.liub171c9a2024-11-12 19:23:29 +0800754 if(cfg_ecalltimer_set(port, "redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800755 || *cme_err != MBTK_RIL_ERR_CME_NON) {
756 goto exit;
757 }
758 }
759 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS)
760 {
b.liub171c9a2024-11-12 19:23:29 +0800761 if(cfg_ecalltimer_set(port, "smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800762 || *cme_err != MBTK_RIL_ERR_CME_NON) {
763 goto exit;
764 }
765 }
766 if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT)
767 {
b.liub171c9a2024-11-12 19:23:29 +0800768 if(cfg_ecalltimer_set(port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
b.liueea595d2024-11-05 19:52:10 +0800769 || *cme_err != MBTK_RIL_ERR_CME_NON) {
770 goto exit;
771 }
b.liu15f456b2024-10-31 20:16:06 +0800772 }
773
774exit:
b.liu15f456b2024-10-31 20:16:06 +0800775 return err;
776}
777
778/*
779AT*ECALLMUTESPK=1
780OK
781
782*/
b.liub171c9a2024-11-12 19:23:29 +0800783static int req_ecall_spkmute_set(ATPortType_enum port, int mute, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800784{
785 ATResponse *response = NULL;
786 char cmd[100] = {0};
787 sprintf(cmd, "AT*ECALLMUTESPK=%d", mute);
b.liub171c9a2024-11-12 19:23:29 +0800788 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800789 if (err < 0 || response->success == 0){
790 *cme_err = at_get_cme_error(response);
791 goto exit;
792 }
793
794exit:
795 at_response_free(response);
796 return err;
797}
798
799
800/*
801AT*ECALLSMSNUM?
802*ECALLSMSNUM: "18981991452"
803
804OK
805
806*/
b.liub171c9a2024-11-12 19:23:29 +0800807static int req_ecall_sms_num_get(ATPortType_enum port, uint8 *number, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800808{
809 ATResponse *response = NULL;
810 char *tmp_ptr = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800811 int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
b.liu15f456b2024-10-31 20:16:06 +0800812
813 if (err < 0 || response->success == 0 || !response->p_intermediates){
814 *cme_err = at_get_cme_error(response);
815 goto exit;
816 }
817
818 char *line = response->p_intermediates->line;
819 err = at_tok_start(&line);
820 if (err < 0)
821 {
822 goto exit;
823 }
824
825 err = at_tok_nextstr(&line, &tmp_ptr);
826 if (err < 0)
827 {
828 goto exit;
829 }
830
831 if(tmp_ptr && strlen(tmp_ptr) > 0) {
832 memcpy(number, tmp_ptr, strlen(tmp_ptr));
833 }
834
835 goto exit;
836exit:
837 at_response_free(response);
838 return err;
839}
840
841/*
842AT*ECALLSMSNUM=18981991452
843OK
844
845*/
b.liub171c9a2024-11-12 19:23:29 +0800846static int req_ecall_sms_num_set(ATPortType_enum port, const uint8 *number, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800847{
848 ATResponse *response = NULL;
849 char cmd[100] = {0};
850 sprintf(cmd, "AT*ECALLSMSNUM=%s", number);
b.liub171c9a2024-11-12 19:23:29 +0800851 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800852 if (err < 0 || response->success == 0){
853 *cme_err = at_get_cme_error(response);
854 goto exit;
855 }
856
857exit:
858 at_response_free(response);
859 return err;
860}
861
862/*
863AT*AUDGAIN=8,1 // Set Rx voice gain = 8dB
864OK
865
866*/
b.liub171c9a2024-11-12 19:23:29 +0800867static int req_ecall_gain_set(ATPortType_enum port, mbtk_ecall_gain_info_t *gain, int *cme_err)
b.liu15f456b2024-10-31 20:16:06 +0800868{
869 ATResponse *response = NULL;
870 char cmd[100] = {0};
871 sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode);
b.liub171c9a2024-11-12 19:23:29 +0800872 int err = at_send_command(port, cmd, &response);
b.liu15f456b2024-10-31 20:16:06 +0800873 if (err < 0 || response->success == 0){
874 *cme_err = at_get_cme_error(response);
875 goto exit;
876 }
877
878exit:
879 at_response_free(response);
880 return err;
881}
882
883//void net_list_free(void *data);
884// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
885// Otherwise, do not call pack_error_send().
886mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
887{
888 mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
889 int cme_err = MBTK_RIL_ERR_CME_NON;
890 switch(pack->msg_id)
891 {
892 case RIL_MSG_ID_ECALL_MSDCFG: // mbtk_ecall_msd_cfg_info_t
893 {
894 if(pack->data_len == 0 || pack->data == NULL)
895 {
896 err = MBTK_RIL_ERR_UNSUPPORTED;
897 }
898 else // Set
899 {
900 mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +0800901 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 +0800902 {
903 if(cme_err != MBTK_RIL_ERR_CME_NON) {
904 err = MBTK_RIL_ERR_CME + cme_err;
905 } else {
906 err = MBTK_RIL_ERR_UNKNOWN;
907 }
908 LOG("AT*ECALLMSDCFG fail.");
909 }
910 else
911 {
b.liub171c9a2024-11-12 19:23:29 +0800912 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 +0800913 }
914 }
915 break;
916 }
917 case RIL_MSG_ID_ECALL_MSDGEN:
918 {
919 if(pack->data_len == 0 || pack->data == NULL)
920 {
b.liub171c9a2024-11-12 19:23:29 +0800921 if(req_ecall_msdgen(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800922 {
923 if(cme_err != MBTK_RIL_ERR_CME_NON) {
924 err = MBTK_RIL_ERR_CME + cme_err;
925 } else {
926 err = MBTK_RIL_ERR_UNKNOWN;
927 }
928 LOG("AT*ECALLMSDGEN fail.");
929 }
930 else
931 {
b.liub171c9a2024-11-12 19:23:29 +0800932 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 +0800933 }
934 }
935 else // Set
936 {
937 err = MBTK_RIL_ERR_UNSUPPORTED;
938 }
939 break;
940 }
941 case RIL_MSG_ID_ECALL_MSD: // uint8[]
942 {
943 uint8 msd[MBTK_ECALL_MSD_LEN_MAX];
944 memset(msd, 0, sizeof(msd));
945 if(pack->data_len == 0 || pack->data == NULL)
946 {
b.liub171c9a2024-11-12 19:23:29 +0800947 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 +0800948 {
949 if(cme_err != MBTK_RIL_ERR_CME_NON) {
950 err = MBTK_RIL_ERR_CME + cme_err;
951 } else {
952 err = MBTK_RIL_ERR_UNKNOWN;
953 }
954 LOG("Get MSD fail.");
955 }
956 else
957 {
b.liub171c9a2024-11-12 19:23:29 +0800958 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 +0800959 }
960 }
961 else // Set
962 {
963 memcpy(msd, pack->data, pack->data_len);
b.liub171c9a2024-11-12 19:23:29 +0800964 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 +0800965 {
966 if(cme_err != MBTK_RIL_ERR_CME_NON) {
967 err = MBTK_RIL_ERR_CME + cme_err;
968 } else {
969 err = MBTK_RIL_ERR_UNKNOWN;
970 }
971 LOG("AT*ECALLMSD fail.");
972 }
973 else
974 {
b.liub171c9a2024-11-12 19:23:29 +0800975 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 +0800976 }
977 }
978 break;
979 }
980 case RIL_MSG_ID_ECALL_PUSH:
981 {
982 if(pack->data_len == 0 || pack->data == NULL)
983 {
b.liub171c9a2024-11-12 19:23:29 +0800984 if(req_ecall_push(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu15f456b2024-10-31 20:16:06 +0800985 {
986 if(cme_err != MBTK_RIL_ERR_CME_NON) {
987 err = MBTK_RIL_ERR_CME + cme_err;
988 } else {
989 err = MBTK_RIL_ERR_UNKNOWN;
990 }
991 LOG("AT*ECALLPUSH fail.");
992 }
993 else
994 {
b.liub171c9a2024-11-12 19:23:29 +0800995 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 +0800996 }
997 }
998 else // Set
999 {
1000 err = MBTK_RIL_ERR_UNSUPPORTED;
1001 }
1002 break;
1003 }
1004 case RIL_MSG_ID_ECALL_ONLY: // mbtk_ecall_only_info_t
1005 {
1006 if(pack->data_len == 0 || pack->data == NULL)
1007 {
1008 mbtk_ecall_only_info_t only_info;
1009 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
b.liub171c9a2024-11-12 19:23:29 +08001010 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 +08001011 {
1012 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1013 err = MBTK_RIL_ERR_CME + cme_err;
1014 } else {
1015 err = MBTK_RIL_ERR_UNKNOWN;
1016 }
1017 LOG("Get ecall only mode fail.");
1018 }
1019 else
1020 {
b.liub171c9a2024-11-12 19:23:29 +08001021 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 +08001022 }
1023 }
1024 else // Set
1025 {
1026 mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +08001027 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 +08001028 {
1029 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1030 err = MBTK_RIL_ERR_CME + cme_err;
1031 } else {
1032 err = MBTK_RIL_ERR_UNKNOWN;
1033 }
1034 LOG("AT*ECALLONLY fail.");
1035 }
1036 else
1037 {
b.liub171c9a2024-11-12 19:23:29 +08001038 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 +08001039 }
1040 }
1041 break;
1042 }
1043 case RIL_MSG_ID_ECALL_REG: // reg <uint8>
1044 {
1045 if(pack->data_len == 0 || pack->data == NULL)
1046 {
1047 err = MBTK_RIL_ERR_UNSUPPORTED;
1048 }
1049 else
1050 {
1051 uint8 reg = pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001052 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 +08001053 {
1054 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1055 err = MBTK_RIL_ERR_CME + cme_err;
1056 } else {
1057 err = MBTK_RIL_ERR_UNKNOWN;
1058 }
1059 LOG("ecall reg(%d) fail.", reg);
1060 }
1061 else
1062 {
b.liub171c9a2024-11-12 19:23:29 +08001063 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 +08001064 }
1065 }
1066 break;
1067 }
1068 case RIL_MSG_ID_ECALL_DIAL: // mbtk_ecall_dial_type_enum
1069 {
1070 if(pack->data_len == 0 || pack->data == NULL)
1071 {
1072 mbtk_ecall_dial_type_enum type;
b.liub171c9a2024-11-12 19:23:29 +08001073 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 +08001074 {
1075 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1076 err = MBTK_RIL_ERR_CME + cme_err;
1077 } else {
1078 err = MBTK_RIL_ERR_UNKNOWN;
1079 }
1080 LOG("Get ecall type fail.");
1081 }
1082 else
1083 {
b.liub171c9a2024-11-12 19:23:29 +08001084 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 +08001085 }
1086 }
1087 else
1088 {
1089 mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001090 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 +08001091 {
1092 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1093 err = MBTK_RIL_ERR_CME + cme_err;
1094 } else {
1095 err = MBTK_RIL_ERR_UNKNOWN;
1096 }
1097 LOG("Start ecall %d fail.", type);
1098 }
1099 else
1100 {
b.liub171c9a2024-11-12 19:23:29 +08001101 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 +08001102 }
1103 }
1104 break;
1105 }
1106 case RIL_MSG_ID_ECALL_MODE: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
1107 {
1108 if(pack->data_len == 0 || pack->data == NULL)
1109 {
1110 mbtk_ecall_mode_type_enum mode;
b.liub171c9a2024-11-12 19:23:29 +08001111 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 +08001112 {
1113 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1114 err = MBTK_RIL_ERR_CME + cme_err;
1115 } else {
1116 err = MBTK_RIL_ERR_UNKNOWN;
1117 }
1118 LOG("Get ecall mode fail.");
1119 }
1120 else
1121 {
b.liub171c9a2024-11-12 19:23:29 +08001122 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 +08001123 }
1124 }
1125 else
1126 {
1127 mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0];
b.liub171c9a2024-11-12 19:23:29 +08001128 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 +08001129 {
1130 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1131 err = MBTK_RIL_ERR_CME + cme_err;
1132 } else {
1133 err = MBTK_RIL_ERR_UNKNOWN;
1134 }
1135 LOG("Set ecall mode %d fail.", mode);
1136 }
1137 else
1138 {
b.liub171c9a2024-11-12 19:23:29 +08001139 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 +08001140 }
1141 }
1142 break;
1143 }
1144 case RIL_MSG_ID_ECALL_CFG: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
1145 {
1146 if(pack->data_len == 0 || pack->data == NULL)
1147 {
1148 err = MBTK_RIL_ERR_UNSUPPORTED;
1149 }
1150 else
1151 {
1152 if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set
1153 mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data;
b.liub171c9a2024-11-12 19:23:29 +08001154 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 +08001155 {
1156 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1157 err = MBTK_RIL_ERR_CME + cme_err;
1158 } else {
1159 err = MBTK_RIL_ERR_UNKNOWN;
1160 }
b.liueea595d2024-11-05 19:52:10 +08001161 LOG("Set ecall config[%x] fail.", cfg_info->type);
b.liu15f456b2024-10-31 20:16:06 +08001162 }
1163 else
1164 {
b.liub171c9a2024-11-12 19:23:29 +08001165 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 +08001166 }
1167 } else { // Get
1168 mbtk_ecall_cfg_info_t cfg_info;
1169 memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t));
b.liueea595d2024-11-05 19:52:10 +08001170 uint32 *type = (uint32*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +08001171 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 +08001172 {
1173 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1174 err = MBTK_RIL_ERR_CME + cme_err;
1175 } else {
1176 err = MBTK_RIL_ERR_UNKNOWN;
1177 }
b.liueea595d2024-11-05 19:52:10 +08001178 LOG("Get ecall config[%x] fail.", *type);
b.liu15f456b2024-10-31 20:16:06 +08001179 }
1180 else
1181 {
b.liub171c9a2024-11-12 19:23:29 +08001182 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 +08001183 }
1184 }
1185 }
1186 break;
1187 }
1188 case RIL_MSG_ID_ECALL_SMS_NUM: // uint8[]
1189 {
1190 uint8 number[RIL_MAX_NUMBER_LEN];
1191 memset(number, 0, sizeof(number));
1192 if(pack->data_len == 0 || pack->data == NULL)
1193 {
b.liub171c9a2024-11-12 19:23:29 +08001194 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 +08001195 {
1196 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1197 err = MBTK_RIL_ERR_CME + cme_err;
1198 } else {
1199 err = MBTK_RIL_ERR_UNKNOWN;
1200 }
1201 LOG("Get ecall sms number fail.");
1202 }
1203 else
1204 {
b.liub171c9a2024-11-12 19:23:29 +08001205 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 +08001206 }
1207 }
1208 else // Set
1209 {
1210 memcpy(number, pack->data, pack->data_len);
b.liub171c9a2024-11-12 19:23:29 +08001211 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 +08001212 {
1213 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1214 err = MBTK_RIL_ERR_CME + cme_err;
1215 } else {
1216 err = MBTK_RIL_ERR_UNKNOWN;
1217 }
1218 LOG("Set ecall sms number fail.");
1219 }
1220 else
1221 {
b.liub171c9a2024-11-12 19:23:29 +08001222 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 +08001223 }
1224 }
1225 break;
1226 }
1227 case RIL_MSG_ID_ECALL_MUTESPK:
1228 {
1229 if(pack->data_len == 0 || pack->data == NULL)
1230 {
1231 err = MBTK_RIL_ERR_UNSUPPORTED;
1232 }
1233 else // Set mute state.
1234 {
1235 uint8 mute = pack->data[0];
1236 if(pack->data_len != sizeof(uint8) || (mute != 0 && mute != 1))
1237 {
1238 err = MBTK_RIL_ERR_REQ_PARAMETER;
1239 LOG("Set spk mute parameter error.");
1240 break;
1241 }
1242
b.liub171c9a2024-11-12 19:23:29 +08001243 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 +08001244 {
1245 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1246 err = MBTK_RIL_ERR_CME + cme_err;
1247 } else {
1248 err = MBTK_RIL_ERR_UNKNOWN;
1249 }
1250 LOG("Set spk mute state fail.");
1251 }
1252 else
1253 {
b.liub171c9a2024-11-12 19:23:29 +08001254 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 +08001255 }
1256 }
1257 break;
1258 }
1259 case RIL_MSG_ID_ECALL_DSP_GAIN: // mbtk_ecall_gain_info_t
1260 {
1261 if(pack->data_len == 0 || pack->data == NULL)
1262 {
1263 err = MBTK_RIL_ERR_UNSUPPORTED;
1264 }
1265 else // Set
1266 {
1267 mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
b.liub171c9a2024-11-12 19:23:29 +08001268 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 +08001269 {
1270 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1271 err = MBTK_RIL_ERR_CME + cme_err;
1272 } else {
1273 err = MBTK_RIL_ERR_UNKNOWN;
1274 }
1275 LOGE("Set ecall gain fail.");
1276 }
1277 else
1278 {
b.liub171c9a2024-11-12 19:23:29 +08001279 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 +08001280 }
1281 }
1282 break;
1283 }
1284 default:
1285 {
1286 err = MBTK_RIL_ERR_REQ_UNKNOWN;
1287 LOG("Unknown request : %s", id2str(pack->msg_id));
1288 break;
1289 }
1290 }
1291
1292 return err;
1293}
1294
1295
1296