Merge "[Feature][S300][task-view-1900][arms] Docking with ARMS platform"
diff --git a/lynq/S300/BJMTN/ap/app/zte_mifi/zte_mifi.c b/lynq/S300/BJMTN/ap/app/zte_mifi/zte_mifi.c
new file mode 100755
index 0000000..29d30f2
--- /dev/null
+++ b/lynq/S300/BJMTN/ap/app/zte_mifi/zte_mifi.c
@@ -0,0 +1,299 @@
+#define _GNU_SOURCE /**/
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/sysctl.h>
+#include <net/if.h>
+#include <poll.h>
+#include <stddef.h>
+#include <linux/if_packet.h>
+#include <netinet/ether.h>
+#include <netinet/if_ether.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include <zte_mifi.h>
+#include "softap_api.h"
+
+void nvserver_entry(void)
+{
+	nvserver_main(0,NULL);
+	return;
+}
+
+void at_ctl_entry(char *arg)
+{
+	//printf("at_ctl_entry boot:%s\n", arg);
+	char *argv[2];
+	argv[0] = NULL;
+	argv[1] = arg;
+
+	at_ctl_main(2, argv);
+	return;
+}
+
+void rtc_service_entry(char *arg)
+{
+	rtc_service_main(0,NULL);
+	return;
+}
+
+void zte_mainctrl_entry(char *arg)
+{
+	/*if (0 == strcmp(arg, "2")) {
+		char *argv[2];
+		argv[0] = NULL;
+		argv[1] = "poweroff_charger";
+
+		zte_mainctrl_main(2, argv);
+	} else {*/
+		zte_mainctrl_main(0,NULL);
+	//}
+
+	return;
+}
+
+void zte_hotplug_entry(char *arg)
+{
+	zte_hotplug_main(0,NULL);
+	return;
+}
+/*
+void zte_audio_res_ctrl_entry(char *arg)
+{
+	zte_audio_res_ctrl_main(0,NULL);
+	return;
+}
+*/
+void zte_drv_serial_ctrl_entry(char *arg)
+{
+	zte_drv_serial_ctrl_main();
+	return;
+}
+
+void zte_drv_usb_ctrl_entry(char *arg)
+{
+	if(arg)
+		zte_drv_usb_ctrl_main(3,NULL);
+	else
+		zte_drv_usb_ctrl_main(0,NULL);
+	return;
+}
+
+void zte_mmi_entry(char *arg)
+{
+	//printf("zte_mmi_entry boot:%s\n", arg);
+/*	if (0 == strcmp(arg, "2")) {
+		char *argv[2];
+		argv[0] = NULL;
+		argv[1] = "poweroff_charger";
+
+		zte_mmi_main(2, argv);
+	} else {*/
+		zte_mmi_main(0,NULL);
+	//}
+	return;
+}
+
+void zte_locknet_entry(char *arg)
+{
+	zte_locknet_main(0,NULL);
+	//return; //klocwork
+}
+
+void zte_watchdog_entry(char *arg)
+{
+	zte_watchdog_main(0,NULL);
+	return;
+}
+
+void fluxstat_entry(char *arg)
+{
+	fluxstat_main(0,NULL);
+	return;
+}
+
+void sntp_entry(char *arg)
+{
+	sntp_main(0,NULL);
+	return;
+}
+
+void schedule_restart_entry(char *arg)
+{
+	schedule_restart_main(0,NULL);
+	return;
+}
+
+void tcp_socket_server_entry(char *arg)
+{
+	tcp_socket_server_main(0,NULL);
+	return;
+}
+
+void tcp_socket_reset_server_entry(char *arg)
+{
+	tcp_socket_reset_server_main(0,NULL);
+	return;
+}
+
+/*
+void sd_hotplug_entry(char *arg)
+{
+	sd_hotplug_main(0,NULL);
+	return;
+}
+*/
+void sms_entry(char *arg)
+{
+	sms_main(0,NULL);
+}
+
+void phonebook_entry(char *arg)
+{
+	phonebook_main(0,NULL);
+	return;
+}
+
+void wlan_entry(char *arg)
+{
+	wlan_main(0,NULL);
+	return;
+}
+/*
+void fota_dm_entry(char *arg)
+{
+	fota_dm_main(0,NULL);
+}
+*/
+
+int main(int argc, char *argv[])
+{
+	int ret = 0;
+	/* nvserver */
+    pthread_t nvserver_thread_tid;
+    pthread_create(&nvserver_thread_tid, NULL, (void *)nvserver_entry, NULL);
+
+	/* zte_hotplug */
+	pthread_t zte_hotplug_thread_tid;
+	pthread_create(&zte_hotplug_thread_tid, NULL, (void *)zte_hotplug_entry, NULL);
+
+    /* zte_drv_serial_ctrl */
+	pthread_t zte_drv_serial_ctrl_thread_tid;
+	pthread_create(&zte_drv_serial_ctrl_thread_tid, NULL, (void *)zte_drv_serial_ctrl_entry, NULL);
+	if (0 == strcmp(argv[2], "amt")) {
+		ret = cfg_set("ver_mode", "0");
+		if(ret < 0)
+			printf("zte_mifi set vermode fail\n");
+		else
+			cfg_save();
+		printf("---set ver mode to 0\n");
+	}
+	/* zte_drv_usb_ctrl */
+	pthread_t zte_drv_usb_ctrl_thread_tid;
+
+	if (0 != strcmp(argv[2], "amt")) { //³äµç»òÕý³£¿ª»úģʽ
+		char LanEnable[10] = {0};
+		/* at_ctl */
+		pthread_t at_ctl_thread_tid;
+		pthread_create(&at_ctl_thread_tid, NULL, (void *)at_ctl_entry, argv[1]);
+		/* rtc_service */
+		pthread_t rtc_service_thread_tid;
+		pthread_create(&rtc_service_thread_tid, NULL, (void *)rtc_service_entry, NULL);
+		/* zte_mainctrl */
+		pthread_t zte_mainctrl_thread_tid;
+		pthread_create(&zte_mainctrl_thread_tid, NULL, (void *)zte_mainctrl_entry, argv[1]);
+
+		/* zte_audio_res_ctrl */
+		//pthread_t zte_audio_res_ctrl_thread_tid;
+		//pthread_create(&zte_audio_res_ctrl_thread_tid, NULL, (void *)zte_audio_res_ctrl_entry, NULL);
+
+		cfg_get_item("LanEnable", LanEnable, sizeof(LanEnable));
+		if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+			/* zte_mmi */
+			pthread_t zte_mmi_thread_tid;
+			pthread_create(&zte_mmi_thread_tid, NULL, (void *)zte_mmi_entry, argv[1]);
+		}	
+
+		//if(0 != strcmp(argv[1], "2")){
+			pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+
+			if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+					/* zte_locknet */
+				pthread_t zte_locknet_thread_tid;
+				pthread_create(&zte_locknet_thread_tid, NULL, (void *)zte_locknet_entry, NULL);
+				/* fluxstat */
+
+
+				pthread_t fluxstat_thread_tid;
+				pthread_create(&fluxstat_thread_tid, NULL, (void *)fluxstat_entry, NULL);
+				/* sntp */
+				pthread_t sntp_thread_tid;
+				pthread_create(&sntp_thread_tid, NULL, (void *)sntp_entry, NULL);
+				/* schedule_restart */
+				//pthread_t schedule_restart_thread_tid;
+				//pthread_create(&schedule_restart_thread_tid, NULL, (void *)schedule_restart_entry, NULL);
+				/* tcp socket server */
+				pthread_t tcp_socket_server_thread_tid;
+				pthread_create(&tcp_socket_server_thread_tid, NULL, (void *)tcp_socket_server_entry, NULL);
+				pthread_t tcp_socket_reset_server_thread_tid;
+				pthread_create(&tcp_socket_reset_server_thread_tid, NULL, (void *)tcp_socket_reset_server_entry, NULL);
+				/* sd_hotplug */
+				//pthread_t sd_hotplug_thread_tid;
+				//pthread_create(&sd_hotplug_thread_tid, NULL, (void *)sd_hotplug_entry, NULL);
+				//sd_hotplug_init();
+				/* sms */
+				pthread_t sms_thread_tid;
+				pthread_create(&sms_thread_tid, NULL, (void *)sms_entry, NULL);
+				/* phonebook */
+				//NV_NEED_SUPPORT_PB
+				pthread_t phonebook_thread_tid;
+				pthread_create(&phonebook_thread_tid, NULL, (void *)phonebook_entry, NULL);
+
+				/* wifi_manager */
+				pthread_t wlan_thread_tid;
+				pthread_create(&wlan_thread_tid, NULL, (void *)wlan_entry, NULL);
+
+			}	
+
+			/* fota_dm */
+			// pthread_t fota_dm_thread_tid;
+			// pthread_create(&fota_dm_thread_tid, NULL, (void *)fota_dm_entry, NULL);			
+/*		}else{
+			pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, "poweroff_charger");
+		}*/
+
+
+		/* zte_watchdog */
+		pthread_t zte_watchdog_thread_tid;
+		pthread_create(&zte_watchdog_thread_tid, NULL, (void *)zte_watchdog_entry, NULL);
+	}
+	else
+	{
+		pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+	}
+
+
+	while(1)
+	{
+		sleep(20);
+		//printf("zte app test -1 \n");
+	}
+
+	return 0;
+}
+