blob: 97595faeb81d1c4f6ab6b04866bfcd09eea60305 [file] [log] [blame]
b.liu87afc4c2024-08-14 17:33:45 +08001#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <errno.h>
5#include <sys/socket.h>
6#include <sys/un.h>
7#include <netinet/in.h>
8#include <pthread.h>
9#include <sys/epoll.h>
10#include <fcntl.h>
11#include <signal.h>
12
13#include "mbtk_type.h"
14#include "mbtk_ril.h"
15#include "atchannel.h"
16#include "at_tok.h"
17#include "mbtk_utils.h"
18#include "ril_info.h"
19
b.liu7ca612c2025-04-25 09:23:36 +080020void 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);
21ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
b.liu87afc4c2024-08-14 17:33:45 +080022
23/*
24ATDXXXXXXX;
25OK
26
27*/
b.liu7ca612c2025-04-25 09:23:36 +080028static int req_call_start(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *phont_number, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080029{
30 ATResponse *response = NULL;
b.liu62240ee2024-11-07 17:52:45 +080031// int tmp_int;
32// char *tmp_str = NULL;
b.liu87afc4c2024-08-14 17:33:45 +080033 char cmd[100] = {0};
34 sprintf(cmd, "ATD%s;", phont_number);
b.liu7ca612c2025-04-25 09:23:36 +080035 int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +080036 if (err < 0 || response->success == 0){
37 *cme_err = at_get_cme_error(response);
38 goto exit;
39 }
40
41exit:
42 at_response_free(response);
43 return err;
44}
45
46/*
47
48AT+CHLD=2
49OK
50
51*/
b.liu7ca612c2025-04-25 09:23:36 +080052static int req_answer_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080053{
54 ATResponse *response = NULL;
b.liu7ca612c2025-04-25 09:23:36 +080055 int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=2", &response);
b.liu87afc4c2024-08-14 17:33:45 +080056 if (err < 0 || response->success == 0){
57 *cme_err = at_get_cme_error(response);
58 goto exit;
59 }
60
61exit:
62 at_response_free(response);
63 return err;
64}
65
66/*
67ATH
68OK
69
70*/
b.liu7ca612c2025-04-25 09:23:36 +080071static int req_hangup_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080072{
73 ATResponse *response = NULL;
b.liu7ca612c2025-04-25 09:23:36 +080074 int err = at_send_command(portType_2_portId(sim_id, port), "ATH", &response);
b.liu87afc4c2024-08-14 17:33:45 +080075 if (err < 0 || response->success == 0){
76 *cme_err = at_get_cme_error(response);
77 goto exit;
78 }
79
80exit:
81 at_response_free(response);
82 return err;
83}
84
85/*
86AT+CHLD=1x
87OK
88
89*/
b.liu7ca612c2025-04-25 09:23:36 +080090static int req_hangup_a_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int phone_id, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080091{
92 ATResponse *response = NULL;
93 char cmd[100] = {0};
94 sprintf(cmd, "AT+CHLD=1%d", phone_id);
b.liu7ca612c2025-04-25 09:23:36 +080095 int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +080096 if (err < 0 || response->success == 0){
97 *cme_err = at_get_cme_error(response);
98 goto exit;
99 }
100
101exit:
102 at_response_free(response);
103 return err;
104}
105
106/*
107AT+CHLD=0
108OK
109
110*/
b.liu7ca612c2025-04-25 09:23:36 +0800111static int req_hangup_waiting_or_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800112{
113 ATResponse *response = NULL;
b.liu7ca612c2025-04-25 09:23:36 +0800114 int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=0", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800115 if (err < 0 || response->success == 0){
116 *cme_err = at_get_cme_error(response);
117 goto exit;
118 }
119
120exit:
121 at_response_free(response);
122 return err;
123}
124
125/*
126AT+CHLD=1
127OK
128
129*/
b.liu7ca612c2025-04-25 09:23:36 +0800130static int req_hangup_foreground_resume_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800131{
132 ATResponse *response = NULL;
b.liu7ca612c2025-04-25 09:23:36 +0800133 int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=1", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800134 if (err < 0 || response->success == 0){
135 *cme_err = at_get_cme_error(response);
136 goto exit;
137 }
138
139exit:
140 at_response_free(response);
141 return err;
142}
143
144/*
145AT+CLCC
146OK
147
148*/
b.liu7ca612c2025-04-25 09:23:36 +0800149static int req_waitin_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800150{
151 ATResponse *response = NULL;
152 int tmp_int;
153 char *tmp_str = NULL;
154
b.liu7ca612c2025-04-25 09:23:36 +0800155 int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CLCC", "+CLCC:", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800156 if (err < 0 || response->success == 0){
157 *cme_err = at_get_cme_error(response);
158 goto exit;
159 }
160
161 if(response->success == 1 && !response->p_intermediates)
162 {
163 reg->call_wait = 0;
164 goto exit;
165 }
166
167 reg->call_wait = 1;
168 char *line = response->p_intermediates->line;
169 err = at_tok_start(&line);
170 if (err < 0)
171 {
172 goto exit;
173 }
174 err = at_tok_nextint(&line, &tmp_int); // dir1
175 if (err < 0)
176 {
177 goto exit;
178 }
179 reg->dir1 = (uint8)tmp_int;
180 err = at_tok_nextint(&line, &tmp_int);// dir
181 if (err < 0)
182 {
183 goto exit;
184 }
185 reg->dir = (uint8)tmp_int;
186 err = at_tok_nextint(&line, &tmp_int);// state
187 if (err < 0)
188 {
189 goto exit;
190 }
191 reg->state = (uint8)tmp_int;
192 err = at_tok_nextint(&line, &tmp_int);// mode
193 if (err < 0)
194 {
195 goto exit;
196 }
197 reg->mode = (uint8)tmp_int;
198 err = at_tok_nextint(&line, &tmp_int);// mpty
199 if (err < 0)
200 {
201 goto exit;
202 }
203 reg->mpty = (uint8)tmp_int;
204 err = at_tok_nextstr(&line, &tmp_str); // phone_number
205 if (err < 0)
206 {
207 goto exit;
208 }
209 memcpy(reg->phone_number, tmp_str, strlen(tmp_str));
210 err = at_tok_nextint(&line, &tmp_int);// tpye
211 if (err < 0)
212 {
213 goto exit;
214 }
215 reg->type = (uint8)tmp_int;
216
217exit:
218 at_response_free(response);
219 return err;
220}
221
222/*
223AT+CMUT?
224+CMUT: 0
225
226OK
227*/
b.liu7ca612c2025-04-25 09:23:36 +0800228static int req_mute_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800229{
230 ATResponse *response = NULL;
231 int tmp_int;
b.liu7ca612c2025-04-25 09:23:36 +0800232 int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CMUT?", "+CMUT:", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800233
234 if (err < 0 || response->success == 0 || !response->p_intermediates){
235 *cme_err = at_get_cme_error(response);
236 goto exit;
237 }
238
239 char *line = response->p_intermediates->line;
240 err = at_tok_start(&line);
241 if (err < 0)
242 {
243 goto exit;
244 }
245 err = at_tok_nextint(&line, &tmp_int);
246 if (err < 0)
247 {
248 goto exit;
249 }
250 *state = tmp_int;
251
252exit:
253 at_response_free(response);
254 return err;
255}
256
257/*
258AT+CMUT=0;
259OK
260
261*/
b.liu7ca612c2025-04-25 09:23:36 +0800262static int req_mute_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800263{
264 ATResponse *response = NULL;
265 char cmd[100] = {0};
266 sprintf(cmd, "AT+CMUT=%d", state);
267 LOG("Set the mute command is = %s.\n", cmd);
b.liu7ca612c2025-04-25 09:23:36 +0800268 int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +0800269 if (err < 0 || response->success == 0){
270 *cme_err = at_get_cme_error(response);
271 goto exit;
272 }
273
274exit:
275 at_response_free(response);
276 return err;
277}
278
279/*
280AT+VTS=0; //0, 1, ..., 9, A, B, C, D, *, #
281OK
282
283*/
b.liu7ca612c2025-04-25 09:23:36 +0800284static int req_dtmf_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800285{
286 ATResponse *response = NULL;
287 char cmd[100] = {0};
288 sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration);
289 LOG("Set the DTMF command is = %s.\n", cmd);
b.liu7ca612c2025-04-25 09:23:36 +0800290 int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +0800291 if (err < 0 || response->success == 0){
292 *cme_err = at_get_cme_error(response);
293 goto exit;
294 }
295
296exit:
297 at_response_free(response);
298 return err;
299}
300
b.liu7ca612c2025-04-25 09:23:36 +0800301static int req_centric_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
liuyang3c60be92024-12-19 16:42:32 +0800302{
303 ATResponse *response = NULL;
304 int tmp_int = 0;
b.liu7ca612c2025-04-25 09:23:36 +0800305 int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CEUS?", "+CEUS:", &response);
liuyang3c60be92024-12-19 16:42:32 +0800306
307 if (err < 0 || response->success == 0 || !response->p_intermediates){
308 *cme_err = at_get_cme_error(response);
309 goto exit;
310 }
311
312 char *line = response->p_intermediates->line;
313 err = at_tok_start(&line);
314 if (err < 0)
315 {
316 goto exit;
317 }
318 err = at_tok_nextint(&line, &tmp_int);
319 if (err < 0)
320 {
321 goto exit;
322 }
323 *state = tmp_int;
324
325exit:
326 at_response_free(response);
327 return err;
328}
329
330/*
331AT+CMUT=0;
332OK
333
334*/
b.liu7ca612c2025-04-25 09:23:36 +0800335static int req_centric_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
liuyang3c60be92024-12-19 16:42:32 +0800336{
337 ATResponse *response = NULL;
338 char cmd[100] = {0};
339 sprintf(cmd, "AT+CEUS=%d", state);
340 LOG("Set the centric command is = %s.\n", cmd);
b.liu7ca612c2025-04-25 09:23:36 +0800341 int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
liuyang3c60be92024-12-19 16:42:32 +0800342 if (err < 0 || response->success == 0){
343 *cme_err = at_get_cme_error(response);
344 goto exit;
345 }
346
347exit:
348 at_response_free(response);
349 return err;
350}
351
352
b.liu87afc4c2024-08-14 17:33:45 +0800353//void net_list_free(void *data);
354// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
355// Otherwise, do not call pack_error_send().
356mbtk_ril_err_enum call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
357{
358 mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
359 int cme_err = MBTK_RIL_ERR_CME_NON;
360 switch(pack->msg_id)
361 {
362 case RIL_MSG_ID_CALL_START: // <string> phone number
363 {
q.huangfd4b1d82025-08-26 18:57:31 +0800364 if(pack->data_len == 1 || pack->data == NULL) // data_len == 1 is wrote by hq at 2025/08/26 for bug 2187
b.liu87afc4c2024-08-14 17:33:45 +0800365 {
366 err = MBTK_RIL_ERR_UNSUPPORTED;
367 }
368 else // Set
369 {
370 char *pn = (char*)(pack->data);
b.liu7ca612c2025-04-25 09:23:36 +0800371 if(req_call_start(cli_info->sim_id, cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800372 {
373 if(cme_err != MBTK_RIL_ERR_CME_NON) {
374 err = MBTK_RIL_ERR_CME + cme_err;
375 } else {
376 err = MBTK_RIL_ERR_UNKNOWN;
377 }
378 LOG("ATD fail.");
379 }
380 else
381 {
b.liu7ca612c2025-04-25 09:23:36 +0800382 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800383 }
384 }
385 break;
386 }
387 case RIL_MSG_ID_CALL_ANSWER:
388 {
389 if(pack->data_len == 0 || pack->data == NULL)
390 {
b.liu7ca612c2025-04-25 09:23:36 +0800391 if(req_answer_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800392 {
393 if(cme_err != MBTK_RIL_ERR_CME_NON) {
394 err = MBTK_RIL_ERR_CME + cme_err;
395 } else {
396 err = MBTK_RIL_ERR_UNKNOWN;
397 }
398 LOG("Answer call fail.");
399 }
400 else
401 {
b.liu7ca612c2025-04-25 09:23:36 +0800402 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800403 }
404 }
405 else // Set
406 {
407 err = MBTK_RIL_ERR_UNSUPPORTED;
408 LOG("Answer call fail. NO DATA\n");
409 }
410 break;
411 }
412 case RIL_MSG_ID_CALL_HANGUP:
413 {
414 if(pack->data_len == 0 || pack->data == NULL)
415 {
b.liu7ca612c2025-04-25 09:23:36 +0800416 if(req_hangup_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800417 {
418 if(cme_err != MBTK_RIL_ERR_CME_NON) {
419 err = MBTK_RIL_ERR_CME + cme_err;
420 } else {
421 err = MBTK_RIL_ERR_UNKNOWN;
422 }
423 LOG("Hang up call fail.");
424 }
425 else
426 {
b.liu7ca612c2025-04-25 09:23:36 +0800427 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800428 }
429 }
430 else // Set
431 {
432 err = MBTK_RIL_ERR_UNSUPPORTED;
433 LOG("Hang up call fail.");
434 }
435 break;
436 }
437 case RIL_MSG_ID_CALL_HANGUP_A:
438 {
439 if(pack->data_len == 0 || pack->data == NULL)
440 {
441 err = MBTK_RIL_ERR_UNSUPPORTED;
442 LOG("Hang up a call fail.");
443 }
444 else
445 {
446 uint8 phone_id = *(pack->data);
b.liu7ca612c2025-04-25 09:23:36 +0800447 if(req_hangup_a_call(cli_info->sim_id, cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800448 {
449 if(cme_err != MBTK_RIL_ERR_CME_NON) {
450 err = MBTK_RIL_ERR_CME + cme_err;
451 } else {
452 err = MBTK_RIL_ERR_UNKNOWN;
453 }
454 LOG("Hang up a call fail.");
455 }
456 else
457 {
b.liu7ca612c2025-04-25 09:23:36 +0800458 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800459 }
460 }
461 break;
462 }
463 case RIL_MSG_ID_CALL_HANGUP_B:
464 {
465 if(pack->data_len == 0 || pack->data == NULL)
466 {
b.liu7ca612c2025-04-25 09:23:36 +0800467 if(req_hangup_waiting_or_background_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800468 {
469 if(cme_err != MBTK_RIL_ERR_CME_NON) {
470 err = MBTK_RIL_ERR_CME + cme_err;
471 } else {
472 err = MBTK_RIL_ERR_UNKNOWN;
473 }
474 LOG("Hang up waiting_or_background call fail.");
475 }
476 else
477 {
b.liu7ca612c2025-04-25 09:23:36 +0800478 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800479 }
480 }
481 else
482 {
483 err = MBTK_RIL_ERR_UNSUPPORTED;
484 LOG("Hang up waiting_or_background call fail.");
485 }
486 break;
487 }
488 case RIL_MSG_ID_CALL_HANGUP_C:
489 {
490 if(pack->data_len == 0 || pack->data == NULL)
491 {
b.liu7ca612c2025-04-25 09:23:36 +0800492 if(req_hangup_foreground_resume_background_call(cli_info->sim_id, cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800493 {
494 if(cme_err != MBTK_RIL_ERR_CME_NON) {
495 err = MBTK_RIL_ERR_CME + cme_err;
496 } else {
497 err = MBTK_RIL_ERR_UNKNOWN;
498 }
499 LOG("Hang up waiting_or_background call fail.");
500 }
501 else
502 {
b.liu7ca612c2025-04-25 09:23:36 +0800503 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800504 }
505 }
506 else
507 {
508 err = MBTK_RIL_ERR_UNSUPPORTED;
509 LOG("Hang up waiting_or_background call fail.");
510 }
511 break;
512 }
513 case RIL_MSG_ID_CALL_WAITIN:
514 {
515 if(pack->data_len == 0 || pack->data == NULL)
516 {
517 mbtk_call_info_t reg;
518 memset(&reg, 0, sizeof(mbtk_call_info_t));
b.liu7ca612c2025-04-25 09:23:36 +0800519 if(req_waitin_call(cli_info->sim_id, cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800520 {
521 if(cme_err != MBTK_RIL_ERR_CME_NON) {
522 err = MBTK_RIL_ERR_CME + cme_err;
523 } else {
524 err = MBTK_RIL_ERR_UNKNOWN;
525 }
526 LOG("Wait incoing call fail.");
527 }
528 else
529 {
b.liu7ca612c2025-04-25 09:23:36 +0800530 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
b.liu87afc4c2024-08-14 17:33:45 +0800531 }
532 }
533 else // Set
534 {
535 err = MBTK_RIL_ERR_UNSUPPORTED;
536 LOG("Wait incoing call fail.");
537 }
538 break;
539 }
540 case RIL_MSG_ID_CALL_MUTE:
541 {
542 if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state.
543 {
544 int state;
b.liu7ca612c2025-04-25 09:23:36 +0800545 if(req_mute_get(cli_info->sim_id, cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800546 {
547 if(cme_err != MBTK_RIL_ERR_CME_NON) {
548 err = MBTK_RIL_ERR_CME + cme_err;
549 } else {
550 err = MBTK_RIL_ERR_UNKNOWN;
551 }
552 LOG("Get mute state fail.");
553 }
554 else
555 {
b.liu7ca612c2025-04-25 09:23:36 +0800556 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
b.liu87afc4c2024-08-14 17:33:45 +0800557 }
558 }
559 else // Set mute state.
560 {
561 uint8 on = *(pack->data);
562 if(pack->data_len != sizeof(uint8) || (on != 0 && on != 1))
563 {
564 err = MBTK_RIL_ERR_REQ_PARAMETER;
565 LOG("Set mute parameter error.");
566 break;
567 }
568
b.liu7ca612c2025-04-25 09:23:36 +0800569 if(req_mute_set(cli_info->sim_id, cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800570 {
571 if(cme_err != MBTK_RIL_ERR_CME_NON) {
572 err = MBTK_RIL_ERR_CME + cme_err;
573 } else {
574 err = MBTK_RIL_ERR_UNKNOWN;
575 }
576 LOG("Set mute state fail.");
577 }
578 else
579 {
b.liu7ca612c2025-04-25 09:23:36 +0800580 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800581 }
582 }
583 break;
584 }
585 case RIL_MSG_ID_CALL_DTMF:
586 {
587 if(pack->data_len == 0 || pack->data == NULL)
588 {
589 err = MBTK_RIL_ERR_UNSUPPORTED;
590 LOG("Wait incoing call fail.");
591 }
592 else // Set
593 {
594 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
b.liu7ca612c2025-04-25 09:23:36 +0800595 if(req_dtmf_set(cli_info->sim_id, cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800596 {
597 if(cme_err != MBTK_RIL_ERR_CME_NON) {
598 err = MBTK_RIL_ERR_CME + cme_err;
599 } else {
600 err = MBTK_RIL_ERR_UNKNOWN;
601 }
602 LOG("Wait incoing call fail.");
603 }
604 else
605 {
b.liu7ca612c2025-04-25 09:23:36 +0800606 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800607 }
608 }
609 break;
610 }
liuyang3c60be92024-12-19 16:42:32 +0800611 case RIL_MSG_ID_CALL_CENTRIC:
612 {
613 if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state.
614 {
615 int state;
b.liu7ca612c2025-04-25 09:23:36 +0800616 if(req_centric_get(cli_info->sim_id, cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
liuyang3c60be92024-12-19 16:42:32 +0800617 {
618 if(cme_err != MBTK_RIL_ERR_CME_NON) {
619 err = MBTK_RIL_ERR_CME + cme_err;
620 } else {
621 err = MBTK_RIL_ERR_UNKNOWN;
622 }
623 LOG("Get mute state fail.");
624 }
625 else
626 {
b.liu7ca612c2025-04-25 09:23:36 +0800627 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
liuyang3c60be92024-12-19 16:42:32 +0800628 }
629 }
630 else // Set mute state.
631 {
632 uint8 on = *(pack->data);
633 if(pack->data_len != sizeof(uint8) || (on != 0 && on != 1))
634 {
635 err = MBTK_RIL_ERR_REQ_PARAMETER;
636 LOG("Set mute parameter error.");
637 break;
638 }
639
b.liu7ca612c2025-04-25 09:23:36 +0800640 if(req_centric_set(cli_info->sim_id, cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
liuyang3c60be92024-12-19 16:42:32 +0800641 {
642 if(cme_err != MBTK_RIL_ERR_CME_NON) {
643 err = MBTK_RIL_ERR_CME + cme_err;
644 } else {
645 err = MBTK_RIL_ERR_UNKNOWN;
646 }
647 LOG("Set mute state fail.");
648 }
649 else
650 {
b.liu7ca612c2025-04-25 09:23:36 +0800651 ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
liuyang3c60be92024-12-19 16:42:32 +0800652 }
653 }
654 break;
655 }
b.liu87afc4c2024-08-14 17:33:45 +0800656 default:
657 {
658 err = MBTK_RIL_ERR_REQ_UNKNOWN;
659 LOG("Unknown request : %s", id2str(pack->msg_id));
660 break;
661 }
662 }
663
664 return err;
665}
666
667
668