blob: f07eb0d7442d7007c57262fdc881e6f4bf244923 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#define _GNU_SOURCE /**/
2
3#include <string.h>
4#include <stdio.h>
5#include <stdarg.h>
6#include <stdlib.h>
7#include <time.h>
8#include <syslog.h>
9#include <unistd.h>
10#include <errno.h>
11#include <signal.h>
12#include <netdb.h>
13#include <sys/types.h>
14#include <sys/ioctl.h>
15#include <sys/socket.h>
16#include <sys/time.h>
17#include <sys/uio.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <sys/sysctl.h>
21#include <net/if.h>
22#include <poll.h>
23#include <stddef.h>
24#include <linux/if_packet.h>
25#include <netinet/ether.h>
26#include <netinet/if_ether.h>
27#include <arpa/inet.h>
28#include <pthread.h>
29#include <zte_cpe.h>
30#include "softap_api.h"
31
32void nvserver_entry(void)
33{
34 nvserver_main(0,NULL);
35 return;
36}
37
38void at_ctl_entry(char *arg)
39{
40 //printf("at_ctl_entry boot:%s\n", arg);
41 char *argv[2];
42 argv[0] = NULL;
43 argv[1] = arg;
44
45 at_ctl_main(2, argv);
46 return;
47}
48
49void rtc_service_entry(char *arg)
50{
51 rtc_service_main(0,NULL);
52 return;
53}
54
55void zte_mainctrl_entry(char *arg)
56{
57 if (0 == strcmp(arg, "2")) {
58 char *argv[2];
59 argv[0] = NULL;
60 argv[1] = "poweroff_charger";
61
62 zte_mainctrl_main(2, argv);
63 } else {
64 zte_mainctrl_main(0,NULL);
65 }
66
67 return;
68}
69
70void zte_hotplug_entry(char *arg)
71{
72 zte_hotplug_main(0,NULL);
73 return;
74}
75
76void zte_audio_res_ctrl_entry(char *arg)
77{
78 zte_audio_res_ctrl_main(0,NULL);
79 return;
80}
81
82void zte_drv_serial_ctrl_entry(char *arg)
83{
84 zte_drv_serial_ctrl_main();
85 return;
86}
87
88void zte_drv_usb_ctrl_entry(char *arg)
89{
90 if(arg)
91 zte_drv_usb_ctrl_main(3,NULL);
92 else
93 zte_drv_usb_ctrl_main(0,NULL);
94 return;
95}
96
97void zte_mmi_entry(char *arg)
98{
99 //printf("zte_mmi_entry boot:%s\n", arg);
100 if (0 == strcmp(arg, "2")) {
101 char *argv[2];
102 argv[0] = NULL;
103 argv[1] = "poweroff_charger";
104
105 zte_mmi_main(2, argv);
106 } else {
107 zte_mmi_main(0,NULL);
108 }
109 return;
110}
111
112void zte_locknet_entry(char *arg)
113{
114 zte_locknet_main(0,NULL);
115 //return; //klocwork
116}
117
118void zte_watchdog_entry(char *arg)
119{
120 zte_watchdog_main(0,NULL);
121 return;
122}
123
124void fluxstat_entry(char *arg)
125{
126 fluxstat_main(0,NULL);
127 return;
128}
129
130void sntp_entry(char *arg)
131{
132 sntp_main(0,NULL);
133 return;
134}
135
136void sd_hotplug_entry(char *arg)
137{
138 sd_hotplug_main(0,NULL);
139 return;
140}
141
142void sms_entry(char *arg)
143{
144 sms_main(0,NULL);
145}
146
147void phonebook_entry(char *arg)
148{
149 phonebook_main(0,NULL);
150 return;
151}
152
153void wlan_entry(char *arg)
154{
155 wlan_main(0,NULL);
156 return;
157}
158
159void fota_dm_entry(char *arg)
160{
161 fota_dm_main(0,NULL);
162}
163
164
165int main(int argc, char *argv[])
166{
167 int ret = 0;
168 /* nvserver */
169 pthread_t nvserver_thread_tid;
170 pthread_create(&nvserver_thread_tid, NULL, (void *)nvserver_entry, NULL);
171
172 /* zte_hotplug */
173 pthread_t zte_hotplug_thread_tid;
174 pthread_create(&zte_hotplug_thread_tid, NULL, (void *)zte_hotplug_entry, NULL);
175
176 /* zte_drv_serial_ctrl */
177 pthread_t zte_drv_serial_ctrl_thread_tid;
178 pthread_create(&zte_drv_serial_ctrl_thread_tid, NULL, (void *)zte_drv_serial_ctrl_entry, NULL);
179 /* zte_drv_usb_ctrl */
180 pthread_t zte_drv_usb_ctrl_thread_tid;
181#ifdef WEBS_SECURITY
182 {
183 char rstr[24] = {0};
184
185 sc_cfg_get("dbinfo", rstr, sizeof(rstr));
186 if(strlen(rstr) == 0)
187 {
188 unsigned int rnum = 0;
189
190 system("rm -rf /etc_rw/pbm.*");
191 system("rm -rf /etc_rw/sms.*");
192 srand( (unsigned)time( NULL ) );
193 rnum = (rand()|0xf000000);
194 snprintf((char *)rstr, sizeof(rstr), "%ld", rnum);
195 sc_cfg_set("dbinfo", rstr);
196 sc_cfg_save();
197 }
198 {
199 unsigned char i = 0;
200 char nstr[24] = {0};
201 for(i = 0; i < 22; i++)
202 {
203 if(rstr[i] >= 0x30)
204 {
205 nstr[i] = rstr[i] + (((i&0x7)|0x18)+1)*(2>>(i%3));
206 }
207 else
208 {
209 nstr[i] = (i%10) + 0x30 + (((i&0x7)|0x18)+1)*(2>>(i%3));
210 }
211 }
212 sc_cfg_set("rnum_at", nstr);
213 }
214 }
215#endif
216 if (0 == strcmp(argv[2], "amt")) {
217 ret = sc_cfg_set("ver_mode", "0");
218 if(ret < 0)
xf.libdd93d52023-05-12 07:10:14 -0700219 printf("cpe set vermode fail\n");
lh9ed821d2023-04-07 01:36:19 -0700220 else
221 sc_cfg_save();
222 printf("---set ver mode to 0\n");
223 }
224
225 if (0 != strcmp(argv[2], "amt")) { //³äµç»òÕý³£¿ª»úģʽ
226 char LanEnable[10] = {0};
227 /* at_ctl */
228 pthread_t at_ctl_thread_tid;
229 pthread_create(&at_ctl_thread_tid, NULL, (void *)at_ctl_entry, argv[1]);
230 /* rtc_service */
231 pthread_t rtc_service_thread_tid;
232 pthread_create(&rtc_service_thread_tid, NULL, (void *)rtc_service_entry, NULL);
233 /* zte_mainctrl */
234 pthread_t zte_mainctrl_thread_tid;
235 pthread_create(&zte_mainctrl_thread_tid, NULL, (void *)zte_mainctrl_entry, argv[1]);
236
237 /* zte_audio_res_ctrl */
238 pthread_t zte_audio_res_ctrl_thread_tid;
239 pthread_create(&zte_audio_res_ctrl_thread_tid, NULL, (void *)zte_audio_res_ctrl_entry, NULL);
240
241 sc_cfg_get("LanEnable", LanEnable, sizeof(LanEnable));
242 if(atoi(LanEnable) == 1) { //mifiÐÎ̬
243 /* zte_mmi */
244 pthread_t zte_mmi_thread_tid;
245 pthread_create(&zte_mmi_thread_tid, NULL, (void *)zte_mmi_entry, argv[1]);
246 }
247 if (0 != strcmp(argv[1], "2")) { //·Ç³äµçģʽ
248
249 pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
250 if(atoi(LanEnable) == 1) { //mifiÐÎ̬
251 /* zte_locknet */
252 pthread_t zte_locknet_thread_tid;
253 pthread_create(&zte_locknet_thread_tid, NULL, (void *)zte_locknet_entry, NULL);
254 /* fluxstat */
255
256 pthread_t fluxstat_thread_tid;
257 pthread_create(&fluxstat_thread_tid, NULL, (void *)fluxstat_entry, NULL);
258 /* sntp */
259 pthread_t sntp_thread_tid;
260 pthread_create(&sntp_thread_tid, NULL, (void *)sntp_entry, NULL);
261 /* sd_hotplug */
262 //pthread_t sd_hotplug_thread_tid;
263 //pthread_create(&sd_hotplug_thread_tid, NULL, (void *)sd_hotplug_entry, NULL);
264 sd_hotplug_init();
265 /* sms */
266 pthread_t sms_thread_tid;
267 pthread_create(&sms_thread_tid, NULL, (void *)sms_entry, NULL);
268 /* phonebook */
269 pthread_t phonebook_thread_tid;
270 pthread_create(&phonebook_thread_tid, NULL, (void *)phonebook_entry, NULL);
271 /* wifi_manager */
272 pthread_t wlan_thread_tid;
273 pthread_create(&wlan_thread_tid, NULL, (void *)wlan_entry, NULL);
274 }
275
276 /* fota_dm */
277 pthread_t fota_dm_thread_tid;
278 pthread_create(&fota_dm_thread_tid, NULL, (void *)fota_dm_entry, NULL);
279 }else{
280
281 pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, "poweroff_charger");
282
283 }
284
285
286 /* zte_watchdog */
287 pthread_t zte_watchdog_thread_tid;
288 pthread_create(&zte_watchdog_thread_tid, NULL, (void *)zte_watchdog_entry, NULL);
289
290 }
291 else
292 {
293 pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
294 }
295
296
297 while(1)
298 {
299 sleep(20);
xf.libdd93d52023-05-12 07:10:14 -0700300 //printf("app test -1 \n");
lh9ed821d2023-04-07 01:36:19 -0700301 }
302
303 return 0;
304}
305