[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/lib/libatext/Makefile b/ap/lib/libatext/Makefile
new file mode 100644
index 0000000..0e39b78
--- /dev/null
+++ b/ap/lib/libatext/Makefile
@@ -0,0 +1,49 @@
+#*******************************************************************************
+# include ZTE library makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+#include ../net_team.mk
+
+ifeq ($(USE_DSDS_VSIM),yes)
+CFLAGS += -DUSE_DSDS_VSIM
+endif
+
+LIB_STATIC = libatext.a
+LIB_SHARED = libatext.so
+
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+
+CFLAGS += -I$(zte_app_path)/zte_comm/at_ctl/inc
+CFLAGS += -I$(zte_lib_path)/libatutils
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(zte_lib_path)/libamt
+CFLAGS += -I$(LINUX_DIR)/include
+CFLAGS += -g -Werror=implicit-function-declaration
+CFLAGS += -I$(APP_DIR)/include
+
+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv
+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/drv
+CFLAGS += -I/$(CP_ROOT_DIR)/ps/driver/inc/misc
+
+##############USER COMIZE END##################
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -fPIC
+LDFLAGS += -shared
+
+
+all: $(LIB_STATIC) $(LIB_SHARED)
+
+$(LIB_STATIC) : $(OBJS)
+ $(AR) rcs $(LIB_STATIC) $(OBJS)
+
+$(LIB_SHARED): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -lm
+
+romfs:
+ $(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
+
+clean:
+ -$(RM) *.a *.o *.so $(LIB_SHARED) $(LIB_STATIC) $(OBJS)
+
diff --git a/ap/lib/libatext/ext_amt_func.c b/ap/lib/libatext/ext_amt_func.c
new file mode 100755
index 0000000..d5470d5
--- /dev/null
+++ b/ap/lib/libatext/ext_amt_func.c
@@ -0,0 +1,2134 @@
+/**
+ *
+ * @file ext_amt_func.c
+ * @brief
+ * This file is part of FTM.
+ * AMTÄ£¿éÏà¹ØATÃüÁî
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.1
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2018/04/28 1.0 liu.xin Create file
+ * 2019/02/02 1.1 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+#include "ext_regist.h"
+#include "at_com.h"
+#include <unistd.h>
+#include <sys/syscall.h>
+#include "RONvParam_AMT.h"
+#include "ref_nv_def.h"
+#include "nv_api.h"
+#include "amtnv.h"
+#include <linux/soc/zte/efuse/efuse_zx.h>
+#include "NvParam_drv.h"
+#include "libkey.h"
+
+//mdlÓû§Ä£Ê½ÇÐÑз¢Ä£Ê½¼øÈ¨½á¹û
+static int auth_device_key_result = 0;
+
+#define GET_LCD_INFO 378
+#define GET_WIFI_INFO 379
+#define GET_FLASH_INFO 380
+#define GET_CPU_INFO 381
+#define GET_DDR_INFO 382
+//CP
+typedef unsigned char BYTE;
+
+#define DC_MacLen (BYTE)12
+#define DC_ImeiLen (BYTE)8
+#define MSN_MAX_NVINFO_LEN 20
+#define MSINFO_MAX_NVINFO_LEN 200
+#define MDMVERSION_MAX_LEN 64
+#define bInside(data, up, down) (((data) <= (up) && (data) >= (down)) || \
+ ((data) >= (up) && (data) <= (down)))
+typedef unsigned long u32_t;
+
+#ifndef SMEMCPY
+#define SMEMCPY(dst,src,len) memcpy(dst,src,len)
+#endif
+
+/**
+ * @brief ZMDMVERSIONÏìÓ¦ÏûÏ¢½á¹¹Ìå
+ * @param result ½á¹ûÂë AT_RSP_OK/AT_RSP_ERR
+ * @param mdmVer modem°æ±¾ºÅ
+ */
+typedef struct
+{
+ char mdmVer[MDMVERSION_MAX_LEN];
+ int result;
+}AT_MDMVERSION_RSP_INFO;
+
+//static char mdmVer[MDMVERSION_MAX_LEN] = {0};//ÓÃÓڼǼZGMR »Ø¸´½á¹û
+
+struct flash_ddr_info{
+ char manu[32];
+ char model[32];
+ char size[32];
+ char other[32];
+};
+
+struct lcd_info
+{
+ char manu[32];
+ char ic[32];
+ char resolution[32];
+};
+
+struct wifi_info
+{
+ char manu[32];
+ char ic[32];
+};
+struct cpu_info{
+ char manu[32];
+ char model[32];
+};
+
+/* Data structure for MD5 (Message-Digest) computation */
+typedef struct {
+ u32_t i[2]; /* number of _bits_ handled mod 2^64 */
+ u32_t buf[4]; /* scratch buffer */
+ unsigned char in[64]; /* input buffer */
+ unsigned char digest[16]; /* actual digest after md5_final call */
+} md5_ctx;
+
+
+extern void at_context_chn_info_mod(char *at_paras);
+
+/*
+ ***********************************************************************
+ ** Message-digest routines: **
+ ** To form the message digest for a message M **
+ ** (1) Initialize a context buffer ctx using md5_init **
+ ** (2) Call md5_update on ctx and M **
+ ** (3) Call md5_final on ctx **
+ ** The message digest is now in ctx->digest[0...15] **
+ ***********************************************************************
+ */
+
+/* forward declaration */
+static void transform(u32_t *buf, u32_t *in);
+
+static unsigned char PADDING[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* F, G, H and I are basic MD5 functions */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s, ac) \
+ {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) \
+ {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) \
+ {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) \
+ {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+#ifdef __STDC__
+#define UL(x) x##UL
+#else
+#ifdef WIN32
+#define UL(x) x##UL
+#else
+#define UL(x) x
+#endif
+#endif
+
+/* The routine md5_init initializes the message-digest context
+ mdContext. All fields are set to zero.
+ */
+void md5_init(md5_ctx *ctx)
+{
+ ctx->i[0] = ctx->i[1] = (u32_t)0;
+
+ /* Load magic initialization constants. */
+ ctx->buf[0] = (u32_t)0x67452301UL;
+ ctx->buf[1] = (u32_t)0xefcdab89UL;
+ ctx->buf[2] = (u32_t)0x98badcfeUL;
+ ctx->buf[3] = (u32_t)0x10325476UL;
+}
+
+/* The routine md5_update updates the message-digest context to
+ account for the presence of each of the characters buf[0..inLen-1]
+ in the message whose digest is being computed.
+ */
+
+void md5_update(md5_ctx *ctx, unsigned char *buf, unsigned int len)
+{
+ u32_t in[16];
+ int mdi;
+ unsigned int i, ii;
+
+#if 0
+ ppp_trace(LOG_INFO, "MD5Update: %u:%.*H\n", len, MIN(len, 20) * 2, buf);
+ ppp_trace(LOG_INFO, "MD5Update: %u:%s\n", len, buf);
+#endif
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((ctx->i[0] >> 3) & 0x3F);
+
+ /* update number of bits */
+ if ((ctx->i[0] + ((u32_t)len << 3)) < ctx->i[0]) {
+ ctx->i[1]++;
+ }
+ ctx->i[0] += ((u32_t)len << 3);
+ ctx->i[1] += ((u32_t)len >> 29);
+
+ while (len--) {
+ /* add new character to buffer, increment mdi */
+ ctx->in[mdi++] = *buf++;
+
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4) {
+ in[i] = (((u32_t)ctx->in[ii+3]) << 24) |
+ (((u32_t)ctx->in[ii+2]) << 16) |
+ (((u32_t)ctx->in[ii+1]) << 8) |
+ ((u32_t)ctx->in[ii]);
+ }
+ transform (ctx->buf, in);
+ mdi = 0;
+ }
+ }
+}
+
+/* The routine md5_final terminates the message-digest computation and
+ ends with the desired message digest in ctx->digest[0...15].
+ */
+
+void md5_final(unsigned char hash[], md5_ctx *ctx)
+{
+ u32_t in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int pad_len;
+
+ /* save number of bits */
+ in[14] = ctx->i[0];
+ in[15] = ctx->i[1];
+
+ /* compute number of bytes mod 64 */
+ mdi = (int)((ctx->i[0] >> 3) & 0x3F);
+
+ /* pad out to 56 mod 64 */
+ pad_len = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ md5_update (ctx, PADDING, pad_len);
+
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4) {
+ in[i] = (((u32_t)ctx->in[ii+3]) << 24) |
+ (((u32_t)ctx->in[ii+2]) << 16) |
+ (((u32_t)ctx->in[ii+1]) << 8) |
+ ((u32_t)ctx->in[ii]);
+ }
+ transform (ctx->buf, in);
+
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ ctx->digest[ii] = (unsigned char)(ctx->buf[i] & 0xFF);
+ ctx->digest[ii+1] =
+ (unsigned char)((ctx->buf[i] >> 8) & 0xFF);
+ ctx->digest[ii+2] =
+ (unsigned char)((ctx->buf[i] >> 16) & 0xFF);
+ ctx->digest[ii+3] =
+ (unsigned char)((ctx->buf[i] >> 24) & 0xFF);
+ }
+ SMEMCPY(hash, ctx->digest, 16);
+}
+
+/* Basic MD5 step. Transforms buf based on in.
+ */
+static void transform (u32_t *buf, u32_t *in)
+{
+ u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+
+ /* Round 1 */
+ #define S11 7
+ #define S12 12
+ #define S13 17
+ #define S14 22
+ FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
+ FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
+ FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
+ FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
+ FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
+ FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
+ FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
+ FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
+ FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
+ FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
+ FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
+ FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
+ FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
+ FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
+ FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
+ FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
+
+ /* Round 2 */
+ #define S21 5
+ #define S22 9
+ #define S23 14
+ #define S24 20
+ GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
+ GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
+ GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
+ GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
+ GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
+ GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
+ GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
+ GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
+ GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
+ GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
+ GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
+ GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
+ GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
+ GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
+ GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
+ GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
+
+ /* Round 3 */
+ #define S31 4
+ #define S32 11
+ #define S33 16
+ #define S34 23
+ HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
+ HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
+ HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
+ HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
+ HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
+ HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
+ HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
+ HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
+ HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
+ HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
+ HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
+ HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
+ HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
+ HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
+ HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
+ HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
+
+ /* Round 4 */
+ #define S41 6
+ #define S42 10
+ #define S43 15
+ #define S44 21
+ II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
+ II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
+ II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
+ II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
+ II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
+ II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
+ II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+static int is_mac_valid(char*macStr)
+{
+ int Macindex = 0;
+ for (; (macStr[Macindex] != '\0') && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE); Macindex++)
+ {
+ char chmac = macStr[Macindex];
+ if (!(bInside(chmac, '0', '9') || bInside(chmac, 'a', 'f') || bInside(chmac, 'A', 'F')))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+static char Ascii2BCD(char iAscii)
+{
+ char iBCD;
+
+ if ( bInside(iAscii, '0', '9'))
+ {
+ iBCD = iAscii - '0';
+
+ }
+ else if (bInside(iAscii, 'a', 'f'))
+ {
+ iBCD = iAscii - 'a' + 0x0a;
+
+ }
+ else if (bInside(iAscii, 'A', 'F'))
+ {
+ iBCD = iAscii - 'A' + 0x0a;
+ }
+ else
+ {
+ return -1;
+ }
+
+ return iBCD;
+
+}
+
+static char BCD2Ascii(char iBCD)
+{
+ char iAscii;
+
+ if (bInside(iBCD, 0x00, 0x09))
+ {
+ iAscii = (unsigned char)(iBCD + '0');
+ }
+ else if (bInside(iBCD, 0x0a, 0x0f))
+ {
+ iAscii = (unsigned char)((iBCD - 0x0a) + 'A');
+ }
+ else
+ {
+ return -1;
+ }
+ return iAscii;
+}
+
+static int IsImeiStrValid(char* imeiStr)
+{
+ int i = 0;
+ for (; i < 15; ++i)
+ {
+ if (imeiStr[i] < '0' || imeiStr[i] > '9')
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static long Char2Int(char chr)
+{
+ long value = 0;
+ value = (chr - '0');
+ return value;
+}
+
+static char Int2Char(long value)
+{
+ char ch = '0'+value;
+ return ch;
+}
+
+static unsigned long DC_Writeimei(char * imeistr)
+{
+ int Imeiindex =0,checkindex=0;
+ BYTE abImei[DC_ImeiLen]={0};
+ BYTE Index1=0,Index2=0;
+
+ for(Imeiindex=0;imeistr[Imeiindex]!='\0';Imeiindex+=2)
+ {
+ at_print(AT_DEBUG,"Imeiindex= %d\r\n",Imeiindex);
+ at_print(AT_DEBUG,"imeistr[%d]= %c\r\n",Imeiindex,imeistr[Imeiindex]);
+
+ Index1=Char2Int((char)imeistr[Imeiindex]);
+ at_print(AT_DEBUG,"Index1= %d\r",Index1);
+
+ if((imeistr[Imeiindex+1])!='\0')
+ {
+
+ Index2= Char2Int((char)imeistr[Imeiindex+1]);
+ at_print(AT_DEBUG,"Index2= %d, Index2<<4 =%x , (Index2<<4)&Index1 = %x\r\n",Index2,Index2<<4,(Index2<<4)|Index1);
+
+ abImei[Imeiindex/2]=(Index2<<4)|Index1;
+ at_print(AT_DEBUG,"abImei[%d]= %x\r\n",Imeiindex/2,abImei[Imeiindex/2]);
+ }
+ else
+ {
+ abImei[Imeiindex/2]=0xF0|Index1;
+ at_print(AT_DEBUG,"abImei[%d]= %x\r\n",Imeiindex/2,abImei[Imeiindex/2]);
+ break;
+ }
+ }
+ for(checkindex=0;checkindex<8;checkindex++)
+ {
+ at_print(AT_DEBUG,"abImei[%d] = %x\r\n",checkindex,abImei[checkindex]);
+ }
+
+ if(CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_IMEI_ADDRESS, sizeof(abImei), abImei))
+ {
+ at_print(AT_ERR,"Write amt imei failed\r\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: DC_WriteMacAddr
+* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+static unsigned long DC_WriteMacAddr(char *macstr)
+{
+ unsigned long Macindex = 0;
+ unsigned char abMac[OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE] = {0};
+ unsigned char Index1 = 0;
+ unsigned char Index2 = 0;
+
+ if(!is_mac_valid(macstr))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return -1;
+ }
+
+ /*ASCIIÂëת»»³ÉBCDÂë*/
+ for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE); Macindex += 2)
+ {
+ Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
+ Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
+ abMac[Macindex/2]=(Index1<<4)|Index2;
+ }
+
+ if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_WIFIMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE, abMac))
+ {
+ at_print(AT_DEBUG,"Write amt mac failed\r");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: DC_WriteMac2Addr
+* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+static unsigned long DC_WriteMac2Addr(char *macstr)
+{
+ unsigned long Macindex = 0;
+ unsigned char abMac[OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE] = {0};
+ unsigned char Index1 = 0;
+ unsigned char Index2 = 0;
+
+ if(!is_mac_valid(macstr))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return -1;
+ }
+
+ /*ASCIIÂëת»»³ÉBCDÂë*/
+ for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE); Macindex += 2)
+ {
+ Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
+ Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
+ abMac[Macindex/2]=(Index1<<4)|Index2;
+ }
+
+ if (CPNV_ERROR== amt_nvro_write(OS_FLASH_AMT_COMM_RO_WIFIMAC2_ADDRESS, OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE, abMac))
+ {
+ at_print(AT_DEBUG,"Write amt mac failed\r");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: DC_WriteRJ45MacAddr
+* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«MACµØÖ·Ð´Èëµ½NVÖÐ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+unsigned long DC_WriteRJ45MacAddr(char *macstr)
+{
+ unsigned long Macindex = 0;
+ unsigned char abMac[OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE] = {0};
+ unsigned char Index1 = 0;
+ unsigned char Index2 = 0;
+
+ if(!is_mac_valid(macstr))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return -1;
+ }
+
+ /*ASCIIÂëת»»³ÉBCDÂë*/
+ for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE); Macindex += 2)
+ {
+ Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
+ Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
+ abMac[Macindex/2]=(Index1<<4)|Index2;
+ }
+
+ if (CPNV_ERROR== amt_nvro_write(OS_FLASH_AMT_COMM_RO_ETHMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE, abMac))
+ {
+ at_print(AT_DEBUG,"Write amt ethmac failed\r");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: DC_WriteMacAddr
+* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«USB MACµØÖ·Ð´Èëµ½NVÖÐ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+static unsigned long DC_WriteUSBMacAddr(char *macstr)
+{
+ unsigned long Macindex = 0;
+ unsigned char abMac[OS_FLASH_AMT_COMM_RO_USBMAC_SIZE] = {0};
+ unsigned char Index1 = 0;
+ unsigned char Index2 = 0;
+
+ if(!is_mac_valid(macstr))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return -1;
+ }
+
+ /*ASCIIÂëת»»³ÉBCDÂë*/
+ for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_USBMAC_SIZE); Macindex += 2)
+ {
+ Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
+ Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
+ abMac[Macindex/2]=(Index1<<4)|Index2;
+ }
+
+ if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_USBMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_USBMAC_SIZE, abMac))
+ {
+ at_print(AT_DEBUG,"Write amt usb mac failed\r");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: DC_WriteMacAddr
+* ¹¦ÄÜÃèÊö: ASCIIÂëת»»³ÉBCDÂ룬²¢ ½«GMACµØÖ·Ð´Èëµ½NVÖÐ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+static unsigned long DC_WriteGmacAddr(char *macstr)
+{
+ unsigned long Macindex = 0;
+ unsigned char abMac[OS_FLASH_AMT_COMM_RO_GMAC_SIZE] = {0};
+ unsigned char Index1 = 0;
+ unsigned char Index2 = 0;
+
+ if(!is_mac_valid(macstr))
+ {
+ at_print(AT_DEBUG,"mac is not hex str\r");
+ return -1;
+ }
+
+ /*ASCIIÂëת»»³ÉBCDÂë*/
+ for (Macindex = 0; macstr[Macindex] != '\0' && (Macindex < OS_FLASH_AMT_COMM_RO_GMAC_SIZE); Macindex += 2)
+ {
+ Index1 = (unsigned char)Ascii2BCD((char)macstr[Macindex]);
+ Index2 = (unsigned char)Ascii2BCD((char)macstr[Macindex + 1]);
+ abMac[Macindex/2]=(Index1<<4)|Index2;
+ }
+
+ if (CPNV_ERROR == amt_nvro_write(OS_FLASH_AMT_COMM_RO_GMAC_ADDRESS, OS_FLASH_AMT_COMM_RO_GMAC_SIZE, abMac))
+ {
+ at_print(AT_DEBUG,"Write amt Gmac failed\r");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int rkeydc_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ int retCode = -1;
+ //char pStr[8] = {0};
+ char *at_str = NULL;
+ struct flash_ddr_info flashInfo = {{0}};
+ struct flash_ddr_info ddrInfo = {{0}};
+ struct cpu_info cpuInfo = {{0}};
+ struct wifi_info wifiInfo = {{0}};
+ struct lcd_info lcdInfo = {{0}};
+
+ at_print(AT_ERR,"rkeydc_act_func: \n");
+ at_str = malloc(64);
+ if(at_str == NULL)
+ return AT_END;
+ memset(at_str,0,64);
+ if(strstr(at_paras, "DDR"))
+ {
+ retCode = syscall(GET_DDR_INFO,ddrInfo.manu,ddrInfo.size,ddrInfo.model);
+ if(retCode < 0)
+ {
+ at_print(AT_ERR,"rkeydc_act_func: syscall GET_DDR_INFO failed \n");
+ free(at_str);
+ return AT_END;
+ }
+ at_print(AT_ERR,"rkeydc_act_func: ddrInfo.manu = %s,size = %s,model =%s\n",ddrInfo.manu,ddrInfo.size,ddrInfo.model);
+ snprintf((char*)at_str,64,"\r\n%s?NA?NA?%s?%s\r\n",ddrInfo.manu,ddrInfo.size,ddrInfo.model);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ else if(strstr(at_paras, "FLASH"))
+ {
+ retCode = syscall(GET_FLASH_INFO,flashInfo.manu,flashInfo.model,flashInfo.size);
+ if(retCode < 0)
+ {
+ at_print(AT_ERR,"rkeydc_act_func: syscall GET_FLASH_INFO failed \n");
+ free(at_str);
+ return AT_END;
+ }
+ at_print(AT_ERR,"rkeydc_act_func: flashInfo.manu = %s,model = %s,size =%s\n",flashInfo.manu,flashInfo.model,flashInfo.size);
+ snprintf((char*)at_str,64,"\r\n%s?%s?NA?%s?NA\r\n",flashInfo.manu,flashInfo.model,flashInfo.size);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ else if(strstr(at_paras, "LCD"))
+ {
+ retCode = syscall(GET_LCD_INFO,lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
+ if(retCode < 0)
+ {
+ at_print(AT_ERR,"rkeydc_act_func: syscall GET_LCD_INFO failed \n");
+ free(at_str);
+ return AT_END;
+ }
+ at_print(AT_ERR,"rkeydc_act_func: lcdInfo.manu = %s,ic = %s,resolution =%s\n",lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
+ snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?%s\r\n",lcdInfo.manu,lcdInfo.ic,lcdInfo.resolution);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ else if(strstr(at_paras, "WIFI"))
+ {
+ retCode = syscall(GET_WIFI_INFO,wifiInfo.manu,wifiInfo.ic);
+ if(retCode < 0)
+ {
+ at_print(AT_ERR,"rkeydc_act_func: syscall GET_WIFI_INFO failed \n");
+ free(at_str);
+ return AT_END;
+ }
+ at_print(AT_ERR,"rkeydc_act_func: wifiInfo.manu = %s,ic = %s\n",wifiInfo.manu,wifiInfo.ic);
+ snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?NA\r\n",wifiInfo.manu,wifiInfo.ic);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ else if(strstr(at_paras, "CPU"))
+ {
+ retCode = syscall(GET_CPU_INFO,cpuInfo.manu,cpuInfo.model);
+ if(retCode < 0)
+ {
+ at_print(AT_ERR,"rkeydc_act_func: syscall GET_CPU_INFO failed \n");
+ free(at_str);
+ return AT_END;
+ }
+ at_print(AT_ERR,"rkeydc_act_func: cpuInfo.manu = %s,model =%s\n",cpuInfo.manu,cpuInfo.model);
+ snprintf((char*)at_str,64,"\r\n%s?%s?NA?NA?NA\r\n",cpuInfo.manu,cpuInfo.model);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ free(at_str);
+ }
+
+ return AT_END;
+
+}
+
+int poweroff_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ system("poweroff");
+ // add by houweifeng for zhangwei 20200707, systemº¯Êý²¢²»ÊÇÒ»¶¨Í¬²½Ö´ÐÐ
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: chip_platform_read_act_func
+* ¹¦ÄÜÃèÊö: return chip platform 1:7520V3 2:7100
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int chip_platform_read_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ char TmpChipPlatform[32] ={0};
+ snprintf((char *)TmpChipPlatform, 32,"1");
+ *res_msg = at_query_result_build("PLATFORM",TmpChipPlatform);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: imeiRead_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁimeiºÅ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int imeiRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = -1;
+ char TmpImei[DC_ImeiLen]= {0}; //imei³¤¶È×î´óÖµ
+ int abImeiindex = 0,imeistrindex = 0;
+ static char imeistr[2*DC_ImeiLen] = {0};
+ char *at_str = NULL;
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_IMEI_ADDRESS, (unsigned char *)TmpImei, OS_FLASH_AMT_COMM_RO_IMEI_SIZE);
+ at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
+ if(CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ for (abImeiindex=0; abImeiindex<DC_ImeiLen-1; abImeiindex++,imeistrindex+=2)
+ {
+ imeistr[imeistrindex] = Int2Char(TmpImei[abImeiindex]&0x0F);
+ imeistr[imeistrindex+1] = Int2Char((TmpImei[abImeiindex]&0xF0)>>4);
+ }
+
+ imeistr[2*DC_ImeiLen-2]=Int2Char(TmpImei[DC_ImeiLen-1]&0x0F);
+ imeistr[2*DC_ImeiLen-1] = '\0';
+
+ //*res_msg = at_query_result_build(NULL,imeistr);
+ at_str = malloc(32);
+ if(at_str)
+ {
+ sprintf(at_str,"\r\n%s\r\nOK\r\n",imeistr);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ }
+ return AT_END;
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: imeiWrite_act_func
+* ¹¦ÄÜÃèÊö: дimeiºÅ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int imeiWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = -1;
+ char *at_str = NULL;
+ char Imeistr[2*DC_ImeiLen]= {0};
+
+
+ at_str = at_paras;
+
+ at_print(AT_DEBUG,"imeiWrite_act_func = %s.\n", at_str);
+
+ //if ((strstr((const char *)at_str,"\r")-(char *)at_str)!= (2*DC_ImeiLen-1) || !IsImeiStrValid(at_str))
+ if (strlen(at_paras) != (2*DC_ImeiLen-1) || !IsImeiStrValid(at_str))
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ if (-1 ==DC_Writeimei((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ memcpy(Imeistr,at_str,2*DC_ImeiLen-1);
+ Imeistr[2*DC_ImeiLen-1] = '\0';
+ *res_msg = at_query_result_build("MODIMEI",Imeistr);
+ *res_msglen = strlen(*res_msg);
+ }
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: ssidRead_act_func
+* ¹¦ÄÜÃèÊö: »ñÈ¡SSIDºÅ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int ssidRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpSSID[ZPS_REF_MSINFO_MAX_SSID_LEN+1]={0};
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_SSID_BASE_ADDR, (unsigned char*)TmpSSID, ZPS_REF_MSINFO_MAX_SSID_LEN);
+ TmpSSID[ZPS_REF_MSINFO_MAX_SSID_LEN] = '\0';
+ if(CPNV_ERROR == retCode)
+ {
+ at_print(AT_ERR,"cpnv_NvItemRead ssid fail !\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ //strcpy(TmpSSID, (const char*)cfg_get("zssid"));
+
+ *res_msg = at_query_result_build("SSID",TmpSSID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: ssidWrite_act_func
+* ¹¦ÄÜÃèÊö: дSSIDºÅ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: µ±SSIDºÅ¸Ä±äʱatserverÖ÷¶¯Éϱ¨¸øctrm£¬ctrm½«SSIDºÅдÈëNVÖÐ
+**************************************************************************/
+int ssidWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ at_print(AT_ERR,"at_paras=%s\n",at_paras);
+
+ at_str = at_paras;
+
+ retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_SSID_BASE_ADDR, (unsigned char*)at_str, strlen(at_str));
+ at_print(AT_ERR,"at_str=%s\n",at_str);
+ at_print(AT_ERR,"retCode=%d\n",retCode);
+
+ if(CPNV_ERROR == retCode)
+ {
+ at_print(AT_ERR,"cpnv_NvItemWrite ssid fail !\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ else
+ {
+ at_print(AT_ERR,"cpnv_NvItemWrite ssid success !\n");
+ }
+
+ sc_cfg_set("zssid",at_str);
+
+ retCode = cpnv_NvramFlush();
+
+ if (retCode == CPNV_OK)
+ {
+ *res_msg = at_query_result_build("SSID",at_str);
+ }
+ else
+ {
+ at_print(AT_ERR,"cpnv_NvramFlush ssid fail !\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: versionTypeSet_act_func
+* ¹¦ÄÜÃèÊö: ÉèÖð汾ÀàÐÍ£¬AMT°æ±¾/´ó°æ±¾
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: AT+ZVERSIONTYPE=0Ϊ´ó°æ±¾£¬AT+ZVERSIONTYPE=1ΪAMT°æ±¾
+**************************************************************************/
+int versionTypeSet_act_func(int at_fd, char * at_paras,void **res_msg, int * res_msglen)
+{
+ long retCode = -1;
+ char *at_str = NULL;
+ int ntype = -1;
+
+ at_print(AT_ERR,"at_paras=%s\n", at_paras);
+ at_str = at_paras;
+
+ unsigned char bootmode[] = {0x54, 0x4D};
+ unsigned char atmode[] = {0x41, 0x54};
+ get_at_cmd_param_int(at_str, &ntype, (const char **)&at_str);
+
+ if(!is_at_cmd_end(at_str))
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if(ntype == 1)
+ {
+ retCode = amt_set_bootmode(bootmode);
+ }
+ else if(ntype == 0)
+ {
+ memset(bootmode, 0xFF, 2);
+ retCode = amt_set_bootmode(bootmode);
+ }
+ else if(ntype == 2)
+ {
+ retCode = amt_set_amt_atmode(bootmode,atmode);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ if (retCode == 0)
+ {
+ if (ntype == 0)
+ {
+ *res_msg = at_query_result_build("versionType","0");
+ }
+ else if(ntype == 1)
+ {
+ *res_msg = at_query_result_build("versionType","1");
+ }
+ else if(ntype == 2)
+ {
+ *res_msg = at_query_result_build("versionType","2");
+ }
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: macRead_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+int macRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpMacAddr[Comm_DEV_MSINFO_MAX_WIFIMAC_Area_Len] = {0};//imei³¤¶È×î´óÖµ
+ char str[13];
+ unsigned long abMacindex = 0;
+ static char macstr[2 * AT_CMD_MAX - 1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_WIFIMAC_ADDRESS, (unsigned char *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_WIFIMAC_SIZE);
+ at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
+ if(CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
+ memset(str, 0, 13);
+
+ for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
+ {
+ str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
+ str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
+
+ macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
+ macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
+ }
+
+ *res_msg = at_query_result_build("MAC",macstr);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: macWrite_act_func
+* ¹¦ÄÜÃèÊö: дMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int macWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+
+ if (strlen(at_str) != DC_MacLen)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if (-1 == DC_WriteMacAddr((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ //*res_msg = at_query_result_build("MAC",at_str);
+ *res_msg = at_ok_build();
+ }
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: wifikeyRead_act_func
+* ¹¦ÄÜÃèÊö: »ñÈ¡WifiKeyµÄÖµ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int wifikeyRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpWifiKey[ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN+1]={0};
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR, (unsigned char *)TmpWifiKey, ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN);
+ TmpWifiKey[ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN] = '\0';
+ //zOss_ASSERT(retCode!=ZOSS_ERROR);
+ if(CPNV_ERROR == retCode)
+ {
+ at_print(AT_ERR,"cpnv_NvItemRead wifikey fail !\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ //strcpy(TmpWifiKey, (const char*)cfg_get("zwifikey"));
+
+ *res_msg = at_query_result_build("WIFIKEY",TmpWifiKey);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: wifikeyWrite_act_func
+* ¹¦ÄÜÃèÊö: дWIFI KEYµÄÖµ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int wifikeyWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ //char *pStrValue = NULL;
+ unsigned long retCode = CPNV_ERROR;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+ if(strlen(at_str)> ZPS_REF_MSINFO_MAX_NEWWIFIKEY_LEN)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_NEWWIFIKEY_BASE_ADDR, (unsigned char *)at_str, strlen(at_str));
+ //sc_cfg_set("zwifikey",at_str);
+
+ if (retCode == CPNV_OK)
+ {
+ retCode = cpnv_NvramFlush();
+
+ if (retCode == CPNV_OK)
+ {
+ *res_msg = at_query_result_build("WIFIKEY",at_str);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: rj45MacAddrRead_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+int rj45MacAddrRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned long retCode = CPNV_ERROR;
+ char TmpMacAddr[OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE] = {0};
+ char str[13];
+ long abMacindex = 0;
+ static char macstr[2 * OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE - 1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_ETHMAC_ADDRESS, (unsigned char *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_ETHMAC_SIZE);
+ at_print(AT_DEBUG,"retCode = %d\r\n",retCode );
+ if(CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
+ memset(str, 0, 13);
+
+ for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
+ {
+ str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
+ str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
+
+ macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
+ macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
+ }
+
+ /* MACµØÖ·×ª»»½áÊø*/
+ *res_msg = at_query_result_build("ETHMAC",macstr);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: rj45MacAddWrite_act_func
+* ¹¦ÄÜÃèÊö: дMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+int rj45MacAddWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+
+ if (strlen(at_str)!= DC_MacLen)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if (-1 == DC_WriteRJ45MacAddr((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ *res_msg = at_query_result_build("ETHMAC",at_str);
+ }
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: mac2Read_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+int mac2Read_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned long retCode = CPNV_ERROR;
+ char TmpMacAddr[OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE] = {0};//imei³¤¶È×î´óÖµ
+ char str[13];
+ long abMacindex = 0;
+ static char macstr[2 * OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE - 1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_WIFIMAC2_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_WIFIMAC2_SIZE);
+
+ if (CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
+ memset(str, 0, 13);
+
+ for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
+ {
+ str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
+ str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
+
+ macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
+ macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
+ }
+
+ /* MACµØÖ·×ª»»½áÊø*/
+ *res_msg = at_query_result_build("MAC2",macstr);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: mac2Write_act_func
+* ¹¦ÄÜÃèÊö: дMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int mac2Write_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+
+ if (strlen(at_str)!= DC_MacLen)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if (-1 == DC_WriteMac2Addr((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ *res_msg = at_query_result_build("MAC2",at_str);
+ }
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: usbmacRead_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁUSB MACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+int usbmacRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned long retCode = CPNV_ERROR;
+ char TmpMacAddr[OS_FLASH_AMT_COMM_RO_USBMAC_SIZE] = {0};//imei³¤¶È×î´óÖµ
+ char str[13];
+ long abMacindex = 0;
+ static char macstr[2 * OS_FLASH_AMT_COMM_RO_USBMAC_SIZE - 1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_USBMAC_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_USBMAC_SIZE);
+
+ if (CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
+ memset(str, 0, 13);
+
+ for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
+ {
+ str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
+ str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
+
+ macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
+ macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
+ }
+
+ /* MACµØÖ·×ª»»½áÊø*/
+ *res_msg = at_query_result_build("USBMAC",macstr);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: usbmacWrite_act_func
+* ¹¦ÄÜÃèÊö: дUSB MACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int usbmacWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+
+ if (strlen(at_str)!= DC_MacLen)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if (-1 == DC_WriteUSBMacAddr((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ *res_msg = at_query_result_build("USBMAC",at_str);
+ }
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: gmacRead_act_func
+* ¹¦ÄÜÃèÊö: ¶ÁGMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷: NVÖÐMACµØÖ·ÎªBCDÂ룬ÐèҪת³ÉASCIIÂë
+**************************************************************************/
+
+int gmacRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned long retCode = CPNV_ERROR;
+ char TmpMacAddr[OS_FLASH_AMT_COMM_RO_GMAC_SIZE] = {0};//imei³¤¶È×î´óÖµ
+ char str[13];
+ long abMacindex = 0;
+ static char macstr[2 * OS_FLASH_AMT_COMM_RO_GMAC_SIZE - 1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_GMAC_ADDRESS, (UINT8 *)TmpMacAddr, OS_FLASH_AMT_COMM_RO_GMAC_SIZE);
+
+ if (CPNV_ERROR == retCode )
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ /* MACµØÖ·×ª»»BCDÂëת»»ÎªAscii */
+ memset(str, 0, 13);
+
+ for (abMacindex = 0; abMacindex< 12; abMacindex += 2)
+ {
+ str[abMacindex] = ((TmpMacAddr[abMacindex/2]) >> 4) & 0x0F;
+ str[abMacindex+1] = TmpMacAddr[abMacindex/2] & 0x0F;
+
+ macstr[abMacindex] = BCD2Ascii(str[abMacindex]);
+ macstr[abMacindex+1] = BCD2Ascii(str[abMacindex+1]);
+ }
+
+ /* MACµØÖ·×ª»»½áÊø*/
+ *res_msg = at_query_result_build("GMAC",macstr);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: gmacWrite_act_func
+* ¹¦ÄÜÃèÊö: дGMACµØÖ·
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int gmacWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //long retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ //zOss_ASSERT(at_paras!=NULL);
+ at_str = at_paras;
+
+ if (strlen(at_str)!= DC_MacLen)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if (-1 == DC_WriteGmacAddr((char *)at_str))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ *res_msg = at_query_result_build("GMAC",at_str);
+ }
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: batdetRead_act_func
+* ¹¦ÄÜÃèÊö: »ñÈ¡BATDETµÄÖµ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int batdetRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpBatdet[32] = {0};
+ int nv_value = 0;
+
+ retCode = cpnv_NvItemRead(DRV_PERI_NV_ADDR, (unsigned char *)&nv_value, 1);
+
+ at_print(AT_DEBUG, "batdetRead_act_func:nv_value = %d\n", nv_value);
+
+ snprintf((char *)TmpBatdet, 32, "%d", nv_value);
+ if(retCode != CPNV_ERROR)
+ {
+ *res_msg = at_query_result_build("BATDET", TmpBatdet);
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ }
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: batdetWrite_act_func
+* ¹¦ÄÜÃèÊö: дBATDETµÄÖµ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int batdetWrite_act_func(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ //char *pStrValue = NULL;
+ //char TmpBatdet[32] = {0};
+ unsigned long retCode = CPNV_ERROR;
+ int nv_value = -1;
+
+ at_str = at_paras;
+ at_print(AT_DEBUG, "batdetWrite_act_func:at_str = %s\n", at_str);
+
+ get_at_cmd_param_int(at_str, &nv_value, (const char **)&at_str);
+
+ at_print(AT_DEBUG,"batdetWrite_act_func:at_str = %s\n", at_str);
+ at_print(AT_DEBUG,"batdetWrite_act_func:nv_value = %d\n", nv_value);
+
+ if(!(0 == nv_value || 1 == nv_value)) // szLanEnableÖ»ÓÐ0ºÍ1Á½¸öÖµ
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ retCode =amt_set_batdet_flag(nv_value);
+
+ if (retCode == CPNV_OK)
+ {
+ if(nv_value == 1)
+ {
+ *res_msg = at_query_result_build("BATDET","1");
+ }
+ else
+ {
+ *res_msg = at_query_result_build("BATDET","0");
+ }
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int msnRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpMSN[MSN_MAX_NVINFO_LEN+1]= {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_MSerialNum_ADDRESS, (UINT8 *)TmpMSN, MSN_MAX_NVINFO_LEN);
+ TmpMSN[MSN_MAX_NVINFO_LEN] = '\0';
+ if(retCode != CPNV_ERROR)
+ {
+ *res_msg = at_query_result_build("MSN",TmpMSN);
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ }
+ return AT_END;
+}
+
+int msnWrite_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char *at_str = NULL;
+
+ if(NULL !=at_paras)
+ {
+ at_str = at_paras;
+ at_print(AT_DEBUG,"msnWrite_act_func = %s.\n", at_str);
+ if((strlen(at_str) >= 12) && (strlen(at_str) <= 20))
+ {
+ retCode = amt_nvro_write(OS_FLASH_AMT_COMM_RO_MSerialNum_ADDRESS, MSN_MAX_NVINFO_LEN, (unsigned char *)at_str);
+ if(retCode != CPNV_ERROR)
+ {
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+ }
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+int testInfoRead_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int retCode = CPNV_ERROR;
+ char TmpTestInfo[MSINFO_MAX_NVINFO_LEN+1] = {0};
+
+ retCode = cpnv_NvItemRead(OS_FLASH_AMT_COMM_RO_TestInfo_ADDRESS, (UINT8 *)TmpTestInfo, MSINFO_MAX_NVINFO_LEN);
+ TmpTestInfo[MSINFO_MAX_NVINFO_LEN] = '\0';
+ if(retCode != CPNV_ERROR)
+ {
+ *res_msg = at_query_result_build("RTESTINFO",TmpTestInfo);
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ }
+ return AT_END;
+}
+
+int closeAutoInd_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ if('1' == at_paras[0])
+ {
+ at_context_chn_info_mod("none");
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ }
+ return AT_END;
+}
+
+
+
+int zphone_mode_query_req_act(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ UINT32 retCode = CPNV_ERROR;
+ UINT8 TmpPhoneMode = 0;
+ char *pPtr = NULL;
+
+ pPtr = malloc(256);
+ if(pPtr == NULL)
+ {
+ softap_assert("");
+ return AT_END;
+ }
+ memset(pPtr, 0x00, 256);
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR, &TmpPhoneMode, sizeof(UINT8));
+ if(retCode == CPNV_ERROR){softap_assert("");}
+
+ if( 1 == (TmpPhoneMode & 0x1)) //×îºóһλÊÇ1 ´¿modem°æ±¾
+ {
+ snprintf((char *)pPtr, 64,"\r\n+PHONEMODE: %d", 0);
+ }
+ else if (0 == (TmpPhoneMode & 0x1)) //×îºóһλÊÇ 0 Õý³£°æ±¾
+ {
+ snprintf((char *)pPtr, 64,"\r\n+PHONEMODE: %d", 1);
+ }
+
+ strcat((char *)pPtr,"\r\n\r\nOK\r\n");
+
+
+ *res_msg = pPtr;
+ *res_msglen = strlen(pPtr);
+
+ return AT_END;
+}
+
+int zphone_mode_set_req_act(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ UINT8 phoneModeStatus = 0;
+ UINT32 retCode = CPNV_ERROR;
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
+ if(retCode == CPNV_ERROR)
+ {
+ softap_assert("");
+ }
+
+ //Õý³£°æ±¾
+ if('1' == at_paras[0])
+ {
+ phoneModeStatus = (0xfe & phoneModeStatus); // ºóһλ0±íʾÕý³£°æ±¾
+ sc_cfg_set("version_mode","0");
+ }
+ //´¿modem°æ±¾
+ else if('0' == at_paras[0])
+ {
+ phoneModeStatus = (0x1 | phoneModeStatus); // ºóһλ1±íʾÊÇ´¿modem°æ±¾
+ sc_cfg_set("version_mode","1"); //version_mode==1 phonemode==0 Ϊ´¿modem°æ±¾
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ retCode = cpnv_NvItemWrite(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
+ if(retCode == CPNV_ERROR){softap_assert("");}
+ retCode = cpnv_NvramFlush();
+ if(retCode == CPNV_ERROR){softap_assert("");}
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: zsoftreset_act_func
+* ¹¦ÄÜÃèÊö: ÉèÖÃÈí¼þÖØÆô
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ: ÎÞ
+* ÆäËü˵Ã÷:
+**************************************************************************/
+int zsoftreset_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ //char *pPtr = NULL;
+
+ //zOss_SysSoftReset(SYS_RESET_TO_NORMAL);
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+
+ *res_msg = at_query_result_build("ZSOFTRESET", "");
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ext_ramdump_func(char *at_paras, void ** res_msg)
+{
+ assert(0);
+ return AT_END;
+}
+
+int zmodeSet_act_func_check_mode(char *at_paras, void ** res_msg, int *res_msglen)
+{
+ int iUsbMode = -1;
+ char* at_str = NULL;
+
+
+ if(at_paras==NULL)
+ softap_assert("zmodeSet_act_func:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iUsbMode, (const char **)&at_str);
+ at_print(AT_DEBUG,"zmodeSet_act_func:iUsbMode == %d\n", iUsbMode);
+
+ char strCfgGetItem[AT_CMD_MAX] = {0};
+ nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
+ at_print(AT_ERR,"current usb mode type = %s\n", strCfgGetItem);
+
+ //´ÓÓû§Ä£Ê½Çе½ÆäËû·ÇÓû§Ä£Ê½¶¼ÐèÒª¼øÈ¨
+/* if((strcmp(strCfgGetItem,"user")== 0)&&(iUsbMode != 0))
+ {
+ if(auth_device_key_result != 1 && auth_device_key_init_value() != 1)
+ {
+ at_print(AT_ERR,"auth_device_key_result=%d,device key verify fail!\n", auth_device_key_result);
+ *res_msg = at_err_build(ATERR_NOT_ALLOWED);
+ *res_msglen = strlen(*res_msg);
+
+ iUsbMode = -1;
+ }
+ }*/
+
+ return iUsbMode;
+}
+
+
+int zmodeSet_act_func(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int iUsbMode = 0;
+ UINT8 bootmode[] = {0x54,0x4D};
+ long retCode = -1;
+
+ at_print(AT_DEBUG,"ext_amt_func.c:zmodeSet_act_func\n");
+
+ iUsbMode = zmodeSet_act_func_check_mode(at_paras, res_msg, res_msglen);
+ if(iUsbMode < 0)
+ {
+ return AT_END;
+ }
+
+ switch(iUsbMode)
+ {
+ case 0: //user mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "user", 1);
+ bootmode[1] =0x00;
+ retCode = amt_set_bootmode(bootmode);
+ break;
+ }
+ case 1://debug mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "debug", 1);
+ bootmode[1] =0x01;
+ retCode = amt_set_bootmode(bootmode);
+ break;
+ }
+ case 2://factory mode
+ {
+ nv_set_item(NV_RO, "usb_modetype", "factory", 1);
+ bootmode[1] =0x02;
+ retCode = amt_set_bootmode(bootmode);
+ break;
+ }
+ case 3://amt mode
+ {
+ //nv_set_item(NV_RO, "usb_modetype", "amt", 1);
+ retCode = amt_set_bootmode(bootmode);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+
+ nv_commit(NV_RO);
+
+ at_print(AT_DEBUG,"zmodeSet_act_func:retCode == %d\n", retCode);
+ if (retCode == 0)
+ {
+ *res_msg = at_ok_build();
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int write_security_info(int at_fd, char *at_paras, void **res_msg, int *res_msglen)
+{
+ UINT32 pubKeyHash[4] = {0};
+ UINT32 secureFlag = 0xFF;
+ T_ZDrvEfuse_Secure efuseInfo = {{0}};
+ char strValue[16];
+ char strLog[256] = {0};
+ md5_ctx stStc;
+ int i;
+ int efuse_fd = -1;
+ //int ret = -1;
+
+ /*************************»ñÈ¡¹«Ô¿hash**************************/
+ // »ñÈ¡¹«Ô¿
+ efuse_fd = open("/dev/efuse", O_RDWR);
+ if (efuse_fd < 0) {
+ at_print(AT_ERR,"open %s fail.\n","/dev/efuse");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
+ {
+ at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+ at_print(AT_NORMAL, "security flag in efuse: %08X\r", efuseInfo.secureFlag);
+
+ // ¼ÆË㹫ԿhashÖµ
+ md5_init(&stStc);
+ md5_update(&stStc, (unsigned char *)efuseInfo.pubKeyRsaE, sizeof(efuseInfo.pubKeyRsaE));
+ md5_update(&stStc, (unsigned char *)efuseInfo.pubKeyRsaN, sizeof(efuseInfo.pubKeyRsaN));
+ md5_final((UINT8 *)pubKeyHash, &stStc);
+
+ // ´òÓ¡¹«Ô¿hash
+ strLog[0] = '\0';
+ for (i = 0; i < sizeof(pubKeyHash)/sizeof(UINT32); i++)
+ {
+ pubKeyHash[i] = ((pubKeyHash[i] & 0xff000000) >> 24)
+ | ((pubKeyHash[i] & 0x00ff0000) >> 8)
+ | ((pubKeyHash[i] & 0x0000ff00) << 8)
+ | ((pubKeyHash[i] & 0x000000ff) << 24) ;
+
+ sprintf(strValue, "%08lX", pubKeyHash[i]);
+ strcat(strLog, strValue);
+ }
+
+ at_print(AT_NORMAL, "Public key hash: %s\r", strLog);
+
+ /*************************½«°²È«ÐÅϢдÈëefuse**************************/
+
+ if (memcmp(efuseInfo.pubKeyHash, pubKeyHash, sizeof(pubKeyHash)) != 0)
+ {
+ // ¹«Ô¿hashֵдÈëefuse
+ if (ioctl(efuse_fd , EFUSE_SET_PUB_KEY_HASH, pubKeyHash) != 0)
+ {
+ at_print(AT_ERR, "Write public key hash to efuse fail!\r");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+ else
+ {
+ at_print(AT_NORMAL, "Write public key hash to efuse success!\r");
+ }
+ }
+ else
+ {
+ at_print(AT_NORMAL, "Public key's hash value already exists!\r");
+ }
+ /*efuseInfo.secureFlagÇ°Ãæ3¸ö×Ö½ÚÊÇchip flag,×îºóÒ»¸ö×Ö½ÚÊǰ²È«Ê¹ÄܱêÖ¾*/
+
+ if ((efuseInfo.secureFlag&0xff) != secureFlag)
+ {
+ // ʹÄܱêʶλдÈëefuse
+ if (ioctl(efuse_fd , EFUSE_SET_SECURE_EN, &secureFlag) != 0)
+ {
+ at_print(AT_ERR, "Write security flag to efuse fail!\r");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+ else
+ {
+ at_print(AT_NORMAL, "Write security flag to efuse success!\r");
+ }
+ }
+
+ else
+ {
+ at_print(AT_NORMAL, "Secure flag already exists!\r");
+ }
+
+ /*************************ÅжÏдÈëµÄÐÅÏ¢ÊÇ·ñÕýÈ·**************************/
+ // ´Óefuse¶ÁÈ¡
+ memset(&efuseInfo, 0, sizeof(efuseInfo));
+ if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuseInfo)!= 0)
+ {
+ at_print(AT_ERR,"ioctl: EFUSE_GET_DATA fail.\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+
+ if ((efuseInfo.secureFlag&0xff) != secureFlag)
+ {
+ at_print(AT_ERR, "Security flag(%#08X) is not consistent!\r", efuseInfo.secureFlag);
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+
+ if (memcmp(efuseInfo.pubKeyHash, pubKeyHash, sizeof(pubKeyHash)) != 0)
+ {
+ at_print(AT_ERR, "Public key hash is not consistent!\r");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+ }
+
+ *res_msg = at_query_result_build("write security infomation", NULL);
+ *res_msglen = strlen(*res_msg);
+ close(efuse_fd);
+ return AT_END;
+}
+/*
+int auth_device_key(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+
+ at_print(AT_ERR,"at_paras=%s\n",at_paras);
+
+ at_str = at_paras;
+ char seed[] = SEED;
+ auth_device_key_result = verify_device_key(at_str,strlen(at_str),seed,strlen(seed));
+ at_print(AT_ERR,"auth_device_key_result=%d\n",auth_device_key_result);
+
+ if (auth_device_key_result == 1)
+ {
+ *res_msg = at_ok_build();
+ }
+ else
+ {
+ at_print(AT_ERR,"verify device key fail !\n");
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+*/
+
+int ext_amt_regist(void)
+{
+ if(!ext_is_usermode())
+ {
+ register_serv_func2("MODIMEI=",0,0,0,imeiWrite_act_func,NULL);
+ register_serv_func2("PHONEMODE=",0,0,0,zphone_mode_set_req_act, 0);
+ register_serv_func("ramdump",0,ext_ramdump_func);
+ // дÈ밲ȫÐÅÏ¢
+ register_serv_func2("WSCYINFO",0,0,0,write_security_info,NULL);
+ }
+ register_serv_func2("RKEYDC=",0,0,0,rkeydc_act_func,NULL);
+ register_serv_func2("ZPOWEROFF",0,0,0,poweroff_act_func,NULL);
+ register_serv_func2("PLATFORM?",0,0,0,chip_platform_read_act_func,NULL);
+ register_serv_func2("READIMEI",0,0,0,imeiRead_act_func,NULL);
+ register_serv_func2("READIMEI?",0,0,0,imeiRead_act_func,NULL);
+ register_serv_func2("SSID?",0,0,0,ssidRead_act_func,NULL);
+ register_serv_func2("SSID=",0,0,0,ssidWrite_act_func,NULL);
+ register_serv_func2("ZVERSIONTYPE=",0,0,0,versionTypeSet_act_func,NULL);
+ register_serv_func2("MAC?",0,0,0,macRead_act_func,NULL);
+ register_serv_func2("MAC=",0,0,0,macWrite_act_func,NULL);
+ register_serv_func2("WIFIKEY?",0,0,0,wifikeyRead_act_func,NULL);
+ register_serv_func2("WIFIKEY=",0,0,0,wifikeyWrite_act_func,NULL);
+ register_serv_func2("ETHMAC?",0,0,0,rj45MacAddrRead_act_func,NULL);
+ register_serv_func2("ETHMAC=",0,0,0,rj45MacAddWrite_act_func,NULL);
+ register_serv_func2("MAC2?",0,0,0,mac2Read_act_func,NULL);
+ register_serv_func2("MAC2=",0,0,0,mac2Write_act_func,NULL);
+ register_serv_func2("USBMAC?",0,0,0,usbmacRead_act_func,NULL);
+ register_serv_func2("USBMAC=",0,0,0,usbmacWrite_act_func,NULL);
+ register_serv_func2("GMAC?",0,0,0,gmacRead_act_func,NULL);
+ register_serv_func2("GMAC=",0,0,0,gmacWrite_act_func,NULL);
+ register_serv_func2("BATDET?",0,0,0,batdetRead_act_func,NULL);
+ register_serv_func2("BATDET=",0,0,0,batdetWrite_act_func,NULL);
+ register_serv_func2("MSN?",0,0,0,msnRead_act_func,NULL);
+ register_serv_func2("MSN=",0,0,0,msnWrite_act_func,NULL);
+ register_serv_func2("RTESTINFO",0,0,0,testInfoRead_act_func,NULL);
+ register_serv_func2("ZAMTMODE=",0,0,0,closeAutoInd_act_func,NULL);
+
+ //Çл»Õý³£°æ±¾ºÍ´¿modem°æ±¾
+ register_serv_func2("PHONEMODE?",0,0,0,zphone_mode_query_req_act, 0);
+
+ register_serv_func2("ZSOFTRESET",0,0,0,zsoftreset_act_func,NULL);
+
+ register_serv_func2("zmode=",0,0,0,zmodeSet_act_func,NULL);
+ //mdlÓû§Ä£Ê½ÇÐÑз¢Ä£Ê½¼øÈ¨AT+ZAUTH=KEY
+ //register_serv_func2("ZAUTH=",0,0,0,auth_device_key,NULL);
+ return 0;
+}
diff --git a/ap/lib/libatext/ext_ccapp_fnc.c b/ap/lib/libatext/ext_ccapp_fnc.c
new file mode 100755
index 0000000..6e351cf
--- /dev/null
+++ b/ap/lib/libatext/ext_ccapp_fnc.c
@@ -0,0 +1,312 @@
+/*********************************************************************************
+ * °æ±¾ËùÓÐ (C)
+ *
+ * ¹¦ÄÜ : CcAppÏà¹ØAT´¦Àí
+ * ×÷Õß :
+ * °æ±¾ : V1.0
+ * Íê³ÉÈÕÆÚ : 2017.2.1
+ * ÆäËü˵Ã÷ :
+ * ²ÎÊý :
+ * ÊäÈë :
+ * Êä³ö :
+ * ¸ü¸Ä¼Ç¼ :
+ * ʱ¼ä ×÷Õß ÄÚÈÝ
+ *-----------------------------------------------------------------------
+ *
+ *
+***********************************************************************************/
+#ifndef CONFIG_MIN_8M_VERSION
+#include "at_context.h"
+#include "cfg_nv_def.h"
+#include "at_com.h"
+
+#define ZAT_INVALID_LEN -1
+#define MSG_RETRY_NUM 4
+#define MSG_RETRY_INTERVAL 50
+
+char* atCcapp_SendAtdReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ T_zCcapp_CallMoReq *callReq = (T_zCcapp_CallMoReq *)msgbuf->aucDataBuf;
+ char *pAtcmdStr = NULL;
+
+ pAtcmdStr = malloc(ZDIAL_NUM_MAX+4);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, ZDIAL_NUM_MAX+4);
+ snprintf(pAtcmdStr, ZDIAL_NUM_MAX+4,"ATD%s;\r\n", callReq->number);
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendAtaReq(void *param)
+{
+ char *pAtcmdStr = NULL;
+
+ pAtcmdStr = malloc(10);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 10);
+ snprintf(pAtcmdStr, 10,"ATA\r\n");
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendChupReq(void *param)
+{
+ char *pAtcmdStr = NULL;
+
+ pAtcmdStr = malloc(30);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 30);
+ snprintf(pAtcmdStr, 30,"AT+CHUP\r\n");
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendVtsReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ char *pAtcmdStr = NULL;
+ T_zCcapp_VtsReq *vtsReq = (T_zCcapp_VtsReq *)msgbuf->aucDataBuf;
+
+ pAtcmdStr = malloc(30);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 30);
+ snprintf(pAtcmdStr, 30,"AT+VTS=%c,30\r\n",vtsReq->dtmfchar);
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendImsplusReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ char *pAtcmdStr = NULL;
+ T_zCcapp_ImsplusReq *imsplusReq = (T_zCcapp_ImsplusReq *)msgbuf->aucDataBuf;
+
+ pAtcmdStr = malloc(30);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 30);
+ if (imsplusReq->setfg == 1)
+ {
+ snprintf(pAtcmdStr, 30,"AT+ZIMSPLUS=%d\r\n",imsplusReq->act);
+ }
+ else
+ {
+ snprintf(pAtcmdStr, 30,"AT+ZIMSPLUS=%d,4\r\n",imsplusReq->act);
+ }
+
+return pAtcmdStr;
+}
+char* atCcapp_SendClckReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ char *pAtcmdStr = NULL;
+ T_zCcapp_ClckReq *clckReq = (T_zCcapp_ClckReq *)msgbuf->aucDataBuf;
+
+
+ pAtcmdStr = malloc(50);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 50);
+ if (clckReq->type == 0)
+ snprintf(pAtcmdStr, 50,"AT+CLCK=\"AO\",%d,\"%s\"\r\n",clckReq->act,clckReq->pw);
+ else if (clckReq->type == 1)
+ snprintf(pAtcmdStr, 50,"AT+CLCK=\"OI\",%d,\"%s\"\r\n",clckReq->act,clckReq->pw);
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendCcfcReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ char *pAtcmdStr = NULL;
+ T_zCcapp_CcfcReq *ccfcReq = (T_zCcapp_CcfcReq *)msgbuf->aucDataBuf;
+
+ pAtcmdStr = malloc(30);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 30);
+ if (ccfcReq->act ==1)
+ snprintf(pAtcmdStr, 30,"AT+CCFC=%d,%d,\"%s\"\r\n",ccfcReq->type, ccfcReq->act, ccfcReq->dn);
+ else if (ccfcReq->act ==0)
+ snprintf(pAtcmdStr, 30,"AT+CCFC=%d,%d\r\n",ccfcReq->type, ccfcReq->act);
+
+ return pAtcmdStr;
+}
+char* atCcapp_SendChldReq(void *param)
+{
+ MSG_BUF *msgbuf = (MSG_BUF *)param;
+ char *pAtcmdStr = NULL;
+ T_zCcapp_ChldReq *chldReq = (T_zCcapp_ChldReq *)msgbuf->aucDataBuf;
+
+ pAtcmdStr = malloc(30);
+ assert(pAtcmdStr);
+ memset(pAtcmdStr, 0x00, 30);
+ snprintf(pAtcmdStr, 30,"AT+CHLD=%d\r\n",chldReq->type);
+
+ return pAtcmdStr;
+}
+VOID zCc_NumProc(CHAR *pParaLine)
+{
+ SINT32 flg = 0;
+ UINT32 i = 0;
+ UINT32 length = 0;
+ CHAR *pSource = pParaLine;
+ CHAR *pDest = NULL;
+ CHAR abStrDest[ZDIAL_NUM_MAX+50] = {0};
+
+ pDest = abStrDest;
+ length = strlen(pParaLine);
+
+ for (i = 0; i < length ; i++)
+ {
+ if ('"' == *pSource)
+ {
+ flg = (0 == flg)?1:0;
+ if (0 == flg)
+ {
+ break;
+ }
+ pSource++;
+ }
+ else
+ {
+ *pDest++ = *pSource++;
+ }
+ }
+
+ memset(pParaLine, 0, length); /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */
+ strcpy(pParaLine, abStrDest);
+}
+int atCcapp_RecvDsciInd( char *at_paras ,int is_query_report)
+{
+ T_zCcApp_DsciInd *dsciInd = NULL;
+ char abNum[ZDIAL_NUM_MAX+50]= {0};
+ unsigned int type;
+
+ dsciInd = malloc(sizeof(T_zCcApp_DsciInd));
+ if(dsciInd==NULL){softap_assert(""); return AT_END;}
+ memset(dsciInd, 0, sizeof(T_zCcApp_DsciInd));
+ //zCc_PreProcRes(at_paras);
+ at_print(AT_DEBUG,"[CCAPP] dsci ind! pResLine->resParas:%s.\n", at_paras);
+ sscanf(at_paras, "%u, %u, %u, %u, %u, %97s", &dsciInd->cid, &dsciInd->dir, &dsciInd->state,&type, &dsciInd->inMpty, abNum);
+ zCc_NumProc(abNum);
+ memcpy(dsciInd->num, abNum, sizeof(dsciInd->num)-1);//cov ¿ÉÄÜÓÐÎÊÌâ
+
+ at_print(AT_DEBUG,"[CCAPP] DSCI %d %d %d\n", dsciInd->cid, dsciInd->dir, dsciInd->state);
+
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_DSCI_IND, sizeof(T_zCcApp_DsciInd), (unsigned char *)dsciInd,0);
+ at_print(AT_DEBUG,"[CCAPP]send DSCI %d\n ",MSG_CMD_DSCI_IND );
+ free(dsciInd);
+ return AT_CONTINUE;
+}
+
+int atCcapp_RecvZvoicechnlInd(char *at_paras ,int is_query_report)
+{
+ T_zCcApp_VoiceChnl *voicechnl = NULL;
+
+ voicechnl = malloc(sizeof(T_zCcApp_VoiceChnl));
+ if(voicechnl==NULL){softap_assert(""); return AT_END;}
+ memset(voicechnl, 0, sizeof(T_zCcApp_VoiceChnl));
+
+ at_print(AT_DEBUG,"[CCAPP] voicechnl ind! pResLine->resParas:%s.\n", at_paras);
+ sscanf(at_paras, "%u, %u, %u, %u", &voicechnl->op, &voicechnl->act, &voicechnl->codetype, &voicechnl->amrpath);
+ at_print(AT_DEBUG,"[CCAPP] voicechnl->op= %d voicechnl->act= %d voicechnl->codetype= %d voicechnl->amrpath= %d\n", voicechnl->op, voicechnl->act, voicechnl->codetype, voicechnl->amrpath);
+
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZVOICECHNL, sizeof(T_zCcApp_VoiceChnl), (unsigned char *)voicechnl,0);
+ at_print(AT_DEBUG,"[CCAPP]send VOICECHNL %d\n ",MSG_CMD_ZVOICECHNL );
+ free(voicechnl);
+ return AT_CONTINUE;
+}
+
+
+
+int atCcapp_RecvImsplusInd(char *at_paras ,int is_query_report)
+{
+ T_zCcApp_ImsplusInd *imsplusInd = NULL;
+
+ imsplusInd = malloc(sizeof(T_zCcApp_ImsplusInd));
+ if(imsplusInd==NULL){softap_assert("");return AT_END;}
+ memset(imsplusInd, 0, sizeof(T_zCcApp_ImsplusInd));
+
+ //zCc_PreProcRes(at_paras);
+ at_print(AT_DEBUG,"[CCAPP] imsplus ind! pResLine->resParas:%s.\n", at_paras);
+ sscanf(at_paras, "%u, %u", &imsplusInd->act, &imsplusInd->rate);
+ at_print(AT_DEBUG,"[CCAPP] imsplusInd->act= %d imsplusInd->rate= %d\n", imsplusInd->act, imsplusInd->rate);
+
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZIMSPLUS_IND, sizeof(T_zCcApp_ImsplusInd), (unsigned char *)imsplusInd,0);
+ at_print(AT_DEBUG,"[CCAPP]send IMSPLUS %d\n ",MSG_CMD_ZIMSPLUS_IND );
+ free(imsplusInd);
+ return AT_CONTINUE;
+}
+
+int atCcapp_RecvZcpiInd(char *at_paras ,int is_query_report)
+{
+ T_zCcApp_ZcpiInd *zcpiInd = NULL;
+
+ zcpiInd = malloc(sizeof(T_zCcApp_ZcpiInd));
+ if(zcpiInd==NULL){softap_assert("");return AT_END;}
+ memset(zcpiInd, 0, sizeof(T_zCcApp_ZcpiInd));
+
+ //zCc_PreProcRes(at_paras);
+ at_print(AT_DEBUG,"[CCAPP] zcpi ind! pResLine->resParas:%s.\n", at_paras);
+ sscanf(at_paras, "%u, %u, %u",&zcpiInd->cid,&zcpiInd->state,&zcpiInd->progdsp);
+
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZCPI, sizeof(T_zCcApp_ZcpiInd), (unsigned char *)zcpiInd,0);
+ free(zcpiInd);
+ return AT_CONTINUE;
+}
+int atCcapp_RecvOk(char *at_str,struct at_context *context,void **next_req,int *next_len)
+{
+ T_zCcapp_optRsp* optRsp = NULL;
+
+ optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
+ if(optRsp == NULL){softap_assert("");return AT_END;}
+ memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
+ optRsp->result = 0;
+ *next_req = optRsp;
+ *next_len = sizeof(T_zCcapp_optRsp);
+ at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive ok\n");
+ return AT_END;
+}
+
+int atCcapp_RecvErr(char *at_str,struct at_context *context,void **next_req,int *next_len)
+{
+ T_zCcapp_optRsp* optRsp = NULL;
+
+ optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
+ if(optRsp == NULL){softap_assert("");return AT_END;}
+ memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
+ optRsp->result = -1;
+ *next_req = optRsp;
+ *next_len = sizeof(T_zCcapp_optRsp);
+ at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive err\n");
+ return AT_END;
+}
+
+void ext_ccapp_regist(void)
+{
+ /****************************************************************************************
+ *×¢²áccAPPµÄops
+ *****************************************************************************************/
+ register_psclt_func(MSG_CMD_ATD_DIAL_REQ, MSG_CMD_ATD_DIAL_RSP, atCcapp_SendAtdReq);
+ register_psclt_func(MSG_CMD_ATA_REQ, MSG_CMD_ATA_RSP, atCcapp_SendAtaReq);
+ register_psclt_func(MSG_CMD_CHUP_REQ, MSG_CMD_CHUP_RSP, atCcapp_SendChupReq);
+ register_psclt_func(MSG_CMD_VTS_REQ, MSG_CMD_VTS_RSP, atCcapp_SendVtsReq);
+ register_psclt_func(MSG_CMD_ZIMSPLUS_REQ, MSG_CMD_ZIMSPLUS_RSP, atCcapp_SendImsplusReq);
+ register_psclt_func(MSG_CMD_CHLD_REQ, MSG_CMD_CHLD_RSP, atCcapp_SendChldReq);
+ register_psclt_func(MSG_CMD_CCFC_REQ, MSG_CMD_CCFC_RSP, atCcapp_SendCcfcReq);
+ register_psclt_func(MSG_CMD_CLCK_REQ, MSG_CMD_CLCK_RSP, atCcapp_SendClckReq);
+
+ /**********************×¢²áat_ctlÄÚ²¿µÄÇëÇóÀàµÄops********************************/
+ register_clt_func("ATD", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("ATA", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("CHUP", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("VTS=", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("ZIMSPLUS=", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("CHLD=", atCcapp_RecvOk, atCcapp_RecvErr);
+ register_clt_func("CCFC=", atCcapp_RecvOk, atCcapp_RecvErr);
+ //register_clt_func("CLCK=", atCcapp_RecvOk, atCcapp_RecvErr);
+
+
+ /**********************×¢²áPSÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨µÄ»Øµ÷**************************/
+ /*ÒÔÏÂÊÇÇëÇóÃüÁîµÄÖмä½á¹û*/
+ register_inform_func("DSCI",atCcapp_RecvDsciInd);
+ register_inform_func("ZCPI",atCcapp_RecvZcpiInd);
+ register_inform_func("ZIMSPLUS",atCcapp_RecvImsplusInd);
+ register_inform_func("ZVOICECHNL",atCcapp_RecvZvoicechnlInd);
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_cmux_func.c b/ap/lib/libatext/ext_cmux_func.c
new file mode 100644
index 0000000..56e4a6d
--- /dev/null
+++ b/ap/lib/libatext/ext_cmux_func.c
@@ -0,0 +1,284 @@
+/*******************************************************************************
+* Ö÷Òª¹¦ÄÜÊÇÉèÖÃCMUX¹¦ÄÜÇл»
+* Ö§³ÖµÄ¹¦ÄÜÈçÏÂ:
+* ²éѯ»òÉèÖÃCMUXģʽÇл»
+*
+* ºóÐøÈçÓÐCMUX¹¦ÄÜÏà¹ØµÄ״̬²éѯ»òÉèÖõÄÏà¹ØÐèÇ󣬿ÉÒÔÔÚ´ËÎļþÖÐÌí¼ÓATÃüÁî´¦Àí
+**********************************************************************************/
+
+
+#if (APP_OS_TYPE == APP_OS_LINUX)
+#include "ext_cmux_func.h"
+#include "ext_dev_func.h"
+
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+
+int32_t g_cmux_flag = 0;//Åжϵ±Ç°ÊÇ·ñÊÇcmux״̬
+int32_t g_commonPortinCmux = -1; //Çл»³Écmux״̬ʱÆÕͨģʽÏÂÎļþÃèÊö·û
+int32_t g_selfAdaptFlag = 0; //±ê¼ÇÊÇ·ñÐèÒªÅжϲ¨ÌØÂÊ×ÔÊÊÓ¦£¬0:²»ÐèÒª£¬1:ÐèÒª
+int32_t g_iUartPort = -1; //µ±Ç°UartÉ豸¾ä±ú
+
+static pthread_t s_uiMonitorHungupThread = -1; //´¦Àí¼à¿ØhungupµÄÏß³Ì
+
+#define N_GSM0710 21 //cmuxÏà¹ØÅäÖÃ
+#define cmuxChID 1 //µ±Ç°Ê¹ÓõÄcmuxͨµÀºÅ
+
+
+//========================================================================================================//
+//º¯ÊýʵÏÖÇø
+//========================================================================================================//
+
+static int zUP_SetPort(int32_t iFd)
+{
+ if(iFd < 0)
+ {
+ at_print(AT_ERR,"Set usb port error. iFd == %d\n", iFd);
+ return 0;
+ }
+ at_print(AT_ERR,"Set usb port ok. iFd == %d\n", iFd);
+ //ioctl(iFd, (('R'<<8)|1|(0x4004<<16)), 0x400);
+ //ioctl(iFd, (('R'<<8)|4|(0x4004<<16)), 0);
+ vFnSetUsbInfo(iFd, &s_tUsbInfo, AUTO_MODE);
+ return 1;
+}
+
+static void zUP_MuxChannelConfig(int32_t iFd)
+{
+ static struct termios Muxtio;
+
+ tcgetattr(iFd, &Muxtio); // save current port settings
+ Muxtio.c_cflag = CS8 | CLOCAL | CREAD;
+
+
+ Muxtio.c_iflag = IGNPAR;
+ Muxtio.c_oflag = 0;
+ Muxtio.c_lflag = 0; //!ICANON;
+
+ Muxtio.c_cc[VMIN] = 1;
+ Muxtio.c_cc[VTIME] = 0;
+ //cfsetospeed(&Muxtio, B38400);
+ //cfsetispeed(&Muxtio, B38400);
+ tcsetattr(iFd, TCSANOW, &Muxtio);
+}
+
+int zUP_CreateCMUXATThread()
+{
+ char shellCmd[AT_CMD_MAX] = {0};
+ char mainDevNum[AT_CMD_MAX] = {0};
+ char cmuxDevice[AT_CMD_MAX] = {0};
+ FILE *fp = NULL;
+ int32_t result = -1;
+ int32_t g_modeToCMUXAT = -1; //CMUX1µÄÎļþÃèÊö·û
+
+ system("rm -f /tmp/uartproxy_file");
+ system("cat /proc/devices | grep gsmtty > /tmp/uartproxy_file");
+ fp = fopen("/tmp/uartproxy_file", "r");
+ if(NULL == fp)
+ {
+ at_print(AT_ERR,"can not open file /tmp/uartproxy_file\n");
+ return -1;
+ }
+ memset(shellCmd, 0, sizeof(shellCmd));
+ fgets(shellCmd, sizeof(shellCmd), fp);
+ at_print(AT_ERR,"shellCmd= %s!!!\n", shellCmd);
+ memcpy(mainDevNum, shellCmd, (int32_t)(strchr(shellCmd,' ') - shellCmd));
+ at_print(AT_ERR,"mainDevNum= %s!!!\n", mainDevNum);
+ fclose(fp);
+ memset(shellCmd, 0, sizeof(shellCmd));
+ snprintf(shellCmd, sizeof(shellCmd), "/bin/mknod /dev/gsmtty0 c %s 0", mainDevNum);//cmuxͨµÀ0±ØÐë´´½¨
+ result = zxic_system(shellCmd);
+ at_print(AT_ERR,"result1= %d!!!\n", result);
+ memset(shellCmd, 0, sizeof(shellCmd));
+ snprintf(shellCmd, sizeof(shellCmd),"/bin/mknod /dev/gsmtty%d c %s %d", cmuxChID, mainDevNum, cmuxChID);
+ result = zxic_system(shellCmd);
+ at_print(AT_ERR,"result2= %d!!!\n", result);
+ sprintf(cmuxDevice, "/dev/gsmtty%d", cmuxChID);//»ñÈ¡cmuxÉ豸Ãû
+ g_modeToCMUXAT = open(cmuxDevice, O_RDWR);
+ if(g_modeToCMUXAT < 0)
+ {
+ // UART_PROXY_LOG("Open port %d error.\n", g_modeToCMUXAT);
+ return 0;
+ }
+ g_commonPortinCmux = g_iUartPort;
+ g_iUartPort = g_modeToCMUXAT;
+ at_print(AT_ERR,"use gsmtty%d start!!!!\n", cmuxChID);
+
+ zUP_MuxChannelConfig(g_iUartPort);
+
+ return 1;
+}
+
+static int32_t zUP_GetUartEvents(int32_t fd)
+{
+ struct pollfd fds;
+ int32_t time_delay = 300;
+ fds.fd = fd;
+ fds.events = POLLHUP;
+ if(poll(&fds, 1, time_delay) <= 0)
+ {
+ return 0;
+ }
+ if(fds.revents)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+static void *zUP_MonitorHungupHander()
+{
+ int32_t result = 0;
+ while(1)
+ {
+ result = zUP_GetUartEvents(g_commonPortinCmux);
+ at_print(AT_DEBUG,"tty GetUartEvents ret is %d\n",result);
+ if(result > 0)
+ {
+ at_print(AT_DEBUG,"GetUartEvents ret is %d\n",result);
+
+ //·¢ËÍÏûÏ¢¸øat_Ctl£¬½øÐÐmux2USBµÄ²Ù×÷£¬ÖØÐ»ñÈ¡µ½fd
+ //ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_AT_CTL, XXX, 0, NULL,0);
+ #if 0
+ if(zUP_UartOpenConfig() == 0)
+ {
+ at_print(AT_DEBUG,"zUP_UartOpenConfig 0 %d\n");
+ return NULL;
+ }
+ g_cmux_flag = 0;
+ zUP_Mux2USB(g_iUartPort);
+ #endif
+
+ g_cmux_flag = 0;
+ pthread_cancel(s_uiMonitorHungupThread);
+ }
+ }
+ return NULL;
+}
+
+
+int zUP_CreateMonitorHungupThread()
+{
+ int32_t iResult = -1;
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ iResult = pthread_create(&s_uiMonitorHungupThread, &attr, zUP_MonitorHungupHander, NULL);
+ pthread_attr_destroy(&attr);
+ if(0 != iResult)
+ {
+ at_print(AT_ERR,"Call MonitorHungup pthread_create() error.\n");
+ return 0;
+ }
+ return 1;
+}
+
+void OpenMultiCmuxChannel()
+{
+// UART_PROXY_LOG("Enter %s, and will go open multi mux_fd\n", __FUNCTION__);
+
+ if(!zUP_CreateCMUXATThread())
+ {
+ at_print(AT_ERR,"Call zUP_CreateCMUXATThread() error.\n");
+ return;
+ }
+ if(!zUP_CreateMonitorHungupThread())
+ {
+ at_print(AT_ERR,"Call zUP_CreateMonitorHungupThread() error.\n");
+ return;
+ }
+
+}
+
+static void bFnCmuxProc()
+{
+ int ldisc = N_GSM0710;
+ int ret = 0;
+ struct gsm_config cmux_config;
+
+ g_cmux_flag = 1;
+ ret = ioctl(g_iUartPort, TIOCSETD, &ldisc);//Çл»Ïß·¹æ³Ì
+
+ at_print(AT_DEBUG,"tty goto mux ret is %d\n",ret);
+ ret = ioctl(g_iUartPort, GSMIOC_GETCONF, &cmux_config);
+ at_print(AT_DEBUG,"get mux ret is %d\n",ret);
+
+ cmux_config.initiator = 0;
+ cmux_config.encapsulation = 0;
+ cmux_config.mru = 512;
+ cmux_config.mtu = 512;
+ ret = ioctl(g_iUartPort, GSMIOC_SETCONF, &cmux_config);
+ at_print(AT_DEBUG,"set mux ret is %d\n",ret);
+ OpenMultiCmuxChannel();
+}
+
+struct at_cmux_req
+{
+ char name[32];
+ int cmux_mode; //»ù±¾/¸ß¼¶Ä£Ê½
+ int subset; //Ö¡¸ñʽÀàÐÍ
+ int port_speed; //cmux²¨ÌØÂÊ
+ int frame_len; //×î´óÖ¡³¤(N1)
+ int ack_time; //½ÓÊÕÈ·ÈÏʱ¼ä(T1)
+ int recon_count; //×î´óÖØÁ¬´ÎÊý(N2)
+ int resp_time; //ÏìӦʱ¼ä(T2)
+ int awak_time; //»½ÐÑʱ¼ä(T3)
+ int win_size; //´°¿Ú´óС
+};
+
+int zcmuxSet_req(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+
+ struct at_cmux_req *req = NULL;
+ req = malloc(sizeof(struct at_cmux_req));
+ if(req == NULL){softap_assert("");return AT_END;}
+ memset(req,0,sizeof(struct at_cmux_req));
+ void *p[9] = {&req->cmux_mode,&req->subset,&req->port_speed,&req->frame_len,&req->ack_time,&req->recon_count,&req->resp_time,&req->awak_time,&req->win_size};
+
+ if(at_paras==NULL)
+ softap_assert("zcmuxSet_req:at_paras is null");
+
+ parse_param2("%d,%d,%d,%d,%d,%d,%d,%d,%d",at_paras,p);
+ at_print(AT_DEBUG,"zcmuxSet_req: cmux_mode = %d, subset = %d, port_speed = %d, frame_len = %d, ack_time = %d, recon_count = %d, resp_time = %d, awak_time = %d, win_size = %d\n",
+ req->cmux_mode, req->subset, req->port_speed, req->frame_len, req->ack_time, req->recon_count,
+ req->resp_time, req->awak_time, req->win_size);
+
+ if(req->cmux_mode == 0 && req->subset >= 0 && req->subset <= 1 && req->port_speed >= 0 && req->port_speed <= 5 &&
+ (req->frame_len >= 8||req->frame_len == 0) && req->frame_len <= 32768 && req->ack_time >= 0 && req->ack_time <= 255 && req->recon_count >= 0 && req->recon_count <= 100
+ && req->resp_time >= 0 && req->resp_time <= 255 && req->awak_time == 0 && req->win_size == 0)
+ {
+ at_print(AT_ERR, "Enter zcmuxSet_req\n");
+
+ //req->fd = at_fd;
+ char *name = at_portmng_get_name_by_fd(at_fd);
+ if(name)
+ memcpy(req->name, name, sizeof(req->name));
+ *res_msg = req;
+ *res_msglen = sizeof(struct at_cmux_req);
+ return AT_CONTINUE;
+ }
+ free(req);
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+int zcmuxSet_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ int rsp = *(int *)rsp_msg;
+ if(rsp)
+ {
+ *ret = at_ok_build();
+ }
+ else
+ {
+ *ret = at_err_build(ATERR_PROC_FAILED);
+ }
+ *retlen = strlen(*ret);
+ return AT_END;
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_cmux_func.h b/ap/lib/libatext/ext_cmux_func.h
new file mode 100644
index 0000000..5278107
--- /dev/null
+++ b/ap/lib/libatext/ext_cmux_func.h
@@ -0,0 +1,39 @@
+
+#ifndef __EXT_CMUX_REGIST_H__
+#define __EXT_CMUX_REGIST_H__
+
+#if (APP_OS_TYPE == APP_OS_LINUX)
+
+#include "ext_regist.h"
+#include "softap_api.h"
+#include "at_utils.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/stat.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <pty.h>
+
+//add for cmux
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <poll.h>
+
+//========================================================================================================//
+//º¯ÊýÉùÃ÷Çø
+//========================================================================================================//
+
+int zcmuxSet_req(int at_fd,char * at_paras,void * *res_msg,int * res_msglen);
+int zcmuxSet_rsp(void *rsp_msg, void**ret, int *retlen);
+
+#endif
+
+#endif /*__EXT_CMUX_REGIST_H__*/
diff --git a/ap/lib/libatext/ext_dev_func.c b/ap/lib/libatext/ext_dev_func.c
new file mode 100755
index 0000000..24cbc83
--- /dev/null
+++ b/ap/lib/libatext/ext_dev_func.c
@@ -0,0 +1,566 @@
+/************************************************************************
+*¹¦ÄܽéÉÜ£ºÓÃÓÚ¹¦ÄÜ»úap²à´¦ÀíµÄAP\CPºË¼äUSB\TcardÀ©Õ¹at£¬ÓÉat_ctlÔÚÆô¶¯Ê±µ÷ÓÃ
+*¸ºÔðÈË£º
+*±¸·ÝÈË£º
+*ÐÞ¸ÄÈÕ£º
+*ÐÞ¸ÄÄÚÈÝ£º
+*°æ±¾ºÅ£º
+************************************************************************/
+#if (APP_OS_TYPE == APP_OS_LINUX)
+#include "at_msg.h"
+#include "at_com.h"
+#include "at_context.h"
+#include "ext_dev_func.h"
+#include "ext_cmux_func.h"
+
+//add for cmux
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <poll.h>
+#include <termios.h>
+#include <limits.h>
+
+#define OPENECHO 1 //´ò¿ª»ØÏÔ¹¦ÄÜ
+#define CLOSEECHO 0 //¹Ø±Õ»ØÏÔ¹¦ÄÜ
+#define USB_GPIO_DETECT_ENABLE_EXT "/sys/dwc_usb/usbconfig/gpio_detect"
+
+static int writefile(char*path, char*buf, unsigned len)
+{
+ FILE *fp;
+ int rtv;
+ if((fp=fopen(path,"w"))==NULL)
+ {
+ slog(USBCFGMNG_PRINT,SLOG_ERR, "[ext_dev_fun] open file %s error.\n",path);
+ return -1;
+ }
+ rtv = fwrite(buf,len,1, fp);
+ fclose(fp);
+ return rtv;
+}
+
+
+// USB¶Ë¿ÚÐÅÏ¢
+T_PCS_USB_INFO s_tUsbInfo =
+{
+ '0', // print prompt after receiving
+ 0, // baudrate: 0
+ '8', // databit: 8
+ '0', // debug: off
+ '0', // echo: off
+ '0', // flow control: software
+ '0', // default tty: COM1
+ '0', // parity: none
+ '1', // stopbit: 1
+ 0 // reserved
+};
+
+
+// ²¨ÌØÂÊת»¯×ª»»º¯Êý
+static int32_t iFnConvbaud(int32_t iBaudrate)
+{
+ //PC_SERVER_LOG();
+
+ switch(iBaudrate)
+ {
+ case 2400:
+ return B2400;
+ case 4800:
+ return B4800;
+ case 9600:
+ return B9600;
+ case 19200:
+ return B19200;
+ case 38400:
+ return B38400;
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ default:
+ return B9600;
+ }
+}
+
+// ²¨ÌØÂÊ·´×ª»¯×ª»»º¯Êý
+static int32_t iFnBaudconv(int32_t Baudrate)
+{
+ switch(Baudrate)
+ {
+ case B2400:
+ return 2400;
+ case B4800:
+ return 4800;
+ case B9600:
+ return 9600;
+ case B19200:
+ return 19200;
+ case B38400:
+ return 38400;
+ case B57600:
+ return 57600;
+ case B115200:
+ return 115200;
+ default:
+ return 9600;
+ }
+}
+
+// ÉèÖö˿ÚÐÅÏ¢¡£iFdCom: ´®¿ÚÎļþÃèÊö·û, ptPortInfo: ´ýÉèÖõĶ˿ÚÐÅÏ¢¡£
+void vFnSetUsbInfo(int32_t iFdCom, const PT_PCS_USB_INFO ptPortInfo, USB_PORT_MODE usbPortMode)
+{
+ struct termios tOldTermios = {0}, tNewTermios = {0};
+ int32_t iBaudrate = 0;
+ char cDatabit = 0, cStopbit = 0, cParity = 0, cFctl = 0;
+
+ //PC_SERVER_LOG();
+
+ bzero(&tOldTermios, sizeof(tOldTermios));
+ bzero(&tNewTermios, sizeof(tNewTermios));
+ cfmakeraw(&tNewTermios);
+ tcgetattr(iFdCom, &tOldTermios); // get the serial port attributions
+ /*------------ÉèÖö˿ÚÊôÐÔ----------------*/
+ if(usbPortMode == AUTO_MODE)
+ {
+ iBaudrate = cfgetispeed(&tOldTermios);
+ }
+ else
+ {
+ iBaudrate = iFnConvbaud(ptPortInfo->iBaudrate);
+ tcflush(iFdCom, TCIOFLUSH);
+ cfsetispeed(&tOldTermios, iBaudrate); //ÌîÈë´®¿ÚÊäÈë¶Ë²¨ÌØÂÊ
+ cfsetospeed(&tOldTermios, iBaudrate); //ÌîÈë´®¿ÚÊä³ö¶Ë²¨ÌØÂÊ
+ if(tcsetattr(iFdCom, TCSANOW, &tOldTermios) != 0) //ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ {
+ return;
+ }
+ tcflush(iFdCom, TCIOFLUSH);
+ return;
+ }
+ cfsetispeed(&tNewTermios, iBaudrate); //ÌîÈë´®¿ÚÊäÈë¶Ë²¨ÌØÂÊ
+ cfsetospeed(&tNewTermios, iBaudrate); //ÌîÈë´®¿ÚÊä³ö¶Ë²¨ÌØÂÊ
+ tNewTermios.c_cflag |= CLOCAL; //¿ØÖÆÄ£Ê½, ±£Ö¤³ÌÐò²»»á³ÉΪ¶Ë¿ÚµÄÕ¼ÓÐÕß
+ tNewTermios.c_cflag |= CREAD; //¿ØÖÆÄ£Ê½, ʹÄܶ˿ڶÁÈ¡ÊäÈëµÄÊý¾Ý
+ // ¿ØÖÆÄ£Ê½, flow control
+ cFctl = ptPortInfo->cFctl;
+ switch(cFctl)
+ {
+ case '0':
+ {
+ tNewTermios.c_cflag &= ~CRTSCTS; //no flow control
+ }break;
+ case '1':
+ {
+ tNewTermios.c_cflag |= CRTSCTS; //hardware flow control
+ }break;
+ case '2':
+ {
+ tNewTermios.c_iflag |= IXON | IXOFF | IXANY; //software flow control
+ }break;
+ default:
+ {
+ break;
+ }
+ }
+ // ¿ØÖÆÄ£Ê½, data bits
+ tNewTermios.c_cflag &= ~CSIZE; //¿ØÖÆÄ£Ê½, ÆÁ±Î×Ö·û´óСλ
+ cDatabit = ptPortInfo->cDatabit;
+ switch(cDatabit)
+ {
+ case '5':
+ tNewTermios.c_cflag |= CS5;
+ // lint -fallthrough
+ case '6':
+ tNewTermios.c_cflag |= CS6;
+ // lint -fallthrough
+ case '7':
+ tNewTermios.c_cflag |= CS7;
+ // lint -fallthrough
+ default:
+ tNewTermios.c_cflag |= CS8;
+ }
+ // ¿ØÖÆÄ£Ê½ parity check
+ cParity = ptPortInfo->cParity;
+ switch(cParity)
+ {
+ case '0':
+ {
+ tNewTermios.c_cflag &= ~PARENB; //no parity check
+ }break;
+ case '1':
+ {
+ tNewTermios.c_cflag |= PARENB; //odd check
+ tNewTermios.c_cflag &= ~PARODD;
+ }break;
+ case '2':
+ {
+ tNewTermios.c_cflag |= PARENB; //even check
+ tNewTermios.c_cflag |= PARODD;
+ }break;
+ default:
+ {
+ break;
+ }
+ }
+ // ¿ØÖÆÄ£Ê½, stop bits
+ cStopbit = ptPortInfo->cStopbit;
+ if('2' == cStopbit)
+ {
+ tNewTermios.c_cflag |= CSTOPB;
+ }
+ else
+ {
+ tNewTermios.c_cflag &= ~CSTOPB;
+ }
+ // other attributions default
+ tNewTermios.c_oflag &= ~OPOST; //Êä³öģʽ, ÔʼÊý¾ÝÊä³ö
+ tNewTermios.c_cc[VMIN] = 1; //¿ØÖÆ×Ö·û, ËùÒª¶ÁÈ¡×Ö·ûµÄ×îСÊýÁ¿
+ tNewTermios.c_cc[VTIME] = 1; //¿ØÖÆ×Ö·û, ¶ÁÈ¡µÚÒ»¸ö×Ö·ûµÄµÈ´ýʱ¼ä£¬unit: (1/10)second
+ tcflush(iFdCom, TCIFLUSH); //Òç³öµÄÊý¾Ý¿ÉÒÔ½ÓÊÕ,µ«²»¶Á
+ tcsetattr(iFdCom, TCSANOW, &tNewTermios); //ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ tcgetattr(iFdCom, &tOldTermios);
+}
+
+static int32_t vFnPortEchoType(int32_t fdcom, int32_t echoType)
+{
+ struct termios termios_old;
+ int32_t setResult = 0;
+
+ bzero(&termios_old, sizeof(termios_old));
+ tcgetattr(fdcom, &termios_old); //get the serial port attributions
+ /*------------ÉèÖö˿ÚÊôÐÔ----------------*/
+ if(echoType == OPENECHO)
+ {
+ termios_old.c_lflag |= ECHO; //±¾µØÄ£Ê½ÉèÖûØÏÔ
+ //termios_old.c_lflag |= ECHONL;
+ }
+ else
+ {
+ termios_old.c_lflag &= ~ECHO; //±¾µØÄ£Ê½¹Ø±Õ»ØÏÔ
+ //termios_old.c_lflag &= ~ECHONL;
+ }
+
+ tcflush(fdcom, TCIFLUSH); //Òç³öµÄÊý¾Ý¿ÉÒÔ½ÓÊÕ,µ«²»¶Á
+ setResult = tcsetattr(fdcom, TCSANOW, &termios_old); //ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+ return setResult;
+}
+
+int ziprSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char* at_str = NULL;
+ int32_t iBaudrate = 0;
+ char strAtReplyCmd[AT_CMD_MAX] = {0};
+
+ if(at_paras==NULL)
+ softap_assert("ziprSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iBaudrate, &at_str);
+ at_print(AT_DEBUG,"ziprSet_rsq:iBaudrate == %d\n", iBaudrate);
+ if (iBaudrate < 0 || iBaudrate > INT_MAX-1) //kw 3
+ iBaudrate = 0;
+ s_tUsbInfo.iBaudrate = iBaudrate;
+ sleep(0.002);
+ vFnSetUsbInfo(at_fd, &s_tUsbInfo, SET_MODE);
+ sprintf(strAtReplyCmd,"%d", iBaudrate);
+ *res_msg = at_query_result_build("IPR",strAtReplyCmd);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ziprGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ struct termios tOldTermios = {0};
+ int32_t iBaudrate = 0;
+ char strAtReplyCmd[AT_CMD_MAX] = {0};
+
+ tcgetattr(at_fd, &tOldTermios); // get the serial port attributions
+ iBaudrate = iFnBaudconv(cfgetispeed(&tOldTermios));
+
+ sprintf(strAtReplyCmd,"%d", iBaudrate);
+ *res_msg = at_query_result_build("IPR",strAtReplyCmd);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zsetUsb_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t usbMode = -1;
+ char msgBuf[10] = { 0 };
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("zsetUsb_req:at_paras is null");
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &usbMode, &at_str);
+ at_print(AT_DEBUG,"zsetUsb_req:usbMode == %d\n", usbMode);
+
+ if(!is_at_cmd_end(at_str))
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if(usbMode != 0 && usbMode != 1)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ snprintf(msgBuf,sizeof(msgBuf)-1,"%d",usbMode);
+ int result = ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_USBCFGMNG, MSG_CMD_USBMOD_SETREQ, sizeof(msgBuf), msgBuf,0);
+ at_print(AT_DEBUG,"result == %d\n", result);
+ if(result != 0)
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int ate_req_rcv_act(char *at_paras,int at_fd,struct at_context *context)
+{
+ int32_t setResult = 0;
+ char strAtReplyCmd[AT_CMD_MAX] = {0};
+
+ if(atoi(at_paras) == 0 || atoi(at_paras) == 1)
+ {
+//#ifdef GUODIAN
+ if(g_customer_type == CUSTOMER_GUODIAN || g_customer_type == CUSTOMER_NANDIAN)
+ {
+ at_write(at_fd, "\r\nOK\r\n", strlen("\r\nOK\r\n"));
+ }
+ else
+ {
+//#else
+ if(atoi(at_paras) == 0)
+ setResult = vFnPortEchoType(at_fd, CLOSEECHO);
+ else
+ setResult = vFnPortEchoType(at_fd, OPENECHO);
+
+ if(setResult != 0)
+ {
+ sprintf(strAtReplyCmd,"\r\nERROR: %d\r\n", setResult);
+ at_write(at_fd, strAtReplyCmd, strlen(strAtReplyCmd));
+ }
+ else
+ {
+ at_write(at_fd, "\r\nOK\r\n", strlen("\r\nOK\r\n"));
+ }
+ }
+//#endif
+ return AT_END;
+ }
+ return AT_CONTINUE;
+}
+
+
+int zudiskstat_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ at_print(AT_ERR, "Enter zudiskstat_req\n");
+ *res_msg = malloc(AT_CMD_PREFIX);
+ assert(*res_msg!=NULL);
+ memset(*res_msg, 0, AT_CMD_PREFIX);
+ sprintf(*res_msg, "AT+ZUDISKSTAT=%s\r", at_paras);
+ at_print(AT_ERR, "*res_msg:%s, len: %d\n", (char *)(*res_msg), strlen(*res_msg));
+ *res_msglen = strlen(*res_msg);
+ return AT_CONTINUE;
+}
+
+int zudiskstat_rsp( void *rsp_msg, void **ret, int *retlen)
+{
+ *ret = malloc(strlen(rsp_msg)+1);
+ assert(*ret!=NULL);
+ memset(*ret,0,strlen(rsp_msg)+1);
+ memcpy(*ret,rsp_msg,strlen(rsp_msg));
+ *retlen = strlen(*ret);
+ return AT_END;
+}
+
+char *zusbStat_req(void *msg,struct at_context *context)
+{
+ char *at_next=malloc(AT_CMD_PREFIX);
+ assert(at_next!=NULL);
+ memset(at_next,0, AT_CMD_PREFIX);
+
+ snprintf(at_next, AT_CMD_PREFIX, "AT+USBINQ=%s\r\n", ((MSG_BUF *)msg)->aucDataBuf);
+ return at_next;
+}
+
+//AP²àNVÇå³ý
+int zaprest_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t restMode = 0;
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("zaprest_req:at_paras is null");
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &restMode, &at_str);
+ at_print(AT_DEBUG,"zaprest_req:restMode == %d\n", restMode);
+
+ if(!is_at_cmd_end(at_str))
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ //µ÷WiFiÌṩµÄ½Ó¿Ú,Çå³ýapËùÓÐnv
+ if(restMode==1)
+ {
+ //nv_clear(NV_RT2860);
+ sc_cfg_reset();
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zflowcontrolset_req(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ int cFctl = -1;
+ void *p[1] = {&cFctl};
+
+ parse_param2("%d", at_paras, p);
+ at_print(AT_NORMAL,"zflowcontrolset_req:cFctl = %d\n", cFctl);
+
+ switch(cFctl)
+ {
+ case 0://¹Ø±ÕÁ÷¿Ø
+ {
+ //sc_cfg_set("uart_control","1");
+ sc_cfg_set("uart_ctstrs_enable","");
+ sc_cfg_set("uart_softcontrol_enable","");
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ sc_cfg_save();
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+ break;
+ }
+ case 1://¿ªÆôÓ²¼þÁ÷¿Ø
+ {
+ //sc_cfg_set("uart_control","1");
+ sc_cfg_set("uart_ctstrs_enable","1");
+ sc_cfg_set("uart_softcontrol_enable","");
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ sc_cfg_save();
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+ break;
+ }
+ case 2://¿ªÆôÈí¼þÁ÷¿Ø
+ {
+ sc_cfg_set("uart_ctstrs_enable","");
+ sc_cfg_set("uart_softcontrol_enable","1");
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ sc_cfg_save();
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ break;
+ }
+ }
+ return AT_END;
+}
+
+int zSetgpio_detect_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char* at_str = NULL;
+ int32_t set_value = 0;
+ int ret = 0;
+ if(at_paras==NULL)
+ softap_assert("zSetgpio_detect_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &set_value, &at_str);
+ at_print(AT_DEBUG,"zSetgpio_detect_req:set_value = %d\n", set_value);
+
+ if(!is_at_cmd_end(at_str))
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if(set_value < 0 || set_value > 1)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ sc_cfg_set("usb_gpio_detect", (set_value == 1) ? "1" : "0");
+
+ sc_cfg_save();
+ //write this attr,
+ ret = writefile(USB_GPIO_DETECT_ENABLE_EXT, (set_value == 1) ? "1" : "0", 1);
+ if(ret < 0)
+ at_print(AT_DEBUG,"zSetgpio_detect_req:set attr fail \n");
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zGetgpio_detect_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char gpio_detect[4] = {0};
+
+ sc_cfg_get("usb_gpio_detect",gpio_detect,sizeof(gpio_detect));
+
+ *res_msg = at_query_result_build("gpio_detect",gpio_detect);
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ext_dev_ser_regist()
+{
+ register_serv_func2("ZAPRESET=",0,0,0,zaprest_req,NULL);
+
+ //ATE»ØÏÔ£¬¶ÔÓÚATE0ºÍATE1£¬ÔÚ¼à¿Øº¯ÊýÖÐÖ±½Ó´¦Àíºó·µ»Ø½á¹û£¬ÆäËûÇé¿öÏÂ͸´«¸øÐÒéÕ»
+ register_fwd_func("ate",ate_req_rcv_act,NULL,NULL);
+
+ //¹Ì¶¨²¨ÌØÂÊÉèÖúͲéѯÃüÁî
+ register_serv_func2("ipr=",0,0,0,ziprSet_req,NULL);
+ register_serv_func2("ipr?",0,0,0,ziprGet_req,NULL);
+
+ //Ä£ÄâUSB²å°Î
+ register_serv_func2("zsetusb=",MODULE_ID_USBCFGMNG,MSG_CMD_USBMOD_SETREQ,0,zsetUsb_req,NULL);
+
+ //CMUXģʽÇл»
+ register_serv_func2("cmux=",MODULE_ID_DRVCOMMNG,MSG_CMD_CMUX_SET_REQ,MSG_CMD_CMUX_SET_RSP,zcmuxSet_req,zcmuxSet_rsp);
+
+ //
+ register_serv_func2("ifc=",0,0,0,zflowcontrolset_req,NULL);
+
+ //GPIO¼ì²âusb²å°ÎÉèÖÃ
+ register_serv_func2("gpio_detect=",0,0,0,zSetgpio_detect_req,NULL);
+ register_serv_func2("gpio_detect?",0,0,0,zGetgpio_detect_req,NULL);
+ return 0;
+}
+
+void ext_dev_regist_init()
+{
+ //intercore_ext_clt_regist();
+ ext_dev_ser_regist();
+
+}
+#endif
+
diff --git a/ap/lib/libatext/ext_dev_func.h b/ap/lib/libatext/ext_dev_func.h
new file mode 100644
index 0000000..7a08594
--- /dev/null
+++ b/ap/lib/libatext/ext_dev_func.h
@@ -0,0 +1,33 @@
+#ifndef __EXT_DEV_REGIST_H__
+#define __EXT_DEV_REGIST_H__
+
+#if (APP_OS_TYPE == APP_OS_LINUX)
+
+#include "ext_regist.h"
+#include "softap_api.h"
+
+typedef struct TAG_PCS_USB_INFO
+{
+ char cPrompt; // prompt after reciving data
+ int32_t iBaudrate; // baudrate
+ char cDatabit; // data bits, 5, 6, 7, 8
+ char cDebug; // debug mode, 0: none, 1: debug
+ char cEcho; // echo mode, 0: none, 1: echo
+ char cFctl; // flow control, 0: none, 1: hardware, 2: software
+ char cTty; // tty: 0, 1, 2, 3, 4, 5, 6, 7
+ char cParity; // parity 0: none, 1: odd, 2: even
+ char cStopbit; // stop bits, 1, 2
+ int32_t iReserved; // reserved, must be zero
+}T_PCS_USB_INFO, *PT_PCS_USB_INFO;
+
+typedef enum{
+ AUTO_MODE,
+ SET_MODE
+}USB_PORT_MODE;
+
+void vFnSetUsbInfo(int32_t iFdCom, const PT_PCS_USB_INFO ptPortInfo, USB_PORT_MODE usbPortMode);
+extern T_PCS_USB_INFO s_tUsbInfo;
+
+#endif
+
+#endif /*__EXT_DEV_REGIST_H__*/
diff --git a/ap/lib/libatext/ext_ftp_func.c b/ap/lib/libatext/ext_ftp_func.c
new file mode 100755
index 0000000..60425af
--- /dev/null
+++ b/ap/lib/libatext/ext_ftp_func.c
@@ -0,0 +1,387 @@
+/**
+ * @file ext_ftp_func.c
+ * @brief zte_ftpÏà¹ØÀ©Õ¹at×¢²á¼°´¦ÀíʵÏÖ
+ *
+ * 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 CONFIG_MIN_8M_VERSION
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "ext_regist.h"
+#include "at_utils.h"
+#include "softap_api.h"
+#include "ext_ftp_func.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+/*
+ $MYFTPOPEN=<channel>,<destination_ip/url>,<username>,<password>,<mode>,<Tout>,<FTPtype>
+*/
+static int ext_ftpopen_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_open_reqmsg *reqmsg = malloc(sizeof(struct zteftp_open_reqmsg));
+ assert(reqmsg);
+ char *p[7] = {
+ &reqmsg->channel,
+ reqmsg->destination,
+ reqmsg->username,
+ reqmsg->password,
+ &reqmsg->mode,
+ &reqmsg->tout,
+ &reqmsg->ftptype
+ };
+ memset(reqmsg, 0x00, sizeof(struct zteftp_open_reqmsg));
+ parse_param2("%d,%s,%s,%s,%d,%d,%d", at_paras, p);
+ at_print(AT_NORMAL, "ext_ftpopen_req %d,%s,%s,%s,%d,%d,%d\n", reqmsg->channel,
+ reqmsg->destination,
+ reqmsg->username,
+ reqmsg->password,
+ reqmsg->mode,
+ reqmsg->tout,
+ reqmsg->ftptype);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_open_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>OK<CR><LF>
+ <CR><LF>ERROR:<err><CR><LF>
+*/
+static int ext_ftpopen_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_open_rspmsg *rspmsg = (struct zteftp_open_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ at_print(AT_NORMAL, "result %d\n", rspmsg->result);
+ if (rspmsg->result < 0) {
+ sprintf(at_str, "\r\nERROR: %d\r\n", rspmsg->err);
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+/*
+ at$MYFTPOPEN?
+*/
+static int ext_ftpstate_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>$MYFTPOPEN:<connect_status>
+ <CR><LF>OK<CR><LF>
+*/
+static int ext_ftpstate_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_query_rspmsg *rspmsg = (struct zteftp_query_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ sprintf(at_str, "\r\n$MYFTPOPEN: %d\r\nOK\r\n", rspmsg->connect_status);
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+/*
+ at$MYFTPOPEN=?
+
+ <CR><LF>OK<CR><LF>
+*/
+static int ext_ftpstate_confirm(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ sprintf(at_str, "\r\nOK\r\n");
+
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+
+/*
+ at$MYFTPCLOSE
+*/
+static int ext_ftpclose_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>OK<CR><LF>
+ <CR><LF>ERROR:<err><CR><LF>
+*/
+static int ext_ftpclose_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_close_rspmsg *rspmsg = (struct zteftp_close_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (rspmsg->result < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+/*
+ at$MYFTPSIZE=<File_Name>
+*/
+static int ext_ftpsize_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_size_reqmsg *reqmsg = malloc(sizeof(struct zteftp_size_reqmsg));
+ assert(reqmsg);
+ char *p[5] = {reqmsg->file_name};
+ memset(reqmsg, 0x00, sizeof(struct zteftp_size_reqmsg));
+ parse_param2("%s", at_paras, p);
+ at_print(AT_NORMAL, "ext_ftpsize_req %s", reqmsg->file_name);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_size_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>$MYFTPSIZE:<file_lenth>
+ <CR><LF>OK<CR><LF>
+
+ <CR><LF>ERROR:<err><CR><LF>
+
+ <CR><LF>$MYURLFTP:<status><CR><LF>
+*/
+static int ext_ftpsize_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_size_rspmsg *rspmsg = (struct zteftp_size_rspmsg*)rsp_msg;
+ int offset = 0;
+ char *at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+
+ if (rspmsg->file_lenth < 0) {
+ offset += sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ offset += sprintf(at_str, "\r\n$MYFTPSIZE: %d\r\nOK\r\n", rspmsg->file_lenth);
+#if 0
+ offset += sprintf(at_str + offset, "\r\n$MYURCFTP:1\r\n");/*Êý¾ÝÁ¬½Ó¶Ï¿ª*/
+#endif
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+/*
+ at$MYFTPSIZE=<File_Name>[,<data_offset>,<data_lenth>]
+*/
+static int ext_ftpget_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_get_reqmsg *reqmsg = malloc(sizeof(struct zteftp_get_reqmsg));
+ assert(reqmsg);
+ char *p[5] = {reqmsg->file_name, &reqmsg->data_offset, &reqmsg->data_lenth};
+ memset(reqmsg, 0x00, sizeof(struct zteftp_get_reqmsg));
+ parse_param2("%s,%d,%d", at_paras, p);
+ at_print(AT_NORMAL, "ext_ftpget_req %s,%d,%d", reqmsg->file_name, reqmsg->data_offset, reqmsg->data_lenth);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_get_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>CONNECT<CR><LF>
+ <CR><LF><file_content>
+ <CR><LF>OK<CR><LF>
+
+ <CR><LF>ERROR<CR><LF>
+
+ <CR><LF>CONNECT<CR><LF>
+ <CR><LF><file_content>
+ <CR><LF>ERROR<CR><LF>
+*/
+static int ext_ftpget_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_get_rspmsg *rspmsg = (struct zteftp_get_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+
+ if (rspmsg->result < 0) {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ offset += sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ at_str = malloc(64 + rspmsg->data_lenth);
+ assert(at_str);
+ memset(at_str, 0x00, 64 + rspmsg->data_lenth);
+#if 1
+ offset += sprintf(at_str, "\r\nCONNECT");
+#else
+ offset += sprintf(at_str, "\r\nCONNECT\r\n");
+ /*Êý¾Ýͨ¹ýpassthrough·¢ËÍ*/
+ //offset += sprintf(at_str+offset, "%s",rspmsg->file_content);
+ memcpy(at_str + offset, rspmsg->file_content, rspmsg->data_lenth);
+ offset += rspmsg->data_lenth;
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+#endif
+ }
+
+ *ret = at_str;
+ *retlen = offset;//strlen(at_str);
+
+ return AT_END;
+}
+/*
+ at$MYFTPSIZE=<File_Name>,<data_lenth>,<EOF>
+*/
+static int ext_ftpput_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_put_reqmsg *reqmsg = malloc(sizeof(struct zteftp_put_reqmsg));
+ assert(reqmsg);
+ char *p[5] = {reqmsg->file_name, &reqmsg->data_lenth, &reqmsg->eof};
+ memset(reqmsg, 0x00, sizeof(struct zteftp_put_reqmsg));
+ parse_param2("%s,%d,%d", at_paras, p);
+ at_print(AT_NORMAL, "ext_ftpput_req %s,%d,%d\n", reqmsg->file_name, reqmsg->data_lenth, reqmsg->eof);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_put_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>CONNECT<CR><LF>
+ <CR><LF><file_content>
+ <CR><LF>OK<CR><LF>
+
+ <CR><LF>ERROR<CR><LF>
+*/
+static int ext_ftpput_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_put_rspmsg *rspmsg = (struct zteftp_put_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+
+ memset(at_str, 0x00, 32);
+ if (rspmsg->ret < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else if (rspmsg->ret == 0) {
+ sprintf(at_str, "\r\nCONNECT\r\n");
+ } else if (rspmsg->ret == 1) {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+ return AT_END;
+}
+
+/*
+ at+FTPFOTA
+*/
+static int ext_ftpfota_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_fota_reqmsg *reqmsg = malloc(sizeof(struct zteftp_fota_reqmsg));
+ assert(reqmsg);
+ char *p[7] = {
+ &reqmsg->channel,
+ reqmsg->destination,
+ reqmsg->file_name,
+ reqmsg->username,
+ reqmsg->password
+ };
+ memset(reqmsg, 0x00, sizeof(struct zteftp_fota_reqmsg));
+ parse_param2("%d,%s,%s,%s,%s", at_paras, p);
+ at_print(AT_NORMAL, "zteftp_fota_reqmsg %d,%s,%s,%s,%s\n", reqmsg->channel,
+ reqmsg->destination,
+ reqmsg->file_name,
+ reqmsg->username,
+ reqmsg->password
+ );
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_fota_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>OK<CR><LF>
+ <CR><LF>ERROR<CR><LF>
+*/
+static int ext_ftpfota_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_fota_rspmsg *rspmsg = (struct zteftp_fota_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (rspmsg->result < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+/*******************************************************************************
+ * Global variable definitions *
+ ******************************************************************************/
+/**
+ * @brief ×¢²áftpÏà¹ØÀ©Õ¹at
+ * @param
+ * @return
+ * @retval
+ */
+int ext_ftp_regist(void)
+{
+//#ifdef GUODIAN
+ if (g_customer_type == CUSTOMER_GUODIAN) {
+ register_serv_func2("MYFTPOPEN=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPOPEN_REQ, MSG_CMD_FTPOPEN_RSP, ext_ftpopen_req, ext_ftpopen_rsp);
+ register_serv_func2("MYFTPOPEN?", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPSTATE_REQ, MSG_CMD_FTPSTATE_RSP, ext_ftpstate_req, ext_ftpstate_rsp);
+ register_serv_func2("MYFTPOPEN=?", MODULE_ID_SOCKET_PROXY, 0, 0, ext_ftpstate_confirm, NULL);
+ register_serv_func2("MYFTPCLOSE", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPCLOSE_REQ, MSG_CMD_FTPCLOSE_RSP, ext_ftpclose_req, ext_ftpclose_rsp);
+ register_serv_func2("MYFTPSIZE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPSIZE_REQ, MSG_CMD_FTPSIZE_RSP, ext_ftpsize_req, ext_ftpsize_rsp);
+ register_serv_func2("MYFTPGET=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPGET_REQ, MSG_CMD_FTPGET_RSP, ext_ftpget_req, ext_ftpget_rsp);
+ register_serv_func2("MYFTPPUT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPPUT_REQ, MSG_CMD_FTPPUT_RSP, ext_ftpput_req, ext_ftpput_rsp);
+
+ register_serv_func2("FOTAFTP=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPFOTA_REQ, MSG_CMD_FTPFOTA_RSP, ext_ftpfota_req, ext_ftpfota_rsp);
+ } else if (g_customer_type == CUSTOMER_NANDIAN) {
+
+ register_serv_func2("MYFTPOPEN=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPOPEN_REQ, MSG_CMD_FTPOPEN_RSP, ext_ftpopen_req, ext_ftpopen_rsp);
+ register_serv_func2("MYFTPOPEN?", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPSTATE_REQ, MSG_CMD_FTPSTATE_RSP, ext_ftpstate_req, ext_ftpstate_rsp);
+ register_serv_func2("MYFTPOPEN=?", MODULE_ID_SOCKET_PROXY, 0, 0, ext_ftpstate_confirm, NULL);
+ register_serv_func2("MYFTPCLOSE", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPCLOSE_REQ, MSG_CMD_FTPCLOSE_RSP, ext_ftpclose_req, ext_ftpclose_rsp);
+ register_serv_func2("MYFTPSIZE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPSIZE_REQ, MSG_CMD_FTPSIZE_RSP, ext_ftpsize_req, ext_ftpsize_rsp);
+ register_serv_func2("MYFTPGET=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPGET_REQ, MSG_CMD_FTPGET_RSP, ext_ftpget_req, ext_ftpget_rsp);
+ register_serv_func2("MYFTPPUT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_FTPPUT_REQ, MSG_CMD_FTPPUT_RSP, ext_ftpput_req, ext_ftpput_rsp);
+ }
+//#endif
+ return 0;
+
+}
+#endif
diff --git a/ap/lib/libatext/ext_ftp_func.h b/ap/lib/libatext/ext_ftp_func.h
new file mode 100644
index 0000000..895d146
--- /dev/null
+++ b/ap/lib/libatext/ext_ftp_func.h
@@ -0,0 +1,112 @@
+/**
+ * @file ext_ftp_func.h
+ * @brief ÌṩÁËzte_ftpÍⲿÏûÏ¢ºÍÏûÏ¢½á¹¹¶¨Òå
+ *
+ * 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 __EXT_FTP_FUNC_H__
+#define __EXT_FTP_FUNC_H__
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "message.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define MAX_FILE_NAME_LENTH 64
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+/* zte_ftpÄ£¿é´ò¿ªÇëÇóÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_open_reqmsg {
+ unsigned int channel; /* ftpÆô¶¯»ùÓÚµÄchannelÀàÐÍ.0~3*/
+ char destination[256];/*ftpÕ¾µãip/url : port*/
+ char username[256];/*µÇ¼Óû§Ãû*/
+ char password[256];/*µÇ¼ÃÜÂë*/
+ unsigned int mode;/*0±íʾÖ÷¶¯FTPģʽ£»1±íʾ±»¶¯FTPģʽ*/
+ unsigned int tout;/*5~180s,FTPÃüÁî»òÕßÊý¾Ý¿ÕÏг¬Ê±ÉèÖ㬵¥Î»s£»Ä¬ÈÏΪ30s*/
+ unsigned int ftptype;/*0±íʾ¶þ½øÖÆÄ£Ê½(ĬÈÏ);1±íʾÎı¾Ä£Ê½*/
+};
+/* zte_ftpÄ£¿é´ò¿ªÏìÓ¦ÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_open_rspmsg {
+ int result;/*0±íʾOK£»-1±íʾERROR*/
+ int err;/*´íÎóÂë*/
+};
+
+/* ״̬²éѯÏìÓ¦ÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_query_rspmsg {
+ int connect_status;/*1±íʾÁ¬½Ó³É¹¦£»0±íʾÁ¬½Óʧ°Ü*/
+};
+
+/* zte_ftpÄ£¿é¹Ø±ÕÏìÓ¦ÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_close_rspmsg {
+ int result;/*0±íʾ¹Ø±ÕOK£»-1±íʾ¹Ø±ÕERROR*/
+};
+
+/* zte_ftpÄ£¿é»ñÈ¡FTP·þÎñÆ÷¶ÔÓ¦ÎļþµÄ³¤¶ÈÇëÇóÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_size_reqmsg {
+ char file_name[MAX_FILE_NAME_LENTH];
+};
+struct zteftp_size_rspmsg {
+ int file_lenth;
+};
+
+/* zte_ftpÄ£¿éÏÂÔØ¹¦ÄÜÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_get_reqmsg {
+ char file_name[MAX_FILE_NAME_LENTH];/*ÐèÒªÏÂÔØµÄÎļþÃû*/
+ int data_offset;/*ÎļþÊý¾ÝµÄÆ«ÒÆÁ¿*/
+ int data_lenth;/*±¾´Î¶ÁÈ¡Êý¾ÝµÄ³¤¶È*/
+};
+struct zteftp_get_rspmsg {
+ int result;
+ int data_lenth;/*±¾´Î¶ÁÈ¡Êý¾ÝµÄ³¤¶È*/
+ unsigned char file_content[1];/*ftpÊý¾ÝÄÚÈÝ*/
+};
+
+/* zte_ftpÄ£¿éÉÏ´«¹¦ÄÜÏûÏ¢Êý¾Ý½á¹¹*/
+struct zteftp_put_reqmsg {
+ char file_name[MAX_FILE_NAME_LENTH];/*ÐèÒªÉÏÔØµÄÎļþÃû.°üÀ¨Â·¾¶*/
+ unsigned int data_lenth;/*ÿ´ÎÉÏ´«Êý¾ÝµÄ³¤¶È*/
+ unsigned int eof;/* ÉÏ´«Îļþ½áÊø±ê־λ.×î¸ßλΪ0,±íʾÊý¾ÝΪ¿Õ£»Îª1±íʾÓÐÊý¾Ý£¬Êý¾ÝÇø½ô¸ú¸ÃµØÖ·*/
+ unsigned char file_content[1];/*ftpÊý¾ÝÄÚÈÝ*/
+};
+struct zteftp_put_rspmsg {
+ int ret;
+
+ /*ÏÂÃæ²ÎÊýÐÅÏ¢ÓëÇëÇóÐÅÏ¢±£³ÖÒ»ÖÂ.´¦Àí¸ÃputÏìÓ¦ÏûϢʱ²»ÄÜÐÞ¸Ä.ͨ¹ýsocketÏòÓ¦Óò㷢ËÍÊý¾ÝÏûϢʱʹÓÃ*/
+ char file_name[MAX_FILE_NAME_LENTH];/*ÐèÒªÉÏÔØµÄÎļþÃû.°üÀ¨Â·¾¶.*/
+ unsigned int data_lenth;/*ÿ´ÎÉÏ´«Êý¾ÝµÄ³¤¶È*/
+ unsigned int eof;/* ÉÏ´«Îļþ½áÊø±ê־λ*/
+};
+
+/*ftp fotaÉý¼¶*/
+struct zteftp_fota_reqmsg {
+ unsigned int channel; /* ftpÆô¶¯»ùÓÚµÄchannelÀàÐÍ.0~3*/
+ char destination[256];/*ftpÕ¾µãip/url : port*/
+ char file_name[MAX_FILE_NAME_LENTH];/*fota²î·Ö°üÎļþÃû*/
+ char username[256];/*µÇ¼Óû§Ãû*/
+ char password[256];/*µÇ¼ÃÜÂë*/
+};
+struct zteftp_fota_rspmsg {
+ int result;/*0±íʾOK£»-1±íʾERROR*/
+};
+
+#if CONFIG_EXIT_DATAMODE
+struct zteftp_exit_reqmsg {
+ int mode;/*0±íʾ͸´«Ä£Ê½£¬-1±íʾ·Ç͸´«Ä£Ê½¡£Í¸´«Ä£Ê½Ê±£¬ÐèÒªÖ÷¶¯Éϱ¨ÏìÓ¦ÏûÏ¢£»·Ç͸´«Ä£Ê½ÆÕͨÏûÏ¢Éϱ¨*/
+};
+/* zte_ftpÄ£¿éÌø³öÊý¾ÝģʽÏûÏ¢Êý¾Ý½á¹¹.ÊÕµ½"+++"Ê±Ìø³öÊý¾Ýģʽ*/
+struct zteftp_exit_rspmsg {
+ int result;/*0±íʾÍ˳öOK£»-1±íʾÍ˳öERROR*/
+};
+#endif
+
+#endif
diff --git a/ap/lib/libatext/ext_gps_func.c b/ap/lib/libatext/ext_gps_func.c
new file mode 100755
index 0000000..5e18c00
--- /dev/null
+++ b/ap/lib/libatext/ext_gps_func.c
@@ -0,0 +1,40 @@
+#ifndef CONFIG_MIN_8M_VERSION
+#include "ext_socket_func.h"
+#include "cfg_nv_def.h"
+#include "at_context.h"
+#include "kwatch_msg.h"
+
+int ext_mygpshw_inquire_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_GPS,KWATCH_MSG_GPS_INQUIRE_REQ,0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_mygpscdn_set_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_GPS,KWATCH_MSG_GPS_COORDINATE_SET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+int ext_mygpsgpd_set_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_GPS,KWATCH_MSG_GPS_GPD_SET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_mygpspwr_set_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_GPS,KWATCH_MSG_GPS_PWR_SET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_gps_regist(void)
+{
+ register_serv_func("MYGPSPWR=", MODULE_ID_GPS, ext_mygpspwr_set_func);
+ register_serv_func("MYGPSGPD=", MODULE_ID_GPS, ext_mygpsgpd_set_func);
+ register_serv_func("MYGPSCDN=", MODULE_ID_GPS, ext_mygpscdn_set_func);
+ register_serv_func("MYGPSHW?", MODULE_ID_GPS, ext_mygpshw_inquire_func);
+
+ return 0;
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_kwatch_test.c b/ap/lib/libatext/ext_kwatch_test.c
new file mode 100755
index 0000000..8218d48
--- /dev/null
+++ b/ap/lib/libatext/ext_kwatch_test.c
@@ -0,0 +1,42 @@
+#ifndef CONFIG_MIN_8M_VERSION
+#include "ext_regist.h"
+#include "at_utils.h"
+#include "softap_api.h"
+
+static int ext_kwatcholw_fun(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ system("/bin/kwatch_ctrl -m 1 &");
+
+ sprintf(at_str, "\r\nOK\r\n");
+
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+static int ext_kwatchftw_fun(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ system("/bin/kwatch_ctrl -m 2 &");
+
+ sprintf(at_str, "\r\nOK\r\n");
+
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+
+int ext_kwatchtest_regist(void)
+{
+ register_serv_func2("kwatchtest-owl", MODULE_ID_KWATCH_CTRL, 0, 0, ext_kwatcholw_fun, NULL);
+ register_serv_func2("kwatchtest-ftw", MODULE_ID_KWATCH_CTRL, 0, 0, ext_kwatchftw_fun, NULL);
+ return 0;
+}
+#endif
+
diff --git a/ap/lib/libatext/ext_locknet.c b/ap/lib/libatext/ext_locknet.c
new file mode 100755
index 0000000..efe68a0
--- /dev/null
+++ b/ap/lib/libatext/ext_locknet.c
@@ -0,0 +1,110 @@
+#ifndef CONFIG_MIN_8M_VERSION
+#include "at_context.h"
+
+int ext_LocklistAuth_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKLISTAUTH_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetList_set_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETLIST_SET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetKey_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETKEY_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetAmtStatus_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETAMTSTATUS_GET_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetDigest_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETDIGEST_GET_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetSign_set_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETSIGN_SET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetLevel_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETLEVEL_GET_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetList_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETLIST_GET_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetAuth_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETAUTH_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetUnlockTimes_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETUNLOCKTIMES_GET_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetStatus_get_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETSTATUS_GET_REQ, 0, NULL,0);
+ return AT_CONTINUE;
+}
+
+int ext_LocknetUnlock_func(char *at_paras, void ** res_msg)
+{
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_LOCKNET,MSG_CMD_LOCKNETUNLOCK_REQ,strlen(at_paras), (unsigned char *)at_paras,0);
+ return AT_CONTINUE;
+}
+
+//ÊÕµ½zudryÖ÷¶¯Éϱ¨ÃüÁîºó£¬Ï·¢AT+ZSCHPLMN=1ʹmodemÔÊÐíËÑÍø(¸ÃÃüÁîÊÇÔÚËøÍø¹¦ÄÜÖÐʹÓÃ)
+int zurdy_auto_act(char *at_paras ,int is_query_report)
+{
+ int appmode = 0;
+ int initresult = 0;
+ void *p[2] = {&appmode, &initresult};
+
+ parse_param2("%d,%d", at_paras, p);
+ at_print(AT_ERR,"zurdy_auto_act appmode:%d,initresult:%d!\n",appmode,initresult);
+ if(appmode != 0 && (initresult == 30 || initresult == 31))
+ {
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_LOCKNET, MSG_CMD_ZURDY_LOCKAUTH_REQ, 0, NULL,0);
+ }
+ return AT_END;
+}
+
+void ext_locknet_regist_init()
+{
+ register_serv_func("LOCKLISTAUTH=", MODULE_ID_LOCKNET, ext_LocklistAuth_func);
+ register_serv_func("LOCKNETLIST=", MODULE_ID_LOCKNET, ext_LocknetList_set_func);
+ register_serv_func("UNLOCKKEY=", MODULE_ID_LOCKNET, ext_LocknetKey_func);
+ register_serv_func("UNLOCKKEY?", MODULE_ID_LOCKNET, ext_LocknetAmtStatus_get_func);
+ register_serv_func("LOCKDIGEST?", MODULE_ID_LOCKNET, ext_LocknetDigest_get_func);
+ register_serv_func("LOCKSIGN=", MODULE_ID_LOCKNET, ext_LocknetSign_set_func);
+ register_serv_func("LOCKLEVEL?", MODULE_ID_LOCKNET,ext_LocknetLevel_get_func);
+ register_serv_func("MEPCG=", MODULE_ID_LOCKNET, ext_LocknetList_get_func);
+ register_serv_func("LOCKNETAUTH", MODULE_ID_LOCKNET, ext_LocknetAuth_func);
+ register_serv_func("ZNCK?", MODULE_ID_LOCKNET, ext_LocknetUnlockTimes_get_func);
+ register_serv_func("ZSEC?", MODULE_ID_LOCKNET, ext_LocknetStatus_get_func);
+ register_serv_func("ZNCK=", MODULE_ID_LOCKNET, ext_LocknetUnlock_func);
+
+ register_inform_func("ZURDY",zurdy_auto_act);
+}
+#endif
+
diff --git a/ap/lib/libatext/ext_normal_func.c b/ap/lib/libatext/ext_normal_func.c
new file mode 100644
index 0000000..b39c0b2
--- /dev/null
+++ b/ap/lib/libatext/ext_normal_func.c
@@ -0,0 +1,1627 @@
+/*******************************************************************************
+* ¹¦ÄÜ״̬µÈÏà¹ØÐÅÏ¢²éѯÓëÉèÖÃ,Ö÷ÒªÓÃÓÚ״̬²éѯ¡¢ÎÊÌâ·ÖÎö¡¢¼¯³É²âÊԵȣ¬½öÔÚAP²àLINUXʹÓÃ
+* Ö§³ÖµÄ¹¦ÄÜÈçÏÂ:
+* ²éѯ»òÉèÖÃÍø¿ÚÇл»
+* ²éѯ»òÉèÖù¤×÷ģʽÇл»
+* ²éѯ»òÉèÖÃTELNET״̬
+* ²éѯ»òÉèÖÃSALESTAT״̬
+
+* ºóÐøÈçÓй¦ÄÜ״̬²éѯ»ò¿ª¹ØÉèÖõÄÏà¹ØÐèÇ󣬿ÉÒÔÔÚ´ËÎļþÖÐÌí¼ÓATÃüÁî´¦Àí
+**********************************************************************************/
+
+#if (APP_OS_TYPE == APP_OS_LINUX)
+#include "ext_regist.h"
+#include "softap_api.h"
+#include "at_utils.h"
+#include "zxic_errno.h"
+#include "nv_api.h"
+#include "at_context.h"
+#include "syncnv.h"
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include "RONvParam_AMT.h"
+#include "ref_nv_def.h"
+#include <linux/input.h>
+#include "NvParam_drv.h"
+#include "libcpnv.h"
+
+static int32_t cardSlotFlag = 0;
+
+//========================================================================================================//
+//º¯ÊýʵÏÖÇø
+//========================================================================================================//
+#define USB_HOTPLUG_FILE_NAME "/sys/dwc_usb/usbconfig/hotplug"
+#define AP_WORK_LOCK "ap_work_lock"
+
+int writefile(char*path, char*buf, unsigned len)
+{
+ FILE *fp;
+ int rtv;
+ if((fp=fopen(path,"w"))==NULL)
+ {
+ return -1;
+ }
+ rtv = fwrite(buf,len,1, fp);
+ fclose(fp);
+ return rtv;
+}
+
+int zlanenableGet_req(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ char enable_flag[2] = {0};
+
+ sc_cfg_get("LanEnable", enable_flag, sizeof(enable_flag));
+ at_print(AT_DEBUG,"zlanenableGet_req:LanEnable = %s\n", enable_flag);
+
+ *res_msg = at_query_result_build("ZLANENABLE",enable_flag);
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+static void sc_cfg_set_ufi_state(void)
+{
+ sc_cfg_set("LanEnable","1");
+ sc_cfg_set("usblan", "usblan0");
+ sc_cfg_set("need_jilian", "0");
+ sc_cfg_set("need_init_modem","yes");
+ //sc_cfg_set("cid_reserved","12");
+}
+int zlanenableSet_req(int at_fd,char * at_paras,void * * res_msg,int * res_msglen)
+{
+ char* at_str = NULL;
+ int32_t iLanEnable = 0;
+ int32_t iOldLanEnable = 0;
+ char strCfgGetItem[AT_CMD_MAX] = {0};
+
+ if(at_paras==NULL)
+ softap_assert("zlanenableSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iLanEnable, &at_str);
+ at_print(AT_DEBUG,"zlanenableSet_rsq:iLanEnable == %d\n", iLanEnable);
+
+ if(!(0 == iLanEnable || 1 == iLanEnable
+ || 2 == iLanEnable|| 3 == iLanEnable)) // szLanEnableÖ»ÓÐ0ºÍ1Á½¸öÖµ
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ sc_cfg_get("LanEnable", strCfgGetItem, sizeof(strCfgGetItem));
+
+ if(0==strcmp(strCfgGetItem,""))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ iOldLanEnable = atoi(strCfgGetItem);
+
+ if(iOldLanEnable != iLanEnable)
+ {
+ if(iLanEnable == 0)
+ {
+ sc_cfg_set("LanEnable","0");
+ sc_cfg_set("usblan", "");
+ sc_cfg_set("need_jilian", "1");
+ sc_cfg_set("need_init_modem","no");
+ sc_cfg_set("boot_prj","mdl");
+ //sc_cfg_set("cid_reserved","3");
+ }
+ else if(iLanEnable == 1)
+ {
+ sc_cfg_set_ufi_state();
+
+ sc_cfg_set("boot_prj","mifi");
+ }
+ else if(iLanEnable == 2)
+ {
+ sc_cfg_set_ufi_state();
+
+ sc_cfg_set("boot_prj","cpe");
+ }
+ else if(iLanEnable == 3)
+ {
+ sc_cfg_set_ufi_state();
+
+ sc_cfg_set("boot_prj","evb");
+ }
+
+ // sc_cfg_save();
+ }
+
+ *res_msg = at_query_result_build("ZLANENABLE",at_paras);
+ *res_msglen = strlen(*res_msg);
+
+ //ģʽÇл»ºó·¢ËÍÏûÏ¢¸øÖ÷¿ØÖØÆô
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+
+ return AT_END;
+}
+
+int zmode_req_rcv_act(char *at_paras,int at_fd,struct at_context *context)
+{
+ char* err_str = NULL;
+ int32_t iUsbMode = 0;
+
+ at_print(AT_DEBUG, "at_str = %s\n", at_paras);
+
+ get_at_cmd_param_int(at_paras, &iUsbMode, &at_paras);
+ at_print(AT_DEBUG, "iUsbMode == %d\n", iUsbMode);
+ switch(iUsbMode)
+ {
+ case 0:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "user",1);
+ break;
+ }
+ case 1:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "debug",1);
+ break;
+ }
+ case 2:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "factory",1);
+ break;
+ }
+ case 3:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "amt",1);
+ break;
+ }
+ default:
+ {
+ err_str = at_err_build(ATERR_PARAM_INVALID);
+ at_write(context->at_channel->at_fd, err_str, strlen(err_str));
+ free(err_str);
+ return AT_END;
+ }
+ }
+ nv_commit(NV_RO);
+
+ context->app_param = (void*)malloc(sizeof(iUsbMode)+1);
+ if(context->app_param == NULL){softap_assert("");return AT_END;}
+ memset(context->app_param, 0, sizeof(iUsbMode)+1);
+ sprintf(context->app_param, "%d", iUsbMode);
+
+ return AT_CONTINUE;
+}
+
+int zmodeGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t setResult = 0;
+ char strCfgGetItem[AT_CMD_MAX] = {0};
+ int tmp = -1;
+
+ nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
+ at_print(AT_DEBUG,"zmodeGet_req:strCfgGetItem = %s\n", strCfgGetItem);
+
+ if(!strcmp(strCfgGetItem,"user"))
+ {
+ *res_msg = at_query_result_build("ZMODE","0");
+ }
+ else if(!strcmp(strCfgGetItem,"debug"))
+ {
+ *res_msg = at_query_result_build("ZMODE","1");
+ }
+ else if(!strcmp(strCfgGetItem,"factory"))
+ {
+ *res_msg = at_query_result_build("ZMODE","2");
+ }
+ else if(!strcmp(strCfgGetItem,"amt"))
+ {
+ *res_msg = at_query_result_build("ZMODE","3");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int plugoutSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t iPlutout = 0;
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("zmodeSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iPlutout, &at_str);
+ at_print(AT_DEBUG,"zmodeSet_rsq:iUsbMode == %d\n", iPlutout);
+
+ switch(iPlutout)
+ {
+ case 0:
+ {
+ writefile(USB_HOTPLUG_FILE_NAME,"0",1);
+ break;
+ }
+ case 1:
+ {
+ writefile(USB_HOTPLUG_FILE_NAME,"1",1);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int znetcardtypeSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t iNetcardType = 0;
+ int32_t iResult = 0;
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("znetcardtypeSet_req:at_paras is null");
+
+ at_str = at_paras;
+ at_print(AT_DEBUG,"znetcardtypeSet_rsq: come in.\n");
+ get_at_cmd_param_int(at_str, &iNetcardType, &at_str);
+ at_print(AT_DEBUG,"znetcardtypeSet_rsq:iNetcardType == %d\n", iNetcardType);
+
+ switch(iNetcardType)
+ {
+ case 0:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_ndis",1);
+ break;
+ }
+ case 1:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_ecm",1);
+ break;
+ }
+ case 2:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_mbim",1);
+ break;
+ }
+ case 3:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_rndis",1);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+ nv_commit(NV_RO);
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int znetcardtypeGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t setResult = 0;
+ char strCfgGetItem[AT_CMD_MAX] = {0};
+ int tmp = -1;
+
+ nv_get_item(NV_RO, "forcenetcard_type", strCfgGetItem, sizeof(strCfgGetItem));
+ at_print(AT_DEBUG,"znetcardtypeGet_req:strCfgGetItem = %s\n", strCfgGetItem);
+
+ if(!strcmp(strCfgGetItem,"force_ndis"))
+ {
+ *res_msg = at_query_result_build("CARDTYPE","force_ndis");
+ }
+ else if(!strcmp(strCfgGetItem,"force_ecm"))
+ {
+ *res_msg = at_query_result_build("CARDTYPE","force_ecm");
+ }
+ else if(!strcmp(strCfgGetItem,"force_mbim"))
+ {
+ *res_msg = at_query_result_build("CARDTYPE","force_mbim");
+ }
+ else if(!strcmp(strCfgGetItem,"force_rndis"))
+ {
+ *res_msg = at_query_result_build("CARDTYPE","force_rndis");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zusbmodeSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t iUsbMode = 0;
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("zusbmodeSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iUsbMode, &at_str);
+ at_print(AT_DEBUG,"zusbmodeSet_req:iUsbMode == %d\n", iUsbMode);
+
+ switch(iUsbMode)
+ {
+ case 0:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "user",1);
+ break;
+ }
+ case 1:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "debug",1);
+ break;
+ }
+ case 2:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "factory",1);
+ break;
+ }
+ case 3:
+ {
+ nv_set_item(NV_RO,"usb_modetype", "amt",1);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+ nv_commit(NV_RO);
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int znvset_req_func(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char *strch = at_paras;
+ char *p[4] = {0};
+ char nv_name[NV_NAME_LEN] = {0};
+ char nv_value[1024] = {0};
+ int i = 0;
+ if(at_paras == NULL)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ for(i=0; i < 4; i++)
+ {
+ strch = strchr(strch, '"');
+ p[i] = strch;
+ if(strch == NULL)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ strch++;
+ }
+ memcpy(nv_name, p[0]+1, (int)(p[1]-p[0]-1));
+ memcpy(nv_value,p[2]+1, (int)(p[3]-p[2]-1));
+
+ sc_cfg_set(nv_name, nv_value);
+ sc_cfg_save();
+
+ at_print(AT_DEBUG,"znvset_req_func name=%s value=%s\n", nv_name, nv_value);
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int znvget_req_func(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char *strch = at_paras;
+ char nv_name[NV_NAME_LEN] = {0};
+ char nv_value[1024] = {0};
+ char *p[2] = {0};
+ int i = 0;
+ if(at_paras == NULL)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ for(i=0; i < 2; i++)
+ {
+ strch = strchr(strch, '"');
+ p[i] = strch;
+ if(strch == NULL)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ strch++;
+ }
+ memcpy(nv_name, p[0]+1, (int)(p[1]-p[0]-1));
+ sc_cfg_get(nv_name, nv_value, sizeof(nv_value));
+ strch = malloc(strlen(nv_name)+strlen(nv_value)+32);
+ if(strch == NULL) {softap_assert("");return AT_END;}
+ sprintf(strch,"\"%s\",\"%s\"",nv_name, nv_value);
+ *res_msg = at_query_result_build("znvget",strch);
+ *res_msglen = strlen(*res_msg);
+ free(strch);
+ strch = NULL;
+ return AT_END;
+}
+
+/* ͨ¹ýAT ¿Ú½øÐÐshellÃüÁîµ÷ÊÔ*/
+int ext_atshell_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char* cmd = NULL;
+ char *at_str = NULL;
+ int len = strlen(at_paras)+1;
+ cmd = malloc(len);
+ if(cmd == NULL){softap_assert("");return AT_END;}
+ memset(cmd,0,len);
+ memcpy(cmd, at_paras, len-1);
+ soft_system(cmd);
+ at_str = at_ok_build();
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ free(cmd);
+ return AT_END;
+}
+
+int ext_pcfc_set_func(char *at_paras,int at_fd,struct at_context *context)
+{
+ int flag = 0;
+ void *p[1] = {&flag};
+ int ret = 0;
+ char* rspStr = NULL;
+ char strCfgGetItem[AT_CMD_MAX] = {0};
+ int iOldLanEnable = 0;
+ int iLanEnable = 0;
+ UINT8 phoneModeStatus = 0;
+ UINT32 retCode = CPNV_ERROR;
+
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK) // cov M
+ {
+ return AT_END;
+ }
+
+ retCode = cpnv_NvItemRead(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
+ if(retCode == CPNV_ERROR)
+ {
+ // todo: cov m
+ }
+ sc_cfg_get("LanEnable", strCfgGetItem, sizeof(strCfgGetItem));
+ if(0==strcmp(strCfgGetItem,""))
+ {
+ rspStr = at_err_build(ATERR_PROC_FAILED);
+ at_write(context->at_channel->at_fd, rspStr, strlen(rspStr));
+ free(rspStr);
+ return AT_END;
+ }
+ iOldLanEnable = atoi(strCfgGetItem);
+
+ if ((1 <= flag)&&(3 >= flag)){
+ phoneModeStatus = (0x1 | phoneModeStatus); // ºóһλ1±íʾÊÇ´¿modem°æ±¾
+ sc_cfg_set("version_mode","1"); //version_mode==1 phonemode==0 Ϊ´¿modem°æ±¾
+ ret = cpnv_NvItemWrite(ZPS_REF_MSINFO_VERSIONMODE_BASE_ADDR,&phoneModeStatus,sizeof(UINT8));
+ if(ret == CPNV_ERROR){softap_assert("");}
+ ret = cpnv_NvramFlush();
+ if(ret == CPNV_ERROR){softap_assert("");}
+
+ iLanEnable = 0;
+ //sc_cfg_set("cid_reserved","15");
+ sc_cfg_set("cid_reserved","255");
+ if(iOldLanEnable != iLanEnable)
+ {
+ sc_cfg_set("LanEnable","0");
+ sc_cfg_set("usblan", "");
+ sc_cfg_set("need_jilian", "1");
+ sc_cfg_set("need_init_modem","no");
+ sc_cfg_set("boot_prj","mdl");
+
+ //sc_cfg_save();
+ }
+ sc_cfg_save();
+ return AT_CONTINUE;
+ }
+ else
+ {
+ //rspStr = at_err_build(ATERR_PARAM_INVALID);
+ //at_write(context->at_channel->at_fd, rspStr, strlen(rspStr));
+ //free(rspStr);
+ //return AT_END;
+ return AT_CONTINUE;
+ }
+}
+
+int ext_is_usermode(void)
+{
+ char strCfgGetItem[16] = {0};
+
+ nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
+ return !strcmp(strCfgGetItem,"user");
+}
+
+#ifndef CONFIG_MIN_8M_VERSION
+int ztelnetSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char* at_str = NULL;
+ int32_t user_cmd = 0;
+ char enable_flag[AT_CMD_MAX] = {0};
+
+ sc_cfg_get("telnetd_enable", enable_flag, sizeof(enable_flag));
+
+ if(at_paras==NULL)
+ softap_assert("ztelnetSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &user_cmd, &at_str);
+ at_print(AT_DEBUG,"zlanenableSet_rsq:user_cmd == %d\n", user_cmd);
+
+ switch(user_cmd)
+ {
+ case 0:
+ if (0 == strcmp(enable_flag, "y"))
+ {
+ system("killall -9 telnetd");
+ sc_cfg_set("telnetd_enable", "n");
+ //sc_cfg_save();
+ }
+ *res_msg = at_query_result_build("ZTELNET","0");
+ break;
+ case 1:
+ if (0 == strcmp(enable_flag, "n"))
+ {
+ system("/usr/sbin/telnetd -p 4719");
+ sc_cfg_set("telnetd_enable", "y");
+ //sc_cfg_save();
+ }
+ system("adbd &");
+ *res_msg = at_query_result_build("ZTELNET","1");
+ break;
+ default:
+ at_print(AT_DEBUG,"ztelnetSet_rsp:: invaild user_cmd == %d\n", user_cmd);
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ztelnetGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char enable_flag[2] = {0};
+
+ sc_cfg_get("telnetd_enable", enable_flag, sizeof(enable_flag));
+ if (0 == strcmp(enable_flag, "y"))
+ {
+ *res_msg = at_query_result_build("ZTELNET","1");
+ }
+ else if (0 == strcmp(enable_flag, "n"))
+ {
+ *res_msg = at_query_result_build("ZTELNET","0");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zppptatusGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t state = 0;
+ char pdpState[AT_CMD_MAX] = {0};
+
+ sc_cfg_get("ppp_pdpstate", pdpState, sizeof(pdpState));
+ if(strcmp(pdpState, "working") == 0)
+ {
+ *res_msg = at_query_result_build("ZPPPSTATUS","1");
+ }
+ else
+ {
+ *res_msg = at_query_result_build("ZPPPSTATUS","0");
+ }
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int salestatSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t iEnable = 0;
+ char *at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("salestatSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &iEnable, &at_str);
+ at_print(AT_DEBUG,"salestatSet_rsq:str_saleType == %d\n", iEnable);
+
+ if(0 == iEnable)
+ {
+ sc_cfg_set("sale_stat_on","no");
+
+ }
+ else if(1 == iEnable)
+ {
+ sc_cfg_set("sale_stat_on","yes");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int salestatGet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char salestatState[AT_CMD_MAX] = {0};
+
+ sc_cfg_get("sale_stat_on", salestatState, sizeof(salestatState));
+// at_print(AT_DEBUG,"salestatGet_req ret salestatState= %s.\n",salestatState);
+
+ if (0 == strcmp(salestatState, "yes"))
+ {
+ *res_msg = at_query_result_build("SALESTAT","1");
+ }
+ else if(0 == strcmp(salestatState, "no"))
+ {
+ *res_msg = at_query_result_build("SALESTAT","0");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zerrSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t err = 0;
+ int32_t iResult = 0;
+ char* at_str = NULL;
+
+ if(at_paras==NULL)
+ softap_assert("zerrSet_req:at_paras is null");
+
+ at_str = at_paras;
+ get_at_cmd_param_int(at_str, &err, &at_str);
+
+ //at_print(1,"[ERR]zerrSet_req:err = %d\n",err);
+
+ zxic_err_track(err);
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int zautorspSet_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char channel_value[50] = {0};
+
+ if(at_paras==NULL){
+ softap_assert("zautorspSet_req:at_paras is null");
+ return AT_END;
+ }
+ if(strstr(at_paras, "all") != NULL)
+ {
+ sc_cfg_set("autorspchannel_list", "all");
+ }
+ else if(strstr(at_paras, "none") != NULL)
+ {
+ sc_cfg_set("autorspchannel_list", "none");
+ }
+ else
+ {
+ char *pchar = strchr(at_paras,'\0');
+ if(pchar == NULL)
+ softap_assert("");
+
+ memset(channel_value, 0, sizeof(channel_value));
+ if((pchar-at_paras) > 0 && (pchar-at_paras)< sizeof(channel_value))
+ memcpy(channel_value, at_paras, (int)(pchar-at_paras));
+ sc_cfg_set("autorspchannel_list",channel_value);
+ }
+ sc_cfg_save();
+#ifdef MULTI_CPU
+ sync_appointed_nv(NEAR_PS, "autorspchannel_list");
+#endif
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+
+//AT+ZISSENDAUTO=1±íʾ¿ªat_fdͨµÀµÄÖ÷¶¯Éϱ¨£¬0±íʾ¹Ø±Õ
+int modAutoInd_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ struct at_channel_info * at_channel = at_context_find_chn_by_fd(at_fd);
+ if(at_channel){
+ if('1' == at_paras[0])
+ {
+ at_channel->attribution &= 0xFE;
+ }
+ else if('0' == at_paras[0])
+ {
+ at_channel->attribution |= (1<<CH_AUTOIND);
+ }
+ }
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ext_softap_info_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ char lan_enable[NV_NAME_LEN] = {0};
+ char need_init_modem[NV_NAME_LEN] = {0};
+ char cid_reserved[NV_NAME_LEN] = {0};
+
+ at_str = malloc(AT_CMD_MAX);
+ if(at_str == NULL)
+ {
+ softap_assert("");
+ return AT_END;
+ }
+ memset(at_str, 0, AT_CMD_MAX);
+ sc_cfg_get("LanEnable", lan_enable, sizeof(lan_enable));
+ sc_cfg_get("need_init_modem", need_init_modem, sizeof(need_init_modem));
+ sc_cfg_get("cid_reserved", cid_reserved, sizeof(cid_reserved));
+
+ sprintf(at_str+strlen(at_str), "\r\nLanEnable=%s\r\n", lan_enable);
+ sprintf(at_str+strlen(at_str), "\r\nneed_init_modem=%s\r\n", need_init_modem);
+ sprintf(at_str+strlen(at_str), "\r\cid_reserved=%s\r\n", cid_reserved);
+ sprintf(at_str+strlen(at_str), "\r\nOK\r\n");
+
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+
+
+/*
+ * Function: int redirect_console(int redirect)
+ * Param: int redirect
+ * 1: to redirect
+ * 0: reset to console
+ * Return value:
+ * 0: success; -1: error.
+ */
+int redirect_console(int redirect)
+{
+#if (APP_OS_TYPE == APP_OS_LINUX)
+
+ int fp = 0;
+ int ret = 0;
+ char rd_name[128] = {0};
+
+ if(redirect)
+ strcpy(rd_name, "/dev/ttyGS0");
+ else
+ strcpy(rd_name, "/dev/console");
+
+ fp = open(rd_name, O_RDWR);
+ if(fp < 0)
+ {
+ printf("Open %s(fp=%d) failed!\n", rd_name, fp);
+ return -1;
+ }
+ printf("tty_redirect:fd=%d\n", fp);
+
+ ret = ioctl(fp, TIOCCONS);
+ printf("tty_redirect:ret=%d\n", ret);
+
+ close(fp);
+
+ fp = open("/dev/console", O_RDWR);
+ if(fp < 0)
+ {
+ return -1;
+ }
+ dup2(fp, 1);
+ close(fp);
+
+ return 0;
+#endif
+}
+
+
+/* ½«LOGÊä³öµ½ATͨµÀÉÏ */
+int ext_log_stdout_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ int opt = 0;
+ void *p[1] = {&opt};
+
+ parse_param2("%d", at_paras, p);
+
+ if (1 != strlen(at_paras) || opt < 0 || opt > 1)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ redirect_console(opt);
+
+ at_str = at_ok_build();
+
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+
+
+/* ͨ¹ýÀ©Õ¹ÃüÁîÉèÖÃÍⲿMCUÐèÒªµÄÖ÷¶¯Éϱ¨ÃüÁî*/
+int zindcmd_set_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ if (strlen(at_paras)>= NV_MAX_VAL_LEN)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ }
+ else
+ {
+ if(strlen(at_paras) == 0)
+ sc_cfg_set("customIndCmdList","");
+ else
+ sc_cfg_set("customIndCmdList",at_paras);
+ sc_cfg_save();
+ *res_msg = at_ok_build();
+
+ }
+
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ext_worklock_set_func(char *at_paras, void ** res_msg)
+{
+ int i = 0;
+ unsigned long result = 0; // cov M
+ //ÅжϲÎÊýÊÇ·ñÊÇÊ®Áù½øÖÆÊý
+ for(;i<strlen(at_paras);i++)
+ {
+ if(isxdigit(at_paras[i]) == 0)
+ {
+ goto ERROR_PROC;
+ }
+ }
+ errno = 0;
+ result = strtoul(at_paras,0,16);//½«16½øÖƵÄ×Ö·û´®×ª»»³É³¤ÕûÐÎÊý
+ if (errno == ERANGE)// kw ERRNO.NOT_CHECKED
+ {
+ at_print(AT_ERR, "strtoul errno %d: %s\n", errno, strerror(errno));
+ }
+ if(result == 0)//ÊÍ·ÅËø
+ {
+ if(set_wake_unlock(AP_WORK_LOCK) == 0)//ÊÍ·ÅËø²Ù×÷³É¹¦·µ»Øok
+ return AT_END;
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ return AT_END;
+ }
+ }
+ else if(result>0 && result<0xFFFF)//ÉèÖó¬Ê±Ëø
+ {
+ //µ÷ÓÃÉèÖó¬Ê±ËøµÄ½Ó¿Ú
+ if(set_wake_lock_timeout(AP_WORK_LOCK,result) == 0)//ÉèÖó¬Ê±Ëø³É¹¦·µ»Øok
+ return AT_END;
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ return AT_END;
+ }
+ }
+ else if(result == 0xFFFF)//ÉèÖÃÆÕÍ¨Ëø
+ {
+ if(set_wake_lock(AP_WORK_LOCK) == 0)//ÉèÖÃËø²Ù×÷³É¹¦·µ»Øok
+ return AT_END;
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ return AT_END;
+ }
+ }
+ERROR_PROC:
+ //ÎÞЧµÄ²ÎÊýÖµ£¬·µ»Ø´íÎó
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ return AT_END;
+}
+
+
+//#ifdef _ENABLE_AUTOTEST
+#define KPD_PATH "/dev/event0"
+
+#define LED_WAN_RED_BRIGHTNESS "/sys/class/leds/modem_r_led/brightness"
+#define LED_WAN_RED_BLINKTIMEON "/sys/class/leds/modem_r_led/delay_on"
+
+#define LED_WAN_BLUE_BRIGHTNESS "/sys/class/leds/modem_b_led/brightness"
+#define LED_WAN_BLUE_BLINKTIMEON "/sys/class/leds/modem_b_led/delay_on"
+
+#define LED_WAN_GREEN_BRIGHTNESS "/sys/class/leds/modem_g_led/brightness"
+#define LED_WAN_GREEN_BLINKTIMEON "/sys/class/leds/modem_g_led/delay_on"
+
+#define LED_BATTERY_GREEN_BRIGHTNESS "/sys/class/leds/battery_g_led/brightness"
+#define LED_BATTERY_GREEN_BLINKTIMEON "/sys/class/leds/battery_g_led/delay_on"
+
+#define LED_BATTERY_RED_BRIGHTNESS "/sys/class/leds/battery_r_led/brightness"
+#define LED_BATTERY_RED_BLINKTIMEON "/sys/class/leds/battery_r_led/delay_on"
+
+#define LED_SMS_BLUE_BRIGHTNESS "/sys/class/leds/sms_led/brightness"
+#define LED_SMS_BLUE_BLINKTIMEON "/sys/class/leds/sms_led/delay_on"
+
+#define LED_LAN_BLUE_BRIGHTNESS "/sys/class/leds/wifi_led/brightness"
+#define LED_LAN_BLUE_BLINKTIMEON "/sys/class/leds/wifi_led/delay_on"
+
+static int readfile(const char *path, char * buf, int len)
+{
+ FILE *fp = NULL;
+ int cnt = -1;;
+
+ if (NULL == path || NULL == buf)
+ return -1;
+
+ if ( (fp = fopen (path, "rb")) == NULL) {
+ at_print(AT_ERR, "%s can not be open\n", path);
+ cnt = -1;
+ goto err;
+ }
+
+ cnt = fread (buf, 1, len, fp);
+ if (cnt < 0) {
+ at_print(AT_ERR, "%s read failed \n", path);
+ cnt = -1;
+ goto err;
+ }
+err:
+ if (fp != NULL)
+ fclose(fp);
+ return cnt;
+}
+
+static int autotest_led_get(char *fileled, char *fileact)
+{
+ int ledstat_i = 0;
+ char ledstat_s[4] = {0};
+
+ if (access(fileact, F_OK) == 0){
+ ledstat_i = 2;
+ } else {
+ readfile(fileled, ledstat_s, sizeof(ledstat_s) - 1);
+ ledstat_i = atoi(ledstat_s);
+ }
+
+ return ledstat_i;
+}
+
+/*
+AT+KEYEVENT=<code>,<value>
+code: 116 POWER; 117 WPS; 118 RESET;
+value: 0 up; 1 down; 2 long press;
+
+AT+TKEYEVENT=116,1
+OK
+AT+TKEYEVENT=116,0
+OK
+AT+TKEYEVENT=117,1
+OK
+sleep:4
+AT+TKEYEVENT=117,2
+OK
++TKEYEVENT: WPS ACTIVED
+AT+TKEYEVENT=117,0
+OK
+*/
+int autotest_keyset_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ autotest_key_rspmsg param = {0};
+ CHAR *p[2] = {¶m.code, ¶m.value};
+ int fd = -1;
+ struct input_event event = {0};
+ unsigned char *buf = NULL;
+
+ parse_param2("%d,%d", at_paras, p);
+ at_print(AT_NORMAL, "autotest_keyset_req key code:%d,value:%d\n",param.code,param.value);
+
+ buf = malloc(sizeof(struct input_event));
+ if(buf == NULL) {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ fd = open(KPD_PATH, O_WRONLY|O_SYNC);
+ if (fd == -1) {
+ free(buf);
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ event.type = 1; //EV_KEY
+ event.code = (unsigned short)param.code;
+ event.value = param.value;
+ memcpy(buf, &event, sizeof(struct input_event));//klocwork
+ if (write(fd, /*&event*/buf, sizeof(struct input_event)) != sizeof(struct input_event)) {
+ close(fd);
+ free(buf);
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ event.type = 0; //EV_SYN
+ event.code = 0;
+ event.value = 0;
+ memcpy(buf, &event, sizeof(struct input_event));//klocwork
+ if (write(fd, /*&event*/buf, sizeof(struct input_event)) != sizeof(struct input_event)) {
+ close(fd);
+ free(buf);
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ close(fd);
+ free(buf);
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+#if 0
+ autotest_key_rspmsg *param = malloc(sizeof(autotest_key_rspmsg));
+ assert(param);
+ CHAR *p[2] = {¶m->code,¶m->value};
+
+ memset(param, 0, sizeof(autotest_key_rspmsg));
+ parse_param2("%d,%d", at_paras, p);
+ at_print(AT_NORMAL, "autotest_keyset_req key code:%d,value:%d\n",param->code,param->value);
+
+ *res_msg = param;
+ *res_msglen = sizeof(autotest_key_rspmsg);
+ return AT_END_AND_MSG;
+#endif
+}
+/*
+AT+TCPUSTATUS?
++TCPUSTATUS: 0.0% USR 9.0% SYS 0.0% NIC 90.9% IDLE 0.0% IO 0.0% IRQ 0.0% SIRQ
+OK
+*/
+int autotest_cpuget_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char *tmp_str = NULL;
+
+ tmp_str = malloc(AT_CMD_MAX);
+ if (tmp_str != NULL) {
+ char *cpu_ptr = NULL;
+ char *cpu_end = NULL;
+ system("top -n 1 > /tmp/cputop");
+ memset(tmp_str, 0, AT_CMD_MAX);
+ readfile("/tmp/cputop", tmp_str, AT_CMD_MAX - 1);
+ tmp_str[AT_CMD_MAX - 1] = '\0';
+ if ((cpu_ptr = strstr(tmp_str, "CPU: ")) != NULL &&
+ (cpu_end = strstr(tmp_str, "\nLoad average:")) != NULL) {
+ cpu_ptr += strlen("CPU: ");
+ *cpu_end = 0;
+ *res_msg = at_query_result_build("TCPUSTATUS",cpu_ptr);
+ } else {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ free(tmp_str);
+ } else {
+ *res_msg = at_err_build(ATERR_MEM_LESS);
+ }
+ if(*res_msg)
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+/*+TLEDSTATUS: <tpye>,<stat>,<color>;...
+tpye: 0 battery; 1 network; 2 sms; 3 wifi
+stat: 0 off; 1 on; 2 blink
+color: 0 null/off; 1 red; 2 green; 3 blue;
+
+AT+TLEDSTATUS?
++TLEDSTATUS: 0,1,2;1,0,0;2,0,0;3,0,0
+OK
+*/
+int autotest_ledget_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char led_str[36] = {0};
+ int ledstat = 0;
+ int ledcolor = 0;
+ int len = 0;
+ //char *net_led = LED_WAN_BLUE_BRIGHTNESS;
+ //char *net_act = LED_WAN_BLUE_BLINKTIMEON;
+ int net_color = 3;
+ char cus_type[20] = {0};
+
+ sc_cfg_get("customer_type",cus_type,sizeof(cus_type));
+ /*
+ if(0 == strcmp(cus_type, "sdk_min")) {
+ net_led = LED_WAN_GREEN_BRIGHTNESS;
+ net_act = LED_WAN_GREEN_BLINKTIMEON;
+ net_color = 2;
+ }
+ */
+ //battery
+ ledstat = autotest_led_get(LED_BATTERY_GREEN_BRIGHTNESS, LED_BATTERY_GREEN_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 2;
+ } else {
+ ledstat = autotest_led_get(LED_BATTERY_RED_BRIGHTNESS, LED_BATTERY_RED_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 1;
+ }
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "0,%d,%d;", ledstat, ledcolor);
+
+ //network
+ ledcolor = 0;
+ //ledstat = autotest_led_get(net_led, net_act);
+ if(0 == strcmp(cus_type, "sdk_min")) {
+ ledstat = autotest_led_get(LED_WAN_GREEN_BRIGHTNESS, LED_WAN_GREEN_BLINKTIMEON);
+ net_color = 2;
+ }// kw OVERWRITE_CONST_CHAR
+ else
+ {
+ ledstat = autotest_led_get(LED_WAN_BLUE_BRIGHTNESS, LED_WAN_BLUE_BLINKTIMEON);
+ }
+ if (ledstat) {
+ ledcolor = net_color;
+ } else {
+ ledstat = autotest_led_get(LED_WAN_RED_BRIGHTNESS, LED_WAN_RED_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 1;
+ }
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "1,%d,%d;", ledstat, ledcolor);
+
+ //sms
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_SMS_BLUE_BRIGHTNESS, LED_SMS_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = net_color;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "2,%d,%d;", ledstat, ledcolor);
+
+ //wifi
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_LAN_BLUE_BRIGHTNESS, LED_LAN_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = net_color;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "3,%d,%d", ledstat, ledcolor);
+
+ *res_msg = at_query_result_build("TLEDSTATUS",led_str);
+ //*res_msg = at_err_build(ATERR_PROC_FAILED);
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+
+#define LED_SIGNAL1_BLUE_BRIGHTNESS "/sys/class/leds/4g_1_led/brightness"
+#define LED_SIGNAL1_BLUE_BLINKTIMEON "/sys/class/leds/4g_1_led/delay_on"
+
+#define LED_SIGNAL2_BLUE_BRIGHTNESS "/sys/class/leds/4g_2_led/brightness"
+#define LED_SIGNAL2_BLUE_BLINKTIMEON "/sys/class/leds/4g_2_led/delay_on"
+
+#define LED_SIGNAL3_BLUE_BRIGHTNESS "/sys/class/leds/4g_3_led/brightness"
+#define LED_SIGNAL3_BLUE_BLINKTIMEON "/sys/class/leds/4g_3_led/delay_on"
+
+#define LED_SIGNAL4_BLUE_BRIGHTNESS "/sys/class/leds/4g_4_led/brightness"
+#define LED_SIGNAL4_BLUE_BLINKTIMEON "/sys/class/leds/4g_4_led/delay_on"
+
+#define LED_SIGNAL5_BLUE_BRIGHTNESS "/sys/class/leds/4g_5_led/brightness"
+#define LED_SIGNAL5_BLUE_BLINKTIMEON "/sys/class/leds/4g_5_led/delay_on"
+
+#define LED_WPS_BLUE_BRIGHTNESS "/sys/class/leds/wps_led/brightness"
+#define LED_WPS_BLUE_BLINKTIMEON "/sys/class/leds/wps_led/delay_on"
+
+#define LED_RJ11_BLUE_BRIGHTNESS "/sys/class/leds/rj11_led/brightness"
+#define LED_RJ11_BLUE_BLINKTIMEON "/sys/class/leds/rj11_led/delay_on"
+
+
+/*
+cpe switch
++TLEDSTATUS: <tpye>,<stat>,<color>;...
+tpye: 0 signal; 1 network; 2 wps; 3 wifi; 4 rj11
+stat: 0 off; 1 on; 2 blink (signal 1 1led, 2 2led, 3 3led, 4 4led, 5 5led, 12 1led blink)
+color: 0 null/off; 1 red; 2 green; 3 blue;
+
+AT+TLEDSTATUS?
++TLEDSTATUS: 0,1,2;1,0,0;2,0,0;3,0,0
+OK
+*/
+int autotest_ledget_cpesw_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char led_str[36] = {0};
+ int ledstat = 0;
+ int ledcolor = 0;
+ int len = 0;
+
+ //signal
+ ledcolor = 0;
+ if ((ledstat = autotest_led_get(LED_SIGNAL5_BLUE_BRIGHTNESS, LED_SIGNAL5_BLUE_BLINKTIMEON)) > 0) {
+ ledstat = 5;
+ ledcolor = 3;
+ } else if ((ledstat = autotest_led_get(LED_SIGNAL4_BLUE_BRIGHTNESS, LED_SIGNAL4_BLUE_BLINKTIMEON)) > 0) {
+ ledstat = 4;
+ ledcolor = 3;
+ } else if ((ledstat = autotest_led_get(LED_SIGNAL3_BLUE_BRIGHTNESS, LED_SIGNAL3_BLUE_BLINKTIMEON)) > 0) {
+ ledstat = 3;
+ ledcolor = 3;
+ } else if ((ledstat = autotest_led_get(LED_SIGNAL2_BLUE_BRIGHTNESS, LED_SIGNAL2_BLUE_BLINKTIMEON)) > 0) {
+ ledstat = 2;
+ ledcolor = 3;
+ } else if ((ledstat = autotest_led_get(LED_SIGNAL1_BLUE_BRIGHTNESS, LED_SIGNAL1_BLUE_BLINKTIMEON)) > 0) {
+ if (ledstat == 2)
+ ledstat = 12;
+ else
+ ledstat = 1;
+ ledcolor = 3;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "0,%d,%d;", ledstat, ledcolor);
+
+ //network
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_WAN_BLUE_BRIGHTNESS, LED_WAN_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 3;
+ } else {
+ ledstat = autotest_led_get(LED_WAN_RED_BRIGHTNESS, LED_WAN_RED_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 1;
+ }
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "1,%d,%d;", ledstat, ledcolor);
+
+ //wps
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_WPS_BLUE_BRIGHTNESS, LED_WPS_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 3;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "2,%d,%d;", ledstat, ledcolor);
+
+ //wifi
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_LAN_BLUE_BRIGHTNESS, LED_LAN_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 3;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "3,%d,%d;", ledstat, ledcolor);
+
+ //rj11
+ ledcolor = 0;
+ ledstat = autotest_led_get(LED_RJ11_BLUE_BRIGHTNESS, LED_RJ11_BLUE_BLINKTIMEON);
+ if (ledstat) {
+ ledcolor = 3;
+ }
+ len = strlen(led_str);
+ snprintf(led_str + len, sizeof(led_str) - len, "4,%d,%d", ledstat, ledcolor);
+
+ *res_msg = at_query_result_build("TLEDSTATUS", led_str);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+#endif
+
+extern UINT8 Sim_Inserted;
+
+int zCardSwitch_Set_Req(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ int32_t simCardFlag = 0;
+ unsigned long retCode = CPNV_ERROR;
+ int32_t SimInserted = 0;
+
+ char *p[] = {
+ &simCardFlag,
+ &cardSlotFlag,
+ };
+ parse_param("%d,%d", at_paras, p);
+
+ at_print(AT_DEBUG,"zCardSwitch_Set_Req:simCardFlag == %d\n", simCardFlag);
+
+ if(simCardFlag < 0 || simCardFlag > 6) //0 = UICC_CARD, 1 = VSIM_CARD, 2 = UICC_VSIM_AUTO, 3 = UICC_ESIM_CARD,4 = CLOUD_CARD,5 =SOFTSIM_CARD
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ #ifdef USE_DSDS_VSIM
+ if (simCardFlag == 0)
+ {
+ simCardFlag = 0;
+ }
+ else if (simCardFlag == 1)
+ {
+ simCardFlag = 4;
+ }
+ else if (simCardFlag == 2)
+ {
+ simCardFlag = 5;
+ }
+ else if (simCardFlag == 3)
+ {
+ simCardFlag = 1;
+ }
+ #endif
+
+ at_print(AT_DEBUG,"zCardSwitch_Set_Req:simCardFlag transform == %d\n", simCardFlag);
+
+ if(1 == cardSlotFlag)
+ {
+ retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(uicc1PreSwitch), (unsigned char *)(&simCardFlag), DRV_SYS_NV_ITEM_SIZE(uicc1PreSwitch));
+ }
+ else
+ {
+ retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(uiccPreSwitch), (unsigned char *)(&simCardFlag), DRV_SYS_NV_ITEM_SIZE(uiccPreSwitch));
+ }
+
+ if (CPNV_OK == retCode)
+ {
+ retCode= cpnv_NvramFlush();
+ }
+
+ if (retCode == CPNV_OK)
+ {
+ *res_msg = at_ok_build();
+ }
+ else
+ {
+ *res_msg = at_err_build(retCode);
+ }
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int zCardSwitch_Get_Req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ int32_t simCard0Flag = 0;
+ int32_t simCard1Flag = 0;
+ int32_t simCard0PreFlag = 0;
+ int32_t simCard1PreFlag = 0;
+
+ unsigned long retCode = CPNV_ERROR;
+ char tmp[100];
+
+ if (cardSlotFlag == 1)
+ {
+ retCode = cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(uicc1modeSwitch), (unsigned char *)(&simCard1Flag), DRV_SYS_NV_ITEM_SIZE(uicc1modeSwitch));
+ retCode = cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(uicc1PreSwitch), (unsigned char *)(&simCard1PreFlag), DRV_SYS_NV_ITEM_SIZE(uicc1PreSwitch));
+ }
+
+ retCode = cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(uiccmodeSwitch), (unsigned char *)(&simCard0Flag), DRV_SYS_NV_ITEM_SIZE(uiccmodeSwitch));
+ retCode = cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(uiccPreSwitch), (unsigned char *)(&simCard0PreFlag), DRV_SYS_NV_ITEM_SIZE(uiccPreSwitch));
+
+ #ifdef USE_DSDS_VSIM
+
+ if (cardSlotFlag == 1)
+ {
+ if (simCard1Flag == 0)
+ {
+ simCard1Flag = 0;
+ }
+ else if (simCard1Flag == 4)
+ {
+ simCard1Flag = 1;
+ }
+ else if (simCard1Flag == 5)
+ {
+ simCard1Flag = 2;
+ }
+ else if (simCard1Flag == 1)
+ {
+ simCard1Flag = 3;
+ }
+
+ if (simCard1PreFlag == 0)
+ {
+ simCard1PreFlag = 0;
+ }
+ else if (simCard1PreFlag == 4)
+ {
+ simCard1PreFlag = 1;
+ }
+ else if (simCard1PreFlag == 5)
+ {
+ simCard1PreFlag = 2;
+ }
+ else if (simCard1PreFlag == 1)
+ {
+ simCard1PreFlag = 3;
+ }
+ }
+
+ if (simCard0Flag == 0)
+ {
+ simCard0Flag = 0;
+ }
+ else if (simCard0Flag == 4)
+ {
+ simCard0Flag = 1;
+ }
+ else if (simCard0Flag == 5)
+ {
+ simCard0Flag = 2;
+ }
+ else if (simCard0Flag == 1)
+ {
+ simCard0Flag = 3;
+ }
+
+ if (simCard0PreFlag == 0)
+ {
+ simCard0PreFlag = 0;
+ }
+ else if (simCard0PreFlag == 4)
+ {
+ simCard0PreFlag = 1;
+ }
+ else if (simCard0PreFlag == 5)
+ {
+ simCard0PreFlag = 2;
+ }
+ else if (simCard0PreFlag == 1)
+ {
+ simCard0PreFlag = 3;
+ }
+
+ #endif
+
+ if (CPNV_ERROR == retCode)
+ {
+ *res_msg = at_err_build(retCode);
+ }
+ if (cardSlotFlag == 1)
+ {
+ snprintf(tmp,sizeof(tmp),"%d,%d,%d,%d,%d",simCard0PreFlag, simCard0Flag, simCard1PreFlag, simCard1Flag, cardSlotFlag);
+ }
+ else
+ {
+ snprintf(tmp,sizeof(tmp),"%d,%d",simCard0PreFlag, simCard0Flag);
+ }
+
+ *res_msg = at_query_result_build("ZCARDSWITCH", tmp);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int ext_normal_regist(void)
+{
+ char mmi_nv_value[32] = {0};
+ //ÅжϿͻ§ÀàÐÍ
+ if(!ext_is_usermode())
+ {
+ char needInit[20] = {0};
+ sc_cfg_get("customer_type",needInit,sizeof(needInit));
+ if(0 != strcmp(needInit, "v3modem"))
+ {
+ register_serv_func2("znvset=",0,0,0,znvset_req_func,NULL);
+ register_serv_func2("znvget=",0,0,0,znvget_req_func,NULL);
+ }
+
+ //USBģʽÇл»ÃüÁî
+ register_serv_func2("ZUSBMODE=",0,0,0,zusbmodeSet_req,NULL);
+
+ //ÓÃatÃüÁîÖ´ÐÐshellÃüÁÊäÈëµÄ²ÎÊý²»ÐèÒª´øË«ÒýºÅ
+ register_serv_func2("shell=",0,0,0,ext_atshell_req,NULL);
+ }
+ //¹¤×÷ģʽÇл»
+ register_serv_func2("zlanenable?",0,0,0,zlanenableGet_req,NULL);
+ register_serv_func2("zlanenable=",0,0,0,zlanenableSet_req,NULL);
+#ifndef CONFIG_MIN_8M_VERSION
+ if(!ext_is_usermode())
+ {
+ //¿ØÖÆtelnetÆô¶¯
+ register_serv_func2("ztelnet?",0,0,0,ztelnetGet_req,NULL);
+ register_serv_func2("ztelnet=",0,0,0,ztelnetSet_req,NULL);
+ }
+ register_serv_func2("zpppstatus?",0,0,0,zppptatusGet_req,NULL);
+
+ //SALESTAT
+ register_serv_func2("salestat=",0,0,0,salestatSet_req,NULL);
+ register_serv_func2("salestat?",0,0,0,salestatGet_req,NULL);
+ //CP֪ͨAP·¢Éú´íÎó
+ register_serv_func2("CPERR=",0,0,0, zerrSet_req,NULL);
+ register_serv_func2("zautorspset=",0,0,0,zautorspSet_req,NULL);
+
+ //ÉèÖýÓÊÕ¸ÃÀ©Õ¹ÃüÁîµÄͨµÀÖ÷¶¯Éϱ¨ÊôÐÔ
+ register_serv_func2("ZISSENDAUTO=",0,0,0,modAutoInd_act_func,NULL);
+
+ //»ñȡƽ̨ÐÅÏ¢
+ register_serv_func2("ZSOFTAPINFO",0,0,0,ext_softap_info_req,NULL);
+ //LOGÊä³öµ½AT¿Ú
+ register_serv_func2("ZSETOUT=",0,0,0,ext_log_stdout_req,NULL);
+
+ //ÉèÖÃÍⲿMCUÐèÒªµÄÖ÷¶¯Éϱ¨ÃüÁî ʾÀý£ºAT+ZNEEDIND=+CREG+CSQ
+ register_serv_func2("ZNEEDIND=",0,0,0,zindcmd_set_func,NULL);
+
+ //Íâ²¿Ëø¿ªÆôÊÍ·ÅÃüÁî
+ register_serv_func("ZWORKLOCK=", 0, ext_worklock_set_func);
+#endif
+
+ register_serv_func2("ZCARDSWITCH=",0,0,0,zCardSwitch_Set_Req,NULL);
+ register_serv_func2("ZCARDSWITCH?",0,0,0,zCardSwitch_Get_Req,NULL);
+
+ //register_fwd_func("zmode=",zmode_req_rcv_act,NULL,NULL);
+ register_serv_func2("zmode?",0,0,0,zmodeGet_req,NULL);
+ register_serv_func2("plugout=",0,0,0,plugoutSet_req,NULL);
+
+ //Íø¿ÚÇл»
+ register_serv_func2("znetcardtype=",0,0,0,znetcardtypeSet_req,NULL);
+
+ register_serv_func2("znetcardtype?",0,0,0,znetcardtypeGet_req,NULL);
+
+
+ register_fwd_func("PCFC=",ext_pcfc_set_func,NULL,NULL);
+
+#ifndef CONFIG_MIN_8M_VERSION//def _ENABLE_AUTOTEST
+ //×Ô¶¯»¯²âÊÔ ---KEYEVENT=ºÍphoneÖØÃû
+ //register_serv_func2("TKEYEVENT=",MODULE_ID_MMI, MSG_CMD_AUTOTEST_KEY_REQ, 0, autotest_keyset_req, NULL);
+ register_serv_func2("TKEYEVENT=",0,0,0,autotest_keyset_req,NULL);
+ register_serv_func2("TCPUSTATUS?",0,0,0,autotest_cpuget_req,NULL);
+ sc_cfg_get("mmi_led_plan", mmi_nv_value, sizeof(mmi_nv_value));
+ if (0 == strcmp(mmi_nv_value, "yaoyuan")) {
+ register_serv_func2("TLEDSTATUS?",0,0,0,autotest_ledget_cpesw_req,NULL);
+ } else {
+ register_serv_func2("TLEDSTATUS?",0,0,0,autotest_ledget_req,NULL);
+ }
+#endif
+ return 0;
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_regist.c b/ap/lib/libatext/ext_regist.c
new file mode 100755
index 0000000..2a4e3f0
--- /dev/null
+++ b/ap/lib/libatext/ext_regist.c
@@ -0,0 +1,35 @@
+/************************************************************************
+*¹¦ÄܽéÉÜ£ºÆ½Ì¨ÄÚ²¿À©Õ¹at¿Í»§¶ËºÍ·þÎñ¶Ë×¢²á£¬ËùÓÐ×¢²á¾ùÔÚext_regist_init½Ó¿ÚÖÐÍê³É£¬ÓÉat_ctlÔÚÆô¶¯Ê±µ÷ÓÃ
+*¸ºÔðÈË£º
+*±¸·ÝÈË£º
+*ÐÞ¸ÄÈÕ£º
+*ÐÞ¸ÄÄÚÈÝ£º
+*°æ±¾ºÅ£º
+************************************************************************/
+
+#include "ext_regist.h"
+#include "at_com.h"
+
+//ƽ̨ÄÚ²¿À©Õ¹atÃüÁ·¢£¬ËùÓÐÀ©Õ¹µÄ¿Í»§¶ËºÍ·þÎñ¶ËatÃüÁ¾ùÐèÒªÔڸú¯ÊýÖУ¬¸Ãº¯Êý»áÔÚat_ctlÓ¦Óóõʼ»¯Ê±£¬Íê³ÉÉÏÊöatÃüÁîµÄ×¢²á
+
+void ext_regist_init()
+{
+ ext_normal_regist();
+ ext_dev_regist_init();
+#ifndef CONFIG_MIN_8M_VERSION
+ ext_kwatchtest_regist();
+ ext_ftp_regist();
+ ext_user_modem_regist();
+ ext_socket_regist();
+
+#ifndef _USE_BL
+ ext_ccapp_regist();
+#endif
+ ext_gps_regist();
+#endif
+ ext_zcat_regist();
+ ext_amt_regist();
+ ext_wdt_regist_init();
+}
+
+
diff --git a/ap/lib/libatext/ext_regist.h b/ap/lib/libatext/ext_regist.h
new file mode 100644
index 0000000..1cf2466
--- /dev/null
+++ b/ap/lib/libatext/ext_regist.h
@@ -0,0 +1,29 @@
+#ifndef __ATEXT_REGIST_H__
+#define __ATEXT_REGIST_H__
+#include "at_context.h"
+#include "softap_api.h"
+//Óû§¶¨ÖƵÄATÃüÁÑϽûʹÓÃÖ÷¶¯Éϱ¨»úÖÆ£¬±ØÐëÎÊ´ðÎÕÊÖ»úÖÆ£¬·ñÔòÎÞ·¨ÖªÏþ˶ª°üÁË
+enum extat_cmd_t
+{
+ EXT_CLT_TEST_REQ=MSG_CMD_EXTAT_BASE ,
+ EXT_CLT_TEST_RSP,
+ EXT_SER_TEST_REQ,
+ EXT_SER_TEST_RSP,
+
+ EXT_AUTO_ATIND,
+
+};
+extern int ext_normal_regist(void);
+extern void ext_dev_regist_init();
+extern int ext_ftp_regist(void);
+extern int ext_user_modem_regist(void);
+extern int ext_socket_regist(void);
+extern void ext_ccapp_regist(void);
+extern int ext_zcat_regist(void);
+extern int ext_amt_regist(void);
+extern void ext_wdt_regist_init(void);
+extern void ext_gps_regist(void);
+
+extern int ext_is_usermode(void);
+extern int ext_kwatchtest_regist(void);
+#endif
diff --git a/ap/lib/libatext/ext_socket_func.c b/ap/lib/libatext/ext_socket_func.c
new file mode 100755
index 0000000..1019216
--- /dev/null
+++ b/ap/lib/libatext/ext_socket_func.c
@@ -0,0 +1,1635 @@
+#ifndef CONFIG_MIN_8M_VERSION
+#include "softap_api.h"
+#include "ext_socket_func.h"
+#include <math.h>
+#include "at_com.h"
+
+struct netsrv_msg netsrv = {0};
+
+//IPµØÖ·¸ñʽ¼ì²é
+int check_ipaddr_legal(char* ipaddr)
+{
+ char* pointer_tmp_start = NULL;
+ char* pointer_tmp_end = NULL;
+ char str_tmp[64] = {0};
+ int ipaddr_len = strlen(ipaddr);
+ int num = 0;
+ int i = 0;
+
+ pointer_tmp_end = strchr(ipaddr, '.');
+ if (pointer_tmp_end == NULL) {
+ return 0;
+ }
+ if((int)(pointer_tmp_end - ipaddr) < sizeof(str_tmp))
+ snprintf(str_tmp,(int)(pointer_tmp_end - ipaddr)+1,"%s",ipaddr);
+ //strncpy(str_tmp, ipaddr, (int)(pointer_tmp_end - ipaddr));
+ num = atoi(str_tmp);
+
+ if (num < 0 || num > 255) {
+ return 0;
+ }
+ for (i = 0; i < 2; i++) {
+ pointer_tmp_start = pointer_tmp_end + 1;
+ if (pointer_tmp_start >= ipaddr + ipaddr_len) {
+ return 0;
+ }
+ pointer_tmp_end = strchr(pointer_tmp_start, '.');
+ if (pointer_tmp_end == NULL) {
+ return 0;
+ }
+ memset(str_tmp, 0, sizeof(str_tmp));
+ if((int)(pointer_tmp_end - pointer_tmp_start) < sizeof(str_tmp))
+ snprintf(str_tmp,(int)(pointer_tmp_end - pointer_tmp_start)+1,"%s",pointer_tmp_start);
+ //strncpy(str_tmp, pointer_tmp_start, (int)(pointer_tmp_end - pointer_tmp_start));
+ num = atoi(str_tmp);
+ if (num < 0 || num > 255) {
+ return 0;
+ }
+ }
+ pointer_tmp_start = pointer_tmp_end + 1;
+ if (pointer_tmp_start >= ipaddr + ipaddr_len) {
+ return 0;
+ }
+ pointer_tmp_end = ipaddr + ipaddr_len;
+ memset(str_tmp, 0, sizeof(str_tmp));
+ if((int)(ipaddr + ipaddr_len - pointer_tmp_start) < sizeof(str_tmp))
+ snprintf(str_tmp,(int)(ipaddr + ipaddr_len - pointer_tmp_start)+1,"%s",pointer_tmp_start);
+ //strncpy(str_tmp, pointer_tmp_start, (int)(ipaddr + ipaddr_len - pointer_tmp_start));
+ num = atoi(str_tmp);
+ if (num < 0 || num > 255) {
+ return 0;
+ }
+ return 1;
+}
+
+//========================================================================================================//
+//¹úµçsocket·½°¸º¯ÊýʵÏÖÇø
+//========================================================================================================//
+/*
+ at+mynetsrv=1,2,2,0,"192.168.30.201:5100¡±
+*/
+int ext_netsrv_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netsrv_msg *srv = malloc(sizeof(struct netsrv_msg));
+ assert(srv);
+ char * pos_colon = NULL;
+ char * port = NULL;
+ char *at_str = NULL;
+ char *p[5] = {&srv->ch_id, &srv->socketid, &srv->conn_type, &srv->viewMode, srv->ipport};
+ char *c = NULL;
+ char ipport[128];
+ memset(srv, 0x00, sizeof(struct netsrv_msg));
+ if(5 != parse_param2("%d,%d,%d,%d,%s", at_paras, p)){
+ goto error;
+ }
+ //²ÎÊý¼ì²é
+ memcpy(ipport, srv->ipport, sizeof(ipport));
+ pos_colon = strchr(ipport, ':');
+ port = pos_colon + 1;
+ if ((srv->socketid < 0 || srv->socketid >= 6)
+ || (srv->viewMode != 0 && srv->viewMode != 1)
+ || (srv->conn_type < 0 || srv->conn_type > 2)
+ || (srv->ch_id < 0 || srv->ch_id >= 6)
+ || pos_colon == NULL
+ || (atoi(port) < 0 || atoi(port) > 65535)) {
+ goto error;
+ }
+ *pos_colon = '\0';
+ c = ipport;
+ //°´×Ö½ÚÑ»·¼ì²éÊÇ·ñº¬ÓÐ×Öĸ£¬ÈçÓÐÔòbreak
+ while (*c) {
+ if (isalpha(*c))
+ break;
+ c++;
+ }
+ if (!*c) {
+ if (check_ipaddr_legal(ipport) == 0) {
+ goto error;
+ }
+ }
+ netsrv = *srv;//Ϊ²éѯÓÃ
+ *res_msg = srv;
+ *res_msglen = sizeof(struct netsrv_msg);
+ return AT_CONTINUE;
+
+error:
+ free(srv);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+int ext_netsrv_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_netopen_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct comm_reqmsg *reqmsg = malloc(sizeof(struct comm_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ char *p[1] = {&reqmsg->socketid};
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ if(1 != parse_param2("%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct comm_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_netopen_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = malloc(64);
+ assert(at_str);
+ char param[10] = {0};
+ int offset = 0;
+ memset(at_str, 0x00, 64);
+
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ if (msg->remote_mss) {
+ offset += sprintf(at_str + offset, "\r\n$MYNETOPEN: %d,%d\r\n", msg->socketid, msg->remote_mss);
+ } else {
+ offset += sprintf(at_str + offset, "\r\n$MYNETOPEN: %d\r\n", msg->socketid);
+ }
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+int ext_netread_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct comm_reqmsg *reqmsg = malloc(sizeof(struct comm_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ char *p[2] = {&reqmsg->socketid, &reqmsg->len};
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ if(2 != parse_param2("%d,%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct comm_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_netread_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ offset = strlen(at_str);
+ } else if (msg->len == 0) {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ sprintf(at_str, "\r\n$MYNETREAD: %d,0\r\n\r\nOK\r\n", msg->socketid);
+ offset = strlen(at_str);
+ } else {
+ int viewmode = msg->viewmode;
+ char *data = ((char *)rsp_msg + sizeof(struct comm_rspmsg));
+ if (viewmode == 0) { //hexģʽ
+ int i = 0;
+ at_str = malloc(64 + msg->len);
+ assert(at_str);
+ memset(at_str, 0x00, 64 + msg->len);
+ offset += sprintf(at_str + offset, "\r\n$MYNETREAD: %d,%d\r\n", msg->socketid, msg->len);
+ memcpy(at_str + offset, data, msg->len);
+ offset += msg->len;
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else { //textģʽ
+ //int i = 0;
+ at_str = malloc(64 + msg->len * 2);
+ assert(at_str);
+ memset(at_str, 0x00, 64 + msg->len * 2);
+ offset += sprintf(at_str + offset, "\r\n$MYNETREAD: %d,%d\r\n", msg->socketid, msg->len);
+ memcpy(at_str + offset, data, msg->len);
+ offset += msg->len;
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ }
+ }
+ *ret = at_str;
+ *retlen = offset;
+ return AT_END;
+
+}
+
+int ext_sendbuf_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct comm_reqmsg *reqmsg = malloc(sizeof(struct comm_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ char *p[2] = {&reqmsg->socketid, &reqmsg->len};
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ if(2 != parse_param2("%d,%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct comm_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_sendbuf_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ sprintf(at_str, "\r\n$MYNETWRITE: %d,%d\r\n", msg->socketid, msg->len);
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+int ext_netwrite_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR:%d\r\n", msg->err);
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+
+int ext_netclose_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct comm_reqmsg *reqmsg = malloc(sizeof(struct comm_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ char *p[1] = {&reqmsg->socketid};
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ if(1 != parse_param2("%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct comm_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_netclose_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ sprintf(at_str, "\r\n$MYNETCLOSE: %d\r\n\r\nOK\r\n", msg->socketid);
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+/*
+ at+mynetping="192.168.30.201",5,40
+*/
+int ext_netping_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netping_reqmsg *ping = malloc(sizeof(struct netping_reqmsg));
+ assert(ping);
+ char *p[3] = {&ping->remote_ip, &ping->try_count, &ping->packet_size};
+ memset(ping, 0x00, sizeof(struct netping_reqmsg));
+ parse_param2("%s,%d,%d", at_paras, p);
+ ping->try_count = ping->try_count == 0 ? 4 : ping->try_count;
+ ping->packet_size = ping->packet_size == 0 ? 32 : ping->packet_size;
+ *res_msg = ping;
+ *res_msglen = sizeof(struct netping_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_netping_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netping_rspmsg *msg = (struct netping_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR:%d\r\n", msg->err);
+ } else {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ snprintf(at_str, 64,"\r\n$MYNETPING:%d,%d,\"%s\"\r\n",
+ msg->total_recv, msg->echo_rep_ttl, msg->round_trip_sta);
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_netaccept_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netaccept_reqmsg *reqmsg = malloc(sizeof(struct netaccept_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ memset(reqmsg, 0x00, sizeof(struct netaccept_reqmsg));
+ char *p[3] = {&reqmsg->socketid, &reqmsg->action, &reqmsg->transportMode};
+ char *p1[2] = {&reqmsg->socketid, &reqmsg->action};
+ if (g_customer_type == CUSTOMER_GUODIAN){
+ if(3 != parse_param2("%d,%d,%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+ }
+ else if (g_customer_type == CUSTOMER_NANDIAN){
+ if(2 != parse_param2("%d,%d", at_paras, p1)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct netaccept_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_netaccept_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netaccept_rspmsg *msg = (struct netaccept_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ if (msg->transportMode == NON_TRANSPARENT_MODE) {
+ sprintf(at_str, "\r\nOK\r\n");
+ } else {
+ sprintf(at_str, "\r\nCONNECT\r\n");
+ }
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_netcreate_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netcreate_msg *netcreate = malloc(sizeof(struct netcreate_msg));
+ assert(netcreate);
+ char *at_str = NULL;
+ char *p[6] = {&netcreate->ch_id, &netcreate->mode, &netcreate->socketid, netcreate->remote_ip, &netcreate->remote_port, &netcreate->local_port};
+ memset(netcreate, 0x00, sizeof(struct netcreate_msg));
+ if(5 > parse_param2("%d,%d,%d,%s,%d,%d", at_paras, p)){
+ free(netcreate);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+ *res_msg = netcreate;
+ *res_msglen = sizeof(struct netcreate_msg);
+ return AT_CONTINUE;
+}
+int ext_netcreate_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netcreate_rspmsg *msg = (struct netcreate_rspmsg*)rsp_msg;
+ char *at_str = malloc(64);
+ assert(at_str);
+ char param[10] = {0};
+ int offset = 0;
+
+ memset(at_str, 0x00, 64);
+
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR:%d\r\n", msg->err);
+ } else {
+ if (msg->mode == CONN_TYPE_TCP_S) {
+ sprintf(at_str, "\r\nOK\r\n");
+ } else {
+ sprintf(at_str, "\r\nCONNECT\r\n");
+ }
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+
+int ext_neturc_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct neturc_reqmsg *reqmsg = malloc(sizeof(struct neturc_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ memset(reqmsg, 0x00, sizeof(struct neturc_reqmsg));
+ char *p[1] = {&reqmsg->on_off};
+ if(1 != parse_param2("%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct neturc_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_neturc_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_ipfilter_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct ipfilter_reqmsg *reqmsg = malloc(sizeof(struct ipfilter_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ memset(reqmsg, 0x00, sizeof(struct ipfilter_reqmsg));
+ char *p[4] = {&reqmsg->id, &reqmsg->action, reqmsg->ip_address, reqmsg->net_mask};
+ if(2 > parse_param2("%d,%d,%s,%s", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+ //ipfilter = *reqmsg;
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct ipfilter_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_ipfilter_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct comm_rspmsg *msg = (struct comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->err);
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_netack_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct comm_reqmsg *reqmsg = malloc(sizeof(struct comm_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ char *p[1] = {&reqmsg->socketid};
+ if(1 != parse_param2("%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct comm_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_netack_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netack_rspmsg *msg = (struct netack_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret < 0) {
+ snprintf(at_str, 32,"\r\nERROR: %d\r\n", msg->err);
+ } else {
+ snprintf(at_str, 32,"\r\n$MYNETACK: %d,%d,%d\r\n\r\nOK\r\n", msg->socketid, msg->unacked_datalen, msg->rest_bufferlen);
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_type_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+
+}
+int ext_type_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct type_rspmsg *msg = (struct type_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ if (g_customer_type == CUSTOMER_GUODIAN)
+ snprintf(at_str, 32,"\r\n$MYTYPE:%.2x,%.2x,%.2x\r\n\r\nOK\r\n", msg->mode, msg->network_type, msg->extended_feature);
+ else if (g_customer_type == CUSTOMER_NANDIAN)
+ snprintf(at_str, 32,"\r\n$MYMODEM: %.2x,%.4x\r\n\r\nOK\r\n", msg->mode, msg->network_type);
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_netact_query_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+
+}
+
+int ext_netact_query_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netact_query_rspmsg *msg = (struct netact_query_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+
+ snprintf(at_str, 64,"\r\n$MYNETACT: %d,%d,\"%s\"\r\n\r\nOK\r\n", msg->channel, msg->status, msg->ip);
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+int ext_netact_equal_query_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0, 64);
+ sprintf((char*)at_str, "\r\n$MYNETACT: (0-1),(0-5)\r\nOK\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+int ext_neturc_query_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+
+}
+int ext_neturc_query_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct neturc_query_rspmsg *msg = (struct neturc_query_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ sprintf(at_str, "\r\n$MYNETURC: %d\r\nOK\r\n", msg->on_off);
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_ipfilter_query_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+
+}
+int ext_ipfilter_query_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct ipfilter_query_rspmsg *msg = (struct ipfilter_query_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int i,j = 0;
+ int offset = 0;
+
+ at_str = malloc(32 + IP_FILTER_NUM*sizeof(struct ipfilter_query_rspmsg));
+ assert(at_str);
+ memset(at_str, 0x00, 32 + IP_FILTER_NUM*sizeof(struct ipfilter_query_rspmsg));
+
+ for (i = 0; i < IP_FILTER_NUM; i++) {
+ for(j = 0; j < msg->num; j++) {
+ if(i == msg->ipfilter_info[j].id){
+ break;
+ }
+ }
+ if(j == msg->num){
+ offset += sprintf(at_str + offset, "\r\n$MYIPFILTER: %d,\"\",\"\"", i);
+ }else{
+ offset += sprintf(at_str + offset, "\r\n$MYIPFILTER: %d,\"%s\",\"%s\"", msg->ipfilter_info[j].id, msg->ipfilter_info[j].ip_address, msg->ipfilter_info[j].net_mask);
+ }
+ }
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+
+ *ret = at_str;
+ *retlen = offset;
+ return AT_END;
+}
+int ext_netsrv_query_rsp(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+ int offset = 0;
+
+ at_str = malloc(32 + sizeof(netsrv));
+ assert(at_str);
+ memset(at_str, 0, 32 + sizeof(netsrv));
+ offset += snprintf(at_str, 32 + sizeof(netsrv),"\r\n$MYNETSRV: %d,%d,%d,%d,\"%s\"", netsrv.ch_id, netsrv.socketid, netsrv.conn_type, netsrv.viewMode, netsrv.ipport);
+ offset += snprintf(at_str + offset,32 + sizeof(netsrv)-offset, "\r\nOK\r\n");
+ *res_msg = at_str;
+ *res_msglen = offset;
+ return AT_END;
+
+}
+int ext_ipfilter_equal_query_rsp(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+ int offset = 0;
+
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0, 64);
+ offset += sprintf(at_str, "\r\n$MYIPFILTER: (0-4),(0-2),\"\",\"\"");
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ *res_msg = at_str;
+ *res_msglen = offset;
+ return AT_END;
+
+}
+int ext_netopen_query_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+
+}
+int ext_netopen_query_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct netopen_query_rspmsg *msg = (struct netopen_query_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->ret == -1) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ at_str = malloc(32 + sizeof(struct netopen_query_rspmsg));
+ assert(at_str);
+ memset(at_str, 0x00, 32 + sizeof(struct netopen_query_rspmsg));
+
+ snprintf(at_str,32 + sizeof(struct netopen_query_rspmsg), "\r\n$MYNETOPEN: %d,\"%s\",%d,\"%s\",\"%s\",\"%s\",%d,\"%s\",%d\r\nOK\r\n",
+ msg->socket_id, msg->local_ip, msg->local_port, msg->gate, msg->dns1, msg->dns2, msg->type, msg->dest_ip, msg->dest_prot);
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_ok_rsp(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0, 32);
+ sprintf((char*)at_str, "\r\nOK\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+char * csq_format(char *at_str)
+{
+ int rssi = 0, ber = 0, act = 0;
+ char *at_new = malloc(strlen(at_str) + 1);
+ assert(at_new);
+ void *p[3] = {&rssi, &ber, &act};
+ char str_tmp[64] = {0};
+ char *pchrstart = NULL;
+
+ pchrstart = at_str + 1;
+
+ char *pchrend = strstr(pchrstart, "\r\n");
+ if(pchrend && (pchrend - pchrstart) < sizeof(str_tmp))
+ snprintf(str_tmp,(pchrend - pchrstart)+1, "%s",pchrstart);
+ //strncpy(str_tmp, pchrstart, (int)(pchrend - pchrstart));
+
+ //if (at_new == NULL)
+ // softap_assert("");
+
+ parse_param2("%d,%d,%d", str_tmp, p);
+
+ if (act == 5 || act == 15) { //W TD
+ if (rssi == 199) {
+ rssi = rssi - 100;
+ } else {
+ rssi = floor((((rssi - 100 - 116) * (100.0 / 91.0) + 127.4) * 31) / 100 + 0.1);
+ }
+ } else if (act == 17) { //LTE
+ if (rssi == 199) {
+ rssi = rssi - 100;
+ } else {
+ rssi = floor((((rssi - 100 - 141) * (100.0 / 97.0) + 145.3) * 31) / 100 + 0.1);
+ }
+ }
+
+
+ memset(at_new, 0, strlen(at_str) + 1);
+ sprintf(at_new, ": %ld,%ld", rssi, ber);
+ printf("csq_format at_new = %s\n", at_new);
+ return at_new;
+}
+
+char * xreg_format(char *at_str)
+{
+ char *at_new = malloc(strlen(at_str) + 1);
+ assert(at_new);
+ char str_tmp[64] = {0};
+ char *pchrstart = NULL;
+ int offset = 0;
+
+ //if (at_new == NULL)
+ // softap_assert("");
+ memset(at_new, 0, strlen(at_str) + 1);
+
+ pchrstart = at_str + 2;
+ char *pchrend = strstr(pchrstart, "\r\n");
+ if (pchrend == NULL){
+ softap_assert("");
+ return at_new;
+ }
+ if (strstr(pchrstart, "OK") == NULL) {
+ memcpy(at_new, at_str, pchrend - at_str);
+ } else if (strchr(pchrstart, '(') != NULL) {
+ memcpy(at_new, at_str, pchrend - at_str);
+ } else {
+ int n = 0;
+ int stat = 0;
+ char cereg_stat[20] = {0};
+
+ offset += sprintf(at_new, ": %d", 0);
+
+ get_at_cmd_param_int(pchrstart, &n, &pchrstart);
+
+ move_to_next_param(pchrstart, &pchrstart);
+
+ get_at_cmd_param_int(pchrstart, &stat, &pchrstart);
+
+ sc_cfg_get("cereg_stat", cereg_stat, sizeof(cereg_stat));
+ if (stat != 1 && stat != 5 && (1 == atoi(cereg_stat) || 5 == atoi(cereg_stat))) {
+ offset += sprintf(at_new + offset, ",%d", 1);
+ } else {
+ offset += sprintf(at_new + offset, ",%d", stat);
+ }
+
+ //ºóÃæ»¹ÓвÎÊý
+ if (!is_at_cmd_end(pchrstart)) {
+ strncpy(at_new + offset, pchrstart - 1, (int)(pchrend - pchrstart + 1));
+ }
+ }
+
+ //printf("xreg_format at_new = %s\n", at_new);
+ return at_new;
+}
+
+char * cgatt_format(char *at_str)
+{
+ char *at_new = malloc(strlen(at_str) + 1);
+ assert(at_new);
+ //if (at_new == NULL)
+ // softap_assert("");
+
+ memset(at_new, 0, strlen(at_str) + 1);
+ sprintf(at_new, ": %d", 1);
+
+ printf("cgatt_format at_new = %s\n", at_new);
+ return at_new;
+}
+
+char * cgsn_format(char *at_str)
+{
+ char *at_new = malloc(strlen(at_str) + 3);
+ assert(at_new);
+ char str_tmp[32] = {0};
+ char *pchrstart = NULL;
+
+ pchrstart = at_str + 2;
+
+ char *pchrend = strstr(pchrstart, "\r\n");
+ if(pchrend && (pchrend - pchrstart) < sizeof(str_tmp))
+ snprintf(str_tmp,(pchrend - pchrstart)+1, "%s",pchrstart);
+ //strncpy(str_tmp, pchrstart, (int)(pchrend - pchrstart));
+ //if (at_new == NULL)
+ // softap_assert("");
+
+ memset(at_new, 0, strlen(at_str) + 1);
+ sprintf(at_new, ": \"%s\"", str_tmp);
+
+ printf("cgsn_format at_new = %s\n", at_new);
+ return at_new;
+}
+
+#ifdef AT_QUECTEL
+//========================================================================================================//
+//quectel socket·½°¸º¯ÊýʵÏÖÇø
+//========================================================================================================//
+/*
+ at+qiopen=1,0,"TCP","192.168.30.201",5100,0,0
+*/
+int ext_qiopen_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct quectel_qiopen_msg *qiopen = malloc(sizeof(struct quectel_qiopen_msg));
+ char *p[7] = {&qiopen->context_id, &qiopen->connect_id, qiopen->service_type, qiopen->ip_addr, qiopen->remote_port, qiopen->local_port, qiopen->access_mode};
+ memset(qiopen, 0x00, sizeof(struct quectel_qiopen_msg));
+ parse_param2("%d,%d,%s,%s,%d,%d,%d", at_paras, p);
+ *res_msg = qiopen;
+ *res_msglen = sizeof(struct quectel_qiopen_msg);
+ return AT_CONTINUE;
+}
+int ext_qiopen_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_comm_rspmsg *msg = (struct quectel_comm_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+
+ if (msg->access_mode == BUFFER_ACCESS_MODE || msg->access_mode == DIRECT_PUSH_MODE) {
+ sprintf(at_str, "\r\nOK\r\n+QIOPEN: %d,%d\r\n", msg->connect_id, msg->err);
+ } else if (msg->access_mode == TRANSPARENT_ACCESS_MODE) {
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nCONNECT\r\n");
+ }
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_qiclose_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct quectel_qiclose_reqmsg *reqmsg = malloc(sizeof(struct quectel_qiclose_reqmsg));
+ char *p[2] = {&reqmsg->connect_id, &reqmsg->timeout};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qiclose_reqmsg));
+ parse_param2("%d,%d", at_paras, p);
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qiclose_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_qiclose_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_comm_rspmsg *msg = (struct quectel_comm_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+int ext_qistate_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct quectel_qistate_reqmsg *reqmsg = malloc(sizeof(struct quectel_qistate_reqmsg));
+ char *p[2] = {&reqmsg->query_type, &reqmsg->query_id};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qistate_reqmsg));
+ parse_param2("%d,%d", at_paras, p);
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qistate_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qistate_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_qistate_rspmsg *msg = (struct quectel_qistate_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+ int i = 0;
+
+ if (msg->num == 0) {
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR\r\n");
+ offset = strlen(at_str);
+ } else if (msg->query_type == QUERY_CONNECTION_STATUS_BY_CONNECTID) {
+ at_str = malloc(64 + sizeof(struct quectel_sock_info));
+ memset(at_str, 0x00, 64 + sizeof(struct quectel_sock_info));
+ offset += sprintf(at_str, "\r\n+QISTATE:\n");
+ offset += sprintf(at_str + offset, "%d,%d,%s,%d,%d,%d,%d,%d,%d,%d\r\n",
+ msg->query_status_info[0].connect_id,
+ msg->query_status_info[0].service_type,
+ msg->query_status_info[0].ip_addr,
+ msg->query_status_info[0].remote_port,
+ msg->query_status_info[0].local_port,
+ msg->query_status_info[0].socket_state,
+ msg->query_status_info[0].context_id,
+ msg->query_status_info[0].server_id,
+ msg->query_status_info[0].access_mode,
+ msg->query_status_info[0].at_port);
+ } else {
+ at_str = malloc(64 + msg->num * sizeof(struct quectel_sock_info));
+ memset(at_str, 0x00, 64 + msg->num * sizeof(struct quectel_sock_info));
+ offset += sprintf(at_str, "\r\nList of(+QISTATE:\n");
+ for (i = 0; i < msg->num; i++) {
+ offset += sprintf(at_str + offset, "%d,%d,%s,%d,%d,%d,%d,%d,%d,%d\r\n",
+ msg->query_status_info[i].connect_id,
+ msg->query_status_info[i].service_type,
+ msg->query_status_info[i].ip_addr,
+ msg->query_status_info[i].remote_port,
+ msg->query_status_info[i].local_port,
+ msg->query_status_info[i].socket_state,
+ msg->query_status_info[i].context_id,
+ msg->query_status_info[i].server_id,
+ msg->query_status_info[i].access_mode,
+ msg->query_status_info[i].at_port);
+ }
+ offset += sprintf(at_str + offset, ")\n");
+ }
+ *ret = at_str;
+ *retlen = offset;
+ return AT_END;
+
+}
+int ext_qisend_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ int ret = 0;
+ struct quectel_qisend_reqmsg *reqmsg = malloc(sizeof(struct quectel_qisend_reqmsg));
+ char *p[4] = {&reqmsg->connect_id, &reqmsg->len, reqmsg->ip_addr, &reqmsg->remote_port};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qisend_reqmsg));
+ ret = parse_param2("%d,%d,%s,%d", at_paras, p);
+ if (ret == 1) {
+ reqmsg->send_type = CHANGEABLE_LENGTH;
+ } else if (ret == 2) {
+ if (reqmsg->len == 0) {
+ reqmsg->send_type = QUERY_DATA_INFO;
+ } else {
+ reqmsg->send_type = FIXED_LENGTH;
+ }
+ } else if (ret == 4) {
+ reqmsg->send_type = UDP_DATA;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qisend_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qisend_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_qisend_rspmsg *msg = (struct quectel_qisend_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+
+ if (msg->send_type == QUERY_DATA_INFO) {
+ if (msg->ret == CONNECTION_EXIST) {
+ offset += sprintf(at_str, "\r\n+QISEND:\n");
+ offset += sprintf(at_str + offset, "%d,%d,%d\r\n", msg->total_send_length, msg->ackedbytes, msg->unackedbytes);
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == CONNECTION_NOT_EXIST) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else {
+ if (msg->ret == READY_TO_SEND) {
+ sprintf(at_str, "\r\nSEND OK\r\n");
+ } else if (msg->ret == SEND_OK) {
+ sprintf(at_str, "\r\n");
+ } else if (msg->ret == SEND_FAIL) {
+ sprintf(at_str, "\r\nSEND FAIL\r\n");
+ } else if (msg->ret == SEND_ERROR || msg->ret == CONNECTION_NOT_EXIST) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+int ext_qisendex_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct quectel_qisendex_reqmsg *reqmsg = malloc(sizeof(struct quectel_qisendex_reqmsg));
+ char *p[2] = {&reqmsg->connect_id, reqmsg->hex_data};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qisendex_reqmsg));
+ parse_param2("%d,%s", at_paras, p);
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qisendex_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qisendex_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_comm_rspmsg *msg = (struct quectel_comm_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret == SEND_OK) {
+ sprintf(at_str, "\r\nSEND OK\r\n");
+ } else if (msg->ret == SEND_FAIL) {
+ sprintf(at_str, "\r\nSEND FAIL\r\n");
+ } else if (msg->ret == SEND_ERROR) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+int ext_qird_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ int ret = 0;
+ struct quectel_qird_reqmsg *reqmsg = malloc(sizeof(struct quectel_qird_reqmsg));
+ char *p[2] = {&reqmsg->connect_id, &reqmsg->len};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qird_reqmsg));
+
+ ret = parse_param2("%d,%d", at_paras, p);
+ if (ret == 1) {
+ reqmsg->read_type = CHANGEABLE_LENGTH;
+ } else if (ret == 2) {
+ if (reqmsg->len == 0) {
+ reqmsg->read_type = QUERY_DATA_INFO;
+ } else {
+ reqmsg->read_type = FIXED_LENGTH;
+ }
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qird_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qird_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ int offset = 0;
+ struct quectel_qird_rspmsg *msg = (struct quectel_qird_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->read_type == QUERY_DATA_INFO) {
+ if (msg->ret == CONNECTION_EXIST) {
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+ offset += sprintf(at_str, "\r\n+QIRD:\n");
+ offset += sprintf(at_str + offset, "%d,%d,%d\r\n", msg->total_rcv_length, msg->have_read_length, msg->unread_length);
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == CONNECTION_NOT_EXIST) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else {
+ if (msg->service_type == TCP || msg->service_type == UDP || msg->service_type == TCP_LISTENER) {
+ if (msg->ret == READ_OK) {
+ at_str = malloc(32 + msg->read_actual_length);
+ memset(at_str, 0x00, 32 + msg->read_actual_length);
+ offset += sprintf(at_str, "\r\n+QIRD:%d\r\n", msg->read_actual_length);
+ memcpy(at_str + offset, msg->data, msg->read_actual_length);
+ offset += msg->read_actual_length;
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == NODATA_READ) {
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+ offset += sprintf(at_str, "\r\n+QIRD:0\n");
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == CONNECTION_NOT_EXIST) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else if (msg->service_type == UDP_SERVICE) {
+ if (msg->ret == READ_OK) {
+ at_str = malloc(32 + msg->read_actual_length);
+ memset(at_str, 0x00, 32 + msg->read_actual_length);
+ offset += sprintf(at_str, "\r\n+QIRD:%d,%s,%d\r\n", msg->read_actual_length, msg->remote_ipaddr, msg->remote_port);
+ memcpy(at_str + offset, msg->data, msg->read_actual_length);
+ offset += msg->read_actual_length;
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == NODATA_READ) {
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+ offset += sprintf(at_str, "\r\n+QIRD:0\n");
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == CONNECTION_NOT_EXIST) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ }
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_qiswtmd_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct quectel_qiswtmd_reqmsg *reqmsg = malloc(sizeof(struct quectel_qiswtmd_reqmsg));
+ char *p[2] = {&reqmsg->connect_id, &reqmsg->access_mode};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qiswtmd_reqmsg));
+ parse_param2("%d,%d", at_paras, p);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qiswtmd_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_qiswtmd_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_qiswtmd_rspmsg *msg = (struct quectel_qiswtmd_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+
+ if (msg->ret == SW_SUCC) {
+ if (msg->access_mode == BUFFER_ACCESS_MODE || msg->access_mode == DIRECT_PUSH_MODE) {
+ sprintf(at_str, "\r\nOK\r\n");
+ } else if (msg->access_mode == BUFFER_ACCESS_MODE || msg->access_mode == DIRECT_PUSH_MODE) {
+ sprintf(at_str, "\r\nCONNECT\r\n");
+ }
+ } else if (msg->ret == SW_FAIL) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+ext_qidnscfg_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ int ret = 0;
+ struct quectel_qidnscfg_reqmsg *reqmsg = malloc(sizeof(struct quectel_qidnscfg_reqmsg));
+ char *p[3] = {&reqmsg->context_id, reqmsg->pri_dns_addr, reqmsg->sec_dns_addr};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qidnscfg_reqmsg));
+
+ ret = parse_param2("%d,%d", at_paras, p);
+ if (ret == 1) {
+ reqmsg->action_type = DNS_QUERY;
+ } else if (ret == 2) {
+ reqmsg->action_type = DNS_CFG_NO_SECDNSADDR;
+ } else if (ret == 3) {
+ reqmsg->action_type = DNS_CFG_WITH_SECDNSADDR;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qird_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qidnscfg_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ int offset = 0;
+ struct quectel_qidnscfg_rspmsg *msg = (struct quectel_qidnscfg_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->action_type == DNS_CFG_WITH_SECDNSADDR || msg->action_type == DNS_CFG_NO_SECDNSADDR) {
+ if (msg->ret == DNS_ACTION_SUCC) {
+ sprintf(at_str, "\r\nOK\r\n");
+ } else if (msg->ret == DNS_ACTION_FAIL) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else if (msg->action_type == DNS_QUERY) {
+ if (msg->ret == DNS_ACTION_SUCC) {
+ at_str = malloc(32 + sizeof(msg->pri_dns_addr) + sizeof(msg->sec_dns_addr));
+ memset(at_str, 0x00, 32 + sizeof(msg->pri_dns_addr) + sizeof(msg->sec_dns_addr));
+ offset += sprintf(at_str, "\r\n+QIDNSCFG:%d,%s,%s\r\n", msg->context_id, msg->pri_dns_addr, msg->sec_dns_addr);
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == DNS_ACTION_FAIL) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+ext_qidnsgip_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ int ret = 0;
+ struct quectel_qidnsgip_reqmsg *reqmsg = malloc(sizeof(struct quectel_qidnsgip_reqmsg));
+ char *p[2] = {&reqmsg->context_id, reqmsg->host_name};
+ memset(reqmsg, 0x00, sizeof(struct quectel_qidnsgip_reqmsg));
+
+ ret = parse_param2("%d,%s", at_paras, p);
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct quectel_qidnsgip_reqmsg);
+ return AT_CONTINUE;
+
+}
+int ext_qidnsgip_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ int offset = 0;
+ struct quectel_qidnscfg_rspmsg *msg = (struct quectel_qidnscfg_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+
+ if (msg->action_type == DNS_CFG_WITH_SECDNSADDR || msg->action_type == DNS_CFG_NO_SECDNSADDR) {
+ if (msg->ret == DNS_ACTION_SUCC) {
+ sprintf(at_str, "\r\nOK\r\n");
+ } else if (msg->ret == DNS_ACTION_FAIL) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else if (msg->action_type == DNS_QUERY) {
+ if (msg->ret == DNS_ACTION_SUCC) {
+ at_str = malloc(32 + sizeof(msg->pri_dns_addr) + sizeof(msg->sec_dns_addr));
+ memset(at_str, 0x00, 32 + sizeof(msg->pri_dns_addr) + sizeof(msg->sec_dns_addr));
+ offset += sprintf(at_str, "\r\n+QIDNSCFG:%d,%s,%s\r\n", msg->context_id, msg->pri_dns_addr, msg->sec_dns_addr);
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ } else if (msg->ret == DNS_ACTION_FAIL) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+int ext_qigeterror_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ *res_msg = NULL;
+ *res_msglen = 0;
+ return AT_CONTINUE;
+}
+int ext_qigeterror_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct quectel_qigeterror_rspmsg *msg = (struct quectel_qigeterror_rspmsg*)rsp_msg;
+ int offset = 0;
+ char *at_str = malloc(64);
+ memset(at_str, 0x00, 64);
+
+ offset += sprintf(at_str, "\r\n+QIGETERROR:%d,%s\r\n", msg->err, msg->errcode_description);
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+
+}
+int ext_qping_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct qping_reqmsg *ping = malloc(sizeof(struct qping_reqmsg));
+ char *p[4] = {&ping->context, ping->remote_ip, &ping->timeout, &ping->ping_num};
+ memset(ping, 0x00, sizeof(struct netping_reqmsg));
+ parse_param2("%d,%s,%d,%d", at_paras, p);
+ ping->timeout = ping->timeout == 0 ? 4 : ping->timeout;
+ ping->ping_num = ping->ping_num == 0 ? 4 : ping->ping_num;
+ *res_msg = ping;
+ *res_msglen = sizeof(struct qping_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_qping_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct qping_rspmsg *msg = (struct qping_rspmsg*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+ int i = 0;
+
+ if (msg->ret < 0) {
+ at_str = malloc(32);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ at_str = malloc(32 + sizeof(struct qping_rspmsg));
+ memset(at_str, 0x00, 32 + sizeof(struct qping_rspmsg));
+ offset += sprintf(at_str + offset, "\r\nOK\r\n");
+ for (i = 0; i < msg->ping_num; i++) {
+ if (msg->each_ping_result[i].result == 0) {
+ offset += sprintf(at_str + offset, "\r\n$QPING:\r\n%d,%s,%d,%d,%d\r\n",
+ msg->each_ping_result[i].result,
+ msg->each_ping_result[i].remote_ip,
+ msg->each_ping_result[i].ping_len,
+ msg->each_ping_result[i].response_time,
+ msg->each_ping_result[i].ttl);
+ } else {
+ offset += sprintf(at_str + offset, "\r\n$QPING:\r\n%d\r\n", msg->each_ping_result[i].result);
+ }
+ }
+ if (msg->finresult == 0) {
+ offset += sprintf(at_str + offset, "\r\n$QPING:\r\n%d,%d,%d,%d,%d,%d,%d\r\n",
+ msg->finresult, msg->sent, msg->rcvd, msg->lost, msg->min, msg->max, msg->avg);
+ } else {
+ offset += sprintf(at_str + offset, "\r\n$QPING:\r\n%d\r\n", msg->finresult);
+ }
+
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+#endif
+
+/*
+ at$MYSOCKETLED=<ONOFF>
+*/
+static int ext_socketled_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct zteftp_socketled_reqmsg *reqmsg = malloc(sizeof(struct zteftp_socketled_reqmsg));
+ assert(reqmsg);
+ char *at_str = NULL;
+ char *p[1] = {&reqmsg->iswitch};
+ memset(reqmsg, 0x00, sizeof(struct zteftp_socketled_reqmsg));
+ if(1 != parse_param2("%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+ //at_print(AT_NORMAL,"zteftp_socketled_reqmsg %d\n", reqmsg->iswitch);
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct zteftp_socketled_reqmsg);
+ return AT_CONTINUE;
+}
+/*
+ <CR><LF>OK<CR><LF>
+ <CR><LF>ERROR<CR><LF>
+*/
+static int ext_socketled_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ struct zteftp_socketled_rspmsg *rspmsg = (struct zteftp_socketled_rspmsg*)rsp_msg;
+ char *at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+
+ if (rspmsg->result < 0) {
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+ return AT_END;
+}
+
+int ext_enpwrsave_set_func(char *at_paras, void ** res_msg)
+{
+ int enpwrsave = 0;
+ void *p[] = {&enpwrsave};
+ int ret = 0;
+ char *at_str = NULL;
+ at_str = malloc(16);
+ assert(at_str);
+ memset(at_str,0,16);
+
+ ret = parse_param("%d",at_paras, p);
+ if(ret != AT_PARSE_OK)
+ {
+ sprintf(at_str,"\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ return AT_END;
+ }
+
+ if(0 == enpwrsave) //²»ÔÊÐí½øÈëÐÝÃßģʽ
+ {
+ set_wake_lock(AP_LOCK);
+ g_ap_lock = 0;
+ }
+ else if(1 == enpwrsave) //ÔÊÐí½øÈëÐÝÃßģʽ
+ {
+ set_wake_unlock(AP_LOCK);
+ g_ap_lock = 1;
+ }
+ else
+ {
+ sprintf(at_str,"\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ return AT_END;
+ }
+
+ sprintf(at_str,"\r\nOK\r\n");
+ *res_msg = at_str;
+ return AT_END;
+
+}
+
+int ext_enpwrsave_query_func(char *at_paras, void ** res_msg)
+{
+ char *at_str = NULL;
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str,0,32);
+
+ sprintf(at_str,"\r\n+ENPWRSAVE: %d\r\nOK\r\n",g_ap_lock);
+ *res_msg = at_str;
+ return AT_END;
+}
+
+
+int ext_socket_regist(void)
+{
+ if (g_customer_type == CUSTOMER_GUODIAN) {
+ //SOCKET´´½¨¡¢Êý¾ÝÊÕ·¢
+ register_serv_func2("MYNETSRV=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETSRV_REQ, MSG_CMD_NETSRV_RSP, ext_netsrv_req, ext_netsrv_rsp);
+ register_serv_func2("MYNETOPEN=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETOPEN_REQ, MSG_CMD_NETOPEN_RSP, ext_netopen_req, ext_netopen_rsp);
+ register_serv_func2("MYNETREAD=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETREAD_REQ, MSG_CMD_NETREAD_RSP, ext_netread_req, ext_netread_rsp);
+ register_serv_func2("MYNETWRITE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_SENDBUF_REQ, MSG_CMD_SENDBUF_RSP, ext_sendbuf_req, ext_sendbuf_rsp);
+ register_serv_func2("MYNETCLOSE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCLOSE_REQ, MSG_CMD_NETCLOSE_RSP, ext_netclose_req, ext_netclose_rsp);
+ register_serv_func2("MYNETPING=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETPING_REQ, MSG_CMD_NETPING_RSP, ext_netping_req, ext_netping_rsp);
+ register_serv_func2("MYNETACCEPT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACCEPT_REQ, MSG_CMD_NETACCEPT_RSP, ext_netaccept_req, ext_netaccept_rsp);
+ register_serv_func2("MYNETCREATE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCREATE_REQ, MSG_CMD_NETCREATE_RSP, ext_netcreate_req, ext_netcreate_rsp);
+ register_serv_func2("MYNETURC=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETURC_REQ, MSG_CMD_NETURC_RSP, ext_neturc_req, ext_neturc_rsp);
+ register_serv_func2("MYIPFILTER=", MODULE_ID_SOCKET_PROXY, MSG_CMD_IPFILTER_REQ, MSG_CMD_IPFILTER_RSP, ext_ipfilter_req, ext_ipfilter_rsp);
+ register_serv_func2("MYNETACK=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACK_REQ, MSG_CMD_NETACK_RSP, ext_netack_req, ext_netack_rsp);
+ register_serv_func2("MYSOCKETLED=", MODULE_ID_SOCKET_PROXY, MSG_CMD_SOCKETLED_REQ, MSG_CMD_SOCKETLED_RSP, ext_socketled_req, ext_socketled_rsp);
+ register_serv_func2("MYTYPE?", MODULE_ID_SOCKET_PROXY, MSG_CMD_TYPE_REQ, MSG_CMD_TYPE_RSP, ext_type_req, ext_type_rsp);
+ register_serv_func2("MYNETACT?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_QUERY_REQ, MSG_CMD_NETACT_QUERY_RSP, ext_netact_query_req, ext_netact_query_rsp);
+ register_serv_func2("MYNETURC?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETURC_QUERY_REQ, MSG_CMD_NETURC_QUERY_RSP, ext_neturc_query_req, ext_neturc_query_rsp);
+ register_serv_func2("MYNETACT=?", 0, 0, 0, ext_netact_equal_query_req, NULL);
+ register_serv_func2("MYIPFILTER?", MODULE_ID_SOCKET_PROXY, MSG_CMD_IPFILTER_QUERY_REQ, MSG_CMD_IPFILTER_QUERY_RSP, ext_ipfilter_query_req, ext_ipfilter_query_rsp);
+ register_serv_func2("MYIPFILTER=?", 0, 0, 0, ext_ipfilter_equal_query_rsp, NULL);
+ register_serv_func2("MYNETSRV?", 0, 0, 0, ext_netsrv_query_rsp, NULL);
+ register_serv_func2("MYNETSRV=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETOPEN?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETOPEN_QUERY_REQ, MSG_CMD_NETOPEN_QUERY_RSP, ext_netopen_query_req, ext_netopen_query_rsp);
+ register_serv_func2("MYNETOPEN=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETREAD=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETWRITE=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCLOSE?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCLOSE=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETACCEPT?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETACCEPT=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCREATE?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCREATE=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func("ENPWRSAVE=",0,ext_enpwrsave_set_func);
+ register_serv_func("ENPWRSAVE?",0,ext_enpwrsave_query_func);
+
+ register_formatInform_func("+CSQ", csq_format);
+ register_formatInform_func("+CREG", xreg_format);
+ register_formatInform_func("+CGREG", xreg_format);
+ register_formatInform_func("+CEREG", xreg_format);
+ register_formatInform_func("+CGATT", cgatt_format);
+ register_formatInform_func("+CGSN", cgsn_format);
+ } else if (g_customer_type == CUSTOMER_NANDIAN) {
+ register_serv_func2("MYNETACT?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_QUERY_REQ, MSG_CMD_NETACT_QUERY_RSP, ext_netact_query_req, ext_netact_query_rsp);
+ register_serv_func2("MYNETACT=?", 0, 0, 0, ext_netact_equal_query_req, NULL);
+ register_serv_func2("MYIPFILTER=", MODULE_ID_SOCKET_PROXY, MSG_CMD_IPFILTER_REQ, MSG_CMD_IPFILTER_RSP, ext_ipfilter_req, ext_ipfilter_rsp);
+ register_serv_func2("MYIPFILTER?", MODULE_ID_SOCKET_PROXY, MSG_CMD_IPFILTER_QUERY_REQ, MSG_CMD_IPFILTER_QUERY_RSP, ext_ipfilter_query_req, ext_ipfilter_query_rsp);
+ register_serv_func2("MYIPFILTER=?", 0, 0, 0, ext_ipfilter_equal_query_rsp, NULL);
+ register_serv_func2("MYNETSRV=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETSRV_REQ, MSG_CMD_NETSRV_RSP, ext_netsrv_req, ext_netsrv_rsp);
+ register_serv_func2("MYNETSRV?", 0, 0, 0, ext_netsrv_query_rsp, NULL);
+ register_serv_func2("MYNETSRV=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETOPEN=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETOPEN_REQ, MSG_CMD_NETOPEN_RSP, ext_netopen_req, ext_netopen_rsp);
+ register_serv_func2("MYNETOPEN?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETOPEN_QUERY_REQ, MSG_CMD_NETOPEN_QUERY_RSP, ext_netopen_query_req, ext_netopen_query_rsp);
+ register_serv_func2("MYNETOPEN=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETREAD=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETREAD_REQ, MSG_CMD_NETREAD_RSP, ext_netread_req, ext_netread_rsp);
+ register_serv_func2("MYNETREAD=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETWRITE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_SENDBUF_REQ, MSG_CMD_SENDBUF_RSP, ext_sendbuf_req, ext_sendbuf_rsp);
+ register_serv_func2("MYNETWRITE=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCLOSE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCLOSE_REQ, MSG_CMD_NETCLOSE_RSP, ext_netclose_req, ext_netclose_rsp);
+ register_serv_func2("MYNETCLOSE?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETCLOSE=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETACK=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACK_REQ, MSG_CMD_NETACK_RSP, ext_netack_req, ext_netack_rsp);
+ register_serv_func2("MYNETACCEPT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACCEPT_REQ, MSG_CMD_NETACCEPT_RSP, ext_netaccept_req, ext_netaccept_rsp);
+ register_serv_func2("MYNETACCEPT?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETACCEPT=?", 0, 0, 0, ext_ok_rsp, NULL);
+ register_serv_func2("MYNETURC=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETURC_REQ, MSG_CMD_NETURC_RSP, ext_neturc_req, ext_neturc_rsp);
+ register_serv_func2("MYNETURC?", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETURC_QUERY_REQ, MSG_CMD_NETURC_QUERY_RSP, ext_neturc_query_req, ext_neturc_query_rsp);
+ register_serv_func2("MYMODEM?", MODULE_ID_SOCKET_PROXY, MSG_CMD_TYPE_REQ, MSG_CMD_TYPE_RSP, ext_type_req, ext_type_rsp);
+ register_serv_func("ENPWRSAVE=",0,ext_enpwrsave_set_func);
+ register_serv_func("ENPWRSAVE?",0,ext_enpwrsave_query_func);
+
+ register_formatInform_func("+CSQ", csq_format);
+ register_formatInform_func("+CGATT", cgatt_format);
+ register_formatInform_func("+CGSN", cgsn_format);
+
+ }
+
+#ifdef AT_QUECTEL
+ register_serv_func2("QIOPEN=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QIOPEN_REQ, MSG_CMD_QIOPEN_RSP, ext_qiopen_req, ext_qiopen_rsp);
+ register_serv_func2("QICLOSE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QICLOSE_REQ, MSG_CMD_QICLOSE_RSP, ext_qiclose_req, ext_qiclose_rsp);
+ register_serv_func2("QISTATE=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QISTATE_REQ, MSG_CMD_QISTATE_RSP, ext_qistate_req, ext_qistate_rsp);
+ register_serv_func2("QISEND=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QISEND_REQ, MSG_CMD_QISEND_RSP, ext_qisend_req, ext_qisend_rsp);
+ register_serv_func2("QIRD=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QIRD_REQ, MSG_CMD_QIRD_RSP, ext_qird_req, ext_qird_rsp);
+ register_serv_func2("QISENDEX=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QISENDEX_REQ, MSG_CMD_QISENDEX_RSP, ext_qisendex_req, ext_qisendex_rsp);
+ register_serv_func2("QISWTMD=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QISWTMD_REQ, MSG_CMD_QISWTMD_RSP, ext_qiswtmd_req, ext_qiswtmd_rsp);
+ register_serv_func2("QIDNSCFG=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QIDNSCFG_REQ, MSG_CMD_QIDNSCFG_RSP, ext_qidnscfg_req, ext_qidnscfg_rsp);
+ register_serv_func2("QIDNSGIP=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QIDNSGIP_REQ, MSG_CMD_QIDNSGIP_RSP, ext_qidnsgip_req, ext_qidnsgip_rsp);
+ register_serv_func2("QIGETERROR=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QIGETERROR_REQ, MSG_CMD_QIGETERROR_RSP, ext_qigeterror_req, ext_qigeterror_rsp);
+ register_serv_func2("QPING=", MODULE_ID_SOCKET_PROXY, MSG_CMD_QPING_REQ, MSG_CMD_QPING_RSP, ext_qping_req, ext_qping_rsp);
+#endif
+
+ return 0;
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_socket_func.h b/ap/lib/libatext/ext_socket_func.h
new file mode 100644
index 0000000..11e3dca
--- /dev/null
+++ b/ap/lib/libatext/ext_socket_func.h
@@ -0,0 +1,436 @@
+/**
+ * @file ext_socket_func.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 __EXT_SOCKET_FUNC_H__
+#define __EXT_SOCKET_FUNC_H__
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include "arpa/inet.h"
+
+#include "ext_ftp_func.h"
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+
+
+//¹úµçsocket
+
+#define UNIX_SOCKET_SERVER "socket_proxy_server"
+
+#define NON_TRANSPARENT_MODE 0 //·Ç͸Ã÷´«Êä
+#define TRANSPARENT_MODE 1 //͸Ã÷´«Êä
+
+#define CONN_TYPE_TCP_C 0 //tcp ¿Í»§¶Ë
+#define CONN_TYPE_TCP_S 1 //tcp ·þÎñ¶Ë
+#define CONN_TYPE_UDP 2 //udp
+#define IP_FILTER_NUM 5
+#define MAX_WRITE_LEN 1460
+#define MAX_WRITE_LEN_NANDIAN 2000
+#define AP_LOCK "ap_lock"
+
+struct comm_rspmsg {
+ int ret;
+ int err;
+ int socketid;
+ int len;
+ int viewmode;
+ int remote_mss;
+};
+
+struct comm_reqmsg {
+ int socketid;
+ int len;
+};
+
+struct netsrv_msg {
+ int ch_id;
+ int socketid;
+ int conn_type;
+ int viewMode;
+ char ipport[128];
+};
+struct netcreate_msg {
+ int ch_id;
+ int mode;
+ int socketid;
+ char remote_ip[128];
+ int remote_port;
+ int local_port;
+};
+struct netcreate_rspmsg {
+ int ret;
+ int err;
+ int socketid;
+ int mode;
+};
+struct netping_reqmsg {
+ char remote_ip[128];
+ int try_count;
+ int packet_size;
+};
+
+struct netping_rspmsg {
+ int ret;
+ int err;
+ int try_count;
+ int total_recv;
+ int packet_size;
+ char remote_ip[128];
+ int echo_rep_ttl;
+ char round_trip_sta[100];
+};
+struct netaccept_reqmsg {
+ int socketid;
+ int action;//ÊÇ·ñ½ÓÊÜÕìÌý 0-½ÓÊÜ 1-¾Ü¾ø
+ int transportMode;//ÕìÌý³É¹¦ºóµÄ´«Êäģʽ 0-·Ç͸Ã÷´«Êäģʽ 1-͸Ã÷´«Êäģʽ
+};
+struct netaccept_rspmsg {
+ int ret;
+ int err;
+ int socketid;
+ int transportMode;//ÕìÌý³É¹¦ºóµÄ´«Êäģʽ 0-·Ç͸Ã÷´«Êäģʽ 1-͸Ã÷´«Êäģʽ
+};
+struct netcon_reqmsg {
+ int extcid;//Ìṩ¸øÍⲿʹÓõÄcidÖµ£¬Ö§³Ö1-16
+ int is_userpwd;//ÓÉÓÚÓû§ÃûºÍÃÜÂë¿ÉÄÜΪ¿Õ£¬ÐèÒª¸Ã±ê־λָʾµ±Ç°ÅäÖÃÊÇ·ñÊÇÓû§ÃûºÍÃÜÂëÅäÖÃ
+ int cfgt;//ÿ°ü·¢Ë͵ȴýʱ¼ä
+ int cfgp;//Êý¾Ý°ü±»·¢Ë͵ÄÃÅÏÞÖµ
+ char apn[70];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄapn
+ int auth_type;//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖÃÈÏÖ¤ÀàÐÍ
+ char username[65];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄÓû§Ãû
+ char password[65];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄÃÜÂë
+};
+struct netact_reqmsg {
+ int act_type;// 1±íʾ¼¤»î²Ù×÷£¬0±íʾȥ¼¤»î²Ù×÷
+ int extcid; //Ö¸¶¨½øÐ줻î»òÕßÈ¥¼¤»îµÄÍⲿcid
+};
+
+struct neturc_reqmsg {
+ int on_off;// 0-¹Ø±ÕÐÒéÕ»Ö÷¶¯Éϱ¨ 1-´ò¿ªÐÒéÕ»Ö÷¶¯Éϱ¨
+};
+struct ipfilter_reqmsg {
+ int id;
+ int action;
+ char ip_address[128];
+ char net_mask[128];
+};
+struct netack_rspmsg {
+ int ret;
+ int err;
+ int socketid;
+ int unacked_datalen;
+ int rest_bufferlen;
+};
+struct type_rspmsg {
+ int mode;
+ int network_type;
+ int extended_feature;
+};
+struct netact_query_rspmsg {
+ int channel;
+ int status;
+ char ip[128];
+};
+struct neturc_query_rspmsg {
+ int on_off;// 0-¹Ø±ÕÐÒéÕ»Ö÷¶¯Éϱ¨ 1-´ò¿ªÐÒéÕ»Ö÷¶¯Éϱ¨
+};
+struct ipfilter_config_info {
+ int id;
+ char ip_address[128];
+ char net_mask[128];
+};
+struct ipfilter_query_rspmsg {
+ int num;
+ struct ipfilter_config_info ipfilter_info[IP_FILTER_NUM];
+};
+struct netopen_query_rspmsg {
+ int ret;
+ int socket_id;
+ char local_ip[128];
+ int local_port;
+ char gate[128];
+ char dns1[128];
+ char dns2[128];
+ int type;
+ char dest_ip[128];
+ int dest_prot;
+};
+
+
+
+
+//quectel socket
+
+#define MAX_SOCKET_SERVICE_NUM 12
+#define MAX_CONTEXT_NUM 16
+
+#define MAX_SEND_LEN 1024
+#define MAX_READ_LEN 1500
+#define MAX_SEND_HEX_LEN 512
+#define MAX_PING_NUM 10
+
+
+
+/*·þÎñÀàÐÍ */
+enum service_type {
+ TCP,
+ UDP,
+ TCP_LISTENER,
+ UDP_SERVICE
+};
+/*Êý¾Ý´«ÊäÀàÐÍ */
+enum access_mode {
+ BUFFER_ACCESS_MODE,
+ DIRECT_PUSH_MODE,
+ TRANSPARENT_ACCESS_MODE
+};
+/*͸Ã÷´«ÊäģʽÏÂÊý¾Ýģʽ/ÃüÁîģʽ */
+enum data_mode_or_cmd_mode {
+ TM_DATA_MODE,
+ TM_CMD_MODE
+};
+
+/*socket״̬*/
+enum socket_state {
+ INITIAL_STATE,
+ OPENING_STATE,
+ CONNECTED_STATE,
+ LISTENING_STATE,
+ CLOSING_STATE
+};
+
+/*²éѯÁ´½Ó״̬µÄÀàÐÍ */
+enum query_type {
+ QUERY_CONNECTION_STATUS_BY_CONTEXTID,
+ QUERY_CONNECTION_STATUS_BY_CONNECTID
+};
+
+/*Êý¾Ý·¢ËÍ»ò½ÓÊÕµÄÀàÐÍ */
+enum data_type {
+ CHANGEABLE_LENGTH,
+ FIXED_LENGTH,
+ UDP_DATA,
+ QUERY_DATA_INFO
+};
+
+/*Êý¾Ý·¢Ë͵Ľá¹û */
+enum send_rsp {
+ SEND_OK,
+ SEND_FAIL,
+ SEND_ERROR,
+ READY_TO_SEND
+};
+/*Êý¾Ý½ÓÊյĽá¹û */
+enum read_rsp {
+ READ_OK,
+ NODATA_READ,
+ CONNECTION_EXIST,
+ CONNECTION_NOT_EXIST
+};
+/*ģʽÇл»µÄ½á¹û */
+enum swtmd_rsp {
+ SW_SUCC,
+ SW_FAIL
+};
+enum dns_action_req {
+ DNS_CFG_WITH_SECDNSADDR,
+ DNS_CFG_NO_SECDNSADDR,
+ DNS_QUERY
+};
+enum dns_action_rsp {
+ DNS_ACTION_SUCC,
+ DNS_ACTION_FAIL
+};
+struct quectel_sock_info {
+ int socket;//Ó¦ÓÃÖÐÕæÊµ´´½¨µÄsocket¾ä±ú
+ int connect_id;//
+ char service_type[20];//
+ struct in_addr ip_addr; //ipµØÖ·
+ int remote_port;//Ô¶¶Ëport
+ int local_port; //±¾µØport
+ int socket_state;
+ int context_id;
+ int server_id;
+ int access_mode;
+ int at_port;
+ int total_send_length;
+ int ackedbytes;
+ int unackedbytes;
+ int total_rcv_length;
+ int have_read_length;
+ int unread_length;
+};
+
+struct each_ping_req_result {
+ int result;
+ char remote_ip[128];
+ int ping_len;
+ int response_time;//in ms
+ int ttl;
+};
+
+struct quectel_comm_reqmsg {
+ int connect_id;
+ int len;
+};
+struct quectel_comm_rspmsg {
+ int ret;
+ int err;
+ int connect_id;
+ int access_mode;
+ //int len;
+};
+
+struct quectel_qiclose_reqmsg {
+ int connect_id;
+ //int len;
+ int timeout;
+};
+
+struct quectel_qisend_reqmsg {
+ int send_type;//0-changeable length 1-fixed length 2-udp send 3-query
+ int connect_id;
+ int len;
+ char ip_addr[128];
+ int remote_port;
+};
+
+struct quectel_qisend_rspmsg {
+ int send_type;//0-changeable length 1-fixed length 2-udp send 3-query
+ int ret;
+ int connect_id;
+ int total_send_length;
+ int ackedbytes;
+ int unackedbytes;
+};
+struct quectel_qisendex_reqmsg {
+ int connect_id;
+ char hex_data[MAX_SEND_HEX_LEN];
+};
+struct quectel_qird_reqmsg {
+ int read_type;//0-changeable length 1-fixed length 2-query
+ int connect_id;
+ int len;
+};
+
+struct quectel_qird_rspmsg {
+ int read_type;//0-changeable length 1-fixed length 2-query
+ int service_type;
+ int ret;
+ int read_actual_length;
+ char remote_ipaddr[128];
+ int remote_port;
+ int total_rcv_length;
+ int have_read_length;
+ int unread_length;
+ //int ackedbytes;
+ //int unackedbytes;
+ char data[MAX_READ_LEN];
+};
+struct quectel_qiopen_msg {
+ int context_id;
+ int connect_id;
+ char service_type[20];
+ char ip_addr[128];
+ int remote_port;
+ int local_port;
+ int access_mode;
+};
+struct quectel_qistate_reqmsg {
+ int query_type;
+ int query_id;
+};
+struct quectel_qistate_rspmsg {
+ int num;
+ int query_type;
+ struct quectel_sock_info query_status_info[MAX_SOCKET_SERVICE_NUM];
+};
+
+struct quectel_qiswtmd_reqmsg {
+ int connect_id;
+ int access_mode;
+};
+struct quectel_qiswtmd_rspmsg {
+ int ret;
+ int access_mode;
+};
+struct quectel_qidnscfg_reqmsg {
+ int action_type;//0-config 1-query
+ int context_id;
+ char pri_dns_addr[128];
+ char sec_dns_addr[128];
+};
+struct quectel_qidnscfg_rspmsg {
+ int action_type;//0-config 1-query
+ int ret;
+ int context_id;
+ char pri_dns_addr[128];
+ char sec_dns_addr[128];
+};
+struct quectel_qidnsgip_reqmsg {
+ int context_id;
+ char host_name[128];
+};
+struct quectel_qidnsgip_rspmsg {
+ int ret;
+ int error;
+ int ip_count;
+ int dns_ttl;
+ char host_ipaddr[4][128];
+};
+struct quectel_qigeterror_rspmsg {
+ int err;
+ char errcode_description[32];
+};
+struct qping_reqmsg {
+ int context;
+ char remote_ip[128];
+ int timeout;
+ int ping_num;
+};
+
+struct qping_rspmsg {
+ int ret;
+ int ping_num;
+ struct each_ping_req_result each_ping_result[MAX_PING_NUM];
+ int finresult;
+ int sent;
+ int rcvd;
+ int lost;
+ int min;
+ int max;
+ int avg;
+};
+struct quectel_qiurc_rspmsg {
+ int buffer_mode;
+ int service_type;
+ int connect_id;
+ int currentrecvlength;
+ char remote_ipaddr[128];
+ int remote_port;
+ char data[MAX_READ_LEN];
+};
+/*ÍøÂçͬ²½ÐźŵƿØÖÆ£¬ÓÃÓÚÍâÖÃÐÒéÕ»socketÁ¬½Ó³É¹¦Ê±£¬LEDÐźŵÆÉÁ˸¿ØÖÆ*/
+struct zteftp_socketled_reqmsg {
+ int iswitch;/*0±íʾsocketδÁ¬½ÓʱLEDÉÁ˸״̬£»1±íʾsocketÁ¬½Ó³É¹¦Ê±£¬LEDÉÁµÆ£»*/
+};
+struct zteftp_socketled_rspmsg {
+ int result;/*0±íʾOK£»-1±íʾERROR*/
+};
+#endif
diff --git a/ap/lib/libatext/ext_user_modem.c b/ap/lib/libatext/ext_user_modem.c
new file mode 100755
index 0000000..780a582
--- /dev/null
+++ b/ap/lib/libatext/ext_user_modem.c
@@ -0,0 +1,584 @@
+#ifndef CONFIG_MIN_8M_VERSION
+#include "ext_socket_func.h"
+#include "cfg_nv_def.h"
+#include "at_context.h"
+#include "kwatch_msg.h"
+
+int netcon_extcid = -1;
+char netcon_configname[10] = {0};
+int netcon_value_int = 0;
+char netcon_value_char[70] = {0};
+extern char* normal_getzversion();
+int urcsysinfo = 0;
+typedef struct {
+ int mode;
+ int creg;
+ int cgreg;
+ int cereg;
+} EXT_NETSTATE_INFO;
+EXT_NETSTATE_INFO urcinfo = {0};
+//========================================================================================================//
+//¹úµçsocket·½°¸º¯ÊýʵÏÖÇø
+//========================================================================================================//
+static int gsmband = 0;
+
+static void comm_rspmsg_proc(void *rsp_msg, void**ret, int *retlen)
+{
+ AT_COMM_RSPMSG *msg = (AT_COMM_RSPMSG*)rsp_msg;
+ char *at_str = NULL;
+ int offset = 0;
+
+ if (msg->result < 0) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ if (msg->errcode) {
+ sprintf(at_str, "\r\nERROR: %d\r\n", msg->errcode);
+ } else {
+ sprintf(at_str, "\r\nERROR\r\n");
+ }
+ } else {
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0x00, 64);
+ if (msg->msg_cmd == MSG_CMD_NETACT_REQ) {
+ offset += sprintf(at_str, "\r\nOK\r\n");
+ if (msg->urc_switch) {
+ if (g_customer_type == CUSTOMER_GUODIAN)
+ offset += sprintf(at_str + offset, "\r\n$MYURCACT: %d,%d\r\n", msg->extcid, msg->act_type);
+ else if (g_customer_type == CUSTOMER_NANDIAN)
+ offset += sprintf(at_str + offset, "\r\n$MYURCACT: %d,%d,\"%s\"\r\n", msg->extcid, msg->act_type, msg->ip);
+ }
+
+ *ret = at_str;
+ *retlen = offset;
+ return;
+ }
+ sprintf(at_str, "\r\nOK\r\n");
+ }
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+}
+
+
+int ext_netcon_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netcon_reqmsg *reqmsg = malloc(sizeof(struct netcon_reqmsg));
+ assert(reqmsg);
+ char configname[10] = {0};
+ char *l_quota = NULL;//×óË«ÒýºÅ
+ char *r_quota = NULL;//ÓÒË«ÒýºÅ
+ char *at_str = NULL;
+
+ //if (NULL == reqmsg) softap_assert("");
+ //³õʼ»¯
+ memset(reqmsg, 0x00, sizeof(struct netcon_reqmsg));
+ reqmsg->auth_type = -1;
+ reqmsg->cfgp = -1;
+ reqmsg->cfgt = -1;
+
+ reqmsg->extcid = at_paras[0] - '0';
+ if (reqmsg->extcid < 0 || reqmsg->extcid >= 6)
+ goto error;
+ l_quota = strstr(at_paras, "\"");
+ if (NULL == l_quota) {
+ goto error;
+ }
+ r_quota = strstr(l_quota + 1, "\"");
+
+ if (NULL == r_quota) {
+ goto error;
+ }
+ memcpy(configname, l_quota + 1, r_quota - l_quota - 1);
+ if (0 == at_strncmp(configname, "APN", strlen("APN"))) {
+ l_quota = strstr(r_quota + 1, "\"");
+ if (l_quota == NULL)
+ goto error;
+ r_quota = strstr(l_quota + 1, "\"");
+ if (r_quota == NULL)
+ goto error;
+ memcpy(reqmsg->apn, l_quota + 1, r_quota - l_quota - 1);
+ memset(netcon_value_char, 0, sizeof(netcon_value_char));
+ memcpy(netcon_value_char, l_quota + 1, r_quota - l_quota - 1);
+ } else if (0 == at_strncmp(configname, "USERPWD", strlen("USERPWD"))) {
+ l_quota = strstr(r_quota + 1, "\"");
+ if (l_quota == NULL)
+ goto error;
+ r_quota = strstr(l_quota + 1, "\"");
+ if (r_quota == NULL)
+ goto error;
+ char *comma = strstr(l_quota + 1, ",");
+ if (NULL != comma) { //ÓжººÅ£¬Óû§ÃûÃÜÂ벻Ϊ¿Õ
+ if (comma > r_quota)
+ goto error;
+ memcpy(reqmsg->username, l_quota + 1, comma - l_quota - 1);
+ memcpy(reqmsg->password, comma + 1, r_quota - comma - 1);
+ }
+ memset(netcon_value_char, 0, sizeof(netcon_value_char));
+ memcpy(netcon_value_char, l_quota + 1, r_quota - l_quota - 1);
+
+ reqmsg->is_userpwd = 1;
+ } else if (0 == at_strncmp(configname, "CFGT", strlen("CFGT"))) {
+ int len = strlen(r_quota + 2);
+ char* str = malloc(len + 1);
+ assert(str);
+ strcpy(str, r_quota + 2);
+ reqmsg->cfgt = atoi(str);
+ if (reqmsg->cfgt < 1 || reqmsg->cfgt > 65535){
+ free(str);
+ goto error;
+ }
+ netcon_value_int = atoi(str);
+ free(str);
+ } else if (0 == at_strncmp(configname, "CFGP", strlen("CFGP"))) {
+ int len = strlen(r_quota + 2);
+ char* str = malloc(len + 1);
+ assert(str);
+ strcpy(str, r_quota + 2);
+ reqmsg->cfgp = atoi(str);
+ if (reqmsg->cfgp < 1 || reqmsg->cfgp > 1460) {
+ free(str);
+ goto error;
+ }
+ netcon_value_int = atoi(str);
+ free(str);
+ } else if (0 == at_strncmp(configname, "AUTH", strlen("AUTH"))) {
+ int len = strlen(r_quota + 2);
+ char* str = malloc(len + 1);
+ assert(str);
+ strcpy(str, r_quota + 2);
+ reqmsg->auth_type = atoi(str);
+ if (reqmsg->auth_type < 0 || reqmsg->auth_type > 2) {
+ free(str);
+ goto error;
+ }
+ netcon_value_int = atoi(str);
+ free(str);
+ } else {
+ goto error;
+ }
+ netcon_extcid = reqmsg->extcid;
+ strncpy(netcon_configname, configname,sizeof(netcon_configname)-1);
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct netcon_reqmsg);
+ return AT_CONTINUE;
+error:
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+}
+int ext_netcon_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ comm_rspmsg_proc(rsp_msg, ret, retlen);
+ return AT_END;
+}
+
+int ext_netact_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ struct netact_reqmsg *reqmsg = malloc(sizeof(struct netact_reqmsg));
+ assert(reqmsg);
+ char *p[2] = {&reqmsg->extcid, &reqmsg->act_type};
+ char *at_str = NULL;
+ memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
+ if(2 != parse_param2("%d,%d", at_paras, p)){
+ free(reqmsg);
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(at_str);
+ return AT_END;
+ }
+
+ *res_msg = reqmsg;
+ *res_msglen = sizeof(struct netact_reqmsg);
+ return AT_CONTINUE;
+}
+int ext_netact_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ comm_rspmsg_proc(rsp_msg, ret, retlen);
+
+ return AT_END;
+}
+
+/*Èí¹Ø»ú*/
+int ext_poweroff_req(int at_fd, char * at_paras, void **res_msg, int * res_msglen)
+{
+ return AT_CONTINUE;
+}
+
+
+
+int ext_i_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ char *at_str = NULL;
+
+ at_str = malloc(128);
+ assert(at_str);
+ memset(at_str, 0, 128);
+ sprintf((char*)at_str, "\r\nLQBS\r\nLQ300V3\r\nREVISION V1.0.0\r\nOK\r\n");
+
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+int ext_myband_set_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYBAND_SET_REQ, strlen(at_paras), (unsigned char *)at_paras, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+
+int ext_myband_query_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYBAND_QUERY_REQ, 0, NULL, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+
+int ext_beeh_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int ext_poweroff_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ char *at_str = NULL;
+
+ at_str = at_ok_build();
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+ return AT_END;
+}
+
+/*¶ÁÈí¼þÍⲿ°æ±¾ºÅ*/
+int ext_gmr_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ char hwver[32] = {0};
+ char swver[32] = {0};
+ char *at_str = NULL;
+
+ //sc_cfg_get(NV_HW_VERSION, hwver, sizeof(hwver));
+ //sc_cfg_get(NV_WA_VERSION, swver, sizeof(swver));
+ //³§ÉÌ´úºÅ¡¢Ä£¿éÐͺš¢Ó²¼þ·¢²¼ÈÕÆÚ¡¢Èí¼þ·¢²¼ÈÕÆÚÈçºÎ»ñÈ¡
+ at_str = malloc(128);
+ assert(at_str);
+ memset(at_str, 0, 128);
+ sprintf((char*)at_str, "\r\nLQBS\r\nLQ300V3\r\nV1.0.0\r\n151017\r\nV1.0\r\n151017\r\nOK\r\n");
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+/*»ñÈ¡SIM¿¨ÐòÁкÅ*/
+int ext_ccid_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ char iccid[32] = {0};
+ char *at_str = NULL;
+
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str, 0, 64);
+ sc_cfg_get(NV_ZICCID, iccid, sizeof(iccid));
+ //at_print(1,"ext_ccid_act_func: iccid = %s\n",iccid);
+ sprintf((char*)at_str, "\r\n$MYCCID: \"%s\"\r\nOK\r\n", iccid);
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+int ext_netcon_query_func(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
+{
+ char *at_str = NULL;
+ int offset = 0;
+
+ if (netcon_extcid == -1) {
+ at_str = malloc(32);
+ assert(at_str);
+ memset(at_str, 0x00, 32);
+ sprintf(at_str, "\r\nERROR\r\n");
+ } else {
+ at_str = malloc(32 + sizeof(netcon_extcid) + sizeof(netcon_configname) + sizeof(netcon_value_char));
+ assert(at_str);
+ memset(at_str, 0, 32 + sizeof(netcon_extcid) + sizeof(netcon_configname) + sizeof(netcon_value_char));
+ offset += sprintf(at_str + offset, "\r\n$MYNETCON: %d,\"%s\",", netcon_extcid, netcon_configname);
+ if (0 == at_strncmp(netcon_configname, "APN", strlen("APN")) || 0 == at_strncmp(netcon_configname, "USERPWD", strlen("USERPWD"))) {
+ offset += sprintf(at_str + offset, "\"%s\"\r\nOK\r\n", netcon_value_char);
+ } else {
+ offset += sprintf(at_str + offset, "%d\r\nOK\r\n", netcon_value_int);
+ }
+ }
+
+ *res_msg = at_str;
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+int ext_gmr_query_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_GMR_QUERY_REQ, 0, NULL, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+int ext_gmr_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
+{
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int ext_mysysinfo_query_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYSYSINFO_QUERY_REQ, 0, NULL, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+
+int ext_mynetinfo_set_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYNETINFO_SET_REQ, strlen(at_paras), (unsigned char *)at_paras, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+
+int ext_mynetinfo_query_func(char *at_paras, void ** res_msg)
+{
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYNETINFO_QUERY_REQ, 0, NULL, 0))
+ softap_assert("");
+ return AT_CONTINUE;
+}
+
+int ext_urcsysinfo_act_func(char *at_paras, void ** res_msg)
+{
+ int flag = 0;
+ void *p[1] = {&flag};
+ int ret = 0;
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ if (1 == flag) {
+ urcsysinfo = 1;
+ *res_msg = at_ok_build();
+ } else {
+ *res_msg = at_err_build(0);
+ }
+ return AT_END;
+}
+
+int mode_inform_act(char *at_paras, int is_query_report)
+{
+ int mode = 0;
+ void *p[1] = {&mode};
+ int ret = 0;
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ if ((mode != urcinfo.mode) && (urcsysinfo == 1)) {
+ urcinfo.mode = mode;
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0))
+ softap_assert("");
+ }
+ return AT_END;
+}
+
+int net_state_transfer(int state)
+{
+ if ((state == 1) || (state == 5))
+ return 1;
+ else return 0;
+}
+int creg_inform_act(char *at_paras, int is_query_report)
+{
+ int state = 0;
+ void *p[1] = {&state};
+ int ret = 0;
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ state = net_state_transfer(state);
+ if ((state != urcinfo.creg) && (urcsysinfo == 1)) {
+ urcinfo.creg = state;
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0))
+ softap_assert("");
+ }
+ return AT_END;
+}
+int cgreg_inform_act(char *at_paras, int is_query_report)
+{
+ int state = 0;
+ void *p[1] = {&state};
+ int ret = 0;
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ state = net_state_transfer(state);
+ if ((state != urcinfo.cgreg) && (urcsysinfo == 1)) {
+ urcinfo.cgreg = state;
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0))
+ softap_assert("");
+ }
+ return AT_END;
+}
+int cereg_inform_act(char *at_paras, int is_query_report)
+{
+ int state = 0;
+ void *p[1] = {&state};
+ int ret = 0;
+ ret = parse_param("%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ state = net_state_transfer(state);
+ if ((state != urcinfo.cereg) && (urcsysinfo == 1)) {
+ urcinfo.cereg = state;
+ if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0))
+ softap_assert("");
+ }
+ return AT_END;
+}
+
+int ext_time_set_func(char *at_paras, void ** res_msg)
+{
+ char settime[32] = {0};
+ void *p[] = {settime};
+ int ret = 0;
+ char *at_str = NULL;
+ at_str = malloc(16);
+ assert(at_str);
+ memset(at_str,0,16);
+ struct tm set_tm = {0};
+ struct timeval time_tv = {0};
+ struct timezone time_tz = {0, 0};
+
+ ret = parse_param("%32s",at_paras, p);
+ if(ret != AT_PARSE_OK)
+ {
+ sprintf(at_str,"\r\nERROR: 980\r\n");
+ *res_msg = at_str;
+ return AT_END;
+ }
+ sscanf(settime,"%2d/%2d/%2d,%2d:%2d:%2d",&set_tm.tm_year,
+ &set_tm.tm_mon,&set_tm.tm_mday,&set_tm.tm_hour,&set_tm.tm_min,&set_tm.tm_sec);
+ at_print(1,"ext_time_set_func: %2d/%2d/%2d,%2d:%2d:%2d\n",set_tm.tm_year,
+ set_tm.tm_mon,set_tm.tm_mday,set_tm.tm_hour,set_tm.tm_min,set_tm.tm_sec);
+
+#if 1 // kw 3
+ if(set_tm.tm_year < 0 || set_tm.tm_year > 5000)
+ {
+ set_tm.tm_year = 1970;
+ }
+
+ if(set_tm.tm_mon < 0 || set_tm.tm_mon > 13)
+ {
+ set_tm.tm_mon = 1;
+ }
+#endif
+ set_tm.tm_year = set_tm.tm_year + 100;
+ set_tm.tm_mon = set_tm.tm_mon - 1;
+
+ time_tv.tv_sec = mktime(&set_tm);
+ if(time_tv.tv_sec < 0)// cov M
+ {
+ time_tv.tv_sec = 0;
+ }
+
+// time_tv.tv_sec = time_tv.tv_sec; // cov M
+ struct tm * new_time = gmtime(&time_tv.tv_sec);
+ if(new_time)
+ time_tz.tz_minuteswest = (mktime(new_time) - (time_tv.tv_sec)) / 60;
+
+ if (0 != settimeofday(&time_tv,&time_tz))
+ {
+ at_print(AT_ERR,"zmmi_auto_act,set time of system wrong");
+ sprintf(at_str,"\r\nERROR: 981\r\n");
+ *res_msg = at_str;
+ return AT_END;
+ }
+ rtc_set_time(MODULE_ID_AT_CTL);
+ sprintf(at_str,"\r\nOK\r\n");
+ *res_msg = at_str;
+ return AT_END;
+}
+
+int ext_time_query_func(char *at_paras, void ** res_msg)
+{
+ struct tm *p;
+ time_t timep;
+ char buf[32] = {0};
+ char *at_str = NULL;
+ at_str = malloc(64);
+ assert(at_str);
+ memset(at_str,0,64);
+ time(&timep);
+ p = localtime(&timep);
+ assert(p);
+ snprintf(buf,32,"%02d/%02d/%02d,%02d:%02d:%02d",(1900 + p->tm_year)%100,1 + p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
+ at_print(1,"ext_time_query_func: time: %s\n",buf);
+ sprintf(at_str,"\r\n+CCLK: \"%s\"\r\nOK\r\n",buf);
+ *res_msg = at_str;
+ return AT_END;
+}
+
+int ext_user_modem_regist(void)
+{
+//#ifdef GUODIAN
+ if (g_customer_type == CUSTOMER_GUODIAN) {
+ //PDP¼¤»î
+ register_serv_func2("MYNETCON=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCON_REQ, MSG_CMD_NETCON_RSP, ext_netcon_req, ext_netcon_rsp);
+ register_serv_func2("MYNETACT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_REQ, MSG_CMD_NETACT_RSP, ext_netact_req, ext_netact_rsp);
+ register_serv_func2("MYPOWEROFF", MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, MSG_CMD_POWEROFF_RSP, ext_poweroff_req, ext_poweroff_rsp);
+
+ register_serv_func2("MYGMR", 0, 0, 0, ext_gmr_act_func, NULL);
+ register_serv_func2("MYCCID", 0, 0, 0, ext_ccid_act_func, NULL);
+ register_serv_func2("ATI", 0, 0, 0, ext_i_act_func, NULL);
+
+ register_serv_func2("MYBCCH?", 0, 0, 0, ext_beeh_act_func, NULL);
+ register_serv_func2("MYBCCH=?", 0, 0, 0, ext_beeh_act_func, NULL);
+ register_serv_func2("MYBCCH=", 0, 0, 0, ext_beeh_act_func, NULL);
+
+ register_serv_func("MYBAND=", MODULE_ID_SOCKET_PROXY, ext_myband_set_func);
+ register_serv_func("MYBAND?", MODULE_ID_SOCKET_PROXY, ext_myband_query_func);
+
+ register_serv_func2("MYNETCON?", 0, 0, 0, ext_netcon_query_func, NULL);
+
+ register_serv_func("GMR", MODULE_ID_SOCKET_PROXY, ext_gmr_query_func);
+ register_serv_func2("GMR=?", 0, 0, 0, ext_gmr_func, NULL);
+ } else if (g_customer_type == CUSTOMER_NANDIAN) {
+ register_serv_func2("MYPOWEROFF", MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, MSG_CMD_POWEROFF_RSP, ext_poweroff_req, ext_poweroff_rsp);
+ register_serv_func2("MYNETCON=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCON_REQ, MSG_CMD_NETCON_RSP, ext_netcon_req, ext_netcon_rsp);
+ register_serv_func2("MYNETCON?", 0, 0, 0, ext_netcon_query_func, NULL);
+ register_serv_func2("MYNETACT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_REQ, MSG_CMD_NETACT_RSP, ext_netact_req, ext_netact_rsp);
+
+ register_serv_func2("MYGMR", 0, 0, 0, ext_gmr_act_func, NULL);
+ register_serv_func2("MYCCID", 0, 0, 0, ext_ccid_act_func, NULL);
+
+ register_serv_func2("ATI", 0, 0, 0, ext_i_act_func, NULL);
+ register_serv_func("GMR", MODULE_ID_SOCKET_PROXY, ext_gmr_query_func);
+ register_serv_func2("GMR=?", 0, 0, 0, ext_gmr_func, NULL);
+
+ register_serv_func("MYURCSYSINFO=", 0, ext_urcsysinfo_act_func);
+ register_serv_func("MYSYSINFO", MODULE_ID_SOCKET_PROXY, ext_mysysinfo_query_func);
+ register_serv_func("MYNETINFO=", MODULE_ID_SOCKET_PROXY, ext_mynetinfo_set_func);
+ register_serv_func("MYNETINFO?", MODULE_ID_SOCKET_PROXY, ext_mynetinfo_query_func);
+
+ register_inform_func("CEREG", cereg_inform_act);
+ register_inform_func("CGREG", cgreg_inform_act);
+ register_inform_func("CREG", creg_inform_act);
+ register_inform_func("MODE", mode_inform_act);
+ }
+ register_serv_func("CCLK=",0,ext_time_set_func);
+ register_serv_func("CCLK?",0,ext_time_query_func);
+ return 0;
+}
+
+#endif
diff --git a/ap/lib/libatext/ext_wdt_func.c b/ap/lib/libatext/ext_wdt_func.c
new file mode 100644
index 0000000..e289b5f
--- /dev/null
+++ b/ap/lib/libatext/ext_wdt_func.c
@@ -0,0 +1,180 @@
+#include "ext_regist.h"
+
+#include "NvParam_drv.h"
+#include "libcpnv.h"
+#define ZOSS_ERROR 0xffffffff
+#define ZOSS_SUCCESS 0x0
+
+/*wdt nv flag*/
+#define WDT_OFF (0x57445446) //ascii:WDTF
+#define WDT_ON (0x5744544F) //ascii:WDTO
+
+#define ZX_WDT_IOC_MAGIC 'W'
+
+/*ioctl cmd usd by device*/
+#define ZX_WDT_SET_INTERNAL _IOW(ZX_WDT_IOC_MAGIC, 1, char *)
+#define ZX_WDT_SET_WAKEUP _IOW(ZX_WDT_IOC_MAGIC, 2, char *)
+#define ZX_WDT_FEED_DOG _IOW(ZX_WDT_IOC_MAGIC, 3, char *)
+#define ZX_WDT_GET_HANDLE_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 4, char *)
+#define ZX_WDT_GET_GLOBAL_CNT _IOWR(ZX_WDT_IOC_MAGIC, 5, char *)
+#define ZX_WDT_GET_AP_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 6, char *)
+#define ZX_WDT_SET_AP_SWITCH _IOWR(ZX_WDT_IOC_MAGIC, 7, char *)
+#define ZX_WDT_SET_NV _IOWR(ZX_WDT_IOC_MAGIC, 8, char *)
+#define ZX_WDT_GET_NV _IOWR(ZX_WDT_IOC_MAGIC, 9, char *)
+#define ZX_WDT_SET_CHECK _IOWR(ZX_WDT_IOC_MAGIC, 10, char *)
+
+#define ZX_SOFT_WDT_DEV "/dev/zx_soft_wdt"
+
+
+extern int zx_wdt_set_nv(BOOL nv_flag);
+extern BOOL zx_wdt_get_wdtnv_for_ctrm(void);
+//static long int wdt_fd;
+
+int wdt_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ unsigned long retCode = ZOSS_ERROR;
+ int nv_value = 0;
+ unsigned int wdt_nvdata = 0;
+
+ assert(at_paras!=NULL);
+ at_str = at_paras;
+
+ get_at_cmd_param_int(at_str, &nv_value, &at_str);
+ at_print(AT_DEBUG,"wdt_act_func:nv_value == %d\n", nv_value);
+
+ if(0 == nv_value )
+ {
+
+ //ioctl(wdt_fd, ZX_WDT_SET_NV, FALSE);
+ wdt_nvdata=WDT_OFF;
+ retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
+ if(ZOSS_SUCCESS == retCode ){
+ retCode= cpnv_NvramFlush();
+ }
+
+ }
+ else if(1 == nv_value )
+ {
+ //ioctl(wdt_fd, ZX_WDT_SET_NV, TRUE);
+ wdt_nvdata=WDT_ON;
+ retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
+ if(ZOSS_SUCCESS == retCode ){
+ retCode= cpnv_NvramFlush();
+ }
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if (retCode == ZOSS_SUCCESS)
+ {
+ *res_msg = at_query_result_build("WDT=",at_str);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int wdt_get_nv_state(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+
+ unsigned int wdt_nvdata = 0;
+ long retCode = CPNV_ERROR;
+
+ //ioctl(wdt_fd, ZX_WDT_GET_NV, &retCode);
+
+ retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
+ if(CPNV_ERROR == retCode) softap_assert("");
+ if (WDT_OFF == wdt_nvdata )
+ {
+ *res_msg = at_query_result_build("WDT","WDT OFF");
+
+ } else if(WDT_ON== wdt_nvdata )
+ {
+ *res_msg = at_query_result_build("WDT","WDT ON");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int wdt_set_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ char *at_str = NULL;
+ unsigned long retCode = ZOSS_ERROR;
+ int nv_value = 0;
+ char strCmd[AT_CMD_MAX] = {0};
+
+ assert(at_paras!=NULL);
+ at_str = at_paras;
+
+ get_at_cmd_param_int(at_str, &nv_value, &at_str);
+ at_print(AT_DEBUG,"wdt_set_nv_priority:nv_value == %d\n", nv_value);
+
+ if((nv_value > 0)&&(nv_value <= 99))//priority
+ {
+ retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&nv_value), DRV_SYS_NV_ITEM_SIZE(wdtPriority));
+ if(ZOSS_SUCCESS == retCode ){
+ retCode= cpnv_NvramFlush();
+ }
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ if (retCode == ZOSS_SUCCESS)
+ {
+ sprintf(strCmd,"%d", nv_value);
+ *res_msg = at_query_result_build("WDTP=",strCmd);
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ }
+
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+int wdt_get_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
+{
+ unsigned int wdt_nvdata = 0;
+ long retCode = CPNV_ERROR;
+ char strCmd[AT_CMD_MAX] = {0};
+
+ retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtPriority));
+ if(CPNV_ERROR == retCode) softap_assert("");
+
+ sprintf(strCmd,"%d", wdt_nvdata);
+
+ *res_msg = at_query_result_build("WDTP",strCmd);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+}
+
+void ext_wdt_regist_init(void)
+{
+ //wdt_fd = open(ZX_SOFT_WDT_DEV, O_RDWR);
+ //ioctl(wdt_fd, ZX_WDT_SET_CHECK, FALSE);
+
+ register_serv_func2("WDT=", 0, 0, 0, wdt_act_func, NULL);
+ register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);
+ register_serv_func2("WDTP=", 0, 0, 0, wdt_set_nv_priority, NULL);
+ register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);
+}
+
diff --git a/ap/lib/libatext/ext_zcat_func.c b/ap/lib/libatext/ext_zcat_func.c
new file mode 100644
index 0000000..11aaf45
--- /dev/null
+++ b/ap/lib/libatext/ext_zcat_func.c
@@ -0,0 +1,205 @@
+/**
+ *
+ * @file ext_zcat_func.c
+ * @brief
+ * This file is part of ZCAT.
+ * ZCATÄ£¿éÏà¹ØATÃüÁî
+ *
+ * @details
+ * @author Tools Team.
+ * @email
+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.
+ * @warning
+ * @date 2019/02/02
+ * @version 1.2
+ * @pre
+ * @post
+ *
+ * @par
+ * Change History :
+ * ---------------------------------------------------------------------------
+ * date version author description
+ * ---------------------------------------------------------------------------
+ * 2017/05/22 1.0 hou.bing Create file
+ * 2019/01/15 1.1 jiang.fenglin Ôö¼ÓÉèÖÃ/²éѯzcat_usblogÃüÁî
+ * 2019/02/02 1.2 jiang.fenglin ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen
+ * 2019/07/08 1.3 jiang.fenglin Ôö¼ÓAPFS/CPFSģʽ
+ * ---------------------------------------------------------------------------
+ *
+ *
+ */
+
+
+#if (APP_OS_TYPE == APP_OS_LINUX)
+#include "ext_regist.h"
+#include "at_utils.h"
+#include "softap_api.h"
+#include "zxic_errno.h"
+#include "nv_api.h"
+//#include "nvserver.h"
+
+#ifndef max
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef min
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+
+/**
+ * º¯ÊýʵÏÖ
+ */
+
+int ext_zcat_set_mode(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char zcat_mode[512] = {0};
+ //E_AT_PARSE parseRst = AT_PARSE_SUCCESS;
+
+ printf("ext_zcat_set %s,len is %d\n",at_paras,strlen(at_paras));
+ memcpy(zcat_mode,at_paras,min(strlen(at_paras), sizeof(zcat_mode) - 1));
+ printf("zcat_mode is %s",zcat_mode);
+ if(0==strcmp(zcat_mode,"APUSB") || 0==strcmp(zcat_mode,"APNET") || 0==strcmp(zcat_mode,"APTF") \
+ || 0==strcmp(zcat_mode,"APFS") || 0==strcmp(zcat_mode,"CPFS") \
+ || 0==strcmp(zcat_mode,"CPUSB") || 0==strcmp(zcat_mode,"CPTF"))
+ {
+ sc_cfg_set("zcat_mode",zcat_mode);
+ sc_cfg_save();
+ nv_set_item("cfg","zcat_mode", zcat_mode,1);
+ nv_commit("cfg");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+ #if 0
+ switch(iNetcardType)
+ {
+ case 0:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_ndis",1);
+ break;
+ }
+ case 1:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_ecm",1);
+ break;
+ }
+ case 2:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_mbim",1);
+ break;
+ }
+ case 3:
+ {
+ nv_set_item(NV_RO,"forcenetcard_type", "force_rndis",1);
+ break;
+ }
+ default:
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ }
+ nv_commit(NV_RO);
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+ #endif
+}
+
+
+int ext_zcat_get_mode(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char zcat_mode[512] = {0};
+ printf("ext_zcat_get %s\n",at_paras);
+
+ if(-1 == sc_cfg_get("zcat_mode", zcat_mode, sizeof(zcat_mode)))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+ nv_get_item("cfg", "zcat_mode", zcat_mode, sizeof(zcat_mode));
+ printf("zcat_mode is %s ,%d",zcat_mode,strlen(zcat_mode));
+ *res_msg = at_query_result_build("ZCAT_MODE",zcat_mode);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+
+int ext_zcat_set_usblog(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char zcat_usblog[512] = {0};
+ //E_AT_PARSE parseRst = AT_PARSE_SUCCESS;
+
+ printf("ext_zcat_set %s,len is %d\n", at_paras, strlen(at_paras));
+ memcpy(zcat_usblog, at_paras, min(strlen(at_paras), sizeof(zcat_usblog)-1));
+ printf("zcat_usblog is %s", zcat_usblog);
+ if(strstr(zcat_usblog, "tty"))
+ {
+ sc_cfg_set("zcat_usblog", zcat_usblog);
+ sc_cfg_save();
+ nv_set_item("cfg", "zcat_usblog", zcat_usblog, 1);
+ nv_commit("cfg");
+ }
+ else
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ *res_msg = at_ok_build();
+ *res_msglen = strlen(*res_msg);
+
+ return AT_END;
+}
+
+int ext_zcat_get_usblog(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ char zcat_usblog[512] = {0};
+ printf("ext_zcat_get %s\n", at_paras);
+
+ if(-1 == sc_cfg_get("zcat_usblog", zcat_usblog, sizeof(zcat_usblog)))
+ {
+ *res_msg = at_err_build(ATERR_PROC_FAILED);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ nv_get_item("cfg", "zcat_usblog", zcat_usblog, sizeof(zcat_usblog));
+ printf("zcat_usblog is %s ,%d",zcat_usblog,strlen(zcat_usblog));
+ *res_msg = at_query_result_build("ZCAT_USBLOG",zcat_usblog);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+
+}
+
+
+int ext_zcat_regist(void)
+{
+
+ register_serv_func2("zcatmode=",0,0,0, ext_zcat_set_mode, NULL);
+ register_serv_func2("zcatmode?",0,0,0, ext_zcat_get_mode, NULL);
+
+ register_serv_func2("zcatusblog=",0,0,0,ext_zcat_set_usblog, NULL);
+ register_serv_func2("zcatusblog?",0,0,0,ext_zcat_get_usblog, NULL);
+
+ return 0;
+
+}
+
+#endif
+
diff --git a/ap/lib/libatext/readme.txt b/ap/lib/libatext/readme.txt
new file mode 100644
index 0000000..061a19f
--- /dev/null
+++ b/ap/lib/libatext/readme.txt
@@ -0,0 +1,92 @@
+±¾ÎÄÖ÷ÒªÏêϸ˵Ã÷ƽ̨ÄÚ²¿À©Õ¹atÃüÁîµÄ×¢²á¡¢´¦ÀíÁ÷³Ì£¬ÎªÆ½Ì¨ÄÚ²¿À©Õ¹atÃüÁ·¢Ìṩָµ¼¡£
+
+±¾Ä¿Â¼ÏµÄext_clt_func.c¡¢ext_ser_func.cºÍext_demo_func.hΪʾÀý²Î¿¼´úÂë¡£
+
+ƽ̨ÄÚÒª¿ª·¢Ò»¸öÀ©Õ¹atÃüÁÊ×ÏȱØÐëÔÚlibatext¿âµÄext_regist_init½Ó¿Úµ±ÖÐ×¢²á¸ÃatÃüÁî
+
+1¡¢À©Õ¹at ¿Í»§¶ËµÄ×¢²áºÍ´¦Àí
+
+ a¡¢À©Õ¹at¿Í»§¶ËµÄ×¢²á
+ int register_extclt_func(int position,char *at_cmd_prefix,int req_msg_id,int rsp_msg_id,clt_req_func req_proc,clt_ok_func ok_act,clt_err_func err_act, inform_act_func inform_act)
+
+ ÆäÖÐ:
+ position±íʾ¸Ã¿Í»§¶ËʹÓÃatͨµÀµÄλÖ㬼´ÔÚ±¾cpuÄÚ²¿£¬Î»Öÿ¿½ümodemÐÒéÕ»(NEAR_PS)£¬»¹ÊÇÔ¶ÀëmodemÐÒéÕ»(FAR_PS)£»
+ at_cmd_prefix±íʾÀ©Õ¹atÃüÁîµÄǰ׺ÐÅÏ¢£»
+ req_msg_idΪ±¾Ä£¿é·¢Ë͸øat_ctlÓ¦ÓõÄÏûÏ¢id£¬ÓÃÓÚ´¥·¢atÇëÇóÁ÷³Ì£¬±ØÐëÔÚlibatext¿âÖеÄext_regist.hÖж¨Òå
+ rsp_msg_idΪat_ctlÓ¦Óô¦ÀíÍêÉÏÃæµÄatÇëÇóÁ÷³Ìºó£¬·¢Ë͸ÃÏûÏ¢id¸ø±¾Ä£¿é£¬±íʾat¿Í»§¶ËÁ÷³Ì½áÊø£»±ØÐëÓëreq_msg_idÔÚlibatext¿âÖеÄext_regist.hÖÐÒ»Æð¶¨Òå
+ req_proc ÏûÏ¢´¦Àíº¯Êý£¬at_ctlÓ¦ÓÃÔÚ½ÓÊÕµ½ÏûÏ¢idΪreq_msg_idʱ£¬¾Í»áµ÷Óô¦Àíº¯Êý£¬´¦Àí±¾Ä£¿é·¢Ë͸øat_ctlµÄÏûÏ¢£»
+ ok_act À©Õ¹atÃüÁîµÄokÏìÓ¦´¦Àíº¯Êý
+ err_actÀ©Õ¹atÃüÁîµÄerrÏìÓ¦´¦Àíº¯Êý
+ inform_act_funcÀ©Õ¹atÃüÁîµÄÖ÷¶¯Éϱ¨/Öмä½á¹ûÉϱ¨´¦Àíº¯Êý
+
+ b¡¢ÔÚ¸ÃÀ©Õ¹at ÅäÌ×µÄÓ¦Óýø³Ì/Ä£¿éÖУ¬µ±ÐèÒª´¥·¢at ¿Í»§¶Ëʱ£¬·¢ËÍ×¢²áµÄreq_msg_idÏûÏ¢id¸øat_ctl,²¢ÔÚÏûÏ¢ÄÚÈÝÖÐЯ´øÏìÓ¦²ÎÊý£»at_ctl½ÓÊÕµ½¸ÃÏûÏ¢ºó£¬µ÷ÓÃÉÏÃæ×¢²áµÄreq_procº¯Êý£¬½«ÏûϢת»»¸øÏàÓ¦µÄatÇëÇóÃüÁ
+ at_ctlÔÚ½ÓÊÕµ½okÏìÓ¦¡¢errorÏìÓ¦¡¢Ö÷¶¯Éϱ¨/Öмä½á¹ûÉϱ¨ºó£¬»á·Ö±ðµ÷ÓÃÉÏÃæ×¢²áµÄok_act¡¢err_act¡¢auto_act´¦Àí£¬ÆäÖпͻ§¶Ë½öÖ§³ÖÒ»À´Ò»»ØµÄat½»»¥Á÷³Ì£¬Òò´Ëok_actºÍerr_actµÄ·µ»ØÖµ±ØÐëÊÇAT_END£»
+ ÔÚÀ©Õ¹at ¿Í»§¶ËµÄatÇëÇóÁ÷³Ì½áÊøÖ®ºó£¬at_ctl½«ÉÏÃæok_act/err_act´¦Àí½á¹û£¬·¢ËÍÏûÏ¢¸ø¸ÃÅäÌ×½ø³Ì/Ä£¿é£¬ÏûÏ¢idΪrsp_msg_id£¬£¬±íʾ±¾´Îat¿Í»§¶ËÁ÷³ÌÒѽáÊø£»
+
+ c¡¢ ¶ÔÓÚreq_proc´¦Àíº¯Êý£¬ÔÚ½«ÏûϢת»»atÇëÇóÃüÁîʱ£¬ÄÚ²¿±ØÐëµ÷ÓÃlibatutils¿âÖеĺ¯Êý£¬Éú³É¹Ì¶¨¸ñʽµÄatÇëÇóÃüÁ
+
+ /***************************************************************/
+ //
+ //Éú³Éat¶¯×÷ÇëÇóÃüÁî,Ò»°ãÔÚapp_clt_ops_tÖÐreq_procº¯Êýµ÷Ó㬸ù¾ÝÏûÏ¢ÄÚÈÝ£¬Éú³É×îÖÕµÄatÇëÇóÃüÁî
+ //Éú³ÉatÇëÇóÃüÁîʱ£¬±ØÐëͨ¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬
+ //×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ
+ //input: cmd "xx"
+ // param "yy,zz"
+ //output: at+xx=yy,zz\r\n
+ /***************************************************************/
+ char* at_act_build(char* cmd, char* param);
+
+
+
+ /***************************************************************/
+ //Éú³Éat²éѯÇëÇóÃüÁһ°ãÔÚapp_clt_ops_tÖÐreq_procº¯Êýµ÷Ó㬸ù¾ÝÏûÏ¢ÄÚÈÝ£¬Éú³É×îÖÕµÄatÇëÇóÃüÁî
+ //Éú³Éat²éѯÃüÁîʱ£¬Í¨¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬
+ //×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ¡£¶ÔÓÚÀ©Õ¹atµÄ²éѯÇëÇóÃüÁ½öÖ§³Öat+xx?µÄ¸ñʽ
+ //input: cmd "xx"
+ //output: at+xx? \r\n
+ /***************************************************************/
+ char* at_query_build(char* cmd);
+
+
+2¡¢À©Õ¹at ·þÎñ¶ËµÄ×¢²áºÍ´¦Àí
+ a¡¢À©Õ¹at·þÎñ¶ËµÄ×¢²á
+ 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)
+ ÆäÖÐ:
+ at_cmd_prefix±íʾÀ©Õ¹atÃüÁîǰ׺
+ module_id ±íʾģ¿éID£¬at_ctlÓ¦ÓÃÔÚ½ÓÊÕµ½×¢²áÀ©Õ¹atÃüÁîºó£¬·¢ËÍÏûÏ¢¸ø¸ÃÄ£¿é£»¸ÃÄ£¿éid±ØÐëÔÚmessage.hÖж¨Òå
+ req_msg_id ±íʾÇëÇóÏûÏ¢id£¬at_ctlÓ¦ÓÃÔÚ½ÓÊÕµ½×¢²áÀ©Õ¹atÃüÁîºó£¬ÔÚ·¢ËÍÏûÏ¢¸ømodule_idʱµÄÏûÏ¢id£¬±ØÐëÔÚlibatext¿âÖеÄext_regist.hÖж¨Ò壻
+ rsp_msg_id ±íʾÏìÓ¦ÏûÏ¢id£¬Ä£¿émodule_idÔÚ´¦ÀíÍêÉÏÃæµÄÇëÇóÏûÏ¢ºó£¬·¢ËÍÏûÏ¢idΪrsp_msg_idµÄÏûÏ¢¸øat_ctl£¬Í¨Öª´¦Àí½á¹û£»±ØÐëÓëreq_msg_idÔÚlibatext¿âÖеÄext_regist.hÖÐÒ»Æð¶¨Òå
+ req_rcv_act ×¢²áµÄ½ÓÊÕµ½À©Õ¹atÃüÁî´¦Àíº¯Êý£¬ÔÚat_ctl½ÓÊÕµ½À©Õ¹atÃüÁîºó£¬»áµ÷Óøô¦Àíº¯Êý£¬²¢½«´¦Àí½á¹û·¢Ë͸øÄ£¿émodule_id£¬ÏûÏ¢idΪreq_msg_id£»
+ rsp_act ×¢²áµÄ½ÓÊÕµ½Ä£¿émodule_idµÄÏìÓ¦ÏûÏ¢rsp_msg_idºó£¬µ÷Óøô¦Àíº¯Êý£¬´¦ÀíÏìÓ¦ÏûÏ¢£¬×ª»»ÎªatÏìÓ¦ÃüÁ
+
+ b¡¢at_ctlÓ¦ÓÃÔÚ½ÓÊÕµ½ÉÏÃæ×¢²áµÄÀ©Õ¹atÃüÁîºó£¬µ÷ÓÃ×¢²áµÄreq_rcv_act´¦Àíº¯Êý£¬½«À©Õ¹atÃüÁîת»»ÎªÏûÏ¢¸ñʽ£¬²¢·¢Ë͸øÄ£¿émodule_id£¬ÏûÏ¢idΪע²áµÄreq_msg_id£»Ä£¿émodule_idÔÚ´¦ÀíÍê¸ÃÏûÏ¢ºó£¬
+ ·¢ËÍÏìÓ¦ÏûÏ¢¸øat_ctlÓ¦Óã¬ÏûÏ¢idΪע²áµÄrsp_msg_id£¬at_ctlÔÚ½ÓÊÕµ½ÏìÓ¦ÏûÏ¢ºó£¬µ÷ÓÃrsp_act£¬½«ÏìÓ¦ÏûÏ¢£¬×ª»»ÎªatÏìÓ¦ÃüÁ
+
+ c¡¢¶ÔÓÚrsp_act´¦Àíº¯Êý£¬½«ÏìÓ¦ÏûϢת»»¸øatÏìÓ¦ÃüÁîʱ£¬ÄÚ²¿±ØÐëµ÷ÓÃlibatutils¿âÖеĺ¯Êý£¬Éú³É¹Ì¶¨¸ñʽµÄatÏìÓ¦ÃüÁ
+ /***************************************************************/
+ //Éú³Éat²éѯÇëÇóÃüÁîµÄÏìÓ¦ÃüÁµ±ÓÐÖмä½á¹ûÉϱ¨Ê±£¬ÔÚser_ops_tµÄrsp_actµ÷Óã¬
+ //¸Ãº¯ÊýÖн«ÖмäÉϱ¨½á¹ûºÍokatÃüÁî×é×°ÔÚÒ»Æð£¬Í¨¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø
+ //¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ
+ //input: cmd "xx"
+ // param "yy,zz"
+ //output: \r\n+xx:yy,zz\r\n
+ /***************************************************************/
+ char* at_query_result_build(char* cmd, char* param);
+
+ /***************************************************************/
+ //Éú³ÉatµÄokÏìÓ¦ÃüÁ¸ù¾Ý²ÎÊýÐÅÏ¢Éú³É²»Í¬µÄokÏìÓ¦ÃüÁî
+ //ͨ¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ
+ //output: \r\nok:xx
+ /***************************************************************/
+ char* at_ok_build();
+
+
+ /***************************************************************/
+ //Éú³ÉatµÄerrÏìÓ¦ÃüÁ¸ù¾Ý²ÎÊýÐÅÏ¢Éú³É²»Í¬µÄerrÏìÓ¦ÃüÁî
+ //ͨ¹ýmallocÉêÇëʹÓõÄÄڴ棬²¢·µ»Ø¸ÃÖ¸Õë¸øÍâ²ãµ÷Óú¯ÊýʹÓã¬×îÖÕÓÉÍâ²ãµ÷Óú¯ÊýÊͷŸÃÄÚ´æ
+ //input: param xx
+ //output: \r\nerr:xx
+ /***************************************************************/
+ char* at_err_build(int param);
+
+