[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/include/at_msg.h b/ap/app/include/at_msg.h
new file mode 100755
index 0000000..434faea
--- /dev/null
+++ b/ap/app/include/at_msg.h
@@ -0,0 +1,304 @@
+/**
+ * @file at_msg.h
+ * @brief ÌṩÁËÆ½Ì¨¶ÔÍâÏûÏ¢½Ó¿ÚºÍÏûÏ¢½á¹¹¶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __AT_MSG_H__
+#define __AT_MSG_H__
+
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include "message.h"
+
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+/* ÏÂÃæÈý¸öÏûÏ¢ÊÇÂú×ã¿Í»§ÐèÇó£¬ÊµÏÖ¿Í»§appͨ¹ýÏûÏ¢Ö±½Ó·¢ËÍATÃüÁî¡£
+   Ô­À´¶¨ÒåµÄÈý¸öÏûÏ¢Ãû²»ºÃÀí½â£¬µ«ÒѾ­Íâ·¢¸ø¿Í»§£¬²»ÔÙÐ޸ģ¬ÄÚ²¿Öض¨Òå³ÉºÃÀí½âµÄÏûÏ¢Ãû */
+#define MSG_CMD_SET_MSG_IS_FD  		MSG_CMD_AT_PORT_EXT
+#define MSG_CMD_SEND_ATREQ_BY_MSG 	MSG_CMD_AT_REQ
+#define MSG_CMD_SEND_ATRSP_BY_MSG   MSG_CMD_AT_RSP
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+ * @brief ƽ̨Íⲿ½Ó¿ÚÏûÏ¢½Ó¿Ú¶¨Òå
+ */
+enum  at_msg_type {
+	AT_OUTER_MSG_BEG = MSG_CMD_ATCTL_BASE,
+
+	/*ͨ¹ý¸ÃÏûϢ֪ͨatctlÖ÷¿ØÍ¨¹ýÀ©Õ¹Ö÷¶¯Éϱ¨ATÃüÁîʵÏֺ˼äÄ£¿éÏûÏ¢´«µÝ*/
+	MSG_CMD_SOC_MSG_REQ,
+	MSG_CMD_AT_PORT_OPEN,//mux2USB²Ù×÷  MODULE_ID_DRVCOMMNGÄ£¿é·¢ËÍ
+	MSG_CMD_AT_PORT_CLOSE,//mux2USB²Ù×÷
+
+	MSG_CMD_CMUX_SET_REQ,
+	MSG_CMD_CMUX_SET_RSP,
+
+	MSG_CMD_ZSET_REQ,//TSP°æ±¾ÅäÖÃÉèÖÃ
+	MSG_CMD_ZSET_RSP,
+
+	/****************at_ctlÓëVOLTEÖ®¼äÏûÏ¢¶¨Òå*************************/
+	MSG_CMD_FD1_ATCTL_TO_VOLTE,   //at_ctl·¢ËÍÇëÇóµ½VOLTE
+	MSG_CMD_FD1_VOLTE_TO_ATCTL,   //VOLTE·µ»ØÇëÇóµÄÏìÓ¦»òÕß½«ÇëÇóԭ··µ»Ø
+	MSG_CMD_FD2_ATCTL_TO_VOLTE,   //at_ctl·µ»ØÏìÓ¦µ½VOLTE
+	MSG_CMD_FD2_VOLTE_TO_ATCTL,   //VOLTEÖ÷¶¯·¢ËÍÇëÇóµ½at_ctl
+	/**********************ÒÔÏÂΪPSÏà¹ØµÄÒµÎñÀàÇëÇó*********************************/
+	MSG_CMD_PPP_QUICK_DISCONNECT,	//ÍøÂçÖ÷¶¯È¥¼¤»îʱ£¬ÓÉpppÄ£¿éÔÚlcpЭÉÌÍê³Éºó£¬Á¢¼´Í¨Öªat_ctl¶Ï¿ª²¦ºÅ//zhangfen ²»ÐèÒªat_ctl´¦Àí
+	MSG_CMD_QUERY_CSQ_REQ,		 	//²éѯÐźÅÇ¿¶ÈÇëÇó
+	MSG_CMD_QUERY_SYSINFO_REQ,		//sysinfo²éѯÇëÇó
+	MSG_CMD_QUERY_CEREG_REQ,		//cereg²éѯÇëÇó
+	MSG_CMD_CSIM_AUTH_REQ,			//csimÑéÖ¤ÇëÇó
+	MSG_CMD_CSIM_AUTH_RSP,			//csimÑéÖ¤ÏìÓ¦
+	MSG_CMD_CARD_MODE_REQ,			//¿¨Ä£Ê½Ê¶±ðÇëÇó
+	MSG_CMD_CARD_MODE_RSP,			//¿¨Ä£Ê½Ê¶±ðÏìÓ¦
+	MSG_CMD_PIN_STATUS_REQ,			//pinÂë״̬ÇëÇó
+	MSG_CMD_PIN_STATUS_RSP,			//pinÂë״̬ÏìÓ¦
+	MSG_CMD_PIN_VERIFY_REQ,			//pinÂëÑéÖ¤ÇëÇó
+	MSG_CMD_PIN_VERIFY_RSP,			//pinÂëÑéÖ¤ÏìÓ¦
+	MSG_CMD_PIN_NUM_REQ,			//pinÂëÊ£Óà´ÎÊý²éѯÇëÇó
+	MSG_CMD_PIN_NUM_RSP,			//pinÂëÊ£Óà´ÎÊý²éѯÏìÓ¦
+	MSG_CMD_VERIFY_PIN_REQ,			//webuiÇëÇópinÂëÑéÖ¤£¬¶ÔÓ¦½á¹¹ÌåT_zAt_CpinPukSet
+	MSG_CMD_VERIFY_PUK_REQ,			//webuiÇëÇópukÂëÑéÖ¤,¶ÔÓ¦½á¹¹ÌåT_zAt_CpinPukSet
+	MSG_CMD_PIN_MANAGE_REQ,			//webui pinÂë¹ÜÀí(´ò¿ª¡¢¹Ø±Õ¡¢ÐÞ¸Ä),¶ÔÓ¦½á¹¹ÌåT_zAt_PinManage
+	MSG_CMD_CRSM_REQ,				//crsmÇëÇó
+	MSG_CMD_CRSM_RSP,				//crsmÏìÓ¦
+	MSG_CMD_CIMI_REQ,				//imsi²éѯÇëÇó
+	MSG_CMD_CIMI_RSP,				//imsi²éѯÏìÓ¦
+	MSG_CMD_AIRMODE_SET_REQ,		//½ø³ö·ÉÐÐģʽÉèÖÃ(1½ø,0³ö)
+	MSG_CMD_NET_SELECT_REQ,			//webuiÑ¡ÔñÍøÂç(×Ô¶¯ËÑÍø¡¢ÊÖ¶¯ËÑÍø)
+	MSG_CMD_NETWORK_SET_REQ,		//ÊÖ¶¯ËÑÍøºó£¬Ñ¡ÔñÍøÂç×¢²á
+	MSG_CMD_USSD_SET_REQ,			//USSDÉèÖÃÇëÇó
+	MSG_CMD_USSD_CANCEL_REQ,		//USSDÈ¡ÏûÇëÇó
+	MSG_CMD_CELL_LOCK_REQ,			//LTEÏÂËø»ò½âËøÆµÇëÇó,WEBUIÔÝʱûÓÐÕâ¸ö¹¦ÄÜ
+	MSG_CMD_IMEI_REQ,				//imeiºÅ²éѯÇëÇó
+	MSG_CMD_GET_MAC_REQ,			//macµØÖ·»ñÈ¡
+
+	MSG_CMD_AT_PORT_EXT,	//´ò¿ªÎ±atͨµÀ£¬atͨµÀ¾ä±úµÈÓÚÄ£¿éID
+	MSG_CMD_AT_REQ,			//ÒÔÏûÏ¢·½Ê½·¢ËÍATÃüÁîÇëÇó
+	MSG_CMD_AT_RSP,			//ÒÔÏûÏ¢·½Ê½·¢ËÍATÃüÁîÏìÓ¦
+	MSG_CMD_SEND_AT_TO_PS, 	//ÓÃÓÚ·¢ËÍÇëÇóAT×Ö·û´®¸øPS
+	MSG_CMD_SEND_REQAT_TO_FARPS, //Ó¦Ó÷¢ËÍÇëÇóAT×Ö·û´®¸øÍⲿMCU
+	MSG_CMD_SEND_AT_MSG_RSP, //¾ßÌåÓ¦ÓÃÄ£¿é·¢Ë͵ÄATÇëÇóÏûÏ¢¶ÔÓ¦µÄÓ¦´ðÏûÏ¢£¬°üÀ¨²éѯÖмä½á¹ûµÄÉϱ¨
+
+	MSG_CMD_SEND_REQ_TO_APP,	 //at_ctl½«Íⲿ·¢Ë͵ÄATÇëÇóÖ±½Ó͸´«¸øÓ¦ÓÃ
+	MSG_CMD_SEND_RSP_TO_OUTSIDE, //¹©Ó¦Ó÷¢ËÍ͸´«×Ö·û´®¸øÎïÀíͨµÀ£¬Ò»°ãÓÃÓÚ·¢ËÍÓ¦´ðAT×Ö·û´®¸øÍⲿMCU //sunquan1130
+
+
+
+	MSG_CMD_ZVERSION_REQ,	//version²éѯÇëÇó zhangfen ´ýɾ³ý£¬ÏÖÔÚÓпª»ú´ÓCPͬ²½°æ±¾ºÅµ½AP£¬²»ÐèÒª²éѯÁË
+
+	MSG_CMD_PPP_AUTH_REQ,	//ppp²¦ºÅ(δʵÏÖ) //zhangfen ´ýɾ³ý
+	MSG_CMD_PPP_DEAUTH_REQ,	//pppÈ¥²¦ºÅ(δʵÏÖ) //zhangfen ´ýɾ³ý
+
+	MSG_CMD_APN_SET_REQ,	//apnÉèÖÃÇëÇó//zhangfen at_ctlûÓÐ×¢²áÕâ¸öÏûÏ¢£¬È·¶¨ÐèÒª?
+
+
+	MSG_CMD_ZSODCP_REQ,		//zhangfen ²»ÖªµÀÓÃ;£¬Ã»ÓÐʹÓà ´ýɾ³ý
+	MSG_CMD_EXT_ZSODCP_REQ,	//zhangfen ²»ÖªµÀÓÃ;£¬Ã»ÓÐʹÓà ´ýɾ³ý
+
+	MSG_CMD_MDMVERSION_REQ,//MBBÀ©Õ¹at:²éѯmodem°æ±¾ºÅ
+	MSG_CMD_MDMVERSION_RSP,
+	MSG_CMD_LTE_TECH_REQ,	//zeact LTE×ÓÖÆÊ½Ñ¡Ôñ
+	MSG_CMD_LTE_TECH_RSP,
+	MSG_CMD_NITZ_REQ,	//ʱ¼äͬ²½
+	MSG_CMD_NITZ_RSP,
+	MSG_CMD_AMRWB_REQ,	//VOLTE¸ßÇåÓïÒô
+	MSG_CMD_AMRWB_RSP,
+	/**********************ÒÔÏÂΪ·ÇPSÏà¹ØµÄÒµÎñÀàÇëÇó*******************************/
+	MSG_CMD_SYCTIME_SET_REQ,		//cp²àʱ¼äÉèÖÃÇëÇó
+
+	MSG_CMD_FORCE_RAMDUMP_REQ,	//Ç¿ÖÆËÀ»úÇëÇó zhangfen ûÓÐʹÓ㬴ýɾ³ý
+	MSG_CMD_UNLOCK_REQ,			//½âËøÍøÇëÇó zhangfen WEBUIÓз¢ËÍ,at_ctlûÓд¦Àí£¬´ýɾ³ý
+
+	MSG_CMD_SSID_SET_REQ, 		//zhangfen  SSIDºÅ±£´æÔÚCP²àNV£¬¶ÔÓ¦À©Õ¹ATÃüÁîAT+SSID=XXдCPµÄNV£¬ÈôNVÒÆµ½AP£¬¸ÃÏûÏ¢¿Éɾ³ý
+	MSG_CMD_SSID_SET_RSP,		//zhangfen ´ýɾ³ý
+	MSG_CMD_WIFIKEY_SET_REQ, 	//zhangfen WIFIKEY±£´æÔÚCP²àNV£¬ÈôNVÒÆµ½AP£¬´ËÏûÏ¢¿ÉÒÔɾ³ý
+	MSG_CMD_WIFIKEY_SET_RSP,	//zhangfen ͬÉÏ
+
+	/**********************ÒÔÏÂΪPSÏà¹ØµÄÖ÷¶¯Éϱ¨ÏûÏ¢ºê***********************************/
+	MSG_CMD_SIM_ABNORMAL_IND, 		//¿ª»ú²éѯÎÞ¿¨£¬¿¨Ë𻵣¬ÐèÒªPIN¡¢PUKʱÉϱ¨
+	MSG_CMD_PDP_STATUS_IND, 		//PDPÁ´Â·×´Ì¬Ö¸Ê¾ "1"PDP¼¤»î "0"PDPÈ¥¼¤»î
+	MSG_CMD_ZPBIC_IND,  			//¿¨³õʼ»¯Íê³ÉÉϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zAt_ZpbicRes
+	MSG_CMD_ZUSLOT_IND,  			//¿¨²å°ÎÐÅÏ¢Éϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zAt_ZuslotRes
+	MSG_CMD_CREG_IND,               //ÍøÂç×¢²á³É¹¦ÏûÏ¢Éϱ¨£¬creg_stat=1 or 5
+
+
+	/**********************ÒÔÏÂΪpsÏà¹ØµÄ·þÎñ¶ËÇëÇóÏûÏ¢ºê***********************************/
+	SERVER_BASE,
+
+	SERVER_END,
+
+	/**********************ÒÔÏÂΪ·ÇPSÏà¹ØµÄ·þÎñ¶ËÇëÇóÏûÏ¢ºê*************************/
+	EXTAT_SERVER_BASE,
+
+	EXTAT_SERVER_END,
+
+	/**********************ÒÔÏÂΪ²»È·¶¨²¿·Ö,δʹÓ㬴ýɾ³ý*************************/
+	MSG_CMD_WEB_REQ_RESET_MODEM,		//Ôݲ»È·¶¨
+	MSG_CMD_WEB_REQ_SERAILPORT_ON,		//Ôݲ»È·¶¨
+	MSG_CMD_WEB_LOG_DIRECTION,			//Ôݲ»È·¶¨
+	MSG_CMD_SIM_INIT_READY,				//Ôݲ»È·¶¨,ÇëÒÆÖÁwifi
+	MSG_CMD_WEB_REQ_TCARDSET,			//t¿¨ÉèÖã¬Ôݲ»È·¶¨
+	MSG_CMD_GET_LOG_DIR,				//Ôݲ»È·¶¨
+	MSG_CMD_GET_LOG_DIR_OK,				//Ôݲ»È·¶¨
+
+
+	/***************¶ÌÐÅÏà¹Ø begin******************************/
+	MSG_CMD_SENDSMS_REQ,    	//·¢ËͶÌÐÅÇëÇó ¶ÔÓ¦½á¹¹ÌåT_zSms_SendSmsReq
+	MSG_CMD_SENDSMS_RSP,
+	MSG_CMD_DELSMS_REQ,     	//ɾ³ý¶ÌÐÅÇëÇó ¶ÔÓ¦½á¹¹ÌåT_zSms_DelSmsReq
+	MSG_CMD_DELSMS_RSP,
+	MSG_CMD_STORAGE_CAP_REQ,  	//ÉÏ²ã´æ´¢ÄÜÁ¦ÇëÇó ¶ÔÓ¦½á¹¹ÌåT_zSms_StroageReq
+	MSG_CMD_STORAGE_CAP_RSP,
+	MSG_CMD_MODIFY_TAG_REQ,    	//Ð޸ĶÌÐÅ״̬ΪÒѶÁ ¶ÔÓ¦½á¹¹ÌåT_zSms_ModifyTagReq
+	MSG_CMD_MODIFY_TAG_RSP,
+	MSG_CMD_READSMS_REQ,      	//¶Á¶ÌÐÅÇëÇó ¶ÔÓ¦½á¹¹ÌåT_zSms_ReadSmsReq
+	MSG_CMD_READSMS_RSP,		//¶Á¶ÌÐÅÏìÓ¦
+	MSG_CMD_SCA_SET_REQ, 		//SCAÉèÖÃÇëÇó ¶ÔÓ¦½á¹¹ÌåT_zSms_SetScaReq
+	MSG_CMD_SCA_SET_RSP,
+	MSG_CMD_NOTIFY_SET_REQ,  	//¶ÌÐÅ֪ͨģʽÉèÖà  ¶ÔÓ¦½á¹¹ÌåT_zSms_NotifySetReq
+	MSG_CMD_NOTIFY_SET_RSP,
+	MSG_CMD_SMSACK_REQ,         //È·È϶ÌÐÅ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsAckReq
+	MSG_CMD_SMSACK_RSP,
+	MSG_CMD_SMSINIT_REQ, 		//¶ÌÐÅÄ£¿é³õʼ»¯
+	MSG_CMD_SMSINIT_RSP,
+
+	MSG_CMD_NEWSMS_IND,     	//жÌÐÅÉϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsInd
+	MSG_CMD_NEWSMS_STATUS_IND,  //жÌÐÅ״̬Éϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsInd
+	MSG_CMD_NEWSMS_INDEX_IND, 	//жÌÐÅindexÉϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsIndexInd
+	MSG_CMD_NEWSMS_STATUS_INDEX_IND,//жÌÐÅ״̬±¨¸æµ½´ïָʾ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsIndexInd
+	MSG_CMD_ZMGR_IND,           //¶Á¶ÌÐÅÖмäÄÚÈÝÖ÷¶¯Éϱ¨  ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsInd
+	MSG_CMD_CSCA_IND,			//¶ÌÐÅÖÐÐĽá¹ûÉϱ¨  ¶ÔÓ¦½á¹¹ÌåT_zSms_CscaInd
+	MSG_CMD_ZMGL_IND,			//¶ÌÐÅÁбíÐÅÏ¢Éϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zSms_SmsInd
+	MSG_CMD_CPMS_IND,    		//¶ÌÐÅ´æ´¢ÇøÒÑÓúÍ×ÜÈÝÁ¿Éϱ¨ ¶ÔÓ¦½á¹¹ÌåT_zSms_CpmsInd
+	/**************¶ÌÐÅÏà¹Ø end**************************/
+
+	/***ÃûƬ¼ÐÏà¹Ø begin****/
+	MSG_CMD_READ_PB_REQ,//¶ÁÈ¡µ¥ÌõÃûƬ¼ÐÇëÇó
+	MSG_CMD_READ_PB_RSP,//¶ÁÈ¡µ¥ÌõÃûƬ¼Ð»Ø¸´
+	MSG_CMD_ADD_MODIFY_PB_REQ,//Ð޸ĵ¥ÌõÃûƬ¼ÐÇëÇó
+	MSG_CMD_ADD_MODIFY_PB_RSP,//Ð޸ĵ¥ÌõÃûƬ¼Ð»Ø¸´
+	MSG_CMD_DELETE_PB_REQ,//ɾ³ýÃûƬ¼ÐÇëÇó
+	MSG_CMD_DELETE_PB_RSP,//ɾ³ýÃûƬ¼Ð»Ø¸´
+	MSG_CMD_PBINIT_REQ,//³õʼ»¯ÃûƬ¼ÐÇëÇó
+	MSG_CMD_PBINIT_RSP,//³õʼ»¯ÃûƬ¼Ð»Ø¸´
+	MSG_CMD_CPBS_IND,//²éѯpbÐÅÏ¢µÄ×Ü´æ´¢Æ÷¸öÊý¡¢ÒÑÓô洢Æ÷¸öÊýÐÅÏ¢
+	MSG_CMD_SCPBR_IND,//²éѯpbµÄÈÝÁ¿¼°´æ´¢ÀàÐÍ
+	MSG_CMD_SCPBR_READ_IND,//²éѯµ¥ÌõpbÐÅÏ¢Öмä¹ý³ÌÉϱ¨
+	/***ÃûƬ¼ÐÏà¹Ø end****/
+
+	//Ìṩ¸øccappʹÓÃ
+	MSG_CMD_ATD_DIAL_REQ,
+	MSG_CMD_ATD_DIAL_RSP,
+	MSG_CMD_ATA_REQ,
+	MSG_CMD_ATA_RSP,
+	MSG_CMD_CHUP_REQ,
+	MSG_CMD_CHUP_RSP,
+	MSG_CMD_VTS_REQ,
+	MSG_CMD_VTS_RSP,
+	MSG_CMD_ZIMSPLUS_REQ,
+	MSG_CMD_ZIMSPLUS_RSP,
+	MSG_CMD_CCFC_REQ,
+	MSG_CMD_CCFC_RSP,
+	MSG_CMD_CHLD_REQ,
+	MSG_CMD_CHLD_RSP,
+	MSG_CMD_CLCK_REQ,
+	MSG_CMD_CLCK_RSP,
+	MSG_CMD_SET_VPLOOP_REQ,
+	/****************/
+	//Ìṩ¸øccappʹÓÃ
+	MSG_CMD_DSCI_IND,
+	MSG_CMD_ZIMSPLUS_IND,
+	MSG_CMD_ZCPI,
+	MSG_CMD_ZVOICECHNL,
+      
+	MSG_CMD_MODEMREG_INFO_REQ,    //ÊÕµ½ZPBICºó´¥·¢Ð­ÒéÕ»¹Ì¶¨ÐÅÏ¢»ñȡʼþÁ´ZICCID CIMI CNUM
+	MSG_CMD_MODEMREG_INFO_RSP,
+	MSG_CMD_ROAM_STATUS_IND,      //ÂþÓÎ״̬·¢Éú±ä»¯Ö¸Ê¾
+
+	/******************Ö÷¶¯Éϱ¨¼°Öмä½á¹ûÉϱ¨********************/
+	MSG_CMD_AUTO_RSP,
+
+	/***************************NV******************************/
+	MSG_CMD_SYNC_NV_REQ,   //AP²à·¢ÆðNVͬ²½ÇëÇ󣬽«nvͬ²½µ½CP
+
+
+	/***************************AT_CTL******************************/
+	MSG_CMD_DATASWITCH_ON_REQ,              //CPÊý¾Ý¿ª¹Ø(²¦ºÅÉÏÍø)֪ͨAP
+	MSG_CMD_DATASWITCH_OFF_REQ,             //CPÊý¾Ý¿ª¹Ø(È¥²¦ºÅ)֪ͨAP
+
+	MSG_CMD_AT_FILTER_REQ,                  //AP֪ͨCPÐèÒª¹ýÂËÖ÷¶¯Éϱ¨µÄATÃüÁî
+	MSG_CMD_SYNC_ATCMD_STREAM,              //AP²à·¢ÆðNVͬ²½£¬ÒòATÃüÁîÁ÷½Ï³¤ÇÒÃüÁ˫ÒýºÅ£¬µ¥¶Àͬ²½
+
+/**------------------------ÒÔÏÂÊÇOPENCPUµÄÏûÏ¢ID-----------------------------**/
+	MSG_CMD_PDP_ACT_REQ,		//pdp¼¤»îÒµÎñÇëÇ󣬶ÔÓ¦½á¹¹ÌåAT_PDP_ACT_INFO
+	MSG_CMD_PDP_ACT_RSP,		//pdp¼¤»îÒµÎñÏìÓ¦£¬¶ÔÓ¦½á¹¹ÌåAT_PDP_ACT_RSP
+	MSG_CMD_PDP_DEACT_REQ,		//pdpÈ¥¼¤»îÒµÎñÇëÇ󣬶ÔÓ¦½á¹¹ÌåAT_PDP_DEACT_INFO
+	MSG_CMD_PDP_DEACT_RSP,		//pdpÈ¥¼¤»îÒµÎñÏìÓ¦£¬¶ÔÓ¦½á¹¹ÌåAT_PDP_DEACT_RSP
+	MSG_CMD_PDP_DEACT_IND,		//pdpÍøÂç²àÈ¥¼¤»îָʾ£¬ÏûϢЯ´øÈ¥¼¤»îµÄcidºÅ
+/**--------------------------------------------------------------------------**/
+	MSG_CMD_QUERY_CGDCONT_REQ,  //оƬÈÏÖ¤°æ±¾²éѯcgdcontÏûÏ¢
+	MSG_CMD_ZUTR_REQ,  //´¦ÀízupciµÄÏìÓ¦
+	MSG_CMD_QUERY_CGCONTRDP_REQ,		//CGCONTRDP²éѯÇëÇó
+	MSG_CMD_ROAM_SET_REQ, 		//webuiÑ¡Ôñroam
+	MSG_CMD_ZCARDSWITCHIND_IND,		//ZCARDSWITCHIND
+	MSG_CMD_VSIMDEBUG_IND, 	//VSIMDEBUG
+};
+#endif
+
+typedef struct {
+	int result;		//´¦Àí½á¹û
+	int errcode;	//´íÎóÂë
+	unsigned short msg_cmd;//ÏûÏ¢ÀàÐÍ
+    int extcid; //channel
+    int act_type; // 0 È¥¼¤»î  1 ¼¤»î
+    char ip[128];//ip
+    int urc_switch; //0 ¹Ø±ÕÖ÷¶¯Éϱ¨  1 ´ò¿ªÖ÷¶¯Éϱ¨
+} AT_COMM_RSPMSG;
+
+//¶ÔÓ¦ÏûÏ¢MSG_CMD_SEND_AT_MSG_REQ
+struct app_send_req_at{
+	char atstr[MSG_DATA_MAX_LEN-12];
+    int  str_len;//¸Ã±äÁ¿ÎªÁ˽â¾ö¶þ½øÖÆÂëÁ÷µÄÖ±½Ó·¢ËÍ£¬ÎÞ·¨Ö±½ÓʹÓÃstrlen
+	int  timeout;
+};
+
+
+/*ÉϲãÓ¦ÓÃÐèÒªÒÔÏûÏ¢ÐÎʽ·¢ËÍÖ÷¶¯Éϱ¨ÃüÁîµ½Íⲿmcu*/
+typedef struct {
+	char autorsp_cmd[MSG_DATA_MAX_LEN-8]; //Êý×鳤¶ÈÊÇÏûÏ¢ÄÚÈÝ×î´ó³¤¶È¼õ2*intÀàÐ͵ij¤¶È
+	int len;
+} AT_AUTORSP_INFO;
+
+/*ÉϲãÓ¦Óô¦ÀíÍê͸´«Êý¾ÝºóµÄÏìÓ¦ÏûÏ¢*/
+typedef struct {
+	char rsp_cmd[MSG_DATA_MAX_LEN - 8];
+	int len;
+} AT_PASSTHROUGH_RSP;
+
+/* ¶ÔÓ¦VOLTEÓëAT_CTLÖ®¼ä½»»¥µÄÏûÏ¢MSG_CMD_FD2_VOLTE_TO_ATCTL/MSG_CMD_FD2_ATCTL_TO_VOLTE */
+typedef struct 
+{
+    char msg_data[MSG_DATA_MAX_LEN-12];
+	int msg_len;
+    int at_fd;
+}VOLTE_MSG_DATA;
+
+
+#endif
+
diff --git a/ap/app/include/at_other_api.h b/ap/app/include/at_other_api.h
new file mode 100755
index 0000000..7240d11
--- /dev/null
+++ b/ap/app/include/at_other_api.h
@@ -0,0 +1,364 @@
+/**

+ * @file at_other_msg.h

+ * @brief ÌṩÁËAT_CTLÖзÇOPENCPUµÄÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ì嶨Òå

+ *

+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.

+ * @author

+ *

+ * This program is free software; you can redistribute it and/or modify

+ * it under the terms of the GNU General Public License version 2 as

+ * published by the Free Software Foundation.

+ *

+ */

+	

+#ifndef __AT_OTHER_API_H__

+#define __AT_OTHER_API_H__

+	

+	

+/*******************************************************************************

+*							 Include header files							   *

+******************************************************************************/

+#include "max_macro.h"

+/*******************************************************************************

+*							   Macro definitions							   *

+******************************************************************************/

+#define ZDIAL_NUM_MAX                48

+

+/*******************************************************************************

+*                             Type definitions                                *

+******************************************************************************/

+typedef struct {

+	unsigned char	pduLen;

+	char	pdu[1024];

+	unsigned char	seq;

+} T_zAt_CsimRes;

+	

+

+

+/**

+ * @brief ¿¨²å°ÎÐÅÏ¢Éϱ¨£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_ZUSLOT_IND

+ * @param slot£¬¿¨²Û ȡֵ·¶Î§ 0,1,2

+ * @param slot_state, ¿¨×´Ì¬ 0 °Î¿¨ 1 ²å¿¨

+ */

+typedef struct {

+	long  slot;

+	long  slot_state;

+} T_zAt_ZuslotRes;

+

+

+/**

+ * @brief PINÂëÑéÖ¤ÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_VERIFY_PIN_REQ/MSG_CMD_VERIFY_PUK_REQ

+ * @param pin»òpin2£¬µ±Ç°ÃÜÂëÊäÈëÇëÇóΪPIN»òPIN2£¬ÔòÊäÈë+CPIN=<pin>½øÐÐУÑé

+ * @param newpin, µ±Ç°ÃÜÂëÊäÈëÇëÇóΪPUK»òPUK2£¬ÔòÊäÈë+CPIN=<pin>,<newpin>½øÐнâËø£¬

+ * µÚÒ»¸ö²ÎÊýpinΪSIM PUKÂë»òÕßSIM PUK2Â룬µÚ¶þ¸ö²ÎÊýnewpinΪеÄPINÂë»òPIN2Âë

+ */

+typedef struct {

+	char	pin[10];

+	char	newpin[10];

+} T_zAt_CpinPukSet;

+

+

+/**

+ * @brief PINÂë¹ÜÀíÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_PIN_MANAGE_REQ

+ * @param action£¬²Ù×÷ÀàÐÍ 0 ¹Ø±Õ 1 ´ò¿ª 2 ÐÞ¸Ä

+ * @param oldPin, ¹Ø±Õ/´ò¿ªÊ±ÊäÈëµÄPINÂ룬ÐÞ¸ÄʱÊäÈëµÄ¾ÉPINÂë

+ * @param newPin ÐÞ¸ÄʱÊäÈëµÄÐÂPINÂë

+ */

+typedef struct {

+	unsigned int action;		   /*¶¯×÷ÀàÐÍ£¬enable, disable, modify*/

+	char  oldPin[10];

+	char  newPin[10];

+} T_zAt_PinManage;

+

+

+/**

+ * @brief ¿¨³õʼ»¯½á¹û£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_ZPBIC_IND

+ * @param result£¬0 ʧ°Ü 1 ³É¹¦

+ * @param opertype, ÒµÎñÀàÐÍ 0 ¶ÌÐÅ 1 µç»°±¾ 2 È«²¿

+ */

+typedef struct {

+	long result;

+	long opertype;

+} T_zAt_ZpbicRes;

+

+

+/*****************¶ÌÐÅÏà¹ØÏûÏ¢¶ÔÓ¦½á¹¹Ìå begin*****************************/

+

+/**

+ * @brief ·¢ËͶÌÐÅÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_SENDSMS_REQ

+ * @param length£¬¶ÌÐÅÄÚÈݳ¤¶È

+ * @param pdu, pdu

+ */

+typedef struct {

+	int 	length;

+	char	pdu[ZSMS_PDU_SIZE];

+} T_zSms_SendSmsReq;

+

+/**

+ * @brief ɾ³ý¶ÌÐÅÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_DELSMS_REQ

+ * @param index£¬´ýɾ¶ÌÐÅË÷Òý

+ */

+typedef struct {

+	int 	index;

+} T_zSms_DelSmsReq;

+

+

+/**

+ * @brief ÉèÖÃÉϲã¿Õ¼ä±ä³É¿ÉÓûò²»¿ÉÓ㬶ÔÓ¦ÏûÏ¢MSG_CMD_STORAGE_CAP_REQ

+ * @param type	0 ²»Âú  1 Âú

+ */

+typedef struct {

+	int 	type;

+} T_zSms_StroageReq;

+

+

+/**

+ * @brief ½«¶ÌÐÅ´Óδ¶Á״̬±ä³ÉÒѶÁ£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_MODIFY_TAG_REQ

+ * @param index£¬¶ÌÐÅË÷Òý

+ */

+typedef struct {

+	int 	index;

+} T_zSms_ModifyTagReq;

+

+

+/**

+ * @brief ¶Á¶ÌÐÅÇëÇó½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_READSMS_REQ

+ * @param index£¬¶ÌÐÅË÷Òý

+ */

+typedef struct {

+	int 	index;

+} T_zSms_ReadSmsReq;

+

+

+/**

+ * @brief ÉèÖöÌÐÅÖÐÐÄ£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_SCA_SET_REQ

+ * @param sca£¬¶ÌÐÅÖÐÐĺÅÂë

+ */

+typedef struct {

+	char sca[22];

+} T_zSms_SetScaReq;

+

+

+/**

+ * @brief жÌÐÅ֪ͨÉèÖ㬶ÔÓ¦ÏûÏ¢MSG_CMD_NOTIFY_SET_REQ

+ * @param mt£¬Ö¸Ê¾Ð¶ÌÐŵ½´ïʱµÄָʾ·½Ê½

+ */

+typedef struct {

+	int mt;

+} T_zSms_NotifySetReq;

+

+

+/**

+ * @brief жÌÐÅÈ·ÈÏ£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_SMSACK_REQ

+ * @param ackmode£¬ÏìÓ¦·½Ê½

+ * @param length£¬PDUµÄ³¤¶È

+ * @param pdu£¬SMSCµØÖ·ºÍTPDUÊý¾Ý°ü

+ */

+typedef struct {

+	int   ackmode;

+	int   length;

+	char  pdu[50];

+} T_zSms_SmsAckReq;

+

+

+/**

+ * @brief ¶ÌÐŲÙ×÷½á¹û£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_SENDSMS_RSP

+ *		/MSG_CMD_DELSMS_RSP /MSG_CMD_STORAGE_CAP_RSP

+ *		/MSG_CMD_MODIFY_TAG_RSP/MSG_CMD_NOTIFY_SET_RSP/MSG_CMD_SCA_SET_RSP

+ *		/MSG_CMD_SMSACK_RSP/MSG_CMD_SMSINIT_RSP

+ * @param result£¬1 ³É¹¦  ÆäËû ʧ°Ü

+ */

+typedef struct {

+	int   result;

+} T_zSms_optRsp;

+

+

+/*¶ÔÓ¦ÏûÏ¢ MSG_CMD_NEWSMS_STATUS_IND MSG_CMD_ZMGR_IND MSG_CMD_READSMS_RSP*/

+/**

+ * @brief жÌÐÅÉϱ¨£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_NEWSMS_STATUS_IND/MSG_CMD_ZMGR_IND

+ * @param index£¬¶ÌÐÅÔÚ´æ´¢ÇøÖеÄË÷ÒýºÅ

+ * @param stat£¬´æ´¢Æ÷ÖжÌÏûÏ¢µÄÐÅϢ״̬

+ * @param alpha£¬²ÎÊýÄÚÈÝÊÜ+CSCSÃüÁî¿ØÖÆ

+ * @param length£¬pdu³¤¶È

+ * @param pdu£¬pdu

+ */

+typedef struct {

+	int 	index;

+	int 	stat;

+	char	alpha[36];

+	int 	length;

+	char	pdu[ZSMS_PDU_SIZE];

+} T_zSms_SmsInd;

+

+

+/**

+ * @brief жÌÐÅindexÉϱ¨£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_NEWSMS_INDEX_IND/MSG_CMD_NEWSMS_STATUS_INDEX_IND

+ * @param storetype£¬¶ÌÏûÏ¢½ÓÊÕµÄ´æ´¢Çø

+ * @param index£¬´æ´¢Î»ÖÃÐòºÅ

+ */

+typedef struct {

+	char	storetype[10];

+	int 	index;

+} T_zSms_SmsIndexInd;

+

+

+/**

+ * @brief ¶ÌÐÅÖÐÐÄÉϱ¨£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_CSCA_IND

+ * @param sca£¬¶ÌÐÅÖÐÐĵØÖ·

+ * @param tosca£¬<sca>µÄÀàÐÍ

+ */

+typedef struct {

+	char sca[22];

+	char tosca[22];

+} T_zSms_CscaInd;

+

+

+/**

+ * @brief ¶ÌÐÅ´æ´¢ÇøÐÅÏ¢£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_CPMS_IND

+ * @param used£¬ÒÑÓÃÌõÊý

+ * @param total£¬×ܹ²¿ÉÈÝÄÉÌõÊý

+ */

+typedef struct {

+	int used;

+	int total;

+} T_zSms_CpmsInd;

+/*****************¶ÌÐÅÏà¹ØÏûÏ¢¶ÔÓ¦½á¹¹Ìå end*****************************/

+

+

+/************ÃûƬ¼ÐÏà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåbegin***********/

+/*µ¥ÌõcontactÐÅÏ¢£¬¶ÔÓ¦ÏûÏ¢MSG_CMD_READ_PB_RSP*/

+typedef struct {

+	char    number1[42];

+	char    number2[42];

+	char    number3[42];

+	char    number4[42];

+	char    text[182];

+	char    email[182];

+	unsigned char   coding;

+	unsigned char   num1Type;

+	unsigned char   num2Type;

+	unsigned char   num3Type;

+	unsigned char   num4Type;

+	unsigned int  index;

+} T_zPb_ScpbrSetRes;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_READ_PB_REQ*/

+typedef struct {

+	int minIndex;//ɾ³ýpb¿ªÊ¼Î»ÖÃ

+	int maxIndex;//ɾ³ýpb½áÊøÎ»ÖÃ

+} T_zPb_ScpbrReadRes;

+

+typedef struct {

+	int      pbIndex;

+	int      coding;

+	char        name[185];

+	char        mobilNumber[42];

+	char        officeNumber[42];

+	char        homeNumber[42];

+	char        faxNumber[42];

+	char        email[182];

+} T_zPb_ScpbwParam;

+

+/*¶ÔÓ¦ÏûÏ¢ ²Ù×÷½á¹û*/

+typedef struct {

+	int   result;

+} T_zPb_optRsp;

+

+/*²éѯpbÐÅÏ¢µÄ×Ü´æ´¢Æ÷¸öÊý¡¢ÒÑÓô洢Æ÷¸öÊýÐÅÏ¢£¬Öмä½á¹ûÉϱ¨*/

+typedef struct {

+	char   locType[10];

+	unsigned int  usedEntries;

+	unsigned int  totalEntries;

+} T_zPb_AtCpbsReadRes;

+/*²éѯpbÐÅÏ¢µÄ×î´óË÷Òý¡¢³¤¶ÈµÈÐÅÏ¢£¬Öмä½á¹ûÉϱ¨*/

+typedef struct {

+	int  minIndex;

+	int  maxIndex;

+	int  maxNumberLen;

+	int  maxTextLen;

+	int  maxEmailLen;

+} T_zPb_AtScpbrTestRes;

+/************ÃûƬ¼ÐÏà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåend***********/

+

+/************ccappÏà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåbegin***********/

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_ATD_DIAL_REQ*/

+typedef struct {

+	char    number[ZDIAL_NUM_MAX];

+} T_zCcapp_CallMoReq;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_VTS_REQ*/

+typedef struct {

+	char    dtmfchar;

+} T_zCcapp_VtsReq;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_ZIMSPLUS_REQ*/

+typedef struct {

+	unsigned int     setfg;

+	unsigned int     act;

+} T_zCcapp_ImsplusReq;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_CLCK_REQ*/

+typedef struct {

+	unsigned int     type;

+	unsigned int     act;

+	char     pw[5];

+} T_zCcapp_ClckReq;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_CCFC_REQ*/

+typedef struct {

+	unsigned int     type;

+	unsigned int     act;

+	char     dn[ZDIAL_NUM_MAX];

+} T_zCcapp_CcfcReq;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_CCFC_REQ*/

+typedef struct {

+	unsigned int     type;

+} T_zCcapp_ChldReq;

+

+/*¶ÔÓ¦ÏûÏ¢ ²Ù×÷½á¹û*/

+typedef struct {

+	int   result;

+} T_zCcapp_optRsp;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_DSCI_IND*/

+typedef struct {

+	unsigned int     cid;

+	unsigned int     dir;

+	unsigned int     state;

+	unsigned int     inMpty;

+	char    num[ZDIAL_NUM_MAX];

+} T_zCcApp_DsciInd;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_ZIMSPLUS_IND*/

+typedef struct {

+	unsigned int     act;

+	unsigned int     rate;

+} T_zCcApp_ImsplusInd;

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_ZCPI*/

+typedef struct {

+	unsigned int     cid;

+	unsigned int     state;

+	unsigned int     progdsp;

+} T_zCcApp_ZcpiInd;

+

+

+

+

+

+/*¶ÔÓ¦ÏûÏ¢MSG_CMD_ZVOICECHNL*/

+typedef struct {

+	unsigned int     op; //0-close,1-open

+	unsigned int     act; //   3-gsm,  5-w, 15-tds, 17-lte

+	unsigned int     codetype; //0-nb, 1-wb

+    	unsigned int     amrpath;  //0-teak, 1-softlib

+} T_zCcApp_VoiceChnl;

+

+

+

+

+

+

+/************ccappÏà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåend***********/

+#endif

diff --git a/ap/app/include/at_pdp_api.h b/ap/app/include/at_pdp_api.h
new file mode 100755
index 0000000..1b8b2da
--- /dev/null
+++ b/ap/app/include/at_pdp_api.h
@@ -0,0 +1,100 @@
+/**

+ * @file at_pdp_api.h

+ * @brief ÌṩÁËPDPµÄOPENCPUÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ì嶨Òå

+ *

+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.

+ * @author

+ *

+ * This program is free software; you can redistribute it and/or modify

+ * it under the terms of the GNU General Public License version 2 as

+ * published by the Free Software Foundation.

+ *

+ */

+	

+#ifndef __AT_PDP_API_H__

+#define __AT_PDP_API_H__

+	

+	

+/*******************************************************************************

+*							 Include header files							   *

+******************************************************************************/

+

+/*******************************************************************************

+*							   Macro definitions							   *

+******************************************************************************/

+

+/*******************************************************************************

+*                             Type definitions                                *

+******************************************************************************/

+

+

+/**

+* @brief pdp¼¤»îÐÅÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_PDP_ACT_REQ

+* @param ip_type IPÀàÐÍ£¬È¡ÖµÎª×Ö·û´®£¬"IP","IPV6","IPV4V6"£¬×¢ÒâÈ«²¿ÊÇ´óд£¬±ØÐëÌîд

+* @param apn ÍøÂç½ÓÈëµãÃû³Æ£¬±ØÐëÌîд

+* @param username Óû§Ãû£¬ÐèÒª¼øÈ¨Ê±Ìîд

+* @param password ÃÜÂ룬ÐèÒª¼øÈ¨Ê±Ìîд

+* @param challenge ¼øÈ¨·½Ê½ÊÇCHAP_AUTHʱʹÓã¬ÐèÒª¼øÈ¨Ê±Ìîд

+*/

+typedef struct {

+	char ip_type[10];

+	char apn[100];

+	int  auth_type;

+	char username[65];

+	char password[65];

+	char challenge[50];

+	//int cfgt;//ÿ°ü·¢Ë͵ȴýʱ¼ä

+	//int cfgp;//Êý¾Ý°ü±»·¢Ë͵ÄÃÅÏÞÖµ

+} AT_PDP_ACT_REQ_INFO;

+

+/*Íⲿģ¿é·¢ËÍMSG_CMD_PDP_ACT_REQ£¬½á¹¹ÌåAT_PDP_ACT_INFOת»»³ÉÄÚ²¿Ê¹ÓõĽṹÌåstruct pdp_act_req*/

+struct pdp_act_req

+{

+	/*char ip_type[10];	

+    char apn[70];	

+	int  auth_type;		

+    char username[65];

+    char password[65];

+    char challenge[50];		

+	//int at_fd;    */

+	//½«Íⲿpdp¼¤»îÏûÏ¢ÖÐЯ´øµÄÄÚÈÝ£¬×÷ΪͨÓÃpdp¼¤»îÐÅÏ¢£¬volte_param2ºÍppp_cid×÷Ϊat_ctlÄÚ²¿¶¨ÖƲÎÊýʹÓÃ

+	AT_PDP_ACT_REQ_INFO comm_info;

+	int ext_cid;	//ÓÃÓÚÍⲿģ¿éÖ¸¶¨cid ppp²¦ºÅ£¬½øÐÐPDP_EXT×éÍø£¬¸Ãcid±ØÐëʱԤÁôcid

+	int volte_param1;

+	int volte_param2;

+	int volte_param3;

+	int ppp_cid;//½öÓÃÓÚppp²¦ºÅʱºòÖ¸¶¨cidʹÓã¬ÆäËûʱºò¾ùΪ0

+	char default_flag;

+};

+

+/**

+ * @brief pdpÈ¥¼¤»îÐÅÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_PDP_DEACT_REQ

+ * @param c_id  pdpÉÏÏÂÎĵıêʶ

+ */

+typedef struct {

+	int c_id;

+} AT_PDP_DEACT_REQ_INFO;

+

+

+/**

+ * @brief pdp¼¤»îÏìÓ¦ÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_PDP_ACT_RSP

+ * @param result  ½á¹ûÂë AT_RSP_OK/AT_RSP_ERR

+ * @param cid  pdpÉÏÏÂÎĵıêʶ

+ * @param errcode  Èç¹ûpdp¼¤»îʧ°Ü£¬·µ»Ø´íÎóÂë

+ */

+typedef struct {

+	int result;

+	int cid;

+	int errcode;

+} AT_PDP_ACT_RSP_INFO;

+

+

+/**

+ * @brief pdpÈ¥¼¤»îÏìÓ¦ÏûÏ¢½á¹¹Ì壬¶ÔÓ¦ÏûÏ¢MSG_CMD_PDP_DEACT_RSP

+ * @param result  ½á¹ûÂë AT_RSP_OK/AT_RSP_ERR

+ */

+typedef struct {

+	int result;

+} AT_PDP_DEACT_RSP_INFO;

+

+#endif

diff --git a/ap/app/include/at_reg.h b/ap/app/include/at_reg.h
new file mode 100755
index 0000000..107b571
--- /dev/null
+++ b/ap/app/include/at_reg.h
@@ -0,0 +1,48 @@
+/**
+ * @file at_reg.h
+ * @brief Ìṩat_ctlÄ£¿é¿Í»§¶ËºÍ·þÎñ¶Ë×¢²á½Ó¿Ú
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __AT_REG_H__
+#define __AT_REG_H__
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+
+
+/**
+ * @brief ·¢ÍùPS,atÉÏÏÂÎĺÍatͨµÀµÄpositionΪNEAR_PS£¬Ô¶ÀëPS²àatÉÏÏÂÎĺÍatͨµÀµÄpositionΪFAR_PS
+ * ָʾCPUºËÄÚµÄATͨµÀµÄ·½Î»£¬ÒÔPSЭÒéÕ»µÄÔ¶½ü×÷Ϊ²ÎÕÕÎï¡£
+ * @param NEAR_PS ¿¿½üPSЭÒéÕ»²àµÄATͨµÀ£¬ÀýÈçAPºËÄÚ¹²ÏíDDRÐéÄâµÄATͨµÀ
+ * @param FAR_PS Ô¶ÀëPSЭÒéÕ»µÄATͨµÀ£¬ÀýÈçAPºËÄÚUSBö¾ÙµÄATͨµÀ,uartͨµÀ
+ * @param POSITION_VOLTE ÓëvolteÄ£¿éͨÐŵÄptyͨµÀλÖÃ
+ * @param POSITION_MAX ÉÏÏÞºê
+ */
+enum at_channel_site {
+	FAR_PS = 0,    //Ô¶ÀëPSЭÒéÕ»µÄATͨµÀ£¬ÀýÈçAPºËÄÚUSBö¾ÙµÄATͨµÀ
+	NEAR_PS,       //¿¿½üPSЭÒéÕ»²àµÄATͨµÀ£¬ÀýÈçAPºËÄÚ¹²ÏíDDRÐéÄâµÄATͨµÀ
+	POSITION_VOLTE, //ÓëvolteÄ£¿éͨÐŵÄptyͨµÀλÖÃ
+	POSITION_MAX,  //ÉÏÏÞºê
+};
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+  µçÐÅÖ÷¿Ø·¢ËÍÇëÇóµÄÓ¦´ð½á¹û¸øÍⲿ£¬µ±Ä¿±êÄ£¿éIDΪ¾ä±úʱ£¬×é×°Ó¦´ðATÃüÁîдATͨµÀ£»·ñÔò·¢ËÍÏûÏ¢¸øÄ¿±êÄ£¿é
+  */
+int send_rsp_msg(int dst_id, unsigned short req_cmd, unsigned short rsp_cmd, unsigned short datalen, unsigned char *pData);
+
+#endif
+
+
diff --git a/ap/app/include/at_utils.h b/ap/app/include/at_utils.h
new file mode 100755
index 0000000..fbc210a
--- /dev/null
+++ b/ap/app/include/at_utils.h
@@ -0,0 +1,304 @@
+/**
+ * @file at_utils.h
+ * @brief Ìṩ¸øÓ¦ÓÃʹÓõÄsoftapƽ̨¹«¹²½Ó¿Ú
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __AT_UTILS_H__
+#define __AT_UTILS_H__
+#include "os_type_def.h"
+#include "softap_api.h"
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+ * @brief ¶¨ÒåATÉÏÏÂÎĵ±Ç°´¦ÀíµÄ״̬»ú£¬ÒÔ¾ö¶¨ÏÂÒ»²½´¦Àí
+ * @param AT_END          ATÁ÷³Ì½áÊø£¬¿Í»§¶Ë¿ÉÒÔÏòÉϲãapp·¢ËÍÏìÓ¦ÏûÏ¢£¬·þÎñ¶ËÐèÒªÏòatͨµÀ·¢ËÍatÏìÓ¦ÃüÁî
+ * @param AT_CONTINUE     AT½»»¥Á÷³Ì¼ÌÐø
+ * @param AT_END_AND_MSG  ÓÃÓÚ·þÎñ¶ËÊÕµ½ATÇëÇóºó£¬Á¢¼´»Ø¸´OK½á¹ûÂ룬ͬʱ»¹Ðè·¢ËÍÏûÏ¢¸ø·þÎñ¶ËAPP
+ * @param AT_STATE_MAX    ÉÏÏÞºê
+ */
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+enum at_context_state {
+	AT_END = 0, //ATÁ÷³Ì½áÊø£¬¿Í»§¶Ë¿ÉÒÔÏòÉϲãapp·¢ËÍÏìÓ¦ÏûÏ¢£¬·þÎñ¶ËÐèÒªÏòatͨµÀ·¢ËÍatÏìÓ¦ÃüÁî
+	AT_CONTINUE,//AT½»»¥Á÷³Ì¼ÌÐø
+	AT_END_AND_MSG,//ÓÃÓÚ·þÎñ¶ËÊÕµ½ATÇëÇóºó£¬Á¢¼´»Ø¸´OK½á¹ûÂ룬ͬʱ»¹Ðè·¢ËÍÏûÏ¢¸ø·þÎñ¶ËAPP
+	AT_WAIT_AUTO,//ÓÃÓÚÊÕµ½Ó¦´ðºó£¬ÉÐδ»ñÈ¡µ½ÏëÒªµÄÖ÷¶¯Éϱ¨Ê±£¬·µ»Ø¸ÃÖµ£»Ä¿Ç°½öÓÃÓÚPDP¼¤»îµÄzgipdnsÖ÷¶¯Éϱ¨³ÙÓÚOKºóÉϱ¨µÄÇé¿ö
+	AT_STATE_MAX,//ÉÏÏÞºê
+};
+#endif
+
+/**
+ * @brief ´¦Àí×÷Ϊ·þÎñ¶ËµÄÊÕµ½µÄÇëÇóÃüÁî¡£¶ÔÓÚat_ctl±¾µØµÄ·þÎñ¶Ë£¬ÊÕµ½ÇëÇóÖ®ºó£¬×÷Ϊͬ²½´¦Àí·½Ê½Ö±½ÓÔڸú¯ÊýÖд¦Àí£¬²¢·µ»Øok
+ *¶ÔÓÚDEMO·þÎñ¶Ë(¿Í»§¶þ´Î¿ª·¢×¢²áµÄ·þÎñ¶Ë)ÊÕµ½µÄÇëÇ󣬱ØÐëͨ¹ýÒì²½ÏûÏ¢µÄ·½Ê½£¬ÓÉDEMOµÄAPP·þÎñ¶Ëͨ¹ýÏûÏ¢½øÐÐÓ¦´ð
+ * @param at_fd 		 ½ÓÊÕATÃüÁîµÄͨµÀ
+ * @param at_paras		 ATÃüÁî²ÎÊý
+ * @param res_msg		 ÈôΪͬ²½´¦Àí·½Ê½£¬res_msgΪ»Ø¸´µÄ½á¹ûÂ룻ÈôΪÒì²½´¦Àí·½Ê½£¬res_msgΪATÃüÁîת»»ºóµÄÏûÏ¢½á¹¹Ìå
+ * @param res_msglen	 ²ÎÊýres_msgµÄ³¤¶È
+ * @return intÐͽá¹ûÂë   ·µ»Øenum at_context_stateö¾ÙÖµ£¬AT_END±íʾͬ²½Ó¦´ð·½Ê½£»AT_CONTINUE±íʾÒì²½Ó¦´ð·½Ê½,ÓÉ¿ò¼Ü¾ö¶¨ÏÂÒ»²½´¦Àí
+ * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c
+ */
+typedef int (*ser_req_func2)(int at_fd, char *at_paras, void ** res_msg, int *res_msglen);
+
+
+/**
+ * @brief ·þÎñ¶ËAPP·¢Ë͵ÄÓ¦´ðÏûÏ¢µÄATÃüÁî·â×°£¬×îÖÕ×é×°³ÉATÓ¦´ðÃüÁîºó£¬´Óat_fdͨµÀ·¢Ë͸øÔ¶¶Ë¿Í»§¶Ë
+ * @param rsp_msg		 APP·¢Ë͵ÄÓ¦´ðÏûÏ¢ÄÚÈÝ
+ * @param ret			 ATÃüÁî
+ * @param retlen		 ATÃüÁ¶È
+ * @return intÐͽá¹ûÂë   ·µ»Øenum at_context_stateö¾ÙÖµ
+ * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c
+ */
+typedef int (*app_rsp_proc)(void *rsp_msg, void**ret, int *retlen);
+
+/**
+ * @brief ¶ÔÓÚÉϱ¨atÃüÁî´¦Àíº¯Êý£¬°üº¬²éѯÖмä½á¹ûºÍÖ÷¶¯Éϱ¨µÄatÃüÁî´¦Àí
+ *	¶ÔÓÚpsÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨£¬Ò»°ãÎÞÐ轫Éϱ¨ÄÚÈÝ·¢Ë͸øÆäËûÄ£¿éÓ¦Óã¬Òò´Ë¾¡Á¿Ê¹ÓÃnvºÍÈ«¾Ö±äÁ¿µÄ·½Ê½´æ·Å
+ *	¶ÔÓÚÀ©Õ¹atµÄÖмä½á¹ûÉϱ¨£¬Ò»°ãÐèÒª½«²éѯ½á¹û·¢Ë͸øÆäËûÄ£¿éÓ¦Ó㬶¯Ì¬ÉêÇëÄڴ棬·ÅÔÚcontextÉÏÏÂÎÄÖеÄapp_para±äÁ¿ÖÐ
+ * @param at_paras	ATÃüÁî×Ö·û´®
+ * @return charÐÍ×Ö·û´®£¬±íʾת»»ºóµÄatÃüÁî²ÎÊý
+ * @note
+ * at_paraÖ¸ÏòÈ¥µôATÃüÁîÍ·²¿ºóµÄµÚÒ»¸ö×Ö·û£¬¼´¡®£º¡¯
+ * ·µ»ØµÄATÃüÁîÒ²ÊÇ': '¿ªÍ·µÄATÃüÁî²ÎÊý£¬ 
+ * Àý£º+CSQ: <rssi>,<ber>,<act>, at_paraΪ: <rssi>,<ber>,<act>, ·µ»Ø: <rssi>,<ber>
+ */
+
+typedef char * (*format_inform_func)(char *at_paras);
+
+
+/**
+ * @brief Éú³Éat¶¯×÷ÇëÇóÃüÁî
+ * @param cmd	 ATÃüÁîÇëÇóÃû³Æ
+ * @param param  ATÃüÁîÇëÇó²ÎÊý
+ * @return at¶¯×÷ÇëÇó×Ö·û´®µÄÖ¸Õë
+ * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ
+ */
+char* at_act_build(char* cmd, char* param);
+
+/**
+ * @brief Éú³Éat²éѯÇëÇóÃüÁî
+ * @param cmd	ATÃüÁîÇëÇóÃû³Æ
+ * @return at²éѯÇëÇó×Ö·û´®µÄÖ¸Õë
+ * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ
+ */
+char* at_query_build(char* cmd);
+
+
+/**
+ * @brief  Éú³Éat²éѯÇëÇóÃüÁîµÄÏìÓ¦ÃüÁµ±ÓÐÖмä½á¹ûÉϱ¨Ê±£¬ÔÚser_ops_t2µÄrsp_actµ÷Óã¬
+ * ¸Ãº¯ÊýÖн«ÖмäÉϱ¨½á¹ûºÍokatÃüÁî×é×°ÔÚÒ»Æð£¬Í¨¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø
+ * ¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ
+ * @param cmd	ATÃüÁîÏìÓ¦Ãû³Æ
+ * @param param  ATÃüÁîÏìÓ¦²ÎÊý
+ * @return at¶¯×÷ÏìÓ¦×Ö·û´®µÄÖ¸Õë
+ * @note input:  cmd  "xx"   
+ *           	param    "yy,zz" 
+ *       output:   \r\n+xx:yy,zz\r\n
+ */
+char* at_query_result_build(char* cmd, char* param);
+
+
+
+/**
+ * @brief Éú³ÉatÏìÓ¦½á¹ûOKº¯Êý
+ * @return atÏìÓ¦½á¹ûOK×Ö·û´®µÄÖ¸Õë
+ * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ
+ */
+char* at_ok_build();
+
+
+/**
+* @brief atÃüÁî½âÎö
+* @param fmt ÿ¸ö²ÎÊýÊä³öµÄÊý¾Ý¸ñʽ
+* @param buf ԭʼÊý¾Ý
+* @param pval Êä³ö¸ñʽ»¯ºóÊý¾ÝÖµ
+* @return ¿ÉÒÔÕýÈ·½âÎö²ÎÊýµÄ¸öÊý
+* @note ¸ñʽ½öÖ§³Ö%dºÍ%s,ͬʱ¿ÉÒÔÔÚÿ¸ö¸ñʽǰ¼ÓÉÏÊý×ÖÒÔÖ¸¶¨
+	 ±äÁ¿¿ÉÒÔ¸³ÖµµÄ¿Õ¼ä´óС£¬µ¥Î»Îª×Ö½Ú£¬ÀýÈç%2d±íʾ½ÓÊÜ´æ´¢¿Õ¼äΪ2×Ö½Ú£»%5s±íʾËãÉÏ'\0'£¬×î¶à¿ÉÒÔ
+	 ½ÓÊÜ5¸ö×Ö·û¡£µ±%d²»Ö¸¶¨Êý×Öʱ£¬°´ÕÕ4×Ö½Ú½øÐи³Öµ£¬%sÔò°´ÕÕʵ¼Ê½âÎöµÄ×Ö·û´®³¤¶ÈÍêÈ«¸³Öµ£¬ÓпÉÄÜ
+	 »áÓÐÔ½½ç¡£
+*ʾÀý
+<pre>
+	char buf[]="1,2,\"test\"";
+	int n1 = 0;
+	int n2 = 0;
+	char *n3 = malloc(strlen(buf));
+	char *p[] = {&n1,&n2,n3};
+	ret = parse_param2("%d,%d,%s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="test"	 
+	ret = parse_param2("%4d,%d,%3s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="te"	 
+	retµÄֵΪ3
+</pre>
+*/
+int parse_param2(char *fmt, char *buf, void **pval);
+
+
+/**
+ * @brief ATÃüÁî½âÎö½Ó¿Ú
+ * @param fmt ATÇëÇó»òÏìÓ¦µÄ¸ñʽ»¯·½Ê½
+ * @param buf  ATÇëÇó»òÏìÓ¦µÄ×Ö·û´®Ö¸Õë²»º¬Í·²¿ºÍ¿Õ¸ñ
+ * @param pval	¸ñʽ»¯ºóµÄATÃüÁî
+ * @return 0±íʾ½âÎö²ÎÊýÕý³££¬ÄÚ²¿½øÐÐÑϸñµÄ²ÎÊý¼ì²é£¬°üÀ¨²ÎÊý¸öÊýÒ»ÖÂÐÔ¼ì²é£¬¶ÔÓÚ¿ÉÑ¡²ÎÊý£¬ÐèÒªµ÷ÓÃÕß×ÔÐп¼ÂÇ
+ * @note  
+ * 1. ½âÎöµÄATÃüÁî±ØÐë°´ÕÕ3GPP27007±ê׼ЭÒ飬²ÎÊýÒÔ¶ººÅ¸ô¿ª£¬×Ö·û´®Ðè´øË«ÒýºÅ£¬·ñÔò»á¶ÏÑÔ
+ * 2. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç
+ * 3. ·µ»ØÖµÇë²Î¿¼Ã¶¾Ùenum SAP_ERR£¬º¬¿ÉÑ¡²ÎÊýÒ»ÖÂÐÔ¼ì²é
+ * 4. ÈôfmtÖ¸¶¨µÄ²ÎÊýÀàÐͱØÐëÓëpvalÖÐÖ¸ÕëµÄÒ»Ò»¶ÔÓ¦
+ * 5. ʾÀý
+<pre>
+	char buf[]="1,2,\"test\"";
+	int n1 = 0;
+	int n2 = 0;
+	char *n3 = malloc(strlen(buf));
+	char *p[] = {&n1,&n2,n3};
+	ret = parse_param_safe("%d,%d,%s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="test"	 
+	ret = parse_param_safe("%4d,%d,%3s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="te"	 
+</pre>
+ * @warning 
+ */
+int  parse_param_safe(char *fmt, char *buf, void **pval);
+
+
+/**
+ * @brief Ó¦Ó÷¢ËͶ¯×÷Àà»ò²éѯÀàATÇëÇó¸ø3GPPЭÒéÕ»£¬²¢³¬Ê±µÈ´ý¶¯×÷½á¹û£»×¢Ò⣺¸Ã½Ó¿ÚÖ»ÄÜÓÃÓÚ²éѯºÍÉèÖúÍÖ´ÐÐÇëÇó£¬Í¨¹ýÈë²Î½øÐÐÖмä½á¹ûµÄÄÚ²¿½âÎö´¦Àí£¬²¢ÇÒ
+		  ÓÐÖмä½á¹ûÉϱ¨Ê±£¬Ö»Ö§³ÖÒ»ÌõÖмä½á¹ûµÄÉϱ¨½âÎö£»
+ * @param req_at  ÇëÇóATÃüÁ´óСдÃô¸Ð£¬±ØÐë´óд
+ * @param info_fmt ATÏìÓ¦µÄ¸ñʽ»¯·½Ê½
+ * @param pval	¸ñʽ»¯ºóµÄATÏìÓ¦£¬¾ßÌåʹÓòο´parse_param½Ó¿Ú
+ * @param safe_parm_check	ָʾÊÇ·ñ¶Ô²ÎÊý¸öÊý½øÐÐÒ»ÖÂÐÔ¼ì²é£¬0±íʾº¬¿ÉÑ¡²ÎÊý£¬²»¶Ô²ÎÊý¸öÊý½øÐмì²é;1±íʾ¶Ô²ÎÊý¸öÊý½øÐÐÑϸñ¼ì²é
+ * @param timeout timeout==0 ±íʾÓÀ¾ÃµÈ´ý½á¹ûÂ룬·ñÔòµÈ´ýʱ¼äΪ[timeout]Ãë
+ * @return 0±íʾ·µ»Ø³É¹¦£¬ÆäËûÖµ±íʾʧ°Ü´íÎóÂë
+ * @note  
+ * 1. Óû§Ê¹ÓÃʱ£¬Èô²»ÏëÓɸýӿÚÄÚ²¿½øÐвÎÊýµÄ¸ñʽ»¯½âÎö£¬¿ÉÒÔ½«info_fmt¸³ÖµÎª"%s"£¬pval¸³ÖµÎªchar **p˫ָÕ룬ÕâÑù²ÎÊý½«×÷ΪÕûÌå×Ö·û´®·µ»Ø¸øµ÷ÓÃÕß
+ * 2. ¶ÔÓÚZMGL,CPBR, COPS=?µÈÒ»ÌõÇëÇó»áÓжàÌõÖмä½á¹ûÇé¿ö£¬¸Ãº¯Êý²»ÊÊÓÃ
+ * 3. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç
+ * 4. µ±´æÔÚÖмäÉϱ¨Ê±£¬pvalºÍinfo_fmt²»Îª¿Õ£»µ±ÎªÖмäÉϱ¨Ê±£¬Á½¸ö±ØÐë½ÔΪ¿Õ
+ * 5. pvalºÍinfo_fmtÁ½ÕßҪô¶¼ÎªNULL,Ҫô¶¼²»ÎªNULL£¬²»ÄÜ´æÔÚÆäÖÐÒ»¸öΪNULL£¬ÁíÒ»¸ö²»ÎªNULLµÄÇé¿ö
+ * 6. ʾÀý
+<pre>
+	int ret = 0;
+	ret = get_modem_info2("AT+CFUN=1\r", NULL,  NULL);
+	//·µ»Ø¼´±íʾִÐгɹ¦
+
+	char *pstr = malloc(50);
+	memset(pstr,0,50);
+	ret = get_modem_info2("AT+CIMI\r", "%s",  (void**)&pstr,0,10);
+	//·µ»Øºópstr==111111111111111
+
+	int n1 = 0;
+	int n2 = 0;
+	int n3 = 0;
+	char *p2[] = {&n1,&n2,&n3};
+	ret = get_modem_info2("AT+CCIOTOPT?\r", "%d,%d,%d",	(void**)p2,0,10);
+	//+CCIOTOPT: 1,2,3½âÎöºón1==1 n2==2 n3==3
+</pre>
+ * @warning 
+ */
+int  get_modem_info2(char *req_at,char *info_fmt,void **pval, int safe_parm_check, int timeout);
+
+
+/**
+ * @brief ÓÃÓÚ¿ª»ú×¢²áËùÓеķþÎñ¶Ë¾ßÌåATÃüÁîʼþ£¬³£ÓÃÓÚÉϲ㼰¿Í»§¶¨ÖÆ£¬²»×¼ÓÃÓÚPSЭÒéÕ»¡£
+ * @param at_cmd_prefix  ATÃüÁîǰ׺ָÕë
+ * @param module_id 	 Ô´Ä£¿é¶ÓÁÐid
+ * @param req_msg_id	 ÇëÇóÏûÏ¢id
+ * @param rsp_msg_id	 ÏìÓ¦ÏûÏ¢id
+ * @param req_rcv_act	 ÊÕµ½ÇëÇóÏûϢʱµÄ´¦Àíº¯Êý
+ * @param rsp_act		 ÊÕµ½ÏìÓ¦½á¹ûʱµÄ´¦Àíº¯Êý
+ * @return intÐͽá¹ûÂë
+ * @retval ³É¹¦ 0
+ * @note ¿É²Î¿¼Ê¾Àý´úÂë: user_regist.c
+ */
+int  register_serv_func2(char *at_cmd_prefix, int  module_id, int  req_msg_id, int	rsp_msg_id, ser_req_func2 req_rcv_act, app_rsp_proc rsp_act);
+
+/**
+ * @brief ×¢²áÉϱ¨ATÃüÁîµÄ¸ñʽ»¯´¦Àíº¯Êý£¬ÍⲿMCU·¢ËÍATÃüÁmodem·µ»ØµÄÖмä½á¹û²»Âú×ãÍⲿMCUµÄ¸ñʽҪÇó£¬
+ÐèÒªat_ctl½øÐÐת»»
+ * @param at_cmd_prefix  ATÃüÁîǰ׺ָÕë
+ * @param inform_act  ½ÓÊÕµ½ATÃüÁîÖмä½á¹ûµÄת»»´¦Àíº¯Êý
+ * @return intÐͽá¹ûÂë
+ * @retval ³É¹¦ 0
+ * @note
+ */
+int  register_formatInform_func(char *at_cmd_prefix, format_inform_func inform_act);
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+ * @brief ¿É´òÓ¡×Ö·û´®×ª»»Îª×Ö½ÚÊý¾Ý £¬È磺
+                "C8329BFD0E01" --> {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01}
+ * @param pSrc Ô´×Ö·û´®Ö¸Õë
+ * @param pDst Ä¿±êÊý¾ÝÖ¸Õë
+ * @param nSrcLength Ô´×Ö·û´®³¤¶È
+ * @return Ä¿±êÊý¾Ý³¤¶È
+ * @note
+ * @warning
+ */
+int string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength);
+/**
+ * @brief ×Ö½ÚÊý¾Ýת»»Îª¿É´òÓ¡×Ö·û´® £¬È磺
+                     {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} --> "C8329BFD0E01"
+ * @param pSrc Ô´Êý¾ÝÖ¸Õë
+ * @param pDst Ä¿±ê×Ö·û´®Ö¸Õë
+ * @param nSrcLength Ô´Êý¾Ý³¤¶È
+ * @return Ä¿±êÊý¾Ý³¤¶È£»
+ * @note
+ * @warning
+ */
+int bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength);
+
+
+
+ /**
+  * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬±È½ÏÁ½¸öat×Ö·û´®ÊÇ·ñÏàͬ
+  * @param dest  Ä¿±ê×Ö·û´®
+  * @param source Ô´×Ö·û´®
+  * @return 0±íʾÁ½×Ö·û´®ÍêÈ«Ïàͬ£¬Èç¹ûµÚÒ»¸öÈë²Î´óÓÚµÚ¶þ¸öÈë²Î£¬·µ»ØÕýÖµ£¬·ñÔò·µ»Ø¸ºÖµ£»
+  * @note
+  * @warning 
+  */
+ int at_strcmp(const char *dest, const char *source);
+
+
+ /**
+  * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬±È½ÏÁ½¸öat×Ö·û´®Ç°size³¤¶ÈÊÇ·ñÏàͬ
+  * @param dest  Ä¿±ê×Ö·û´®
+  * @param source Ô´×Ö·û´®
+  * @param size ±È½ÏµÄ×Ö½ÚÊý
+  * @return 0±íʾÁ½×Ö·û´®Ç°size³¤¶ÈÍêÈ«Ïàͬ£¬Èç¹ûµÚÒ»¸öÈë²Î´óÓÚµÚ¶þ¸öÈë²Î£¬·µ»ØÕýÖµ£¬·ñÔò·µ»Ø¸ºÖµ£»
+  * @note
+  * @warning 
+  */
+ int at_strncmp(const char *dest, const char *source, int size);
+
+  /**
+  * @brief ÔÚºöÂÔ´óСдµÄÇé¿öÏ£¬ÔÚsourceÖÐѰÕÒsubstr×Ó´®µÄλÖÃ
+  * @param dest  Ä¿±ê×Ö·û´®
+  * @param source Ô´×Ö·û´®
+  * @return Èç¹ûÕÒµ½£¬Ö±½Ó·µ»ØsubstrÔÚsourceÖеÚÒ»´Î³öÏÖµÄλÖã¬Èç¹ûûÓÐÕÒµ½£¬·µ»ØNULL
+  * @note
+  * @warning 
+  */
+ char * at_strstr(const char * source, const char * substr);
+
+ 
+  //ÓÃÓÚ¼ÆËãÀÛ¼ÓµÄCHECKSUMÖµ
+ unsigned short get_chksum(const unsigned char *ptr, unsigned short len);
+#endif
+
+#endif
+
diff --git a/ap/app/include/audio_res_ctrl.h b/ap/app/include/audio_res_ctrl.h
new file mode 100755
index 0000000..74914a3
--- /dev/null
+++ b/ap/app/include/audio_res_ctrl.h
@@ -0,0 +1,86 @@
+/**
+* @File: codec_res_main_ctrl.h
+* @Brief: Implementation of Device Manager in Sanechips
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @Author: sun.quan@zte.com.cn
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+* */
+#ifndef _AUDIO_RES_CTRL_
+#define _AUDIO_RES_CTRL_
+/*******************************************************************************
+ *						    Í·Îļþ   	          					       *
+ ******************************************************************************/
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+/*******************************************************************************
+ *                             ºê¶¨Òå                                         *
+ ******************************************************************************/
+//#define  MODULE_ID_CODEC 0 
+
+/*******************************************************************************
+ *                             Êý¾ÝÀàÐͶ¨Òå                                    *
+ ******************************************************************************/
+
+enum audio_type {
+	VOICE_23G = 0,    
+	VOICE_VOLTE,       
+	POC,
+	ZCORE,
+};
+
+enum  audio_msg_type {
+	USE_AUDIO_REQ = 0,  //¹©ÒµÎñÄ£¿éÉêÇëʹÓÃȨ
+	USE_AUDIO_RSP,      //ÏûÏ¢µÚÒ»¸ö²ÎÊýָʾÉêÇë³É¹¦»¹ÊÇʧ°Ü£¬µÚ¶þ¸ö²ÎÊýָʾµ±Ç°Ê¹ÓõÄÒµÎñ
+	REL_AUDIO_REQ,      //¹©Ö÷¿ØÇëÇóijҵÎñÄ£¿éÊÍ·ÅÕýÔÚ½øÐеÄAUDIOʹÓÃȨ
+	REL_AUDIO_IND,      //ÇëÇóijҵÎñÄ£¿éÊÍ·ÅaudioµÄ½á¹ûÓ¦´ð£¬Èôʧ°Ü£¬¶ÏÑÔ£»»»ÑÔÖ®£¬±ØÐë³É¹¦
+	IDLE_AUDIO_INFO     //Ö÷¿ØÍ¨ÖªËùÓÐÉêÇë¹ýAUDIO×ÊÔ´µÄÒµÎñÄ£¿é£¬¸æÖªµ±Ç°¿ÕÏУ¬ÒÔ½â¾öÒµÎñÄ£¿é´¦ÓÚ¹ÒÆð̬»ò֮ǰ±»Ç¿ÐÐÊͷŵÄÒµÎñÄ£¿é£¬ÈçMP3ÒôÀÖ²¥·ÅµÈ£»
+};
+
+
+typedef struct {
+	int	type;          //ָʾÉêÇëµÄ¾ßÌåÒµÎñÀàÐÍ
+	int moduleId;     //ÉêÇëµÄÄ£¿éºÅ
+	int tempModuleId; 
+} T_audio_UseReq;
+
+typedef struct {
+	int	result;       //ָʾÉêÇëµÄ½á¹û£¬0±íʾ³É¹¦£¬1±íʾʧ°Ü
+	int	type;         //ָʾÉêÇëµÄ¾ßÌåÒµÎñÀàÐÍ
+	int	using_type;   //ָʾµ±Ç°ÕýÔÚʹÓõÄÒµÎñÀàÐÍ£¬Ê§°Üʱ¹©¾ßÌåÒµÎñÄ£¿é²éѯʹÓÃ
+} T_audio_UseRsp;
+
+typedef struct {
+	int	using_type;  //ָʾµ±Ç°Äĸö¸ßÓÅÏȼ¶ÒµÎñÄ£¿éÔÚÉêÇë×ÊÔ´
+	int mouleId;     //Ä£¿éµÄid
+} T_audio_RelReq;
+
+typedef struct {
+	int	result;      //ָʾÉêÇëµÄ½á¹û£¬0±íʾ³É¹¦£¬1±íʾʧ°Ü
+	int	type;        //ָʾÊÍ·Å¿ØÖÆÈ¨µÄÒµÎñ
+	int moduleId;    //ÊÍ·Å¿ØÖÆÈ¨µÄÄ£¿éid
+} T_audio_RelInd;
+
+
+/* Ó¦ÓÃÇëÇócodec×ÊÔ´²ÎÊý */
+typedef struct audioResRequest
+{
+    int moduleId;           /* ÒµÎñÄ£¿éºÅ */
+    int tempMouduleId;       /* ÉêÇë×ÊÔ´µÄ½ÓÊÜÏûÏ¢ÁÙʱId */
+    int audioType;          /* ÒµÎñÀàÐÍ */
+}T_audio_Res_Request;
+/**
+ *º¯Êý˵Ã÷£ºÇëÇóʹÓÃcodec×ÊÔ´£¬µÈ´ýcodecÖ÷¿Ø»Ø¸´         
+ *@param :  Ó¦ÓÃÇëÇóµÄ²ÎÊý
+ *
+ */
+BOOL audio_resource_request(struct audioResRequest *param,  T_audio_UseRsp *RspData);
+#endif
diff --git a/ap/app/include/cfg_api.h b/ap/app/include/cfg_api.h
new file mode 100755
index 0000000..8021365
--- /dev/null
+++ b/ap/app/include/cfg_api.h
@@ -0,0 +1,129 @@
+/**
+* @file cfg_api.h
+* @brief nv½Ó¿ÚÍ·Îļþ
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+*
+*/
+
+#ifndef _CFG_API_H
+#define _CFG_API_H
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                       Global variable declarations                          *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+* @brief »ñȡָ¶¨×ֶζÔÓ¦µÄÖµ
+* @param name     Èë²Î£¬×Ö¶ÎÃû
+* @param buf      ³ö²Î£¬´æ·Å×ֶζÔÓ¦Êý¾ÝµÄ»º³åÇøÖ¸Õë
+* @param len      Èë²Î£¬»º³åÇøbuf³¤¶È
+* @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+* @retval 0  ³É¹¦
+* @retval -1 ʧ°Ü
+* @note
+* @warning
+*/
+int sc_cfg_get(char *name, char *buf, int bufLen);
+
+/**
+ * @brief ÉèÖÃÖ¸¶¨×ֶζÔÓ¦µÄÖµ
+ * @param name       Èë²Î£¬×Ö¶ÎÃû
+ * @param value      Èë²Î£¬ÏëÒª´æ´¢µÄÊý¾Ý
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note   cfg_set½öÉèÖõ½Äڴ棬µ÷ÓÃcfg_save²Å»á±£´æµ½Îļþ£¬²Å»áÖØÆôÉúЧ
+ * @warning  ½öÔÚparameterÖеÄnv²Å»áµôµç±£´æ£¬ÆäËû½ÔÊÓΪÁÙʱnv
+ */
+int sc_cfg_set(char *name, char *value);
+
+/**
+ * @brief ɾ³ýÖ¸¶¨×Ö¶Î
+ * @param name     Èë²Î£¬×Ö¶ÎÃû
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note
+ * @warning
+ */
+int sc_cfg_unset(char *name);
+
+/**
+ * @brief Çå¿ÕÈ«²¿×ֶδ洢ÐÅÏ¢
+ * @param
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note
+ * @warning »Ö¸´³ö³§ÐÅϢʱµ÷ÓÃ
+ */
+int sc_cfg_reset(void);
+
+/**
+ * @brief ´òÓ¡ÏÔʾËùÓÐÅäÖÃÏîÐÅÏ¢µ½¿ØÖÆÌ¨
+ * @param
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note
+ * @warning
+ */
+int sc_cfg_show(void);
+
+/**
+ * @brief ±£´æÈ«²¿ÅäÖÃÊý¾Ýµ½Îļþ
+ * @param
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note cfg_saveµ÷Óúó£¬ÅäÖõÄÊý¾ÝÖØÆôºó»¹ÄÜÉúЧ
+ * @warning
+ */
+int sc_cfg_save(void);
+
+#ifndef LIBNVRAM_API_NEW
+int cfg_get_item(char *name, char *buf, int bufLen);
+int cfg_set(char *name, char *value);
+int cfg_unset(char *name);
+int cfg_reset(void);
+int cfg_show(void);
+int cfg_save(void);
+#endif
+
+/**
+ * @brief systemϵͳµ÷Ó÷â×°½Ó¿Ú
+ * @param cmd  Èë²Î  ÃüÁî
+ * @return 0£º³É¹¦£¬-1£ºÊ§°Ü
+ * @retval 0  ³É¹¦
+ * @retval -1 ʧ°Ü
+ * @note 
+ * @warning
+ */
+extern int zxic_system(const char *cmd);
+
+extern int zxic_system_outdata(const char *cmd, const char *outfile, char *out_data, int out_len);
+/*******************************************************************************
+ *                      Inline function implementations                        *
+ ******************************************************************************/
+
+#endif  // #ifndef _CFG_API_H
+
diff --git a/ap/app/include/cfg_nv_def.h b/ap/app/include/cfg_nv_def.h
new file mode 100755
index 0000000..d796c82
--- /dev/null
+++ b/ap/app/include/cfg_nv_def.h
@@ -0,0 +1,299 @@
+/**
+ * @file cfg_nv_def.h
+ * @brief ÌṩÁËap²àµÄnvºê¶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __CFG_NV_DEF_H_
+#define __CFG_NV_DEF_H_
+
+//atserver inner
+#define NV_CFUN_STATE "cfun_state"
+#define NV_SIM_PIN "sim_pin"
+#define NV_SIM_PUK "sim_puk"
+#define NV_ZCONSTAT_UP_RESULT "zconstat_up_result"
+#define NV_CGATT_SET_RESULT "cgatt_set_result"
+#define NV_ZGACT_RESULT_DEFAULTCID "zgact_result_defaultcid" //ĬÈÏcid
+#define NV_ZGACT_RESULT_PPPDCID "zgact_result_pppdcid" //pppdcid
+#define NV_CSQ_DONE "csq_done"
+#define NV_M_NETSELECT_MODE "m_netselect_mode"
+#define NV_SMS_STORE "sms_store"
+#define NV_SMS_LOAD_RESULT "sms_load_result"
+#define NV_SMS_STATE "sms_state"
+#define NV_SMS_RECV_RESULT "sms_recv_result"
+#define NV_SMS_SEND_RESULT "sms_send_result"
+#define NV_REG_STATUS "reg_status"
+#define NV_TDREG_STATUS "tdreg_status"
+#define NV_PB_USEDENTRIES "pb_usedEntries"
+#define NV_PB_TOTALENTRIES "pb_totalEntries"
+#define NV_SMS_SAVE_RESULT "sms_save_result"
+#define NV_SMS_DEL_RESULT "sim_del_result"
+#define NV_SR_STATE "sr_state"
+#define NV_CHECK_UDL "check_udl"
+#define NV_CPMS_SET_CURRENT "cpms_set_current"
+#define NV_SMS_LOCATION_SET "sms_location_set"
+#define NV_SMS_INIT_STATUS "sms_init_status"
+#define NV_SMS_IN_NUM "sms_in_num"
+#define NV_ACTIONLTE "actionlte"
+#define NV_UARFCNLTE "uarfcnlte"
+#define NV_CELLPARAIDLTE "cellParaIdlte"
+#define NV_DAIL_STEP "dail_step"
+#define NV_CONNECT_LOGIC "connect_logic"
+#define NV_NETWORK_CATEGORY_BASED_ON "network_category_based_on"
+#define NV_SSID1 "SSID1"
+#define NV_WPAPSK1 "WPAPSK1"
+/*lock cell*/
+#define LOCK_CELL_STATE_FLAG                               "LOCK_CELL_STATE"
+/*sms*/
+#define ZTE_WMS_NVCONFIG_SIM_CAPABILITY "sms_sim_capability"
+#define ZTE_WMS_NVCONFIG_NV_CAPABILITY "sms_nv_capability"
+#define ZTE_WMS_NVCONFIG_RECEVIED "sms_received_flag"
+#define ZTE_WMS_NVCONFIG_SMS_REPORT "sts_received_flag"
+#define ZTE_WMS_NVCONFIG_RECEVIED_LED "view_message_flag"  /*this nv used for led,and the function same as sms_received_flag*/
+#define ZTE_WMS_NVCONFIG_RECEVIED_REMIND "sms_remind"  /*this nv used for web remind */
+#define ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL "sim_card_total"
+#define ZTE_WMS_NVCONFIG_SIM_CARD_USED "sim_card_used"
+#define ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN "sim_card_remain"
+/*pb*/
+#define ZPB_NV_USIMINDEXMIN        "pbusimindexmin"
+#define ZPB_NV_USIMINDEXMAX        "pbusimindexmax"
+#define ZPB_NV_USIMMEMORYFULL      "usimmemoryfull"
+//common
+#define NV_NETWORK_PROVIDER "network_provider"
+#define NV_NETWORK_TYPE "network_type"
+#define NV_SUB_NETWORK_TYPE "sub_network_type"
+#define NV_SIMCARD_ROAM "simcard_roam"
+#define NV_CSQ "csq"
+#define NV_RSSI "rssi"
+#define NV_WAN_IPADDR "wan_ipaddr"
+#define NV_WAN_NETMASK "wan_netmask"
+#define NV_WAN_GATEWAY "wan_gateway"
+#define NV_PREFER_DNS_AUTO "prefer_dns_auto"
+#define NV_STANDBY_DNS_AUTO "standby_dns_auto"
+#define NV_PIN_MANAGE_RESULT "pin_manage_result"
+#define NV_PINNUMBER "pinnumber"
+#define NV_PUKNUMBER "puknumber"
+#define NV_PIN_STATUS "pin_status"
+#define NV_PIN_PUK_PROCESS "pin_puk_process"
+#define NV_PIN_MANAGE_PROCESS "pin_manage_process"
+#define NV_MCC "mcc"
+#define NV_MNC "mnc"
+#define NV_SIMCARD_TYPE "cardType"
+#define NV_OPER_NUM "network_num_oper"
+#define NV_ZGIPDNS_RESULT_DEFAULTCID "zgipdns_result_defaultcid"//ĬÈÏcid
+#define NV_ZGIPDNS_RESULT_PPPDCID "zgipdns_result_pppdcid"//pppdcid
+#define NV_RESETMODEM "resetModem"
+#define NV_SIGNALBAR "signalbar"
+#define NV_AUTO_RECONNECT "auto_reconnect"
+#define NV_IPV6_WAN_IPADDR "ipv6_wan_ipaddr"
+#define NV_IPV6_WAN_DEFAULT_GW_ADDR "ipv6_wan_default_gw_addr"
+#define NV_IPV6_PREFER_DNS_AUTO "ipv6_prefer_dns_auto"
+#define NV_IPV6_STANDBY_DNS_AUTO "ipv6_standby_dns_auto"
+#define NV_SD_CARD_STATE "sd_card_state"
+#define NV_SIM_IMSI "sim_imsi"
+#define NV_SIM_ICCID "sim_iccid"
+#define NV_MSISDN   "msisdn"
+#define NV_ZICCID "ziccid"
+#define NV_SYS_MODE "sys_mode"
+#define NV_SYS_SUBMODE "sys_submode"
+#define NV_DATA_CARD "data_card"
+#define NV_NEED_SUPPORT_PB "need_support_pb"
+#define NV_NEED_SUPPORT_SMS "need_support_sms"
+#define NV_SMS_CENTER_NUM "sms_center_num"
+#define NV_SMS_DB_CHANGE "sms_db_change"
+#define NV_PPP_STATUS "ppp_status" //cid=1 Á´Â·×´Ì¬
+#define NV_DIAL_MODE "dial_mode"
+#define NV_MODEM_MAIN_STATE "modem_main_state"
+#define NV_PINSET_RESULT "pinset_result"
+#define NV_IMEI "imei"
+#define NV_CR_VERSION "cr_version"
+#define NV_WA_VERSION "wa_version"
+#define NV_HW_VERSION "hw_version"
+#define NV_CR_INNER_VERSION "cr_inner_version"
+#define NV_SET_DEVICEMODE_DEBUG_ENABLE "set_devicemode_debug_enable"
+#define NV_SET_DEVICEMODE_STATUS "set_devicemode_status"
+#define NV_SET_DEVICEMODE_PROCESS "set_devicemode_process"
+#define NV_AUTO_SIMPIN "auto_simpin"
+#define NV_SYSTIME_MODE "systime_mode"
+#define NV_APN_MODE "apn_mode"
+#define NV_PDP_TYPE "pdp_type"
+#define NV_PDP_STATUS "pdp_status"
+#define NV_WAN_APN "wan_apn"
+#define NV_IPV6_WAN_APN "ipv6_wan_apn"
+#define NV_M_PROFILE_NAME "m_profile_name"
+#define NV_APN_AUTO_CONFIG "apn_auto_config"
+#define NV_NET_NUM "net_num"
+#define NV_M_NETSELECT_STATUS "m_netselect_status"
+#define NV_M_NETSELECT_CONTENTS "m_netselect_contents"
+#define NV_M_NETSELECT_RESULT "m_netselect_result"
+#define NV_STR_NUM_RPLMN_TMP "str_num_rplmn_tmp"
+#define NV_STR_NUM_RPLMN "str_num_rplmn"
+#define NV_CURRENT_RAT_TMP "current_rat_tmp"
+#define NV_CURRENT_RAT "current_rat"
+#define NV_ROAM_SETTING_OPTION "roam_setting_option"
+#define NV_NET_SELECT_RESULT "net_select_result"
+#define NV_NET_SELECT_MODE "net_select_mode"
+#define NV_TRAFFIC_RECV_SMS_ID "traffic_recv_sms_id"
+#define NV_TRAFFIC_SMS_NUMBER "traffic_sms_number"
+#define NV_REPORT_ENABLE "report_enable"
+#define NV_SENDFAIL_RETRY "sendfail_retry"
+#define NV_OUTDATE_DELETE "outdate_delete"
+#define NV_DEFAULT_STORE "default_store"
+#define NV_PRA_MEMSTORE "pra_memstore"
+#define NV_SMS_VP "sms_vp"
+#define NV_CLEAR_SMS_WHEN_RESTORE "clear_sms_when_restore"
+#define NV_CLEAR_PB_WHEN_RESTORE "clear_pb_when_restore"
+#define NV_NET_SELECT "net_select"
+#define NV_PRE_MODE "pre_mode"
+#define NV_AUTO_SIMPIN_CODE "auto_simpin_code"
+#define NV_NETWORK_NEED_TDS "network_need_tds"
+#define NV_NETWORK_NEED_GSM "network_need_gsm"
+#define NV_PPP_AUTH_MODE "ppp_auth_mode"
+#define NV_PPP_USERNAME "ppp_username"
+#define NV_PPP_PASSWD "ppp_passtmp"
+#define NV_IPV6_PPP_AUTH_MODE "ipv6_ppp_auth_mode"
+#define NV_IPV6_PPP_USERNAME "ipv6_ppp_username"
+#define NV_IPV6_PPP_PASSWD "ipv6_ppp_passtmp"
+#define NV_IPV6_PDP_TYPE "ipv6_pdp_type"
+#define NV_UNLOCK_NCK_TIME "unlock_nck_time"
+#define NV_SN_BOARDNUM "sn_boardnum"
+#define NV_OPMS_WAN_MODE "opms_wan_mode"
+#define NV_LAC_CODE "lac_code"
+#define NV_TAC_CODE "tac_code"
+#define NV_CELL_ID "cell_id"
+//unused
+#define NV_ECIO "ecio"
+#define NV_UNLOCK_AT_WAIT "unlock_at_wait"
+#define NV_SIM_SPN "sim_spn"
+#define NV_SEND_PIN_FLAG "send_pin_flag"
+#define NV_LOCK_UI "lock_ui"
+#define NV_ACTION "action"
+#define NV_UARFCN "uarfcn"
+#define NV_CELLPARAID "cellParaId"
+#define NV_BANDLOCKSET "BandLockSet"
+#define NV_BANDLOCKSTATE "BandLockState"
+#define NV_PPP_DIAL "ppp_dial"
+#define NV_ZCELL_RESULT "Zcell_result"
+#define NV_CELLLOCKSET "CellLockSet"
+#define NV_CELLLOCKSTATE "CellLockState"
+#define NV_PHO_DEL "pho_del"
+
+#define NV_CLCK_SET_MODE			"clck_set_mode"
+#define NV_NEED_SIM_PIN				"need_sim_pin"
+
+#define NV_BLC_WAN_MODE "blc_wan_mode"
+#define NV_BLC_WAN_AUTO_MODE "blc_wan_auto_mode"
+
+//mmiʹÓõÄÏà¹ØµÄNV
+
+/*******************************NETÄ£¿é**********************************/
+//#define NETTYPE_NV_NAME                 	"network_type"
+//#define PPP_STATUS_NV_NAME              	"ppp_status"
+//#define NV_SIGNAL_NUM                   	"signalbar"
+#define NV_RJ45_PLUG                   	    "rj45_plug"
+#define RJ45_WAN_LAN_OFF                   	"wan_lan_off"
+#define RJ45_WAN_ON_LAN_OFF                 "wan_on_lan_off"
+#define RJ45_WAN_OFF_LAN_ON                 "wan_off_lan_on"
+#define RJ45_WAN_LAN_ON                     "wan_lan_on"
+
+/*******************************quotaÄ£¿é**********************************/
+//#define NV_QUOTA_FROM_SERVER		   		"quota_from_server"
+#define NV_TOTALQUOTA_FROM_SERVER      		"totalquota_from_server"
+
+/*******************************smsÄ£¿é**********************************/
+//#define SMS_IN_BOX_STATUS_NV       			"sms_init_status"
+#define SMS_IN_BOX_STATUS_UNREAD   			"sms_unread"
+#define SMS_IN_BOX_STATUS_FULL     			"sms_memory_full"
+#define SMS_IN_BOX_STATUS_NOR      			"sms_normal"
+#define SMS_UNREAD_COUNT_NV        			"sms_unread_count"
+
+/*******************************voipÄ£¿é**********************************/
+#define NV_VOIP_STATUS       			    "voip_status"
+
+/*******************************timeÄ£¿é**********************************/
+#define HOUR_NV								"sntp_hour"
+#define MINUTE_NV							"sntp_minute"
+
+/*******************************tipÄ£¿é**********************************/
+//#define NV_SIM_CARD_STATE         			"modem_main_state"
+#define NV_SIM_STATE_PUK_WATIT         		"modem_waitpuk"
+#define NV_SIM_STATE_PIN_WATIT          	"modem_waitpin"
+#define NV_SIM_STATE_DESTROY				"modem_sim_destroy"
+#define NV_SIM_STATE_READY					"modem_ready"
+#define NV_SIM_STATE_NCK_WAIT				"modem_imsi_waitnck"
+#define NV_SIM_STATE_UNDETECTED				"modem_sim_undetected"
+#define NV_SIM_STATE_BUSY					"afdafaf"
+#define NV_SIM_STATE_INIT_COMPLETE     	 	"modem_init_complete"
+#define NV_SIM_STATE_INIT_EXCPTION 			"modem_undetected"
+
+
+//#define NV_NET_PROVIDER                 	"network_provider"
+#define NV_NET_PROVIDER_CMCC				"China Mobile"
+#define NV_NET_PROVIDER_CUCC				"China Unicom"
+#define NV_NET_PROVIDER_CTCC				"China Telecom"
+#define NV_NET_BOLT_4G_1					"PLMN--51088"
+#define NV_NET_BOLT_4G_2					"PLMN--51068"
+#define NV_NET_BOLT_4G_3					"51088"
+#define NV_NET_BOLT_4G_4					"51068"
+#define NV_NET_BOLT_4G_5					"BOLT SUPER 4G"
+
+
+#define NV_SSID_WRITE_FLAG					"ssid_write_flag"
+//#define NV_SSID								"SSID1"
+#define NV_WIFIKEY							"WPAPSK1"
+#define NV_MULTI_SSID_SWITCH				"m_ssid_enable"
+#define NV_SSID2							"m_SSID"
+#define NV_WIFIKEY2							"m_WPAPSK1"
+#define NV_WIFISTA_SSID						"EX_SSID1"
+
+
+//#define NV_MSISDN							"msisdn_from_server"
+#define NV_SINR								"lte_sinr"
+#define NV_PCI								"lte_pci"
+#define NV_ACESS_DURATION					"realtime_time"
+#define NV_CURRENT_UAAGE_TX					"realtime_tx_bytes"
+#define NV_CURRENT_UAAGE_RX					"realtime_rx_bytes"
+//#define NV_NEED_SIM_PIN					    "need_sim_pin"
+
+/*******************************trafficÄ£¿é**********************************/
+#define NV_TRAFFIC_LIMIT_SWITCH       		"data_volume_limit_switch"			//Á÷Á¿¼à¿Ø¿ª¹Ø 1:¿ª£¬0:¹Ø
+#define NV_TRAFFIC_LIMIT_UNIT          		"data_volume_limit_unit"			//Á÷Á¿µ¥Î» ÓÐdataºÍtimeÁ½ÖÖ
+#define NV_TRAFFIC_LIMIT_SIZE          		"data_volume_limit_size"			//Á÷Á¿×ÜÖµ
+#define NV_TRAFFIC_ALERT_PERCENT       		"data_volume_alert_percent"			//Á÷Á¿¸æ¾¯Öµ
+#define NV_TRAFFIC_USED_DATA           		"flux_month_total"					//ÒÑʹÓÃÁ÷Á¿Öµ µ¥Î»B
+#define NV_TRAFFIC_USED_TIME 		   		"monthly_time"						//ÒÑʹÓÃʱ¼äÁ÷Á¿Öµ µ¥Î»S
+
+#define NV_TRAFFIC_LIMIT_UNIT_DATA     		"data"
+#define NV_TRAFFIC_LIMIT_UNIT_TIME     		"time"
+
+
+/*******************************wifiÄ£¿é**********************************/
+//#define WLAN_NV_WIFI_SLEEP_NAME  			"wifiSleep"
+#define WLAN_NV_AP_HIDESSID_NAME       		"HideSSID"
+#define WLAN_NV_AUTHMODE_NAME          		"AuthMode"
+#define WLAN_NV_ENCRYP_TYPE_NAME        	"EncrypType"
+#define WLAN_NV_WSC_MODE_NAME				"WscModeOption"
+#define WLAM_NV_WPS_MODE_NAME				"wps_mode"
+#define WLAN_NV_VA0_WIIF_NUM				"sta_count"
+#define WLAN_NV_VA1_WIIF_NUM				"m_sta_count"
+#define WLAN_NV_CUR_STATE                   "wifi_cur_state"
+#define WLAN_NV_PROCESS_STATE               "wifi_process_state"
+
+/**************************  ¿ìËÙ¿ª»úÏà¹Ø¶¨Òå***********************/
+#define POWERON_MODE						"mgmt_quicken_power_on"
+#define FAST_POWERON_MODE 					"1"
+#define NV_FAKE_POWEROFF_STATE      		"mmi_fake_poweroff_state"                //is fake-poweroff state?  1:yes  , 0:no
+
+/****************GPS***********************************************/
+#define GPS_NV_UPDATE_FLAG "gps_update_flag"
+
+
+#endif
+
diff --git a/ap/app/include/drv_msg.h b/ap/app/include/drv_msg.h
new file mode 100644
index 0000000..397eb16
--- /dev/null
+++ b/ap/app/include/drv_msg.h
@@ -0,0 +1,39 @@
+/**
+* @file drv_msg.h
+* @brief ÌṩdrvÉèÖÃ/ÈȲå°ÎµÄÏûÏ¢½Ó¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author Linxu Gebin
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+************************************************************************
+*/
+
+#ifndef __DRV_MSG_H__
+#define __DRV_MSG_H__
+
+#include "message.h"
+
+/**
+* @brief ¶¨ÒåusbÏûÏ¢
+ * @param MSG_CMD_DRV_USB_CHANGE USB±ä»¯ÏûÏ¢
+ * @param MSG_CMD_DRV_USB_ADD USB²åÈëÏûÏ¢
+ * @param MSG_CMD_DRV_USB_REMOVE USB°Î³öÏûÏ¢
+
+*/
+enum drv_usb_msg_cmd {
+	MSG_CMD_DRV_USB_CHANGE = MSG_CMD_DRV_BASE,
+	MSG_CMD_DRV_USB_ADD,
+	MSG_CMD_DRV_USB_REMOVE,
+	MSG_CMD_DRV_SD_ADD,
+	MSG_CMD_DRV_SD_REMOVE,
+	MSG_CMD_DRV_SD_OFFLINE,
+	MSG_CMD_DRV_VSD_ADD,
+	MSG_CMD_DRV_VSD_REMOVE,
+	MSG_CMD_DRV_VSD_OFFLINE
+};
+
+#endif
diff --git a/ap/app/include/fota_common.h b/ap/app/include/fota_common.h
new file mode 100755
index 0000000..9429d72
--- /dev/null
+++ b/ap/app/include/fota_common.h
@@ -0,0 +1,242 @@
+#ifndef __FOTA_COMMON_H__
+#define __FOTA_COMMON_H__
+
+#define ZTE_FOTA_UPDATEFLAG_LEN 32
+#define ZTE_FOTA_NETDOG_FLAG_LEN 256
+#define ZTE_FOTA_FLAG_LEN ZTE_FOTA_NETDOG_FLAG_LEN+ZTE_FOTA_UPDATEFLAG_LEN+4
+
+#define ZTE_FOTA_PARTITION_STR_LEN 32
+
+typedef struct {
+	char update_flag[ZTE_FOTA_UPDATEFLAG_LEN];
+	int state_flag;
+	char netdog_flag[ZTE_FOTA_NETDOG_FLAG_LEN];
+	void* reserve;
+
+} fotaflag_t;
+
+typedef enum {
+	STATEFLAG_NULL = 0,
+	RECOVERY,
+	RECOVERY_KERNEL,
+	CPUM0,
+	CPUZSP,
+	CPUR7,
+	CPUAP,
+	CPFS,
+	USERDATA,
+	SECUREFS
+} stateflag_t;
+
+typedef struct {
+	stateflag_t stateflag;
+	char name[ZTE_FOTA_PARTITION_STR_LEN];
+} stateflag_print_t;
+
+typedef enum {
+	SNTP_FAILED = 0,
+	MEMORY_ALLOC_FAILED,
+	NETWORK_NOT_AVAILABLE,
+	DMSESSION_ABORTED_HIGH,
+	DMSESSION_ABORTED_LOW,
+	DLSESSION_ABORTED_HIGH,
+	DLSESSION_ABORTED_LOW,
+	IMEI_INVALID,
+	CR_INNER_VERSION_INVALID,
+} netdogflag_error_t;
+
+#define NET_DOG_INIT_FLAG 0xFF
+#define NET_DOG_EXCEPTION_FLAG 1
+
+//UPDATE_STATE
+#define 	IDLE 					"idle"
+#define	CHECKING				"checking"
+#define	CHECK_COMPLETE			"check_complete"
+#define	WAIT_CONFIRM			"wait_confirm"
+#define	DOWNLOADING			"downloading"
+#define	DOWNLOAD_SUCCESS	"download_success"
+#define	DOWNLOAD_FAILED		"download_failed"
+#define	LOW_BATTERY			"low_battery"
+#define	PREPARE_INSTALL		"prepare_install"
+#define 	NONE					"none"
+
+//new version state  has state below
+
+//#define 	IDLE 					"idle"
+#define	CHECK_FAILED				"check_failed"
+#define	ROAMING					"roaming"
+#define	BAD_NETWORK			"bad_network"
+#define	NO_NEW_VERSION 			"no_new_version"
+#define	HAS_OPTIONAL 			"has_optional"
+#define	HAS_CRITICAL				"has_critical"
+#define	PKG_TOO_BIG				"pkg_too_big"
+#define	ALREADY_HAS_PKG				"already_has_pkg"
+
+
+
+// nv Ïà¹Ø
+
+
+#define NV_FOTA_PKG_TOTAL_SIZE 						"fota_pkg_total_size"
+#define NV_FOTA_PKG_DL_SIZE 						"fota_dl_pkg_size"
+#define NV_FOTA_DM_VENDOR 							"fota_dm_vendor"
+
+/*polling  Ïà¹Ø*/
+/*¸ø²âÊÔÈËÔ±¶ÁȡʹÓÃ*/
+#define NV_DM_NEXTPOLLINGTIME 						"dm_nextpollingtime"
+/*unit in second,  ʵ¼ÊʹÓÃÕâ¸ö*/
+#define NV_FOTA_POLLING_NEXT_TIME                   "polling_nexttime"
+
+#define NV_DM_FOTA_ALLOW_ROAMING 					"fota_allowRoamingUpdate" //"dm_fota_allow_roaming" 
+#define NV_DM_POLLINGCYCLE 							"fota_updateIntervalDay" //"dm_pollingcycle"
+#define NV_DM_POLLINGSWITCH 						"fota_updateMode" //"dm_pollingswitch"
+#define NV_FOTA_TESTMODE_SWITCH						"fota_test_mode"  //fota test mode switch
+
+
+/*¸ÃnvÊÇÔÚrcÆô¶¯½Å±¾ÖÐʹÓÃ*/
+#define NV_UPDATE_TYPE 								"update_type"
+
+
+
+#define NV_FOTA_NEW_VERSION_STATE 					"fota_new_version_state"
+#define NV_FOTA_CURR_UPGRADE_STATE 				"fota_current_upgrade_state"
+#define NV_FOTA_UPGRADE_SELECTOR 				"fota_upgrade_selector"
+#define NV_FOTA_NEED_USER_CONFIRM_DOWNLOAD 				"fota_need_user_confirm_download"
+#define NV_FOTA_NEED_USER_CONFIRM_UPDATE 				"fota_need_user_confirm_update"
+
+/*
+1.   when poweron,  it will be init according to the delta.package file
+2.  when downloaded, it will be set
+3.  it does not exist in the default_parameter_user file,  it means when restart, it must be reinit
+*/
+#define NV_FOTA_PKG_EXIST			 			"fota_package_already_download"
+#define NV_FOTA_PACKAGE_ALREADY_DOWNLOAD 		"fota_package_already_download"
+
+
+/*ÓÐÈý¸ö¸üнá¹û£¬ÐèÒªÓÅ»¯*/
+#define NV_FOTA_UPGRADE_RESULT 					"fota_upgrade_result"
+#define NV_FOTA_UPGRADE_RESULT_MMI				"fota_upgrade_result_mmi"
+
+
+/*goadhead ÈÔÈ»ÔÚʹÓÃ*/
+#define NV_FOTA_DM_LAST_CHECK_TIME   				"dm_last_check_time"
+
+#define NV_FOTA_VERSION_NAME 						"fota_version_name"
+#define NV_FOTA_VERSION_DELTA_ID 					"fota_version_delta_id"
+#define NV_FOTA_VERSION_DELTA_URL 					"fota_version_delta_url"
+#define NV_FOTA_VERSION_MD5SUM 					"fota_version_md5sum"
+
+#define NV_FOTA_OEM									"fota_oem"
+#define NV_FOTA_TOKEN 								"fota_token"
+#define NV_FOTA_DEVICE_TYPE 						"fota_device_type"
+#define NV_FOTA_PLATFORM 							"fota_platform"
+#define NV_FOTA_MODELS 								"fota_models"
+
+// add by new libdmgr
+#define NV_FOTA_PRODUCTID							"fota_product_id"
+#define NV_FOTA_PRODUCTSECRET 						"fota_product_secret"
+#define NV_FOTA_APPVERSION 							"fota_app_version"
+#define NV_FOTA_NETWORKTYPE 						"fota_network_type"
+
+
+
+
+#define NV_FOTA_DL_URL 								"fota_dl_url"
+#define NV_FOTA_CHK_URL 							"fota_chk_url"
+#define NV_FOTA_REG_URL 							"fota_reg_url"
+#define NV_FOTA_REPORT_DLR_URL 						"fota_report_dlr_url"
+#define NV_FOTA_REPORT_UPGR_URL 					"fota_report_upgr_url"
+#define NV_FOTA_REPORT_SALES_URL 					"fota_report_sales_url"
+
+/*
+	SNTP ¸üÐÂģʽ£¬¿ÉÒÔȡֵ
+	manual
+	auto
+*/
+//#define NV_SYSTIME_MODE 							"systime_mode"
+#define NV_SNTP_MANUAL_MODE 						"manual"
+#define NV_SNTP_AUTO_MODE 							"auto"
+#define NV_SNTP_PROCESS_RESULT 						"sntp_process_result"
+/*
+ÍøÂç״̬
+International:::Internal:::Home*/
+#define NV_SIMCARD_ROAM 							"simcard_roam"
+#define NV_MODEM_MAIN_STATE 						"modem_main_state"
+
+/*wa_inner_mod = ZTE_MF910S  MF910W MF922*/
+#define NV_WA_INNER_MOD 							"wa_inner_mod"
+#define NV_IMEI 										"imei"
+#define NV_CR_INNER_VERSION 						"cr_inner_version"
+#define NV_HARDWARE_VERSION 						"hardware_version"
+
+#define UPGRADE_STATE_ACCEPT 						"accept"
+#define UPGRADE_STATE_CANCEL 						"cancel"
+
+#define UPGRADE_SELECTOR_NONE 						"none"
+#define UPGRADE_SELECTOR_ACCEPT 					"accept"
+#define UPGRADE_SELECTOR_CANCEL 					"cancel"
+
+#define UPDATE_SUCCESS 							"success"
+#define UPDATE_FAIL 								"fail"
+
+#define SUCCESS_STRING 								"success"
+/***********************************************/
+
+/*****************NV_SIMCARD_ROAM***************/
+typedef enum NetworkStatus_tag {
+	NETWORK_IDLE,
+	ROAMING_HOME,
+	ROAMING_INTERNATIONAL,
+	ROAMING_INTERNAL,
+	ROAMING_NA,
+	HAS_USER_DATA,
+	CHANGE_APN_FAIL,
+	NO_SIMCARD_INSERTED,
+	NETWORK_AVAILABLE
+} NetworkStatus;
+
+#define ROAM_INTERNATIONAL "International"
+#define ROAM_INTERNAL "Internal"
+#define ROAM_HOME "Home"
+
+/***********************************************/
+
+/****************NV_MODEM_MAIN_STATE*************/
+#define MODEM_MAIN_STATE_MODEM_SIM_UNDETECTED "modem_sim_undetected"
+/***********************************************/
+
+/****************NV_FOTA_STATE*******************/
+#define FOTA_SEARCH_FAILED "fota_search_failed"
+/***********************************************/
+
+/***********NV_FOTA_PKG_DL_CHECK_RESUL************/
+#define FOTA_PKG_DL_FAILED "fota_pkg_dl_failed"
+/***********************************************/
+
+
+#define 	ZTE_FOTA_MAIN_PATH							"/cache/zte_fota/"
+#define  	FOTAUPI										ZTE_FOTA_MAIN_PATH"upi.log"
+#define  	FOTARB										ZTE_FOTA_MAIN_PATH"lib.log"
+#define  	FOTADM										ZTE_FOTA_MAIN_PATH"dm.log"
+#define 	FOTA_UPDATE_STATUS_FILE 					ZTE_FOTA_MAIN_PATH"update_status"
+#define 	FOTA_UPDATE_STATUS_FILE_OLD					ZTE_FOTA_MAIN_PATH"/dua/update_status"
+
+
+
+#define 	FOTA_PACKAGE_FILE   					 	ZTE_FOTA_MAIN_PATH"delta.package"
+#define     FOTA_PACKAGE_FILE_FAILED   				     ZTE_FOTA_MAIN_PATH"delta.package.failed"
+#define 	CHARGER_VOLTAGE_FILE   						"/sys/class/power_supply/battery/voltage_now"
+#define     FOTA_DM_UPGRADE_TEMP 						ZTE_FOTA_MAIN_PATH"upgrade_temp"
+#define 	FOTA_DM_META_FILE                             ZTE_FOTA_MAIN_PATH"meta_data"
+
+
+#define 	DL_TMP_FILENAME            						ZTE_FOTA_MAIN_PATH"process_delta.package" //¹ãÉý¶ÏµçÐø´«ÏÂÔØ¹ý³ÌÖÐÁÙʱÎļþ
+
+#define 	DELTA_VERIFY_FAILED 						ZTE_FOTA_MAIN_PATH"delta.package.verifyFailed"
+#define 	DELTA_RECO_FAILED 							ZTE_FOTA_MAIN_PATH"delta.package.recoFailed"
+#define 	DELTA_SYS_FAILED    							ZTE_FOTA_MAIN_PATH"delta.package.systemFailed"
+
+#define  	FOTA_DLSVR_DOMAIN							"mg.adups.cn"
+
+
+#endif
diff --git a/ap/app/include/ipsec_api.h b/ap/app/include/ipsec_api.h
new file mode 100644
index 0000000..c278944
--- /dev/null
+++ b/ap/app/include/ipsec_api.h
@@ -0,0 +1,119 @@
+#ifndef __VOLTE_PROXY_H__

+#define __VOLTE_PROXY_H__

+#include "softap_api.h"

+

+#define IPSEC_PROTO_BASE	0x00

+#define	IPSEC_PROTO_UNKOWN	IPSEC_PROTO_BASE

+#define IPSEC_PROTO_UDP		0x01

+#define	IPSEC_PROTO_TCP		0x02

+#define IPSEC_PROTO_TCP_UDP	0x03

+#define IPSEC_PROTO_MAX		IPSEC_PROTO_TCP_UDP

+#define IPSEC_NETIF_NAME_LEN	20

+#define IPSEC_NV_NAME_LEN		30

+#define IPSEC_IPV4ADDLEN_MAX         16

+#define IPSEC_IPV6ADDLEN_MAX         46

+

+

+typedef struct ipsec_set_msg 

+{

+	char dir[8];    /*in or out*/

+	int  IsIpv4;

+	unsigned short	PortC;

+	unsigned short	PortS;	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char 	SrcIpv6[64];

+	char 	DestIpv6[64];

+	char	Ikey[64];

+	char	Ckey[64];

+	int 	Spi;	

+	char	Prot[16];

+	char	Mod[16];

+	char	Ealg[16];

+	char	Alg[16];

+} ipsec_set_msg;

+

+typedef struct ipsec_set_sa_msg 

+{

+

+	int IsIpv4;			//ipv4=1   ipv6=0	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char	SrcIpv6[64];  

+	char	DestIpv6[64];

+	char	Ikey[64];

+	char	Ckey[64];

+	int 	Spi;	

+	char	XfrmProt[16];	

+	char	Mod[16];

+	char	Ealg[16];

+	char	Alg[16];

+} ipsec_set_sa_msg;

+

+typedef struct ipsec_set_sp_msg 

+{

+	char dir[8];    /*in or out*/

+	int IsIpv4;			//ipv4=1   ipv6=0

+	unsigned short	PortC;

+	unsigned short	PortS;	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char	SrcIpv6[64];  

+	char	DestIpv6[64];

+	int 	Spi;	

+	char	XfrmProt[16];

+	int		Prot;

+	char	Mod[16];

+} ipsec_set_sp_msg;

+

+typedef struct ipsec_del_msg 

+{

+	char dir[8];    /*in or out*/

+	int IsIpv4;			//ipv4=1   ipv6=0

+	unsigned short	PortC;

+	unsigned short	PortS;	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char	SrcIpv6[64];  

+	char	DestIpv6[64];

+	char	Ikey[64];

+	char	Ckey[64];

+	int 	Spi;	

+	char	Prot[16];

+	char	Mod[16];

+	char	Ealg[16];

+	char	Alg[16];

+} ipsec_del_msg;

+

+typedef struct ipsec_del_sa_msg

+{

+	int 	IsIpv4;			//ipv4=1   ipv6=0	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char	SrcIpv6[64];  

+	char	DestIpv6[64];

+	int 	Spi;	

+	char	XfrmProt[16];

+	char	Mod[16];

+}ipsec_del_sa_msg;

+

+typedef struct ipsec_del_sp_msg

+{

+	char dir[8];    /*in or out*/

+	int IsIpv4;			//ipv4=1   ipv6=0

+	unsigned short	PortC;

+	unsigned short	PortS;	

+	char	SrcIpv4[32];  

+	char	DestIpv4[32];

+	char	SrcIpv6[64];  

+	char	DestIpv6[64];	

+	int 	Prot;

+}ipsec_del_sp_msg;

+

+extern int ipsec_set(int s, void *data, int datalen);

+extern int ipsec_del(int s, void *data, int datalen);

+extern int ipsec_set_sa(int s, void *data, int datalen);

+extern int ipsec_set_sp(int s, void *data, int datalen);

+extern int ipsec_del_sa(int s, void *data, int datalen);

+extern int ipsec_del_sp(int s, void *data, int datalen);

+#endif

diff --git a/ap/app/include/kwatch_msg.h b/ap/app/include/kwatch_msg.h
new file mode 100644
index 0000000..d10eeb4
--- /dev/null
+++ b/ap/app/include/kwatch_msg.h
@@ -0,0 +1,738 @@
+/**
+ * @file kwatch_msg.h
+ * @brief ¶¨Òå¶ùͯÊÖ±íºǫ́·þÎñÓëMMI½»»¥µÄÏûÏ¢½Ó¿Ú
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _KWATCH_MSG_H
+#define _KWATCH_MSG_H
+/*******************************************************************************
+*                           Include header files                              *
+******************************************************************************/
+/* Include "app/include/message.h". */
+#include "message.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+#define KWATCH_MSG_BASE MSG_CMD_KWATCH_BASE //0x8001
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+enum {
+    /*ƽ̨¿Í»§¶ËÏûÏ¢*/
+    //KWATCH_MSG_PLATFORM_CLIENT = KWATCH_MSG_BASE,
+
+    //ÉèÖÃÀà
+    /*Êý¾ÝÉÏ´«¼ä¸ôÉèÖÃ,µ¥Î»·ÖÖÓ*/
+    //KWATCH_MSG_SET_TIMEPERIOD_REQ,
+    //KWATCH_MSG_SET_TIMEPERIOD_RSP,
+
+    /*²¦´òµç»°*/
+    //KWATCH_MSG_CALL_REQ,
+    //KWATCH_MSG_CALL_RSP,
+
+	TRACK_MSG_ID_START = KWATCH_MSG_BASE + 1,
+	TRACK_MSG_ID_SERVER_RECEIVE,
+	TRACK_MSG_ID_SERVER_SEND,
+	TRACK_MSG_ID_SLAVE_SERVER_RECEIVE,
+	TRACK_MSG_ID_SLAVE_SERVER_SEND,
+	TRACK_MSG_ID_REPORT_SERVER_RECEIVE,
+	TRACK_MSG_ID_REPORT_SERVER_SEND,
+	TRACK_MSG_ID_GPS_POWERON_REQ,
+	TRACK_MSG_ID_GPS_POWEROFF_REQ,
+	MSG_ID_GPS_NMEA_GGA,
+	MSG_ID_GPS_NMEA_GSA,
+	MSG_ID_GPS_NMEA_GSV,
+	MSG_ID_GPS_NMEA_RMC,
+	MSG_ID_GPS_NMEA_VTG,
+	MSG_ID_GPS_NMEA_ACCURACY,
+	TRACK_MSG_ID_UPLOAD,   /*¶¨Ê±Éϱ¨*/
+	TRACK_MSG_ID_LK_TIME_OUT,   /*LK³¬Ê±¼ì²â*/
+	TRACK_MSG_ID_LK_TIME_RESET_NET, /*LK³¬Ê±ÖØÖÃÍøÂç*/
+	TRACK_MSG_SERVER_CHECK,   /*Ö÷·þÎñÍøÂç¼ì²â*/
+	TRACK_MSG_WEATHER_CHECK,  /*ÌìÆø¼ì²é*/
+	TRACK_MSG_SLAVE_SERVER_CHECK,   /*ʱ¼ä·þÎñÆ÷ÍøÂç¼ì²â*/
+	TRACK_MSG_ID_CR_TIMEOUT,
+	TRACK_MSG_ID_AGPS_CHECK,
+	TRACK_MSG_ID_UPLOAD_MODE_ONE,
+	TRACK_MSG_ID_UPLOAD_MODE_TWO,
+	TRACK_MSG_ID_UPLOAD_MODE_THREE,
+	TRACK_MSG_ID_ENCRYPT_ERR,
+	TRACK_MSG_ID_LOG_SAVE,
+	TRACK_MSG_ID_STOP_REMOTE_HEARTRATE,
+	TRACK_MSG_ID_DEV_UNBIN_TIME_OUT,
+	TRACK_MSG_ID_GET_AP,
+	TRACK_MSG_ID_PP_FRIEND,
+	TRACK_MSG_ID_END = KWATCH_MSG_BASE + 100,
+	/*ÒÔÉÏÏûÏ¢IDÖ÷ÒªÊǸøwatch_svrÄÚ²¿ÏûϢʹÓÃ*/
+	/*ÒÔÏÂÏûÏ¢IDÖ÷ÒªÊǸøwatch_svrÓëÆäËü½ø³Ì¼äÏûϢʹÓÃ*/
+    /*************************Èý»ùͬ´´ÏûÏ¢½Ó¿Ú************************/
+    /*Êý¾ÝÉÏ´«¼ä¸ôÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_upload_infoºÍkwatch_common_result*/
+    //KWATCH_MSG_SET_UPLOAD_REQ,
+    //KWATCH_MSG_SET_UPLOAD_RSP,
+    /*ÖÐÐĺÅÂëÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_center_infoºÍkwatch_common_result*/
+	KWATCH_MSG_SET_CENTER_REQ,     //02
+    KWATCH_MSG_SET_CENTER_RSP,
+    /*¿ØÖÆÃÜÂëÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_pw_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_PW_REQ,
+    KWATCH_MSG_SET_PW_RSP,
+    /*¼àÌý(µ¥ÏòñöÌý)ÇëÇó£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_common_result¡£ËµÃ÷:ÖÕ¶Ë×Ô¶¯»Ø²¦ÖÐÐĺÅÂë*/
+    KWATCH_MSG_OWL_REQ,
+    KWATCH_MSG_OWL_RSP,
+    /*SOSºÅÂëÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_sos_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_SOS_REQ,
+    KWATCH_MSG_SET_SOS_RSP,
+    /*ÓïÑÔºÍÊ±ÇøÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_lz_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_LZ_REQ,    //10
+    KWATCH_MSG_SET_LZ_RSP,
+    /*SOS¶ÌÐű¨¾¯¿ª¹Ø£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_sossms_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_SOSSMS_REQ,
+    KWATCH_MSG_SET_SOSSMS_RSP,
+    /*µÍµç¶ÌÐű¨¾¯¿ª¹Ø£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_lowbat_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_LOWBAT_REQ,
+    KWATCH_MSG_SET_LOWBAT_RSP,
+    /*°æ±¾²éѯ£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_verno_info*/
+    KWATCH_MSG_GET_VERNO_REQ,
+    KWATCH_MSG_GET_VERNO_RSP,
+    /*Á¢¼´¶¨Î»Ö¸ÁÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_common_result¡£ËµÃ÷:Á¢¼´»½ÐÑÖÕ¶ËGPSÄ£¿é£¬Á¬ÐøÒ»¶Îʱ¼äÒ»Ö±´¦ÓÚ¶¨Î»×´Ì¬*/
+    KWATCH_MSG_CR_REQ,
+    KWATCH_MSG_CR_RSP,
+    /*¹Ø»úÖ¸ÁÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_common_result¡£*/
+    KWATCH_MSG_POWEROFF_REQ,  //20
+    KWATCH_MSG_POWEROFF_RSP,
+    /*¼Æ²½Ê±¼ä¶ÎÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_walktime_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_WALKTIME_REQ,
+    KWATCH_MSG_SET_WALKTIME_RSP,
+    /*·­¹ö¼ì²âʱ¼ä¶ÎÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_sleeptime_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_SLEEPTIME_REQ,
+    KWATCH_MSG_SET_SLEEPTIME_RSP,
+    /*Ãâ´òÈÅʱ¼ä¶ÎÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_silencetime_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_SILENCETIME_REQ,
+    KWATCH_MSG_SET_SILENCETIME_RSP,
+    /*ÕÒÊÖ±í£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_common_result¡£*/
+    KWATCH_MSG_FIND_REQ,
+    KWATCH_MSG_FIND_RSP,
+    /*ÄÖÖÓÉèÖã¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_remind_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_REMIND_REQ,  //30
+    KWATCH_MSG_SET_REMIND_RSP,
+    /*µç»°±¾ÉèÖã¬ÓÃÓÚÉèÖÃǰ5¸öÁªÏµÈË£¬¼´ÁªÏµÈË1-5£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_phb_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_PHB_REQ,
+    KWATCH_MSG_SET_PHB_RSP,
+    /*µç»°±¾2ÉèÖã¬ÓÃÓÚÉèÖúó5¸öÁªÏµÈË£¬¼´ÁªÏµÈË6-10£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_phb_infoºÍkwatch_common_result*/
+    KWATCH_MSG_SET_PHB2_REQ,
+    KWATCH_MSG_SET_PHB2_RSP,
+    /*¶Ô½²¹¦ÄÜ£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_tk_infoºÍkwatch_common_result¡£
+      ˵Ã÷:¸ÃÏûÏ¢ÓÃÀ´·¢ËͽÓÊÕµ½µÄƽ̨¶Ô½²Êý¾Ýµ½ÖÕ¶Ë£¬¸ÃÏûÏ¢ÊǺǫ́·þÎñ·¢Ë͸øUIµÄ*/
+    KWATCH_MSG_RECV_TK_REQ,
+    KWATCH_MSG_RECV_TK_RSP,
+    /*¶Ô½²¹¦ÄÜ£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_tk_infoºÍkwatch_common_result¡£
+      ˵Ã÷:¸ÃÏûÏ¢ÓÃÀ´·¢ËÍÖն˶Խ²Êý¾Ýµ½Æ½Ì¨£¬¸ÃÏûÏ¢ÊÇUI·¢Ë͵½ºǫ́·þÎñµÄ*/
+    KWATCH_MSG_SEND_TK_REQ,
+    KWATCH_MSG_SEND_TK_RSP,
+    /* ·¢¶ÌÐÅ£¬ÓÃÓÚÊÖ±í·þÎñͨ¹ýƽ̨ʵÏÖ·¢¶ÌÐŹ¦ÄÜ. */
+    KWATCH_MSG_SEND_SMS_REQ,   //40
+    KWATCH_MSG_SEND_SMS_RSP,
+    /* ÏòÊÖ±í·þÎñת·¢Æ½Ì¨½ÓÊÕµ½µÄ¶ÌÐÅ. */
+    KWATCH_MSG_FORWARD_SMS_REQ,
+    KWATCH_MSG_FORWARD_SMS_RSP,
+    /* SOS´òµç»°. */
+    KWATCH_MSG_SOS_CALL_REQ,
+    KWATCH_MSG_SOS_CALL_RSP,
+    /* ÆÕͨ´òµç»°. */
+    KWATCH_MSG_NORMAL_CALL_REQ,
+    KWATCH_MSG_NORMAL_CALL_RSP,
+    /* »ñÈ¡ÌìÆøÐÅÏ¢. */
+    KWATCH_MSG_GET_WEATHER_INFO_REQ,
+    KWATCH_MSG_GET_WEATHER_INFO_RSP,
+    /* ½»ÅóÓÑ. */
+    KWATCH_MSG_MAKE_FRIENDS_REQ,   //50
+    KWATCH_MSG_MAKE_FRIENDS_RSP,
+    /* »ñÈ¡°®ÐÄÊýÁ¿. */
+    KWATCH_MSG_RED_HEART_REQ,
+    KWATCH_MSG_RED_HEART_RSP,
+
+	KWATCH_MSG_SET_PROFILE_REQ,
+	KWATCH_MSG_SET_PROFILE_RSP,
+
+	/* ·¢ËÍSOSʼþ֪ͨ */
+    KWATCH_MSG_EXEC_SOS_REQ,
+    KWATCH_MSG_EXEC_SOS_RSP,
+
+    /* ¼Æ²½ÐÅÏ¢»ñÈ¡ */
+    KWATCH_MSG_GET_STEP_REQ,
+    KWATCH_MSG_GET_STEP_RSP,
+
+	/* GPS */
+    KWATCH_MSG_GPS_GPD_SET_REQ, //60
+	KWATCH_MSG_GPS_PWR_SET_REQ,
+	KWATCH_MSG_GPS_COORDINATE_SET_REQ,
+	KWATCH_MSG_GPS_INQUIRE_REQ,
+	KWATCH_MSG_GPS_RSP,
+
+    /* ÊÖ±í×¥ÅIJ¢ÉÏ´«ÕÕÆ¬ */
+	/* watch_svrÏòÊÖ±íÉ豸·¢×¥ÅÄÏûÏ¢,ÎÞ²ÎÊý */
+	KWATCH_MSG_SNAP_REQ,
+	/* ÊÖ±íÉ豸»Ø¸´×¥ÅÄÐÅÏ¢,·µ»Økwatch_snap_infoÀàÐÍÊý¾Ý */
+	KWATCH_MSG_SNAP_RSP,
+
+    /* ÏàÆ¬·ÖÏí */
+	/* ÊÖ±íÉ豸Ïòwatch_svr·¢ËÍ·ÖÏíÏàÆ¬ÏûÏ¢,ÏûÏ¢Êý¾ÝÌåΪkwatch_share_photos_infoÀàÐÍ */
+	KWATCH_MSG_SHARE_PHOTOS_REQ,
+	/* watch_svr»Ø¸´ÏàÆ¬·ÖÏí½á¹û */
+	KWATCH_MSG_SHARE_PHOTOS_RSP,
+
+    /* »Ö¸´³ö³§ÉèÖÃ */
+	/* watch_svrÏòÊÖ±íÉ豸·¢Ëͻָ´³ö³§ÉèÖÃÏûÏ¢,ÎÞ²ÎÊý */
+	KWATCH_MSG_FAC_RESET_REQ,
+	/* ÊÖ±íÉ豸´ð¸´»Ö¸´³ö³§Ö´Ðнá¹û */
+	KWATCH_MSG_FAC_RESET_RSP,  //70
+
+    /* ¶¨Ê±¿ª¹Ø»ú*/
+    /* watch_svrÏòÊÖ±íÉ豸·¢ËͶ¨Ê±¿ª¹Ø»úÐÅÏ¢,kwatch_spof_info*/
+    KWATCH_MSG_SPOF_REQ,
+    /*ÊÖ±íÉ豸·¢ËͶ¨Ê±¿ª¹Ø»úÉèÖýá¹û kwatch_common_result*/
+    KWATCH_MSG_SPOF_RSP,
+
+	/*mmi·¢ËÍÍøÂçÇл»£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_pdp_status_info*/
+	KWATCH_MSG_PDP_STATUS_IND,
+
+    /* ¹¤³Ìģʽ£ºG-Sensor²âÊÔ */
+	/* ÊÖ±íÉ豸Ïòwatch_svr·¢Ë͹¤³ÌģʽG-Sensor²âÊÔÏûÏ¢ */
+	KWATCH_MSG_GSENSOR_TEST_REQ,
+	/* watch_svrÏòÊÖ±íÉ豸·µ»ØG-sensor²âÊÔ½á¹ûÐÅÏ¢,·µ»Økwatch_gsensor_test_infoÀàÐÍÊý¾Ý */
+	KWATCH_MSG_GSENSOR_TEST_RSP,
+
+    /* ¹¤³Ìģʽ£ºGPS²âÊÔ */
+	/* ÊÖ±íÉ豸Ïòwatch_svr·¢Ë͹¤³ÌģʽGPS²âÊÔÏûÏ¢ */
+	KWATCH_MSG_GPS_TEST_REQ,
+	/* watch_svrÏòÊÖ±íÉ豸·µ»ØGPS²âÊÔ½á¹ûÐÅÏ¢,·µ»Økwatch_gps_test_infoÀàÐÍÊý¾Ý */
+	KWATCH_MSG_GPS_TEST_RSP,
+
+    /* ¹¤³Ìģʽ£ºWi-Fi²âÊÔ */
+	/* ÊÖ±íÉ豸Ïòwatch_svr·¢Ë͹¤³ÌģʽWi-Fi²âÊÔÏûÏ¢ */
+	KWATCH_MSG_WIFI_TEST_REQ,
+	/* watch_svrÏòÊÖ±íÉ豸·µ»ØWi-Fi²âÊÔ½á¹ûÐÅÏ¢,·µ»Økwatch_wifi_test_infoÀàÐÍÊý¾Ý */
+	KWATCH_MSG_WIFI_TEST_RSP,
+
+	/* »ùÕ¾¶¨Î»£ºLBSÐÅÏ¢Éϱ¨ */
+	/* Ôݲ»Ê¹Óà */
+	KWATCH_MSG_LBS_REQ,
+	/* ModemÏòwatch_svrת·¢µÄLBSÐÅÏ¢ */
+	KWATCH_MSG_LBS_RSP,
+
+	/*watch_svr ·¢ËͽûֹʹÓò¦ºÅÅÌ*/
+	KWATCH_MSG_DIALER_FORBIDDEN_REQ,
+
+	/* watch_svrÏòÊÖ±íÉ豸·¢ËÍ»ñÈ¡µç³ØÏà¹ØÐÅÏ¢ÏûÏ¢,ÎÞ²ÎÊý */
+	KWATCH_MSG_BATTERY_INFO_REQ,
+
+	/* ÊÖ±íÉ豸´ð¸´µç³ØÏà¹ØÏûÏ¢,²ÎÊýÓÉkwatch_battery_info½á¹¹¶¨Òå */
+	KWATCH_MSG_BATTERY_INFO_RSP,
+
+	/* MMI·¢ËÍPP½»ÓÑÇëÇó*/
+	KWATCH_PP_FRIEND_REQ = KWATCH_MSG_LBS_RSP+100,
+	/* watch_svr ֪ͨMMI½»Óѽá¹û */
+	KWATCH_PP_FRIEND_RSP,
+
+	/*ºÃÓѹ¦ÄÜ£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_friend_tk_infoºÍkwatch_common_result¡£
+      ˵Ã÷:¸ÃÏûÏ¢ÓÃÀ´·¢ËͽÓÊÕµ½µÄƽ̨¶Ô½²Êý¾Ýµ½ÖÕ¶Ë£¬¸ÃÏûÏ¢ÊǺǫ́·þÎñ·¢Ë͸øUIµÄ*/
+    KWATCH_MSG_RECV_FRIEND_TK_REQ,
+    KWATCH_MSG_RECV_FRIEND_TK_RSP,
+
+	/*ºÃÓѹ¦ÄÜ£¬ÏàÓ¦Êý¾Ý½á¹¹ÐÅÏ¢kwatch_friend_tk_infoºÍkwatch_common_result¡£
+      ˵Ã÷:¸ÃÏûÏ¢ÓÃÀ´·¢ËÍÖն˶Խ²Êý¾Ýµ½Æ½Ì¨£¬¸ÃÏûÏ¢ÊÇUI·¢Ë͵½ºǫ́·þÎñµÄ*/
+    KWATCH_MSG_SEND_FRIEND_TK_REQ,
+    KWATCH_MSG_SEND_FRIEND_TK_RSP,
+
+	/*mmi·¢ËͺÃÓÑɾ³ýÏûÏ¢*/
+	KWATCH_MSG_PP_FRIEND_DEL_REQ,
+	/*watch_svr ·¢ËͺÃÓÑɾ³ý½á¹û*/
+	KWATCH_MSG_PP_FRIEND_DEL_RSP,
+
+	/*΢ÁĽÓÊÕÎÄ×ÖÐÅÏ¢*/
+    KWATCH_TEXT_MSG_RECV_REQ,
+    KWATCH_TEXT_MSG_RECV_RSP,
+
+	/*ÐÄÂÊѪѹ²âÁ¿*/
+	KWATCH_HEARTRATE_MEASURE_REQ,  /*MMI ·¢ËͲâÁ¿ÇëÇó ÏûÏ¢½á¹¹Ìå kwatch_heartrate_measure_req*/
+    KWATCH_HEARTRATE_MEASURE_RSP,  /*watch_svr ²âÁ¿½á¹û·¢Ë͸øMMI ÏûÏ¢½á¹¹Ìå kwatch_heartrate_info*/
+
+	KWATCH_POWER_SAVE_REQ,  /*watch_svr ·¢ËÍÊ¡µçģʽ ÏûÏ¢½á¹¹Ìå kwatch_power_save_req*/
+
+	KWATCH_WIFI_AP_RSP,  /*½ÓÊÜWIFI ɨÃè½á¹û*/
+	KWATCH_MSG_WIFI_OPEN_REQ,/*WIFI ´ò¿ªÇëÇó*/
+	KWATCH_MSG_WIFI_OPEN_RSP,
+	/*ÈÚÔÆÊÓÆµÍ¨»°*/
+	KWATCH_PRYVCALL_REQ,  /*APP¶ËÏòÊÖ±í·¢ÆðÊÓÆµÍ¨»°ÇëÇó watch_svr to mmi*/
+	KWATCH_PRYVCALL_RSP,  /*ÊÓÆµÍ¨»°ÇëÇó½á¹û״̬ mmi to watch_svr*/
+	
+	KWATCH_RYVCALLCANCEL_REQ,  /*APP¶ËÈ¡ÏûÏòÊÖ±í·¢ÆðÊÓÆµÍ¨»°ÇëÇó watch_svr to mmi*/
+	
+	KWATCH_RYVCALLREFUSE_REQ,  /*APP¶Ë¾Ü¾øÊÖ±íÊÓÆµÍ¨»°ÇëÇó watch_svr to mmi*/
+	KWATCH_RYVCALLREFUSE_RSP,  /*ÊÖ±í¾Ü½Óapp¶ËÊÓÆµÍ¨»°ÇëÇó mmi to watch_svr*/
+
+	KWATCH_WRYVCALL_RSP,  /*ÊÖ±í¶ËÏòapp¶Ë·¢ÆðÊÓÆµÍ¨»°ÇëÇómmi to watch_svr*/
+	KWATCH_WRYVCALL_REQ,  /*app»Ø¸´ÊÖ±í¶ËÊÓÆµÍ¨»°ÇëÇó״̬watch_svr to mmi*/
+
+	KWATCH_UPRYROOMCOUNT_RSP,  /*ÊÖ±í¶Ë½ø³ö·¿¼ä¶¼Ïòapp¶ËÉϱ¨·¿¼äÊ£ÓàÈËÊý mmi to watch_svr*/
+	
+	KWATCH_RYCONFIG_REQ,  /*·þÎñÆ÷¶ËÉèÖÃÊÖ±íÈÚÔÆsdk log¿ª¹Ø watch_svr to mmi*/
+	
+	KWATCH_CLOCK_BJ_CHANGE,
+};
+/*ÏìÓ¦½á¹û´íÎóÂë*/
+typedef enum {
+    KWATCH_RET_FAIL = -1,/*ʧ°Ü*/
+    KWATCH_RET_OK = 0,/*³É¹¦*/
+    /*¸ù¾ÝÐèÒªÌí¼ÓÆäËü´íÎóÂë*/
+} kwatch_result;
+
+/*ͨÓÃÏìÓ¦½á¹ûÊý¾Ý½á¹¹*/
+typedef struct {
+    /*²Î¼ûkwatch_result*/
+    kwatch_result result;
+} kwatch_common_result;
+
+#if 0
+/*Êý¾ÝÉÏ´«¼ä¸ôÉèÖÃÐÅÏ¢,ÓÃÓÚÉèÖÃÖն˶¨Ê±Éϱ¨µÄʱ¼ä¼ä¸ô*/
+typedef struct {
+    unsigned int period;/*µ¥Î»:·ÖÖÓ*/
+} kwatch_upload_info;
+#endif
+/*ÖÐÐĺÅÂëÉèÖÃÐÅÏ¢,ͨ¹ý¸ÃÊÖ»úºÅ¿ÉÒÔ·¢ËͶÌÐÅÖ¸Áî¡¢¼àÌýµÈ*/
+typedef struct {
+    char number[48];/*µç»°ºÅÂë*/
+} kwatch_center_info;
+
+/*¿ØÖÆÃÜÂëÉèÖÃÐÅÏ¢,·ÇÖÐÐĺÅÂë·¢ËͶÌÐÅÖ¸ÁîÐèÒªÌí¼ÓÃÜÂë*/
+typedef struct {
+    char password[32];/*ÃÜÂë*/
+} kwatch_pw_info;
+
+/*SOSºÅÂëÉèÖÃÐÅÏ¢£¬×î¶àÉèÖÃ3¸öSOSºÅÂë*/
+typedef struct {
+    char number1[48];/*SOSµç»°ºÅÂë1*/
+    char number2[48];/*SOSµç»°ºÅÂë2*/
+    char number3[48];/*SOSµç»°ºÅÂë3*/
+} kwatch_sos_info;
+
+/*ÓïÑÔºÍÊ±ÇøÉèÖÃÐÅÏ¢,ÓÃÓÚÉèÖÃÖÕ¶ËÓïÑÔºÍÊ±Çø*/
+typedef struct {
+    unsigned int languge;/*ÓïÑÔ£¬0-ÖÐÎÄ£»1-Ó¢ÎÄ*/
+    unsigned int timezone;/*Ê±Çø*/
+} kwatch_lz_info;
+
+/*SOS¶ÌÐű¨¾¯¿ª¹ØÉèÖÃÐÅÏ¢,ÉèÖòúÉúSOS±¨¾¯ºóÊÇ·ñÏòSOSºÅÂë·¢ËͶÌÐÅ*/
+typedef struct {
+    unsigned int onoff;/*¿ª¹Ø£¬0-¹Ø±Õ£»1-´ò¿ª*/
+} kwatch_sossms_info;
+/*µÍµç±¨¾¯¿ª¹ØÉèÖÃÐÅÏ¢,ÉèÖòúÉúµÍµç±¨¾¯ºóÊÇ·ñÏòÖÐÐĺÅÂë·¢ËͶÌÐÅ*/
+typedef struct {
+    unsigned int onoff;/*¿ª¹Ø£¬0-¹Ø±Õ£»1-´ò¿ª*/
+} kwatch_lowbat_info;
+
+/*Öն˰汾ÐÅÏ¢,ÓÃÓÚÉÏ´«°æ±¾ÐÅÏ¢*/
+typedef struct {
+    char version[128];/*°æ±¾ÐÅÏ¢*/
+} kwatch_verno_info;
+
+typedef struct {
+    unsigned char hour; /* 0~23 */
+    unsigned char min;  /* 0~59 */
+    unsigned char sec;  /* 0~59 */
+} kwatch_time;
+/*¼Æ²½Ê±¼ä¶ÎÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖüƲ½´ò¿ªµÄʱ¼ä¶Î·¶Î§,×î¶àÉèÖÃ3¸ö*/
+typedef struct {
+    kwatch_time time1[2];/*ʱ¼ä¶Î1£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+    kwatch_time time2[2];/*ʱ¼ä¶Î2£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+    kwatch_time time3[2];/*ʱ¼ä¶Î3£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+} kwatch_walktime_info;
+
+/*·­¹ö¼ì²âʱ¼ä¶ÎÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖ÷­¹ö¼ì²âµÄʱ¼ä¶Î·¶Î§,×î¶àÉèÖÃ1¸ö*/
+typedef struct {
+    kwatch_time time[2];/*ʱ¼ä¶Î£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+} kwatch_sleeptime_info;
+
+/*Ãâ´òÈÅʱ¼ä¶ÎÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖÃÃâ´òÈÅʱ¼ä¶Î·¶Î§,×î¶àÉèÖÃ4¸ö*/
+typedef struct {
+    kwatch_time time1[2];/*ʱ¼ä¶Î1£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+    kwatch_time time2[2];/*ʱ¼ä¶Î2£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+    kwatch_time time3[2];/*ʱ¼ä¶Î3£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+    kwatch_time time4[2];/*ʱ¼ä¶Î4£¬0-Æðʼʱ¼ä£»1-½áÊøÊ±¼ä*/
+} kwatch_silencetime_info;
+
+/*ÄÖÖÓÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖÃÖÕ¶ËÄÖÖÓ,×î¶àÉèÖÃ3¸ö*/
+typedef struct {
+    struct {
+        kwatch_time time;/*ʱ¼ä*/
+        unsigned int onoff;/*¿ª¹Ø,0-¹Ø±Õ£»1-´ò¿ª*/
+        unsigned int freq;/*ƵÂÊ*/
+		unsigned int days; /*×Ô¶¨Òå*/
+    } alarm[3];
+} kwatch_remind_info;
+
+/*×Ô¶¯¿ª¹Ø»úÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖÃÖÕ¶ËÄÖÖÓ,×î¶àÉèÖÃ3¸ö*/
+typedef struct {
+		kwatch_time time;/*ʱ¼ä*/
+		unsigned int onoff;/*¿ª¹Ø,0-¹Ø±Õ£»1-´ò¿ª*/
+		unsigned int type;
+} kwatch_auto_poweronff_info;
+
+/*¶¨Ê±¿ª¹Ø»úÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖö¨Ê±¿ª¹Ø»ú*/
+typedef struct
+{
+    kwatch_time time;	/*ʱ¼ä*/
+    unsigned int onoff;/*¿ª¹Ø,0-¹Ø±Õ£»1-´ò¿ª*/
+    unsigned int freq;/*ƵÂÊ*/
+    unsigned int days; /*×Ô¶¨Òå*/
+    unsigned int spof; /*0Ϊ¿ª»ú 1Ϊ¹Ø»ú*/
+} kwatch_spof_info;
+
+
+
+
+
+/*µç»°±¾ÉèÖÃÐÅÏ¢£¬ÓÃÓÚÉèÖÃÖն˵绰±¾,ÿ´Î×î¶àÉèÖÃ5¸ö*/
+typedef struct {
+    int index;
+    struct {
+        char number[48];/*µç»°ºÅÂë*/
+        char name[128];/*ÐÕÃû*/
+    } contact[5];
+} kwatch_phb_info;
+
+/*¶Ô½²Êý¾ÝÐÅÏ¢*/
+typedef struct {
+	char contact_num[20]; /*APPÁªÏµÈ˺ÅÂë*/
+	unsigned int x_type;/*²ÎÊýxΪ0´ú±íµ¥ÁÄ  xΪ1´ú±íȺÁÄÏûÏ¢ xΪ2´ú±íºÃÓÑÏûÏ¢*/
+    unsigned int type;/*ÒôƵÊý¾Ý¸ñʽ£¬0-±íʾAMR£»ÆäËü´ýÀ©Õ¹  0xff:±íʾΪÎÄ×ÖÐÅÏ¢*/
+    unsigned int datalen;/*ÒôƵÊý¾Ý³¤¶È*/
+    char fpath[256];     /*ÒôƵÊý¾ÝÎļþ·¾¶*/
+} kwatch_tk_info;
+
+
+/* µ¥ÏòñöÌýµÄÇëÇóÊý¾Ý */
+typedef struct {
+    char number[48];/*µ¥ÏòñöÌýºÅÂë*/
+} kwatch_owl_info;
+
+/*¼Æ²½ÐÅÏ¢,ÓÃÓڻظ´Éϲã²éѯ²½Êý¶¯×÷*/
+typedef struct {
+    long steps;   /*²½ÊýÐÅÏ¢*/
+    char isopen; /*0±íʾ¹Ø±Õ 1±íʾ´ò¿ª*/
+} kwatch_pedometer_info;
+
+typedef struct {
+    int  numcnt;              /* ÊÕ·¢ºÅÂë¸öÊý£¬·¢ËÍΪ 1~5¡£½ÓÊչ̶¨Îª1 */
+    char number[5*40 + 1];    /* ÊÕ·¢ºÅÂ룬Ⱥ·¢¶à¸öºÅÂë¼äÒÔ','×÷Ϊ·Ö¸ô£¬½ÓÊչ̶¨Îª1¸öºÅÂë */
+    unsigned char data[10*153*2 + 1];/* ÊÕ·¢¶ÌÐÅÄÚÈÝ£¬·¢ËÍ×î´óÖ§³Ö176£¬½ÓÊÕ×î´óÖ§³Ö 1530£¬GBK ±àÂë */
+} kwatch_snd_sms_info;
+
+typedef struct {
+    int  call_type; /* ±êʶ²¦´òÀàÐÍ£¬0ΪÆÕͨµç»°£¬ºóÐøÐèÇó±ä¸ü¿ÉÀ©³ä */
+    char number[48];/* Õý³£²¦´òµÄºÅÂë */
+} kwatch_call_info;
+
+typedef struct {
+    int weather_type;    /* ÌìÆøÀàÐÍ£¬ÈçÓꡢѩ¡¢ÇçµÈ  */
+    int cur_temperature; /* µ±Ç°ÎÂ¶È */
+    int min_temperature; /*µÍÎÂ*/
+    int max_temperature; /*¸ßÎÂ*/
+    char zone[64];       /*µØÇø³ÇÊÐÃû³Æ*/
+	char date[20]; /*ÈÕÆÚ*/
+	char time[20]; /*ʱ¼ä*/
+} kwatch_weather_info;
+
+typedef struct {
+    int type; /* 1,½»ÅóÓÑÓ¦ÓÃÆô¶¯£¬0£¬½»ÅóÓÑÓ¦ÓýáÊø  */
+} kwatch_make_friends_info;
+
+typedef struct {
+    int counts; /* °®ÐÄÊýÁ¿  */
+} kwatch_red_heart_info;
+
+typedef struct{
+
+ int type;  /*1.ÏìÁå¼°Õ𶯠 2.½öÏìÁå 3.½öÕ𶯠4.¾²Òô*/
+
+}kwatch_profile_info;
+
+
+/* ÊÖ±íÉ豸»Ø¸´×¥ÅÄÐÅÏ¢ */
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+    /* ×¥ÅĵÄͼƬÃû³ÆÂ·¾¶ */
+    char file_name[256];
+}kwatch_snap_info;
+
+/* ÊÖ±íÉ豸Ïòwatch_svr·¢ËÍ·ÖÏíÏàÆ¬ÏûÏ¢ */
+typedef struct{
+    /* ·ÖÏíµÄͼƬÃû³ÆÂ·¾¶ */
+    char file_name[256];
+}kwatch_share_photos_info;
+
+/* watch_svrÏòÊÖ±íÉ豸·µ»ØG-sensor²âÊÔ½á¹ûÐÅÏ¢ */
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+    /* G-Sensor²âÊÔ½á¹ûÐÅÏ¢£¬ÈçÈýÖáÊý¾ÝµÈ */
+    char gsensor_info[256];
+}kwatch_gsensor_test_info;
+
+/* watch_svrÏòÊÖ±íÉ豸·µ»ØGPS²âÊÔ½á¹ûÐÅÏ¢ */
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+    /* GPS²âÊÔ½á¹ûÐÅÏ¢£¬ÈçÎÀÐÇÊýÁ¿¡¢ÐźÅÇ¿¶ÈµÈ */
+    char gps_info[256];
+}kwatch_gps_test_info;
+
+/* watch_svrÏòÊÖ±íÉ豸·µ»ØWi-Fi²âÊÔ½á¹ûÐÅÏ¢ */
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+    /* Wi-Fi²âÊÔ½á¹ûÐÅÏ¢£¬ÈçÈȵãÃû³Æ¡¢ÐźÅÇ¿¶ÈµÈ */
+    char wifi_info[256];
+}kwatch_wifi_test_info;
+
+#define WORK_TIME_TOTAL   36
+#define GPS_WORK_TIME_START 0
+#define SLEEP_TIME_START    12
+#define WALK_TIME_START    20
+#define SILENCE_TIME_START 28
+
+typedef struct
+{
+	unsigned int start_time[WORK_TIME_TOTAL];
+	unsigned int end_time[WORK_TIME_TOTAL];
+}work_time_struct;
+
+
+/*MMI·¢ËÍÍøÂçÇл»*/
+typedef struct{	
+	int result;/*1,¼¤»î;0,È¥¼¤»î*/
+}kwatch_pdp_status_info;
+
+/* ModemÏòwatch_svrת·¢µÄLBSÐÅÏ¢ */
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+    /* ModemÏòwatch_svrת·¢µÄLBSÐÅÏ¢ */
+    char lbs_info[1280]; /* LBS AT·µ»ØµÄÊý¾Ý±£´æÔڸóÉÔ±±äÁ¿ÖÐ */
+}kwatch_lbs_info;
+
+
+/*watch_svr·¢ËͲ¦ºÅÅÌ¿ª¹ØÇëÇó*/
+typedef struct{
+    /* Ö´Ðнá¹û */
+    unsigned int onoff;  /*0:½ûÖ¹²¦ºÅÅÌ  1:¿ªÆô²¦ºÅÅÌ*/
+}kwatch_dialer_info;
+
+typedef struct{
+    /* Ö´Ðнá¹û */
+    kwatch_common_result result;
+	/* type&0x1 == 1 :ÊǶÔKWATCH_MSG_BATTERY_INFO_REQÏûÏ¢µÄÏìÓ¦·µ»ØÊý¾Ý; voltage,percentageÓÐЧ */
+    /* type&0x2 == 1 :´ú±í³äµçÆ÷²åÈë¡¢°Î³ö¡¢µç³äÒÑÂúʱÖ÷¶¯Ïòwatch_svr·¢Ë͵Ä֪ͨ; battery_full, charger_pluginÓÐЧ */
+    int type; 
+    int voltage; /* µç³Øµçѹ£¬µ¥Î»ºÁ·ü */
+    int percentage; /* µçÁ¿°Ù·Ö±È */
+    int battery_full; /* µç³ØÒѳäÂúΪ1£¬Î´³äÂúΪ0 */
+    int charger_plugin; /* ÎÞЧֵΪ-1, ²åÈëUSBֵΪ1, ²¦³öUSBֵΪ0 */
+}kwatch_battery_info;
+
+
+
+/*MMIÏòwatch_svr·¢Ëͽ»ÓÑÇëÇó*/
+typedef struct{
+    /* Ö´Ðнá¹û */
+    unsigned int onoff;  /*0:½»ÓÑ¿ªÆô  1:½»ÓѹرÕ*/
+}kwatch_pp_req_info;
+
+/*APPÁªÏµÈËÐÅÏ¢*/
+typedef struct{
+	int new_msg;   /*0 ÒѶÁ  1:δ¶Á*/
+	char friend_did[20]; /*APPÁªÏµÈ˺ÅÂë*/
+	char friend_name[30];/*APPÁªÏµÈËÐÕÃû*/
+	char friend_num[20]; /*APPÁªÏµÈ˺ÅÂë*/
+}kwatch_pp_info;
+
+/*watch_svrÏòMMI·¢Ëͽ»Óѽá¹û*/
+typedef struct{
+    /* Ö´Ðнá¹û */
+    unsigned int rst;  /*0:½»Óѳɹ¦  1:½»ÓÑʧ°Ü  2:ºÃÓÑÖØ¸´  3:ɾ³ýºÃÓÑ*/
+	char friend_did[20]; /*ºÃÓÑÉ豸ID*/
+	char friend_num[20]; /*APPÁªÏµÈ˺ÅÂë*/
+	char friend_name[30];/*APPÁªÏµÈËÐÕÃû*/
+}kwatch_pp_rsp_info;
+
+/*ºÃÓѶԽ²Êý¾ÝÐÅÏ¢*/
+typedef struct {
+	char did[20];        /*ºÃÓÑID*/
+    unsigned int type;/*ÒôƵÊý¾Ý¸ñʽ£¬0-±íʾAMR£»ÆäËü´ýÀ©Õ¹*/
+    unsigned int datalen;/*ÒôƵÊý¾Ý³¤¶È*/
+    char fpath[256];     /*ÒôƵÊý¾ÝÎļþ·¾¶*/
+} kwatch_friend_tk_info;
+
+/*ºÃÓÑɾ³ý*/
+typedef struct{
+    /* Ö´Ðнá¹û */
+    unsigned int rst;  /*ÓÃÓÚºÃÓÑɾ³ý»Ø¸´ 0:ɾ³ý³É¹¦  1:ɾ³ýʧ°Ü  2:ͨ¹ýbblistЭÒéɾ³ýºÃÓÑ*/
+	char friend_did[20]; /*ºÃÓÑÉ豸ID*/
+	char friend_num[20]; /*APPÁªÏµÈ˺ÅÂë*/
+}kwatch_pp_del_info;
+
+/*APPÁªÏµÈËÐÅÏ¢*/
+typedef struct{
+	int new_msg;   /*0 ÒѶÁ  1:δ¶Á*/
+	char contact_num[20]; /*APPÁªÏµÈ˺ÅÂë*/
+	char contact_name[30];/*APPÁªÏµÈËÐÕÃû*/
+}appcontact_info;
+
+/*ÐÄÂÊѪѹ*/
+typedef struct{
+	int rst;   /*0 Õý³£²âÁ¿  -1:ÍÑÀë  -2:ÆäËüʧ°Ü*/
+	unsigned int heartrate;
+	unsigned int bloodpressure_low;
+	unsigned int bloodpressure_high;
+}kwatch_heartrate_info;
+
+typedef struct{
+	unsigned int enable;  /*1´ò¿ª²âÁ¿  0¹Ø±Õ²âÁ¿*/
+}kwatch_heartrate_measure_req;
+
+typedef struct{
+	unsigned int enable;  /*1½øÈëÊ¡µçģʽ  0Í˳öÊ¡µçģʽ*/
+}kwatch_power_save_req;
+
+/*watch_svrÈÚÔÆÊÓÆµÍ¨»°*/
+//app·¢ÆðÊÓÆµÁÄÌì
+//KWATCH_PRYVCALL_REQ
+typedef struct{
+    unsigned int type;  /*0:µ¥ÁÄ  1:ȺÁÄ*/
+	char num[30]; /*·¢ÆðÁÄÌìÓû§ºÅÂë*/
+	char room_num[30]; /*·¢ÆðȺÁÄ·¿¼äºÅ*/
+}kwatch_pryvcall_info;
+//app·¢ÆðÊÓÆµÁÄÌì ÊÖ±í»Ø¸´×´Ì¬
+//KWATCH_PRYVCALL_RSP
+typedef struct{
+    unsigned int status;  /*0  Ö§³Öµ±Ç°Í¨»°ÇëÇó   1  ÕýÔÚͨ»°ÖУ¬²»Ö§³Öµ±Ç°Í¨»°ÇëÇó*/
+}kwatch_pryvcall_req;
+
+//ÊÖ±í·¢ÆðÊÓÆµÁÄÌì
+//KWATCH_WRYVCALL_RSP
+typedef struct{
+    unsigned int type;  /*0:µ¥ÁÄ  1:ȺÁÄ*/
+	char num[30]; /*·¢ÆðÁÄÌìÓû§ºÅÂë*/
+	char room_num[30]; /*·¢ÆðÁÄÌì·¿¼äºÅ*/
+}kwatch_wryvcall_info;
+//ÊÖ±í·¢ÆðÊÓÆµÁÄÌì app¶Ë»Ø¸´×´Ì¬
+//KWATCH_WRYVCALL_REQ
+typedef struct{
+    unsigned int status;  /*0  ʧ°Ü  1  ³É¹¦ */
+}kwatch_wryvcall_req;
+
+//ÊÖ±í½ø³ö·¿¼äÉϱ¨app¶Ë
+//KWATCH_UPRYROOMCOUNT_RSP
+typedef struct{
+    unsigned int type;  /*0:µ¥ÁÄ  1:ȺÁÄ*/
+	unsigned int count; /*·¿¼äÈËÊý*/
+	char room_num[30]; /*·¢ÆðÁÄÌì·¿¼äºÅ*/
+}kwatch_upryroomcount_info;
+
+//ÊÖ±í/app¾Ü½Ó
+//KWATCH_RYVCALLREFUSE_RSP
+typedef struct{
+    unsigned int type;  /*0:µ¥ÁÄ  1:ȺÁÄ*/
+	char num[30]; /*·¢ÆðÁÄÌìÓû§ºÅÂë*/
+	char room_num[30]; /*·¢ÆðÁÄÌì·¿¼äºÅ*/
+}kwatch_ryvcallrefuse_info;
+
+// log ÅäÖÃ
+//KWATCH_RYCONFIG_REQ
+typedef struct{
+	char config[30]; /*Àý£ºRYCONFIG = 0-1-0 ÈÕÖ¾¿ª¹Ø£º0£º¹Ø  1¿ª  ĬÈÏ¿ª ÈÕÖ¾Îļþ´óС£ºµ¥Î»£ºM  ĬÈÏ1M  ÈÕÖ¾Éϱ¨±êʶ£º0£º²»Éϱ¨  1Éϱ¨  ĬÈϲ»Éϱ¨*/
+}kwatch_ryconfig_info;
+
+struct resp_header//±£³ÖÏàӦͷÐÅÏ¢
+{
+    int status_code;//HTTP/1.1 '200' OK
+    char content_type[128];//Content-Type: application/gzip
+    long content_length;//Content-Length: 11683079
+    char file_name[256];
+};
+
+typedef struct{
+	char name[20];
+    int month;         //01~12
+    int day;           //01~31 
+    int dayflow;
+	int dayflow_already; 
+	int dayflow_on;  
+	int monthflow; 
+	int monthflow_already;
+	int monthflow_on;
+	int monthcount;
+	int countflow;
+}nwflow_info;
+
+typedef struct{
+    int year;        
+    int month;         //01~12
+    int day;           //01~31 
+    int hour;         
+    int minute;         
+    int second;           
+}nwpwrtime_info;
+
+
+typedef enum {
+	SJTC_TIMER_ID_0=0,  /*ģʽһ¶¨Ê±Éϱ¨*/
+	SJTC_TIMER_ID_1,    /*²»´øGPS¶¨Ê±Éϱ¨*/
+	SJTC_TIMER_ID_2,    /*lk³¬Ê±¼ì²â*/
+	SJTC_TIMER_ID_3,    /*ÍøÂçÁ¬½Ó¼ì²â*/
+	SJTC_TIMER_ID_4,    /*ÌìÆø¸üÐÂ*/
+	SJTC_TIMER_ID_5,    /*LKµÚÒ»´ÎÑÓʱ·¢ËÍ*/
+	SJTC_TIMER_ID_6,    /*ʱ¼ä·þÎñÆ÷ÍøÂç¼ì²â*/
+	SJTC_TIMER_ID_7,    /*ÑÓ³Ù·¢ËÍÓïÒô*/
+	SJTC_TIMER_ID_8,    /*»°·Ñ²éѯ*/
+	SJTC_TIMER_ID_9,   /*CRÖ¸Áʱ*/
+	SJTC_TIMER_ID_10,  /*TKQ*/
+	SJTC_TIMER_ID_11,  /*Êý¾ÝÉÏ´«*/
+	SJTC_TIMER_ID_12,  /*ÅäÖÃÉϱ¨*/
+	SJTC_TIMER_ID_13,  /*µÍµç±¨¾¯*/
+	SJTC_TIMER_ID_14,  /*ÅöÅöºÃÓÑÇëÇó*/
+	SJTC_TIMER_ID_15,  /*LK¼ä¸ô´¦Àí*/ 
+	SJTC_TIMER_ID_16,  /*¼ÓÃÜ*/
+	SJTC_TIMER_ID_17,  /*ÑÓʱ¹Ø»ú*/
+	SJTC_TIMER_ID_18,  /*AGPS*/
+	SJTC_TIMER_ID_19,  /*¼ÓÃܳö´í´¦Àí*/
+	SJTC_TIMER_ID_20,  /*¶ÌÐÅת·¢*/
+	SJTC_TIMER_ID_21,  /*ĬÈ϶¨Ê±¿ª¹Ø»ú*/
+	SJTC_TIMER_ID_22,  /*»ñÈ¡ÐÄÂÊÊý¾Ý*/
+	SJTC_TIMER_ID_23,  /*»»¿¨½â°ó³¬Ê±*/
+	SJTC_TIMER_ID_24,  /*WIFIËÑË÷*/
+	SJTC_TIMER_ID_25,  /*send AGPS*/
+	SJTC_TIMER_ID_26,
+	SJTC_TIMER_ID_27,
+	SJTC_TIMER_ID_28,
+	SJTC_TIMER_ID_29,
+	SJTC_TIMER_ID_30,
+}timer_id;
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+
+
+
+#endif /*_KWATCH_MSG_H*/
+
diff --git a/ap/app/include/libcpnv.h b/ap/app/include/libcpnv.h
new file mode 100755
index 0000000..9eac4c1
--- /dev/null
+++ b/ap/app/include/libcpnv.h
@@ -0,0 +1,115 @@
+#ifndef __LIBCPNV_H

+#define __LIBCPNV_H

+

+

+enum FS_PARTITION_NO {

+	FS_IMAGEFS,

+	FS_RESOURCEFS,

+	FS_NVROFS,

+	FS_PARTITION_NO_MAX

+};

+

+#define SYSCALL_jffs2_quick_gc_wait_done   385

+

+#define CPNV_OK     (0)

+#define CPNV_ERROR (0xFFFFFFFF)

+

+/**
+ * @brief 写CP侧NVRW区NV项
+ * @param NvItemID      入参,NV项ID
+ * @param NvItemData    入参,写入NV项数据缓冲区
+ * @param NvItemLen     入参,写入NV项数据缓冲区长度
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note
+ * @warning 数据先写到内存,定时刷新到flash。如果要求及时刷新到flash需要再调用cpnv_NvramFlush刷新
+ */
+extern unsigned int cpnv_NvItemWrite(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);

+

+/**
+ * @brief 读取CP侧NVRW区NV项
+ * @param NvItemID      入参,NV项ID
+ * @param NvItemData    出参,读取NV项数据缓冲区
+ * @param NvItemLen     入参,读取NV项数据缓冲区长度
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note
+ * @warning
+ */
+extern unsigned int cpnv_NvItemRead(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);

+

+/**
+ * @brief  刷新NVRW区缓存数据到flash
+ * @param  无
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note
+ * @warning
+ */
+extern unsigned int cpnv_NvramFlush(void);

+

+/**
+ * @brief 写CP侧NVFAC区NV项
+ * @param NvItemID      入参,NV项ID
+ * @param NvItemData    入参,写入NV项数据缓冲区
+ * @param NvItemLen     入参,写入NV项数据缓冲区长度
+ * @return 无
+ * @retval
+ * @note
+ * @warning
+ */
+void cpnv_NvItemWriteFactory(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);
+

+/**
+ * @brief 写CP侧NVRO区NV项
+ * @param NvItemID      入参,NV项ID
+ * @param NvItemData    入参,写入NV项数据缓冲区
+ * @param NvItemLen     入参,写入NV项数据缓冲区长度
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note 调用之前要用cpnv_ChangeNvRoAttr设置为可写
+ * @warning 调用后要用cpnv_ChangeNvRoAttr设置为只读,保护NVRO区数据
+ */
+unsigned int cpnv_NvItemWriteNvro(unsigned int NvItemID, unsigned char *NvItemData, unsigned int NvItemLen);
+
+/**
+ * @brief  NV恢复出厂数据
+ * @param  无
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note
+ * @warning
+ */
+unsigned int cpnv_ResetNVFactory(void);
+
+/**
+ * @brief  设置NVRO区读写属性

+ * @param  writable为0设置NVRO区为只读,其他值设置为可写

+ * @return CPNV_OK 成功,CPNV_ERROR 失败

+ * @retval

+ * @note

+ * @warning

+ */

+unsigned int cpnv_ChangeNvRoAttr(int writable);

+

+/**

+ * @brief  设置imagefs/resource/nvrofs分区可写属性
+ * @param  partition_no取值自enum FS_PARTITION_NO;writable为0设置为只读,其他值设置为可写
+ * @return CPNV_OK 成功,CPNV_ERROR 失败
+ * @retval
+ * @note
+ * @warning
+ */
+unsigned int cpnv_ChangeFsPartitionAttr(int partition_no, int writable);
+
+/**

+ * @brief  等待imagefs/resource/nvrofs 文件系统垃圾回收,partition_no取值自enum FS_PARTITION_NO

+ * @param  partition_no取值自enum FS_PARTITION_NO

+ * @return CPNV_OK 成功,CPNV_ERROR 失败

+ * @retval

+ * @note

+ * @warning 只能在整个该分区文件系统都写完毕后调用才有意义

+ */

+unsigned int cpnv_FsGcWait(int partition_no);

+

+#endif // __LIBCPNV_H

diff --git a/ap/app/include/libkey.h b/ap/app/include/libkey.h
new file mode 100644
index 0000000..2f5c5c4
--- /dev/null
+++ b/ap/app/include/libkey.h
@@ -0,0 +1,31 @@
+#ifndef __LIBKEY_H

+#define __LIBKEY_H

+

+//ÖÖ×Ó¶¨Ò壬ÖÖ×Ó³¤¶È±ØÐëµÈÓÚ8£¬¿Í»§¿ÉÒÔÐÞ¸Ä

+#define SEED    "ZXIC-TSP"

+

+

+/**

+ * @brief  Óû§Ä£Ê½ÇÐÑз¢Ä£Ê½¼øÈ¨

+ * @param device_key  ÐèÒªÑéÖ¤µÄkey

+ * @param key_len  key³¤¶È

+ * @param seed  ¼øÈ¨Ê¹ÓõÄÖÖ×Ó

+ * @param seed_len  ¼øÈ¨Ê¹ÓõÄÖÖ×Ó³¤¶È

+ * @return 1 ³É¹¦  

+ * @return ÆäËûÖµ ʧ°Ü

+ * @note   

+ * @warning 

+ */

+int verify_device_key(char *device_key,int key_len,char *seed,int seed_len);

+

+/**

+ * @brief  Óû§Ä£Ê½ÇÐÑз¢Ä£Ê½Ä¬ÈÏ״̬

+ * @param ÎÞ

+ * @return 1 ÎÞÐèÑéÖ¤  

+ * @return 0 ÐèÒªÑéÖ¤

+ * @note   

+ * @warning 

+ */

+int auth_device_key_init_value(void);

+

+#endif // __LIBKEY_H

diff --git a/ap/app/include/lq_msg.h b/ap/app/include/lq_msg.h
new file mode 100644
index 0000000..e0fccf2
--- /dev/null
+++ b/ap/app/include/lq_msg.h
@@ -0,0 +1,163 @@
+/**
+ * @file at_msg.h
+ * @brief ÌṩÁËÆ½Ì¨¶ÔÍâÏûÏ¢½Ó¿ÚºÍÏûÏ¢½á¹¹¶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __LQ_MSG_H__
+#define __LQ_MSG_H__
+
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include "message.h"
+
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+
+#define AT_CMD_MODE				0	//·Ç͸Ã÷ģʽÏÂatÃüÁî´«Êäģʽ
+#define WRITE_DATA_MODE			1	//·Ç͸Ã÷ģʽÏÂwriteÁ÷³ÌÖеÄÊý¾Ý͸´«Ä£Ê½
+#define TRANSPARENT_CMD_MODE	2	//͸Ã÷ģʽÏÂÃüÁîģʽ
+#define TRANSPARENT_DATA_MODE	3	//͸Ã÷ģʽÏÂÊý¾Ýģʽ
+#define FTP_DATA_MODE			4	//FTP PUT/GETÖеÄÊý¾Ý͸´«Ä£Ê½
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+ * @brief at socketÏûÏ¢¿ªÊ¼
+ */
+enum  lq_msg_type {
+	MSG_CMD_NETCON_REQ = MSG_CMD_LQ_BASE,//ÅäÖÃPDP¼¤»îÏà¹Ø²ÎÊý
+	MSG_CMD_NETCON_RSP,
+	MSG_CMD_NETACT_REQ,//PDP¼¤»îÈ¥¼¤»î
+	MSG_CMD_NETACT_RSP,
+	MSG_CMD_NETSRV_REQ,//ÅäÖ÷Ç͸Ã÷ģʽsocket²ÎÊý
+	MSG_CMD_NETSRV_RSP,
+	MSG_CMD_NETOPEN_REQ,//´´½¨·Ç͸Ã÷ģʽsocketÁ´½Ó
+	MSG_CMD_NETOPEN_RSP,
+	MSG_CMD_NETREAD_REQ,//¶ÁÈ¡·Ç͸Ã÷ģʽsocketÊý¾Ý
+	MSG_CMD_NETREAD_RSP,
+	MSG_CMD_SENDBUF_REQ,//ÇëÇó·¢ËÍ·Ç͸Ã÷ģʽsocketÊý¾Ý
+	MSG_CMD_SENDBUF_RSP,
+	MSG_CMD_NETWRITE_REQ,//µÃµ½¿É·¢ËÍÈ·ÈϺó·¢ËÍ´ý·¢Ë͵Ädata
+	MSG_CMD_NETWRITE_RSP,
+	MSG_CMD_NETCLOSE_REQ,//¹Ø±ÕÒ»¸ösocketÁ´½Ó
+	MSG_CMD_NETCLOSE_RSP,
+	MSG_CMD_NETPING_REQ,//pingÃüÁî
+	MSG_CMD_NETPING_RSP,
+	MSG_CMD_NETACCEPT_REQ,//µ±×÷Ϊserver¶ËÊÕµ½¿Í»§¶ËÁ¬½ÓÇëÇóʱ£¬¾ö¶¨½ÓÊÜ»ò¾Ü¾ø¸ÃÇëÇó
+	MSG_CMD_NETACCEPT_RSP,
+	MSG_CMD_NETCREATE_REQ,//´´½¨Í¸Ã÷ģʽsocketÁ´½Ó
+	MSG_CMD_NETCREATE_RSP,
+	MSG_CMD_NETURC_REQ,//ÉèÖÃÖ÷¶¯Éϱ¨¿ª¹Ø
+	MSG_CMD_NETURC_RSP,
+	MSG_CMD_IPFILTER_REQ,//µ±×÷Ϊserver¶Ëʱ£¬ÉèÖÃÔÊÐíÓëÆäÁ¬½ÓµÄIPµØÖ··¶Î§
+	MSG_CMD_IPFILTER_RSP,
+	MSG_CMD_NETACK_REQ,//²éѯijsocketµÄ·¢ËÍ»º´æÇøÕ¼ÓõĴóС¼°¿ÕÏеĴóС
+	MSG_CMD_NETACK_RSP,
+	MSG_CMD_TYPE_REQ,//²éѯ֧³ÖµÄ´«Êäģʽ ÍøÂçÖÆÊ½  ¸½¼Ó¹¦ÄÜ
+	MSG_CMD_TYPE_RSP,
+	MSG_CMD_NETACT_QUERY_REQ,//²éѯ×î½üÒ»´ÎµÄPDP¼¤»îÐÅÏ¢
+	MSG_CMD_NETACT_QUERY_RSP,
+	//MSG_CMD_NETACT_EQUAL_QUERY_REQ,
+	//MSG_CMD_NETACT_EQUAL_QUERY_RSP,
+	MSG_CMD_NETURC_QUERY_REQ,//²éѯÉèÖõÄÖ÷¶¯Éϱ¨¿ª¹Ø
+	MSG_CMD_NETURC_QUERY_RSP,
+	MSG_CMD_IPFILTER_QUERY_REQ,//²éѯÉèÖõÄIPµØÖ·¹ýÂËÐÅÏ¢
+	MSG_CMD_IPFILTER_QUERY_RSP,
+	MSG_CMD_NETOPEN_QUERY_REQ,//²éѯNETOPEN²ÎÊý
+	MSG_CMD_NETOPEN_QUERY_RSP,
+	MSG_CMD_DATA_TO_CMD_MODE,//͸Ã÷ģʽÓÉÊý¾Ý̬Çе½ÃüÁî̬
+	MSG_CMD_CMD_TO_DATA_MODE,//͸Ã÷ģʽÓÉÃüÁî̬Çе½Êý¾Ý̬
+	MSG_CMD_SOCKETLED_REQ,/*ÍøÂçͬ²½ÐźŵƿØÖÆ£¬ÓÃÓÚÍâÖÃЭÒéÕ»socketÁ¬½Ó³É¹¦Ê±£¬LEDÐźŵÆÉÁ˸¿ØÖÆ*/
+	MSG_CMD_SOCKETLED_RSP,
+	
+	//quectel
+	MSG_CMD_QIOPEN_REQ,
+	MSG_CMD_QIOPEN_RSP,
+	MSG_CMD_QICLOSE_REQ,
+	MSG_CMD_QICLOSE_RSP,
+	MSG_CMD_QISTATE_REQ,
+	MSG_CMD_QISTATE_RSP,
+	MSG_CMD_QISEND_REQ,
+	MSG_CMD_QISEND_RSP,
+	MSG_CMD_QISENDBUF_REQ,
+	MSG_CMD_QISENDBUF_RSP,
+	MSG_CMD_QIRD_REQ,
+	MSG_CMD_QIRD_RSP,
+	MSG_CMD_QISENDEX_REQ,
+	MSG_CMD_QISENDEX_RSP,
+	MSG_CMD_QISWTMD_REQ,
+	MSG_CMD_QISWTMD_RSP,
+	MSG_CMD_QIDNSCFG_REQ,
+	MSG_CMD_QIDNSCFG_RSP,
+	MSG_CMD_QIDNSGIP_REQ,
+	MSG_CMD_QIDNSGIP_RSP,
+	MSG_CMD_QIGETERROR_REQ,
+	MSG_CMD_QIGETERROR_RSP,
+	MSG_CMD_QPING_REQ,
+	MSG_CMD_QPING_RSP,
+	MSG_CMD_QIURC,
+	
+	/*zte_ftpÏûÏ¢*/
+	MSG_CMD_FTPOPEN_REQ, //´ò¿ªÁ¬½Ó
+	MSG_CMD_FTPOPEN_RSP,
+	MSG_CMD_FTPSTATE_REQ, //Á¬½Ó״̬²éѯ
+	MSG_CMD_FTPSTATE_RSP,
+	MSG_CMD_FTPCLOSE_REQ, //¹Ø±ÕÁ¬½Ó
+	MSG_CMD_FTPCLOSE_RSP,
+	MSG_CMD_FTPSIZE_REQ, //»ñÈ¡Îļþ³ß´ç
+	MSG_CMD_FTPSIZE_RSP,
+	MSG_CMD_FTPGET_REQ, //ÎļþÏÂÔØ
+	MSG_CMD_FTPGET_RSP,
+	MSG_CMD_FTPPUT_REQ, //ÎļþÉÏ´«
+	MSG_CMD_FTPPUT_RSP,
+	MSG_CMD_FTPFOTA_REQ, //FTP FOTAÉý¼¶
+	MSG_CMD_FTPFOTA_RSP,
+	
+	//¹úµç
+	MSG_CMD_MYBAND_SET_REQ,//GSMƵ¶ÎËø¶¨
+	MSG_CMD_MYBAND_QUERY_REQ,
+	MSG_CMD_GMR_QUERY_REQ,//Ä£¿é°æ±¾ºÅ»ñÈ¡
+	
+	//Äϵç
+	MSG_CMD_MYSYSINFO_QUERY_REQ,//»ñÈ¡µ±Ç°ÍøÂç×¢²áÐÅÏ¢
+	MSG_CMD_MYNETINFO_QUERY_REQ,//ÍøÂçÑ¡ÔñģʽµÄ²éѯºÍÉèÖÃ
+	MSG_CMD_MYNETINFO_SET_REQ,
+	MSG_CMD_MYURCSYSINFO_INFORM_REQ,
+	MSG_CMD_MYGPSPOS_SET_REQ,
+	MSG_CMD_MYGPSPWR_SET_REQ,
+
+	/******************Êý¾Ý͸´«ÏìÓ¦********************/
+	MSG_CMD_PASSTHROUGH_RSP,
+
+    /******************͸Ã÷ģʽÏÂsocket¹Ø±Õ֪ͨÏûÏ¢********************/
+	MSG_CMD_TRANSPARENT_SOCKET_CLOSE_IND,
+};
+
+/* ¶¨Òå¿Í»§ÀàÐÍ  */
+typedef enum {
+	CUSTOMER_SDK = 0,
+	CUSTOMER_SDK_MIN,
+	CUSTOMER_YAOYUAN,    /* ҢԶcpe */
+	CUSTOMER_GUODIAN,    /* ¹úµç */
+	CUSTOMER_NANDIAN     /* Äϵç */
+} CUSTOMER_TYPE;
+
+#endif
+
+#endif
+
diff --git a/ap/app/include/mainctl_msg.h b/ap/app/include/mainctl_msg.h
new file mode 100755
index 0000000..8c66cc5
--- /dev/null
+++ b/ap/app/include/mainctl_msg.h
@@ -0,0 +1,147 @@
+/**
+* @file Mainctl_msg.h
+* @brief ÌṩÖ÷¿Ø¡¢ÍøÂçÏà¹ØÏûÏ¢½Ó¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author Linxu Gebin
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+************************************************************************
+*/
+
+#ifndef __MAINCTRL_MSG_H__
+#define __MAINCTRL_MSG_H__
+
+#include "message.h"
+
+/**
+* @brief ¶¨ÒåÖ÷¿ØÏûÏ¢
+* @param MSG_CMD_RESET_REQUEST »Ö¸´³ö³§ÉèÖÃÇëÇó
+* @param MSG_CMD_POWEROFF_REQUEST ¹Ø»úÇëÇó
+* @param MSG_CMD_RESTART_REQUEST ÖØÆôÇëÇó
+* @param MSG_CMD_NET_IPPORT_FILTER ·À»ðǽ-¶Ë¿Ú¹ýÂËÏûÏ¢
+* @param MSG_CMD_NET_IPPORT_FORWARD ·À»ðǽ-¶Ë¿Úת·¢ÏûÏ¢
+* @param MSG_CMD_NET_DMZ ·À»ðǽ-DMZÏûÏ¢
+* @param MSG_CMD_NET_IPPORT_MAPPING ·À»ðǽ-¶Ë¿ÚÓ³ÉäÏûÏ¢
+* @param MSG_CMD_NET_UPNP ·À»ðǽ-UPNPÏûÏ¢
+* @param MSG_CMD_NET_URL_FILTER ·À»ðǽ-URL¹ýÂËÏûÏ¢
+* @param MSG_CMD_NET_MTU MTUÏà¹ØÅäÖÃÏûÏ¢
+* @param MSG_CMD_NET_STATIC_DHCP DHCPµØÖ·³ØÖеľ²Ì¬IPÏà¹ØÉèÖÃÏûÏ¢
+* @param MSG_CMD_NET_PLUGIN ÈȲå°ÎÉ豸²åÈëÏûÏ¢
+* @param MSG_CMD_NET_PLUGOUT ÈȲå°ÎÉ豸°Î³öÏûÏ¢
+* @param MSG_CMD_NET_CONNECT rj45ºÍwifiµÈÉ豸Á¬½ÓÍøÂçÏûÏ¢
+* @param MSG_CMD_NET_DISCON rj45ºÍwifiµÈÉ豸¶Ï¿ªÍøÂçÏûÏ¢
+* @param MSG_CMD_NET_PDP_ACT pdp¼¤»îÏûÏ¢
+* @param MSG_CMD_NET_PDP_DEACT pdpÈ¥¼¤»îÏûÏ¢
+* @param MSG_CMD_NET_TC_CTRL Á÷Á¿¿ØÖÆÏûÏ¢
+* @param MSG_CMD_NET_GET_HOSTNAME Ð޸ĽÓÈëÉ豸µÄhostnameÏûÏ¢
+* @param MSG_CMD_NET_BIND_STATIC_ADDRESS ¾²Ì¬µØÖ·°ó¶¨ÏûÏ¢
+* @param MSG_CMD_NET_BIND_STATIC_ADDRESS_ADD Ìí¼Ó¾²Ì¬µØÖ·°ó¶¨ÏûÏ¢
+* @param MSG_CMD_NET_BIND_STATIC_ADDRESS_DEL ɾ³ý¾²Ì¬µØÖ·°ó¶¨ÏûÏ¢
+* @param MSG_CMD_NET_PING_DIAGNOSTICS pingÕï¶Ï²Ù×÷ÏûÏ¢
+* @param MSG_CMD_NET_DHCP_SETTING_REQ DHCPÉèÖÃÇëÇóÏûÏ¢
+*/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/*Ö÷¿ØÏà¹ØÏûÏ¢ÃüÁî*/
+typedef enum {
+	/*Ö÷¿Ø¿ØÖÆÏà¹Ø*/
+	MSG_CMD_MAINCTRL_BEG = MSG_CMD_MAINCTRL_BASE,
+
+	/* Ö÷¿ØÊÕµ½ÇëÇóºó£¬Í¨ÖªÐèÒªµÄÄ£¿é×öÏàÓ¦²Ù×÷£¬ÊÕµ½µÄÄ£¿é±ØÐë»Ø¸´result
+	  * Ö÷¿ØÊÕµ½ËùÓÐresultºóÔÙÖ´ÐÐ×îºóµÄ²Ù×÷(±£´æNV£¬ÖØÆô¡¢¹Ø»ú¡¢resetµÈ)
+	  */
+	MSG_CMD_RESET_REQUEST,               /*ÇëÇó»Ö¸´³ö³§ÉèÖà 211D, ²ÎÊý:ÎÞ */
+	MSG_CMD_POWEROFF_REQUEST,            /*ÇëÇ󹨻ú211E, ²ÎÊý:ÎÞ */
+	MSG_CMD_RESTART_REQUEST,             /*ÇëÇóÖØÆô211F, ²ÎÊý:ÎÞ */
+	MSG_CMD_RESET_NOTIFY,                /*֪ͨ»Ö¸´³ö³§ÉèÖÃ2120, ²ÎÊý:ÎÞ, ´¦ÀíÄ£¿é±ØÐë»Ø¸´MSG_CMD_RESET_RSP */
+	MSG_CMD_POWEROFF_NOTIFY,             /*֪ͨ¹Ø»ú2121, ²ÎÊý:ÎÞ, ´¦ÀíÄ£¿é±ØÐë»Ø¸´MSG_CMD_POWEROFF_RSP */
+	MSG_CMD_RESTART_NOTIFY,              /*Í¨ÖªÖØÆô2122, ²ÎÊý:ÎÞ, ´¦ÀíÄ£¿é±ØÐë»Ø¸´MSG_CMD_RESTART_RSP */
+	MSG_CMD_RESET_RSP,                   /*»Ö¸´³ö³§ÉèÖûظ´ÏûÏ¢, ²ÎÊý:ÎÞ */
+	MSG_CMD_POWEROFF_RSP,                /*¹Ø»úÉèÖýá¹û»Ø¸´ÏûÏ¢, ²ÎÊý:ÎÞ */
+	MSG_CMD_RESTART_RSP,                 /*ÖØÆôÉèÖýá¹û»Ø¸´ÏûÏ¢, ²ÎÊý:ÎÞ */
+
+	//ÍøÂçÏà¹Ø
+	MSG_CMD_NET_IPPORT_FILTER,           /*·À»ðǽ-¶Ë¿Ú¹ýÂË, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_IPPORT_FORWARD,          /*·À»ðǽ-¶Ë¿Úת·¢, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_DMZ,                     /*·À»ðǽ-DMZ,      ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_IPPORT_MAPPING,          /*·À»ðǽ-¶Ë¿ÚÓ³Éä, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_UPNP,                    /*upnp, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_URL_FILTER,              /*·À»ðǽ-URL¹ýÂË, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í, ²»Ö§³ÖHTTPS */
+	MSG_CMD_NET_MTU,                     /*MTUÏà¹ØÅäÖÃ, ²»´ø²ÎÊý£¬ÐèÒª·¢ËÍǰÉèÖÃNV mtuÖµ */
+	MSG_CMD_NET_STATIC_DHCP,             /*DHCPµØÖ·³ØÖеľ²Ì¬IPÏà¹ØÉèÖÃ, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_PLUGIN,                  /*ÈȲå°ÎÉ豸²åÈ룬¹©netdev_plugin_proc_byname/netdev_plugin_procʹÓà */
+	MSG_CMD_NET_PLUGOUT,                 /*ÈȲå°ÎÉ豸°Î³ö£¬¹©netdev_plugout_proc_byname/netdev_plugout_procʹÓà */
+	MSG_CMD_NET_CONNECT,                 /*rj45ºÍwifiµÈÉ豸Á¬½ÓÍøÂ磬¹©netdev_connect_internetʹÓà */
+	MSG_CMD_NET_DISCON,                  /*rj45ºÍwifiµÈÉ豸¶Ï¿ªÍøÂ磬¹©netdev_disconnect_internetʹÓà */
+	MSG_CMD_NET_PDP_ACT,                 /*pdp¼¤»î,¹©pdp_act_procʹÓà */
+	MSG_CMD_NET_PDP_DEACT,               /*pdpÈ¥¼¤»î,¹©pdp_deact_procʹÓà */
+	MSG_CMD_NET_TC_CTRL,                 /*Á÷Á¿¿ØÖÆ,¹©tc_controlʹÓà */
+	MSG_CMD_NET_GET_HOSTNAME,            /*Ð޸ĽÓÈëÉ豸µÄhostname, ²ÎÊý:struct mac_hostname_info */
+	MSG_CMD_NET_BIND_STATIC_ADDRESS,     /*¾²Ì¬µØÖ·°ó¶¨, ²ÎÊý:ÎÞ ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_BIND_STATIC_ADDRESS_ADD, /*Ìí¼Ó¾²Ì¬µØÖ·°ó¶¨, ²ÎÊý: struct static_macip_info */
+	MSG_CMD_NET_BIND_STATIC_ADDRESS_DEL, /*ɾ³ý¾²Ì¬µØÖ·°ó¶¨, ²ÎÊý: macµØÖ· */
+	MSG_CMD_NET_PING_DIAGNOSTICS,		 /*pingÕï¶Ï²Ù×÷, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+
+	MSG_CMD_NET_DHCP_SETTING_REQ,        /*ÍøÂçDHCP»ù´¡²ÎÊýÅäÖÃÇëÇó*/
+	MSG_CMD_NET_DHCP_SETTING_RSP,        /*ÍøÂçDHCP»ù´¡²ÎÊýÅäÖûظ´*/
+
+	/* --------------------- ÒÔÏÂÊÇÄÚ²¿Ê¹ÓÃÏûÏ¢ ---------------- */
+	MSG_CMD_NET_WAN4_CHANGE,             /*ipv4ÍâÍø¿Ú·¢Éú±ä»¯, ²ÎÊý:ÎÞ */
+	MSG_CMD_NET_WAN6_CHANGE,             /*ipv6ÍâÍø¿Ú·¢Éú±ä»¯, ²ÎÊý:ÎÞ */
+	MSG_CMD_NET_TIMER_DEL,               /*ɾ³ý¶¨Ê±Æ÷²Ù×÷, ²ÎÊý:ÍâÍø¿ÚÀàÐÍethwan¡¢wifiwan */
+	MSG_CMD_NET_TIMER_OUT,               /*¶¨Ê±Æ÷³¬Ê±²Ù×÷, ²ÎÊý:É豸dev_ID */
+	MSG_CMD_NET_SET_RJ45_LAN,            /*½«rj45ÉèÖÃΪÄÚÍø¿Ú, ²ÎÊý:ÎÞ */
+	MSG_CMD_NET_ADD_CHILDREN_DEVICE,     /*¼Ò³¤Ä£Ê½¹¦ÄÜÖÐ, Ìí¼ÓÉ豸µ½¶ùͯ×éÉ豸, ²ÎÊý: struct mac_hostname_info*/
+	MSG_CMD_NET_DEL_CHILDREN_DEVICE,     /*¼Ò³¤Ä£Ê½¹¦ÄÜÖÐ, ɾ³ý¶ùͯ×éÉ豸, ²ÎÊý: macµØÖ· */
+	MSG_CMD_NET_ADD_WHITE_SITE,          /*¼Ò³¤Ä£Ê½¹¦ÄÜÖÐ, Ìí¼ÓÍøÕ¾µ½°×Ãûµ¥, ²ÎÊý: struct white_site_info */
+	MSG_CMD_NET_REMOVE_WHITE_SITE,       /*¼Ò³¤Ä£Ê½¹¦ÄÜÖÐ, ɾ³ý°×Ãûµ¥ÖеÄÍøÖ·, ²ÎÊý: °×Ãûµ¥ÍøÕ¾ */
+	MSG_CMD_NET_START_NONET,             /*¼Ò³¤Ä£Ê½¹¦ÄÜÖÐ, ½ûÖ¹ÉÏÍøÊ±¼ä¿ªÊ¼, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_STOP_NONET,              /*¼Ò³¤Ä£Ê½¹¦ÄÜÖУ¬½ûÖ¹ÉÏÍøÊ±¼ä½áÊø, ²ÎÊý:ÎÞ, ÐèÒª·¢ËÍǰÉèÖÃÏà¹ØNV, ¼ûNV±í */
+	MSG_CMD_NET_WAN_DIAL_FAIL,           /*֪ͨÍâÍø¿ÚÁªÍø³¬Ê±, ²ÎÊý:ÎÞ */
+	MSG_CMD_SECURITY_LOG_SAVE,                /*°²È«ÈÕÖ¾´æ´¢, ²ÎÊý:ÈÕÖ¾×Ö·û´®s */
+} emMSG_CMD_MainCtrl;
+#endif
+
+/** * @brief dhcp·þÎñÆ÷ÐÅÏ¢
+ * @param lan_ip        Íø¹Øip
+ * @param lan_netmask   ÑÚÂë
+ * @param dhcp_enabled  dhcp ·þÎñÆ÷ʹÄܱêÖ¾
+ * @param dchp_start    dhcp µØÖ·³ØÆðʼµØÖ·
+ * @param dchp_end      dhcp µØÖ·³Ø½áÊøµØÖ·
+ * @param dchp_dns      dnsµØÖ·
+ * @param dchp_lease    dhcp×âÔ¼Îļþ
+ */
+typedef struct {
+	char lan_ip[SOFTAP_IP_MAX_LEN];
+	char lan_netmask[SOFTAP_IP_MAX_LEN];
+	int  dhcp_enabled;
+	char dhcp_start[SOFTAP_IP_MAX_LEN];
+	char dhcp_end[SOFTAP_IP_MAX_LEN];
+	char dhcp_dns[SOFTAP_IP_MAX_LEN];
+	char dhcp_lease[SOFTAP_STR_LEN_16];
+} dhcp_setting_req;
+
+/** * @brief restart request message info
+ * @param action        restart or reset
+ * @param subactuon   finally realized by MCU or mainCtrl
+ */
+typedef struct {
+	int action;
+	int subaction;
+} restart_info;
+
+typedef enum {
+	Restart_Action_RESTART = 0,
+	Restart_Action_RESET,
+} emACTION_RESTART_MainCtrl;
+
+typedef enum {
+	Operate_By_MCU = 0,
+	Operate_By_SOC,
+} emSUBACTION_RESTART_MainCtrl;
+
+
+#endif
diff --git a/ap/app/include/max_macro.h b/ap/app/include/max_macro.h
new file mode 100755
index 0000000..6067a56
--- /dev/null
+++ b/ap/app/include/max_macro.h
@@ -0,0 +1,94 @@
+/**
+ * @file max_macro.h
+ * @brief ƽ̨¼¶Ä£¿é¼ä¹«¹²ÉÏÏ޺궨Ò壬Óû§¿ÉÐÞ¸ÄÉÏÏÞÖµ£¬·²ÊDz»»á±»Ð޸ĵĺ꣬²»×¼ÔÚ´ËÍ·ÎļþÖж¨Òå
+ *ËùÓпçÄ£¿éµÄ²ßÂԺ꣬ÈçÏûÏ¢³¤¶È¡¢NV³¤¶ÈµÈ£»SMS¡¢PB³¤¶È£»¶¨Ê±Æ÷ʱ³¤£»³¢ÊÔ´ÎÊý£»Ñ­»·ÉÏÏÞ£»
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __MAX_MACRO_H__
+#define __MAX_MACRO_H__
+
+/**
+ * @brief ½ø³Ì¼äÏûÏ¢·¢Ë͵ÄÏûÏ¢ÄÚÈݳ¤¶ÈÉÏÏÞ
+ */
+#define MSG_DATA_MAX_LEN  3500
+
+/**
+ * @brief ºË¼äÏûÏ¢·¢Ë͵ÄÏûÏ¢ÄÚÈݳ¤¶ÈÉÏÏÞ
+ */
+#define SOC_MSG_MAX_LEN (MSG_DATA_MAX_LEN-16)
+
+/**
+ * @brief ºË¼äͨµÀ»º´æ´óС
+ */
+#define AT_CHAN_MAX_BUF_LEN			8*1024
+
+/**
+ * @brief NVÅäÖÃÎļþÃû³¤¶ÈÉÏÏÞ
+ */
+#define NV_MAX_FILE_LEN     256
+
+/**
+ * @brief NVÏîÃû³Æ³¤¶ÈÉÏÏÞ
+ */
+#define NV_MAX_KEY_LEN      1024
+
+/**
+ * @brief NVÖµ³¤¶ÈÉÏÏÞ
+ */
+#define NV_MAX_VAL_LEN      1024
+
+/**
+ * @brief NVÏîºÍNVÖµ³¤¶ÈÉÏÏÞ
+ */
+#define NV_MAX_ITEM_LEN     (NV_MAX_KEY_LEN + NV_MAX_VAL_LEN)
+
+/**
+ * @brief Ó¦ÓòãÃæ´íÎóÂë¸ú×Ù¸öÊýÉÏÏÞ£¬½öÓÃÓÚÎÊÌⶨλ.
+ *Õâ¸ö´óСÊÜÏÞÓÚNV_MAX_VAL_LENµÄ´óС
+ */
+#define ERR_TRACK_MAX_NUM   (NV_MAX_VAL_LEN-16)/(2 * 8)
+
+/**
+ * @brief µ¥ÌõATÃüÁî×î´ó³¤¶È
+ */
+#define AT_CMD_MAX						2048
+
+/**
+ * @brief Íø¿ÚÃû³¤¶ÈÉÏÏÞ
+ */
+#define NETIF_NAME_LEN 20
+
+/**
+ * @brief PCÖ÷»úÃû³¤¶ÈÉÏÏÞ
+ */
+#define HOSTNAME_LEN 150
+
+/**
+ * @brief ÍøÂçIPµØÖ·³¤¶ÈÉÏÏÞ
+ */
+#define SOFTAP_IP_MAX_LEN 32
+
+
+/**
+ * @brief ×Ö·û´®³¤¶È
+ */
+#define SOFTAP_STR_LEN_16 16
+
+
+//////ÒÔÏÂÊÇPBµç»°±¾µÄºê¶¨Ò壬ÇëÕÅ·ÒǣͷÕûÀí
+
+
+//////ÒÔÏÂÊÇSMSµÄºê¶¨Ò壬ÇëÕÅ·ÒǣͷÕûÀí
+
+#define ZSMS_PDU_SIZE               400
+
+
+
+
+#endif
diff --git a/ap/app/include/message.h b/ap/app/include/message.h
new file mode 100755
index 0000000..86f0fb2
--- /dev/null
+++ b/ap/app/include/message.h
@@ -0,0 +1,323 @@
+/**
+ * @file message.h
+ * @brief ¶¨ÒåÓ¦Óù«¹²ÏûÏ¢¶ÓÁÐkey, ÏûÏ¢Ìå, ÏûÏ¢ÃüÁîID, ·¢ËÍÏûÏ¢µÄAPI½Ó¿Ú
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _MESSAGE_H_
+#define _MESSAGE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "max_macro.h"
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+ * @brief ¸÷Ó¦ÓÃÄ£¿éµÄÏûÏ¢ID£¬ÓÃÓÚÏûÏ¢¶ÓÁеÄÉú³É£¬ÒÔ¼°Ö¸Ê¾ÏûÏ¢ÊÕ·¢Ä£¿é
+ * @note MODULE_ID_USER_BASE±íʾ¿Í»§¿ª·¢Ó¦ÓÃ×Ô¶¨ÒåÄ£¿éÏûÏ¢IDµÄÆðʼµã
+ */
+
+/* -- APºË´æÔÚµÄÄ£¿éID£¬Óû§ÐÂÔöÓ¦ÓÃÄ£¿éIDÐèÒª¶¨ÒåÔÚ´ËenumÖеÄMODULE_ID_USER_BASE¶Î -- */
+typedef enum AP_Module_ID{
+	MODULE_ID_APBASE = 0x1000,		/*APºËÄ£¿éIDÆðʼµØÖ·£¬×î´óÖµ<0x2000(MODULE_ID_CPBASE)*/
+	MODULE_ID_WEB_CGI,				/*WEB CGIÄ£¿éµÄÏûÏ¢¶ÓÁÐID*/
+	MODULE_ID_SLAAC,
+	MODULE_ID_WIFI,					/*wifi control*/
+	MODULE_ID_WLAN_SERVER,			/*wifi×Ô¼º¸ø×Ô¼º·¢ÏûÏ¢¶¨ÒåµÄmsg id*/
+	MODULE_ID_MMI,
+	MODULE_ID_FLUXSTAT,				/*fluxstat*/
+	MODULE_ID_AP_RTC_SERVICE,
+	MODULE_ID_SMS,					/*SMSÏûÏ¢¶ÓÁÐÃû³Æ*/
+	MODULE_ID_SMS_LOCAL,			/*SMSÏûÏ¢¶ÓÁÐÃû³Æ, SMSÄ£¿éÄÚ²¿Ê¹Ó㬷Ŵ˴¦±ãÓÚͳһ¹ÜÀí*/
+	MODULE_ID_PB,					/*PBÏûÏ¢¶ÓÁÐÃû³Æ*/
+	MODULE_ID_PB_LOCAL,				/*PBÏûÏ¢¶ÓÁÐÃû³Æ, PBÄ£¿éÄÚ²¿Ê¹Ó㬷Ŵ˴¦±ãÓÚͳһ¹ÜÀí*/
+	MODULE_ID_SNTP,
+	MODULE_ID_PPPD,
+	MODULE_ID_WDT,
+
+	MODULE_ID_AP_AT_CTL,			/*at ctlÄ£¿éID*/
+	MODULE_ID_SLIC,					/*slicÄ£¿éµÄÏûÏ¢¶ÓÁÐID*/
+	MODULE_ID_DM,					/*DMÄ£¿é*/
+	MODULE_ID_DM_POLLING,			/*DM POLLING*/
+	MODULE_ID_DM_WEBUI_AT,
+	MODULE_ID_FAC_DIAL,				/*Éú²ú²âÊÔÄ£¿é µÄÏûÏ¢¶ÓÁÐID*/
+	MODULE_ID_TR069,				/*TR069 Ä£¿é*/
+	MODULE_ID_MAIN_CTRL,			/*Ö÷¿ØÄ£¿éID*/
+	MODULE_ID_ZSSID,
+	MODULE_ID_LOG_AGENT,
+	MODULE_ID_LOCALUPDATE,			/*localUpdateID*/
+	MODULE_ID_PARENT_CONTROL_SET,
+	MODULE_ID_WPA_SUPPLICANT,
+	MODULE_ID_EMBMS_CTRL,
+	MODULE_ID_HOTPLUG,				/*ÈȲå°ÎÄ£¿éID*/
+	MODULE_ID_VOLTE,
+	MODULE_ID_VOLTE_TEMP1,	/*·ÏÆú£¬Ê¹ÓÃMODULE_ID_ATCTL_TO_VOLTE */
+	MODULE_ID_VOLTE_TEMP2,  /*·ÏÆú£¬Ê¹ÓÃMODULE_ID_VOLTE_TO_ATCTL */
+
+	MODULE_ID_USBCFGMNG,  /* ´Ë´¦Èç´Ë¶¨ÒåÊÇΪÁ˸øVOLTEÔ¤ÁôαͨµÀºÅ */
+	MODULE_ID_DRVCOMMNG,
+	
+
+	/********************************************************************/
+	//µ÷ÓÃÍøÂç½Ó¿Úʱ½«Ä£¿éID×÷Ϊ²ÎÊý´«µÝ¸øÍøÂçÄ£¿é
+	/********************************************************************/
+	MODULE_ID_CALL_CTRL,
+	MODULE_ID_CALL_CTRL_LOCAL,
+	MODULE_ID_CALL_CTRL_RSP,
+	MODULE_ID_NV,
+	MODULE_ID_UICTL,
+	MODULE_ID_ISMS,
+	MODULE_ID_DMREG,
+	MODULE_ID_DMSENDMSG,
+	MODULE_ID_SAFECARE,
+	MODULE_ID_CODEC,				/*audioÖ÷¿Ø*/
+	MODULE_ID_AT_TOOL,				/*ÓÃÓÚ¿ØÖÆÊäÈëatÃüÁîµÄÓ¦ÓÃ*/
+	MODULE_ID_AT_TEST,				/*ÓÃÓÚ¿ØÖÆÊäÈëatÃüÁîµÄÓ¦ÓÃ*/
+	MODULE_ID_IP_PROXY,             /*ip proxyÄ£¿éID*/
+
+	MODULE_ID_BIP,					/* BIPÓ¦ÓÃ */
+
+	/* ----- ƽ̨ÄÚ²¿¾²Ì¬Ä£¿éIDµÄ½áβ£¬Æ½Ì¨ÄÚ²¿ÐÂÔöIDÐèÌí¼ÓÔÚÉÏ·½ ------ */
+	
+	//ÒÔÏÂΪ¶¯Ì¬¶ÓÁеÄID±êʶ£¬¶¯Ì¬´´½¨ºÍ¹Ø±Õ£¬²»ÄÜÓ뾲̬ģ¿éIDÒ»Ö£¬ÈκÎʱ¿ÌµãÖ»ÄÜÓÐÒ»¸öʹÓ÷½
+	//£¨²»×¼ÔÚÖмä²åÈëÐÂID£©
+	MODULE_ID_SOFTTIMER_BASE,												/*AP²àÈí¶¨Ê±Æ÷¶¯Ì¬IDÆðʼֵ*/
+	MODULE_ID_SOFTTIMER_END = MODULE_ID_SOFTTIMER_BASE + 0x100,				/*AP²àÈí¶¨Ê±Æ÷¶¯Ì¬ID½áÊøÖµ*/
+	MODULE_ID_AP_ATDYNAMIC_BASE,											/*AP²à²éѯatÃüÁ̬IDÆðʼֵ*/
+	MODULE_ID_AP_ATDYNAMIC_END = MODULE_ID_AP_ATDYNAMIC_BASE + 0x100,		/*AP²à²éѯatÃüÁ̬ID½áÊøÖµ*/
+	MODULE_ID_AP_AUDIODYNAMIC_BASE,											/*AP²àaudio¶¯Ì¬IDÆðʼֵ*/
+	MODULE_ID_AP_AUDIODYNAMIC_END = MODULE_ID_AP_AUDIODYNAMIC_BASE + 0x100,	/*AP²àaudio¶¯Ì¬IDÆðʼֵ*/
+	MODULE_ID_AP_GETHOSTBYNAME_BASE,										 /*ap²àgethostbyname¶¯Ì¬IDÆðʼֵ*/
+	MODULE_ID_AP_GETHOSTBYNAME_END = MODULE_ID_AP_GETHOSTBYNAME_BASE + 0x100, /*ap²àgethostbyname¶¯Ì¬ID½áÊøÖµ*/
+	//AP¶¯Ì¬¶ÓÁÐEND
+
+	//µ±Ç°cmux×î´óÖ§³Ö4·£¬ÐèÒªÆô¶¯4¸ösocket proxy½ø³Ì£¬Èç¹ûºóÐøcmux×î´óÖ§³ÖµÄͨµÀÊýÓиı䣬ÔòÕâÀïÒ²ÐèÒªÐÞ¸Ä
+	MODULE_ID_SOCKET_PROXY,    //¿Í»§¶þ´Î¿ª·¢Ó¦ÓøöÊýÖ§³Ö0x100¸ö£¬¿É¶¯Ì¬ÐÞ¸Ä
+	MODULE_ID_SOCKET_PROXY_END = MODULE_ID_SOCKET_PROXY + 3, 
+	MODULE_ID_GUODIAN_BASE,
+	MODULE_ID_GPS,  //	GPSÓ¦ÓÃÄ£¿éID
+
+	// for audio-ctrl
+	MODULE_ID_ZCORE,
+	MODULE_ID_CALL_23G,
+	MODULE_ID_CLAL_VOLTE,
+	MODULE_ID_ZCORE_TEMP,
+	MODULE_ID_CALL_23G_TEMP,
+	MODULE_ID_CLAL_VOLTE_TEMP,
+	MODULE_ID_LOCKNET,
+	//kwatchtest
+	MODULE_ID_KWATCH_CTRL, /*¶ùͯÊÖ±íºǫ́·þÎñÄ£¿éID*/
+	MODULE_ID_KWATCH_CTRL_LOCAL,
+	MODULE_ID_MMI_SVR, /*zte_phone MMI·þÎñ²ãÄ£¿éID*/
+	MODULE_ID_MMI_SVR_LOCAL,
+
+	MODULE_ID_AMT,	
+	
+	/********************************************************************/
+	//¿Í»§¶þ´Î¿ª·¢Ó¦ÓõÄÏûÏ¢¶ÓÁÐIDÆðʼ£¬×î´óÖµ±ØÐë<0x2000(MODULE_ID_CPBASE)
+	/********************************************************************/
+	MODULE_ID_USER_BASE,
+	MODULE_ID_AP_GPS_APP,
+	MODULE_ID_USER_END = MODULE_ID_USER_BASE + 0x100,
+
+	MODULE_ID_ATCTL_TO_VOLTE, /*²»¶ÔӦʵ¼ÊÓ¦Óã¬Ö»ÊÇÓÃÀ´±êʶÓëVOLTEͨѶµÄαͨµÀºÅ£¬´ËMODULEID¶ÔÓ¦at_ctlÖ÷¶¯·¢ËÍÇëÇó¸øVOLTEµÄαͨµÀ */
+	MODULE_ID_VOLTE_TO_ATCTL = MODULE_ID_ATCTL_TO_VOLTE +10, /*²»¶ÔӦʵ¼ÊÓ¦Óã¬Ö»ÊÇÓÃÀ´±êʶÓëVOLTEͨѶµÄαͨµÀºÅ£¬´ËMODULEID¶ÔÓ¦VOLTEÖ÷¶¯·¢ËÍÇëÇó¸øat_ctlµÄαͨµÀ */
+	MODULE_ID_USBHOTPLUG,
+	MODULE_ID_POC_CTRL, /*POCºǫ́·þÎñÄ£¿éID*/
+	MODULE_ID_SECURITY_LOG,
+	MODULE_ID_MBIM,
+	MODULE_ID_VSIM,
+} T_AP_Module_ID;
+
+/* ------------- CPºË´æÔÚµÄÄ£¿éID£¬Æ½Ì¨ÄÚ²¿Ê¹Ó㬲»¿ª·Å¸ø¿Í»§ ------------- */
+typedef enum {
+	MODULE_ID_CPBASE = 0x2000,		/*CPºËÄ£¿éIDÆðʼµØÖ·*/
+	MODULE_ID_BL,
+	MODULE_ID_FP_CLOCK,				/*ÄÖÖÓÄ£¿éID*/
+//	MODULE_ID_ZCORE,
+	MODULE_ID_CP_AT_CTL,
+	MODULE_ID_CP_RTC_SERVICE,
+	MODULE_ID_CP_MMI,
+	MODUEL_ID_TCARD,
+	MODULE_ID_CP_GPS_APP,
+
+	// for audio ctrl
+//	MODULE_ID_CALL_23G,
+//	MODULE_ID_CLAL_VOLTE,
+//	MODULE_ID_ZCORE_TEMP,
+//	MODULE_ID_CALL_23G_TEMP,
+//	MODULE_ID_CLAL_VOLTE_TEMP,
+	
+	/////ÒÔÏÂΪ¶¯Ì¬¶ÓÁеÄID±êʶ£¬¶¯Ì¬´´½¨ºÍ¹Ø±Õ£¬²»ÄÜÓ뾲̬ģ¿éIDÒ»Ö£¬ÈκÎʱ¿ÌµãÖ»ÄÜÓÐÒ»¸öʹÓ÷½
+	//£¨²»×¼ÔÚÖмä²åÈëÐÂID£©
+	//MODULE_ID_SOFTTIMER_BASE,
+	//MODULE_ID_SOFTTIMER_END = MODULE_ID_SOFTTIMER_BASE + 0x100,
+	MODULE_ID_CP_ATDYNAMIC_BASE,											/*cp²à²éѯatÃüÁ̬IDÆðʼֵ*/
+	MODULE_ID_CP_ATDYNAMIC_END = MODULE_ID_CP_ATDYNAMIC_BASE + 0x100,		/*cp²à²éѯatÃüÁ̬ID½áÊøÖµ*/
+	MODULE_ID_CP_AUDIODYNAMIC_BASE,											/*cp²àaudio¶¯Ì¬IDÆðʼֵ*/
+	MODULE_ID_CP_AUDIODYNAMIC_END = MODULE_ID_CP_AUDIODYNAMIC_BASE + 0x100,	/*cp²àaudio¶¯Ì¬ID½áÊøÖµ*/
+	//CP¶¯Ì¬¶ÓÁÐEND
+
+	MODULE_ID_MAX, /*ÓÐЧmdouleidµÄ×î´óÖµ*/
+} T_CP_Module_ID;
+
+#if 0//(APP_OS_TYPE == APP_OS_TOS)
+#define  MODULE_ID_AT_CTL  MODULE_ID_AP_AT_CTL
+#define  MODULE_ID_EXTERNAL_AT_CTL  MODULE_ID_AP_AT_CTL
+#define  MODULE_ID_RTC_SERVICE MODULE_ID_CP_RTC_SERVICE
+#define  MODULE_ID_EXTERNAL_RTC_SERVICE MODULE_ID_AP_RTC_SERVICE
+#define  MODULE_ID_ATDYNAMIC_BASE MODULE_ID_CP_ATDYNAMIC_BASE
+#define  MODULE_ID_ATDYNAMIC_END MODULE_ID_CP_ATDYNAMIC_END
+#define  MODULE_ID_AUDIODYNAMIC_BASE MODULE_ID_CP_AUDIODYNAMIC_BASE
+#define  MODULE_ID_AUDIODYNAMIC_END MODULE_ID_CP_AUDIODYNAMIC_END
+#define  MODULE_ID_GPS_APP  MODULE_ID_CP_GPS_APP
+//#elif(APP_OS_TYPE == APP_OS_LINUX)
+#else
+#define  MODULE_ID_AT_CTL  MODULE_ID_AP_AT_CTL
+#define  MODULE_ID_EXTERNAL_AT_CTL  MODULE_ID_AP_AT_CTL
+#define  MODULE_ID_RTC_SERVICE MODULE_ID_AP_RTC_SERVICE
+#define  MODULE_ID_EXTERNAL_RTC_SERVICE MODULE_ID_AP_RTC_SERVICE
+#define  MODULE_ID_ATDYNAMIC_BASE MODULE_ID_AP_ATDYNAMIC_BASE
+#define  MODULE_ID_ATDYNAMIC_END MODULE_ID_AP_ATDYNAMIC_END
+#define  MODULE_ID_AUDIODYNAMIC_BASE MODULE_ID_AP_AUDIODYNAMIC_BASE
+#define  MODULE_ID_AUDIODYNAMIC_END MODULE_ID_AP_AUDIODYNAMIC_END
+#define  MODULE_ID_GPS_APP  MODULE_ID_AP_GPS_APP
+#endif
+
+/* ¶¨Òå¸÷Ä£¿éID´¦ÀíµÄÏûÏ¢Âë MSG CMD·¶Î§ */
+enum MSG_CDM_SCOPE {
+	/**/
+	MSG_CMD_MAINCTRL_BASE 	= 0x1000,
+	MSG_CMD_MAINCTRL_END	= 0x1500,
+	/**/
+	MSG_CMD_ATCTL_BASE 		= 0x1501,
+	MSG_CMD_ATCTL_END		= 0x1800,
+	/**/
+	MSG_CMD_ATCTL_INNER_BASE = 0x1801,
+	MSG_CMD_ATCTL_INNER_END	= 0x2000,
+	/**/
+	MSG_CMD_SMS_BASE 		= 0x2001,
+	MSG_CMD_SMS_END			= 0x2200,
+	/**/
+	MSG_CMD_PB_BASE 		= 0x2201,
+	MSG_CMD_PB_END			= 0x2400,
+	/**/
+	MSG_CMD_BL_BASE 		= 0x2401,
+	MSG_CMD_BL_END			= 0x3500,
+	/**/
+	MSG_CMD_OTHER_BASE  	= 0x3501,
+	MSG_CMD_OTHER_END		= 0x4000,
+	/**/
+	MSG_CMD_WIFI_BASE 		= 0x4001,
+	MSG_CMD_WIFI_END		= 0x4200,
+	/**/
+	MSG_CMD_MMI_BASE		= 0x4201,
+	MSG_CMD_MMI_END			= 0x4400,
+	/**/
+	MSG_CMD_FOTA_BASE 		= 0x4401,
+	MSG_CMD_FOTA_END		= 0x4600,
+
+	/**/
+	MSG_CMD_DM_BASE 		= 0x4801,
+	MSG_CMD_DM_END			= 0x5000,
+	/**/
+	MSG_CMD_RTC_BASE 		= 0x5001,
+	MSG_CMD_RTC_END			= 0x5200,
+	/**/
+	MSG_CMD_USER_BASE 		= 0x5201,
+	MSG_CMD_USER_END		= 0x5700,
+	/**/
+	MSG_CMD_EXTAT_BASE 		= 0x5701,
+	MSG_CMD_EXTAT_END		= 0x6000,
+
+	/**/
+	MSG_CMD_SOCMSG_BASE		= 0x6001,
+	MSG_CMD_SOCMSG_END		= 0x6800,
+	
+	/**/
+	MSG_CMD_LQ_BASE		    = 0x6801,
+	MSG_CMD_LQ_END		    = 0x6900,
+
+	/**/
+	MSG_CMD_DRV_BASE 		= 0x6901,
+	MSG_CMD_DRV_END			= 0x7000,
+
+	//kwatchtest
+	MSG_CMD_KWATCH_BASE      = 0x8001,
+	MSG_CMD_KWATCH_END      = 0x9000,
+
+	//amt device test
+	MSG_CMD_AMT_DEVICE_TEST_BASE      = 0x9001,
+	MSG_CMD_AMT_DEVICE_TEST_END      = 0x90C8,
+	
+	//pocsvr
+	MSG_CMD_POCSVR_BASE      = 0x9101,
+	MSG_CMD_POCSVR_END      = 0x9200,
+};
+#endif
+
+#define MSG_MAGIC_WORD       0x3A3A3A3A  /*ȱʡħÊõ×Ö*/
+#define MSG_TYPE_DEFAULT     1   /*lMsgTypeĬÈϵÄÏûÏ¢ÀàÐÍ*/
+#define MSG_TYPE_SOFTTIMER_TIMEOUT  2     /*soft timer³¬Ê±ÏûÏ¢,ɾ³ý¶¨Ê±Æ÷ɾ³ý³¬Ê±ÏûϢʱÐèÒªÖ¸¶¨ÀàÐÍ*/
+
+/*¶¨ÒåͨÓõÄÏûÏ¢½á¹¹*/
+
+/**
+ * @brief message queue body for processes to exchange data
+ * @param lMsgType ÏûÏ¢ÀàÐÍ£¬Õâ¸öÊÇÓÃÀ´¿ØÖÆÏûÏ¢ÊÕÈ¡µÄÓÅÏÈ˳ÐòµÄ
+ * @param usTargetModuleID Ä¿µÄÄ£¿éÏûÏ¢¶ÓÁÐID
+ * @param usSourceModuleID Ô´Ä£¿éÏûÏ¢¶ÓÁÐID
+ * @param usMsgCmd ÏûÏ¢Â룬Õâ¸öÊÇÓÃÀ´Ö¸Ê¾ÏûÏ¢µÄÄÚÈÝÊÇʲôµÄ
+ * @param usDataLen Я´øµÄÓÐЧÊý¾Ý³¤¶È
+ * @param aucDataBuf Я´øµÄÓÐЧÊý¾Ýbuffer
+ * @param ulMagic ħÊõ×Ö£¬Õý³£Çé¿öÏÂֵΪMSG_MAGIC_WORD
+ */
+typedef struct tagMSG_BUF {
+	long   lMsgType;                /*ÏûÏ¢ÀàÐÍ£¬Õâ¸öÊÇÓÃÀ´¿ØÖÆÏûÏ¢ÊÕÈ¡µÄÓÅÏÈ˳ÐòµÄ*/
+	int dst_id;                     /*Ä¿µÄÄ£¿éÏûÏ¢¶ÓÁÐID*/
+	int src_id;                     /*Ô´Ä£¿éÏûÏ¢¶ÓÁÐID*/
+	unsigned short usMsgCmd;        /*ÏûÏ¢Â룬Õâ¸öÊÇÓÃÀ´Ö¸Ê¾ÏûÏ¢µÄÄÚÈÝÊÇʲôµÄ*/
+	unsigned short usDataLen;       /*Я´øµÄÓÐЧÊý¾Ý³¤¶È*/
+	unsigned long  ulMagic;         /*ħÊõ×Ö£¬Õý³£Çé¿öÏÂֵΪMSG_MAGIC_WORD*/
+	unsigned char  aucDataBuf[MSG_DATA_MAX_LEN]; /*Я´øµÄÓÐЧÊý¾Ýbuffer*/
+} MSG_BUF;
+
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+ * @brief ͨ¹ýATÃüÁî·¢Ë͵ĺ˼äÏûÏ¢
+ * @param targetId ½ÓÊÕÏûÏ¢µÄÄ£¿éºÅ
+ * @param position  ÏûÏ¢·¢Ë͵ķ½Ïò
+ * @param msg_cmd  ÏûÏ¢id
+ * @param len  Êý¾Ý³¤¶È
+ * @param msg  Êý¾ÝÄÚÈÝ
+ */
+typedef struct {
+	int srcId;
+	int targetId;
+	unsigned short position;
+	unsigned short msg_cmd;
+	unsigned short len;
+	unsigned char  msg[SOC_MSG_MAX_LEN];
+} T_Soc_Msg;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/ap/app/include/mmi_msg.h b/ap/app/include/mmi_msg.h
new file mode 100755
index 0000000..40f9a1c
--- /dev/null
+++ b/ap/app/include/mmi_msg.h
@@ -0,0 +1,91 @@
+/**
+ * @file mmi_msg.h
+ * @brief ÌṩÁËmmiÏûÏ¢½Ó¿ÚºÍÏûÏ¢½á¹¹¶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __MMI_MSG_H__
+#define __MMI_MSG_H__
+#include "message.h"
+
+
+/*ϵͳÐÅÏ¢²éѯ*/
+typedef struct {
+	signed long     srvStatus;        /*ϵͳ·þÎñ״̬  */
+	signed long     srvDomain;        /*ϵͳ·þÎñÓò    */
+	signed long     roamStatus;       /*ÂþÓÎ״̬      */
+	signed long     sysMode;          /*ϵͳģʽ      */
+	signed long     simState;         /*SIM¿¨×´Ì¬     */
+	signed long     reserve;          /*±£ÁôÖµ       */
+	signed long     sysSubmode;       /*ϵͳ×Óģʽ    */
+} T_zAt_SysinfoRes;
+
+
+/* ÏûÏ¢½á¹¹Ìå */
+typedef struct {
+	unsigned char sms_unread_ind; //0:ÎÞδ¶Á¶ÌÐÅ£» 1:ÓÐδ¶Á¶ÌÐÅ
+	unsigned char sms_memory_full_ind; //0:²»Âú; 1: Âú
+	unsigned char sms_new_ind;
+	unsigned char sms_is_reading;
+	unsigned char sms_unread_count;
+} T_zUfi_SmsStatusInfoInd;
+
+/* ¹Ø»úÖØÆôÏûϢʵ¼Ê²Ù×÷Öµ */
+typedef enum {
+	Ext_Cmd_Base = 0,
+	Ext_Cmd_REBOOT,
+	Ext_Cmd_POWEROFF,
+	Ext_Cmd_POWEROFF_CHARGING,
+	Ext_Cmd_POWEROFF_FAKE,
+	Ext_Cmd_POWEROFF_CLOCK,
+	Ext_Cmd_MAX
+} T_zUfi_ExtCmd;
+
+struct ext_msg_data {
+	int cmd;
+};
+
+//autotest ×Ô¶¯»¯²âÊÔÏûÏ¢Êý¾Ý
+typedef struct  {
+	SINT32 code;
+	SINT32 value;
+} autotest_key_rspmsg;
+
+//ÇëÎâºì½«mmiÄÚ²¿ÏûϢʹÓõÄÏûÏ¢Â룬ҲÌí¼Óµ½ÕâÀï
+enum mmi_msg_cmd {
+	MSG_CMD_CHANNEL_NETWORK_MODE = MSG_CMD_MMI_BASE,
+	MSG_CMD_MULTI_CONNECT_STATUS,//ÊÇ·ñ´æÔÚ¶à·PDP¼¤»î
+	MSG_CMD_CHANNEL_CONNECT_STATUS,
+	MSG_CMD_SMS_STATUS_INFO_IND,
+	MSG_CMD_OUT_REG_GET_SIGNAL_NUM,
+	MSG_CMD_MODIFY_SSID_KEY,
+	MSG_CMD_GET_TRAFFIC_INFO_START,
+	MSG_CMD_GET_TRAFFIC_INFO_END,
+	MSG_CMD_TRAFFIC_INFO_RESET,
+	MSG_CMD_GET_NET_PROVIDER,
+	MSG_CMD_SET_USB_MODE,
+	MSG_CMD_VOIP_STATUS_INFO,
+	MSG_CMD_STA_COUNT_CHANGE,
+	MSG_CMD_POWEROFF_PLUGOUT_RESULT,
+	MSG_CMD_SOCKET_STATE_CHANGE,    //ÄÚÖÃsocket connect state
+	MSG_CMD_MCUSOCKET_STATE_CHANGE, //ÍâÖÃsocket connect state
+	MSG_CMD_MMIGET_WIFI_STANUM,//ÏÂÃæÊÇMMI ÄÚ²¿Ê¹ÓõÄÏûÏ¢
+	MSG_CMD_MMISTART_BACKLIGHTOFF_TIMER,
+	MSG_CMD_MMICHECK_TIP_INFO,
+	MSG_CMD_MMISHOW_SSID_INFO,
+	MSG_CMD_MMIGET_WIFI_DATA,
+	MSG_CMD_RJ11_STATUS_INFO, //ҢԶcpe
+//#ifdef _ENABLE_AUTOTEST
+	MSG_CMD_AUTOTEST_KEY_REQ,
+//#endif
+};
+
+#endif
+
diff --git a/ap/app/include/netapi.h b/ap/app/include/netapi.h
new file mode 100755
index 0000000..2db6114
--- /dev/null
+++ b/ap/app/include/netapi.h
@@ -0,0 +1,461 @@
+/**
+ * @file netapi.h
+ * @brief Public APIs of Sanechips, linux network external interface
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Linxu Gebin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ ************************************************************************
+ */
+
+#ifndef __NETAPI_H__
+#define __NETAPI_H__
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+/**
+ * @brief NVÖµµÄ³¤¶È£¬ÎªÁ˽Úʡջ¿Õ¼äʹÓÃÕâ¸öºê£¬ÈôʹÓÃNV_MAX_KEY_LENÓпÉÄÜ»áÔì³ÉÕ»Ô½½ç
+ */
+#define	NV_NAME_LEN   30
+
+#define RJ45_ALL_OUT	0x00
+#define RJ45_LAN_IN		0x01
+#define RJ45_WAN_IN		0x02
+#define RJ45_ALL_IN		0x03
+
+#define USB_LAN_OUT     0x00
+#define USB_LAN_IN		0x01
+
+
+
+/**
+ * @brief ¹©atÏà¹ØÓ¦Óýø³Ìµ÷ÓÃÍøÂç½Ó¿Úʱ¸³Öµ£¬Ö¸Ê¾PDP ¼¤»îµÄ·¢ÆðλÖ㬽ø¶ø¹©ÍøÂçÄÚ²¿½øÐв»Í¬×éÍøºÍ·ÓÉÅäÖÃ
+ * @param PDP_LOCAL ±íʾÊDZ¾µØÓ¦Ó÷¢ÆðµÄPDP¼¤»î£¬Èç²ÊÐÅ¡¢VoLTEµÈ
+ * @param PDP_EXT ±íʾÊÇÓɷDZ¾ºËÄÚ·¢ÆðµÄATÃüÁîÁ÷³Ì£¬Èç´ó°å·¢ÆðµÄATÃüÁÎÒÃǺËÄÚ½ö×÷͸´«£¬´ËʱÐèÒª¶ÔÍø¿Ú½øÐÐÖ±Á¬£»
+ * @param PDP_NORMAL ±íʾÊDZ¾ºËµÄatserver·¢ÆðµÄPDP¼¤»î£¬ÓÃÓÚNATת»»µÄÍâÍø¿Ú
+ * @param PDP_PPP ±íʾÊDZ¾ºËµÄPPPÏà¹ØµÄPDP¼¤»î£¬³£¼ûÓÚÄ£¿éµÄPPP¹¦ÄÜÐèÇó
+ */
+#define PDP_LOCAL     0
+#define PDP_EXT       1
+#define PDP_NORMAL    2
+#define PDP_PPP       3
+
+#define   NONE_AUTH           0
+#define   PAP_AUTH            1
+#define   CHAP_AUTH           2
+#define   PAP_CHAP_AUTH       3
+#define   PPP_NONE_AUTH       4
+#define   PPP_CHAP_AUTH       5
+#define   PPP_PAP_AUTH        PAP_AUTH
+
+/**
+ * @brief IPV4µØÖ·³¤¶ÈÉÏÏÞ
+ */
+#define IPV4ADDLEN_MAX         16
+
+/**
+ * @brief IPV6µØÖ·³¤¶ÈÉÏÏÞ
+ */
+#define IPV6ADDLEN_MAX         46
+
+/**
+ * @brief MACµØÖ·³¤¶ÈÉÏÏÞ
+ */
+#define MAX_MACADDR_LEN 		14
+
+/**
+ * @brief MACµØÖ·³¤¶È
+ */
+#define MAC_ADDR_LEN 18
+
+/**
+ * @brief Ö÷»úÃû³¤¶È
+ */
+#define HOSTNAME_LEN 150
+
+/**
+ * @brief ÍøÖ·³¤¶È
+ */
+#define SITE_LEN 400
+
+
+/**
+ * @brief PPPDʹÓõĺ궨Òå
+ * @param NUM_PPPD_AUTH Ò»¸öppp½ø³ÌÖ§³ÖµÄÓû§ÊýÁ¿
+ * @param USER_MAX Óû§Ãû»òÕßÌôÕ½idµÄ³¤¶ÈÉÏÏÞ
+ * @param PW_MAX ÃÜÂëµÄ³¤¶ÈÉÏÏÞ
+ * @param CHALLENGE_MAX ÌôÕ½»ØÓ¦ÉÏÏÞ
+ */
+#define NUM_PPPD_AUTH		1
+#define USER_MAX			50
+#define PW_MAX				50
+#define CHALLENGE_MAX		50
+
+
+/**
+* @brief ¶¨ÒåPDP¼¤»îÀàÐÍ
+* @param V4V6_INVALID ³õʼֵ£¬²»½øÐÐÈκβÙ×÷
+* @param V4_VALID ¶ÔV4½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
+* @param V6_VALID ¶ÔV6½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
+* @param V46_VALID ¶ÔV4ºÍV6½øÐвÙ×÷£¬°üÀ¨¼¤»îºÍÈ¥»î
+*/
+enum ipv4v6_flag {
+	V4V6_INVALID = 0x00,
+	V4_VALID,
+	V6_VALID,
+	V46_VALID,
+};
+
+/**
+* @brief ¶¨ÒåÍø¿Ú״̬
+* @param DEV_STATE_IDLE ÍøÂçÉ豸´¦ÓÚ¿ÕÏÐ״̬
+* @param DEV_STATE_CONNECT ÍøÂçÉ豸´¦ÓÚ»ñÈ¡µØÖ·×´Ì¬
+* @param DEV_STATE_WORKING ÍøÂçÉ豸»ñÈ¡µØÖ·Íê³É£¬´¦ÓÚ¹¤×÷״̬
+* @param DEV_STATE_DEAD ÍøÂçÉ豸´¦ÓÚÍøÂçÁ¬½Ó¶Ï¿ª×´Ì¬
+*/
+enum emDev_State {
+	DEV_STATE_IDLE,
+	DEV_STATE_CONNECT,
+	DEV_STATE_WORKING,
+	DEV_STATE_DEAD,
+};
+
+/**
+* brief  ¶¨ÒåËùÓеÄÄÚÍâÍø¿Ú¡¢¼¶ÁªµÈÍøÂçÉ豸IDºêÖµ
+* @param PS_NET_DEV PS ÍøÂçÉ豸±êʶ£¬µ±ÔËÐÐÔÚAPºËʱ£¬Æä¶ÔÓ¦µÄÍøÂçÉ豸ΪUSB¡¢DDRNETµÈÐéÄâ³öµÄÍøÂçÉ豸
+* @param PS_EXT_DEV1 ÓëPS¼¶ÁªµÄÍøÂçÉ豸£¬³£¼ûÓÚÊý¾Ý¿¨ÐÎ̬£¬Ò»°ãΪUSBÎïÀíͨµÀ£¬Ò²¿ÉÄÜÊǹ²ÏíDDRµÈͨµÀ£¬µ«¹²ÏíDDRͨµÀÎÞÈȲå°ÎʼþÉϱ¨
+* @param PS_EXT_DEV2 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV3 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV4 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV5 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV6 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV7 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param PS_EXT_DEV8 Ŀǰ֧³Ö1-8µÄCID¹ØÁª
+* @param RJ45_WAN_DEV RJ45ÍâÍø¿ÚÉ豸±êʶ£¬Ïà¶ÔÓÚRJ45_LAN_DEV£¬ÓÅÏÈʶ±ð£¬ÒòΪÍâÍø¿ÚÖ§³ÖÄÚÍâÍø×Ô¶¯Çл»
+* @param RJ45_LAN_DEV RJ45ÄÚÍø¿ÚÉ豸±êʶ£¬½öÓÃÓÚRJ45ÄÚÍâÍø¿Úͬʱ´æÔÚ³¡¾°
+* @param SW_WAN_DEV Realtek switch ÍâÍø¿ÚÉ豸±êʶ£¬Ö§³ÖÈȲå°Î
+* @param SW_LAN_DEV Realtek switch ÍâÍø¿ÚÉ豸±êʶ£¬Ö§³ÖÈȲå°Î
+* @param WIFI_WAN_DEV stationÍâÍø¿ÚÉ豸±êʶ
+* @param WIFI_LAN_DEV stationÄÚÍø¿ÚÉ豸±êʶ
+* @param USB_LAN_DEV USBÄÚÍø¿ÚÉ豸±êʶ
+* @param NO_DEV ȱʡÍâÍø¿ÚΪ¿Õʱºò±êʶ
+*/
+enum dev_ID {
+	PS_NET_DEV,
+	PS_EXT_DEV1,
+	PS_EXT_DEV2,
+	PS_EXT_DEV3,
+	PS_EXT_DEV4,
+	PS_EXT_DEV5,
+	PS_EXT_DEV6,
+	PS_EXT_DEV7,
+	PS_EXT_DEV8,
+	RJ45_WAN_DEV,
+	RJ45_LAN_DEV,
+	SW_WAN_DEV,
+	SW_LAN_DEV,
+	WIFI_WAN_DEV,
+	WIFI_LAN_DEV,
+	USB_LAN_DEV,
+	NO_DEV,
+};
+
+/**
+* @brief ÍâÍø¿ÚÁªÍøÊ§°ÜµÄÔ­ÒòIDºêÖµ
+* @param TIME_OUT Á¬½Ó³¬Ê±
+*/
+enum dialfail_reason_ID {
+	TIME_OUT = 0,
+};
+
+/**
+ * @brief Íø¿ÚµÄip46µÈµØÖ·ÐÅÏ¢
+ * @param ip46flag ipv4/ipv6 ±ê־λ
+ * @param ip ipv4µØÖ·
+ * @param gateway Íø¹ØµØÖ·
+ * @param netmask ÑÚÂë
+ * @param pri_dns Ê×Ñ¡dnsµØÖ·
+ * @param sec_dns ´ÎÑ¡dnsµØÖ·
+ * @param  ip6 ipv6 µØÖ·
+ * @param gateway6 ipv6 Íø¹ØµØÖ·
+ * @param  pri_dns6 ipv6 Ê×Ñ¡dnsµØÖ·
+ * @param  sec_dns6 ipv6 ´ÎÑ¡dnsµØÖ·
+ * @note ip46flag µÄȡֵ²Î¿¼V46_VALIDµÈºêÖµ
+ */
+struct netdev_act_info {
+	unsigned char  ip46flag;
+	char ip[IPV4ADDLEN_MAX];
+	char gateway[IPV4ADDLEN_MAX];
+	char netmask[IPV4ADDLEN_MAX];
+	char pri_dns[IPV4ADDLEN_MAX];
+	char sec_dns[IPV4ADDLEN_MAX];
+	char ip6[IPV6ADDLEN_MAX];
+	char gateway6[IPV6ADDLEN_MAX];
+	char pri_dns6[IPV6ADDLEN_MAX];
+	char sec_dns6[IPV6ADDLEN_MAX];
+};
+
+/**
+ * @brief ½á¹¹Ìå˵Ã÷:PDP¼¤»îÐÅÏ¢£¬×¨ÓÃÓÚPSÍâÍø¿Ú£¬ÆäÖÐcidÓÃÓÚʶ±ð²»Í¬µÄPSÍâÍø¿Ú
+ * @param c_id PDPΨһ±êʶ
+ * @param pdp_type pdp ¼¤»îÀàÐÍ
+ * @param act_info Íø¿ÚµØÖ·µÈÐÅÏ¢
+ * @note pdp type µÄȡֵ²Î¼ûPDP_LOCALµÈºêÖµ
+ */
+struct pdp_active_info {
+	int c_id;
+	unsigned char pdp_type;
+	struct netdev_act_info act_info;
+};
+
+/**
+ * @brief macµØÖ·ºÍ¶ÔÓ¦Ö÷»úÃûÐÅÏ¢
+ * @param mac macµØÖ·
+ * @param hostname macµØÖ·¶ÔÓ¦µÄÖ÷»úÃû
+ */
+struct mac_hostname_info {
+	char mac[MAC_ADDR_LEN];
+	char hostname[HOSTNAME_LEN];
+};
+
+/**
+ * @brief ¾²Ì¬mac ipµØÖ·ÐÅÏ¢
+ * @param mac mac µØÖ·
+ * @param ip  macµØÖ·°ó¶¨µÄ¾²Ì¬ipµØÖ·
+ */
+struct static_macip_info {
+	char mac[32];
+	char ip[32];
+};
+
+/**
+ * @brief ¼Ò³¤Ä£Ê½°×Ãûµ¥ÍøÕ¾ÐÅÏ¢
+ * @param name ÍøÕ¾Ãû³Æ
+ * @param site ÍøÕ¾ÍøÖ·
+ */
+struct white_site_info {
+	char name[HOSTNAME_LEN];
+	char site[SITE_LEN];
+};
+
+/**
+ * @brief ȱʡÍâÍø¿ÚÐÅÏ¢
+ * @param p46flag ipv4/ipv6±ê־λ
+ * @param dev_id  É豸idºÅ
+ */
+struct default_dev_info {
+	unsigned char  ip46flag;
+	unsigned char  dev_id;
+};
+
+/**
+ * @brief Á÷Á¿¿ØÖÆÐÅÏ¢
+ * @param c_id PDPΨһ±êʶ£¬ucÊý¾Ý¿¨Ä£Ê½ÐèÒª´«È룬ufiģʽ²»ÐèÒª
+ * @param tc_downlink  ÏÂÐÐÁ÷Á¿¿ØÖÆÖµ£¬µ¥Î»:±ÈÌØ
+ * @param tc_uplink  ÏÂÐÐÁ÷Á¿¿ØÖÆÖµ£¬µ¥Î»:±ÈÌØ
+ * @note tc_downlink/tc_uplink 0 ±íʾ²»ÐèÒªÁ÷¿Ø£¬Òòlinux±ê×¼ÃüÁîÊǶÔ×Ö½Ú´¦Àí£¬ËùÒÔ×îÖÕÅäÖÃÖµ»áÕû³ý8
+ */
+struct tc_control_info {
+	int c_id;
+	unsigned int tc_downlink;
+	unsigned int tc_uplink;
+};
+
+/**
+ * @brief ÁªÍøÊ§°ÜʱµÄÏà¹ØÅäÖÃÏî½á¹¹Ìå
+ * @param ip46flag ipv4/ipv6 ±ê־λ
+ * @param dev_id É豸id
+ * @param dialfail_reason ÁªÍøÊ§°ÜÔ­Òò
+ * @note dialfail_reasonȡֵ²Î¼ûTIME_OUTµÈºêÖµ
+ */
+struct dialfail_dev_info {
+	unsigned char  ip46flag;
+	unsigned char  dev_id;
+	unsigned char  dialfail_reason;
+};
+
+
+/**
+ * @brief PDPÈ¥¼¤»îÐÅÏ¢£¬×¨ÓÃÓÚPSÍâÍø¿Ú
+ * @param c_id PDP Ψһ±êʶ
+ * @param ip46flag  ipv4/ipv6 ±êÖ¾
+ * @note c_id ÓÃÓÚʶ±ð²»Í¬µÄPSÍâÍø¿Ú
+ */
+struct pdp_deactive_info {
+	int c_id;
+	unsigned char ip46flag;
+};
+
+#if 0
+typedef struct {
+	int result;
+	int cid;
+	char v6_addr[46];
+} V6ADDR_INFORM;
+#endif
+
+/**
+ * @brief PPPD·¢ËÍPDP¼¤»îÏûÏ¢ÐÅÏ¢
+ * @param auth_type ÈÏÖ¤·½Ê½0´ú±íPAP£¬1´ú±íCHAP
+ * @param user_len  Óû§Ãû ³¤¶È
+ * @param user  Óû§Ãû£¬ÔÚCHAP·½Ê½Ï¸ÃÖµÖÃΪÌôÕ½idºÅ
+ * @param pw_len ÃÜÂ볤¶È
+ * @param pw ÃÜÂ룬ֻÓÃÓÚPAP·½Ê½
+ * @param chg_len ÌôÕ½³¤¶È
+ * @param challenge ÌôÕ½id£¬ÓÃÓÚCHAP·½Ê½
+ */
+typedef struct pppd_auth {
+	int 	auth_type;
+	int 	user_len;
+	char 	user[USER_MAX];
+	int 	pw_len;
+	char 	pw[PW_MAX];
+	int 	chg_len;
+	char 	challenge[CHALLENGE_MAX];
+} pppd_auth;
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+
+
+
+
+/**
+ * @brief ¸ù¾ÝÍøÂçÉ豸Ãû»ñÈ¡¶ÔÓ¦µÄÉ豸ID,°´ÕÕÓÅÏȼ¶ÓëNVÖеÄÉ豸Ãû½øÐÐÆ¥Åä
+ * @param dev_name ÍøÂçÉ豸Ãû
+ * @return ʧ°Ü·µ»Ø-1
+ */
+int getDevId_byname(char *dev_name);
+
+
+/**
+ * @brief  PSÍøÂçÉ豸¼¤»î½Ó¿Ú
+ * @param actinfo pdp ¼¤»îÐÅÏ¢
+ * @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+ * @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+ * @note atÏà¹ØÓ¦Óýø³Ìµ÷Óã¬Èçatserver¡¢pcserver¡¢VoLTE¡¢²ÊÐŵÈÓ¦Óýø³Ì
+ */
+int pdp_act_proc(struct pdp_active_info *actinfo, int src_id);
+
+
+/**
+ * @brief PPPÍøÂçÉ豸¼¤»î½Ó¿Ú
+ * @param ttyname  tty É豸Ãû
+ * @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+ */
+int ppp_act_proc(char *ttyname);
+
+/**
+ * @brief PSÍøÂçÉ豸ȥ»î½Ó¿Ú
+ * @param c_id  PDP¼¤»îc_id
+ * @param ip46flag  ip4/ipv6±êÖ¾
+ * @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+ * @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+ * @note atÏà¹ØÓ¦Óýø³Ìµ÷Óã¬Èçatserver¡¢pcserver¡¢VoLTE¡¢²ÊÐŵÈÓ¦Óýø³Ì
+ */
+int pdp_deact_proc(int c_id, unsigned char ip46flag, int src_id);
+
+
+/**
+ * @brief ÈȲå°ÎÉ豸²åÈë,½Ó¿ÚÄÚ²¿¼ì²âÊÇ·ñÐèÒª½øÐв¦ºÅ£¬ÈçÐèÒª£¬Ö´ÐеØÖ··ÖÅä¡¢×éÍøµÈÁ÷³Ì
+ * @param netdev_id	 É豸idºÅ
+ * @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+ * @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+ * @note É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒÑͨ£¬¿ÉÒÔ½øÐÐIPÊý¾Ý°üµÄÊÕ·¢ÁË£»
+ * Ö÷¿Ø½ø³ÌÐèÒª±£Ö¤ÈȲå°Îʼþ²»»áÖØ¸´µ÷Óøýӿڣ¬·ñÔòÍøÂçÄÚ²¿»áƵ·±½øÐÐÖØ¸´µÄÖØÅäÖÃIPµØÖ·µÄÁ÷³Ì
+ */
+int netdev_plugin_proc(unsigned char netdev_id, int src_id);
+
+/**
+* @brief ÈȲå°ÎÉ豸°Î³ö,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* @param netdev_id	É豸idºÅ
+* @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+* @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+* @note É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒѶϣ¬²»ÒªÔÙ½øÐÐIPÊý¾Ý°üÊÕ·¢
+*/
+int netdev_plugout_proc(unsigned char netdev_id, int src_id);
+
+
+/**
+* @brief webui·¢Ë͵ÄÁ¬½ÓÇëÇó,½Ó¿ÚÄÚ²¿½øÐÐifconfig up£¬²¢Æô¶¯ÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* @param netdev_id	É豸idºÅ
+* @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+* @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+* @note É豸Ö÷¿ØÄ£¿éµ÷Óô˽ӿÚǰ£¬ÐèÒª¼ì²âµ±Ç°É豸ÎïÀíͨ·ÒÑͨ£¬·ñÔò²»Ó¦¸Ãµ÷Óô˽ӿÚ
+*/
+int netdev_connect_internet(unsigned char netdev_id, int src_id);
+
+
+/**
+* @brief webui·¢Ë͵ĶϿªÁ¬½ÓÇëÇó,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* @param netdev_id	É豸idºÅ
+* @param src_id  µ÷Óô˽ӿڵĽø³Ìid
+* @return ³É¹¦ ·µ»Ø 0, ʧ°Ü ·µ»Ø -1
+* @note É豸Ö÷¿ØÄ£¿éµ÷Óô˽ӿÚ
+*/
+int netdev_disconnect_internet(unsigned char netdev_id, int src_id);
+
+
+/**
+* @brief Á÷Á¿¿ØÖÆ
+* @param tcinfo	Á÷Á¿¿ØÖÆÐÅÏ¢£¬ÐèÒªÁ÷Á¿¼à¿ØµÄÉÏÏÂÐÐÁ¿
+* @param src_id	 Ô´½ø³ÌidºÅ
+* @return ²Ù×÷³É¹¦·µ»Ø1£¬Ê§°Ü·µ»Ø0
+* @note ¸øÐèÒªÁ÷Á¿¿ØÖƵÄÓ¦Óõ÷Óã¬ÈçÉÏÐÐÐèÒªÁ÷¿Ø£¬ÇëµÈÄÜÉÏÍâÍøºóÔÙµ÷Ó㬷ñÔòÎÞ·¨»ñÈ¡ÍâÍø¿Ú½øÐÐÁ÷¿Ø
+*           Õý³£¹Ø»úÖØÐ¿ª»ú£¬Ö®Ç°ÉèÖõÄÁ÷¿ØÒÀÈ»ÓÐЧ
+*/
+int tc_control(struct tc_control_info *tcinfo, int src_id);
+
+
+/**
+* @brief  ÈȲå°ÎÉ豸²åÈë,½Ó¿ÚÄÚ²¿¼ì²âÊÇ·ñÐèÒª½øÐÐ×Ô¶¯²¦ºÅ£¬ÈçÐèÒª£¬Ö´ÐеØÖ··ÖÅä¡¢×éÍøµÈÁ÷³Ì
+* @param netdev_name  ÍøÂçÉ豸Ãû
+* @param src_id  Ô´½ø³Ì id ºÅ
+* @return ²Ù×÷³É¹¦·µ»Ø1£¬Ê§°Ü·µ»Ø0
+* @note É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒÑͨ£¬¿ÉÒÔ½øÐÐIPÊý¾Ý°üµÄÊÕ·¢ÁË
+*/
+int netdev_plugin_proc_byname(char *netdev_name, int src_id);
+
+
+/**
+* @brief ÈȲå°ÎÉ豸°Î³ö,½Ó¿ÚÄÚ²¿½øÐÐifconfig down£¬²¢É±µôÏàÓ¦µÄµØÖ··ÖÅä½ø³Ì
+* @param netdev_name  ÍøÂçÉ豸Ãû
+* @param src_id  Ô´½ø³Ì id ºÅ
+* @return  ²Ù×÷³É¹¦·µ»Ø1£¬Ê§°Ü·µ»Ø0
+* @note É豸Ö÷¿Øµ÷Óô˽ӿÚʱ£¬±íÃ÷¸ÃÍøÂçÉ豸ÎïÀíͨ·ÒѶϣ¬²»ÒªÔÙ½øÐÐIPÊý¾Ý°üÊÕ·¢
+*/
+int netdev_plugout_proc_byname(char *netdev_name, int src_id);
+
+
+/**
+* @brief  »Ö¸´³ö³§ÉèÖÃʱɾ³ý³ÌÐòÔËÐÐÖÐÉú³ÉµÄÎļþ
+* @param ÎÞ
+* @return ÎÞ
+*/
+void tcpip_reset_configure();
+
+/**
+* @brief  ÉèÖÃswitchÉ豸eth0.200Íø¿Ú¶ÔÓ¦µÄport3Ϊwan¿Ú»¹ÊÇlan¿Ú
+* @param mode:1 => wan¿Ú£¬0 => lan¿Ú
+* @return ÎÞ
+*/
+void set_ethwan_port_mode(int mode);
+
+
+#endif
+
+/*******************************************************************************
+ *                      Global function implementations                          *
+ ******************************************************************************/
+
+#endif/* __NETAPI__ */
diff --git a/ap/app/include/netioctl.h b/ap/app/include/netioctl.h
new file mode 100755
index 0000000..df07c21
--- /dev/null
+++ b/ap/app/include/netioctl.h
@@ -0,0 +1,383 @@
+/************************************************************************
+*¹¦ÄܽéÉÜ£º×ÔÑÐʵÏÖµÄioctl½Ó¿Ú²ÎÊý¶¨Òå
+*¸ºÔðÈË£º
+*±¸·ÝÈË£º
+*ÐÞ¸ÄÈÕ£º
+*ÐÞ¸ÄÄÚÈÝ£º
+*°æ±¾ºÅ£º
+************************************************************************/
+
+#ifndef _ZXIC_IOCTL_H_
+#define _ZXIC_IOCTL_H_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+
+#ifdef _MBB_OS_UCLINUX
+#include <stdint.h>
+#endif
+
+
+#define NIOCTL_MAGIC 'x'
+#define NIOCTL_MAX_NR 32         //IOCTL¿ÉÓÃÃüÁîµÄ×î´ó¸öÊý
+
+
+#define NIOCTL_READ _IO(NIOCTL_MAGIC,0)
+
+/*»ñÈ¡¶þ²ãÁÚ¾ÓÁбíÖÐmacµØÖ·ºÍ³ö¿Údevname*/
+
+#define NIOCGPCINFO  _IOWR(NIOCTL_MAGIC,1,ioctl_data)
+
+/*»ñÈ¡ÍøÂçÉ豸tx¡¢rx¡¢dropµÈͳ¼Æ£¬ÍøÂçÉ豸״̬ÐÅÏ¢*/
+
+#define NIOCGSTATS _IOWR(NIOCTL_MAGIC,2,ioctl_data)
+
+/*ÉèÖÃÄں˲ÎÊýͨÓÃÃüÁÀýÈçfastnat/fastbr/leak/brmoniterµÈ¿ª¹Ø»ò¼¶±ð*/
+
+#define NIOCSKPARAM _IOWR(NIOCTL_MAGIC,3,ioctl_data)
+
+/*»ñÈ¡skbÉêÇë³É¹¦/ʧ°Ü¸öÊýͳ¼Æ*/
+
+#define NIOCGSKBCNT _IOR(NIOCTL_MAGIC,4,ioctl_data)
+
+/*»ñÈ¡fastnat ×î´óÁ´½ÓÊý*/
+
+#define NIOCGFASTMAXLINKS _IOR(NIOCTL_MAGIC,7,ioctl_data)//È·¶¨ºóÐøÊÇ·ñ»¹ÒªÊ¹ÓÃ
+
+
+/*»ñÈ¡×Ô´ò¿ªÍ³¼Æ¿ª¹ØÖ®ºó£¬skb µÄµ±Ç°¸öÊý¡¢Ë²¼ä·åÖµµÈͳ¼ÆÐÅÏ¢¡¢skb¿½±´´ÎÊý¡¢skbÍ·À©Õ¹´ÎÊý
+skbÔÚÈíÖжÏÊÍ·Å´ÎÊý*/
+
+#define NIOCGSKBNUM _IOWR(NIOCTL_MAGIC,13,ioctl_data)
+
+/*ÉèÖÃÄÚºËskb dumpÆ¥ÅäÐÅÏ¢£¬ÀýÈçÆ¥ÅäÌØ¶¨macµØÖ·¡¢IPµØÖ·*/
+
+#define NIOCGSKBDUMP _IOR(NIOCTL_MAGIC,14,ioctl_data)
+
+/*ÉèÖÃÄÚºËtcpdump ¿ª¹Ø*/
+
+#define NIOCSTCPDUMP _IOR(NIOCTL_MAGIC,15,ioctl_data)
+
+/**/
+
+#define NIOCPDP     _IOR(NIOCTL_MAGIC,17,ioctl_data)
+
+/**/
+
+#define NIOCFLUSHFLAG _IOR(NIOCTL_MAGIC,18,ioctl_data)
+#define NIOCGKPARAM _IOR(NIOCTL_MAGIC,19,ioctl_data)
+
+
+
+#define NIOCGSLAB _IOR(NIOCTL_MAGIC,21,ioctl_data)
+
+/*add by jiangjing,»ñÈ¡init_netÖÐËùÓÐÍøÂçÉ豸µÄÃû³ÆºÍ״̬ÐÅÏ¢*/
+#define NIOCGDEVLIST  _IOR(NIOCTL_MAGIC, 22, ioctl_data)
+
+/*add by zhangpeimin£¬»ñÈ¡SKB FASTµ±Ç°Í³¼ÆÐÅÏ¢*/
+#define NIOCGSKBFAST _IOR(NIOCTL_MAGIC, 24, ioctl_data)
+
+#define NIOCGMAXMSG  _IOR(NIOCTL_MAGIC, 25, ioctl_data)
+
+#define NIOCGPTYPE  _IOR(NIOCTL_MAGIC, 26, ioctl_data)
+
+#define NIOCGPSINFO  _IOR(NIOCTL_MAGIC, 27, ioctl_data)
+
+#define NIOCGHASH   _IOR(NIOCTL_MAGIC, 28, ioctl_data)
+
+/*»ñÈ¡µ±Ç°TCP¶ª°üͳ¼ÆÐÅÏ¢*/
+#define NIOCGPKTLOST _IOR(NIOCTL_MAGIC, 29, ioctl_data)
+
+/*»ñÈ¡±¾µØTCPÌ×½Ó×Öͳ¼ÆÐÅÏ¢*/
+#define NIOCGTCPSOCKSTATS _IOR(NIOCTL_MAGIC, 30, ioctl_data)
+
+#define NIOCTL_MAX_MSGLEN 128    //×Ö·û´®ÀàÐͲÎÊýÖµµÄ×î´ó³¤¶È
+#define NIOCTL_MAX_NAMELEN 20    //²ÎÊýÃû³ÆµÄ×î´ó³¤¶È
+/*
+    ͨÓÃioctlµÄ²ÎÊýÀàÐÍ£¬µ±²ÎÊýֵΪ×Ö·û´®Ê±£¬Ê¹ÓÃbuf±äÁ¿ÓëÄں˽»»¥£»
+    µ±²ÎÊýֵΪÕûÐÍʱ£¬Ê¹ÓÃvalue±äÁ¿ÓëÄں˽»»¥
+
+*/
+typedef struct {
+	unsigned int size;                     //×Ö·û´®ÀàÐͲÎÊýµÄ³¤¶È£¬¶ÔÓÚÕûÐͲÎÊý£¬¸ÃÖµ½¨Ò鸳ֵΪ0
+	char name[NIOCTL_MAX_NAMELEN];         //²ÎÊýÃû³Æ£¬ÀýÈçfastnat¡¢fastbr¡¢leak
+	unsigned char buf[NIOCTL_MAX_MSGLEN];  //×Ö·û´®ÀàÐͲÎÊýÖµ£¬ÀýÈçon/off
+	void *data;                            //×Ô¶¨Òå½á¹¹Ìå
+	int value;                             //ÕûÐͲÎÊýÖµ£¬ÀýÈç0/1/2/3
+
+} __attribute__((packed))  ioctl_data;
+
+
+
+enum dev_opt_state {
+	DEV_UNOPT = 0,  //ÈôÓû§Î´×öÈκβÙ×÷£¬³õʼֵΪ0
+	DEV_NOPRESENT,  //¶ÔÓ¦!netif_device_presentÒì³££¬±íÃ÷Çý¶¯µ×²ãÉÐδ׼±¸ºÃ
+	DEV_OPENED,     //dev is opened
+	DEV_OPEN_FAIL,      //open  fail
+	DEV_CLOSED,      	//dev is closed
+};
+
+
+//ÍøÂçÌí¼Ó£¬Í³¼ÆÍøÂç²ãÃæÊÕ·¢°üÇé¿ö
+struct net_dev_skbinfo {
+	unsigned long	rx_packets;  //Çý¶¯·¢ËÍÀ´µÄÊý¾Ý°ü¸öÊý£¬ÔÚnetif_rxÍ·ÀÛ¼Ó
+	unsigned long	tx_packets;  //·¢Ë͸øÇý¶¯µÄÊý¾Ý°ü¸öÊý£¬ÔÚdev_queue_xmitÍ·ÀÛ¼Ó
+	unsigned long	rx_bytes;     //×Ö½ÚÊý
+	unsigned long	tx_bytes;     //×Ö½ÚÊý
+	unsigned long	rx_dropped; //netif_rxÄÚ²¿Á÷³ÌÖÐËùÓÐÒì³£ÊÍ·ÅskbµÄÀÛ¼Ó£¬Èç´ïµ½netdev_max_backlogÈë¶ÓÁÐÉÏÏÞ¶ø¶ª°ü
+	unsigned long	tx_dropped; //dev_queue_xmitÄÚ²¿Á÷³ÌÖÐËùÓÐÒì³£ÊÍ·ÅskbµÄÀÛ¼Ó£¬Èç(txq->xmit_lock_owner == cpu)Ôì³ÉµÄ¶ª°ü
+};
+
+/* ¸Ã½á¹¹ÌåÖеÄËùÓÐÐÅÏ¢½ÔÓÉÇý¶¯¸³Öµ£¬ÍøÂç×é²»»á¸³Öµ */
+//Õâ¸ö½á¹¹Ì屨ÐëºÍ <linux/netdevice.h>ÖеÄnet_device_stats±£³ÖÒ»ÖÂ
+struct net_dev_stats {
+	unsigned long    rx_packets;
+	unsigned long    tx_packets;
+	unsigned long    rx_bytes;
+	unsigned long    tx_bytes;
+	unsigned long    rx_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_dropped;   //Ðè¼à¿Ø
+	unsigned long    tx_dropped;   //Ðè¼à¿Ø
+	unsigned long    multicast;
+	unsigned long    collisions;
+	unsigned long    rx_length_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_over_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_crc_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_frame_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_fifo_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_missed_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_aborted_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_carrier_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_fifo_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_heartbeat_errors;   //Ðè¼à¿Ø
+	unsigned long    tx_window_errors;   //Ðè¼à¿Ø
+	unsigned long    rx_compressed;
+	unsigned long    tx_compressed;
+};
+enum netdev_queue_state {
+	__QUEUE_STATE_DRV_XOFF,
+	__QUEUE_STATE_STACK_XOFF,
+	__QUEUE_STATE_FROZEN,
+};
+
+struct dev_ioctl_info {
+	char dev_name[20];
+	struct net_dev_skbinfo  stats_dbg;  //ÍøÂçÌí¼ÓµÄ£¬Í³¼ÆÍøÂç²ãÃæÊÕ·¢°üÇé¿ö
+	struct net_dev_stats  skb_status;     //Êý¾ÝÊÕ·¢Í³¼ÆÖµ£¬¸Ãֵȫ²¿ÓÉÇý¶¯¸³ÖµµÄ£¬ÍøÂç²»¸³Öµ
+	unsigned int        flags;           //IFF_UPµÈ
+	unsigned char       operstate;    //ĿǰûɶÓÃ
+	unsigned long       state;           //µ×²ãÇý¶¯×´Ì¬£¬__LINK_STATE_NOCARRIER
+	int                 net_flag;        //Óû§ifconfigµÄ½á¹û״̬£¬ÈçDEV_OPEN_FAIL
+	unsigned long       que_state;       //¶ÓÁÐ״̬£¬¶ÔÓ¦ dev->_tx[0].state£¬Èç__QUEUE_STATE_DRV_XOFF
+	unsigned int        num_tx_queues;   //TX¶ÓÁÐÊýÁ¿£¬¶àÊýÇý¶¯Ê¹ÓÃΨһ¶ÓÁУ¬ÔòֵΪ1
+};
+
+//ÓëÄÚºËskb_using_msg ½á¹¹ÌåÒ»ÖÂ
+struct skb_ioctl_info {
+	unsigned long skb_all;
+	unsigned long skb_tocp;
+	unsigned long skb_fromcp;
+	unsigned long skb_data_num;
+	unsigned long skb_data_size;
+	unsigned long skb_stop;
+	unsigned long skb_lock;
+
+	unsigned long skb_panic;
+	unsigned long skb_fail;
+};
+
+struct skb_fast_ioctl_info {
+	int  skb_num4;               //½ÓÊÕµ½µÄV4Êý¾Ý°ü
+	int  skb_num6;               //½ÓÊÕµ½µÄV6Êý¾Ý°ü
+	int  skb_big_num;            //len³¤¶È³¬¹ý1000µÄÊý¾Ý°ü£¬º¬V4ºÍV6
+	int  skb_small_num;          //len³¤¶ÈСÓÚ100µÄÊý¾Ý°ü£¬º¬V4ºÍV6
+	int  skb_bytes4;             //½ÓÊÕµ½µÄV4Êý¾Ý°ü×Ö½ÚÊý
+	int  skb_bytes6;             //½ÓÊÕµ½µÄV6Êý¾Ý°ü×Ö½ÚÊý
+	int  skb_unknown;            //½ÓÊÕµ½µÄδ֪ЭÒéÊý¾Ý°ü£¬°üÀ¨ARPµÈ·ÇV4ºÍV6µÄ±¨ÎÄ
+	int  skb_tcpnum;             //½ÓÊÕµ½µÄtcpÊý¾Ý°ü£¬º¬V4ºÍV6£¬µ«²»º¬fastbrµÄ±¨ÎÄ
+	int  skb_udpnum;             //½ÓÊÕµ½µÄudpÊý¾Ý°ü£¬º¬V4ºÍV6£¬µ«²»º¬fastbrµÄ±¨ÎÄ
+	int  broadcast_num4;         //½ÓÊÕµ½µÄV4¹ã²¥°ü
+	int  broadcast_num6;         //½ÓÊÕµ½µÄV6¹ã²¥°ü
+	int  multicast_num4;         //½ÓÊÕµ½µÄV4×é²¥±¨
+	int  multicast_num6;         //½ÓÊÕµ½µÄV6×é²¥±¨
+	int  fastnat_num;            //fastnat³É¹¦µÄ±¨ÎÄ
+	int  fast6_num;              //fast6³É¹¦µÄ±¨ÎÄ
+	int  fastbr_num;             //fastbr³É¹¦µÄ±¨ÎÄ
+	int  fastnat_level;          //²Î¿´FAST_NET_DEVICE
+	int  fastbr_level;           //²¼¶ûÀàÐÍ
+	//ÏÂÃæ¼¸¸öֵΪÀÛ¼ÓÖµ£¬ÐÔÄÜÏà¹Ø
+	int  irqfree_num;            //ͨ¹ýÈíÖжÏÊͷŵÄskb£¬ÐÔÄÜÏà¹Ø
+	int  skbcopy_num;            //Êý¾Ý¿½±´µÄskb£¬ÐÔÄÜÏà¹Ø
+	int  cache_copy;             //net_cacheÔ´Îļþ½øÐп½±´µÄÀÛ»ý¼ÆÊý£¬ÐÔÄÜÏà¹Ø
+	int  skbflood_num;           //·ººéµÄskb£¬ÐÔÄÜÏà¹Ø
+	int  errfree_num;            //devÔ´ÎļþÖдíÎóÊͷŵÄskb¼ÆÊý£¬°üÀ¨SKB_QUEUE_STOPºÍSKB_QUEUE_LOCKÁ½¸ö¼ÆÊýÖµ
+	int  frag_num;               //½ÓÊÕµ½µÄ·ÖƬ±¨ÎÄ£¬ÐÔÄÜÏà¹Ø
+	int  mtu_num;                //fastÖÐÊý¾Ý³¤¶È´óÓÚ³ö¿Údev MTUʱ£¬fastʧ°Ü¸öÊýͳ¼Æ
+	int  fast_loop;              //ͶµÝ¸øÇý¶¯£¬ÓÖ´ÓÇý¶¯ÊÕµ½µÄÒì³£»Ø»·¸öÊýͳ¼Æ
+	int  skb_alloc_fail ;        //ÉêÇëskbʧ°ÜµÄ¸öÊýÀÛ¼ÓÖµ
+	int  xmit_lock_num;          //xmit_lock_owner±»Ëø×¡Ôì³ÉµÄ¶ª°üµÄÀÛ¼Ó¼ÆÊý£¬Çý¶¯Ôì³ÉµÄ
+	int  xmit_stop_num;          //!netif_xmit_stopped(txq)Ôì³ÉµÄ¶ª°üµÄÀÛ¼Ó¼ÆÊý£¬Çý¶¯Ôì³ÉµÄ
+	int  br_mac_change_num;      //ÍøÇÅmacµØÖ·±»¸Ä±ä´ÎÊý
+	int  fast_tcpdump_num;       //fast×¥°üÊý
+	int  fast_switch;            //fast×Ó¹¦ÄÜλͼ¿ª¹Ø
+	int  fast_local4_rcv_num;    //±¾µØfast_local4³É¹¦½ÓÊÕ±¨ÎÄ
+	int  fast_local6_rcv_num;    //±¾µØfast_local6³É¹¦½ÓÊÕ±¨ÎÄ
+	int  fast_local4_output_num; //±¾µØfast_local4³É¹¦·¢Ëͱ¨ÎÄ
+	int  fast_local6_output_num; //±¾µØfast_local6³É¹¦·¢Ëͱ¨ÎÄ
+};
+
+#define SLAB_NUM  21
+enum slabinfo_file {
+	SKB_SLAB = 0,
+	BRFDB_SLAB,
+	DST_SLAB,
+	FIB_TRIE_SLAB,
+	FLOW_SLAB,
+	INETPEER_SLAB,
+	INET_HASHTABLES_SLAB,
+	INET_TIMEWAIT_SOCK_SLAB,
+	MYSOCKET_SLAB,
+	NF_CONNTRACK_CORE_SLAB,
+	NF_CONNTRACK_EXCEPT_SLAB,
+	REQUEST_SOCK_SLAB,
+	SOCK_SLAB,
+	SOCKET_SLAB,
+	XFRM6_TUNNEL_SLAB,
+	XT_HASHLIMIT_SLAB,
+	SOCK_ALLOC_PAGES,
+	IP6_OUTPUT_ALLOC_PAGES,
+	IP_OUTPUT_ALLOC_PAGES,
+	SKB_ALLOC_PAGES,
+};
+
+struct slab_info {
+	int num[SLAB_NUM][2];
+};
+
+#define HASH_ARRAY_COUNT 512
+struct hash_info {
+	int max_hash_size;
+	int current_hash_num;
+	int hash[HASH_ARRAY_COUNT][2];
+	int current_array_size;
+};
+
+struct neigh_info {
+	unsigned int ip_len;          //IPµØÖ·³¤¶È£¬Çø·ÖV4ºÍV6
+	unsigned char ip_addr[IPV4ADDLEN_MAX];
+	unsigned char mac_addr[MAX_MACADDR_LEN];
+};
+
+#define MAX_NEIGH_NUM           20
+struct dev_neigh_info {
+	unsigned int num;
+	struct neigh_info neigh_nod[MAX_NEIGH_NUM];
+};
+
+enum dev_layer {
+	L3_DEV = 0,  //²ã3É豸
+	BR_DEV,  //ÍøÇŵÄL3ÌØÊâÉ豸
+	L2_DEV,     //L2²ãÉ豸
+};
+
+enum {
+	LOCAL_L3DEV = 0,
+	LOCAL_BR_PORT,
+	NEIGH_AND_DSTDEV,
+	DEV_STATISTIC,
+};
+
+enum IFMAC_ERR {
+	ZERO_ADDRERR = 1,
+	MULTICAST_ADDRERR,
+	BROADCAST_ADDRERR,
+};
+
+/*add by jiangjing*/
+struct dev_and_neigh {
+	char name[20];
+	unsigned char  dev_layer;   //ָʾ¸Ã±¾µØÍø¿ÚµÄЭÒé²ã£¬²Î¼ûºêÖµL3_DEV
+	/*MACµØÖ·,IPv4µØÖ·*/
+	unsigned char		mac_addr[20];  //±¾µØÍø¿ÚµØÖ·
+	unsigned int		ipv4_addr;        //±¾µØÍø¿ÚIPµØÖ·
+	struct dev_neigh_info  dev_neigh;  //¸Ã±¾µØÍø¿ÚЯ´øµÄÔ¶³ÌÁÚ¾ÓµØÖ·ÐÅÏ¢Êý×é
+	int mac_errtype;
+};
+#define MAX_DEV_NUM   30
+/*Íø¿ÚÏà¹ØµÄÐÅÏ¢*/
+struct devlist_ioctl_info {
+	unsigned int num;        //±¾µØÓÐÐ§Íø¿ÚµÄ¸öÊý
+	struct dev_and_neigh info[MAX_DEV_NUM];  //±¾µØÓÐÐ§Íø¿ÚµÄ¾ßÌåÐÅÏ¢²ÎÊý
+};
+
+/****×ÊԴʹÓü°ÉÏÏÞÐÅÏ¢£¬ËùÓбê×¼ÄÚºËÓÐÉÏÏÞÇé¿öµÄ£¬½ÔÐè¼ì²â£¬ÒÔ·ÀÖ¹Òì³£·¢Éú****/
+struct net_max_check_msg {
+	/*nf_conntrack*/
+	unsigned long nf_conntrack_max;        //nf_conntrack_max = 4832
+	unsigned long nf_conntrack_now;        //net->ct.count
+	/*enqueue*/
+	int          netdev_max_backlog;       //netdev_max_backlog=1000
+	int          input_queue_len;          //²Î¿´enqueue_to_backlog½Ó¿ÚʵÏÖ
+	int          rx_dropped;                 //ÒòΪÈë¶ÓÁÐÒÑÂúÔì³ÉµÄÈë¶ÓÁжª°üµÄÀÛ¼ÓÖµ
+	/*ÐÔÄÜÏà¹Ø*/
+	int          fastnat_link_max;         //nf_conntrack_max
+	int          fastnat_link_now;         //working_list.count
+	int          fast6_link_max;           //nf_conntrack_max
+	int          fast6_link_now;           //working_list6.count
+	/*ÍøÂçÄÚºËÔËÐÐʱµÄͳ¼ÆÖµ£¬ÖØµã¹Ø×¢½á¹¹ÌåµÄÉêÇëµã*/
+	unsigned long br_mac_change;		  //ÍøÇÅmacµØÖ·±»¸Ä±ä´ÎÊý
+	unsigned long neigh_alloc;				   //neighbourÉêÇë´ÎÊý
+	unsigned long neigh_free;					  //neighbourÊͷŵãÀÛ¼ÓÖµ
+	unsigned long br_neigh_vary;				//ÇŵãµÄ³ö¿ÚdevµÄmacµØÖ·±»¶à¸öpc¹²Ïí
+	unsigned long conn_alloc;					//connÉêÇë´ÎÊýÀÛ¼ÓÖµ
+	unsigned long conn_free;						  //connÊͷŵãÀÛ¼ÓÖµ
+	unsigned long brfdb_alloc; 				   //ÇŵãÉêÇë´ÎÊýÀÛ¼ÓÖµ
+	unsigned long dst_alloc;						  //dst_entryÉêÇëÀÛ¼ÓÖµ
+	unsigned long dst_free;							//dst_entryÊͷŵãÀÛ¼ÓÖµ
+	unsigned long hh_update;						  //hh¶þ²ãmacÍ·¸üÐÂÀÛ¼ÓÖµ
+	unsigned long rt_cache_invalid;         			      //Çå¿Õ·ÓÉcacheµÄÀÛ¼ÓÖµ
+	unsigned long rt_hash_add; 					   //ÐÂÔört_hash_table½ÚµãµÄÀÛ¼ÓÖµ
+	unsigned long rt_hash_del; 					   //ɾ³ýrt_hash_table½ÚµãµÄÀÛ¼ÓÖµ
+	unsigned long ssmac_change_indev;	   	//ͬһԴMACµØÖ·Èë¿Údev¸Ä±äµÄ´ÎÊý
+};
+
+struct ptype_info {
+	unsigned long ptype_all[5];
+	unsigned long ptype_base[15];
+};
+
+
+struct pkt_lost_stats {
+	unsigned int send_drops;
+	unsigned int send_drop_bytes;
+	unsigned int recv_drops;
+	unsigned int recv_drop_bytes;
+	unsigned int total_packets;
+	unsigned int total_bytes;
+};
+
+struct pkt_lost_info {
+	struct pkt_lost_stats stats[2];  /*0:origin·½Ïò£¬1:reply·½Ïò*/
+};
+
+
+struct tcp_sock_stat {
+	unsigned long tcp_recv_num;
+	unsigned long tcp_send_num;
+	unsigned long tcp_retrans_num;
+	unsigned long tcp_recv_drops;
+	unsigned long tcp_send_drops;
+	unsigned long tcp_rst_send;
+	unsigned long tcp_rst_recv;
+};
+
+
+//½Ó¿ÚÉùÃ÷
+extern int netioctl_handle(int cmd, void *val);
+
+#endif //end _ZXIC_IOCTL_H_
+
diff --git a/ap/app/include/netotherapi.h b/ap/app/include/netotherapi.h
new file mode 100755
index 0000000..4df92ef
--- /dev/null
+++ b/ap/app/include/netotherapi.h
@@ -0,0 +1,250 @@
+/**
+* @file netotherapi.h
+* @brief Public APIs of Sanechips , linux network external interface
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author  Linxu Gebin
+* @defgroup si_id Sanechips
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*************************************************************************
+*/
+
+#ifndef __NETOTHERAPI_H__
+#define __NETOTHERAPI_H__
+#include "zxic_list.h"
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+******************************************************************************/
+
+#define WAKE_LOCK_PATH                  "/sys/power/wake_lock"
+#define WAKE_UNLOCK_PATH                "/sys/power/wake_unlock"
+
+
+
+#define PROC_IF_STATISTIC	"/proc/net/dev"
+#define TXBYTE		0       //·¢ËÍÊý¾Ý
+#define TXPACKET	1
+#define RXBYTE		2       //½ÓÊÕÊý¾Ý
+#define RXPACKET	3
+
+#define  PC_MAX_NUM  100
+#define     DEV_NAME_LEN 50
+#define TIMER_GETHOSTBYNAME_ID  62
+
+#define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)
+
+/* Used to retry syscalls that can return EINTR. */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) ({           \
+	typeof (exp) _rc;                        \
+	do{                                      \
+		_rc = (exp);                         \
+	}while((_rc == -1) && (errno == EINTR)); \
+	_rc; })
+#endif
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+struct pc_info {
+	unsigned char mac_addr[6];
+	char  dev_name[DEV_NAME_LEN];
+};
+struct pc_node {
+	unsigned int num;
+	struct pc_info info[PC_MAX_NUM];
+};
+
+
+/**
+* @brief ÄÚÍøÐÅÏ¢
+* @param mac mac µØÖ·
+* @param ip ip µØÖ·
+* @param hostname Ö÷»úÃû
+* @param dev_name É豸Ãû
+* @param time_remain µ±Ç°Ê±¼äµ½ÉÏÒ»¸üиÃÉ豸ÐÅÏ¢¼ä¸ôʱ¼ä
+* @param time_last  ×î½üÒ»´Î¸üÐÂʱ¼äµã
+* @note ÎÞ
+*/
+typedef struct LAN_INFO {
+	unsigned char mac[6];
+	unsigned long ip;
+	char host_name[32];
+	char dev_name[32];
+	unsigned long time_remain;
+	unsigned long time_last;
+} LAN_INFO_t;
+
+/**
+* @brief ÄÚÍøÐÅÏ¢Á´±í
+* @param list_head Á´±íÍ·½Úµã
+* @param lan_info lÄÚÍøÐÄÏ¢
+* @note ÎÞ
+*/
+typedef struct LAN_INFO_LIST {
+	struct list_head  list;
+	LAN_INFO_t  lan_info;
+} LAN_INFO_LIST_t;
+
+/**
+* @brief dhcp server´æ´¢µÄleaseÎļþ½á¹¹Ìå
+* @param expires expires
+* @param ip ip µØÖ·
+* @param mac mac µØÖ·
+* @param host_nameÖ÷»úÃû
+* @param pad
+*/
+typedef struct _DHCPOFFERADDRNET {
+	unsigned long expires;
+	unsigned long ip;
+	unsigned char mac[6];
+	unsigned char host_name[20];
+	unsigned char pad[2];
+} DHCPOFFERADDRNET;
+
+/**
+* @brief dhcp ÐÅÏ¢Á´±í
+* @param list Á´±íÍ·½Úµã
+* @param dhcp_info dhcp ÐÅÏ¢
+*/
+typedef struct _DHCPOFFERADDR_LIST {
+	struct list_head  list;
+	DHCPOFFERADDRNET  dhcp_info;
+} DHCPOFFERADDR_LIST_t;
+/**
+* @brief dhcp gethostbynameÐÅÏ¢
+* @param time ³¬Ê±Ê±¼ä£¬µ¥Î»ÎªºÁÃë
+* @param ¶ÓÁкÅ
+*/
+struct gethostbyname_info{
+	int time;
+	char name[HOSTNAME_LEN];
+	int msg_id;
+};
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+
+/**
+* @brief ´Ódhcpd.leasesÎļþÖлñÈ¡dhcpÐÅÏ¢
+* @param dhcp_list_info dhcp ÐÅÏ¢Á´±í
+* @return ³É¹¦ ·µ»Ø 0, ʧ°Ü·µ»Ø-1
+*/
+int  zte_get_mac_list_from_lease(struct list_head *dhcp_list_info);
+
+/**
+* @brief É豸ÐÅÏ¢
+* @param mypc_node  É豸ÐÅÏ¢Á´±í
+* @param info	information
+* @return ³É¹¦ ·µ»Ø 0, ʧ°Ü·µ»Ø-1
+*/
+int get_dev_list(struct pc_node* mypc_node);
+
+/**
+* @brief ±£´æÐÅÏ¢µ½Îļþ
+* @param filename ÎļþÃû
+* @param info ÐèÒª±£´æµÄÐÅÏ¢
+* @return ÎÞ
+*/
+void save_file(char *filename, char* info);
+
+/**
+* @brief дÐÅÏ¢µ½Îļþ
+* @param filename ÎļþÃû
+* @param info ÐèҪдµÄÐÅÏ¢
+* @return ÎÞ
+*/
+void file_write(char *filename, char *info);
+
+/**
+* @brief  ÊÍ·ÅdhcpÐÅÏ¢Á´±í
+* @param dhcp_info_list	dhcpÁ´±íÍ·½áµã
+* @return ÎÞ
+*/
+void  free_dhcp_list(struct list_head * dhcp_info_list);
+
+/**
+* @brief  ÊÍ·ÅÄÚÍøÐÅÏ¢Á´±í
+* @param dhcp_info_list	ÄÚÍøÐÅÏ¢Á´±íÍ·½áµã
+* @return ÎÞ
+*/
+void  free_laninfo_list(struct list_head * dhcp_info_list);
+
+/**
+* @brief »ñÈ¡É豸ÐÅÏ¢
+* @param interface ÍøÂçÉ豸Ãû
+* @param type	Êý¾ÝÀàÐÍ
+* @return  ³É¹¦·µ»Ø0£¬Ê§°Ü·Å»Ø-1
+*/
+int getIfStatistic(char *interface, int type, unsigned long long *result_data);
+
+/**
+ * @brief  »ñÈ¡wakelockËø
+ * @param lockId wakelockËøID
+ * @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1£»
+ */
+int set_wake_lock(const char *lockId);
+
+/**
+ * @brief  »ñÈ¡wakelock³¬Ê±Ëø
+ * @param lockId wakelockËøID
+ * @param interval ³¬Ê±Ê±¼ä£¬µ¥Î»: Ãë
+ * @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1£»
+ */
+int set_wake_lock_timeout(const char *lockId, unsigned long interval);
+
+/**
+ * @brief  ÊÍ·ÅwakelockËø
+ * @param lockId wakelockËøID
+ * @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1£»
+ */
+int set_wake_unlock(const char *lockId);
+
+
+int get_lan_info_list(struct list_head *file_list_info);
+
+/**
+ * @brief  ÉêÇëÄÚ´æ
+ * @param size ÉêÇëÄÚ´æ´óС
+ * @param is_assert£¬ÉêÇëʧ°ÜÊÇ·ñassert
+ * @return ÉêÇë³É¹¦·µ»ØÉêÇëÄÚ´æµØÖ·£»Ê§°Ü·µ»ØNULL
+ */
+void *safe_malloc(int size, BOOL is_assert);
+
+unsigned long time_sec();
+
+
+/**
+* @brief  »ñȡָ¶¨Ïß³ÌÃûµÄpidºÅ
+* @param pidNameΪ½ø³ÌÃû
+* @return  ³É¹¦·µ»Ø½ø³ÌºÅpid_tÀàÐÍÖ¸Õë
+* @note µ÷Óøú¯Êý»ñÈ¡·µ»ØÖµ£¬Ê¹ÓúóÒ»¶¨ÒªÊͷŸÃÄÚ´æ¿Õ¼ä
+*/
+pid_t* find_pid_by_name(char *pidName);
+
+/**
+* @brief ¾ßÓг¬Ê±´¦ÀíµÄgethostbyname
+* @param name url
+* @param time ³¬Ê±Ê±³¤,µ¥Î»:Ãë, 0¾ÍÊDZê×¼µÄgethostbyname¹¦ÄÜ
+* @return hostÐÅÏ¢
+* @Note: ͬһ½ø³ÌͬʱֻÄܵ÷ÓÃÒ»´Î¸Ã½Ó¿Ú
+*/
+struct hostent *gethostbyname_t(const char *name, int time);
+
+/**
+* @±¾µØ¼¤»î»ñÈ¡dns½Ó¿Ú£¬²»ÒÀÀµÂ·ÓÉ£¬·µ»ØÖµÎªu32ÀàÐÍipµØÖ·
+*/
+unsigned long gethostbyname_l(char *hostname,char* dev_name);
+
+#endif
+
+#endif /* __NETOTHERAPI_H__ */
diff --git a/ap/app/include/os_type_def.h b/ap/app/include/os_type_def.h
new file mode 100755
index 0000000..d21f2f2
--- /dev/null
+++ b/ap/app/include/os_type_def.h
@@ -0,0 +1,117 @@
+/**************************************************************************
+*
+*                  Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : Atserver
+* ÎÄ ¼þ Ãû : ufi_oss.h
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : uFiƽ̨²Ù×÷ϵͳÀàÐͶ¨Òå¼°º¯ÊýÉùÃ÷
+* ×÷    Õß : Ê©êÉ10129223
+* °æ    ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-04-16
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ :
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+#ifndef _OS_TYPE_DEF_H_
+#define _OS_TYPE_DEF_H_
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <time.h>
+#include <sys/msg.h>
+
+/**************************************************************************
+* ¸÷ÖÖÊý¾ÝÀàÐÍÊÊÅäÇø
+**************************************************************************/
+#define ZUFI_NULL     NULL
+#ifndef TRUE
+#define TRUE          1
+#endif
+#ifndef FALSE
+#define FALSE         0
+#endif
+#define ZUFI_SUCC     1
+#define ZUFI_FAIL     0
+#ifndef CHAR
+#define CHAR          char
+#endif
+#ifndef SHORT
+#define SHORT 	  	short
+#endif
+#ifndef INT
+#define INT 	  	int
+#endif
+#ifndef UINT
+#define UINT 	  	unsigned int
+#endif
+#ifndef LONG
+#define LONG 	  	long
+#endif
+#ifndef UCHAR
+#define UCHAR 	  	unsigned char
+#endif
+#ifndef USHORT
+#define USHORT 	  	unsigned short
+#endif
+#ifndef ULONG
+#define ULONG 	  	unsigned long
+#endif
+#ifndef BOOL
+#define BOOL 	  	unsigned char
+#endif
+#ifndef NULL
+#define NULL 	  	0
+#endif
+
+typedef signed char         SINT8;
+typedef unsigned char       UINT8;
+typedef signed short        SINT16;
+typedef unsigned short      UINT16;
+typedef signed long         SINT32;
+typedef unsigned long       UINT32;
+#ifndef VOID
+typedef void                VOID;
+#endif
+typedef char                *PSTR;
+typedef unsigned char       *PBYTE;
+typedef unsigned short      *PWORD;
+typedef unsigned long       *PDWORD;
+typedef void                *PVOID;
+typedef unsigned long       *PHANDLE;
+typedef UINT8               BYTE;
+typedef UINT32              u32;
+
+
+
+
+
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+
+/**************************************************************************
+* º¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿ÉùÃ÷Çø
+**************************************************************************/
+
+#endif
+
diff --git a/ap/app/include/other_msg.h b/ap/app/include/other_msg.h
new file mode 100755
index 0000000..5c29d84
--- /dev/null
+++ b/ap/app/include/other_msg.h
@@ -0,0 +1,285 @@
+/**
+ * @file other_msg.h
+ * @brief ÌṩÁËÆ½Ì¨ÄÚ²¿Ð¡Ä£¿éµÄÏûÏ¢ID£¬ÈçDM¡¢FOTA¡¢SNTPµÈ£¬at_ctl¡¢mainctlÕâÁ½¸ö×î»ù±¾µÄ¹¦ÄܵÄÏûÏ¢IDÑϽûÔڴ˶¨Òå
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __OTHER_MSG_H__
+#define __OTHER_MSG_H__
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include"message.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+
+/**
+ * @brief
+ */
+enum other_msg_cmd {
+
+	MSG_CMD_EMBMS_CTRL_CLOSE_SOCKET = MSG_CMD_OTHER_BASE,
+	MSG_CMD_LINKUP_END,    //zte_mainctrlÖ´ÐÐlinkup½Å±¾ºó£¬·¢ËÍÏûÏ¢¸øat_ctl
+	MSG_CMD_LINKDOWN_END,  //zte_mainctrlÖ´ÐÐlinkdown½Å±¾ºó£¬·¢ËÍÏûÏ¢¸øat_ctl
+	//MSG_CMD_V6ADDR_IND,//¶ÔÓ¦½á¹¹ÌåV6ADDR_INFORM£¬IPv6 PDP¼¤»îʱ£¬slaac»ñÈ¡µ½ipv6µØÖ·³É¹¦»òʧ°Üºó£¬·¢ËÍÏûÏ¢¸øat_ctl
+	MSG_CMD_DATA_START,  //Á÷Á¿Í³¼Æ
+	MSG_CMD_DATA_END,     //Á÷Á¿Í³¼Æ
+	MSG_CMD_PARENT_CONTROL_SET, //ÉèÖüҳ¤¿ØÖÆ
+	MSG_CMD_PARENT_CONTROL_CLOSE,                // ¹Ø±Õ¼Ò³¤¿ØÖÆ
+	MSG_CMD_SOFTTIMER_CREATE,
+	MSG_CMD_SOFTTIMER_DELETE,
+	MSG_CMD_SOFTTIMER_TIMEOUT,
+	MSG_CMD_LOCALUPDATE_START,
+	MSG_CMD_LOCALUPDATE_GET_RESULT,
+	MSG_CMD_SNTP_SET_MODE,                  //ÉèÖÃSNTPģʽ: ÊÖ¶¯¡¢×Ô¶¯
+	MSG_CMD_SNTP_SET_TIME,                  //ÉèÖÃSNTPʱ¼ä
+	MSG_CMD_SNTP_START,
+	MSG_CMD_SNTP_REGISTER, //ÐèҪ׼ȷʱ¼äµÄÓ¦ÓÃÏòsntp×¢²á
+	MSG_CMD_SNTP_UNREGISTER,
+	MSG_CMD_SNTP_SUCCESS,
+
+	/*¿ìËÙ¿ª»ú/¹Ø»ú֪ͨÏûÏ¢£¬Ã¶¾Ù¶ÔÓ¦¶Ë¿Ú*/
+	MSG_CMD_FASTPOWER_IND,
+	/*Ä£ÄâUSB²åÈë/°Î³ö*/
+	MSG_CMD_USBMOD_SETREQ,
+
+	//ÒÔÏÂΪоƬÈÏÖ¤ÏûÏ¢
+	MSG_CMD_SEND_ATCMD_STREAM_REQ,
+	MSG_CMD_SEND_ATCMD_STREAM_RSP,
+
+	/****************************ISMS*******************************/
+	MSG_CMD_ISMSSTART_REQ,	              //Æô¶¯ÖÇÄܶÌÐŽø³Ì
+	MSG_CMD_ISMSREADY_RSP,              	//ÖÇÄܶÌÐÅÆô¶¯Íê³É֪ͨ
+	MSG_CMD_ISMSINFO_REQ,                   //ÖÇÄܶÌÐŲéѯÇëÇó
+	MSG_CMD_ISMSDEL_REQ,                    //ɾ³ýÖ¸¶¨ÖÇÄܶÌÐÅÇëÇó
+	MSG_CMD_ISMSCLEAN_REQ,                  //Çå³ýÈ«²¿ÖÇÄܶÌÐÅÇëÇó
+	MSG_CMD_ISMSINFO_RSP,                  //ÖØÖÃÖÇÄܶÌÐÅÇëÇó(ÓëÇå³ý²Ù×÷Ò»Ñù)
+	MSG_CMD_ISMSUD_REQ,                     // ÉÏ´«ÖÕ¶ËÐÅÏ¢µÄÇëÇó
+
+	/***************************DM*********************************/
+	MSG_CMD_DM_CONFIG_REQ,                  //ÉèÖÃdm²¿·Ö¿ØÖÆÐÅÏ¢
+
+	/*************************ÊØ»¤±¦SAFECARE*************************/
+	MSG_CMD_SAFECARE_ONOFF_REQ,             //¿ªÆô»ò¹Ø±ÕÊØ»¤±¦¹¦ÄÜÇëÇó
+	MSG_CMD_SAFECARE_ONOFF_RSP,             //¿ªÆô»ò¹Ø±ÕÊØ»¤±¦¹¦ÄÜÏìÓ¦
+	MSG_CMD_SAFECARE_ACCOUNT_REQ,           //¿ª»§ÇëÇó
+	MSG_CMD_SAFECARE_ACCOUNT_RSP,           //¿ª»§ÏìÓ¦
+	MSG_CMD_SAFECARE_MOBSITE_REQ,           //·þÎñЭÒ鵨ַÇëÇó
+	MSG_CMD_SAFECARE_MOBSITE_RSP,           //·þÎñЭÒ鵨ַÏìÓ¦
+	MSG_CMD_SAFECARE_PLATLOCATION_REQ,      //ƽ̨¶¨Î»ÇëÇó
+	MSG_CMD_SAFECARE_PLATLOCATION_RSP,      //ƽ̨¶¨Î»ÏìÓ¦
+	MSG_CMD_SAFECARE_PERIOD_LOCATION_REQ,   //ÖÜÆÚ¶¨Î»ÇëÇó
+	MSG_CMD_SAFECARE_PERIOD_LOCATION_RSP,   //ÖÜÆÚ¶¨Î»ÏìÓ¦
+	MSG_CMD_SAFECARE_SMSNUM_REQ,            //ÉÏÐжÌÐźÅÂë»ñÈ¡ÇëÇó
+	MSG_CMD_SAFECARE_SMSNUM_RSP,            //ÉÏÐжÌÐźÅÂë»ñÈ¡ÏìÓ¦
+	MSG_CMD_SAFECARE_LOCATION_REQ,          //¶¨Î»ÇëÇó
+	MSG_CMD_SAFECARE_LOCATION_RSP,          //¶¨Î»ÏìÓ¦
+
+	MSG_CMD_SAFECARE_DATAUPDATE_REQ,        //¸üÐÂÈ«¾ÖÊý¾ÝÇëÇó
+	MSG_CMD_SAFECARE_DATAUPDATE_RSP,        //¸üÐÂÈ«¾ÖÊý¾ÝÏìÓ¦
+
+	MSG_CMD_SAFECARE_SOS_LOCATION_REQ,      //SOS¶¨Î»ÇëÇó
+	MSG_CMD_SAFECARE_SOS_LOCATION_RSP,      //SOS¶¨Î»ÏìÓ¦
+
+	MSG_CMD_SAFECARE_SENDKHSMS_REQ,         //ÇëÇó·¢ËÍ¿ª»§¶ÌÐÅ
+
+	MSG_CMD_SAFECARE_POWER_ONOFF_REQ,       //¿ªÆô»ò¹Ø±ÕÖÕ¶ËÇëÇó
+	MSG_CMD_SAFECARE_POWER_ONOFF_RSP,       //¿ªÆô»ò¹Ø±ÕÖÕ¶ËÏìÓ¦
+
+	/*K318 T¿¨Çл»Ê¹ÓõÄÏûÏ¢begin*/
+	MSG_CMD_UDISKSTAT_SET_REQ,             //ÉèÖÃÇëÇóÃüÁÇл»³ÉUÅÌģʽ/½ö³äµçģʽ
+	MSG_CMD_UDISKSTAT_SET_RSP,             //ÉèÖÃÃüÁîµÄ»Ø¸´£¬Çл»³ÉUÅÌģʽ/½ö³äµçģʽ
+	MSG_CMD_USBFLAG_STAT_REQ,              //²åÈë/°Î³öUSBÏßµÄ֪ͨÏûÏ¢
+	/*K318 T¿¨Çл»Ê¹ÓõÄÏûÏ¢end*/
+
+	/******************fotaÏà¹Ø*************************/
+	MSG_CMD_FOTAMANUAL_REQ,
+	MSG_CMD_FOTADL_REQ,
+	MSG_CMD_FOTADY_REQ,
+	MSG_CMD_FOTAVERSION_IND,
+	MSG_CMD_FOTAPKG_IND,
+	MSG_CMD_FOTARLT_IND,
+	MSG_CMD_FOTADLRESUME_IND,
+	MSG_CMD_FOTAUPRESUME_IND,
+
+	/******************fotaÏà¹Ø*************************/
+
+	MSG_GET_HOST_BY_NAME_SUCCESS, //»ñÈ¡hostÐÅÏ¢³É¹¦
+	MSG_GET_HOST_BY_NAME_TIMEOUT, //gehostbynameÐÅÏ¢³¬Ê±
+	
+	/*************************¹Ì¶¨Ì¨WiFi*************************/
+	MSG_CMD_WIFI_GET_STATE_REQ,				//»ñÈ¡WiFi״̬(¿ª¹Ø)ÇëÇó
+	MSG_CMD_WIFI_GET_STATE_RSP,				//»ñÈ¡WiFi״̬(¿ª¹Ø)»ØÓ¦
+	MSG_CMD_WIFI_GET_INFO_REQ,				//»ñÈ¡WiFiÐÅÏ¢(SSID¡¢ÃÜÂë¡¢°²È«Ä£Ê½)ÇëÇó
+	MSG_CMD_WIFI_GET_INFO_RSP,				//»ñÈ¡WiFiÐÅÏ¢(SSID¡¢ÃÜÂë¡¢°²È«Ä£Ê½)»ØÓ¦
+	MSG_CMD_WIFI_GET_USER_LIST_REQ,			//»ñÈ¡WiFiÓû§ÁбíÇëÇó
+	MSG_CMD_WIFI_GET_USER_LIST_RSP,			//»ñÈ¡WiFiÓû§ÁÐ±í»ØÓ¦
+	
+	MSG_CMD_WIFI_SET_ON_REQ,				//´ò¿ªWiFiÇåÇó
+	MSG_CMD_WIFI_SET_ON_RSP,				//´ò¿ªWiFi»ØÓ¦
+	MSG_CMD_WIFI_SET_OFF_REQ,				//¹Ø±ÕWiFiÇåÇó
+	MSG_CMD_WIFI_SET_OFF_RSP,				//¹Ø±ÕWiFi»ØÓ¦
+	MSG_CMD_WIFI_SET_SECURITY_REQ,			//ÉèÖÃWiFi°²È«Ä£Ê½¡¢SSID¡¢ÃÜÂëÇëÇó
+	MSG_CMD_WIFI_SET_SECURITY_RSP,			//ÉèÖÃWiFi°²È«Ä£Ê½¡¢SSID¡¢ÃÜÂë»ØÓ¦
+	MSG_CMD_WIFI_NOTIFY_CHARGER_STATUS,
+	MSG_CMD_WIFI_IS_READY,
+
+	/*************************¹Ì¶¨Ì¨Á÷Á¿¹ÜÀí*************************/
+	MSG_CMD_DATAMANAGER_SET_SWITCH_REQ,		 //ÉèÖÃÁ÷Á¿¹ÜÀí¿ª¹Ø´ò¿ªÇëÇó
+	MSG_CMD_DATAMANAGER_SET_SWITCH_RSP,     //ÉèÖÃÁ÷Á¿¹ÜÀí¿ª¹Ø´ò¿ª»ØÓ¦
+	MSG_CMD_DATAMANAGER_GET_INFO_REQ,		//»ñÈ¡ÒÑʹÓÃÁ÷Á¿¡¢×ÜÁ÷Á¿¡¢¸æ¾¯ÖµÇëÇó
+	MSG_CMD_DATAMANAGER_GET_INFO_RSP,		//»ñÈ¡ÒÑʹÓÃÁ÷Á¿¡¢×ÜÁ÷Á¿¡¢¸æ¾¯Öµ»ØÓ¦
+	MSG_CMD_DATAMANAGER_SET_TOTAL_REQ,		//ÉèÖÃ×ÜÁ÷Á¿ÇëÇó
+	MSG_CMD_DATAMANAGER_SET_TOTAL_RSP,		//ÉèÖÃ×ÜÁ÷Á¿»ØÓ¦
+	MSG_CMD_DATAMANAGER_SET_WARNVALUE_REQ,	//ÉèÖÃÁ÷Á¿¸æ¾¯ÖµÇëÇó
+	MSG_CMD_DATAMANAGER_SET_WARNVALUE_RSP,	//ÉèÖÃÁ÷Á¿¸æ¾¯Öµ»ØÓ¦
+	MSG_CMD_DATAMANAGER_REACH_WARNVALUE,	//Á÷Á¿Ê¹Óôﵽ×ÜÁ¿
+	MSG_CMD_DATAMANAGER_REACH_LIMIT,		//Á÷Á¿Ê¹Óôﵽ×ÜÁ¿
+	MSG_CMD_DATAMANAGER_FLUXSTAT_READY,		//Á÷Á¿Ä£¿éÆô¶¯Íê³É
+	MSG_CMD_PDPSTATUS_SET_SWITCH_REQ,       //ÉèÖÃÍøÂçÁ¬½Ó¿ª¹ØÍ¨Öª
+	MSG_CMD_PDPSTATUS_SET_SWITCH_RSP,       //ÉèÖÃÍøÂçÁ¬½Ó¿ª¹ØÏìÓ¦
+    /*BIPÏà¹Ø,BIPÄÚ²¿×Ô¼ºÊÕ·¢µÄÏûÏ¢*/
+    MSG_CMD_ID_BIP_AT_RCV, 
+    /*ËøÍøÏà¹ØµÄÏûÏ¢*/
+	MSG_CMD_LOCKLISTAUTH_REQ,
+	MSG_CMD_LOCKNETLIST_SET_REQ,
+	MSG_CMD_LOCKNETKEY_REQ,
+	MSG_CMD_LOCKNETAMTSTATUS_GET_REQ,
+	MSG_CMD_LOCKNETDIGEST_GET_REQ,
+	MSG_CMD_LOCKNETSIGN_SET_REQ,
+	MSG_CMD_LOCKNETLEVEL_GET_REQ,
+	MSG_CMD_LOCKNETLIST_GET_REQ,
+	MSG_CMD_LOCKNETAUTH_REQ,
+	MSG_CMD_LOCKNETUNLOCKTIMES_GET_REQ,
+	MSG_CMD_LOCKNETSTATUS_GET_REQ,
+	MSG_CMD_LOCKNETUNLOCK_REQ,
+	MSG_CMD_ZURDY_LOCKAUTH_REQ,
+};
+
+/**
+ * @brief DMÄ£¿é½ÓÊÕÏûÏ¢µÄÀàÐÍ
+ */
+enum dm_msg_cmd {
+	MSG_CMD_DMREG_INFO = MSG_CMD_DM_BASE,
+	MSG_CMD_DMREG_FLAG,
+	MSG_CMD_SEND_REGMSG
+};
+
+/**
+ * @brief FOTAÄ£¿é½ÓÊÕÏûÏ¢µÄÀàÐÍ
+ */
+typedef enum {
+
+	MSG_CMD_FOTA_DM_EVENT_START = MSG_CMD_FOTA_BASE,
+	MSG_CMD_FOTA_DM_CI_POLLING,
+	MSG_CMD_FOTA_DM_CI_REPORTING,        //Éý¼¶ºóÉϱ¨
+	MSG_CMD_FOTA_DM_UI_INIT_FOTA,
+	MSG_CMD_FOTA_DM_UI_CHANGE_PARA,  //WEBUI֪ͨDMÉèÖòÎÊý(Òþ²Ø²Ëµ¥)
+	MSG_CMD_FOTA_DM_NI_NIA,
+	MSG_CMD_FOTA_DM_NI_BOOTSTRAP,
+	MSG_CMD_FOTA_DM_MC_CHANGE_APN_SUCCEED,       //Ö÷¿ØÍ¨ÖªDMÇл»APN³É¹¦ÏûÏ¢
+	MSG_CMD_FOTA_DM_MC_CHANGE_APN_FAIL,  //Ö÷¿ØÍ¨ÖªDMÇл»APNʧ°ÜÏûÏ¢
+	MSG_CMD_FOTA_DM_MC_DATA_STATUS,      //Ö÷¿ØÍ¨ÖªDMÓÐÊý¾ÝÒµÎñ
+	MSG_CMD_FOTA_DM_MC_NODATA_STATUS,    //Ö÷¿ØÍ¨ÖªDMÎÞÊý¾ÝÒµÎñ
+	MSG_CMD_FOTA_DM_BSP_PROC_OK,         //bsp֪ͨDM´¦ÀíÍê³É
+	MSG_CMD_FOTA_DM_BSP_PROC_FAILED,     //bsp֪ͨDM´¦Àíʧ°Ü
+	MSG_CMD_FOTA_DM_WAKE_UP_OK,//»½ÐÑÉ豸³É¹¦
+	MSG_CMD_FOTA_DM_FALL_ASLEEP_OK,//É豸ÐÝÃß
+	MSG_CMD_FOTA_DM_POWER_ON,//±íʾdmÄ£¿éµÄÆô¶¯
+	MSG_CMD_FOTA_DM_DEVICE_IS_POWER_ON,//É豸´Ó¹Ø»ú»ò³äµçģʽ½øÈëÕý³£¿ª»ú
+	MSG_CMD_FOTA_DM_DEVICE_IS_POWER_OFF,//É豸ÕýÔÚ½øÐгäµçµÈ·ÇÕý³£×´Ì¬
+	MSG_CMD_FOTA_DM_QUERY_SLEEP_FROM_SLEEP_MODULE,//˯ÃßÄ£¿éÓøÃÏûÏ¢²éѯfotaÄܹ»Ë¯Ãß
+	MSG_CMD_FOTA_DM_IF_GET_VERSION_STATUS,
+	MSG_CMD_FOTA_DM_IF_GET_CUR_OPS,
+	MSG_CMD_FOTA_DM_IF_GET_UPDATE_CMD,
+	MSG_CMD_FOTA_DM_IF_SET_UPDATE_CMD,
+	MSG_CMD_FOTA_DM_IF_GET_DL_PROGRESS,
+	MSG_CMD_FOTA_DM_IF_GET_FOTA_PKG_INFO,
+	MSG_CMD_FOTA_DM_IF_GET_UPDATE_RESULT,
+	MSG_CMD_FOTA_DM_IF_GET_UPDATE_SETTINGS,
+	MSG_CMD_FOTA_DM_IF_SET_UPDATE_SETTINGS,
+
+	MSG_CMD_FOTA_WEBUI_START_FOTA,
+	MSG_CMD_FOTA_WEBUI_START_DOWNLOAD,
+	MSG_CMD_FOTA_WEBUI_CHANGE_PARAMETER,
+	MSG_CMD_FOTA_DM_START_UPDATE,
+
+	MSG_CMD_FOTA_DM_VERIFY,
+	MSG_CMD_FOTA_DM_DO_UPDATE,
+
+	MSG_CMD_FOTA_DM_ENEVT_END
+
+} E_DM_Event_Type;
+
+enum amt_device_test_msg_cmd  {
+	MSG_CMD_AMT_KEY_TEST_START_REQ   = MSG_CMD_AMT_DEVICE_TEST_BASE,			//¿ªÊ¼°´¼ü²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_KEY_TEST_START_RSP,				//¿ªÊ¼°´¼ü²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_KEY_TEST_STOP_REQ,				//Í£Ö¹°´¼ü²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_KEY_TEST_STOP_RSP,				//Í£Ö¹°´¼ü²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_LCD_TEST_START_REQ,				//¿ªÊ¼LCDÆÁÄ»²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_LCD_TEST_START_RSP,				//¿ªÊ¼LCDÆÁÄ»²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_LCD_TEST_STOP_REQ,				//Í£Ö¹LCDÆÁÄ»²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_LCD_TEST_STOP_RSP,				//Í£Ö¹LCDÆÁÄ»²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_BATTERY_VOLTAGE_TEST_REQ,		//µç³Øµçѹ²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_BATTERY_VOLTAGE_TEST_RSP,		//µç³Øµçѹ²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_LCD_BACKLIGHT_TEST_START_REQ,		//¿ªÊ¼LCD±³¹â²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_LCD_BACKLIGHT_TEST_START_RSP,		//¿ªÊ¼LCD±³¹â²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_LCD_BACKLIGHT_TEST_STOP_REQ,		//Í£Ö¹LCD±³¹â²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_LCD_BACKLIGHT_TEST_STOP_RSP,		//Í£Ö¹LCD±³¹â²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_VIBRATOR_TEST_START_REQ,		//¿ªÊ¼Âí´ï²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_VIBRATOR_TEST_START_RSP,		//¿ªÊ¼Âí´ï²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_VIBRATOR_TEST_STOP_REQ,		//Í£Ö¹Âí´ï²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_VIBRATOR_TEST_STOP_RSP,		//Í£Ö¹Âí´ï²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_CAMERA_TEST_START_REQ,		//¿ªÊ¼ÉãÏñÍ·²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_CAMERA_TEST_START_RSP,		//¿ªÊ¼ÉãÏñÍ·²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_CAMERA_TEST_STOP_REQ,		//Í£Ö¹ÉãÏñÍ·²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_CAMERA_TEST_STOP_RSP,		//Í£Ö¹ÉãÏñÍ·²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_SPEAKER_TEST_REQ,		//Âó¿Ë-À®°È»ØÂ·²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_SPEAKER_TEST_RSP,		//Âó¿Ë-À®°È»ØÂ·²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_SPEAKER_TEST_STOP_REQ,		//Âó¿Ë-À®°È»ØÂ·²âÊÔÍ£Ö¹ÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_SPEAKER_TEST_STOP_RSP,		//Âó¿Ë-À®°È»ØÂ·²âÊÔÍ£Ö¹ÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_RECEIVER_TEST_REQ,		//ÑïÉùÆ÷²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_RECEIVER_TEST_RSP,		//ÑïÉùÆ÷²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_RECEIVER_TEST_STOP_REQ,		//ÑïÉùÆ÷²âÊÔÍ£Ö¹ÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_RECEIVER_TEST_STOP_RSP,		//ÑïÉùÆ÷²âÊÔÍ£Ö¹ÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_TP_TEST_START_REQ,		//¿ªÊ¼´¥ÃþÆÁ²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_TP_TEST_START_RSP,		//¿ªÊ¼´¥ÃþÆÁ²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_TP_TEST_STOP_REQ,		//Í£Ö¹´¥ÃþÆÁ²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_TP_TEST_STOP_RSP,		//Í£Ö¹´¥ÃþÆÁ²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_GSENSOR_TEST_START_REQ,		//¿ªÊ¼G-Sensor²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_GSENSOR_TEST_START_RSP,		//¿ªÊ¼G-Sensor²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_GSENSOR_TEST_STOP_REQ,		//Í£Ö¹G-Sensor²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_GSENSOR_TEST_STOP_RSP,		//Í£Ö¹G-Sensor²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_WIFI_TEST_START_REQ,		//¿ªÊ¼wifi²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_WIFI_TEST_START_RSP,		//¿ªÊ¼wifi²âÊÔÏûÏ¢»ØÓ¦
+	MSG_CMD_AMT_FLASHLIGHT_START_REQ,       //¿ªÊ¼ÊÖµçͲ²âÊÔÏûÏ¢ÇëÇó
+	MSG_CMD_AMT_FLASHLIGHT_START_RSP,       //¿ªÊ¼ÊÖµçͲ²âÊÔÏûÏ¢»ØÓ¦
+};
+
+/*********************************************************************
+			¼Ò³¤¿ØÖÆÄ£¿éÏûÏ¢Ìå
+**********************************************************************/
+typedef struct {
+	char strAtCmd[128];
+	int deviceID;
+} PCS_MSG;
+
+typedef struct{
+	int cid;
+	int iptype;  //enum ipv4v6_flag
+}TScriptMSG;
+#endif
diff --git a/ap/app/include/pb_msg.h b/ap/app/include/pb_msg.h
new file mode 100755
index 0000000..c34b4cc
--- /dev/null
+++ b/ap/app/include/pb_msg.h
@@ -0,0 +1,75 @@
+/**
+ * @file pb_msg.h
+ * @brief ÃûƬ¼ÐÓ¦ÓöÔÍâÌṩµÄÏûÏ¢¼°½á¹¹Ì壬Ö÷ҪʹÓÃÕß°üÀ¨webserver¼°tro69»òÆäËûÓ¦ÓÃ
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __PB_MSG_H__
+#define __PB_MSG_H__
+
+#include "message.h"
+
+#define ZPB_GROUP_SIZE          32
+#define ZPB_SNE_SIZE            32
+
+#ifndef ZPB_MAX_DEL_LEN
+#define ZPB_MAX_DEL_LEN 50
+#endif
+
+#ifndef ZPB_NUM_SIZE
+#define ZPB_NUM_SIZE (ZPB_MAX_NUM_LENGTH+2)  /* + and null for string */
+#endif
+
+#ifndef ZPB_MAX_NUM_LENGTH
+#define ZPB_MAX_NUM_LENGTH   40
+#endif
+
+//name length
+#ifndef ZPB_MAX_TEXT_LENGTH
+#define ZPB_MAX_TEXT_LENGTH 90
+#endif
+
+#ifndef ZPB_TEXT_SIZE_CHARS
+#define ZPB_TEXT_SIZE_CHARS (ZPB_MAX_TEXT_LENGTH+1)              /* Null terminated string */
+#endif
+
+#ifndef ZPB_TEXT_SIZE_BYTES
+#define ZPB_TEXT_SIZE_BYTES (ZPB_TEXT_SIZE_CHARS*sizeof(short)) /* size in bytes */
+#endif
+
+enum pb_msg_cmd {
+	MSG_CMD_WRITE_PB = MSG_CMD_PB_BASE,//Ôö¼ÓÒ»ÌõÃûƬ¼Ð£¬¶ÔÓ¦½á¹¹ÌåT_zPb_WebContact
+	MSG_CMD_DEL_A_PB,                  //¶ÔÓ¦½á¹¹ÌåT_zPb_DelInfo
+	MSG_CMD_DEL_MUTI_PB,               //¶ÔÓ¦½á¹¹ÌåT_zPb_DelInfo
+	MSG_CMD_DEL_ALL_PB,                //¶ÔÓ¦½á¹¹ÌåT_zPb_DelInfo
+};
+
+typedef struct {
+	signed long      pbId;   //the id in the pbm table,unique,ASC
+	signed long      pbIndex;
+	signed long      pbLocation;
+	char        name[ZPB_TEXT_SIZE_BYTES];
+	char        mobilNumber[ZPB_NUM_SIZE];
+	signed long      pbType;
+	char        homeNumber[ZPB_NUM_SIZE];
+	char        officeNumber[ZPB_NUM_SIZE];
+	char        email[ZPB_TEXT_SIZE_BYTES];
+	char        sne[ZPB_SNE_SIZE];
+	char        group[ZPB_GROUP_SIZE];
+	signed long      del_id;
+} T_zPb_WebContact;
+
+typedef struct {
+	signed long  delId[ZPB_MAX_DEL_LEN];
+	signed long  delTotal;
+	signed long  delLocation;
+	signed long  delIndex[ZPB_MAX_DEL_LEN];
+} T_zPb_DelInfo;
+
+#endif
diff --git a/ap/app/include/poc_msg.h b/ap/app/include/poc_msg.h
new file mode 100644
index 0000000..289c15f
--- /dev/null
+++ b/ap/app/include/poc_msg.h
@@ -0,0 +1,263 @@
+/**
+ * @file poc_msg.h
+ * @brief ¶¨ÒåPOCºǫ́·þÎñÓëMMI½»»¥µÄÏûÏ¢½Ó¿Ú
+ *
+ * Copyright (C) 2019 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+ 
+#ifndef __POC_MSG_H
+#define __POC_MSG_H
+/*******************************************************************************
+*                           Include header files                              *
+******************************************************************************/
+/* Include "app/include/message.h". */
+#include "message.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+#define POC_SVR_PRINT 0
+#define SVRPOC "[PTT]"
+#define POC_PRINT "[PTT]"
+#if POC_SVR_PRINT
+#define POC_SVR_LOG(format, ...) \
+    do {  \
+        slog(POC_PRINT,SLOG_NORMAL,format,##__VA_ARGS__ );\
+    } while(0)
+
+#define POC_SVR_LOG_ERR(format, ...) \
+    do {  \
+        slog(POC_PRINT,SLOG_ERR,format,##__VA_ARGS__ );\
+    } while(0)
+#else
+#define POC_SVR_LOG(format, ...) \
+	do { \
+		printf(format,##__VA_ARGS__); \
+	} while(0)
+
+#define POC_SVR_LOG_ERR(format, ...) \
+	do { \
+		printf(format,##__VA_ARGS__); \
+	} while(0)
+#endif
+
+/*×î´óÃû³Æ³¤¶È*/
+#define SVRPOC_NAME_LENTH_MAX 32 
+/*×î´ó×éÊýÄ¿*/
+#define SVRPOC_GROUP_NUMBER_MAX 32 
+/*×î´ó³ÉÔ±ÊýÄ¿*/
+#define SVRPOC_MEMBERS_NUMBER_MAX 32 
+
+/*Îı¾ÐÅÏ¢×î´ó³¤¶È*/
+#define SVRPOC_TEXT_INFO_MAX 256 
+
+/*ÉÏËÍÏûÏ¢¶¨Òå*/
+#define SVRPOC_BASE MSG_CMD_POCSVR_BASE
+
+#define SVRPOC_INIT_CHECK_REQ  (SVRPOC_BASE + 1)
+#define SVRPOC_INIT_CHECK_RSP  (SVRPOC_BASE + 2)
+
+#define SVRPOC_USER_LOGIN_REQ  (SVRPOC_BASE + 3)
+#define SVRPOC_USER_LOGIN_RSP  (SVRPOC_BASE + 4)
+
+#define SVRPOC_USER_LOGOUT_REQ  (SVRPOC_BASE + 5)
+#define SVRPOC_USER_LOGOUT_RSP  (SVRPOC_BASE + 6)
+
+#define SVRPOC_GET_GROUPLIST_REQ  (SVRPOC_BASE + 7)
+#define SVRPOC_GET_GROUPLIST_RSP  (SVRPOC_BASE + 8)
+
+#define SVRPOC_GET_MEMBERS_REQ  (SVRPOC_BASE + 9)
+#define SVRPOC_GET_MEMBERS_RSP  (SVRPOC_BASE + 10)
+
+#define SVRPOC_SEARCH_MEMBERS_REQ  (SVRPOC_BASE + 11)
+#define SVRPOC_SEARCH_MEMBERS_RSP  (SVRPOC_BASE + 12)
+
+#define SVRPOC_GET_FRIENDS_REQ  (SVRPOC_BASE + 13)
+#define SVRPOC_GET_FRIENDS_RSP  (SVRPOC_BASE + 14)
+
+#define SVRPOC_SEARCH_FRIENDS_REQ  (SVRPOC_BASE + 15)
+#define SVRPOC_SEARCH_FRIENDS_RSP  (SVRPOC_BASE + 16)
+
+
+#define SVRPOC_GET_USERINFO_REQ  (SVRPOC_BASE + 17)
+#define SVRPOC_GET_USERINFO_RSP  (SVRPOC_BASE + 18)
+
+#define SVRPOC_GET_LOCATION_INFO_REQ  (SVRPOC_BASE + 19)
+#define SVRPOC_GET_LOCATION_INFO_RSP  (SVRPOC_BASE + 20)
+
+#define SVRPOC_GET_ACCOUNT_INFO_REQ  (SVRPOC_BASE + 21)
+#define SVRPOC_GET_ACCOUNT_INFO_RSP  (SVRPOC_BASE + 22)
+
+#define SVRPOC_HARDWARE_UPGRADE_REQ  (SVRPOC_BASE + 23)
+#define SVRPOC_HARDWARE_UPGRADE_RSP  (SVRPOC_BASE + 24)
+
+#define SVRPOC_JOIN_GROUP_REQ  (SVRPOC_BASE + 25)
+#define SVRPOC_JOIN_GROUP_RSP  (SVRPOC_BASE + 26)
+
+#define SVRPOC_JOIN_TEMPORARY_GROUP_REQ  (SVRPOC_BASE + 27)
+#define SVRPOC_JOIN_TEMPORARY_GROUP_RSP  (SVRPOC_BASE + 28)
+
+#define SVRPOC_GET_MIC_REQ  (SVRPOC_BASE + 29)
+#define SVRPOC_GET_MIC_RSP  (SVRPOC_BASE + 30)
+
+#define SVRPOC_RELEASE_MIC_REQ  (SVRPOC_BASE + 31)
+#define SVRPOC_RELEASE_MIC_RSP  (SVRPOC_BASE + 32)
+
+#define SVRPOC_USER_ACTIVITY_REQ  (SVRPOC_BASE + 33)
+#define SVRPOC_USER_ACTIVITY_RSP  (SVRPOC_BASE + 34)
+
+#define SVRPOC_GET_ONLINE_MEMBERS_REQ  (SVRPOC_BASE + 35)
+#define SVRPOC_GET_ONLINE_MEMBERS_RSP  (SVRPOC_BASE + 36)
+
+#define SVRPOC_PTT_PUSH_REQ  (SVRPOC_BASE + 37)
+#define SVRPOC_PTT_PUSH_RSP  (SVRPOC_BASE + 38)
+
+#define SVRPOC_PTT_RELEASE_REQ  (SVRPOC_BASE + 39)
+#define SVRPOC_PTT_RELEASE_RSP  (SVRPOC_BASE + 40)
+
+#define SVRPOC_PTT_IS_MEMBER_LOST_REQ  (SVRPOC_BASE + 41)
+#define SVRPOC_PTT_IS_MEMBER_LOST_RSP  (SVRPOC_BASE + 42)
+
+#define SVRPOC_SCAN_MEMBER_STATE_REQ  (SVRPOC_BASE + 43)
+#define SVRPOC_SCAN_MEMBER_STATE_RSP  (SVRPOC_BASE + 44)
+
+#define SVRPOC_USER_LIFE_INIT_REQ  (SVRPOC_BASE + 45)
+#define SVRPOC_USER_LIFE_INIT_RSP  (SVRPOC_BASE + 46)
+
+#define SVRPOC_ENTER_SELECT_GROUP_REQ  (SVRPOC_BASE + 47)
+#define SVRPOC_ENTER_SELECT_GROUP_RSP  (SVRPOC_BASE + 48)
+
+#define SVRPOC_ENTER_SELECT_MEMBER_REQ  (SVRPOC_BASE + 49)
+#define SVRPOC_ENTER_SELECT_MEMBER_RSP  (SVRPOC_BASE + 50)
+
+#define SVRPOC_ENTER_SELECT_PLAY_GROUP_REQ  (SVRPOC_BASE + 51)
+#define SVRPOC_ENTER_SELECT_PLAY_GROUP_RSP  (SVRPOC_BASE + 52)
+
+#define SVRPOC_SELECT_MEMBER_UP_REQ  (SVRPOC_BASE + 53)
+#define SVRPOC_SELECT_MEMBER_UP_RSP  (SVRPOC_BASE + 54)
+
+#define SVRPOC_SELECT_MEMBER_DOWN_REQ  (SVRPOC_BASE + 55)
+#define SVRPOC_SELECT_MEMBER_DOWN_RSP  (SVRPOC_BASE + 56)
+
+#define SVRPOC_EXIT_SELECT_MEMBER_REQ  (SVRPOC_BASE + 57)
+#define SVRPOC_EXIT_SELECT_MEMBER_RSP  (SVRPOC_BASE + 58)
+
+#define SVRPOC_EXIT_SELECT_GROUP_REQ  (SVRPOC_BASE + 59)
+#define SVRPOC_EXIT_SELECT_GROUP_RSP  (SVRPOC_BASE + 60)
+
+#define SVRPOC_ENTER_SELECT_GROUP_UP_REQ  (SVRPOC_BASE + 61)
+#define SVRPOC_ENTER_SELECT_GROUP_UP_RSP  (SVRPOC_BASE + 62)
+
+#define SVRPOC_ENTER_SELECT_GROUP_DOWN_REQ  (SVRPOC_BASE + 63)
+#define SVRPOC_ENTER_SELECT_GROUP_DOWN_RSP  (SVRPOC_BASE + 64)
+
+#define SVRPOC_ENTER_TTS_PLAY_USER_NAME_REQ  (SVRPOC_BASE + 65)
+#define SVRPOC_ENTER_TTS_PLAY_USER_NAMEP_RSP  (SVRPOC_BASE + 66)
+
+#define SVRPOC_USER_TEMP_CALL_WITH_NO_GID_REQ  (SVRPOC_BASE + 67)
+#define SVRPOC_USER_TEMP_CALL_WITH_NO_GID_RSP  (SVRPOC_BASE + 68)
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+/*ͨÓÃÏìÓ¦½á¹û*/
+struct svr_poc_comm_result{
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+};
+
+/*Óû§ÐÅÏ¢*/
+struct svr_poc_user_info{
+	char userName[SVRPOC_NAME_LENTH_MAX];/*Óû§Ãû*/
+	unsigned int uid ;/*Óû§id*/	
+	unsigned int currentGid;/*µ±Ç°×éid*/
+	char groupName[SVRPOC_NAME_LENTH_MAX];/*µ±Ç°×éÃû*/
+	unsigned char isOnline;/*ÊÇ·ñÔÚÏß*/
+};
+
+/*Ⱥ×éÐÅÏ¢*/
+struct svr_poc_group{
+	unsigned int gid;/*×éid*/
+	char name[SVRPOC_NAME_LENTH_MAX];/*×éÃû*/
+	unsigned int n_members;/*³ÉÔ±ÊýÄ¿*/
+	unsigned char has_type;/*ÊÇ·ñÓÐÀàÐÍ*/
+	unsigned int type; /*0´úÂëÖÐдËÀµÄ,1ºǫ́ÉèÖõÄ,ÁÙʱ´´½¨µÄ*/
+};
+
+/*
+ *²éѯȺ×éµÄÏìÓ¦
+ */
+struct svr_poc_group_ack{
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+	unsigned int n_groups;/*·µ»Ø¸ÃÕ˺ÅËùÔÚµÄËùÓÐȺ×éÐÅÏ¢*/
+	struct svr_poc_group groups[SVRPOC_GROUP_NUMBER_MAX];	
+};
+
+struct svr_poc_member{
+		/*
+	   *User ID,¿ÉÒÔÖ÷¶¯Éϱ¨ÆäËûÓû§ÐÅÏ¢
+	   */
+	  unsigned int uid;
+	  /*
+	   *Õ˺ÅÃû³Æ
+	   */
+	  char name[SVRPOC_NAME_LENTH_MAX];
+	  /*
+	   *ÊÇ·ñÔÚÏß
+	   */
+	  unsigned char has_online;
+};
+
+/*×é³ÉÔ±ÐÅÏ¢*/
+struct svr_poc_group_members{
+	unsigned int gid;/*×éid*/
+	/*
+	*ËùÓиÃȺ×éÄÚÔÚÏßÓû§IDÐÅÏ¢
+	*/
+	unsigned int n_ingroups;
+	unsigned int ingroups[SVRPOC_MEMBERS_NUMBER_MAX];
+	/*
+	*ËùÓиÃȺ×éÄÚÀëÏßÓû§IDÐÅÏ¢
+	*/
+	unsigned int n_outgroups;
+	unsigned int outgroups[SVRPOC_MEMBERS_NUMBER_MAX];
+	/*
+	*¸ÃȺ×éÄÚËùÓÐÓû§ÐÅÏ¢
+	*/
+	unsigned int n_members;/*³ÉÔ±ÊýÄ¿*/
+	struct svr_poc_member members[SVRPOC_MEMBERS_NUMBER_MAX];
+};
+
+/*
+ *²éѯȺ×éÄÚÓû§ÐÅÏ¢µÄÇëÇóµÄÏìÓ¦
+ */
+struct svr_poc_group_members_ack{
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+	unsigned int n_members;/*³ÉÔ±ÊýÄ¿*/
+	struct svr_poc_group_members members;
+};
+
+struct svr_poc_search_member_ack {
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+	struct svr_poc_member member;
+};
+
+struct svr_poc_get_location_ack {
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+	char location[SVRPOC_TEXT_INFO_MAX];
+};
+
+struct svr_poc_get_account_info_ack {
+	int result;/*0²Ù×÷³É¹¦£»·Ç0²Ù×÷ʧ°Ü*/
+	char ip[SVRPOC_NAME_LENTH_MAX];
+	char dns[SVRPOC_NAME_LENTH_MAX];
+	char username[SVRPOC_NAME_LENTH_MAX];
+};
+
+#endif /*__POC_MSG_H*/
diff --git a/ap/app/include/ref_nv_def.h b/ap/app/include/ref_nv_def.h
new file mode 100755
index 0000000..bf848bf
--- /dev/null
+++ b/ap/app/include/ref_nv_def.h
@@ -0,0 +1,88 @@
+/**

+ * @file ref_nv_def.h

+ * @brief ÌṩÁËnvºê¶¨Òå

+ *

+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.

+ * @author

+ *

+ * This program is free software; you can redistribute it and/or modify

+ * it under the terms of the GNU General Public License version 2 as

+ * published by the Free Software Foundation.

+ *

+ */

+ 

+#ifndef __REF_NV_DEF__

+#define __REF_NV_DEF__

+

+#include "RWNvConfig.h"

+#include "libcpnv.h"

+

+/******************************

+  7520 NVRWÇøÊ×µØÖ·

+*******************************/

+#define ZPS_REF_MSINFO_REFDESIGN_BASE_ADDR                                (OS_FLASH_REF_DESIGN_RW_OFFSET_FROM_NV)

+

+/******************************

+  ²Î¿¼Éè¼ÆÓû§Êý¾ÝÇø£¬3K

+*******************************/

+#define NVRW_REF_NV_USER_OFFSET_SIZE                           (3 * 1024)

+

+/******************************

+  ²Î¿¼Éè¼ÆË½ÓÐÇø£¬8K

+  Ïà¶ÔNVRWÇøÆðʼµØÖ·µÄÆ«ÒÆµØÖ·Îª0x100C00

+*******************************/

+#define NVRW_REF_NV_PRIVATE_OFFSET_ADDRESS                     (ZPS_REF_MSINFO_REFDESIGN_BASE_ADDR + NVRW_REF_NV_USER_OFFSET_SIZE)

+#define NVRW_REF_NV_PRIVATE_OFFSET_SIZE                        (8 * 1024)

+

+

+/******************************

+  ²Î¿¼Éè¼ÆË½ÓÐÇøNV¹æ»®£¬8K

+*******************************/

+#define ZPS_REF_MSINFO_SOFTVERSION_INT_BASE_ADDR              (NVRW_REF_NV_PRIVATE_OFFSET_ADDRESS)

+#define ZPS_REF_MSINFO_MAX_SOFTVERSION_INT_LEN                (unsigned char)100        /*ÄÚ²¿Èí¼þ°æ±¾ºÅ×î´ó³¤¶È*/

+

+#define ZPS_REF_MSINFO_SOFTVERSION_EXT_BASE_ADDR              (ZPS_REF_MSINFO_SOFTVERSION_INT_BASE_ADDR + ZPS_REF_MSINFO_MAX_SOFTVERSION_INT_LEN)

+#define ZPS_REF_MSINFO_MAX_SOFTVERSION_EXT_LEN                (unsigned char)100        /*ÍⲿÈí¼þ°æ±¾ºÅ×î´ó³¤¶È*/

+

+#define ZPS_REF_MSINFO_HARDWAREVERSION_BASE_ADDR              (ZPS_REF_MSINFO_SOFTVERSION_EXT_BASE_ADDR + ZPS_REF_MSINFO_MAX_SOFTVERSION_EXT_LEN)

+#define ZPS_REF_MSINFO_MAX_HARDWAREVERSION_LEN                (unsigned char)100        /*Ó²¼þ°æ±¾ºÅ×î´ó³¤¶È*/

+

+#define	ZPS_REF_MSINFO_PHONE_INT_BASE_ADDR                    (ZPS_REF_MSINFO_HARDWAREVERSION_BASE_ADDR + ZPS_REF_MSINFO_MAX_HARDWAREVERSION_LEN)

+#define	ZPS_REF_MSINFO_MAX_PHONE_INT_LEN                      (unsigned char)32         /*ÄÚ²¿»úÐÍ×î´ó³¤¶È*/

+

+#define	ZPS_REF_MSINFO_PHONE_EXT_BASE_ADDR                    (ZPS_REF_MSINFO_PHONE_INT_BASE_ADDR + ZPS_REF_MSINFO_MAX_PHONE_INT_LEN)

+#define	ZPS_REF_MSINFO_MAX_PHONE_EXT_LEN                      (unsigned char)32         /*Íⲿ»úÐÍ×î´ó³¤¶È*/

+

+#define ZPS_REF_MSINFO_SSID_BASE_ADDR                         (ZPS_REF_MSINFO_PHONE_EXT_BASE_ADDR + ZPS_REF_MSINFO_MAX_PHONE_EXT_LEN)

+#define ZPS_REF_MSINFO_MAX_SSID_LEN                           (unsigned char)100        /*ZTE_WIRELESS_MACµØÖ·ºóËÄλ*/

+

+#define ZPS_REF_MSINFO_CGMI_BASE_ADDR                         (ZPS_REF_MSINFO_SSID_BASE_ADDR + ZPS_REF_MSINFO_MAX_SSID_LEN)

+#define ZPS_REF_MSINFO_MAX_CGMI_LEN                           (unsigned char)100        /*³§ÉÌÐÅÏ¢*/

+

+#define ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR                   (ZPS_REF_MSINFO_CGMI_BASE_ADDR + ZPS_REF_MSINFO_MAX_CGMI_LEN)

+#define ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN                     (unsigned char)65        /*wifikey*/

+

+#define ZPS_REF_MSINFO_UNLOCKTIMES_BASE_ADDR                  (ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR + ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN)

+#define ZPS_REF_MSINFO_MAX_UNLOCKTIMES_LEN                    (unsigned char)4        /*ËøÍø×î´ó½âËø´ÎÊý*/

+

+#define ZPS_REF_MSINFO_PLATFORM_END							  (ZPS_REF_MSINFO_UNLOCKTIMES_BASE_ADDR + ZPS_REF_MSINFO_MAX_UNLOCKTIMES_LEN)

+

+///======´Ë´¦NV¶¨ÒåΪƽ̨ÄÚ²¿NV£¬ºóÐøÆäËûÄ£¿éNV¶¨Òå¾ùÔÚ¸÷×ÔÄ£¿éÄÚ²¿Ìí¼Ó¶¨Òå

+

+#define ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR                  (ZPS_REF_MSINFO_PLATFORM_END)

+#define ZPS_REF_MSINFO_MAX_VERSIONMODE_LEN                    (unsigned char)1        /*°æ±¾Ä£Ê½ÀàÐÍ£¬Õý³£°æ±¾/¹Ò²à°æ±¾*/

+

+#define ZPS_REF_MSINFO_ZISMS_BASE_ADDR                  	  (ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR + ZPS_REF_MSINFO_MAX_VERSIONMODE_LEN)

+#define ZPS_REF_MSINFO_MAX_ZISMS_LEN                    	  (unsigned char)1        /*ÖÇÄܶÌÐŹ¦ÄÜ¿ª¹Ø*/

+

+#define ZPS_REF_MSINFO_WEBKEY_FLAG_BASE_ADDR                  (ZPS_REF_MSINFO_ZISMS_BASE_ADDR + ZPS_REF_MSINFO_MAX_ZISMS_LEN)

+#define ZPS_REF_MSINFO_MAX_WEBKEY_FLAG_LEN                    (unsigned char)1        /*ʹÓÃnvÖÐhttpsÃØÔ¿¿ª¹Ø*/

+

+#define ZPS_REF_MSINFO_WEBKEY_DATA_BASE_ADDR                   (ZPS_REF_MSINFO_WEBKEY_FLAG_BASE_ADDR + ZPS_REF_MSINFO_MAX_WEBKEY_FLAG_LEN)

+#define ZPS_REF_MSINFO_MAX_WEBKEY_DATA_LEN                     (unsigned char)2048        /*httpsÃØÔ¿Êý¾Ý*/

+

+#define REF_REF_NV_END                                        (NVRW_REF_NV_PRIVATE_OFFSET_ADDRESS + NVRW_REF_NV_PRIVATE_OFFSET_SIZE - 1)/*¿ØÖƹÜÀíNV½áÊøµØÖ·0x2BFF*/

+

+

+#endif

+

diff --git a/ap/app/include/rtc_timer.h b/ap/app/include/rtc_timer.h
new file mode 100755
index 0000000..3dbecf6
--- /dev/null
+++ b/ap/app/include/rtc_timer.h
@@ -0,0 +1,171 @@
+/**
+* @file rtc_timer.h
+* @brief Public APIs of Sanechips
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author  Linxu Gebin
+* @defgroup si_id Sanechips
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*************************************************************************
+*/
+
+#ifndef _RTC_TIMER_H
+#define _RTC_TIMER_H
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include  <sys/time.h>
+#include "message.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+******************************************************************************/
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+/**
+* @brief rtc message type
+* @note
+*/
+enum RTC_CPU {
+	RTC_CPU_CP = 0,   //rtcÓÉcp·¢Æð
+	RTC_CPU_AP,       //rtcÓÉAP·¢Æð
+};
+
+/**
+* @brief rtc type
+* @note
+*/
+typedef enum {
+	RTC_ID_START = 0,
+	WIFI_INTERVAL_SLEEP,
+	WIFI_PWR_SAVE,
+	WIFI_WAKE_UP_SYSTEM,
+	WIFI_WPS_RESULT_CHECK,
+	WIFI_TSW_SLEEP,
+	WIFI_TSW_WAKEUP,
+	WIFI_ACL_SERVICE,
+	WDT_TEMP_PROTECT,
+	RTC_SAFECARE_CONTIME,
+	RTC_SAFECARE_DELAY,
+	RTC_ID_FP_CLOCK,
+	RTC_ID_NOTDISTURB_BEGIN,
+	RTC_ID_NOTDISTURB_END,
+	RTC_ID_MMI_ALARM,
+	RTC_ID_MMI_CLOCK_MODE_CHECK,
+	RTC_ID_TRACK_BEGIN,
+	RTC_ID_TRACK_UPLOAD=RTC_ID_TRACK_BEGIN,
+	RTC_ID_TRACK_BASE,
+	RTC_ID_TRACK_SERVER_CON,
+	RTC_ID_TRACK_SLAVE_SERVER_CON,
+	RTC_ID_TRACK_SLAVE_SERVER_CMD,
+	RTC_ID_TRACK_DEBUG_SERVER_CON,
+	RTC_ID_TRACK_LINK,
+	RTC_ID_TRACK_LINK_TIMEOUT,
+	RTC_ID_TRACK_AGPS,
+	RTC_ID_TRACK_WEATHER_UPDATE,
+	RTC_ID_TRACK_END,
+	RTC_ID_END,
+} RTC_ID;
+#endif
+
+/**
+* @brief rtc ÏûÏ¢ÀàÐÍ
+* @param RTC_MSG_ALARM_ELAPSED µ±¶¨Ê±Æ÷´¥·¢Ê±»á·¢Õâ¸öÏûÏ¢¸ø¶¨Ê±Æ÷ÓµÓÐÕß
+* @param RTC_MSG_TIME_CHANGED RTCʱ¼ä¸üÐÂ:±íʾÊÀ½çʱ¼ä·¢Éú±ä»¯£¬¼´Ê±¼äͬ²½Íê³É»òÕßÓû§ÊÖ¶¯ÖØÐÂÉèÖõ±Ç°µÄÊÀ½çʱ¼äÁË£¬´ËʱRTC½ø³Ì»á¹ã²¥¸øÒÑ×¢²áÊÀ½çʱ¼äµÄÄ£¿é£¬ÒÔÈÃÏà¹ØÄ£¿é½øÐÐÊÀ½çʱ¼ä¶¨Ê±Æ÷µÄÖØÐÂÉèÖÃ
+* @note
+*/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+enum RTC_MSG_CMD {
+	RTC_MSG_GET_TIME = MSG_CMD_RTC_BASE,	//»ñȡʱ¼ä£¬Ö±½Óµ÷ÓÃlinuxϵͳʱ¼ä½Ó¿Ú
+	RTC_MSG_SET_TIME,						//ÉèÖÃʱ¼ä
+	RTC_MSG_ADD_ALARM,						//Ìí¼Órtc¶¨Ê±Æ÷
+	RTC_MSG_DEL_ALARM,						//ɾ³ýrtc¶¨Ê±Æ÷
+	RTC_MSG_ALARM_TIMEOUT,					//RTC alarm¶¨Ê±Æ÷ʱ¼ä³¬Ê±
+	RTC_MSG_TIMER_TIMEOUT,					//RTC timer¶¨Ê±Æ÷ʱ¼ä³¬Ê±
+	RTC_MSG_ALARM_ELAPSED,					//µ±¶¨Ê±Æ÷´¥·¢Ê±»á·¢Õâ¸öÏûÏ¢¸ø¶¨Ê±Æ÷ÓµÓÐÕß
+	RTC_MSG_DEL_ALL,						//Çå³ýËùÓйػú²»±£´æµÄ¶¨Ê±Æ÷£¬·ñÔòrtc¶¨Ê±Æ÷µ½µã»¹»áÉϱ¨
+	RTC_MSG_TIME_CHANGED,					//RTCʱ¼ä¸üÐÂ:±íʾÊÀ½çʱ¼ä·¢Éú±ä»¯£¬¼´Ê±¼äͬ²½Íê³É»òÕßÓû§ÊÖ¶¯ÖØÐÂÉèÖõ±Ç°µÄÊÀ½çʱ¼äÁË£¬´ËʱRTC½ø³Ì»á¹ã²¥¸øÒÑ×¢²áÊÀ½çʱ¼äµÄÄ£¿é£¬ÒÔÈÃÏà¹ØÄ£¿é½øÐÐÊÀ½çʱ¼ä¶¨Ê±Æ÷µÄÖØÐÂÉèÖÃ
+};
+#endif
+
+/**
+* @brief rtc data buffer
+* @param srcModule ´´½¨¶¨Ê±Æ÷µÄÄ£¿é
+* @param module ¶¨Ê±Æ÷id
+* @param ulSec ¼ä¸ôʱ¼ä£¬µ¥Î»:s
+* @param time_val  µ±Ç°Ê±¼ä
+* @param wakeup   ¹Ø»ú»½ÐÑ£¬1:´ò¿ª£¬0:¹Ø±Õ
+* @param is_utc  ÊÇ·ñutcʱ¼ä£¬
+* @param cpu  rtc·¢ÆðµÄcpu£¬ 0: cp, 1:ap
+* @note utcʱ¼äÕý³£±È½Ï³¤£¬ÓÃWKALM¶¨Ê±Æ÷
+*/
+typedef struct tag_RTC_DATA_BUF {
+	int srcModule;
+	unsigned int   module;
+	unsigned long   ulSec;
+	unsigned long time_val;
+	int wakeup;
+	int is_utc;
+	int cpu;
+} RTC_DATA_BUF;
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+* @brief  Ìí¼Ó¶¨Ê±Æ÷
+* @param ulSec	¶¨Ê±Æ÷ʱ¼ä£¬µ¥Î»Ãë
+* @param rtc_id	¶¨Ê±Æ÷ID
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_add(unsigned long ulSec, RTC_ID rtc_id, int src_id);
+
+/**
+* @brief Ìí¼Ó¶¨Ê±Æ÷
+* @param time	¶¨Ê±Æ÷ʱ¼ä£¬µ¥Î»ÊÀ½çʱÖÓ,ÐèÒªÌî: tm_sec/tm_min/tm_hour/tm_mday/tm_mon/tm_year
+* @param rtc_id	¶¨Ê±Æ÷ID£¬
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @param wakeup	¹Ø»úÊÇ·ñ»½ÐÑ
+* @note wakeup	ÊÇ0²»»½ÐÑ, 1 »½ÐÑ
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_add_utc(struct tm *time, RTC_ID rtc_id, int src_id, int wakeup);
+
+
+/**
+* @brief ɾ³ý¶¨Ê±Æ÷
+* @param rtc_id	¶¨Ê±Æ÷ID
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_del(RTC_ID rtc_id, int src_id);
+
+
+/**
+* @brief ɾ³ýËùÓж¨Ê±Æ÷
+* @param src_id		ɾ³ý¶¨Ê±Æ÷µÄÄ£¿éID
+* @param req_cmd	»Ø¸´µÄÏûÏ¢cmd
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_del_all(int src_id, unsigned short req_cmd);
+
+
+/**
+* @brief ÉèÖÃrtcµ±Ç°Ê±¼ä
+* @param src_id	ÉèÖÃʱ¼äµÄÄ£¿éID
+* @return ÉèÖÃrtcµ±Ç°Ê±¼ä
+*/
+int  rtc_set_time(int src_id);
+
+#endif
+
+
diff --git a/ap/app/include/rtk_arch.h b/ap/app/include/rtk_arch.h
new file mode 100755
index 0000000..7a4b40c
--- /dev/null
+++ b/ap/app/include/rtk_arch.h
@@ -0,0 +1,37 @@
+
+#ifndef _RTK_ARCH_H_
+#define _RTK_ARCH_H_
+
+#ifndef MAX_PATH
+#define MAX_PATH	256
+#endif
+
+
+#define TOP_CONFIG_DIR		        	"/etc_rw/wifi/realtek"
+#define WIFI_CONFIG_ROOT_DIR		"/etc_rw/wifi/realtek/rtl8192c"
+
+#define WIFI_SCRIPT_DIR				"/sbin"
+#define QRCODE_SCRIPT_DIR			"/sbin"
+#define WIFI_BIN_DIR					"/bin"
+#define WIFI_WPS_TMP_DIR			"/tmp"
+#define WIFI_MP_TMP_FILE			"/tmp/MP.txt"
+#define WIFI_WAPI_TMP_DIR			"/tmp"
+#define WIFI_WAPI_CERT_DIR			"/myca"
+//=======================================
+
+#define DAEMON_VERSION	"svn:( date:2015-07-08 )"
+
+#define  WIFISTATUS                            "/etc_rw/wifiStatus"
+#define  WPSSTATUS                             "/etc_rw/wpsStatus"
+#define  QRSTATUS                                "/etc_rw/qrStatus"
+#define  WPSDISPLAYSTATUS              "/etc_rw/wpsdisplayStatus"
+#define  STASTATUS   				"/etc_rw/staStatus"
+
+//#define  DEBUG_FILE_PATH		         "/wifi/wlan_watch"
+//#define  DEBUG_OUTFILE_PATH		 "/wifi/wlan_dump"
+
+//#define WLAN_LOG1_FILE_PATH         "/wifi/clog1"
+//#define WLAN_LOG2_FILE_PATH         "/wifi/clog2"
+
+#endif // _RTK_ARCH_H_
+
diff --git a/ap/app/include/sms_msg.h b/ap/app/include/sms_msg.h
new file mode 100755
index 0000000..8331e89
--- /dev/null
+++ b/ap/app/include/sms_msg.h
@@ -0,0 +1,217 @@
+/**
+ * @file sms_msg.h
+ * @brief ¶ÌÏûÏ¢Ó¦ÓöÔÍâÌṩµÄÏûÏ¢¼°½á¹¹Ì壬Ö÷ҪʹÓÃÕß°üÀ¨webserver¼°tro69»òÆäËûÓ¦ÓÃ
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __SMS_MSG_H__
+#define __SMS_MSG_H__
+
+#include "message.h"
+
+enum sms_msg_cmd {
+	MSG_CMD_COPY_SMS = MSG_CMD_SMS_BASE,//0x4100     /*Ò³Ãæ·¢Ë͸´ÖƶÌÐÅÇëÇó*/
+	MSG_CMD_SEND_SMS,//¶ÔÓ¦½á¹¹ÌåT_zGoaheadMsgBuf
+	MSG_CMD_DEL_SMS_BY_INDEX,//¶ÔÓ¦½á¹¹ÌåT_zUfiSms_DelReq
+	MSG_CMD_DEL_SMS_BY_TYPE,
+	MSG_CMD_SMS_MODIFY_TAG,//¶ÔÓ¦½á¹¹ÌåT_zGoaheadMsgBuf
+	MSG_CMD_DRAFTS_SAVE,//¶ÔÓ¦½á¹¹ÌåT_zGoaheadMsgBuf
+	MSG_CMD_SMS_LOCATION_SET,//¶ÔÓ¦½á¹¹ÌåT_zGoaheadMsgBuf
+	MSG_CMD_SMS_OUTDATE_CHECK,//ÎÞ²ÎÊý
+	/***----MSG_CMD_SMS_END 0x4180 ºÏ¼Æ128¸ö-------*/
+};
+
+/************¶ÌÏûÏ¢Ïà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåbegin***********/
+#define ZTE_MODEM_RELAY_MSGBUF_MAX_LEN 				600
+#ifdef CONFIG_MIN_8M_VERSION
+#define ZTE_WMS_DELETE_COUNT_MAX         20
+#else
+#define ZTE_WMS_DELETE_COUNT_MAX         100
+#endif
+
+typedef enum {
+	ZTE_MC_STATE_TYPE,			//machine state maintain type
+	ZTE_MDM_REALY_TYPE,		//mdm mode relay type
+	ZTE_WAN_RELAY_TYPE,		//wan mode  relay type
+	ZTE_LAN_RELAY_TYPE,			//lan mode relay type
+	ZTE_SMS_RELAY_TYPE,			//shortmsg mode  relay type
+	ZTE_PBM_RELAY_TYPE,			//phonebook mode relay type
+	ZTE_ATSERVER_RELAY_TYPE,	//at server mode relay type
+	ZTE_SLEEP_WAKEUP_RELAY_TYPE,		// relay sleep and wakeup  type
+	ZTE_FOTA_RELAY_TYPE,          //fota modle relay type
+	ZTE_USSD_RELAY_TYPE,		// relay USSDtype
+	ZTE_AP_STATION_RELAY_TYPE,		// relay USSDtype
+	ZTE_BUZZER_RELAY_TYPE,		//
+	ZTE_MODE_RELAY_TYPE,		//
+	ZTE_KEY_RELAY_TYPE		//
+} zte_mc_msg_mode_e_type;
+
+typedef struct {
+	zte_mc_msg_mode_e_type type;
+	unsigned long 		   id;
+	int				       result;
+} zte_mc_msg_hdr_s_type;
+
+//MSG_CMD_SEND_SMS/MSG_CMD_SMS_MODIFY_TAG/MSG_CMD_DRAFTS_SAVEÏûÏ¢·¢ËÍʹÓøòÎÊý
+typedef struct {
+	zte_mc_msg_hdr_s_type  msg_hdr;				//the message header
+	unsigned long 			msg_len;				//the message len
+	unsigned char			   msg_data[ZTE_MODEM_RELAY_MSGBUF_MAX_LEN];   //the message data
+} T_zGoaheadMsgBuf;
+
+
+//MSG_CMD_DEL_SMS_BY_INDEXÏûÏ¢·¢ËÍʹÓøòÎÊý
+typedef struct {
+	unsigned char all_or_count;                        /*all_or_count=0--->delete all,others--->delete partial sms*/
+	int id[ZTE_WMS_DELETE_COUNT_MAX];
+	unsigned char sql[2];
+} T_zUfiSms_DelReq;
+
+/************¶ÌÏûÏ¢Ïà¹ØÏûÏ¢¶ÔÓ¦µÄ½á¹¹Ìåend***********/
+
+
+//Ô´×Ôsms_com.h£¬¹©webserverʹÓÃ
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+#define ZTE_WMS_MESSAGE_LIST_MAX         255
+#define ZTE_WMS_DB_EXECSQL_LEN           1024
+#define ZTE_WMS_SEND_NUM_MAX             5
+#define ZTE_WMS_ADDRESS_LEN_MAX          32
+#define ZTE_WMS_SMS_COUNT_MAX            10
+#define ZTE_WMS_DB_MSG_COUNT_MAX         (ZTE_WMS_DELETE_COUNT_MAX)
+#define ZTE_WMS_CONCAT_SMS_COUNT_MAX     10
+#define ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX  160
+#define ZTE_WMS_ADDRESS_DIGIT_MAX_V01  	 21
+
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+/* smsµÄ²Ù×÷ÀàÐÍ */
+typedef enum {
+	WMS_SMS_CMD_NONE = 0,
+
+	WMS_SMS_CMD_INIT,
+	WMS_SMS_CMD_GET_MEM_CAPABILITY,
+
+	WMS_SMS_CMD_CFG_SET_PARAMETERS,
+	WMS_SMS_CMD_MSG_SEND,
+	WMS_SMS_CMD_MSG_WRITE,
+	WMS_SMS_CMD_MSG_DELETE,
+	WMS_SMS_CMD_MSG_MODIFY_TAG,
+	WMS_SMS_CMD_MSG_REPLY,
+
+	WMS_SMS_CMD_SMS_INIT_LOAD,
+	WMS_SMS_CMD_SMS_LOAD_COMPLETE,
+
+	WMS_SMS_CMD_RECEIVE_MSG,
+	WMS_SMS_CMD_SLEEP_WAKEUP,
+
+	WMS_SMS_CMD_RESTORE,
+
+	WMS_SMS_CMD_WMS_MAX
+} T_zUfiSms_CmdType;
+
+typedef enum {
+	WMS_CMD_NONE = 0x00,
+	WMS_CMD_PROCESSING,
+	WMS_CMD_FAILED,
+	WMS_CMD_SUCCESS,
+	WMS_CMD_CONFLICT,        /*WHEN db data conflict with sim card or nv */
+	WMS_CMD_STATUS_MAX = 0x1000
+} T_zUfiSms_CmdStatus;
+
+
+typedef enum {
+	ZTE_SMS_CMS_NONE               = 0,
+	ZTE_SMS_CMS_ME_FAILURE         = 300,
+	ZTE_SMS_CMS_SERVICE_RESERVED   = 301,
+	ZTE_SMS_CMS_OP_NOT_ALLOWED     = 302,
+	ZTE_SMS_CMS_OP_NOT_SUPPORTED   = 303,
+	ZTE_SMS_CMS_INVALID_PDU_PARAM  = 304,
+	ZTE_SMS_CMS_INVALID_TXT_PARAM  = 305,
+	ZTE_SMS_CMS_SIM_NOT_INSERTED   = 310,
+	ZTE_SMS_CMS_SIM_PIN_REQ        = 311,
+	ZTE_SMS_CMS_PHSIM_PIN_REQ      = 312,
+	ZTE_SMS_CMS_SIM_FAILURE        = 313,
+	ZTE_SMS_CMS_SIM_BUSY           = 314,
+	ZTE_SMS_CMS_SIM_WRONG          = 315,
+	ZTE_SMS_CMS_SIM_PUK_REQ        = 316,
+	ZTE_SMS_CMS_SIM_PIN2_REQ       = 317,
+	ZTE_SMS_CMS_SIM_PUK2_REQ       = 318,
+	ZTE_SMS_CMS_MEM_FAILURE        = 320,
+	ZTE_SMS_CMS_INVALID_INDEX      = 321,
+	ZTE_SMS_CMS_MEM_FULL           = 322,
+	ZTE_SMS_CMS_SCA_ADDR_UNKNOWN   = 330,
+	ZTE_SMS_CMS_NO_SERVICE         = 331,
+	ZTE_SMS_CMS_NETWORK_TIMEOUT    = 332,
+	ZTE_SMS_CMS_CNMA_NOT_EXP       = 340,
+	ZTE_SMS_CMS_UNKNOWN_ERR        = 500,
+	ZTE_SMS_CMS_MAX                = 512
+} T_zUfiSms_ErrorType;
+
+
+//µ±Ç°Á÷³ÌµÄ״̬ÐÅÏ¢
+typedef struct {
+	T_zUfiSms_CmdType cmd; //µ±Ç°µÄÒµÎñÁ÷³Ì±ê¼Ç£¬·¢¡¢ÊÕ¡¢É¾µÈ
+	T_zUfiSms_CmdStatus cmd_status;
+	T_zUfiSms_ErrorType err_code;
+	int send_failed_count;
+	int delete_failed_count;
+} T_zUfiSms_StatusInfo;
+
+/*Ð޸IJÎÊý*/
+typedef struct {
+	unsigned char tags;
+	unsigned int total_id;
+	unsigned int type;
+	unsigned int id[ZTE_WMS_DB_MSG_COUNT_MAX];
+} T_zUfiSms_ModifyFlag;
+
+typedef struct {
+	unsigned char sca[ZTE_WMS_ADDRESS_DIGIT_MAX_V01 + 1];    /*read from the sim card,null terminated */
+	unsigned int mem_store;            /*´æ´¢Î»Ö㬠Sim»òNv*/
+	unsigned int tp_validity_period;                    /* [0,255], initial vaule=255 */
+	unsigned int status_report_on;                        /*1-->open, 0-->close, initial vaue=0 */
+	unsigned int sendfail_retry_on;                        /*1-->open, 0-->close, initial vaue=0 */
+	unsigned int outdate_delete_on;                        /*1-->open, 0-->close, initial vaue=0 */
+	unsigned char default_store[10];                        /*nv, sim, initial vaue=nv */
+} zte_wms_parameter_info_s_type, T_zUfiSms_ParaInfo;
+
+
+typedef struct {
+	unsigned char year[5];
+	unsigned char month[3];
+	unsigned char day[3];
+	unsigned char hour[3];
+	unsigned char min[3];
+	unsigned char sec[3];
+	unsigned char timezone[4];//ʱ¼äÒª¸ú×ÅÊ±Çø×öЩµ÷Õû
+} T_zUfiSms_Date;
+
+/* ·¢¶ÌÐÅ */
+typedef struct {
+	unsigned char receiver_count;
+	unsigned char mem_store; //¶ÌÐŴ洢λÖ㬻ò¿¨£¬»òNV
+	unsigned char dest_num[ZTE_WMS_SEND_NUM_MAX][ZTE_WMS_ADDRESS_LEN_MAX + 1]; //ÊÕ¼þÈË
+	unsigned short msg_len;
+
+	unsigned char dcs;  /* ±àÂë¸ñʽ 1-->ASCII, 2-->UNICODE, 3-->GSM7 SPANISH, 4-->GSM7 DEFAULT, 5-->GSM7 PORTUGUESE*/
+	unsigned char tags; /* ¶ÌÐÅÊÕ·¢×´Ì¬ */
+	unsigned char isDelete;  //ÖÃ1ÔòÐèɾ³ý¸Ã¶ÌÐÅ
+
+	long id; // ¶ÌÐŵÄË÷Òý,webÉÏн¨¶ÌÐÅÌî-1£¬²Ý¸åÏäÖеĶÌÐÅ·¢ËÍʱЯ´øÊý¾Ý¿âΪÆä·ÖÅäµÄid
+	T_zUfiSms_Date date;
+	unsigned char draft_group_id[32]; //´æ²Ý¸åʱʹÓÃ
+} T_zUfiSms_SendReq, T_zUfiSms_SaveReq;
+
+
+#endif
diff --git a/ap/app/include/soft_timer.h b/ap/app/include/soft_timer.h
new file mode 100755
index 0000000..447e3b3
--- /dev/null
+++ b/ap/app/include/soft_timer.h
@@ -0,0 +1,169 @@
+/**
+ * @file soft_timer.h
+ * @brief Èí¶¨Ê±Æ÷Í·Îļþ
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ *
+ */
+
+#ifndef _SOFT_TIMER_H_
+#define _SOFT_TIMER_H_
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "message.h"
+#include "os_type_def.h"
+
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷µÄ×î´ó¸öÊý
+ */
+#define MAX_SOFT_TIMER_NUM 32
+
+/**
+ * @brief ¶¨Ê±Æ÷ÀàÐͱê־λucFlagµÄºê,´Ë¶¨Ê±Æ÷Ö»´¥·¢Ò»´Î
+ */
+#define TIMER_FLAG_ONCE  0
+
+/**
+ * @brief ¶¨Ê±Æ÷ÀàÐͱê־λucFlagµÄºê,´Ë¶¨Ê±Æ÷³ÖÐøÓÐЧ
+ */
+#define TIMER_FLAG_RESTART 1
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬»Øµ÷º¯ÊýΪ¿Õ
+ */
+#define SOFTTIMER_ERRCODE_CALLBACK_NULL 1
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬³õʼ»¯Ê§°Ü
+ */
+#define SOFTTIMER_ERRCODE_INIT_FAIL 	2
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬´´½¨µÄÈí¶¨Ê±Æ÷³¬¹ý×î´ó¸öÊý
+ */
+#define SOFTTIMER_ERRCODE_QUEUE_FULL 	3
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬´´½¨µÄÈí¶¨Ê±Æ÷idÒѾ­´æÔÚ
+ */
+#define SOFTTIMER_ERRCODE_TIMERID_EXIST 4
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/**
+ * @brief Ó²¼þ¶¨Ê±Æ÷µÄ²½³¤£¬10ms
+ */
+#define TIMER_STEP 10
+
+/*if the thread of soft timer is exist, 0 means not exist*/
+#define   SOFT_TIMER_THREAD_NULL  0
+#define   SOFT_TIMER_THREAD_EXIST  1
+
+#endif//#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/*¶¨ÒåÈí¼þ¶¨Ê±Æ÷µÄÊý¾Ý½á¹¹*/
+typedef struct tagSOFT_TIMER {
+	struct tagSOFT_TIMER *prev;
+	struct tagSOFT_TIMER *next;
+	int used;
+	int done;
+	int timerValue;
+
+	USHORT usTimerID;      /*¶¨Ê±Æ÷ID,ÓÃÀ´Çø·Ö²»Í¬µÄÈí¼þ¶¨Ê±Æ÷, 0±êʶ*/
+	UCHAR  ucFlag;         /*¶¨Ê±Æ÷ÀàÐͱê־λ*/
+	UCHAR  ucReserved;     /*±£Áô×Ö¶Î*/
+	ULONG  ulCurInterval;   /*µ±Ç°¶¨Ê±Æ÷³¬Ê±Ê£Óàʱ¼ä£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)£¬±ØÐ붨ÒåΪӲ¼þ¶¨Ê±Æ÷²½³¤µÄ±¶Êý*/
+	ULONG  ulNextInterval;  /*³¬Ê±ºó¶¨Ê±Æ÷ÖØÖõļä¸ô£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)*/
+	void * (*procCallBack)(void *); /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýÖ¸Õë*/
+	void   *args;                /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýµÄ²ÎÊý*/
+} SOFT_TIMER;
+
+typedef struct tagMSG_TIMERBUF {
+	LONG   lMsgType;        /*ÏûÏ¢ÀàÐÍ£¬Õâ¸öÊÇÓÃÀ´¿ØÖÆÏûÏ¢ÊÕÈ¡µÄÓÅÏÈ˳ÐòµÄ*/
+	USHORT usMsgCmd;        /*ÏûÏ¢Â룬Õâ¸öÊÇÓÃÀ´Ö¸Ê¾ÏûÏ¢µÄÄÚÈÝÊÇʲôµÄ*/
+	USHORT usDataLen;       /*Я´øµÄÓÐЧÊý¾Ý³¤¶È*/
+	UCHAR  aucDataBuf[4];   /*Я´øµÄÓÐЧÊý¾Ýbuffer,´æ·Å¶¨Ê±Æ÷index*/
+	ULONG  ulMagic;         /*ħÊõ×Ö£¬Õý³£Çé¿öÏÂֵΪMSG_MAGIC_WORD*/
+} T_TIMER_MSG_BUF;
+
+#endif//#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/*******************************************************************************
+ *                       Global variable declarations                          *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+ * @brief ´´½¨Èí¶¨Ê±Æ÷½Ó¿Ú
+ * @param usTimerID      Èë²Î£¬Èí¶¨Ê±Æ÷id£¬ÓÃÀ´Çø·Ö²»Í¬µÄÈí¼þ¶¨Ê±Æ÷
+ * @param ucFlag         Èë²Î£¬¶¨Ê±Æ÷ÀàÐͱê־λ
+ * @param ulInterval     Èë²Î£¬Èí¶¨Ê±Æ÷³¬Ê±Ê±¼ä¼ä¸ô£¬µ¥Î»£ºms
+ * @param procCallBack   Èë²Î£¬¶¨Ê±Æ÷³¬Ê±ºóµÄ»Øµ÷º¯ÊýÖ¸Õë
+ * @param args           Èë²Î£¬¶¨Ê±Æ÷³¬Ê±ºóµÄ»Øµ÷º¯Êý²ÎÊý
+ * @return OK ³É¹¦£¬ÆäËûֵʧ°Ü
+ * @retval OK  ³É¹¦
+ * @retval SOFTTIMER_ERRCODE_CALLBACK_NULL  Èí¶¨Ê±Æ÷µÄ»Øµ÷º¯ÊýµØÖ·Îª¿Õ
+ * @retval SOFTTIMER_ERRCODE_INIT_FAIL      Èí¶¨Ê±Æ÷³õʼ»¯Ê§°Ü
+ * @retval SOFTTIMER_ERRCODE_QUEUE_FULL     ´´½¨µÄÈí¶¨Ê±Æ÷³¬¹ý×î´ó¸öÊýÏÞÖÆ
+ * @retval SOFTTIMER_ERRCODE_TIMERID_EXIST  ¸ÃÈí¶¨Ê±Æ÷idÒѾ­´æÔÚ
+ * @note
+ * @warning
+ */
+LONG sc_timer_create(USHORT usTimerID,
+                     UCHAR ucFlag,
+                     ULONG ulInterval,
+                     void * (*procCallBack)(void *),
+                     void *args);
+
+/**
+ * @brief ɾ³ýÈí¶¨Ê±Æ÷½Ó¿Ú
+ * @param usTimerID   Èë²Î£¬ÒªÉ¾³ýµÄÈí¶¨Ê±Æ÷id
+ * @return OK£º³É¹¦£¬ERROR£ºÊ§°Ü
+ * @retval OK  ³É¹¦
+ * @retval ERROR  ʧ°Ü
+ * @note
+ * @warning
+ */
+LONG sc_timer_delete(USHORT usTimerID);
+
+#ifndef LIBSOFT_TIMER_API_NEW
+LONG CreateSoftTimer(USHORT usTimerID,
+                     UCHAR ucFlag,
+                     ULONG ulInterval,
+                     void * (*procCallBack)(void *),
+                     void *args);
+LONG DeleteSoftTimer(USHORT usTimerID);
+#endif
+
+/*******************************************************************************
+ *                      Inline function implementations                        *
+ ******************************************************************************/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  // #ifndef _SOFT_TIMER_H_
+
diff --git a/ap/app/include/softap_api.h b/ap/app/include/softap_api.h
new file mode 100755
index 0000000..4025e2c
--- /dev/null
+++ b/ap/app/include/softap_api.h
@@ -0,0 +1,392 @@
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/*! \mainpage
+ *
+ * <pre>
+ * ZX7520V3ƽ̨AP½Ó¿Ú£¬°üº¬ÒÔÏÂÍ·Îļþ£º
+ * softap_api.h£º ÉϲãÓ¦Óù«¹²Í·Îļþ£¬ÉϲãÓ¦Óÿª·¢°üº¬´ËÎļþ¼´¿É
+ * message.h£º    ¶¨ÒåÓ¦Óù«¹²ÏûÏ¢¶ÓÁÐkey, ÏûÏ¢Ìå, ÏûÏ¢ÃüÁîID, ·¢ËÍÏûÏ¢µÄAPI½Ó¿Ú
+ * softap_log.h£º ÉϲãÓ¦ÓÃlogÏà¹Ø½Ó¿Ú
+ * netapi.h£º     ÍøÂçÄ£¿é¶ÔÍ⹫¹²½Ó¿Ú
+ * cfg_api.h£º    AP²àÓ¦ÓÃNV¶Áд½Ó¿Ú
+ * soft_timer.h£º Èí¼þ¶¨Ê±Æ÷½Ó¿Ú
+ * rtc_timer.h:   rtc¶¨Ê±Æ÷½Ó¿Ú£¬ÊµÊ±¶¨Ê±Æ÷£¬»á»½ÐÑϵͳ
+ * at_msg.h£º     at_ctlÄ£¿éµÄÏûÏ¢idºÍÏûÏ¢½á¹¹¶¨Òå
+ * at_reg.h£º     at_ctlÄ£¿é¿Í»§¶ËºÍ·þÎñ¶Ë×¢²á½Ó¿Ú
+ * at_utils.h£º   at_ctlÄ£¿éÉú³ÉAT¶¯×÷Àà¡¢²éѯÀàÇëÇó¼°ÏìÓ¦½Ó¿Ú
+ * user_msg.h£º   AT¿Í»§¶Ë¡¢·þÎñ¶Ë¿ª·¢Ê¾Àý´úÂ룬½ö¹©²Î¿¼
+ * </pre>
+ */
+#endif
+
+/**
+ * @file softap_api.h
+ * @brief ÉϲãÓ¦Óù«¹²Í·Îļþ£¬ÉϲãÓ¦Óÿª·¢°üº¬´ËÎļþ¼´¿É
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef __SOFTAP_API_H__
+#define __SOFTAP_API_H__
+
+#include "os_type_def.h"
+#include "zxic_list.h"
+#include "cfg_api.h"
+#include "rtc_timer.h"
+#include "soft_timer.h"
+#include "wlan_interface.h"
+#include "zxic_errno.h"
+#include "netapi.h"
+#include "netioctl.h"
+#include "netotherapi.h"
+#include "at_reg.h"
+#include "at_utils.h"
+#include "at_msg.h"
+#include "at_pdp_api.h"
+#include "at_other_api.h"
+#include "sms_msg.h"
+#include "pb_msg.h"
+#include "mainctl_msg.h"
+#include "mmi_msg.h"
+#include "wifi_msg.h"
+#include "other_msg.h"
+#include "max_macro.h"
+#include <syslog.h>
+#include "softap_log.h"
+#include "audio_res_ctrl.h"
+#include "lq_msg.h"
+#include <sys/prctl.h>
+#include <sys/sysinfo.h>
+
+#define _GNU_SOURCE
+
+/**
+* @brief ¶¨ÒåÆ½Ì¨´íÎóÂë
+* 3GPP±ê×¼ATÃüÁîµÄ´íÎóÂ뷶Χ0-277, 6000-8000,¾ßÌå´íÎóÔ­Òò¿É²é¿´¡¶ZX297520V3ƽ̨ATÃüÁîÊÖ²á.doc¡·¸½Â¼A
+* @param AT_PARSE_OK				parse_param²ÎÊý½âÎöÕýÈ·
+* @param ATERR_ZXIC_ERR				ÖÐÐË΢оƬ·¢ÉúÒì³££¬ÇÒÎÞ·¨»Ö¸´£¬ÐèÒª½øÐÐÕû»úÖØÆô
+* @param ATERR_PARAM_INVALID		ÃüÁî²ÎÊýϸ½Ú²»¶Ô£¬Óë¾ßÌåATÃüÁî½ô¹ØÁª
+* @param ATERR_NOT_ALLOWED			Óë¾ßÌåÒµÎñÁ÷³Ì³åÍ»£¬²Ù×÷²»ÔÊÐí
+* @param ATERR_PROC_FAILED			ÃüÁî´¦Àíʧ°Ü£¬ÊôÓÚsoftapϵͳÒì³££¬ÈçÏûÏ¢·¢ËÍʧ°ÜµÈ
+* @param ATERR_DROP_MARK			Ë«ÒýºÅ¶ªÊ§Ò»¸ö£¬¿ÉÄÜÊǶª¶ººÅÔì³ÉµÄÆ«ÒÆ
+* @param ATERR_NO_PRINT				×Ö·û´®ÄÚÈÝ·ÇASCIIÃ÷ÎÄ£¬¿ÉÄÜÊǶª¶ººÅÔì³ÉµÄÆ«ÒÆ
+* @param ATERR_STR_TOO_LONG			ASCII×Ö·û´®¶ÁÈ¡µÄ³¤¶È³¬¹ý½âÎöÔ¼¶¨µÄ³¤¶È£¬¿ÉÄÜÊÇÍⲿÊäÈëµÄATÃüÁî²»ºÏ·¨
+* @param ATWARN_DROP_RN				ʵ¼Ê×Ö·û´®²ÎÊý¸öÊý´óÓÚfmt¸ñʽ»¯¸öÊý£¬¿ÉÄÜÊǵ÷ÓÃÕßÖ»¹ØÐIJ¿·Ö²ÎÊý£¬Ðè½÷É÷´¦Àí¸ÃºêÖµ
+* @param ATWARN_LACK_PARAM			°´ÕÕÈë²Î¸ñʽfmt½âÎö£¬ÄÚÈÝȱÉÙ²ÎÊý£¬ÓÉÓÚ²ÎÊý¿ÉÑ¡£¬¿ÉÄÜÊÇÕý³£µÄ£¬Ðè½÷É÷ʹÓøúêÖµ
+* @param ATERR_MEM_LESS				ÖÐÐË΢оƬÄÚ²¿ÄÚ´æ²»×ãÔì³ÉÎÞ·¨½ÓÊÕµ±Ç°ATÃüÁî
+* @param ATERR_WAIT_REQ_END_TIMEOUT	µÈ´ýÍⲿÊäÈëµÄREQÇëÇóÃüÁî½áÊø·û\r³¬Ê±
+* @param ATERR_WAIT_RSP_TIMEOUT		·¢ËÍÍêATÇëÇóºó£¬µÈ´ýÔ¶¶ËRSPÓ¦´ð½á¹û³¬Ê±
+* @param ATERR_CHANNEL_BUSY			µ±Ç°ATͨµÀÕýÔÚ´¦ÀíATÇëÇó£¬ÓÖÊÕµ½Ò»ÌõATÇëÇ󱨴í
+* @param ATERR_UNKNOWN_CMD			ÍⲿÊäÈëµÄÃüÁî²»¿Éʶ±ð£¬Îª·Ç·¨µÄATÃüÁî
+* @param ATERR_PARAM_CHECKSUM		¶ÔÓÚ½ÓÊÕµ½µÄATÃüÁî²ÎÊý½øÐÐchecksumУÑéʧ°Ü
+* @param ATERR_PPP_FILE_FAILED		PPPÎļþ²Ù×÷ʧ°Ü
+* @param ATERR_PPP_NOT_EXISTED		PPPD²»´æÔÚ
+* @param ATERR_PPP_WRONG_CHAN		PPPͨµÀ´íÎó
+* @param ATERR_PDP_IPADDR_FAILED	»ñÈ¡PDPµØÖ·Ê§°Ü
+* @param USER_EXTAND_ERR_BASE		³¬¹ý9000µÄΪÓëÍⲿMCUÏà¹ØµÄ¶¨ÖÆ´íÎóÂ룬ÐèÒªÍⲿMCUÓû§°´ÕÕ´íÎóÂë½øÐÐÏà¹ØÈÝ´í¶¯×÷
+*/
+enum SAP_ERR {
+    AT_PARSE_OK             = 0,      /*parse_param²ÎÊý½âÎöÕýÈ·*/
+    ATERR_ZXIC_ERR          = 8000,   /*ÖÐÐË΢оƬ·¢ÉúÒì³££¬ÇÒÎÞ·¨»Ö¸´£¬ÐèÒª½øÐÐÕû»úÖØÆô*/
+    ATERR_PARAM_INVALID     = 8001,   /*ÃüÁî²ÎÊýϸ½Ú²»¶Ô£¬Óë¾ßÌåATÃüÁî½ô¹ØÁª*/
+    ATERR_NOT_ALLOWED       = 8002,   /*Óë¾ßÌåÒµÎñÁ÷³Ì³åÍ»£¬²Ù×÷²»ÔÊÐí*/
+    ATERR_PROC_FAILED       = 8003,   /*ÃüÁî´¦Àíʧ°Ü£¬ÊôÓÚsoftapϵͳÒì³££¬ÈçÏûÏ¢·¢ËÍʧ°ÜµÈ*/
+    ATERR_DROP_MARK         = 8004,   /*Ë«ÒýºÅ¶ªÊ§Ò»¸ö£¬¿ÉÄÜÊǶª¶ººÅÔì³ÉµÄÆ«ÒÆ*/
+    ATERR_NO_PRINT          = 8005,   /*×Ö·û´®ÄÚÈÝ·ÇASCIIÃ÷ÎÄ£¬¿ÉÄÜÊǶª¶ººÅÔì³ÉµÄÆ«ÒÆ*/
+    ATERR_STR_TOO_LONG      = 8006,   /*ASCII×Ö·û´®¶ÁÈ¡µÄ³¤¶È³¬¹ý½âÎöÔ¼¶¨µÄ³¤¶È£¬¿ÉÄÜÊÇÍⲿÊäÈëµÄATÃüÁî²»ºÏ·¨*/
+    ATWARN_DROP_RN          = 8007,   /*ʵ¼Ê×Ö·û´®²ÎÊý¸öÊý´óÓÚfmt¸ñʽ»¯¸öÊý£¬¿ÉÄÜÊǵ÷ÓÃÕßÖ»¹ØÐIJ¿·Ö²ÎÊý£¬Ðè½÷É÷´¦Àí¸ÃºêÖµ*/
+    ATWARN_LACK_PARAM       = 8008,   /*°´ÕÕÈë²Î¸ñʽfmt½âÎö£¬ÄÚÈÝȱÉÙ²ÎÊý£¬ÓÉÓÚ²ÎÊý¿ÉÑ¡£¬¿ÉÄÜÊÇÕý³£µÄ£¬Ðè½÷É÷ʹÓøúêÖµ*/
+    ATERR_MEM_LESS          = 8009,   /*ÖÐÐË΢оƬÄÚ²¿ÄÚ´æ²»×ãÔì³ÉÎÞ·¨½ÓÊÕµ±Ç°ATÃüÁî*/
+    ATERR_WAIT_REQ_END_TIMEOUT = 8010, /*µÈ´ýÍⲿÊäÈëµÄREQÇëÇóÃüÁî½áÊø·û\r³¬Ê±*/
+    ATERR_WAIT_RSP_TIMEOUT  = 8011,   /*·¢ËÍÍêATÇëÇóºó£¬µÈ´ýÔ¶¶ËRSPÓ¦´ð½á¹û³¬Ê±*/
+    ATERR_CHANNEL_BUSY      = 8012,   /*µ±Ç°ATͨµÀÕýÔÚ´¦ÀíATÇëÇó£¬ÓÖÊÕµ½Ò»ÌõATÇëÇ󱨴í*/
+    ATERR_UNKNOWN_CMD       = 8013,   /*ÍⲿÊäÈëµÄÃüÁî²»¿Éʶ±ð£¬Îª·Ç·¨µÄATÃüÁî*/
+    ATERR_PARAM_CHECKSUM    = 8014,   /*¶ÔÓÚ½ÓÊÕµ½µÄATÃüÁî²ÎÊý½øÐÐchecksumУÑéʧ°Ü*/
+    ATERR_PPP_FILE_FAILED   = 8100,   /*PPPÎļþ²Ù×÷ʧ°Ü*/
+    ATERR_PPP_NOT_EXISTED   = 8101,   /*PPPD²»´æÔÚ*/
+    ATERR_PPP_WRONG_CHAN    = 8102,   /*PPPͨµÀ´íÎó*/
+    ATERR_PDP_IPADDR_FAILED = 8200,   /*»ñÈ¡PDPµØÖ·Ê§°Ü*/
+    USER_EXTAND_ERR_BASE    = 9000,   /*³¬¹ý9000µÄΪÓëÍⲿMCUÏà¹ØµÄ¶¨ÖÆ´íÎóÂ룬ÐèÒªÍⲿMCUÓû§°´ÕÕ´íÎóÂë½øÐÐÏà¹ØÈÝ´í¶¯×÷*/
+};
+
+
+/**
+ * @brief ´¦Àí×÷Ϊ·þÎñ¶ËµÄÊÕµ½µÄÇëÇóÃüÁî¡£at_parasΪATÃüÁî²ÎÊýÊ×µØÖ·£¬rsp_cmdΪӦ´ð½á¹û×Ö·û´®£¬×÷Ϊ³ö²Î´æÔÚ£»Ò»°ãµÄ£¬Óû§ÔڸýӿڵľßÌåʵÏÖʱ£¬
+ * ÄÚ²¿µ÷ÓÃparse_param½Ó¿Ú½øÐвÎÊý½âÎö£¬²¢¸ù¾Ý·µ»ØÖµ½øÐвÎÊýÓÐЧÐÔ¼ì²é£¬ÒÔ·ÀÖ¹ÍⲿMCUÓëZXICоƬ¼äµÄÎïÀí´®¿ÚͨÐÅÒì³£Ôì³ÉATÃüÁîÊý¾Ý´íÎó¡£
+ * ¶ÔÓÚͬ²½Ó¦´ðÀ©Õ¹ATÇëÇ󣬱ØÐëÔÚ½Ó¿ÚÄÚ²¿Îªrsp_cmdÉêÇëÄÚ´æ¿Õ¼ä£¬²¢¸³ÖµÖмäÉϱ¨ºÍ½á¹ûÂ룬²¢·µ»ØAT_END£»
+ * ¶ÔÓÚÐèÒª·¢Ë͸ø¿Í»§Ó¦Óýø³Ì½øÐд¦ÀíµÄ£¬Óɿͻ§ÔÚ×¢²áº¯ÊýÄÚ²¿½øÐÐÒì²½½»»¥£¬²¢·µ»ØAT_CONTINUE,atctlÖ÷¿Ø×èÈûµ±Ç°ATͨµÀ£»Ö±µ½Óû§½ø³Ìµ÷ÓÃ
+ * send_rsp_str_to_farps½Ó¿Ú½«Ó¦´ð½á¹û·¢Ë͸øatctl£¬ÔÙÓÉatctl·¢Ë͸øÍⲿMCU£¬²¢ÊÍ·ÅATͨµÀ
+ * @param res_msg		 µ±ÊÇͬ²½Ó¦´ð·½Ê½Ê±£¬Èô*res_msg²»ÎªNULL£¬ÔòÄÚÈÝΪӦ´ð½á¹ûÂ룬ÓÉat_ctl·¢Ë͸øÍⲿMCUºóÊÍ·ÅATͨµÀ£»
+ 						 Èô*res_msgΪNULL£¬ÓÉat_ctlÖ±½Ó»Ø¸´\r\nOK\r\n·¢Ë͸øÍⲿMCUºóÊÍ·ÅATͨµÀ
+ *						 µ±ÊÇÓ¦Óýø³ÌÒì²½·½Ê½´¦Àíʱ£¬*res_msg±ØÐëΪNULL£¬´Ëʱ»á³¤Ê±¼ä¶ÂÈûסATͨµÀ£¬Ö±ÖÁÓû§½ø³Ìµ÷ÓÃsend_rsp_str_to_farps½Ó¿Ú½â×èÈûATͨµÀ
+ * @return intÐͽá¹ûÂ룬AT_END±íʾͬ²½Ó¦´ð·½Ê½£»AT_CONTINUE±íʾÒì²½Ó¦´ð·½Ê½£¬ÐèÒªÓ¦Óýø³ÌÒì²½½»»¥
+ * @note
+ */
+typedef int (*ser_req_func)(char *at_paras, void ** res_msg);
+
+/**
+ * @brief ¶ÔÓÚÉϱ¨atÃüÁî´¦Àíº¯Êý£¬°üº¬²éѯÖмä½á¹ûºÍÖ÷¶¯Éϱ¨µÄatÃüÁî´¦Àí
+ *	¶ÔÓÚpsÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨£¬Ò»°ãÎÞÐ轫Éϱ¨ÄÚÈÝ·¢Ë͸øÆäËûÄ£¿éÓ¦Óã¬Òò´Ë¾¡Á¿Ê¹ÓÃnvºÍÈ«¾Ö±äÁ¿µÄ·½Ê½´æ·Å
+ *	¶ÔÓÚÀ©Õ¹atµÄÖмä½á¹ûÉϱ¨£¬Ò»°ãÐèÒª½«²éѯ½á¹û·¢Ë͸øÆäËûÄ£¿éÓ¦Ó㬶¯Ì¬ÉêÇëÄڴ棬·ÅÔÚcontextÉÏÏÂÎÄÖеÄapp_para±äÁ¿ÖÐ
+ * @param at_paras	ATÃüÁî×Ö·û´®
+ * @param is_query_report
+ * @return intÐÍ×Ö·û´®
+ */
+
+typedef int (*inform_act_func)(char *at_paras, int is_query_report);
+
+
+/**
+* @brief ½ø³Ì¼äͨÐÅÏûÏ¢·¢Ëͽӿڣ¬Èç¹ûÏûÏ¢¶ÓÁÐδ´´½¨£¬·µ»ØÊ§°ÜֵΪ-1
+* @param source_id(IN)	:ÏûÏ¢·¢ËÍÄ£¿éID
+* @param target_id(IN)	:ÏûÏ¢½ÓÊÕÄ£¿éID
+* @param Msg_cmd(IN)  	:ÏûÏ¢ÃüÁÓÃÓÚ½ÓÊÕÄ£¿é´¦ÀíÏûϢʱ£¬È·¶¨ÏûÏ¢´¦ÀíµÄ·½Ê½
+* @param us_DataLen(IN)	:ÏûÏ¢ÖÐЯ´øÊý¾ÝµÄ³¤¶È
+* @param pData(IN)		:ÏûÏ¢ÖÐЯ´øµÄÊý¾ÝÄÚÈÝ
+* @param msgflag(IN)		:ÏûÏ¢µÄ·¢ËÍ·½Ê½£¬0±íʾ×èÈû·¢ËÍ£¬IPC_NOWAIT±íʾ·Ç×èÈû·¢ËÍ
+* @return ·¢Ëͳɹ¦·µ»Ø0£¬·¢ËÍʧ°Ü·µ»Ø·Ç0£¬¾ßÌå´íÎóÀàÐÍÇë²Î¿¼linux±ê×¼µÄerrnoÀàÐÍ
+* @note ·¢ËÍʧ°Ü£¬Ó¦ÓÃÅжÏerrno == ENOENT, ±íʾ¶ÓÁÐÂú£»Èô½ÓÊÕ·½Ò»¶¨»á±»Æô¶¯£¬·¢ËÍ·½¿É¼ÌÐøµ÷ÓÃipc_send_msg2½Ó¿Ú
+*/
+int ipc_send_message(int src_id, int dst_id, unsigned short Msg_cmd, unsigned short us_DataLen, unsigned char *pData, int msgflag);
+
+/**
+* @brief ½ø³Ì¼äͨÐÅÏûÏ¢·¢Ëͽӿڣ¬Èç½ÓÊÕÓ¦ÓÃÒ»¶¨»áÆô¶¯Ê±£¬·¢ËÍ·½µ÷Óøýӿڣ¬Èç¹ûÏûÏ¢¶ÓÁÐδ´´½¨£¬»á×Ô¶¯´´½¨ÏûÏ¢¶ÓÁÐ
+* @param source_id(IN)	:ÏûÏ¢·¢ËÍÄ£¿éID
+* @param target_id(IN)	:ÏûÏ¢½ÓÊÕÄ£¿éID
+* @param Msg_cmd(IN)  	:ÏûÏ¢ÃüÁÓÃÓÚ½ÓÊÕÄ£¿é´¦ÀíÏûϢʱ£¬È·¶¨ÏûÏ¢´¦ÀíµÄ·½Ê½
+* @param us_DataLen(IN)	:ÏûÏ¢ÖÐЯ´øÊý¾ÝµÄ³¤¶È
+* @param pData(IN)		:ÏûÏ¢ÖÐЯ´øµÄÊý¾ÝÄÚÈÝ
+* @param msgflag(IN)		:ÏûÏ¢µÄ·¢ËÍ·½Ê½£¬0±íʾ×èÈû·¢ËÍ£¬IPC_NOWAIT±íʾ·Ç×èÈû·¢ËÍ
+* @return ·¢Ëͳɹ¦·µ»Ø0£¬·¢ËÍʧ°Ü·µ»Ø·Ç0£¬¾ßÌå´íÎóÀàÐÍÇë²Î¿¼linux±ê×¼µÄerrnoÀàÐÍ
+* @note ´Ë½Ó¿ÚÓÃÓÚÏûÏ¢²»×¼¶ªÊ§µÄ³¡¾°£¬¼´: Ä¿±êÓ¦ÓÃÒ»¶¨»áÆô¶¯´¦Àí´ËÏûÏ¢£¬µ«ÓÐʱ´æÔÚ·¢ËÍÏûϢʱĿ±êÓ¦ÓÃÉÐδÆô¶¯
+*       Èç: ¿ª»ú³õʼ»¯Ê±Ò»Ð©ÌØÊâÏûÏ¢ÈçÈȲå°ÎʼþÉϱ¨¶ø½ÓÊÕÓ¦ÓÃÉÐδÆô¶¯£¬½ÓÊÕ¶ÓÁÐÉÐδ´´½¨
+*/
+int ipc_send_message2(int src_id, int dst_id, unsigned short Msg_cmd, unsigned short us_DataLen, unsigned char *pData, int msgflag);
+
+
+/**
+ * @brief ATÃüÁî½âÎö½Ó¿Ú
+ * @param fmt ATÇëÇó»òÏìÓ¦µÄ¸ñʽ»¯·½Ê½
+ * @param buf  ATÇëÇó»òÏìÓ¦µÄ×Ö·û´®Ö¸Õë²»º¬Í·²¿ºÍ¿Õ¸ñ
+ * @param pval	¸ñʽ»¯ºóµÄATÃüÁî
+ * @return 0±íʾ½âÎö²ÎÊýÕý³££¬²»½øÐвÎÊý¸öÊýµÄÓÐЧÐÔ¼ì²é£¬¾ßÌå·µ»ØÖµ²Î¿´¸ÃÍ·ÎļþSAP_ERRö¾ÙÀàÐÍÖÐAT_PARSE_OKµÈºêÖµ
+ * @note  
+ * 1. ½âÎöµÄATÃüÁî±ØÐë°´ÕÕ3GPP27007±ê׼ЭÒ飬²ÎÊýÒÔ¶ººÅ¸ô¿ª£¬×Ö·û´®Ðè´øË«ÒýºÅ£¬·ñÔò»á¶ÏÑÔ
+ * 2. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç
+ * 3. ·µ»ØÖµÇë²Î¿¼Ã¶¾Ùenum SAP_ERR,²»½øÐвÎÊý¸öÊýµÄÓÐЧÐÔ¼ì²é
+ * 4. ÈôfmtÖ¸¶¨µÄ²ÎÊýÀàÐͱØÐëÓëpvalÖÐÖ¸ÕëµÄÒ»Ò»¶ÔÓ¦
+ * 5. ʾÀý
+<pre>
+	char buf[]="1,2,\"test\"";
+	int n1 = 0;
+	int n2 = 0;
+	char *n3 = malloc(strlen(buf));
+	char *p[] = {&n1,&n2,n3};
+	ret = parse_param("%d,%d,%s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="test"	 
+	ret = parse_param("%4d,%d,%3s", buf, (void**)p);
+	//½âÎöºón1==1 n2==2 n3=="te"	 
+</pre>
+ * @warning 
+ */
+int  parse_param(char *fmt, char *buf, void **pval);
+
+
+/**
+ * @brief Ó¦Ó÷¢ËͶ¯×÷Àà»ò²éѯÀàATÇëÇó¸ø3GPPЭÒéÕ»£¬²¢×èÈûµÈ´ý¶¯×÷½á¹û£»×¢Ò⣺¸Ã½Ó¿ÚÖ»ÄÜÓÃÓÚ²éѯºÍÉèÖúÍÖ´ÐÐÇëÇó£¬Í¨¹ýÈë²Î½øÐÐÖмä½á¹ûµÄÄÚ²¿½âÎö´¦Àí£¬²¢ÇÒ
+		  ÓÐÖмä½á¹ûÉϱ¨Ê±£¬Ö»Ö§³ÖÒ»ÌõÖмä½á¹ûµÄÉϱ¨½âÎö£»
+ * @param req_at  ÇëÇóATÃüÁ´óСдÃô¸Ð£¬±ØÐë´óд
+ * @param info_fmt ATÏìÓ¦µÄ¸ñʽ»¯·½Ê½
+ * @param pval	¸ñʽ»¯ºóµÄATÏìÓ¦£¬¾ßÌåʹÓòο´parse_param½Ó¿Ú
+ * @return 0±íʾ·µ»Ø³É¹¦£¬ÆäËûÖµ±íʾʧ°Ü´íÎóÂë
+ * @note  
+ * 1. Óû§Ê¹ÓÃʱ£¬Èô²»ÏëÓɸýӿÚÄÚ²¿½øÐвÎÊýµÄ¸ñʽ»¯½âÎö£¬¿ÉÒÔ½«info_fmt¸³ÖµÎª"%s"£¬pval¸³ÖµÎªchar **p˫ָÕ룬ÕâÑù²ÎÊý½«×÷ΪÕûÌå×Ö·û´®·µ»Ø¸øµ÷ÓÃÕß
+ * 2. ¶ÔÓÚZMGL,CPBR, COPS=?µÈÒ»ÌõÇëÇó»áÓжàÌõÖмä½á¹ûÇé¿ö£¬¸Ãº¯Êý²»ÊÊÓÃ
+ * 3. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç
+ * 4. µ±´æÔÚÖмäÉϱ¨Ê±£¬pvalºÍinfo_fmt²»Îª¿Õ£»µ±ÎªÖмäÉϱ¨Ê±£¬Á½¸ö±ØÐë½ÔΪ¿Õ
+ * 5. pvalºÍinfo_fmtÁ½ÕßҪô¶¼ÎªNULL,Ҫô¶¼²»ÎªNULL£¬²»ÄÜ´æÔÚÆäÖÐÒ»¸öΪNULL£¬ÁíÒ»¸ö²»ÎªNULLµÄÇé¿ö
+ * 6. ʾÀý
+<pre>
+	int ret = 0;
+	ret = get_modem_info("AT+CFUN=1\r", NULL,  NULL);
+	//·µ»Ø¼´±íʾִÐгɹ¦
+
+	char *pstr = malloc(50);
+	memset(pstr,0,50);
+	ret = get_modem_info("AT+CIMI\r", "%s",  (void**)&pstr);
+	//·µ»Øºópstr==111111111111111
+
+	int n1 = 0;
+	int n2 = 0;
+	int n3 = 0;
+	char *p2[] = {&n1,&n2,&n3};
+	ret = get_modem_info("AT+CCIOTOPT?\r", "%d,%d,%d",	(void**)p2);
+	//+CCIOTOPT: 1,2,3½âÎöºón1==1 n2==2 n3==3
+</pre>
+ * @warning 
+ */
+int  get_modem_info(char *req_at,char *info_fmt,void **pval);
+
+
+/**
+ * @brief Ó¦Ó÷¢ËͶ¯×÷Àà»ò²éѯÀàATÇëÇó¸øÍⲿMCU£¬²¢×èÈûµÈ´ý¶¯×÷½á¹û£¬Ö»Ö§³ÖÒ»ÌõÖмä½á¹ûµÄÉϱ¨½âÎö£»
+ * ÓÉÓÚ´®¿ÚͨÐÅ´æÔÚ¶ªÊý¾Ý¿ÉÄÜ£¬¼ì²âµ½ÖмäÉϱ¨»òÓ¦´ð½á¹ûÓдíÎóʱ£¬»á½øÐÐÖØ·¢³¢ÊÔ£¬Ä¿Ç°ÖØ·¢3´Îºó»á¶ÏÑÔ£»
+ * À©Õ¹ATÃüÁÒåµÄ´íÎóÂ볬¹ý9000£¬²»½øÐÐÖØ·¢³¢ÊÔ
+ * @param req_at  ÇëÇóATÃüÁ´óСдÃô¸Ð£¬±ØÐë´óд
+ * @param len     ÇëÇóATÃüÁîµÄ³¤¶È
+ * @param info_fmt ATÏìÓ¦µÄ¸ñʽ»¯·½Ê½
+ * @param pval	¸ñʽ»¯ºóµÄATÏìÓ¦£¬£¬¾ßÌåʹÓòο´parse_param½Ó¿Ú
+ * @param safe_parm_check	ָʾÊÇ·ñ¶Ô²ÎÊý¸öÊý½øÐÐÒ»ÖÂÐÔ¼ì²é£¬0±íʾº¬¿ÉÑ¡²ÎÊý£¬²»¶Ô²ÎÊý¸öÊý½øÐмì²é;1±íʾ¶Ô²ÎÊý¸öÊý½øÐÐÑϸñ¼ì²é
+ * @param timeout timeout==0 ±íʾÓÀ¾ÃµÈ´ý½á¹ûÂ룬·ñÔòµÈ´ýʱ¼äΪ[timeout]Ãë
+ * @return 0±íʾ·µ»Ø³É¹¦£¬ÆäËûÖµ±íʾʧ°Ü´íÎóÂë
+ * @note  
+ * 1. Óû§Ê¹ÓÃʱ£¬Èô²»ÏëÓɸýӿÚÄÚ²¿½øÐвÎÊýµÄ¸ñʽ»¯½âÎö£¬¿ÉÒÔ½«info_fmt¸³ÖµÎª"%s"£¬pval¸³ÖµÎªchar **p˫ָÕ룬ÕâÑù²ÎÊý½«×÷ΪÕûÌå×Ö·û´®·µ»Ø¸øµ÷ÓÃÕß
+ * 2. ¶ÔÓÚZMGL,CPBR, COPS=?µÈÒ»ÌõÇëÇó»áÓжàÌõÖмä½á¹ûÇé¿ö£¬¸Ãº¯Êý²»ÊÊÓÃ
+ * 3. ×Ö·û´®½âÎöʱµÄÈë²Î³¤¶È±ØÐë´óÓÚ¿ÉÄܽâ³öµÄ×Ö·û´®³¤¶È£¬·ñÔò»áÔ½½ç
+ * 4. µ±´æÔÚÖмäÉϱ¨Ê±£¬pvalºÍinfo_fmt²»Îª¿Õ£»µ±ÎªÖмäÉϱ¨Ê±£¬Á½¸ö±ØÐë½ÔΪ¿Õ
+ * 5. pvalºÍinfo_fmtÁ½ÕßҪô¶¼ÎªNULL,Ҫô¶¼²»ÎªNULL£¬²»ÄÜ´æÔÚÆäÖÐÒ»¸öΪNULL£¬ÁíÒ»¸ö²»ÎªNULLµÄÇé¿ö
+ * 6. ʾÀý
+<pre>
+	int ret = 0;
+	ret = send_reqat_to_farps("AT+CFUN=1\r", NULL,  NULL, 0);
+	//·µ»Ø¼´±íʾִÐгɹ¦
+
+	char *pstr = malloc(50);
+	memset(pstr,0,50);
+	ret = send_reqat_to_farps("AT+CIMI\r", "%3s",  (void**)&pstr, 3000);
+	//·µ»Øºópstr==111111111111111, pstrÖÐ×Ö·ûÊýÄ¿×î´óΪ2
+
+	int n1 = 0;
+	int n2 = 0;
+	int n3 = 0;
+	char *p2[] = {&n1,&n2,&n3};
+	ret = send_reqat_to_farps("AT+CCIOTOPT?\r", "%d,%d,%d",	(void**)p2, 5000);
+	//+CCIOTOPT: 1,2,3½âÎöºón1==1 n2==2 n3==3,×î´óµÈʱ¼äΪ5000ms
+</pre>
+ * @warning 
+ */
+int  send_reqat_to_farps(char *req_at,int len,char *info_fmt,void **pval, int safe_parm_check, int timeout);
+
+
+/**
+ * @brief ÓÃÓÚ¿ª»ú×¢²áËùÓеķþÎñ¶Ë¾ßÌåATÃüÁîʼþ£¬³£ÓÃÓÚÉϲ㼰¿Í»§¶¨ÖÆ£¬²»×¼ÓÃÓÚPSЭÒéÕ»¡£
+ * @param at_cmd_prefix	 ATÃüÁîǰ׺ָÕë
+ * @param module_id      Ô´Ä£¿é¶ÓÁÐid
+ * @param req_rcv_act    ¾ßÌ庬Òå²Î¼ûtypedef int (*ser_req_func)(char *at_paras, void ** res_msg)½Ó¿Ú˵Ã÷
+ * @return intÐͽá¹ûÂë
+ * @retval ³É¹¦ 0
+ * @note ¸Ã×¢²áº¯ÊýÓëregister_serv_func2µÄÇø±ðÊÇÈë²ÎÖ»ÓÐat_cmd_prefix¡¢module_idºÍreq_rcv_act
+ *  at_ctlÊÕµ½ATÃüÁîºó£¬µ÷ÓÃ×¢²áµÄreq_rcv_act£¬at_ctlÄÜ·µ»Ø´¦Àí½á¹û£¬Ö±½Ó½«½á¹ûÂë·¢Ë͸øÍⲿMCU£¬
+ ·ñÔò£¬ÊÕµ½Íⲿ·¢Ë͵ÄATÇëÇó£¬Í¨¹ýÏûÏ¢MSG_CMD_SEND_REQ_TO_APP·¢Ë͸øÓ¦Ó㬠
+ Ó¦Óô¦Àíºóͨ¹ýµ÷Óú¯Êýsend_rsp_str_to_farps£¬ÓÉat_ctl½«Ó¦´ð½á¹û·¢Ë͵½ÍⲿMCU
+ */
+int  register_serv_func(char *at_cmd_prefix, int  module_id, ser_req_func req_rcv_act);
+
+
+/**
+ * @brief ×¢²áÉϱ¨ATÃüÁîµÄʼþ´¦Àí£¬°üÀ¨²éѯÖмä½á¹ûÉϱ¨ºÍÖ÷¶¯Éϱ¨¡£
+ * @param at_cmd_prefix	 ATÃüÁîǰ׺ָÕë
+ * @param inform_act     ½ÓÊÕµ½ATÃüÁîÖмä½á¹ûºÍÖ÷¶¯Éϱ¨ºóµÄ´¦Àíº¯Êý
+ * @return intÐͽá¹ûÂë
+ * @retval ³É¹¦ 0, ʧ°Ü -1
+ * @note ÏàͬµÄÃüÁîǰ׺¿ÉÒÔÖØ¸´×¢²á¶à¸ö£¬at_ctl¿ò¼ÜÔÚÊÕµ½Ö÷¶¯Éϱ¨»òÖмä½á¹ûʱ£¬±éÀúÁ´±í£¬Ã¿¸öÖ´Ðк¯Êý¶¼»áÖ´ÐÐÒ»±é¡£
+ * ÕâÑù£¬Èç¹ûÊÇÖмä½á¹û£¬¾Í¿ÉÄܱ»µ±³ÉÖ÷¶¯Éϱ¨Éϱ¨¸øÓ¦Óã¬ÓÉÓ¦ÓùýÂËÎÞЧµÄÖ÷¶¯Éϱ¨ÏûÏ¢
+ */
+int  register_inform_func(char *at_cmd_prefix, inform_act_func inform_act);
+
+
+/**
+  * @brief ·þÎñ¶ËÓ¦ÓóÌÐò£¬·¢ËÍÖмä½á¹ûºÍÏìÓ¦µ½ÍⲿMCU
+  * @param module_id	  Ó¦ÓÃÄ£¿é¶ÓÁÐid
+  * @param rsp_cmd		  ´ý·¢Ë͵½ÍⲿMCUµÄÊý¾Ý
+  * @param rsp_len		  ÃüÁ¶È
+  * @return intÐͽá¹ûÂë
+  * @retval ³É¹¦ 0, ʧ°Ü -1
+  * @note 
+  */
+int send_rsp_str_to_farps(int	module_id, char *rsp_cmd,int rsp_len);
+
+
+/**
+ * @brief Éú³ÉatÏìÓ¦½á¹ûERRORº¯Êý
+ * @param param  ERRORµÄ´íÎóÂë
+ * @return atÏìÓ¦½á¹ûERROR×Ö·û´®µÄÖ¸Õë
+ * @note ÓÉat_ctl¸ºÔðÊÍ·ÅÄÚ´æ
+ */
+char* at_err_build(int param);
+
+/**
+ * @brief ·¢Æð¹Ø»úÇëÇó
+ * @param src_id ·¢Æð·½Ä£¿éid£¬Î´ÉêÇë¿ÉÒÔÌî0
+ * @return ·¢Ëͽá¹û£¬0³É¹¦£¬·Ç0ʧ°Ü
+ */
+int poweroff_request(int src_id);
+
+/**
+ * @brief ·¢ÆðÖØÆôÇëÇó
+ * @param src_id ·¢Æð·½Ä£¿éid£¬Î´ÉêÇë¿ÉÒÔÌî0
+ * @return ·¢Ëͽá¹û£¬0³É¹¦£¬·Ç0ʧ°Ü
+ */
+int restart_request(int src_id);
+
+/**
+ * @brief ·¢Æð»Ö¸´³ö³§ÉèÖÃÇëÇó
+ * @param src_id ·¢Æð·½Ä£¿éid£¬Î´ÉêÇë¿ÉÒÔÌî0
+ * @return ·¢Ëͽá¹û£¬0³É¹¦£¬·Ç0ʧ°Ü
+ */
+int reset_request(int src_id);
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/**
+* @brief ½ø³Ì¼äͨÐÅÏûÏ¢·¢ËͽӿÚ
+* @param position(IN)	:ÏûÏ¢·¢ËÍ·½Ïò
+* @param msg_cmd(IN)	:ÏûÏ¢ÃüÁÓÃÓÚ½ÓÊÕÄ£¿é´¦ÀíÏûϢʱ£¬È·¶¨ÏûÏ¢´¦ÀíµÄ·½Ê½
+* @param len(IN)  	    :ÏûÏ¢¶ÔÓ¦½á¹¹ÌåÊý¾Ý³¤¶È
+* @param msg(IN)	 	:ÏûÏ¢¶ÔÓ¦½á¹¹ÌåÊý¾Ý
+* @return ·¢Ëͳɹ¦·µ»Ø0£¬·¢ËÍʧ°Ü·µ»Ø·Ç0£¬¾ßÌå´íÎóÀàÐÍÇë²Î¿¼linux±ê×¼µÄerrnoÀàÐÍ
+* @note Éæ¼°ºË¼õÏûÏ¢´«µÝ£¬½öÄÚ²¿Ê¹Óá£
+*/
+int send_soc_msg(unsigned short position, int dst_id, unsigned short msg_cmd, unsigned short len, void *msg);
+
+/**
+* @brief ½ø³Ì¼äͨÐż°ºË¼äͨÐÅÏûÏ¢·¢ËÍͨÓýӿÚ
+* @param src_id(IN)		:ÏûÏ¢·¢ËÍÄ£¿éID
+* @param dst_id(IN)		:ÏûÏ¢½ÓÊÕÄ£¿éID
+* @param msg_cmd(IN)	:ÏûÏ¢ÃüÁÓÃÓÚ½ÓÊÕÄ£¿é´¦ÀíÏûϢʱ£¬È·¶¨ÏûÏ¢´¦ÀíµÄ·½Ê½
+* @param datalen(IN)	:ÏûÏ¢¶ÔÓ¦½á¹¹ÌåÊý¾Ý³¤¶È
+* @param pData(IN)		:ÏûÏ¢¶ÔÓ¦½á¹¹ÌåÊý¾Ý
+* @return ·¢Ëͳɹ¦·µ»Ø0£¬·¢ËÍʧ°Ü·µ»Ø·Ç0£¬¾ßÌå´íÎóÀàÐÍÇë²Î¿¼linux±ê×¼µÄerrnoÀàÐÍ
+* @note Éæ¼°ºË¼õÏûÏ¢´«µÝ£¬½öÄÚ²¿Ê¹Óá£
+*/
+int platform_send_msg(int src_id, int dst_id, unsigned short msg_cmd, unsigned short datalen, unsigned char *pData);
+
+/**
+* @brief   ƽ̨ÄÚ´íÎó¸ú×Ù
+* @param   err(IN):
+* @return
+*/
+void zxic_err_track(int err);
+
+/**
+* @brief    ¼ì²éĬÈÏ·ÓÉÊÇ·ñÅäÖóɹ¦
+* @return  ÅäÖóɹ¦·µ»Ø1, ²»³É¹¦·µ»Ø-1
+*/
+int default_route_check();
+
+extern long long int get_time_us();
+
+extern int soft_system(const char *command);
+
+#endif
+
+/**
+*brief 	»ñȡϵͳÆô¶¯Ê±¼ä
+*return ·µ»ØÏµÍ³×Ô¿ª»úµ½ÏÖÔÚµÄʱ¼ä¼ä¸ô£¬µ¥Î»ÎªÃë
+*/
+long get_sys_uptime();
+
+#endif
diff --git a/ap/app/include/softap_log.h b/ap/app/include/softap_log.h
new file mode 100755
index 0000000..88ac791
--- /dev/null
+++ b/ap/app/include/softap_log.h
@@ -0,0 +1,97 @@
+#ifndef _SOFTAP_LOG_H_
+#define _SOFTAP_LOG_H_
+#define _POSIX_C_SOURCE 199309
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "cfg_api.h"
+
+#define SIG_LOGLEV  (SIGRTMIN + 1)
+
+#define LOG_OFF 0
+#define LOG_ON 0xff
+
+/*
+ * ´òÓ¡µÈ¼¶
+ */
+#define SLOG_DEBUG	1	//Ñз¢¸öÌåÐÐΪlogÊä³ö£¬Á¿ºÜ´ó
+#define SLOG_NORMAL 2	//¼¯³É²âÊÔ½×¶ÎlogÊä³ö£¬Á¿ÊÊÖÐ
+#define SLOG_ERR	3	//ÖÂÃü»ò¿ìÕÕÀàlogÊä³ö£¬Á¿Ð¡
+#define SLOG_OFF	4	//È«²¿¹Ø±Õ´òÓ¡
+
+#define SLOG_SOCTIME_OFF 0
+#define SLOG_SOCTIME_ON 1
+
+#define NET_PRINT       "[net]"
+#define AT_PRINT        "[at]"
+#define MMI_PRINT       "[mmi]"
+#define MISC_PRINT      "[misc]"
+#define SDCARD_PRINT    "[sdcard]"
+#define USBCFGMNG_PRINT "[usbcfgmng]"
+#define FLUXSTAT_PRINT  "[fluxstat]"
+#define WIFI_PRINT      "[wifi]"
+#define RTC_PRINT       "[rtc]"
+#define TR069_PRINT     "[tr069]"
+#define PB_PRINT        "[pb]"
+#define SMS_PRINT       "[sms]"
+#define MISC_MBIM      "[mbim]"
+#define DRVCOMMNG_PRINT       "[drvcommng]"
+
+extern int asprintf(char **strp, const char *fmt, ...);
+
+/**
+ * @brief ͳһ¶ÏÑÔËÀ»ú½Ó¿Ú£¬½«ËÀ»úÔ­Òòechoµ½ÄÚºËsoftap_assert½ÚµãÖУ¬¶ÔÓ¦Äں˵ÄassertÈ«¾Ö±äÁ¿ÖÐ
+ */
+ #if 0//klocwork
+#define softap_assert(...) do { \
+                char *p,*t;    \
+                if (-1 == asprintf(&p, __VA_ARGS__)) { \
+                    char tmp[128] = {0}; \
+                    sprintf(tmp,"echo \"%s:%d \">/proc/softap_assert", \
+                                                __FUNCTION__, __LINE__); \
+                    system(tmp);    \
+                    bzero(tmp, 128); \
+                    sprintf(tmp,"echo \"%s:%d \">/cache/net_last_asrt.txt", \
+                                                __FUNCTION__, __LINE__); \
+                    system(tmp);    \
+                }else { \
+                    asprintf(&t, "echo \"%s:%d %s \">/proc/softap_assert", \
+                                                __FUNCTION__, __LINE__, p); \
+                    system(t);\
+                    free(t);\
+                    asprintf(&p, "echo \"%s:%d %s \">/cache/net_last_asrt.txt", \
+                                                __FUNCTION__, __LINE__, p); \
+                    system(p); \
+                    free(p); \
+                } \
+                assert(0);  \
+            }while(0)
+#endif
+#define softap_assert(fmt,...) do { \
+                printf("%s:%d "fmt,  __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+                assert(0);  \
+            }while(0)
+
+extern int slog_sysloglevel;
+extern int slog_printlevel;
+
+/*
+ * ´òÓ¡½Ó¿Ú£¬ÒÔºó×ÔÑÐÄ£¿é´òÓ¡Ö»Ðèµ÷ÓøýӿÚ
+ *		mod: ±êÇ©£¬ÓÃÓÚ¼ÓÉÏÄ£¿éÃû»ò×Ô¼ºÏ²°®µÄ×Ö·û´®×÷Ϊ±êÇ©
+ *		prio: ´òÓ¡µÈ¼¶£¬¼´ºê:
+ *							SLOG_DEBUG
+ *							SLOG_ERR
+ *							SLOG_NORMAL
+  *		fmt¼°... : ¸ñʽ»¯×Ö·û´®, Õâ¸ö²¿·ÖÍêÈ«ºÍprintfµÄ²Î?Ò»ÖÂ
+ */
+extern int slog(char *mod, int prio, const char *fmt, ...);
+
+void loglevel_init(void);
+
+void security_log(int mod,const char *fmt, ...);
+
+#endif
diff --git a/ap/app/include/wifi.h b/ap/app/include/wifi.h
new file mode 100755
index 0000000..b829d27
--- /dev/null
+++ b/ap/app/include/wifi.h
@@ -0,0 +1,57 @@
+#ifndef _WIFI_H_
+#define _WIFI_H_
+
+#ifdef CONFIG_RT2860V2_AP_WAPI
+#define MAX_NUMBER_OF_MAC               96
+#else
+#define MAX_NUMBER_OF_MAC               37 /*support max station num is 37-1*/ // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
+#endif
+
+typedef union _MACHTTRANSMIT_SETTING {
+	struct  {
+		unsigned short  MCS: 7; // MCS
+		unsigned short  BW: 1;  //channel bandwidth 20MHz or 40 MHz
+		unsigned short  ShortGI: 1;
+		unsigned short  STBC: 2; //SPACE
+		unsigned short	eTxBF: 1;
+		unsigned short	rsv: 1;
+		unsigned short	iTxBF: 1;
+		unsigned short  MODE: 2; // Use definition MODE_xxx.
+	} field;
+	unsigned short      word;
+} MACHTTRANSMIT_SETTING;
+
+typedef struct _RT_802_11_MAC_ENTRY {
+	unsigned char			ApIdx;
+	unsigned char           Addr[6];
+	unsigned char           Aid;
+	unsigned char           Psm;     // 0:PWR_ACTIVE, 1:PWR_SAVE
+	unsigned char           MimoPs;  // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
+	char                    AvgRssi0;
+	char                    AvgRssi1;
+	char                    AvgRssi2;
+	unsigned int            ConnectedTime;
+	MACHTTRANSMIT_SETTING	TxRate;
+	unsigned int			LastRxRate;
+	int						StreamSnr[3];
+	int						SoundingRespSnr[3];
+	unsigned int            SSID_index; // for multissid station_list nxl
+
+} RT_802_11_MAC_ENTRY;
+
+typedef struct _RT_802_11_MAC_TABLE {
+	unsigned long            Num;
+	RT_802_11_MAC_ENTRY      Entry[MAX_NUMBER_OF_MAC]; //MAX_LEN_OF_MAC_TABLE = 32
+} RT_802_11_MAC_TABLE;
+
+/*add by myc for wifi_client_show 2012-04-19 begin*/
+typedef struct _DHCPOFFERADDR {
+	unsigned long expires;
+	unsigned long ip;
+	unsigned char mac[6];
+	unsigned char host_name[20];
+	unsigned char pad[2];
+} DHCPOFFERADDR;
+
+
+#endif
diff --git a/ap/app/include/wifi_msg.h b/ap/app/include/wifi_msg.h
new file mode 100755
index 0000000..3cba081
--- /dev/null
+++ b/ap/app/include/wifi_msg.h
@@ -0,0 +1,481 @@
+/**
+* @file Wifi_msg.h
+* @brief ÌṩwifiÉèÖõÄÏûÏ¢½Ó¿Ú
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author Linxu Gebin
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+************************************************************************
+*/
+
+#ifndef __WIFI_MSG_H__
+#define __WIFI_MSG_H__
+
+#include "message.h"
+#include "wifi.h"
+
+
+/**
+* @brief ¶¨ÒåwifiÏûÏ¢
+ * @param MSG_CMD_WIFI_BASE ÉèÖÃÖ÷ssidµÄ»ù±¾²ÎÊýÏûÏ¢
+ * @param MSG_CMD_WIFI_SSID_M ÉèÖø±ssidµÄ»ù±¾²ÎÊýÏûÏ¢
+ * @param MSG_CMD_WIFI_CLOSE ¹Ø±ÕwifiÏûÏ¢
+ * @param MSG_CMD_WIFI_OPEN ¿ªÆôwifiÏûÏ¢
+ * @param MSG_CMD_WIFI_RESTART ÖØÆôwifiÏûÏ¢
+ * @param MSG_CMD_WIFI_ADVANCED wifiµÄ¸ß¼¶²ÎÊýÉèÖÃÏûÏ¢
+ * @param MSG_CMD_WIFI_WPS ¿ªÆôWPS¹¦ÄÜÏûÏ¢
+ * @param MSG_CMD_WIFI_WPS_UP WPSÄ£¿é·¢À´µÄWPSÆô¶¯ÏûÏ¢
+ * @param MSG_CMD_WIFI_WPS_DOWN WPSÄ£¿é·¢À´µÄWPS ¹Ø±ÕÏûÏ¢
+ * @param MSG_CMD_WIFI_SLEEP WEBUIÉèÖÃ˯Ãßʱ³¤ÏûÏ¢
+ * @param MSG_CMD_CAPTURE_STATION ²éѯstaµÄÁ¬½ÓÇé¿öÏûÏ¢
+ * @param MSG_CMD_WIFI_COVERAGE ÉèÖÃwifiµÄ¸²¸Ç·¶Î§ÏûÏ¢
+ * @param MSG_CMD_WIFI_MAC ÉèÖÃmac¹ýÂ˹¦ÄÜÏûÏ¢
+ * @param MSG_CMD_USB_CHARGING_CHANGED Çý¶¯¼ì²âµ½usb³äµç״̬±ä»¯Éϱ¨ÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_OPEN ´ò¿ªapsta¹¦ÄÜÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_CLOSE ¹Ø±Õapsta¹¦ÄÜÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID ´ò¿ªapsta£¬¹Ø±Õ¶àssidÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_SCAN ɨÃèÈȵãÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_CONNECT Á¬½ÓÈȵãÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT Á¬½Ó³¬Ê±µÄ´¦ÀíÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS ²éѯsim¿¨ÓÐÎÞÆôÓõĶ¨Ê±Æ÷ÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS_TIMER_PROCESS wpa_supplicantÖ÷¶¯É¨ÃèÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_DISCONNECT Ö÷¶¯¶Ï¿ªÕýÔÚÁ¬½ÓµÄÈȵãÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_SPOT_UPDATE ¸üÐÂÈȵãÁбíÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_EVENT_CONNECTING wpa_supplicantÕýÔÚ³¢ÊÔÁ¬½ÓʼþÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_EVENT_CONNECTED apstaÓëÈȵãÁ¬½Ó³É¹¦Í¨ÖªÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED apstaÓëÈȵã¶Ï¿ªÁ¬½Ó֪ͨÏûÏ¢
+ * @param MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS blc·¢Ë͵ÄÁ¬½Ó³É¹¦£¬stationµÄipÒÑ·ÖÅäµ½ÏûÏ¢
+ * @param MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS blc·¢À´ÏûÏ¢´ò¿ªapstaÁ¬½ÓÏûÏ¢
+ * @param MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS blc·¢À´ÏûÏ¢¶Ï¿ªapstaÁ¬½ÓÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP apstaÎÞЧÏûÏ¢
+ * @param MSG_CMD_WIFI_STATION_END apstationµÄÏûÏ¢·¶Î§end
+ * @param MSG_CMD_WIFI_TSW_SET ÉèÖö¨Ê±Ë¯Ãß»½ÐѵÄÏûÏ¢
+ * @param MSG_CMD_WIFI_TSW_CLOSE ¹Ø±Õ¶¨Ê±Ë¯Ãß»½Ðѹ¦ÄܵÄÏûÏ¢
+ * @param MSG_CMD_RTC_TIME_UPDATE ¸üÐÂÐèÖØÐÂÉèÖö¨Ê±Ë¯Ãß»½ÐÑÏûÏ¢
+ * @param MSG_CMD_WIFI_RESET_TIMER mmi°´¼üÖØÐÂÉèÖÃ˯Ãßtimer
+*/
+enum wifi_msg_cmd {
+	MSG_CMD_WIFI_CFG_AP = MSG_CMD_WIFI_BASE, //ÉèÖÃÖ÷ssidµÄ»ù±¾²ÎÊýµÄÏûÏ¢4001
+	MSG_CMD_WIFI_CFG_AP2, //ÉèÖø±ssidµÄ»ù±¾²ÎÊýµÄÏûÏ¢
+	//³ýMMIÆäËûÄ£¿é²»Ó¦¸Ã´¦Àí¼Ù¹Ø»úµÄÂß¼­£¬ÓÉMMIÌṩ1¸ö¹Ø»ú²»±£´æNV£¬ÐèÒªµÄÄ£¿é¶ÁÈ¡ÅжÏÊÇ·ñ¼Ù¹Ø»ú¼´¿É
+	//MSG_CMD_WIFI_CLOSE_FAST,             //ÉèÖÿìËٹػúµÄÏûÏ¢
+	MSG_CMD_WIFI_CLOSE,                    //¹Ø±ÕwifiµÄÏûÏ¢
+	MSG_CMD_WIFI_OPEN,                     //¿ªÆôwifiµÄÏûÏ¢
+	MSG_CMD_WIFI_FORCE_RESTART,            //CrashºóÇ¿ÖÆÖØÆôwifiµÄÏûÏ¢
+	MSG_CMD_WIFI_ADVANCED,                 //wifiµÄ¸ß¼¶²ÎÊýÉèÖÃÏûÏ¢
+	MSG_CMD_WIFI_WPS,                      //¿ªÆôWPS¹¦ÄÜ£¬2·ÖÖÓ×Ô¶¯¹Ø£¬¹Ê²»ÐèÒª¹Ø±ÕÏûÏ¢
+	MSG_CMD_WIFI_WPS_UP,                   //WPSÄ£¿é·¢À´µÄWPSÆô¶¯µÄÏûÏ¢
+	MSG_CMD_WIFI_WPS_DOWN,                 //WPSÄ£¿é·¢À´µÄWPS ¹Ø±ÕµÄÏûÏ¢
+	MSG_CMD_WIFI_SLEEP,                    //WEBUIÉèÖÃ˯Ãßʱ³¤µÄÏûÏ¢
+	MSG_CMD_CAPTURE_STATION,               //²éѯstaµÄÁ¬½ÓÇé¿ö
+	MSG_CMD_WIFI_COVERAGE,                 //ÉèÖÃwifiµÄ¸²¸Ç·¶Î§
+	MSG_CMD_WIFI_MAC,                      //ÉèÖÃmac¹ýÂ˹¦ÄÜ
+	MSG_CMD_WIFI_CHANNEL_FOLLOW,           //ÉèÖÃwifi APÐŵÀ¸úËæSTA
+
+	MSG_CMD_USB_CHARGING_CHANGED,          //Çý¶¯¼ì²âµ½usb³äµç״̬±ä»¯Éϱ¨ÏûÏ¢
+
+	//for apstation
+	MSG_CMD_WIFI_STATION_OPEN,             //´ò¿ªapsta¹¦ÄÜ
+	MSG_CMD_WIFI_STATION_OPEN_SUCCESS,   //0x4010
+	MSG_CMD_WIFI_STATION_OPEN_FAIL,
+	MSG_CMD_WIFI_STATION_CLOSE,            //¹Ø±Õapsta¹¦ÄÜ
+	MSG_CMD_WIFI_STATION_CLOSE_SUCCESS,
+	MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID, //´ò¿ªapsta£¬¹Ø±Õ¶àssid
+	MSG_CMD_WIFI_STATION_SCAN,             //ɨÃèÈȵã
+	MSG_CMD_WIFI_STATION_CONNECT,          //Á¬½ÓÈȵã
+	MSG_CMD_WIFI_STATION_CONNECT_TIMEOUT,  //Á¬½Ó³¬Ê±µÄ´¦ÀíÏûÏ¢
+
+	MSG_CMD_WIFI_STATION_SIM_INIT_TIMER_PROCESS,   //eap-sim/aka¹¦ÄÜ£¬²éѯsim¿¨ÓÐÎÞÆôÓõĶ¨Ê±Æ÷ÏûÏ¢
+	MSG_CMD_WIFI_STATION_GET_SCAN_RESULTS,         // wpa_supplicantÖ÷¶¯É¨Ãè8sÒ»´Î
+	MSG_CMD_WIFI_STATION_DISCONNECT,               //Ö÷¶¯¶Ï¿ªÕýÔÚÁ¬½ÓµÄÈȵã
+	MSG_CMD_WIFI_STATION_SPOT_UPDATE,              //¸üÐÂÈȵãÁбí
+	MSG_CMD_WIFI_STATION_EVENT_CONNECTING,         //wpa_supplicantÕýÔÚ³¢ÊÔÁ¬½ÓʼþÏûÏ¢
+	MSG_CMD_WIFI_STATION_EVENT_CONNECTED,          //apstaÓëÈȵãÁ¬½Ó³É¹¦Í¨ÖªÏûÏ¢
+	MSG_CMD_WIFI_STATION_EVENT_DISCONNECTED,       //apstaÓëÈȵã¶Ï¿ªÁ¬½Ó֪ͨÏûÏ¢
+	MSG_CMD_WIFI_STATION_BLC_CONNECTED,            //blc·¢Ë͵ÄÁ¬½Ó³É¹¦£¬stationµÄipÒÑ·ÖÅäµ½
+	MSG_CMD_BLC_OPEN_WIFISTATION_ACCESS,           //blc·¢À´ÏûÏ¢´ò¿ªapstaÁ¬½Ó//0x4020
+	MSG_CMD_BLC_CLOSE_WIFISTATION_ACCESS,          //blc·¢À´ÏûÏ¢¶Ï¿ªapstaÁ¬½Ó
+	MSG_CMD_WIFI_STATION_NO_AVAILABLE_AP,
+	MSG_CMD_WIFI_STATION_FORGET,               //
+	MSG_CMD_WIFI_STATION_INDICATE_SCAN_RESULTS,
+	MSG_CMD_WIFI_STATION_CONNECT_FAIL,
+	MSG_CMD_WIFI_STATION_SUPPLICANT_EVT, //
+	MSG_CMD_WIFI_STATION_TEMP_DISABLED,         //apstaδ³É¹¦Á¬½ÓÉÏÈȵãµÄ¹ý¶Éʼþ£¬Ö®ºó»á×Ô¶¯ÖØÁ¬
+	MSG_CMD_WIFI_STATION_FAILED_SET,         //apstaδ³É¹¦Á¬½ÓÉÏÈȵãµÄ¼øÈ¨Ê§°Üʼþ£¬Ö®ºó²»ÖØÁ¬
+	
+	MSG_CMD_WIFI_STATION_DEBUG_DUMP,
+	MSG_CMD_WIFI_STATION_WPA_CMD,
+	MSG_CMD_WIFI_STATION_CONNECTED_ENABLE_AP_CMD, //apstaÁ¬½ÓÈȵã³É¹¦Æô¶¯ap
+	MSG_CMD_WIFI_STATION_END,                      //apstationµÄÏûÏ¢·¶Î§end
+
+	//timing of sleep wake up
+	MSG_CMD_WIFI_TSW_SET,         //ÉèÖö¨Ê±Ë¯Ãß»½ÐѵÄÏûÏ¢
+	MSG_CMD_WIFI_TSW_CLOSE,       //¹Ø±Õ¶¨Ê±Ë¯Ãß»½Ðѹ¦ÄܵÄÏûÏ¢
+	MSG_CMD_RTC_TIME_UPDATE,      //rtcʱ¼ä ¸üÐÂÐèÖØÐÂÉèÖö¨Ê±Ë¯Ãß»½ÐÑ
+	MSG_CMD_WIFI_RESET_TIMER,     //mmi°´¼üÖØÐÂÉèÖÃ˯Ãßtimer
+
+
+	/***************wifi OPENCPUÏûÏ¢****************/
+	MSG_CMD_WIFI_SWITCH_REQ,
+	MSG_CMD_WIFI_SWITCH_RSP,
+	MSG_CMD_WIFI_CFG_SSID_REQ,  //0x4030
+	MSG_CMD_WIFI_CFG_SSID_RSP,
+	MSG_CMD_WIFI_CFG_PWD_REQ,
+	MSG_CMD_WIFI_CFG_PWD_RSP,
+	/***************wifi OPENCPUÏûÏ¢****************/
+	MSG_CMD_AP_STA_CONNECTED,
+	MSG_CMD_AP_STA_DISCONNECTED,
+
+};
+
+
+#define WIFI_SSID_LEN			33
+#define WLAN_PSK_LEN 			65
+#define WLAN_SECURITY_LEN		20
+#define WLAN_ENCRYPT_LEN		10
+#define WLAN_DEFAULTID_LEN		4
+#define WLAN_WEPKEY_LEN			32
+#define WLAN_ENCODE_PSK_LEN		100
+#define WLAN_MAX_ACCESS_NUM_LEN 4
+#define WLAN_HIDESSID_LEN		4
+#define WF_AUTH_OPEN			"OPEN"
+#define WF_AUTH_SHARE			"SHARED"
+#define WF_AUTH_WEPAUTO			"WEPAUTO"
+#define WF_AUTH_WPA				"WPAPSK"
+#define WF_AUTH_WPA2			"WPA2PSK"
+#define WF_AUTH_WPA_WPA2		"WPAPSKWPA2PSK"
+#define WF_AUTH_WAPIPSK			"WAPIPSK"
+#define WF_ENCRP_NONE			"NONE"   //encrypt
+#define WF_ENCRP_WEP			"WEP"
+#define WF_ENCRP_TKIP			"TKIP"
+#define WF_ENCRP_CCMP			"CCMP"
+#define WF_ENCRP_AES			"AES"
+#define WF_ENCRP_TKIP_CCMP		"TKIPCCMP"
+#define WF_ENCRP_TKIP_AES		"TKIPAES"
+
+/**
+* @brief ¶¨ÒåMSG_CMD_WIFI_CFG_AP ,MSG_CMD_WIFI_CFG_AP2 ÏûÏ¢¸½´øÊý¾Ý½á¹¹Ìå
+*
+*
+*
+*/
+typedef struct wlan_cfg_basic {
+	char ssid[WIFI_SSID_LEN];			//ssid should be less than 32 bytes
+	char pwd[WLAN_PSK_LEN];				//pwd len should be in 8~64 bytes
+	char authmode[WLAN_SECURITY_LEN];
+	char encrypt[WLAN_ENCRYPT_LEN];
+	char max_access_num[WLAN_MAX_ACCESS_NUM_LEN];
+	char hidessid[WLAN_HIDESSID_LEN];
+} wlan_basic_info;
+
+typedef struct _wlan_mac_info{
+	char hostname[32];
+	char mac[20];
+}wlan_mac_info;
+
+typedef struct _wlan_mac_info_list{
+	wlan_mac_info mac_info[MAX_NUMBER_OF_MAC];
+	int access_count;
+}wlan_mac_info_list;
+
+/**
+* @brief ¶¨Òåwifi״̬ÃüÁî
+ * @param WIFI_ADVANCED_CLOSE ¹Ø±ÕwifiµÄÏûÏ¢
+ * @param WIFI_ADVANCED_OPEN ¿ªÆôwifiµÄÏûÏ¢
+ * @param WIFI_ADVANCED_OPEN_VA01 ͬʱ¿ªÆôÖ÷¡¢¸±ssidµÄÏûÏ¢
+ * @param WIFI_ADVANCED_CLOSE_MSSID ¹Ø±Õ¸±ssidµÄÏûÏ¢
+ * @param WIFI_ADVANCED_OPEN_VA1 ´ò¿ª¸±ssidµÄÏûÏ¢
+ * @param WIFI_ADVANCED_RF ÉèÖÃÉ䯵²ÎÊýµÄÏûÏ¢
+ * @param WIFI_ADVANCED_RESTART Ð¾Æ¬ÖØÆôµÄÏûÏ¢
+*/
+enum {
+	WIFI_ADVANCED_CLOSE = 0,	// 0 ¹Ø±Õwifi
+	WIFI_ADVANCED_OPEN,			// 1 ¿ªÆôva0
+	WIFI_ADVANCED_OPEN_VA01,	// 2 ͬʱ¿ªÆôÖ÷¡¢¸±ssid
+	WIFI_ADVANCED_CLOSE_MSSID,	// 3¹Ø±Õ¸±ssid
+	WIFI_ADVANCED_OPEN_VA1,		// 4 ´ò¿ª¸±ssid
+	WIFI_ADVANCED_RF,			// 5 ÉèÖÃÉ䯵²ÎÊý
+	WIFI_ADVANCED_RESTART,		// 6 Ð¾Æ¬ÖØÆô
+};
+
+/**********wlan atate***************/
+#define WIFI_OPENED        "1"    //ÒÑ»½ÐÑ
+#define WIFI_CLOSED        "0"    //ÒѹرÕ
+
+#define WLAN_ON             1    //ÒÑ»½ÐÑ
+#define WLAN_OFF            0
+
+/**
+* @brief ¶¨Òåwifi apstation SIM¿¨×´Ì¬
+ * @param CARD_MODE_NO_SIM ûÓÐSIMµÄÏûÏ¢
+ * @param WCARD_MODE_SIM ´æÔÚSIMµÄÏûÏ¢
+ * @param CARD_MODE_USIM ´æÔÚUSIMµÄÏûÏ¢
+*/
+//ÓÃÓÚapsta¹¦ÄÜÀïʶ±ðsim¿¨
+enum CardMode_Def {
+	/*T_zUfi_CardMode*/
+	CARD_MODE_NO_SIM = 0x1b00,
+	CARD_MODE_SIM,
+	CARD_MODE_USIM,
+	/*--------------------*/
+};
+
+
+/**
+* @brief ¶¨Òåwifi PIN״̬
+ * @param PIN_STATUS_NO_PIN ûÓÐPINÂëµÄÏûÏ¢
+ * @param PIN_STATUS_PIN1 PIN1ÂëµÄÏûÏ¢
+ * @param PIN_STATUS_PIN2 PIN2ÂëµÄÏûÏ¢
+ * @param PIN_STATUS_PUK1 PUK1ÂëµÄÏûÏ¢
+ * @param PIN_STATUS_PUK2 PUK2ÂëµÄÏûÏ¢
+*/
+enum PinStatus_Def {
+	/*T_zUfi_PinStatus*/
+	PIN_STATUS_NO_PIN = 0x1c00,
+	PIN_STATUS_PIN1,
+	PIN_STATUS_PIN2,
+	PIN_STATUS_PUK1,
+	PIN_STATUS_PUK2,
+	/*--------------------*/
+};
+
+/*********************station begin****************/
+
+//#ifndef  __REALTEK_8192_CHIP__
+#if !(defined(__REALTEK_8192_CHIP__) || defined(__SSV_6X5X_CHIP__) || defined(__AIC_8800DW_CHIP__))
+
+
+#define WIFI_STATION_MAC_LEN                20
+#define WIFI_STATION_SSID_LEN               128
+#define WIFI_STATION_AUTH_MODE_LEN  		20
+#define WIFI_STATION_ENCRYPT_TYPE_LEN  		20
+#define WIFI_STATION_SPOT_PASSWORD_LEN  	128
+
+typedef struct scan_result {
+	char     mac[WIFI_STATION_MAC_LEN];
+	char     ssid[WIFI_STATION_SSID_LEN];
+	char     auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char     encrypt_type[WIFI_STATION_ENCRYPT_TYPE_LEN];
+	short    connect_status;
+	short    channel;
+	short    signal;
+	short    network_id;
+} scan_result_t;
+
+typedef struct spot {
+	char     mac[WIFI_STATION_MAC_LEN];
+	char     ssid[WIFI_STATION_SSID_LEN];
+	char     auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char     encrypt_type[WIFI_STATION_ENCRYPT_TYPE_LEN];
+	char     password[WIFI_STATION_SPOT_PASSWORD_LEN];
+	short    network_id;
+} spot_t;
+
+typedef enum{
+	SAVE_ACTION,
+	DEL_ACTION,
+	CONNECTING_ACTION,
+	DHCPING_ACTION,
+	CONNECTED_ACTION,
+	DISCONNECT_ACTION,
+	
+	//kw 3
+	ACTION_MAX
+}spot_action_t;
+
+typedef struct  msg_act_spot {
+	spot_action_t  act;
+	char  mac[WIFI_STATION_MAC_LEN];
+	char  ssid[WIFI_STATION_SSID_LEN];
+	int network_id;
+} msg_act_spot_t;
+
+typedef enum scan_content {	
+	WIFI_STATION_AP_CONTENT_UNDEFINED,
+	WIFI_STATION_AP_MAC,
+	WIFI_STATION_AP_SSID,
+	WIFI_STATION_AP_AUTH_MODE,
+	WIFI_STATION_AP_ENCRYPT_TYPE,	
+	WIFI_STATION_AP_CHANNEL,
+	WIFI_STATION_AP_SIGNAL,
+	WIFI_STATION_AP_CONNECT_STATUS,
+	WIFI_STATION_AP_NETWORK_ID,
+} scan_content_t;
+
+typedef enum{
+	DISCONNECT_STATUS,
+	CONNECTING_STATUS,
+	DHCPING_STATUS,
+	CONNECTED_STATUS,
+}connect_status_t;
+
+typedef enum {
+	WIFI_STATION_WRONG_KEY,
+	WIFI_STATION_IP_FAIL,
+	WIFI_STATION_AUTH_FAIL,
+	WIFI_STATION_OTHER,
+}conn_fail_reason_t;
+
+#else
+
+#define WIFI_STATION_SPOT_ACTION_LEN             32
+#define WIFI_STATION_SPOT_LEN  256
+#define WIFI_STATION_SPOT_LIST_NUM  10
+#define WIFI_STATION_SPOT_PROFILE_NAME_LEN  30
+#define WIFI_STATION_SPOT_PASSWORD_LEN  128
+#define WIFI_STATION_SPOT_KEY_ID_LEN  10
+#define WIFI_STATION_PROFILE_NV_NAME_LEN  20
+
+#define WIFI_STATION_WPA_STATUS_LEN         30
+#define WIFI_STATION_MAC_LEN                20
+#define WIFI_STATION_SSID_LEN               128
+#define WIFI_STATION_AUTH_MODE_LEN  20
+#define WIFI_STATION_ENCRYPT_TYPE_LEN  20
+#define WIFI_STATION_FLAGS_LEN    128
+
+typedef struct  update_spot_info {
+	char  spot[WIFI_STATION_SPOT_LEN];
+	char action[WIFI_STATION_SPOT_ACTION_LEN];
+} updateinfo_t;
+
+typedef enum wifi_profile_content {
+	WIFI_STATION_CONTENT_UNDEFINED,
+	WIFI_STATION_PROFILE_NAME,
+	WIFI_STATION_FROM_PROVIDER,
+	WIFI_STATION_CONNECT_STATUS,
+	WIFI_STATION_SIGNAL,
+	WIFI_STATION_SSID,
+	WIFI_STATION_AUTH_MODE,
+	WIFI_STATION_ENCRYPT_TYPE,
+	WIFI_STATION_PASSWORD,
+	WIFI_STATION_KEY_ID,
+	WIFI_STATION_AP_MAC
+} wifi_profile_content_t;
+
+typedef struct scan_result {
+	char     mac[WIFI_STATION_MAC_LEN];
+	char     ssid[WIFI_STATION_SSID_LEN];
+	char     auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char     encrypt_type[WIFI_STATION_ENCRYPT_TYPE_LEN];
+	short    from_provider;//0:·ÇÔËÓªÉÌ£¬1:ÔËÓªÉÌ
+	short    connect_status;
+	short    channel;
+	short    signal;
+} scan_result_t;
+
+
+typedef struct spot {
+	char      profile_name[WIFI_STATION_SPOT_PROFILE_NAME_LEN];
+	short    from_provider;//0:·ÇÔËÓªÉÌ£¬1:ÔËÓªÉÌ
+	short    connect_status;
+	short    signal;
+	char      ssid[WIFI_STATION_SSID_LEN];
+	char      auth_mode[WIFI_STATION_AUTH_MODE_LEN];
+	char      encrypt_type[WIFI_STATION_ENCRYPT_TYPE_LEN];
+	char      password[WIFI_STATION_SPOT_PASSWORD_LEN];
+	short    keyID;
+	char     mac[WIFI_STATION_MAC_LEN];
+	BOOL    is_tried_connect;
+	short    network_id;
+} spot_t;
+
+
+typedef struct  spot_ssid_id {
+	int  id;
+	char  ssid[WIFI_STATION_SSID_LEN];
+} spot_ssid_id_t;
+#endif
+
+/*********************station end****************/
+
+/*nv   set flags */
+
+//wifi
+
+#define NVIO_WIFI_MAX_LEN  				200 /*write or read nv length*/
+#define WIFI_PSW_DEFAULT_LENGTH  		65
+#define WIFI_STATUS_LEN					 2
+#define WIFI_PSW_MIN_LEN 				1
+#define WIFI_PSW_MAN_LEN 				64
+#define WIFI_CONFIG_DEFAULT_LENGTH  	128
+#define WF_WPS_KEY_INDEX_LEN  			2
+#define WF_KEY_MODE_LEN  				3
+#define WF_WEP_KEY_MAX_LEN  			27
+#define WF_WPA_KEY_MAX_LEN  			65
+#define WF_ENCRY_TYPE_LEN 				16
+#define WF_AU_MODE_LEN  				16
+#define WPS_MODE_PIN 					"PIN"      //wps mode 
+#define WPS_MODE_PBC  					"PBC"
+#define WPS_MODE_AP_PIN   				"APPIN"
+#define WF_AU_OPEN            				"OPEN"            //wifi auth mode?
+#define WF_AU_SHARE           				"SHARED"
+#define WF_AU_WEPAUTO         				"WEPAUTO"
+#define WF_AU_WPA             				"WPAPSK"
+#define WF_AU_WPA2            				"WPA2PSK"
+#define WF_AU_WPA_WPA2  	  			"WPAPSKWPA2PSK"
+#define WF_AU_WPA3            				"WPA3Personal"
+#define WF_AU_WPA2_WPA3            				"WPA2WPA3"
+#define WF_AU_WAPIPSK	      				"WAPIPSK"
+#define WF_ENCRY_NONE      				"NONE"   //encrypt
+#define WF_ENCRY_WEP      				 "WEP"
+#define WF_ENCRY_TKIP      				"TKIP"
+#define WF_ENCRY_CCMP     				 "CCMP"
+#define WF_ENCRY_AES       				"AES"
+#define WF_ENCRY_TKIP_CCMP 				"TKIPCCMP"
+#define WF_ENCRY_TKIP_AES  				"TKIPAES"
+#define WIFI_SSID_INDEX 					"ssid_index"
+#define WIFI_STATION_MAC 				"mac_addr"
+#define WIFI_STATION_HOSTNAME 			"hostname"
+#define WIFI_STATION_IPADDR 				"ip_addr"
+#define WIFI_STATION_CONNECTTIME 		"connect_time"
+#define WIFI_STATION_VALIDTIME 			"valid_time"
+#define WIFI_STATION_IPTYPE 				"ip_type"
+#define WIFI_STATION_DEVTYPE 			"dev_type"
+#define WIFI_NV_ITEM_WIFI_SET_FLAGS 	"wifi_set_flags"
+#define NV_WIFI_SCAN_FINISH         			"scan_finish"
+
+#define NV_WIFI_WPA_PASS            			"WPAPSK1"
+#define NV_WIFI_WPA_PASS_ENCODE     		"WPAPSK1_encode"
+#define NV_WIFI_WPA_PASS_M          		"m_WPAPSK1"
+#define NV_WIFI_WPA_PASS_M_ENCODE   	"m_WPAPSK1_encode"
+#define NV_WIFI_COVERAGE  				"wifi_coverage"
+#define NV_WIFI_WPS_STATE 				 "WscModeOption"
+#define NV_WIFI_WPS_MODE      			"wps_mode"
+#define NV_WIFI_WPS_SSID       			"WPS_SSID"
+#define NV_WIFI_WPS_INDEX   				"wifi_wps_index"
+#define NV_WIFI_WPS_PIN   				"wps_pin"
+#define NV_WIFI_WPS_AP_PIN   			"wifi_ap_pin"
+#define NV_WIFI_WPS_DEF_PIN   			"wifi_def_pin"
+#define CMD_WIFI_STATION_LIST 			"station_list"
+#define CMD_HOSTNAME_LIST 				"hostNameList"
+#define CMD_WIFI_WPS_AP_PIN 			"wifi_ap_pin"
+#define CMD_WIFI_WPS_AP_DEF_PIN 		"wifi_def_pin"
+
+typedef enum {
+	ZTE_WLAN_SSID_SET = 0x1,
+	ZTE_WLAN_BROADCAST_SET = 0x2,
+	ZTE_WLAN_BASIC_SECURITY_SET = 0x4,
+	ZTE_WLAN_MAX_ACCESS_NUM_SET = 0x8,
+
+
+	ZTE_WLAN_ON_OFF_SET = 0x10,
+	ZTE_WLAN_WIRELESS_MODE_SET = 0x20,	
+	ZTE_WLAN_CHANNEL_SET = 0x40,	
+	ZTE_WLAN_COUNTRY_SET = 0x80,
+	ZTE_WLAN_WIFI_BAND_SET = 0x100,
+
+	ZTE_WLAN_POWER_SET = 0x1000,	
+	ZTE_WLAN_ACL_SET = 0x2000,	
+	ZTE_WLAN_WPS_SET = 0x4000,	
+	ZTE_WLAN_SET_AP_SLEEPTIMER = 0x8000,
+
+
+	ZTE_WLAN_SET_AP_MSSID = 0x10000,	
+
+} zte_wlan_set_e_flags;
+
+#endif
diff --git a/ap/app/include/wlan_interface.h b/ap/app/include/wlan_interface.h
new file mode 100755
index 0000000..f18ee86
--- /dev/null
+++ b/ap/app/include/wlan_interface.h
@@ -0,0 +1,17 @@
+#ifndef _WLAN_INTERFACE
+#define _WLAN_INTERFACE
+
+#include "wifi.h"
+
+int zte_wlan_get_ssid1_settings(char* ssid, char* password, int ssid_len, int password_len);
+int zte_wlan_ssid1_set(char* ssid, char* password);
+int zte_wlan_capture_sta_num();
+
+void zte_wlan_get_wifi_mac_list(RT_802_11_MAC_TABLE *maclist);
+#if 0 //kw 3
+int pipecmd(const char *cmd, char* result);
+int get_channel();
+#endif
+int get_vap_sta_num(char* vapIface);
+
+#endif
diff --git a/ap/app/include/zxic_errno.h b/ap/app/include/zxic_errno.h
new file mode 100755
index 0000000..002dc1a
--- /dev/null
+++ b/ap/app/include/zxic_errno.h
@@ -0,0 +1,33 @@
+/*********************************************************************************
+ * @file zxic_errno.h
+ * @brief ¶¨ÒåÆ½Ì¨µÄ´íÎóÂë
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+***********************************************************************************/
+#ifndef _ZXIC_ERRNO_H_
+#define _ZXIC_ERRNO_H_
+
+#include "max_macro.h"
+
+
+
+#ifndef NULL
+#define NULL                ((void*)0)
+#endif
+
+
+typedef struct {
+	int  err_no;
+	unsigned long err_time;   //´íÎó·¢Éúʱ¼ä
+} ERR_INFO;
+
+typedef struct {
+	unsigned int  num;  //¼Ç¼errno×ܸöÊý
+	ERR_INFO errInfo[ERR_TRACK_MAX_NUM];   //Ñ­»·¸²¸Çϱê num % ERR_TRACK_MAX_NUM
+} ERR_TRACK;
+#endif
diff --git a/ap/app/include/zxic_list.h b/ap/app/include/zxic_list.h
new file mode 100755
index 0000000..bb9a3aa
--- /dev/null
+++ b/ap/app/include/zxic_list.h
@@ -0,0 +1,253 @@
+#ifndef _ZXIC_LIST_H__
+#define _ZXIC_LIST_H__
+
+#undef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr:    the pointer to the member.
+ * @type:   the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({          \
+        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+        (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+	struct list_head name = LIST_HEAD_INIT(name)
+
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+	list->next = list;
+	list->prev = list;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+                              struct list_head *prev,
+                              struct list_head *next)
+{
+	next->prev = new;
+	new->next = next;
+	new->prev = prev;
+	prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+	__list_add(new, head, head->next);
+}
+
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+	__list_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+	next->prev = prev;
+	prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void __list_del_entry(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+}
+
+#define LIST_POISON1 0
+#define LIST_POISON2 0
+
+static inline void list_del(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	entry->next = LIST_POISON1;
+	entry->prev = LIST_POISON2;
+}
+
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+                                struct list_head *new)
+{
+	new->next = old->next;
+	new->next->prev = new;
+	new->prev = old->prev;
+	new->prev->next = new;
+}
+
+static inline void list_replace_init(struct list_head *old,
+                                     struct list_head *new)
+{
+	list_replace(old, new);
+	INIT_LIST_HEAD(old);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+	__list_del_entry(entry);
+	INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+	__list_del_entry(list);
+	list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+                                  struct list_head *head)
+{
+	__list_del_entry(list);
+	list_add_tail(list, head);
+}
+
+/**
+ * list_is_last - tests whether @list is the last entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+                               const struct list_head *head)
+{
+	return list->next == head;
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+	return head->next == head;
+}
+
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+	return !list_empty(head) && (head->next == head->prev);
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:	the &struct list_head pointer.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+	container_of(ptr, type, member)
+
+
+/**
+ * list_for_each	-	iterate over a list
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @head:	the head for your list.
+ *
+ * This variant doesn't differ from list_for_each() any more.
+ * We don't do prefetching in either case.
+ */
+#define list_for_each(pos, head) \
+	for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_entry	-	iterate over list of given type
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member)				\
+        for (pos = list_entry((head)->next, typeof(*pos), member);  \
+             &pos->member != (head);    \
+             pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_safe	-	iterate over a list safe against removal of list entry
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @n:		another &struct list_head to use as temporary storage
+ * @head:	the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+        for (pos = (head)->next, n = pos->next; pos != (head); \
+            pos = n, n = pos->next)
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:	the type * to use as a loop counter.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)			\
+            for (pos = list_entry((head)->next, typeof(*pos), member),  \
+                n = list_entry(pos->member.next, typeof(*pos), member); \
+                 &pos->member != (head);                    \
+                 pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+#endif