blob: ca8087135817b4c428c15c843520c10af48a8c4c [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.liub171c9a2024-11-12 19:23:29 +080020void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
b.liu87afc4c2024-08-14 17:33:45 +080021
22/*
23ATDXXXXXXX;
24OK
25
26*/
b.liub171c9a2024-11-12 19:23:29 +080027static int req_call_start(ATPortType_enum port, char *phont_number, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080028{
29 ATResponse *response = NULL;
b.liu62240ee2024-11-07 17:52:45 +080030// int tmp_int;
31// char *tmp_str = NULL;
b.liu87afc4c2024-08-14 17:33:45 +080032 char cmd[100] = {0};
33 sprintf(cmd, "ATD%s;", phont_number);
b.liub171c9a2024-11-12 19:23:29 +080034 int err = at_send_command(port, cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +080035 if (err < 0 || response->success == 0){
36 *cme_err = at_get_cme_error(response);
37 goto exit;
38 }
39
40exit:
41 at_response_free(response);
42 return err;
43}
44
45/*
46
47AT+CHLD=2
48OK
49
50*/
b.liub171c9a2024-11-12 19:23:29 +080051static int req_answer_call(ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080052{
53 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +080054 int err = at_send_command(port, "AT+CHLD=2", &response);
b.liu87afc4c2024-08-14 17:33:45 +080055 if (err < 0 || response->success == 0){
56 *cme_err = at_get_cme_error(response);
57 goto exit;
58 }
59
60exit:
61 at_response_free(response);
62 return err;
63}
64
65/*
66ATH
67OK
68
69*/
b.liub171c9a2024-11-12 19:23:29 +080070static int req_hangup_call(ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080071{
72 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +080073 int err = at_send_command(port, "ATH", &response);
b.liu87afc4c2024-08-14 17:33:45 +080074 if (err < 0 || response->success == 0){
75 *cme_err = at_get_cme_error(response);
76 goto exit;
77 }
78
79exit:
80 at_response_free(response);
81 return err;
82}
83
84/*
85AT+CHLD=1x
86OK
87
88*/
b.liub171c9a2024-11-12 19:23:29 +080089static int req_hangup_a_call(ATPortType_enum port, int phone_id, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +080090{
91 ATResponse *response = NULL;
92 char cmd[100] = {0};
93 sprintf(cmd, "AT+CHLD=1%d", phone_id);
b.liub171c9a2024-11-12 19:23:29 +080094 int err = at_send_command(port, cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +080095 if (err < 0 || response->success == 0){
96 *cme_err = at_get_cme_error(response);
97 goto exit;
98 }
99
100exit:
101 at_response_free(response);
102 return err;
103}
104
105/*
106AT+CHLD=0
107OK
108
109*/
b.liub171c9a2024-11-12 19:23:29 +0800110static int req_hangup_waiting_or_background_call(ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800111{
112 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800113 int err = at_send_command(port, "AT+CHLD=0", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800114 if (err < 0 || response->success == 0){
115 *cme_err = at_get_cme_error(response);
116 goto exit;
117 }
118
119exit:
120 at_response_free(response);
121 return err;
122}
123
124/*
125AT+CHLD=1
126OK
127
128*/
b.liub171c9a2024-11-12 19:23:29 +0800129static int req_hangup_foreground_resume_background_call(ATPortType_enum port, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800130{
131 ATResponse *response = NULL;
b.liub171c9a2024-11-12 19:23:29 +0800132 int err = at_send_command(port, "AT+CHLD=1", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800133 if (err < 0 || response->success == 0){
134 *cme_err = at_get_cme_error(response);
135 goto exit;
136 }
137
138exit:
139 at_response_free(response);
140 return err;
141}
142
143/*
144AT+CLCC
145OK
146
147*/
b.liub171c9a2024-11-12 19:23:29 +0800148static int req_waitin_call(ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800149{
150 ATResponse *response = NULL;
151 int tmp_int;
152 char *tmp_str = NULL;
153
b.liub171c9a2024-11-12 19:23:29 +0800154 int err = at_send_command_multiline(port, "AT+CLCC", "+CLCC:", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800155 if (err < 0 || response->success == 0){
156 *cme_err = at_get_cme_error(response);
157 goto exit;
158 }
159
160 if(response->success == 1 && !response->p_intermediates)
161 {
162 reg->call_wait = 0;
163 goto exit;
164 }
165
166 reg->call_wait = 1;
167 char *line = response->p_intermediates->line;
168 err = at_tok_start(&line);
169 if (err < 0)
170 {
171 goto exit;
172 }
173 err = at_tok_nextint(&line, &tmp_int); // dir1
174 if (err < 0)
175 {
176 goto exit;
177 }
178 reg->dir1 = (uint8)tmp_int;
179 err = at_tok_nextint(&line, &tmp_int);// dir
180 if (err < 0)
181 {
182 goto exit;
183 }
184 reg->dir = (uint8)tmp_int;
185 err = at_tok_nextint(&line, &tmp_int);// state
186 if (err < 0)
187 {
188 goto exit;
189 }
190 reg->state = (uint8)tmp_int;
191 err = at_tok_nextint(&line, &tmp_int);// mode
192 if (err < 0)
193 {
194 goto exit;
195 }
196 reg->mode = (uint8)tmp_int;
197 err = at_tok_nextint(&line, &tmp_int);// mpty
198 if (err < 0)
199 {
200 goto exit;
201 }
202 reg->mpty = (uint8)tmp_int;
203 err = at_tok_nextstr(&line, &tmp_str); // phone_number
204 if (err < 0)
205 {
206 goto exit;
207 }
208 memcpy(reg->phone_number, tmp_str, strlen(tmp_str));
209 err = at_tok_nextint(&line, &tmp_int);// tpye
210 if (err < 0)
211 {
212 goto exit;
213 }
214 reg->type = (uint8)tmp_int;
215
216exit:
217 at_response_free(response);
218 return err;
219}
220
221/*
222AT+CMUT?
223+CMUT: 0
224
225OK
226*/
b.liub171c9a2024-11-12 19:23:29 +0800227static int req_mute_get(ATPortType_enum port, int *state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800228{
229 ATResponse *response = NULL;
230 int tmp_int;
b.liub171c9a2024-11-12 19:23:29 +0800231 int err = at_send_command_singleline(port, "AT+CMUT?", "+CMUT:", &response);
b.liu87afc4c2024-08-14 17:33:45 +0800232
233 if (err < 0 || response->success == 0 || !response->p_intermediates){
234 *cme_err = at_get_cme_error(response);
235 goto exit;
236 }
237
238 char *line = response->p_intermediates->line;
239 err = at_tok_start(&line);
240 if (err < 0)
241 {
242 goto exit;
243 }
244 err = at_tok_nextint(&line, &tmp_int);
245 if (err < 0)
246 {
247 goto exit;
248 }
249 *state = tmp_int;
250
251exit:
252 at_response_free(response);
253 return err;
254}
255
256/*
257AT+CMUT=0;
258OK
259
260*/
b.liub171c9a2024-11-12 19:23:29 +0800261static int req_mute_set(ATPortType_enum port, int state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800262{
263 ATResponse *response = NULL;
264 char cmd[100] = {0};
265 sprintf(cmd, "AT+CMUT=%d", state);
266 LOG("Set the mute command is = %s.\n", cmd);
b.liub171c9a2024-11-12 19:23:29 +0800267 int err = at_send_command(port, cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +0800268 if (err < 0 || response->success == 0){
269 *cme_err = at_get_cme_error(response);
270 goto exit;
271 }
272
273exit:
274 at_response_free(response);
275 return err;
276}
277
278/*
279AT+VTS=0; //0, 1, ..., 9, A, B, C, D, *, #
280OK
281
282*/
b.liub171c9a2024-11-12 19:23:29 +0800283static int req_dtmf_set(ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
b.liu87afc4c2024-08-14 17:33:45 +0800284{
285 ATResponse *response = NULL;
286 char cmd[100] = {0};
287 sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration);
288 LOG("Set the DTMF command is = %s.\n", cmd);
b.liub171c9a2024-11-12 19:23:29 +0800289 int err = at_send_command(port, cmd, &response);
b.liu87afc4c2024-08-14 17:33:45 +0800290 if (err < 0 || response->success == 0){
291 *cme_err = at_get_cme_error(response);
292 goto exit;
293 }
294
295exit:
296 at_response_free(response);
297 return err;
298}
299
liuyang3c60be92024-12-19 16:42:32 +0800300static int req_centric_get(ATPortType_enum port, int *state, int *cme_err)
301{
302 ATResponse *response = NULL;
303 int tmp_int = 0;
304 int err = at_send_command_singleline(port, "AT+CEUS?", "+CEUS:", &response);
305
306 if (err < 0 || response->success == 0 || !response->p_intermediates){
307 *cme_err = at_get_cme_error(response);
308 goto exit;
309 }
310
311 char *line = response->p_intermediates->line;
312 err = at_tok_start(&line);
313 if (err < 0)
314 {
315 goto exit;
316 }
317 err = at_tok_nextint(&line, &tmp_int);
318 if (err < 0)
319 {
320 goto exit;
321 }
322 *state = tmp_int;
323
324exit:
325 at_response_free(response);
326 return err;
327}
328
329/*
330AT+CMUT=0;
331OK
332
333*/
334static int req_centric_set(ATPortType_enum port, int state, int *cme_err)
335{
336 ATResponse *response = NULL;
337 char cmd[100] = {0};
338 sprintf(cmd, "AT+CEUS=%d", state);
339 LOG("Set the centric command is = %s.\n", cmd);
340 int err = at_send_command(port, cmd, &response);
341 if (err < 0 || response->success == 0){
342 *cme_err = at_get_cme_error(response);
343 goto exit;
344 }
345
346exit:
347 at_response_free(response);
348 return err;
349}
350
351
b.liu87afc4c2024-08-14 17:33:45 +0800352//void net_list_free(void *data);
353// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
354// Otherwise, do not call pack_error_send().
355mbtk_ril_err_enum call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
356{
357 mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
358 int cme_err = MBTK_RIL_ERR_CME_NON;
359 switch(pack->msg_id)
360 {
361 case RIL_MSG_ID_CALL_START: // <string> phone number
362 {
363 if(pack->data_len == 0 || pack->data == NULL)
364 {
365 err = MBTK_RIL_ERR_UNSUPPORTED;
366 }
367 else // Set
368 {
369 char *pn = (char*)(pack->data);
b.liub171c9a2024-11-12 19:23:29 +0800370 if(req_call_start(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800371 {
372 if(cme_err != MBTK_RIL_ERR_CME_NON) {
373 err = MBTK_RIL_ERR_CME + cme_err;
374 } else {
375 err = MBTK_RIL_ERR_UNKNOWN;
376 }
377 LOG("ATD fail.");
378 }
379 else
380 {
b.liub171c9a2024-11-12 19:23:29 +0800381 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800382 }
383 }
384 break;
385 }
386 case RIL_MSG_ID_CALL_ANSWER:
387 {
388 if(pack->data_len == 0 || pack->data == NULL)
389 {
b.liub171c9a2024-11-12 19:23:29 +0800390 if(req_answer_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800391 {
392 if(cme_err != MBTK_RIL_ERR_CME_NON) {
393 err = MBTK_RIL_ERR_CME + cme_err;
394 } else {
395 err = MBTK_RIL_ERR_UNKNOWN;
396 }
397 LOG("Answer call fail.");
398 }
399 else
400 {
b.liub171c9a2024-11-12 19:23:29 +0800401 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800402 }
403 }
404 else // Set
405 {
406 err = MBTK_RIL_ERR_UNSUPPORTED;
407 LOG("Answer call fail. NO DATA\n");
408 }
409 break;
410 }
411 case RIL_MSG_ID_CALL_HANGUP:
412 {
413 if(pack->data_len == 0 || pack->data == NULL)
414 {
b.liub171c9a2024-11-12 19:23:29 +0800415 if(req_hangup_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800416 {
417 if(cme_err != MBTK_RIL_ERR_CME_NON) {
418 err = MBTK_RIL_ERR_CME + cme_err;
419 } else {
420 err = MBTK_RIL_ERR_UNKNOWN;
421 }
422 LOG("Hang up call fail.");
423 }
424 else
425 {
b.liub171c9a2024-11-12 19:23:29 +0800426 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800427 }
428 }
429 else // Set
430 {
431 err = MBTK_RIL_ERR_UNSUPPORTED;
432 LOG("Hang up call fail.");
433 }
434 break;
435 }
436 case RIL_MSG_ID_CALL_HANGUP_A:
437 {
438 if(pack->data_len == 0 || pack->data == NULL)
439 {
440 err = MBTK_RIL_ERR_UNSUPPORTED;
441 LOG("Hang up a call fail.");
442 }
443 else
444 {
445 uint8 phone_id = *(pack->data);
b.liub171c9a2024-11-12 19:23:29 +0800446 if(req_hangup_a_call(cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800447 {
448 if(cme_err != MBTK_RIL_ERR_CME_NON) {
449 err = MBTK_RIL_ERR_CME + cme_err;
450 } else {
451 err = MBTK_RIL_ERR_UNKNOWN;
452 }
453 LOG("Hang up a call fail.");
454 }
455 else
456 {
b.liub171c9a2024-11-12 19:23:29 +0800457 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800458 }
459 }
460 break;
461 }
462 case RIL_MSG_ID_CALL_HANGUP_B:
463 {
464 if(pack->data_len == 0 || pack->data == NULL)
465 {
b.liub171c9a2024-11-12 19:23:29 +0800466 if(req_hangup_waiting_or_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800467 {
468 if(cme_err != MBTK_RIL_ERR_CME_NON) {
469 err = MBTK_RIL_ERR_CME + cme_err;
470 } else {
471 err = MBTK_RIL_ERR_UNKNOWN;
472 }
473 LOG("Hang up waiting_or_background call fail.");
474 }
475 else
476 {
b.liub171c9a2024-11-12 19:23:29 +0800477 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800478 }
479 }
480 else
481 {
482 err = MBTK_RIL_ERR_UNSUPPORTED;
483 LOG("Hang up waiting_or_background call fail.");
484 }
485 break;
486 }
487 case RIL_MSG_ID_CALL_HANGUP_C:
488 {
489 if(pack->data_len == 0 || pack->data == NULL)
490 {
b.liub171c9a2024-11-12 19:23:29 +0800491 if(req_hangup_foreground_resume_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800492 {
493 if(cme_err != MBTK_RIL_ERR_CME_NON) {
494 err = MBTK_RIL_ERR_CME + cme_err;
495 } else {
496 err = MBTK_RIL_ERR_UNKNOWN;
497 }
498 LOG("Hang up waiting_or_background call fail.");
499 }
500 else
501 {
b.liub171c9a2024-11-12 19:23:29 +0800502 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800503 }
504 }
505 else
506 {
507 err = MBTK_RIL_ERR_UNSUPPORTED;
508 LOG("Hang up waiting_or_background call fail.");
509 }
510 break;
511 }
512 case RIL_MSG_ID_CALL_WAITIN:
513 {
514 if(pack->data_len == 0 || pack->data == NULL)
515 {
516 mbtk_call_info_t reg;
517 memset(&reg, 0, sizeof(mbtk_call_info_t));
b.liub171c9a2024-11-12 19:23:29 +0800518 if(req_waitin_call(cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800519 {
520 if(cme_err != MBTK_RIL_ERR_CME_NON) {
521 err = MBTK_RIL_ERR_CME + cme_err;
522 } else {
523 err = MBTK_RIL_ERR_UNKNOWN;
524 }
525 LOG("Wait incoing call fail.");
526 }
527 else
528 {
b.liub171c9a2024-11-12 19:23:29 +0800529 ril_rsp_pack_send(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 +0800530 }
531 }
532 else // Set
533 {
534 err = MBTK_RIL_ERR_UNSUPPORTED;
535 LOG("Wait incoing call fail.");
536 }
537 break;
538 }
539 case RIL_MSG_ID_CALL_MUTE:
540 {
541 if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state.
542 {
543 int state;
b.liub171c9a2024-11-12 19:23:29 +0800544 if(req_mute_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800545 {
546 if(cme_err != MBTK_RIL_ERR_CME_NON) {
547 err = MBTK_RIL_ERR_CME + cme_err;
548 } else {
549 err = MBTK_RIL_ERR_UNKNOWN;
550 }
551 LOG("Get mute state fail.");
552 }
553 else
554 {
b.liub171c9a2024-11-12 19:23:29 +0800555 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
b.liu87afc4c2024-08-14 17:33:45 +0800556 }
557 }
558 else // Set mute state.
559 {
560 uint8 on = *(pack->data);
561 if(pack->data_len != sizeof(uint8) || (on != 0 && on != 1))
562 {
563 err = MBTK_RIL_ERR_REQ_PARAMETER;
564 LOG("Set mute parameter error.");
565 break;
566 }
567
b.liub171c9a2024-11-12 19:23:29 +0800568 if(req_mute_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800569 {
570 if(cme_err != MBTK_RIL_ERR_CME_NON) {
571 err = MBTK_RIL_ERR_CME + cme_err;
572 } else {
573 err = MBTK_RIL_ERR_UNKNOWN;
574 }
575 LOG("Set mute state fail.");
576 }
577 else
578 {
b.liub171c9a2024-11-12 19:23:29 +0800579 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800580 }
581 }
582 break;
583 }
584 case RIL_MSG_ID_CALL_DTMF:
585 {
586 if(pack->data_len == 0 || pack->data == NULL)
587 {
588 err = MBTK_RIL_ERR_UNSUPPORTED;
589 LOG("Wait incoing call fail.");
590 }
591 else // Set
592 {
593 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
b.liub171c9a2024-11-12 19:23:29 +0800594 if(req_dtmf_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +0800595 {
596 if(cme_err != MBTK_RIL_ERR_CME_NON) {
597 err = MBTK_RIL_ERR_CME + cme_err;
598 } else {
599 err = MBTK_RIL_ERR_UNKNOWN;
600 }
601 LOG("Wait incoing call fail.");
602 }
603 else
604 {
b.liub171c9a2024-11-12 19:23:29 +0800605 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
b.liu87afc4c2024-08-14 17:33:45 +0800606 }
607 }
608 break;
609 }
liuyang3c60be92024-12-19 16:42:32 +0800610 case RIL_MSG_ID_CALL_CENTRIC:
611 {
612 if(pack->data_len == 0 || pack->data == NULL) // Get VoLTE state.
613 {
614 int state;
615 if(req_centric_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
616 {
617 if(cme_err != MBTK_RIL_ERR_CME_NON) {
618 err = MBTK_RIL_ERR_CME + cme_err;
619 } else {
620 err = MBTK_RIL_ERR_UNKNOWN;
621 }
622 LOG("Get mute state fail.");
623 }
624 else
625 {
626 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
627 }
628 }
629 else // Set mute state.
630 {
631 uint8 on = *(pack->data);
632 if(pack->data_len != sizeof(uint8) || (on != 0 && on != 1))
633 {
634 err = MBTK_RIL_ERR_REQ_PARAMETER;
635 LOG("Set mute parameter error.");
636 break;
637 }
638
639 if(req_centric_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
640 {
641 if(cme_err != MBTK_RIL_ERR_CME_NON) {
642 err = MBTK_RIL_ERR_CME + cme_err;
643 } else {
644 err = MBTK_RIL_ERR_UNKNOWN;
645 }
646 LOG("Set mute state fail.");
647 }
648 else
649 {
650 ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
651 }
652 }
653 break;
654 }
b.liu87afc4c2024-08-14 17:33:45 +0800655 default:
656 {
657 err = MBTK_RIL_ERR_REQ_UNKNOWN;
658 LOG("Unknown request : %s", id2str(pack->msg_id));
659 break;
660 }
661 }
662
663 return err;
664}
665
666
667