blob: 1f4ac7aef8adbed560ff6d77efe2a13fa65256a7 [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);
167 }
168}
169
170static void signal_state_change_cb(const void* data, int data_len)
171{
172
173}
174
175static void ecall_state_change_cb(const void* data, int data_len)
176{
177 if(data)
178 {
179 mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
180 printf("ecall state change : urc_id - %d, urc_data - %s\n", ecall_data->urc_id, ecall_data->urc_data);
181 }
182}
183
184
b.liu87afc4c2024-08-14 17:33:45 +0800185static void sig_process(int sig)
186{
187 LOGI("I got signal %d\n", sig);
188 switch(sig)
189 {
190 case SIGINT: // Ctrl + C
191 {
192 LOGI("Exit by SIGINT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800193#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800194 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800195#endif
b.liub171c9a2024-11-12 19:23:29 +0800196 mbtk_ril_close(MBTK_AT_PORT_DEF);
197 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800198 exit(0);
199 }
200 case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
201 {
202 LOGI("Exit by SIGQUIT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800203#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800204 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800205#endif
b.liub171c9a2024-11-12 19:23:29 +0800206 mbtk_ril_close(MBTK_AT_PORT_DEF);
207 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800208 exit(0);
209 }
210 case SIGTERM:// 默认kill (同 SIGKILL ,但 SIGKILL 不可捕获)
211 {
212 LOGI("Exit by SIGTERM.\n");
b.liu62240ee2024-11-07 17:52:45 +0800213#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800214 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800215#endif
b.liub171c9a2024-11-12 19:23:29 +0800216 mbtk_ril_close(MBTK_AT_PORT_DEF);
217 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800218 exit(0);
219 }
220 case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
221 {
222 LOGI("Exit by SIGTSTP.\n");
223 exit(0);
224 }
225 case SIGSEGV: // 如空指针
226 {
227 LOGI("Exit by SIGSEGV.\n");
228 exit(0);
229 }
230 default:
231 {
232 LOGI("Unknown sig:%d\n",sig);
233 break;
234 }
235 }
236}
237
b.liu62240ee2024-11-07 17:52:45 +0800238#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800239static char* thread_id2name(pthread_t pid)
240{
241 int i = 0;
242 while(i < CLI_THREAD_MAX) {
243 if(pid == cli_threads[i].pid) {
244 return cli_threads[i].name;
245 }
246 i++;
247 }
248
249 return "UNKNOWN";
250}
251
252static void* sub_thread_run(void *arg)
253{
254 ril_cli_thread_info_t *cli = (ril_cli_thread_info_t*)arg;
255 cli->pid = pthread_self();
256 cli->is_running = TRUE;
257 sprintf(cli->name, "PID-%d", cli_pid_index++);
258
259 printf("[%s] enter.\n", thread_id2name(cli->pid));
260 while(cli->is_running) {
261 srand((int)(time(0) + cli->pid));
262 int time_sec = 1 + (int)(10.0 * rand() / ( RAND_MAX + 1.0));
263 char version[50] = {0};
264 mbtk_ril_err_enum err = mbtk_version_get(version);
265 if(err != MBTK_RIL_ERR_SUCCESS) {
266 printf("[%s : %ds]Error : %d\n", thread_id2name(cli->pid), time_sec, err);
267 } else {
268 printf("[%s : %ds]Version : %s\n", thread_id2name(cli->pid), time_sec, version);
269 }
270
271 sleep(time_sec);
272 }
273 printf("[%s] exit.\n", thread_id2name(cli->pid));
274 return NULL;
275}
b.liu62240ee2024-11-07 17:52:45 +0800276#endif
b.liu87afc4c2024-08-14 17:33:45 +0800277
278int main(int argc, char *argv[])
279{
280 signal(SIGINT, sig_process);
281 signal(SIGQUIT, sig_process);
282 signal(SIGTERM, sig_process);
283 //signal(SIGTSTP, sig_process);
284 //signal(SIGSEGV, sig_process);
285
286 mbtk_log_init("radio","RIL_CLI");
287
288#ifdef MBTK_DUMP_SUPPORT
289 mbtk_debug_open(NULL, TRUE);
290#endif
291
292 //test2(0, "192.168.1.198");
293 //test2(1, "2409:8162:140:cd3c:1:2:1494:72ba");
294 //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
295 //test2(1, "2400:3200::1");
296
b.liub171c9a2024-11-12 19:23:29 +0800297 mbtk_ril_handle* handle_def = mbtk_ril_open(MBTK_AT_PORT_DEF);
298 if(handle_def == NULL) {
299 printf("mbtk_ril_open(MBTK_AT_PORT_DEF/ATPORTTYPE_0) fail.");
300 return -1;
301 }
302
303 mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
304 if(handle_1 == NULL) {
305 printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
b.liu87afc4c2024-08-14 17:33:45 +0800306 return -1;
307 }
308
b.liu15f456b2024-10-31 20:16:06 +0800309 mbtk_ril_ser_state_change_cb_reg(ril_ser_state_change_cb);
310
311 mbtk_net_reg_state_change_cb_reg(net_reg_state_change_cb);
312
313 mbtk_call_state_change_cb_reg(call_state_change_cb);
314
315 mbtk_sms_state_change_cb_reg(sms_state_change_cb);
316
317 mbtk_radio_state_change_cb_reg(radio_state_change_cb);
318
319 mbtk_sim_state_change_cb_reg(sim_state_change_cb);
320
321 mbtk_pdp_state_change_cb_reg(pdp_state_change_cb);
322
323 mbtk_signal_state_change_cb_reg(signal_state_change_cb);
324
325 mbtk_ecall_state_change_cb_reg(ecall_state_change_cb);
326
b.liu62240ee2024-11-07 17:52:45 +0800327#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800328 memset(cli_threads, 0, sizeof(ril_cli_thread_info_t) * CLI_THREAD_MAX);
329
330 pthread_t pid1, pid2, pid3;
331 if(pthread_create(&pid1, NULL, sub_thread_run, &cli_threads[0]))
332 {
333 printf("pthread_create() fail.");
334 goto exit;
335 }
336
337 if(pthread_create(&pid2, NULL, sub_thread_run, &cli_threads[1]))
338 {
339 printf("pthread_create() fail.");
340 goto exit;
341 }
342
343 if(pthread_create(&pid3, NULL, sub_thread_run, &cli_threads[2]))
344 {
345 printf("pthread_create() fail.");
346 goto exit;
347 }
348#endif
349 printf(">>>>>>>>>>>>>>>>>>>>>>>>Enter cmd:\n");
350 char cmd[100];
351 while(1)
352 {
353 memset(cmd, 0, 100);
354 mbtk_ril_err_enum err;
355 if(fgets(cmd, 100, stdin))
356 {
357 char *ptr = cmd + strlen(cmd) - 1;
358 while(ptr >= cmd && (*ptr == '\r' || *ptr == '\n'))
359 {
360 *ptr-- = '\0';
361 }
362 if(!strncasecmp(cmd, "version", 7))
363 {
364 char version[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800365 err = mbtk_version_get(handle_def, version);
b.liu87afc4c2024-08-14 17:33:45 +0800366 if(err != MBTK_RIL_ERR_SUCCESS) {
367 printf("Error : %d\n", err);
368 } else {
369 printf("Version : %s\n", version);
370 }
371 }
372 else if(!strncasecmp(cmd, "imei", 4)){
373 char imei[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800374 err = mbtk_imei_get(handle_def, imei);
b.liu87afc4c2024-08-14 17:33:45 +0800375 if(err != MBTK_RIL_ERR_SUCCESS) {
376 printf("Error : %d\n", err);
377 } else {
378 printf("IMEI : %s\n", imei);
379 }
380 } else if(!strncasecmp(cmd, "sn", 2)){
381 char sn[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800382 err = mbtk_sn_get(handle_def, sn);
b.liu87afc4c2024-08-14 17:33:45 +0800383 if(err != MBTK_RIL_ERR_SUCCESS) {
384 printf("Error : %d\n", err);
385 } else {
386 printf("SN : %s\n", sn);
387 }
388 } else if(!strncasecmp(cmd, "meid", 4)){
389 char meid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800390 err = mbtk_meid_get(handle_def, meid);
b.liu87afc4c2024-08-14 17:33:45 +0800391 if(err != MBTK_RIL_ERR_SUCCESS) {
392 printf("Error : %d\n", err);
393 } else {
394 printf("MEID : %s\n", meid);
395 }
396 } else if(!strncasecmp(cmd, "volte", 5)){ // "volte" or "volte 0" or "volte 1"
397 int volte;
398 if(!strcasecmp(cmd, "volte")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800399 err = mbtk_volte_state_get(handle_def, &volte);
b.liu87afc4c2024-08-14 17:33:45 +0800400 if(err != MBTK_RIL_ERR_SUCCESS) {
401 printf("Error : %d\n", err);
402 } else {
403 printf("VoLTE : %d\n", volte);
404 }
405 } else { // Set
406 if(!strcasecmp(cmd, "volte 1")) { // Open VoLTE
407 volte = 1;
408 } else { // Close VoLTE
409 volte = 0;
410 }
b.liub171c9a2024-11-12 19:23:29 +0800411 err = mbtk_volte_state_set(handle_def, volte);
b.liu87afc4c2024-08-14 17:33:45 +0800412 if(err != MBTK_RIL_ERR_SUCCESS) {
413 printf("Error : %d\n", err);
414 } else {
415 printf("VoLTE set success\n");
416 }
417 }
418 } else if(!strncasecmp(cmd, "radio", 5)){ // "radio" or "radio 0" or "radio 1"
419 mbtk_radio_state_enum radio;
420 if(!strcasecmp(cmd, "radio")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800421 err = mbtk_radio_state_get(handle_def, &radio);
b.liu87afc4c2024-08-14 17:33:45 +0800422 if(err != MBTK_RIL_ERR_SUCCESS) {
423 printf("Error : %d\n", err);
424 } else {
425 printf("Radio : %d\n", radio);
426 }
427 } else { // Set
428 int reset;
429 int count = sscanf(cmd, "radio %d %d", &radio, &reset);
430 if(count > 0) {
431 if(count == 1) {
432 reset = 0;
433 }
434
b.liub171c9a2024-11-12 19:23:29 +0800435 err = mbtk_radio_state_set(handle_def, radio, reset);
b.liu87afc4c2024-08-14 17:33:45 +0800436 if(err != MBTK_RIL_ERR_SUCCESS) {
437 printf("Error : %d\n", err);
438 } else {
439 printf("Radio set success\n");
440 }
441 }
442 }
443 } else if(!strncasecmp(cmd, "temp", 4)){
444 int temp;
445 if(!strcasecmp(cmd, "temp 0")) {
b.liub171c9a2024-11-12 19:23:29 +0800446 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_SOC, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800447 if(err != MBTK_RIL_ERR_SUCCESS) {
448 printf("Error : %d\n", err);
449 } else {
450 printf("SOC : %d\n", temp);
451 }
452 } else if(!strcasecmp(cmd, "temp 1")) {
b.liub171c9a2024-11-12 19:23:29 +0800453 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_RF, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800454 if(err != MBTK_RIL_ERR_SUCCESS) {
455 printf("Error : %d\n", err);
456 } else {
457 printf("RF : %d\n", temp);
458 }
459 }
460 } else if(!strncasecmp(cmd, "cell_time", 9)){
461 char time[128] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800462 err = mbtk_cell_time_get(handle_def, time);
b.liu87afc4c2024-08-14 17:33:45 +0800463 if(err != MBTK_RIL_ERR_SUCCESS) {
464 printf("Error : %d\n", err);
465 } else {
466 printf("Cell Time : %s\n", time);
467 }
468 } else if(!strncasecmp(cmd, "sim_state", 9)){
469 mbtk_sim_state_enum sim;
b.liub171c9a2024-11-12 19:23:29 +0800470 err = mbtk_sim_state_get(handle_def, &sim);
b.liu87afc4c2024-08-14 17:33:45 +0800471 if(err != MBTK_RIL_ERR_SUCCESS) {
472 printf("Error : %d\n", err);
473 } else {
474 printf("Sim State : %d\n", sim);
475 }
476 } else if(!strncasecmp(cmd, "sim_type", 8)){
477 mbtk_sim_card_type_enum type;
b.liub171c9a2024-11-12 19:23:29 +0800478 err = mbtk_sim_type_get(handle_def, &type);
b.liu87afc4c2024-08-14 17:33:45 +0800479 if(err != MBTK_RIL_ERR_SUCCESS) {
480 printf("Error : %d\n", err);
481 } else {
482 printf("Sim Type : %d\n", type);
483 }
484 } else if(!strncasecmp(cmd, "imsi", 4)){
485 char imsi[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800486 err = mbtk_imsi_get(handle_def, imsi);
b.liu87afc4c2024-08-14 17:33:45 +0800487 if(err != MBTK_RIL_ERR_SUCCESS) {
488 printf("Error : %d\n", err);
489 } else {
490 printf("IMSI : %s\n", imsi);
491 }
492 } else if(!strncasecmp(cmd, "iccid", 5)){
493 char iccid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800494 err = mbtk_iccid_get(handle_def, iccid);
b.liu87afc4c2024-08-14 17:33:45 +0800495 if(err != MBTK_RIL_ERR_SUCCESS) {
496 printf("Error : %d\n", err);
497 } else {
498 printf("ICCID : %s\n", iccid);
499 }
500 } else if(!strncasecmp(cmd, "pn", 2)){
501 char phone_number[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800502 err = mbtk_phone_number_get(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +0800503 if(err != MBTK_RIL_ERR_SUCCESS) {
504 printf("Error : %d\n", err);
505 } else {
506 printf("Phone Number : %s\n", phone_number);
507 }
508 }
509 /*
510 printf("pin_state:Get Sim lock state.\n");
511 printf("pin_times:Get PIN/PUK last times.\n");
512 printf("pin_open <PIN>:Enable sim lock.\n");
513 printf("pin_close <PIN>:Disable sim lock.\n");
514 printf("pin_change <old_pin> <new_pin>:Change sim PIN.\n");
515 printf("pin_verify <PIN>:Verify PIN.\n");
516 printf("puk_verify <PUK> <PIN>:Verify PUK.\n");
517 */
518 else if(!strncasecmp(cmd, "pin_state", 9)){
519 int lock_state;
b.liub171c9a2024-11-12 19:23:29 +0800520 err = mbtk_sim_lock_get(handle_def, &lock_state);
b.liu87afc4c2024-08-14 17:33:45 +0800521 if(err != MBTK_RIL_ERR_SUCCESS) {
522 printf("Error : %d\n", err);
523 } else {
524 printf("PIN state : %d\n", lock_state);
525 }
526 } else if(!strncasecmp(cmd, "pin_times", 9)){
527 mbtk_pin_puk_last_times_t times;
b.liub171c9a2024-11-12 19:23:29 +0800528 err = mbtk_sim_lock_retry_times_get(handle_def, &times);
b.liu87afc4c2024-08-14 17:33:45 +0800529 if(err != MBTK_RIL_ERR_SUCCESS) {
530 printf("Error : %d\n", err);
531 } else {
532 printf("PIN/PUK retry times:%d,%d,%d,%d\n", times.p1_retry, times.p2_retry, times.puk1_retry, times.puk2_retry);
533 }
534 } else if(!strncasecmp(cmd, "pin_open", 8)){
535 mbtk_sim_lock_info_t info;
536 info.type = MBTK_SIM_LOCK_TYPE_ENABLE;
537 int count = sscanf(cmd, "pin_open %s", info.pin1);
538 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800539 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800540 if(err != MBTK_RIL_ERR_SUCCESS) {
541 printf("Error : %d\n", err);
542 } else {
543 printf("Enable sim lock success.\n");
544 }
545 }
546 } else if(!strncasecmp(cmd, "pin_close", 9)){
547 mbtk_sim_lock_info_t info;
548 info.type = MBTK_SIM_LOCK_TYPE_DISABLE;
549 int count = sscanf(cmd, "pin_close %s", info.pin1);
550 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800551 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800552 if(err != MBTK_RIL_ERR_SUCCESS) {
553 printf("Error : %d\n", err);
554 } else {
555 printf("Disable sim lock success.\n");
556 }
557 }
558 } else if(!strncasecmp(cmd, "pin_change", 10)){
559 mbtk_sim_lock_info_t info;
560 info.type = MBTK_SIM_LOCK_TYPE_CHANGE;
561 int count = sscanf(cmd, "pin_change %s %s", info.pin1, info.pin2);
562 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800563 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800564 if(err != MBTK_RIL_ERR_SUCCESS) {
565 printf("Error : %d\n", err);
566 } else {
567 printf("PIN change success.\n");
568 }
569 }
570 } else if(!strncasecmp(cmd, "pin_verify", 10)){
571 mbtk_sim_lock_info_t info;
572 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PIN;
573 int count = sscanf(cmd, "pin_verify %s", info.pin1);
574 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800575 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800576 if(err != MBTK_RIL_ERR_SUCCESS) {
577 printf("Error : %d\n", err);
578 } else {
579 printf("PIN verify success.\n");
580 }
581 }
582 } else if(!strncasecmp(cmd, "puk_verify", 10)){
583 mbtk_sim_lock_info_t info;
584 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PUK;
585 int count = sscanf(cmd, "puk_verify %s %s", info.puk, info.pin1);
586 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800587 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800588 if(err != MBTK_RIL_ERR_SUCCESS) {
589 printf("Error : %d\n", err);
590 } else {
591 printf("PUK verify success.\n");
592 }
593 }
594 } else if(!strncasecmp(cmd, "plmn", 4)){
595 mbtk_plmn_info info;
b.liub171c9a2024-11-12 19:23:29 +0800596 err = mbtk_plmn_list_get(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800597 if(err != MBTK_RIL_ERR_SUCCESS) {
598 printf("Error : %d\n", err);
599 } else {
600 printf("PLMN number:%d\n", info.count);
601 int i = 0;
602 while(i < info.count) {
603 printf("%d,%d,%s\n", i+1, info.plmn[i].format, info.plmn[i].name);
604 i++;
605 }
606 }
607 }
608 else if(!strncasecmp(cmd, "avail_net", 9)){
609 mbtk_net_info_array_t net_list;
b.liub171c9a2024-11-12 19:23:29 +0800610 err = mbtk_available_net_get(handle_1, &net_list);
b.liu87afc4c2024-08-14 17:33:45 +0800611 if(err != MBTK_RIL_ERR_SUCCESS) {
612 printf("Error : %d\n", err);
613 } else {
614 printf("Available net number:%d\n", net_list.num);
615 int i = 0;
616 while(i < net_list.num) {
617 printf("NET : %d,%d,%d,%d\n", net_list.net_info[i].net_sel_mode,
618 net_list.net_info[i].net_type, net_list.net_info[i].net_state,
619 net_list.net_info[i].plmn);
620 i++;
621 }
622 }
623 } else if(!strncasecmp(cmd, "sel_mode", 8)){ // "sel_mode" or "sel_mode 1 7 46000"
624 mbtk_net_info_t net;
625 memset(&net, 0, sizeof(mbtk_net_info_t));
626 if(!strcasecmp(cmd, "sel_mode")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800627 err = mbtk_net_sel_mode_get(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800628 if(err != MBTK_RIL_ERR_SUCCESS) {
629 printf("Error : %d\n", err);
630 } else {
631 printf("Net : %d, %d, %d, %d\n", net.net_sel_mode, net.net_type, net.net_state, net.plmn);
632 }
633 } else { // Set
634 char *ptr = strstr(cmd, " ");
635 if(ptr == NULL)
636 continue;
637 while(*ptr != '\0' && *ptr == ' ')
638 ptr++;
639 net.net_sel_mode = (uint8)atoi(ptr);
640
641 ptr = strstr(ptr, " ");
642 if(ptr == NULL)
643 continue;
644 while(*ptr != '\0' && *ptr == ' ')
645 ptr++;
646 net.net_type = (uint8)atoi(ptr);
647
648 ptr = strstr(ptr, " ");
649 if(ptr == NULL)
650 continue;
651 while(*ptr != '\0' && *ptr == ' ')
652 ptr++;
653 net.plmn = (uint32)atoi(ptr);
654
b.liub171c9a2024-11-12 19:23:29 +0800655 err = mbtk_net_sel_mode_set(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800656 if(err != MBTK_RIL_ERR_SUCCESS) {
657 printf("Error : %d\n", err);
658 } else {
659 printf("Net select mode set success\n");
660 }
661 }
662 } else if(!strncasecmp(cmd, "band", 4)){ // "band" or "band support" or "band 0 79 147 482 524503"
663 mbtk_band_info_t band;
664 memset(&band, 0x0, sizeof(mbtk_band_info_t));
665 if(!strcasecmp(cmd, "band")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800666 err = mbtk_current_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800667 if(err != MBTK_RIL_ERR_SUCCESS) {
668 printf("Error : %d\n", err);
669 } else {
670 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);
671 }
672 } else if(!strcasecmp(cmd, "band support")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800673 err = mbtk_support_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800674 if(err != MBTK_RIL_ERR_SUCCESS) {
675 printf("Error : %d\n", err);
676 } else {
677 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);
678 }
679 } else { // "band 0 79 147 482 524503"
680 char *ptr = strstr(cmd, " ");
681 if(ptr == NULL)
682 continue;
683 while(*ptr != '\0' && *ptr == ' ')
684 ptr++;
685 band.net_pref = (uint8)atoi(ptr);
686
687 ptr = strstr(ptr, " ");
688 if(ptr == NULL)
689 continue;
690 while(*ptr != '\0' && *ptr == ' ')
691 ptr++;
692 band.gsm_band = (uint16)atoi(ptr);
693
694 ptr = strstr(ptr, " ");
695 if(ptr == NULL)
696 continue;
697 while(*ptr != '\0' && *ptr == ' ')
698 ptr++;
699 band.umts_band = (uint16)atoi(ptr);
700
701 ptr = strstr(ptr, " ");
702 if(ptr == NULL)
703 continue;
704 while(*ptr != '\0' && *ptr == ' ')
705 ptr++;
706 band.tdlte_band = (uint32)atoi(ptr);
707
708 ptr = strstr(ptr, " ");
709 if(ptr == NULL)
710 continue;
711 while(*ptr != '\0' && *ptr == ' ')
712 ptr++;
713 band.fddlte_band = (uint32)atoi(ptr);
714
b.liub171c9a2024-11-12 19:23:29 +0800715 err = mbtk_current_band_set(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800716 if(err != MBTK_RIL_ERR_SUCCESS) {
717 printf("Error : %d\n", err);
718 } else {
719 printf("Band set success\n");
720 }
721 }
722 } else if(!strncasecmp(cmd, "signal", 6)){
723 mbtk_signal_info_t signal;
b.liub171c9a2024-11-12 19:23:29 +0800724 err = mbtk_net_signal_get(handle_def, &signal);
b.liu87afc4c2024-08-14 17:33:45 +0800725 if(err != MBTK_RIL_ERR_SUCCESS) {
726 printf("Error : %d\n", err);
727 } else {
728 printf("Signal : %d, %d, %d, %d, %d, %d, %d, %d\n", signal.type, signal.rssi, signal.rxlev, signal.ber,
729 signal.rscp, signal.ecno, signal.rsrq, signal.rsrp);
730 }
731 } else if(!strncasecmp(cmd, "reg", 3)){
732 mbtk_net_reg_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +0800733 err = mbtk_net_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +0800734 if(err != MBTK_RIL_ERR_SUCCESS) {
735 printf("Error : %d\n", err);
736 } else {
737 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);
738 }
739 } else if(!strncasecmp(cmd, "apn_del", 7)) {
740 mbtk_apn_info_t apn;
741 memset(&apn, 0, sizeof(mbtk_apn_info_t));
742 int cid, auto_save;
743 int count = sscanf(cmd, "apn_del %d %d", &cid, &auto_save);
744 if(count == 2) {
745 apn.cid = (mbtk_ril_cid_enum)cid;
746 apn.auto_save = (uint8)auto_save;
747 }
b.liub171c9a2024-11-12 19:23:29 +0800748 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800749 if(err != MBTK_RIL_ERR_SUCCESS) {
750 printf("Error : %d\n", err);
751 } else {
752 printf("APN delete success\n");
753 }
754
755 } else if(!strncasecmp(cmd, "apn", 3)){
756 if(!strcasecmp(cmd, "apn")) { // Get apn
757 mbtk_apn_info_array_t apns;
b.liub171c9a2024-11-12 19:23:29 +0800758 err = mbtk_apn_get(handle_def, &apns);
b.liu87afc4c2024-08-14 17:33:45 +0800759 if(err != MBTK_RIL_ERR_SUCCESS) {
760 printf("Error : %d\n", err);
761 } else {
762 printf("APN Num:%d\n", apns.num);
763 int i = 0;
764 while(i < apns.num) {
b.liu10a34102024-08-20 20:36:24 +0800765 // printf("APN : %d, %s, %s\n", apns.apns[i].cid, apn2str(apns.apns[i].ip_type), apns.apns[i].apn);
766 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),
767 apns.apns[i].auth, apns.apns[i].auto_save, apns.apns[i].auto_boot_call,
b.liu62240ee2024-11-07 17:52:45 +0800768 str_empty(apns.apns[i].apn) ? "NULL" : (char*)apns.apns[i].apn,
769 str_empty(apns.apns[i].user) ? "NULL" : (char*)apns.apns[i].user,
770 str_empty(apns.apns[i].pass) ? "NULL" : (char*)apns.apns[i].pass,
771 str_empty(apns.apns[i].type) ? "NULL" : (char*)apns.apns[i].type);
b.liu87afc4c2024-08-14 17:33:45 +0800772 i++;
773 }
b.liu10a34102024-08-20 20:36:24 +0800774 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 +0800775 }
776 } else { // apn <cid> <0/1/2/3> <0/1> <0/1> <apn>
777 mbtk_apn_info_t apn;
778 memset(&apn, 0, sizeof(mbtk_apn_info_t));
779#if 1
b.liubcf86c92024-08-19 19:48:28 +0800780 int cid, ip_type, auto_save, auto_boot_call, def_route, as_dns;
781 int count = sscanf(cmd, "apn %d %d %d %d %d %d %s",
782 &cid, &ip_type, &auto_save, &auto_boot_call,
783 &def_route, &as_dns, apn.apn);
b.liu87afc4c2024-08-14 17:33:45 +0800784
785 // Delete APN
b.liu62240ee2024-11-07 17:52:45 +0800786 if(strcmp((char*)apn.apn,"null") == 0 || strcmp((char*)apn.apn,"NULL") == 0) {
b.liu87afc4c2024-08-14 17:33:45 +0800787 memset(apn.apn, 0, sizeof(apn.apn));
788 }
b.liubcf86c92024-08-19 19:48:28 +0800789 if(count == 7) {
b.liu87afc4c2024-08-14 17:33:45 +0800790 apn.cid = (mbtk_ril_cid_enum)cid;
791 apn.ip_type = (mbtk_ip_type_enum)ip_type;
792 apn.auto_save = (uint8)auto_save;
793 apn.auto_boot_call = (uint8)auto_boot_call;
b.liubcf86c92024-08-19 19:48:28 +0800794 apn.def_route = (uint8)def_route;
795 apn.as_dns = (uint8)as_dns;
b.liu87afc4c2024-08-14 17:33:45 +0800796 }
797#else
798 char *ptr = strstr(cmd, " ");
799 if(ptr == NULL)
800 continue;
801 while(*ptr != '\0' && *ptr == ' ')
802 ptr++;
803 apn.cid = (mbtk_ril_cid_enum)atoi(ptr);
804
805 ptr = strstr(ptr, " ");
806 if(ptr == NULL)
807 continue;
808 while(*ptr != '\0' && *ptr == ' ')
809 ptr++;
810 apn.ip_type = (mbtk_ip_type_enum)atoi(ptr);
811
812 ptr = strstr(ptr, " ");
813 if(ptr == NULL)
814 continue;
815 while(*ptr != '\0' && *ptr == ' ')
816 ptr++;
817 memcpy(apn.apn, ptr, strlen(ptr));
818#endif
b.liub171c9a2024-11-12 19:23:29 +0800819 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800820 if(err != MBTK_RIL_ERR_SUCCESS) {
821 printf("Error : %d\n", err);
822 } else {
823 printf("APN set success\n");
824 }
825 }
826 }
b.liubcf86c92024-08-19 19:48:28 +0800827 else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
828 // mbtk_ril_cid_enum cid, bool auto_boot_call, bool def_route, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info
829 // data_call <0/1/2> <cid> <timeout>
830 int type, cid, auto_boot_call, def_route, as_dns;
831 int count = sscanf(cmd, "data_call %d %d %d %d %d", &type, &cid, &auto_boot_call, &def_route, &as_dns);
832 if(count != 5) {
833 count = sscanf(cmd, "data_call %d %d", &type, &cid);
834 }
835
836 if(count == 5 || count == 2) {
837 mbtk_ip_info_t ip;
838 memset(&ip, 0, sizeof(mbtk_ip_info_t));
839 if(type == MBTK_DATA_CALL_START) {
b.liu15f456b2024-10-31 20:16:06 +0800840 int retry_interval[] = {5, 10, 15};
b.liuafdf2c62024-11-12 11:10:44 +0800841 if(count == 5) {
b.liub171c9a2024-11-12 19:23:29 +0800842 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 +0800843 (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 +0800844 3, 0, &ip);
b.liuafdf2c62024-11-12 11:10:44 +0800845 } else {
b.liub171c9a2024-11-12 19:23:29 +0800846 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 +0800847 MBTK_DATA_CALL_ITEM_STATE_NON, MBTK_DATA_CALL_ITEM_STATE_NON, retry_interval,
848 3, 0, &ip);
849 }
b.liubcf86c92024-08-19 19:48:28 +0800850 } else if(type == MBTK_DATA_CALL_STOP) {
b.liub171c9a2024-11-12 19:23:29 +0800851 err = mbtk_data_call_stop(handle_def, (mbtk_ril_cid_enum)cid, 10);
b.liubcf86c92024-08-19 19:48:28 +0800852 } else {
b.liub171c9a2024-11-12 19:23:29 +0800853 err = mbtk_data_call_state_get(handle_def, (mbtk_ril_cid_enum)cid, &ip);
b.liubcf86c92024-08-19 19:48:28 +0800854 }
855 if(err) {
856 printf("Error : %d\n", err);
857 } else {
858 printf("DATA_CALL success\n");
859 if(type == MBTK_DATA_CALL_START || type == MBTK_DATA_CALL_STATE) {
860 if(ip.ipv4.valid) {
861 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
862 char ip_tmp[20];
863
864 memset(ip_tmp, 0, 20);
865 if(inet_ntop(AF_INET, &(ip.ipv4.IPAddr), ip_tmp, 20) == NULL) {
866 printf("IP error.\n");
867 } else {
868 printf("IP : %s\n", ip_tmp);
869 }
870
871 memset(ip_tmp, 0, 20);
872 if(inet_ntop(AF_INET, &(ip.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
873 printf("PrimaryDNS error.\n");
874 } else {
875 printf("PrimaryDNS : %s\n", ip_tmp);
876 }
877
878 memset(ip_tmp, 0, 20);
879 if(inet_ntop(AF_INET, &(ip.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
880 printf("SecondaryDNS error.\n");
881 } else {
882 printf("SecondaryDNS : %s\n", ip_tmp);
883 }
884
885 memset(ip_tmp, 0, 20);
886 if(inet_ntop(AF_INET, &(ip.ipv4.GateWay), ip_tmp, 20) == NULL) {
887 printf("GateWay error.\n");
888 } else {
889 printf("GateWay : %s\n", ip_tmp);
890 }
891
892 memset(ip_tmp, 0, 20);
893 if(inet_ntop(AF_INET, &(ip.ipv4.NetMask), ip_tmp, 20) == NULL) {
894 printf("NetMask error.\n");
895 } else {
896 printf("NetMask : %s\n", ip_tmp);
897 }
898 }
899
900 if(ip.ipv6.valid) {
901 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
902 char ip_tmp[50];
903
904 memset(ip_tmp, 0, 50);
905 if(ipv6_2_str(&(ip.ipv6.IPV6Addr), ip_tmp)) {
906 printf("IP error.\n");
907 } else {
908 printf("IP : %s\n", ip_tmp);
909 }
910
911 memset(ip_tmp, 0, 50);
912 if(ipv6_2_str(&(ip.ipv6.PrimaryDNS), ip_tmp)) {
913 printf("PrimaryDNS error.\n");
914 } else {
915 printf("PrimaryDNS : %s\n", ip_tmp);
916 }
917
918 memset(ip_tmp, 0, 50);
919 if(ipv6_2_str(&(ip.ipv6.SecondaryDNS), ip_tmp)) {
920 printf("SecondaryDNS error.\n");
921 } else {
922 printf("SecondaryDNS : %s\n", ip_tmp);
923 }
924
925 memset(ip_tmp, 0, 50);
926 if(ipv6_2_str(&(ip.ipv6.GateWay), ip_tmp)) {
927 printf("GateWay error.\n");
928 } else {
929 printf("GateWay : %s\n", ip_tmp);
930 }
931
932 memset(ip_tmp, 0, 50);
933 if(ipv6_2_str(&(ip.ipv6.NetMask), ip_tmp)) {
934 printf("NetMask error.\n");
935 } else {
936 printf("NetMask : %s\n", ip_tmp);
937 }
938 }
939 }
940 }
941 }
942 }
b.liu87afc4c2024-08-14 17:33:45 +0800943 else if(!strncasecmp(cmd, "cell", 4)){
944 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
945 if(ptr == NULL)
946 {
b.liub4772072024-08-15 14:47:03 +0800947 mbtk_cell_info_array_t cell;
b.liub171c9a2024-11-12 19:23:29 +0800948 err = mbtk_cell_get(handle_def, &cell);
b.liub4772072024-08-15 14:47:03 +0800949 if(err) {
b.liu87afc4c2024-08-14 17:33:45 +0800950 printf("Error : %d\n", err);
b.liub4772072024-08-15 14:47:03 +0800951 } else if(cell.num > 0){
952 // Current server cell.
953 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +0800954 {
b.liub4772072024-08-15 14:47:03 +0800955 case MBTK_CELL_TYPE_GSM:
956 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);
957 break;
958 case MBTK_CELL_TYPE_UMTS:
959 printf("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell.cell[0].value1, cell.cell[0].value2, cell.cell[0].value3);
960 break;
961 case MBTK_CELL_TYPE_LTE:
962 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);
963 break;
964 default:
965 break;
966 }
967
968 int i = 1;
969 while (i < cell.num)
970 {
971 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +0800972 {
b.liub4772072024-08-15 14:47:03 +0800973 case MBTK_CELL_TYPE_GSM:
974 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 +0800975 break;
b.liub4772072024-08-15 14:47:03 +0800976 case MBTK_CELL_TYPE_UMTS:
977 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 +0800978 break;
b.liub4772072024-08-15 14:47:03 +0800979 case MBTK_CELL_TYPE_LTE:
980 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 +0800981 break;
982 default:
983 break;
984 }
b.liub4772072024-08-15 14:47:03 +0800985 i++;
b.liu87afc4c2024-08-14 17:33:45 +0800986 }
b.liub4772072024-08-15 14:47:03 +0800987 } else {
988 printf("Cell no found.");
b.liu87afc4c2024-08-14 17:33:45 +0800989 }
b.liu87afc4c2024-08-14 17:33:45 +0800990 }
991 else{
992 char *ptr = strstr(cmd, ","); //cell,2,3,,40936,430
993 char mem[50]={0};
994 char resp[1024] = {0};
995 if(ptr != NULL)
996 {
997 ptr++;
998 memset(mem, 0, sizeof(mem));
999 memcpy(mem, ptr, strlen(ptr));
1000 printf("cell:%s\n", mem);
1001 }
1002 printf("cell_mem: %s \n", mem);
1003
1004 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001005 err = mbtk_cell_set(handle_def, mem, resp);
b.liu87afc4c2024-08-14 17:33:45 +08001006 if(err) {
1007 printf("Error : %d\n", err);
1008 } else {
1009 printf("cell set . resp:%s\n", resp);
1010 }
b.liu87afc4c2024-08-14 17:33:45 +08001011 }
b.liub4772072024-08-15 14:47:03 +08001012 }
1013 else if(!strncasecmp(cmd, "call", 4)){
b.liu87afc4c2024-08-14 17:33:45 +08001014 char phone_number[12];
1015 char *ptr = strstr(cmd, " ");
1016 if(ptr == NULL)
1017 continue;
1018 while(*ptr != '\0' && *ptr == ' ')
1019 ptr++;
1020 memset(phone_number,0,strlen(phone_number));
1021 memcpy(phone_number,ptr,strlen(ptr));
1022 printf("phone number is: %s\n",phone_number);
b.liub171c9a2024-11-12 19:23:29 +08001023 err = mbtk_call_start(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +08001024 if(err) {
1025 printf("Error : %d\n", err);
1026 } else {
1027 printf("Call success.\n");
1028 }
1029 } else if(!strncasecmp(cmd, "answer", 6)){
b.liub171c9a2024-11-12 19:23:29 +08001030 err = mbtk_call_answer(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001031 if(err) {
1032 printf("Error : %d\n", err);
1033 } else {
1034 printf("Call success.\n");
1035 }
1036 } else if(!strncasecmp(cmd, "hangup", 6)){
b.liu62240ee2024-11-07 17:52:45 +08001037 int phone_id = 1;
b.liu87afc4c2024-08-14 17:33:45 +08001038 if(!strcasecmp(cmd, "hangup")) { // hang up all
b.liub171c9a2024-11-12 19:23:29 +08001039 err = mbtk_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001040 if(err) {
1041 printf("Error : %d\n", err);
1042 } else {
1043 printf("Call hang up all.\n");
1044 }
1045 } else if(!strcasecmp(cmd, "hangup 0")) {
b.liub171c9a2024-11-12 19:23:29 +08001046 err = mbtk_waiting_or_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001047 if(err) {
1048 printf("Error : %d\n", err);
1049 } else {
1050 printf("Call hang up waiting or background.\n");
1051 }
1052 } else if(!strcasecmp(cmd, "hangup 3")) {
b.liub171c9a2024-11-12 19:23:29 +08001053 err = mbtk_foreground_resume_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001054 if(err) {
1055 printf("Error : %d\n", err);
1056 } else {
1057 printf("Call hang up foreground resume background.\n");
1058 }
1059 } else {
1060 if(!strcasecmp(cmd, "hangup 1")) { // hang up a call
1061 phone_id = 1;
1062 } else if(!strcasecmp(cmd, "hangup 2")) {
1063 phone_id = 2;
1064 } else {
1065 printf("Error : Invalid input\n");
1066 }
b.liub171c9a2024-11-12 19:23:29 +08001067 err = mbtk_a_call_hang(handle_def, phone_id);
b.liu87afc4c2024-08-14 17:33:45 +08001068 if(err) {
1069 printf("Error : %d\n", err);
1070 } else {
1071 printf("A Call hang up.\n");
1072 }
1073 }
1074 } else if(!strncasecmp(cmd, "waitin", 6)){
1075 mbtk_call_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +08001076 err = mbtk_call_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001077 if(err) {
1078 printf("Error : %d\n", err);
1079 } else {
1080 if(reg.call_wait == 0) {
1081 printf("No call ring\n");
1082 }
1083 else {
1084 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);
1085 }
1086 }
1087 } else if(!strncasecmp(cmd, "mute", 4)){ // "mute" or "mute 0" or "mute 1"
1088 int mute;
1089 if(!strcasecmp(cmd, "mute")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001090 err = mbtk_mute_state_get(handle_def, &mute);
b.liu87afc4c2024-08-14 17:33:45 +08001091 if(err) {
1092 printf("Error : %d\n", err);
1093 } else {
1094 printf("mute : %d\n", mute);
1095 }
1096 } else { // Set
1097 if(!strcasecmp(cmd, "mute 1")) { // on mute
1098 mute = 1;
1099 } else { // off mute
1100 mute = 0;
1101 }
b.liub171c9a2024-11-12 19:23:29 +08001102 err = mbtk_mute_state_set(handle_def, mute);
b.liu87afc4c2024-08-14 17:33:45 +08001103 if(err) {
1104 printf("Error : %d\n", err);
1105 } else {
1106 printf("mute set success\n");
1107 }
1108 }
1109 } else if(!strncasecmp(cmd, "DTMF", 4)){ // valid character: (0, 1, ..., 9, A, B, C, D, *, #)
1110
1111 mbtk_call_dtmf_info_t reg;
1112
1113 char *ptr = strstr(cmd, " ");
1114 if(ptr == NULL)
1115 continue;
1116 while(*ptr != '\0' && *ptr == ' ')
1117 ptr++;
1118 reg.character = *ptr;
1119
1120 ptr = strstr(ptr, " ");
1121 if(ptr == NULL)
1122 continue;
1123 while(*ptr != '\0' && *ptr == ' ')
1124 ptr++;
1125 reg.duration = (uint32)atoi(ptr);
1126 printf("DTMF character is: %c,%d\n",reg.character, reg.duration);
b.liub171c9a2024-11-12 19:23:29 +08001127 err = mbtk_dtmf_send(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001128 if(err) {
1129 printf("Error : %d\n", err);
1130 } else {
1131 printf("DTMF success.\n");
1132 }
b.liub4772072024-08-15 14:47:03 +08001133 } else if(!strncasecmp(cmd, "cmgf", 4)){ // set mode 0: pud, 1:text
1134 int mode;
1135 if(!strcasecmp(cmd, "cmgf")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001136 err = mbtk_sms_cmgf_get(handle_def, &mode);
b.liub4772072024-08-15 14:47:03 +08001137 if(err) {
1138 printf("Error : %d\n", err);
1139 } else {
1140 printf("VoLTE : %d\n", mode);
1141 }
1142 } else { // Set
1143 if(!strcasecmp(cmd, "cmgf 1")) { // cmgf 1
1144 mode = 1;
1145 } else { //
1146 mode = 0;
1147 }
1148 printf("mode:%d\n", mode);
1149 sleep(2);
b.liub171c9a2024-11-12 19:23:29 +08001150 err = mbtk_sms_cmgf_set(handle_def, mode);
b.liub4772072024-08-15 14:47:03 +08001151 if(err) {
1152 printf("Error : %d\n", err);
1153 } else {
1154 printf("VoLTE set success\n");
1155 }
1156 }
1157 }else if(!strncasecmp(cmd, "cpms", 4)){ // //CPMS=ME, ME, ME
1158 char mem[100] = {0};
1159 char resp[100] = {0};
1160 if(!strcasecmp(cmd, "cpms")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001161 err = mbtk_sms_cpms_get(handle_def, mem);
b.liub4772072024-08-15 14:47:03 +08001162 if(err) {
1163 printf("Error : %d\n", err);
1164 } else {
1165 printf("cpms : %s\n", mem);
1166 }
1167 } else { // Set
1168
1169 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1170 if(ptr != NULL)
1171 {
1172 ptr++;
1173 memset(mem, 0, sizeof(mem));
1174 memcpy(mem, ptr, strlen(ptr));
1175 printf("cpms:%s\n", mem);
1176 }
1177 printf("cpms 0\n");
1178
1179 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001180 err = mbtk_sms_cpms_set(handle_def, mem, resp);
b.liub4772072024-08-15 14:47:03 +08001181 if(err) {
1182 printf("Error : %d\n", err);
1183 } else {
1184 printf("cpms set success. resp:%s\n", resp);
1185 }
1186 }
1187 }else if(!strncasecmp(cmd, "cmgs", 4)){ // AT+CMGS="10086", CMGS TEST
1188 char cmgs[1024] = {0};
1189 char resp[50] = {0};
1190 if(!strcasecmp(cmd, "cmgs")) { // Get
1191 int mode;
1192 // err = mbtk_sms_cmgs_get(info_handle, &mode);
1193 if(err) {
1194 printf("Error : %d\n", err);
1195 } else {
1196 printf("VoLTE : %d\n", mode);
1197 }
1198 } else { // Set
1199
1200 /*
1201 *AT+CMGS="10086", CMGS TEST // Send a SMS
1202 > CMGS TEST
1203 +CMGS: 17
1204 OK
1205 */
1206
1207 char *ptr = strstr(cmd, "cmgs,"); //CMGS="10086",hf
1208 if(ptr != NULL)
1209 {
1210 ptr = strstr(cmd, ",");
1211 ptr++;
1212 memset(cmgs, 0, sizeof(cmgs));
1213 memcpy(cmgs, ptr, strlen(ptr));
1214 printf("1cmgs:%s, strlen(cmgs):%d\n", cmgs, strlen(cmgs));
1215 }
1216
1217 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001218 err = mbtk_sms_cmgs_set(handle_def, cmgs, resp);
b.liub4772072024-08-15 14:47:03 +08001219 if(err) {
1220 printf("Error : %d\n", err);
1221 } else {
1222 printf("cmgs set success . resp:%s\n", resp);
1223 }
1224 }
1225 }else if(!strncasecmp(cmd, "cmss", 4)){ // +CMSS=<index>[,<da>[,<toda>]]
1226 char cmss[20] = {0};
1227 char resp[20] = {0};
1228 if(!strcasecmp(cmd, "cmgs")) { // Get
1229 printf("cmss : OK\n");
1230
1231 } else {
1232 char *ptr = strstr(cmd, "cmss,"); //CMSS=<index>
1233 if(ptr != NULL)
1234 {
1235 ptr = strstr(cmd, ",");
1236 ptr++;
1237 memset(cmss, 0, sizeof(cmss));
1238 memcpy(cmss, ptr, strlen(ptr));
1239 printf("1cmss:%s\n", cmss);
1240 }
1241
1242
b.liub171c9a2024-11-12 19:23:29 +08001243 err = mbtk_sms_cmss_set(handle_def, cmss, resp);
b.liub4772072024-08-15 14:47:03 +08001244 if(err) {
1245 printf("Error : %d\n", err);
1246 } else {
1247 printf("cmss set success. resp:%s\n", resp);
1248 }
1249 }
1250 }
1251 else if(!strncasecmp(cmd, "cmgr", 4)){ // +CMGR=<index
1252 int index = 0;
1253 char resp[1024] = {0};
1254 if(!strcasecmp(cmd, "cmgr")) { // Get
1255 printf("cmgr : OK\n");
1256
1257 } else {
1258 char *ptr = strstr(cmd, "cmgr,"); //+CMGR <index>
1259 if(ptr != NULL)
1260 {
1261 ptr = strstr(cmd, ",");
1262 ptr++;
1263 index = atoi(ptr);
1264 }
1265 printf("1index:%d\n", index);
1266
1267 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001268 err = mbtk_sms_cmgr_set(handle_def, index, resp);
b.liub4772072024-08-15 14:47:03 +08001269 if(err) {
1270 printf("Error : %d\n", err);
1271 } else {
1272 printf("cmgr set success. rep:%s\n", resp);
1273 }
1274 }
1275 }
1276 else if(!strncasecmp(cmd, "cmgw", 4)){ // +CMGW=<oa/da>[,<tooa/toda>[,<stat>]]<CR>
1277 //+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
1278 char cmgw[128] = {0};
1279 char resp[50] = {0};
1280 if(!strcasecmp(cmd, "cmgw")) { // Get
1281 printf("cmgw : OK\n");
1282
1283 } else {
1284 char *ptr = strstr(cmd, "cmgw,"); //+CMGW, <oa/da>, data
1285 if(ptr != NULL)
1286 {
1287 ptr = strstr(cmd, ",");
1288 ptr++;
1289 memset(cmgw, 0, sizeof(cmgw));
1290 memcpy(cmgw, ptr, strlen(ptr));
1291 printf("cmgw:%s\n", cmgw);
1292 }
1293
1294 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001295 err = mbtk_sms_cmgw_set(handle_def, cmgw, resp);
b.liub4772072024-08-15 14:47:03 +08001296 if(err) {
1297 printf("Error : %d\n", err);
1298 } else {
1299 printf("cmgw set success. resp:%s\n", resp);
1300 }
1301 }
1302 }
1303 else if(!strncasecmp(cmd, "cmgd", 4)){ // +CMGD=<index>[,<delflag>
1304 //
1305 char cmgd[128] = {0};
1306 if(!strcasecmp(cmd, "cmgd")) { // Get
1307 printf("cmgd : OK\n");
1308
1309 } else {
1310 char *ptr = strstr(cmd, ","); //+CMGD=<index>[,<delflag>
1311 if(ptr != NULL)
1312 {
1313 ptr++;
1314 memset(cmgd, 0, sizeof(cmgd));
1315 memcpy(cmgd, ptr, strlen(ptr));
1316 printf("1cmgd:%s\n", cmgd);
1317 }
1318
1319
b.liub171c9a2024-11-12 19:23:29 +08001320 err = mbtk_sms_cmgd_set(handle_def, cmgd);
b.liub4772072024-08-15 14:47:03 +08001321 if(err) {
1322 printf("Error : %d\n", err);
1323 } else {
1324 printf("VoLTE set success\n");
1325 }
1326 }
1327 }
1328 else if(!strncasecmp(cmd, "cmgl", 4)){ // AT+CMGL[=<stat>]
1329 //
1330 char cmgl[128] = {0};
1331 char resp[5*1024] ={0};
1332 if(!strcasecmp(cmd, "cmgl")) { // Get
1333 printf("cmgl : OK\n");
1334
1335 } else {
1336 char *ptr = strstr(cmd, "cmgl,"); // AT+CMGL[=<stat>]
1337 if(ptr != NULL)
1338 {
1339 ptr = strstr(cmd, ",");
1340 ptr++;
1341 memset(cmgl, 0, sizeof(cmgl));
1342 memcpy(cmgl, ptr, strlen(ptr));
1343 printf("0cmgl:%s\n", cmgl);
1344 }
1345
1346 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001347 err = mbtk_sms_cmgl_set(handle_def, cmgl, resp);
b.liub4772072024-08-15 14:47:03 +08001348 if(err) {
1349 printf("Error : %d\n", err);
1350 } else {
1351 // printf("cmgl set success, reg:%s\n",resp);
1352 }
1353 }
1354 }
1355 else if(!strncasecmp(cmd, "csca", 4)){ // AT+CSCA=<number> [,<type>]
1356 //
1357 char csca[128] = {0};
1358 if(!strcasecmp(cmd, "csca")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001359 err = mbtk_sms_csca_get(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001360 if(err) {
1361 printf("mbtk_sms_csca_get Error : %d\n", err);
1362 } else {
1363 printf("mbtk_sms_csca_get success\n");
1364 }
1365
1366 } else {
1367 char *ptr = strstr(cmd, ","); // AT+CSCA=<number> [,<type>]
1368 if(ptr != NULL)
1369 {
1370 ptr++;
1371 memset(csca, 0, sizeof(csca));
1372 memcpy(csca, ptr, strlen(ptr));
1373 printf("csca:%s\n", csca);
1374 }
1375
b.liub171c9a2024-11-12 19:23:29 +08001376 err = mbtk_sms_csca_set(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001377 if(err) {
1378 printf("Error : %d\n", err);
1379 } else {
1380 printf("VoLTE set success\n");
1381 }
1382 }
1383 }
1384 else if(!strncasecmp(cmd, "csmp", 4)){ // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1385 //
1386 char csmp[128] = {0};
1387 if(!strcasecmp(cmd, "csmp")) { // Get
1388 printf("cmgl : OK\n");
1389
1390 } else {
1391 char *ptr = strstr(cmd, ","); // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1392 if(ptr != NULL)
1393 {
1394 ptr++;
1395 memset(csmp, 0, sizeof(csmp));
1396 memcpy(csmp, ptr, strlen(ptr));
1397 printf("csmp:%s\n", csmp);
1398 }
1399
b.liub171c9a2024-11-12 19:23:29 +08001400 err = mbtk_sms_csmp_set(handle_def, csmp);
b.liub4772072024-08-15 14:47:03 +08001401 if(err) {
1402 printf("Error : %d\n", err);
1403 } else {
1404 printf("VoLTE set success\n");
1405 }
1406 }
1407 }
1408 else if(!strncasecmp(cmd, "cscb", 4)){ // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1409 //
1410 char cscb[128] = {0};
1411 if(!strcasecmp(cmd, "cscb")) { // Get
1412 printf("cmgl : OK\n");
1413
1414 } else {
1415 char *ptr = strstr(cmd, ","); // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1416 if(ptr != NULL)
1417 {
1418 ptr++;
1419 memset(cscb, 0, sizeof(cscb));
1420 memcpy(cscb, ptr, strlen(ptr));
1421 printf("cscb:%s\n", cscb);
1422 }
1423
b.liub171c9a2024-11-12 19:23:29 +08001424 err = mbtk_sms_cscb_set(handle_def, cscb);
b.liub4772072024-08-15 14:47:03 +08001425 if(err) {
1426 printf("Error : %d\n", err);
1427 } else {
1428 printf("VoLTE set success\n");
1429 }
1430 }
1431 }
1432#if 0
1433 else if(!strncasecmp(cmd, "shutdown", 8)){
b.liu87afc4c2024-08-14 17:33:45 +08001434 if(!strcasecmp(cmd, "shutdown 0")) {
1435 err = mbtk_system_reboot(0);
1436 if(err) {
1437 printf("Error : %d\n", err);
1438 } else {
1439 printf("Success.\n");
1440 }
1441 } else if(!strcasecmp(cmd, "shutdown 1")) {
1442 err = mbtk_system_reboot(1);
1443 if(err) {
1444 printf("Error : %d\n", err);
1445 } else {
1446 printf("Success.\n");
1447 }
1448 } else if(!strcasecmp(cmd, "shutdown 2")) {
1449 err = mbtk_system_reboot(2);
1450 if(err) {
1451 printf("Error : %d\n", err);
1452 } else {
1453 printf("Success.\n");
1454 }
1455 } else {
1456 printf("Error.");
1457 }
1458 } else if(!strncasecmp(cmd, "power_sim", 9)){
1459 if(!strcasecmp(cmd, "power_sim 0")) {
1460 err = mbtk_sim_power_set(0);
1461 if(err) {
1462 printf("Error : %d\n", err);
1463 } else {
1464 printf("Success.\n");
1465 }
1466 } else if(!strcasecmp(cmd, "power_sim 1")) {
1467 err = mbtk_sim_power_set(1);
1468 if(err) {
1469 printf("Error : %d\n", err);
1470 } else {
1471 printf("Success.\n");
1472 }
1473 } else {
1474 printf("Error.");
1475 }
1476 } else if(!strncasecmp(cmd, "time", 4)){
1477 if(!strcasecmp(cmd, "time 0")) {
1478 err = mbtk_time_set(info_handle, 0, NULL);
1479 if(err) {
1480 printf("Error : %d\n", err);
1481 } else {
1482 printf("Success.\n");
1483 }
1484 } else if(!strcasecmp(cmd, "time 1")) {
1485 err = mbtk_time_set(info_handle, 1, NULL);
1486 if(err) {
1487 printf("Error : %d\n", err);
1488 } else {
1489 printf("Success.\n");
1490 }
1491 } else if(!strncasecmp(cmd, "time 2 ", 7)) {
1492 err = mbtk_time_set(info_handle, 2, cmd + 7);
1493 if(err) {
1494 printf("Error : %d\n", err);
1495 } else {
1496 printf("Success.\n");
1497 }
1498 } else { // Get time type.
1499 int time_type;
1500 err = mbtk_time_get(info_handle, &time_type);
1501 if(err) {
1502 printf("Error : %d\n", err);
1503 } else {
1504 printf("Time type:%d.\n", time_type);
1505 }
1506 }
b.liu87afc4c2024-08-14 17:33:45 +08001507 }
1508#endif
1509 else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
1510 help();
1511 } else if(!strcasecmp(cmd, "q")) {
b.liub171c9a2024-11-12 19:23:29 +08001512 mbtk_ril_close(MBTK_AT_PORT_DEF);
1513 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +08001514 break;
1515 } else {
1516 printf("\n");
1517 }
1518 }
1519 }
1520
b.liu62240ee2024-11-07 17:52:45 +08001521#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +08001522 thread_exit_with_wait();
b.liu87afc4c2024-08-14 17:33:45 +08001523exit:
b.liu62240ee2024-11-07 17:52:45 +08001524#endif
b.liub171c9a2024-11-12 19:23:29 +08001525 mbtk_ril_close(MBTK_AT_PORT_DEF);
1526 mbtk_ril_close(ATPORTTYPE_1);
1527
b.liu87afc4c2024-08-14 17:33:45 +08001528
1529 LOG("Client exec complete.");
1530
1531 return 0;
1532}