blob: 8aacb7c7060e7f02f471db912e3896b963da8ff2 [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#include <cutils/properties.h>
13#include <arpa/inet.h>
14
15#include "mbtk_type.h"
16#include "mbtk_ril.h"
17#include "atchannel.h"
18#include "at_tok.h"
19#include "mbtk_utils.h"
20#include "ril_info.h"
21#include "mbtk_str.h"
22
b.liub4772072024-08-15 14:47:03 +080023mbtk_cell_pack_info_t cell_info;
24
b.liu87afc4c2024-08-14 17:33:45 +080025extern ril_band_info_t band_info;
26void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
b.liu87afc4c2024-08-14 17:33:45 +080027
28/*
29AT+COPS=?
30
31+COPS: (2, "CHN-CT", "CT", "46011", 7),(3, "CHN-UNICOM", "UNICOM", "46001", 7),(3, "CHINA MOBILE", "CMCC", "46000", 0),(3, "CHINA MOBILE", "CMCC", "46000", 7),(3, "China Broadnet", "CBN", "46015", 7),,(0,1,2,3,4),(0,1,2)
32
33OK
34*/
35static int req_available_net_get(mbtk_net_info_array_t* nets, int *cme_err)
36{
37 ATResponse *response = NULL;
38 int err = at_send_command_singleline("AT+COPS=?", "+COPS:", &response);
39
40 if (err < 0 || response->success == 0 || !response->p_intermediates){
41 if(cme_err) {
42 *cme_err = at_get_cme_error(response);
43 }
44 goto exit;
45 }
46 char *line_ptr = response->p_intermediates->line;
47 if(line_ptr == NULL) {
48 LOG("line is NULL");
49 err = -1;
50 goto exit;
51 }
52 //LOG("Line:%s",line_ptr);
53 line_ptr = strstr(line_ptr, "(");
54 while(line_ptr) {
55 line_ptr++;
56 // Only for available/current net.
57 if(*line_ptr == '1' || *line_ptr == '2' || *line_ptr == '3') {
58 nets->net_info[nets->num].net_state = (uint8)atoi(line_ptr); // net_state
59
60 line_ptr = strstr(line_ptr, ",");
61 if(line_ptr == NULL) {
62 err = -1;
63 goto exit;
64 }
65 line_ptr++;
66
67 line_ptr = strstr(line_ptr, ",");
68 if(line_ptr == NULL) {
69 err = -1;
70 goto exit;
71 }
72 line_ptr++;
73
74 line_ptr = strstr(line_ptr, ",");
75 if(line_ptr == NULL) {
76 err = -1;
77 goto exit;
78 }
79
80 while(*line_ptr != '\0' && (*line_ptr == ',' || *line_ptr == ' ' || *line_ptr == '"'))
81 line_ptr++;
82
83 // set sel_mode to 0
84 nets->net_info[nets->num].net_sel_mode = (uint8)0;
85 // Point to "46000"
86 //LOG("PLMN:%s",line_ptr);
87 //sleep(1);
88 //uint32_2_byte((uint32)atoi(line_ptr), buff_ptr + 3, false); // plmn
89 nets->net_info[nets->num].plmn = (uint32)atoi(line_ptr);
90
91 line_ptr = strstr(line_ptr, ",");
92 if(line_ptr == NULL) {
93 err = -1;
94 goto exit;
95 }
96
97 while(*line_ptr != '\0' && (*line_ptr == ',' || *line_ptr == ' '))
98 line_ptr++;
99
100 // Point to "7"
101 if(*line_ptr == '\0') {
102 err = -1;
103 goto exit;
104 }
105 //LOG("Type:%s",line_ptr);
106 //sleep(1);
107 nets->net_info[nets->num].net_type = (uint8)atoi(line_ptr); // net_type
108
109 nets->num++;
110 }
111
112 line_ptr = strstr(line_ptr, "(");
113 }
114exit:
115 at_response_free(response);
116 return err;
117}
118
119/*
120AT+COPS?
121+COPS: 1
122
123OK
124
125or
126
127AT+COPS?
128+COPS: 0,2,"46001",7
129
130OK
131
132*/
133static int req_net_sel_mode_get(mbtk_net_info_t *net, int *cme_err)
134{
135 //LOG("req_net_sel_mode_get() 0");
136 //sleep(1);
137 ATResponse *response = NULL;
138 int tmp_int;
139 char *tmp_ptr = NULL;
140 int err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
141 //LOG("req_net_sel_mode_get() 00");
142 //sleep(1);
143 if (err < 0 || response->success == 0 || !response->p_intermediates){
144 if(cme_err != NULL)
145 *cme_err = at_get_cme_error(response);
146 err = -1;
147 goto exit;
148 }
149 //LOG("req_net_sel_mode_get() 1");
150 //sleep(1);
151 char *line = response->p_intermediates->line;
152 if(line == NULL) {
153 LOG("line is NULL");
154 goto exit;
155 }
156 //LOG("req_net_sel_mode_get() 2");
157 //sleep(1);
158 err = at_tok_start(&line);
159 if (err < 0)
160 {
161 goto exit;
162 }
163 //LOG("req_net_sel_mode_get() 3");
164 //sleep(1);
165 err = at_tok_nextint(&line, &tmp_int);
166 if (err < 0)
167 {
168 goto exit;
169 }
170 net->net_sel_mode = (uint8)tmp_int;
171 //LOG("req_net_sel_mode_get() 4");
172 //sleep(1);
173 // +COPS: 1
174 if(!at_tok_hasmore(&line)) {
175 goto exit;
176 }
177 //LOG("req_net_sel_mode_get() 5");
178 //sleep(1);
179 err = at_tok_nextint(&line, &tmp_int);
180 if (err < 0)
181 {
182 goto exit;
183 }
184 //LOG("req_net_sel_mode_get() 6");
185 //sleep(1);
186 err = at_tok_nextstr(&line, &tmp_ptr);
187 if (err < 0)
188 {
189 goto exit;
190 }
191 // memcpy(net->plmn, tmp_ptr, strlen(tmp_ptr));
192 net->plmn = (uint32)atoi(tmp_ptr);
193 //LOG("req_net_sel_mode_get() 7");
194 //sleep(1);
195 err = at_tok_nextint(&line, &tmp_int);
196 if (err < 0)
197 {
198 goto exit;
199 }
200 net->net_type = (uint8)tmp_int;
201
202 net->net_state = (uint8)MBTK_NET_AVIL_STATE_CURRENT;
203
204exit:
205 //LOG("req_net_sel_mode_get() 8");
206 //sleep(1);
207 at_response_free(response);
208 return err;
209}
210
211/*
212AT+COPS=0
213or
214AT+COPS=1,2,"46000",7
215
216OK
217
218*/
219static int req_net_sel_mode_set(mbtk_net_info_t* net, int *cme_err)
220{
221 ATResponse *response = NULL;
222 char cmd[50] = {0};
223 char* cmp_ptr = cmd;
224 if(net == NULL) {
225 cmp_ptr += sprintf(cmp_ptr, "AT+COPS=0");
226 } else {
227 if(net->net_sel_mode == 0) {
228 cmp_ptr += sprintf(cmp_ptr, "AT+COPS=0");
229 } else if(net->net_type == 0xFF) {
230 cmp_ptr += sprintf(cmp_ptr, "AT+COPS=1,2,\"%d\"",net->plmn);
231 } else {
232 cmp_ptr += sprintf(cmp_ptr, "AT+COPS=1,2,\"%d\",%d",net->plmn, net->net_type);
233 }
234 }
235
236 int err = at_send_command(cmd, &response);
237
238 if (err < 0 || response->success == 0) {
239 if(cme_err) {
240 *cme_err = at_get_cme_error(response);
241 }
242 goto exit;
243 }
244
245exit:
246 at_response_free(response);
247 return err;
248}
249
250/*
251AT*BAND=15
252OK
253
254*/
255static int req_band_set(mbtk_band_info_t* band, int *cme_err)
256{
257 ATResponse *response = NULL;
258 char cmd[100] = {0};
259 int err = -1;
260
261 if(band->gsm_band == 0 && band->umts_band == 0
262 && band->tdlte_band == 0 && band->fddlte_band == 0) {
263 sprintf(cmd, "AT*BAND=%d", band->net_pref);
264 } else {
265 log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t));
266 log_hex("BAND", band, sizeof(mbtk_band_info_t));
267
268 if(band->gsm_band == 0) {
269 band->gsm_band = band_info.band_support.gsm_band;
270 }
271 if(band->umts_band == 0) {
272 band->umts_band = band_info.band_support.umts_band;
273 }
274 if(band->tdlte_band == 0) {
275 band->tdlte_band = band_info.band_support.tdlte_band;
276 }
277 if(band->fddlte_band == 0) {
278 band->fddlte_band = band_info.band_support.fddlte_band;
279 }
280
281 if((band->gsm_band & band_info.band_support.gsm_band) != band->gsm_band) {
282 LOG("GSM band error.");
283 goto exit;
284 }
285
286 if((band->umts_band & band_info.band_support.umts_band) != band->umts_band) {
287 LOG("UMTS band error.");
288 goto exit;
289 }
290
291 if((band->tdlte_band & band_info.band_support.tdlte_band) != band->tdlte_band) {
292 LOG("TDLTE band error.");
293 goto exit;
294 }
295
296 if((band->fddlte_band & band_info.band_support.fddlte_band) != band->fddlte_band) {
297 LOG("FDDLTE band error.");
298 goto exit;
299 }
300
301 if((band->lte_ext_band & band_info.band_support.lte_ext_band) != band->lte_ext_band) {
302 LOG("EXT_LTE band error.");
303 goto exit;
304 }
305
306 if(band->net_pref == 0xFF) { // No change net_pref.
307 int tmp_int;
308 err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
309 if (err < 0 || response->success == 0 || !response->p_intermediates){
310 if(cme_err) {
311 *cme_err = at_get_cme_error(response);
312 }
313 goto exit;
314 }
315
316 char *line = response->p_intermediates->line;
317 err = at_tok_start(&line);
318 if (err < 0)
319 {
320 goto exit;
321 }
322
323 err = at_tok_nextint(&line, &tmp_int);
324 if (err < 0)
325 {
326 goto exit;
327 }
328 band->net_pref = (uint8)tmp_int; // Set to current net_pref.
329
330 at_response_free(response);
331 }
332
333 if(band->lte_ext_band > 0) {
334 sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, band->lte_ext_band);
335 } else {
336 sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band);
337 }
338 }
339 err = at_send_command(cmd, &response);
340
341 if (err < 0 || response->success == 0){
342 if(cme_err) {
343 *cme_err = at_get_cme_error(response);
344 }
345 goto exit;
346 }
347
348 err = 0;
349exit:
350 at_response_free(response);
351 return err;
352}
353
354/*
355// ???????
356AT*BAND=?
357*BAND:(0-18),79,147,482,524503
358
359OK
360
361// ???????????
362AT*BAND?
363*BAND: 15, 78, 147, 482, 524503, 0, 2, 2, 0, 0
364
365OK
366
367// ?????????
368AT*BAND=5,79,147,128,1
369OK
370
371net_prefferred??
372 0 : GSM only
373 1 : UMTS only
374 2 : GSM/UMTS(auto)
375 3 : GSM/UMTS(GSM preferred)
376 4 : GSM/UMTS(UMTS preferred)
377 5 : LTE only
378 6 : GSM/LTE(auto)
379 7 : GSM/LTE(GSM preferred)
380 8 : GSM/LTE(LTE preferred)
381 9 : UMTS/LTE(auto)
382 10 : UMTS/LTE(UMTS preferred)
383 11 : UMTS/LTE(LTE preferred)
384 12 : GSM/UMTS/LTE(auto)
385 13 : GSM/UMTS/LTE(GSM preferred)
386 14 : GSM/UMTS/LTE(UMTS preferred)
387 15 : GSM/UMTS/LTE(LTE preferred)
388GSM band??
389 1 ?C PGSM 900 (standard or primary)
390 2 ?C DCS GSM 1800
391 4 ?C PCS GSM 1900
392 8 ?C EGSM 900 (extended)
393 16 ?C GSM 450
394 32 ?C GSM 480
395 64 ?C GSM 850
396 512 - BAND_LOCK_BIT // used for GSM band setting
397UMTS band??
398 1 ?C UMTS_BAND_1
399 2 ?C UMTS_BAND_2
400 4 ?C UMTS_BAND_3
401 8 ?C UMTS_BAND_4
402 16 ?C UMTS_BAND_5
403 32 ?C UMTS_BAND_6
404 64 ?C UMTS_BAND_7
405 128 ?C UMTS_BAND_8
406 256 ?C UMTS_BAND_9
407LTEbandH(TDD-LTE band)
408 32 ?C TDLTE_BAND_38
409 64 ?C TDLTE_BAND_39
410 128 ?C TDLTE_BAND_40
411 256 ?C TDLTE_BAND_41
412LTEbandL(FDD-LTE band)
413 1 ?C FDDLTE_BAND_1
414 4 ?C FDDLTE _BAND_3
415 8 ?C FDDLTE _BAND_4
416 64 ?C FDDLTE _BAND_7
417 65536 ?C FDDLTE _BAND_17
418 524288 ?C FDDLTE _BAND_20
419*/
420static int req_band_get(mbtk_band_info_t *band, int *cme_err)
421{
422 ATResponse *response = NULL;
423 int tmp_int;
424
425 log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t));
426 int err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
427 if (err < 0 || response->success == 0 || !response->p_intermediates){
428 if(cme_err) {
429 *cme_err = at_get_cme_error(response);
430 }
431 goto exit;
432 }
433
434 char *line = response->p_intermediates->line;
435 err = at_tok_start(&line);
436 if (err < 0)
437 {
438 goto exit;
439 }
440
441 err = at_tok_nextint(&line, &tmp_int);
442 if (err < 0)
443 {
444 goto exit;
445 }
446 band->net_pref = (uint8)tmp_int;
447
448 err = at_tok_nextint(&line, &tmp_int);
449 if (err < 0)
450 {
451 goto exit;
452 }
453 band->gsm_band = (uint16)tmp_int;
454
455 err = at_tok_nextint(&line, &tmp_int);
456 if (err < 0)
457 {
458 goto exit;
459 }
460 band->umts_band = (uint16)tmp_int;
461
462 err = at_tok_nextint(&line, &tmp_int);
463 if (err < 0)
464 {
465 goto exit;
466 }
467 band->tdlte_band = (uint32)tmp_int;
468
469 err = at_tok_nextint(&line, &tmp_int);
470 if (err < 0)
471 {
472 goto exit;
473 }
474 band->fddlte_band = (uint32)tmp_int;
475
476 // roamingConfig
477 err = at_tok_nextint(&line, &tmp_int);
478 if (err < 0)
479 {
480 goto exit;
481 }
482
483 // srvDomain
484 err = at_tok_nextint(&line, &tmp_int);
485 if (err < 0)
486 {
487 goto exit;
488 }
489
490 // bandPriorityFlag
491 err = at_tok_nextint(&line, &tmp_int);
492 if (err < 0)
493 {
494 goto exit;
495 }
496
497 //
498 err = at_tok_nextint(&line, &tmp_int);
499 if (err < 0)
500 {
501 goto exit;
502 }
503
504 // ltebandExt
505 err = at_tok_nextint(&line, &tmp_int);
506 if (err < 0)
507 {
508 goto exit;
509 }
510 band->lte_ext_band = (uint32)tmp_int;
511
512 log_hex("BAND", band, sizeof(mbtk_band_info_t));
513
514exit:
515 at_response_free(response);
516 return err;
517}
518
519/*
520AT+CSQ
521+CSQ: 31,99
522
523OK
524
525AT+CESQ
526+CESQ: 60,99,255,255,20,61
527
528OK
529
530AT+COPS?
531+COPS: 0,2,"46001",7
532
533OK
534
535*/
536static int req_net_signal_get(mbtk_signal_info_t *signal, int *cme_err)
537{
538 ATResponse *response = NULL;
539 int tmp_int;
540 char *tmp_ptr = NULL;
541 // AT+EEMOPT=1 in the first.
542 int err = at_send_command_singleline("AT+CSQ", "+CSQ:", &response);
543 if (err < 0 || response->success == 0 || !response->p_intermediates){
544 if(cme_err != NULL)
545 *cme_err = at_get_cme_error(response);
546 err = -1;
547 goto exit;
548 }
549
550 char *line = response->p_intermediates->line;
551 err = at_tok_start(&line);
552 if (err < 0)
553 {
554 goto exit;
555 }
556 err = at_tok_nextint(&line, &tmp_int);
557 if (err < 0)
558 {
559 goto exit;
560 }
561 signal->rssi = (uint8)tmp_int;
562 at_response_free(response);
563
564 err = at_send_command_singleline("AT+CESQ", "+CESQ:", &response);
565 if (err < 0 || response->success == 0 || !response->p_intermediates){
566 if(cme_err != NULL)
567 *cme_err = at_get_cme_error(response);
568 err = -1;
569 goto exit;
570 }
571
572 line = response->p_intermediates->line;
573 err = at_tok_start(&line);
574 if (err < 0)
575 {
576 goto exit;
577 }
578 err = at_tok_nextint(&line, &tmp_int);
579 if (err < 0)
580 {
581 goto exit;
582 }
583 signal->rxlev = (uint8)tmp_int;
584
585 err = at_tok_nextint(&line, &tmp_int);
586 if (err < 0)
587 {
588 goto exit;
589 }
590 signal->ber = (uint8)tmp_int;
591
592 err = at_tok_nextint(&line, &tmp_int);
593 if (err < 0)
594 {
595 goto exit;
596 }
597 signal->rscp = (uint8)tmp_int;
598
599 err = at_tok_nextint(&line, &tmp_int);
600 if (err < 0)
601 {
602 goto exit;
603 }
604 signal->ecno = (uint8)tmp_int;
605
606 err = at_tok_nextint(&line, &tmp_int);
607 if (err < 0)
608 {
609 goto exit;
610 }
611 signal->rsrq = (uint8)tmp_int;
612
613 err = at_tok_nextint(&line, &tmp_int);
614 if (err < 0)
615 {
616 goto exit;
617 }
618 signal->rsrp = (uint8)tmp_int;
619
620 at_response_free(response);
621 err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
622 if (err < 0 || response->success == 0 || !response->p_intermediates){
623 if(cme_err != NULL)
624 *cme_err = at_get_cme_error(response);
625 err = -1;
626 goto exit;
627 }
628 line = response->p_intermediates->line;
629 err = at_tok_start(&line);
630 if (err < 0)
631 {
632 goto exit;
633 }
634 err = at_tok_nextint(&line, &tmp_int);
635 if (err < 0)
636 {
637 goto exit;
638 }
639 if(!at_tok_hasmore(&line)) {
640 goto exit;
641 }
642 err = at_tok_nextint(&line, &tmp_int);
643 if (err < 0)
644 {
645 goto exit;
646 }
647 err = at_tok_nextstr(&line, &tmp_ptr);
648 if (err < 0)
649 {
650 goto exit;
651 }
652 err = at_tok_nextint(&line, &tmp_int);
653 if (err < 0)
654 {
655 goto exit;
656 }
657 signal->type = (uint8)tmp_int;
658
659exit:
660 at_response_free(response);
661 return err;
662}
663
664/*
665AT+CREG=3
666OK
667
668AT+CREG?
669+CREG: 3,1,"8330","06447340",7
670
671OK
672
673AT+CREG?
674+CREG: 3,0
675
676OK
677
678AT+CEREG?
679+CEREG: 3,1,"8330","06447340",7
680
681OK
682
683
684AT+CIREG?
685+CIREG: 2,1,15
686
687OK
688
689AT+CIREG?
690+CIREG: 0
691
692OK
693
694
695*/
696static int req_net_reg_get(mbtk_net_reg_info_t *reg, int *cme_err)
697{
698 ATResponse *response = NULL;
699 int tmp_int;
700 char *tmp_str = NULL;
701 int err = at_send_command("AT+CREG=3", &response);
702 if (err < 0 || response->success == 0){
703 if(cme_err) {
704 *cme_err = at_get_cme_error(response);
705 }
706 goto exit;
707 }
708 at_response_free(response);
709
710 err = at_send_command_multiline("AT+CREG?", "+CREG:", &response);
711 if (err < 0 || response->success == 0 || !response->p_intermediates){
712 if(cme_err) {
713 *cme_err = at_get_cme_error(response);
714 }
715 goto exit;
716 }
717
718 char *line = response->p_intermediates->line;
719 err = at_tok_start(&line);
720 if (err < 0)
721 {
722 goto exit;
723 }
724 err = at_tok_nextint(&line, &tmp_int); // n
725 if (err < 0)
726 {
727 goto exit;
728 }
729 err = at_tok_nextint(&line, &tmp_int);// stat
730 if (err < 0)
731 {
732 goto exit;
733 }
734 reg->call_state = (uint8)tmp_int;
735
736 if(at_tok_hasmore(&line)) {
737 err = at_tok_nextstr(&line, &tmp_str); // lac
738 if (err < 0)
739 {
740 goto exit;
741 }
742 reg->lac = strtol(tmp_str, NULL, 16);
743
744 err = at_tok_nextstr(&line, &tmp_str); // ci
745 if (err < 0)
746 {
747 goto exit;
748 }
749 reg->ci = strtol(tmp_str, NULL, 16);
750
751 err = at_tok_nextint(&line, &tmp_int);// AcT
752 if (err < 0)
753 {
754 goto exit;
755 }
756 reg->type = (uint8)tmp_int;
757 }
758 at_response_free(response);
759
760 err = at_send_command_multiline("AT+CEREG?", "+CEREG:", &response);
761 if (err < 0 || response->success == 0 || !response->p_intermediates){
762 if(cme_err) {
763 *cme_err = at_get_cme_error(response);
764 }
765 goto exit;
766 }
767
768 line = response->p_intermediates->line;
769 err = at_tok_start(&line);
770 if (err < 0)
771 {
772 goto exit;
773 }
774 err = at_tok_nextint(&line, &tmp_int); // n
775 if (err < 0)
776 {
777 goto exit;
778 }
779 err = at_tok_nextint(&line, &tmp_int);// stat
780 if (err < 0)
781 {
782 goto exit;
783 }
784 reg->data_state = (uint8)tmp_int;
785
786 if(reg->lac == 0 && at_tok_hasmore(&line)) {
787 err = at_tok_nextstr(&line, &tmp_str); // lac
788 if (err < 0)
789 {
790 goto exit;
791 }
792 reg->lac = strtol(tmp_str, NULL, 16);
793
794 err = at_tok_nextstr(&line, &tmp_str); // ci
795 if (err < 0)
796 {
797 goto exit;
798 }
799 reg->ci = strtol(tmp_str, NULL, 16);
800
801 err = at_tok_nextint(&line, &tmp_int);// AcT
802 if (err < 0)
803 {
804 goto exit;
805 }
806 reg->type = (uint8)tmp_int;
807 }
808 at_response_free(response);
809
810 err = at_send_command_multiline("AT+CIREG?", "+CIREG:", &response);
811 if (err < 0 || response->success == 0 || !response->p_intermediates){
812 reg->ims_state = (uint8)0;
813 err = 0;
814 goto exit;
815 }
816 line = response->p_intermediates->line;
817 err = at_tok_start(&line);
818 if (err < 0)
819 {
820 goto exit;
821 }
822 err = at_tok_nextint(&line, &tmp_int); // n/stat
823 if (err < 0)
824 {
825 goto exit;
826 }
827 if(at_tok_hasmore(&line)) {
828 err = at_tok_nextint(&line, &tmp_int);// stat
829 if (err < 0)
830 {
831 goto exit;
832 }
833 reg->ims_state = (uint8)tmp_int;
834 } else {
835 reg->ims_state = (uint8)tmp_int;
836 }
837
838exit:
839 at_response_free(response);
840 return err;
841}
842
843/*
b.liub4772072024-08-15 14:47:03 +0800844AT+EEMOPT=1
845OK
846
847// LTE
848AT+EEMGINFO?
849// <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,
850// <rsrp>,<rsrq>, <sinr>,
851// errcModeState,emmState,serviceState,IsSingleEmmRejectCause,EMMRejectCause,mmeGroupId,mmeCode,mTmsi,
852// cellId,subFrameAssignType,specialSubframePatterns,transMode
853// mainRsrp,diversityRsrp,mainRsrq,diversityRsrq,rssi,cqi,pathLoss,tb0DlTpt,tb1DlTpt,tb0DlPeakTpt,tb1DlPeakTpt,tb0UlPeakTpt,
854// tb1UlPeakTpt,dlThroughPut,dlPeakThroughPut,averDlPRB,averCQITb0,averCQITb1,rankIndex,grantTotal,ulThroughPut,ulPeakThroughPut,currPuschTxPower,averUlPRB,
855// dlBer, ulBer,
856// diversitySinr, diversityRssi
857+EEMLTESVC: 1120, 2, 0, 33584, 430, 40936, 40936, 41, 20,
8580, 0, 0,
8591, 10, 0, 1, 0, 1059, 78, 3959566565,
860105149248, 2, 7, 7,
8610, 0, 0, 0, 0, 0, 0, 1190919, 0, 0, 0, 16779777,
8620, 5112867, 3959566565, 2, 0, 0, 0, 0, 0, 0, 0, 0,
8630, 0,
8647, 44
865
866// index,phyCellId,euArfcn,rsrp,rsrq
867+EEMLTEINTER: 0, 65535, 38950, 0, 0
868
869+EEMLTEINTER: 1, 0, 0, 0, 0
870
871+EEMLTEINTER: 2, 0, 4294967295, 255, 255
872
873+EEMLTEINTER: 3, 65535, 1300, 0, 0
874
875+EEMLTEINTER: 4, 0, 0, 0, 0
876
877+EEMLTEINTER: 5, 0, 4294967295, 247, 0
878
879+EEMLTEINTER: 6, 197, 41332, 24, 9
880
881+EEMLTEINTER: 7, 0, 0, 0, 0
882
883+EEMLTEINTER: 8, 0, 0, 0, 0
884
885+EEMLTEINTRA: 0, 429, 40936, 56, 12
886
887+EEMLTEINTERRAT: 0,0
888
889+EEMLTEINTERRAT: 1,0
890
891+EEMGINFO: 3, 2 // <state>:
892 // 0: ME in Idle mode
893 // 1: ME in Dedicated mode
894 // 2: ME in PS PTM mode
895 // 3: invalid state
896 // <nw_type>:
897 // 0: GSM 1: UMTS 2: LTE
898
899OK
900
901// WCDMA
902AT+EEMGINFO?
903// Mode, sCMeasPresent, sCParamPresent, ueOpStatusPresent,
904
905// if sCMeasPresent == 1
906// cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev, txPower,
907// endif
908
909// if sCParamPresent == 1
910// rac, nom, mcc, mnc_len, mnc, lac, ci,
911// uraId, psc, arfcn, t3212, t3312, hcsUsed, attDetAllowed,
912// csDrxCycleLen, psDrxCycleLen, utranDrxCycleLen, HSDPASupport, HSUPASupport,
913// endif
914
915// if ueOpStatusPresent == 1
916// rrcState, numLinks, srncId, sRnti,
917// algPresent, cipherAlg, cipherOn, algPresent, cipherAlg, cipherOn,
918// HSDPAActive, HSUPAActive, MccLastRegisteredNetwork, MncLastRegisteredNetwork, TMSI, PTMSI, IsSingleMmRejectCause, IsSingleGmmRejectCause,
919// MMRejectCause, GMMRejectCause, mmState, gmmState, gprsReadyState, readyTimerValueInSecs, NumActivePDPContext, ULThroughput, DLThroughput,
920// serviceStatus, pmmState, LAU_status, LAU_count, RAU_status, RAU_count
921// endif
922//
923+EEMUMTSSVC: 3, 1, 1, 1,
924-80, 27, -6, -18, -115, -32768,
9251, 1, 1120, 2, 1, 61697, 168432821,
92615, 24, 10763, 0, 0, 0, 0,
927128, 128, 65535, 0, 0,
9282, 255, 65535, 4294967295,
9290, 0, 0, 0, 0, 0,
9300, 0, 0, 0, 0, 0, 1, 1,
93128672, 28672, 0, 0, 0, 0, 0, 0, 0,
9320, 0, 0, 0, 0, 0
933
934// index, cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev ,mcc, mnc, lac, ci, arfcn, psc
935+EEMUMTSINTRA: 0, -32768, -1, -32768, -18, -115, 0, 0, 65534, 1, 10763, 32
936
937+EEMUMTSINTRA: 1, -1, -32768, -18, -115, 0, 0, 65534, 2, 10763, 40, 32768
938
939+EEMUMTSINTRA: 2, -32768, -18, -115, 0, 0, 65534, 3, 10763, 278, 32768, 65535
940
941+EEMUMTSINTRA: 3, -18, -115, 0, 0, -2, 4, 10763, 28, 32768, 65535, 32768
942
943+EEMUMTSINTRA: 4, -115, 0, 0, -2, 5, 10763, 270, 32768, 65535, 32768, 65518
944
945+EEMUMTSINTRA: 5, 0, 0, -2, 6, 10763, 286, 32768, 65535, 32768, 65518, 65421
946
947+EEMUMTSINTRA: 6, 0, -2, 7, 10763, 80, 32768, 65535, 32768, 65518, 65421, 0
948
949+EEMUMTSINTRA: 7, -2, 8, 10763, 206, -32768, 65535, 32768, 65518, 65421, 0, 0
950
951+EEMUMTSINTRA: 8, 9, 10763, 11, -32768, -1, 32768, 65518, 65421, 0, 0, 65534
952
953+EEMUMTSINTRA: 9, 10763, 19, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 11
954
955+EEMUMTSINTRA: 10, 232, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 12, 10763
956
957+EEMUMTSINTRA: 11, -32768, -1, -32768, -18, -115, 0, 0, 65534, 13, 10763, 66
958
959+EEMUMTSINTRA: 12, -1, -32768, -18, -115, 0, 0, 65534, 14, 10763, 216, 32768
960
961+EEMUMTSINTRA: 13, -32768, -18, -115, 0, 0, 65534, 15, 10763, 183, 32768, 65535
962
963+EEMUMTSINTRA: 14, -18, -115, 0, 0, -2, 16, 10763, 165, 32768, 65535, 32768
964
965+EEMUMTSINTRA: 15, -115, 0, 0, -2, 17, 10763, 151, 32768, 65535, 32768, 65518
966
967+EEMUMTSINTRA: 16, 0, 0, -2, 18, 10763, 43, 32768, 65535, 32768, 65518, 65421
968
969+EEMUMTSINTRA: 17, 0, -2, 19, 10763, 72, 32768, 65535, 32768, 65518, 65421, 0
970
971+EEMUMTSINTRA: 18, -2, 20, 10763, 157, -32768, 65535, 32768, 65518, 65421, 0, 0
972
973+EEMUMTSINTRA: 19, 21, 10763, 165, -32768, -1, 32768, 65518, 65421, 0, 0, 65534
974
975+EEMUMTSINTRA: 20, 10763, 301, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 23
976
977+EEMUMTSINTRA: 21, 23, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 24, 10763
978
979+EEMUMTSINTRA: 22, -32768, -1, -32768, -18, -115, 0, 0, 65534, 25, 10763, 0
980
981+EEMUMTSINTRA: 23, -1, -32768, -18, -115, 0, 0, 65534, 26, 10763, 167, 32768
982
983+EEMUMTSINTRA: 24, -32768, -18, -115, 0, 0, 65534, 27, 10763, 34, 32768, 65535
984
985+EEMUMTSINTRA: 25, -18, -115, 0, 0, -2, 28, 10763, 313, 32768, 65535, 32768
986
987+EEMUMTSINTRA: 26, -115, 0, 0, -2, 29, 10763, 152, 32768, 65535, 32768, 65518
988
989+EEMUMTSINTRA: 27, 0, 0, -2, 30, 10763, 239, 0, 0, 0, 0, 0
990
991+EEMUMTSINTRA: 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
992
993+EEMUMTSINTRA: 29, 0, 0, 0, 0, -115, 0, 0, 65534, 30, 10763, 239
994
995// index,gsmRssi,rxLev,C1,C2,mcc,mnc,lac,ci,arfcn,bsic
996+EEMUMTSINTERRAT: 0, -32768, -107, -1, -1, 0, 0, 65534, 0, 117, 36
997
998+EEMUMTSINTERRAT: 1, -107, -1, -1, 0, 0, 65534, 1, 72, 49, 0
999
1000+EEMUMTSINTERRAT: 2, -1, -1, 0, 0, 65534, 2, 119, 15, 32768, 149
1001
1002+EEMUMTSINTERRAT: 3, -1, 0, 0, -2, 3, 121, 23, 0, 0, 0
1003
1004+EEMGINFO: 3, 1
1005
1006OK
1007
1008
1009// GSM
1010AT+EEMGINFO?
1011+EEMGINFOBASIC: 2
1012
1013// mcc, mnc_len, mnc, lac, ci, nom, nco,
1014// bsic, C1, C2, TA, TxPwr,
1015// RxSig, RxSigFull, RxSigSub, RxQualFull, RxQualSub,
1016// ARFCB_tch, hopping_chnl, chnl_type, TS, PacketIdle, rac, arfcn,
1017// bs_pa_mfrms, C31, C32, t3212, t3312, pbcch_support, EDGE_support,
1018// ncc_permitted, rl_timeout, ho_count, ho_succ, chnl_access_count, chnl_access_succ_count,
1019// gsmBand,channelMode
1020+EEMGINFOSVC: 1120, 2, 0, 32784, 24741, 2, 0,
102163, 36, 146, 1, 7,
102246, 42, 42, 7, 0,
102353, 0, 8, 0, 1, 6, 53,
10242, 0, 146, 42, 54, 0, 1,
10251, 32, 0, 0, 0, 0,
10260, 0
1027
1028// PS_attached, attach_type, service_type, tx_power, c_value,
1029// ul_ts, dl_ts, ul_cs, dl_cs, ul_modulation, dl_modulation,
1030// gmsk_cv_bep, 8psk_cv_bep, gmsk_mean_bep, 8psk_mean_bep, EDGE_bep_period, single_gmm_rej_cause
1031// pdp_active_num, mac_mode, network_control, network_mode, EDGE_slq_measurement_mode, edge_status
1032+EEMGINFOPS: 1, 255, 0, 0, 0,
10330, 0, 268435501, 1, 0, 0,
10344, 0, 96, 0, 0, 0,
10350, 0, 0, 65535, 0, 13350
1036
1037+EEMGINFO: 0, 0
1038
1039OK
1040
1041*/
1042static int req_cell_info_get(int *cme_err)
1043{
1044 ATResponse *response = NULL;
1045 int tmp_int;
1046 int buff_size = 0;
1047 // AT+EEMOPT=1 in the first.
1048 int err = at_send_command("AT+EEMOPT=1", &response);
1049 if (err < 0 || response->success == 0){
1050 *cme_err = at_get_cme_error(response);
1051 goto exit;
1052 }
1053
1054 // Reset buffer in the first.
1055 memset(&cell_info, 0xFF, sizeof(mbtK_cell_pack_info_t));
1056 cell_info.running = true;
1057 cell_info.cell_list.num = 0;
1058
1059 err = at_send_command_singleline("AT+EEMGINFO?", "+EEMGINFO:", &response);
1060 if (err < 0 || response->success == 0 || !response->p_intermediates){
1061 *cme_err = at_get_cme_error(response);
1062 goto exit;
1063 }
1064
1065 // Now, cell infomation has get from URC message.
1066
1067 char *line = response->p_intermediates->line;
1068 err = at_tok_start(&line);
1069 if (err < 0)
1070 {
1071 goto exit;
1072 }
1073 err = at_tok_nextint(&line, &tmp_int);
1074 if (err < 0)
1075 {
1076 goto exit;
1077 }
1078 err = at_tok_nextint(&line, &tmp_int);
1079 if (err < 0)
1080 {
1081 goto exit;
1082 }
1083
1084 cell_info.cell_list.type = (uint8)tmp_int;
1085 cell_info.running = false;
1086
1087#if 0
1088 while(lines_ptr)
1089 {
1090 // LTE
1091 if(strStartsWith(line, "+EEMLTESVC:")) // LTE Server Cell
1092 {
1093
1094 }
1095 else if(strStartsWith(line, "+EEMLTEINTER:")) // LTE
1096 {
1097
1098 }
1099 else if(strStartsWith(line, "+EEMLTEINTRA:")) // LTE
1100 {
1101
1102 }
1103 else if(strStartsWith(line, "+EEMLTEINTERRAT:")) // LTE
1104 {
1105
1106 }
1107 else if(strStartsWith(line, "+EEMGINFO:")) // <state>: 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode 3: invalid state
1108 // <nw_type>: 0: GSM 1: UMTS 2: LTE
1109 {
1110
1111 }
1112 // WCDMA
1113 else if(strStartsWith(line, "+EEMUMTSSVC:")) // WCDMA Server Cell
1114 {
1115
1116 }
1117 else if(strStartsWith(line, "+EEMUMTSINTRA:")) // WCDMA
1118 {
1119
1120 }
1121 else if(strStartsWith(line, "+EEMUMTSINTERRAT:")) // WCDMA
1122 {
1123
1124 }
1125 // GSM
1126 else if(strStartsWith(line, "+EEMGINFOBASIC:")) // Basic information in GSM
1127 // 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode
1128 {
1129
1130 }
1131 else if(strStartsWith(line, "+EEMGINFOSVC:")) // GSM Server Cell
1132 {
1133
1134 }
1135 else if(strStartsWith(line, "+EEMGINFOPS:")) // PS
1136 {
1137
1138 }
1139
1140
1141 lines_ptr = lines_ptr->p_next;
1142 }
1143#endif
1144
1145exit:
1146 at_response_free(response);
1147 return buff_size;
1148}
1149
1150static int req_cell_info_set(const char *cmgl, char *reg, int len, int *cme_err)
1151{
1152 ATResponse *response = NULL;
b.liu62240ee2024-11-07 17:52:45 +08001153 char cmd[500] = {0};
b.liub4772072024-08-15 14:47:03 +08001154 char data[218] = {0};
1155 int err = 0;
1156
1157 memcpy(data, cmgl, len);
1158
1159 sprintf(cmd, "AT*CELL=%s", data);
1160
1161 if(strlen(cmd) > 0)
1162 {
1163 err = at_send_command_multiline(cmd, "", &response);
1164 if (err < 0 || response->success == 0 || !response->p_intermediates){
1165 *cme_err = at_get_cme_error(response);
1166 goto exit;
1167 }
1168
1169 ATLine* lines_ptr = response->p_intermediates;
1170 char *line = NULL;
b.liu62240ee2024-11-07 17:52:45 +08001171// int reg_len = 0;
1172// bool flag = false;
b.liub4772072024-08-15 14:47:03 +08001173 while(lines_ptr)
1174 {
1175 line = lines_ptr->line;
1176 if(line ==NULL)
1177 {
1178 LOGD("line is null----------------------");
1179 }
1180 lines_ptr = lines_ptr->p_next;
1181 }
1182 }
1183 err = 0;
1184 memcpy(reg, "req_cell_info_set succss", strlen("req_cell_info_set succss"));
1185exit:
1186 at_response_free(response);
1187 return err;
1188}
1189
b.liu87afc4c2024-08-14 17:33:45 +08001190//void net_list_free(void *data);
1191// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
1192// Otherwise, do not call pack_error_send().
1193mbtk_ril_err_enum net_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
1194{
1195 mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
1196 int cme_err = MBTK_RIL_ERR_CME_NON;
1197 switch(pack->msg_id)
1198 {
1199 case RIL_MSG_ID_NET_AVAILABLE:
1200 {
1201 if(pack->data_len == 0 || pack->data == NULL)
1202 {
1203 mbtk_net_info_array_t net_array;
1204 memset(&net_array, 0, sizeof(mbtk_net_info_array_t));
1205 if(req_available_net_get(&net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1206 {
1207 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1208 err = MBTK_RIL_ERR_CME + cme_err;
1209 } else {
1210 err = MBTK_RIL_ERR_UNKNOWN;
1211 }
1212 LOGD("Get Available Net fail.");
1213 }
1214 else
1215 {
1216 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
1217 }
1218 }
1219 else // Set
1220 {
1221 err = MBTK_RIL_ERR_UNSUPPORTED;
1222 LOGW("Unsupport set available net.");
1223 }
1224 break;
1225 }
1226 case RIL_MSG_ID_NET_SEL_MODE:
1227 {
1228 if(pack->data_len == 0 || pack->data == NULL)
1229 {
1230 mbtk_net_info_t info;
1231 memset(&info, 0, sizeof(mbtk_net_info_t));
1232 if(req_net_sel_mode_get(&info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1233 {
1234 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1235 err = MBTK_RIL_ERR_CME + cme_err;
1236 } else {
1237 err = MBTK_RIL_ERR_UNKNOWN;
1238 }
1239 LOGD("Get Net sel mode fail.");
1240 }
1241 else
1242 {
1243 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
1244 }
1245 }
1246 else // Set
1247 {
1248 mbtk_net_info_t *info = (mbtk_net_info_t*)pack->data;
1249 if(req_net_sel_mode_set(info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1250 {
1251 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1252 err = MBTK_RIL_ERR_CME + cme_err;
1253 } else {
1254 err = MBTK_RIL_ERR_UNKNOWN;
1255 }
1256 LOGD("Set Net sel mode fail.");
1257 }
1258 else
1259 {
1260 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
1261 }
1262 }
1263 break;
1264 }
1265 case RIL_MSG_ID_NET_BAND:
1266 {
1267 if(pack->data_len == 0 || pack->data == NULL)
1268 {
1269 err = MBTK_RIL_ERR_REQ_PARAMETER;
1270 LOG("No data found.");
1271 }
1272 else // Set
1273 {
1274 if(pack->data_len == sizeof(uint8)) {
1275 if(*(pack->data)) { // Get current bands.
1276 mbtk_band_info_t band;
1277 memset(&band, 0x0, sizeof(mbtk_band_info_t));
1278 if(req_band_get(&band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1279 {
1280 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1281 err = MBTK_RIL_ERR_CME + cme_err;
1282 } else {
1283 err = MBTK_RIL_ERR_UNKNOWN;
1284 }
1285 LOG("Get net band fail.");
1286 }
1287 else
1288 {
1289 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
1290 }
1291 } else { // Get support bands.
1292 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
1293 }
1294 } else { // Set current bands.
1295 mbtk_band_info_t* band = (mbtk_band_info_t*)pack->data;
1296 if(pack->data_len != sizeof(mbtk_band_info_t))
1297 {
1298 err = MBTK_RIL_ERR_REQ_PARAMETER;
1299 LOG("Set net band error.");
1300 break;
1301 }
1302
1303 if(req_band_set(band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1304 {
1305 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1306 err = MBTK_RIL_ERR_CME + cme_err;
1307 } else {
1308 err = MBTK_RIL_ERR_UNKNOWN;
1309 }
1310 LOG("Set net band fail.");
1311 }
1312 else
1313 {
1314 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
1315 }
1316 }
1317 }
1318 break;
1319 }
1320 case RIL_MSG_ID_NET_SIGNAL:
1321 {
1322 if(pack->data_len == 0 || pack->data == NULL)
1323 {
1324 mbtk_signal_info_t signal;
1325 memset(&signal, 0, sizeof(mbtk_signal_info_t));
1326 if(req_net_signal_get(&signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1327 {
1328 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1329 err = MBTK_RIL_ERR_CME + cme_err;
1330 } else {
1331 err = MBTK_RIL_ERR_UNKNOWN;
1332 }
1333 LOGD("Get net signal fail.");
1334 }
1335 else
1336 {
1337 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
1338 }
1339 }
1340 else // Set
1341 {
1342 err = MBTK_RIL_ERR_UNSUPPORTED;
1343 LOGW("Unsupport set net signal.");
1344 }
1345 break;
1346 }
1347 case RIL_MSG_ID_NET_REG:
1348 {
1349 if(pack->data_len == 0 || pack->data == NULL)
1350 {
1351 mbtk_net_reg_info_t net_reg;
1352 memset(&net_reg, 0, sizeof(mbtk_net_reg_info_t));
1353 if(req_net_reg_get(&net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1354 {
1355 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1356 err = MBTK_RIL_ERR_CME + cme_err;
1357 } else {
1358 err = MBTK_RIL_ERR_UNKNOWN;
1359 }
1360 LOGD("Get Net reg info fail.");
1361 }
1362 else
1363 {
1364 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
1365 }
1366 }
1367 else // Set
1368 {
1369 err = MBTK_RIL_ERR_UNSUPPORTED;
1370 LOGW("Unsupport set net reg info.");
1371 }
1372 break;
1373 }
1374 case RIL_MSG_ID_NET_CELL:
1375 {
b.liub4772072024-08-15 14:47:03 +08001376 if(pack->data_len == 0 || pack->data == NULL) // Get net cell.
b.liu87afc4c2024-08-14 17:33:45 +08001377 {
b.liub4772072024-08-15 14:47:03 +08001378 if(req_cell_info_get(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
b.liu87afc4c2024-08-14 17:33:45 +08001379 {
1380 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1381 err = MBTK_RIL_ERR_CME + cme_err;
1382 } else {
1383 err = MBTK_RIL_ERR_UNKNOWN;
1384 }
b.liub4772072024-08-15 14:47:03 +08001385 LOG("Get net cell fail.");
b.liu87afc4c2024-08-14 17:33:45 +08001386 }
1387 else
1388 {
b.liub4772072024-08-15 14:47:03 +08001389 LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
1390 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
b.liu87afc4c2024-08-14 17:33:45 +08001391 }
1392 }
b.liub4772072024-08-15 14:47:03 +08001393 else // Lock cell
b.liu87afc4c2024-08-14 17:33:45 +08001394 {
b.liub4772072024-08-15 14:47:03 +08001395 char *mem = (char*)(pack->data);
1396 int len = pack->data_len;
1397 char reg[100] = {0};
1398 if(req_cell_info_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
1399 {
1400 if(cme_err != MBTK_RIL_ERR_CME_NON) {
1401 err = MBTK_RIL_ERR_CME + cme_err;
1402 } else {
1403 err = MBTK_RIL_ERR_UNKNOWN;
1404 }
1405 }
1406 else
1407 {
1408 ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
1409 }
b.liu87afc4c2024-08-14 17:33:45 +08001410 }
1411 break;
1412 }
b.liu87afc4c2024-08-14 17:33:45 +08001413 default:
1414 {
1415 err = MBTK_RIL_ERR_REQ_UNKNOWN;
1416 LOG("Unknown request : %s", id2str(pack->msg_id));
1417 break;
1418 }
1419 }
1420
1421 return err;
1422}
1423