blob: 83d05b237ef288229085478bc0ff9a1e52d2ed2a [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");
b.liu571445f2025-02-13 10:22:55 +080064 printf("band support: Get support bands.\n");
65 printf("band <net_pref> <gsm_band> <umts_band> <tdlte_band> <fddlte_band>: Set current bands.\n");
b.liu87afc4c2024-08-14 17:33:45 +080066 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;
b.liu571445f2025-02-13 10:22:55 +0800126 printf("net reg state change : type - %d, tech - %d, reg_state - %d\n", state->type,
127 state->tech, state->reg_state);
b.liu15f456b2024-10-31 20:16:06 +0800128 }
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{
b.liuaced4f92024-12-31 11:14:51 +0800142 if(data) {
143 mbtk_ril_sms_state_info_t *state = (mbtk_ril_sms_state_info_t*)data;
144 printf("SMS PDU(%d) : %s\n", state->pdu_len, state->pdu);
145 }
b.liu15f456b2024-10-31 20:16:06 +0800146}
147
148static void radio_state_change_cb(const void* data, int data_len)
149{
150 if(data) {
151 mbtk_ril_radio_state_info_t *state = (mbtk_ril_radio_state_info_t*)data;
152 printf("radio state change : %d\n", state->radio_state);
153 }
154}
155
156static void sim_state_change_cb(const void* data, int data_len)
157{
158 if(data) {
159 mbtk_ril_sim_state_info_t *state = (mbtk_ril_sim_state_info_t*)data;
160 printf("sim state change : type - %d, state - %d\n", state->sim_type, state->sim_state);
161 }
162}
163
164static void pdp_state_change_cb(const void* data, int data_len)
165{
166 if(data) {
167 mbtk_ril_pdp_state_info_t *state = (mbtk_ril_pdp_state_info_t*)data;
168 printf("pdp state change : cid - %d, action - %d, reason-%d, auto_change - %d\n",
169 state->cid, state->action, state->reason, state->auto_change);
b.liufd87baf2024-11-15 15:30:38 +0800170 if(state->ip_info_valid) {
171 if(state->ip_info.ipv4.valid) {
172 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
173 char ip_tmp[20];
174
175 memset(ip_tmp, 0, 20);
176 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.IPAddr), ip_tmp, 20) == NULL) {
177 printf("IP error.\n");
178 } else {
179 printf("IP : %s\n", ip_tmp);
180 }
181
182 memset(ip_tmp, 0, 20);
183 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
184 printf("PrimaryDNS error.\n");
185 } else {
186 printf("PrimaryDNS : %s\n", ip_tmp);
187 }
188
189 memset(ip_tmp, 0, 20);
190 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
191 printf("SecondaryDNS error.\n");
192 } else {
193 printf("SecondaryDNS : %s\n", ip_tmp);
194 }
195
196 memset(ip_tmp, 0, 20);
197 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.GateWay), ip_tmp, 20) == NULL) {
198 printf("GateWay error.\n");
199 } else {
200 printf("GateWay : %s\n", ip_tmp);
201 }
202
203 memset(ip_tmp, 0, 20);
204 if(inet_ntop(AF_INET, &(state->ip_info.ipv4.NetMask), ip_tmp, 20) == NULL) {
205 printf("NetMask error.\n");
206 } else {
207 printf("NetMask : %s\n", ip_tmp);
208 }
209 }
210
211 if(state->ip_info.ipv6.valid) {
212 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
213 char ip_tmp[50];
214
215 memset(ip_tmp, 0, 50);
216 if(ipv6_2_str(&(state->ip_info.ipv6.IPV6Addr), ip_tmp)) {
217 printf("IP error.\n");
218 } else {
219 printf("IP : %s\n", ip_tmp);
220 }
221
222 memset(ip_tmp, 0, 50);
223 if(ipv6_2_str(&(state->ip_info.ipv6.PrimaryDNS), ip_tmp)) {
224 printf("PrimaryDNS error.\n");
225 } else {
226 printf("PrimaryDNS : %s\n", ip_tmp);
227 }
228
229 memset(ip_tmp, 0, 50);
230 if(ipv6_2_str(&(state->ip_info.ipv6.SecondaryDNS), ip_tmp)) {
231 printf("SecondaryDNS error.\n");
232 } else {
233 printf("SecondaryDNS : %s\n", ip_tmp);
234 }
235
236 memset(ip_tmp, 0, 50);
237 if(ipv6_2_str(&(state->ip_info.ipv6.GateWay), ip_tmp)) {
238 printf("GateWay error.\n");
239 } else {
240 printf("GateWay : %s\n", ip_tmp);
241 }
242
243 memset(ip_tmp, 0, 50);
244 if(ipv6_2_str(&(state->ip_info.ipv6.NetMask), ip_tmp)) {
245 printf("NetMask error.\n");
246 } else {
247 printf("NetMask : %s\n", ip_tmp);
248 }
249 }
250 }
b.liu15f456b2024-10-31 20:16:06 +0800251 }
252}
253
254static void signal_state_change_cb(const void* data, int data_len)
255{
256
257}
258
259static void ecall_state_change_cb(const void* data, int data_len)
260{
261 if(data)
262 {
263 mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
264 printf("ecall state change : urc_id - %d, urc_data - %s\n", ecall_data->urc_id, ecall_data->urc_data);
265 }
266}
267
268
b.liu87afc4c2024-08-14 17:33:45 +0800269static void sig_process(int sig)
270{
271 LOGI("I got signal %d\n", sig);
272 switch(sig)
273 {
274 case SIGINT: // Ctrl + C
275 {
276 LOGI("Exit by SIGINT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800277#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800278 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800279#endif
b.liub171c9a2024-11-12 19:23:29 +0800280 mbtk_ril_close(MBTK_AT_PORT_DEF);
281 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800282 exit(0);
283 }
284 case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
285 {
286 LOGI("Exit by SIGQUIT.\n");
b.liu62240ee2024-11-07 17:52:45 +0800287#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800288 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800289#endif
b.liub171c9a2024-11-12 19:23:29 +0800290 mbtk_ril_close(MBTK_AT_PORT_DEF);
291 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800292 exit(0);
293 }
294 case SIGTERM:// 默认kill (同 SIGKILL ,但 SIGKILL 不可捕获)
295 {
296 LOGI("Exit by SIGTERM.\n");
b.liu62240ee2024-11-07 17:52:45 +0800297#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800298 thread_exit_with_wait();
b.liu62240ee2024-11-07 17:52:45 +0800299#endif
b.liub171c9a2024-11-12 19:23:29 +0800300 mbtk_ril_close(MBTK_AT_PORT_DEF);
301 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +0800302 exit(0);
303 }
304 case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
305 {
306 LOGI("Exit by SIGTSTP.\n");
307 exit(0);
308 }
309 case SIGSEGV: // 如空指针
310 {
311 LOGI("Exit by SIGSEGV.\n");
312 exit(0);
313 }
314 default:
315 {
316 LOGI("Unknown sig:%d\n",sig);
317 break;
318 }
319 }
320}
321
b.liu62240ee2024-11-07 17:52:45 +0800322#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800323static char* thread_id2name(pthread_t pid)
324{
325 int i = 0;
326 while(i < CLI_THREAD_MAX) {
327 if(pid == cli_threads[i].pid) {
328 return cli_threads[i].name;
329 }
330 i++;
331 }
332
333 return "UNKNOWN";
334}
335
336static void* sub_thread_run(void *arg)
337{
338 ril_cli_thread_info_t *cli = (ril_cli_thread_info_t*)arg;
339 cli->pid = pthread_self();
340 cli->is_running = TRUE;
341 sprintf(cli->name, "PID-%d", cli_pid_index++);
342
343 printf("[%s] enter.\n", thread_id2name(cli->pid));
344 while(cli->is_running) {
345 srand((int)(time(0) + cli->pid));
346 int time_sec = 1 + (int)(10.0 * rand() / ( RAND_MAX + 1.0));
347 char version[50] = {0};
348 mbtk_ril_err_enum err = mbtk_version_get(version);
349 if(err != MBTK_RIL_ERR_SUCCESS) {
350 printf("[%s : %ds]Error : %d\n", thread_id2name(cli->pid), time_sec, err);
351 } else {
352 printf("[%s : %ds]Version : %s\n", thread_id2name(cli->pid), time_sec, version);
353 }
354
355 sleep(time_sec);
356 }
357 printf("[%s] exit.\n", thread_id2name(cli->pid));
358 return NULL;
359}
b.liu62240ee2024-11-07 17:52:45 +0800360#endif
b.liu87afc4c2024-08-14 17:33:45 +0800361
362int main(int argc, char *argv[])
363{
364 signal(SIGINT, sig_process);
365 signal(SIGQUIT, sig_process);
366 signal(SIGTERM, sig_process);
367 //signal(SIGTSTP, sig_process);
368 //signal(SIGSEGV, sig_process);
369
370 mbtk_log_init("radio","RIL_CLI");
371
372#ifdef MBTK_DUMP_SUPPORT
373 mbtk_debug_open(NULL, TRUE);
374#endif
375
376 //test2(0, "192.168.1.198");
377 //test2(1, "2409:8162:140:cd3c:1:2:1494:72ba");
378 //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
379 //test2(1, "2400:3200::1");
380
b.liub171c9a2024-11-12 19:23:29 +0800381 mbtk_ril_handle* handle_def = mbtk_ril_open(MBTK_AT_PORT_DEF);
382 if(handle_def == NULL) {
383 printf("mbtk_ril_open(MBTK_AT_PORT_DEF/ATPORTTYPE_0) fail.");
384 return -1;
385 }
386
387 mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
388 if(handle_1 == NULL) {
389 printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
b.liu87afc4c2024-08-14 17:33:45 +0800390 return -1;
391 }
392
b.liu15f456b2024-10-31 20:16:06 +0800393 mbtk_ril_ser_state_change_cb_reg(ril_ser_state_change_cb);
394
395 mbtk_net_reg_state_change_cb_reg(net_reg_state_change_cb);
396
397 mbtk_call_state_change_cb_reg(call_state_change_cb);
398
399 mbtk_sms_state_change_cb_reg(sms_state_change_cb);
400
401 mbtk_radio_state_change_cb_reg(radio_state_change_cb);
402
403 mbtk_sim_state_change_cb_reg(sim_state_change_cb);
404
405 mbtk_pdp_state_change_cb_reg(pdp_state_change_cb);
406
407 mbtk_signal_state_change_cb_reg(signal_state_change_cb);
408
409 mbtk_ecall_state_change_cb_reg(ecall_state_change_cb);
410
b.liu62240ee2024-11-07 17:52:45 +0800411#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +0800412 memset(cli_threads, 0, sizeof(ril_cli_thread_info_t) * CLI_THREAD_MAX);
413
414 pthread_t pid1, pid2, pid3;
415 if(pthread_create(&pid1, NULL, sub_thread_run, &cli_threads[0]))
416 {
417 printf("pthread_create() fail.");
418 goto exit;
419 }
420
421 if(pthread_create(&pid2, NULL, sub_thread_run, &cli_threads[1]))
422 {
423 printf("pthread_create() fail.");
424 goto exit;
425 }
426
427 if(pthread_create(&pid3, NULL, sub_thread_run, &cli_threads[2]))
428 {
429 printf("pthread_create() fail.");
430 goto exit;
431 }
432#endif
433 printf(">>>>>>>>>>>>>>>>>>>>>>>>Enter cmd:\n");
434 char cmd[100];
435 while(1)
436 {
437 memset(cmd, 0, 100);
438 mbtk_ril_err_enum err;
439 if(fgets(cmd, 100, stdin))
440 {
441 char *ptr = cmd + strlen(cmd) - 1;
442 while(ptr >= cmd && (*ptr == '\r' || *ptr == '\n'))
443 {
444 *ptr-- = '\0';
445 }
446 if(!strncasecmp(cmd, "version", 7))
447 {
448 char version[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800449 err = mbtk_version_get(handle_def, version);
b.liu87afc4c2024-08-14 17:33:45 +0800450 if(err != MBTK_RIL_ERR_SUCCESS) {
451 printf("Error : %d\n", err);
452 } else {
453 printf("Version : %s\n", version);
454 }
455 }
456 else if(!strncasecmp(cmd, "imei", 4)){
457 char imei[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800458 err = mbtk_imei_get(handle_def, imei);
b.liu87afc4c2024-08-14 17:33:45 +0800459 if(err != MBTK_RIL_ERR_SUCCESS) {
460 printf("Error : %d\n", err);
461 } else {
462 printf("IMEI : %s\n", imei);
463 }
464 } else if(!strncasecmp(cmd, "sn", 2)){
465 char sn[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800466 err = mbtk_sn_get(handle_def, sn);
b.liu87afc4c2024-08-14 17:33:45 +0800467 if(err != MBTK_RIL_ERR_SUCCESS) {
468 printf("Error : %d\n", err);
469 } else {
470 printf("SN : %s\n", sn);
471 }
472 } else if(!strncasecmp(cmd, "meid", 4)){
473 char meid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800474 err = mbtk_meid_get(handle_def, meid);
b.liu87afc4c2024-08-14 17:33:45 +0800475 if(err != MBTK_RIL_ERR_SUCCESS) {
476 printf("Error : %d\n", err);
477 } else {
478 printf("MEID : %s\n", meid);
479 }
480 } else if(!strncasecmp(cmd, "volte", 5)){ // "volte" or "volte 0" or "volte 1"
481 int volte;
482 if(!strcasecmp(cmd, "volte")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800483 err = mbtk_volte_state_get(handle_def, &volte);
b.liu87afc4c2024-08-14 17:33:45 +0800484 if(err != MBTK_RIL_ERR_SUCCESS) {
485 printf("Error : %d\n", err);
486 } else {
487 printf("VoLTE : %d\n", volte);
488 }
489 } else { // Set
490 if(!strcasecmp(cmd, "volte 1")) { // Open VoLTE
491 volte = 1;
492 } else { // Close VoLTE
493 volte = 0;
494 }
b.liub171c9a2024-11-12 19:23:29 +0800495 err = mbtk_volte_state_set(handle_def, volte);
b.liu87afc4c2024-08-14 17:33:45 +0800496 if(err != MBTK_RIL_ERR_SUCCESS) {
497 printf("Error : %d\n", err);
498 } else {
499 printf("VoLTE set success\n");
500 }
501 }
502 } else if(!strncasecmp(cmd, "radio", 5)){ // "radio" or "radio 0" or "radio 1"
503 mbtk_radio_state_enum radio;
504 if(!strcasecmp(cmd, "radio")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800505 err = mbtk_radio_state_get(handle_def, &radio);
b.liu87afc4c2024-08-14 17:33:45 +0800506 if(err != MBTK_RIL_ERR_SUCCESS) {
507 printf("Error : %d\n", err);
508 } else {
509 printf("Radio : %d\n", radio);
510 }
511 } else { // Set
512 int reset;
513 int count = sscanf(cmd, "radio %d %d", &radio, &reset);
514 if(count > 0) {
515 if(count == 1) {
516 reset = 0;
517 }
518
b.liub171c9a2024-11-12 19:23:29 +0800519 err = mbtk_radio_state_set(handle_def, radio, reset);
b.liu87afc4c2024-08-14 17:33:45 +0800520 if(err != MBTK_RIL_ERR_SUCCESS) {
521 printf("Error : %d\n", err);
522 } else {
523 printf("Radio set success\n");
524 }
525 }
526 }
527 } else if(!strncasecmp(cmd, "temp", 4)){
528 int temp;
529 if(!strcasecmp(cmd, "temp 0")) {
b.liub171c9a2024-11-12 19:23:29 +0800530 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_SOC, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800531 if(err != MBTK_RIL_ERR_SUCCESS) {
532 printf("Error : %d\n", err);
533 } else {
534 printf("SOC : %d\n", temp);
535 }
536 } else if(!strcasecmp(cmd, "temp 1")) {
b.liub171c9a2024-11-12 19:23:29 +0800537 err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_RF, &temp);
b.liu87afc4c2024-08-14 17:33:45 +0800538 if(err != MBTK_RIL_ERR_SUCCESS) {
539 printf("Error : %d\n", err);
540 } else {
541 printf("RF : %d\n", temp);
542 }
543 }
544 } else if(!strncasecmp(cmd, "cell_time", 9)){
545 char time[128] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800546 err = mbtk_cell_time_get(handle_def, time);
b.liu87afc4c2024-08-14 17:33:45 +0800547 if(err != MBTK_RIL_ERR_SUCCESS) {
548 printf("Error : %d\n", err);
549 } else {
550 printf("Cell Time : %s\n", time);
551 }
552 } else if(!strncasecmp(cmd, "sim_state", 9)){
553 mbtk_sim_state_enum sim;
b.liub171c9a2024-11-12 19:23:29 +0800554 err = mbtk_sim_state_get(handle_def, &sim);
b.liu87afc4c2024-08-14 17:33:45 +0800555 if(err != MBTK_RIL_ERR_SUCCESS) {
556 printf("Error : %d\n", err);
557 } else {
558 printf("Sim State : %d\n", sim);
559 }
560 } else if(!strncasecmp(cmd, "sim_type", 8)){
561 mbtk_sim_card_type_enum type;
b.liub171c9a2024-11-12 19:23:29 +0800562 err = mbtk_sim_type_get(handle_def, &type);
b.liu87afc4c2024-08-14 17:33:45 +0800563 if(err != MBTK_RIL_ERR_SUCCESS) {
564 printf("Error : %d\n", err);
565 } else {
566 printf("Sim Type : %d\n", type);
567 }
568 } else if(!strncasecmp(cmd, "imsi", 4)){
569 char imsi[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800570 err = mbtk_imsi_get(handle_def, imsi);
b.liu87afc4c2024-08-14 17:33:45 +0800571 if(err != MBTK_RIL_ERR_SUCCESS) {
572 printf("Error : %d\n", err);
573 } else {
574 printf("IMSI : %s\n", imsi);
575 }
576 } else if(!strncasecmp(cmd, "iccid", 5)){
577 char iccid[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800578 err = mbtk_iccid_get(handle_def, iccid);
b.liu87afc4c2024-08-14 17:33:45 +0800579 if(err != MBTK_RIL_ERR_SUCCESS) {
580 printf("Error : %d\n", err);
581 } else {
582 printf("ICCID : %s\n", iccid);
583 }
584 } else if(!strncasecmp(cmd, "pn", 2)){
585 char phone_number[50] = {0};
b.liub171c9a2024-11-12 19:23:29 +0800586 err = mbtk_phone_number_get(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +0800587 if(err != MBTK_RIL_ERR_SUCCESS) {
588 printf("Error : %d\n", err);
589 } else {
590 printf("Phone Number : %s\n", phone_number);
591 }
592 }
593 /*
594 printf("pin_state:Get Sim lock state.\n");
595 printf("pin_times:Get PIN/PUK last times.\n");
596 printf("pin_open <PIN>:Enable sim lock.\n");
597 printf("pin_close <PIN>:Disable sim lock.\n");
598 printf("pin_change <old_pin> <new_pin>:Change sim PIN.\n");
599 printf("pin_verify <PIN>:Verify PIN.\n");
600 printf("puk_verify <PUK> <PIN>:Verify PUK.\n");
601 */
602 else if(!strncasecmp(cmd, "pin_state", 9)){
603 int lock_state;
b.liub171c9a2024-11-12 19:23:29 +0800604 err = mbtk_sim_lock_get(handle_def, &lock_state);
b.liu87afc4c2024-08-14 17:33:45 +0800605 if(err != MBTK_RIL_ERR_SUCCESS) {
606 printf("Error : %d\n", err);
607 } else {
608 printf("PIN state : %d\n", lock_state);
609 }
610 } else if(!strncasecmp(cmd, "pin_times", 9)){
611 mbtk_pin_puk_last_times_t times;
b.liub171c9a2024-11-12 19:23:29 +0800612 err = mbtk_sim_lock_retry_times_get(handle_def, &times);
b.liu87afc4c2024-08-14 17:33:45 +0800613 if(err != MBTK_RIL_ERR_SUCCESS) {
614 printf("Error : %d\n", err);
615 } else {
616 printf("PIN/PUK retry times:%d,%d,%d,%d\n", times.p1_retry, times.p2_retry, times.puk1_retry, times.puk2_retry);
617 }
618 } else if(!strncasecmp(cmd, "pin_open", 8)){
619 mbtk_sim_lock_info_t info;
620 info.type = MBTK_SIM_LOCK_TYPE_ENABLE;
621 int count = sscanf(cmd, "pin_open %s", info.pin1);
622 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800623 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800624 if(err != MBTK_RIL_ERR_SUCCESS) {
625 printf("Error : %d\n", err);
626 } else {
627 printf("Enable sim lock success.\n");
628 }
629 }
630 } else if(!strncasecmp(cmd, "pin_close", 9)){
631 mbtk_sim_lock_info_t info;
632 info.type = MBTK_SIM_LOCK_TYPE_DISABLE;
633 int count = sscanf(cmd, "pin_close %s", info.pin1);
634 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800635 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800636 if(err != MBTK_RIL_ERR_SUCCESS) {
637 printf("Error : %d\n", err);
638 } else {
639 printf("Disable sim lock success.\n");
640 }
641 }
642 } else if(!strncasecmp(cmd, "pin_change", 10)){
643 mbtk_sim_lock_info_t info;
644 info.type = MBTK_SIM_LOCK_TYPE_CHANGE;
645 int count = sscanf(cmd, "pin_change %s %s", info.pin1, info.pin2);
646 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800647 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800648 if(err != MBTK_RIL_ERR_SUCCESS) {
649 printf("Error : %d\n", err);
650 } else {
651 printf("PIN change success.\n");
652 }
653 }
654 } else if(!strncasecmp(cmd, "pin_verify", 10)){
655 mbtk_sim_lock_info_t info;
656 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PIN;
657 int count = sscanf(cmd, "pin_verify %s", info.pin1);
658 if(count == 1) {
b.liub171c9a2024-11-12 19:23:29 +0800659 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800660 if(err != MBTK_RIL_ERR_SUCCESS) {
661 printf("Error : %d\n", err);
662 } else {
663 printf("PIN verify success.\n");
664 }
665 }
666 } else if(!strncasecmp(cmd, "puk_verify", 10)){
667 mbtk_sim_lock_info_t info;
668 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PUK;
669 int count = sscanf(cmd, "puk_verify %s %s", info.puk, info.pin1);
670 if(count == 2) {
b.liub171c9a2024-11-12 19:23:29 +0800671 err = mbtk_sim_lock_set(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800672 if(err != MBTK_RIL_ERR_SUCCESS) {
673 printf("Error : %d\n", err);
674 } else {
675 printf("PUK verify success.\n");
676 }
677 }
678 } else if(!strncasecmp(cmd, "plmn", 4)){
679 mbtk_plmn_info info;
b.liub171c9a2024-11-12 19:23:29 +0800680 err = mbtk_plmn_list_get(handle_def, &info);
b.liu87afc4c2024-08-14 17:33:45 +0800681 if(err != MBTK_RIL_ERR_SUCCESS) {
682 printf("Error : %d\n", err);
683 } else {
684 printf("PLMN number:%d\n", info.count);
685 int i = 0;
686 while(i < info.count) {
687 printf("%d,%d,%s\n", i+1, info.plmn[i].format, info.plmn[i].name);
688 i++;
689 }
690 }
691 }
692 else if(!strncasecmp(cmd, "avail_net", 9)){
693 mbtk_net_info_array_t net_list;
b.liub171c9a2024-11-12 19:23:29 +0800694 err = mbtk_available_net_get(handle_1, &net_list);
b.liu87afc4c2024-08-14 17:33:45 +0800695 if(err != MBTK_RIL_ERR_SUCCESS) {
696 printf("Error : %d\n", err);
697 } else {
698 printf("Available net number:%d\n", net_list.num);
699 int i = 0;
700 while(i < net_list.num) {
701 printf("NET : %d,%d,%d,%d\n", net_list.net_info[i].net_sel_mode,
702 net_list.net_info[i].net_type, net_list.net_info[i].net_state,
703 net_list.net_info[i].plmn);
704 i++;
705 }
706 }
707 } else if(!strncasecmp(cmd, "sel_mode", 8)){ // "sel_mode" or "sel_mode 1 7 46000"
708 mbtk_net_info_t net;
709 memset(&net, 0, sizeof(mbtk_net_info_t));
710 if(!strcasecmp(cmd, "sel_mode")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800711 err = mbtk_net_sel_mode_get(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800712 if(err != MBTK_RIL_ERR_SUCCESS) {
713 printf("Error : %d\n", err);
714 } else {
715 printf("Net : %d, %d, %d, %d\n", net.net_sel_mode, net.net_type, net.net_state, net.plmn);
716 }
717 } else { // Set
718 char *ptr = strstr(cmd, " ");
719 if(ptr == NULL)
720 continue;
721 while(*ptr != '\0' && *ptr == ' ')
722 ptr++;
723 net.net_sel_mode = (uint8)atoi(ptr);
724
725 ptr = strstr(ptr, " ");
726 if(ptr == NULL)
727 continue;
728 while(*ptr != '\0' && *ptr == ' ')
729 ptr++;
730 net.net_type = (uint8)atoi(ptr);
731
732 ptr = strstr(ptr, " ");
733 if(ptr == NULL)
734 continue;
735 while(*ptr != '\0' && *ptr == ' ')
736 ptr++;
737 net.plmn = (uint32)atoi(ptr);
738
b.liub171c9a2024-11-12 19:23:29 +0800739 err = mbtk_net_sel_mode_set(handle_def, &net);
b.liu87afc4c2024-08-14 17:33:45 +0800740 if(err != MBTK_RIL_ERR_SUCCESS) {
741 printf("Error : %d\n", err);
742 } else {
743 printf("Net select mode set success\n");
744 }
745 }
746 } else if(!strncasecmp(cmd, "band", 4)){ // "band" or "band support" or "band 0 79 147 482 524503"
747 mbtk_band_info_t band;
748 memset(&band, 0x0, sizeof(mbtk_band_info_t));
749 if(!strcasecmp(cmd, "band")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800750 err = mbtk_current_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800751 if(err != MBTK_RIL_ERR_SUCCESS) {
752 printf("Error : %d\n", err);
753 } else {
b.liu571445f2025-02-13 10:22:55 +0800754 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);
b.liu87afc4c2024-08-14 17:33:45 +0800755 }
b.liu571445f2025-02-13 10:22:55 +0800756 } else if(!strcasecmp(cmd, "band support")) { // Get
b.liub171c9a2024-11-12 19:23:29 +0800757 err = mbtk_support_band_get(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800758 if(err != MBTK_RIL_ERR_SUCCESS) {
759 printf("Error : %d\n", err);
760 } else {
b.liu571445f2025-02-13 10:22:55 +0800761 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);
b.liu87afc4c2024-08-14 17:33:45 +0800762 }
b.liu571445f2025-02-13 10:22:55 +0800763 } else { // "band 0 79 147 482 524503"
b.liu87afc4c2024-08-14 17:33:45 +0800764 char *ptr = strstr(cmd, " ");
765 if(ptr == NULL)
766 continue;
767 while(*ptr != '\0' && *ptr == ' ')
768 ptr++;
769 band.net_pref = (uint8)atoi(ptr);
770
771 ptr = strstr(ptr, " ");
772 if(ptr == NULL)
773 continue;
774 while(*ptr != '\0' && *ptr == ' ')
775 ptr++;
776 band.gsm_band = (uint16)atoi(ptr);
777
778 ptr = strstr(ptr, " ");
779 if(ptr == NULL)
780 continue;
781 while(*ptr != '\0' && *ptr == ' ')
782 ptr++;
783 band.umts_band = (uint16)atoi(ptr);
784
785 ptr = strstr(ptr, " ");
786 if(ptr == NULL)
787 continue;
788 while(*ptr != '\0' && *ptr == ' ')
789 ptr++;
790 band.tdlte_band = (uint32)atoi(ptr);
791
792 ptr = strstr(ptr, " ");
793 if(ptr == NULL)
794 continue;
795 while(*ptr != '\0' && *ptr == ' ')
796 ptr++;
797 band.fddlte_band = (uint32)atoi(ptr);
798
b.liub171c9a2024-11-12 19:23:29 +0800799 err = mbtk_current_band_set(handle_def, &band);
b.liu87afc4c2024-08-14 17:33:45 +0800800 if(err != MBTK_RIL_ERR_SUCCESS) {
801 printf("Error : %d\n", err);
802 } else {
803 printf("Band set success\n");
804 }
805 }
806 } else if(!strncasecmp(cmd, "signal", 6)){
807 mbtk_signal_info_t signal;
b.liub171c9a2024-11-12 19:23:29 +0800808 err = mbtk_net_signal_get(handle_def, &signal);
b.liu87afc4c2024-08-14 17:33:45 +0800809 if(err != MBTK_RIL_ERR_SUCCESS) {
810 printf("Error : %d\n", err);
811 } else {
b.liu571445f2025-02-13 10:22:55 +0800812 printf("Signal : %d, %d, %d, %d, %d, %d, %d, %d\n", signal.type, signal.rssi, signal.rxlev, signal.ber,
813 signal.rscp, signal.ecno, signal.rsrq, signal.rsrp);
b.liu87afc4c2024-08-14 17:33:45 +0800814 }
815 } else if(!strncasecmp(cmd, "reg", 3)){
816 mbtk_net_reg_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +0800817 err = mbtk_net_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +0800818 if(err != MBTK_RIL_ERR_SUCCESS) {
819 printf("Error : %d\n", err);
820 } else {
b.liu571445f2025-02-13 10:22:55 +0800821 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);
b.liu87afc4c2024-08-14 17:33:45 +0800822 }
823 } else if(!strncasecmp(cmd, "apn_del", 7)) {
824 mbtk_apn_info_t apn;
825 memset(&apn, 0, sizeof(mbtk_apn_info_t));
826 int cid, auto_save;
827 int count = sscanf(cmd, "apn_del %d %d", &cid, &auto_save);
828 if(count == 2) {
829 apn.cid = (mbtk_ril_cid_enum)cid;
830 apn.auto_save = (uint8)auto_save;
831 }
b.liub171c9a2024-11-12 19:23:29 +0800832 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800833 if(err != MBTK_RIL_ERR_SUCCESS) {
834 printf("Error : %d\n", err);
835 } else {
836 printf("APN delete success\n");
837 }
838
839 } else if(!strncasecmp(cmd, "apn", 3)){
840 if(!strcasecmp(cmd, "apn")) { // Get apn
841 mbtk_apn_info_array_t apns;
b.liub171c9a2024-11-12 19:23:29 +0800842 err = mbtk_apn_get(handle_def, &apns);
b.liu87afc4c2024-08-14 17:33:45 +0800843 if(err != MBTK_RIL_ERR_SUCCESS) {
844 printf("Error : %d\n", err);
845 } else {
846 printf("APN Num:%d\n", apns.num);
847 int i = 0;
848 while(i < apns.num) {
b.liu10a34102024-08-20 20:36:24 +0800849 // printf("APN : %d, %s, %s\n", apns.apns[i].cid, apn2str(apns.apns[i].ip_type), apns.apns[i].apn);
850 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),
851 apns.apns[i].auth, apns.apns[i].auto_save, apns.apns[i].auto_boot_call,
b.liu62240ee2024-11-07 17:52:45 +0800852 str_empty(apns.apns[i].apn) ? "NULL" : (char*)apns.apns[i].apn,
853 str_empty(apns.apns[i].user) ? "NULL" : (char*)apns.apns[i].user,
854 str_empty(apns.apns[i].pass) ? "NULL" : (char*)apns.apns[i].pass,
855 str_empty(apns.apns[i].type) ? "NULL" : (char*)apns.apns[i].type);
b.liu87afc4c2024-08-14 17:33:45 +0800856 i++;
857 }
b.liu10a34102024-08-20 20:36:24 +0800858 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 +0800859 }
860 } else { // apn <cid> <0/1/2/3> <0/1> <0/1> <apn>
861 mbtk_apn_info_t apn;
862 memset(&apn, 0, sizeof(mbtk_apn_info_t));
863#if 1
b.liubcf86c92024-08-19 19:48:28 +0800864 int cid, ip_type, auto_save, auto_boot_call, def_route, as_dns;
865 int count = sscanf(cmd, "apn %d %d %d %d %d %d %s",
866 &cid, &ip_type, &auto_save, &auto_boot_call,
867 &def_route, &as_dns, apn.apn);
b.liu87afc4c2024-08-14 17:33:45 +0800868
869 // Delete APN
b.liu62240ee2024-11-07 17:52:45 +0800870 if(strcmp((char*)apn.apn,"null") == 0 || strcmp((char*)apn.apn,"NULL") == 0) {
b.liu87afc4c2024-08-14 17:33:45 +0800871 memset(apn.apn, 0, sizeof(apn.apn));
872 }
b.liubcf86c92024-08-19 19:48:28 +0800873 if(count == 7) {
b.liu87afc4c2024-08-14 17:33:45 +0800874 apn.cid = (mbtk_ril_cid_enum)cid;
875 apn.ip_type = (mbtk_ip_type_enum)ip_type;
876 apn.auto_save = (uint8)auto_save;
877 apn.auto_boot_call = (uint8)auto_boot_call;
b.liubcf86c92024-08-19 19:48:28 +0800878 apn.def_route = (uint8)def_route;
879 apn.as_dns = (uint8)as_dns;
b.liu87afc4c2024-08-14 17:33:45 +0800880 }
881#else
882 char *ptr = strstr(cmd, " ");
883 if(ptr == NULL)
884 continue;
885 while(*ptr != '\0' && *ptr == ' ')
886 ptr++;
887 apn.cid = (mbtk_ril_cid_enum)atoi(ptr);
888
889 ptr = strstr(ptr, " ");
890 if(ptr == NULL)
891 continue;
892 while(*ptr != '\0' && *ptr == ' ')
893 ptr++;
894 apn.ip_type = (mbtk_ip_type_enum)atoi(ptr);
895
896 ptr = strstr(ptr, " ");
897 if(ptr == NULL)
898 continue;
899 while(*ptr != '\0' && *ptr == ' ')
900 ptr++;
901 memcpy(apn.apn, ptr, strlen(ptr));
902#endif
b.liub171c9a2024-11-12 19:23:29 +0800903 err = mbtk_apn_set(handle_def, &apn);
b.liu87afc4c2024-08-14 17:33:45 +0800904 if(err != MBTK_RIL_ERR_SUCCESS) {
905 printf("Error : %d\n", err);
906 } else {
907 printf("APN set success\n");
908 }
909 }
910 }
b.liubcf86c92024-08-19 19:48:28 +0800911 else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
912 // mbtk_ril_cid_enum cid, bool auto_boot_call, bool def_route, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info
913 // data_call <0/1/2> <cid> <timeout>
914 int type, cid, auto_boot_call, def_route, as_dns;
915 int count = sscanf(cmd, "data_call %d %d %d %d %d", &type, &cid, &auto_boot_call, &def_route, &as_dns);
916 if(count != 5) {
917 count = sscanf(cmd, "data_call %d %d", &type, &cid);
918 }
919
920 if(count == 5 || count == 2) {
921 mbtk_ip_info_t ip;
922 memset(&ip, 0, sizeof(mbtk_ip_info_t));
923 if(type == MBTK_DATA_CALL_START) {
b.liu15f456b2024-10-31 20:16:06 +0800924 int retry_interval[] = {5, 10, 15};
b.liuafdf2c62024-11-12 11:10:44 +0800925 if(count == 5) {
b.liub171c9a2024-11-12 19:23:29 +0800926 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 +0800927 (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 +0800928 3, 0, &ip);
b.liuafdf2c62024-11-12 11:10:44 +0800929 } else {
b.liub171c9a2024-11-12 19:23:29 +0800930 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 +0800931 MBTK_DATA_CALL_ITEM_STATE_NON, MBTK_DATA_CALL_ITEM_STATE_NON, retry_interval,
932 3, 0, &ip);
933 }
b.liubcf86c92024-08-19 19:48:28 +0800934 } else if(type == MBTK_DATA_CALL_STOP) {
b.liub171c9a2024-11-12 19:23:29 +0800935 err = mbtk_data_call_stop(handle_def, (mbtk_ril_cid_enum)cid, 10);
b.liubcf86c92024-08-19 19:48:28 +0800936 } else {
b.liub171c9a2024-11-12 19:23:29 +0800937 err = mbtk_data_call_state_get(handle_def, (mbtk_ril_cid_enum)cid, &ip);
b.liubcf86c92024-08-19 19:48:28 +0800938 }
939 if(err) {
940 printf("Error : %d\n", err);
941 } else {
942 printf("DATA_CALL success\n");
943 if(type == MBTK_DATA_CALL_START || type == MBTK_DATA_CALL_STATE) {
944 if(ip.ipv4.valid) {
945 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
946 char ip_tmp[20];
947
948 memset(ip_tmp, 0, 20);
949 if(inet_ntop(AF_INET, &(ip.ipv4.IPAddr), ip_tmp, 20) == NULL) {
950 printf("IP error.\n");
951 } else {
952 printf("IP : %s\n", ip_tmp);
953 }
954
955 memset(ip_tmp, 0, 20);
956 if(inet_ntop(AF_INET, &(ip.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
957 printf("PrimaryDNS error.\n");
958 } else {
959 printf("PrimaryDNS : %s\n", ip_tmp);
960 }
961
962 memset(ip_tmp, 0, 20);
963 if(inet_ntop(AF_INET, &(ip.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
964 printf("SecondaryDNS error.\n");
965 } else {
966 printf("SecondaryDNS : %s\n", ip_tmp);
967 }
968
969 memset(ip_tmp, 0, 20);
970 if(inet_ntop(AF_INET, &(ip.ipv4.GateWay), ip_tmp, 20) == NULL) {
971 printf("GateWay error.\n");
972 } else {
973 printf("GateWay : %s\n", ip_tmp);
974 }
975
976 memset(ip_tmp, 0, 20);
977 if(inet_ntop(AF_INET, &(ip.ipv4.NetMask), ip_tmp, 20) == NULL) {
978 printf("NetMask error.\n");
979 } else {
980 printf("NetMask : %s\n", ip_tmp);
981 }
982 }
983
984 if(ip.ipv6.valid) {
985 // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
986 char ip_tmp[50];
987
988 memset(ip_tmp, 0, 50);
989 if(ipv6_2_str(&(ip.ipv6.IPV6Addr), ip_tmp)) {
990 printf("IP error.\n");
991 } else {
992 printf("IP : %s\n", ip_tmp);
993 }
994
995 memset(ip_tmp, 0, 50);
996 if(ipv6_2_str(&(ip.ipv6.PrimaryDNS), ip_tmp)) {
997 printf("PrimaryDNS error.\n");
998 } else {
999 printf("PrimaryDNS : %s\n", ip_tmp);
1000 }
1001
1002 memset(ip_tmp, 0, 50);
1003 if(ipv6_2_str(&(ip.ipv6.SecondaryDNS), ip_tmp)) {
1004 printf("SecondaryDNS error.\n");
1005 } else {
1006 printf("SecondaryDNS : %s\n", ip_tmp);
1007 }
1008
1009 memset(ip_tmp, 0, 50);
1010 if(ipv6_2_str(&(ip.ipv6.GateWay), ip_tmp)) {
1011 printf("GateWay error.\n");
1012 } else {
1013 printf("GateWay : %s\n", ip_tmp);
1014 }
1015
1016 memset(ip_tmp, 0, 50);
1017 if(ipv6_2_str(&(ip.ipv6.NetMask), ip_tmp)) {
1018 printf("NetMask error.\n");
1019 } else {
1020 printf("NetMask : %s\n", ip_tmp);
1021 }
1022 }
1023 }
1024 }
1025 }
1026 }
b.liu87afc4c2024-08-14 17:33:45 +08001027 else if(!strncasecmp(cmd, "cell", 4)){
1028 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1029 if(ptr == NULL)
1030 {
b.liub4772072024-08-15 14:47:03 +08001031 mbtk_cell_info_array_t cell;
b.liub171c9a2024-11-12 19:23:29 +08001032 err = mbtk_cell_get(handle_def, &cell);
b.liub4772072024-08-15 14:47:03 +08001033 if(err) {
b.liu87afc4c2024-08-14 17:33:45 +08001034 printf("Error : %d\n", err);
b.liub4772072024-08-15 14:47:03 +08001035 } else if(cell.num > 0){
1036 // Current server cell.
1037 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +08001038 {
b.liub4772072024-08-15 14:47:03 +08001039 case MBTK_CELL_TYPE_GSM:
1040 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);
1041 break;
1042 case MBTK_CELL_TYPE_UMTS:
1043 printf("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell.cell[0].value1, cell.cell[0].value2, cell.cell[0].value3);
1044 break;
1045 case MBTK_CELL_TYPE_LTE:
1046 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);
1047 break;
1048 default:
1049 break;
1050 }
1051
1052 int i = 1;
1053 while (i < cell.num)
1054 {
1055 switch(cell.type)
b.liu87afc4c2024-08-14 17:33:45 +08001056 {
b.liub4772072024-08-15 14:47:03 +08001057 case MBTK_CELL_TYPE_GSM:
1058 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 +08001059 break;
b.liub4772072024-08-15 14:47:03 +08001060 case MBTK_CELL_TYPE_UMTS:
1061 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 +08001062 break;
b.liub4772072024-08-15 14:47:03 +08001063 case MBTK_CELL_TYPE_LTE:
1064 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 +08001065 break;
1066 default:
1067 break;
1068 }
b.liub4772072024-08-15 14:47:03 +08001069 i++;
b.liu87afc4c2024-08-14 17:33:45 +08001070 }
b.liub4772072024-08-15 14:47:03 +08001071 } else {
1072 printf("Cell no found.");
b.liu87afc4c2024-08-14 17:33:45 +08001073 }
b.liu87afc4c2024-08-14 17:33:45 +08001074 }
1075 else{
1076 char *ptr = strstr(cmd, ","); //cell,2,3,,40936,430
1077 char mem[50]={0};
1078 char resp[1024] = {0};
1079 if(ptr != NULL)
1080 {
1081 ptr++;
1082 memset(mem, 0, sizeof(mem));
1083 memcpy(mem, ptr, strlen(ptr));
1084 printf("cell:%s\n", mem);
1085 }
1086 printf("cell_mem: %s \n", mem);
1087
1088 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001089 err = mbtk_cell_set(handle_def, mem, resp);
b.liu87afc4c2024-08-14 17:33:45 +08001090 if(err) {
1091 printf("Error : %d\n", err);
1092 } else {
1093 printf("cell set . resp:%s\n", resp);
1094 }
b.liu87afc4c2024-08-14 17:33:45 +08001095 }
b.liub4772072024-08-15 14:47:03 +08001096 }
1097 else if(!strncasecmp(cmd, "call", 4)){
b.liu87afc4c2024-08-14 17:33:45 +08001098 char phone_number[12];
1099 char *ptr = strstr(cmd, " ");
1100 if(ptr == NULL)
1101 continue;
1102 while(*ptr != '\0' && *ptr == ' ')
1103 ptr++;
1104 memset(phone_number,0,strlen(phone_number));
1105 memcpy(phone_number,ptr,strlen(ptr));
1106 printf("phone number is: %s\n",phone_number);
b.liub171c9a2024-11-12 19:23:29 +08001107 err = mbtk_call_start(handle_def, phone_number);
b.liu87afc4c2024-08-14 17:33:45 +08001108 if(err) {
1109 printf("Error : %d\n", err);
1110 } else {
1111 printf("Call success.\n");
1112 }
1113 } else if(!strncasecmp(cmd, "answer", 6)){
b.liub171c9a2024-11-12 19:23:29 +08001114 err = mbtk_call_answer(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001115 if(err) {
1116 printf("Error : %d\n", err);
1117 } else {
1118 printf("Call success.\n");
1119 }
1120 } else if(!strncasecmp(cmd, "hangup", 6)){
b.liu62240ee2024-11-07 17:52:45 +08001121 int phone_id = 1;
b.liu87afc4c2024-08-14 17:33:45 +08001122 if(!strcasecmp(cmd, "hangup")) { // hang up all
b.liub171c9a2024-11-12 19:23:29 +08001123 err = mbtk_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001124 if(err) {
1125 printf("Error : %d\n", err);
1126 } else {
1127 printf("Call hang up all.\n");
1128 }
1129 } else if(!strcasecmp(cmd, "hangup 0")) {
b.liub171c9a2024-11-12 19:23:29 +08001130 err = mbtk_waiting_or_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001131 if(err) {
1132 printf("Error : %d\n", err);
1133 } else {
1134 printf("Call hang up waiting or background.\n");
1135 }
1136 } else if(!strcasecmp(cmd, "hangup 3")) {
b.liub171c9a2024-11-12 19:23:29 +08001137 err = mbtk_foreground_resume_background_call_hang(handle_def);
b.liu87afc4c2024-08-14 17:33:45 +08001138 if(err) {
1139 printf("Error : %d\n", err);
1140 } else {
1141 printf("Call hang up foreground resume background.\n");
1142 }
1143 } else {
1144 if(!strcasecmp(cmd, "hangup 1")) { // hang up a call
1145 phone_id = 1;
1146 } else if(!strcasecmp(cmd, "hangup 2")) {
1147 phone_id = 2;
1148 } else {
1149 printf("Error : Invalid input\n");
1150 }
b.liub171c9a2024-11-12 19:23:29 +08001151 err = mbtk_a_call_hang(handle_def, phone_id);
b.liu87afc4c2024-08-14 17:33:45 +08001152 if(err) {
1153 printf("Error : %d\n", err);
1154 } else {
1155 printf("A Call hang up.\n");
1156 }
1157 }
1158 } else if(!strncasecmp(cmd, "waitin", 6)){
1159 mbtk_call_info_t reg;
b.liub171c9a2024-11-12 19:23:29 +08001160 err = mbtk_call_reg_get(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001161 if(err) {
1162 printf("Error : %d\n", err);
1163 } else {
1164 if(reg.call_wait == 0) {
1165 printf("No call ring\n");
1166 }
1167 else {
1168 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);
1169 }
1170 }
1171 } else if(!strncasecmp(cmd, "mute", 4)){ // "mute" or "mute 0" or "mute 1"
1172 int mute;
1173 if(!strcasecmp(cmd, "mute")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001174 err = mbtk_mute_state_get(handle_def, &mute);
b.liu87afc4c2024-08-14 17:33:45 +08001175 if(err) {
1176 printf("Error : %d\n", err);
1177 } else {
1178 printf("mute : %d\n", mute);
1179 }
1180 } else { // Set
1181 if(!strcasecmp(cmd, "mute 1")) { // on mute
1182 mute = 1;
1183 } else { // off mute
1184 mute = 0;
1185 }
b.liub171c9a2024-11-12 19:23:29 +08001186 err = mbtk_mute_state_set(handle_def, mute);
b.liu87afc4c2024-08-14 17:33:45 +08001187 if(err) {
1188 printf("Error : %d\n", err);
1189 } else {
1190 printf("mute set success\n");
1191 }
1192 }
1193 } else if(!strncasecmp(cmd, "DTMF", 4)){ // valid character: (0, 1, ..., 9, A, B, C, D, *, #)
1194
1195 mbtk_call_dtmf_info_t reg;
1196
1197 char *ptr = strstr(cmd, " ");
1198 if(ptr == NULL)
1199 continue;
1200 while(*ptr != '\0' && *ptr == ' ')
1201 ptr++;
1202 reg.character = *ptr;
1203
1204 ptr = strstr(ptr, " ");
1205 if(ptr == NULL)
1206 continue;
1207 while(*ptr != '\0' && *ptr == ' ')
1208 ptr++;
1209 reg.duration = (uint32)atoi(ptr);
1210 printf("DTMF character is: %c,%d\n",reg.character, reg.duration);
b.liub171c9a2024-11-12 19:23:29 +08001211 err = mbtk_dtmf_send(handle_def, &reg);
b.liu87afc4c2024-08-14 17:33:45 +08001212 if(err) {
1213 printf("Error : %d\n", err);
1214 } else {
1215 printf("DTMF success.\n");
1216 }
b.liub4772072024-08-15 14:47:03 +08001217 } else if(!strncasecmp(cmd, "cmgf", 4)){ // set mode 0: pud, 1:text
1218 int mode;
1219 if(!strcasecmp(cmd, "cmgf")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001220 err = mbtk_sms_cmgf_get(handle_def, &mode);
b.liub4772072024-08-15 14:47:03 +08001221 if(err) {
1222 printf("Error : %d\n", err);
1223 } else {
1224 printf("VoLTE : %d\n", mode);
1225 }
1226 } else { // Set
1227 if(!strcasecmp(cmd, "cmgf 1")) { // cmgf 1
1228 mode = 1;
1229 } else { //
1230 mode = 0;
1231 }
1232 printf("mode:%d\n", mode);
1233 sleep(2);
b.liub171c9a2024-11-12 19:23:29 +08001234 err = mbtk_sms_cmgf_set(handle_def, mode);
b.liub4772072024-08-15 14:47:03 +08001235 if(err) {
1236 printf("Error : %d\n", err);
1237 } else {
1238 printf("VoLTE set success\n");
1239 }
1240 }
1241 }else if(!strncasecmp(cmd, "cpms", 4)){ // //CPMS=ME, ME, ME
1242 char mem[100] = {0};
1243 char resp[100] = {0};
1244 if(!strcasecmp(cmd, "cpms")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001245 err = mbtk_sms_cpms_get(handle_def, mem);
b.liub4772072024-08-15 14:47:03 +08001246 if(err) {
1247 printf("Error : %d\n", err);
1248 } else {
1249 printf("cpms : %s\n", mem);
1250 }
1251 } else { // Set
1252
1253 char *ptr = strstr(cmd, ","); //CPMS,ME,ME,ME
1254 if(ptr != NULL)
1255 {
1256 ptr++;
1257 memset(mem, 0, sizeof(mem));
1258 memcpy(mem, ptr, strlen(ptr));
1259 printf("cpms:%s\n", mem);
1260 }
1261 printf("cpms 0\n");
1262
1263 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001264 err = mbtk_sms_cpms_set(handle_def, mem, resp);
b.liub4772072024-08-15 14:47:03 +08001265 if(err) {
1266 printf("Error : %d\n", err);
1267 } else {
1268 printf("cpms set success. resp:%s\n", resp);
1269 }
1270 }
1271 }else if(!strncasecmp(cmd, "cmgs", 4)){ // AT+CMGS="10086", CMGS TEST
1272 char cmgs[1024] = {0};
1273 char resp[50] = {0};
1274 if(!strcasecmp(cmd, "cmgs")) { // Get
b.liudeb8e422024-12-14 17:36:56 +08001275 int mode = 0;
1276 err = 0;
b.liub4772072024-08-15 14:47:03 +08001277 // err = mbtk_sms_cmgs_get(info_handle, &mode);
1278 if(err) {
1279 printf("Error : %d\n", err);
1280 } else {
1281 printf("VoLTE : %d\n", mode);
1282 }
1283 } else { // Set
1284
1285 /*
1286 *AT+CMGS="10086", CMGS TEST // Send a SMS
1287 > CMGS TEST
1288 +CMGS: 17
1289 OK
1290 */
1291
1292 char *ptr = strstr(cmd, "cmgs,"); //CMGS="10086",hf
1293 if(ptr != NULL)
1294 {
1295 ptr = strstr(cmd, ",");
1296 ptr++;
1297 memset(cmgs, 0, sizeof(cmgs));
1298 memcpy(cmgs, ptr, strlen(ptr));
1299 printf("1cmgs:%s, strlen(cmgs):%d\n", cmgs, strlen(cmgs));
1300 }
1301
1302 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001303 err = mbtk_sms_cmgs_set(handle_def, cmgs, resp);
b.liub4772072024-08-15 14:47:03 +08001304 if(err) {
1305 printf("Error : %d\n", err);
1306 } else {
1307 printf("cmgs set success . resp:%s\n", resp);
1308 }
1309 }
1310 }else if(!strncasecmp(cmd, "cmss", 4)){ // +CMSS=<index>[,<da>[,<toda>]]
1311 char cmss[20] = {0};
1312 char resp[20] = {0};
1313 if(!strcasecmp(cmd, "cmgs")) { // Get
1314 printf("cmss : OK\n");
1315
1316 } else {
1317 char *ptr = strstr(cmd, "cmss,"); //CMSS=<index>
1318 if(ptr != NULL)
1319 {
1320 ptr = strstr(cmd, ",");
1321 ptr++;
1322 memset(cmss, 0, sizeof(cmss));
1323 memcpy(cmss, ptr, strlen(ptr));
1324 printf("1cmss:%s\n", cmss);
1325 }
1326
1327
b.liub171c9a2024-11-12 19:23:29 +08001328 err = mbtk_sms_cmss_set(handle_def, cmss, resp);
b.liub4772072024-08-15 14:47:03 +08001329 if(err) {
1330 printf("Error : %d\n", err);
1331 } else {
1332 printf("cmss set success. resp:%s\n", resp);
1333 }
1334 }
1335 }
1336 else if(!strncasecmp(cmd, "cmgr", 4)){ // +CMGR=<index
1337 int index = 0;
1338 char resp[1024] = {0};
1339 if(!strcasecmp(cmd, "cmgr")) { // Get
1340 printf("cmgr : OK\n");
1341
1342 } else {
1343 char *ptr = strstr(cmd, "cmgr,"); //+CMGR <index>
1344 if(ptr != NULL)
1345 {
1346 ptr = strstr(cmd, ",");
1347 ptr++;
1348 index = atoi(ptr);
1349 }
1350 printf("1index:%d\n", index);
1351
1352 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001353 err = mbtk_sms_cmgr_set(handle_def, index, resp);
b.liub4772072024-08-15 14:47:03 +08001354 if(err) {
1355 printf("Error : %d\n", err);
1356 } else {
1357 printf("cmgr set success. rep:%s\n", resp);
1358 }
1359 }
1360 }
1361 else if(!strncasecmp(cmd, "cmgw", 4)){ // +CMGW=<oa/da>[,<tooa/toda>[,<stat>]]<CR>
1362 //+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
1363 char cmgw[128] = {0};
1364 char resp[50] = {0};
1365 if(!strcasecmp(cmd, "cmgw")) { // Get
1366 printf("cmgw : OK\n");
1367
1368 } else {
1369 char *ptr = strstr(cmd, "cmgw,"); //+CMGW, <oa/da>, data
1370 if(ptr != NULL)
1371 {
1372 ptr = strstr(cmd, ",");
1373 ptr++;
1374 memset(cmgw, 0, sizeof(cmgw));
1375 memcpy(cmgw, ptr, strlen(ptr));
1376 printf("cmgw:%s\n", cmgw);
1377 }
1378
1379 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001380 err = mbtk_sms_cmgw_set(handle_def, cmgw, resp);
b.liub4772072024-08-15 14:47:03 +08001381 if(err) {
1382 printf("Error : %d\n", err);
1383 } else {
1384 printf("cmgw set success. resp:%s\n", resp);
1385 }
1386 }
1387 }
1388 else if(!strncasecmp(cmd, "cmgd", 4)){ // +CMGD=<index>[,<delflag>
1389 //
1390 char cmgd[128] = {0};
1391 if(!strcasecmp(cmd, "cmgd")) { // Get
1392 printf("cmgd : OK\n");
1393
1394 } else {
1395 char *ptr = strstr(cmd, ","); //+CMGD=<index>[,<delflag>
1396 if(ptr != NULL)
1397 {
1398 ptr++;
1399 memset(cmgd, 0, sizeof(cmgd));
1400 memcpy(cmgd, ptr, strlen(ptr));
1401 printf("1cmgd:%s\n", cmgd);
1402 }
1403
1404
b.liub171c9a2024-11-12 19:23:29 +08001405 err = mbtk_sms_cmgd_set(handle_def, cmgd);
b.liub4772072024-08-15 14:47:03 +08001406 if(err) {
1407 printf("Error : %d\n", err);
1408 } else {
1409 printf("VoLTE set success\n");
1410 }
1411 }
1412 }
1413 else if(!strncasecmp(cmd, "cmgl", 4)){ // AT+CMGL[=<stat>]
1414 //
1415 char cmgl[128] = {0};
1416 char resp[5*1024] ={0};
1417 if(!strcasecmp(cmd, "cmgl")) { // Get
1418 printf("cmgl : OK\n");
1419
1420 } else {
1421 char *ptr = strstr(cmd, "cmgl,"); // AT+CMGL[=<stat>]
1422 if(ptr != NULL)
1423 {
1424 ptr = strstr(cmd, ",");
1425 ptr++;
1426 memset(cmgl, 0, sizeof(cmgl));
1427 memcpy(cmgl, ptr, strlen(ptr));
1428 printf("0cmgl:%s\n", cmgl);
1429 }
1430
1431 memset(resp, 0, sizeof(resp));
b.liub171c9a2024-11-12 19:23:29 +08001432 err = mbtk_sms_cmgl_set(handle_def, cmgl, resp);
b.liub4772072024-08-15 14:47:03 +08001433 if(err) {
1434 printf("Error : %d\n", err);
1435 } else {
1436 // printf("cmgl set success, reg:%s\n",resp);
1437 }
1438 }
1439 }
1440 else if(!strncasecmp(cmd, "csca", 4)){ // AT+CSCA=<number> [,<type>]
1441 //
1442 char csca[128] = {0};
1443 if(!strcasecmp(cmd, "csca")) { // Get
b.liub171c9a2024-11-12 19:23:29 +08001444 err = mbtk_sms_csca_get(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001445 if(err) {
1446 printf("mbtk_sms_csca_get Error : %d\n", err);
1447 } else {
1448 printf("mbtk_sms_csca_get success\n");
1449 }
1450
1451 } else {
1452 char *ptr = strstr(cmd, ","); // AT+CSCA=<number> [,<type>]
1453 if(ptr != NULL)
1454 {
1455 ptr++;
1456 memset(csca, 0, sizeof(csca));
1457 memcpy(csca, ptr, strlen(ptr));
1458 printf("csca:%s\n", csca);
1459 }
1460
b.liub171c9a2024-11-12 19:23:29 +08001461 err = mbtk_sms_csca_set(handle_def, csca);
b.liub4772072024-08-15 14:47:03 +08001462 if(err) {
1463 printf("Error : %d\n", err);
1464 } else {
1465 printf("VoLTE set success\n");
1466 }
1467 }
1468 }
1469 else if(!strncasecmp(cmd, "csmp", 4)){ // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1470 //
1471 char csmp[128] = {0};
1472 if(!strcasecmp(cmd, "csmp")) { // Get
1473 printf("cmgl : OK\n");
1474
1475 } else {
1476 char *ptr = strstr(cmd, ","); // AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
1477 if(ptr != NULL)
1478 {
1479 ptr++;
1480 memset(csmp, 0, sizeof(csmp));
1481 memcpy(csmp, ptr, strlen(ptr));
1482 printf("csmp:%s\n", csmp);
1483 }
1484
b.liub171c9a2024-11-12 19:23:29 +08001485 err = mbtk_sms_csmp_set(handle_def, csmp);
b.liub4772072024-08-15 14:47:03 +08001486 if(err) {
1487 printf("Error : %d\n", err);
1488 } else {
1489 printf("VoLTE set success\n");
1490 }
1491 }
1492 }
1493 else if(!strncasecmp(cmd, "cscb", 4)){ // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1494 //
1495 char cscb[128] = {0};
1496 if(!strcasecmp(cmd, "cscb")) { // Get
1497 printf("cmgl : OK\n");
1498
1499 } else {
1500 char *ptr = strstr(cmd, ","); // AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
1501 if(ptr != NULL)
1502 {
1503 ptr++;
1504 memset(cscb, 0, sizeof(cscb));
1505 memcpy(cscb, ptr, strlen(ptr));
1506 printf("cscb:%s\n", cscb);
1507 }
1508
b.liub171c9a2024-11-12 19:23:29 +08001509 err = mbtk_sms_cscb_set(handle_def, cscb);
b.liub4772072024-08-15 14:47:03 +08001510 if(err) {
1511 printf("Error : %d\n", err);
1512 } else {
1513 printf("VoLTE set success\n");
1514 }
1515 }
1516 }
1517#if 0
1518 else if(!strncasecmp(cmd, "shutdown", 8)){
b.liu87afc4c2024-08-14 17:33:45 +08001519 if(!strcasecmp(cmd, "shutdown 0")) {
1520 err = mbtk_system_reboot(0);
1521 if(err) {
1522 printf("Error : %d\n", err);
1523 } else {
1524 printf("Success.\n");
1525 }
1526 } else if(!strcasecmp(cmd, "shutdown 1")) {
1527 err = mbtk_system_reboot(1);
1528 if(err) {
1529 printf("Error : %d\n", err);
1530 } else {
1531 printf("Success.\n");
1532 }
1533 } else if(!strcasecmp(cmd, "shutdown 2")) {
1534 err = mbtk_system_reboot(2);
1535 if(err) {
1536 printf("Error : %d\n", err);
1537 } else {
1538 printf("Success.\n");
1539 }
1540 } else {
1541 printf("Error.");
1542 }
1543 } else if(!strncasecmp(cmd, "power_sim", 9)){
1544 if(!strcasecmp(cmd, "power_sim 0")) {
1545 err = mbtk_sim_power_set(0);
1546 if(err) {
1547 printf("Error : %d\n", err);
1548 } else {
1549 printf("Success.\n");
1550 }
1551 } else if(!strcasecmp(cmd, "power_sim 1")) {
1552 err = mbtk_sim_power_set(1);
1553 if(err) {
1554 printf("Error : %d\n", err);
1555 } else {
1556 printf("Success.\n");
1557 }
1558 } else {
1559 printf("Error.");
1560 }
1561 } else if(!strncasecmp(cmd, "time", 4)){
1562 if(!strcasecmp(cmd, "time 0")) {
1563 err = mbtk_time_set(info_handle, 0, NULL);
1564 if(err) {
1565 printf("Error : %d\n", err);
1566 } else {
1567 printf("Success.\n");
1568 }
1569 } else if(!strcasecmp(cmd, "time 1")) {
1570 err = mbtk_time_set(info_handle, 1, NULL);
1571 if(err) {
1572 printf("Error : %d\n", err);
1573 } else {
1574 printf("Success.\n");
1575 }
1576 } else if(!strncasecmp(cmd, "time 2 ", 7)) {
1577 err = mbtk_time_set(info_handle, 2, cmd + 7);
1578 if(err) {
1579 printf("Error : %d\n", err);
1580 } else {
1581 printf("Success.\n");
1582 }
1583 } else { // Get time type.
1584 int time_type;
1585 err = mbtk_time_get(info_handle, &time_type);
1586 if(err) {
1587 printf("Error : %d\n", err);
1588 } else {
1589 printf("Time type:%d.\n", time_type);
1590 }
1591 }
b.liu87afc4c2024-08-14 17:33:45 +08001592 }
1593#endif
1594 else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
1595 help();
1596 } else if(!strcasecmp(cmd, "q")) {
b.liu571445f2025-02-13 10:22:55 +08001597 mbtk_ril_close(MBTK_AT_PORT_DEF);
1598 mbtk_ril_close(ATPORTTYPE_1);
b.liu87afc4c2024-08-14 17:33:45 +08001599 break;
1600 } else {
1601 printf("\n");
1602 }
1603 }
1604 }
1605
b.liu62240ee2024-11-07 17:52:45 +08001606#if RIL_DEBUG_THREAD
b.liu87afc4c2024-08-14 17:33:45 +08001607 thread_exit_with_wait();
b.liu87afc4c2024-08-14 17:33:45 +08001608exit:
b.liu62240ee2024-11-07 17:52:45 +08001609#endif
b.liude989912025-02-12 14:40:42 +08001610 mbtk_ril_close(MBTK_AT_PORT_DEF);
b.liu571445f2025-02-13 10:22:55 +08001611 mbtk_ril_close(ATPORTTYPE_1);
1612
b.liu87afc4c2024-08-14 17:33:45 +08001613
1614 LOG("Client exec complete.");
1615
1616 return 0;
1617}