blob: 11aaf450aa8938fcdd2832bacb36dba38a5776a6 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 *
3 * @file ext_zcat_func.c
4 * @brief
5 * This file is part of ZCAT.
6 * ZCATÄ£¿éÏà¹ØATÃüÁî
7 *
8 * @details
9 * @author Tools Team.
10 * @email
11 * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
12 * @warning
13 * @date 2019/02/02
14 * @version 1.2
15 * @pre
16 * @post
17 *
18 * @par
19 * Change History :
20 * ---------------------------------------------------------------------------
21 * date version author description
22 * ---------------------------------------------------------------------------
23 * 2017/05/22 1.0 hou.bing Create file
24 * 2019/01/15 1.1 jiang.fenglin Ôö¼ÓÉèÖÃ/²éѯzcat_usblogÃüÁî
25 * 2019/02/02 1.2 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
26 * 2019/07/08 1.3 jiang.fenglin Ôö¼ÓAPFS/CPFSģʽ
27 * ---------------------------------------------------------------------------
28 *
29 *
30 */
31
32
33#if (APP_OS_TYPE == APP_OS_LINUX)
34#include "ext_regist.h"
35#include "at_utils.h"
36#include "softap_api.h"
37#include "zxic_errno.h"
38#include "nv_api.h"
39//#include "nvserver.h"
40
41#ifndef max
42#define max(a, b) (((a) > (b)) ? (a) : (b))
43#endif
44
45#ifndef min
46#define min(a, b) (((a) < (b)) ? (a) : (b))
47#endif
48
49
50/**
51 * º¯ÊýʵÏÖ
52 */
53
54int ext_zcat_set_mode(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
55{
56 char zcat_mode[512] = {0};
57 //E_AT_PARSE parseRst = AT_PARSE_SUCCESS;
58
59 printf("ext_zcat_set %s,len is %d\n",at_paras,strlen(at_paras));
60 memcpy(zcat_mode,at_paras,min(strlen(at_paras), sizeof(zcat_mode) - 1));
61 printf("zcat_mode is %s",zcat_mode);
62 if(0==strcmp(zcat_mode,"APUSB") || 0==strcmp(zcat_mode,"APNET") || 0==strcmp(zcat_mode,"APTF") \
63 || 0==strcmp(zcat_mode,"APFS") || 0==strcmp(zcat_mode,"CPFS") \
64 || 0==strcmp(zcat_mode,"CPUSB") || 0==strcmp(zcat_mode,"CPTF"))
65 {
66 sc_cfg_set("zcat_mode",zcat_mode);
67 sc_cfg_save();
68 nv_set_item("cfg","zcat_mode", zcat_mode,1);
69 nv_commit("cfg");
70 }
71 else
72 {
73 *res_msg = at_err_build(ATERR_PARAM_INVALID);
74 *res_msglen = strlen(*res_msg);
75 return AT_END;
76 }
77
78 *res_msg = at_ok_build();
79 *res_msglen = strlen(*res_msg);
80
81 return AT_END;
82 #if 0
83 switch(iNetcardType)
84 {
85 case 0:
86 {
87 nv_set_item(NV_RO,"forcenetcard_type", "force_ndis",1);
88 break;
89 }
90 case 1:
91 {
92 nv_set_item(NV_RO,"forcenetcard_type", "force_ecm",1);
93 break;
94 }
95 case 2:
96 {
97 nv_set_item(NV_RO,"forcenetcard_type", "force_mbim",1);
98 break;
99 }
100 case 3:
101 {
102 nv_set_item(NV_RO,"forcenetcard_type", "force_rndis",1);
103 break;
104 }
105 default:
106 {
107 *res_msg = at_err_build(ATERR_PARAM_INVALID);
108 *res_msglen = strlen(*res_msg);
109 return AT_END;
110 }
111 }
112 nv_commit(NV_RO);
113
114 *res_msg = at_ok_build();
115 *res_msglen = strlen(*res_msg);
116
117 return AT_END;
118 #endif
119}
120
121
122int ext_zcat_get_mode(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
123{
124 char zcat_mode[512] = {0};
125 printf("ext_zcat_get %s\n",at_paras);
126
127 if(-1 == sc_cfg_get("zcat_mode", zcat_mode, sizeof(zcat_mode)))
128 {
129 *res_msg = at_err_build(ATERR_PROC_FAILED);
130 *res_msglen = strlen(*res_msg);
131 return AT_END;
132 }
133 nv_get_item("cfg", "zcat_mode", zcat_mode, sizeof(zcat_mode));
134 printf("zcat_mode is %s ,%d",zcat_mode,strlen(zcat_mode));
135 *res_msg = at_query_result_build("ZCAT_MODE",zcat_mode);
136 *res_msglen = strlen(*res_msg);
137 return AT_END;
138
139}
140
141
142int ext_zcat_set_usblog(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
143{
144 char zcat_usblog[512] = {0};
145 //E_AT_PARSE parseRst = AT_PARSE_SUCCESS;
146
147 printf("ext_zcat_set %s,len is %d\n", at_paras, strlen(at_paras));
148 memcpy(zcat_usblog, at_paras, min(strlen(at_paras), sizeof(zcat_usblog)-1));
149 printf("zcat_usblog is %s", zcat_usblog);
150 if(strstr(zcat_usblog, "tty"))
151 {
152 sc_cfg_set("zcat_usblog", zcat_usblog);
153 sc_cfg_save();
154 nv_set_item("cfg", "zcat_usblog", zcat_usblog, 1);
155 nv_commit("cfg");
156 }
157 else
158 {
159 *res_msg = at_err_build(ATERR_PARAM_INVALID);
160 *res_msglen = strlen(*res_msg);
161 return AT_END;
162 }
163
164 *res_msg = at_ok_build();
165 *res_msglen = strlen(*res_msg);
166
167 return AT_END;
168}
169
170int ext_zcat_get_usblog(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
171{
172 char zcat_usblog[512] = {0};
173 printf("ext_zcat_get %s\n", at_paras);
174
175 if(-1 == sc_cfg_get("zcat_usblog", zcat_usblog, sizeof(zcat_usblog)))
176 {
177 *res_msg = at_err_build(ATERR_PROC_FAILED);
178 *res_msglen = strlen(*res_msg);
179 return AT_END;
180 }
181
182 nv_get_item("cfg", "zcat_usblog", zcat_usblog, sizeof(zcat_usblog));
183 printf("zcat_usblog is %s ,%d",zcat_usblog,strlen(zcat_usblog));
184 *res_msg = at_query_result_build("ZCAT_USBLOG",zcat_usblog);
185 *res_msglen = strlen(*res_msg);
186 return AT_END;
187
188}
189
190
191int ext_zcat_regist(void)
192{
193
194 register_serv_func2("zcatmode=",0,0,0, ext_zcat_set_mode, NULL);
195 register_serv_func2("zcatmode?",0,0,0, ext_zcat_get_mode, NULL);
196
197 register_serv_func2("zcatusblog=",0,0,0,ext_zcat_set_usblog, NULL);
198 register_serv_func2("zcatusblog?",0,0,0,ext_zcat_get_usblog, NULL);
199
200 return 0;
201
202}
203
204#endif
205