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