blob: 35c29f39648ac45fe394b2d1004754bcd88f528b [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 <string.h>
11#include <fcntl.h>
12#include <signal.h>
b.liu62240ee2024-11-07 17:52:45 +080013#include <arpa/inet.h>
b.liu87afc4c2024-08-14 17:33:45 +080014
15#include "mbtk_ril_api.h"
b.liu62240ee2024-11-07 17:52:45 +080016#include "mbtk_str.h"
b.liu87afc4c2024-08-14 17:33:45 +080017
18#define CLI_THREAD_MAX 3
19
b.liu62240ee2024-11-07 17:52:45 +080020#define RIL_DEBUG_THREAD 0
21
22#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +080023typedef struct {
24 pthread_t pid;
25 bool is_running;
26 char name[20];
27} ril_cli_thread_info_t;
28
29static ril_cli_thread_info_t cli_threads[CLI_THREAD_MAX];
30static int cli_pid_index = 1;
b.liu62240ee2024-11-07 17:52:45 +080031#endif
b.liu87afc4c2024-08-14 17:33:45 +080032
33static void help()
34{
35 printf("version: Get version.\n");
36 printf("imei: Get IMEI.\n");
37 printf("sn: Get SN.\n");
38 printf("meid: Get MEID.\n");
39 printf("volte: Get VoLTE state.\n");
40 printf("volte 0: Close VoLTE.\n");
41 printf("volte 1: Open VoLTE.\n");
42 printf("radio: Get radio state.\n");
43 printf("radio 0 [0/1]: Close radio.\n");
44 printf("radio 1 [0/1]: Open radio.\n");
45 printf("temp <0,1>: Get SOC/RF temperature.\n");
46 printf("cell_time: Get cell time.\n");
47 printf("sim_state: Get sim state.\n");
48 printf("sim_type: Get sim type.\n");
49 printf("imsi: Get IMSI.\n");
50 printf("iccid: Get ICCID.\n");
51 printf("pn: Get Phone Number.\n");
52 printf("pin_state:Get Sim lock state.\n");
53 printf("pin_times:Get PIN/PUK last times.\n");
54 printf("pin_open <PIN>:Enable sim lock.\n");
55 printf("pin_close <PIN>:Disable sim lock.\n");
56 printf("pin_change <old_pin> <new_pin>:Change sim PIN.\n");
57 printf("pin_verify <PIN>:Verify PIN.\n");
58 printf("puk_verify <PUK> <PIN>:Verify PUK.\n");
59 printf("plmn:Get PLMN List.\n");
60 printf("avail_net: Get available network.\n");
61 printf("sel_mode: Get network select mode.\n");
62 printf("sel_mode <sel_mode> <net_type> <plmn>: Set network select mode.\n");
63 printf("band: Get current bands.\n");
64 printf("band support: Get support bands.\n");
65 printf("band <net_pref> <gsm_band> <umts_band> <tdlte_band> <fddlte_band>: Set current bands.\n");
66 printf("signal: Get network signal.\n");
67 printf("reg: Get network registe information.\n");
68 printf("cell: Get current cell information.\n");
69 printf("shutdown <0,1,2>: reboot/poweroff/halt system.\n");
70 printf("power_sim <0,1>: Power off/on sim.\n");
71 printf("time <0,1,2> YYYY-MM-DD HH:MM:SS : Set system time as CELL/NTP/User.\n");
72 printf("apn : Get current apns.\n");
b.liubcf86c92024-08-19 19:48:28 +080073 printf("apn <cid> <ip_type:1/2/3/4> <save:0/1> <auto_call:0/1> <def_route:0/1> <as_dns:0/1> <apn/null> : Set apn.\n");
b.liu87afc4c2024-08-14 17:33:45 +080074 printf("apn_del <cid> <save:0/1> : Delete APN.\n");
b.liubcf86c92024-08-19 19:48:28 +080075 printf("data_call <0/1/2> <cid> <auto_boot_call> <def_route> <as_dns>: Stop/Start/State data call.\n");
b.liu87afc4c2024-08-14 17:33:45 +080076 printf("call: Call the phone number.\n");
77 printf("answer: Answer the phone call.\n");
78 printf("hangup: Hang up all phone call. No id.\n");
79 printf("hangup 0: Hang up waiting or background phone call.\n");
80 printf("hangup 1: Hang up a phone call.\n");
81 printf("hangup 2: Hang up a phone call.\n");
82 printf("hangup 3: Hangup foreground resume background call.\n");
83 printf("waitin: Returns the list of current calls.\n");
84 printf("mute: Get mute state.\n");
85 printf("mute 0: Close mute.\n");
86 printf("mute 1: Open mute.\n");
87 printf("dtmf : Set dtmf character[0, 1, 2, ..., A, B, C, D, *, #], duration [300-600].\n Such as: dtmf 0 300\n");
88 printf("ims_en 0/1 : Close/Open IMS(Restart takes effect).\n");
89 printf("ims_state : Get IMS open or not?\n");
90 printf("ims_reg: Get IMS register state.\n");
91}
92
b.liu62240ee2024-11-07 17:52:45 +080093#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +080094static void thread_exit_with_wait()
95{
96 int i = 0;
97 while(i < CLI_THREAD_MAX) {
98 cli_threads[i].is_running = FALSE;
99 i++;
100 }
101
102 i = 0;
103 while(i < CLI_THREAD_MAX) {
104 if(cli_threads[i].pid) {
105 pthread_join(cli_threads[i].pid, NULL);
106 printf("Thread (%s) exit.\n", cli_threads[i].name);
107 }
108 i++;
109 }
110}
b.liu62240ee2024-11-07 17:52:45 +0800111#endif
b.liu87afc4c2024-08-14 17:33:45 +0800112
b.liu15f456b2024-10-31 20:16:06 +0800113static void ril_ser_state_change_cb(const void* data, int data_len)
114{
115 if(data) {
b.liu62240ee2024-11-07 17:52:45 +0800116 const uint8 *ptr = (const uint8*)data;
b.liu15f456b2024-10-31 20:16:06 +0800117 mbtk_ril_ser_state_enum state = (mbtk_ril_ser_state_enum)ptr[0];
118 printf("ril server state : %d.\n", state);
119 }
120}
121
122static void net_reg_state_change_cb(const void* data, int data_len)
123{
124 if(data) {
125 mbtk_ril_net_reg_state_info_t *state = (mbtk_ril_net_reg_state_info_t*)data;
126 printf("net reg state change : type - %d, tech - %d, reg_state - %d\n", state->type,
127 state->tech, state->reg_state);
128 }
129}
130
131static void call_state_change_cb(const void* data, int data_len)
132{
133 if(data) {
134 mbtk_ril_call_state_info_t *state = (mbtk_ril_call_state_info_t*)data;
135 printf("call state change : call_id-%d, dir-%d, state-%d, num_type-%d,number-%s\n", state->call_id,
136 state->dir, state->state, state->num_type, state->call_number);
137 }
138}
139
140static void sms_state_change_cb(const void* data, int data_len)
141{
142
143}
144
145static void radio_state_change_cb(const void* data, int data_len)
146{
147 if(data) {
148 mbtk_ril_radio_state_info_t *state = (mbtk_ril_radio_state_info_t*)data;
149 printf("radio state change : %d\n", state->radio_state);
150 }
151}
152
153static void sim_state_change_cb(const void* data, int data_len)
154{
155 if(data) {
156 mbtk_ril_sim_state_info_t *state = (mbtk_ril_sim_state_info_t*)data;
157 printf("sim state change : type - %d, state - %d\n", state->sim_type, state->sim_state);
158 }
159}
160
161static void pdp_state_change_cb(const void* data, int data_len)
162{
163 if(data) {
164 mbtk_ril_pdp_state_info_t *state = (mbtk_ril_pdp_state_info_t*)data;
165 printf("pdp state change : cid - %d, action - %d, reason-%d, auto_change - %d\n",
166 state->cid, state->action, state->reason, state->auto_change);
b.liufd87baf2024-11-15 15:30:38 +0800167 if(state->ip_info_valid) {
168 if(state->ip_info.ipv4.valid) {
169 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
170 char ip_tmp[20];
171
172 memset(ip_tmp, 0, 20);
173 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.IPAddr), ip_tmp, 20) == NULL) {
174 printf("IP error.\n");
175 } else {
176 printf("IP : %s\n", ip_tmp);
177 }
178
179 memset(ip_tmp, 0, 20);
180 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
181 printf("PrimaryDNS error.\n");
182 } else {
183 printf("PrimaryDNS : %s\n", ip_tmp);
184 }
185
186 memset(ip_tmp, 0, 20);
187 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
188 printf("SecondaryDNS error.\n");
189 } else {
190 printf("SecondaryDNS : %s\n", ip_tmp);
191 }
192
193 memset(ip_tmp, 0, 20);
194 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.GateWay), ip_tmp, 20) == NULL) {
195 printf("GateWay error.\n");
196 } else {
197 printf("GateWay : %s\n", ip_tmp);
198 }
199
200 memset(ip_tmp, 0, 20);
201 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.NetMask), ip_tmp, 20) == NULL) {
202 printf("NetMask error.\n");
203 } else {
204 printf("NetMask : %s\n", ip_tmp);
205 }
206 }
207
208 if(state->ip_info.ipv6.valid) {
209 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
210 char ip_tmp[50];
211
212 memset(ip_tmp, 0, 50);
213 if(ipv6_2_str(&(state->ip_info.ipv6.IPV6Addr), ip_tmp)) {
214 printf("IP error.\n");
215 } else {
216 printf("IP : %s\n", ip_tmp);
217 }
218
219 memset(ip_tmp, 0, 50);
220 if(ipv6_2_str(&(state->ip_info.ipv6.PrimaryDNS), ip_tmp)) {
221 printf("PrimaryDNS error.\n");
222 } else {
223 printf("PrimaryDNS : %s\n", ip_tmp);
224 }
225
226 memset(ip_tmp, 0, 50);
227 if(ipv6_2_str(&(state->ip_info.ipv6.SecondaryDNS), ip_tmp)) {
228 printf("SecondaryDNS error.\n");
229 } else {
230 printf("SecondaryDNS : %s\n", ip_tmp);
231 }
232
233 memset(ip_tmp, 0, 50);
234 if(ipv6_2_str(&(state->ip_info.ipv6.GateWay), ip_tmp)) {
235 printf("GateWay error.\n");
236 } else {
237 printf("GateWay : %s\n", ip_tmp);
238 }
239
240 memset(ip_tmp, 0, 50);
241 if(ipv6_2_str(&(state->ip_info.ipv6.NetMask), ip_tmp)) {
242 printf("NetMask error.\n");
243 } else {
244 printf("NetMask : %s\n", ip_tmp);
245 }
246 }
247 }
b.liu15f456b2024-10-31 20:16:06 +0800248 }
249}
250
251static void signal_state_change_cb(const void* data, int data_len)
252{
253
254}
255
256static void ecall_state_change_cb(const void* data, int data_len)
257{
258 if(data)
259 {
260 mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
261 printf("ecall state change : urc_id - %d, urc_data - %s\n", ecall_data->urc_id, ecall_data->urc_data);
262 }
263}
264
265
b.liu87afc4c2024-08-14 17:33:45 +0800266static void sig_process(int sig)
267{
268 LOGI("I got signal %d\n", sig);
269 switch(sig)
270 {
271 case SIGINT: // Ctrl + C
272 {
273 LOGI("Exit by SIGINT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800274#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800275 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800276#endif
b.liub171c9a2024-11-12 19:23:29 +0800277 mbtk_ril_close(MBTK_AT_PORT_DEF);
278 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800279 exit(0);
280 }
281 case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
282 {
283 LOGI("Exit by SIGQUIT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800284#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800285 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800286#endif
b.liub171c9a2024-11-12 19:23:29 +0800287 mbtk_ril_close(MBTK_AT_PORT_DEF);
288 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800289 exit(0);
290 }
291 case SIGTERM:// 默认kill (同 SIGKILL ,但 SIGKILL 不可捕获)
292 {
293 LOGI("Exit by SIGTERM.\n");
b.liu62240ee2024-11-07 17:52:45 +0800294#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800295 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800296#endif
b.liub171c9a2024-11-12 19:23:29 +0800297 mbtk_ril_close(MBTK_AT_PORT_DEF);
298 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800299 exit(0);
300 }
301 case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
302 {
303 LOGI("Exit by SIGTSTP.\n");
304 exit(0);
305 }
306 case SIGSEGV: // 如空指针
307 {
308 LOGI("Exit by SIGSEGV.\n");
309 exit(0);
310 }
311 default:
312 {
313 LOGI("Unknown sig:%d\n",sig);
314 break;
315 }
316 }
317}
318
b.liu62240ee2024-11-07 17:52:45 +0800319#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800320static char* thread_id2name(pthread_t pid)
321{
322 int i = 0;
323 while(i < CLI_THREAD_MAX) {
324 if(pid == cli_threads[i].pid) {
325 return cli_threads[i].name;
326 }
327 i++;
328 }
329
330 return "UNKNOWN";
331}
332
333static void* sub_thread_run(void *arg)
334{
335 ril_cli_thread_info_t *cli = (ril_cli_thread_info_t*)arg;
336 cli->pid = pthread_self();
337 cli->is_running = TRUE;
338 sprintf(cli->name, "PID-%d", cli_pid_index++);
339
340 printf("[%s] enter.\n", thread_id2name(cli->pid));
341 while(cli->is_running) {
342 srand((int)(time(0) + cli->pid));
343 int time_sec = 1 + (int)(10.0 * rand() / ( RAND_MAX + 1.0));
344 char version[50] = {0};
345 mbtk_ril_err_enum err = mbtk_version_get(version);
346 if(err != MBTK_RIL_ERR_SUCCESS) {
347 printf("[%s : %ds]Error : %d\n", thread_id2name(cli->pid), time_sec, err);
348 } else {
349 printf("[%s : %ds]Version : %s\n", thread_id2name(cli->pid), time_sec, version);
350 }
351
352 sleep(time_sec);
353 }
354 printf("[%s] exit.\n", thread_id2name(cli->pid));
355 return NULL;
356}
b.liu62240ee2024-11-07 17:52:45 +0800357#endif
b.liu87afc4c2024-08-14 17:33:45 +0800358
359int main(int argc, char *argv[])
360{
361 signal(SIGINT, sig_process);
362 signal(SIGQUIT, sig_process);
363 signal(SIGTERM, sig_process);
364 //signal(SIGTSTP, sig_process);
365 //signal(SIGSEGV, sig_process);
366
367 mbtk_log_init("radio","RIL_CLI");
368
369#ifdef MBTK_DUMP_SUPPORT
370 mbtk_debug_open(NULL, TRUE);
371#endif
372
373 //test2(0, "192.168.1.198");
374 //test2(1, "2409:8162:140:cd3c:1:2:1494:72ba");
375 //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
376 //test2(1, "2400:3200::1");
377
b.liub171c9a2024-11-12 19:23:29 +0800378 mbtk_ril_handle* handle_def = mbtk_ril_open(MBTK_AT_PORT_DEF);
379 if(handle_def == NULL) {
380 printf("mbtk_ril_open(MBTK_AT_PORT_DEF/ATPORTTYPE_0) fail.");
381 return -1;
382 }
383
384 mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
385 if(handle_1 == NULL) {
386 printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
b.liu87afc4c2024-08-14 17:33:45 +0800387 return -1;
388 }
389
b.liu15f456b2024-10-31 20:16:06 +0800390 mbtk_ril_ser_state_change_cb_reg(ril_ser_state_change_cb);
391
392 mbtk_net_reg_state_change_cb_reg(net_reg_state_change_cb);
393
394 mbtk_call_state_change_cb_reg(call_state_change_cb);
395
396 mbtk_sms_state_change_cb_reg(sms_state_change_cb);
397
398 mbtk_radio_state_change_cb_reg(radio_state_change_cb);
399
400 mbtk_sim_state_change_cb_reg(sim_state_change_cb);
401
402 mbtk_pdp_state_change_cb_reg(pdp_state_change_cb);
403
404 mbtk_signal_state_change_cb_reg(signal_state_change_cb);
405
406 mbtk_ecall_state_change_cb_reg(ecall_state_change_cb);
407
b.liu62240ee2024-11-07 17:52:45 +0800408#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800409 memset(cli_threads, 0, sizeof(ril_cli_thread_info_t) * CLI_THREAD_MAX);
410
411 pthread_t pid1, pid2, pid3;
412 if(pthread_create(&pid1, NULL, sub_thread_run, &cli_threads[0]))
413 {
414 printf("pthread_create() fail.");
415 goto exit;
416 }
417
418 if(pthread_create(&pid2, NULL, sub_thread_run, &cli_threads[1]))
419 {
420 printf("pthread_create() fail.");
421 goto exit;
422 }
423
424 if(pthread_create(&pid3, NULL, sub_thread_run, &cli_threads[2]))
425 {
426 printf("pthread_create() fail.");
427 goto exit;
428 }
429#endif
430 printf(">>>>>>>>>>>>>>>>>>>>>>>>Enter cmd:\n");
431 char cmd[100];
432 while(1)
433 {
434 memset(cmd, 0, 100);
435 mbtk_ril_err_enum err;
436 if(fgets(cmd, 100, stdin))
437 {
438 char *ptr = cmd + strlen(cmd) - 1;
439 while(ptr >= cmd && (*ptr == '\r' || *ptr == '\n'))
440 {
441 *ptr-- = '\0';
442 }
443 if(!strncasecmp(cmd, "version", 7))
444 {
445 char version[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800446 err = mbtk_version_get(handle_def, version);
b.liu87afc4c2024-08-14 17:33:45 +0800447 if(err != MBTK_RIL_ERR_SUCCESS) {
448 printf("Error : %d\n", err);
449 } else {
450 printf("Version : %s\n", version);
451 }
452 }
453 else if(!strncasecmp(cmd, "imei", 4)){
454 char imei[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800455 err = mbtk_imei_get(handle_def, imei);
b.liu87afc4c2024-08-14 17:33:45 +0800456 if(err != MBTK_RIL_ERR_SUCCESS) {
457 printf("Error : %d\n", err);
458 } else {
459 printf("IMEI : %s\n", imei);
460 }
461 } else if(!strncasecmp(cmd, "sn", 2)){
462 char sn[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800463 err = mbtk_sn_get(handle_def, sn);
b.liu87afc4c2024-08-14 17:33:45 +0800464 if(err != MBTK_RIL_ERR_SUCCESS) {
465 printf("Error : %d\n", err);
466 } else {
467 printf("SN : %s\n", sn);
468 }
469 } else if(!strncasecmp(cmd, "meid", 4)){
470 char meid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800471 err = mbtk_meid_get(handle_def, meid);
b.liu87afc4c2024-08-14 17:33:45 +0800472 if(err != MBTK_RIL_ERR_SUCCESS) {
473 printf("Error : %d\n", err);
474 } else {
475 printf("MEID : %s\n", meid);
476 }
477 } else if(!strncasecmp(cmd, "volte", 5)){ // "volte" or "volte 0" or "volte 1"
478 int volte;
479 if(!strcasecmp(cmd, "volte")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800480 err = mbtk_volte_state_get(handle_def, &volte);
b.liu87afc4c2024-08-14 17:33:45 +0800481 if(err != MBTK_RIL_ERR_SUCCESS) {
482 printf("Error : %d\n", err);
483 } else {
484 printf("VoLTE : %d\n", volte);
485 }
486 } else { // Set
487 if(!strcasecmp(cmd, "volte 1")) { // Open VoLTE
488 volte = 1;
489 } else { // Close VoLTE
490 volte = 0;
491 }
b.liub171c9a2024-11-12 19:23:29 +0800492 err = mbtk_volte_state_set(handle_def, volte);
b.liu87afc4c2024-08-14 17:33:45 +0800493 if(err != MBTK_RIL_ERR_SUCCESS) {
494 printf("Error : %d\n", err);
495 } else {
496 printf("VoLTE set success\n");
497 }
498 }
499 } else if(!strncasecmp(cmd, "radio", 5)){ // "radio" or "radio 0" or "radio 1"
500 mbtk_radio_state_enum radio;
501 if(!strcasecmp(cmd, "radio")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800502 err = mbtk_radio_state_get(handle_def, &radio);
b.liu87afc4c2024-08-14 17:33:45 +0800503 if(err != MBTK_RIL_ERR_SUCCESS) {
504 printf("Error : %d\n", err);
505 } else {
506 printf("Radio : %d\n", radio);
507 }
508 } else { // Set
509 int reset;
510 int count = sscanf(cmd, "radio %d %d", &radio, &reset);
511 if(count > 0) {
512 if(count == 1) {
513 reset = 0;
514 }
515
b.liub171c9a2024-11-12 19:23:29 +0800516 err = mbtk_radio_state_set(handle_def, radio, reset);
b.liu87afc4c2024-08-14 17:33:45 +0800517 if(err != MBTK_RIL_ERR_SUCCESS) {
518 printf("Error : %d\n", err);
519 } else {
520 printf("Radio set success\n");
521 }
522 }
523 }
524 } else if(!strncasecmp(cmd, "temp", 4)){
525 int temp;
526 if(!strcasecmp(cmd, "temp 0")) {
b.liub171c9a2024-11-12 19:23:29 +0800527 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_SOC, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800528 if(err != MBTK_RIL_ERR_SUCCESS) {
529 printf("Error : %d\n", err);
530 } else {
531 printf("SOC : %d\n", temp);
532 }
533 } else if(!strcasecmp(cmd, "temp 1")) {
b.liub171c9a2024-11-12 19:23:29 +0800534 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_RF, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800535 if(err != MBTK_RIL_ERR_SUCCESS) {
536 printf("Error : %d\n", err);
537 } else {
538 printf("RF : %d\n", temp);
539 }
540 }
541 } else if(!strncasecmp(cmd, "cell_time", 9)){
542 char time[128] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800543 err = mbtk_cell_time_get(handle_def, time);
b.liu87afc4c2024-08-14 17:33:45 +0800544 if(err != MBTK_RIL_ERR_SUCCESS) {
545 printf("Error : %d\n", err);
546 } else {
547 printf("Cell Time : %s\n", time);
548 }
549 } else if(!strncasecmp(cmd, "sim_state", 9)){
550 mbtk_sim_state_enum sim;
b.liub171c9a2024-11-12 19:23:29 +0800551 err = mbtk_sim_state_get(handle_def, &sim);
b.liu87afc4c2024-08-14 17:33:45 +0800552 if(err != MBTK_RIL_ERR_SUCCESS) {
553 printf("Error : %d\n", err);
554 } else {
555 printf("Sim State : %d\n", sim);
556 }
557 } else if(!strncasecmp(cmd, "sim_type", 8)){
558 mbtk_sim_card_type_enum type;
b.liub171c9a2024-11-12 19:23:29 +0800559 err = mbtk_sim_type_get(handle_def, &type);
b.liu87afc4c2024-08-14 17:33:45 +0800560 if(err != MBTK_RIL_ERR_SUCCESS) {
561 printf("Error : %d\n", err);
562 } else {
563 printf("Sim Type : %d\n", type);
564 }
565 } else if(!strncasecmp(cmd, "imsi", 4)){
566 char imsi[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800567 err = mbtk_imsi_get(handle_def, imsi);
b.liu87afc4c2024-08-14 17:33:45 +0800568 if(err != MBTK_RIL_ERR_SUCCESS) {
569 printf("Error : %d\n", err);
570 } else {
571 printf("IMSI : %s\n", imsi);
572 }
573 } else if(!strncasecmp(cmd, "iccid", 5)){
574 char iccid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800575 err = mbtk_iccid_get(handle_def, iccid);
b.liu87afc4c2024-08-14 17:33:45 +0800576 if(err != MBTK_RIL_ERR_SUCCESS) {
577 printf("Error : %d\n", err);
578 } else {
579 printf("ICCID : %s\n", iccid);
580 }
581 } else if(!strncasecmp(cmd, "pn", 2)){
582 char phone_number[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800583 err = mbtk_phone_number_get(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +0800584 if(err != MBTK_RIL_ERR_SUCCESS) {
585 printf("Error : %d\n", err);
586 } else {
587 printf("Phone Number : %s\n", phone_number);
588 }
589 }
590 /*
591 printf("pin_state:Get Sim lock state.\n");
592 printf("pin_times:Get PIN/PUK last times.\n");
593 printf("pin_open <PIN>:Enable sim lock.\n");
594 printf("pin_close <PIN>:Disable sim lock.\n");
595 printf("pin_change <old_pin> <new_pin>:Change sim PIN.\n");
596 printf("pin_verify <PIN>:Verify PIN.\n");
597 printf("puk_verify <PUK> <PIN>:Verify PUK.\n");
598 */
599 else if(!strncasecmp(cmd, "pin_state", 9)){
600 int lock_state;
b.liub171c9a2024-11-12 19:23:29 +0800601 err = mbtk_sim_lock_get(handle_def, &lock_state);
b.liu87afc4c2024-08-14 17:33:45 +0800602 if(err != MBTK_RIL_ERR_SUCCESS) {
603 printf("Error : %d\n", err);
604 } else {
605 printf("PIN state : %d\n", lock_state);
606 }
607 } else if(!strncasecmp(cmd, "pin_times", 9)){
608 mbtk_pin_puk_last_times_t times;
b.liub171c9a2024-11-12 19:23:29 +0800609 err = mbtk_sim_lock_retry_times_get(handle_def, &times);
b.liu87afc4c2024-08-14 17:33:45 +0800610 if(err != MBTK_RIL_ERR_SUCCESS) {
611 printf("Error : %d\n", err);
612 } else {
613 printf("PIN/PUK retry times:%d,%d,%d,%d\n", times.p1_retry, times.p2_retry, times.puk1_retry, times.puk2_retry);
614 }
615 } else if(!strncasecmp(cmd, "pin_open", 8)){
616 mbtk_sim_lock_info_t info;
617 info.type = MBTK_SIM_LOCK_TYPE_ENABLE;
618 int count = sscanf(cmd, "pin_open %s", info.pin1);
619 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800620 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800621 if(err != MBTK_RIL_ERR_SUCCESS) {
622 printf("Error : %d\n", err);
623 } else {
624 printf("Enable sim lock success.\n");
625 }
626 }
627 } else if(!strncasecmp(cmd, "pin_close", 9)){
628 mbtk_sim_lock_info_t info;
629 info.type = MBTK_SIM_LOCK_TYPE_DISABLE;
630 int count = sscanf(cmd, "pin_close %s", info.pin1);
631 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800632 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800633 if(err != MBTK_RIL_ERR_SUCCESS) {
634 printf("Error : %d\n", err);
635 } else {
636 printf("Disable sim lock success.\n");
637 }
638 }
639 } else if(!strncasecmp(cmd, "pin_change", 10)){
640 mbtk_sim_lock_info_t info;
641 info.type = MBTK_SIM_LOCK_TYPE_CHANGE;
642 int count = sscanf(cmd, "pin_change %s %s", info.pin1, info.pin2);
643 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800644 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800645 if(err != MBTK_RIL_ERR_SUCCESS) {
646 printf("Error : %d\n", err);
647 } else {
648 printf("PIN change success.\n");
649 }
650 }
651 } else if(!strncasecmp(cmd, "pin_verify", 10)){
652 mbtk_sim_lock_info_t info;
653 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PIN;
654 int count = sscanf(cmd, "pin_verify %s", info.pin1);
655 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800656 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800657 if(err != MBTK_RIL_ERR_SUCCESS) {
658 printf("Error : %d\n", err);
659 } else {
660 printf("PIN verify success.\n");
661 }
662 }
663 } else if(!strncasecmp(cmd, "puk_verify", 10)){
664 mbtk_sim_lock_info_t info;
665 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PUK;
666 int count = sscanf(cmd, "puk_verify %s %s", info.puk, info.pin1);
667 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800668 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800669 if(err != MBTK_RIL_ERR_SUCCESS) {
670 printf("Error : %d\n", err);
671 } else {
672 printf("PUK verify success.\n");
673 }
674 }
675 } else if(!strncasecmp(cmd, "plmn", 4)){
676 mbtk_plmn_info info;
b.liub171c9a2024-11-12 19:23:29 +0800677 err = mbtk_plmn_list_get(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800678 if(err != MBTK_RIL_ERR_SUCCESS) {
679 printf("Error : %d\n", err);
680 } else {
681 printf("PLMN number:%d\n", info.count);
682 int i = 0;
683 while(i < info.count) {
684 printf("%d,%d,%s\n", i+1, info.plmn[i].format, info.plmn[i].name);
685 i++;
686 }
687 }
688 }
689 else if(!strncasecmp(cmd, "avail_net", 9)){
690 mbtk_net_info_array_t net_list;
b.liub171c9a2024-11-12 19:23:29 +0800691 err = mbtk_available_net_get(handle_1, &net_list);
b.liu87afc4c2024-08-14 17:33:45 +0800692 if(err != MBTK_RIL_ERR_SUCCESS) {
693 printf("Error : %d\n", err);
694 } else {
695 printf("Available net number:%d\n", net_list.num);
696 int i = 0;
697 while(i < net_list.num) {
698 printf("NET : %d,%d,%d,%d\n", net_list.net_info[i].net_sel_mode,
699 net_list.net_info[i].net_type, net_list.net_info[i].net_state,
700 net_list.net_info[i].plmn);
701 i++;
702 }
703 }
704 } else if(!strncasecmp(cmd, "sel_mode", 8)){ // "sel_mode" or "sel_mode 1 7 46000"
705 mbtk_net_info_t net;
706 memset(&net, 0, sizeof(mbtk_net_info_t));
707 if(!strcasecmp(cmd, "sel_mode")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800708 err = mbtk_net_sel_mode_get(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800709 if(err != MBTK_RIL_ERR_SUCCESS) {
710 printf("Error : %d\n", err);
711 } else {
712 printf("Net : %d, %d, %d, %d\n", net.net_sel_mode, net.net_type, net.net_state, net.plmn);
713 }
714 } else { // Set
715 char *ptr = strstr(cmd, " ");
716 if(ptr == NULL)
717 continue;
718 while(*ptr != '\0' && *ptr == ' ')
719 ptr++;
720 net.net_sel_mode = (uint8)atoi(ptr);
721
722 ptr = strstr(ptr, " ");
723 if(ptr == NULL)
724 continue;
725 while(*ptr != '\0' && *ptr == ' ')
726 ptr++;
727 net.net_type = (uint8)atoi(ptr);
728
729 ptr = strstr(ptr, " ");
730 if(ptr == NULL)
731 continue;
732 while(*ptr != '\0' && *ptr == ' ')
733 ptr++;
734 net.plmn = (uint32)atoi(ptr);
735
b.liub171c9a2024-11-12 19:23:29 +0800736 err = mbtk_net_sel_mode_set(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800737 if(err != MBTK_RIL_ERR_SUCCESS) {
738 printf("Error : %d\n", err);
739 } else {
740 printf("Net select mode set success\n");
741 }
742 }
743 } else if(!strncasecmp(cmd, "band", 4)){ // "band" or "band support" or "band 0 79 147 482 524503"
744 mbtk_band_info_t band;
745 memset(&band, 0x0, sizeof(mbtk_band_info_t));
746 if(!strcasecmp(cmd, "band")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800747 err = mbtk_current_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800748 if(err != MBTK_RIL_ERR_SUCCESS) {
749 printf("Error : %d\n", err);
750 } else {
751 printf("Band : %d, %d, %d, %d, %d, %d\n", band.net_pref, band.gsm_band, band.umts_band, band.tdlte_band, band.fddlte_band, band.lte_ext_band);
752 }
753 } else if(!strcasecmp(cmd, "band support")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800754 err = mbtk_support_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800755 if(err != MBTK_RIL_ERR_SUCCESS) {
756 printf("Error : %d\n", err);
757 } else {
758 printf("Band : %d, %d, %d, %d, %d, %d\n", band.net_pref, band.gsm_band, band.umts_band, band.tdlte_band, band.fddlte_band, band.lte_ext_band);
759 }
760 } else { // "band 0 79 147 482 524503"
761 char *ptr = strstr(cmd, " ");
762 if(ptr == NULL)
763 continue;
764 while(*ptr != '\0' && *ptr == ' ')
765 ptr++;
766 band.net_pref = (uint8)atoi(ptr);
767
768 ptr = strstr(ptr, " ");
769 if(ptr == NULL)
770 continue;
771 while(*ptr != '\0' && *ptr == ' ')
772 ptr++;
773 band.gsm_band = (uint16)atoi(ptr);
774
775 ptr = strstr(ptr, " ");
776 if(ptr == NULL)
777 continue;
778 while(*ptr != '\0' && *ptr == ' ')
779 ptr++;
780 band.umts_band = (uint16)atoi(ptr);
781
782 ptr = strstr(ptr, " ");
783 if(ptr == NULL)
784 continue;
785 while(*ptr != '\0' && *ptr == ' ')
786 ptr++;
787 band.tdlte_band = (uint32)atoi(ptr);
788
789 ptr = strstr(ptr, " ");
790 if(ptr == NULL)
791 continue;
792 while(*ptr != '\0' && *ptr == ' ')
793 ptr++;
794 band.fddlte_band = (uint32)atoi(ptr);
795
b.liub171c9a2024-11-12 19:23:29 +0800796 err = mbtk_current_band_set(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800797 if(err != MBTK_RIL_ERR_SUCCESS) {
798 printf("Error : %d\n", err);
799 } else {
800 printf("Band set success\n");
801 }
802 }
803 } else if(!strncasecmp(cmd, "signal", 6)){
804 mbtk_signal_info_t signal;
b.liub171c9a2024-11-12 19:23:29 +0800805 err = mbtk_net_signal_get(handle_def, &signal);
b.liu87afc4c2024-08-14 17:33:45 +0800806 if(err != MBTK_RIL_ERR_SUCCESS) {
807 printf("Error : %d\n", err);
808 } else {
809 printf("Signal : %d, %d, %d, %d, %d, %d, %d, %d\n", signal.type, signal.rssi, signal.rxlev, signal.ber,
810 signal.rscp, signal.ecno, signal.rsrq, signal.rsrp);
811 }
812 } else if(!strncasecmp(cmd, "reg", 3)){
813 mbtk_net_reg_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +0800814 err = mbtk_net_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +0800815 if(err != MBTK_RIL_ERR_SUCCESS) {
816 printf("Error : %d\n", err);
817 } else {
818 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);
819 }
820 } else if(!strncasecmp(cmd, "apn_del", 7)) {
821 mbtk_apn_info_t apn;
822 memset(&apn, 0, sizeof(mbtk_apn_info_t));
823 int cid, auto_save;
824 int count = sscanf(cmd, "apn_del %d %d", &cid, &auto_save);
825 if(count == 2) {
826 apn.cid = (mbtk_ril_cid_enum)cid;
827 apn.auto_save = (uint8)auto_save;
828 }
b.liub171c9a2024-11-12 19:23:29 +0800829 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800830 if(err != MBTK_RIL_ERR_SUCCESS) {
831 printf("Error : %d\n", err);
832 } else {
833 printf("APN delete success\n");
834 }
835
836 } else if(!strncasecmp(cmd, "apn", 3)){
837 if(!strcasecmp(cmd, "apn")) { // Get apn
838 mbtk_apn_info_array_t apns;
b.liub171c9a2024-11-12 19:23:29 +0800839 err = mbtk_apn_get(handle_def, &apns);
b.liu87afc4c2024-08-14 17:33:45 +0800840 if(err != MBTK_RIL_ERR_SUCCESS) {
841 printf("Error : %d\n", err);
842 } else {
843 printf("APN Num:%d\n", apns.num);
844 int i = 0;
845 while(i < apns.num) {
b.liu10a34102024-08-20 20:36:24 +0800846 // printf("APN : %d, %s, %s\n", apns.apns[i].cid, apn2str(apns.apns[i].ip_type), apns.apns[i].apn);
847 printf("APN : %d, %s, auth-%d, auto_save-%d, auto_boot_call-%d, %s, %s, %s, %s\n", apns.apns[i].cid, apn2str(apns.apns[i].ip_type),
848 apns.apns[i].auth, apns.apns[i].auto_save, apns.apns[i].auto_boot_call,
b.liu62240ee2024-11-07 17:52:45 +0800849 str_empty(apns.apns[i].apn) ? "NULL" : (char*)apns.apns[i].apn,
850 str_empty(apns.apns[i].user) ? "NULL" : (char*)apns.apns[i].user,
851 str_empty(apns.apns[i].pass) ? "NULL" : (char*)apns.apns[i].pass,
852 str_empty(apns.apns[i].type) ? "NULL" : (char*)apns.apns[i].type);
b.liu87afc4c2024-08-14 17:33:45 +0800853 i++;
854 }
b.liu10a34102024-08-20 20:36:24 +0800855 printf("Def route : %d, def dns : %d\n", apns.cid_for_def_route, apns.cid_for_def_dns);
b.liu87afc4c2024-08-14 17:33:45 +0800856 }
857 } else { // apn <cid> <0/1/2/3> <0/1> <0/1> <apn>
858 mbtk_apn_info_t apn;
859 memset(&apn, 0, sizeof(mbtk_apn_info_t));
860#if 1
b.liubcf86c92024-08-19 19:48:28 +0800861 int cid, ip_type, auto_save, auto_boot_call, def_route, as_dns;
862 int count = sscanf(cmd, "apn %d %d %d %d %d %d %s",
863 &cid, &ip_type, &auto_save, &auto_boot_call,
864 &def_route, &as_dns, apn.apn);
b.liu87afc4c2024-08-14 17:33:45 +0800865
866 // Delete APN
b.liu62240ee2024-11-07 17:52:45 +0800867 if(strcmp((char*)apn.apn,"null") == 0 || strcmp((char*)apn.apn,"NULL") == 0) {
b.liu87afc4c2024-08-14 17:33:45 +0800868 memset(apn.apn, 0, sizeof(apn.apn));
869 }
b.liubcf86c92024-08-19 19:48:28 +0800870 if(count == 7) {
b.liu87afc4c2024-08-14 17:33:45 +0800871 apn.cid = (mbtk_ril_cid_enum)cid;
872 apn.ip_type = (mbtk_ip_type_enum)ip_type;
873 apn.auto_save = (uint8)auto_save;
874 apn.auto_boot_call = (uint8)auto_boot_call;
b.liubcf86c92024-08-19 19:48:28 +0800875 apn.def_route = (uint8)def_route;
876 apn.as_dns = (uint8)as_dns;
b.liu87afc4c2024-08-14 17:33:45 +0800877 }
878#else
879 char *ptr = strstr(cmd, " ");
880 if(ptr == NULL)
881 continue;
882 while(*ptr != '\0' && *ptr == ' ')
883 ptr++;
884 apn.cid = (mbtk_ril_cid_enum)atoi(ptr);
885
886 ptr = strstr(ptr, " ");
887 if(ptr == NULL)
888 continue;
889 while(*ptr != '\0' && *ptr == ' ')
890 ptr++;
891 apn.ip_type = (mbtk_ip_type_enum)atoi(ptr);
892
893 ptr = strstr(ptr, " ");
894 if(ptr == NULL)
895 continue;
896 while(*ptr != '\0' && *ptr == ' ')
897 ptr++;
898 memcpy(apn.apn, ptr, strlen(ptr));
899#endif
b.liub171c9a2024-11-12 19:23:29 +0800900 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800901 if(err != MBTK_RIL_ERR_SUCCESS) {
902 printf("Error : %d\n", err);
903 } else {
904 printf("APN set success\n");
905 }
906 }
907 }
b.liubcf86c92024-08-19 19:48:28 +0800908 else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
909 // mbtk_ril_cid_enum cid, bool auto_boot_call, bool def_route, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info
910 // data_call <0/1/2> <cid> <timeout>
911 int type, cid, auto_boot_call, def_route, as_dns;
912 int count = sscanf(cmd, "data_call %d %d %d %d %d", &type, &cid, &auto_boot_call, &def_route, &as_dns);
913 if(count != 5) {
914 count = sscanf(cmd, "data_call %d %d", &type, &cid);
915 }
916
917 if(count == 5 || count == 2) {
918 mbtk_ip_info_t ip;
919 memset(&ip, 0, sizeof(mbtk_ip_info_t));
920 if(type == MBTK_DATA_CALL_START) {
b.liu15f456b2024-10-31 20:16:06 +0800921 int retry_interval[] = {5, 10, 15};
b.liuafdf2c62024-11-12 11:10:44 +0800922 if(count == 5) {
b.liub171c9a2024-11-12 19:23:29 +0800923 err = mbtk_data_call_start(handle_def, (mbtk_ril_cid_enum)cid, (mbtk_data_call_item_state_enum)auto_boot_call,
b.liuafdf2c62024-11-12 11:10:44 +0800924 (mbtk_data_call_item_state_enum)def_route, (mbtk_data_call_item_state_enum)as_dns, retry_interval,
b.liu15f456b2024-10-31 20:16:06 +0800925 3, 0, &ip);
b.liuafdf2c62024-11-12 11:10:44 +0800926 } else {
b.liub171c9a2024-11-12 19:23:29 +0800927 err = mbtk_data_call_start(handle_def, (mbtk_ril_cid_enum)cid, MBTK_DATA_CALL_ITEM_STATE_NON,
b.liuafdf2c62024-11-12 11:10:44 +0800928 MBTK_DATA_CALL_ITEM_STATE_NON, MBTK_DATA_CALL_ITEM_STATE_NON, retry_interval,
929 3, 0, &ip);
930 }
b.liubcf86c92024-08-19 19:48:28 +0800931 } else if(type == MBTK_DATA_CALL_STOP) {
b.liub171c9a2024-11-12 19:23:29 +0800932 err = mbtk_data_call_stop(handle_def, (mbtk_ril_cid_enum)cid, 10);
b.liubcf86c92024-08-19 19:48:28 +0800933 } else {
b.liub171c9a2024-11-12 19:23:29 +0800934 err = mbtk_data_call_state_get(handle_def, (mbtk_ril_cid_enum)cid, &ip);
b.liubcf86c92024-08-19 19:48:28 +0800935 }
936 if(err) {
937 printf("Error : %d\n", err);
938 } else {
939 printf("DATA_CALL success\n");
940 if(type == MBTK_DATA_CALL_START || type == MBTK_DATA_CALL_STATE) {
941 if(ip.ipv4.valid) {
942 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
943 char ip_tmp[20];
944
945 memset(ip_tmp, 0, 20);
946 if(inet_ntop(AF_INET, &(ip.ipv4.IPAddr), ip_tmp, 20) == NULL) {
947 printf("IP error.\n");
948 } else {
949 printf("IP : %s\n", ip_tmp);
950 }
951
952 memset(ip_tmp, 0, 20);
953 if(inet_ntop(AF_INET, &(ip.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
954 printf("PrimaryDNS error.\n");
955 } else {
956 printf("PrimaryDNS : %s\n", ip_tmp);
957 }
958
959 memset(ip_tmp, 0, 20);
960 if(inet_ntop(AF_INET, &(ip.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
961 printf("SecondaryDNS error.\n");
962 } else {
963 printf("SecondaryDNS : %s\n", ip_tmp);
964 }
965
966 memset(ip_tmp, 0, 20);
967 if(inet_ntop(AF_INET, &(ip.ipv4.GateWay), ip_tmp, 20) == NULL) {
968 printf("GateWay error.\n");
969 } else {
970 printf("GateWay : %s\n", ip_tmp);
971 }
972
973 memset(ip_tmp, 0, 20);
974 if(inet_ntop(AF_INET, &(ip.ipv4.NetMask), ip_tmp, 20) == NULL) {
975 printf("NetMask error.\n");
976 } else {
977 printf("NetMask : %s\n", ip_tmp);
978 }
979 }
980
981 if(ip.ipv6.valid) {
982 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
983 char ip_tmp[50];
984
985 memset(ip_tmp, 0, 50);
986 if(ipv6_2_str(&(ip.ipv6.IPV6Addr), ip_tmp)) {
987 printf("IP error.\n");
988 } else {
989 printf("IP : %s\n", ip_tmp);
990 }
991
992 memset(ip_tmp, 0, 50);
993 if(ipv6_2_str(&(ip.ipv6.PrimaryDNS), ip_tmp)) {
994 printf("PrimaryDNS error.\n");
995 } else {
996 printf("PrimaryDNS : %s\n", ip_tmp);
997 }
998
999 memset(ip_tmp, 0, 50);
1000 if(ipv6_2_str(&(ip.ipv6.SecondaryDNS), ip_tmp)) {
1001 printf("SecondaryDNS error.\n");
1002 } else {
1003 printf("SecondaryDNS : %s\n", ip_tmp);
1004 }
1005
1006 memset(ip_tmp, 0, 50);
1007 if(ipv6_2_str(&(ip.ipv6.GateWay), ip_tmp)) {
1008 printf("GateWay error.\n");
1009 } else {
1010 printf("GateWay : %s\n", ip_tmp);
1011 }
1012
1013 memset(ip_tmp, 0, 50);
1014 if(ipv6_2_str(&(ip.ipv6.NetMask), ip_tmp)) {
1015 printf("NetMask error.\n");
1016 } else {
1017 printf("NetMask : %s\n", ip_tmp);
1018 }
1019 }
1020 }
1021 }
1022 }
1023 }
b.liu87afc4c2024-08-14 17:33:45 +08001024 else if(!strncasecmp(cmd, "cell", 4)){
1025 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1026 if(ptr == NULL)
1027 {
b.liub4772072024-08-15 14:47:03 +08001028 mbtk_cell_info_array_t cell;
b.liub171c9a2024-11-12 19:23:29 +08001029 err = mbtk_cell_get(handle_def, &cell);
b.liub4772072024-08-15 14:47:03 +08001030 if(err) {
b.liu87afc4c2024-08-14 17:33:45 +08001031 printf("Error : %d\n", err);
b.liub4772072024-08-15 14:47:03 +08001032 } else if(cell.num > 0){
1033 // Current server cell.
1034 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +08001035 {
b.liub4772072024-08-15 14:47:03 +08001036 case MBTK_CELL_TYPE_GSM:
1037 printf("GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell.cell[0].value1, cell.cell[0].value2, cell.cell[0].value3, cell.cell[0].value4);
1038 break;
1039 case MBTK_CELL_TYPE_UMTS:
1040 printf("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell.cell[0].value1, cell.cell[0].value2, cell.cell[0].value3);
1041 break;
1042 case MBTK_CELL_TYPE_LTE:
1043 printf("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell.cell[0].value1, cell.cell[0].value2, cell.cell[0].value3, cell.cell[0].value4, cell.cell[0].value5);
1044 break;
1045 default:
1046 break;
1047 }
1048
1049 int i = 1;
1050 while (i < cell.num)
1051 {
1052 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +08001053 {
b.liub4772072024-08-15 14:47:03 +08001054 case MBTK_CELL_TYPE_GSM:
1055 printf("CELL : %d, %d, %d, %d, %d", cell.cell[i].value1, cell.cell[i].value2, cell.cell[i].value3, cell.cell[i].value4, cell.cell[i].value5);
b.liu87afc4c2024-08-14 17:33:45 +08001056 break;
b.liub4772072024-08-15 14:47:03 +08001057 case MBTK_CELL_TYPE_UMTS:
1058 printf("CELL : lac=%d, ci=%d, arfcn=%d\n", cell.cell[i].value1, cell.cell[i].value2, cell.cell[i].value3);
b.liu87afc4c2024-08-14 17:33:45 +08001059 break;
b.liub4772072024-08-15 14:47:03 +08001060 case MBTK_CELL_TYPE_LTE:
1061 printf("CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d\n", cell.cell[i].value1, cell.cell[i].value2, cell.cell[i].value3, cell.cell[i].value4);
b.liu87afc4c2024-08-14 17:33:45 +08001062 break;
1063 default:
1064 break;
1065 }
b.liub4772072024-08-15 14:47:03 +08001066 i++;
b.liu87afc4c2024-08-14 17:33:45 +08001067 }
b.liub4772072024-08-15 14:47:03 +08001068 } else {
1069 printf("Cell no found.");
b.liu87afc4c2024-08-14 17:33:45 +08001070 }
b.liu87afc4c2024-08-14 17:33:45 +08001071 }
1072 else{
1073 char *ptr = strstr(cmd, ","); //cell,2,3,,40936,430
1074 char mem[50]={0};
1075 char resp[1024] = {0};
1076 if(ptr != NULL)
1077 {
1078 ptr++;
1079 memset(mem, 0, sizeof(mem));
1080 memcpy(mem, ptr, strlen(ptr));
1081 printf("cell:%s\n", mem);
1082 }
1083 printf("cell_mem: %s \n", mem);
1084
1085 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001086 err = mbtk_cell_set(handle_def, mem, resp);
b.liu87afc4c2024-08-14 17:33:45 +08001087 if(err) {
1088 printf("Error : %d\n", err);
1089 } else {
1090 printf("cell set . resp:%s\n", resp);
1091 }
b.liu87afc4c2024-08-14 17:33:45 +08001092 }
b.liub4772072024-08-15 14:47:03 +08001093 }
1094 else if(!strncasecmp(cmd, "call", 4)){
b.liu87afc4c2024-08-14 17:33:45 +08001095 char phone_number[12];
1096 char *ptr = strstr(cmd, " ");
1097 if(ptr == NULL)
1098 continue;
1099 while(*ptr != '\0' && *ptr == ' ')
1100 ptr++;
1101 memset(phone_number,0,strlen(phone_number));
1102 memcpy(phone_number,ptr,strlen(ptr));
1103 printf("phone number is: %s\n",phone_number);
b.liub171c9a2024-11-12 19:23:29 +08001104 err = mbtk_call_start(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +08001105 if(err) {
1106 printf("Error : %d\n", err);
1107 } else {
1108 printf("Call success.\n");
1109 }
1110 } else if(!strncasecmp(cmd, "answer", 6)){
b.liub171c9a2024-11-12 19:23:29 +08001111 err = mbtk_call_answer(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001112 if(err) {
1113 printf("Error : %d\n", err);
1114 } else {
1115 printf("Call success.\n");
1116 }
1117 } else if(!strncasecmp(cmd, "hangup", 6)){
b.liu62240ee2024-11-07 17:52:45 +08001118 int phone_id = 1;
b.liu87afc4c2024-08-14 17:33:45 +08001119 if(!strcasecmp(cmd, "hangup")) { // hang up all
b.liub171c9a2024-11-12 19:23:29 +08001120 err = mbtk_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001121 if(err) {
1122 printf("Error : %d\n", err);
1123 } else {
1124 printf("Call hang up all.\n");
1125 }
1126 } else if(!strcasecmp(cmd, "hangup 0")) {
b.liub171c9a2024-11-12 19:23:29 +08001127 err = mbtk_waiting_or_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001128 if(err) {
1129 printf("Error : %d\n", err);
1130 } else {
1131 printf("Call hang up waiting or background.\n");
1132 }
1133 } else if(!strcasecmp(cmd, "hangup 3")) {
b.liub171c9a2024-11-12 19:23:29 +08001134 err = mbtk_foreground_resume_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001135 if(err) {
1136 printf("Error : %d\n", err);
1137 } else {
1138 printf("Call hang up foreground resume background.\n");
1139 }
1140 } else {
1141 if(!strcasecmp(cmd, "hangup 1")) { // hang up a call
1142 phone_id = 1;
1143 } else if(!strcasecmp(cmd, "hangup 2")) {
1144 phone_id = 2;
1145 } else {
1146 printf("Error : Invalid input\n");
1147 }
b.liub171c9a2024-11-12 19:23:29 +08001148 err = mbtk_a_call_hang(handle_def, phone_id);
b.liu87afc4c2024-08-14 17:33:45 +08001149 if(err) {
1150 printf("Error : %d\n", err);
1151 } else {
1152 printf("A Call hang up.\n");
1153 }
1154 }
1155 } else if(!strncasecmp(cmd, "waitin", 6)){
1156 mbtk_call_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +08001157 err = mbtk_call_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001158 if(err) {
1159 printf("Error : %d\n", err);
1160 } else {
1161 if(reg.call_wait == 0) {
1162 printf("No call ring\n");
1163 }
1164 else {
1165 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);
1166 }
1167 }
1168 } else if(!strncasecmp(cmd, "mute", 4)){ // "mute" or "mute 0" or "mute 1"
1169 int mute;
1170 if(!strcasecmp(cmd, "mute")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001171 err = mbtk_mute_state_get(handle_def, &mute);
b.liu87afc4c2024-08-14 17:33:45 +08001172 if(err) {
1173 printf("Error : %d\n", err);
1174 } else {
1175 printf("mute : %d\n", mute);
1176 }
1177 } else { // Set
1178 if(!strcasecmp(cmd, "mute 1")) { // on mute
1179 mute = 1;
1180 } else { // off mute
1181 mute = 0;
1182 }
b.liub171c9a2024-11-12 19:23:29 +08001183 err = mbtk_mute_state_set(handle_def, mute);
b.liu87afc4c2024-08-14 17:33:45 +08001184 if(err) {
1185 printf("Error : %d\n", err);
1186 } else {
1187 printf("mute set success\n");
1188 }
1189 }
1190 } else if(!strncasecmp(cmd, "DTMF", 4)){ // valid character: (0, 1, ..., 9, A, B, C, D, *, #)
1191
1192 mbtk_call_dtmf_info_t reg;
1193
1194 char *ptr = strstr(cmd, " ");
1195 if(ptr == NULL)
1196 continue;
1197 while(*ptr != '\0' && *ptr == ' ')
1198 ptr++;
1199 reg.character = *ptr;
1200
1201 ptr = strstr(ptr, " ");
1202 if(ptr == NULL)
1203 continue;
1204 while(*ptr != '\0' && *ptr == ' ')
1205 ptr++;
1206 reg.duration = (uint32)atoi(ptr);
1207 printf("DTMF character is: %c,%d\n",reg.character, reg.duration);
b.liub171c9a2024-11-12 19:23:29 +08001208 err = mbtk_dtmf_send(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001209 if(err) {
1210 printf("Error : %d\n", err);
1211 } else {
1212 printf("DTMF success.\n");
1213 }
b.liub4772072024-08-15 14:47:03 +08001214 } else if(!strncasecmp(cmd, "cmgf", 4)){ // set mode 0: pud, 1:text
1215 int mode;
1216 if(!strcasecmp(cmd, "cmgf")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001217 err = mbtk_sms_cmgf_get(handle_def, &mode);
b.liub4772072024-08-15 14:47:03 +08001218 if(err) {
1219 printf("Error : %d\n", err);
1220 } else {
1221 printf("VoLTE : %d\n", mode);
1222 }
1223 } else { // Set
1224 if(!strcasecmp(cmd, "cmgf 1")) { // cmgf 1
1225 mode = 1;
1226 } else { //
1227 mode = 0;
1228 }
1229 printf("mode:%d\n", mode);
1230 sleep(2);
b.liub171c9a2024-11-12 19:23:29 +08001231 err = mbtk_sms_cmgf_set(handle_def, mode);
b.liub4772072024-08-15 14:47:03 +08001232 if(err) {
1233 printf("Error : %d\n", err);
1234 } else {
1235 printf("VoLTE set success\n");
1236 }
1237 }
1238 }else if(!strncasecmp(cmd, "cpms", 4)){ // //CPMS=ME, ME, ME
1239 char mem[100] = {0};
1240 char resp[100] = {0};
1241 if(!strcasecmp(cmd, "cpms")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001242 err = mbtk_sms_cpms_get(handle_def, mem);
b.liub4772072024-08-15 14:47:03 +08001243 if(err) {
1244 printf("Error : %d\n", err);
1245 } else {
1246 printf("cpms : %s\n", mem);
1247 }
1248 } else { // Set
1249
1250 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1251 if(ptr != NULL)
1252 {
1253 ptr++;
1254 memset(mem, 0, sizeof(mem));
1255 memcpy(mem, ptr, strlen(ptr));
1256 printf("cpms:%s\n", mem);
1257 }
1258 printf("cpms 0\n");
1259
1260 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001261 err = mbtk_sms_cpms_set(handle_def, mem, resp);
b.liub4772072024-08-15 14:47:03 +08001262 if(err) {
1263 printf("Error : %d\n", err);
1264 } else {
1265 printf("cpms set success. resp:%s\n", resp);
1266 }
1267 }
1268 }else if(!strncasecmp(cmd, "cmgs", 4)){ // AT+CMGS="10086", CMGS TEST
1269 char cmgs[1024] = {0};
1270 char resp[50] = {0};
1271 if(!strcasecmp(cmd, "cmgs")) { // Get
b.liudeb8e422024-12-14 17:36:56 +08001272 int mode = 0;
1273 err = 0;
b.liub4772072024-08-15 14:47:03 +08001274 // err = mbtk_sms_cmgs_get(info_handle, &mode);
1275 if(err) {
1276 printf("Error : %d\n", err);
1277 } else {
1278 printf("VoLTE : %d\n", mode);
1279 }
1280 } else { // Set
1281
1282 /*
1283 *AT+CMGS="10086", CMGS TEST // Send a SMS
1284 > CMGS TEST
1285 +CMGS: 17
1286 OK
1287 */
1288
1289 char *ptr = strstr(cmd, "cmgs,"); //CMGS="10086",hf
1290 if(ptr != NULL)
1291 {
1292 ptr = strstr(cmd, ",");
1293 ptr++;
1294 memset(cmgs, 0, sizeof(cmgs));
1295 memcpy(cmgs, ptr, strlen(ptr));
1296 printf("1cmgs:%s, strlen(cmgs):%d\n", cmgs, strlen(cmgs));
1297 }
1298
1299 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001300 err = mbtk_sms_cmgs_set(handle_def, cmgs, resp);
b.liub4772072024-08-15 14:47:03 +08001301 if(err) {
1302 printf("Error : %d\n", err);
1303 } else {
1304 printf("cmgs set success . resp:%s\n", resp);
1305 }
1306 }
1307 }else if(!strncasecmp(cmd, "cmss", 4)){ // +CMSS=<index>[,<da>[,<toda>]]
1308 char cmss[20] = {0};
1309 char resp[20] = {0};
1310 if(!strcasecmp(cmd, "cmgs")) { // Get
1311 printf("cmss : OK\n");
1312
1313 } else {
1314 char *ptr = strstr(cmd, "cmss,"); //CMSS=<index>
1315 if(ptr != NULL)
1316 {
1317 ptr = strstr(cmd, ",");
1318 ptr++;
1319 memset(cmss, 0, sizeof(cmss));
1320 memcpy(cmss, ptr, strlen(ptr));
1321 printf("1cmss:%s\n", cmss);
1322 }
1323
1324
b.liub171c9a2024-11-12 19:23:29 +08001325 err = mbtk_sms_cmss_set(handle_def, cmss, resp);
b.liub4772072024-08-15 14:47:03 +08001326 if(err) {
1327 printf("Error : %d\n", err);
1328 } else {
1329 printf("cmss set success. resp:%s\n", resp);
1330 }
1331 }
1332 }
1333 else if(!strncasecmp(cmd, "cmgr", 4)){ // +CMGR=<index
1334 int index = 0;
1335 char resp[1024] = {0};
1336 if(!strcasecmp(cmd, "cmgr")) { // Get
1337 printf("cmgr : OK\n");
1338
1339 } else {
1340 char *ptr = strstr(cmd, "cmgr,"); //+CMGR <index>
1341 if(ptr != NULL)
1342 {
1343 ptr = strstr(cmd, ",");
1344 ptr++;
1345 index = atoi(ptr);
1346 }
1347 printf("1index:%d\n", index);
1348
1349 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001350 err = mbtk_sms_cmgr_set(handle_def, index, resp);
b.liub4772072024-08-15 14:47:03 +08001351 if(err) {
1352 printf("Error : %d\n", err);
1353 } else {
1354 printf("cmgr set success. rep:%s\n", resp);
1355 }
1356 }
1357 }
1358 else if(!strncasecmp(cmd, "cmgw", 4)){ // +CMGW=<oa/da>[,<tooa/toda>[,<stat>]]<CR>
1359 //+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
1360 char cmgw[128] = {0};
1361 char resp[50] = {0};
1362 if(!strcasecmp(cmd, "cmgw")) { // Get
1363 printf("cmgw : OK\n");
1364
1365 } else {
1366 char *ptr = strstr(cmd, "cmgw,"); //+CMGW, <oa/da>, data
1367 if(ptr != NULL)
1368 {
1369 ptr = strstr(cmd, ",");
1370 ptr++;
1371 memset(cmgw, 0, sizeof(cmgw));
1372 memcpy(cmgw, ptr, strlen(ptr));
1373 printf("cmgw:%s\n", cmgw);
1374 }
1375
1376 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001377 err = mbtk_sms_cmgw_set(handle_def, cmgw, resp);
b.liub4772072024-08-15 14:47:03 +08001378 if(err) {
1379 printf("Error : %d\n", err);
1380 } else {
1381 printf("cmgw set success. resp:%s\n", resp);
1382 }
1383 }
1384 }
1385 else if(!strncasecmp(cmd, "cmgd", 4)){ // +CMGD=<index>[,<delflag>
1386 //
1387 char cmgd[128] = {0};
1388 if(!strcasecmp(cmd, "cmgd")) { // Get
1389 printf("cmgd : OK\n");
1390
1391 } else {
1392 char *ptr = strstr(cmd, ","); //+CMGD=<index>[,<delflag>
1393 if(ptr != NULL)
1394 {
1395 ptr++;
1396 memset(cmgd, 0, sizeof(cmgd));
1397 memcpy(cmgd, ptr, strlen(ptr));
1398 printf("1cmgd:%s\n", cmgd);
1399 }
1400
1401
b.liub171c9a2024-11-12 19:23:29 +08001402 err = mbtk_sms_cmgd_set(handle_def, cmgd);
b.liub4772072024-08-15 14:47:03 +08001403 if(err) {
1404 printf("Error : %d\n", err);
1405 } else {
1406 printf("VoLTE set success\n");
1407 }
1408 }
1409 }
1410 else if(!strncasecmp(cmd, "cmgl", 4)){ // AT+CMGL[=<stat>]
1411 //
1412 char cmgl[128] = {0};
1413 char resp[5*1024] ={0};
1414 if(!strcasecmp(cmd, "cmgl")) { // Get
1415 printf("cmgl : OK\n");
1416
1417 } else {
1418 char *ptr = strstr(cmd, "cmgl,"); // AT+CMGL[=<stat>]
1419 if(ptr != NULL)
1420 {
1421 ptr = strstr(cmd, ",");
1422 ptr++;
1423 memset(cmgl, 0, sizeof(cmgl));
1424 memcpy(cmgl, ptr, strlen(ptr));
1425 printf("0cmgl:%s\n", cmgl);
1426 }
1427
1428 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001429 err = mbtk_sms_cmgl_set(handle_def, cmgl, resp);
b.liub4772072024-08-15 14:47:03 +08001430 if(err) {
1431 printf("Error : %d\n", err);
1432 } else {
1433 // printf("cmgl set success, reg:%s\n",resp);
1434 }
1435 }
1436 }
1437 else if(!strncasecmp(cmd, "csca", 4)){ // AT+CSCA=<number> [,<type>]
1438 //
1439 char csca[128] = {0};
1440 if(!strcasecmp(cmd, "csca")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001441 err = mbtk_sms_csca_get(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001442 if(err) {
1443 printf("mbtk_sms_csca_get Error : %d\n", err);
1444 } else {
1445 printf("mbtk_sms_csca_get success\n");
1446 }
1447
1448 } else {
1449 char *ptr = strstr(cmd, ","); // AT+CSCA=<number> [,<type>]
1450 if(ptr != NULL)
1451 {
1452 ptr++;
1453 memset(csca, 0, sizeof(csca));
1454 memcpy(csca, ptr, strlen(ptr));
1455 printf("csca:%s\n", csca);
1456 }
1457
b.liub171c9a2024-11-12 19:23:29 +08001458 err = mbtk_sms_csca_set(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001459 if(err) {
1460 printf("Error : %d\n", err);
1461 } else {
1462 printf("VoLTE set success\n");
1463 }
1464 }
1465 }
1466 else if(!strncasecmp(cmd, "csmp", 4)){ // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1467 //
1468 char csmp[128] = {0};
1469 if(!strcasecmp(cmd, "csmp")) { // Get
1470 printf("cmgl : OK\n");
1471
1472 } else {
1473 char *ptr = strstr(cmd, ","); // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1474 if(ptr != NULL)
1475 {
1476 ptr++;
1477 memset(csmp, 0, sizeof(csmp));
1478 memcpy(csmp, ptr, strlen(ptr));
1479 printf("csmp:%s\n", csmp);
1480 }
1481
b.liub171c9a2024-11-12 19:23:29 +08001482 err = mbtk_sms_csmp_set(handle_def, csmp);
b.liub4772072024-08-15 14:47:03 +08001483 if(err) {
1484 printf("Error : %d\n", err);
1485 } else {
1486 printf("VoLTE set success\n");
1487 }
1488 }
1489 }
1490 else if(!strncasecmp(cmd, "cscb", 4)){ // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1491 //
1492 char cscb[128] = {0};
1493 if(!strcasecmp(cmd, "cscb")) { // Get
1494 printf("cmgl : OK\n");
1495
1496 } else {
1497 char *ptr = strstr(cmd, ","); // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1498 if(ptr != NULL)
1499 {
1500 ptr++;
1501 memset(cscb, 0, sizeof(cscb));
1502 memcpy(cscb, ptr, strlen(ptr));
1503 printf("cscb:%s\n", cscb);
1504 }
1505
b.liub171c9a2024-11-12 19:23:29 +08001506 err = mbtk_sms_cscb_set(handle_def, cscb);
b.liub4772072024-08-15 14:47:03 +08001507 if(err) {
1508 printf("Error : %d\n", err);
1509 } else {
1510 printf("VoLTE set success\n");
1511 }
1512 }
1513 }
1514#if 0
1515 else if(!strncasecmp(cmd, "shutdown", 8)){
b.liu87afc4c2024-08-14 17:33:45 +08001516 if(!strcasecmp(cmd, "shutdown 0")) {
1517 err = mbtk_system_reboot(0);
1518 if(err) {
1519 printf("Error : %d\n", err);
1520 } else {
1521 printf("Success.\n");
1522 }
1523 } else if(!strcasecmp(cmd, "shutdown 1")) {
1524 err = mbtk_system_reboot(1);
1525 if(err) {
1526 printf("Error : %d\n", err);
1527 } else {
1528 printf("Success.\n");
1529 }
1530 } else if(!strcasecmp(cmd, "shutdown 2")) {
1531 err = mbtk_system_reboot(2);
1532 if(err) {
1533 printf("Error : %d\n", err);
1534 } else {
1535 printf("Success.\n");
1536 }
1537 } else {
1538 printf("Error.");
1539 }
1540 } else if(!strncasecmp(cmd, "power_sim", 9)){
1541 if(!strcasecmp(cmd, "power_sim 0")) {
1542 err = mbtk_sim_power_set(0);
1543 if(err) {
1544 printf("Error : %d\n", err);
1545 } else {
1546 printf("Success.\n");
1547 }
1548 } else if(!strcasecmp(cmd, "power_sim 1")) {
1549 err = mbtk_sim_power_set(1);
1550 if(err) {
1551 printf("Error : %d\n", err);
1552 } else {
1553 printf("Success.\n");
1554 }
1555 } else {
1556 printf("Error.");
1557 }
1558 } else if(!strncasecmp(cmd, "time", 4)){
1559 if(!strcasecmp(cmd, "time 0")) {
1560 err = mbtk_time_set(info_handle, 0, NULL);
1561 if(err) {
1562 printf("Error : %d\n", err);
1563 } else {
1564 printf("Success.\n");
1565 }
1566 } else if(!strcasecmp(cmd, "time 1")) {
1567 err = mbtk_time_set(info_handle, 1, NULL);
1568 if(err) {
1569 printf("Error : %d\n", err);
1570 } else {
1571 printf("Success.\n");
1572 }
1573 } else if(!strncasecmp(cmd, "time 2 ", 7)) {
1574 err = mbtk_time_set(info_handle, 2, cmd + 7);
1575 if(err) {
1576 printf("Error : %d\n", err);
1577 } else {
1578 printf("Success.\n");
1579 }
1580 } else { // Get time type.
1581 int time_type;
1582 err = mbtk_time_get(info_handle, &time_type);
1583 if(err) {
1584 printf("Error : %d\n", err);
1585 } else {
1586 printf("Time type:%d.\n", time_type);
1587 }
1588 }
b.liu87afc4c2024-08-14 17:33:45 +08001589 }
1590#endif
1591 else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
1592 help();
1593 } else if(!strcasecmp(cmd, "q")) {
b.liub171c9a2024-11-12 19:23:29 +08001594 mbtk_ril_close(MBTK_AT_PORT_DEF);
1595 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +08001596 break;
1597 } else {
1598 printf("\n");
1599 }
1600 }
1601 }
1602
b.liu62240ee2024-11-07 17:52:45 +08001603#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +08001604 thread_exit_with_wait();
b.liu87afc4c2024-08-14 17:33:45 +08001605exit:
b.liu62240ee2024-11-07 17:52:45 +08001606#endif
b.liub171c9a2024-11-12 19:23:29 +08001607 mbtk_ril_close(MBTK_AT_PORT_DEF);
1608 mbtk_ril_close(ATPORTTYPE_1);
1609
b.liu87afc4c2024-08-14 17:33:45 +08001610
1611 LOG("Client exec complete.");
1612
1613 return 0;
1614}