blob: 2ee0f5888b68eb617e064f7fb3311b77b6d23506 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +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 <string.h>
11#include <fcntl.h>
12#include <signal.h>
13
14#include "mbtk_info_api.h"
b.liu4e243dc2023-11-27 11:20:00 +080015
16#define DSC_to_msg(DSC) (DSC == 0 ? "Bit7" : (DSC == 1 ? "Bit8" : "UCS2"))
liubin281ac462023-07-19 14:22:54 +080017
18//#include "lynq_net_api.h"
19
20static mbtk_info_handle_t* info_handle = NULL;
21
22void net_state_change_cb(const void* data, int data_len)
23{
b.liufe320632024-01-17 20:38:08 +080024 if(data && data_len > 0) {
25 const uint8 *ptr = (const uint8*)data;
26 if(*ptr == 0) { // CS
27 printf("CS:act=%d, mode=%d\n", *(ptr + 1), *(ptr + 2));
28 } else { // PS
29 printf("PS[%s]:act=%d, mode=%d\n", *(ptr + 3) == 0 ? "GSM/WCDMA" : "LTE", *(ptr + 1), *(ptr + 2));
30 }
31 } else
32 LOGD("NET_CB : NULL");
liubin281ac462023-07-19 14:22:54 +080033}
34
35void call_state_change_cb(const void* data, int data_len)
36{
37 mbtk_call_info_t *reg = (mbtk_call_info_t *)data;
38 switch (reg->call_wait)
39 {
40 case MBTK_CLCC:
41 printf("\r\nRING : %d, %d, %d, %d, %d, %s, %d\r\n", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type);
42 break;
43 case MBTK_DISCONNECTED:
44 printf("\r\nRING : call dis connected!\r\n");
45 break;
46 case MBTK_CPAS:
47 printf("\r\nCALL : Call state = %d\r\n", reg->pas);
48 /*
49 MBTK_CALL_RADY, //MT allows commands from TA/TE
50 MBTK_CALL_UNAVAILABLE, //MT does not allow commands from TA/TE
51 MBTK_CALL_UNKNOWN, //MT is not guaranteed to respond to instructions
52 MBTK_CALL_RINGING, //MT is ready for commands from TA/TE, but the ringer is active
53 MBTK_CALL_PROGRESS, //MT is ready for commands from TA/TE, but a call is in progress
54 MBTK_CALL_ASLEEP, //MT is unable to process commands from TA/TE because it is in a low functionality state
55 MBTK_CALL_ACTIVE,
56 */
57 switch (reg->pas)
58 {
59 case MBTK_CALL_RADY:
60 printf("CALL: call READY\r\n");
61 break;
62 case MBTK_CALL_UNAVAILABLE:
63 printf("CALL: call unavaliable\r\n");
64 break;
65 case MBTK_CALL_UNKNOWN:
66 printf("CALL: call unknown\r\n");
67 break;
68 case MBTK_CALL_RINGING:
69 printf("CALL: call ringing\r\n");
70 break;
71 case MBTK_CALL_PROGRESS:
72 printf("CALL: call progress\r\n");
73 break;
74 case MBTK_CALL_ASLEEP:
75 printf("CALL: call asleep\r\n");
76 break;
77 case MBTK_CALL_ACTIVE:
78 printf("CALL: call active\r\n");
79 break;
80 default:
81 printf("\r\n");
82 break;
83 }
84 break;
85 default:
86 printf("\r\nRING : None call_wait = %d\r\n", reg->call_wait);
87 break;
88 }
89 /*
90 if(reg->call_wait == ) //CLCC
91 {
92 printf("\r\nRING : %d, %d, %d, %d, %d, %s, %d\r\n", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type);
93 }
94 else if(reg->call_wait == 2) //Disconnected
95 {
96 printf("\r\nRING : call dis connected!\r\n");
97 }
98 else
99 {
100 printf("\r\nRING : None\r\n");
101 }
102 */
103}
104
105void sms_state_change_cb(const void* data, int data_len)
106{
107 LOGV("sms_state_change_cb()----------start\n");
108 uint8 *ptr = (uint8*)data;
109 printf("3sms_state_change_cb() : %s\n", ptr);
110
111 struct SMS_Struct s = PDUDecoding(ptr);
112 printf("服务中心地址: %s\n", s.SCA);
113 printf("发送方地址: %s\n", s.OA);
114 printf("服务中心时间戳: %s\n", s.SCTS);
115 printf("消息内容: %s\n", s.UD);
116 printf("数据编码方案: %s\n", DSC_to_msg(s.DCS));
117
118}
119
120void radio_state_change_cb(const void* data, int data_len)
121{
122 uint8 *ptr = (uint8*)data;
123 printf("Radio state : %d\n", *ptr);
124}
125
126void sim_state_change_cb(const void* data, int data_len)
127{
128 uint8 *ptr = (uint8*)data;
129 printf("SIM state : %d\n", *ptr);
130}
131
132#include <netdb.h>
133#include <sys/socket.h>
134#include <netinet/in.h>
135#include <arpa/inet.h>
136
137static void test2(int is_ipv6, char *ip)
138{
139 char ipaddr[20] = {0};
140 if(is_ipv6) {
141 struct in6_addr sin_addr;
142 if(inet_pton(AF_INET6, ip, &sin_addr) < 0) {
143 printf("inet_pton() fail.\n");
144 } else {
145 log_hex("IPv6", &sin_addr, sizeof(struct in6_addr));
146 }
147 } else {
148 struct in_addr sin_addr;
149 if(inet_pton(AF_INET, ip, &sin_addr) < 0) {
150 printf("inet_pton() fail.\n");
151 } else {
152 log_hex("IPv4", &sin_addr, sizeof(struct in_addr));
153 }
154 }
155}
156
157
158static void help()
159{
160 printf("version: Get version.\n");
161 printf("imei: Get IMEI.\n");
162 printf("sn: Get SN.\n");
163 printf("meid: Get MEID.\n");
164 printf("volte: Get VoLTE state.\n");
165 printf("volte 0: Close VoLTE.\n");
166 printf("volte 1: Open VoLTE.\n");
167 printf("radio: Get radio state.\n");
168 printf("radio 0: Close radio.\n");
169 printf("radio 1: Open radio.\n");
170 printf("sim: Get sim state.\n");
171 printf("avail_net: Get available network.\n");
172 printf("imsi: Get IMSI.\n");
173 printf("iccid: Get ICCID.\n");
174 printf("pn: Get Phone Number.\n");
175 printf("sel_mode: Get network select mode.\n");
176 printf("sel_mode <sel_mode> <net_type> <plmn>: Set network select mode.\n");
177 printf("band: Get current bands.\n");
178 printf("band support: Get support bands.\n");
179 printf("band <net_pref> <gsm_band> <umts_band> <tdlte_band> <fddlte_band>: Set current bands.\n");
180 printf("signal: Get network signal.\n");
181 printf("reg: Get network registe information.\n");
182 printf("cell: Get current cell information.\n");
183 printf("shutdown <0,1,2>: reboot/poweroff/halt system.\n");
184 printf("power_sim <0,1>: Power off/on sim.\n");
185 printf("temp <0,1>: Get SOC/RF temperature.\n");
186 printf("time <0,1,2> YYYY-MM-DD HH:MM:SS : Set system time as CELL/NTP/User.\n");
187 printf("apn : Get current apns.\n");
188 printf("apn <cid> <1/2/3/4> <apn> : Set apn.\n");
189 printf("data_call <0/1/2> <cid> <timeout>: Stop/Start/State data call.\n");
190 printf("call: Call the phone number.\n");
191 printf("answer: Answer the phone call.\n");
192 printf("hangup: Hang up all phone call. No id.\n");
193 printf("hangup 0: Hang up waiting or background phone call.\n");
194 printf("hangup 1: Hang up a phone call.\n");
195 printf("hangup 2: Hang up a phone call.\n");
196 printf("hangup 3: Hangup foreground resume background call.\n");
197 printf("waitin: Returns the list of current calls.\n");
198 printf("mute: Get mute state.\n");
199 printf("mute 0: Close mute.\n");
200 printf("mute 1: Open mute.\n");
201 printf("dtmf : Set dtmf character[0, 1, 2, ..., A, B, C, D, *, #], duration [300-600].\n Such as: dtmf 0 300\n");
b.liud8043a32024-06-07 16:08:22 +0800202 printf("ims_en 0/1 : Close/Open IMS(Restart takes effect).\n");
203 printf("ims_state : Get IMS open or not?\n");
204 printf("ims_reg: Get IMS register state.\n");
liubin281ac462023-07-19 14:22:54 +0800205}
206
207static void sig_process(int sig)
208{
209 LOGI("I got signal %d\n", sig);
210 switch(sig)
211 {
212 case SIGINT: // Ctrl + C
213 {
214 LOGI("Exit by SIGINT.\n");
215 mbtk_info_handle_free(&info_handle);
216 exit(0);
217 }
218 case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
219 {
220 LOGI("Exit by SIGQUIT.\n");
221 mbtk_info_handle_free(&info_handle);
222 exit(0);
223 }
224 case SIGTERM:// 默认kill (同 SIGKILL ,但 SIGKILL 不可捕获)
225 {
226 LOGI("Exit by SIGTERM.\n");
227 mbtk_info_handle_free(&info_handle);
228 exit(0);
229 }
230 case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
231 {
232 LOGI("Exit by SIGTSTP.\n");
233 exit(0);
234 }
235 case SIGSEGV: // 如空指针
236 {
237 LOGI("Exit by SIGSEGV.\n");
238 exit(0);
239 }
240 default:
241 {
242 LOGI("Unknown sig:%d\n",sig);
243 break;
244 }
245 }
246}
247
248int main(int argc, char *argv[])
249{
250 signal(SIGINT, sig_process);
251 signal(SIGQUIT, sig_process);
252 signal(SIGTERM, sig_process);
253 //signal(SIGTSTP, sig_process);
254 //signal(SIGSEGV, sig_process);
255
b.liufe320632024-01-17 20:38:08 +0800256 mbtk_log_init("radio","INFO_CLI");
liubin281ac462023-07-19 14:22:54 +0800257
258 //test2(0, "192.168.1.198");
259 //test2(1, "2409:8162:140:cd3c:1:2:1494:72ba");
260 //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
261 //test2(1, "2400:3200::1");
262
263 info_handle = mbtk_info_handle_get();
264 if(!info_handle)
265 {
266 return -1;
267 }
268
269 mbtk_net_state_change_cb_reg(info_handle, net_state_change_cb);
270 mbtk_call_state_change_cb_reg(info_handle, call_state_change_cb);
271 mbtk_sms_state_change_cb_reg(info_handle, sms_state_change_cb);
272 mbtk_radio_state_change_cb_reg(info_handle, radio_state_change_cb);
273 mbtk_sim_state_change_cb_reg(info_handle, sim_state_change_cb);
274
275 printf(">>>>>>>>>>>>>>>>>>>>>>>>Enter cmd:\n");
276 char cmd[100];
277 while(1)
278 {
279 memset(cmd, 0, 100);
280 int err;
281 if(fgets(cmd, 100, stdin))
282 {
283 char *ptr = cmd + strlen(cmd) - 1;
284 while(ptr >= cmd && (*ptr == '\r' || *ptr == '\n'))
285 {
286 *ptr-- = '\0';
287 }
288 if(!strncasecmp(cmd, "version", 7))
289 {
290 char version[50] = {0};
291 err = mbtk_version_get(info_handle, version);
292 if(err) {
293 printf("Error : %d\n", err);
294 } else {
295 printf("Version : %s\n", version);
296 }
297 } else if(!strncasecmp(cmd, "imei", 4)){
298 char imei[50] = {0};
299 err = mbtk_imei_get(info_handle, imei);
300 if(err) {
301 printf("Error : %d\n", err);
302 } else {
303 printf("IMEI : %s\n", imei);
304 }
305 } else if(!strncasecmp(cmd, "sn", 2)){
306 char sn[50] = {0};
307 err = mbtk_sn_get(info_handle, sn);
308 if(err) {
309 printf("Error : %d\n", err);
310 } else {
311 printf("SN : %s\n", sn);
312 }
313 } else if(!strncasecmp(cmd, "meid", 4)){
314 char meid[50] = {0};
315 err = mbtk_meid_get(info_handle, meid);
316 if(err) {
317 printf("Error : %d\n", err);
318 } else {
319 printf("MEID : %s\n", meid);
320 }
321 } else if(!strncasecmp(cmd, "volte", 5)){ // "volte" or "volte 0" or "volte 1"
322 int volte;
323 if(!strcasecmp(cmd, "volte")) { // Get
324 err = mbtk_volte_state_get(info_handle, &volte);
325 if(err) {
326 printf("Error : %d\n", err);
327 } else {
328 printf("VoLTE : %d\n", volte);
329 }
330 } else { // Set
331 if(!strcasecmp(cmd, "volte 1")) { // Open VoLTE
332 volte = 1;
333 } else { // Close VoLTE
334 volte = 0;
335 }
336 err = mbtk_volte_state_set(info_handle, volte);
337 if(err) {
338 printf("Error : %d\n", err);
339 } else {
340 printf("VoLTE set success\n");
341 }
342 }
343 } else if(!strncasecmp(cmd, "radio", 5)){ // "radio" or "radio 0" or "radio 1"
344 int radio;
345 if(!strcasecmp(cmd, "radio")) { // Get
346 err = mbtk_radio_state_get(info_handle, &radio);
347 if(err) {
348 printf("Error : %d\n", err);
349 } else {
350 printf("Radio : %d\n", radio);
351 }
352 } else { // Set
353 if(!strcasecmp(cmd, "radio 1")) { // Open radio
354 radio = 1;
355 } else { // Close radio
356 radio = 0;
357 }
358 err = mbtk_radio_state_set(info_handle, radio);
359 if(err) {
360 printf("Error : %d\n", err);
361 } else {
362 printf("Radio set success\n");
363 }
364 }
365 } else if(!strncasecmp(cmd, "sim", 3)){
366 mbtk_sim_state_enum sim;
367 err = mbtk_sim_state_get(info_handle, &sim);
368 if(err) {
369 printf("Error : %d\n", err);
370 } else {
371 printf("Sim : %d\n", sim);
372 }
373 } else if(!strncasecmp(cmd, "imsi", 4)){
374 char imsi[50] = {0};
375 err = mbtk_imsi_get(info_handle, imsi);
376 if(err) {
377 printf("Error : %d\n", err);
378 } else {
379 printf("IMSI : %s\n", imsi);
380 }
381 } else if(!strncasecmp(cmd, "iccid", 5)){
382 char iccid[50] = {0};
383 err = mbtk_iccid_get(info_handle, iccid);
384 if(err) {
385 printf("Error : %d\n", err);
386 } else {
387 printf("ICCID : %s\n", iccid);
388 }
389 } else if(!strncasecmp(cmd, "pn", 2)){
390 char phone_number[50] = {0};
391 err = mbtk_phone_number_get(info_handle, phone_number);
392 if(err) {
393 printf("Error : %d\n", err);
394 } else {
395 printf("Phone Number : %s\n", phone_number);
396 }
397 } else if(!strncasecmp(cmd, "avail_net", 9)){
398 list_node_t* net_list = NULL;
399 err = mbtk_available_net_get(info_handle, &net_list);
400 if(err || net_list == NULL) {
401 printf("Error : %d\n", err);
402 } else {
403 mbtk_net_info_t* net = NULL;
404 list_first(net_list);
405 while ((net = (mbtk_net_info_t*) list_next(net_list)))
406 {
407 printf("Net : %d, %d, %d, %d\n", net->net_sel_mode, net->net_type, net->net_state, net->plmn);
408 }
409 }
410 list_free(net_list);
411 } else if(!strncasecmp(cmd, "cell", 4)){
412 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
413 if(ptr == NULL)
414 {
415 printf("ptr == NULL\n");
416 list_node_t* cell_list = NULL;
417 int type;
418 err = mbtk_cell_get(info_handle, &type, &cell_list);
419 if(err || cell_list == NULL) {
420 printf("Error : %d\n", err);
421 } else {
422 list_first(cell_list);
423 mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);
424 if(cell) { // Current server cell.
425 switch(type)
426 {
427 case 0:
428 printf("GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);
429 break;
430 case 1:
431 printf("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
432 break;
433 case 2:
434 printf("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
435 break;
436 default:
437 break;
438 }
439 }
440 while ((cell = (mbtk_cell_info_t*) list_next(cell_list)))
441 {
442 switch(type)
443 {
444 case 0:
445 printf("CELL : %d, %d, %d, %d, %d", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
446 break;
447 case 1:
448 printf("CELL : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
449 break;
450 case 2:
451 printf("CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);
452 break;
453 default:
454 break;
455 }
456 }
457 }
458 list_free(cell_list);
459 }
460 else{
461 char *ptr = strstr(cmd, ","); //cell,2,3,,40936,430
462 char mem[50]={0};
463 char resp[1024] = {0};
464 if(ptr != NULL)
465 {
466 ptr++;
467 memset(mem, 0, sizeof(mem));
468 memcpy(mem, ptr, strlen(ptr));
469 printf("cell:%s\n", mem);
470 }
471 printf("cell_mem: %s \n", mem);
472
473 memset(resp, 0, sizeof(resp));
474 err = mbtk_cell_set(info_handle, mem, resp);
475 if(err) {
476 printf("Error : %d\n", err);
477 } else {
478 printf("cell set . resp:%s\n", resp);
479 }
480
481 }
482 } else if(!strncasecmp(cmd, "sel_mode", 8)){ // "sel_mode" or "sel_mode 1 7 46000"
483 mbtk_net_info_t net;
484 memset(&net, 0, sizeof(mbtk_net_info_t));
485 if(!strcasecmp(cmd, "sel_mode")) { // Get
486 err = mbtk_net_sel_mode_get(info_handle, &net);
487 if(err) {
488 printf("Error : %d\n", err);
489 } else {
490 printf("Net : %d, %d, %d, %d\n", net.net_sel_mode, net.net_type, net.net_state, net.plmn);
491 }
492 } else { // Set
493 char *ptr = strstr(cmd, " ");
494 if(ptr == NULL)
495 continue;
496 while(*ptr != '\0' && *ptr == ' ')
497 ptr++;
498 net.net_sel_mode = (uint8)atoi(ptr);
499
500 ptr = strstr(ptr, " ");
501 if(ptr == NULL)
502 continue;
503 while(*ptr != '\0' && *ptr == ' ')
504 ptr++;
505 net.net_type = (uint8)atoi(ptr);
506
507 ptr = strstr(ptr, " ");
508 if(ptr == NULL)
509 continue;
510 while(*ptr != '\0' && *ptr == ' ')
511 ptr++;
512 net.plmn = (uint32)atoi(ptr);
513
514 err = mbtk_net_sel_mode_set(info_handle, &net);
515 if(err) {
516 printf("Error : %d\n", err);
517 } else {
518 printf("Net select mode set success\n");
519 }
520 }
521 } else if(!strncasecmp(cmd, "band", 4)){ // "band" or "band support" or "band 0 79 147 482 524503"
522 mbtk_band_info_t band;
b.liu288093c2024-05-09 17:02:57 +0800523 memset(&band, 0x0, sizeof(mbtk_band_info_t));
liubin281ac462023-07-19 14:22:54 +0800524 if(!strcasecmp(cmd, "band")) { // Get
525 err = mbtk_current_band_get(info_handle, &band);
526 if(err) {
527 printf("Error : %d\n", err);
528 } else {
529 printf("Band : %d, %d, %d, %d, %d\n", band.net_pref, band.gsm_band, band.umts_band, band.tdlte_band, band.fddlte_band);
530 }
531 } else if(!strcasecmp(cmd, "band support")) { // Get
532 err = mbtk_support_band_get(info_handle, &band);
533 if(err) {
534 printf("Error : %d\n", err);
535 } else {
536 printf("Band : %d, %d, %d, %d, %d\n", band.net_pref, band.gsm_band, band.umts_band, band.tdlte_band, band.fddlte_band);
537 }
538 } else { // "band 0 79 147 482 524503"
539 char *ptr = strstr(cmd, " ");
540 if(ptr == NULL)
541 continue;
542 while(*ptr != '\0' && *ptr == ' ')
543 ptr++;
544 band.net_pref = (uint8)atoi(ptr);
545
546 ptr = strstr(ptr, " ");
547 if(ptr == NULL)
548 continue;
549 while(*ptr != '\0' && *ptr == ' ')
550 ptr++;
551 band.gsm_band = (uint16)atoi(ptr);
552
553 ptr = strstr(ptr, " ");
554 if(ptr == NULL)
555 continue;
556 while(*ptr != '\0' && *ptr == ' ')
557 ptr++;
558 band.umts_band = (uint16)atoi(ptr);
559
560 ptr = strstr(ptr, " ");
561 if(ptr == NULL)
562 continue;
563 while(*ptr != '\0' && *ptr == ' ')
564 ptr++;
565 band.tdlte_band = (uint32)atoi(ptr);
566
567 ptr = strstr(ptr, " ");
568 if(ptr == NULL)
569 continue;
570 while(*ptr != '\0' && *ptr == ' ')
571 ptr++;
572 band.fddlte_band = (uint32)atoi(ptr);
573
574 err = mbtk_current_band_set(info_handle, &band);
575 if(err) {
576 printf("Error : %d\n", err);
577 } else {
578 printf("Band set success\n");
579 }
580 }
581 } else if(!strncasecmp(cmd, "signal", 6)){
582 mbtk_signal_info_t signal;
583 err = mbtk_net_signal_get(info_handle, &signal);
584 if(err) {
585 printf("Error : %d\n", err);
586 } else {
587 printf("Signal : %d, %d, %d, %d, %d, %d, %d, %d\n", signal.type, signal.rssi, signal.rxlev, signal.ber,
588 signal.rscp, signal.ecno, signal.rsrq, signal.rsrp);
589 }
590 } else if(!strncasecmp(cmd, "reg", 3)){
591 mbtk_net_reg_info_t reg;
592 err = mbtk_net_reg_get(info_handle, &reg);
593 if(err) {
594 printf("Error : %d\n", err);
595 } else {
596 printf("REG : call_state=%d, data_state=%d, ims_state=%d, net_type=%d, %04x, %08x\n", reg.call_state, reg.data_state, reg.ims_state, reg.type, reg.lac, reg.ci);
597 }
598 } else if(!strncasecmp(cmd, "call", 4)){
599 char phone_number[12];
600 char *ptr = strstr(cmd, " ");
601 if(ptr == NULL)
602 continue;
603 while(*ptr != '\0' && *ptr == ' ')
604 ptr++;
605 memset(phone_number,0,strlen(phone_number));
606 memcpy(phone_number,ptr,strlen(ptr));
607 printf("phone number is: %s\n",phone_number);
608 err = mbtk_call_start(info_handle, phone_number);
609 if(err) {
610 printf("Error : %d\n", err);
611 } else {
612 printf("Call success.\n");
613 }
614 } else if(!strncasecmp(cmd, "answer", 6)){
615 err = mbtk_call_answer(info_handle);
616 if(err) {
617 printf("Error : %d\n", err);
618 } else {
619 printf("Call success.\n");
620 }
621 } else if(!strncasecmp(cmd, "hangup", 6)){
622 int phone_id;
623 if(!strcasecmp(cmd, "hangup")) { // hang up all
624 err = mbtk_call_hang(info_handle);
625 if(err) {
626 printf("Error : %d\n", err);
627 } else {
628 printf("Call hang up all.\n");
629 }
630 } else if(!strcasecmp(cmd, "hangup 0")) {
631 err = mbtk_waiting_or_background_call_hang(info_handle);
632 if(err) {
633 printf("Error : %d\n", err);
634 } else {
635 printf("Call hang up waiting or background.\n");
636 }
637 } else if(!strcasecmp(cmd, "hangup 3")) {
638 err = mbtk_foreground_resume_background_call_hang(info_handle);
639 if(err) {
640 printf("Error : %d\n", err);
641 } else {
642 printf("Call hang up foreground resume background.\n");
643 }
644 } else {
645 if(!strcasecmp(cmd, "hangup 1")) { // hang up a call
646 phone_id = 1;
647 } else if(!strcasecmp(cmd, "hangup 2")) {
648 phone_id = 2;
649 } else {
650 printf("Error : Invalid input\n");
651 }
652 err = mbtk_a_call_hang(info_handle, phone_id);
653 if(err) {
654 printf("Error : %d\n", err);
655 } else {
656 printf("A Call hang up.\n");
657 }
658 }
659 } else if(!strncasecmp(cmd, "waitin", 6)){
660 mbtk_call_info_t reg;
661 err = mbtk_call_reg_get(info_handle, &reg);
662 if(err) {
663 printf("Error : %d\n", err);
664 } else {
665 if(reg.call_wait == 0) {
666 printf("No call ring\n");
667 }
668 else {
669 printf("RING : %d, %d, %d, %d, %d, %s, %d\n", reg.dir1, reg.dir, reg.state, reg.mode, reg.mpty, reg.phone_number, reg.type);
670 }
671 }
672 } else if(!strncasecmp(cmd, "mute", 4)){ // "mute" or "mute 0" or "mute 1"
673 int mute;
674 if(!strcasecmp(cmd, "mute")) { // Get
675 err = mbtk_mute_state_get(info_handle, &mute);
676 if(err) {
677 printf("Error : %d\n", err);
678 } else {
679 printf("mute : %d\n", mute);
680 }
681 } else { // Set
682 if(!strcasecmp(cmd, "mute 1")) { // on mute
683 mute = 1;
684 } else { // off mute
685 mute = 0;
686 }
687 err = mbtk_mute_state_set(info_handle, mute);
688 if(err) {
689 printf("Error : %d\n", err);
690 } else {
691 printf("mute set success\n");
692 }
693 }
694 } else if(!strncasecmp(cmd, "DTMF", 4)){ // valid character: (0, 1, ..., 9, A, B, C, D, *, #)
695
696 mbtk_call_dtmf_info_t reg;
697
698 char *ptr = strstr(cmd, " ");
699 if(ptr == NULL)
700 continue;
701 while(*ptr != '\0' && *ptr == ' ')
702 ptr++;
703 reg.character = *ptr;
704
705 ptr = strstr(ptr, " ");
706 if(ptr == NULL)
707 continue;
708 while(*ptr != '\0' && *ptr == ' ')
709 ptr++;
710 reg.duration = (uint32)atoi(ptr);
711 printf("DTMF character is: %c,%d\n",reg.character, reg.duration);
712 err = mbtk_dtmf_send(info_handle, &reg);
713 if(err) {
714 printf("Error : %d\n", err);
715 } else {
716 printf("DTMF success.\n");
717 }
718 } else if(!strncasecmp(cmd, "shutdown", 8)){
719 if(!strcasecmp(cmd, "shutdown 0")) {
720 err = mbtk_system_reboot(0);
721 if(err) {
722 printf("Error : %d\n", err);
723 } else {
724 printf("Success.\n");
725 }
726 } else if(!strcasecmp(cmd, "shutdown 1")) {
727 err = mbtk_system_reboot(1);
728 if(err) {
729 printf("Error : %d\n", err);
730 } else {
731 printf("Success.\n");
732 }
733 } else if(!strcasecmp(cmd, "shutdown 2")) {
734 err = mbtk_system_reboot(2);
735 if(err) {
736 printf("Error : %d\n", err);
737 } else {
738 printf("Success.\n");
739 }
740 } else {
741 printf("Error.");
742 }
743 } else if(!strncasecmp(cmd, "power_sim", 9)){
744 if(!strcasecmp(cmd, "power_sim 0")) {
745 err = mbtk_sim_power_set(0);
746 if(err) {
747 printf("Error : %d\n", err);
748 } else {
749 printf("Success.\n");
750 }
751 } else if(!strcasecmp(cmd, "power_sim 1")) {
752 err = mbtk_sim_power_set(1);
753 if(err) {
754 printf("Error : %d\n", err);
755 } else {
756 printf("Success.\n");
757 }
758 } else {
759 printf("Error.");
760 }
761 } else if(!strncasecmp(cmd, "temp", 4)){
762 int temp;
763 if(!strcasecmp(cmd, "temp 0")) {
764 err = mbtk_temp_get(info_handle, 0, &temp);
765 if(err) {
766 printf("Error : %d\n", err);
767 } else {
768 printf("SOC : %d\n", temp);
769 }
770 } else if(!strcasecmp(cmd, "temp 1")) {
771 err = mbtk_temp_get(info_handle, 1, &temp);
772 if(err) {
773 printf("Error : %d\n", err);
774 } else {
775 printf("RF : %d\n", temp);
776 }
777 } else {
778 printf("Error.");
779 }
780 } else if(!strncasecmp(cmd, "time", 4)){
781 if(!strcasecmp(cmd, "time 0")) {
782 err = mbtk_time_set(info_handle, 0, NULL);
783 if(err) {
784 printf("Error : %d\n", err);
785 } else {
786 printf("Success.\n");
787 }
788 } else if(!strcasecmp(cmd, "time 1")) {
789 err = mbtk_time_set(info_handle, 1, NULL);
790 if(err) {
791 printf("Error : %d\n", err);
792 } else {
793 printf("Success.\n");
794 }
795 } else if(!strncasecmp(cmd, "time 2 ", 7)) {
796 err = mbtk_time_set(info_handle, 2, cmd + 7);
797 if(err) {
798 printf("Error : %d\n", err);
799 } else {
800 printf("Success.\n");
801 }
802 } else { // Get time type.
803 int time_type;
804 err = mbtk_time_get(info_handle, &time_type);
805 if(err) {
806 printf("Error : %d\n", err);
807 } else {
808 printf("Time type:%d.\n", time_type);
809 }
810 }
811 } else if(!strncasecmp(cmd, "apn", 3)){
812 if(!strcasecmp(cmd, "apn")) { // Get apn
813 #define APN_MAX 10
814 mbtk_apn_info_t apns[APN_MAX];
815 int apn_num = APN_MAX;
816 err = mbtk_apn_get(info_handle, &apn_num, apns);
817 if(err) {
818 printf("Error : %d\n", err);
819 } else {
820 printf("APN Num:%d\n", apn_num);
821 int i = 0;
822 while(i < apn_num) {
823 printf("APN : %d, %s, %s\n", apns[i].cid, apn2str(apns[i].ip_type), apns[i].apn);
824 i++;
825 }
826 }
827 } else { // apn <cid> <0/1/2/3> <apn>
828 char *ptr = strstr(cmd, " ");
829 if(ptr == NULL)
830 continue;
831 while(*ptr != '\0' && *ptr == ' ')
832 ptr++;
833 int cid = atoi(ptr);
834
835 ptr = strstr(ptr, " ");
836 if(ptr == NULL)
837 continue;
838 while(*ptr != '\0' && *ptr == ' ')
839 ptr++;
840 mbtk_ip_type_enum ip_type = (mbtk_ip_type_enum)atoi(ptr);
841
842 ptr = strstr(ptr, " ");
843 if(ptr == NULL)
844 continue;
845 while(*ptr != '\0' && *ptr == ' ')
846 ptr++;
847 char *apn = ptr;
848
849 err = mbtk_apn_set(info_handle, cid, ip_type, apn, NULL, NULL, NULL);
850 if(err) {
851 printf("Error : %d\n", err);
852 } else {
853 printf("APN set success\n");
854 }
855 }
856 } else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
857 // data_call <0/1/2> <cid> <timeout>
858 char *ptr = strstr(cmd, " ");
859 if(ptr == NULL)
860 continue;
861 while(*ptr != '\0' && *ptr == ' ')
862 ptr++;
863 mbtk_data_call_type_enum type = (mbtk_data_call_type_enum)atoi(ptr);
864
865 ptr = strstr(ptr, " ");
866 if(ptr == NULL)
867 continue;
868 while(*ptr != '\0' && *ptr == ' ')
869 ptr++;
870 int cid = atoi(ptr);
871
872 ptr = strstr(ptr, " ");
873 if(ptr == NULL)
874 continue;
875 while(*ptr != '\0' && *ptr == ' ')
876 ptr++;
877 int timeout = atoi(ptr);
878
879 if(type == MBTK_DATA_CALL_START) {
880 err = mbtk_data_call_start(info_handle, cid, 0, FALSE, timeout);
881 } else if(type == MBTK_DATA_CALL_STOP) {
882 err = mbtk_data_call_stop(info_handle, cid, timeout);
883 } else {
884 mbtk_ipv4_info_t ipv4;
885 mbtk_ipv6_info_t ipv6;
886 err = mbtk_data_call_state_get(info_handle, cid, &ipv4, &ipv6);
887 if(!err) {
888 if(ipv4.valid) {
889 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
890 char ip_tmp[20];
891
892 memset(ip_tmp, 0, 20);
893 if(inet_ntop(AF_INET, &(ipv4.IPAddr), ip_tmp, 20) == NULL) {
894 printf("IP error.\n");
895 } else {
896 printf("IP : %s\n", ip_tmp);
897 }
898
899 memset(ip_tmp, 0, 20);
900 if(inet_ntop(AF_INET, &(ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
901 printf("PrimaryDNS error.\n");
902 } else {
903 printf("PrimaryDNS : %s\n", ip_tmp);
904 }
905
906 memset(ip_tmp, 0, 20);
907 if(inet_ntop(AF_INET, &(ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
908 printf("SecondaryDNS error.\n");
909 } else {
910 printf("SecondaryDNS : %s\n", ip_tmp);
911 }
912
913 memset(ip_tmp, 0, 20);
914 if(inet_ntop(AF_INET, &(ipv4.GateWay), ip_tmp, 20) == NULL) {
915 printf("GateWay error.\n");
916 } else {
917 printf("GateWay : %s\n", ip_tmp);
918 }
919
920 memset(ip_tmp, 0, 20);
921 if(inet_ntop(AF_INET, &(ipv4.NetMask), ip_tmp, 20) == NULL) {
922 printf("NetMask error.\n");
923 } else {
924 printf("NetMask : %s\n", ip_tmp);
925 }
926 }
927
928 if(ipv6.valid) {
929 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
930 char ip_tmp[50];
931
932 memset(ip_tmp, 0, 50);
933 if(ipv6_2_str(&(ipv6.IPV6Addr), ip_tmp)) {
934 printf("IP error.\n");
935 } else {
936 printf("IP : %s\n", ip_tmp);
937 }
938
939 memset(ip_tmp, 0, 50);
940 if(ipv6_2_str(&(ipv6.PrimaryDNS), ip_tmp)) {
941 printf("PrimaryDNS error.\n");
942 } else {
943 printf("PrimaryDNS : %s\n", ip_tmp);
944 }
945
946 memset(ip_tmp, 0, 50);
947 if(ipv6_2_str(&(ipv6.SecondaryDNS), ip_tmp)) {
948 printf("SecondaryDNS error.\n");
949 } else {
950 printf("SecondaryDNS : %s\n", ip_tmp);
951 }
952
953 memset(ip_tmp, 0, 50);
954 if(ipv6_2_str(&(ipv6.GateWay), ip_tmp)) {
955 printf("GateWay error.\n");
956 } else {
957 printf("GateWay : %s\n", ip_tmp);
958 }
959
960 memset(ip_tmp, 0, 50);
961 if(ipv6_2_str(&(ipv6.NetMask), ip_tmp)) {
962 printf("NetMask error.\n");
963 } else {
964 printf("NetMask : %s\n", ip_tmp);
965 }
966 }
967 }
968 }
969 if(err) {
970 printf("Error : %d\n", err);
971 } else {
972 printf("DATA_CALL success\n");
973 }
974 }else if(!strncasecmp(cmd, "cmgf", 4)){ // set mode 0: pud, 1:text
975 int mode;
976 if(!strcasecmp(cmd, "cmgf")) { // Get
977 err = mbtk_sms_cmgf_get(info_handle, &mode);
978 if(err) {
979 printf("Error : %d\n", err);
980 } else {
981 printf("VoLTE : %d\n", mode);
982 }
983 } else { // Set
984 if(!strcasecmp(cmd, "cmgf 1")) { // cmgf 1
985 mode = 1;
986 } else { //
987 mode = 0;
988 }
989 printf("mode:%d\n", mode);
990 sleep(2);
991 err = mbtk_sms_cmgf_set(info_handle, mode);
992 if(err) {
993 printf("Error : %d\n", err);
994 } else {
995 printf("VoLTE set success\n");
996 }
997 }
998 }else if(!strncasecmp(cmd, "cpms", 4)){ // //CPMS=ME, ME, ME
999 char mem[100] = {0};
1000 char resp[100] = {0};
1001 if(!strcasecmp(cmd, "cpms")) { // Get
1002 err = mbtk_sms_cpms_get(info_handle, &mem);
1003 if(err) {
1004 printf("Error : %d\n", err);
1005 } else {
1006 printf("cpms : %s\n", mem);
1007 }
1008 } else { // Set
1009
1010 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1011 if(ptr != NULL)
1012 {
1013 ptr++;
1014 memset(mem, 0, sizeof(mem));
1015 memcpy(mem, ptr, strlen(ptr));
1016 printf("cpms:%s\n", mem);
1017 }
1018 printf("cpms 0\n");
1019
1020 memset(resp, 0, sizeof(resp));
1021 err = mbtk_sms_cpms_set(info_handle, mem, resp);
1022 if(err) {
1023 printf("Error : %d\n", err);
1024 } else {
1025 printf("cpms set success. resp:%s\n", resp);
1026 }
1027 }
1028 }else if(!strncasecmp(cmd, "cmgs", 4)){ // AT+CMGS="10086", CMGS TEST
1029 char cmgs[1024] = {0};
1030 char resp[50] = {0};
1031 if(!strcasecmp(cmd, "cmgs")) { // Get
1032 int mode;
1033 // err = mbtk_sms_cmgs_get(info_handle, &mode);
1034 if(err) {
1035 printf("Error : %d\n", err);
1036 } else {
1037 printf("VoLTE : %d\n", mode);
1038 }
1039 } else { // Set
1040
1041 /*
1042 *AT+CMGS="10086", CMGS TEST // Send a SMS
1043 > CMGS TEST
1044 +CMGS: 17
1045 OK
1046 */
1047
1048 char *ptr = strstr(cmd, "cmgs,"); //CMGS="10086",hf
1049 if(ptr != NULL)
1050 {
1051 ptr = strstr(cmd, ",");
1052 ptr++;
1053 memset(cmgs, 0, sizeof(cmgs));
1054 memcpy(cmgs, ptr, strlen(ptr));
1055 printf("1cmgs:%s, strlen(cmgs):%d\n", cmgs, strlen(cmgs));
1056 }
1057
1058 memset(resp, 0, sizeof(resp));
1059 err = mbtk_sms_cmgs_set(info_handle, cmgs, resp);
1060 if(err) {
1061 printf("Error : %d\n", err);
1062 } else {
1063 printf("cmgs set success . resp:%s\n", resp);
1064 }
1065 }
1066 }else if(!strncasecmp(cmd, "cmss", 4)){ // +CMSS=<index>[,<da>[,<toda>]]
1067 char cmss[20] = {0};
1068 char resp[20] = {0};
1069 if(!strcasecmp(cmd, "cmgs")) { // Get
1070 printf("cmss : OK\n");
1071
1072 } else {
1073 char *ptr = strstr(cmd, "cmss,"); //CMSS=<index>
1074 if(ptr != NULL)
1075 {
1076 ptr = strstr(cmd, ",");
1077 ptr++;
1078 memset(cmss, 0, sizeof(cmss));
1079 memcpy(cmss, ptr, strlen(ptr));
1080 printf("1cmss:%s\n", cmss);
1081 }
1082
1083
1084 err = mbtk_sms_cmss_set(info_handle, cmss, resp);
1085 if(err) {
1086 printf("Error : %d\n", err);
1087 } else {
1088 printf("cmss set success. resp:%s\n", resp);
1089 }
1090 }
1091 }
1092 else if(!strncasecmp(cmd, "cmgr", 4)){ // +CMGR=<index
1093 int index = 0;
1094 char resp[1024] = {0};
1095 if(!strcasecmp(cmd, "cmgr")) { // Get
1096 printf("cmgr : OK\n");
1097
1098 } else {
1099 char *ptr = strstr(cmd, "cmgr,"); //+CMGR <index>
1100 if(ptr != NULL)
1101 {
1102 ptr = strstr(cmd, ",");
1103 ptr++;
1104 index = atoi(ptr);
1105 }
1106 printf("1index:%d\n", index);
1107
1108 memset(resp, 0, sizeof(resp));
1109 err = mbtk_sms_cmgr_set(info_handle, index, resp);
1110 if(err) {
1111 printf("Error : %d\n", err);
1112 } else {
1113 printf("cmgr set success. rep:%s\n", resp);
1114 }
1115 }
1116 }
1117 else if(!strncasecmp(cmd, "cmgw", 4)){ // +CMGW=<oa/da>[,<tooa/toda>[,<stat>]]<CR>
1118 //+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
1119 char cmgw[128] = {0};
1120 char resp[50] = {0};
1121 if(!strcasecmp(cmd, "cmgw")) { // Get
1122 printf("cmgw : OK\n");
1123
1124 } else {
1125 char *ptr = strstr(cmd, "cmgw,"); //+CMGW, <oa/da>, data
1126 if(ptr != NULL)
1127 {
1128 ptr = strstr(cmd, ",");
1129 ptr++;
1130 memset(cmgw, 0, sizeof(cmgw));
1131 memcpy(cmgw, ptr, strlen(ptr));
1132 printf("cmgw:%s\n", cmgw);
1133 }
1134
1135 memset(resp, 0, sizeof(resp));
1136 err = mbtk_sms_cmgw_set(info_handle, cmgw, resp);
1137 if(err) {
1138 printf("Error : %d\n", err);
1139 } else {
1140 printf("cmgw set success. resp:%s\n", resp);
1141 }
1142 }
1143 }
1144 else if(!strncasecmp(cmd, "cmgd", 4)){ // +CMGD=<index>[,<delflag>
1145 //
1146 char cmgd[128] = {0};
1147 if(!strcasecmp(cmd, "cmgd")) { // Get
1148 printf("cmgd : OK\n");
1149
1150 } else {
1151 char *ptr = strstr(cmd, ","); //+CMGD=<index>[,<delflag>
1152 if(ptr != NULL)
1153 {
1154 ptr++;
1155 memset(cmgd, 0, sizeof(cmgd));
1156 memcpy(cmgd, ptr, strlen(ptr));
1157 printf("1cmgd:%s\n", cmgd);
1158 }
1159
1160
1161 err = mbtk_sms_cmgd_set(info_handle, cmgd);
1162 if(err) {
1163 printf("Error : %d\n", err);
1164 } else {
1165 printf("VoLTE set success\n");
1166 }
1167 }
1168 }
1169 else if(!strncasecmp(cmd, "cmgl", 4)){ // AT+CMGL[=<stat>]
1170 //
1171 char cmgl[128] = {0};
1172 char resp[5*1024] ={0};
1173 if(!strcasecmp(cmd, "cmgl")) { // Get
1174 printf("cmgl : OK\n");
1175
1176 } else {
1177 char *ptr = strstr(cmd, "cmgl,"); // AT+CMGL[=<stat>]
1178 if(ptr != NULL)
1179 {
1180 ptr = strstr(cmd, ",");
1181 ptr++;
1182 memset(cmgl, 0, sizeof(cmgl));
1183 memcpy(cmgl, ptr, strlen(ptr));
1184 printf("0cmgl:%s\n", cmgl);
1185 }
1186
1187 memset(resp, 0, sizeof(resp));
1188 err = mbtk_sms_cmgl_set(info_handle, cmgl, resp);
1189 if(err) {
1190 printf("Error : %d\n", err);
1191 } else {
1192 // printf("cmgl set success, reg:%s\n",resp);
1193 }
1194 }
1195 }
1196 else if(!strncasecmp(cmd, "csca", 4)){ // AT+CSCA=<number> [,<type>]
1197 //
1198 char csca[128] = {0};
1199 if(!strcasecmp(cmd, "csca")) { // Get
1200 err = mbtk_sms_csca_get(info_handle, csca);
1201 if(err) {
1202 printf("mbtk_sms_csca_get Error : %d\n", err);
1203 } else {
1204 printf("mbtk_sms_csca_get success\n");
1205 }
1206
1207 } else {
1208 char *ptr = strstr(cmd, ","); // AT+CSCA=<number> [,<type>]
1209 if(ptr != NULL)
1210 {
1211 ptr++;
1212 memset(csca, 0, sizeof(csca));
1213 memcpy(csca, ptr, strlen(ptr));
1214 printf("csca:%s\n", csca);
1215 }
1216
1217 err = mbtk_sms_csca_set(info_handle, csca);
1218 if(err) {
1219 printf("Error : %d\n", err);
1220 } else {
1221 printf("VoLTE set success\n");
1222 }
1223 }
1224 }
1225 else if(!strncasecmp(cmd, "csmp", 4)){ // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1226 //
1227 char csmp[128] = {0};
1228 if(!strcasecmp(cmd, "csmp")) { // Get
1229 printf("cmgl : OK\n");
1230
1231 } else {
1232 char *ptr = strstr(cmd, ","); // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1233 if(ptr != NULL)
1234 {
1235 ptr++;
1236 memset(csmp, 0, sizeof(csmp));
1237 memcpy(csmp, ptr, strlen(ptr));
1238 printf("csmp:%s\n", csmp);
1239 }
1240
1241 err = mbtk_sms_csmp_set(info_handle, csmp);
1242 if(err) {
1243 printf("Error : %d\n", err);
1244 } else {
1245 printf("VoLTE set success\n");
1246 }
1247 }
1248 }
1249 else if(!strncasecmp(cmd, "cscb", 4)){ // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1250 //
1251 char cscb[128] = {0};
1252 if(!strcasecmp(cmd, "cscb")) { // Get
1253 printf("cmgl : OK\n");
1254
1255 } else {
1256 char *ptr = strstr(cmd, ","); // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1257 if(ptr != NULL)
1258 {
1259 ptr++;
1260 memset(cscb, 0, sizeof(cscb));
1261 memcpy(cscb, ptr, strlen(ptr));
1262 printf("cscb:%s\n", cscb);
1263 }
1264
1265 err = mbtk_sms_cscb_set(info_handle, cscb);
1266 if(err) {
1267 printf("Error : %d\n", err);
1268 } else {
1269 printf("VoLTE set success\n");
1270 }
1271 }
1272 }
b.liud8043a32024-06-07 16:08:22 +08001273 else if(!strncasecmp(cmd, "ims_en", 6)){ // ims_en 0/1
1274 char enable[10] = {0};
1275 if(1 == sscanf(cmd, "ims_en %s", enable)) {
1276 err = mbtk_net_ims_set(info_handle, atoi(enable) ? 1 : 0);
1277 if(err) {
1278 printf("Set IMS fail : %d\n", err);
1279 } else {
1280 printf("Set IMS success\n");
1281 }
1282 } else {
1283 printf("ARG error\n");
1284 }
1285 }
1286 else if(!strncasecmp(cmd, "ims_state", 9)){ // ims_state
1287 int enable = 0;
1288 err = mbtk_net_ims_get(info_handle, &enable);
1289 if(err) {
1290 printf("Get IMS state fail : %d\n", err);
1291 } else {
1292 printf("IMS state : %d\n", enable);
1293 }
1294 }
1295 else if(!strncasecmp(cmd, "ims_reg", 7)){ // ims_reg
1296 int reg = 0;
1297 err = mbtk_net_ims_reg_state_get(info_handle, &reg);
1298 if(err) {
1299 printf("Get IMS register state fail : %d\n", err);
1300 } else {
1301 printf("IMS register state : %d\n", reg);
1302 }
1303 }
liubin281ac462023-07-19 14:22:54 +08001304 else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
1305 help();
1306 } else if(!strcasecmp(cmd, "q")) {
1307 mbtk_info_handle_free(&info_handle);
1308 break;
1309 } else {
1310 printf("\n");
1311 }
1312 }
1313 }
1314
1315 LOG("Client exec complete.");
1316#if 1
1317 while(1)
1318 {
1319 sleep(1000 * 365 * 24 * 60 * 60);
1320 }
1321#else
1322 sleep(1);
1323#endif
1324 return 0;
1325}