Merge "[Feature][S300][task-view-1920][app] add S300V2 BJMTN plmn dial lock base"
diff --git a/lynq/R306_MTN/BJMTN/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin b/lynq/R306_MTN/BJMTN/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
index c621e92..3df3efc 100755
--- a/lynq/R306_MTN/BJMTN/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
+++ b/lynq/R306_MTN/BJMTN/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
Binary files differ
diff --git a/lynq/S300/BJMTN/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user b/lynq/S300/BJMTN/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
index 5b4331a..e98ba8c 100755
--- a/lynq/S300/BJMTN/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/lynq/S300/BJMTN/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -501,3 +501,10 @@
 fsfota_server_url=ftp://ftp:ftp123456@183.67.24.178:6521/FOTA/fsfota
 #for fsfota end
 SSIDbak=
+#for apparms begin
+arms_task_id=
+arms_device_id=
+arms_device_sec=
+arms_device_md5=
+arms_fota_version=
+#for apparms end
\ No newline at end of file
diff --git a/lynq/S300/ap/app/apparms/Makefile b/lynq/S300/ap/app/apparms/Makefile
new file mode 100755
index 0000000..9390829
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/Makefile
@@ -0,0 +1,219 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(zte_app_mak)
+include $(COMMON_MK)
+
+CURRENT_DIR = $(shell pwd)/
+
+#TARGET BOARD OPTIONS: EXAMPLE
+TARGET_BOARD = EXAMPLE
+#FOTA OPTIONS: NONE, HTTP, HTTPS
+TARGET_FOTA = HTTP
+#DM OPTIONS: NONE, UDP, MQTTTLS, MQTTTCP
+TARGET_DM = MQTTTCP
+#handle data in another application
+TARGET_DM_RPC = TRUE
+#RPC loop back test
+TARGET_DM_RPC_TEST = TRUE
+#JSON-C LIB
+SUPPORT_LIBJSOC_PC = TRUE
+#DYNAMIC ARGV
+SUPPORT_ARGV = TRUE
+
+#FOTA
+ifeq ($(TARGET_FOTA),HTTP)
+SUPPORT_FOTA = TRUE
+FOTA_PROTOCAL = HTTP
+SUPPORT_TCP = TRUE
+endif
+ifeq ($(TARGET_FOTA),HTTPS)
+SUPPORT_FOTA = TRUE
+FOTA_PROTOCAL = HTTPS
+SUPPORT_MQNET = TRUE
+SUPPORT_TLS = TRUE
+SUPPORT_TCP = TRUE
+endif
+
+#DM
+ifeq ($(TARGET_DM),UDP)
+SUPPORT_DM = TRUE
+DM_PROTOCAL = UDP
+endif
+ifeq ($(TARGET_DM),MQTTTCP)
+SUPPORT_DM = TRUE
+DM_PROTOCAL = MQTT
+SUPPORT_TCP = TRUE
+SUPPORT_MQNET = TRUE
+endif
+ifeq ($(TARGET_DM),MQTTTLS)
+SUPPORT_DM = TRUE
+DM_PROTOCAL = MQTT
+SUPPORT_MQNET = TRUE
+SUPPORT_TLS = TRUE
+endif
+
+ARMSLIB = log algo list util argv
+objects = apparms.o apparms_loop.o apparms_config_os.o apparms_data_os.o apparms_sock.o apparms_json.o
+
+CFLAGS += -g -Wall -Werror -I$(CURRENT_DIR)algo -I$(CURRENT_DIR)list -I$(CURRENT_DIR)argv -I$(CURRENT_DIR)log -I$(CURRENT_DIR)util -I/.
+LDFLAGS += -L$(CURRENT_DIR)argv -lapparmsargv -L$(CURRENT_DIR)algo -lapparmsalgo -L$(CURRENT_DIR)list -lapparmslist -L$(CURRENT_DIR)log -lapparmslog -L$(CURRENT_DIR)util -lapparmsutil -lpthread -lrt
+
+# target board
+ifeq ($(TARGET_BOARD),EXAMPLE)
+objects += apparms_config_example.o apparms_data_example.o 
+APPARMS_DEFS += -DARMS_BOARD_EXAMPLE -DEXAMPLE_REF_VALUE
+endif
+
+
+# FOTA option
+ifeq ($(SUPPORT_FOTA),TRUE)
+APPARMS_DEFS += -DARMS_SUPPORT_FOTA -DARMS_FOTA_HTTP -DARMS_FOTA_CHECK_INTERVAL_VIA_TIMER
+objects += apparms_fota.o
+endif
+
+ifeq ($(FOTA_PROTOCAL),HTTPS)
+APPARMS_DEFS += -DARMS_FOTA_HTTPS
+endif
+
+# DM option
+ifeq ($(SUPPORT_DM),TRUE)
+APPARMS_DEFS += -DARMS_SUPPORT_DM -DARMS_DM_ATRACS -DARMS_DM_REPORT_INTERVAL_VIA_TIMER
+objects += apparms_dm.o apparms_atracs.o
+endif
+
+# DM RPC option
+ifeq ($(TARGET_DM_RPC),TRUE)
+objects += apparms_dmrpc.o
+APPARMS_DEFS += -DARMS_DM_RPC
+endif
+
+# MQTT
+ifeq ($(DM_PROTOCAL),MQTT)
+ARMSLIB += mqtt
+APPARMS_DEFS += -DARMS_DM_MQTT
+CFLAGS += -I$(CURRENT_DIR)mqtt -I$(CURRENT_DIR)mqtt/inc -I$(CURRENT_DIR)mqtt/common
+LDFLAGS += -L$(CURRENT_DIR)mqtt -lapparmsmqtt
+endif
+
+# MQNET option
+ifeq ($(SUPPORT_MQNET),TRUE)
+ARMSLIB += mqnet
+CFLAGS += -I$(CURRENT_DIR)mqnet
+LDFLAGS += -L$(CURRENT_DIR)mqnet -lapparmsmqnet
+endif
+
+# TLS option
+ifeq ($(SUPPORT_TLS),TRUE)
+ARMSLIB += mbedTLS
+APPARMS_DEFS += -DARMS_AUTH_X509
+CFLAGS += -I$(CURRENT_DIR)mbedTLS/include
+LDFLAGS += -L$(CURRENT_DIR)mbedTLS/library -lmbedtls -lmbedcrypto -lmbedx509
+endif
+
+# TCP option
+ifeq ($(SUPPORT_TCP),TRUE)
+ARMSLIB += sock
+CFLAGS += -I$(CURRENT_DIR)sock
+LDFLAGS += -L$(CURRENT_DIR)sock -lapparmstcp
+endif
+
+# UDP 
+ifeq ($(DM_PROTOCAL),UDP)
+ARMSLIB += sock
+APPARMS_DEFS += -DARMS_DM_UDP
+CFLAGS += -I$(CURRENT_DIR)sock
+LDFLAGS += -L$(CURRENT_DIR)sock -lapparmsudp
+endif
+
+# UNIX
+ifeq ($(TARGET_DM_RPC),TRUE)
+ARMSLIB += sock
+CFLAGS += -I$(CURRENT_DIR)sock
+LDFLAGS += -L$(CURRENT_DIR)sock -lapparmsunix
+endif
+
+# ARGV option
+ifeq ($(SUPPORT_ARGV),TRUE)
+APPARMS_DEFS += -DARMS_SUPPORT_ARGV
+ifeq ($(SUPPORT_TEST_MULTIPLE),TRUE)
+APPARMS_DEFS += -DARMS_SUPPORT_TEST_MULTI_INSTANCE
+endif
+endif
+
+ifeq ($(TARGET_DM_RPC_TEST),TRUE)
+ARMSLIB += ipatc
+CFLAGS += -I$(CURRENT_DIR)ipatc
+RPCTESTLDFLAGS += -L$(CURRENT_DIR)ipatc -lapparmsipatc 
+RPCTESTLDFLAGS += -L$(CURRENT_DIR)sock -lapparmstcp 
+RPCTESTLDFLAGS += -L$(CURRENT_DIR)sock -lapparmsunix
+RPCTESTLDFLAGS += -L$(CURRENT_DIR)log -lapparmslog -lpthread -lrt
+RPCTESTOBJ = apparms_dmrpc_test.o
+RPCTESTAPP = apprpctest
+else
+RPCTESTAPP =
+endif
+
+SRC_LIBJSON_C = $(CURRENT_DIR)json-c
+ifeq ($(SUPPORT_LIBJSOC_PC),TRUE)
+LIBJSON = libjson
+APPARMS_DEFS += -DSUPPORT_LIBJSOC_PC
+CFLAGS += -I$(SRC_LIBJSON_C) -I$(SRC_LIBJSON_C)/build
+JSONCLDFLAGS = -L$(SRC_LIBJSON_C)/build -ljson-c
+else
+LIBJSON = 
+endif
+
+CFLAGS += $(APPARMS_DEFS)
+CFLAGS += -I$(zte_lib_path)/libnvram
+
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram
+
+all:clean apparms $(RPCTESTAPP) $(SPEEDTESTAPP) $(NETSPEEDTESTAPP)
+
+libjson:
+	@for dir in $(ARMSLIB);do\
+		make -C $$dir APPARMS_DEFS="$(APPARMS_DEFS)" SUPPORT_TLS="$(SUPPORT_TLS)" || exit $?;\
+	done
+	if [ ! -e $(SRC_LIBJSON_C)/Makefile ]; then \
+		cd $(SRC_LIBJSON_C); \
+		mkdir build ; \
+		cd build ; \
+		cmake -DBUILD_SHARED_LIBS=OFF ../; \
+		make ; \
+		#sudo make install; \
+	fi
+	@echo "compile $(SRC_LIBJSON_C) completed"
+
+libjson_clean:
+	if [ -e $(SRC_LIBJSON_C)/Makefile ]; then \
+		cd $(SRC_LIBJSON_C) && make clean;\
+	fi
+	if [ -e $(SRC_LIBJSON_C)/build ]; then \
+		rm -rf $(SRC_LIBJSON_C)/build;\
+	fi
+
+
+
+$(RPCTESTAPP): $(RPCTESTOBJ)
+	$(CC) $(CFLAGS) -o $(RPCTESTAPP) $(RPCTESTOBJ) $(LDLIBS) $(EXTRA_CFLAGS) $(RPCTESTLDFLAGS) $(JSONCLDFLAGS) 
+
+libarms: $(LIBJSON)
+	#@for dir in $(ARMSLIB);do\
+	#	make -C $$dir APPARMS_DEFS="$(APPARMS_DEFS)" SUPPORT_TLS="$(SUPPORT_TLS)" || exit $?;\
+	#done
+
+apparms: libarms $(objects)
+	$(CC) $(CFLAGS) -o apparms $(objects) $(LDLIBS) $(EXTRA_CFLAGS) $(LDFLAGS) $(JSONCLDFLAGS) 
+
+romfs:
+	$(ROMFSINST)  /sbin/apparms
+
+libarms_clean: libjson_clean 
+	@for dir in $(ARMSLIB);do\
+		make -C $$dir clean || exit $?;\
+	done
+
+clean: libarms_clean
+	-rm $(objects) $(objectscli) $(RPCTESTOBJ) $(RPCTESTAPP) apparms 
+
diff --git a/lynq/S300/ap/app/apparms/algo/Makefile b/lynq/S300/ap/app/apparms/algo/Makefile
new file mode 100755
index 0000000..c4791ec
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/Makefile
@@ -0,0 +1,14 @@
+
+LOG_STATIC_LIB = libapparmsalgo.a
+LOG_LIB_OBJS = apparms_sha256.o apparms_hmac_sha256.o apparms_md5.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g
+
+all: $(LOG_STATIC_LIB)
+
+$(LOG_STATIC_LIB): $(LOG_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(LOG_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.c b/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.c
new file mode 100755
index 0000000..d899f38
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.c
@@ -0,0 +1,139 @@
+

+#include "apparms_hmac_sha256.h"

+

+/* Filler bytes: */

+#define IPAD_BYTE	0x36

+#define OPAD_BYTE	0x5c

+#define ZERO_BYTE	0x00

+

+void arms_hmac_sha256_init(HMAC_SHA256_CTX *ctx) {

+	memset(&(ctx->key[0]), ZERO_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	memset(&(ctx->ipad[0]), IPAD_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	memset(&(ctx->opad[0]), OPAD_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	ctx->keylen = 0;

+	ctx->hashkey = 0;

+}

+

+void arms_hmac_sha256_update_key(HMAC_SHA256_CTX *ctx, const unsigned char *key, unsigned int keylen) {

+

+	/* Do we have anything to work with?  If not, return right away. */

+	if (keylen < 1)

+		return;

+

+	/*

+	 * Is the total key length (current data and any previous data)

+	 * longer than the hash block length?

+	 */

+	if (ctx->hashkey !=0 || (keylen + ctx->keylen) > HMAC_SHA256_BLOCK_LENGTH) {

+		/*

+		 * Looks like the key data exceeds the hash block length,

+		 * so that means we use a hash of the key as the key data

+		 * instead.

+		 */

+		if (ctx->hashkey == 0) {

+			/*

+			 * Ah, we haven't started hashing the key

+			 * data yet, so we must init. the hash

+			 * monster to begin feeding it.

+			 */

+

+			/* Set the hash key flag to true (non-zero) */

+			ctx->hashkey = 1;

+

+			/* Init. the hash beastie... */

+			arms_sha256_init(&ctx->shactx);

+

+			/* If there's any previous key data, use it */

+			if (ctx->keylen > 0) {

+				arms_sha256_update(&ctx->shactx, &(ctx->key[0]), ctx->keylen);

+			}

+

+			/*

+			 * Reset the key length to the future true

+			 * key length, HMAC_SHA256_DIGEST_LENGTH

+			 */

+			ctx->keylen = HMAC_SHA256_DIGEST_LENGTH;

+		}

+		/* Now feed the latest key data to the has monster */

+		arms_sha256_update(&ctx->shactx, key, keylen);

+	} else {

+		/*

+		 * Key data length hasn't yet exceeded the hash

+		 * block length (HMAC_SHA256_BLOCK_LENGTH), so theres

+		 * no need to hash the key data (yet).  Copy it

+		 * into the key buffer.

+		 */

+		memcpy(&(ctx->key[ctx->keylen]), key, keylen);

+		ctx->keylen += keylen;

+	}

+}

+

+void arms_hmac_sha256_end_key(HMAC_SHA256_CTX *ctx) {

+	unsigned char	*ipad, *opad, *key;

+	unsigned int	i;

+

+	/* Did we end up hashing the key? */

+	if (ctx->hashkey) {

+		memset(&(ctx->key[0]), ZERO_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+		/* Yes, so finish up and copy the key data */

+		arms_sha256_final(&ctx->shactx,&(ctx->key[0]));

+		/* ctx->keylen was already set correctly */

+	}

+	/* Pad the key if necessary with zero bytes */

+	if ((i = HMAC_SHA256_BLOCK_LENGTH - ctx->keylen) > 0) {

+		memset(&(ctx->key[ctx->keylen]), ZERO_BYTE, i);

+	}

+

+	ipad = &(ctx->ipad[0]);

+	opad = &(ctx->opad[0]);

+

+	/* Precompute the respective pads XORed with the key */

+	key = &(ctx->key[0]);

+	for (i = 0; i < ctx->keylen; i++, key++) {

+		/* XOR the key byte with the appropriate pad filler byte */

+		*ipad++ ^= *key;

+		*opad++ ^= *key;

+	}

+}

+

+void arms_hmac_sha256_start_msg(HMAC_SHA256_CTX *ctx) {

+	arms_sha256_init(&ctx->shactx);

+	arms_sha256_update(&ctx->shactx, &(ctx->ipad[0]), HMAC_SHA256_BLOCK_LENGTH);

+}

+

+void arms_hmac_sha256_update_msg(HMAC_SHA256_CTX *ctx, const unsigned char *data, unsigned int datalen) {

+	arms_sha256_update(&ctx->shactx, data, datalen);

+}

+

+void arms_hmac_sha256_end_msg(unsigned char *out, HMAC_SHA256_CTX *ctx) {

+	unsigned char	buf[HMAC_SHA256_DIGEST_LENGTH];

+	SHA256_CTX		*c = &ctx->shactx;

+

+	arms_sha256_final(c, &(buf[0]));

+	arms_sha256_init(c);

+	arms_sha256_update(c, &(ctx->opad[0]), HMAC_SHA256_BLOCK_LENGTH);

+	arms_sha256_update(c, buf, HMAC_SHA256_DIGEST_LENGTH);

+	arms_sha256_final(c, out);

+}

+

+void arms_hmac_sha256_done(HMAC_SHA256_CTX *ctx) {

+	/* Just to be safe, toast all context data */

+	memset(&(ctx->ipad[0]), ZERO_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	memset(&(ctx->ipad[0]), ZERO_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	memset(&(ctx->key[0]), ZERO_BYTE, HMAC_SHA256_BLOCK_LENGTH);

+	ctx->keylen = 0;

+	ctx->hashkey = 0;

+} 

+

+void arms_hmac_sha256_encypt(unsigned char *enkey,unsigned int keylen,unsigned char *encdata,unsigned int datalen,unsigned char *output)

+{

+	HMAC_SHA256_CTX ctx;

+	arms_hmac_sha256_init(&ctx);

+	arms_hmac_sha256_update_key(&ctx,enkey,keylen);

+	arms_hmac_sha256_end_key(&ctx);

+	arms_hmac_sha256_start_msg(&ctx);

+	arms_hmac_sha256_update_msg(&ctx,encdata,datalen);

+	arms_hmac_sha256_end_msg(output,&ctx);

+	arms_hmac_sha256_done(&ctx);

+}

+

diff --git a/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.h b/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.h
new file mode 100755
index 0000000..733078e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_hmac_sha256.h
@@ -0,0 +1,28 @@
+#ifndef APPARMS_HMAC_SHA256_H

+#define APPARMS_HMAC_SHA256_H

+

+#include "apparms_sha256.h"

+

+#define HMAC_SHA256_DIGEST_LENGTH	32

+#define HMAC_SHA256_BLOCK_LENGTH	64

+

+/* The HMAC_SHA256 structure: */

+typedef struct _HMAC_SHA256_CTX {

+	unsigned char	ipad[HMAC_SHA256_BLOCK_LENGTH];

+	unsigned char	opad[HMAC_SHA256_BLOCK_LENGTH];

+	SHA256_CTX		shactx;

+	unsigned char	key[HMAC_SHA256_BLOCK_LENGTH];

+	unsigned int	keylen;

+	unsigned int	hashkey;

+} HMAC_SHA256_CTX;

+

+void arms_hmac_sha256_init(HMAC_SHA256_CTX *ctx);

+void arms_hmac_sha256_update_key(HMAC_SHA256_CTX *ctx, const unsigned char *key, unsigned int keylen);

+void arms_hmac_sha256_end_key(HMAC_SHA256_CTX *ctx);

+void arms_hmac_sha256_start_msg(HMAC_SHA256_CTX *ctx);

+void arms_hmac_sha256_update_msg(HMAC_SHA256_CTX *ctx, const unsigned char *data, unsigned int datalen);

+void arms_hmac_sha256_end_msg(unsigned char *out, HMAC_SHA256_CTX *ctx);

+void arms_hmac_sha256_done(HMAC_SHA256_CTX *ctx);

+void arms_hmac_sha256_encypt(unsigned char *enkey,unsigned int keylen,unsigned char *encdata,unsigned int datalen,unsigned char *output);

+

+#endif

diff --git a/lynq/S300/ap/app/apparms/algo/apparms_md5.c b/lynq/S300/ap/app/apparms/algo/apparms_md5.c
new file mode 100755
index 0000000..8fef3d3
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_md5.c
@@ -0,0 +1,274 @@
+#include "apparms_md5.h"

+/*

+ * The basic MD5 functions.

+ *

+ * F and G are optimized compared to their RFC 1321 definitions for

+ * architectures that lack an AND-NOT instruction, just like in Colin Plumb's

+ * implementation.

+ */

+#define F(x, y, z)          ((z) ^ ((x) & ((y) ^ (z))))

+#define G(x, y, z)          ((y) ^ ((z) & ((x) ^ (y))))

+#define H(x, y, z)          (((x) ^ (y)) ^ (z))

+#define H2(x, y, z)         ((x) ^ ((y) ^ (z)))

+#define I(x, y, z)          ((y) ^ ((x) | ~(z)))

+

+/*

+ * The MD5 transformation for all four rounds.

+ */

+#define STEP(f, a, b, c, d, x, t, s) \

+	(a) += f((b), (c), (d)) + (x) + (t); \

+	(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \

+	(a) += (b);

+/*

+ * SET reads 4 input bytes in little-endian byte order and stores them

+ * in a properly aligned word in host byte order.

+ *

+ * The check for little-endian architectures that tolerate unaligned

+ * memory accesses is just an optimization.  Nothing will break if it

+ * doesn't work.

+ */

+#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)

+#define SET(n) \

+		(*(MD5_u32plus *)&ptr[(n) * 4])

+#define GET(n) \

+		SET(n)

+#else

+#define SET(n) \

+		(ctx->block[(n)] = \

+		(MD5_u32plus)ptr[(n) * 4] | \

+		((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \

+		((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \

+		((MD5_u32plus)ptr[(n) * 4 + 3] << 24))

+#define GET(n) \

+		(ctx->block[(n)])

+#endif

+

+/*

+ * This processes one or more 64-byte data blocks, but does NOT update

+ * the bit counters.  There are no alignment requirements.

+ */

+static const void *body(ARMS_MD5_CTX *ctx, const void *data, unsigned long size)

+{

+	const unsigned char *ptr;

+	MD5_u32plus a, b, c, d;

+	MD5_u32plus saved_a, saved_b, saved_c, saved_d;

+

+	ptr = (const unsigned char *)data;

+

+	a = ctx->a;

+	b = ctx->b;

+	c = ctx->c;

+	d = ctx->d;

+

+	do

+	{

+		saved_a = a;

+		saved_b = b;

+		saved_c = c;

+		saved_d = d;

+

+		/* Round 1 */

+		STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)

+		STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)

+		STEP(F, c, d, a, b, SET(2), 0x242070db, 17)

+		STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)

+		STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)

+		STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)

+		STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)

+		STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)

+		STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)

+		STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)

+		STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)

+		STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)

+		STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)

+		STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)

+		STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)

+		STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)

+

+		/* Round 2 */

+		STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)

+		STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)

+		STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)

+		STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)

+		STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)

+		STEP(G, d, a, b, c, GET(10), 0x02441453, 9)

+		STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)

+		STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)

+		STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)

+		STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)

+		STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)

+		STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)

+		STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)

+		STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)

+		STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)

+		STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)

+

+		/* Round 3 */

+		STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)

+		STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)

+		STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)

+		STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)

+		STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)

+		STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)

+		STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)

+		STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)

+		STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)

+		STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)

+		STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)

+		STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)

+		STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)

+		STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)

+		STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)

+		STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)

+

+		/* Round 4 */

+		STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)

+		STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)

+		STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)

+		STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)

+		STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)

+		STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)

+		STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)

+		STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)

+		STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)

+		STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)

+		STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)

+		STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)

+		STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)

+		STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)

+		STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)

+		STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)

+

+		a += saved_a;

+		b += saved_b;

+		c += saved_c;

+		d += saved_d;

+

+		ptr += 64;

+	} while (size -= 64);

+

+	ctx->a = a;

+	ctx->b = b;

+	ctx->c = c;

+	ctx->d = d;

+

+	return ptr;

+}

+

+void arms_MD5_Init(ARMS_MD5_CTX *ctx)

+{

+	ctx->a = 0x67452301;

+	ctx->b = 0xefcdab89;

+	ctx->c = 0x98badcfe;

+	ctx->d = 0x10325476;

+

+	ctx->lo = 0;

+	ctx->hi = 0;

+}

+

+void arms_MD5_Update(ARMS_MD5_CTX *ctx, const void *data, unsigned long size)

+{

+	MD5_u32plus saved_lo;

+	unsigned long used, available;

+

+	saved_lo = ctx->lo;

+

+	if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)

+	{

+		ctx->hi++;

+	}

+

+	ctx->hi += size >> 29;

+

+	used = saved_lo & 0x3f;

+

+	if (used)

+	{

+		available = 64 - used;

+

+		if (size < available)

+		{

+			memcpy(&ctx->buffer[used], data, size);

+			return;

+		}

+

+		memcpy(&ctx->buffer[used], data, available);

+		data = (const unsigned char *)data + available;

+		size -= available;

+		body(ctx, ctx->buffer, 64);

+	}

+

+	if (size >= 64)

+	{

+		data = body(ctx, data, size & ~(unsigned long)0x3f);

+		size &= 0x3f;

+	}

+

+	memcpy(ctx->buffer, data, size);

+}

+

+void arms_MD5_Final(unsigned char *result, ARMS_MD5_CTX *ctx)

+{

+	unsigned long used, available;

+

+	used = ctx->lo & 0x3f;

+

+	ctx->buffer[used++] = 0x80;

+

+	available = 64 - used;

+

+	if (available < 8)

+	{

+		memset(&ctx->buffer[used], 0, available);

+		body(ctx, ctx->buffer, 64);

+		used = 0;

+		available = 64;

+	}

+

+	memset(&ctx->buffer[used], 0, available - 8);

+

+	ctx->lo <<= 3;

+	ctx->buffer[56] = ctx->lo;

+	ctx->buffer[57] = ctx->lo >> 8;

+	ctx->buffer[58] = ctx->lo >> 16;

+	ctx->buffer[59] = ctx->lo >> 24;

+	ctx->buffer[60] = ctx->hi;

+	ctx->buffer[61] = ctx->hi >> 8;

+	ctx->buffer[62] = ctx->hi >> 16;

+	ctx->buffer[63] = ctx->hi >> 24;

+

+	body(ctx, ctx->buffer, 64);

+

+	result[0] = ctx->a;

+	result[1] = ctx->a >> 8;

+	result[2] = ctx->a >> 16;

+	result[3] = ctx->a >> 24;

+	result[4] = ctx->b;

+	result[5] = ctx->b >> 8;

+	result[6] = ctx->b >> 16;

+	result[7] = ctx->b >> 24;

+	result[8] = ctx->c;

+	result[9] = ctx->c >> 8;

+	result[10] = ctx->c >> 16;

+	result[11] = ctx->c >> 24;

+	result[12] = ctx->d;

+	result[13] = ctx->d >> 8;

+	result[14] = ctx->d >> 16;

+	result[15] = ctx->d >> 24;

+

+	memset(ctx, 0, sizeof(*ctx));

+}

+

+void arms_MD5_Encode(char *output, unsigned char *input, unsigned int len)

+{

+	unsigned int i = 0, j = 0;

+	char index[]="0123456789abcdef";

+	while (i < len)

+	{

+		output[j] = index[(input[i] & 0xF0) >> 4];

+		output[j+1] = index[input[i] & 0x0F];

+		i++;

+		j += 2;

+	}

+}

+

diff --git a/lynq/S300/ap/app/apparms/algo/apparms_md5.h b/lynq/S300/ap/app/apparms/algo/apparms_md5.h
new file mode 100755
index 0000000..9ccd414
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_md5.h
@@ -0,0 +1,33 @@
+#ifndef __APPARMS_MD5_H__

+#define __APPARMS_MD5_H__

+

+#include <string.h>

+#include <stdio.h>

+#include <stdlib.h>

+

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+/* Any 32-bit or wider unsigned integer data type will do */

+typedef unsigned int MD5_u32plus;

+

+typedef struct

+{

+	MD5_u32plus lo, hi;

+	MD5_u32plus a, b, c, d;

+	unsigned char buffer[64];

+	MD5_u32plus block[16];

+} ARMS_MD5_CTX;

+

+void arms_MD5_Init(ARMS_MD5_CTX *ctx);

+void arms_MD5_Update(ARMS_MD5_CTX *ctx, const void *data, unsigned long size);

+void arms_MD5_Final(unsigned char *result, ARMS_MD5_CTX *ctx);

+void arms_MD5_Encode(char *output, unsigned char *input, unsigned int len);

+

+#ifdef __cplusplus

+}

+#endif

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/algo/apparms_sha256.c b/lynq/S300/ap/app/apparms/algo/apparms_sha256.c
new file mode 100755
index 0000000..92313e9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_sha256.c
@@ -0,0 +1,147 @@
+
+#include "apparms_sha256.h"
+
+/****************************** MACROS ******************************/
+#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
+#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
+
+#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
+#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
+#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
+#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
+#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
+
+/**************************** VARIABLES *****************************/
+static const unsigned int k[64] = {
+	0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
+	0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
+	0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
+	0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
+	0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
+	0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
+	0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
+	0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
+};
+
+/*********************** FUNCTION DEFINITIONS ***********************/
+static void arms_sha256_transform(SHA256_CTX *ctx, const unsigned char databuf[])
+{
+	unsigned int a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
+
+	// initialization 
+	for (i = 0, j = 0; i < 16; ++i, j += 4)
+		m[i] = (databuf[j] << 24) | (databuf[j + 1] << 16) | (databuf[j + 2] << 8) | (databuf[j + 3]);
+	for ( ; i < 64; ++i)
+		m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
+
+	a = ctx->state[0];
+	b = ctx->state[1];
+	c = ctx->state[2];
+	d = ctx->state[3];
+	e = ctx->state[4];
+	f = ctx->state[5];
+	g = ctx->state[6];
+	h = ctx->state[7];
+
+	for (i = 0; i < 64; ++i) {
+		t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
+		t2 = EP0(a) + MAJ(a,b,c);
+		h = g;
+		g = f;
+		f = e;
+		e = d + t1;
+		d = c;
+		c = b;
+		b = a;
+		a = t1 + t2;
+	}
+
+	ctx->state[0] += a;
+	ctx->state[1] += b;
+	ctx->state[2] += c;
+	ctx->state[3] += d;
+	ctx->state[4] += e;
+	ctx->state[5] += f;
+	ctx->state[6] += g;
+	ctx->state[7] += h;
+}
+
+void arms_sha256_init(SHA256_CTX *ctx)
+{
+	ctx->datalen = 0;
+	ctx->bitlen = 0;
+	ctx->state[0] = 0x6a09e667;
+	ctx->state[1] = 0xbb67ae85;
+	ctx->state[2] = 0x3c6ef372;
+	ctx->state[3] = 0xa54ff53a;
+	ctx->state[4] = 0x510e527f;
+	ctx->state[5] = 0x9b05688c;
+	ctx->state[6] = 0x1f83d9ab;
+	ctx->state[7] = 0x5be0cd19;
+}
+
+void arms_sha256_update(SHA256_CTX *ctx, const unsigned char databuf[], unsigned int len)
+{
+	unsigned int i;
+
+	for (i = 0; i < len; ++i) {
+		ctx->ctxdata[ctx->datalen] = databuf[i];
+		ctx->datalen++;
+		if (ctx->datalen == 64) {
+			// 64 byte = 512 bit  means the buffer ctx->data has fully stored one chunk of message
+			// so do the sha256 hash map for the current chunk
+			arms_sha256_transform(ctx, ctx->ctxdata);
+			ctx->bitlen += 512;
+			ctx->datalen = 0;
+		}
+	}
+}
+
+void arms_sha256_final(SHA256_CTX *ctx, unsigned char hash[])
+{
+	unsigned int i;
+
+	i = ctx->datalen;
+
+	// Pad whatever data is left in the buffer.
+	if (ctx->datalen < 56) {
+		ctx->ctxdata[i++] = 0x80;  // pad 10000000 = 0x80
+		while (i < 56)
+			ctx->ctxdata[i++] = 0x00;
+	}
+	else {
+		ctx->ctxdata[i++] = 0x80;
+		while (i < 64)
+			ctx->ctxdata[i++] = 0x00;
+		arms_sha256_transform(ctx, ctx->ctxdata);
+		memset(ctx->ctxdata, 0, 56);
+	}
+
+	// Append to the padding the total message's length in bits and transform.
+	ctx->bitlen += ctx->datalen * 8;
+	ctx->ctxdata[63] = (ctx->bitlen) & 0xFF;
+	ctx->ctxdata[62] = (ctx->bitlen >> 8) & 0xFF;
+	ctx->ctxdata[61] = (ctx->bitlen >> 16) & 0xFF;
+	ctx->ctxdata[60] = (ctx->bitlen >> 24) & 0xFF;
+	ctx->ctxdata[59] = (ctx->bitlen >> 32) & 0xFF;
+	ctx->ctxdata[58] = (ctx->bitlen >> 40) & 0xFF;
+	ctx->ctxdata[57] = (ctx->bitlen >> 48) & 0xFF;
+	ctx->ctxdata[56] = (ctx->bitlen >> 56) & 0xFF;
+	arms_sha256_transform(ctx, ctx->ctxdata);
+
+	// copying the final state to the output hash(use big endian).
+	for (i = 0; i < 4; ++i) {
+		hash[i]      = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 4]  = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 8]  = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff;
+		hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
+	}
+
+}
+
+
diff --git a/lynq/S300/ap/app/apparms/algo/apparms_sha256.h b/lynq/S300/ap/app/apparms/algo/apparms_sha256.h
new file mode 100755
index 0000000..78c7e28
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/algo/apparms_sha256.h
@@ -0,0 +1,21 @@
+#ifndef APPARMS_SHA256_H
+#define APPARMS_SHA256_H
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
+
+typedef struct {
+	unsigned char ctxdata[64];  // current 512-bit chunk of message data, just like a buffer
+	unsigned int datalen;   // sign the data length of current chunk
+	unsigned long long bitlen;  // the bit length of the total message
+	unsigned int state[8];  // store the middle state of hash abstract
+} SHA256_CTX;
+
+void arms_sha256_init(SHA256_CTX *ctx);
+void arms_sha256_update(SHA256_CTX *ctx, const unsigned char data[], unsigned int len);
+void arms_sha256_final(SHA256_CTX *ctx, unsigned char hash[]);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms.c b/lynq/S300/ap/app/apparms/apparms.c
new file mode 100755
index 0000000..7e16c3c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms.c
@@ -0,0 +1,342 @@
+

+#include "apparms.h"

+#include "apparms_log.h"

+#include "apparms_hmac_sha256.h"

+#include "apparms_argv.h"

+#if defined(ARMS_BOARD_EXAMPLE)

+#include "apparms_config_example.h"

+#include "apparms_data_example.h"

+#endif

+

+static APPARMS g_stARMSAPP;

+PAPPARMS GetARMSAppPointer(void)

+{

+	return &g_stARMSAPP;

+}

+

+PARMSCFGFUNLIST GetARMSAppCfgFunPointer(void)

+{

+	return g_stARMSAPP.pCfgFunList;

+}

+

+PARMSDATAFUNLIST GetARMSAppDataFunPointer(void)

+{

+	return g_stARMSAPP.pDataFunList;

+}

+

+#ifdef ARMS_SUPPORT_DM

+PARMSDM GetARMSAppDMSTPointer(void)

+{

+	return &g_stARMSAPP.stARMSDM;

+}

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+PARMSFOTA GetARMSAppFOTASTPointer(void)

+{

+	return &g_stARMSAPP.stARMSFOTA;

+}

+#endif

+

+#ifndef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER

+static void arms_signal_user_handle_usr2(int signum)

+{	

+	if (signum != SIGUSR2)

+		return;

+

+}

+#endif

+

+#ifndef ARMS_DM_REPORT_INTERVAL_VIA_TIMER

+static void arms_signal_user_handle_usr1(int signum)

+{	

+	if (signum != SIGUSR1)

+		return;

+

+}

+#endif

+

+static void arms_signal_termsignal_handle(int signum)

+{

+	PAPPARMS pARMS = GetARMSAppPointer();

+

+	if ((pARMS->stARMSLOOP.emAppStatus == APP_STATUS_INIT) || (pARMS->stARMSLOOP.emAppStatus == APP_STATUS_CHK_NETWORK))

+		exit(0);

+

+	if (pARMS->stARMSLOOP.exitflag == 1)

+		return;

+

+	#ifdef ARMS_SUPPORT_EXTIF

+	arms_extif_stop_thread(&pARMS->stARMSEXTIF);

+	#endif

+

+	#ifdef ARMS_SUPPORT_DM

+	#ifdef ARMS_DM_REPORT_INTERVAL_VIA_TIMER

+	arms_dm_stop_timer(&pARMS->stARMSDM);

+	#endif

+	arms_dm_stop_thread(&pARMS->stARMSDM);

+	#ifdef ARMS_DM_MQTT

+	arms_sock_dm_mqtt_stop_thread(&pARMS->stARMSDM.stDMSock);

+	#endif

+	#ifdef ARMS_DM_LWM2M

+	arms_sock_dm_lwm2m_stop_thread(&pARMS->stARMSDM.stDMSock);

+	#endif

+	#ifdef ARMS_DM_IPC

+	arms_dmipc_stop_timer(&pARMS->stARMSDM.stDMIPC, &pARMS->stARMSDM.stDMCfg.stIPCCfg);

+	arms_dmipc_stop_thread(&pARMS->stARMSDM.stDMIPC, &pARMS->stARMSDM.stDMCfg.stIPCCfg);

+	#endif

+	#ifdef ARMS_DM_RPC

+	arms_dmrpc_stop(&pARMS->stARMSDM.stDMRPC, &pARMS->stARMSDM.stDMCfg.stRPCCfg);

+	#endif

+	#endif

+

+	#ifdef ARMS_SUPPORT_FOTA

+	#ifdef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER

+	arms_fota_stop_timer(&pARMS->stARMSFOTA);

+	#endif

+	arms_fota_stop_thread(&pARMS->stARMSFOTA);

+	#endif

+

+	#ifdef ARMS_SUPPORT_EC2

+	arms_ec2_stop_thread(&pARMS->stARMSEC2);

+	#endif

+

+	sleep(1);

+

+	arms_loop_stop(&pARMS->stARMSLOOP);

+}

+

+static void arms_signal_handle_reg(void)

+{

+	/* configure to ignore SIGPIPE, this will cause write to fail on a closed socket (instead of receiving SIGPIPE) */ 

+	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)

+	{

+		fprintf(stderr, "can't execute signal \n");

+		//exit(1);

+	}

+

+	//SIGUSR1 and SIGUSR2 is used for DM and FOTA, ignore here.

+	#ifndef ARMS_DM_REPORT_INTERVAL_VIA_TIMER

+	signal(SIGUSR1, arms_signal_user_handle_usr1);

+	#endif

+	

+	#ifndef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER

+	signal(SIGUSR2, arms_signal_user_handle_usr2);

+	#endif

+	

+	signal(SIGTERM, arms_signal_termsignal_handle);

+	signal(SIGINT, arms_signal_termsignal_handle);

+	signal(SIGPIPE, SIG_IGN);

+}

+

+static int arms_init_phase1_imei(void)

+{

+	int ret;

+	unsigned char *pDMIMEI = NULL;

+	char szIMEI[32] = {0};

+	PAPPARMS pApp = GetARMSAppPointer();

+

+#ifdef ARMS_SUPPORT_DM

+	pDMIMEI = pApp->stARMSDM.stDMCfg.stDMCommCfg.szIMEI;

+#endif

+

+	do

+	{

+		/*start with customzied platform init*/

+		ret = arms_config_os_get_imei(pApp->pCfgFunList, pDMIMEI, (unsigned char *)szIMEI);

+		if (ret >= 0)

+		{			

+			ARMS_LOG_INFO("%s(%d) IMEI=[%s].\n",__FUNCTION__,__LINE__, szIMEI);

+			pApp->stARMSLOOP.emAppStatus = APP_STATUS_CHK_NETWORK;

+			break;

+		}

+		

+		sleep(2);

+	}while(pApp->stARMSLOOP.emAppStatus == APP_STATUS_INIT);

+

+#ifdef ARMS_SUPPORT_FOTA

+	strcpy((char *)pApp->stARMSFOTA.stFOTACfg.stFOTACommCfg.szIMEI, szIMEI);

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+	strcpy((char *)pApp->stARMSEC2.stEC2Cfg.stEC2CommCfg.szIMEI, szIMEI);

+#endif

+

+	return 0;

+}

+

+static int arms_init_phase1_get_network(void)

+{

+	int ret;

+	PAPPARMS pApp = GetARMSAppPointer();

+	do

+	{

+		/*start with customzied platform init*/

+		ret = arms_config_os_get_networkst(pApp->pCfgFunList, pApp->stARMSLOOP.szIPAddr);

+		if (ret >= 0)

+		{

+			ARMS_LOG_INFO("%s(%d) szIPAddr=[%s].\n",__FUNCTION__,__LINE__, pApp->stARMSLOOP.szIPAddr);

+			pApp->stARMSLOOP.emAppStatus = APP_STATUS_READY;

+			break;

+		}

+		

+		sleep(2);

+	}while(pApp->stARMSLOOP.emAppStatus == APP_STATUS_CHK_NETWORK);

+

+	return 0;

+}

+

+static int arms_init_phase1_cfg(void)

+{

+	PAPPARMS pApp = GetARMSAppPointer();

+	

+#ifdef ARMS_SUPPORT_DM

+	pApp->stARMSDM.pCfgFunList = g_stARMSAPP.pCfgFunList;

+	pApp->stARMSDM.pDataFunList = g_stARMSAPP.pDataFunList;

+	arms_config_os_dm_init(pApp->pCfgFunList, &pApp->stARMSDM.stDMCfg);

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+	pApp->stARMSFOTA.pCfgFunList = g_stARMSAPP.pCfgFunList;

+	pApp->stARMSFOTA.pDataFunList = g_stARMSAPP.pDataFunList;

+	arms_config_os_fota_init(pApp->pCfgFunList, &pApp->stARMSFOTA.stFOTACfg);

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+	pApp->stARMSEC2.pCfgFunList = g_stARMSAPP.pCfgFunList;

+	pApp->stARMSEC2.pDataFunList = g_stARMSAPP.pDataFunList;

+	arms_config_os_ec2_init(pApp->pCfgFunList, &pApp->stARMSEC2.stEC2Cfg);

+#endif

+

+

+	return 0;

+}

+

+static int arms_init_phase1(void)

+{

+	PAPPARMS pApp = GetARMSAppPointer();

+

+	memset(pApp, 0, sizeof(APPARMS));

+	pApp->stARMSLOOP.emAppStatus = APP_STATUS_INIT;

+

+#if defined(ARMS_BOARD_EXAMPLE)

+	g_stARMSAPP.pCfgFunList = arms_config_example_get_cfgfun_pointer();

+	g_stARMSAPP.pDataFunList = arms_data_example_get_cfgfun_pointer();

+#endif

+

+	arms_config_os_platform_init(g_stARMSAPP.pCfgFunList);

+

+	arms_init_phase1_imei();

+

+	arms_init_phase1_get_network();

+

+	arms_init_phase1_cfg();

+

+	arms_loop_init((void*)pApp);

+

+	#ifdef ARMS_SUPPORT_DM

+	arms_dm_init(pApp);

+	#endif

+

+	#ifdef ARMS_SUPPORT_FOTA

+	arms_fota_init(pApp);

+	#endif

+

+	#ifdef ARMS_SUPPORT_EC2

+	arms_ec2_init(pApp);

+	#endif

+	

+	return 0;

+}

+

+static int arms_init_phase2(void)

+{

+	PAPPARMS pApp = GetARMSAppPointer();

+	

+	#ifdef ARMS_SUPPORT_DM

+	arms_dm_start_thread(&pApp->stARMSDM);

+	#ifdef ARMS_DM_REPORT_INTERVAL_VIA_TIMER

+	arms_dm_start_timer(&pApp->stARMSDM);

+	#endif

+	#ifdef ARMS_DM_IPC

+	arms_dmipc_start_timer(&pApp->stARMSDM.stDMIPC, &pApp->stARMSDM.stDMCfg.stIPCCfg);

+	#endif

+	#ifdef ARMS_DM_RPC

+	arms_dmrpc_start(&pApp->stARMSDM.stDMRPC, &pApp->stARMSDM.stDMCfg.stRPCCfg);

+	#endif

+	#endif

+

+	#ifdef ARMS_SUPPORT_FOTA

+	arms_fota_start_thread(&pApp->stARMSFOTA);

+	#ifdef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER

+	arms_fota_start_timer(&pApp->stARMSFOTA);

+	#endif

+	#endif

+

+	#ifdef ARMS_SUPPORT_EC2

+	arms_ec2_start_thread(&pApp->stARMSEC2);

+	#endif

+

+	#ifdef ARMS_SUPPORT_EXTIF

+	arms_extif_start_thread(&pApp->stARMSEXTIF);

+	#endif

+

+	arms_signal_handle_reg();

+

+	return 0;

+}

+

+static int arms_uninit_phase1(void)

+{

+	PAPPARMS pApp = GetARMSAppPointer();

+	

+	#ifdef ARMS_SUPPORT_DM

+	arms_dm_uninit(pApp);

+	#endif

+

+	#ifdef ARMS_SUPPORT_FOTA

+	arms_fota_uninit(pApp);

+	#endif

+

+	#ifdef ARMS_SUPPORT_EC2

+	arms_ec2_uninit(pApp);

+	#endif

+

+	arms_loop_uninit(pApp);

+	arms_config_os_platform_uninit(pApp->pCfgFunList);

+	

+	return 0;

+}

+

+static int arms_uninit_phase2(void)

+{

+	

+	return 0;

+}

+

+static int arms_main(int argc, char *argv[])

+{

+	PAPPARMS pApp = GetARMSAppPointer();

+	

+	arms_init_phase1();

+	arms_init_phase2();

+

+	arms_loop_main((void*)pApp);

+

+	arms_uninit_phase2();

+	arms_uninit_phase1();

+

+	return 0;

+}

+

+int main(int argc, char *argv[])

+{

+	arms_argv_parse_cmdargs(argc, argv);

+	arms_log_open();

+	ARMS_LOG_INFO("%s(%d) apparms v%d.%d.%d.596 started.\n",__FUNCTION__,__LINE__,ARMS_VERSION_MAJOR,ARMS_VERSION_MINOR,ARMS_VERSION_PATCH);

+	arms_main(argc, argv);

+	arms_log_close();

+	

+	return 0;

+}

+

diff --git a/lynq/S300/ap/app/apparms/apparms.h b/lynq/S300/ap/app/apparms/apparms.h
new file mode 100755
index 0000000..72bf964
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms.h
@@ -0,0 +1,48 @@
+#ifndef _APPARMS_COMMON_HEAD

+#define _APPARMS_COMMON_HEAD

+

+#include "apparms_macro.h"

+#include "apparms_dm.h"

+#include "apparms_fota.h"

+#include "apparms_loop.h"

+

+typedef struct _tagAPPARMS

+{

+	PARMSCFGFUNLIST pCfgFunList;

+	PARMSDATAFUNLIST pDataFunList;

+	

+	ARMSLOOP stARMSLOOP;

+	

+#ifdef ARMS_SUPPORT_DM	

+	ARMSDM stARMSDM;

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+	ARMSFOTA stARMSFOTA;

+#endif

+

+#ifdef ARMS_SUPPORT_EXTIF

+	ARMSEXTIF stARMSEXTIF;

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+	ARMSEC2 stARMSEC2;

+#endif

+

+

+}APPARMS, *PAPPARMS;

+

+

+PAPPARMS GetARMSAppPointer(void);

+PARMSCFGFUNLIST GetARMSAppCfgFunPointer(void);

+PARMSDATAFUNLIST GetARMSAppDataFunPointer(void);

+#ifdef ARMS_SUPPORT_DM

+PARMSDM GetARMSAppDMSTPointer(void);

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+PARMSFOTA GetARMSAppFOTASTPointer(void);

+#endif

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/apparms_atracs.c b/lynq/S300/ap/app/apparms/apparms_atracs.c
new file mode 100755
index 0000000..b3c7d08
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_atracs.c
@@ -0,0 +1,589 @@
+
+#include "apparms_atracs.h"
+#include "apparms_hmac_sha256.h"
+
+#ifdef ARMS_DM_ATRACS
+
+//return 1 is LowBit mode 0 is HighBit mode
+int arms_atracs_check_high_low_bit(void)
+{
+    union w
+    {
+        int a;
+        char b;
+    }c;
+    c.a = 1;
+    return (c.b == 1);
+}
+
+int arms_atracs_get2Bytes(int bIsLowBitMode, unsigned char* pSrc, unsigned short* pDest)
+{
+    if (NULL == pSrc || NULL == pDest)
+        return 0;
+
+    *pDest = 0;
+    if (bIsLowBitMode)
+        *pDest = ((pSrc[0] & 0xFF) << 8) | (pSrc[1] & 0xFF);
+    else
+        *pDest = (pSrc[0] & 0xFF) | ((pSrc[1] & 0xFF) << 8);
+
+    return 2;
+}
+
+int arms_atracs_add2Bytes(unsigned short value, unsigned char* pDest)
+{
+    if ( NULL == pDest)
+        return 0;
+
+    *pDest++ = (value >> 8) & 0xFF;
+    *pDest++ = value & 0xFF;
+
+    return 2;
+}
+
+int arms_atracs_add1or2Bytes(unsigned short value, unsigned char* pDest)
+{
+    if (NULL == pDest)
+        return 0;
+
+    if (value < 0xE0)
+    {
+        *pDest++ = (unsigned char)value;
+        return 1;
+    }
+    else
+    {
+        *pDest++ = ((value >> 8) & 0x1F) | 0xE0;
+        *pDest++ = value >> 0 & 0xFF;
+        return 2;
+    }
+}
+
+int arms_atracs_add4Bytes(unsigned long value, unsigned char* pDest)
+{
+    if ( NULL == pDest)
+        return 0;
+
+    *pDest++ = (value >> 24) & 0xFF;
+    *pDest++ = (value >> 16) & 0xFF;
+    *pDest++ = (value >> 8) & 0xFF;
+    *pDest++ = value & 0xFF;
+
+    return 4;
+}
+
+int arms_atracs_get_report_header(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, unsigned short seq, unsigned char* pIMEI)
+{	
+	if ((pHeader == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	memset(pHeader, 0, sizeof(ATRACSHEADER));
+
+	pHeader->seq = seq;
+	pHeader->start_of_frame = REPORT_FRAME_FLAG;
+	
+	arms_data_os_get_dm_header_tag(pFunc, &pHeader->tag);
+
+	arms_util_convert_hexstr_value(pIMEI, &pHeader->sndr_id[0], 16);
+	
+	arms_data_os_get_timestamp(pFunc, &pHeader->timestamp);
+
+	arms_data_os_get_dm_header_event(pFunc, &pHeader->event);
+
+	return 0;
+}
+
+int arms_atracs_get_report_generic(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, PATRACSGENERIC pGeneric)
+{
+	if ((pHeader == NULL) || (pGeneric == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_GENERAL) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;
+
+
+	return 0;
+}
+
+
+int arms_atracs_get_report_version(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSVERSION pVersion)
+{
+	int i;
+	ARMS_DM_TLV_VER_MASK emDMTLVTmpMask;
+
+	if ((pVersion == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_VERSION) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;	
+
+	emDMTLVTmpMask = ARMS_DM_TLV_VER_MAIN | ARMS_DM_TLV_VER_EXT 
+			| ARMS_DM_TLV_VER_FW | ARMS_DM_TLV_VER_MCU
+			| ARMS_DM_TLV_VER_CONF;
+	
+	memset(pVersion, 0, sizeof(ATRACSVERSION));
+
+	if (pTLVCfg->emDMTLVVerMask & emDMTLVTmpMask)
+	{
+		int nVer[DM_VERSION_MAX_BIT] = {0};
+		DMVERSIONDATA stDMVERSIONDATA;
+
+		memset(&stDMVERSIONDATA, 0, sizeof(stDMVERSIONDATA));
+		
+		arms_data_os_get_dm_version(pFunc, &stDMVERSIONDATA);
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_MAIN)
+		{
+			sscanf((char *)stDMVERSIONDATA.main, "%d.%d.%d.%d", &nVer[0], &nVer[1], &nVer[2], &nVer[3]);
+			for (i = 0; i < DM_VERSION_MAIN_BIT; i++)
+			{
+				pVersion->main[i] = (unsigned char)nVer[i];
+			}
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_EXT)
+		{
+			nVer[0] = atoi((char*)stDMVERSIONDATA.ext);
+			arms_atracs_add2Bytes((unsigned short)nVer[0], pVersion->ext);
+		}
+		
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_FW)
+		{
+			sscanf((char *)stDMVERSIONDATA.fw, "%d.%d.%d.%d.%d", &nVer[0], &nVer[1], &nVer[2], &nVer[3], &nVer[4]);
+			
+			for (i = 0; i < DM_VERSION_FW_BIT; i++)
+			{
+				pVersion->fw[i] = (unsigned char)nVer[i];
+			}
+		}
+		
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_MCU)
+		{
+			sscanf((char *)stDMVERSIONDATA.mcu, "%d.%d.%d.%d", &nVer[0], &nVer[1], &nVer[2], &nVer[3]);
+
+			for (i = 0; i < DM_VERSION_MCU_BIT; i++)
+			{
+				pVersion->mcu[i] = (unsigned char)nVer[i];
+			}
+		}
+		
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_CONF)
+		{
+			nVer[0] = atoi((char*)stDMVERSIONDATA.cfg);
+			arms_atracs_add2Bytes((unsigned short)nVer[0], pVersion->cfg);
+		}
+	}
+
+	return 0;
+}
+
+int arms_atracs_get_report_extver_mcu(unsigned char* pDst, unsigned char* pSrc)
+{
+	int i, nVer[DM_VERSION_MAX_BIT] = {0};
+
+	if ((pDst == NULL) || (pSrc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if (strlen((char *)pSrc) <= 0)
+		return ARMS_ATRACS_STRING_LENGTH_ERROR;
+	
+	sscanf((char *)pSrc, "%d.%d.%d.%d", &nVer[0], &nVer[1], &nVer[2], &nVer[3]);
+
+	for (i = 0; i < DM_VERSION_MCU_BIT; i++)
+	{
+		pDst[i] = (unsigned char)nVer[i];
+	}
+
+	return 0;
+}
+
+int arms_atracs_get_report_extver(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSEXTVER pExtver)
+{
+	ARMS_DM_TLV_EXTVER_MASK emDMTLVTmpMask;
+
+	if ((pExtver == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_EXTVER) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;
+
+	emDMTLVTmpMask = ARMS_DM_TLV_EXTVER_MCU2 | ARMS_DM_TLV_EXTVER_MCU3 
+			| ARMS_DM_TLV_EXTVER_MCU4 | ARMS_DM_TLV_EXTVER_MCU5
+			| ARMS_DM_TLV_EXTVER_MCU6 | ARMS_DM_TLV_EXTVER_MCU7
+			| ARMS_DM_TLV_EXTVER_MCU8 | ARMS_DM_TLV_EXTVER_MCU9;
+	
+	memset(pExtver, 0, sizeof(ATRACSEXTVER));
+
+	if (pTLVCfg->emDMTLVEXTVerMask & emDMTLVTmpMask)
+	{	
+		DMEXTVERDATA stDMEXTVERDATA;
+		memset(&stDMEXTVERDATA, 0, sizeof(stDMEXTVERDATA));
+		arms_data_os_get_dm_extver(pFunc, &stDMEXTVERDATA);
+
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU2)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu2, stDMEXTVERDATA.mcu2);
+		}
+
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU3)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu3, stDMEXTVERDATA.mcu3);
+		}
+
+	
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU4)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu4, stDMEXTVERDATA.mcu4);
+		}
+
+		
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU5)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu5, stDMEXTVERDATA.mcu5);
+		}
+
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU6)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu6, stDMEXTVERDATA.mcu6);
+		}
+
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU7)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu7, stDMEXTVERDATA.mcu7);
+		}		
+
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU8)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu8, stDMEXTVERDATA.mcu8);
+		}
+		
+		if (pTLVCfg->emDMTLVEXTVerMask & ARMS_DM_TLV_EXTVER_MCU9)
+		{
+			arms_atracs_get_report_extver_mcu(pExtver->mcu9, stDMEXTVERDATA.mcu9);
+		}
+	}
+
+	return 0;
+}
+
+int arms_atracs_get_report_token(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, unsigned char* pToken, unsigned char* szKey)
+{
+	unsigned char encdata[12] = {0};	//SNDR_ID:8-BYTE TIMESTAMP:4-BYTE
+	unsigned char encoutput[32] = {0};
+	int nOffset = 0;
+		
+	if ((pHeader == NULL) || (pToken == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_TOKEN) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;
+
+	memcpy(encdata, pHeader->sndr_id, 8);
+	arms_atracs_add4Bytes(pHeader->timestamp, encdata + 8);
+
+	arms_hmac_sha256_encypt(szKey, strlen((char*)szKey), encdata, 12, encoutput);
+
+	nOffset = encoutput[31] & 0x0F;
+
+	memcpy(pToken, encoutput + nOffset, 4);
+
+	return 0;
+}
+
+int arms_atracs_get_report_dmreport(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSDMREPORT pDMreport)
+{
+	
+	if ((pDMreport == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_DMREPORT) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;
+
+	return 0;
+}
+
+int arms_atracs_get_report_cusdata(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, unsigned char index, PATRACSCUSDATA pCusData)
+{
+	unsigned char szData[ATRACS_CUSDATA_DATA_LEN * 2 + 20] = {0};
+	int nTmpLen = 0, dataLen = 0;
+	if ((pCusData == NULL) || (pTLVCfg == NULL) || (pFunc == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if ((pTLVCfg->emDMTLVMask & (ARMS_DM_TLV_COMM_CUSDATA1<<index)) == 0)
+		return ARMS_ATRACS_TLV_MASK_OFF_ERROR;
+
+	memset(pCusData, 0, sizeof(ATRACSCUSDATA));
+	arms_data_os_get_dm_cusdata(pFunc, index, &nTmpLen, szData);
+
+	if(nTmpLen > ATRACS_CUSDATA_DATA_LEN)
+		pCusData->len = ATRACS_CUSDATA_DATA_LEN;
+	else
+		pCusData->len = (unsigned char)nTmpLen;
+
+#if 1
+	dataLen = pCusData->len;
+	memset(pCusData->data, 0xFF, sizeof(pCusData->data));
+	memcpy(pCusData->data, szData, dataLen);
+#else
+	dataLen = strlen((char*)szData);
+	memset(pCusData->data, 0xFF, sizeof(pCusData->data));
+	if (dataLen % 2 == 0)
+		arms_util_convert_hexstr_value(szData, pCusData->data, dataLen);
+#endif
+	return 0;
+}
+
+int arms_atracs_get_push_response(PATRACSDMDMPUSHRSP pRspData, unsigned char *pPushCont, int nPushLen)
+{
+	if ((pRspData == NULL) || (pPushCont == NULL) || (nPushLen <= 0))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+
+	if (nPushLen > ATRACS_PUSH_RSP_MAX_SIZE)
+		return ARMS_ATRACS_PUSH_RSP_LENGTH_ERROR;
+
+	memcpy(pRspData->pushrsp_ext, pPushCont, nPushLen);
+	pRspData->pushrsp_len = nPushLen;
+
+	return 0;
+}
+
+int arms_atracs_get_report_notifcation(PATRACSDMNTFY pDstNtf, PATRACSDMNTFY pSrcNtf)
+{	
+	if ((pDstNtf == NULL) || (pSrcNtf == NULL))
+		return ARMS_ATRACS_POINT_NULL_ERROR;
+	
+	memcpy(pDstNtf, pSrcNtf, sizeof(ATRACSDMNTFY));
+	
+	return 0;
+}
+
+int arms_atracs_construct_report_data(PDMCOMMCFG pCommCfg, PDMTLVCFG pTLVCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize)
+{
+	unsigned char szTLVValue[ATRACS_TLV_MAX_SIZE] = {0};
+	int nDataLen = 0;	//construct payload length
+	unsigned short lenTLVValue = 0;	//length of the TLV <value> field
+	unsigned char *pLengthPos = NULL;
+	unsigned char *pTLVPos = NULL;
+	unsigned char *p = NULL;
+	int i = 0;
+	//PDMTLVCFG pTLVCfg = &pDMCfg->stDMTLVCfg;
+	//PDMCOMMCFG pCommCfg = &pDMCfg->stDMCommCfg;
+
+	//memset(pARMSDM->stDMSock.dmsocksend.szSendBuf, 0, sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf));
+	p = pSendBuf;
+	
+	*p++ = pAtracsData->stAtracsHeader.start_of_frame;
+	*p++ = pAtracsData->stAtracsHeader.tag;
+	memcpy(p, pAtracsData->stAtracsHeader.sndr_id, 8);
+	p += 8;
+	p += arms_atracs_add2Bytes(pAtracsData->stAtracsHeader.seq, p);
+	p += arms_atracs_add4Bytes(pAtracsData->stAtracsHeader.timestamp, p);
+	p += arms_atracs_add1or2Bytes(pAtracsData->stAtracsHeader.event, p);
+
+	//Reserve 2 byte for payload length(1 or 2 byte)
+	pLengthPos = p;
+	p += 2;
+	
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_GENERAL)
+	{
+		
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_VERSION)
+	{
+		PATRACSVERSION pVersion = &pAtracsData->stAtracsVersion;
+
+		memset(szTLVValue, 0, sizeof(szTLVValue));
+		pTLVPos = szTLVValue;
+
+		*pTLVPos++ = pTLVCfg->emDMTLVVerMask;
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_HID)
+		{
+			//memcpy(pTLVPos, pVersion->hid, 3);
+			//pTLVPos += 3;
+			*pTLVPos++ = ((pCommCfg->unHWId) >> 16) & 0xFF;
+			*pTLVPos++ = ((pCommCfg->unHWId) >> 8) & 0xFF;
+			*pTLVPos++ = (pCommCfg->unHWId) & 0xFF;
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_MAIN)
+		{
+			memcpy(pTLVPos, pVersion->main, DM_VERSION_MAIN_BIT);
+			pTLVPos += DM_VERSION_MAIN_BIT;
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_EXT)
+		{
+			memcpy(pTLVPos, pVersion->ext, DM_VERSION_EXT_BIT);
+			pTLVPos += DM_VERSION_EXT_BIT;
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_FW)
+		{
+			memcpy(pTLVPos, pVersion->fw, DM_VERSION_FW_BIT);
+			pTLVPos += DM_VERSION_FW_BIT;
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_MCU)
+		{
+			memcpy(pTLVPos, pVersion->mcu, DM_VERSION_MCU_BIT);
+			pTLVPos += DM_VERSION_MCU_BIT;
+		}
+
+		if (pTLVCfg->emDMTLVVerMask & ARMS_DM_TLV_VER_CONF)
+		{
+			memcpy(pTLVPos, pVersion->cfg, DM_VERSION_CFG_BIT);
+			pTLVPos += DM_VERSION_CFG_BIT;
+		}
+
+		lenTLVValue = (pTLVPos - szTLVValue) & 0xFFFF;
+		
+		pTLVPos = p;
+		p += arms_atracs_add1or2Bytes((unsigned short)ATRACS_TLV_VER, p);
+		p += arms_atracs_add1or2Bytes(lenTLVValue, p);
+		memcpy(p, szTLVValue, lenTLVValue);
+		p += lenTLVValue;
+
+		nDataLen += (p - pTLVPos);
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_EXTVER)
+	{
+		
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_TOKEN)
+	{
+		unsigned char *pToken = pAtracsData->token;
+		
+		pTLVPos = p;
+		p += arms_atracs_add1or2Bytes((unsigned short)ATRACS_TLV_TOKEN, p);
+		*p++ = 4;	//4-bytte field
+		memcpy(p, pToken, 4);
+		p += 4;
+
+		nDataLen += (p - pTLVPos);
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_DMREPORT)
+	{
+		
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_WARNMSG)
+	{
+		
+	}
+
+	for(i = 0; i < ATRACS_CUSDATA_TYPE_NUM; i++)
+	{
+		if(pTLVCfg->emDMTLVMask & (ARMS_DM_TLV_COMM_CUSDATA1 << i))
+		{
+			PATRACSCUSDATA pCusData = &pAtracsData->stAtracsCusData[i];
+
+			pTLVPos = p;
+			p += arms_atracs_add1or2Bytes((unsigned short)((ATRACS_TLV_CUSDATA1 + i) & 0xFFFF), p);
+			p += arms_atracs_add1or2Bytes((unsigned short)(pCusData->len & 0xFF), p);
+			memcpy(p, pCusData->data, pCusData->len);
+			p += pCusData->len;
+
+			nDataLen += (p - pTLVPos);
+		}
+	}
+
+	if(pTLVCfg->emDMTLVMask & ARMS_DM_TLV_COMM_RSPMSG)
+	{
+		PATRACSDMDMPUSHRSP pDMPushRsp = &pAtracsData->stAtracsPushRsp;
+
+		memset(szTLVValue, 0, sizeof(szTLVValue));
+		pTLVPos = szTLVValue;
+
+		for (i = 0; i < pDMPushRsp->pushrsp_len; i++)
+			*pTLVPos++ = pDMPushRsp->pushrsp_ext[i];
+
+		lenTLVValue = (pTLVPos - szTLVValue) & 0xFFFF;
+		
+		pTLVPos = p;
+		p += arms_atracs_add1or2Bytes((unsigned short)ATRACS_TLV_PUSHMSGRSP, p);
+		p += arms_atracs_add1or2Bytes(lenTLVValue, p);
+		memcpy(p, szTLVValue, lenTLVValue);
+		p += lenTLVValue;
+
+		nDataLen += (p - pTLVPos);
+	}
+
+	i = arms_atracs_add1or2Bytes(nDataLen, pLengthPos);
+	if(1 == i)
+	{
+		//The payload length only occupies 1 byte(reserved 2 byte), so the data moves forward 1 byte.
+		memmove(pLengthPos+1, (pLengthPos+2), nDataLen);
+		*(pLengthPos + 1 + nDataLen) = 0;
+	}
+
+	*nSendSize = (pLengthPos - pSendBuf) + i + nDataLen;
+	
+	return 0;
+}
+
+int arms_atracs_construct_report_telemetry(PDMCFG pDMCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize)
+{
+	PDMCOMMCFG pCommCfg = &pDMCfg->stDMCommCfg;
+	PDMTLVCFG pTLVCfg = &pDMCfg->stDMTLVCfg;
+	
+	return arms_atracs_construct_report_data(pCommCfg,pTLVCfg,pAtracsData,pSendBuf,nSendSize);
+}
+
+int arms_atracs_construct_report_notifcation_msg(PDMCFG pDMCfg, PATRACSDATA pAtracsData,unsigned char* pSendBuf, int* nSendSize)
+{
+	PDMCOMMCFG pCommCfg = &pDMCfg->stDMCommCfg;
+	PDMTLVCFG pTLVCfg = &pDMCfg->stDMNtfyTLVCfg;
+	
+	return arms_atracs_construct_report_data(pCommCfg,pTLVCfg,pAtracsData,pSendBuf,nSendSize);
+}
+
+int arms_atracs_construct_push_response_msg(PDMCFG pDMCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize)
+{
+	PDMCOMMCFG pCommCfg = &pDMCfg->stDMCommCfg;
+	PDMTLVCFG pTLVCfg = &pDMCfg->stDMPushRspTLVCfg;
+	
+	return arms_atracs_construct_report_data(pCommCfg,pTLVCfg,pAtracsData,pSendBuf,nSendSize);
+}
+
+ATRACSRPTACKTYPE arms_atracs_parse_report_ack_type(unsigned char* pDataIN,int *pDataINSize)
+{
+	unsigned char* pIN = pDataIN;
+	int bIsLowBitMode = arms_atracs_check_high_low_bit();
+	unsigned short ackLen = 0;
+	unsigned char ackType = 0;
+	ATRACSRPTACKTYPE ret = ATRACS_RPT_ACK_MAX;
+
+	if (NULL == pDataIN || NULL == pDataINSize)
+		return ret;
+
+	if (ACK_FRAME_FLAG == *pIN)
+	{
+		pIN++;	//ACK_FRAME_FLAG
+
+		pIN += arms_atracs_get2Bytes(bIsLowBitMode, pIN, &ackLen);
+		ackType = *pIN++;
+		pIN++; //tag
+		pIN = pIN - 2 + ackLen;	//Skip to the end of ACK_FRAME, 2: 1-byte ackType + 1-byte tag
+
+		*pDataINSize = *pDataINSize - (pIN - pDataIN);
+
+		if ((ATRACS_RPT_ACK_FOTA <= ackType && ATRACS_RPT_ACK_UNKNOWN_ERROR >= ackType) || ATRACS_RPT_ACK_OK == ackType)
+		{
+			ret = ackType;
+		}
+	}
+	else 
+	{
+		ret = ATRACS_RPT_ACK_CUSTOMIZED;
+		*pDataINSize = 0;
+	}
+
+	return ret;
+}
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_atracs.h b/lynq/S300/ap/app/apparms/apparms_atracs.h
new file mode 100755
index 0000000..c939c69
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_atracs.h
@@ -0,0 +1,220 @@
+
+#ifndef _APPARMS_ATRACS
+#define _APPARMS_ATRACS 1
+
+#include "apparms_macro.h"
+#include "apparms_config_os.h"
+#include "apparms_data_os.h"
+#include "apparms_util.h"
+
+#ifdef ARMS_DM_ATRACS
+#define REPORT_FRAME_FLAG 0x7D
+#define ACK_FRAME_FLAG    0x7E
+
+#define ATRACS_NBCELL_TYPE_NUM 3
+#define ATRACS_CUSDATA_TYPE_NUM 10
+#define ATRACS_CUSDATA_DATA_LEN 255
+
+#define ATRACS_NTY_EVT_BUF_SIZE 255
+#define ATRACS_NTY_WARN_TEXT_SIZE 255
+
+#define ATRACS_PUSH_RSP_MAX_SIZE (2*1024)
+#define ATRACS_TLV_MAX_SIZE (2*1024)
+
+
+typedef enum _tagATRACSTLV
+{
+    ATRACS_TLV_GENERAL = 0x00,   //General: The recommended report for most of the events
+    ATRACS_TLV_NW = 0x11,    //Network: A maskable collection of cellular network status parameters. Mostly useful for troubleshooting.
+    ATRACS_TLV_GEOFENCE = 0x42,   //Geofence Type: Geofence Enter/Exit event
+    ATRACS_TLV_VER = 0x104,  //Versions: Versions of the different product s/w and h/w components
+    ATRACS_TLV_FILETST = 0x200,   //File Transfer Status
+    ATRACS_TLV_DMEXTVER = 0x600,    //DM Extended Version
+    ATRACS_TLV_EXTPRODID,    //Extended Product ID
+    ATRACS_TLV_TOKEN,    //Token: Contains the registration content
+    ATRACS_TLV_DMREPORT,    //DM Report Data
+    ATRACS_TLV_NOTIFICATION,    //Notification Data: This data is used for Phone APP
+    ATRACS_TLV_CUSDATA1,    //Custom Data
+    ATRACS_TLV_CUSDATA2,
+    ATRACS_TLV_CUSDATA3,
+    ATRACS_TLV_CUSDATA4,
+    ATRACS_TLV_CUSDATA5,
+    ATRACS_TLV_CUSDATA6,
+    ATRACS_TLV_CUSDATA7,
+    ATRACS_TLV_CUSDATA8,
+    ATRACS_TLV_CUSDATA9,
+    ATRACS_TLV_CUSDATA10,
+    ATRACS_TLV_PUSHMSGRSP = 0x620,
+
+    ATRACS_TLV_MAX = 0xFFFF
+}ATRACSTLV;
+
+typedef enum _tagATRACSRPTACKTYPE
+{
+    ATRACS_RPT_ACK_FOTA = 0xA0,
+    ATRACS_RPT_ACK_SRV_DECODE_ERROR,
+    ATRACS_RPT_ACK_DEVICE_DISABLED,
+    ATRACS_RPT_ACK_AUTH_FAIL,
+    ATRACS_RPT_ACK_SRV_REJECT,
+    ATRACS_RPT_ACK_RPT_OVERFLOW,
+    ATRACS_RPT_ACK_SRV_REG_ERROR,
+    ATRACS_RPT_ACK_SRV_CACHE_ERROR,
+    ATRACS_RPT_ACK_UNKNOWN_ERROR,
+
+    ATRACS_RPT_ACK_OK = 0xE0,
+
+    ATRACS_RPT_ACK_CUSTOMIZED = 0xF0,
+
+    ATRACS_RPT_ACK_MAX = 0xFF
+}ATRACSRPTACKTYPE;
+
+typedef struct _tagATRACSHEADER
+{
+    unsigned char start_of_frame;
+    unsigned char tag;
+    unsigned char sndr_id[8];
+    unsigned short seq;
+    unsigned long timestamp;
+    unsigned short event;
+}ATRACSHEADER, *PATRACSHEADER;
+
+typedef struct _tagATRACSGENERIC
+{
+    unsigned char pid;
+    unsigned long gps_time;
+    unsigned long gps_lat;
+    unsigned long gps_lon;
+    unsigned char gps_speed;
+    unsigned short gps_heading;
+    short gps_altitude;
+    unsigned short gps_accuracy;
+    unsigned short main_voltage;
+    unsigned short batt_voltage;
+    unsigned short aux_voltage;
+    unsigned short solar_voltage;
+	
+    unsigned char roaming_srvtype;
+    unsigned short nw_mcc;
+    unsigned short nw_mnc;
+    char nw_rssi;
+    unsigned char gpio_ad;
+    unsigned char gpio_eh;
+    unsigned long odometer;
+    short temperature;
+    unsigned char battery_percentage;
+    unsigned short battery_charge;	
+}ATRACSGENERIC, *PATRACSGENERIC;
+
+typedef struct _tagATRACSEXTPID
+{
+    unsigned char hpid;
+    unsigned char lpid;
+}ATRACSEXTPID, *PATRACSEXTPID;
+
+typedef struct _tagATRACSVERSION
+{
+    unsigned char hid[3];
+    unsigned char main[4];	//major.middle.minor.build
+    unsigned char ext[2];
+    unsigned char fw[5];  //type.major.middle.minor.build
+    unsigned char mcu[4];	//major.middle.minor.build
+    unsigned char cfg[2];
+}ATRACSVERSION, *PATRACSVERSION;
+
+typedef struct _tagATRACSEXTVER
+{
+    unsigned char mcu2[4];
+    unsigned char mcu3[4];
+    unsigned char mcu4[4];
+    unsigned char mcu5[4];
+    unsigned char mcu6[4];
+    unsigned char mcu7[4];
+    unsigned char mcu8[4];
+    unsigned char mcu9[4];	
+}ATRACSEXTVER, *PATRACSEXTVER;
+
+typedef struct _tagATRACSDMREPORTNECGI
+{
+    unsigned short nb_mcc;
+    unsigned short nb_mnc;
+    unsigned long nb_eci;
+    unsigned char nb_rssi;
+}ATRACSDMREPORTNECGI, *PATRACSDMREPORTNECGI;
+
+typedef struct _tagATRACSDMREPORT
+{
+    unsigned long lightlux;
+    unsigned short lightontime;
+    unsigned short lightofftime;
+    unsigned short lightdurationtime;	
+    unsigned char mdn[10];
+    unsigned char iccid[10];
+    unsigned char macaddr[6];
+    unsigned short mcc;
+    unsigned short mnc;
+    unsigned long eci;
+    ATRACSDMREPORTNECGI nbcell[ATRACS_NBCELL_TYPE_NUM];
+}ATRACSDMREPORT, *PATRACSDMREPORT;
+
+typedef struct _tagATRACSDMNOTIFCATION
+{
+    unsigned short evt_type;
+    unsigned char evt_len;
+    unsigned char evt_content[ATRACS_NTY_EVT_BUF_SIZE];
+	
+    unsigned char warn_text[ATRACS_NTY_WARN_TEXT_SIZE];
+    int warn_len;
+}ATRACSDMNTFY, *PATRACSDMNTFY;
+
+typedef struct _tagATRACSCUSDATA
+{
+    unsigned char len;
+    unsigned char data[ATRACS_CUSDATA_DATA_LEN];
+}ATRACSCUSDATA, *PATRACSCUSDATA;
+
+typedef struct _tagATRACSDMPUSHRSP
+{
+    unsigned char pushrsp_ext[ATRACS_PUSH_RSP_MAX_SIZE];
+    int pushrsp_len;
+}ATRACSDMDMPUSHRSP, *PATRACSDMDMPUSHRSP;
+
+typedef struct _tagATRACSDATA
+{
+    ATRACSHEADER stAtracsHeader;
+    ATRACSGENERIC stAtracsGen;
+    ATRACSEXTPID stAtracsExtPid;
+    ATRACSVERSION stAtracsVersion;
+    ATRACSEXTVER stAtracsExtver;
+    ATRACSDMREPORT stAtracsDMReport;
+    unsigned char token[4];
+    ATRACSCUSDATA stAtracsCusData[ATRACS_CUSDATA_TYPE_NUM];
+
+    ATRACSDMNTFY stAtracsNtfy;
+    ATRACSDMDMPUSHRSP stAtracsPushRsp;
+}ATRACSDATA, *PATRACSDATA;
+
+int arms_atracs_check_high_low_bit(void);
+int arms_atracs_get2Bytes(int bIsLowBitMode, unsigned char* pSrc, unsigned short* pDest);
+int arms_atracs_add2Bytes(unsigned short value, unsigned char* pDest);
+int arms_atracs_add1or2Bytes(unsigned short value, unsigned char* pDest);
+int arms_atracs_add4Bytes(unsigned long value, unsigned char* pDest);
+
+int arms_atracs_get_report_header(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, unsigned short seq, unsigned char* pIMEI);
+int arms_atracs_get_report_generic(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, PATRACSGENERIC pGeneric);
+int arms_atracs_get_report_version(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSVERSION pVersion);
+int arms_atracs_get_report_extver(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSEXTVER pExtver);
+int arms_atracs_get_report_token(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSHEADER pHeader, unsigned char* pToken, unsigned char* szKey);
+int arms_atracs_get_report_dmreport(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, PATRACSDMREPORT pDMreport);
+int arms_atracs_get_report_cusdata(PARMSDATAFUNLIST pFunc, PDMTLVCFG pTLVCfg, unsigned char index, PATRACSCUSDATA pCusData);
+int arms_atracs_construct_report_telemetry(PDMCFG pDMCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize);
+
+int arms_atracs_get_push_response(PATRACSDMDMPUSHRSP pRspData, unsigned char *pPushCont, int nPushLen);
+int arms_atracs_construct_push_response_msg(PDMCFG pDMCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize);
+
+int arms_atracs_get_report_notifcation(PATRACSDMNTFY pDstNtf, PATRACSDMNTFY pSrcNtf);
+int arms_atracs_construct_report_notifcation_msg(PDMCFG pDMCfg, PATRACSDATA pAtracsData, unsigned char* pSendBuf, int* nSendSize);
+
+ATRACSRPTACKTYPE arms_atracs_parse_report_ack_type(unsigned char* pDataIN,int *pDataINSize);
+
+#endif
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_config_example.c b/lynq/S300/ap/app/apparms/apparms_config_example.c
new file mode 100755
index 0000000..097738a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_config_example.c
@@ -0,0 +1,456 @@
+#include "apparms_config_example.h"

+#include "apparms_util.h"

+

+#ifdef ARMS_SUPPORT_ARGV

+#include "apparms_argv.h"

+#endif

+

+#ifdef ARMS_BOARD_EXAMPLE

+

+static ARMSCFGFUNLIST arms_example_cfgfun_pointer =

+{

+	arms_config_example_get_imei,

+	arms_config_example_get_sn,

+	arms_config_example_get_networkst,

+	

+#ifdef ARMS_SUPPORT_DM

+	arms_config_example_get_dm_mode_cfg,

+	arms_config_example_get_dm_tlv_cfg,

+	arms_config_example_get_dm_push_rsp_tlv_cfg,

+	arms_config_example_get_dm_notification_tlv_cfg,

+#ifdef ARMS_DM_UDP

+	arms_config_example_get_dm_udp_cfg,

+#endif

+#ifdef ARMS_DM_MQTT

+	arms_config_example_get_dm_mqtt_cfg,

+#endif

+#ifdef ARMS_DM_LWM2M

+	arms_config_example_get_dm_lwm2m_cfg,

+#endif

+#ifdef ARMS_DM_IPC

+	arms_config_example_get_dm_ipc_cfg,

+#endif

+#ifdef ARMS_DM_RPC

+	arms_config_example_get_dm_rpc_cfg,

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+#ifdef ARMS_FOTA_HTTP	

+	arms_config_example_get_http_cfg,

+#endif	

+	arms_config_example_get_fota_mode_cfg,

+	arms_config_example_get_fota_tlv_cfg,

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+	arms_config_example_get_ec2_cfg,

+#endif

+

+	arms_config_example_init,

+	arms_config_example_uninit

+};

+

+PARMSCFGFUNLIST arms_config_example_get_cfgfun_pointer(void)

+{

+	return &arms_example_cfgfun_pointer;

+}

+

+int arms_config_example_get_imei(unsigned char *pDMIMEI, unsigned char* pIMEI)

+{

+	char szIMEI[32] = {0};

+#if 0

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_imei(szIMEI, sizeof(szIMEI)) <= 0)

+	#endif

+	{

+		#if defined(ARMS_DM_MQTT)

+			#ifdef ARMS_AUTH_X509

+			strcpy(szIMEI, "920000000000051");

+			#else

+			strcpy(szIMEI, "990000000000053");

+			#endif

+		#elif defined(ARMS_DM_LWM2M)

+			strcpy(szIMEI, "930000000000151");

+		#else

+			strcpy(szIMEI, "998199055256418");

+		#endif

+	}

+#endif

+	cfg_get_item("imei", szIMEI, sizeof(szIMEI));

+	printf("****arms_config_example_get_imei imei=[%s]\n", szIMEI);

+	if (pDMIMEI != NULL)

+	{

+		strcpy((char *)pDMIMEI, "0");

+		strcat((char *)pDMIMEI, szIMEI);

+	}

+

+	if (pIMEI != NULL)

+	{

+		strcpy((char *)pIMEI, szIMEI);

+	}

+

+	return 0;

+}

+

+int arms_config_example_get_sn(unsigned char *pSN)

+{

+	char szSN[32] = {0};

+

+	strcpy(szSN, "123456789012345");

+

+	if (pSN != NULL)

+	{

+		strcpy((char *)pSN, szSN);

+	}

+

+	return 0;

+}

+

+int arms_config_example_get_networkst(char *pIPAddr)

+{

+	int ret = -3;

+	char buf[32] = {0};

+	char wan_ipaddr[32] = {0};

+	

+	if (pIPAddr == NULL)

+		return -1;

+#if 0

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_intf(szIntf, sizeof(szIntf)) <= 0)

+	#endif

+	{

+		strcpy(szIntf, ARMS_DM_WAN_IF);

+	}

+

+	ret = arms_util_get_if_ip(szIntf, pIPAddr);

+	if ((ret >= 0) && (strcmp(pIPAddr, "0.0.0.0") == 0))

+	{

+		ret = -3;

+	}

+	

+#endif

+	cfg_get_item("ppp_status", buf, sizeof(buf));

+	if (0 == strcmp(buf, "ppp_connected"))

+	{

+		cfg_get_item("wan_ipaddr", wan_ipaddr, sizeof(wan_ipaddr));

+		strcpy(pIPAddr, wan_ipaddr);

+		ret = 0;

+	}

+

+	return ret;

+}

+

+int arms_config_example_init(void)

+{

+	return 0;

+}

+

+int arms_config_example_uninit(void)

+{

+	return 0;

+}

+

+

+#ifdef ARMS_SUPPORT_DM

+int arms_config_example_get_dm_mode_cfg(PDMCOMMCFG pDMCommCfg)

+{

+	if (pDMCommCfg == NULL)

+		return -1;	

+

+#if defined(ARMS_DM_MQTT)

+	pDMCommCfg->emCommMode = ARMS_DM_COMM_MQTT;

+	#ifdef ARMS_AUTH_X509

+		pDMCommCfg->emAuthMode = ARMS_DM_AUTH_CERT;

+	#else

+		pDMCommCfg->emAuthMode = ARMS_DM_AUTH_KEY;

+	#endif

+#elif defined(ARMS_DM_LWM2M)

+	pDMCommCfg->emCommMode = ARMS_DM_COMM_LWM2M;

+#else

+	pDMCommCfg->emCommMode = ARMS_DM_COMM_UDP;

+#endif

+

+	pDMCommCfg->nReportPeriod = ARMS_DM_REPORT_INTERVAL; //Report DM telemetry for every 60 seconds

+

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_dm(&pDMCommCfg->unHWId, (char *)pDMCommCfg->szKey, sizeof(pDMCommCfg->szKey)) <= 0)

+	#endif

+	{

+		#if defined(ARMS_DM_MQTT)

+			#ifdef ARMS_AUTH_X509

+				pDMCommCfg->unHWId = 5168;

+				strcpy((char *)pDMCommCfg->szKey, "feb3aed743e74f45b718de349f0774e1");

+			#else

+				pDMCommCfg->unHWId = ARMS_DM_ACCESS_ID_MQTT;

+				strcpy((char *)pDMCommCfg->szKey, ARMS_DM_ACCESS_PW_MQTT);

+			#endif

+		#elif defined(ARMS_DM_LWM2M)

+			pDMCommCfg->unHWId = ARMS_DM_ACCESS_ID_LWM2M;

+			strcpy((char *)pDMCommCfg->szKey, ARMS_DM_ACCESS_PW_LWM2M);

+		#else

+			pDMCommCfg->unHWId = ARMS_DM_ACCESS_ID_UDP;

+			strcpy((char *)pDMCommCfg->szKey, ARMS_DM_ACCESS_PW_UDP);

+		#endif

+	}

+

+	return 0;

+}

+

+int arms_config_example_get_dm_tlv_cfg(PDMTLVCFG pDMTLVCfg)

+{

+	if (pDMTLVCfg == NULL)

+		return -1;

+	

+	//pDMTLVCfg->emDMTLVMask = 0xFFFFF & ~ARMS_DM_TLV_COMM_RSPMSG & ~ARMS_DM_TLV_COMM_WARNMSG;

+	pDMTLVCfg->emDMTLVMask = ARMS_DM_TLV_COMM_VERSION | ARMS_DM_TLV_COMM_TOKEN; 

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA1; //SW Ver

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA2; //Inner Ver

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA3; //RSRP

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA4; //RSRQ

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA5; //RSSI

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA6; //SINR

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA7; //Carrier

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA8; //GCI

+

+	pDMTLVCfg->emDMTLVGenMask = 0x1FFFF;

+	pDMTLVCfg->emDMTLVVerMask = ARMS_DM_TLV_VER_HID | ARMS_DM_TLV_VER_MCU;

+	pDMTLVCfg->emDMTLVEXTVerMask = ARMS_DM_TLV_EXTVER_MCU2;

+	pDMTLVCfg->emDMTLVDMReportMask = 0x7F;

+

+	return 0;	

+}

+

+int arms_config_example_get_dm_push_rsp_tlv_cfg(PDMTLVCFG pDMTLVCfg)

+{

+	if (pDMTLVCfg == NULL)

+		return -1;

+

+	pDMTLVCfg->emDMTLVMask = ARMS_DM_TLV_COMM_VERSION | ARMS_DM_TLV_COMM_TOKEN | ARMS_DM_TLV_COMM_RSPMSG;

+	pDMTLVCfg->emDMTLVGenMask = 0x00000;

+	pDMTLVCfg->emDMTLVVerMask = ARMS_DM_TLV_VER_HID;

+	pDMTLVCfg->emDMTLVEXTVerMask = 0x00;

+	pDMTLVCfg->emDMTLVDMReportMask = 0x00;

+	

+	return 0;	

+}

+

+int arms_config_example_get_dm_notification_tlv_cfg(PDMTLVCFG pDMTLVCfg)

+{

+	if (pDMTLVCfg == NULL)

+		return -1;

+	

+	pDMTLVCfg->emDMTLVMask = ARMS_DM_TLV_COMM_VERSION | ARMS_DM_TLV_COMM_TOKEN | ARMS_DM_TLV_COMM_WARNMSG;

+

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA1; //SW Ver

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA2; //Inner Ver

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA3; //RSRP

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA4; //RSRQ

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA5; //RSSI

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA6; //SINR

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA7; //Carrier

+	pDMTLVCfg->emDMTLVMask |= ARMS_DM_TLV_COMM_CUSDATA8; //GCI

+

+	pDMTLVCfg->emDMTLVGenMask = 0x00000;

+	pDMTLVCfg->emDMTLVVerMask = ARMS_DM_TLV_VER_HID;

+	pDMTLVCfg->emDMTLVEXTVerMask = 0x00;

+	pDMTLVCfg->emDMTLVDMReportMask = 0x00;

+

+	return 0;	

+}

+

+#ifdef ARMS_DM_UDP

+int arms_config_example_get_dm_udp_cfg(PUDPCFG pUDPCfg)

+{

+	if (pUDPCfg == NULL)

+		return -1;

+

+	pUDPCfg->nUDPPort = 9000;

+

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_udp_url(pUDPCfg->szUDPAddr, sizeof(pUDPCfg->szUDPAddr)) <= 0)

+	#endif

+	{

+		strcpy(pUDPCfg->szUDPAddr, ARMS_DM_SRV_UDP_ADDR);

+	}

+	

+	return 0;	

+}

+#endif

+

+#ifdef ARMS_DM_MQTT

+int arms_config_example_get_dm_mqtt_cfg(PMQTTCFG pMQTTCfg,PDMCOMMCFG pDMCommCfg)

+{

+	unsigned char *p = NULL;

+	if (pMQTTCfg == NULL)

+		return -1;

+

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_mqtt_url(pMQTTCfg->szMQTTAddr, sizeof(pMQTTCfg->szMQTTAddr)) <= 0)

+	#endif

+	{

+		strcpy(pMQTTCfg->szMQTTAddr,ARMS_DM_SRV_MQTT_ADDR);

+	}

+

+	pMQTTCfg->nMQTTLiveTM = 180;

+#ifdef ARMS_AUTH_X509

+	pMQTTCfg->nMQTTPort = 8099;

+#else

+	pMQTTCfg->nMQTTPort = 8089;

+#endif

+	p = pDMCommCfg->szIMEI + 1;

+	sprintf(pMQTTCfg->szUserName,"%ld_%s",pDMCommCfg->unHWId,p);

+#ifdef ARMS_AUTH_X509

+	strcpy(pMQTTCfg->szPassWord,"123456");

+	strcpy(pMQTTCfg->szCaCert,"./certs/ca-cert.pem");

+	strcpy(pMQTTCfg->szClientCert,"./certs/client-cert.pem");

+	strcpy(pMQTTCfg->szClientKey,"./certs/client-key.pem");

+#else

+	strcpy(pMQTTCfg->szPassWord,(char *)pDMCommCfg->szKey);

+#endif

+

+	return 0;	

+}

+#endif

+

+#ifdef ARMS_DM_LWM2M

+int arms_config_example_get_dm_lwm2m_cfg(PLWM2MCFG pLWM2MCfg,PDMCOMMCFG pDMCommCfg)

+{

+	unsigned char *p = NULL;

+	if (pLWM2MCfg == NULL)

+		return -1;

+

+	

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_lwm2m_url(pLWM2MCfg->szLwM2MAddr, sizeof(pLWM2MCfg->szLwM2MAddr)) <= 0)

+	#endif

+	{

+		strcpy(pLWM2MCfg->szLwM2MAddr,ARMS_DM_SRV_LWM2M_ADDR);

+	}

+

+	pLWM2MCfg->nLwM2MPort = 5683;

+	p = pDMCommCfg->szIMEI + 1;

+	sprintf(pLWM2MCfg->szEndpointName,"%s",p);

+

+	return 0;	

+}

+#endif

+

+#ifdef ARMS_DM_IPC

+int arms_config_example_get_dm_ipc_cfg(PDMIPCCFG pIPCCfg)

+{

+	memset(pIPCCfg, 0, sizeof(DMIPCCFG));

+	pIPCCfg->enable = 1;

+	strcpy(pIPCCfg->intf[0], ARMS_DM_WAN_IF);

+	pIPCCfg->nPort = ARMS_DM_IPC_LISTEN_PORT;

+	pIPCCfg->uMaxclient = ARMS_DM_IPC_MAX_CLIENT;

+	pIPCCfg->mtimeout = ARMS_DM_IPC_CLOSE_TIME;

+	pIPCCfg->bUnixMode = 0;

+	pIPCCfg->bDynamicOpen = 1;

+	

+	return 0;

+}

+#endif

+

+#ifdef ARMS_DM_RPC

+int arms_config_example_get_dm_rpc_cfg(PDMRPCCFG pRPCCfg)

+{

+	memset(pRPCCfg, 0, sizeof(DMRPCCFG));

+	pRPCCfg->bRPC = 1;

+	#ifdef ARMS_DM_RPC_UNX_MODE

+	pRPCCfg->bRPCUnixMode = 1;

+	strcpy(pRPCCfg->szRPCUnix, ARMS_DM_RPC_UNIX_PATH);

+	#else

+	pRPCCfg->bRPCUnixMode = 0;

+	strcpy(pRPCCfg->szRPCTCPSrv, "127.0.0.1");

+	pRPCCfg->nRPCTCPPort = ARMS_DM_RPC_TCP_PORT;

+	#endif

+

+	pRPCCfg->mRPCTimeout = 300*1000;

+	

+	return 0;

+}

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_config_example_get_fota_mode_cfg(PFOTACOMMCFG pFOTACommCfg)

+{

+	if (pFOTACommCfg == NULL)

+		return -1;	

+

+#if defined(ARMS_FOTA_HTTP)

+	pFOTACommCfg->emCommMode = ARMS_FOTA_COMM_HTTP_HTTPS;

+#endif

+

+	pFOTACommCfg->nCheckPeriod = ARMS_FOTA_CHECK_INTERVAL; //Check fota for every 30 seconds

+

+	return 0;

+}

+

+int arms_config_example_get_fota_tlv_cfg(PFOTATLVCFG pFOTATLVCfg)

+{

+	if (pFOTATLVCfg == NULL)

+		return -1;

+

+

+	return 0;	

+}

+

+

+#ifdef ARMS_FOTA_HTTP

+int arms_config_example_get_http_cfg(PHTTPCFG pHTTPCfg)

+{

+	if (pHTTPCfg == NULL)

+		return -1;

+	

+#ifdef ARMS_FOTA_HTTPS

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_fota_url(1, pHTTPCfg->szAddr, sizeof(pHTTPCfg->szAddr)) <= 0)

+	#endif

+	{

+		strcpy(pHTTPCfg->szAddr,ARMS_FOTA_SRV_HTTPS_ADDR);

+	}

+	pHTTPCfg->nPort = 443;

+#else

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_fota_url(0, pHTTPCfg->szAddr, sizeof(pHTTPCfg->szAddr)) <= 0)

+	#endif

+	{

+		strcpy(pHTTPCfg->szAddr,ARMS_FOTA_SRV_HTTP_ADDR);

+	}

+	pHTTPCfg->nPort = 80;

+#endif	

+	strcpy(pHTTPCfg->szDownFilePath,ARMS_FOTA_DOWNLOAD_PATH);

+

+	#ifdef ARMS_SUPPORT_ARGV

+	if (arms_argv_get_fota(pHTTPCfg->szProdID, sizeof(pHTTPCfg->szProdID), 

+								pHTTPCfg->szPassword, sizeof(pHTTPCfg->szPassword)) <= 0)

+	#endif

+	{

+		strcpy(pHTTPCfg->szProdID,ARMS_FOTA_ACCESS_ID);

+		strcpy(pHTTPCfg->szPassword,ARMS_FOTA_ACCESS_PW);

+	}

+

+	return 0;	

+}

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+int arms_config_example_get_ec2_cfg(PEC2CFG pEC2Cfg)

+{

+	if (pEC2Cfg == NULL)

+		return -1;	

+

+	strcpy(pEC2Cfg->stHttpCfg.szAddr,ARMS_EC2_SRV_HTTP_ADDR);

+	pEC2Cfg->stHttpCfg.nPort = 80;

+	sprintf(pEC2Cfg->stHttpCfg.szProdID,"%d",ARMS_EC2_ACCESS_ID);

+	strcpy(pEC2Cfg->szHttpRspPath,ARMS_EC2_HTTP_RSP_PATH);

+

+	return 0;

+}

+#endif

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/apparms_config_example.h b/lynq/S300/ap/app/apparms/apparms_config_example.h
new file mode 100755
index 0000000..69f87bd
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_config_example.h
@@ -0,0 +1,56 @@
+#ifndef _APPARMS_CONFIG_EXAMPLE_HEAD

+#define _APPARMS_CONFIG_EXAMPLE_HEAD

+

+#include "apparms_config_os.h"

+#include "apparms_config_example_srv.h"

+

+#ifdef ARMS_BOARD_EXAMPLE

+PARMSCFGFUNLIST arms_config_example_get_cfgfun_pointer(void);

+int arms_config_example_get_imei(unsigned char *pDMIMEI, unsigned char* pIMEI);

+int arms_config_example_get_sn(unsigned char* pSN);

+int arms_config_example_get_networkst(char *pIPAddr);

+int arms_config_example_init(void);

+int arms_config_example_uninit(void);

+

+

+#ifdef ARMS_SUPPORT_DM

+int arms_config_example_get_dm_mode_cfg(PDMCOMMCFG pDMCommCfg);

+int arms_config_example_get_dm_tlv_cfg(PDMTLVCFG pDMTLVCfg);

+int arms_config_example_get_dm_push_rsp_tlv_cfg(PDMTLVCFG pDMTLVCfg);

+int arms_config_example_get_dm_notification_tlv_cfg(PDMTLVCFG pDMTLVCfg);

+

+#ifdef ARMS_DM_UDP

+int arms_config_example_get_dm_udp_cfg(PUDPCFG pUDPCfg);

+#endif

+

+#ifdef ARMS_DM_MQTT

+int arms_config_example_get_dm_mqtt_cfg(PMQTTCFG pMQTTCfg,PDMCOMMCFG pDMCommCfg);

+#endif

+

+#ifdef ARMS_DM_LWM2M

+int arms_config_example_get_dm_lwm2m_cfg(PLWM2MCFG pLWM2MCfg,PDMCOMMCFG pDMCommCfg);

+#endif

+

+#ifdef ARMS_DM_IPC

+int arms_config_example_get_dm_ipc_cfg(PDMIPCCFG pIPCCfg);

+#endif

+

+#ifdef ARMS_DM_RPC

+int arms_config_example_get_dm_rpc_cfg(PDMRPCCFG pRPCCfg);

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_config_example_get_fota_mode_cfg(PFOTACOMMCFG pFOTACommCfg);

+int arms_config_example_get_fota_tlv_cfg(PFOTATLVCFG pFOTATLVCfg);

+#ifdef ARMS_FOTA_HTTP

+int arms_config_example_get_http_cfg(PHTTPCFG pHTTPCfg);

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+int arms_config_example_get_ec2_cfg(PEC2CFG pEC2Cfg);

+#endif

+

+#endif

+#endif

diff --git a/lynq/S300/ap/app/apparms/apparms_config_example_srv.h b/lynq/S300/ap/app/apparms/apparms_config_example_srv.h
new file mode 100755
index 0000000..246cd6e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_config_example_srv.h
@@ -0,0 +1,50 @@
+#ifndef _APPARMS_CONFIG_EXAMPLE_SRV_HEAD

+#define _APPARMS_CONFIG_EXAMPLE_SRV_HEAD

+

+//FOTA

+#define ARMS_FOTA_SRV_HTTP_ADDR "arms-fota-useast1.a-tracs.com"

+#define ARMS_FOTA_SRV_HTTPS_ADDR "https://arms-fota-useast1.a-tracs.com"

+#define ARMS_FOTA_ACCESS_ID "1755240358"

+#define ARMS_FOTA_ACCESS_PW "D350@BJ!7952"

+#define ARMS_FOTA_DOWNLOAD_PATH "/cache/zte_fota/delta.package"

+#define ARMS_FOTA_CHECK_INTERVAL (24 * 60 * 60 * 1000)

+

+//DM

+#define ARMS_DM_SRV_MQTT_ADDR "arms-mqtt-useast1.a-tracs.com"

+#define ARMS_DM_ACCESS_ID_MQTT (217328)

+#define ARMS_DM_ACCESS_PW_MQTT "D350@BJ!7952"

+

+#define ARMS_DM_SRV_UDP_ADDR ""

+#define ARMS_DM_ACCESS_ID_UDP (0)

+#define ARMS_DM_ACCESS_PW_UDP ""

+

+#define ARMS_DM_SRV_LWM2M_ADDR ""

+#define ARMS_DM_ACCESS_ID_LWM2M (0)

+#define ARMS_DM_ACCESS_PW_LWM2M ""

+

+#define ARMS_DM_REPORT_INTERVAL (24 * 60 * 60 * 1000)

+

+//DM IPATC

+#define ARMS_DM_WAN_IF "wlp3s0"

+#define ARMS_DM_IPC_LISTEN_PORT (5588)

+#define ARMS_DM_IPC_MAX_CLIENT (3)

+#define ARMS_DM_IPC_CLOSE_TIME (300 * 1000)

+

+#define ARMS_DM_RPC_UNX_MODE 1 

+#define ARMS_DM_RPC_UNIX_PATH "/tmp/apparms_rpc"

+#define ARMS_DM_RPC_TCP_PORT (5599)

+

+//EC2

+#define ARMS_EC2_SRV_HTTP_ADDR ""

+#define ARMS_EC2_ACCESS_ID (0x0)

+#define ARMS_EC2_HTTP_RSP_PATH "/tmp/arms_ec2_rsp"

+

+

+#define ARMS_NW_STATUS_FILE_PATH "/tmp/cm_status"

+#define ARMS_SW_VERSION_FILE_PATH "/etc/version"

+

+//LOG

+#define ARMS_LOG_FILE_PATH "./test.txt"

+#define ARMS_LOG_FILE_NAME "test.txt"

+

+#endif

diff --git a/lynq/S300/ap/app/apparms/apparms_config_os.c b/lynq/S300/ap/app/apparms/apparms_config_os.c
new file mode 100755
index 0000000..83372bf
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_config_os.c
@@ -0,0 +1,301 @@
+#include "apparms_config_os.h"

+

+int arms_config_os_get_imei(PARMSCFGFUNLIST pFunc, unsigned char *pDMIMEI, unsigned char* pIMEI)

+{	

+	if (pFunc == NULL)

+			return ARMS_CONFIG_POINT_NULL_ERROR;

+	

+	if (pFunc->GetIMEI == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetIMEI)(pDMIMEI, pIMEI);

+}

+

+int arms_config_os_get_sn(PARMSCFGFUNLIST pFunc, unsigned char *pSN)

+{

+	if (pFunc == NULL)

+				return ARMS_CONFIG_POINT_NULL_ERROR;

+		

+	if (pFunc->GetSerialNumber == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetSerialNumber)(pSN);

+

+}

+

+int arms_config_os_get_networkst(PARMSCFGFUNLIST pFunc, char *pIPAddr)

+{	

+	if (pFunc == NULL)

+			return ARMS_CONFIG_POINT_NULL_ERROR;

+	

+	if (pFunc->GetNetworkST == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetNetworkST)(pIPAddr);

+}

+

+int arms_config_os_platform_init(PARMSCFGFUNLIST pFunc)

+{	

+	if (pFunc == NULL)

+			return ARMS_CONFIG_POINT_NULL_ERROR;

+	

+	if (pFunc->CfgPlatformInit == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->CfgPlatformInit)();

+}

+

+int arms_config_os_platform_uninit(PARMSCFGFUNLIST pFunc)

+{

+	if (pFunc == NULL)

+			return ARMS_CONFIG_POINT_NULL_ERROR;

+	

+	if (pFunc->CfgPlatformUnInit == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->CfgPlatformUnInit)();

+}

+

+#ifdef ARMS_SUPPORT_DM

+int arms_config_os_dm_init(PARMSCFGFUNLIST pFunc, PDMCFG pDMCfgData)

+{

+	if ((pFunc == NULL) || (pDMCfgData == NULL))

+		return -1;

+	

+	arms_config_os_get_dm_mode_cfg(pFunc, &pDMCfgData->stDMCommCfg);

+

+	arms_config_os_get_dm_tlv_cfg(pFunc, &pDMCfgData->stDMTLVCfg);

+

+	arms_config_os_get_dm_push_rsp_tlv_cfg(pFunc, &pDMCfgData->stDMPushRspTLVCfg);

+

+	arms_config_os_get_dm_notification_tlv_cfg(pFunc, &pDMCfgData->stDMNtfyTLVCfg);

+

+	#ifdef ARMS_DM_UDP

+	arms_config_os_get_dm_udp_cfg(pFunc, &pDMCfgData->stUDPCfg);

+	#endif

+

+	#ifdef ARMS_DM_MQTT

+	arms_config_os_get_dm_mqtt_cfg(pFunc, &pDMCfgData->stMQTTCfg, &pDMCfgData->stDMCommCfg);

+	#endif

+

+	#ifdef ARMS_DM_LWM2M

+	arms_config_os_get_dm_lwm2m_cfg(pFunc, &pDMCfgData->stLwM2MCfg, &pDMCfgData->stDMCommCfg);

+	#endif

+

+	#ifdef ARMS_DM_IPC

+	arms_config_os_get_dm_ipc_cfg(pFunc, &pDMCfgData->stIPCCfg);

+	#endif

+

+	#ifdef ARMS_DM_RPC

+	arms_config_os_get_dm_rpc_cfg(pFunc, &pDMCfgData->stRPCCfg);

+	#endif

+

+	return 0;

+}

+

+

+void arms_config_os_dm_uninit(PARMSCFGFUNLIST pFunc, PDMCFG pDMCfgData)

+{

+	

+}

+

+int arms_config_os_get_dm_mode_cfg(PARMSCFGFUNLIST pFunc,PDMCOMMCFG pDMCommCfg)

+{

+	if ((pFunc == NULL) || (pDMCommCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMModeCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetDMModeCfg)(pDMCommCfg);

+}

+int arms_config_os_get_dm_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg)

+{

+	if ((pFunc == NULL) || (pDMTlvCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMTLVCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetDMTLVCfg)(pDMTlvCfg);

+}

+

+int arms_config_os_get_dm_push_rsp_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg)

+{

+	if ((pFunc == NULL) || (pDMTlvCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMPushRspTLVCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetDMPushRspTLVCfg)(pDMTlvCfg);

+}

+

+int arms_config_os_get_dm_notification_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg)

+{

+	if ((pFunc == NULL) || (pDMTlvCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMNtfyTLVCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+

+	return (*pFunc->GetDMNtfyTLVCfg)(pDMTlvCfg);

+}

+

+#ifdef ARMS_DM_UDP

+int arms_config_os_get_dm_udp_cfg(PARMSCFGFUNLIST pFunc,PUDPCFG pUDPCfg)

+{

+	if ((pFunc == NULL) || (pUDPCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetUDPCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetUDPCfg)(pUDPCfg);

+}

+#endif

+

+#ifdef ARMS_DM_MQTT

+int arms_config_os_get_dm_mqtt_cfg(PARMSCFGFUNLIST pFunc,PMQTTCFG pMQTTCfg,PDMCOMMCFG pDMCommCfg)

+{

+	if ((pFunc == NULL) || (pMQTTCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetMQTTCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetMQTTCfg)(pMQTTCfg,pDMCommCfg);

+}

+#endif

+

+#ifdef ARMS_DM_LWM2M

+int arms_config_os_get_dm_lwm2m_cfg(PARMSCFGFUNLIST pFunc,PLWM2MCFG pLWM2MCfg,PDMCOMMCFG pDMCommCfg)

+{

+	if ((pFunc == NULL) || (pLWM2MCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetLWM2MCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetLWM2MCfg)(pLWM2MCfg,pDMCommCfg);

+}

+#endif

+

+#ifdef ARMS_DM_IPC

+int arms_config_os_get_dm_ipc_cfg(PARMSCFGFUNLIST pFunc,PDMIPCCFG pIPCCfg)

+{

+	if ((pFunc == NULL) || (pIPCCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetIPCCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetIPCCfg)(pIPCCfg);

+}

+#endif

+

+#ifdef ARMS_DM_RPC

+int arms_config_os_get_dm_rpc_cfg(PARMSCFGFUNLIST pFunc,PDMRPCCFG pRPCCfg)

+{

+	if ((pFunc == NULL) || (pRPCCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetRPCCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetRPCCfg)(pRPCCfg);

+}

+#endif

+#endif

+

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_config_os_fota_init(PARMSCFGFUNLIST pFunc, PFOTACFG pFOTACfgData)

+{

+	if ((pFunc == NULL) || (pFOTACfgData == NULL))

+		return -1;

+

+	arms_config_os_get_fota_mode_cfg(pFunc, &pFOTACfgData->stFOTACommCfg);

+	arms_config_os_get_fota_tlv_cfg(pFunc, &pFOTACfgData->stFOTATLVCfg);

+

+#ifdef ARMS_FOTA_HTTP

+	arms_config_os_get_fota_http_cfg(pFunc, &pFOTACfgData->stHttpCfg);

+#endif

+

+	return 0;

+}

+

+void arms_config_os_fota_uninit(PARMSCFGFUNLIST pFunc, PFOTACFG pFOTACfgData)

+{

+	

+}

+

+int arms_config_os_get_fota_mode_cfg(PARMSCFGFUNLIST pFunc,PFOTACOMMCFG pFOTACommCfg)

+{

+	if ((pFunc == NULL) || (pFOTACommCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAModeCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAModeCfg)(pFOTACommCfg);

+}

+

+

+int arms_config_os_get_fota_tlv_cfg(PARMSCFGFUNLIST pFunc,PFOTATLVCFG pFOTATLVCfg)

+{

+	if ((pFunc == NULL) || (pFOTATLVCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTATLVCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTATLVCfg)(pFOTATLVCfg);

+}

+

+#ifdef ARMS_FOTA_HTTP

+int arms_config_os_get_fota_http_cfg(PARMSCFGFUNLIST pFunc,PHTTPCFG pHTTPCfg)

+{

+	if ((pFunc == NULL) || (pHTTPCfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetHTTPCfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetHTTPCfg)(pHTTPCfg);

+}

+#endif

+#endif

+

+

+#ifdef ARMS_SUPPORT_EC2

+

+int arms_config_os_ec2_init(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2Cfg)

+{

+	if ((pFunc == NULL) || (pEC2Cfg == NULL))

+		return -1;

+

+	arms_config_os_get_ec2_cfg(pFunc, pEC2Cfg);

+

+	arms_config_os_get_sn(pFunc,pEC2Cfg->stEC2CommCfg.szSN);

+

+	return 0;

+}

+

+void arms_config_os_ec2_uninit(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2Cfg)

+{

+	

+}

+

+int arms_config_os_get_ec2_cfg(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2Cfg)

+{

+	if ((pFunc == NULL) || (pEC2Cfg == NULL))

+		return ARMS_CONFIG_POINT_NULL_ERROR;

+

+	if (pFunc->GetEC2Cfg == NULL)

+		return ARMS_CONFIG_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetEC2Cfg)(pEC2Cfg);

+}

+

+#endif	//	ARMS_SUPPORT_EC2

diff --git a/lynq/S300/ap/app/apparms/apparms_config_os.h b/lynq/S300/ap/app/apparms/apparms_config_os.h
new file mode 100755
index 0000000..ca08a17
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_config_os.h
@@ -0,0 +1,443 @@
+#ifndef _APPARMS_CONFIG_OS_HEAD

+#define _APPARMS_CONFIG_OS_HEAD

+

+#include "apparms_macro.h"

+

+#define ARMS_MASK_FOR_BIT(bit) (1UL << (bit))

+

+#if defined(ARMS_FOTA_HTTP) || defined(ARMS_SUPPORT_EC2)

+#define ARMS_HTTP_SRV_ADDR_SIZE 128

+typedef struct _tagHTTPCFG

+{

+	char szAddr[ARMS_HTTP_SRV_ADDR_SIZE];

+	int	 nPort;

+	char szProdID[32];

+	char szPassword[128];

+#if defined(ARMS_SUPPORT_FOTA) && defined(ARMS_FOTA_HTTP)

+	char szDownFilePath[256];

+#endif

+}HTTPCFG, *PHTTPCFG;

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+typedef enum _ARMS_FOTA_VER_MASK_

+{

+	ARMS_FOTA_VER_FW = ARMS_MASK_FOR_BIT(0),

+	ARMS_FOTA_VER_CFG = ARMS_MASK_FOR_BIT(1),

+	ARMS_FOTA_VER_MCU = ARMS_MASK_FOR_BIT(2),

+	ARMS_FOTA_VER_MCU2 = ARMS_MASK_FOR_BIT(3),

+	ARMS_FOTA_VER_MCU3 = ARMS_MASK_FOR_BIT(4),

+	ARMS_FOTA_VER_MCU4 = ARMS_MASK_FOR_BIT(5),

+	ARMS_FOTA_VER_MCU5 = ARMS_MASK_FOR_BIT(6),

+	ARMS_FOTA_VER_MCU6 = ARMS_MASK_FOR_BIT(7),

+	ARMS_FOTA_VER_MCU7 = ARMS_MASK_FOR_BIT(8),

+	ARMS_FOTA_VER_MCU8 = ARMS_MASK_FOR_BIT(9),

+	ARMS_FOTA_VER_MCU9 = ARMS_MASK_FOR_BIT(10)

+}ARMS_FOTA_VER_MASK;

+

+typedef struct _tagFOTATLVCFG

+{

+	ARMS_FOTA_VER_MASK emFOTATLVMask;

+}FOTATLVCFG, *PFOTATLVCFG;

+

+#ifdef ARMS_FOTA_HTTP

+#define ARMS_FOTA_SRV_PATH_SIZE 128

+#define ARMS_FOTA_SRV_PORT_SIZE 6

+

+typedef enum _ARMS_FOTA_COMM_MODE_

+{

+	ARMS_FOTA_COMM_HTTP_HTTPS,

+	ARMS_FOTA_COMM_MAX

+}ARMS_FOTA_COMM_MODE;

+#endif

+

+

+typedef struct FOTACOMMCFG

+{

+	ARMS_FOTA_COMM_MODE emCommMode;

+	

+	unsigned char szIMEI[32];

+	unsigned int nCheckPeriod;

+}FOTACOMMCFG, *PFOTACOMMCFG;

+

+typedef struct _tagFOTACFG

+{

+	FOTACOMMCFG stFOTACommCfg;

+	FOTATLVCFG stFOTATLVCfg;

+#ifdef ARMS_FOTA_HTTP	

+	HTTPCFG stHttpCfg;

+#endif

+}FOTACFG, *PFOTACFG;

+

+typedef int (*ARMS_CFG_GET_FOTA_MODE)(PFOTACOMMCFG);

+typedef int (*ARMS_CFG_GET_FOTA_TLV)(PFOTATLVCFG);

+

+#ifdef ARMS_FOTA_HTTP

+typedef int (*ARMS_CFG_GET_HTTP)(PHTTPCFG);

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+

+typedef struct EC2COMMCFG

+{

+	unsigned char szIMEI[32];

+	unsigned char szSN[32];

+}EC2COMMCFG, *PEC2COMMCFG;

+

+typedef struct _tagEC2CFG

+{

+	EC2COMMCFG stEC2CommCfg;

+	HTTPCFG stHttpCfg;

+	char szHttpRspPath[128];

+}EC2CFG, *PEC2CFG;

+

+typedef int (*ARMS_CFG_GET_EC2)(PEC2CFG);

+

+#endif	// ARMS_SUPPORT_EC2

+

+#ifdef ARMS_SUPPORT_DM

+typedef enum _ARMS_DM_TLV_MASK_

+{

+	ARMS_DM_TLV_COMM_GENERAL = ARMS_MASK_FOR_BIT(0),

+	ARMS_DM_TLV_COMM_NETWORK = ARMS_MASK_FOR_BIT(1),

+	ARMS_DM_TLV_COMM_GEOFENCE = ARMS_MASK_FOR_BIT(2),

+	ARMS_DM_TLV_COMM_VERSION = ARMS_MASK_FOR_BIT(3),

+	ARMS_DM_TLV_COMM_FILETST = ARMS_MASK_FOR_BIT(4),

+	ARMS_DM_TLV_COMM_EXTVER = ARMS_MASK_FOR_BIT(5),

+	ARMS_DM_TLV_COMM_TOKEN = ARMS_MASK_FOR_BIT(6),

+	ARMS_DM_TLV_COMM_DMREPORT = ARMS_MASK_FOR_BIT(7),

+	ARMS_DM_TLV_COMM_WARNMSG = ARMS_MASK_FOR_BIT(8),

+	ARMS_DM_TLV_COMM_CUSDATA1 = ARMS_MASK_FOR_BIT(9),

+	ARMS_DM_TLV_COMM_CUSDATA2 = ARMS_MASK_FOR_BIT(10),

+	ARMS_DM_TLV_COMM_CUSDATA3 = ARMS_MASK_FOR_BIT(11),

+	ARMS_DM_TLV_COMM_CUSDATA4 = ARMS_MASK_FOR_BIT(12),

+	ARMS_DM_TLV_COMM_CUSDATA5 = ARMS_MASK_FOR_BIT(13),

+	ARMS_DM_TLV_COMM_CUSDATA6 = ARMS_MASK_FOR_BIT(14),

+	ARMS_DM_TLV_COMM_CUSDATA7 = ARMS_MASK_FOR_BIT(15),

+	ARMS_DM_TLV_COMM_CUSDATA8 = ARMS_MASK_FOR_BIT(16),

+	ARMS_DM_TLV_COMM_CUSDATA9 = ARMS_MASK_FOR_BIT(17),

+	ARMS_DM_TLV_COMM_CUSDATA10 = ARMS_MASK_FOR_BIT(18),

+	ARMS_DM_TLV_COMM_RSPMSG = ARMS_MASK_FOR_BIT(19)

+}ARMS_DM_TLV_MASK;

+

+typedef enum _ARMS_DM_TLV_GEN_MASK_

+{

+	ARMS_DM_TLV_GEN_PRODUCT_ID = ARMS_MASK_FOR_BIT(0),

+	ARMS_DM_TLV_GEN_GPS_TIME = ARMS_MASK_FOR_BIT(1),

+	ARMS_DM_TLV_GEN_GPS_LOCATION = ARMS_MASK_FOR_BIT(2),

+	ARMS_DM_TLV_GEN_GPS_SPEED_HEADING = ARMS_MASK_FOR_BIT(3),

+	ARMS_DM_TLV_GEN_GPS_ALTITUDE = ARMS_MASK_FOR_BIT(4),

+	ARMS_DM_TLV_GEN_GPS_ACCURACY = ARMS_MASK_FOR_BIT(5),

+	ARMS_DM_TLV_GEN_VOLTAGE_MAIN = ARMS_MASK_FOR_BIT(6),

+	ARMS_DM_TLV_GEN_VOLTAGE_BATTERY = ARMS_MASK_FOR_BIT(7),

+	ARMS_DM_TLV_GEN_VOLTAGE_AUX = ARMS_MASK_FOR_BIT(8),

+	ARMS_DM_TLV_GEN_VOLTAGE_SOLAR = ARMS_MASK_FOR_BIT(9),

+	ARMS_DM_TLV_GEN_NETWORK_SERVICE = ARMS_MASK_FOR_BIT(10),

+	ARMS_DM_TLV_GEN_NETWORK_RSSI = ARMS_MASK_FOR_BIT(11),

+	ARMS_DM_TLV_GEN_GPIO_A_D = ARMS_MASK_FOR_BIT(12),

+	ARMS_DM_TLV_GEN_GPIO_E_H = ARMS_MASK_FOR_BIT(13),

+	ARMS_DM_TLV_GEN_VIRTUAL_ODOMETER = ARMS_MASK_FOR_BIT(14),

+	ARMS_DM_TLV_GEN_TEMPERATURE = ARMS_MASK_FOR_BIT(15),

+	ARMS_DM_TLV_GEN_BATTERY_GAUGE = ARMS_MASK_FOR_BIT(16)

+}ARMS_DM_TLV_GEN_MASK;

+

+typedef enum _ARMS_DM_TLV_VER_MASK_

+{

+	ARMS_DM_TLV_VER_HID = ARMS_MASK_FOR_BIT(0),

+	ARMS_DM_TLV_VER_MAIN = ARMS_MASK_FOR_BIT(1),

+	ARMS_DM_TLV_VER_EXT = ARMS_MASK_FOR_BIT(2),

+	ARMS_DM_TLV_VER_FW = ARMS_MASK_FOR_BIT(3),

+	ARMS_DM_TLV_VER_MCU = ARMS_MASK_FOR_BIT(4),

+	ARMS_DM_TLV_VER_CONF = ARMS_MASK_FOR_BIT(5)

+}ARMS_DM_TLV_VER_MASK;

+

+typedef enum _ARMS_DM_TLV_EXTVER_MASK_

+{

+	ARMS_DM_TLV_EXTVER_MCU2 = ARMS_MASK_FOR_BIT(0),

+	ARMS_DM_TLV_EXTVER_MCU3 = ARMS_MASK_FOR_BIT(1),

+	ARMS_DM_TLV_EXTVER_MCU4 = ARMS_MASK_FOR_BIT(2),

+	ARMS_DM_TLV_EXTVER_MCU5 = ARMS_MASK_FOR_BIT(3),

+	ARMS_DM_TLV_EXTVER_MCU6 = ARMS_MASK_FOR_BIT(4),

+	ARMS_DM_TLV_EXTVER_MCU7 = ARMS_MASK_FOR_BIT(5),

+	ARMS_DM_TLV_EXTVER_MCU8 = ARMS_MASK_FOR_BIT(6),

+	ARMS_DM_TLV_EXTVER_MCU9 = ARMS_MASK_FOR_BIT(7)	

+}ARMS_DM_TLV_EXTVER_MASK;

+

+typedef enum _ARMS_DM_TLV_DMREPORT_MASK_

+{

+	ARMS_DM_TLV_DMREPORT_LIGHTLUX = ARMS_MASK_FOR_BIT(0),

+	ARMS_DM_TLV_DMREPORT_LIGHTTIME= ARMS_MASK_FOR_BIT(1),

+	ARMS_DM_TLV_DMREPORT_MDN = ARMS_MASK_FOR_BIT(2),

+	ARMS_DM_TLV_DMREPORT_ICCID = ARMS_MASK_FOR_BIT(3),

+	ARMS_DM_TLV_DMREPORT_MACADDR = ARMS_MASK_FOR_BIT(4),

+	ARMS_DM_TLV_DMREPORT_ECGI = ARMS_MASK_FOR_BIT(5),

+	ARMS_DM_TLV_DMREPORT_NEGECGI = ARMS_MASK_FOR_BIT(6)

+}ARMS_DM_TLV_DMREPORT_MASK;

+

+typedef struct _tagDMTLVCFG

+{

+	ARMS_DM_TLV_MASK emDMTLVMask;

+	ARMS_DM_TLV_GEN_MASK emDMTLVGenMask;

+	ARMS_DM_TLV_VER_MASK emDMTLVVerMask;

+	ARMS_DM_TLV_EXTVER_MASK emDMTLVEXTVerMask;

+	ARMS_DM_TLV_DMREPORT_MASK emDMTLVDMReportMask;

+}DMTLVCFG, *PDMTLVCFG;

+

+#define ARMS_DM_SRV_ADDR_SIZE 128

+#define ARMS_DM_TOKEN_KEY_SIZE 128

+

+#define ARMS_DM_MQTT_USERNAME_SIZE 32

+#define ARMS_DM_MQTT_PASSWORD_SIZE 128

+#define ARMS_DM_MQTT_CERT_SIZE 2048

+

+#define ARMS_DM_LWM2M_EPNAME_SIZE 128

+

+typedef unsigned long HWIDCFG;

+

+typedef enum _ARMS_DM_COMM_MODE_

+{

+	ARMS_DM_COMM_UDP,

+	ARMS_DM_COMM_MQTT,

+	ARMS_DM_COMM_LWM2M,

+	ARMS_DM_COMM_MAX	

+}ARMS_DM_COMM_MODE;

+

+typedef enum _ARMS_DM_AUTH_MODE_

+{

+	ARMS_DM_AUTH_KEY,

+	ARMS_DM_AUTH_CERT,

+	ARMS_DM_AUTH_MAX

+}ARMS_DM_AUTH_MODE;

+

+typedef enum _ARMS_DM_DATA_MODE_

+{

+	ARMS_DM_DATA_ATRACS,

+	ARMS_DM_DATA_JSON,

+	ARMS_DM_DATA_MAX

+}ARMS_DM_DATA_MODE;

+

+#ifdef ARMS_DM_UDP

+typedef struct _tagUDPCFG

+{

+	char szUDPAddr[ARMS_DM_SRV_ADDR_SIZE];

+	int	 nUDPPort;

+}UDPCFG, *PUDPCFG;

+#endif

+

+#ifdef ARMS_DM_LWM2M

+typedef struct _tagLWM2MCFG

+{

+	char szLwM2MAddr[ARMS_DM_SRV_ADDR_SIZE];

+	int	 nLwM2MPort;

+

+	char szEndpointName[ARMS_DM_LWM2M_EPNAME_SIZE];

+}LWM2MCFG, *PLWM2MCFG;

+#endif

+

+#ifdef ARMS_DM_MQTT

+typedef struct _tagMQTTCFG

+{

+	char szMQTTAddr[ARMS_DM_SRV_ADDR_SIZE];

+	int	 nMQTTPort;

+	unsigned int nMQTTLiveTM;

+

+	char szUserName[ARMS_DM_MQTT_USERNAME_SIZE];

+	char szPassWord[ARMS_DM_MQTT_PASSWORD_SIZE];

+	

+	#ifdef ARMS_AUTH_X509

+	char szCaCert[ARMS_DM_MQTT_CERT_SIZE];

+	char szClientCert[ARMS_DM_MQTT_CERT_SIZE];

+	char szClientKey[ARMS_DM_MQTT_CERT_SIZE];

+	#endif

+	

+}MQTTCFG, *PMQTTCFG;

+#endif

+

+#ifdef ARMS_DM_IPC

+#define ARMS_DM_IPC_MAX_INTF 4

+typedef struct _tagDMIPCCFG

+{

+	unsigned int enable;

+	char intf[ARMS_DM_IPC_MAX_INTF][32];

+	unsigned int nPort;

+	unsigned char bDynamicOpen;

+	unsigned char bUnixMode;

+	char szUnixPath[128];

+	unsigned int uMaxclient;

+	unsigned int mtimeout;

+}DMIPCCFG, *PDMIPCCFG;

+#endif

+

+#ifdef ARMS_DM_RPC

+typedef struct _tagDMRPCCFG

+{

+	unsigned int bRPC;

+	unsigned char bRPCUnixMode;

+	unsigned int mRPCTimeout;

+

+	/*unix path*/

+	char szRPCUnix[128];

+

+	/*TCP path*/

+	char szRPCTCPSrv[128];

+	unsigned int nRPCTCPPort;

+}DMRPCCFG, *PDMRPCCFG;

+#endif

+

+typedef struct _tagDMCOMMCFG

+{

+	ARMS_DM_COMM_MODE emCommMode;

+	ARMS_DM_AUTH_MODE emAuthMode;

+	ARMS_DM_DATA_MODE emDataMode;

+	HWIDCFG unHWId;

+	unsigned char szKey[64];

+	unsigned char szIMEI[32];

+	unsigned int nReportPeriod;

+}DMCOMMCFG, *PDMCOMMCFG;

+

+typedef struct _tagDMCFG

+{

+	DMCOMMCFG stDMCommCfg;

+	DMTLVCFG stDMTLVCfg;	

+	DMTLVCFG stDMNtfyTLVCfg;

+	DMTLVCFG stDMPushRspTLVCfg;

+#ifdef ARMS_DM_UDP

+	UDPCFG stUDPCfg;

+#endif

+

+#ifdef ARMS_DM_LWM2M

+	LWM2MCFG stLwM2MCfg;

+#endif

+

+#ifdef ARMS_DM_MQTT

+	MQTTCFG stMQTTCfg;

+#endif

+

+#ifdef ARMS_DM_IPC

+	DMIPCCFG stIPCCfg;

+#endif

+

+#ifdef ARMS_DM_RPC

+	DMRPCCFG stRPCCfg;

+#endif

+}DMCFG, *PDMCFG;

+

+typedef int (*ARMS_CFG_GET_DM_MODE)(PDMCOMMCFG);

+typedef int (*ARMS_CFG_GET_DM_TLV)(PDMTLVCFG);

+

+#ifdef ARMS_DM_UDP

+typedef int (*ARMS_CFG_GET_UDP)(PUDPCFG);

+#endif

+#ifdef ARMS_DM_MQTT

+typedef int (*ARMS_CFG_GET_MQTT)(PMQTTCFG,PDMCOMMCFG);

+#endif

+#ifdef ARMS_DM_LWM2M

+typedef int (*ARMS_CFG_GET_LW2M2)(PLWM2MCFG,PDMCOMMCFG);

+#endif

+#ifdef ARMS_DM_IPC

+typedef int (*ARMS_CFG_GET_IPC)(PDMIPCCFG);

+#endif

+#ifdef ARMS_DM_RPC

+typedef int (*ARMS_CFG_GET_RPC)(PDMRPCCFG);

+#endif

+#endif

+

+typedef int (*ARMS_CFG_OS_GET_IMEI)(unsigned char*, unsigned char*);

+typedef int (*ARMS_CFG_OS_GET_SN)(unsigned char*);

+typedef int (*ARMS_CFG_OS_GET_NETWORKST)(char *);

+typedef int (*ARMS_CFG_OS_PLATFORM_INIT)(void);

+typedef int (*ARMS_CFG_OS_PLATFORM_UNINIT)(void);

+

+typedef struct _tagARMSCFGFunList

+{

+	ARMS_CFG_OS_GET_IMEI GetIMEI;

+	ARMS_CFG_OS_GET_SN GetSerialNumber;

+	ARMS_CFG_OS_GET_NETWORKST GetNetworkST;

+	

+#ifdef ARMS_SUPPORT_DM

+	ARMS_CFG_GET_DM_MODE GetDMModeCfg;

+	ARMS_CFG_GET_DM_TLV GetDMTLVCfg;

+	ARMS_CFG_GET_DM_TLV GetDMPushRspTLVCfg;

+	ARMS_CFG_GET_DM_TLV GetDMNtfyTLVCfg;

+#ifdef ARMS_DM_UDP

+	ARMS_CFG_GET_UDP GetUDPCfg;

+#endif

+#ifdef ARMS_DM_MQTT

+	ARMS_CFG_GET_MQTT GetMQTTCfg;

+#endif

+#ifdef ARMS_DM_LWM2M

+	ARMS_CFG_GET_LW2M2 GetLWM2MCfg;

+#endif

+#ifdef ARMS_DM_IPC

+	ARMS_CFG_GET_IPC GetIPCCfg;

+#endif

+#ifdef ARMS_DM_RPC

+	ARMS_CFG_GET_RPC GetRPCCfg;

+#endif

+#endif	

+

+#ifdef ARMS_SUPPORT_FOTA

+#ifdef ARMS_FOTA_HTTP

+	ARMS_CFG_GET_HTTP GetHTTPCfg;

+#endif

+	ARMS_CFG_GET_FOTA_MODE GetFOTAModeCfg;

+	ARMS_CFG_GET_FOTA_TLV GetFOTATLVCfg;

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+	ARMS_CFG_GET_EC2 GetEC2Cfg;

+#endif

+

+	ARMS_CFG_OS_PLATFORM_INIT CfgPlatformInit;

+	ARMS_CFG_OS_PLATFORM_UNINIT CfgPlatformUnInit;

+}ARMSCFGFUNLIST, *PARMSCFGFUNLIST;

+

+int arms_config_os_get_imei(PARMSCFGFUNLIST pFunc, unsigned char *pDMIMEI, unsigned char* pIMEI);

+int arms_config_os_get_sn(PARMSCFGFUNLIST pFunc, unsigned char *pSN);

+int arms_config_os_get_networkst(PARMSCFGFUNLIST pFunc, char *pIPAddr);

+int arms_config_os_platform_init(PARMSCFGFUNLIST pFunc);

+int arms_config_os_platform_uninit(PARMSCFGFUNLIST pFunc);

+

+#ifdef ARMS_SUPPORT_DM

+int arms_config_os_dm_init(PARMSCFGFUNLIST pFunc, PDMCFG pDMCfgData);

+void arms_config_os_dm_uninit(PARMSCFGFUNLIST pFunc, PDMCFG pDMCfgData);

+int arms_config_os_get_dm_mode_cfg(PARMSCFGFUNLIST pFunc,PDMCOMMCFG pDMCommCfg);

+int arms_config_os_get_dm_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg);

+int arms_config_os_get_dm_push_rsp_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg);

+int arms_config_os_get_dm_notification_tlv_cfg(PARMSCFGFUNLIST pFunc,PDMTLVCFG pDMTlvCfg);

+

+#ifdef ARMS_DM_UDP

+int arms_config_os_get_dm_udp_cfg(PARMSCFGFUNLIST pFunc,PUDPCFG pUDPCfg);

+#endif

+#ifdef ARMS_DM_MQTT

+int arms_config_os_get_dm_mqtt_cfg(PARMSCFGFUNLIST pFunc,PMQTTCFG pMQTTCfg,PDMCOMMCFG pDMCommCfg);

+#endif

+#ifdef ARMS_DM_LWM2M

+int arms_config_os_get_dm_lwm2m_cfg(PARMSCFGFUNLIST pFunc,PLWM2MCFG pLWM2MCfg,PDMCOMMCFG pDMCommCfg);

+#endif

+#ifdef ARMS_DM_IPC

+int arms_config_os_get_dm_ipc_cfg(PARMSCFGFUNLIST pFunc,PDMIPCCFG pIPCCfg);

+#endif

+#ifdef ARMS_DM_RPC

+int arms_config_os_get_dm_rpc_cfg(PARMSCFGFUNLIST pFunc,PDMRPCCFG pRPCCfg);

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_config_os_fota_init(PARMSCFGFUNLIST pFunc, PFOTACFG pFOTACfgData);

+void arms_config_os_fota_uninit(PARMSCFGFUNLIST pFunc, PFOTACFG pFOTACfgData);

+int arms_config_os_get_fota_mode_cfg(PARMSCFGFUNLIST pFunc,PFOTACOMMCFG pFOTACommCfg);

+int arms_config_os_get_fota_tlv_cfg(PARMSCFGFUNLIST pFunc,PFOTATLVCFG pFOTATLVCfg);

+#ifdef ARMS_FOTA_HTTP

+int arms_config_os_get_fota_http_cfg(PARMSCFGFUNLIST pFunc,PHTTPCFG pHTTPCfg);

+#endif

+#endif

+

+#ifdef ARMS_SUPPORT_EC2

+int arms_config_os_ec2_init(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2CfgData);

+void arms_config_os_ec2_uninit(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2Cfg);

+int arms_config_os_get_ec2_cfg(PARMSCFGFUNLIST pFunc, PEC2CFG pEC2Cfg);

+#endif

+

+#endif

diff --git a/lynq/S300/ap/app/apparms/apparms_data_example.c b/lynq/S300/ap/app/apparms/apparms_data_example.c
new file mode 100755
index 0000000..f1d72dd
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_data_example.c
@@ -0,0 +1,1062 @@
+#include "apparms_data_example.h"

+#include "apparms_util.h"

+

+#ifdef ARMS_BOARD_EXAMPLE

+static ARMSDATAFUNLIST arms_example_datafun_pointer =

+{

+#ifdef ARMS_SUPPORT_DM

+	arms_data_example_get_dm_header_tag,

+	arms_data_example_get_dm_header_event,

+	arms_data_example_get_dm_generic_pid,

+	arms_data_example_get_dm_generic_gps,

+	arms_data_example_get_dm_generic_battchg,

+	arms_data_example_get_dm_generic_network,

+	arms_data_example_get_dm_generic_gpio,

+	arms_data_example_get_dm_generic_odometer,

+	arms_data_example_get_dm_version,

+	arms_data_example_get_dm_extver,

+	arms_data_example_get_dm_dmreport_pricell,

+	arms_data_example_get_dm_dmreport_nbcell,

+	arms_data_example_get_dm_dmreport_light,

+	arms_data_example_get_dm_dmreport_macsim,

+	arms_data_example_get_dm_cusdata,

+	arms_data_example_handle_dm_ack_pushmsg,

+	arms_data_example_handle_dm_ack_ok,

+	arms_data_example_handle_dm_ack_fail,

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+	arms_data_example_get_fota_ret,

+	arms_data_example_get_fota_ver_fw,

+	arms_data_example_get_fota_ver_cfg,

+	arms_data_example_get_fota_ver_mcu,

+	arms_data_example_get_fota_net_status,

+	arms_data_example_get_fota_task_id,

+	arms_data_example_save_fota_task_id,

+	arms_data_example_get_fota_device_id,

+	arms_data_example_save_fota_device_id,

+	arms_data_example_get_fota_device_sec,

+	arms_data_example_save_fota_device_sec,

+	arms_data_example_get_fota_deviceid_md5,

+	arms_data_example_save_fota_deviceid_md5,

+	arms_data_example_get_fota_pre_version_fw,

+	arms_data_example_save_fota_pre_version_fw,

+	arms_data_example_get_fota_pre_version_cfg,

+	arms_data_example_save_fota_pre_version_cfg,

+	arms_data_example_get_fota_pre_version_mcu,

+	arms_data_example_save_fota_pre_version_mcu,

+	arms_data_example_get_fota_backup,

+	arms_data_example_save_fota_backup,

+	arms_data_example_get_fota_down_size,

+	arms_data_example_save_fota_down_size,

+	arms_data_example_upgrade,

+	arms_data_example_get_region_size,

+	arms_data_example_get_log,

+#endif

+

+	arms_data_example_set_waketime,

+	arms_data_example_get_suspend,

+	arms_data_example_get_timestamp

+};

+

+PARMSDATAFUNLIST arms_data_example_get_cfgfun_pointer(void)

+{

+	return &arms_example_datafun_pointer;

+}

+

+int arms_data_example_set_waketime(unsigned long uHWId, long long nNowInSec, unsigned short nIntervalInSec)

+{

+	//TODO: request to wake up the device with nTimeInSec by platform wake mechanism.

+	

+	return 0;	

+}

+

+int arms_data_example_get_suspend(unsigned long uHWId, int* pSuspend)

+{

+	if (pSuspend == NULL)

+		return -1;

+

+	*pSuspend = 0;

+	

+	return 0;	

+}

+

+int arms_data_example_get_timestamp(unsigned long* pTimeStamp)

+{

+	if (pTimeStamp == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	struct tm *p_tm;

+	time_t now = time(NULL);

+	p_tm = localtime(&now);

+

+	*pTimeStamp = ((p_tm->tm_year + 1900) - 2000) * 12;

+	*pTimeStamp = (*pTimeStamp + p_tm->tm_mon) * 31;

+    *pTimeStamp = (*pTimeStamp + p_tm->tm_mday - 1) * 24;

+    *pTimeStamp = ((*pTimeStamp + p_tm->tm_hour) * 60 + p_tm->tm_min) * 60 + p_tm->tm_sec;

+#endif

+	

+	return 0;	

+}

+

+#ifdef ARMS_SUPPORT_DM

+int arms_data_example_get_dm_header_tag(unsigned char* pTag)

+{

+	if (pTag == NULL)

+		return -1;

+

+	*pTag = 0;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pTag = 1;

+#endif	

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_header_event(unsigned short* pEvent)

+{

+	if (pEvent == NULL)

+		return -1;

+

+	*pEvent = 0;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pEvent = 0x22;

+#endif	

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_pid(unsigned char* pID)

+{

+	if (pID == NULL)

+		return -1;

+

+	*pID = 0;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pID = 5;

+#endif	

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_gps(PDMGPSDATA pGPS)

+{

+	if (pGPS == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pGPS->gps_lat = 31.19435;

+	pGPS->gps_lon = 121.5827;

+	pGPS->gps_speed = 100;

+	pGPS->gps_heading = 128;

+	pGPS->gps_altitude = 25;

+	pGPS->gps_status = 1;

+	pGPS->gps_sat_count = 5;

+	pGPS->gps_HOP = 1.1;

+#endif	

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_battchg(PDMBATTCHGDATA pBattChg)

+{

+	if (pBattChg == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pBattChg->main_voltage = 1735;

+	pBattChg->batt_voltage = 2967;

+	pBattChg->aux_voltage = 3527;

+	pBattChg->solar_voltage = 4560;

+	pBattChg->tempeature = 75;

+	pBattChg->percentage = 99;

+	pBattChg->charge = 4321;

+#endif	

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_network(PDMNETWORKDATA pNetwork)

+{

+	if (pNetwork == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pNetwork->roaming = 1;

+	pNetwork->srvtype = 2;

+	pNetwork->nw_mcc = 460;

+	pNetwork->nw_mnc = 0;

+	pNetwork->nw_rssi = 22;

+#endif

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_gpio(PDMGPIODATA pGpio)

+{

+	if (pGpio == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pGpio->GPIOADir=1;

+	pGpio->GPIOAValue=0;

+	pGpio->GPIOBDir=1;

+	pGpio->GPIOBValue=0;

+	pGpio->GPIOCDir=0;

+	pGpio->GPIOCValue=0;

+	pGpio->GPIODDir=1;

+	pGpio->GPIODValue=1;

+

+	pGpio->GPIOEDir=0;

+	pGpio->GPIOEValue=0;

+	pGpio->GPIOFDir=0;

+	pGpio->GPIOFValue=0;

+	pGpio->GPIOGDir=0;

+	pGpio->GPIOGValue=0;

+	pGpio->GPIOHDir=0;

+	pGpio->GPIOHValue=0;

+#endif

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_generic_odometer(unsigned long* pOdometer)

+{

+	if (pOdometer == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pOdometer = 123;

+#endif

+

+	return 0;	

+}

+

+int arms_data_example_get_dm_version(PDMVERSIONDATA pVersion)

+{

+	if (pVersion == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	strcpy((char*)pVersion->main, "7.1.1.0");

+	strcpy((char*)pVersion->ext, "0");

+	strcpy((char*)pVersion->fw, "16.1.0.7.1");	

+	strcpy((char*)pVersion->mcu, "1.0.8.1");	

+	strcpy((char*)pVersion->cfg, "32789");	

+#endif

+

+	return 0;

+}

+

+int arms_data_example_get_dm_extver(PDMEXTVERDATA pExtver)

+{

+	if (pExtver == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	strcpy((char*)pExtver->mcu2, "1.3.3.4");

+	strcpy((char*)pExtver->mcu3, "1.4.3.4");

+	strcpy((char*)pExtver->mcu4, "1.5.3.4");

+	strcpy((char*)pExtver->mcu5, "1.6.3.4");

+	strcpy((char*)pExtver->mcu6, "1.7.3.4");

+	strcpy((char*)pExtver->mcu7, "1.8.3.4");

+	strcpy((char*)pExtver->mcu8, "1.9.3.4");

+	strcpy((char*)pExtver->mcu9, "1.10.3.4");

+#endif

+

+

+	return 0;

+}

+

+int arms_data_example_get_dm_dmreport_pricell(PDMREPORTPRICELL pDMRptPriCell)

+{

+	if (pDMRptPriCell == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pDMRptPriCell->mcc = 460;

+	pDMRptPriCell->mnc = 0;

+	pDMRptPriCell->eci = 0x1813A07;

+#endif

+

+	return 0;

+}

+

+int arms_data_example_get_dm_dmreport_nbcell(PDMREPORTNBCELL pDMRptNBCell)

+{

+	if (pDMRptNBCell == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pDMRptNBCell[0].nb_mcc = 461;

+	pDMRptNBCell[0].nb_mnc = 01;

+	pDMRptNBCell[0].nb_eci = 45234;

+	pDMRptNBCell[0].nb_rssi = 21;

+	pDMRptNBCell[1].nb_mcc = 462;

+	pDMRptNBCell[1].nb_mnc = 02;

+	pDMRptNBCell[1].nb_eci = 12398;

+	pDMRptNBCell[1].nb_rssi = 22;

+	pDMRptNBCell[2].nb_mcc = 463;

+	pDMRptNBCell[2].nb_mnc = 03;

+	pDMRptNBCell[2].nb_eci = 12331;

+	pDMRptNBCell[2].nb_rssi = 23;

+#endif

+

+	return 0;

+}

+

+

+int arms_data_example_get_dm_dmreport_light(PDMREPORTLIGHTDATA pDMRptLight)

+{

+	if (pDMRptLight == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	pDMRptLight->lightlux = 60000;

+	pDMRptLight->lightontime = 500;

+	pDMRptLight->lightofftime = 500;

+	pDMRptLight->lightdurationtime = 12000;

+#endif

+

+	return 0;

+}

+

+int arms_data_example_get_dm_dmreport_macsim(PDMREPORTMACSIM pDMRptMacSim)

+{

+	if (pDMRptMacSim == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	//max len is 20

+	strcpy((char*)pDMRptMacSim->mdn, "008613511112222");

+

+	//max len is 20

+	strcpy((char*)pDMRptMacSim->iccid, "89860000000000000001");

+

+	//max len is 12

+	strcpy((char*)pDMRptMacSim->macaddr, "70B5E83A7507");

+#endif

+

+	return 0;

+}

+

+

+int arms_data_example_get_dm_cusdata(unsigned char index, int* pLen, unsigned char* pData)

+{

+	int nValueLen = 0;

+	char szTemp[256] = {0};

+	

+	if (pLen == NULL || pData == NULL )

+		return -1;

+

+	if (index > 10)

+		return -2;

+

+#ifdef EXAMPLE_REF_VALUE

+	switch(index+1) 

+	{

+		case 1:

+#if 0

+#ifndef ARMS_SUPPORT_TEST_MULTI_INSTANCE

+			if (1 == arms_util_readConfigValue(ARMS_SW_VERSION_FILE_PATH, "SW Ver", (char *)pData))

+			{

+				*pLen = strlen((char *)pData);

+			}

+			else

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+#else

+			strcpy((char*)pData, "1.1.2.1");

+			*pLen = strlen((char*)pData);

+#endif

+#endif

+			memset(szTemp, 0, sizeof(szTemp));

+			cfg_get_item("wa_version", szTemp, sizeof(szTemp));

+			strcpy((char*)pData, szTemp);

+			*pLen = strlen((char*)pData);

+			break;

+			

+		case 2:

+#if 0

+			if (1 == arms_util_readConfigValue(ARMS_SW_VERSION_FILE_PATH, "Inner Ver", (char *)pData))

+			{

+				*pLen = strlen((char *)pData);

+			}

+			else

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+#endif

+			memset(szTemp, 0, sizeof(szTemp));

+			cfg_get_item("cr_inner_version", szTemp, sizeof(szTemp));

+			strcpy((char*)pData, szTemp);

+			*pLen = strlen((char*)pData);

+			break;

+			

+		case 3:

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "RSRP", (char *)szTemp))

+			{

+				nValueLen = strlen(szTemp);

+				*pLen = nValueLen;

+				if ((strstr(szTemp, "dBm") != NULL) && (nValueLen > 3))

+				{

+					szTemp[nValueLen - 3] = '\0';

+					*pLen = nValueLen - 3;

+				}

+				strcpy((char *)pData, szTemp);

+			}

+			

+			if (nValueLen <= 0)

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+			

+		case 4:

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "RSRQ", (char *)szTemp))

+			{

+				nValueLen = strlen(szTemp);

+				*pLen = nValueLen;

+				if ((strstr(szTemp, "dB") != NULL) && (nValueLen > 2))

+				{

+					szTemp[nValueLen - 2] = '\0';

+					*pLen = nValueLen - 2;

+				}

+				strcpy((char *)pData, szTemp);

+			}

+			

+			if (nValueLen <= 0)

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+

+		case 5:

+#if 0

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "RSSI", (char *)szTemp))

+			{

+				nValueLen = strlen(szTemp);

+				*pLen = nValueLen;

+				if ((strstr(szTemp, "dBm") != NULL) && (nValueLen > 3))

+				{

+					szTemp[nValueLen - 3] = '\0';

+					*pLen = nValueLen - 3;

+				}

+				strcpy((char *)pData, szTemp);

+			}

+			

+			if (nValueLen <= 0)

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+#endif

+			memset(szTemp, 0, sizeof(szTemp));

+			cfg_get_item("rssi", szTemp, sizeof(szTemp));

+			strcpy((char*)pData, szTemp);

+			*pLen = strlen((char*)pData);

+			break;

+

+		case 6:

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "SINR", (char *)szTemp))

+			{

+				nValueLen = strlen(szTemp);

+				*pLen = nValueLen;

+				if ((strstr(szTemp, "dB") != NULL) && (nValueLen > 2))

+				{

+					szTemp[nValueLen - 2] = '\0';

+					*pLen = nValueLen - 2;

+				}

+				strcpy((char *)pData, szTemp);

+			}

+			

+			if (nValueLen <= 0)

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+

+		case 7:

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "Carrier", (char *)pData))

+			{

+				*pLen = strlen((char *)pData);

+			}

+			else

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+

+		case 8:

+			if (1 == arms_util_readConfigValue(ARMS_NW_STATUS_FILE_PATH, "GCI", (char *)pData))

+			{

+				*pLen = strlen((char *)pData);

+			}

+			else

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+		

+		case 9:

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+		case 10:

+			{

+				*pLen = 3;

+				strcpy((char*)pData, "N/A");

+			}

+			break;

+		default:

+			break;

+	}

+	

+#endif

+

+	return 0;

+}

+

+int arms_data_example_handle_dm_ack_pushmsg(unsigned char* pInData, int nInLen,unsigned char* pOutData, int *pOutLen)

+{

+#ifdef EXAMPLE_REF_VALUE

+	time_t timep;		

+	struct tm *p;

+	char curren_time[64] = {0};

+	int nTimeLen = 0;

+			

+	time(&timep);

+	p=localtime(&timep);

+	if(p != NULL)

+	{			

+		sprintf(curren_time,"[%02d-%02d %02d:%02d:%02d] ", 

+				(1+p->tm_mon),p->tm_mday, p->tm_hour, 

+				p->tm_min, p->tm_sec);

+

+		strcpy((char *)pOutData, curren_time);

+		strcat((char *)pOutData, " ");

+		nTimeLen = strlen(curren_time) + 1;

+	}

+	

+	strcat((char *)pOutData, (char *)pInData);

+	*pOutLen = nInLen + nTimeLen;

+#endif

+	return 0;

+}

+

+int arms_data_example_handle_dm_ack_ok(void)

+{

+	return 0;

+}

+

+int arms_data_example_handle_dm_ack_fail(int nType)

+{

+	return 0;

+}

+

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+#ifdef EXAMPLE_REF_VALUE

+FOTADATA g_stFotaData = {{0}};

+#endif

+

+int arms_data_example_get_fota_ret(PFOTARET pFOTRet)

+{

+	if (pFOTRet == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(&g_stFotaData.stFOTARet,0,sizeof(g_stFotaData.stFOTARet));

+	memcpy(pFOTRet,&g_stFotaData.stFOTARet,sizeof(FOTARET));

+#endif

+

+	return 0;

+}

+

+int arms_data_example_get_fota_ver_fw(PFOTADATAFW pVerFW)

+{

+	if (pVerFW == NULL)

+		return -1;

+#if 0

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stFWVerArr,0,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+	if (1 != arms_util_readConfigValue(ARMS_SW_VERSION_FILE_PATH, "Project Rev", g_stFotaData.stFWVerArr[0].szFOTAFwVer))

+	{

+		strcpy(g_stFotaData.stFWVerArr[0].szFOTAFwVer,"N/A");

+	}

+

+	if (1 != arms_util_readConfigValue(ARMS_SW_VERSION_FILE_PATH, "Cute Rev", g_stFotaData.stFWVerArr[1].szFOTAFwVer))

+	{

+		strcpy(g_stFotaData.stFWVerArr[1].szFOTAFwVer,"N/A");

+	}

+

+	memcpy(pVerFW,g_stFotaData.stFWVerArr,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+#endif

+#endif

+	char buf[64] = {0};

+	cfg_get_item("wa_version", buf, sizeof(buf));

+	memset(g_stFotaData.stFWVerArr,0,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+	strcpy(g_stFotaData.stFWVerArr[0].szFOTAFwVer, buf);

+	strcpy(g_stFotaData.stFWVerArr[1].szFOTAFwVer, buf);

+	memcpy(pVerFW, g_stFotaData.stFWVerArr, sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+	printf("****arms_data_example_get_fota_ver_fw version:%s\n", pVerFW->szFOTAFwVer);

+

+	return 0;

+}

+

+int arms_data_example_get_fota_ver_cfg(PFOTADATAFCFG pVerCfg)

+{

+	if (pVerCfg == NULL)

+		return -1;

+	

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stCFGVerArr,0,sizeof(FOTADATAFCFG)*ARMS_FOTA_CFG_VER_NUM);

+	memcpy(pVerCfg,g_stFotaData.stCFGVerArr,sizeof(FOTADATAFCFG)*ARMS_FOTA_CFG_VER_NUM);

+#endif

+

+	return 0;	

+}

+

+int arms_data_example_get_fota_ver_mcu(PFOTADATAMCU pVerMCU)

+{

+	if (pVerMCU == NULL)

+		return -1;

+	

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stMCUVerArry,0,sizeof(FOTADATAMCU)*ARMS_FOTA_MCU_VER_NUM);

+	memcpy(pVerMCU,g_stFotaData.stMCUVerArry,sizeof(FOTADATAMCU)*ARMS_FOTA_MCU_VER_NUM);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_net_status(void)

+{

+	int ret = 0;

+	

+#ifdef EXAMPLE_REF_VALUE

+	ret = 1;

+#endif

+

+	return ret;

+}

+

+int arms_data_example_get_fota_task_id(unsigned int *pTaskId)

+{

+	if (pTaskId == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pTaskId = g_stFotaData.nTaskId;

+#endif

+	char buf[16] = {0};

+	cfg_get_item("arms_task_id", buf, sizeof(buf));

+	*pTaskId = atoi(buf);

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_task_id(unsigned int nTaskId)

+{	

+#ifdef EXAMPLE_REF_VALUE

+	g_stFotaData.nTaskId = nTaskId;

+#endif

+	printf("******task id:%u\n", nTaskId);

+	char buf[16] = {0};

+	sprintf(buf, "%u", nTaskId);

+	cfg_set("arms_task_id", buf);

+	cfg_save();

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_device_id(char *pDevId)

+{

+	if (pDevId == NULL)

+		return -1;

+	

+#ifdef EXAMPLE_REF_VALUE

+	strcpy(pDevId,g_stFotaData.cDeviceId);

+#endif

+	char buf[ARMS_FOTA_DEVICE_ID_BUF_SIZE] = {0};

+	cfg_get_item("arms_device_id", buf, sizeof(buf));

+	strcpy(pDevId, buf);

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_device_id(char *pDevId)

+{

+	if (pDevId == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.cDeviceId,0,sizeof(g_stFotaData.cDeviceId));

+	strcpy(g_stFotaData.cDeviceId,pDevId);

+#endif

+	printf("******device_id:%s\n", pDevId);

+	cfg_set("arms_device_id", pDevId);

+	cfg_save();

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_device_sec(char *pDevSec)

+{

+	if (pDevSec == NULL)

+		return -1;

+	

+#ifdef EXAMPLE_REF_VALUE

+	strcpy(pDevSec,g_stFotaData.cDeviceSec);

+#endif

+	char buf[ARMS_FOTA_DEVICE_SEC_BUF_SIZE] = {0};

+	cfg_get_item("arms_device_sec", buf, sizeof(buf));

+	strcpy(pDevSec, buf);

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_device_sec(char *pDevSec)

+{

+	if (pDevSec == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.cDeviceSec,0,sizeof(g_stFotaData.cDeviceSec));

+	strcpy(g_stFotaData.cDeviceSec,pDevSec);

+#endif

+	printf("******device_sec:%s\n", pDevSec);

+	cfg_set("arms_device_sec", pDevSec);

+	cfg_save();

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_deviceid_md5(char *pDevIdMD5)

+{

+	if (pDevIdMD5 == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	strcpy(pDevIdMD5,g_stFotaData.cDeviceidMD5);

+#endif

+	char buf[ARMS_FOTA_DEVICEID_MD5_BUF_SIZE] = {0};

+	cfg_get_item("arms_device_md5", buf, sizeof(buf));

+	strcpy(pDevIdMD5, buf);

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_deviceid_md5(char *pDevIdMD5)

+{

+	if (pDevIdMD5 == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.cDeviceidMD5,0,sizeof(g_stFotaData.cDeviceidMD5));

+	strcpy(g_stFotaData.cDeviceidMD5,pDevIdMD5);

+#endif

+	printf("******deviceid_md5:%s\n", pDevIdMD5);

+	cfg_set("arms_device_md5", pDevIdMD5);

+	cfg_save();

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_pre_version_fw(PFOTADATAFW pPreVerFW)

+{

+	if (pPreVerFW == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memcpy(pPreVerFW,g_stFotaData.stFWPreVerArr,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+#endif

+	char buf[64] = {0};

+	cfg_get_item("arms_fota_version", buf, sizeof(buf));

+	strcpy(pPreVerFW->szFOTAFwVer, buf);

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_pre_version_fw(PFOTADATAFW pPreVerFW)

+{

+	if (pPreVerFW == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stFWPreVerArr,0,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+	memcpy(g_stFotaData.stFWPreVerArr,pPreVerFW,sizeof(FOTADATAFW)*ARMS_FOTA_FW_VER_NUM);

+#endif

+	printf("******pPreVerFW version:%s, nFOTAFwRet:%d\n", pPreVerFW->szFOTAFwVer, pPreVerFW->nFOTAFwRet);

+	cfg_set("arms_fota_version", pPreVerFW->szFOTAFwVer);

+	cfg_save();

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_pre_version_cfg(PFOTADATAFCFG pPreVerCFG)

+{

+	if (pPreVerCFG == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memcpy(pPreVerCFG,g_stFotaData.stCFGPreVerArr,sizeof(FOTADATAFCFG)*ARMS_FOTA_CFG_VER_NUM);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_pre_version_cfg(PFOTADATAFCFG pPreVerCFG)

+{

+	if (pPreVerCFG == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stCFGPreVerArr,0,sizeof(FOTADATAFCFG)*ARMS_FOTA_CFG_VER_NUM);

+	memcpy(g_stFotaData.stCFGPreVerArr,pPreVerCFG,sizeof(FOTADATAFCFG)*ARMS_FOTA_CFG_VER_NUM);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_pre_version_mcu(PFOTADATAMCU pPreVerMCU)

+{

+	if (pPreVerMCU == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memcpy(pPreVerMCU,g_stFotaData.stMCUPreVerArry,sizeof(PFOTADATAMCU)*ARMS_FOTA_MCU_VER_NUM);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_pre_version_mcu(PFOTADATAMCU pPreVerMCU)

+{

+	if (pPreVerMCU == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.stMCUPreVerArry,0,sizeof(PFOTADATAMCU)*ARMS_FOTA_MCU_VER_NUM);

+	memcpy(g_stFotaData.stMCUPreVerArry,pPreVerMCU,sizeof(PFOTADATAMCU)*ARMS_FOTA_MCU_VER_NUM);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_backup(char *pBackup)

+{

+	if (pBackup == NULL)

+		return -1;

+	

+#ifdef EXAMPLE_REF_VALUE

+	memcpy(pBackup,g_stFotaData.cBackup,ARMS_FOTA_BACKUP_BUF_SIZE);

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_backup(char *pBackup)

+{

+	if (pBackup == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	memset(g_stFotaData.cBackup,0,sizeof(g_stFotaData.cBackup));

+	memcpy(g_stFotaData.cBackup,pBackup,sizeof(g_stFotaData.cBackup));

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_get_fota_down_size(unsigned int *pDownSize)

+{

+	if (pDownSize == NULL)

+		return -1;

+

+#ifdef EXAMPLE_REF_VALUE

+	*pDownSize = g_stFotaData.nDownSize;

+#endif

+

+	return 0;		

+}

+

+int arms_data_example_save_fota_down_size(unsigned int nDownSize)

+{

+#ifdef EXAMPLE_REF_VALUE

+	g_stFotaData.nDownSize = nDownSize;

+#endif

+

+	return 0;	

+}

+

+#define FOTA_UPDATE_STATUS_FILE "/cache/zte_fota/update_status"

+

+int fota_is_file_exist(const char* path)

+{

+	if ( (path == NULL) || (*path == '\0') )

+		return 0;

+	if (access(path, R_OK) != 0)

+		return 0;

+

+	return 1;

+}

+

+int fota_read_file(const char*path, char*buf, size_t sz)

+{

+	int fd = -1;

+	size_t cnt;

+

+	fd = open(path, O_RDONLY, 0);

+	if(fd < 0)

+	{

+		printf("fota_read_file failed to open %s\n", path);

+		cnt = -1;

+		return cnt;

+	}

+	cnt = read(fd, buf, sz - 1);

+	if(cnt <= 0)

+	{

+		printf("failed to read %s\n", path);

+		close(fd);

+		cnt = -1;

+		return cnt;

+	}

+	buf[cnt] = '\0';

+	if(buf[cnt - 1] == '\n')

+	{

+		cnt--;

+		buf[cnt] = '\0';

+	}

+	close(fd);

+

+	return cnt;

+}

+

+int fota_read_file_int(const char* path, int *val)

+{

+	char buf[32];

+	char *end;

+	int ret;

+	int tmp;

+

+	ret = fota_read_file(path, buf, sizeof(buf));

+	if(ret < 0)

+		return -1;

+

+	tmp = strtol(buf, &end, 0);

+	if ((end == buf) || ((end < buf + sizeof(buf)) && (*end != '\0')))

+	{

+		return -1;

+	}

+

+	*val = tmp;

+

+	return 0;

+}

+

+int fota_get_update_status(int *fota_status)

+{

+

+	int status = 0;

+	int ret = 0;

+	if(!fota_is_file_exist(FOTA_UPDATE_STATUS_FILE))

+	{

+		printf("fota_get_update_status file not exist\n");

+		*fota_status = -1;

+		return -1;

+	}

+	ret = fota_read_file_int(FOTA_UPDATE_STATUS_FILE, &status);

+	if(ret < 0) {

+		printf("fota_get_update_status read update_status error\n");

+		*fota_status = -1;

+		return -1;

+	}

+	printf("fota_get_update_status read status:%d\n", status);

+	*fota_status = status;

+

+	return 0;

+}

+

+int arms_data_example_upgrade(char *pPath)

+{

+	if (pPath == NULL)

+		return -1;

+

+	int upgradeStatus = 0;

+	int result = 0;

+

+	printf("arms_data_example_upgrade upgrade file path:[%s]\n");

+	system("fota_upi -u verify");

+	result = fota_get_update_status(&upgradeStatus);

+	if(result < 0)

+	{

+		printf("arms_data_example_upgrade failed to read the update_status file\n");

+		return -1;

+	}

+	else if(upgradeStatus != 0)

+	{

+		printf("arms_data_example_upgrade verify failed\n");

+		return -1;

+	}

+	else

+	{

+		printf("arms_data_example_upgrade verify success, start upgrade!\n");

+		system("fota_upi -u recovery");

+	}

+

+#ifdef EXAMPLE_REF_VALUE

+	//remove(pPath);

+#endif

+

+	return 0;	

+}

+

+int arms_data_example_get_region_size(unsigned int* pRegionSize)

+{

+	if (pRegionSize == NULL)

+		return -1;

+

+	*pRegionSize = 20*1024*1024;

+	

+	return 0;

+}

+

+int arms_data_example_get_log(char *pPath, int *pPathLen, char *pFileName, int *pFileNameLen)

+{

+	if ((pPath == NULL) || (pPathLen == NULL) || (pFileName == NULL) || (pFileNameLen == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	

+	if (strlen(ARMS_LOG_FILE_PATH) >= *pPathLen)

+		return -1;

+

+	if (strlen(ARMS_LOG_FILE_NAME) >= *pFileNameLen)

+		return -1;

+

+	strcpy(pPath, ARMS_LOG_FILE_PATH);

+	strcpy(pFileName, ARMS_LOG_FILE_NAME);

+	

+	return 0;

+}

+

+#endif

+

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/apparms_data_example.h b/lynq/S300/ap/app/apparms/apparms_data_example.h
new file mode 100755
index 0000000..c02b9e5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_data_example.h
@@ -0,0 +1,69 @@
+#ifndef _APPARMS_DATA_EXAMPLE_HEAD

+#define _APPARMS_DATA_EXAMPLE_HEAD

+

+#include "apparms_data_os.h"

+#include "apparms_config_example_srv.h"

+

+

+#ifdef ARMS_BOARD_EXAMPLE

+

+PARMSDATAFUNLIST arms_data_example_get_cfgfun_pointer(void);

+

+int arms_data_example_set_waketime(unsigned long uHWId, long long nNowInSec, unsigned short nIntervalInSec);

+int arms_data_example_get_suspend(unsigned long uHWId, int* pSuspend);

+int arms_data_example_get_timestamp(unsigned long* pTimeStamp);

+

+#ifdef ARMS_SUPPORT_DM

+int arms_data_example_get_dm_header_tag(unsigned char* pTag);

+int arms_data_example_get_dm_header_event(unsigned short* pEvent);

+int arms_data_example_get_dm_generic_pid(unsigned char* pID);

+int arms_data_example_get_dm_generic_gps(PDMGPSDATA pGPS);

+int arms_data_example_get_dm_generic_battchg(PDMBATTCHGDATA pBattChg);

+int arms_data_example_get_dm_generic_network(PDMNETWORKDATA pNetwork);

+int arms_data_example_get_dm_generic_gpio(PDMGPIODATA pGpio);

+int arms_data_example_get_dm_generic_odometer(unsigned long* pOdometer);

+int arms_data_example_get_dm_version(PDMVERSIONDATA pVersion);

+int arms_data_example_get_dm_extver(PDMEXTVERDATA pExtver);

+int arms_data_example_get_dm_dmreport_pricell(PDMREPORTPRICELL pDMRptPriCell);

+int arms_data_example_get_dm_dmreport_nbcell(PDMREPORTNBCELL pDMRptNBCell);

+int arms_data_example_get_dm_dmreport_light(PDMREPORTLIGHTDATA pDMRptLight);

+int arms_data_example_get_dm_dmreport_macsim(PDMREPORTMACSIM pDMRptMacSim);

+int arms_data_example_get_dm_cusdata(unsigned char index, int* pLen, unsigned char* pData);

+int arms_data_example_handle_dm_ack_pushmsg(unsigned char* pInData, int nInLen,unsigned char* pOutData, int *pOutLen);

+int arms_data_example_handle_dm_ack_ok(void);

+int arms_data_example_handle_dm_ack_fail(int nType);

+

+#endif

+

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_data_example_get_fota_ret(PFOTARET pFOTRet);

+int arms_data_example_get_fota_ver_fw(PFOTADATAFW pVerFW);

+int arms_data_example_get_fota_ver_cfg(PFOTADATAFCFG pVerCfg);

+int arms_data_example_get_fota_ver_mcu(PFOTADATAMCU pVerMCU);

+int arms_data_example_get_fota_net_status(void);

+int arms_data_example_get_fota_task_id(unsigned int *pTaskId);

+int arms_data_example_save_fota_task_id(unsigned int nTaskId);

+int arms_data_example_get_fota_device_id(char *pDevId);

+int arms_data_example_save_fota_device_id(char *pDevId);

+int arms_data_example_get_fota_device_sec(char *pDevSec);

+int arms_data_example_save_fota_device_sec(char *pDevSec);

+int arms_data_example_get_fota_deviceid_md5(char *pDevIdMD5);

+int arms_data_example_save_fota_deviceid_md5(char *pDevIdMD5);

+int arms_data_example_get_fota_pre_version_fw(PFOTADATAFW pPreVerFW);

+int arms_data_example_save_fota_pre_version_fw(PFOTADATAFW pPreVerFW);

+int arms_data_example_get_fota_pre_version_cfg(PFOTADATAFCFG pPreVerCFG);

+int arms_data_example_save_fota_pre_version_cfg(PFOTADATAFCFG pPreVerCFG);

+int arms_data_example_get_fota_pre_version_mcu(PFOTADATAMCU pPreVerMCU);

+int arms_data_example_save_fota_pre_version_mcu(PFOTADATAMCU pPreVerMCU);

+int arms_data_example_get_fota_backup(char *pBackup);

+int arms_data_example_save_fota_backup(char *pBackup);

+int arms_data_example_get_fota_down_size(unsigned int *pDownSize);

+int arms_data_example_save_fota_down_size(unsigned int nDownSize);

+int arms_data_example_upgrade(char *pPath);

+int arms_data_example_get_region_size(unsigned int* pRegionSize);

+int arms_data_example_get_log(char *pPath, int *pPathLen, char *pFileName, int *pFileNameLen);

+#endif

+

+#endif

+#endif

diff --git a/lynq/S300/ap/app/apparms/apparms_data_os.c b/lynq/S300/ap/app/apparms/apparms_data_os.c
new file mode 100755
index 0000000..1718b33
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_data_os.c
@@ -0,0 +1,529 @@
+#include "apparms_data_os.h"

+

+int arms_data_os_get_timestamp(PARMSDATAFUNLIST pFunc, unsigned long* pTimeStamp)

+{

+	if ((pFunc == NULL) || (pTimeStamp == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetTimestamp == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetTimestamp)(pTimeStamp);

+}

+

+int arms_data_os_get_suspend(PARMSDATAFUNLIST pFunc, unsigned long uHWId, int* pSuspend)

+{

+	if ((pFunc == NULL) || (uHWId == 0))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetSuspend == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetSuspend)(uHWId, pSuspend);

+}

+

+int arms_data_os_set_waketime(PARMSDATAFUNLIST pFunc, unsigned long uHWId, long long nNowInSec, unsigned short nIntervalInSec)

+{

+	if ((pFunc == NULL) || (uHWId == 0))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SetWakeTime == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SetWakeTime)(uHWId, nNowInSec, nIntervalInSec);

+}

+

+#ifdef ARMS_SUPPORT_DM

+int arms_data_os_get_dm_header_tag(PARMSDATAFUNLIST pFunc, unsigned char* pTag)

+{

+	if ((pFunc == NULL) || (pTag == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMHeaderTag == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMHeaderTag)(pTag);

+}

+

+int arms_data_os_get_dm_header_event(PARMSDATAFUNLIST pFunc, unsigned short* pEvent)

+{

+	if ((pFunc == NULL) || (pEvent == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMHeaderEvent == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMHeaderEvent)(pEvent);

+}

+

+int arms_data_os_get_dm_generic_pid(PARMSDATAFUNLIST pFunc, unsigned char* pID)

+{

+	if ((pFunc == NULL) || (pID == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericPID == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericPID)(pID);

+}

+

+int arms_data_os_get_dm_generic_gps(PARMSDATAFUNLIST pFunc, PDMGPSDATA pGPS)

+{

+	if ((pFunc == NULL) || (pGPS == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericGPS == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericGPS)(pGPS);

+}

+

+int arms_data_os_get_dm_generic_battchg(PARMSDATAFUNLIST pFunc, PDMBATTCHGDATA pBattChg)

+{

+	if ((pFunc == NULL) || (pBattChg == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericBattChg == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericBattChg)(pBattChg);

+}

+

+int arms_data_os_get_dm_generic_network(PARMSDATAFUNLIST pFunc, PDMNETWORKDATA pNetwork)

+{

+	if ((pFunc == NULL) || (pNetwork == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericNetwork == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericNetwork)(pNetwork);	

+}

+

+int arms_data_os_get_dm_generic_gpio(PARMSDATAFUNLIST pFunc, PDMGPIODATA pGpio)

+{

+	if ((pFunc == NULL) || (pGpio == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericGpio == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericGpio)(pGpio);	

+}

+

+int arms_data_os_get_dm_generic_odometer(PARMSDATAFUNLIST pFunc, unsigned long* pOdometer)

+{

+	if ((pFunc == NULL) || (pOdometer == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMGenericOdometer == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMGenericOdometer)(pOdometer);

+}

+

+int arms_data_os_get_dm_version(PARMSDATAFUNLIST pFunc, PDMVERSIONDATA pVersion)

+{

+	if ((pFunc == NULL) || (pVersion == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMVersion == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMVersion)(pVersion);

+		

+}

+

+int arms_data_os_get_dm_extver(PARMSDATAFUNLIST pFunc, PDMEXTVERDATA pExtver)

+{

+	if ((pFunc == NULL) || (pExtver == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMExtver == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMExtver)(pExtver);			

+}

+

+int arms_data_os_get_dm_dmreport_pricell(PARMSDATAFUNLIST pFunc, PDMREPORTPRICELL pDMRptPriCell)

+{

+	if ((pFunc == NULL) || (pDMRptPriCell == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMReportPriCell == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMReportPriCell)(pDMRptPriCell);		

+}

+

+int arms_data_os_get_dm_dmreport_nbcell(PARMSDATAFUNLIST pFunc, PDMREPORTNBCELL pDMRptNBCell)

+{

+	if ((pFunc == NULL) || (pDMRptNBCell == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMReportNBCell == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMReportNBCell)(pDMRptNBCell);

+}

+

+int arms_data_os_get_dm_dmreport_light(PARMSDATAFUNLIST pFunc, PDMREPORTLIGHTDATA pDMRptLight)

+{

+	if ((pFunc == NULL) || (pDMRptLight == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMReportLight == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMReportLight)(pDMRptLight);

+}

+

+int arms_data_os_get_dm_dmreport_macsim(PARMSDATAFUNLIST pFunc, PDMREPORTMACSIM pDMRptMacSim)

+{

+	if ((pFunc == NULL) || (pDMRptMacSim == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMReportMacSim == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMReportMacSim)(pDMRptMacSim);

+}

+

+int arms_data_os_get_dm_cusdata(PARMSDATAFUNLIST pFunc, unsigned char index, int *pLen, unsigned char *pData)

+{

+	if ((pFunc == NULL) || (pLen == NULL) || (pData == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetDMCusData == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetDMCusData)(index,pLen,pData);			

+}

+

+int arms_data_os_handle_dm_ack_fail(PARMSDATAFUNLIST pFunc, int nType)

+{

+	if (pFunc == NULL)

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->HandleDMFail == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->HandleDMFail)(nType);			

+}

+

+int arms_data_os_handle_dm_ack_ok(PARMSDATAFUNLIST pFunc)

+{

+	if (pFunc == NULL)

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->HandleDMOK == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->HandleDMOK)();			

+}

+

+int arms_data_os_handle_dm_ack_pushmsg(PARMSDATAFUNLIST pFunc, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen)

+{

+	if ((pFunc == NULL) || (pInData == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->HandleDMPushMsg == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->HandleDMPushMsg)(pInData,nInLen,pOutData,pOutLen);			

+}

+

+#endif

+

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_data_os_get_fota_ret(PARMSDATAFUNLIST pFunc,PFOTARET pFOTARet)

+{

+	if ((pFunc == NULL) || (pFOTARet == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAReT == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAReT)(pFOTARet);

+}

+

+int arms_data_os_get_fota_ver_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pVerFW)

+{

+	if ((pFunc == NULL) || (pVerFW == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAVerFw == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAVerFw)(pVerFW);

+}

+

+int arms_data_os_get_fota_ver_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pVerCfg)

+{

+	if ((pFunc == NULL) || (pVerCfg == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAVerCfg == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAVerCfg)(pVerCfg);

+}

+

+int arms_data_os_get_fota_ver_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pVerMCU)

+{

+	if ((pFunc == NULL) || (pVerMCU == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAVerMCU == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAVerMCU)(pVerMCU);

+}

+

+int arms_data_os_get_net_status(PARMSDATAFUNLIST pFunc)

+{

+	if ((pFunc == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTANetStatus == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTANetStatus)();

+}

+

+int arms_data_os_get_task_id(PARMSDATAFUNLIST pFunc,unsigned int *pTaskId)

+{

+	if ((pFunc == NULL) || (pTaskId == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTATaskId == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTATaskId)(pTaskId);

+}

+

+int arms_data_os_set_task_id(PARMSDATAFUNLIST pFunc,unsigned int nTaskId)

+{

+	if ((pFunc == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTATaskId == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTATaskId)(nTaskId);

+}

+

+int arms_data_os_get_device_id(PARMSDATAFUNLIST pFunc,char *pDevId)

+{

+	if ((pFunc == NULL) || (pDevId == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTADeviceId == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTADeviceId)(pDevId);

+}

+

+int arms_data_os_set_device_id(PARMSDATAFUNLIST pFunc,char *pDevId)

+{

+	if ((pFunc == NULL) || (pDevId == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTADeviceId == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTADeviceId)(pDevId);

+}

+

+int arms_data_os_get_device_sec(PARMSDATAFUNLIST pFunc,char *pDevSec)

+{

+	if ((pFunc == NULL) || (pDevSec == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTADeviceSec == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTADeviceSec)(pDevSec);

+}

+

+int arms_data_os_set_device_sec(PARMSDATAFUNLIST pFunc,char *pDevSec)

+{

+	if ((pFunc == NULL) || (pDevSec == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTADeviceSec == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTADeviceSec)(pDevSec);

+}

+

+int arms_data_os_get_deviceid_md5(PARMSDATAFUNLIST pFunc,char *pDevidMD5)

+{

+	if ((pFunc == NULL) || (pDevidMD5 == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTADeviceidMD5 == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTADeviceidMD5)(pDevidMD5);

+}

+

+int arms_data_os_set_deviceid_md5(PARMSDATAFUNLIST pFunc,char *pDevidMD5)

+{

+	if ((pFunc == NULL) || (pDevidMD5 == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTADeviceidMD5 == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTADeviceidMD5)(pDevidMD5);

+}

+

+int arms_data_os_get_pre_version_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pPreVerFW)

+{

+	if ((pFunc == NULL) || (pPreVerFW == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAPreVerFW == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAPreVerFW)(pPreVerFW);

+}

+

+int arms_data_os_set_pre_version_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pPreVerFW)

+{

+	if ((pFunc == NULL) || (pPreVerFW == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTAPreVerFW == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTAPreVerFW)(pPreVerFW);

+}

+

+int arms_data_os_get_pre_version_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pPreVerCFG)

+{

+	if ((pFunc == NULL) || (pPreVerCFG == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAPreVerCFG == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAPreVerCFG)(pPreVerCFG);

+}

+

+int arms_data_os_set_pre_version_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pPreVerCFG)

+{

+	if ((pFunc == NULL) || (pPreVerCFG == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTAPreVerCFG == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTAPreVerCFG)(pPreVerCFG);

+}

+

+int arms_data_os_get_pre_version_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pPreVerMCU)

+{

+	if ((pFunc == NULL) || (pPreVerMCU == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTAPreVerMCU == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTAPreVerMCU)(pPreVerMCU);

+}

+

+int arms_data_os_set_pre_version_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pPreVerMCU)

+{

+	if ((pFunc == NULL) || (pPreVerMCU == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTAPreVerMCU == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTAPreVerMCU)(pPreVerMCU);

+}

+

+

+

+int arms_data_os_get_backup(PARMSDATAFUNLIST pFunc,char *pBackup)

+{

+	if ((pFunc == NULL) || (pBackup == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTABackup == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTABackup)(pBackup);

+}

+

+int arms_data_os_set_backup(PARMSDATAFUNLIST pFunc,char *pBackup)

+{

+	if ((pFunc == NULL) || (pBackup == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTABackup == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTABackup)(pBackup);

+}

+

+int arms_data_os_get_down_size(PARMSDATAFUNLIST pFunc,unsigned int *pDownSize)

+{

+	if ((pFunc == NULL) || (pDownSize == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTADownSize == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTADownSize)(pDownSize);

+}

+

+int arms_data_os_set_down_size(PARMSDATAFUNLIST pFunc,unsigned int nDownSize)

+{

+	if ((pFunc == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTADownSize == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTADownSize)(nDownSize);

+}

+

+int arms_data_os_upgrade(PARMSDATAFUNLIST pFunc,char *pPath)

+{

+	if ((pFunc == NULL) || (pPath == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->SaveFOTAUpgrade == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->SaveFOTAUpgrade)(pPath);

+}

+

+int arms_data_os_get_region_size(PARMSDATAFUNLIST pFunc,unsigned int *pRegionSize)

+{

+	if ((pFunc == NULL) || (pRegionSize == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetFOTARegionSize == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetFOTARegionSize)(pRegionSize);

+}

+

+int arms_data_os_get_log(PARMSDATAFUNLIST pFunc, char *pPath, int *pPathLen, char *pFileName, int *pFileNameLen)

+{

+	if ((pFunc == NULL) || (pPath == NULL) || (pPathLen == NULL) || (pFileName == NULL) || (pFileNameLen == NULL))

+		return ARMS_DATA_POINT_NULL_ERROR;

+

+	if (pFunc->GetLog == NULL)

+		return ARMS_DATA_FUNC_POINT_NULL_ERROR;

+	

+	return (*pFunc->GetLog)(pPath, pPathLen, pFileName, pFileNameLen);

+}

+#endif

+

+

diff --git a/lynq/S300/ap/app/apparms/apparms_data_os.h b/lynq/S300/ap/app/apparms/apparms_data_os.h
new file mode 100755
index 0000000..bd56134
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_data_os.h
@@ -0,0 +1,336 @@
+#ifndef _APPARMS_DATA_OS_HEAD

+#define _APPARMS_DATA_OS_HEAD

+

+#include "apparms_macro.h"

+

+#ifdef ARMS_SUPPORT_FOTA

+#define ARMS_FOTA_FW_VER_BUF_SIZE 64

+#define ARMS_FOTA_CFG_VER_BUF_SIZE 64

+#define ARMS_FOTA_MCU_VER_BUF_SIZE 64

+

+#define ARMS_FOTA_FW_VER_NUM 2

+#define ARMS_FOTA_CFG_VER_NUM 1

+#define ARMS_FOTA_MCU_VER_NUM 2

+

+#define ARMS_FOTA_DEVICE_ID_BUF_SIZE 34

+#define ARMS_FOTA_DEVICE_SEC_BUF_SIZE 34

+#define ARMS_FOTA_DEVICEID_MD5_BUF_SIZE 128

+#define ARMS_FOTA_BACKUP_BUF_SIZE 4

+

+typedef struct _tagFOTADATAFW

+{

+	char szFOTAFwVer[ARMS_FOTA_FW_VER_BUF_SIZE];

+	int	 nFOTAFwRet;

+}FOTADATAFW,*PFOTADATAFW;

+

+typedef struct _tagFOTADATAFCFG

+{

+	char szFOTCfgVer[ARMS_FOTA_CFG_VER_BUF_SIZE];

+	int nFOTACfgRet;

+}FOTADATAFCFG,*PFOTADATAFCFG;

+

+typedef struct _tagFOTADATAMCU

+{

+	char szFOTMCUVer[ARMS_FOTA_MCU_VER_BUF_SIZE];

+	int nFOTAMCURet;

+}FOTADATAMCU,*PFOTADATAMCU;

+

+typedef struct _tagFOTARet

+{

+	int nFinalDownRet;

+	int nFinalDownCode;

+	int nFinalUpgRet;

+	int nFinalUpgCode;

+}FOTARET, *PFOTARET;

+

+typedef struct _tagFOTADATA

+{

+	FOTARET stFOTARet;

+	FOTADATAFW stFWVerArr[ARMS_FOTA_FW_VER_NUM];

+	FOTADATAFCFG stCFGVerArr[ARMS_FOTA_CFG_VER_NUM];

+	FOTADATAMCU stMCUVerArry[ARMS_FOTA_MCU_VER_NUM];

+	char cDeviceId[ARMS_FOTA_DEVICE_ID_BUF_SIZE];

+	char cDeviceSec[ARMS_FOTA_DEVICE_SEC_BUF_SIZE];

+	char cDeviceidMD5[ARMS_FOTA_DEVICEID_MD5_BUF_SIZE];

+	FOTADATAFW stFWPreVerArr[ARMS_FOTA_FW_VER_NUM];

+	FOTADATAFCFG stCFGPreVerArr[ARMS_FOTA_CFG_VER_NUM];

+	FOTADATAMCU stMCUPreVerArry[ARMS_FOTA_MCU_VER_NUM];

+	char cBackup[ARMS_FOTA_BACKUP_BUF_SIZE];

+	unsigned long timestamp;

+	unsigned int nRegionSize;

+	unsigned int nTaskId;

+	unsigned int nDownSize;

+}FOTADATA, *PFOTADATA;

+

+typedef int (*ARMS_DATA_FOTA_GET_RET)(PFOTARET);

+typedef int (*ARMS_DATA_FOTA_GET_VER_FW)(PFOTADATAFW);

+typedef int (*ARMS_DATA_FOTA_GET_VER_CFG)(PFOTADATAFCFG);

+typedef int (*ARMS_DATA_FOTA_GET_VER_MCU)(PFOTADATAMCU);

+typedef int (*ARMS_DATA_FOTA_GET_NET_STATUS)(void);

+typedef int (*ARMS_DATA_FOTA_GET_DATA)(char *);

+typedef int (*ARMS_DATA_FOTA_SAVE_DATA)(char *);

+typedef int (*ARMS_DATA_FOTA_GET_PRE_VER_FW)(PFOTADATAFW);

+typedef int (*ARMS_DATA_FOTA_SAVE_PRE_VER_FW)(PFOTADATAFW);

+typedef int (*ARMS_DATA_FOTA_GET_PRE_VER_CFG)(PFOTADATAFCFG);

+typedef int (*ARMS_DATA_FOTA_SAVE_PRE_VER_CFG)(PFOTADATAFCFG);

+typedef int (*ARMS_DATA_FOTA_GET_PRE_VER_MCU)(PFOTADATAMCU);

+typedef int (*ARMS_DATA_FOTA_SAVE_PRE_VER_MCU)(PFOTADATAMCU);

+typedef int (*ARMS_DATA_FOTA_GET_DATA_UINT)(unsigned int *);

+typedef int (*ARMS_DATA_FOTA_SAVE_DATA_UINT)(unsigned int);

+typedef int (*ARMS_DATA_FOTA_GET_LOG)(char*,int*,char*,int*);

+#endif

+

+

+#ifdef ARMS_SUPPORT_DM

+

+typedef struct _tagDMGPSDATA

+{

+	unsigned long gps_time;

+	double gps_lat;

+	double gps_lon;

+	unsigned char gps_speed;

+	unsigned short gps_heading;

+	short gps_altitude;

+	unsigned char gps_status;

+	unsigned char gps_sat_count;

+	double gps_HOP;

+}DMGPSDATA, *PDMGPSDATA;

+

+typedef struct _tagDMBATTCHGDATA

+{

+	unsigned short main_voltage;

+	unsigned short batt_voltage;

+	unsigned short aux_voltage;

+	unsigned short solar_voltage;

+	short tempeature;

+	unsigned char percentage;

+	unsigned short charge;	

+}DMBATTCHGDATA, *PDMBATTCHGDATA;

+

+typedef struct _tagDMNETWORKDATA

+{

+	unsigned char roaming;

+	unsigned char srvtype;

+	unsigned short nw_mcc;

+	unsigned short nw_mnc;

+	char nw_rssi;

+}DMNETWORKDATA, *PDMNETWORKDATA;

+

+typedef struct _tagDMGPIODATA

+{

+	unsigned char GPIOADir;

+	unsigned char GPIOAValue;

+	unsigned char GPIOBDir;

+	unsigned char GPIOBValue;

+	unsigned char GPIOCDir;

+	unsigned char GPIOCValue;

+	unsigned char GPIODDir;

+	unsigned char GPIODValue;

+

+	unsigned char GPIOEDir;

+	unsigned char GPIOEValue;

+	unsigned char GPIOFDir;

+	unsigned char GPIOFValue;

+	unsigned char GPIOGDir;

+	unsigned char GPIOGValue;

+	unsigned char GPIOHDir;

+	unsigned char GPIOHValue;

+}DMGPIODATA, *PDMGPIODATA;

+

+#define DM_VERSION_MAIN_BIT 4

+#define DM_VERSION_EXT_BIT 2

+#define DM_VERSION_FW_BIT 5

+#define DM_VERSION_MCU_BIT 4

+#define DM_VERSION_CFG_BIT 2

+#define DM_VERSION_MAX_BIT 5

+

+typedef struct _tagDMVERSIONDATA

+{

+	unsigned char main[DM_VERSION_MAIN_BIT*5];	//major.middle.minor.build

+	unsigned char ext[DM_VERSION_EXT_BIT*5];

+	unsigned char fw[DM_VERSION_FW_BIT*5];  //type.major.middle.minor.build

+	unsigned char mcu[DM_VERSION_MCU_BIT*5];	//major.middle.minor.build

+	unsigned char cfg[DM_VERSION_CFG_BIT*5];

+}DMVERSIONDATA, *PDMVERSIONDATA;

+

+typedef struct _tagDMEXTVERDATA

+{

+	unsigned char mcu2[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu3[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu4[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu5[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu6[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu7[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu8[DM_VERSION_MCU_BIT*5];

+	unsigned char mcu9[DM_VERSION_MCU_BIT*5];	

+}DMEXTVERDATA, *PDMEXTVERDATA;

+

+typedef struct _tagDMREPORTPRICELL

+{

+	unsigned short mcc;

+	unsigned short mnc;

+	unsigned long eci;

+}DMREPORTPRICELL, *PDMREPORTPRICELL;

+

+typedef struct _tagDMREPORTNBCELL

+{

+	unsigned short nb_mcc;

+	unsigned short nb_mnc;

+	unsigned long nb_eci;

+	unsigned char nb_rssi;

+}DMREPORTNBCELL, *PDMREPORTNBCELL;

+

+typedef struct _tagDMREPORTLIGHTDATA

+{

+	unsigned long lightlux;

+	unsigned short lightontime;

+	unsigned short lightofftime;

+	unsigned short lightdurationtime;

+}DMREPORTLIGHTDATA, *PDMREPORTLIGHTDATA;

+

+typedef struct _tagDMREPORTMACSIM

+{

+	unsigned char mdn[21];

+	unsigned char iccid[21];

+	unsigned char macaddr[13];

+}DMREPORTMACSIM, *PDMREPORTMACSIM;

+

+typedef int (*ARMS_DATA_DM_GET_HEADER_TAG)(unsigned char*);

+typedef int (*ARMS_DATA_DM_GET_HEADER_EVENT)(unsigned short*);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_PID)(unsigned char*);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_GPS)(PDMGPSDATA);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_BATTCHG)(PDMBATTCHGDATA);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_NETWORK)(PDMNETWORKDATA);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_GPIO)(PDMGPIODATA);

+typedef int (*ARMS_DATA_DM_GET_GENERIC_ODOMETER)(unsigned long*);

+typedef int (*ARMS_DATA_DM_GET_VERSION)(PDMVERSIONDATA);

+typedef int (*ARMS_DATA_DM_GET_EXTVER)(PDMEXTVERDATA);

+typedef int (*ARMS_DATA_DM_GET_DMREPORT_PRICELL)(PDMREPORTPRICELL);

+typedef int (*ARMS_DATA_DM_GET_DMREPORT_NBCELL)(PDMREPORTNBCELL);

+typedef int (*ARMS_DATA_DM_GET_DMREPORT_LIGHT)(PDMREPORTLIGHTDATA);

+typedef int (*ARMS_DATA_DM_GET_DMREPORT_MACSIM)(PDMREPORTMACSIM);

+typedef int (*ARMS_DATA_DM_GET_CUSDATA)(unsigned char, int*,unsigned char*);

+typedef int (*ARMS_DATA_DM_HANDLE_PUSHMSG)(unsigned char*,int,unsigned char*,int*);

+typedef int (*ARMS_DATA_DM_HANDLE_OK)(void);

+typedef int (*ARMS_DATA_DM_HANDLE_FAIL)(int);

+#endif

+

+

+typedef int (*ARMS_DATA_SET_WAKETIME)(unsigned long, long long, unsigned short);

+typedef int (*ARMS_DATA_GET_SUSPEND)(unsigned long, int*);

+typedef int (*ARMS_DATA_GET_TIEMSTAMP)(unsigned long*);

+

+typedef struct _tagARMSDataFunList

+{	

+#ifdef ARMS_SUPPORT_DM

+	ARMS_DATA_DM_GET_HEADER_TAG GetDMHeaderTag;

+	ARMS_DATA_DM_GET_HEADER_EVENT GetDMHeaderEvent;

+	ARMS_DATA_DM_GET_GENERIC_PID GetDMGenericPID;

+	ARMS_DATA_DM_GET_GENERIC_GPS GetDMGenericGPS;

+	ARMS_DATA_DM_GET_GENERIC_BATTCHG GetDMGenericBattChg;

+	ARMS_DATA_DM_GET_GENERIC_NETWORK GetDMGenericNetwork;	

+	ARMS_DATA_DM_GET_GENERIC_GPIO GetDMGenericGpio;

+	ARMS_DATA_DM_GET_GENERIC_ODOMETER GetDMGenericOdometer;	

+	ARMS_DATA_DM_GET_VERSION GetDMVersion;

+	ARMS_DATA_DM_GET_EXTVER GetDMExtver;

+	ARMS_DATA_DM_GET_DMREPORT_PRICELL GetDMReportPriCell;

+	ARMS_DATA_DM_GET_DMREPORT_NBCELL GetDMReportNBCell;

+	ARMS_DATA_DM_GET_DMREPORT_LIGHT GetDMReportLight;

+	ARMS_DATA_DM_GET_DMREPORT_MACSIM GetDMReportMacSim;	

+	ARMS_DATA_DM_GET_CUSDATA GetDMCusData;

+	ARMS_DATA_DM_HANDLE_PUSHMSG HandleDMPushMsg;

+	ARMS_DATA_DM_HANDLE_OK HandleDMOK;

+	ARMS_DATA_DM_HANDLE_FAIL HandleDMFail;

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+	ARMS_DATA_FOTA_GET_RET GetFOTAReT;

+	ARMS_DATA_FOTA_GET_VER_FW GetFOTAVerFw;

+	ARMS_DATA_FOTA_GET_VER_CFG GetFOTAVerCfg;

+	ARMS_DATA_FOTA_GET_VER_MCU GetFOTAVerMCU;

+	ARMS_DATA_FOTA_GET_NET_STATUS GetFOTANetStatus;

+	ARMS_DATA_FOTA_GET_DATA_UINT GetFOTATaskId;

+	ARMS_DATA_FOTA_SAVE_DATA_UINT SaveFOTATaskId;

+	ARMS_DATA_FOTA_GET_DATA GetFOTADeviceId;

+	ARMS_DATA_FOTA_SAVE_DATA SaveFOTADeviceId;

+	ARMS_DATA_FOTA_GET_DATA GetFOTADeviceSec;

+	ARMS_DATA_FOTA_SAVE_DATA SaveFOTADeviceSec;

+	ARMS_DATA_FOTA_GET_DATA GetFOTADeviceidMD5;

+	ARMS_DATA_FOTA_SAVE_DATA SaveFOTADeviceidMD5;

+	ARMS_DATA_FOTA_GET_PRE_VER_FW GetFOTAPreVerFW;

+	ARMS_DATA_FOTA_SAVE_PRE_VER_FW SaveFOTAPreVerFW;

+	ARMS_DATA_FOTA_GET_PRE_VER_CFG GetFOTAPreVerCFG;

+	ARMS_DATA_FOTA_SAVE_PRE_VER_CFG SaveFOTAPreVerCFG;

+	ARMS_DATA_FOTA_GET_PRE_VER_MCU GetFOTAPreVerMCU;

+	ARMS_DATA_FOTA_SAVE_PRE_VER_MCU SaveFOTAPreVerMCU;

+	ARMS_DATA_FOTA_GET_DATA GetFOTABackup;

+	ARMS_DATA_FOTA_SAVE_DATA SaveFOTABackup;

+	ARMS_DATA_FOTA_GET_DATA_UINT GetFOTADownSize;

+	ARMS_DATA_FOTA_SAVE_DATA_UINT SaveFOTADownSize;

+	ARMS_DATA_FOTA_SAVE_DATA SaveFOTAUpgrade;

+	ARMS_DATA_FOTA_GET_DATA_UINT GetFOTARegionSize;

+	ARMS_DATA_FOTA_GET_LOG GetLog;

+#endif

+

+	ARMS_DATA_SET_WAKETIME SetWakeTime;

+	ARMS_DATA_GET_SUSPEND GetSuspend;

+	ARMS_DATA_GET_TIEMSTAMP GetTimestamp;

+}ARMSDATAFUNLIST, *PARMSDATAFUNLIST;

+

+int arms_data_os_set_waketime(PARMSDATAFUNLIST pFunc, unsigned long uHWId, long long nNowInSec, unsigned short nIntervalInSec);

+int arms_data_os_get_suspend(PARMSDATAFUNLIST pFunc, unsigned long uHWId, int* pSuspend);

+int arms_data_os_get_timestamp(PARMSDATAFUNLIST pFunc, unsigned long* pTimeStamp);

+

+#ifdef ARMS_SUPPORT_DM

+int arms_data_os_get_dm_header_tag(PARMSDATAFUNLIST pFunc, unsigned char* pTag);

+int arms_data_os_get_dm_header_event(PARMSDATAFUNLIST pFunc, unsigned short* pEvent);

+

+int arms_data_os_get_dm_generic_pid(PARMSDATAFUNLIST pFunc, unsigned char* pID);

+int arms_data_os_get_dm_generic_gps(PARMSDATAFUNLIST pFunc, PDMGPSDATA pGPS);

+int arms_data_os_get_dm_generic_battchg(PARMSDATAFUNLIST pFunc, PDMBATTCHGDATA pBattChg);

+int arms_data_os_get_dm_generic_network(PARMSDATAFUNLIST pFunc, PDMNETWORKDATA pNetwork);

+int arms_data_os_get_dm_generic_gpio(PARMSDATAFUNLIST pFunc, PDMGPIODATA pGpio);

+int arms_data_os_get_dm_generic_odometer(PARMSDATAFUNLIST pFunc, unsigned long* pOdometer);

+int arms_data_os_get_dm_version(PARMSDATAFUNLIST pFunc, PDMVERSIONDATA pVersion);

+int arms_data_os_get_dm_extver(PARMSDATAFUNLIST pFunc, PDMEXTVERDATA pExtver);

+int arms_data_os_get_dm_dmreport_pricell(PARMSDATAFUNLIST pFunc, PDMREPORTPRICELL pDMRptPriCell);

+int arms_data_os_get_dm_dmreport_nbcell(PARMSDATAFUNLIST pFunc, PDMREPORTNBCELL pDMRptNBCell);

+int arms_data_os_get_dm_dmreport_light(PARMSDATAFUNLIST pFunc, PDMREPORTLIGHTDATA pDMRptLight);

+int arms_data_os_get_dm_dmreport_macsim(PARMSDATAFUNLIST pFunc, PDMREPORTMACSIM pDMRptMacSim);

+int arms_data_os_get_dm_cusdata(PARMSDATAFUNLIST pFunc, unsigned char index, int *pLen, unsigned char *pData);

+int arms_data_os_handle_dm_ack_pushmsg(PARMSDATAFUNLIST pFunc, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen);

+int arms_data_os_handle_dm_ack_fail(PARMSDATAFUNLIST pFunc, int nType);

+int arms_data_os_handle_dm_ack_ok(PARMSDATAFUNLIST pFunc);

+#endif

+

+#ifdef ARMS_SUPPORT_FOTA

+int arms_data_os_get_fota_ret(PARMSDATAFUNLIST pFunc,PFOTARET pFOTRet);

+int arms_data_os_get_fota_ver_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pVerFW);

+int arms_data_os_get_fota_ver_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pVerCfg);

+int arms_data_os_get_fota_ver_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pVerMCU);

+int arms_data_os_get_net_status(PARMSDATAFUNLIST pFunc);

+int arms_data_os_get_task_id(PARMSDATAFUNLIST pFunc,unsigned int *pTaskId);

+int arms_data_os_set_task_id(PARMSDATAFUNLIST pFunc,unsigned int nTaskId);

+int arms_data_os_get_device_id(PARMSDATAFUNLIST pFunc,char *pDevId);

+int arms_data_os_set_device_id(PARMSDATAFUNLIST pFunc,char *pDevId);

+int arms_data_os_get_device_sec(PARMSDATAFUNLIST pFunc,char *pDevSec);

+int arms_data_os_set_device_sec(PARMSDATAFUNLIST pFunc,char *pDevSec);

+int arms_data_os_get_deviceid_md5(PARMSDATAFUNLIST pFunc,char *pDevidMD5);

+int arms_data_os_set_deviceid_md5(PARMSDATAFUNLIST pFunc,char *pDevidMD5);

+int arms_data_os_get_pre_version_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pPreVerFW);

+int arms_data_os_set_pre_version_fw(PARMSDATAFUNLIST pFunc,PFOTADATAFW pPreVerFW);

+int arms_data_os_get_pre_version_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pPreVerCFG);

+int arms_data_os_set_pre_version_cfg(PARMSDATAFUNLIST pFunc,PFOTADATAFCFG pPreVerCFG);

+int arms_data_os_get_pre_version_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pPreVerMCU);

+int arms_data_os_set_pre_version_mcu(PARMSDATAFUNLIST pFunc,PFOTADATAMCU pPreVerMCU);

+int arms_data_os_get_backup(PARMSDATAFUNLIST pFunc,char *pBackup);

+int arms_data_os_set_backup(PARMSDATAFUNLIST pFunc,char *pBackup);

+int arms_data_os_get_down_size(PARMSDATAFUNLIST pFunc,unsigned int *pDownSize);

+int arms_data_os_set_down_size(PARMSDATAFUNLIST pFunc,unsigned int nDownSize);

+int arms_data_os_upgrade(PARMSDATAFUNLIST pFunc,char *pPath);

+int arms_data_os_get_region_size(PARMSDATAFUNLIST pFunc,unsigned int *pRegionSize);

+int arms_data_os_get_log(PARMSDATAFUNLIST pFunc, char *pPath, int *pPathLen, char *pFileName, int *pFileNameLen);

+#endif

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/apparms_dm.c b/lynq/S300/ap/app/apparms/apparms_dm.c
new file mode 100755
index 0000000..5c4c8ad
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_dm.c
@@ -0,0 +1,526 @@
+
+#include "apparms_dm.h"
+#include "apparms.h"
+#include "apparms_loop.h"
+
+#ifdef ARMS_SUPPORT_DM
+
+int arms_dm_thread_recv_cb(void* pVoidApp, int nSign)
+{
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSDM pARMSDM = &pApp->stARMSDM;
+	PDMSOCKRECV pSockRecv = &pARMSDM->stDMSock.dmsockrecv;
+
+	/*parse content here, 1: E0, 2: A0 or 3 AT command*/
+	ARMS_LOG_INFO("Received = [%d]\n", pSockRecv->nRecvSize);
+	if (pSockRecv->nRecvSize > 0)
+	{
+		int i, nCmdDebugLen;
+		char szCmdDebug[2048] = {0};
+	
+		nCmdDebugLen = sizeof(szCmdDebug) - 1;
+		for(i = 0; i < pSockRecv->nRecvSize; i++)
+		{
+			if (i >= (nCmdDebugLen / 2))
+				break;
+			
+			sprintf(szCmdDebug + i * 2, "%02X", pSockRecv->szRecvBuf[i]);
+		}
+		
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+		ARMS_LOG_INFO("(R:[%s], [%s])\n", pARMSDM->stDMCfg.stDMCommCfg.szIMEI, szCmdDebug);
+#else		
+		ARMS_LOG_INFO("[%s]\n", szCmdDebug);
+#endif
+
+		arms_loop_add_msg_event(&pApp->stARMSLOOP, nSign, pSockRecv->szRecvBuf, pSockRecv->nRecvSize, -1);
+	}
+	
+	return 0;
+}
+
+int arms_dm_thread_send_and_recv(PARMSDM pARMSDM)
+{
+//#ifdef EXAMPLE_REF_VALUE
+	int i, nCmdDebugLen;
+	char szCmdDebug[2048] = {0};
+	unsigned char* pSendBuf;
+	PDMSOCKSEND pDMSockSend = &pARMSDM->stDMSock.dmsocksend;
+
+	pSendBuf = ((pDMSockSend->pSendBuf == NULL) ? pDMSockSend->szSendBuf : pDMSockSend->pSendBuf);
+
+	ARMS_LOG_INFO("Sending: = [%d]\n", pDMSockSend->nSendSize);
+	nCmdDebugLen = sizeof(szCmdDebug) - 1;
+	for(i = 0; i < pDMSockSend->nSendSize; i++)
+	{
+		if (i >= (nCmdDebugLen / 2))
+			break;
+		
+		sprintf(szCmdDebug + i * 2, "%02X", pSendBuf[i]);
+	}
+	
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE	
+	ARMS_LOG_INFO("(S:[%s], [%s])\n", pARMSDM->stDMCfg.stDMCommCfg.szIMEI, szCmdDebug);
+#else
+	ARMS_LOG_INFO("[%s]\n", szCmdDebug);
+#endif	
+//#endif
+
+	arms_sock_dm_send_and_recv_with_server(&pARMSDM->stDMSock);
+
+	return 0; 
+}
+
+int arms_dm_thread_prepare_report_telemetry_refresh(PARMSDM pARMSDM)
+{
+	unsigned char index = 0;
+	PDMCOMMCFG pDMCommCfg = &pARMSDM->stDMCfg.stDMCommCfg;
+	
+	if (pARMSDM->stDMData.atrackseq >= 0xFFFF)
+		pARMSDM->stDMData.atrackseq = 0;
+	
+	arms_atracs_get_report_header(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,
+									&pARMSDM->stDMData.stAtracsData.stAtracsHeader, pARMSDM->stDMData.atrackseq++, pDMCommCfg->szIMEI);
+
+	arms_atracs_get_report_generic(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsHeader,&pARMSDM->stDMData.stAtracsData.stAtracsGen);
+
+	arms_atracs_get_report_version(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsVersion);
+
+	arms_atracs_get_report_extver(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsExtver);
+
+	arms_atracs_get_report_token(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsHeader,pARMSDM->stDMData.stAtracsData.token, pDMCommCfg->szKey);
+
+	arms_atracs_get_report_dmreport(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsDMReport);
+	
+	for(index = 0; index < ATRACS_CUSDATA_TYPE_NUM; index++)
+		arms_atracs_get_report_cusdata(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMTLVCfg, index, &pARMSDM->stDMData.stAtracsData.stAtracsCusData[index]);
+	
+	return 0;
+}
+
+int arms_dm_thread_prepare_report_telemetry_construct(PARMSDM pARMSDM)
+{
+		
+	memset(pARMSDM->stDMSock.dmsocksend.szSendBuf, 0, sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf));
+	pARMSDM->stDMSock.dmsocksend.nSendSize = sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf);
+
+	arms_atracs_construct_report_telemetry(&pARMSDM->stDMCfg, &pARMSDM->stDMData.stAtracsData, 
+											pARMSDM->stDMSock.dmsocksend.szSendBuf,
+											&pARMSDM->stDMSock.dmsocksend.nSendSize);
+	
+	return 0;
+}
+
+
+int arms_dm_thread_prepare_report_telemetry(PARMSDM pARMSDM)
+{
+	arms_dm_thread_prepare_report_telemetry_refresh(pARMSDM);
+
+	arms_dm_thread_prepare_report_telemetry_construct(pARMSDM);
+	
+	return 0;
+}
+
+int arms_dm_thread_prepare_msg_response_refresh(PARMSDM pARMSDM, char* pBuf, int nLen)
+{	
+	PDMCOMMCFG pDMCommCfg = &pARMSDM->stDMCfg.stDMCommCfg;
+	
+	if (pARMSDM->stDMData.atrackseq >= 0xFFFF)
+		pARMSDM->stDMData.atrackseq = 0;
+	
+	arms_atracs_get_report_header(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMPushRspTLVCfg,
+									&pARMSDM->stDMData.stAtracsData.stAtracsHeader, pARMSDM->stDMData.atrackseq++, pDMCommCfg->szIMEI);
+
+	arms_atracs_get_report_version(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMPushRspTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsVersion);
+
+	arms_atracs_get_report_token(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMPushRspTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsHeader,pARMSDM->stDMData.stAtracsData.token, pDMCommCfg->szKey);
+
+	arms_atracs_get_push_response(&pARMSDM->stDMData.stAtracsData.stAtracsPushRsp, (unsigned char*)pBuf, nLen);
+
+	return 0;
+}
+
+int arms_dm_thread_prepare_msg_response_construct(PARMSDM pARMSDM)
+{		
+	memset(pARMSDM->stDMSock.dmsocksend.szSendBuf, 0, sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf));
+	pARMSDM->stDMSock.dmsocksend.nSendSize = sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf);
+
+	arms_atracs_construct_push_response_msg(&pARMSDM->stDMCfg, &pARMSDM->stDMData.stAtracsData, 
+											pARMSDM->stDMSock.dmsocksend.szSendBuf,
+											&pARMSDM->stDMSock.dmsocksend.nSendSize);
+	return 0;
+}
+
+
+int arms_dm_thread_prepare_msg_response(PARMSDM pARMSDM, char* pBuf, int nLen)
+{
+	arms_dm_thread_prepare_msg_response_refresh(pARMSDM, pBuf, nLen);
+
+	arms_dm_thread_prepare_msg_response_construct(pARMSDM);
+	
+	return 0;
+}
+
+
+int arms_dm_thread_prepare_trigger_notification_construct(PARMSDM pARMSDM)
+{	
+	pARMSDM->stDMSock.dmsocksend.nSendSize = sizeof(pARMSDM->stDMSock.dmsocksend.szSendBuf);
+	memset(pARMSDM->stDMSock.dmsocksend.szSendBuf, 0, pARMSDM->stDMSock.dmsocksend.nSendSize);
+
+	arms_atracs_construct_report_notifcation_msg(&pARMSDM->stDMCfg, &pARMSDM->stDMData.stAtracsData, 
+											pARMSDM->stDMSock.dmsocksend.szSendBuf,
+											&pARMSDM->stDMSock.dmsocksend.nSendSize);
+	return 0;
+}
+
+int arms_dm_thread_prepare_trigger_notification_refresh(PARMSDM pARMSDM, char* pBuf, int nLen)
+{	
+	PDMCOMMCFG pDMCommCfg = &pARMSDM->stDMCfg.stDMCommCfg;
+	unsigned char index = 0;
+	
+	if (pARMSDM->stDMData.atrackseq >= 0xFFFF)
+		pARMSDM->stDMData.atrackseq = 0;
+	
+	arms_atracs_get_report_header(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMNtfyTLVCfg,
+									&pARMSDM->stDMData.stAtracsData.stAtracsHeader, pARMSDM->stDMData.atrackseq++, pDMCommCfg->szIMEI);
+	
+	arms_atracs_get_report_generic(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMNtfyTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsHeader,&pARMSDM->stDMData.stAtracsData.stAtracsGen);
+
+	arms_atracs_get_report_version(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMNtfyTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsVersion);
+
+	arms_atracs_get_report_token(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMNtfyTLVCfg,&pARMSDM->stDMData.stAtracsData.stAtracsHeader,pARMSDM->stDMData.stAtracsData.token, pDMCommCfg->szKey);
+
+	arms_atracs_get_report_notifcation(&pARMSDM->stDMData.stAtracsData.stAtracsNtfy, (PATRACSDMNTFY)pBuf);
+
+	for(index = 0; index < ATRACS_CUSDATA_TYPE_NUM; index++)
+		arms_atracs_get_report_cusdata(pARMSDM->pDataFunList,&pARMSDM->stDMCfg.stDMNtfyTLVCfg, index, &pARMSDM->stDMData.stAtracsData.stAtracsCusData[index]);
+
+	return 0;
+}
+
+int arms_dm_thread_prepare_trigger_notification(PARMSDM pARMSDM, char* pBuf, int nLen)
+{
+	arms_dm_thread_prepare_trigger_notification_refresh(pARMSDM, pBuf, nLen);
+	
+	arms_dm_thread_prepare_trigger_notification_construct(pARMSDM);
+	
+	return 0;
+}
+
+static void* arms_dm_thread_handle(void* pVoid)
+{
+	int nSegRet;//, nSleepTime = 2;
+	int nRet = -1, nSig = -1,  nRecvLen = ARMS_DM_THREAD_BUF_LEN;
+	char *pNewMaclloc = NULL, pRecv[ARMS_DM_THREAD_BUF_LEN] = {0};
+	PARMSDM pARMSDM = (PARMSDM)pVoid;
+
+	prctl(PR_SET_NAME, "DM");
+	
+	if (pARMSDM == NULL)
+	{
+		return NULL;
+	}
+	
+	while (!pARMSDM->exitflag)
+	{
+		nRecvLen = ARMS_DM_THREAD_BUF_LEN;
+		pNewMaclloc = NULL;
+		nSig = -1;
+
+		nSegRet = arms_list_wait_msg_event(&pARMSDM->dm_signal,60);
+		if (nSegRet != 0)
+		{
+			ARMS_LOG_ERROR("%s(%d) dm thread sem_timedwait  errno = %d \n",__FUNCTION__,__LINE__, nSegRet);
+			sleep(2);
+		}
+
+		nRet = arms_list_get_msg_event(&pARMSDM->dm_signal,&nSig, pRecv, &nRecvLen, &pNewMaclloc);
+
+		if (nRet == ARMS_LIST_MSG_EMPTY_ERROR)
+			continue;
+		
+		ARMS_LOG_DEBUG("%s(%d) dm thread exe  nRet = %d \n",__FUNCTION__,__LINE__, nRet);
+		
+		if (nRet >= 0) 
+		{		
+			char *pData =  ((pNewMaclloc == NULL) ? pRecv : pNewMaclloc);
+			if ((pData != NULL) || (nSig == ARMS_SIGN_DM_REPORT_TELEMETRY))
+			{
+				pARMSDM->stDMSock.dmsocksend.pSendBuf = NULL;
+				pARMSDM->stDMSock.dmsocksend.nSendSize = 0;
+				memset(pARMSDM->stDMSock.dmsocksend.szSendBuf,0,ARMS_DM_SOCK_SEND_BUF_SIZE);
+				
+				switch (nSig)
+				{
+					case ARMS_SIGN_DM_REPORT_TELEMETRY:
+					{
+						nRet = arms_dm_thread_prepare_report_telemetry(pARMSDM);
+					}
+					break;
+
+					case ARMS_SIGN_DM_MSG_RESPONSE:
+					case ARMS_SIGN_DM_AGS_MSG_RESPONSE:	
+					{
+#ifdef ARMS_DM_UDP
+						if (pARMSDM->stDMSock.dmSockMode == ARMS_SOCK_MODE_DM_UDP)
+						{
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+							char cLastChar = '0';
+							int nIMEILen = strlen((char*)pARMSDM->stDMCfg.stDMCommCfg.szIMEI); 
+							
+							if(nIMEILen > 0)
+								cLastChar = pARMSDM->stDMCfg.stDMCommCfg.szIMEI[nIMEILen-1];
+
+							if(cLastChar < '2')
+							{
+								//last char of IMEI is 0 or 1, send the response with rsp header.
+								nRet = arms_dm_thread_prepare_msg_response(pARMSDM, pData, nRecvLen);
+							}
+							else
+#endif
+							{
+								//send the response directly without rsp header.
+								pARMSDM->stDMSock.dmsocksend.nSendSize = ((nRecvLen < ARMS_DM_SOCK_SEND_BUF_SIZE) ? nRecvLen : ARMS_DM_SOCK_SEND_BUF_SIZE);
+								memcpy(pARMSDM->stDMSock.dmsocksend.szSendBuf,pData,pARMSDM->stDMSock.dmsocksend.nSendSize);
+							}
+						}
+						else
+#endif
+						nRet = arms_dm_thread_prepare_msg_response(pARMSDM, pData, nRecvLen);
+					}
+					break;
+
+					case ARMS_SIGN_DM_TRIGGER_NOTIFICAITON:
+					{
+						nRet = arms_dm_thread_prepare_trigger_notification(pARMSDM, pData, nRecvLen);
+					}
+					break;	
+				}
+
+				if (pARMSDM->stDMSock.dmsocksend.nSendSize > 0)
+				{
+					#ifdef ARMS_DM_MQTT
+					PDMSOCKMQTT pMQTT = &pARMSDM->stDMSock.stsockmqtt;
+					if (nSig == ARMS_SIGN_DM_AGS_MSG_RESPONSE)
+						pMQTT->pubType = DM_MQTT_TOPIC_AGS;
+					else
+						pMQTT->pubType = DM_MQTT_TOPIC_RMS;
+					#endif
+					
+					arms_dm_thread_send_and_recv(pARMSDM);
+				}
+
+				if (pARMSDM->stDMSock.dmsocksend.pSendBuf != NULL)
+					free(pARMSDM->stDMSock.dmsocksend.pSendBuf);
+			}
+
+			if (pNewMaclloc != NULL)
+				free(pNewMaclloc);
+				
+			arms_list_post_msg_event(&pARMSDM->dm_signal); 
+		}	
+		
+	}
+	
+	ARMS_LOG_DEBUG("%s(%d) dm thread EXIT \n",__FUNCTION__,__LINE__);
+	return 0;
+}
+
+int arms_dm_start_thread(PARMSDM pARMSDM)
+{
+	if (pARMSDM == NULL)
+	{
+		return ARMS_DM_POINT_NULL_ERROR;
+	}
+	
+	pthread_attr_init (&pARMSDM->dm_thread_attr);
+	pthread_attr_setdetachstate (&pARMSDM->dm_thread_attr, PTHREAD_CREATE_DETACHED);
+	pthread_create(&pARMSDM->dm_thread_handle, &pARMSDM->dm_thread_attr, arms_dm_thread_handle, pARMSDM);
+
+	return 0;
+}
+
+int arms_dm_stop_thread(PARMSDM pARMSDM)
+{
+	if (pARMSDM == NULL)
+	{
+		return ARMS_DM_POINT_NULL_ERROR;
+	}
+	
+	pARMSDM->exitflag = 1;
+	arms_list_post_msg_event(&pARMSDM->dm_signal);
+	
+	return 0;
+}
+
+#ifdef ARMS_DM_REPORT_INTERVAL_VIA_TIMER
+void arms_dm_timer_cb(int signo) 
+{
+	PARMSDM pARMSDM = GetARMSAppDMSTPointer();
+	
+	arms_dm_add_report_telemetry_msg_event(pARMSDM);
+}
+
+int arms_dm_start_timer(PARMSDM pARMSDM)
+{
+	if (pARMSDM == NULL)
+	{
+		return ARMS_DM_POINT_NULL_ERROR;
+	}
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+	arms_util_create_timer_msec(&pARMSDM->dm_timer, arms_dm_timer_cb, 5*1000, pARMSDM->dm_report_period, SIGUSR1);
+#else
+	arms_util_create_timer_msec(&pARMSDM->dm_timer, arms_dm_timer_cb, 90*1000, pARMSDM->dm_report_period, SIGUSR1);
+#endif
+	return 0;
+}
+
+int arms_dm_stop_timer(PARMSDM pARMSDM)
+{
+	if (pARMSDM == NULL)
+	{
+		return ARMS_DM_POINT_NULL_ERROR;
+	}
+	
+	arms_util_destroy_timer_msec(&pARMSDM->dm_timer);
+
+	ARMS_LOG_DEBUG("%s(%d) dm timer EXIT \n",__FUNCTION__,__LINE__);
+	
+	return 0;
+}
+#endif
+
+static int arms_dm_init_msg_event(PARMSDM pARMSDM)
+{
+	arms_list_init_msg_event(&pARMSDM->dm_signal);
+	return 0;
+}
+
+static int arms_dm_destroy_msg_event(PARMSDM pARMSDM)
+{
+	arms_list_destroy_msg_event(&pARMSDM->dm_signal);
+	return 0;
+}
+
+int arms_dm_add_msg_event(PARMSDM pARMSDM,int nSig, unsigned char* pData, int nDataSize)
+{
+	return arms_list_add_msg_event(&pARMSDM->dm_signal, nSig, (char *)pData, nDataSize, -1);
+}
+
+int arms_dm_add_report_telemetry_msg_event(PARMSDM pARMSDM)
+{
+	return arms_dm_add_msg_event(pARMSDM, ARMS_SIGN_DM_REPORT_TELEMETRY, NULL, 0);
+}
+
+int arms_dm_add_push_response_event(int nSign, PARMSDM pARMSDM, char* pPushRsp, int nPushSize)
+{
+	return arms_dm_add_msg_event(pARMSDM, nSign, (unsigned char*)pPushRsp, nPushSize);
+}
+
+int arms_dm_add_report_notification_event(PARMSDM pARMSDM, PATRACSDMNTFY pPushRsp)
+{
+	return arms_dm_add_msg_event(pARMSDM, ARMS_SIGN_DM_TRIGGER_NOTIFICAITON, (unsigned char *)pPushRsp, sizeof(ATRACSDMNTFY));
+}
+
+static int arms_dm_init_sock(PARMSDM pARMSDM)
+{
+	PDMCOMMCFG pCommCfg = &pARMSDM->stDMCfg.stDMCommCfg;
+
+	pARMSDM->stDMSock.dmSockMode = ARMS_SOCK_MODE_DM_MAX;
+	
+	if (pCommCfg->emCommMode == ARMS_DM_COMM_UDP)
+	{
+		#ifdef ARMS_DM_UDP
+		pARMSDM->stDMSock.dmSockMode = ARMS_SOCK_MODE_DM_UDP;
+		strcpy(pARMSDM->stDMSock.stsockudp.szUDPAddr, pARMSDM->stDMCfg.stUDPCfg.szUDPAddr);
+		pARMSDM->stDMSock.stsockudp.nUDPPort = pARMSDM->stDMCfg.stUDPCfg.nUDPPort;
+		pARMSDM->stDMSock.stsockudp.nUDPFd = ARMS_INVALID_HANDLE;
+		#endif 
+	}
+	else if (pCommCfg->emCommMode == ARMS_DM_COMM_MQTT)
+	{
+		#ifdef ARMS_DM_MQTT
+		pARMSDM->stDMSock.dmSockMode = ARMS_SOCK_MODE_DM_MQTT;
+		pARMSDM->stDMSock.stsockmqtt.nLiveTime = pARMSDM->stDMCfg.stMQTTCfg.nMQTTLiveTM;
+		strcpy(pARMSDM->stDMSock.stsockmqtt.szHostAddr, pARMSDM->stDMCfg.stMQTTCfg.szMQTTAddr);
+		pARMSDM->stDMSock.stsockmqtt.nHostPort = pARMSDM->stDMCfg.stMQTTCfg.nMQTTPort;
+		strcpy(pARMSDM->stDMSock.stsockmqtt.clientID, pARMSDM->stDMCfg.stMQTTCfg.szUserName);
+		strcpy(pARMSDM->stDMSock.stsockmqtt.password, pARMSDM->stDMCfg.stMQTTCfg.szPassWord);
+		if(pCommCfg->emAuthMode == ARMS_DM_AUTH_CERT)
+		{
+			pARMSDM->stDMSock.stsockmqtt.tlsMode = 1;
+			#ifdef ARMS_AUTH_X509
+			strcpy(pARMSDM->stDMSock.stsockmqtt.caCert, pARMSDM->stDMCfg.stMQTTCfg.szCaCert);
+			strcpy(pARMSDM->stDMSock.stsockmqtt.clientCert, pARMSDM->stDMCfg.stMQTTCfg.szClientCert);
+			strcpy(pARMSDM->stDMSock.stsockmqtt.clientPriKey, pARMSDM->stDMCfg.stMQTTCfg.szClientKey);
+			#endif
+		}
+		sprintf(&pARMSDM->stDMSock.stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS][0],"mqtt/dn/%s",pARMSDM->stDMCfg.stMQTTCfg.szUserName);
+		sprintf(&pARMSDM->stDMSock.stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS][0],"mqtt/agsd/%s",pARMSDM->stDMCfg.stMQTTCfg.szUserName);
+
+		sprintf(&pARMSDM->stDMSock.stsockmqtt.pubTopic[DM_MQTT_TOPIC_RMS][0],"mqtt/up/%s",pARMSDM->stDMCfg.stMQTTCfg.szUserName);
+		sprintf(&pARMSDM->stDMSock.stsockmqtt.pubTopic[DM_MQTT_TOPIC_AGS][0],"mqtt/agsu/%s",pARMSDM->stDMCfg.stMQTTCfg.szUserName);
+		arms_sock_dm_mqtt_start_thread(pARMSDM);
+		#endif 
+	}
+	else if (pCommCfg->emCommMode == ARMS_DM_COMM_LWM2M)
+	{
+		#ifdef ARMS_DM_LWM2M
+		pARMSDM->stDMSock.dmSockMode = ARMS_SOCK_MODE_DM_LWM2M;
+		strcpy(pARMSDM->stDMSock.stsocklwm2m.szHostAddr, pARMSDM->stDMCfg.stLwM2MCfg.szLwM2MAddr);
+		pARMSDM->stDMSock.stsocklwm2m.nHostPort = pARMSDM->stDMCfg.stLwM2MCfg.nLwM2MPort;
+		strcpy(pARMSDM->stDMSock.stsocklwm2m.endpoint_name, pARMSDM->stDMCfg.stLwM2MCfg.szEndpointName);
+		arms_sock_dm_lwm2m_start_thread(&pARMSDM->stDMSock);
+		#endif
+	}
+
+	return 0;
+}
+
+#ifdef ARMS_DM_IPC
+static int arms_dm_init_ipc(PARMSDM pARMSDM)
+{
+	snprintf(pARMSDM->stDMIPC.stsockipc.szPort , 6, "%d", pARMSDM->stDMCfg.stIPCCfg.nPort);
+	pARMSDM->stDMIPC.stsockipc.uMaxclient = pARMSDM->stDMCfg.stIPCCfg.uMaxclient;
+	pARMSDM->stDMIPC.stsockipc.bDynamimode = pARMSDM->stDMCfg.stIPCCfg.bDynamicOpen;
+	pARMSDM->stDMIPC.stsockipc.bUnixmode = pARMSDM->stDMCfg.stIPCCfg.bUnixMode;
+	strcpy(pARMSDM->stDMIPC.stsockipc.szUnixPath, pARMSDM->stDMCfg.stIPCCfg.szUnixPath);
+	arms_dmipc_start_thread(&pARMSDM->stDMIPC, &pARMSDM->stDMCfg.stIPCCfg);
+
+	return 0;
+}
+#endif
+
+int arms_dm_init(void* pVoidApp)
+{
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSDM pARMSDM = &pApp->stARMSDM;
+	PDMCOMMCFG pCommCfg = &pARMSDM->stDMCfg.stDMCommCfg;
+	
+	arms_dm_init_sock(pARMSDM);
+	
+	arms_dm_init_msg_event(pARMSDM);
+
+	arms_sock_dm_reg_recv_cb(&pARMSDM->stDMSock, arms_dm_thread_recv_cb, pVoidApp);
+
+	pARMSDM->dm_report_period = pCommCfg->nReportPeriod;
+
+#ifdef ARMS_DM_IPC	
+	arms_dm_init_ipc(pARMSDM);
+#endif
+
+	return 0;
+}
+
+int arms_dm_uninit(void* pVoidApp)
+{
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSDM pARMSDM = &pApp->stARMSDM;
+	
+	arms_dm_destroy_msg_event(pARMSDM);
+	
+	return 0;
+}
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_dm.h b/lynq/S300/ap/app/apparms/apparms_dm.h
new file mode 100755
index 0000000..865024f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_dm.h
@@ -0,0 +1,72 @@
+
+#ifndef _APPARMS_DM
+#define _APPARMS_DM 1
+#ifdef ARMS_SUPPORT_DM
+
+#include "apparms_macro.h"
+#include "apparms_config_os.h"
+#include "apparms_data_os.h"
+#include "apparms_atracs.h"
+#include "apparms_list.h"
+#include "apparms_log.h"
+#include "apparms_sock.h"
+#ifdef ARMS_DM_IPC
+#include "apparms_dmipc.h"
+#endif
+#ifdef ARMS_DM_RPC
+#include "apparms_dmrpc.h"
+#endif
+
+
+#define ARMS_DM_THREAD_BUF_LEN 2048
+
+typedef struct _tagDMDATA
+{
+	unsigned short atrackseq;
+	ATRACSDATA stAtracsData;
+}DMDATA, *PDMDATA;
+
+typedef struct _tagARMSDM
+{
+	int exitflag;
+	pthread_t dm_thread_handle;
+	pthread_attr_t dm_thread_attr;
+	MSGMTXSEM dm_signal;
+	#ifdef ARMS_DM_REPORT_INTERVAL_VIA_TIMER
+	timer_t dm_timer;
+	#endif
+	unsigned int dm_report_period;
+
+	PARMSCFGFUNLIST pCfgFunList;
+	PARMSDATAFUNLIST pDataFunList;
+
+	DMSOCK stDMSock;
+	
+	DMCFG stDMCfg;
+	DMDATA stDMData;
+
+	#ifdef ARMS_DM_IPC
+	DMIPC stDMIPC;
+	#endif
+
+	#ifdef ARMS_DM_RPC
+	DMRPC stDMRPC;
+	#endif
+}ARMSDM, *PARMSDM;
+
+int arms_dm_start_thread(PARMSDM pARMSDM);
+int arms_dm_stop_thread(PARMSDM pARMSDM);
+
+int arms_dm_init(void* pVoidApp);
+int arms_dm_uninit(void* pVoidApp);
+
+int arms_dm_add_msg_event(PARMSDM pARMSDM,int nSig, unsigned char* pData, int nDataSize);
+int arms_dm_add_report_telemetry_msg_event(PARMSDM pARMSDM);
+int arms_dm_add_push_response_event(int nSign,PARMSDM pARMSDM, char* pPushRsp, int nPushSize);
+int arms_dm_add_report_notification_event(PARMSDM pARMSDM, PATRACSDMNTFY pPushRsp);
+
+int arms_dm_start_timer(PARMSDM pARMSDM);
+int arms_dm_stop_timer(PARMSDM pARMSDM);
+
+#endif
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_dmrpc.c b/lynq/S300/ap/app/apparms/apparms_dmrpc.c
new file mode 100755
index 0000000..bf4cb56
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_dmrpc.c
@@ -0,0 +1,239 @@
+
+#ifdef ARMS_SUPPORT_DM
+#ifdef ARMS_DM_RPC
+
+#include "apparms.h"
+#include "apparms_sock_unix.h"
+#include "apparms_sock_tcp.h"
+
+static int arms_dmrpc_open(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	char szPortBuf[64] = {0};
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	if (!pRPCCfg->bRPC)
+		return -2;
+
+	sprintf(szPortBuf,"%d", pRPCCfg->nRPCTCPPort);
+	if (pRPCCfg->bRPCUnixMode)
+		return arms_sock_unix_open((int *)&pDMRPC->nRPCfd, pRPCCfg->szRPCUnix);
+
+	return arms_sock_tcp_open((int *)&pDMRPC->nRPCfd, pRPCCfg->szRPCTCPSrv, szPortBuf);
+}
+
+static void arms_dmrpc_close(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return;
+
+	if (!pRPCCfg->bRPC)
+		return;
+	
+	if (pRPCCfg->bRPCUnixMode)
+		arms_sock_unix_close((int *)&pDMRPC->nRPCfd);
+	else
+		arms_sock_tcp_close((int *)&pDMRPC->nRPCfd);
+}
+
+static int arms_dmrpc_send(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg, unsigned char *pInData, int nInLen)
+{
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	if (!pRPCCfg->bRPC)
+		return -2;
+	
+	if (pRPCCfg->bRPCUnixMode)
+		return arms_sock_unix_send(pDMRPC->nRPCfd, (const char *)pInData, nInLen);
+
+	return arms_sock_tcp_send(pDMRPC->nRPCfd, (const char *)pInData, nInLen);
+}
+
+static int arms_dmrpc_poll(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg, int nCheck)
+{
+	unsigned int timeout;
+	
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	if (!pRPCCfg->bRPC)
+		return -2;
+
+	if (nCheck)
+	{
+		timeout = 50;
+	}
+	else
+	{
+		timeout = pRPCCfg->mRPCTimeout;
+	}
+	
+	if (pRPCCfg->bRPCUnixMode)
+		return arms_sock_unix_poll(pDMRPC->nRPCfd, timeout);
+
+	return arms_sock_tcp_poll(pDMRPC->nRPCfd, timeout);
+}
+
+static int arms_dmrpc_recv(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg, unsigned char*puffer, int* buflen)
+{
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	if (!pRPCCfg->bRPC)
+		return -2;
+	
+	if (pRPCCfg->bRPCUnixMode)
+		return arms_sock_unix_recv(pDMRPC->nRPCfd, (char *)puffer, buflen);
+
+	return arms_sock_tcp_recv(pDMRPC->nRPCfd, (char *)puffer, buflen);
+}
+
+static int arms_dmrpc_open_with_retry(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	int i;
+
+	if(pDMRPC->nRPCfd != ARMS_INVALID_HANDLE)
+		arms_dmrpc_close(pDMRPC, pRPCCfg);
+
+	pDMRPC->nRPCReconnect = 0;
+	
+	for (i = 0; i < 3; i++)
+	{
+		pDMRPC->nRPCfd = arms_dmrpc_open(pDMRPC, pRPCCfg);
+		if (pDMRPC->nRPCfd > 0)
+			return pDMRPC->nRPCfd;
+
+		sleep(i + 1);
+	}
+			
+	ARMS_LOG_ERROR("%s(%d) RPC open failed\n",__FUNCTION__,__LINE__);
+	return -1;
+}
+
+static int arms_dmrpc_check(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	int i, ret, nBufSize;
+	unsigned char szTmpBuf[1024];
+	
+	for (i = 0; i < 5; i++)
+	{
+		nBufSize = sizeof(szTmpBuf);
+		memset(szTmpBuf, 0, nBufSize);
+		
+	 	ret = arms_dmrpc_recv(pDMRPC, pRPCCfg, szTmpBuf, &nBufSize);
+		/*there is exception in socket, retry*/
+		if (ret < 0)
+		{
+			return ret;
+		}
+
+		/*socket is ok and buffer empty*/
+		if (nBufSize <= 0)
+			return 0;
+
+		sleep(1);
+	}
+
+	return -1;
+}
+
+int arms_dmrpc_send_and_recv(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen)
+{
+	int itry, ret;
+	
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	if ((pInData == NULL) || (nInLen == 0) || (pOutData == NULL) || (pOutLen == NULL))
+		return -2;
+
+	pthread_mutex_lock(&pDMRPC->rpcMutex);
+	ARMS_LOG_DEBUG("%s(%d) RPC Sock start nRPCfd =%d, rconnect=%d...\n",__FUNCTION__,__LINE__, pDMRPC->nRPCfd, pDMRPC->nRPCReconnect);
+
+	for (itry = 0; itry < 3; itry++)
+	{
+		if ((pDMRPC->nRPCfd <= 0) || pDMRPC->nRPCReconnect)
+		{
+			ARMS_LOG_DEBUG("%s(%d) RPC Sock Open...\n",__FUNCTION__,__LINE__);
+
+			if (arms_dmrpc_open_with_retry(pDMRPC, pRPCCfg) < 0)
+			{
+				pthread_mutex_unlock(&pDMRPC->rpcMutex);
+				return -3;
+			}
+		}
+		else
+		{
+			#if 0
+			ret = arms_dmrpc_poll(pDMRPC, pRPCCfg, 1);
+			if(ret < 0)
+			{
+				pDMRPC->nRPCReconnect = 1;
+				continue;
+			}
+			#endif
+
+			ret = arms_dmrpc_check(pDMRPC, pRPCCfg);
+			if(ret < 0)
+			{
+				pDMRPC->nRPCReconnect = 1;
+				continue;
+			}
+		}
+
+		break;
+	}
+
+	ARMS_LOG_DEBUG("%s(%d) RPC sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,nInLen);
+	ret = arms_dmrpc_send(pDMRPC, pRPCCfg, pInData, nInLen);
+	if(ret <= 0)
+	{
+		goto EXIT;
+	}
+
+	ARMS_LOG_DEBUG("%s(%d) RPC Sock Polling...\n",__FUNCTION__,__LINE__);
+	ret = arms_dmrpc_poll(pDMRPC, pRPCCfg, 0);
+	if(ret <= 0)
+	{
+		goto EXIT;
+	}
+	
+	ARMS_LOG_DEBUG("%s(%d) RPC Sock Receiving...\n",__FUNCTION__,__LINE__);
+	ret = arms_dmrpc_recv(pDMRPC, pRPCCfg, pOutData, pOutLen);
+	
+
+EXIT:
+	if (ret <= 0)
+	{
+		arms_dmrpc_close(pDMRPC, pRPCCfg);
+	}
+	
+	pthread_mutex_unlock(&pDMRPC->rpcMutex);
+	ARMS_LOG_DEBUG("%s(%d) RPC Sock End with ret = %d ...\n",__FUNCTION__,__LINE__, ret);
+
+	return ret;
+}
+
+int arms_dmrpc_start(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	if ((pDMRPC == NULL) || (pRPCCfg == NULL))
+		return -1;
+
+	pDMRPC->nRPCfd = -1;
+	pDMRPC->nRPCReconnect = 0;
+
+	pthread_mutex_init(&pDMRPC->rpcMutex, NULL);
+	
+	return 0;
+}
+
+void arms_dmrpc_stop(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg)
+{
+	arms_dmrpc_close(pDMRPC, pRPCCfg);
+
+	pthread_mutex_destroy(&pDMRPC->rpcMutex);
+}
+
+#endif
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_dmrpc.h b/lynq/S300/ap/app/apparms/apparms_dmrpc.h
new file mode 100755
index 0000000..e67d9c2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_dmrpc.h
@@ -0,0 +1,24 @@
+
+#ifndef _APPARMS_DMRPC
+#define _APPARMS_DMRPC 1
+#ifdef ARMS_SUPPORT_DM
+#ifdef ARMS_DM_RPC
+
+#include "apparms_macro.h"
+#include "apparms_config_os.h"
+#include "apparms_log.h"
+
+typedef struct _tagDMRPC
+{
+	volatile int nRPCfd;
+	volatile int nRPCReconnect;
+	pthread_mutex_t rpcMutex;
+}DMRPC, *PDMRPC;
+
+int arms_dmrpc_send_and_recv(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen);
+int arms_dmrpc_start(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg);
+void arms_dmrpc_stop(PDMRPC pDMRPC, PDMRPCCFG pRPCCfg);
+
+#endif //ARMS_SUPPORT_DM
+#endif //ARMS_DM_IPATC
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_dmrpc_test.c b/lynq/S300/ap/app/apparms/apparms_dmrpc_test.c
new file mode 100755
index 0000000..40ed7d5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_dmrpc_test.c
@@ -0,0 +1,163 @@
+
+//#ifdef ARMS_SUPPORT_DM
+#include "apparms.h"
+#include "apparms_sock_tcp.h"
+#include "apparms_sock_unix.h"
+#include "apparms_config_example.h"
+#include "apparms_ipatc.h"
+
+static SOCKIPATC stSock;
+
+const char* pLANRsp =
+"{ \"LANRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"Oper\": \"GET\", \"MsgText\": { \"IPAddr\": \"192.168.0.1\", \"Subnet\": \"255.255.255.0\", \"DHCP\": \"ENABLE\", \"StartIP\": \"192.168.0.2\", \"EndIP\": \"192.168.0.254\", \"LeaseTime\": \"86400\" } } }";
+ 
+const char* pDevInfoRsp =
+"{ \"DevInfoRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"Oper\": \"ALLinfor\", \"MsgText\": { \"IPAddr\": \"192.168.0.1\", \"Subnet\": \"255.255.255.0\", \"DHCP\": \"ENABLE\", \"StartIP\": \"192.168.0.2\", \"EndIP\": \"192.168.0.254\", \"LeaseTime\": \"86400\", \"MAC\": \"00:11:22:33:44:55\", \"FWversion\": \"CPE3_WT_J91_AT_V1.1.5\", \"LTEversion\": \"EM12GPAR01A21M4G\", \"RSRP\": \"-111 dBm\", \"RSRQ\": \"-16 dB\", \"SINR\": \"4\", \"IMEI\": \"869710030052108\", \"IMSI\": \"310410133521805\", \"Operator_Name\": \"AT&T\", \"Connection\": \"Connected\", \"Modem\": \"LTE\", \"ICCID\": \"89014103271335218051\", \"IP\": \"10.28.146.89\", \"Received\": \"21.52 GB\", \"Sent\": \"6.415 GB\" } } }";
+ 
+const char* pTTLRsp =
+"{ \"TTLRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"Oper\": \"GET\", \"MsgText\": { \"TTLOpt\": \"DISABLE\", \"TTLValue\": \"64\" } } }";
+
+const char* pAPNGetRsp =
+"{ \"APNGetRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"MsgText\": [ { \"PDNType\": \"INTERNET\", \"Mode\": \"manual\", \"HostName\": \"ATT 500\", \"APNType\": \"IPV4\", \"ProfileName\": \"ATT 500\", \"APNName\": \"broadband\", \"AuthType\": \"NONE\", \"UserName\": \"\", \"Password\": \"\" } ] } }";
+ 
+const char* pNWModeRsp =
+"{ \"NWModeRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"Oper\": \"GET\", \"MsgText\": { \"Mode\": \"4G\" } } }";
+
+const char* pBandGetRsp =
+"{ \"BandGetRsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"MsgText\": [ { \"Type\": \"LTE\", \"Value\": [ \"4\", \"12\", \"14\", \"66\" ], \"Support\": [ \"1\", \"2\", \"3\", \"4\", \"5\", \"7\", \"8\", \"9\", \"12\", \"13\", \"14\", \"17\", \"18\", \"19\", \"20\", \"21\", \"25\", \"26\", \"28\", \"29\", \"30\", \"32\", \"38\", \"39\", \"40\", \"41\", \"66\" ] } ] } }";
+
+const char* pMTURsp =
+"{ \"MTURsp\": { \"RspStatus\": \"OK\", \"MsgCode\": \"0\", \"Oper\": \"GET\", \"MsgText\": { \"MTU\": \"1500\" } } }";
+
+int arms_rpc_test_thread_recv_cb(int nFD)
+{
+	int ret;
+	int nIPCRecvSize = 2048;
+	char szIPCRecvBuf[2048] = {0};
+	char szIPCReplyBuf[2048] = {0};
+	int i;
+
+	memset(szIPCRecvBuf,0,nIPCRecvSize);
+	if (stSock.bUnixmode)
+		ret = arms_sock_unix_recv(nFD, (char *)szIPCRecvBuf, &nIPCRecvSize);
+	else
+		ret = arms_sock_tcp_recv(nFD, (char *)szIPCRecvBuf, &nIPCRecvSize);
+	
+	if (ret >0 && nIPCRecvSize > 0)
+	{
+		printf("Received Len = [%d]\n", nIPCRecvSize);
+		
+		printf("String:\n");
+		puts((const char *)szIPCRecvBuf);
+		//printf("%s", szIPCRecvBuf);
+		
+		printf("Hex:\n");
+		for(i = 0; i < nIPCRecvSize;i++)
+		{
+			printf("%02X",szIPCRecvBuf[i]);
+		}
+		printf("\n");
+
+		if (strstr(szIPCRecvBuf, "LANReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pLANRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "DevInfoReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pDevInfoRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "TTLReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pTTLRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "APNGetReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pAPNGetRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "NWModeReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pNWModeRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "BandGetReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pBandGetRsp);
+		}
+		else if (strstr(szIPCRecvBuf, "MTUReq") != 0)
+		{
+			strcpy(szIPCReplyBuf, pMTURsp);
+		}
+		else
+		{
+			strcpy(szIPCReplyBuf, szIPCRecvBuf);
+		}
+
+		printf("\nReply to Client: \n");
+		puts((const char *)szIPCReplyBuf);
+		
+		if (stSock.bUnixmode)
+			arms_sock_unix_send(nFD, (const char *)szIPCReplyBuf, strlen(szIPCReplyBuf));
+		else
+			arms_sock_tcp_send(nFD, (const char *)szIPCReplyBuf, strlen(szIPCReplyBuf));
+	}
+	
+	return ret;
+}
+
+int arms_dmrpc_test_start_thread(PSOCKIPATC pSockIPATC)
+{		
+	if (pSockIPATC == NULL)
+	{
+		return -1;
+	}
+
+	return arms_ipatc_start_loop(pSockIPATC, arms_rpc_test_thread_recv_cb);
+	
+}
+
+int arms_dmrpc_test_stop_thread(PSOCKIPATC pSockIPATC)
+{
+	if (pSockIPATC == NULL)
+	{
+		return -2;
+	}
+
+	return arms_ipatc_stop_loop(pSockIPATC);
+}
+
+static void arms_dmrpc_test_termsignal_handle(int signum)
+{
+	stSock.nLoop = 0;
+	sleep(1);
+}
+
+int main(int argc, char *argv[])
+{
+	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+	{
+		fprintf(stderr, "can't execute signal \n");
+	}
+	
+	signal(SIGTERM, arms_dmrpc_test_termsignal_handle);
+	signal(SIGPIPE, SIG_IGN);
+
+	memset(&stSock, 0, sizeof(SOCKIPATC));
+	stSock.uMaxclient = 2;
+
+	#ifdef ARMS_DM_RPC_UNX_MODE
+	stSock.bUnixmode = 1;
+	strcpy(stSock.szUnixPath, ARMS_DM_RPC_UNIX_PATH);
+	#else
+	sprintf(stSock.szPort, "%d", ARMS_DM_RPC_TCP_PORT);	
+	#endif
+	
+	arms_dmrpc_test_start_thread(&stSock);
+
+	while (stSock.nLoop)
+	{
+		sleep(3);
+	}
+	
+	return 0; 
+}
+
+//#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_fota.c b/lynq/S300/ap/app/apparms/apparms_fota.c
new file mode 100755
index 0000000..501de34
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_fota.c
@@ -0,0 +1,1838 @@
+
+#include "apparms_fota.h"
+#include "apparms_log.h"
+#include "apparms_hmac_sha256.h"
+#include "apparms_md5.h"
+#include "apparms.h"
+#include "apparms_util.h"
+
+#ifdef ARMS_SUPPORT_FOTA
+/////////////////////////////////////////////
+int arms_fota_local_pre_version_not_empty(PARMSFOTA pARMSFOTA)
+{
+	int i;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+
+	//fw
+	for(i=0;i<ARMS_FOTA_FW_VER_NUM;i++)
+	{
+		if(strlen(pData->stFWPreVerArr[i].szFOTAFwVer) > 0)
+			return 1;
+	}
+
+	//cfg
+	for(i=0;i<ARMS_FOTA_CFG_VER_NUM;i++)
+	{
+		if(strlen(pData->stCFGPreVerArr[i].szFOTCfgVer) > 0)
+			return 1;
+	}
+
+	//mcu
+	for(i=0;i<ARMS_FOTA_MCU_VER_NUM;i++)
+	{
+		if(strlen(pData->stMCUPreVerArry[i].szFOTMCUVer) > 0)
+			return 1;
+	}
+
+	return 0;
+}
+
+int arms_fota_local_version_check(PARMSFOTA pARMSFOTA)
+{
+	int i;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+
+	//fw
+	for(i=0;i<ARMS_FOTA_FW_VER_NUM;i++)
+	{
+		if(strlen(pData->stFWPreVerArr[i].szFOTAFwVer) > 0 && strlen(pData->stFWVerArr[i].szFOTAFwVer) > 0)
+		{
+			if(strcmp(pData->stFWPreVerArr[i].szFOTAFwVer, pData->stFWVerArr[i].szFOTAFwVer) != 0)
+			{
+				ARMS_LOG_DEBUG("%s(%d) Preview fw version=%s\r\n",__FUNCTION__,__LINE__, pData->stFWPreVerArr[i].szFOTAFwVer);
+        		ARMS_LOG_DEBUG("%s(%d) Current fw version=%s\r\n",__FUNCTION__,__LINE__, pData->stFWVerArr[i].szFOTAFwVer);
+        		return 1;
+			}
+		}
+	}
+
+	//cfg
+	for(i=0;i<ARMS_FOTA_CFG_VER_NUM;i++)
+	{
+		if(strlen(pData->stCFGPreVerArr[i].szFOTCfgVer) > 0 && strlen(pData->stCFGVerArr[i].szFOTCfgVer) > 0)
+		{
+			if(strcmp(pData->stCFGPreVerArr[i].szFOTCfgVer, pData->stCFGVerArr[i].szFOTCfgVer) != 0)
+			{
+				ARMS_LOG_DEBUG("%s(%d) Preview cfg version=%s\r\n",__FUNCTION__,__LINE__, pData->stCFGPreVerArr[i].szFOTCfgVer);
+        		ARMS_LOG_DEBUG("%s(%d) Current cfg version=%s\r\n",__FUNCTION__,__LINE__, pData->stCFGVerArr[i].szFOTCfgVer);
+        		return 1;
+			}
+		}
+	}
+
+	//mcu
+	for(i=0;i<ARMS_FOTA_MCU_VER_NUM;i++)
+	{
+		if(strlen(pData->stMCUPreVerArry[i].szFOTMCUVer) > 0 && strlen(pData->stMCUVerArry[i].szFOTMCUVer) > 0)
+		{
+			if(strcmp(pData->stMCUPreVerArry[i].szFOTMCUVer, pData->stMCUVerArry[i].szFOTMCUVer) != 0)
+			{
+				ARMS_LOG_DEBUG("%s(%d) Preview fw version=%s\r\n",__FUNCTION__,__LINE__, pData->stMCUPreVerArry[i].szFOTMCUVer);
+        		ARMS_LOG_DEBUG("%s(%d) Current fw version=%s\r\n",__FUNCTION__,__LINE__, pData->stMCUVerArry[i].szFOTMCUVer);
+        		return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
+unsigned char arms_fota_check_upgrade(PARMSFOTA pARMSFOTA)
+{
+	unsigned char update_result = 0xFF;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+
+	ARMS_LOG_DEBUG("%s(%d) enter\r\n",__FUNCTION__,__LINE__);
+
+    ARMS_LOG_DEBUG("%s(%d) backup:%X %X %X %X\r\n",__FUNCTION__,__LINE__,pData->cBackup[0],pData->cBackup[1],pData->cBackup[2],pData->cBackup[3]);
+    if (pData->cBackup[0] == 'A' && pData->cBackup[1] == 'R' && pData->cBackup[2] == 'M' && pData->cBackup[3] == 'S')
+    {
+        ARMS_LOG_DEBUG("%s(%d) No Upgrade! version=%s.\r\n",__FUNCTION__,__LINE__, pData->stFWVerArr[0].szFOTAFwVer);
+        update_result = 0;
+    }
+    else
+    {
+        if (arms_fota_local_pre_version_not_empty(pARMSFOTA))
+        {
+            if (arms_fota_local_version_check(pARMSFOTA) == 0)
+            {
+                ARMS_LOG_DEBUG("%s(%d) Upgrade Fail!\r\n",__FUNCTION__,__LINE__);
+                update_result = 99;
+            }
+            else
+            {
+                ARMS_LOG_DEBUG("%s(%d) Upgrade Sucess!\r\n",__FUNCTION__,__LINE__);
+                update_result = 1;
+            }
+        }
+        else
+        {
+            ARMS_LOG_DEBUG("%s(%d) No Upgrade! version = %s\r\n",__FUNCTION__,__LINE__, pData->stFWVerArr[0].szFOTAFwVer);
+            update_result = 0;
+        }
+    }
+
+    return update_result;
+}
+
+void arms_fota_set_state(PARMSFOTA pARMSFOTA,ARMS_FOTA_STATE state)
+{
+    if(pARMSFOTA->fota_state == state)
+    {
+        return;
+    }
+
+	if (state == ARMS_FOTA_STATE_DL)
+		pARMSFOTA->download_retry_cnt = 0;
+	
+	ARMS_LOG_ERROR("%s(%d) Change state from %d to %d\n",__FUNCTION__,__LINE__, pARMSFOTA->fota_state, state); 		
+
+	pARMSFOTA->fota_state = state;
+}
+
+void arms_fota_hex_to_str(char* pszDest, unsigned char* pbSrc, int nLen)
+{
+	char	ddl, ddh;
+	int i;
+	for (i = 0; i < nLen; i++)
+	{
+		ddh = 48 + pbSrc[i] / 16;
+		ddl = 48 + pbSrc[i] % 16;
+		if (ddh > 57) ddh = ddh + 7;
+		if (ddl > 57) ddl = ddl + 7;
+		pszDest[i * 2] = ddh;
+		pszDest[i * 2 + 1] = ddl;
+	}
+
+	pszDest[nLen * 2] = '\0';
+}
+
+int arms_fota_check_devid_sec(PARMSFOTA pARMSFOTA)
+{
+	char sign[128] = { 0 };
+	unsigned char signOut[32] = { 0 };
+	char signInput[128] = { 0 };
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+	PFOTACFG pCfg = &pARMSFOTA->stFOTACfg;
+
+	ARMS_LOG_DEBUG("%s(%d) enter\r\n",__FUNCTION__,__LINE__);
+
+	if(strlen(pData->cDeviceId) == 0 || strlen(pData->cDeviceidMD5) == 0 || strlen(pData->cDeviceSec) == 0)
+	{
+		return 0;
+	}
+
+	sprintf(signInput, "%s%s", pData->cDeviceId, pCfg->stFOTACommCfg.szIMEI);
+	arms_hmac_sha256_encypt((unsigned char *)pData->cDeviceSec, strlen(pData->cDeviceSec), (unsigned char *)signInput, strlen(signInput), signOut);
+	arms_fota_hex_to_str(sign, signOut, 32);
+	
+	ARMS_LOG_DEBUG("%s(%d) sign=%s\r\n",__FUNCTION__,__LINE__,sign);
+	ARMS_LOG_DEBUG("%s(%d) cDeviceidMD5=%s\r\n",__FUNCTION__,__LINE__,pData->cDeviceidMD5);
+	
+    if (strncmp(sign, pData->cDeviceidMD5, 32) == 0)
+    {
+        return 1;
+    }
+	
+    return 0;
+}
+
+void arms_fota_set_percentage(PARMSFOTA pARMSFOTA,unsigned int percentage)
+{
+	if (pARMSFOTA->percentage != percentage)
+	{
+		ARMS_LOG_DEBUG("%s(%d) change percentage from %d to %d \r\n",__FUNCTION__,__LINE__, pARMSFOTA->percentage,percentage);
+		pARMSFOTA->percentage = percentage;
+		if(pARMSFOTA->percentage % 10 == 0)
+			ARMS_LOG_INFO("%s(%d) Download Percentage: %d \r\n",__FUNCTION__,__LINE__, pARMSFOTA->percentage);
+	}
+}
+
+unsigned int arms_fota_get_percentage(PARMSFOTA pARMSFOTA)
+{
+	return pARMSFOTA->percentage;
+}
+
+/////////////////////////////////////////////
+char *arms_fota_get_version_info(PARMSFOTA pARMSFOTA,int verType,int isCheck)
+{
+	char *verInfo = NULL;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+	int i;
+	int len;
+
+	verInfo = (char *)malloc(sizeof(char)*1024);
+
+	if(verInfo == NULL)
+		return NULL;
+
+	memset(verInfo,0,1024);
+
+	if(isCheck)
+	{
+		switch(verType)
+		{
+			//fw
+			case 0:
+			{				
+				for(i = 0; i< ARMS_FOTA_FW_VER_NUM; i++)
+				{
+					if (i != 0)
+						strcat(verInfo, ",");
+
+					strcat(verInfo, "\"");
+					
+					if(strlen(pData->stFWVerArr[i].szFOTAFwVer) > 0)
+					{
+						strcat(verInfo, pData->stFWVerArr[i].szFOTAFwVer);
+					}
+
+					strcat(verInfo, "\"");
+				}
+			}
+			break;
+
+			//cfg
+			case 1:
+			{
+				for(i = 0; i< ARMS_FOTA_CFG_VER_NUM; i++)
+				{
+					if (i != 0)
+						strcat(verInfo, ",");
+
+					strcat(verInfo, "\"");
+					
+					if(strlen(pData->stCFGVerArr[i].szFOTCfgVer) > 0)
+					{
+						strcat(verInfo, pData->stCFGVerArr[i].szFOTCfgVer);
+					}
+
+					strcat(verInfo, "\"");
+				}
+			}
+			break;
+
+			//mcu
+			case 2:
+			{
+				for(i = 0; i< ARMS_FOTA_MCU_VER_NUM; i++)
+				{
+					if (i != 0)
+						strcat(verInfo, ",");
+
+					strcat(verInfo, "\"");
+					
+					if(strlen(pData->stMCUVerArry[i].szFOTMCUVer) > 0)
+					{
+						strcat(verInfo, pData->stMCUVerArry[i].szFOTMCUVer);
+					}
+
+					strcat(verInfo, "\"");
+				}
+			}
+			break;
+		}
+	}
+	else
+	{
+		switch(verType)
+		{
+			//fw
+			case 0:
+			{
+				for(i=0;i<ARMS_FOTA_FW_VER_NUM;i++)
+				{
+					ARMS_LOG_DEBUG("%s(%d) FOTAFwVer[%d]: [%s]-[%s]\r\n",__FUNCTION__,__LINE__,i,pData->stFWPreVerArr[i].szFOTAFwVer,pData->stFWVerArr[i].szFOTAFwVer);
+					if(strlen(pData->stFWPreVerArr[i].szFOTAFwVer) > 0 && strlen(pData->stFWVerArr[i].szFOTAFwVer) > 0)
+					{
+						if (i != 0)
+							strcat(verInfo,",");
+						
+						len = strlen(verInfo);
+						sprintf(verInfo+len,"[\"%s\",",pData->stFWVerArr[i].szFOTAFwVer);
+						if(strcmp(pData->stFWPreVerArr[i].szFOTAFwVer, pData->stFWVerArr[i].szFOTAFwVer) != 0)
+						{
+							strcat(verInfo,"1]");
+						}
+						else
+						{
+							strcat(verInfo,"2]");
+						}
+					}
+				}
+			}
+			break;
+
+			//cfg
+			case 1:
+			{
+				for(i=0;i<ARMS_FOTA_CFG_VER_NUM;i++)
+				{
+					ARMS_LOG_DEBUG("%s(%d) FOTCfgVer[%d]: [%s]-[%s]\r\n",__FUNCTION__,__LINE__,i,pData->stCFGPreVerArr[i].szFOTCfgVer,pData->stCFGVerArr[i].szFOTCfgVer);
+					if(strlen(pData->stCFGPreVerArr[i].szFOTCfgVer) > 0 && strlen(pData->stCFGVerArr[i].szFOTCfgVer) > 0)
+					{
+						if (i != 0)
+							strcat(verInfo,",");
+						
+						len = strlen(verInfo);
+						sprintf(verInfo+len,"[\"%s\",",pData->stCFGVerArr[i].szFOTCfgVer);
+						if(strcmp(pData->stCFGPreVerArr[i].szFOTCfgVer, pData->stCFGVerArr[i].szFOTCfgVer) != 0)
+						{
+							strcat(verInfo,"1]");
+						}
+						else
+						{
+							strcat(verInfo,"2]");
+						}
+					}
+				}
+			}
+			break;
+
+			//mcu
+			case 2:
+			{
+				for(i=0;i<ARMS_FOTA_MCU_VER_NUM;i++)
+				{
+					ARMS_LOG_DEBUG("%s(%d) FOTMCUVer[%d]: [%s]-[%s]\r\n",__FUNCTION__,__LINE__,i,pData->stMCUPreVerArry[i].szFOTMCUVer,pData->stMCUVerArry[i].szFOTMCUVer);
+					if(strlen(pData->stMCUPreVerArry[i].szFOTMCUVer) > 0 && strlen(pData->stMCUVerArry[i].szFOTMCUVer) > 0)
+					{
+						if (i != 0)
+							strcat(verInfo,",");
+						
+						len = strlen(verInfo);
+						sprintf(verInfo+len,"[\"%s\",",pData->stMCUVerArry[i].szFOTMCUVer);
+						if(strcmp(pData->stMCUPreVerArry[i].szFOTMCUVer, pData->stMCUVerArry[i].szFOTMCUVer) != 0)
+						{
+							strcat(verInfo,"1]");
+						}
+						else
+						{
+							strcat(verInfo,"2]");
+						}
+					}
+				}
+			}
+			break;
+		}
+	}
+
+	return verInfo;
+}
+
+int arms_fota_thread_prepare_send_construct(PARMSFOTA pARMSFOTA)
+{
+		
+#ifdef ARMS_FOTA_HTTP
+	unsigned char *signptr = 0;
+	char sign[128] = { 0 };
+	unsigned char signOut[32] = { 0 };
+	char signInput[128] = { 0 };
+	char timestamp[64] = { 0 };
+	char sdkVer[16] = { 0 };
+	char content_path[256] = {0}; 
+	char content_host[256] = {0};
+	char content_type[128] = {0};  
+	char content_connection[128] = {0};
+	char content_len[50] = {};
+	char content[1024] = {0};
+	unsigned int len = 0;
+	unsigned int tagert_len = 0;
+	char *pVerFW = NULL;
+	char *pVerCFG = NULL;
+	char *pVerMCU = NULL;
+
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+	PFOTACFG pCfg = &pARMSFOTA->stFOTACfg;
+	PFOTASOCKSEND pFOTASockSend = &pARMSFOTA->stFOTASock.fotasocksend;
+
+	if(pARMSFOTA->fota_state == ARMS_FOTA_STATE_DL)
+	{
+		//sprintf(content_type,"Content-Type: application/zip\r\n");
+	}
+	else
+	{
+		arms_data_os_get_timestamp(pDataFunc,&pData->timestamp);
+		sprintf(timestamp, "%ld", pData->timestamp);
+		ARMS_LOG_DEBUG("%s(%d) timestamp:%s.\r\n",__FUNCTION__,__LINE__,timestamp);
+
+		if(pARMSFOTA->fota_state == ARMS_FOTA_STATE_RG)
+		{
+			sprintf(signInput, "%s%s%s", pCfg->stHttpCfg.szProdID,pCfg->stFOTACommCfg.szIMEI,timestamp);
+			ARMS_LOG_DEBUG("%s(%d) signInput:%s.\r\n",__FUNCTION__,__LINE__,signInput);
+			arms_hmac_sha256_encypt((unsigned char *)pCfg->stHttpCfg.szPassword, strlen(pCfg->stHttpCfg.szPassword), (unsigned char *)signInput, strlen(signInput), signOut);
+		}
+		else
+		{
+			sprintf(signInput, "%s%s", pData->cDeviceId, timestamp);
+			ARMS_LOG_DEBUG("%s(%d) signInput:%s.\r\n",__FUNCTION__,__LINE__,signInput);
+			arms_hmac_sha256_encypt((unsigned char *)pData->cDeviceSec, strlen((char *)pData->cDeviceSec), (unsigned char *)signInput, strlen(signInput), signOut);
+		}
+		ARMS_LOG_DEBUG("%s(%d) signOut:%s.\r\n",__FUNCTION__,__LINE__,signOut);
+		arms_fota_hex_to_str(sign, signOut, 32);
+		ARMS_LOG_DEBUG("%s(%d) sign:%s.\r\n",__FUNCTION__,__LINE__,sign);
+		signptr = (unsigned char*)sign;
+
+		sprintf(sdkVer,"%d.%d.%d",ARMS_VERSION_MAJOR,ARMS_VERSION_MINOR,ARMS_VERSION_PATCH);
+		sprintf(content_type,"Content-Type: application/json\r\n");
+	}
+	
+	switch (pARMSFOTA->fota_state)
+    {
+        case ARMS_FOTA_STATE_RG:
+            ARMS_LOG_INFO("%s(%d) Register.\r\n",__FUNCTION__,__LINE__);
+			sprintf(content_path,"POST /deviceapi/%s/register HTTP/1.1\r\n",pCfg->stHttpCfg.szProdID);
+		
+			sprintf(content,
+                    "{\"mid\":\"%s\",\"timestamp\":%ld,\"sign\":\"%s\",\"sdkversion\":\"%s\"}",
+                    pCfg->stFOTACommCfg.szIMEI,
+                    pData->timestamp,
+                    (signptr == NULL? (char *)"NULL":(char *)signptr),
+                    sdkVer);
+            break;
+
+        case ARMS_FOTA_STATE_CV:
+			ARMS_LOG_INFO("%s(%d) Check Version.\r\n",__FUNCTION__,__LINE__);
+			sprintf(content_path,"POST /deviceapi/%s/%s/check HTTP/1.1\r\n",pCfg->stHttpCfg.szProdID,pData->cDeviceId);
+
+			pVerFW = arms_fota_get_version_info(pARMSFOTA, 0, 1);
+			pVerCFG = arms_fota_get_version_info(pARMSFOTA, 1, 1);
+			pVerMCU = arms_fota_get_version_info(pARMSFOTA, 2, 1);
+			
+			sprintf(content,
+                    "{\"mid\":\"%s\",\"sdkversion\":\"%s\",\"timestamp\":%ld,\"sign\":\"%s\",\"fw\":[%s],\"app\":[%s],\"cf\":[%s]}",
+                    pCfg->stFOTACommCfg.szIMEI,
+                    sdkVer,
+                    pData->timestamp,
+                    (signptr == NULL? (char *)"NULL":(char *)signptr),
+                    pVerFW,
+                    pVerMCU,
+                    pVerCFG);
+
+            break;
+
+        case ARMS_FOTA_STATE_DL:
+			ARMS_LOG_DEBUG("%s(%d) Download.\r\n",__FUNCTION__,__LINE__);
+			sprintf(content_path,"GET %s HTTP/1.1\r\n",pARMSFOTA->stDownInfo.down_path);
+
+			len = (pData->nDownSize+ARMS_FOTA_SOCK_RECV_BUF_SIZE-ARMS_SOCK_HTTP_HEADER_BUF_SIZE);
+			tagert_len = len < pARMSFOTA->stDownInfo.down_file_size ? len : pARMSFOTA->stDownInfo.down_file_size;
+
+#if 0
+			ARMS_LOG_DEBUG("%s(%d) download Range: bytes=%d-%d\r\n",__FUNCTION__,__LINE__, pData->nDownSize, tagert_len);
+            
+			sprintf(content_len, "Range: bytes=%d-%d\r\n",
+					pData->nDownSize, tagert_len);
+
+			if(tagert_len == pARMSFOTA->stDownInfo.down_file_size && pData->nDownSize > 0)
+				pARMSFOTA->stDownInfo.current_block_remaining = tagert_len - pData->nDownSize;
+			else
+				pARMSFOTA->stDownInfo.current_block_remaining = tagert_len - pData->nDownSize + 1;
+#else
+			if(pData->nDownSize == 0)
+			{
+				pARMSFOTA->stDownInfo.current_block_remaining = tagert_len - pData->nDownSize + 1;
+
+				ARMS_LOG_DEBUG("%s(%d) download Range: bytes=%d-%d\r\n",__FUNCTION__,__LINE__, pData->nDownSize, pARMSFOTA->stDownInfo.current_block_remaining - 1);
+            
+				sprintf(content_len, "Range: bytes=%d-%d\r\n",
+					pData->nDownSize, pARMSFOTA->stDownInfo.current_block_remaining - 1);
+			}
+			else
+			{
+				pARMSFOTA->stDownInfo.current_block_remaining = pARMSFOTA->stDownInfo.down_file_size - pData->nDownSize;
+
+				ARMS_LOG_DEBUG("%s(%d) download Range: bytes=%d-%d\r\n",__FUNCTION__,__LINE__, pData->nDownSize, pARMSFOTA->stDownInfo.down_file_size - 1);
+            
+				sprintf(content_len, "Range: bytes=%d-%d\r\n",
+					pData->nDownSize, pARMSFOTA->stDownInfo.down_file_size - 1);
+			}	
+#endif
+			ARMS_LOG_DEBUG("%s(%d) current_block_remaining=%d, retry_cnt=%d\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.current_block_remaining, pARMSFOTA->download_retry_cnt);
+			pARMSFOTA->download_retry_cnt++;
+			break;
+
+        case ARMS_FOTA_STATE_RD:
+            ARMS_LOG_INFO("%s(%d) Report Download Result.\r\n",__FUNCTION__,__LINE__);
+			sprintf(content_path,"POST /deviceapi/%s/%s/download/report HTTP/1.1\r\n",pCfg->stHttpCfg.szProdID,pData->cDeviceId);
+			
+			ARMS_LOG_DEBUG("%s(%d) nTaskId=%d\r\n",__FUNCTION__,__LINE__,pData->nTaskId);
+
+			sprintf(content,
+                    "{\"mid\":\"%s\",\"taskId\":\"%d\",\"resultType\":%d,\"sdkversion\":\"%s\",\"timestamp\":%ld,\"sign\":\"%s\"}",
+                    pCfg->stFOTACommCfg.szIMEI,
+                    pData->nTaskId,
+                    pARMSFOTA->download_result,
+                    sdkVer,
+                    pData->timestamp,
+                    (signptr==NULL?(char *)"NULL":(char *)signptr));
+            break;
+
+        case ARMS_FOTA_STATE_RU:
+        {
+            unsigned char update_result = 0xFF;
+            update_result = arms_fota_check_upgrade(pARMSFOTA);
+
+			ARMS_LOG_INFO("%s(%d) Report Upgrade Result.\r\n",__FUNCTION__,__LINE__);
+			sprintf(content_path,"POST /deviceapi/%s/%s/upgrade/report HTTP/1.1\r\n",pCfg->stHttpCfg.szProdID,pData->cDeviceId);
+
+			ARMS_LOG_DEBUG("%s(%d) nTaskId=%d\r\n",__FUNCTION__,__LINE__,pData->nTaskId);
+
+			pVerFW = arms_fota_get_version_info(pARMSFOTA, 0, 0);
+			pVerCFG = arms_fota_get_version_info(pARMSFOTA, 1, 0);
+			pVerMCU = arms_fota_get_version_info(pARMSFOTA, 2, 0);
+			
+			sprintf(content,
+                    "{\"mid\":\"%s\",\"taskId\":\"%d\",\"upgradeStatus\":%d,\"resultType\":%d,\"timestamp\":%ld,\"sign\":\"%s\",\"fwResult\":[%s],\"appResult\":[%s],\"cfResult\":[%s]}",
+                    pCfg->stFOTACommCfg.szIMEI,
+                    pData->nTaskId,
+                    (update_result==1?1:0),
+                    update_result,
+                    pData->timestamp,
+                    (signptr==NULL?(char *)"NULL":(char *)signptr),
+                    pVerFW,
+                    pVerMCU,
+                    pVerCFG);
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+			sprintf(content,
+                    "{\"mid\":\"%s\",\"taskId\":\"%d\",\"upgradeStatus\":1,\"resultType\":1,\"timestamp\":%ld,\"sign\":\"%s\",\"fwResult\":[[\"1\",1]],\"appResult\":[[\"2\",1]],\"cfResult\":[[\"3\",1]]}",
+                    pCfg->stFOTACommCfg.szIMEI,
+                    pData->nTaskId,
+                    pData->timestamp,
+                    (signptr==NULL?(char *)"NULL":(char *)signptr));
+#endif
+
+        }
+        break;
+
+        default:
+            break;
+    }
+
+	if(pARMSFOTA->fota_state == ARMS_FOTA_STATE_DL)
+	{
+		sprintf(content_host,"HOST: %s\r\n",pARMSFOTA->stDownInfo.down_host);
+		//strcpy(content_connection,"User-Agent: PostmanRuntime/7.26.8\r\nCache-Control: no-cache\r\nPostman-Token: 416b550b-4385-4a00-af55-a39e8da1aad4\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, br\r\nConnection: keep-alive\r\n\r\n");
+		strcpy(content_connection,"Cache-Control: no-cache\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, br\r\nConnection: keep-alive\r\n\r\n");
+		sprintf((char *)pFOTASockSend->szSendBuf,"%s%s%s%s%s",content_path,content_len,content_host,content_type, content_connection);
+	}
+	else
+	{
+		//make http header and http packet
+		char *p = strstr(pARMSFOTA->stFOTACfg.stHttpCfg.szAddr, (char *)"https://");
+		if(p != NULL)
+			sprintf(content_host,"HOST: %s\r\n",pCfg->stHttpCfg.szAddr+strlen("https://"));
+		else
+			sprintf(content_host,"HOST: %s\r\n",pCfg->stHttpCfg.szAddr);
+		strcpy(content_connection,"Connection: keep-alive\r\n");
+		sprintf(content_len,"Content-Length: %d\r\n\r\n",(int)strlen(content));
+		sprintf((char *)pFOTASockSend->szSendBuf,"%s%s%s%s%s%s",content_path,content_host,content_type, content_connection,content_len,content);
+	}
+
+	pFOTASockSend->nSendSize = strlen((char *)pFOTASockSend->szSendBuf);
+	
+	if(pVerFW)
+	{
+		free(pVerFW);
+		pVerFW = NULL;
+	}
+
+	if(pVerCFG)
+	{
+		free((pVerCFG));
+		(pVerCFG) = NULL;
+	}
+
+	if(pVerMCU)
+	{
+		free(pVerMCU);
+		pVerMCU = NULL;
+	}
+#endif
+	return 0;
+}
+
+int arms_fota_get_data(PARMSFOTA pARMSFOTA)
+{
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+
+	arms_data_os_get_fota_ver_fw(pDataFunc,pData->stFWVerArr);
+	arms_data_os_get_fota_ver_cfg(pDataFunc,pData->stCFGVerArr);
+	arms_data_os_get_fota_ver_mcu(pDataFunc,pData->stMCUVerArry);
+	arms_data_os_get_task_id(pDataFunc,&pData->nTaskId);
+	arms_data_os_get_device_id(pDataFunc,pData->cDeviceId);
+	arms_data_os_get_device_sec(pDataFunc,pData->cDeviceSec);
+	arms_data_os_get_deviceid_md5(pDataFunc,pData->cDeviceidMD5);
+	arms_data_os_get_pre_version_fw(pDataFunc,pData->stFWPreVerArr);
+	arms_data_os_get_pre_version_cfg(pDataFunc,pData->stCFGPreVerArr);
+	arms_data_os_get_pre_version_mcu(pDataFunc,pData->stMCUPreVerArry);
+	arms_data_os_get_backup(pDataFunc,pData->cBackup);
+	arms_data_os_get_down_size(pDataFunc,&pData->nDownSize);
+	arms_data_os_get_region_size(pDataFunc,&pData->nRegionSize);
+
+	if(pARMSFOTA->fota_state == ARMS_FOTA_STATE_DL)
+	{
+#ifdef ARMS_FOTA_HTTPS
+		if(strstr(pARMSFOTA->stDownInfo.down_port,"443"))
+		{
+			arms_mqtt_api_tls_init(&pARMSFOTA->stFOTASock.stsockhttp.networkStack, NULL, NULL,
+				NULL, pARMSFOTA->stDownInfo.down_host,
+				atoi(pARMSFOTA->stDownInfo.down_port), 3000, false);
+
+			pARMSFOTA->stFOTASock.stsockhttp.networkStack.tlsMode = 1;
+			pARMSFOTA->stFOTASock.fotaSockMode = ARMS_SOCK_MODE_FOTA_HTTPS;
+		}
+		else
+#endif
+		{
+			strcpy(pARMSFOTA->stFOTASock.stsockhttp.szHttpAddr, pARMSFOTA->stDownInfo.down_host);
+			strcpy(pARMSFOTA->stFOTASock.stsockhttp.szHttpPort ,pARMSFOTA->stDownInfo.down_port);
+			pARMSFOTA->stFOTASock.fotaSockMode = ARMS_SOCK_MODE_FOTA_HTTP;
+		}
+	}
+	else
+	{
+#ifdef ARMS_FOTA_HTTPS
+		char *p;
+		p = strstr(pARMSFOTA->stFOTACfg.stHttpCfg.szAddr, (char *)"https://");
+		if(pARMSFOTA->stFOTACfg.stHttpCfg.nPort == 443 || p != NULL)
+		{
+			if(p != NULL)
+				arms_mqtt_api_tls_init(&pARMSFOTA->stFOTASock.stsockhttp.networkStack, NULL, NULL,
+					NULL, p + strlen("https://"),pARMSFOTA->stFOTACfg.stHttpCfg.nPort, 3000, false);
+			else
+				arms_mqtt_api_tls_init(&pARMSFOTA->stFOTASock.stsockhttp.networkStack, NULL, NULL,
+					NULL, pARMSFOTA->stFOTACfg.stHttpCfg.szAddr,pARMSFOTA->stFOTACfg.stHttpCfg.nPort, 3000, false);
+			pARMSFOTA->stFOTASock.stsockhttp.networkStack.tlsMode = 1;
+			pARMSFOTA->stFOTASock.fotaSockMode = ARMS_SOCK_MODE_FOTA_HTTPS;
+		}
+		else
+#endif			
+		{
+			strcpy(pARMSFOTA->stFOTASock.stsockhttp.szHttpAddr, pARMSFOTA->stFOTACfg.stHttpCfg.szAddr);
+			sprintf(pARMSFOTA->stFOTASock.stsockhttp.szHttpPort,"%d",pARMSFOTA->stFOTACfg.stHttpCfg.nPort);
+			pARMSFOTA->stFOTASock.fotaSockMode = ARMS_SOCK_MODE_FOTA_HTTP;
+		}
+	}
+	return 0;
+}
+
+int arms_fota_thread_prepare_send_telemetry_refresh(PARMSFOTA pARMSFOTA)
+{
+	arms_fota_get_data(pARMSFOTA);
+	
+	return 0;
+}
+
+int arms_fota_thread_prepare_send_telemetry(PARMSFOTA pARMSFOTA)
+{
+	arms_fota_thread_prepare_send_telemetry_refresh(pARMSFOTA);
+
+	arms_fota_thread_prepare_send_construct(pARMSFOTA);
+	
+	return 0;
+}
+
+#ifdef ARMS_FOTA_HTTP
+static void arms_fota_get_string(char *src, char *offset, char *out, unsigned int len)
+{
+    char *p1 = NULL;
+    char *p2 = NULL;
+
+    if ((offset == NULL) || (src == NULL))
+    {
+        return;
+    }
+
+    p1 = (char *)strstr((char *)src, (char *)offset);
+    if (p1 != NULL)
+    {
+        p1 += strlen((char *)offset);
+        p2 = (char *)strstr((char *)p1, (char *)"\"");
+
+        if (p2 != NULL)
+        {
+            if ((p2 - p1) > len)
+            {
+                strncpy((char *)out, (char *)p1, len);
+            }
+            else
+            {
+                strncpy((char *)out, (char *)p1, (p2 - p1));
+            }
+        }
+    }
+}
+
+static void arms_fota_get_int(char *src, char *offset, int *out)
+{
+    char *p1 = NULL;
+    char *p2 = NULL;
+    char p3[12] = {0};
+
+    *out = 0;
+    if ((offset == NULL) || (src == NULL))
+    {
+        return;
+    }
+
+    p1 = (char *)strstr((char *)src, (char *)offset);
+    if (p1 != NULL)
+    {
+        p1 += strlen((char *)offset);
+        p2 = (char *)strstr((char *)p1, (char *)",");
+
+        if (p2 != NULL)
+        {
+            if ((p2 - p1) <= 11)
+            {
+                strncpy((char *)p3, (char *)p1, (p2 - p1));
+                *out = atoi((char *)p3);
+            }
+        }
+    }
+}
+
+static void arms_fota_save_did_dsec(PARMSFOTA pARMSFOTA)
+{
+	char sign[128] = { 0 };
+	unsigned char signOut[32] = { 0 };
+	char signInput[128] = { 0 };
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+	PFOTACFG pCfg = &pARMSFOTA->stFOTACfg;
+
+	ARMS_LOG_DEBUG("%s(%d)\r\n",__FUNCTION__,__LINE__);
+
+	sprintf(signInput, "%s%s", pData->cDeviceId, pCfg->stFOTACommCfg.szIMEI);
+	arms_hmac_sha256_encypt((unsigned char *)pData->cDeviceSec, strlen(pData->cDeviceSec), (unsigned char *)signInput, strlen(signInput), signOut);
+	arms_fota_hex_to_str(sign, signOut, 32);
+
+	strcpy(pData->cDeviceidMD5,sign);
+
+	ARMS_LOG_DEBUG("%s(%d) cDeviceId=%s\r\n",__FUNCTION__,__LINE__,pData->cDeviceId);
+	ARMS_LOG_DEBUG("%s(%d) cDeviceSec=%s\r\n",__FUNCTION__,__LINE__,pData->cDeviceSec);
+	ARMS_LOG_DEBUG("%s(%d) cDeviceidMD5=%s\r\n",__FUNCTION__,__LINE__,pData->cDeviceidMD5);
+
+	arms_data_os_set_device_id(pDataFunc,pData->cDeviceId);
+	arms_data_os_set_device_sec(pDataFunc,pData->cDeviceSec);
+	arms_data_os_set_deviceid_md5(pDataFunc,pData->cDeviceidMD5);
+}
+
+void arms_fota_start_download(PARMSFOTA pARMSFOTA)
+{
+    char backup_str[ARMS_FOTA_BACKUP_BUF_SIZE] = {0};
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+
+	system("rm -rf /cache/zte_fota");
+	system("mkdir /cache/zte_fota/");
+
+	arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_DL);
+
+	ARMS_LOG_INFO("%s(%d) Start Download.\r\n",__FUNCTION__,__LINE__);
+    ARMS_LOG_DEBUG("%s(%d) down_host:%s,down_port:%s\r\n",__FUNCTION__,__LINE__,
+              pARMSFOTA->stDownInfo.down_host,
+              pARMSFOTA->stDownInfo.down_port);
+    ARMS_LOG_DEBUG("%s(%d) down_file_size:%d,down_task_id:%d\r\n",__FUNCTION__,__LINE__,
+              pARMSFOTA->stDownInfo.down_file_size,
+              pARMSFOTA->stDownInfo.down_task_id);
+
+    arms_data_os_set_backup(pDataFunc,"ARMS");
+    arms_data_os_get_backup(pDataFunc,backup_str);
+    if (backup_str[0] != 'A' || backup_str[1] != 'R' || backup_str[2] != 'M' || backup_str[3] != 'S')
+    {
+        ARMS_LOG_ERROR("%s(%d) Flag write fail.\r\n",__FUNCTION__,__LINE__);
+        pARMSFOTA->download_result = 100;
+		arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RD);
+        return;
+    }
+
+    if (pARMSFOTA->stDownInfo.down_file_size > pData->nRegionSize)
+    {
+        ARMS_LOG_ERROR("%s(%d) Not enough space.\r\n",__FUNCTION__,__LINE__);
+        pARMSFOTA->download_result = 99;
+		arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RD);
+        return;
+    }
+}
+
+void arms_fota_change_ip(PARMSFOTA pARMSFOTA)
+{
+	pARMSFOTA->stFOTASock.stsockhttp.nReconnect = 1;
+    switch (pARMSFOTA->fota_state)
+    {
+        case ARMS_FOTA_STATE_CV:
+            arms_fota_start_download(pARMSFOTA);
+            break;
+        case ARMS_FOTA_STATE_DL:
+			arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RD);
+            break;
+        default:
+            ARMS_LOG_DEBUG("%s(%d) change ip in state %d.\r\n",__FUNCTION__,__LINE__,pARMSFOTA->fota_state);
+            break;
+    }
+}
+
+void arms_fota_get_downfile_md5(PARMSFOTA pARMSFOTA,char *file_md5)
+{
+	PFOTACFG pCfg = &pARMSFOTA->stFOTACfg;
+	FILE *fp;
+	
+    unsigned int i = 0;
+    unsigned char tmp_buffer[512] = {0};
+    unsigned int total = 0;
+    ARMS_MD5_CTX abup_md5;
+    unsigned char abup_md5_result[16] = {0};
+    char abup_md5_info[33] = {0};
+
+    total = pARMSFOTA->stDownInfo.down_file_size;
+
+	fp = fopen(pCfg->stHttpCfg.szDownFilePath, "r");
+
+	if(fp == NULL)
+		return;
+	
+    arms_MD5_Init(&abup_md5);
+    while (total > 0)
+    {
+        memset(tmp_buffer,0,512);
+        if (total > 512)
+        {
+            //ARMS_LOG_DEBUG("%s(%d) calc file md5 i = %d,total = %d",__FUNCTION__,__LINE__, i, total);
+			fread(tmp_buffer,1,512,fp); 
+            arms_MD5_Update(&abup_md5, (void *)tmp_buffer, 512);
+            i += 1;
+            total -= 512;
+        }
+        else
+        {
+            //ARMS_LOG_DEBUG("%s(%d) calc file md5 i = %d,total = %d",__FUNCTION__,__LINE__, i, total);
+			fread(tmp_buffer,1,total,fp);
+            arms_MD5_Update(&abup_md5, (void *)tmp_buffer, total);
+            total = 0;
+        }
+    }
+
+	fclose(fp);
+	
+    if (total == 0)
+    {
+        memset(abup_md5_result, 0, 16);
+        memset(abup_md5_info, 0, 33);
+        arms_MD5_Final(abup_md5_result, &abup_md5);
+        arms_MD5_Encode(abup_md5_info, abup_md5_result, 16);
+        ARMS_LOG_DEBUG("%s(%d) md calc = %s\r\n",__FUNCTION__,__LINE__, abup_md5_info);
+        memcpy(file_md5,abup_md5_info, 32);
+    }
+}
+#endif
+
+void arms_fota_set_pre_version(PARMSFOTA pARMSFOTA,int isClear)
+{
+	PFOTADATA pData = &pARMSFOTA->stFOTAData;
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+
+	if(isClear)
+	{
+		//fw
+		memset(pData->stFWPreVerArr,0,sizeof(pData->stFWPreVerArr));
+		arms_data_os_set_pre_version_fw(pDataFunc,pData->stFWPreVerArr);
+
+		//cfg
+		memset(pData->stCFGPreVerArr,0,sizeof(pData->stCFGPreVerArr));
+		arms_data_os_set_pre_version_cfg(pDataFunc,pData->stCFGPreVerArr);
+
+		//mcu
+		memset(pData->stMCUPreVerArry,0,sizeof(pData->stMCUPreVerArry));
+		arms_data_os_set_pre_version_mcu(pDataFunc,pData->stMCUPreVerArry);
+	}
+	else
+	{
+		//fw
+		arms_data_os_set_pre_version_fw(pDataFunc,pData->stFWVerArr);
+
+		//cfg
+		ARMS_LOG_DEBUG("%s(%d) szFOTCfgVer = %s\r\n",__FUNCTION__,__LINE__, pData->stCFGVerArr[0].szFOTCfgVer);
+		arms_data_os_set_pre_version_cfg(pDataFunc,pData->stCFGVerArr);
+
+		//mcu
+		arms_data_os_set_pre_version_mcu(pDataFunc,pData->stMCUVerArry);
+	}
+}
+
+int arms_fota_thread_recv_cb(void* pVoidApp)
+{
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSFOTA pARMSFOTA = &pApp->stARMSFOTA;
+	PFOTASOCKRECV pSockRecv = &pARMSFOTA->stFOTASock.fotasockrecv;
+	
+#ifdef EXAMPLE_REF_VALUE
+	ARMS_LOG_INFO("%s(%d) Cur state %d.\n",__FUNCTION__,__LINE__,pARMSFOTA->fota_state);
+	if (pARMSFOTA->fota_state != ARMS_FOTA_STATE_DL)
+		ARMS_LOG_INFO("%s(%d) Received:\r\n%s\r\n",__FUNCTION__,__LINE__,pSockRecv->szRecvBuf);
+#endif
+
+	if (pSockRecv->nRecvSize > 0)
+	{
+#ifdef ARMS_FOTA_HTTP
+		char *temp_buf = (char *)pSockRecv->szRecvBuf;
+	    char *temp_buf1 = NULL;
+	    int len = 0;
+		int writtenLen = 0;
+		int writtenTotalLen = 0;
+		int status = 0;
+		char msg[ARMS_FOTA_HTTP_MSG_LEN + 1] = {0};
+		PFOTADATA pData = &pARMSFOTA->stFOTAData;
+		PFOTACFG pCfg = &pARMSFOTA->stFOTACfg;
+		PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+		FILE *fp = NULL;
+
+	    if ((strstr((char *)temp_buf, (char *)"HTTP/1.1 301") != NULL) || (strstr((char *)temp_buf, (char *)"HTTP/1.1 302") != NULL) ||
+	        (strstr((char *)temp_buf, (char *)"HTTP/1.0 301") != NULL) || (strstr((char *)temp_buf, (char *)"HTTP/1.0 302") != NULL) || 
+	        (strstr((char *)temp_buf, (char *)"HTTP/1.1 404") != NULL) || (strstr((char *)temp_buf, (char *)"HTTP/1.0 404") != NULL))
+	    {
+	        ARMS_LOG_ERROR("%s(%d) found 301 302 404\r\n",__FUNCTION__,__LINE__);
+	        return ARMS_FOTA_HTTP_RESPONSE_CODE_FAILED;
+	    }
+
+	    temp_buf1 = (char *)strstr((char *)temp_buf, (char *)"HTTP/1.1");
+	    if (temp_buf1 == NULL)
+	    {
+	        if (pARMSFOTA->fota_state != ARMS_FOTA_STATE_DL)
+	        {
+	        	ARMS_LOG_ERROR("%s(%d) not found HTTP/1.1\r\n",__FUNCTION__,__LINE__);
+	            return ARMS_FOTA_HTTP_NOT_FOND_1_1_FAILED;
+	        }
+	    }
+
+	    temp_buf1 = (char *)strstr((char *)temp_buf, (char *)"Connection:");
+	    if (temp_buf1 == NULL)
+	    {
+	        if (pARMSFOTA->fota_state != ARMS_FOTA_STATE_DL)
+	        {
+	        	ARMS_LOG_ERROR("%s(%d) not found Connection\r\n",__FUNCTION__,__LINE__);
+	            return ARMS_FOTA_HTTP_NOT_FOND_CONNECTION_FAILED;
+	        }
+	    }
+
+	    //abup_printf("ABUP-->abup_parse_http_data len:%d", len);
+	    if (pARMSFOTA->fota_state != ARMS_FOTA_STATE_DL)
+	    {
+	        arms_fota_get_int(temp_buf, "\"status\":", &status);
+
+	        if (status != ARMS_FOTA_SUCCESS)
+	        {				
+	            arms_fota_get_string(temp_buf, "\"msg\":\"", msg, ARMS_FOTA_HTTP_MSG_LEN);
+				ARMS_LOG_ERROR("%s(%d) status:%d, msg:%s\r\n",__FUNCTION__,__LINE__, status, msg);
+	            //ARMS_LOG_ERROR("%s(%d) status error.\r\n",__FUNCTION__,__LINE__);
+	            return ARMS_FOTA_HTTP_STATUS_FAILED;
+	        }
+	    }
+
+	    switch (pARMSFOTA->fota_state)
+	    {
+	        case ARMS_FOTA_STATE_RG:
+	            memset(pData->cDeviceId, 0, ARMS_FOTA_DEVICE_ID_BUF_SIZE);
+	            memset(pData->cDeviceSec, 0, ARMS_FOTA_DEVICE_SEC_BUF_SIZE);
+	            arms_fota_get_string(temp_buf, "\"deviceId\":\"", pData->cDeviceId, ARMS_FOTA_DEVICE_ID_BUF_SIZE);
+	            arms_fota_get_string(temp_buf, "\"deviceSecret\":\"", pData->cDeviceSec, ARMS_FOTA_DEVICE_SEC_BUF_SIZE);
+				arms_fota_save_did_dsec(pARMSFOTA);
+	            arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_CV);
+	            break;
+	        case ARMS_FOTA_STATE_CV: // check version
+	        {
+	            char *p1 = NULL, *p2 = NULL;
+
+	            arms_fota_get_string((char *)temp_buf, (char *)"\"fileUrl\":\"", pARMSFOTA->stDownInfo.down_host, ARMS_HTTP_SRV_ADDR_SIZE - 2);
+	            p1 = (char *)strstr(pARMSFOTA->stDownInfo.down_host, (char *)"http://");
+	            if (p1 != NULL)
+	            {
+	                p1 += strlen((char *)"http://");
+	                p2 = (char *)strstr((char *)p1, (char *)"/");
+					ARMS_LOG_DEBUG("%s(%d) p1=%s\r\n",__FUNCTION__,__LINE__,p1);
+	            	ARMS_LOG_DEBUG("%s(%d) p2=%s\r\n",__FUNCTION__,__LINE__,p2);
+	                if (p2 != NULL && (p2 - p1) < ARMS_HTTP_SRV_ADDR_SIZE)
+	                {
+	                	strcpy(pARMSFOTA->stDownInfo.down_path, p2);
+	                    memmove(pARMSFOTA->stDownInfo.down_host, p1, p2 - p1);
+	                    pARMSFOTA->stDownInfo.down_host[p2 - p1] = '\0';
+	                }
+					strcpy((char *)pARMSFOTA->stDownInfo.down_port, (char *)"80");
+					
+					ARMS_LOG_DEBUG("%s(%d) pARMSFOTA->stDownInfo.down_host=%s\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_host);
+	            	ARMS_LOG_DEBUG("%s(%d) pARMSFOTA->stDownInfo.down_path=%s\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_path);
+	            }
+				else
+				{
+					p1 = (char *)strstr(pARMSFOTA->stDownInfo.down_host, (char *)"https://");
+		            if (p1 != NULL)
+		            {
+		                p1 += strlen((char *)"https://");
+		                p2 = (char *)strstr((char *)p1, (char *)"/");
+						ARMS_LOG_DEBUG("%s(%d) p1=%s\r\n",__FUNCTION__,__LINE__,p1);
+		            	ARMS_LOG_DEBUG("%s(%d) p2=%s\r\n",__FUNCTION__,__LINE__,p2);
+		                if (p2 != NULL && (p2 - p1) < ARMS_HTTP_SRV_ADDR_SIZE)
+		                {
+		                	strcpy(pARMSFOTA->stDownInfo.down_path, p2);
+		                    memmove(pARMSFOTA->stDownInfo.down_host, p1, p2 - p1);
+		                    pARMSFOTA->stDownInfo.down_host[p2 - p1] = '\0';
+		                }
+						strcpy((char *)pARMSFOTA->stDownInfo.down_port, (char *)"443");
+						
+						ARMS_LOG_DEBUG("%s(%d) pARMSFOTA->stDownInfo.down_host=%s\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_host);
+		            	ARMS_LOG_DEBUG("%s(%d) pARMSFOTA->stDownInfo.down_path=%s\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_path);
+		            }
+				}
+				
+				arms_fota_get_int(temp_buf, (char *)"\"taskId\":", (int *)&pARMSFOTA->stDownInfo.down_task_id);
+				ARMS_LOG_DEBUG("%s(%d) down_task_id=%d\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_task_id);
+	            arms_fota_get_int(temp_buf, (char *)"\"fileSize\":", (int *)&pARMSFOTA->stDownInfo.down_file_size);
+				ARMS_LOG_DEBUG("%s(%d) down_file_size=%d\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_file_size);
+				arms_fota_get_string(temp_buf, (char *)"\"fileHash\":\"", (char *)pARMSFOTA->stDownInfo.down_md5, ARMS_FOTA_DEVICEID_MD5_BUF_SIZE);
+
+				p1 = (char *)strstr((char *)pARMSFOTA->stDownInfo.down_host, (char *)":");
+	            if (p1 != NULL)
+	            {
+	            	strcpy((char *)pARMSFOTA->stDownInfo.down_port, (char *)(p1 +1));
+					*p1 = '\0';
+	            }
+
+				arms_data_os_set_task_id(pDataFunc,pARMSFOTA->stDownInfo.down_task_id);
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+				pARMSFOTA->download_result = 1;
+				arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RD);
+				return 0;
+#endif
+				arms_fota_change_ip(pARMSFOTA);
+	            break;
+	        }
+	        case ARMS_FOTA_STATE_DL:
+				pARMSFOTA->download_retry_cnt = 0;
+	            temp_buf1 = (char *)strstr((char *)temp_buf, (char *)"Content-Range: bytes ");
+	            if (temp_buf1)
+	            {
+	                unsigned int s = 0, e = 0, t = 0;
+
+	                temp_buf1 += strlen("Content-Range: bytes ");
+	                sscanf((char *)temp_buf1, "%d-%d/%d", &s, &e, &t);
+					
+					if(t != pARMSFOTA->stDownInfo.down_file_size)
+						pARMSFOTA->stDownInfo.down_file_size = t;
+					
+	                if ((e - s) <= pARMSFOTA->stDownInfo.down_file_size)
+	                {
+	                    ARMS_LOG_DEBUG("%s(%d) Download:%d-%d/%d \r\n",__FUNCTION__,__LINE__, s, e, t);
+	                }
+	                else
+	                {
+	                    ARMS_LOG_ERROR("%s(%d) Download size error!\r\n",__FUNCTION__,__LINE__);
+	                    return ARMS_FOTA_HTTP_DOWNLOAD_SIZE_FAILED;
+	                }
+
+	                temp_buf1 = (char *)strstr((char *)temp_buf1, (char *)"\r\n\r\n");
+	                if (temp_buf1)
+	                {
+	                	temp_buf1 += strlen("\r\n\r\n");
+	                }
+	                else
+	                {
+	                    ARMS_LOG_DEBUG("%s(%d)  not find temp_buf1\r\n",__FUNCTION__,__LINE__);
+	                }
+
+					len = pSockRecv->nRecvSize - (temp_buf1 - temp_buf);
+					temp_buf = temp_buf1;
+					if(pData->nDownSize == 0)
+					{
+						ARMS_LOG_DEBUG("%s(%d) open download file for writing first block.\n",__FUNCTION__,__LINE__);
+						fp = fopen(pCfg->stHttpCfg.szDownFilePath, "w");
+					}
+					else
+					{
+						ARMS_LOG_DEBUG("%s(%d) open download file for appending reminding content.\n",__FUNCTION__,__LINE__);
+						fp = fopen(pCfg->stHttpCfg.szDownFilePath, "a");
+					}
+	            }
+	            else
+	            {
+	            	
+					len = pSockRecv->nRecvSize;
+
+					ARMS_LOG_DEBUG("%s(%d) open download file for appending reminding content.\n",__FUNCTION__,__LINE__);
+					fp = fopen(pCfg->stHttpCfg.szDownFilePath, "a");
+	            }
+
+				if(fp)
+				{
+					if (pARMSFOTA->stDownInfo.current_block_remaining < len)
+					{
+						ARMS_LOG_INFO("%s(%d) overwrite adjust left [%d], write[%d].\n", __FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.current_block_remaining, len);
+						len = pARMSFOTA->stDownInfo.current_block_remaining;
+					}
+					
+					while(writtenTotalLen < len)
+					{
+						writtenLen = fwrite(temp_buf+writtenTotalLen, 1, len-writtenTotalLen, fp);
+						writtenTotalLen +=  writtenLen;
+						ARMS_LOG_DEBUG("%s(%d) written(%d/%d).\n",__FUNCTION__,__LINE__,writtenTotalLen,len);
+					}
+
+			    	fclose(fp);	
+				}
+				else
+				{
+					ARMS_LOG_ERROR("%s(%d) fopen failed.\n",__FUNCTION__,__LINE__);
+					return ARMS_FOTA_HTTP_WRITE_FILE_FAILED;
+				}
+
+				pData->nDownSize += len;
+
+				ARMS_LOG_DEBUG("%s(%d) downloaded file size:%d, total file size:%d\r\n",__FUNCTION__,__LINE__, pData->nDownSize,pARMSFOTA->stDownInfo.down_file_size);
+
+				arms_fota_set_percentage(pARMSFOTA,((pData->nDownSize*100) / pARMSFOTA->stDownInfo.down_file_size));
+
+				if (pData->nDownSize >= pARMSFOTA->stDownInfo.down_file_size)
+	            {
+	                char file_md5[ARMS_FOTA_DEVICEID_MD5_BUF_SIZE] = {0};
+	                ARMS_LOG_DEBUG("%s(%d) download complete. md5:%s\r\n",__FUNCTION__,__LINE__,pARMSFOTA->stDownInfo.down_md5);
+
+					arms_data_os_set_down_size(pDataFunc,0);
+					arms_data_os_set_backup(pDataFunc,"");
+
+	                arms_fota_get_downfile_md5(pARMSFOTA,file_md5);
+	                if(strncmp((char *)file_md5, (char *)pARMSFOTA->stDownInfo.down_md5, strlen(pARMSFOTA->stDownInfo.down_md5)) == 0)
+	                {
+	                    ARMS_LOG_INFO("%s(%d) DL MD5 OK.\r\n",__FUNCTION__,__LINE__);
+						arms_fota_set_pre_version(pARMSFOTA,0);
+	                    pARMSFOTA->download_result = 1;
+	                }
+	                else
+	                {
+	                    ARMS_LOG_INFO("%s(%d) DL MD5 FAIL.\r\n",__FUNCTION__,__LINE__);
+	                    remove(pCfg->stHttpCfg.szDownFilePath);
+	                    pARMSFOTA->download_result = 8;
+	                }
+
+	                arms_fota_change_ip(pARMSFOTA);
+	            }
+	            else
+	            {
+	            	arms_data_os_set_down_size(pDataFunc,pData->nDownSize);
+	            }
+				
+				ARMS_LOG_DEBUG("%s(%d) len:%d\r\n",__FUNCTION__,__LINE__, len);
+				pARMSFOTA->stDownInfo.current_block_remaining -= len;
+				ARMS_LOG_DEBUG("%s(%d) current_block_remaining:%d\r\n",__FUNCTION__,__LINE__, pARMSFOTA->stDownInfo.current_block_remaining);
+                if(pARMSFOTA->stDownInfo.current_block_remaining != 0)
+					return ARMS_FOTA_DOWN_CONTINUE;
+				break;
+	        case ARMS_FOTA_STATE_RD:
+	            arms_fota_set_percentage(pARMSFOTA,100);
+	            ARMS_LOG_INFO("%s(%d) Download report done!\r\n",__FUNCTION__,__LINE__);
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+				arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RU);
+				return 0;
+#endif
+
+	            if (pARMSFOTA->download_result == 1)
+	            {
+	            	ARMS_LOG_INFO("%s(%d) Go to Upgrade,it will reboot!\r\n",__FUNCTION__,__LINE__);
+	                arms_data_os_upgrade(pDataFunc,pCfg->stHttpCfg.szDownFilePath);
+					return ARMS_FOTA_DOWNLOAD_DONE;
+	            }
+	            else
+	            {
+	                ARMS_LOG_ERROR("%s(%d) Download fail(download_result=%d)!\r\n",__FUNCTION__,__LINE__, pARMSFOTA->download_result);
+	                return ARMS_FOTA_HTTP_DOWN_FAILED;
+	            }
+	            break;
+	        case ARMS_FOTA_STATE_RU:
+	            ARMS_LOG_INFO("%s(%d) Upgrade report done!\r\n",__FUNCTION__,__LINE__);
+				arms_fota_set_pre_version(pARMSFOTA,1);
+				return ARMS_FOTA_UPGRADE_DONE;
+	            break;
+	        default:
+	            break;
+	    }
+#endif
+	}
+	
+	return 0;
+}
+
+int arms_fota_thread_send_and_recv(PARMSFOTA pARMSFOTA)
+{
+	arms_fota_thread_prepare_send_telemetry(pARMSFOTA);
+	
+#ifdef EXAMPLE_REF_VALUE
+	PFOTASOCKSEND pFOTASockSend = &pARMSFOTA->stFOTASock.fotasocksend;
+
+	ARMS_LOG_INFO("%s(%d) Sending:\r\n%s\r\n",__FUNCTION__,__LINE__,pFOTASockSend->szSendBuf);
+#endif
+
+	return arms_sock_fota_send_and_recv_with_server(&pARMSFOTA->stFOTASock);
+}
+
+
+static int arms_fota_state_idle(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	if (arms_fota_check_upgrade(pARMSFOTA) == 0)
+	{
+		if (arms_fota_check_devid_sec(pARMSFOTA) == 0)
+		{
+			ARMS_LOG_DEBUG("%s(%d) device should register.\r\n",__FUNCTION__,__LINE__);
+			arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RG);
+		}
+		else
+		{
+			arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_CV);
+		}
+	}
+	else
+	{
+		arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RU);
+	}
+
+	if (pARMSFOTA->fota_state != ARMS_FOTA_STATE_RU)
+	{
+		arms_fota_set_percentage(pARMSFOTA,0);
+	}
+
+	if (arms_data_os_get_net_status(pDataFunc) == 0)
+	{
+		ARMS_LOG_ERROR("%s(%d) network is not ok!\r\n",__FUNCTION__,__LINE__);
+		return -2;
+	}
+
+	return 0;
+}
+
+static int arms_fota_state_register(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	return arms_fota_thread_send_and_recv(pARMSFOTA);
+}
+
+static int arms_fota_state_check_version(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	return arms_fota_thread_send_and_recv(pARMSFOTA);
+}
+
+static int arms_fota_state_download(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	if (pARMSFOTA->download_retry_cnt > 60)
+	{
+		ARMS_LOG_ERROR("%s(%d) Download retry timeout! [%d]\n",__FUNCTION__,__LINE__,pARMSFOTA->download_retry_cnt);
+		return ARMS_SOCK_SEND_TO_SERVER_FAILED;
+	}
+
+	return arms_fota_thread_send_and_recv(pARMSFOTA);
+}
+
+static int arms_fota_state_report_download(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	return arms_fota_thread_send_and_recv(pARMSFOTA);
+}
+
+static int arms_fota_state_report_upgrade(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	return arms_fota_thread_send_and_recv(pARMSFOTA);
+}
+
+static int arms_fota_process(PARMSFOTA pARMSFOTA)
+{
+	int nRet = -1;
+	while(1)
+	{
+		nRet = pARMSFOTA->state_cb[pARMSFOTA->fota_state]((void*)pARMSFOTA);
+		if(nRet != 0)
+		{
+			arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_IDLE);
+			arms_sock_fota_close(&pARMSFOTA->stFOTASock);
+			//arms_fota_change_ip(pARMSFOTA);
+			ARMS_LOG_ERROR("%s(%d) end with Ret = [%d]\n",__FUNCTION__,__LINE__, nRet);
+			break;
+		}
+	}
+	
+	return nRet;
+}
+
+int arms_fota_report_log(void* pVoid, int nAppLog, char* pFilePath, char* pFileName)
+{
+	int ret = 0;
+	unsigned char nLogType = 1;
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	PARMSDATAFUNLIST pDataFunc = NULL;
+	PFOTACFG pCfg = NULL;
+	PFOTADATA pData = NULL;
+	//PFOTASOCKSEND pFOTASockSend = NULL;
+	PFOTASOCKHTTP pFOTASockHTTP = NULL;
+
+	char *p = NULL;
+	unsigned char *signptr = 0;
+	char sign[128] = { 0 };
+	unsigned char signOut[32] = { 0 };
+	char signInput[128] = { 0 };
+	char timestamp[64] = { 0 };
+
+	char content_path[256] = { 0 };
+	char content_host[256] = { 0 };
+	char content_type[128] = { 0 };  
+	char content_file[256] = { 0 };
+	char content_timestamp[256] = { 0 };
+	char content_sign[256] = { 0 };
+	char content_mid[256] = { 0 };
+	char content_error_type[256] = { 0 };
+	char content_productid[256] = { 0 };
+	char content_connection[128] = { 0 };
+	char content_encode[128] =  { 0 };
+	char content_len[50] = { 0 };
+
+	char boundary[] = "----WebKitFormBoundary7MA4YWxkTrZu0gW";
+	char szSendBuf[2048] = { 0 };
+	int nSendlen = 0;
+	FILE *fp = NULL;
+	int file_len = 0;
+	char *pfile_buf = NULL;
+
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	if (nAppLog > 0)
+		nLogType = 2;
+
+	ARMS_LOG_INFO("%s(%d) started\n",__FUNCTION__,__LINE__);
+
+	pDataFunc = pARMSFOTA->pDataFunList;
+	pCfg = &pARMSFOTA->stFOTACfg;
+	pData = &pARMSFOTA->stFOTAData;
+	pFOTASockHTTP = &pARMSFOTA->stFOTASock.stsockhttp;
+	//pFOTASockSend = &pARMSFOTA->stFOTASock.fotasocksend;
+
+	if (pFilePath == NULL)
+		return -2;
+
+	if (pFileName == NULL)
+		return -3;
+
+	fp = fopen(pFilePath, "rb");
+	if(NULL == fp)
+	{
+		ARMS_LOG_INFO("%s(%d) Open File error...\n",__FUNCTION__,__LINE__);
+		return -5;
+	}
+
+	fseek(fp, 0, SEEK_END);
+	file_len = ftell(fp);
+	rewind(fp);
+
+	pfile_buf = (char *)malloc(file_len + 1);
+	if(pfile_buf == NULL)
+	{
+		ret = -4;
+		goto ERR_EXIT;
+	}
+	
+	memset(pfile_buf, 0, file_len + 1);
+	fseek(fp, 0, SEEK_SET);
+	fread(pfile_buf, sizeof(char), file_len, fp);
+	
+
+	arms_data_os_get_timestamp(pDataFunc,&pData->timestamp);
+	sprintf(timestamp, "%ld", pData->timestamp);
+	ARMS_LOG_DEBUG("%s(%d) timestamp:%s.\r\n",__FUNCTION__,__LINE__,timestamp);
+	
+	//sprintf(timestamp, "%ld", pData->timestamp);
+	//ARMS_LOG_DEBUG("%s(%d) signInput:%s.\r\n",__FUNCTION__,__LINE__,signInput);
+	sprintf(signInput, "%s%s", pData->cDeviceId, timestamp);
+	ARMS_LOG_DEBUG("%s(%d) signInput:%s.\r\n",__FUNCTION__,__LINE__,signInput);
+
+	arms_hmac_sha256_encypt((unsigned char *)pData->cDeviceSec, strlen((char *)pData->cDeviceSec), (unsigned char *)signInput, strlen(signInput), signOut);
+	ARMS_LOG_DEBUG("%s(%d) signOut:%s.\r\n",__FUNCTION__,__LINE__,signOut);
+
+	arms_fota_hex_to_str(sign, signOut, 32);
+	ARMS_LOG_DEBUG("%s(%d) sign:%s.\r\n",__FUNCTION__,__LINE__,sign);
+
+	signptr = (unsigned char*)sign;
+	
+	sprintf(content_path,"POST /deviceapi/%s/%s/ota/reportErrorLog HTTP/1.1\r\n",pCfg->stHttpCfg.szProdID, pData->cDeviceId);
+	
+	p = strstr(pARMSFOTA->stFOTACfg.stHttpCfg.szAddr, (char *)"https://");
+	if(p != NULL)
+		sprintf(content_host,"Host: %s\r\n",pCfg->stHttpCfg.szAddr+strlen("https://"));
+	else
+		sprintf(content_host,"Host: %s\r\n",pCfg->stHttpCfg.szAddr);
+
+	strcpy(content_encode,"cache-control: no-cache\r\nnAccept-Encoding: gzip, deflate, br\r\n");
+
+	sprintf(content_type,"Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
+
+	strcpy(content_connection,"Connection: keep-alive\r\n\r\n");
+
+	sprintf(content_file,"--%s\r\nContent-Disposition: form-data; name=\"uploadFile\"; filename=\"%s\"\r\nContent-Type: application/zip\r\n\r\n", boundary, pFileName);
+
+	sprintf(content_timestamp,"\r\n--%s\r\nContent-Disposition: form-data; name=\"timestamp\"\r\n\r\n%s\r\n", boundary, timestamp);
+
+	sprintf(content_sign,"--%s\r\nContent-Disposition: form-data; name=\"sign\"\r\n\r\n%s\r\n", boundary, (signptr == NULL? (char *)"NULL":(char *)signptr));
+
+	sprintf(content_mid, "--%s\r\nContent-Disposition: form-data; name=\"mid\"\r\n\r\n%s\r\n", boundary, pCfg->stFOTACommCfg.szIMEI);
+
+	//2: app log
+	sprintf(content_error_type,  "--%s\r\nContent-Disposition: form-data; name=\"errorType\"\r\n\r\n%d\r\n", boundary, nLogType);	
+
+	sprintf(content_productid,  "--%s\r\nContent-Disposition: form-data; name=\"productId\"\r\n\r\n%s\r\n--%s--\r\n",boundary, pCfg->stHttpCfg.szProdID, boundary);
+	
+	nSendlen = strlen(content_file) + file_len + strlen(content_timestamp) + strlen(content_sign) + strlen(content_mid) + strlen(content_error_type) + strlen(content_productid);
+	
+	sprintf(content_len,"Content-Length: %d\r\n", nSendlen);
+
+	memset(szSendBuf, 0, sizeof(szSendBuf));
+	sprintf(szSendBuf,  "%s%s%s%s%s%s%s", content_path, content_host, content_encode, content_len, content_type, content_connection, content_file);
+
+	nSendlen = strlen(szSendBuf);
+
+	if (pFOTASockHTTP->nHttpFd == ARMS_INVALID_HANDLE || pFOTASockHTTP->nReconnect)
+	{
+		if(pFOTASockHTTP->nHttpFd != ARMS_INVALID_HANDLE)
+			arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+
+		pFOTASockHTTP->nReconnect = 0;
+
+		ARMS_LOG_DEBUG("%s(%d) TCP Sock Open...\n",__FUNCTION__,__LINE__);
+		pFOTASockHTTP->nHttpFd = arms_sock_tcp_open(&pFOTASockHTTP->nHttpFd,pFOTASockHTTP->szHttpAddr,pFOTASockHTTP->szHttpPort);
+		if (pFOTASockHTTP->nHttpFd == ARMS_INVALID_HANDLE)
+		{			
+			ARMS_LOG_ERROR("%s(%d) open tcp addr=[%s] port = [%s] failed\n",__FUNCTION__,__LINE__, pFOTASockHTTP->szHttpAddr, pFOTASockHTTP->szHttpPort);
+			ret = ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+			goto ERR_EXIT;
+		}
+	}
+
+//step 1.
+	ARMS_LOG_INFO("%s(%d) TCP sock Sending(len:%d)... buf = [%s]\n",__FUNCTION__,__LINE__, nSendlen ,szSendBuf);
+	ret = arms_sock_tcp_send(pFOTASockHTTP->nHttpFd, (const char *)szSendBuf, nSendlen);
+	if(ret <= 0)
+	{
+		ret = ARMS_SOCK_SEND_TO_SERVER_FAILED;
+		goto ERR_EXIT;
+	}
+
+//step 2.
+	ARMS_LOG_DEBUG("%s(%d) TCP sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,file_len);
+	ret = arms_sock_tcp_send(pFOTASockHTTP->nHttpFd, (const char *)pfile_buf, file_len);
+	if(ret <= 0)
+	{
+		ret = ARMS_SOCK_SEND_TO_SERVER_FAILED;
+		goto ERR_EXIT;
+	}
+	
+//step 3.
+	memset(szSendBuf, 0, sizeof(szSendBuf));
+	sprintf(szSendBuf, "%s%s%s%s%s", content_timestamp, content_sign, content_mid, content_error_type, content_productid);
+	nSendlen =	strlen(content_timestamp) + strlen(content_sign) + strlen(content_mid) + strlen(content_error_type) + strlen(content_productid);
+	ARMS_LOG_DEBUG("%s(%d) TCP sock Sending(len:%d)...\n",__FUNCTION__,__LINE__, nSendlen);
+	ret = arms_sock_tcp_send(pFOTASockHTTP->nHttpFd, (const char *)szSendBuf, nSendlen);
+	sleep(3);
+
+ERR_EXIT:
+	if (fp != NULL)
+	{
+		fclose(fp);
+	}
+
+	ARMS_FREE_PTR(pfile_buf);
+
+	ARMS_LOG_DEBUG("%s(%d) ret = [%d]\n",__FUNCTION__,__LINE__, ret);
+	return ret;
+}
+
+static int arms_log_state_idle(void* pVoid)
+{
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	if (arms_fota_check_devid_sec(pARMSFOTA) == 0)
+	{
+		ARMS_LOG_INFO("%s(%d) device should register.\r\n",__FUNCTION__,__LINE__);
+		arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_RG);
+	}
+	else
+	{
+		arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_CV);
+	}
+
+	if (arms_data_os_get_net_status(pDataFunc) == 0)
+	{
+		ARMS_LOG_ERROR("%s(%d) network is not ok!\r\n",__FUNCTION__,__LINE__);
+		return -2;
+	}
+
+	return 0;
+}
+
+static int arms_log_state_register(void* pVoid)
+{
+	return arms_fota_state_register(pVoid);
+}
+
+static int arms_log_state_report(PARMSFOTA pARMSFOTA)
+{
+	PARMSDATAFUNLIST pDataFunc = pARMSFOTA->pDataFunList;
+	int nRet, nFilePath, nFileName;
+	char szFilePath[256] = {0};
+	char szFileName[128] = {0};
+
+	nFilePath = sizeof(szFilePath);
+	nFileName = sizeof(szFileName);
+	nRet = arms_data_os_get_log(pDataFunc, szFilePath, &nFilePath, szFileName, &nFileName);
+	if (nRet >= 0)
+	{
+		arms_fota_report_log(pARMSFOTA, 1, szFilePath, szFileName);
+		nRet = -1;
+	}
+	
+	return nRet;
+}
+
+static int arms_log_process(PARMSFOTA pARMSFOTA)
+{
+	int i, nRet = -1;
+	ARMS_FOTA_STATE nPreST;
+
+	if (pARMSFOTA == NULL)
+		return 0;
+	
+	nPreST = pARMSFOTA->fota_state;
+	arms_fota_set_state(pARMSFOTA,ARMS_FOTA_STATE_IDLE);
+	
+	for (i = 0; i < 15; i++)
+	{
+		if (pARMSFOTA->fota_state == ARMS_FOTA_STATE_IDLE)
+		{
+			nRet = arms_log_state_idle(pARMSFOTA);
+		}
+		else if (pARMSFOTA->fota_state == ARMS_FOTA_STATE_RG)
+		{
+			nRet = arms_log_state_register(pARMSFOTA);
+		}
+		else if (pARMSFOTA->fota_state == ARMS_FOTA_STATE_CV)
+		{
+			nRet = arms_log_state_report(pARMSFOTA);
+		}
+
+		if (nRet != 0)
+			break;
+
+		sleep(2);
+	}
+
+	arms_sock_fota_close(&pARMSFOTA->stFOTASock);
+	arms_fota_set_state(pARMSFOTA,nPreST);
+	
+	return nRet;
+}
+
+static void* arms_fota_thread_handle(void* pVoid)
+{
+	int nSegRet;//, nSleepTime = 2;
+	int nRet = -1, nSig = -1,  nRecvLen = ARMS_FOTA_THREAD_BUF_LEN;
+	char *pNewMaclloc = NULL, pRecv[ARMS_FOTA_THREAD_BUF_LEN] = {0};
+	PARMSFOTA pARMSFOTA = (PARMSFOTA)pVoid;
+	
+	if (pARMSFOTA == NULL)
+	{
+		return NULL;
+	}
+
+	prctl(PR_SET_NAME, "FOTA");
+	
+	while (!pARMSFOTA->exitflag)
+	{
+		nRecvLen = ARMS_FOTA_THREAD_BUF_LEN;
+		pNewMaclloc = NULL;
+		nSig = -1;
+
+		nSegRet = arms_list_wait_msg_event(&pARMSFOTA->fota_signal,60);
+		if (nSegRet != 0)
+		{
+			ARMS_LOG_ERROR("%s(%d) fota thread sem_timedwait	errno = %d \n",__FUNCTION__,__LINE__, nSegRet);
+			sleep(2);
+		}
+
+		nRet = arms_list_get_msg_event(&pARMSFOTA->fota_signal,&nSig, pRecv, &nRecvLen, &pNewMaclloc);
+		if (nRet == ARMS_LIST_MSG_EMPTY_ERROR)
+			continue;
+
+		ARMS_LOG_DEBUG("%s(%d) fota thread exe  nRet = %d \n",__FUNCTION__,__LINE__, nRet);
+		
+		if (nRet >= 0) 
+		{		
+			char *pData =  ((pNewMaclloc == NULL) ? pRecv : pNewMaclloc);
+			if (pData != NULL || ARMS_SIGN_FOTA_START == nSig)
+			{
+				switch (nSig)
+				{
+					case ARMS_SIGN_FOTA_START:
+					{
+						nRet = arms_fota_process(pARMSFOTA);
+					}
+					break;
+
+					case ARMS_SIGN_LOG_START:
+					{
+						nRet = arms_log_process(pARMSFOTA);
+					}
+					break;
+				}
+			}
+
+			if (pNewMaclloc != NULL)
+				free(pNewMaclloc);
+				
+			arms_list_post_msg_event(&pARMSFOTA->fota_signal); 
+		}	
+		
+	}
+	
+	ARMS_LOG_DEBUG("%s(%d) fota thread EXIT \n",__FUNCTION__,__LINE__);
+	return 0;
+}
+
+int arms_fota_start_thread(PARMSFOTA pARMSFOTA)
+{
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+	
+	pthread_attr_init (&pARMSFOTA->fota_thread_attr);
+	pthread_attr_setdetachstate (&pARMSFOTA->fota_thread_attr, PTHREAD_CREATE_DETACHED);
+	pthread_create(&pARMSFOTA->fota_thread_handle, &pARMSFOTA->fota_thread_attr, arms_fota_thread_handle, pARMSFOTA);
+
+	return 0;
+}
+
+int arms_fota_stop_thread(PARMSFOTA pARMSFOTA)
+{
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+	
+	pARMSFOTA->exitflag = 1;
+	arms_list_post_msg_event(&pARMSFOTA->fota_signal);
+	
+	return 0;
+}
+
+#ifdef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER
+void arms_fota_timer_cb(int signo) 
+{
+	PARMSFOTA pARMSFOTA = GetARMSAppFOTASTPointer();
+	
+	arms_fota_add_msg_event(pARMSFOTA, ARMS_SIGN_FOTA_START, NULL, 0);
+}
+
+int arms_fota_start_timer(PARMSFOTA pARMSFOTA)
+{
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+
+	arms_util_create_timer_msec(&pARMSFOTA->fota_timer, arms_fota_timer_cb, 30*1000, pARMSFOTA->fota_check_period, SIGUSR2);
+
+	return 0;
+}
+
+int arms_fota_stop_timer(PARMSFOTA pARMSFOTA)
+{
+	if (pARMSFOTA == NULL)
+	{
+		return -1;
+	}
+	
+	arms_util_destroy_timer_msec(&pARMSFOTA->fota_timer);
+
+	ARMS_LOG_DEBUG("%s(%d) fota timer EXIT \n",__FUNCTION__,__LINE__);
+	
+	return 0;
+}
+#endif
+
+static int arms_fota_init_sock(PARMSFOTA pARMSFOTA)
+{
+
+	PFOTACOMMCFG pCommCfg = &pARMSFOTA->stFOTACfg.stFOTACommCfg;
+
+	pARMSFOTA->stFOTASock.fotaSockMode = ARMS_SOCK_MODE_FOTA_MAX;
+
+#ifdef ARMS_FOTA_HTTP
+	if (pCommCfg->emCommMode == ARMS_FOTA_COMM_HTTP_HTTPS)
+	{	
+		pARMSFOTA->stFOTASock.stsockhttp.nHttpFd = ARMS_INVALID_HANDLE;
+	}
+#endif
+
+	return 0;
+}
+
+static int arms_fota_init_msg_event(PARMSFOTA pARMSFOTA)
+{
+	arms_list_init_msg_event(&pARMSFOTA->fota_signal);
+	return 0;
+}
+
+static int arms_fota_destroy_msg_event(PARMSFOTA pARMSFOTA)
+{
+	arms_list_destroy_msg_event(&pARMSFOTA->fota_signal);
+	return 0;
+}
+
+int arms_fota_add_msg_event(PARMSFOTA pARMSFOTA,int nSig, unsigned char* pData, int nDataSize)
+{
+	return arms_list_add_msg_event(&pARMSFOTA->fota_signal, nSig, (char *)pData, nDataSize, -1);
+}
+
+int arms_fota_init(void* pVoidApp)
+{	
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSFOTA pARMSFOTA = &pApp->stARMSFOTA;
+	PFOTACOMMCFG pCommCfg = &pARMSFOTA->stFOTACfg.stFOTACommCfg;
+	
+	arms_fota_init_sock(pARMSFOTA);
+	
+	arms_fota_init_msg_event(pARMSFOTA);
+
+	arms_sock_fota_reg_recv_cb(&pARMSFOTA->stFOTASock, arms_fota_thread_recv_cb, pVoidApp);
+
+	pARMSFOTA->fota_state = ARMS_FOTA_STATE_IDLE;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_IDLE] = arms_fota_state_idle;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_RG] = arms_fota_state_register;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_CV] = arms_fota_state_check_version;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_DL] = arms_fota_state_download;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_RD] = arms_fota_state_report_download;
+	pARMSFOTA->state_cb[ARMS_FOTA_STATE_RU] = arms_fota_state_report_upgrade;
+	arms_fota_get_data(pARMSFOTA);
+
+	pARMSFOTA->fota_check_period = pCommCfg->nCheckPeriod;
+	
+	return 0;
+}
+
+int arms_fota_uninit(void* pVoidApp)
+{
+	PAPPARMS pApp = (PAPPARMS)pVoidApp;
+	PARMSFOTA pARMSFOTA = &pApp->stARMSFOTA;
+	
+	arms_fota_destroy_msg_event(pARMSFOTA);
+	
+	return 0;
+}
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_fota.h b/lynq/S300/ap/app/apparms/apparms_fota.h
new file mode 100755
index 0000000..efb048e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_fota.h
@@ -0,0 +1,122 @@
+
+#ifndef _APPARMS_FOTA
+#define _APPARMS_FOTA 1
+
+#include "apparms_macro.h"
+#include "apparms_config_os.h"
+#include "apparms_data_os.h"
+#include "apparms_list.h"
+#include "apparms_sock.h"
+
+#ifdef ARMS_SUPPORT_FOTA
+
+#define ARMS_FOTA_THREAD_BUF_LEN 2048
+#define ARMS_FOTA_TIMER_DEF_PERIOD (60*1000)
+
+typedef enum _ARMS_FOTA_STATE_
+{
+	ARMS_FOTA_STATE_IDLE,
+	ARMS_FOTA_STATE_RG,
+	ARMS_FOTA_STATE_CV,
+	ARMS_FOTA_STATE_DL,
+	ARMS_FOTA_STATE_RD,
+	ARMS_FOTA_STATE_RU,
+	ARMS_FOTA_STATE_MAX
+}ARMS_FOTA_STATE;
+
+#ifdef ARMS_FOTA_HTTP
+#define ARMS_FOTA_HTTP_MSG_LEN 40
+
+typedef enum _ARMS_FOTA_STATUS_CODE_
+{
+	ARMS_FOTA_SUCCESS = 1000,
+	ARMS_FOTA_PID_ERROR,
+	ARMS_FOTA_PROJECT_ERROR,
+	ARMS_FOTA_PARAM_INVAILD,
+	ARMS_FOTA_PARAM_LOST,
+	ARMS_FOTA_SYS_ERROR,
+	ARMS_FOTA_JSON_ERROR,
+	ARMS_FOTA_RG_SIGN_ERROR = 2001,
+	ARMS_FOTA_CV_LAST_VERSION = 2101,
+	ARMS_FOTA_CV_INVAILD_VERSION,
+	ARMS_FOTA_CV_UNREG_DEVICE,
+	ARMS_FOTA_DL_STATE_ERROR = 2201,
+	ARMS_FOTA_DL_DELTAID_ERROR,
+	ARMS_FOTA_RP_DELTAID_ERROR = 2301,
+	ARMS_FOTA_RP_UPGRADE_STATE_ERROR	
+}ARMS_FOTA_STATUS_CODE;
+
+#if 0
+typedef enum _ARMS_FOTA_ERROR_CODE_
+{
+    ARMS_FOTA_ERROR_TYPE_NONE,
+    ARMS_FOTA_ERROR_TYPE_UART_TIMEOUT,// 1
+    ARMS_FOTA_ERROR_TYPE_NO_NETWORK,
+    ARMS_FOTA_ERROR_TYPE_DNS_FAIL,// 3
+    ARMS_FOTA_ERROR_TYPE_CREATE_SOCKET_FAIL,
+    ARMS_FOTA_ERROR_TYPE_NETWORK_ERROR,// 5
+    ARMS_FOTA_ERROR_TYPE_NO_NEW_UPDATE,
+    ARMS_FOTA_ERROR_TYPE_MD5_NOT_MATCH,// 7
+    ARMS_FOTA_ERROR_TYPE_NOT_ENOUGH_SPACE,
+    ARMS_FOTA_ERROR_TYPE_ERASE_FLASH,// 9
+    ARMS_FOTA_ERROR_TYPE_WRITE_FLASH,
+    ARMS_FOTA_ERROR_TYPE_NO_ACCESS_TIMES,// 11
+    ARMS_FOTA_ERROR_TYPE_UNKNOW,
+}ARMS_FOTA_ERROR_CODE;
+#endif
+#endif
+
+
+typedef int(*arms_fota_state_handler_fn )(void *);
+
+typedef struct _tagARMSFOTADOWNINFO
+{
+    char down_host[ARMS_HTTP_SRV_ADDR_SIZE];
+    char down_path[ARMS_FOTA_SRV_PATH_SIZE];
+	char down_port[ARMS_FOTA_SRV_PORT_SIZE];
+    char down_md5[ARMS_FOTA_DEVICEID_MD5_BUF_SIZE + 2];
+    unsigned int down_task_id;
+    unsigned int down_file_size;
+	int current_block_remaining;
+} ARMSFOTADOWNINFO,*PARMSFOTADOWNINFO;
+
+typedef struct _tagARMSFOTA
+{
+	MSGMTXSEM fota_signal;
+	int exitflag;
+	pthread_t fota_thread_handle;
+	pthread_attr_t fota_thread_attr;
+	#ifdef ARMS_FOTA_CHECK_INTERVAL_VIA_TIMER
+	timer_t fota_timer;
+	#endif
+	unsigned int fota_check_period;
+	unsigned int download_retry_cnt;
+
+	PARMSCFGFUNLIST pCfgFunList;
+	PARMSDATAFUNLIST pDataFunList;
+
+	FOTASOCK stFOTASock;
+	
+	FOTACFG stFOTACfg;
+	FOTADATA stFOTAData;
+
+	ARMS_FOTA_STATE fota_state;
+	arms_fota_state_handler_fn state_cb[ARMS_FOTA_STATE_MAX];
+	unsigned int percentage;
+	int download_result;
+	ARMSFOTADOWNINFO stDownInfo;
+}ARMSFOTA, *PARMSFOTA;
+
+int arms_fota_start_thread(PARMSFOTA pARMSFOTA);
+int arms_fota_stop_thread(PARMSFOTA pARMSFOTA);
+
+int arms_fota_init(void* pVoidApp);
+int arms_fota_uninit(void* pVoidApp);
+
+int arms_fota_add_msg_event(PARMSFOTA pARMSFOTA,int nSig, unsigned char* pData, int nDataSize);
+
+int arms_fota_start_timer(PARMSFOTA pARMSFOTA);
+int arms_fota_stop_timer(PARMSFOTA pARMSFOTA);
+
+#endif
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_json.c b/lynq/S300/ap/app/apparms/apparms_json.c
new file mode 100755
index 0000000..1c7babc
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_json.c
@@ -0,0 +1,386 @@
+
+#include "apparms.h"
+#include "apparms_json.h"
+#include "apparms_log.h"
+
+static unsigned char* arms_json_construct_final_buf(int* pResult, char* pType, json_object **pRsp, unsigned char* pOutBuf, int* pOutLen)
+{
+	json_object *final_json = NULL;
+	const char *resp = NULL;
+	int nDataLen;
+	unsigned char* pRetBuf = NULL;
+
+	final_json = json_object_new_object();
+	CHECK_NEW_JSON_WITH_FREE_REQ(final_json, *pRsp);
+
+	//resp = json_object_to_json_string(*pRsp);
+	//CHECK_JSON_STRING_FREE_REQ_RSP(resp, final_json, *pRsp);
+	
+	//my_printf(LOG_MODE_LEVEL_5, "%s(%d) rsp Json string content = %s\n",__FUNCTION__,__LINE__,resp);
+	json_object_object_add(final_json, (const char *)pType, *pRsp);
+	
+	//resp = NULL;
+	resp = json_object_to_json_string(final_json);
+	CHECK_JSON_STRING_FREE_REQ_RSP(resp, final_json, *pRsp);
+
+	ARMS_LOG_DEBUG("%s(%d) final json to string content=%s\n",__FUNCTION__,__LINE__, resp);
+	
+	nDataLen = strlen(resp);
+	/* dynamic buffer is needed*/
+	if (nDataLen >= *pOutLen)
+	{
+		pRetBuf = malloc(nDataLen + 1);
+		CHECK_JSON_STRING_FREE_REQ_RSP(pRetBuf, final_json, *pRsp);
+
+		/*memset(pRetBuf, 0, nDataLen+1);*/
+		memcpy(pRetBuf, resp, nDataLen);
+		pRetBuf[nDataLen] = '\0';
+
+		ARMS_LOG_INFO("%s(%d) Final New Rsp Buffer = %s\n",__FUNCTION__,__LINE__,pRetBuf);
+	}
+	else
+	{		
+		memcpy(pOutBuf, resp, nDataLen);
+		ARMS_LOG_INFO("%s(%d) Final OUT Buffer = %s\n",__FUNCTION__,__LINE__,pOutBuf);
+	}
+
+	json_object_put(final_json);
+	//json_object_put(*pRsp);
+
+	ARMS_LOG_DEBUG("%s(%d) ConstructFinalBuffer Finished\n",__FUNCTION__,__LINE__);
+	*pOutLen = nDataLen;
+	return pRetBuf;
+}
+
+static unsigned char* arms_json_handle_devlog(int nRemote,int *pResult, json_object *pJsonReq, unsigned char* pOutBuf, int* pOutLen, int *pContExe)
+{
+	json_object *rsp_json = NULL;
+	const char *pOperCont = NULL;
+
+	*pResult = JSON_FALSE;
+	
+	rsp_json = json_object_new_object();
+	if (rsp_json == NULL)
+		return NULL;
+
+	json_object_object_foreach(pJsonReq, key, val)
+	{
+		ARMS_LOG_INFO("%s(%d) key=%s, val=%s\n",__FUNCTION__,__LINE__,key, json_object_get_string(val));
+		
+		if (strcmp(key, APPARMS_JSON_COMMON_OPER_STR) == 0)
+		{
+			pOperCont = json_object_get_string(val);
+		}
+	}
+
+#ifdef ARMS_SUPPORT_FOTA
+	if ((pOperCont != NULL) && (strcmp(pOperCont, "ReportToSrv") == 0))
+	{		
+		PAPPARMS  pApp = GetARMSAppPointer();
+		
+		arms_fota_add_msg_event(&pApp->stARMSFOTA, ARMS_SIGN_LOG_START, NULL, 0);
+		
+		*pResult = JSON_TRUE;
+
+		*pContExe = JSON_FALSE;
+	}
+#endif	
+
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_OPER_STR, json_object_new_string(pOperCont)); 
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_RESULT_STR, json_object_new_string(((*pResult != JSON_FALSE) ? APPARMS_JSON_COMMON_OK_STR : APPARMS_JSON_COMMON_FAIL_STR)));
+	json_object_object_add(rsp_json, APPARMS_JSON_COMM_MSG_CODE, json_object_new_string(APPARMS_JSON_COMM_MSG_0000));
+	
+	return arms_json_construct_final_buf(pResult, APPARMS_JSON_DEVLOG_RSP, &rsp_json, pOutBuf, pOutLen);
+}
+
+static unsigned char* arms_json_handle_armslog_cfg(int nRemote,int *pResult, json_object *pJsonReq, unsigned char* pOutBuf, int* pOutLen, int *pContExe)
+{
+	json_object *rsp_json = NULL;
+	const char *pOperCont = NULL;
+	int nLevel = -1;
+
+	*pResult = JSON_FALSE;
+	
+	rsp_json = json_object_new_object();
+	if (rsp_json == NULL)
+		return NULL;
+
+	json_object_object_foreach(pJsonReq, key, val)
+	{
+		ARMS_LOG_INFO("%s(%d) key=%s, val=%s\n",__FUNCTION__,__LINE__,key, json_object_get_string(val));
+		
+		if (strcmp(key, APPARMS_JSON_COMMON_OPER_STR) == 0)
+		{
+			pOperCont = json_object_get_string(val);
+		}
+		else if (strcmp(key, "Level") == 0)
+		{
+			nLevel = json_object_get_int(val);
+		}
+	}
+
+	if ((pOperCont != NULL) && (strcmp(pOperCont, "Set") == 0))
+	{		
+		if(nLevel >= ARMS_LOG_LEVEL_ERROR && nLevel <= ARMS_LOG_LEVEL_ALL)
+		{
+			arms_log_set_level(nLevel);
+			*pResult = JSON_TRUE;
+		}
+	}
+
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_OPER_STR, json_object_new_string(pOperCont)); 
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_RESULT_STR, json_object_new_string(((*pResult != JSON_FALSE) ? APPARMS_JSON_COMMON_OK_STR : APPARMS_JSON_COMMON_FAIL_STR)));
+	json_object_object_add(rsp_json, APPARMS_JSON_COMM_MSG_CODE, json_object_new_string(APPARMS_JSON_COMM_MSG_0000));
+	
+	return arms_json_construct_final_buf(pResult, APPARMS_JSON_ARMSLOG_CFG_RSP, &rsp_json, pOutBuf, pOutLen);
+}
+
+static unsigned char* arms_json_handle_fota(int nRemote,int *pResult, json_object *pJsonReq, unsigned char* pOutBuf, int* pOutLen, int *pContExe)
+{
+	json_object *rsp_json = NULL;
+	const char *pOperCont = NULL;
+
+	*pResult = JSON_FALSE;
+	
+	rsp_json = json_object_new_object();
+	if (rsp_json == NULL)
+		return NULL;
+
+	json_object_object_foreach(pJsonReq, key, val)
+	{
+		ARMS_LOG_INFO("%s(%d) key=%s, val=%s\n",__FUNCTION__,__LINE__,key, json_object_get_string(val));
+		
+		if (strcmp(key, APPARMS_JSON_COMMON_OPER_STR) == 0)
+		{
+			pOperCont = json_object_get_string(val);
+		}
+	}
+
+#ifdef ARMS_SUPPORT_FOTA
+	if ((pOperCont != NULL) && ((strcmp(pOperCont, "Upgrade") == 0) || strcmp(pOperCont, "Check") == 0))
+	{		
+		PAPPARMS  pApp = GetARMSAppPointer();
+		
+		arms_fota_add_msg_event(&pApp->stARMSFOTA, ARMS_SIGN_FOTA_START, NULL, 0);
+		
+		*pResult = JSON_TRUE;
+
+		*pContExe = JSON_FALSE;
+	}
+#endif	
+
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_OPER_STR, json_object_new_string(pOperCont)); 
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_RESULT_STR, json_object_new_string(((*pResult != JSON_FALSE) ? APPARMS_JSON_COMMON_OK_STR : APPARMS_JSON_COMMON_FAIL_STR)));
+	json_object_object_add(rsp_json, APPARMS_JSON_COMM_MSG_CODE, json_object_new_string(APPARMS_JSON_COMM_MSG_0000));
+	
+	return arms_json_construct_final_buf(pResult, APPARMS_JSON_FOTA_RSP, &rsp_json, pOutBuf, pOutLen);
+}
+
+#ifdef ARMS_SUPPORT_DM
+#ifdef ARMS_DM_ATRACS
+static unsigned char* arms_json_handle_reoprt(int nRemote,int *pResult, json_object *pJsonReq, unsigned char* pOutBuf, int* pOutLen, int *pContExe)
+{
+	json_object *rsp_json = NULL;
+	const char *pOper = NULL;
+	const char *pEvtType = NULL;
+	const char *pEvtText = NULL;
+	const char *pWarnText = NULL;
+	int nEvtTypeLen = 0, nEvtTextLen = 0, nEvtWarnLen = 0;
+
+
+	*pResult = JSON_FALSE;
+	
+	rsp_json = json_object_new_object();
+	if (rsp_json == NULL)
+		return NULL;
+
+	json_object_object_foreach(pJsonReq, key, val)
+	{
+		ARMS_LOG_INFO("%s(%d) key=%s, val=%s\n",__FUNCTION__,__LINE__,key, json_object_get_string(val));
+		
+		if (strcmp(key, APPARMS_JSON_COMMON_OPER_STR) == 0)
+		{
+			pOper = json_object_get_string(val);
+		}
+		else if (strcmp(key, APPARMS_JSON_COMMON_EVENT_TYPE) == 0)
+		{
+			pEvtType = json_object_get_string(val);
+			if (pEvtType != NULL)
+				nEvtTypeLen = strlen(pEvtType);
+		}
+		else if (strcmp(key, APPARMS_JSON_COMMON_EVENT_TEXT) == 0)
+		{
+			pEvtText = json_object_get_string(val);
+			if (pEvtText != NULL)
+				nEvtTextLen = strlen(pEvtText);
+		}
+		else if (strcmp(key, APPARMS_JSON_COMMON_WARNING_TEXT) == 0)
+		{
+			pWarnText = json_object_get_string(val);
+			if (pWarnText != NULL)
+				nEvtWarnLen = strlen(pWarnText);
+		}
+	}
+
+	if (pOper != NULL)
+	{		
+		if(strcmp(pOper, "ReportTelemetry") == 0)
+		{
+			PAPPARMS  pApp = GetARMSAppPointer();
+			arms_dm_add_report_telemetry_msg_event(&pApp->stARMSDM);
+			
+			*pResult = JSON_TRUE;
+		}
+		else if(strcmp(pOper, "ReportFota") == 0)
+		{
+			if ((nEvtTypeLen > 0) && (nEvtTextLen > 0) && (nEvtWarnLen > 0))
+			{
+#ifdef ARMS_SUPPORT_EC2
+				PAPPARMS  pApp = GetARMSAppPointer();
+				EC2EVTMSGST stEC2Msg;
+		
+				memset(&stEC2Msg, 0, sizeof(EC2EVTMSGST));
+				
+				stEC2Msg.evt_type = atoi(pEvtType);
+				
+				strcpy((char *)stEC2Msg.evt_content, pEvtText);
+				stEC2Msg.evt_len = nEvtTextLen;
+		
+				strcpy((char *)stEC2Msg.warn_text, pWarnText);
+				stEC2Msg.warn_len = nEvtWarnLen;
+		
+				arms_ec2_add_msg_event(&pApp->stARMSEC2, ARMS_SIGN_FOTA_STATUS_REPORT, (unsigned char*)&stEC2Msg, sizeof(EC2EVTMSGST));
+#endif		
+				*pResult = JSON_TRUE;
+			}
+		}
+
+		
+		json_object_object_add(rsp_json, APPARMS_JSON_COMMON_OPER_STR, json_object_new_string(pOper)); 
+	}
+
+
+	json_object_object_add(rsp_json, APPARMS_JSON_COMMON_RESULT_STR, json_object_new_string(((*pResult != JSON_FALSE) ? APPARMS_JSON_COMMON_OK_STR : APPARMS_JSON_COMMON_FAIL_STR)));
+	json_object_object_add(rsp_json, APPARMS_JSON_COMM_MSG_CODE, json_object_new_string(APPARMS_JSON_COMM_MSG_0000));
+	
+	return arms_json_construct_final_buf(pResult, APPARMS_JSON_REPORT_RSP, &rsp_json, pOutBuf, pOutLen);
+}
+#endif
+#endif
+
+static int arms_json_parse(int nRemote, char *cmdBuf, int cmdBuf_len, unsigned char *rspBuf, int *pRspBuf_len, int *pContExe)
+{
+	int nRet = 0, nHandRet = JSON_FALSE;
+	json_object *req_json = NULL;
+	unsigned char *pRetNewBuf = NULL;
+	int bFound = 0;
+	
+	
+	if ((cmdBuf == NULL) || (rspBuf == NULL) || (pRspBuf_len == NULL) || (pContExe == NULL))
+	{
+		ARMS_LOG_ERROR(" %s(%d) poll struct pointer is null\n",__FUNCTION__,__LINE__);
+		return ARMS_JSON_POINT_NULL_ERROR;
+	}
+
+	if ((cmdBuf_len <= 0) || (*pRspBuf_len <= 0))
+	{
+		ARMS_LOG_ERROR(" %s(%d) poll struct pointer is null\n",__FUNCTION__,__LINE__);
+		return ARMS_JSON_BUFFER_LEN_ERROR;
+	}
+	
+	req_json = json_tokener_parse((const char *)cmdBuf);
+
+	/*Invalid json format, let's send the common Response */
+	if (req_json != NULL)
+	{	
+		enum json_type json_result =  json_object_get_type(req_json);
+		
+		ARMS_LOG_INFO(" %s(%d) json_type =[%d]\n",__FUNCTION__,__LINE__, json_result);
+		
+		if (json_result == json_type_object)
+		{
+			json_object_object_foreach(req_json, key, val)
+			{
+				ARMS_LOG_INFO("%s(%d) key=%s, val=%s\n",__FUNCTION__,__LINE__,key, json_object_get_string(val));
+
+				if (strcmp(key, APPARMS_JSON_DEVLOG_REQ) == 0)
+				{
+					pRetNewBuf = arms_json_handle_devlog(nRemote, &nHandRet, val, rspBuf, pRspBuf_len, pContExe);
+					bFound = 1;
+				}
+				else if (strcmp(key, APPARMS_JSON_ARMSLOG_CFG_REQ) == 0)
+				{
+					pRetNewBuf = arms_json_handle_armslog_cfg(nRemote, &nHandRet, val, rspBuf, pRspBuf_len, pContExe);
+					bFound = 1;
+				}
+				else if (strcmp(key, APPARMS_JSON_FOTA_REQ) == 0)
+				{
+					pRetNewBuf = arms_json_handle_fota(nRemote, &nHandRet, val, rspBuf, pRspBuf_len, pContExe);
+					bFound = 1;
+				}
+				#ifdef ARMS_SUPPORT_DM
+				#ifdef ARMS_DM_ATRACS
+				else if (strcmp(key, APPARMS_JSON_REPORT_REQ) == 0)
+				{
+					pRetNewBuf = arms_json_handle_reoprt(nRemote, &nHandRet, val, rspBuf, pRspBuf_len, pContExe);
+					bFound = 1;
+				}
+				#endif
+				#endif
+				
+				
+				if (bFound == 1)
+					break;
+			}
+		}
+
+		/*free the request json object*/
+		json_object_put(req_json);
+	}	
+
+	//Unkwown Command or Invalid format
+	if (bFound == 0)
+	{
+		if (nRemote == 0)
+		{
+			ARMS_LOG_ERROR("%s(%d) invalid json format=%d\n",__FUNCTION__,__LINE__,nRet);
+		}
+		
+		return ARMS_JSON_UNSUPPORTED_ERROR;
+	}
+			
+	/*Handle json response failed*/
+	if (nHandRet == JSON_FALSE)
+	{
+		ARMS_LOG_ERROR("%s(%d) Handle json response failed\n",__FUNCTION__,__LINE__);
+		return ARMS_JSON_HANDLE_ERROR;
+	}
+
+	if (pRetNewBuf != NULL)
+	{
+		free(pRetNewBuf);
+		return ARMS_JSON_RSP_BUFLEN_ERROR;
+	}
+	
+	return 0;
+}
+
+
+int arms_json_handle_buffer(int nRemote, char *cmdBuf, int cmdBuf_len, unsigned char *rspBuf, int *pRspBuf_len)
+{
+	int nRet, nContExe = JSON_TRUE;
+	nRet = arms_json_parse(nRemote, cmdBuf, cmdBuf_len, rspBuf, pRspBuf_len, &nContExe);
+	
+	if ((nRet < 0) && (nRemote == 1) && (nContExe == JSON_FALSE))
+	{
+		nRet = 0;
+	}
+	else if ((nRemote == 0) && (nRet == ARMS_JSON_UNSUPPORTED_ERROR))
+	{
+		const char *pSupport = "{\"UnknownCmd\":{\"RESULT\":\"FAIL\"}}";
+		strcpy((char *)rspBuf, pSupport);
+		*pRspBuf_len = strlen(pSupport);
+	}
+
+	return nRet;
+}
diff --git a/lynq/S300/ap/app/apparms/apparms_json.h b/lynq/S300/ap/app/apparms/apparms_json.h
new file mode 100755
index 0000000..f7ea75f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_json.h
@@ -0,0 +1,110 @@
+
+#ifndef _APPARMS_JSON
+#define _APPARMS_JSON 1
+
+#ifdef SUPPORT_LIBJSOC_PC
+#include "json.h"
+#else
+#include <json-c/json.h>
+#endif
+
+#define JSON_FALSE 0
+#define JSON_TRUE 1
+#define JSON_CMD_BUF_LEN (2*1024)
+
+#define APPARMS_JSON_COMMON_RESULT_STR "RspStatus"
+#define APPARMS_JSON_COMMON_OK_STR "Success"
+#define APPARMS_JSON_COMMON_FAIL_STR "Fail"
+
+#define APPARMS_JSON_COMM_MSG_CODE "MsgCode"
+#define APPARMS_JSON_COMM_MSG_0000 "0x0000"
+
+
+#define APPARMS_JSON_COMMON_OPER_STR "Oper"
+
+#define APPARMS_JSON_COMMON_EVENT_TYPE "EvtType"
+#define APPARMS_JSON_COMMON_EVENT_TEXT "EvtText"
+#define APPARMS_JSON_COMMON_WARNING_TEXT "WarnText"
+
+//{"DevLogReq":{"Oper":"ReportToSrv"}}
+//{"DevLogRsp":{"Oper":"ReportToSrv","RspStatus":"Success","MsgCode":"0x0000"}}
+#define APPARMS_JSON_DEVLOG_REQ "DevLogReq"
+#define APPARMS_JSON_DEVLOG_RSP "DevLogRsp"
+
+//{"DevUnbindReq":{"Oper":"Check"}}
+//{"DevUnbindRsp":{"Data":{"code":10000,"email":"wenhao@qq.com"},"Oper":"Check","RspStatus":"Success","MsgCode":"0x0000"}}
+#define APPARMS_JSON_DEVUNBIND_REQ "DevUnbindReq"
+#define APPARMS_JSON_DEVUNBIND_RSP "DevUnbindRsp"
+
+//{"DevNotifyReq":{"NtfEvtType":"0001", "NtfEvtText":"Power On", "NtfWarnText":"Your device IMEI 1992210201 12-23 Power on"}}
+#define APPARMS_JSON_NOTIFY_REQ "DevNotifyReq"
+#define APPARMS_JSON_NOTIFY_RSP "DevNotifyRsp"
+#define APPARMS_JSON_NOTIFY_EVENT_TYPE "NtfEvtType"
+#define APPARMS_JSON_NOTIFY_EVENT_TEXT "NtfEvtText"
+#define APPARMS_JSON_NOTIFY_WARNING_TEXT "NtfWarnText"
+
+//{"DevArmslogCfgReq":{"Oper":"Set","Level": 1}}
+//{"DevArmslogCfgRsp":{"Oper":"Set","RspStatus":"Success","MsgCode":"0x0000"}}
+#define APPARMS_JSON_ARMSLOG_CFG_REQ "DevArmslogCfgReq"
+#define APPARMS_JSON_ARMSLOG_CFG_RSP "DevArmslogCfgRsp"
+		
+//{"DevReportReq":{"Oper":"ReportTelemetry"}}
+//{"DevReportRsp":{"Oper":"ReportTelemetry","RspStatus":"Success","MsgCode":"0x0000"}}
+//{"DevReportReq":{"Oper":"ReportFota", "EvtType":"1006", "EvtText":"Fail", "WarnText":"QC25_V8100_1.0.20.803_45"}}
+//{"DevReportRsp":{"Oper":"ReportFota", "EvtType":"1006", "RspStatus":"Success","MsgCode":"0x0000"}}
+#define APPARMS_JSON_REPORT_REQ "DevReportReq"
+#define APPARMS_JSON_REPORT_RSP "DevReportRsp"
+
+//{"DevFOTAReq":{"Oper":"Update"}}
+//{"DevFOTARsp":{"Oper":"Update","RspStatus":"Success","MsgCode":"0x0000"}}
+#define APPARMS_JSON_FOTA_REQ "DevFOTAReq"
+#define APPARMS_JSON_FOTA_RSP "DevFOTARsp"
+
+
+#define JSON_FREE_PTR(ptr) \
+			do \
+			{ \
+				if (ptr != NULL) \
+				{ \
+					json_object_put(ptr);  \
+					ptr = NULL; \
+				} \
+			}while(0)		
+		
+		
+#define CHECK_NEW_JSON(req_json) \
+			do \
+			{ \
+				if (req_json == NULL) \
+				{		\
+					return NULL; \
+				} \
+			}while(0)
+				
+#define CHECK_NEW_JSON_WITH_FREE_REQ(req_json, rsp_json) \
+			do \
+			{ \
+				if (req_json == NULL) \
+				{		\
+					json_object_put(rsp_json); \
+					return NULL; \
+				} \
+			}while(0)
+				
+#define CHECK_JSON_STRING_FREE_REQ_RSP(strtext, req_json, rsp_json) \
+			do \
+			{ \
+				if (strtext == NULL) \
+				{		\
+					json_object_put(req_json); \
+					json_object_put(rsp_json); \
+					return NULL; \
+				} \
+			}while(0)
+
+
+
+int arms_json_handle_buffer(int nRemote, char *cmdBuf, int cmdBuf_len, unsigned char *rspBuf, int *rspBuf_len);
+
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_loop.c b/lynq/S300/ap/app/apparms/apparms_loop.c
new file mode 100755
index 0000000..e1a010b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_loop.c
@@ -0,0 +1,301 @@
+#include "apparms_loop.h"

+#include "apparms_log.h"

+#include "apparms.h"

+#ifdef ARMS_DM_RPC

+#include "apparms_dmrpc.h"

+#endif

+#include "apparms_json.h"

+

+#ifdef ARMS_SUPPORT_DM

+static int arms_loop_main_handle_push_special_msg(void* pVoidApp, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen)

+{

+	return arms_json_handle_buffer(1, (char *)pInData, nInLen, pOutData, pOutLen);

+}

+

+static int arms_loop_main_handle_push_customized_msg(void* pVoidApp, unsigned char *pInData, int nInLen, unsigned char *pOutData, int *pOutLen)

+{

+	int ret;

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+

+	//Wakeup device first. Add stay awake request(for device with power save mode) when receiving a push msg from ARMS.

+	//arms_data_os_set_waketime(pApp->pDataFunList, pApp->stARMSDM.stDMCfg.stDMCommCfg.unHWId, 0, 0);	

+

+	ret = arms_loop_main_handle_push_special_msg(pVoidApp, pInData, nInLen, pOutData, pOutLen);

+	if (ret < 0)

+	{

+#ifdef ARMS_DM_RPC

+		ret = arms_dmrpc_send_and_recv(&pApp->stARMSDM.stDMRPC,&pApp->stARMSDM.stDMCfg.stRPCCfg,pInData, nInLen, pOutData, pOutLen);

+#else

+		#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE

+		char szDataWithHeader[2000] = {0};

+		snprintf(szDataWithHeader, sizeof(szDataWithHeader), "%s-%s", pApp->stARMSDM.stDMCfg.stDMCommCfg.szIMEI + 1, pInData);

+		ret = arms_data_os_handle_dm_ack_pushmsg(pApp->stARMSDM.pDataFunList, (unsigned char*)szDataWithHeader, strlen(szDataWithHeader), pOutData, pOutLen);

+		#else

+		ret = arms_data_os_handle_dm_ack_pushmsg(pApp->stARMSDM.pDataFunList,pInData, nInLen, pOutData, pOutLen);

+		#endif

+#endif

+	}

+

+	return ret;

+}

+#endif

+

+static int arms_loop_main_handle_push_req(int nPushSign, void* pVoidApp, unsigned char* pBuf, int nLen, int nFD)

+{

+	//PARMSLOOP pArmsLoop = &pApp->stARMSLOOP;

+

+#ifdef ARMS_SUPPORT_DM

+#ifdef ARMS_DM_ATRACS

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+	int nParsed = 0;

+	int nRemaining = nLen;

+	int ret = -1;

+	unsigned char szRspBuf[ATRACS_PUSH_RSP_MAX_SIZE] = {0};

+	int nRspLen = ATRACS_PUSH_RSP_MAX_SIZE;

+

+	while(nRemaining > 0)

+	{

+		ATRACSRPTACKTYPE ack_type = arms_atracs_parse_report_ack_type(pBuf + nParsed, &nRemaining);

+

+		switch(ack_type)

+		{

+			case ATRACS_RPT_ACK_FOTA:

+#ifdef ARMS_SUPPORT_FOTA

+				arms_fota_add_msg_event(&pApp->stARMSFOTA, ARMS_SIGN_FOTA_START, NULL, 0);

+#endif

+				break;

+

+			case ATRACS_RPT_ACK_SRV_DECODE_ERROR:

+			case ATRACS_RPT_ACK_DEVICE_DISABLED:

+			case ATRACS_RPT_ACK_AUTH_FAIL:

+			case ATRACS_RPT_ACK_SRV_REJECT:

+			case ATRACS_RPT_ACK_RPT_OVERFLOW:

+			case ATRACS_RPT_ACK_SRV_REG_ERROR:

+			case ATRACS_RPT_ACK_SRV_CACHE_ERROR:

+			case ATRACS_RPT_ACK_UNKNOWN_ERROR:

+				arms_data_os_handle_dm_ack_fail(pApp->stARMSDM.pDataFunList,ack_type);

+				break;

+

+			case ATRACS_RPT_ACK_OK:

+				ARMS_LOG_DEBUG("%s(%d) ATRACS_RPT_ACK_OK\n",__FUNCTION__,__LINE__);

+				arms_data_os_handle_dm_ack_ok(pApp->stARMSDM.pDataFunList);

+				break;

+

+			case ATRACS_RPT_ACK_CUSTOMIZED:

+				ARMS_LOG_INFO("%s(%d) ATRACS_RPT_ACK_CUSTOMIZED\n",__FUNCTION__,__LINE__);

+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE

+#ifdef ARMS_SUPPORT_FOTA

+				if (strstr((char *)(pBuf + nParsed), "AT+FOTA") != 0)

+				{

+					ARMS_LOG_INFO("(F:[%s])\n", pApp->stARMSDM.stDMCfg.stDMCommCfg.szIMEI);

+					arms_fota_add_msg_event(&pApp->stARMSFOTA, ARMS_SIGN_FOTA_START, NULL, 0);

+				}

+#endif

+#endif

+				ret = arms_loop_main_handle_push_customized_msg(pApp, pBuf + nParsed, nLen - nParsed, szRspBuf, &nRspLen);

+				#ifdef ARMS_DM_IPC

+				arms_dmipc_check_update_timer(&pApp->stARMSDM.stDMIPC, &pApp->stARMSDM.stDMCfg.stIPCCfg);

+				if (nFD != -1)

+				{

+					if(0 <= ret && nRspLen > 0)

+					{

+						arms_dmipc_send(nFD, (char *)szRspBuf, nRspLen);

+					}

+					else

+						arms_dmipc_send(nFD, "error", 5);

+				}

+				else

+				#endif	

+				{

+					int nPushRspSign = ARMS_SIGN_DM_MSG_RESPONSE;

+					

+					if (nPushSign == ARMS_SIGN_LOOP_AGS_PUSH_REQ_MSG)

+						nPushRspSign = ARMS_SIGN_DM_AGS_MSG_RESPONSE;

+					

+					if(0 <= ret && nRspLen > 0)

+					{

+						arms_dm_add_push_response_event(nPushRspSign, &pApp->stARMSDM, (char *)szRspBuf, nRspLen);

+					}

+					else

+						arms_dm_add_push_response_event(nPushRspSign, &pApp->stARMSDM, "error", 5);

+				}

+				break;

+

+			default:

+				ARMS_LOG_DEBUG("%s(%d) ack = %d \n",__FUNCTION__,__LINE__, ack_type);						

+				break;

+		}

+

+		nParsed = nLen - nRemaining;

+	}

+#endif

+#endif

+

+	return 0;

+}

+

+int arms_loop_init(void* pVoidApp)

+{

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+	PARMSLOOP pArmsLoop = &pApp->stARMSLOOP;

+

+	arms_list_init_msg_event(&pArmsLoop->loop_signal);

+

+	return 0;

+}

+

+int arms_loop_uninit(void* pVoidApp)

+{

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+	PARMSLOOP pArmsLoop = &pApp->stARMSLOOP;

+

+	arms_list_destroy_msg_event(&pArmsLoop->loop_signal);

+

+	return 0;

+}

+

+int arms_loop_stop(PARMSLOOP pARMSLoop)

+{	

+	pARMSLoop->exitflag = 1;

+	arms_list_post_msg_event(&pARMSLoop->loop_signal);

+

+	return 0;

+}

+

+int arms_loop_add_msg_event(PARMSLOOP pArmsloop,int nSig, unsigned char* pData, int nDataSize, int nFD)

+{

+	return arms_list_add_msg_event(&pArmsloop->loop_signal, nSig, (char *)pData, nDataSize, nFD);

+}

+

+int arms_loop_do_network_update_action(void* pVoidApp, APPSTATUS emOld, APPSTATUS emNew)

+{

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+

+	if (pApp == NULL)

+		return -1;

+

+	if (emNew == APP_STATUS_ERROR)

+	{

+		#ifdef ARMS_DM_MQTT

+		arms_sock_dm_mqtt_set_networkst(&pApp->stARMSDM.stDMSock, 0);

+		#endif

+	}

+	else if (emNew == APP_STATUS_IPCHANGE)

+	{

+		#ifdef ARMS_DM_MQTT

+		arms_sock_dm_mqtt_set_networkst(&pApp->stARMSDM.stDMSock, 0);

+		#endif

+	}

+	else if (emNew == APP_STATUS_READY)

+	{

+		#ifdef ARMS_DM_MQTT

+		arms_sock_dm_mqtt_set_networkst(&pApp->stARMSDM.stDMSock, 1);

+		#endif

+	}

+

+	return 0;

+}

+

+int arms_loop_check_network(void* pVoidApp)

+{

+	int nRet;

+	APPSTATUS emTmpStatus = APP_STATUS_READY;

+	char szIPBuf[128] = {0};

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+	PARMSLOOP pArmsLoop = &pApp->stARMSLOOP;

+

+	memset(szIPBuf, 0, sizeof(szIPBuf));

+	nRet = arms_config_os_get_networkst(pApp->pCfgFunList, szIPBuf);

+	if (nRet < 0 )

+	{

+		emTmpStatus = APP_STATUS_ERROR;

+	}

+	else if (strcmp(pArmsLoop->szIPAddr, szIPBuf) != 0)

+	{

+		ARMS_LOG_ERROR("********* %s(%d) IP update from [%s] to [%s] ###########\n",__FUNCTION__,__LINE__, pArmsLoop->szIPAddr, szIPBuf);	

+		strcpy(pArmsLoop->szIPAddr, szIPBuf);

+		emTmpStatus = APP_STATUS_IPCHANGE;

+	}

+

+	if (emTmpStatus != pArmsLoop->emAppStatus)

+	{		

+		ARMS_LOG_ERROR("********* %s(%d) state update from [%d] to [%d] ###########\n",__FUNCTION__,__LINE__, pArmsLoop->emAppStatus, emTmpStatus);	

+		arms_loop_do_network_update_action(pApp, pArmsLoop->emAppStatus, emTmpStatus);

+		pArmsLoop->emAppStatus = emTmpStatus;

+	}

+	

+	return nRet;

+}

+

+int arms_loop_main(void* pVoidApp)

+{

+	PAPPARMS  pApp = (PAPPARMS)pVoidApp;

+	PARMSLOOP pArmsLoop = &pApp->stARMSLOOP;	

+	int nSegRet;//, nSleepTime = 2;

+	int nRet = -1, nSig = -1, nFD = -1, nRecvLen = ARMS_LOOP_THREAD_BUF_LEN;

+	char *pNewMaclloc = NULL, pRecv[ARMS_LOOP_THREAD_BUF_LEN] = {0};

+	

+	if (pApp == NULL)

+	{

+		return ARMS_LOOP_POINT_NULL_ERROR;

+	}

+	

+	while (!pArmsLoop->exitflag)

+	{

+		arms_loop_check_network(pVoidApp);

+		if (pArmsLoop->emAppStatus != APP_STATUS_READY)

+		{

+			sleep(3);

+			continue;

+		}

+

+		nRecvLen = ARMS_LOOP_THREAD_BUF_LEN;

+		pNewMaclloc = NULL;

+		nSig = -1;

+		nFD = -1;

+

+		nSegRet = arms_list_wait_msg_event(&pArmsLoop->loop_signal,3);

+

+		if (nSegRet != 0)

+		{

+			ARMS_LOG_ERROR("%s(%d) loop sem_timedwait  errno = %d \n",__FUNCTION__,__LINE__, nSegRet);

+			sleep(3);

+		}

+

+		nRet = arms_list_get_msg_event_with_fd(&pArmsLoop->loop_signal,&nSig, pRecv, &nRecvLen, &pNewMaclloc, &nFD);

+		if (nRet == ARMS_LIST_MSG_EMPTY_ERROR)

+			continue;

+

+		ARMS_LOG_DEBUG("%s(%d) loop  exe  nRet = %d \n",__FUNCTION__,__LINE__, nRet);

+		

+		if (nRet >= 0)

+		{		

+			char *pData =  ((pNewMaclloc == NULL) ? pRecv : pNewMaclloc);

+			if (pData != NULL)

+			{

+				switch (nSig)

+				{

+					case ARMS_SIGN_LOOP_PUSH_REQ_MSG:

+					case ARMS_SIGN_LOOP_AGS_PUSH_REQ_MSG:

+						nRet = arms_loop_main_handle_push_req(nSig, pApp, (unsigned char*)pData, nRecvLen, nFD);

+						break;

+

+					default:

+						ARMS_LOG_DEBUG("%s(%d) loop  unknown msg = %d \n",__FUNCTION__,__LINE__, nSig);						

+						break;

+				}

+			}

+

+			if (pNewMaclloc != NULL)

+				free(pNewMaclloc);

+				

+			arms_list_post_msg_event(&pArmsLoop->loop_signal); 

+		}	

+		

+	}

+	ARMS_LOG_DEBUG("%s(%d)  task_loop_thread EXIT \n",__FUNCTION__,__LINE__);

+	return 0;

+}

+

+

+

diff --git a/lynq/S300/ap/app/apparms/apparms_loop.h b/lynq/S300/ap/app/apparms/apparms_loop.h
new file mode 100755
index 0000000..dbce182
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_loop.h
@@ -0,0 +1,39 @@
+
+#ifndef _APPARMS_LOOP
+#define _APPARMS_LOOP 1
+
+#include "apparms_macro.h"
+#include "apparms_list.h"
+#include "apparms_config_os.h"
+#include "apparms_data_os.h"
+
+#define ARMS_LOOP_THREAD_BUF_LEN 2048
+
+typedef enum _tagAPPSTATUS
+{
+	APP_STATUS_INIT = 0, //Get IMEI
+	APP_STATUS_CHK_NETWORK,
+	APP_STATUS_READY,
+	APP_STATUS_IPCHANGE,
+	APP_STATUS_ERROR
+}APPSTATUS;
+
+typedef struct _tagARMSLOOP
+{
+	int exitflag;
+	APPSTATUS emAppStatus;
+	char szIPAddr[128];
+	MSGMTXSEM loop_signal;
+	
+}ARMSLOOP, *PARMSLOOP;
+
+int arms_loop_init(void* pVoidApp);
+int arms_loop_uninit(void* pVoidApp);
+
+int arms_loop_stop(PARMSLOOP pARMSLoop);
+
+int arms_loop_main(void* pVoidApp);
+
+int arms_loop_add_msg_event(PARMSLOOP pArmsloop,int nSig, unsigned char* pData, int nDataSize, int nFD);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/apparms_macro.h b/lynq/S300/ap/app/apparms/apparms_macro.h
new file mode 100755
index 0000000..2c53f0e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_macro.h
@@ -0,0 +1,142 @@
+#ifndef _APPARMS_MACRO_HEAD

+#define _APPARMS_MACRO_HEAD

+

+#include <arpa/inet.h>

+#include <errno.h>

+#include <getopt.h>

+#include <fcntl.h>

+#include <pthread.h>

+#include <netinet/in.h>

+#include <netdb.h>

+#include <net/if.h>

+#include <net/if_arp.h>

+#include <semaphore.h>

+#include <sys/time.h>

+#include <stdio.h>

+#include <stdlib.h>

+#include <string.h>

+#include <sys/wait.h>

+#include <stdio.h>

+#include <stdarg.h>

+#include <sys/types.h>

+#include <sys/stat.h>

+//#include <syslog.h> 

+#include <termios.h> 

+#include <unistd.h>

+#include <sys/socket.h>

+#include <sys/ioctl.h>

+#include <sys/wait.h>

+#include <sys/poll.h> 

+#include <stdlib.h>

+#include <sys/un.h>

+#include <time.h>

+#include <semaphore.h>

+#include <pthread.h>

+#include <stdlib.h>

+#include <string.h>

+#include <time.h>

+#include <semaphore.h>

+#include <errno.h>

+#include <sys/prctl.h>

+

+/*

+important features

+1.1 support FOTA with HTTPS

+1.2 support IPATC for DM

+1.3 support RPC which handle data by remote/another application

+1.4 support LOG to be reported to SRV

+1.4.1 Report RSRP, RSPQ etc. to SRV

+1.5 Support Speedtest and Subcription

+1.6 Support Device Unbind

+1.7 Support extra mqtt topic for AGS 

+1.7.1 Support MQTT suspend on battery

+1.7.2 Support apparms argv feature

+1.8.0 Resolve disconnect issue in case of sleep mode. (r596)

+*/

+

+#define ARMS_VERSION_MAJOR 1

+#define ARMS_VERSION_MINOR 8

+#define ARMS_VERSION_PATCH 0

+

+#define ARMS_CONFIG_POINT_NULL_ERROR (-100)

+#define ARMS_CONFIG_FUNC_POINT_NULL_ERROR (-101)

+#define ARMS_CONFIG_DATA_POINT_NULL_ERROR (-102)

+

+

+#define ARMS_DATA_POINT_NULL_ERROR (-200)

+#define ARMS_DATA_FUNC_POINT_NULL_ERROR (-201)

+#define ARMS_DATA_DATA_POINT_NULL_ERROR (-202)

+

+

+#define ARMS_DM_POINT_NULL_ERROR (-300)

+#define ARMS_DM_SEND_LENGTH_ERROR (-301)

+

+

+#define ARMS_ATRACS_POINT_NULL_ERROR (-400)

+#define ARMS_ATRACS_STRING_LENGTH_ERROR (-401)

+#define ARMS_ATRACS_TLV_MASK_OFF_ERROR (-402)

+#define ARMS_ATRACS_PUSH_RSP_LENGTH_ERROR (-403)

+

+#define ARMS_SOCK_POINT_NULL_ERROR (-500)

+#define ARMS_SOCK_CONNECT_MODE_ERORR (-501)

+#define ARMS_SOCK_CONNECT_TO_SERVER_FAILED (-502)

+#define ARMS_SOCK_CONNECT_NOT_INITED (-503)

+#define ARMS_SOCK_SEND_TO_SERVER_FAILED (-504)

+#define ARMS_SOCK_POLL_FOR_RECV_FAILED (-505)

+#define ARMS_SOCK_RECV_FORM_SERVER_FAILED (-506)

+

+#define ARMS_LOOP_POINT_NULL_ERROR (-600)

+

+#define ARMS_FOTA_HTTP_RESPONSE_CODE_FAILED (-701)

+#define ARMS_FOTA_HTTP_NOT_FOND_1_1_FAILED (-702)

+#define ARMS_FOTA_HTTP_NOT_FOND_CONNECTION_FAILED (-703)

+#define ARMS_FOTA_HTTP_STATUS_FAILED (-704)

+#define ARMS_FOTA_HTTP_DOWNLOAD_SIZE_FAILED (-705)

+#define ARMS_FOTA_HTTP_WRITE_FILE_FAILED (-706)

+#define ARMS_FOTA_HTTP_DOWN_FAILED (-707)

+

+#define ARMS_EXTIF_POINT_NULL_ERROR (-800)

+

+#define ARMS_JSON_POINT_NULL_ERROR (-900)

+#define ARMS_JSON_BUFFER_LEN_ERROR (-901)

+#define ARMS_JSON_UNSUPPORTED_ERROR (-902)

+#define ARMS_JSON_HANDLE_ERROR (-903)

+#define ARMS_JSON_RSP_BUFLEN_ERROR (-904)

+

+#define ARMS_SIGN_DM_REPORT_TELEMETRY (101)

+#define ARMS_SIGN_DM_MSG_RESPONSE (102)

+#define ARMS_SIGN_DM_AGS_MSG_RESPONSE (103)

+#define ARMS_SIGN_DM_TRIGGER_NOTIFICAITON (104)

+

+#define ARMS_SIGN_LOOP_PUSH_REQ_MSG (201)

+#define ARMS_SIGN_LOOP_PUSH_RSP_MSG (202)

+#define ARMS_SIGN_LOOP_AGS_PUSH_REQ_MSG (203)

+#define ARMS_SIGN_LOOP_NTF_RTP_MSG (204)

+

+#define ARMS_SIGN_FOTA_START (301)

+#define ARMS_SIGN_LOG_START (302)

+#define ARMS_SIGN_UNBIND_REQ_MSG (303)

+#define ARMS_SIGN_FOTA_STATUS_REPORT (304)

+

+#define ARMS_FOTA_DOWN_CONTINUE (401)

+#define ARMS_FOTA_DOWNLOAD_DONE (402)

+#define ARMS_FOTA_UPGRADE_DONE (403)

+

+#define ARMS_SIGN_EXTIF_POWER_ON_REQ_MSG (501)

+#define ARMS_SIGN_EXTIF_BATTERY_ON_REQ_MSG (502)

+#define ARMS_SIGN_EXTIF_BATTERY_LOW_REQ_MSG (503)

+

+

+#define ARMS_INVALID_HANDLE (-1)

+#define ARMS_FREE_PTR(ptr) \

+	do \

+	{ \

+		if (ptr != NULL) \

+		{ \

+			free(ptr); \

+			ptr = NULL; \

+		} \

+	}while(0)

+

+#endif

+

diff --git a/lynq/S300/ap/app/apparms/apparms_sock.c b/lynq/S300/ap/app/apparms/apparms_sock.c
new file mode 100755
index 0000000..fd8ba49
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_sock.c
@@ -0,0 +1,1021 @@
+
+#include "apparms_sock.h"
+#include "apparms_log.h"
+#include "apparms_dm.h"
+
+#ifdef ARMS_SUPPORT_DM
+
+#ifdef ARMS_DM_UDP
+int arms_sock_dm_send_and_recv_by_udp(PDMSOCK pDMSock)
+{
+	PDMSOCKUDP pDMSockUDP = &pDMSock->stsockudp;
+	PDMSOCKSEND pDMSockSend = &pDMSock->dmsocksend;
+	PDMSOCKRECV pDMSockRecv= &pDMSock->dmsockrecv;
+	unsigned char* pSendBuf;
+	int nPollTimeout = 1;
+	int ret;
+	
+	if (pDMSock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	if (pDMSockUDP->nUDPFd == ARMS_INVALID_HANDLE)
+	{
+		
+		ARMS_LOG_DEBUG("%s(%d) UDP Sock Open...\n",__FUNCTION__,__LINE__);
+		//arms_sock_udp_open(&pDMSockUDP->nUDPFd);
+		arms_sock_udp_open_s(&pDMSockUDP->nUDPFd, pDMSockUDP->szUDPAddr, pDMSockUDP->nUDPPort);
+		if (pDMSockUDP->nUDPFd == ARMS_INVALID_HANDLE)
+		{			
+			ARMS_LOG_ERROR("%s(%d) open udp addr=[%s] port = [%d] failed\n",__FUNCTION__,__LINE__, pDMSockUDP->szUDPAddr, pDMSockUDP->nUDPPort);
+			return ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+		}
+	}
+
+	pSendBuf =  ((pDMSockSend->pSendBuf == NULL) ? pDMSockSend->szSendBuf : pDMSockSend->pSendBuf);
+	ARMS_LOG_DEBUG("send udp to %s:%d\n",pDMSockUDP->szUDPAddr,pDMSockUDP->nUDPPort);
+	ARMS_LOG_DEBUG("%s(%d) UDP Sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,pDMSockSend->nSendSize);
+	//ret = arms_sock_udp_sendto(pDMSockUDP->nUDPFd, pDMSockUDP->szUDPAddr,pDMSockUDP->nUDPPort,(const char *)pSendBuf, pDMSockSend->nSendSize);
+	ret = arms_sock_udp_send(pDMSockUDP->nUDPFd, (const char *)pSendBuf, pDMSockSend->nSendSize);
+	if(ret <= 0)
+	{
+		arms_sock_udp_close(&pDMSockUDP->nUDPFd);
+		return ARMS_SOCK_SEND_TO_SERVER_FAILED;
+	}
+
+	while(1)
+	{
+		ARMS_LOG_DEBUG("%s(%d) UDP Sock Polling(timeout:%d)...\n",__FUNCTION__,__LINE__,nPollTimeout);
+		ret = arms_sock_udp_poll(pDMSockUDP->nUDPFd, nPollTimeout * 1000);
+		if(ret < 0)
+		{
+			arms_sock_udp_close(&pDMSockUDP->nUDPFd);
+			return ARMS_SOCK_POLL_FOR_RECV_FAILED;
+		}
+
+		if(ret == 0)
+		{
+			break;
+		}
+
+		if(ret > 0)
+		{
+			pDMSockRecv->nRecvSize = ARMS_DM_SOCK_RECV_BUF_SIZE;
+			//ret = arms_sock_udp_recvfrom(pDMSockUDP->nUDPFd, pDMSockUDP->szUDPAddr,pDMSockUDP->nUDPPort,(char *)pDMSockRecv->szRecvBuf, &pDMSockRecv->nRecvSize);
+			ret = arms_sock_udp_recv(pDMSockUDP->nUDPFd, (char *)pDMSockRecv->szRecvBuf, &pDMSockRecv->nRecvSize);
+			if(ret <= 0)
+			{
+				arms_sock_udp_close(&pDMSockUDP->nUDPFd);
+				return ARMS_SOCK_RECV_FORM_SERVER_FAILED;
+			}
+			
+			ARMS_LOG_DEBUG("%s(%d) UDP Sock Received(len:%d)...\n",__FUNCTION__,__LINE__,pDMSockRecv->nRecvSize);
+			if (pDMSock->dmsockrecvcb != NULL)
+				(*pDMSock->dmsockrecvcb)(pDMSock->dmsockrecvptr, ARMS_SIGN_LOOP_PUSH_REQ_MSG);
+		}
+	}
+	
+	return 0;
+}
+#endif
+
+#ifdef ARMS_DM_MQTT
+void arms_sock_dm_mqtt_disconnect_callback_handler(ARMS_MQTT_Client *pClient, void *data) {
+	ARMS_LOG_INFO("%s(%d) MQTT Disconnect\n",__FUNCTION__,__LINE__);
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+
+	if(NULL == pClient) {
+		return;
+	}
+
+	ARMS_MQTT_API_UNUSED(data);
+
+	if(arms_mqtt_is_autoreconnect_enabled(pClient)) {
+		ARMS_LOG_DEBUG("Auto Reconnect is enabled, Reconnecting attempt will start now\n");
+	} else {
+		ARMS_LOG_DEBUG("Auto Reconnect not enabled. Starting manual reconnect...\n");
+		rc = arms_mqtt_reconnect(pClient);
+		if(NETWORK_RECONNECTED == rc) {
+			ARMS_LOG_DEBUG("Manual Reconnect Successful\n");
+		} else {
+			ARMS_LOG_DEBUG("Manual Reconnect Failed - %d\n", rc);
+		}
+	}
+}
+
+void arms_sock_dm_mqtt_subscribe_rms_callback_handler(ARMS_MQTT_Client *pClient, char *topicName, uint16_t topicNameLen,
+									MQTT_Publish_Message_Params *params, void *pData) {
+	char topic[128] = {0};
+	PDMSOCK pDMSock = (PDMSOCK)pData;
+	PDMSOCKRECV pDMSockRecv = &pDMSock->dmsockrecv;
+
+	if (pDMSock == NULL)
+	{
+		return;
+	}
+
+	ARMS_MQTT_API_UNUSED(pData);
+	ARMS_MQTT_API_UNUSED(pClient);
+	ARMS_LOG_INFO("\n\n RMS Subscribe callback\n");
+	ARMS_LOG_INFO("topicNameLen = %d\n", (int)topicNameLen);
+	memcpy(topic,topicName,topicNameLen);
+	ARMS_LOG_INFO("topicName = %s\n", topic);
+	ARMS_LOG_INFO("payloadLen = %d\n", (int)params->payloadLen);
+	pDMSockRecv->nRecvSize = params->payloadLen;
+	memcpy(pDMSockRecv->szRecvBuf,params->payload,pDMSockRecv->nRecvSize);
+	if (pDMSock->dmsockrecvcb != NULL)
+		(*pDMSock->dmsockrecvcb)(pDMSock->dmsockrecvptr, ARMS_SIGN_LOOP_PUSH_REQ_MSG);
+}
+
+void arms_sock_dm_mqtt_subscribe_ags_callback_handler(ARMS_MQTT_Client *pClient, char *topicName, uint16_t topicNameLen,
+									MQTT_Publish_Message_Params *params, void *pData) {
+	char topic[128] = {0};
+	PDMSOCK pDMSock = (PDMSOCK)pData;
+	PDMSOCKRECV pDMSockRecv = &pDMSock->dmsockrecv;
+
+	if (pDMSock == NULL)
+	{
+		return;
+	}
+
+	ARMS_MQTT_API_UNUSED(pData);
+	ARMS_MQTT_API_UNUSED(pClient);
+	ARMS_LOG_INFO("\n\n AGS Subscribe callback\n");
+	ARMS_LOG_INFO("topicNameLen = %d\n", (int)topicNameLen);
+	memcpy(topic,topicName,topicNameLen);
+	ARMS_LOG_INFO("topicName = %s\n", topic);
+	ARMS_LOG_INFO("payloadLen = %d\n", (int)params->payloadLen);
+	pDMSockRecv->nRecvSize = params->payloadLen;
+	memcpy(pDMSockRecv->szRecvBuf,params->payload,pDMSockRecv->nRecvSize);
+	if (pDMSock->dmsockrecvcb != NULL)
+		(*pDMSock->dmsockrecvcb)(pDMSock->dmsockrecvptr, ARMS_SIGN_LOOP_AGS_PUSH_REQ_MSG);
+}
+
+static void* arms_sock_dm_mqtt_loop(void* pVoid)
+{
+	PARMSDM pARMSDM = (PARMSDM)pVoid;
+	PDMSOCK pDMSock;
+
+	int nRetryInterval = 1;
+		
+	if (pARMSDM == NULL)
+		return 0;
+
+	pDMSock = &pARMSDM->stDMSock;
+	prctl(PR_SET_NAME, "MQTT");
+		
+	while (!pDMSock->stsockmqtt.mqttexitflag)
+	{
+		bool infinitePublishFlag = true;
+		int publishCount = 0;
+		int nSuspend = 0;
+
+		
+		ARMS_MQTT_ERROR_T rc = FAILURE;
+		ARMS_MQTT_Client *pClient = &pDMSock->stsockmqtt.client;
+		MQTT_Init_Params mqttInitParams = ClientInitParamsDefault;
+		MQTT_Connect_Params connectParams = ClientConnectParamsDefault;
+
+		if ((arms_data_os_get_suspend(pARMSDM->pDataFunList, pARMSDM->stDMCfg.stDMCommCfg.unHWId, &nSuspend) >= 0)
+			&& (nSuspend > 0))
+		{
+			
+			ARMS_LOG_DEBUG("****%s(%d) MQTT on suspend .................... \n",__FUNCTION__,__LINE__);
+
+			sleep(3);				
+			continue;
+		}
+		
+		/*network error, e.g. no ip address*/
+		if (pDMSock->stsockmqtt.mqttnwst == DM_MQTT_NETWORK_ERROR)
+		{
+			sleep(3);
+			continue;
+		}
+
+		/*IP is OK, but unable to connect server*/
+		if (pDMSock->stsockmqtt.mqttnwst == MD_MQTT_CONNECT_FAIL)
+		{
+			/*retry after 10*nRetryInterval minutes*/
+			if (pDMSock->stsockmqtt.nErrCnt++ > (200*nRetryInterval))
+			{			
+				ARMS_LOG_INFO("****%s(%d) exit connect fail and start retry (%d) \n",__FUNCTION__,__LINE__,nRetryInterval);
+				
+				pDMSock->stsockmqtt.nErrCnt = 0;
+				pDMSock->stsockmqtt.mqttnwst = DM_MQTT_NETWORK_READY;
+				
+				if(nRetryInterval++ > 36)	// About 6 hours interval
+					nRetryInterval = 36;
+			}
+			sleep(3);
+			continue;
+		}
+		
+		memset(&pDMSock->stsockmqtt.client, 0, sizeof(ARMS_MQTT_Client));
+
+		ARMS_LOG_INFO("%s(%d) TLS Mode: %d\n",__FUNCTION__,__LINE__, pDMSock->stsockmqtt.tlsMode);
+
+		ARMS_LOG_INFO("HostAddress:%s\n", pDMSock->stsockmqtt.szHostAddr);
+		ARMS_LOG_DEBUG("port:%d\n", pDMSock->stsockmqtt.nHostPort);
+		ARMS_LOG_DEBUG("publishCount:%d\n", publishCount);
+		ARMS_LOG_INFO("clientID:%s\n", pDMSock->stsockmqtt.clientID);
+		ARMS_LOG_DEBUG("password:%s\n", pDMSock->stsockmqtt.password);
+		ARMS_LOG_DEBUG("RMS subTopic:%s\n", pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS]);
+		ARMS_LOG_DEBUG("AGS subTopic:%s\n", pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS]);
+		
+		ARMS_LOG_DEBUG("RMS pubTopic:%s\n", pDMSock->stsockmqtt.pubTopic[DM_MQTT_TOPIC_RMS]);
+		ARMS_LOG_DEBUG("AGS pubTopic:%s\n", pDMSock->stsockmqtt.pubTopic[DM_MQTT_TOPIC_AGS]);
+#ifdef ARMS_AUTH_X509
+		ARMS_LOG_DEBUG("rootCA %s\n", pDMSock->stsockmqtt.caCert);
+		ARMS_LOG_DEBUG("clientCRT %s\n", pDMSock->stsockmqtt.clientCert);
+		ARMS_LOG_DEBUG("clientKey %s\n", pDMSock->stsockmqtt.clientPriKey);
+#endif
+
+		mqttInitParams.enableAutoReconnect = false; // We enable this later below
+		mqttInitParams.pHostURL = pDMSock->stsockmqtt.szHostAddr;
+		mqttInitParams.port = pDMSock->stsockmqtt.nHostPort;
+#ifdef ARMS_AUTH_X509
+		mqttInitParams.pRootCALocation = pDMSock->stsockmqtt.caCert;
+		mqttInitParams.pDeviceCertLocation = pDMSock->stsockmqtt.clientCert;
+		mqttInitParams.pDevicePrivateKeyLocation = pDMSock->stsockmqtt.clientPriKey;
+#endif
+		mqttInitParams.mqttCommandTimeout_ms = 5000;
+		mqttInitParams.tlsHandshakeTimeout_ms = 5000;
+		mqttInitParams.isSSLHostnameVerify = false;
+		mqttInitParams.disconnectHandler = arms_sock_dm_mqtt_disconnect_callback_handler;
+		mqttInitParams.disconnectHandlerData = NULL;
+
+		pClient->networkStack.tlsMode  = pDMSock->stsockmqtt.tlsMode > 0 ? true : false;
+
+		rc = arms_mqtt_init(pClient, &mqttInitParams);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("arms_mqtt_init returned error : %d \n", rc);
+			sleep(3);
+			continue;
+		}
+
+		connectParams.keepAliveIntervalInSec = pDMSock->stsockmqtt.nLiveTime;
+		connectParams.isCleanSession = true;
+		connectParams.MQTTVersion = MQTT_3_1_1;
+		connectParams.pClientID = pDMSock->stsockmqtt.clientID;
+		connectParams.clientIDLen = strlen(pDMSock->stsockmqtt.clientID);
+		connectParams.pUsername = pDMSock->stsockmqtt.clientID;
+		connectParams.usernameLen = strlen(pDMSock->stsockmqtt.clientID);
+		connectParams.pPassword = pDMSock->stsockmqtt.password;
+		connectParams.passwordLen = strlen(pDMSock->stsockmqtt.password);
+		connectParams.isWillMsgPresent = false;
+
+		ARMS_LOG_INFO("%s(%d) Connecting...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_connect(pClient, &connectParams);
+		if(SUCCESS != rc) 
+		{
+			if (pDMSock->stsockmqtt.nErrCnt++ > 5)
+			{
+				pDMSock->stsockmqtt.nErrCnt = 0;
+				pDMSock->stsockmqtt.mqttnwst = MD_MQTT_CONNECT_FAIL;
+				
+				ARMS_LOG_INFO("****%s(%d) enter connect fail \n",__FUNCTION__,__LINE__);
+			}
+			else
+			{
+				sleep(pDMSock->stsockmqtt.nErrCnt);
+			}
+			
+			ARMS_LOG_ERROR("Error(%d) connecting to %s:%d\n", rc, mqttInitParams.pHostURL, mqttInitParams.port);
+			goto MQTT_DISCONNECT;
+		}
+
+		pDMSock->stsockmqtt.nErrCnt = 0;
+		nRetryInterval = 1;
+		/*
+		 *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
+		 *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
+		 */
+		rc = arms_mqtt_autoreconnect_set_status(pClient, true);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Unable to set Auto Reconnect to true - %d\n", rc);
+			//return 0;
+		}
+
+		ARMS_LOG_INFO("%s(%d) Subscribing RMS...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_subscribe(pClient, &pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS][0], strlen(&pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS][0]), QOS0, arms_sock_dm_mqtt_subscribe_rms_callback_handler, pDMSock);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Error RMS subscribing : %d \n", rc);
+			goto MQTT_UNSUBSCRIBE;
+		}
+
+		ARMS_LOG_INFO("%s(%d) Subscribing AGS...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_subscribe(pClient, &pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS][0], strlen(&pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS][0]), QOS0, arms_sock_dm_mqtt_subscribe_ags_callback_handler, pDMSock);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Error AGS subscribing : %d \n", rc);
+			goto MQTT_UNSUBSCRIBE;
+		}
+
+		if(publishCount != 0) 
+		{
+			infinitePublishFlag = false;
+		}
+
+		pDMSock->stsockmqtt.mqttInited = 1;
+		pDMSock->stsockmqtt.mqttnwst = MD_MQTT_NETWORK_YIELD;
+
+		ARMS_LOG_INFO("%s(%d) Yielding... rc=%d\n",__FUNCTION__,__LINE__, rc);
+		while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)
+			  && (publishCount > 0 || infinitePublishFlag) && (pDMSock->stsockmqtt.mqttnwst == MD_MQTT_NETWORK_YIELD) ) 
+		{
+
+			//Max time the yield function will wait for read messages
+			pthread_mutex_lock(&pDMSock->stsockmqtt.dm_mqtt_mutex);
+			rc = arms_mqtt_yield(pClient, 100);
+			pthread_mutex_unlock(&pDMSock->stsockmqtt.dm_mqtt_mutex);
+			if(NETWORK_ATTEMPTING_RECONNECT == rc) 
+			{
+				// If the client is attempting to reconnect we will skip the rest of the loop.
+				continue;
+			}
+
+			if (publishCount > 0)
+				publishCount--;
+
+			usleep(100000);
+
+			if ((arms_data_os_get_suspend(pARMSDM->pDataFunList, pARMSDM->stDMCfg.stDMCommCfg.unHWId, &nSuspend) >=0)
+				&& (nSuspend > 0))
+			{			
+				ARMS_LOG_DEBUG("****%s(%d) MQTT exit due to suspend....................... \n",__FUNCTION__,__LINE__);
+				break;
+			}
+
+			if((0 != pClient->clientData.keepAliveInterval) && (0 == nSuspend))
+			{
+				#ifdef USE_CLOCK_MONOTONIC_TIME
+				arms_data_os_set_waketime(pARMSDM->pDataFunList, pARMSDM->stDMCfg.stDMCommCfg.unHWId, 
+							(long long)(pClient->pingTimer.time_slot.tv_sec), pClient->clientData.keepAliveInterval);				
+				#else
+				arms_data_os_set_waketime(pARMSDM->pDataFunList, pARMSDM->stDMCfg.stDMCommCfg.unHWId, 
+							(long long)(pClient->pingTimer.end_time.tv_sec), pClient->clientData.keepAliveInterval);
+				#endif
+
+			}
+		}
+
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("An error occurred rc = %d in the loop.\n", rc);
+		} 
+		else 
+		{
+			ARMS_LOG_INFO("%s(%d) Loop done netst = %d\n",__FUNCTION__,__LINE__, pDMSock->stsockmqtt.mqttnwst);
+		}
+
+		pDMSock->stsockmqtt.mqttInited = 0;
+
+MQTT_UNSUBSCRIBE:
+		ARMS_LOG_INFO("%s(%d) RMS Unsubscribing...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_unsubscribe(pClient, &pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS][0], strlen(&pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_RMS][0]));
+		if (SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Error RMS  unsubscribing : %d \n", rc);
+		}
+
+		ARMS_LOG_INFO("%s(%d) AGS Unsubscribing...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_unsubscribe(pClient, &pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS][0], strlen(&pDMSock->stsockmqtt.subTopic[DM_MQTT_TOPIC_AGS][0]));
+		if (SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Error AGS unsubscribing : %d \n", rc);
+		}
+	
+MQTT_DISCONNECT:
+		ARMS_LOG_INFO("%s(%d) Disconnecting...\n",__FUNCTION__,__LINE__);
+		rc = arms_mqtt_disconnect(pClient);
+		if (SUCCESS != rc) 
+		{
+			ARMS_LOG_ERROR("Error(%d) disconnecting %s:%d\n", rc, mqttInitParams.pHostURL, mqttInitParams.port);
+		}
+
+		sleep(1);
+	}
+
+	pthread_mutex_destroy(&pDMSock->stsockmqtt.dm_mqtt_mutex);
+
+	return 0;
+}
+
+int arms_sock_dm_mqtt_start_thread(void* pDM)
+{
+	PARMSDM pARMSDM = (PARMSDM)pDM;
+	PDMSOCK pDMSock = NULL;
+
+	if (pARMSDM == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+
+
+	pDMSock = &pARMSDM->stDMSock;
+	if (pDMSock == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+
+	pthread_mutex_init(&pDMSock->stsockmqtt.dm_mqtt_mutex, NULL);	
+	
+	pthread_attr_init (&pDMSock->stsockmqtt.dm_mqtt_thread_attr);
+	pthread_attr_setdetachstate (&pDMSock->stsockmqtt.dm_mqtt_thread_attr, PTHREAD_CREATE_DETACHED);
+	pthread_create(&pDMSock->stsockmqtt.dm_mqtt_thread_handle, &pDMSock->stsockmqtt.dm_mqtt_thread_attr, arms_sock_dm_mqtt_loop, pARMSDM);
+
+	return 0;
+}
+
+int arms_sock_dm_mqtt_stop_thread(PDMSOCK pDMSock)
+{
+	if (pDMSock == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+	
+	pDMSock->stsockmqtt.mqttexitflag = 1;
+	pDMSock->stsockmqtt.nErrCnt = 0;
+	pDMSock->stsockmqtt.mqttnwst = DM_MQTT_NETWORK_ERROR;
+	pthread_cancel(pDMSock->stsockmqtt.dm_mqtt_thread_handle);
+	
+	return 0;
+}
+
+int arms_sock_dm_mqtt_set_networkst(PDMSOCK pDMSock, int nNWOK)
+{
+	if (pDMSock == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+
+	if (nNWOK == 1)
+		pDMSock->stsockmqtt.mqttnwst = DM_MQTT_NETWORK_READY;
+	else if (nNWOK == 0)
+		pDMSock->stsockmqtt.mqttnwst = DM_MQTT_NETWORK_ERROR;
+
+	pDMSock->stsockmqtt.nErrCnt = 0;
+	return 0;
+}
+
+int arms_sock_dm_send_by_mqtt(PDMSOCK pDMSock)
+{
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+	PDMSOCKSEND pDMSockSend = &pDMSock->dmsocksend;
+	unsigned char* pSendBuf;
+	ARMS_MQTT_Client *pClient = &pDMSock->stsockmqtt.client;
+	MQTT_Publish_Message_Params paramsQOS1;
+	char* pTopicContent;
+
+	if (pDMSock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	if (!pDMSock->stsockmqtt.mqttInited)
+	{
+		//arms_sock_dm_mqtt_start_thread(pDMSock);
+		
+		/* PUSH MESSAGE is received immediately after subscribing TOPIC, but MQTT has not finished initializing. */
+		int nWaitCount = 3;	// 3*0.3 sec
+		for(; nWaitCount > 0; nWaitCount--)
+		{
+			ARMS_LOG_INFO("%s(%d) mqtt Inited not ready, wait 0.3 sec...\n",__FUNCTION__,__LINE__);
+			usleep(300000);
+			if (pDMSock->stsockmqtt.mqttInited)
+				break;
+		}
+
+		if (!pDMSock->stsockmqtt.mqttInited)
+		{
+			ARMS_LOG_ERROR("%s(%d) mqtt Inited not ready, ignore this...\n",__FUNCTION__,__LINE__ );
+			return ARMS_SOCK_CONNECT_NOT_INITED;
+		}
+	}
+
+	if (!arms_mqtt_is_client_connected(pClient))
+	{		
+		ARMS_LOG_ERROR("%s(%d) mqtt not connectedm ignore this\n",__FUNCTION__,__LINE__ );
+		return ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+	}
+
+	pSendBuf =	((pDMSockSend->pSendBuf == NULL) ? pDMSockSend->szSendBuf : pDMSockSend->pSendBuf);
+
+	paramsQOS1.qos = QOS1;
+	paramsQOS1.payload = (void *) pSendBuf;
+	paramsQOS1.isRetained = 0;
+	paramsQOS1.payloadLen = pDMSockSend->nSendSize;
+
+	
+	if (pDMSock->stsockmqtt.pubType == DM_MQTT_TOPIC_AGS)
+	{
+		pTopicContent = &pDMSock->stsockmqtt.pubTopic[DM_MQTT_TOPIC_AGS][0];
+		ARMS_LOG_INFO("%s(%d) AGS Publishing (len:%d)..................\n",__FUNCTION__,__LINE__,pDMSockSend->nSendSize);
+	}
+	else
+	{		
+		ARMS_LOG_INFO("%s(%d) RMS Publishing (len:%d)..................\n",__FUNCTION__,__LINE__,pDMSockSend->nSendSize);
+		pTopicContent = &pDMSock->stsockmqtt.pubTopic[DM_MQTT_TOPIC_RMS][0];
+	}	
+	
+	pthread_mutex_lock(&pDMSock->stsockmqtt.dm_mqtt_mutex);
+	rc = arms_mqtt_publish(pClient, pTopicContent, strlen(pTopicContent),&paramsQOS1);
+	pthread_mutex_unlock(&pDMSock->stsockmqtt.dm_mqtt_mutex);
+	if (rc == MQTT_REQUEST_TIMEOUT_ERROR) 
+	{
+		ARMS_LOG_ERROR("QOS1 publish ack not received.\n");
+		rc = SUCCESS;
+	}
+
+	ARMS_LOG_INFO("%s(%d) Published(rc:%d).....................\n",__FUNCTION__,__LINE__,rc);
+
+	return rc;
+}
+
+#endif
+
+#ifdef ARMS_DM_LWM2M
+void arms_sock_dm_lwm2m_app_write_handler(void *data, int len, void *pData) {
+	PDMSOCK pDMSock = (PDMSOCK)pData;
+	PDMSOCKRECV pDMSockRecv = &pDMSock->dmsockrecv;
+
+	ARMS_LOG_DEBUG("%s(%d) enter...\n",__FUNCTION__,__LINE__);
+
+	if(pDMSock == NULL)
+	{
+		return ;
+	}
+	pDMSockRecv->nRecvSize = len;
+	memcpy(pDMSockRecv->szRecvBuf,data,pDMSockRecv->nRecvSize);
+	if (pDMSock->dmsockrecvcb != NULL)
+		(*pDMSock->dmsockrecvcb)(pDMSock->dmsockrecvptr, ARMS_SIGN_LOOP_PUSH_REQ_MSG);
+}
+
+static void* arms_sock_dm_lwm2m_loop(void* pVoid)
+{
+	PDMSOCK pDMSock = (PDMSOCK)pVoid;
+
+    atiny_param_t *atiny_params = NULL;
+    atiny_security_param_t *iot_security_param = NULL;
+    atiny_security_param_t *bs_security_param = NULL;
+    atiny_device_info_t *device_info = &pDMSock->stsocklwm2m.demoDeviceInfo;
+
+	ARMS_LOG_INFO("%s(%d) LwM2M Loop enter\n",__FUNCTION__,__LINE__);
+	
+	if (pDMSock == NULL)
+	{
+		return 0;
+	}
+
+	prctl(PR_SET_NAME, "LWM2M");
+
+    device_info->endpoint_name = pDMSock->stsocklwm2m.endpoint_name;
+    device_info->manufacturer = "Agent_Tiny";
+    atiny_params = &pDMSock->stsocklwm2m.demoAtinyParams;
+    atiny_params->server_params.binding = "UQ";
+    // atiny_params->server_params.life_time = LWM2M_LIFE_TIME;
+    atiny_params->server_params.life_time = 10;
+    atiny_params->server_params.storing_cnt = 0;
+
+    atiny_params->server_params.bootstrap_mode = BOOTSTRAP_FACTORY;
+    atiny_params->server_params.hold_off_time = 5;
+
+    // pay attention: index 0 for iot server, index 1 for bootstrap server.
+    iot_security_param = &(atiny_params->security_params[0]);
+    bs_security_param = &(atiny_params->security_params[1]);
+
+    iot_security_param->server_ip = pDMSock->stsocklwm2m.szHostAddr;
+    bs_security_param->server_ip  = pDMSock->stsocklwm2m.szHostAddr;
+
+	sprintf(pDMSock->stsocklwm2m.strHostPort,"%d",pDMSock->stsocklwm2m.nHostPort);
+    iot_security_param->server_port = pDMSock->stsocklwm2m.strHostPort;
+    bs_security_param->server_port = pDMSock->stsocklwm2m.strHostPort;
+
+    iot_security_param->psk_Id = NULL;
+    iot_security_param->psk = NULL;
+    iot_security_param->psk_len = 0;
+
+    bs_security_param->psk_Id = NULL;
+    bs_security_param->psk = NULL;
+    bs_security_param->psk_len = 0;
+
+	atiny_register_app_write_handler(arms_sock_dm_lwm2m_app_write_handler,pDMSock);
+
+	ARMS_LOG_INFO("%s(%d) LwM2M Init...\n",__FUNCTION__,__LINE__);
+    if (atiny_init(atiny_params, &pDMSock->stsocklwm2m.pHandle) != ATINY_OK) {
+		ARMS_LOG_ERROR("Error atiny_init");
+        return 0;
+    }
+
+	pDMSock->stsocklwm2m.lwm2mInited = 1;
+
+	ARMS_LOG_INFO("%s(%d) LwM2M Bind...\n",__FUNCTION__,__LINE__);
+    (void)atiny_bind(device_info, pDMSock->stsocklwm2m.pHandle);
+
+	return 0;
+}
+
+int arms_sock_dm_lwm2m_start_thread(PDMSOCK pDMSock)
+{
+	if (pDMSock == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+	
+	pthread_attr_init (&pDMSock->stsocklwm2m.dm_lwm2m_thread_attr);
+	pthread_attr_setdetachstate (&pDMSock->stsocklwm2m.dm_lwm2m_thread_attr, PTHREAD_CREATE_DETACHED);
+	pthread_create(&pDMSock->stsocklwm2m.dm_lwm2m_thread_handle, &pDMSock->stsocklwm2m.dm_lwm2m_thread_attr, arms_sock_dm_lwm2m_loop, pDMSock);
+
+	return 0;
+}
+
+int arms_sock_dm_lwm2m_stop_thread(PDMSOCK pDMSock)
+{
+	if (pDMSock == NULL)
+	{
+		return ARMS_SOCK_POINT_NULL_ERROR;
+	}
+	
+	pDMSock->stsocklwm2m.lwm2mexitflag = 1;
+	atiny_deinit(pDMSock->stsocklwm2m.pHandle);
+	
+	return 0;
+}
+
+void arms_sock_dm_lwm2m_ack_callback(atiny_report_type_e type, int cookie, data_send_status_e status)
+{
+    ARMS_LOG_INFO("%s(%d) type:%d cookie:%d status:%d\n",__FUNCTION__,__LINE__, type, cookie, status);
+}
+
+int arms_sock_dm_send_by_lwm2m(PDMSOCK pDMSock)
+{
+	PDMSOCKSEND pDMSockSend = &pDMSock->dmsocksend;
+	unsigned char* pSendBuf;
+	data_report_t report_data;
+    int ret = 0;
+
+	if (pDMSock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	if (!pDMSock->stsocklwm2m.lwm2mInited)
+	{
+		arms_sock_dm_lwm2m_start_thread(pDMSock);
+		return ARMS_SOCK_CONNECT_NOT_INITED;
+	}
+
+	ARMS_LOG_INFO("%s(%d) LwM2M Data Report(len:%d)...\n",__FUNCTION__,__LINE__,pDMSockSend->nSendSize);
+
+    pSendBuf =	((pDMSockSend->pSendBuf == NULL) ? pDMSockSend->szSendBuf : pDMSockSend->pSendBuf);
+
+    report_data.buf = pSendBuf;
+    report_data.callback = arms_sock_dm_lwm2m_ack_callback;
+    report_data.cookie = 0;
+    report_data.len = pDMSockSend->nSendSize;
+    report_data.type = APP_DATA;
+
+    report_data.cookie = pDMSock->stsocklwm2m.cnt;
+    pDMSock->stsocklwm2m.cnt++;
+    ret = atiny_data_report(pDMSock->stsocklwm2m.pHandle, &report_data);
+    ARMS_LOG_DEBUG("%s(%d) data report ret: %d\n",__FUNCTION__,__LINE__, ret);
+    ret = atiny_data_change(pDMSock->stsocklwm2m.pHandle, DEVICE_MEMORY_FREE);
+    ARMS_LOG_DEBUG("%s(%d) data change ret: %d\n",__FUNCTION__,__LINE__, ret);
+
+	return ret;
+}
+#endif
+
+int arms_sock_dm_reg_recv_cb(PDMSOCK pDMSock, ARMS_SOCK_DM_RECV_CB cb, void* pApp)
+{
+	pDMSock->dmsockrecvcb = cb;
+	pDMSock->dmsockrecvptr = pApp;
+
+	return 0;
+}
+
+int arms_sock_dm_send_and_recv_with_server(PDMSOCK pDMSock)
+{
+	if (pDMSock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	#ifdef ARMS_DM_UDP
+	if (pDMSock->dmSockMode == ARMS_SOCK_MODE_DM_UDP)
+	{
+		return arms_sock_dm_send_and_recv_by_udp(pDMSock);
+	}
+	#endif
+
+	#ifdef ARMS_DM_MQTT
+	if (pDMSock->dmSockMode == ARMS_SOCK_MODE_DM_MQTT)
+	{
+		return arms_sock_dm_send_by_mqtt(pDMSock);
+	}
+	#endif
+
+	#ifdef ARMS_DM_LWM2M
+	if (pDMSock->dmSockMode == ARMS_SOCK_MODE_DM_LWM2M)
+	{
+		return arms_sock_dm_send_by_lwm2m(pDMSock);
+	}
+	#endif
+	
+	ARMS_LOG_ERROR("%s(%d) unknown dm sock mode = %d\n",__FUNCTION__,__LINE__, pDMSock->dmSockMode);
+	return ARMS_SOCK_CONNECT_MODE_ERORR;
+}
+
+#endif
+
+
+#ifdef ARMS_SUPPORT_FOTA
+#ifdef ARMS_FOTA_HTTPS
+int arms_sock_fota_send_and_recv_by_https(PFOTASOCK pFOTASock)
+{
+	PFOTASOCKHTTP pFOTASockHTTPS = &pFOTASock->stsockhttp;
+	PFOTASOCKSEND pFOTASockSend = &pFOTASock->fotasocksend;
+	PFOTASOCKRECV pFOTASockRecv= &pFOTASock->fotasockrecv;
+	int ret = -1;
+	Timer timer;
+	size_t nLen = 0;
+
+	arms_mqtt_api_timer_init(&timer);
+	
+#if 1
+	if (pFOTASock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	ret = pFOTASockHTTPS->networkStack.isConnected(&pFOTASockHTTPS->networkStack);
+	if (ret != SUCCESS || pFOTASockHTTPS->nReconnect)
+	{
+		if(ret == SUCCESS)
+		{
+			pFOTASockHTTPS->networkStack.disconnect(&pFOTASockHTTPS->networkStack);
+			pFOTASockHTTPS->networkStack.destroy(&pFOTASockHTTPS->networkStack);
+		}
+
+		pFOTASockHTTPS->nReconnect = 0;
+
+		ARMS_LOG_DEBUG("%s(%d) TLS Sock Connect...\n",__FUNCTION__,__LINE__);
+		ret = pFOTASockHTTPS->networkStack.connect(&pFOTASockHTTPS->networkStack,NULL);
+		if (ret != SUCCESS)
+		{			
+			ARMS_LOG_ERROR("%s(%d) Connect TLS Sock failed\n",__FUNCTION__,__LINE__);
+			return ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+		}
+	}
+
+	ARMS_LOG_DEBUG("%s(%d) TLS sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,pFOTASockSend->nSendSize);
+	
+	arms_mqtt_api_timer_countdown_ms(&timer, pFOTASockHTTPS->networkStack.tlsConnectParams.timeout_ms);
+	ret = pFOTASockHTTPS->networkStack.write(&pFOTASockHTTPS->networkStack, (unsigned char *)pFOTASockSend->szSendBuf, pFOTASockSend->nSendSize, &timer, &nLen);
+	if(ret != SUCCESS)
+	{
+		pFOTASockHTTPS->networkStack.disconnect(&pFOTASockHTTPS->networkStack);
+		return ARMS_SOCK_SEND_TO_SERVER_FAILED;
+	}
+
+	do
+	{
+		{
+			ARMS_LOG_DEBUG("%s(%d) TLS Sock Receiving...\n",__FUNCTION__,__LINE__);
+			pFOTASockRecv->nRecvSize = 0;
+			nLen = ARMS_FOTA_SOCK_RECV_BUF_SIZE;
+			memset(pFOTASockRecv->szRecvBuf,0,pFOTASockRecv->nRecvSize);
+			
+			arms_mqtt_api_timer_countdown_ms(&timer, pFOTASockHTTPS->networkStack.tlsConnectParams.timeout_ms);
+			pFOTASockHTTPS->networkStack.read(&pFOTASockHTTPS->networkStack, (unsigned char *)pFOTASockRecv->szRecvBuf, nLen, &timer, (size_t *)&pFOTASockRecv->nRecvSize);
+
+			ARMS_LOG_DEBUG("%s(%d) TLS Sock Received(%d)...\n",__FUNCTION__,__LINE__,pFOTASockRecv->nRecvSize);
+			if(pFOTASockRecv->nRecvSize > 0)
+			{
+				if (pFOTASock->fotasockrecvcb != NULL)
+					ret = (*pFOTASock->fotasockrecvcb)(pFOTASock->fotasockrecvptr);
+			}
+		}
+	}while(ret == ARMS_FOTA_DOWN_CONTINUE || pFOTASockRecv->nRecvSize == 0);
+#endif
+	//return (ret >= 0 ? 0 : ret);
+	return ret;
+}
+#endif
+int arms_sock_fota_send_and_recv_by_http(PFOTASOCK pFOTASock)
+{
+	PFOTASOCKHTTP pFOTASockHTTP = &pFOTASock->stsockhttp;
+	PFOTASOCKSEND pFOTASockSend = &pFOTASock->fotasocksend;
+	PFOTASOCKRECV pFOTASockRecv= &pFOTASock->fotasockrecv;
+	int nPollTimeout = 3;
+	int ret = -1;
+	
+	if (pFOTASock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	if (pFOTASockHTTP->nHttpFd == ARMS_INVALID_HANDLE || pFOTASockHTTP->nReconnect)
+	{
+		if(pFOTASockHTTP->nHttpFd != ARMS_INVALID_HANDLE)
+			arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+
+		pFOTASockHTTP->nReconnect = 0;
+
+		ARMS_LOG_DEBUG("%s(%d) TCP Sock Open...\n",__FUNCTION__,__LINE__);
+		pFOTASockHTTP->nHttpFd = arms_sock_tcp_open(&pFOTASockHTTP->nHttpFd,pFOTASockHTTP->szHttpAddr,pFOTASockHTTP->szHttpPort);
+		if (pFOTASockHTTP->nHttpFd == ARMS_INVALID_HANDLE)
+		{			
+			ARMS_LOG_ERROR("%s(%d) open tcp addr=[%s] port = [%s] failed\n",__FUNCTION__,__LINE__, pFOTASockHTTP->szHttpAddr, pFOTASockHTTP->szHttpPort);
+			return ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+		}
+	}
+
+	ARMS_LOG_DEBUG("%s(%d) TCP sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,pFOTASockSend->nSendSize);
+	ret = arms_sock_tcp_send(pFOTASockHTTP->nHttpFd, (const char *)pFOTASockSend->szSendBuf, pFOTASockSend->nSendSize);
+	if(ret <= 0)
+	{
+		arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+		return ARMS_SOCK_SEND_TO_SERVER_FAILED;
+	}
+
+	do
+	{
+		ARMS_LOG_DEBUG("%s(%d) TCP Sock Polling(timeout:%d)...\n",__FUNCTION__,__LINE__,nPollTimeout);
+		ret = arms_sock_tcp_poll(pFOTASockHTTP->nHttpFd, nPollTimeout*1000);
+		if(ret < 0)
+		{
+			arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+			return ARMS_SOCK_POLL_FOR_RECV_FAILED;
+		}
+
+		if(ret == 0)
+		{
+			break;
+		}
+
+		if(ret > 0)
+		{
+			ARMS_LOG_DEBUG("%s(%d) TCP Sock Receiving...\n",__FUNCTION__,__LINE__);
+			pFOTASockRecv->nRecvSize = ARMS_FOTA_SOCK_RECV_BUF_SIZE;
+			memset(pFOTASockRecv->szRecvBuf,0,pFOTASockRecv->nRecvSize);
+			ret = arms_sock_tcp_recv(pFOTASockHTTP->nHttpFd, (char *)pFOTASockRecv->szRecvBuf, &pFOTASockRecv->nRecvSize);
+			if(ret <= 0)
+			{
+				arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+				return ARMS_SOCK_RECV_FORM_SERVER_FAILED;
+			}
+
+			if(pFOTASockRecv->nRecvSize > 0)
+			{
+				if (pFOTASock->fotasockrecvcb != NULL)
+					ret = (*pFOTASock->fotasockrecvcb)(pFOTASock->fotasockrecvptr);
+			}
+		}
+	}while(ret == ARMS_FOTA_DOWN_CONTINUE || pFOTASockRecv->nRecvSize == 0);
+
+	//return (ret >= 0 ? 0 : ret);
+	return ret;
+}
+
+int arms_sock_fota_reg_recv_cb(PFOTASOCK pFOTASock, ARMS_SOCK_FOTA_RECV_CB cb, void* pApp)
+{
+	pFOTASock->fotasockrecvcb = cb;
+	pFOTASock->fotasockrecvptr = pApp;
+
+	return 0;
+}
+
+int arms_sock_fota_send_and_recv_with_server(PFOTASOCK pFOTASock)
+{
+	if (pFOTASock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	#ifdef ARMS_FOTA_HTTP
+	if (pFOTASock->fotaSockMode == ARMS_SOCK_MODE_FOTA_HTTP)
+	{
+		return arms_sock_fota_send_and_recv_by_http(pFOTASock);
+	}
+	else if (pFOTASock->fotaSockMode == ARMS_SOCK_MODE_FOTA_HTTPS)
+	{
+		#ifdef ARMS_FOTA_HTTPS
+		return arms_sock_fota_send_and_recv_by_https(pFOTASock);
+		#endif
+	}
+	#endif
+
+	ARMS_LOG_ERROR("%s(%d) unknown fota sock mode = %d\n",__FUNCTION__,__LINE__, pFOTASock->fotaSockMode);
+	return ARMS_SOCK_CONNECT_MODE_ERORR;
+}
+
+void arms_sock_fota_close(PFOTASOCK pFOTASock)
+{
+	PFOTASOCKHTTP pFOTASockHTTP;
+	
+	if (pFOTASock == NULL)
+		return;
+	
+	pFOTASockHTTP = &pFOTASock->stsockhttp;
+	if(pFOTASockHTTP->nHttpFd != ARMS_INVALID_HANDLE)
+	{
+		arms_sock_tcp_close(&pFOTASockHTTP->nHttpFd);
+	}
+}
+
+#endif
+
+#ifdef ARMS_SUPPORT_EC2
+
+int arms_sock_ec2_send_and_recv_by_http(PEC2SOCK pEC2Sock)
+{
+	PEC2SOCKHTTP pEC2SockHTTP = &pEC2Sock->stsockhttp;
+	PEC2SOCKSEND pEC2SockSend = &pEC2Sock->ec2socksend;
+	PEC2SOCKRECV pEC2SockRecv= &pEC2Sock->ec2sockrecv;
+	
+	int nPollTimeout = 3;
+	int ret = -1;
+	
+	if (pEC2Sock == NULL)
+		return ARMS_SOCK_POINT_NULL_ERROR;
+
+	if (pEC2SockHTTP->nHttpFd == ARMS_INVALID_HANDLE || pEC2SockHTTP->nReconnect)
+	{
+		if(pEC2SockHTTP->nHttpFd != ARMS_INVALID_HANDLE)
+			arms_sock_tcp_close(&pEC2SockHTTP->nHttpFd);
+
+		pEC2SockHTTP->nReconnect = 0;
+
+		ARMS_LOG_DEBUG("%s(%d) TCP Sock Open...\n",__FUNCTION__,__LINE__);
+		pEC2SockHTTP->nHttpFd = arms_sock_tcp_open(&pEC2SockHTTP->nHttpFd,pEC2SockHTTP->szHttpAddr,pEC2SockHTTP->szHttpPort);
+		if (pEC2SockHTTP->nHttpFd == ARMS_INVALID_HANDLE)
+		{			
+			ARMS_LOG_ERROR("%s(%d) open tcp addr=[%s] port = [%s] failed\n",__FUNCTION__,__LINE__, pEC2SockHTTP->szHttpAddr, pEC2SockHTTP->szHttpPort);
+			return ARMS_SOCK_CONNECT_TO_SERVER_FAILED;
+		}
+	}
+
+	ARMS_LOG_DEBUG("%s(%d) TCP sock Sending(len:%d)...\n",__FUNCTION__,__LINE__,pEC2SockSend->nSendSize);
+	ret = arms_sock_tcp_send(pEC2SockHTTP->nHttpFd, (const char *)pEC2SockSend->szSendBuf, pEC2SockSend->nSendSize);
+	if(ret <= 0)
+	{
+		arms_sock_tcp_close(&pEC2SockHTTP->nHttpFd);
+		return ARMS_SOCK_SEND_TO_SERVER_FAILED;
+	}
+
+	do
+	{
+		ARMS_LOG_DEBUG("%s(%d) TCP Sock Polling(timeout:%d)...\n",__FUNCTION__,__LINE__,nPollTimeout);
+		ret = arms_sock_tcp_poll(pEC2SockHTTP->nHttpFd, nPollTimeout*1000);
+		if(ret < 0)
+		{
+			arms_sock_tcp_close(&pEC2SockHTTP->nHttpFd);
+			return ARMS_SOCK_POLL_FOR_RECV_FAILED;
+		}
+
+		if(ret == 0)
+		{
+			break;
+		}
+
+		if(ret > 0)
+		{
+			ARMS_LOG_DEBUG("%s(%d) TCP Sock Receiving...\n",__FUNCTION__,__LINE__);
+			pEC2SockRecv->nRecvSize = ARMS_EC2_SOCK_RECV_BUF_SIZE;
+			memset(pEC2SockRecv->szRecvBuf,0,pEC2SockRecv->nRecvSize);
+			ret = arms_sock_tcp_recv(pEC2SockHTTP->nHttpFd, (char *)pEC2SockRecv->szRecvBuf, &pEC2SockRecv->nRecvSize);
+			if(ret <= 0)
+			{
+				arms_sock_tcp_close(&pEC2SockHTTP->nHttpFd);
+				return ARMS_SOCK_RECV_FORM_SERVER_FAILED;
+			}
+
+			if(pEC2SockRecv->nRecvSize > 0)
+			{
+				if (pEC2Sock->ec2sockrecvcb != NULL)
+					ret = (*pEC2Sock->ec2sockrecvcb)(pEC2Sock->ec2sockrecvptr);
+			}
+		}
+	}while(pEC2SockRecv->nRecvSize == 0);
+
+	return ret;
+}
+
+
+int arms_sock_ec2_reg_recv_cb(PEC2SOCK pEC2Sock, ARMS_SOCK_EC2_RECV_CB cb, void* pApp)
+{
+	pEC2Sock->ec2sockrecvcb = cb;
+	pEC2Sock->ec2sockrecvptr = pApp;
+
+	return 0;
+}
+
+void arms_sock_ec2_close(PEC2SOCK pEC2Sock)
+{
+	PEC2SOCKHTTP pEC2SockHTTP;
+	
+	if (pEC2Sock == NULL)
+		return;
+	
+	pEC2SockHTTP = &pEC2Sock->stsockhttp;
+	if(pEC2SockHTTP->nHttpFd != ARMS_INVALID_HANDLE)
+	{
+		arms_sock_tcp_close(&pEC2SockHTTP->nHttpFd);
+	}
+}
+
+
+#endif	//	ARMS_SUPPORT_EC2
+
diff --git a/lynq/S300/ap/app/apparms/apparms_sock.h b/lynq/S300/ap/app/apparms/apparms_sock.h
new file mode 100755
index 0000000..0ffee59
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/apparms_sock.h
@@ -0,0 +1,278 @@
+#ifndef _APPARMS_SOCK_H
+#define _APPARMS_SOCK_H
+
+#include "apparms_macro.h"
+#include "apparms_config_os.h"
+
+#ifdef ARMS_DM_UDP
+#include "apparms_sock_udp.h"
+#endif
+
+#ifdef ARMS_DM_MQTT
+#include "apparms_sock_mqtt.h"
+#endif
+
+#ifdef ARMS_DM_LWM2M
+#include "apparms_sock_lwm2m.h"
+#endif
+
+#ifdef ARMS_FOTA_HTTP
+#ifdef ARMS_FOTA_HTTPS
+#include "apparms_mqtt_api_net.h"
+#endif
+#include "apparms_sock_tcp.h"
+#endif
+
+#ifdef ARMS_SUPPORT_EC2
+#include "apparms_sock_tcp.h"
+#endif
+
+#ifdef ARMS_SUPPORT_DM
+#define ARMS_DM_SOCK_SEND_BUF_SIZE (8*1024)
+#define ARMS_DM_SOCK_RECV_BUF_SIZE (2*1024)
+
+typedef enum _ARMS_DM_SOCK_MODE_
+{
+	ARMS_SOCK_MODE_DM_UDP,
+	ARMS_SOCK_MODE_DM_MQTT,
+	ARMS_SOCK_MODE_DM_LWM2M,
+	ARMS_SOCK_MODE_DM_MAX	
+}ARMS_DM_SOCK_MODE;
+
+typedef struct _tagDMSOCKSEND
+{
+	unsigned char *pSendBuf;	
+	unsigned char szSendBuf[ARMS_DM_SOCK_SEND_BUF_SIZE];
+	
+	int nSendSize;
+	int nUsePBuf;
+}DMSOCKSEND, *PDMSOCKSEND;
+
+typedef struct _tagDMSOCKRECV
+{
+	unsigned char szRecvBuf[ARMS_DM_SOCK_RECV_BUF_SIZE];
+	int nRecvSize;
+}DMSOCKRECV, *PDMSOCKRECV;
+
+#ifdef ARMS_DM_UDP
+typedef struct _tagDMSOCKUDP
+{
+	int nUDPFd;
+
+	char szUDPAddr[ARMS_DM_SRV_ADDR_SIZE];
+	int	 nUDPPort;
+}DMSOCKUDP, *PDMSOCKUDP;
+#endif
+
+#ifdef ARMS_DM_MQTT
+
+typedef enum _tagDMMQTTNWST
+{
+	DM_MQTT_NETWORK_READY,
+	DM_MQTT_NETWORK_ERROR,
+	MD_MQTT_NETWORK_YIELD,
+	MD_MQTT_CONNECT_FAIL
+}DMMQTTNWST;
+
+#define DM_MQTT_TOPIC_RMS 0
+#define DM_MQTT_TOPIC_AGS 1
+#define DM_MQTT_TOPIC_MAX 2 
+	
+typedef struct _tagDMSOCKMQTT
+{
+	//status
+	volatile int mqttexitflag;
+	volatile int mqttInited;
+	volatile DMMQTTNWST mqttnwst;
+	volatile unsigned int nErrCnt;
+	pthread_t dm_mqtt_thread_handle;
+	pthread_attr_t dm_mqtt_thread_attr;
+	pthread_mutex_t dm_mqtt_mutex;
+	ARMS_MQTT_Client client;
+
+	//cfg
+	char szHostAddr[ARMS_DM_SRV_ADDR_SIZE];
+	int	 nHostPort;
+	int  nLiveTime;
+#ifdef ARMS_AUTH_X509
+	char caCert[ARMS_DM_MQTT_CERT_SIZE];
+	char clientCert[ARMS_DM_MQTT_CERT_SIZE];
+	char clientPriKey[ARMS_DM_MQTT_CERT_SIZE];
+#endif
+	char clientID[ARMS_DM_MQTT_USERNAME_SIZE];
+	char password[ARMS_DM_MQTT_PASSWORD_SIZE];
+	char subTopic[DM_MQTT_TOPIC_MAX][ARMS_DM_MQTT_PASSWORD_SIZE];
+	char pubTopic[DM_MQTT_TOPIC_MAX][ARMS_DM_MQTT_PASSWORD_SIZE];
+	int tlsMode;
+	int pubType;
+}DMSOCKMQTT, *PDMSOCKMQTT;
+#endif
+
+#ifdef ARMS_DM_LWM2M
+typedef struct _tagDMSOCKLWM2M
+{
+	//status
+	int lwm2mexitflag;
+	int lwm2mInited;
+	pthread_t dm_lwm2m_thread_handle;
+	pthread_attr_t dm_lwm2m_thread_attr;
+	void *pHandle;
+	atiny_device_info_t demoDeviceInfo;
+	atiny_param_t demoAtinyParams;
+	int cnt;
+
+	//cfg
+	char endpoint_name[ARMS_DM_LWM2M_EPNAME_SIZE];
+	char szHostAddr[ARMS_DM_SRV_ADDR_SIZE];
+	int	 nHostPort;
+	char strHostPort[10];
+}DMSOCKLWM2M, *PDMSOCKLWM2M;
+#endif
+
+
+typedef int (*ARMS_SOCK_DM_RECV_CB)(void*, int);
+
+typedef struct _tagDMSOCK
+{
+	ARMS_DM_SOCK_MODE dmSockMode;
+	ARMS_SOCK_DM_RECV_CB dmsockrecvcb;
+	void* dmsockrecvptr;
+
+	#ifdef ARMS_DM_UDP
+	DMSOCKUDP stsockudp;
+	#endif
+
+	#ifdef ARMS_DM_MQTT
+	DMSOCKMQTT stsockmqtt;
+	#endif
+
+	#ifdef ARMS_DM_LWM2M
+	DMSOCKLWM2M stsocklwm2m;
+	#endif
+		
+	DMSOCKSEND dmsocksend;
+	DMSOCKRECV dmsockrecv;	
+}DMSOCK, *PDMSOCK;
+
+
+int arms_sock_dm_reg_recv_cb(PDMSOCK pDMSock, ARMS_SOCK_DM_RECV_CB cb,void* pApp);
+int arms_sock_dm_send_and_recv_with_server(PDMSOCK pDMSock);
+
+#endif
+
+
+#ifdef ARMS_SUPPORT_FOTA
+#define ARMS_FOTA_SOCK_SEND_BUF_SIZE 2048
+#define ARMS_FOTA_SOCK_RECV_BUF_SIZE 4096
+#define ARMS_SOCK_HTTP_HEADER_BUF_SIZE 512
+
+typedef enum _ARMS_FOTA_SOCK_MODE_
+{
+	ARMS_SOCK_MODE_FOTA_HTTP,
+	ARMS_SOCK_MODE_FOTA_HTTPS,
+	ARMS_SOCK_MODE_FOTA_MAX	
+}ARMS_FOTA_SOCK_MODE;
+
+typedef struct _tagFOTASOCKSEND
+{
+	unsigned char szSendBuf[ARMS_FOTA_SOCK_SEND_BUF_SIZE];	
+	int nSendSize;
+}FOTASOCKSEND, *PFOTASOCKSEND;
+
+typedef struct _tagFOTASOCKRECV
+{
+	unsigned char szRecvBuf[ARMS_FOTA_SOCK_RECV_BUF_SIZE];
+	int nRecvSize;
+}FOTASOCKRECV, *PFOTASOCKRECV;
+
+#ifdef ARMS_FOTA_HTTP
+typedef struct _tagFOTASOCKHTTP
+{
+	int nHttpFd;
+	int nReconnect;
+#ifdef ARMS_FOTA_HTTPS
+	Network networkStack;
+#endif
+	char szHttpAddr[ARMS_HTTP_SRV_ADDR_SIZE];
+	char szHttpPort[ARMS_FOTA_SRV_PORT_SIZE];
+}FOTASOCKHTTP, *PFOTASOCKHTTP;
+#endif
+
+typedef int (*ARMS_SOCK_FOTA_RECV_CB)(void*);
+
+typedef struct _tagFOTASOCK
+{
+	ARMS_FOTA_SOCK_MODE fotaSockMode;
+	ARMS_SOCK_FOTA_RECV_CB fotasockrecvcb;
+	void* fotasockrecvptr;
+
+	#ifdef ARMS_FOTA_HTTP
+	FOTASOCKHTTP stsockhttp;
+	#endif
+		
+	FOTASOCKSEND fotasocksend;
+	FOTASOCKRECV fotasockrecv;	
+}FOTASOCK, *PFOTASOCK;
+
+int arms_sock_fota_reg_recv_cb(PFOTASOCK pFOTASock, ARMS_SOCK_FOTA_RECV_CB cb,void* pApp);
+int arms_sock_fota_send_and_recv_with_server(PFOTASOCK pFOTASock);
+void arms_sock_fota_close(PFOTASOCK pFOTASock);
+#endif
+
+#ifdef ARMS_SUPPORT_EC2
+#define ARMS_EC2_SOCK_SEND_BUF_SIZE 2048
+#define ARMS_EC2_SOCK_RECV_BUF_SIZE 4096
+#define ARMS_EC2_SOCK_HTTP_HEADER_BUF_SIZE 512
+
+typedef struct _tagEC2SOCKSEND
+{
+	unsigned char szSendBuf[ARMS_EC2_SOCK_SEND_BUF_SIZE];	
+	int nSendSize;
+}EC2SOCKSEND, *PEC2SOCKSEND;
+
+typedef struct _tagEC2SOCKRECV
+{
+	unsigned char szRecvBuf[ARMS_EC2_SOCK_RECV_BUF_SIZE];
+	int nRecvSize;
+}EC2SOCKRECV, *PEC2SOCKRECV;
+
+typedef struct _tagEC2SOCKHTTP
+{
+	int nHttpFd;
+	int nReconnect;
+	char szHttpAddr[ARMS_HTTP_SRV_ADDR_SIZE];
+	char szHttpPort[6];
+}EC2SOCKHTTP, *PEC2SOCKHTTP;
+
+typedef int (*ARMS_SOCK_EC2_RECV_CB)(void*);
+
+typedef struct _tagEC2SOCK
+{
+	ARMS_SOCK_EC2_RECV_CB ec2sockrecvcb;
+	void* ec2sockrecvptr;
+
+	EC2SOCKHTTP stsockhttp;
+		
+	EC2SOCKSEND ec2socksend;
+	EC2SOCKRECV ec2sockrecv;	
+}EC2SOCK, *PEC2SOCK;
+
+int arms_sock_ec2_reg_recv_cb(PEC2SOCK pEC2Sock, ARMS_SOCK_EC2_RECV_CB cb,void* pApp);
+int arms_sock_ec2_send_and_recv_by_http(PEC2SOCK pEC2Sock);
+void arms_sock_ec2_close(PEC2SOCK pEC2Sock);
+#endif	//	ARMS_SUPPORT_EC2
+
+
+#ifdef ARMS_SUPPORT_DM
+#ifdef ARMS_DM_MQTT
+int arms_sock_dm_mqtt_start_thread(void* pDM);
+int arms_sock_dm_mqtt_stop_thread(PDMSOCK pDMSock);
+int arms_sock_dm_mqtt_set_networkst(PDMSOCK pDMSock, int nNWOK);
+#endif
+#ifdef ARMS_DM_LWM2M
+int arms_sock_dm_lwm2m_start_thread(PDMSOCK pDMSock);
+int arms_sock_dm_lwm2m_stop_thread(PDMSOCK pDMSock);
+#endif
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/argv/Makefile b/lynq/S300/ap/app/apparms/argv/Makefile
new file mode 100755
index 0000000..0a512c5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/argv/Makefile
@@ -0,0 +1,17 @@
+
+APPARMS_DEFS ?= 
+LOG_STATIC_LIB = libapparmsargv.a
+LOG_LIB_OBJS = apparms_argv.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g -I../ -I../log
+
+CFLAGS += $(APPARMS_DEFS)
+
+all: $(LOG_STATIC_LIB)
+
+$(LOG_STATIC_LIB): $(LOG_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(LOG_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/argv/apparms_argv.c b/lynq/S300/ap/app/apparms/argv/apparms_argv.c
new file mode 100755
index 0000000..dd32f73
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/argv/apparms_argv.c
@@ -0,0 +1,592 @@
+
+#include "apparms_argv.h"
+#include "apparms_log.h"
+
+//FOTA
+#define ARMS_FOTA_DEBUG_SRV_HTTP_ADDR  ""
+#define ARMS_FOTA_DEBUG_SRV_HTTPS_ADDR ""
+#define ARMS_FOTA_COMM_SRV_HTTP_ADDR   "arms-fota-useast1.a-tracs.com"
+#define ARMS_FOTA_COMM_SRV_HTTPS_ADDR  "https://arms-fota-useast1.a-tracs.com"
+
+//DM
+#define ARMS_DM_DEBUG_SRV_MQTT_ADDR    ""
+#define ARMS_DM_DEBUG_SRV_UDP_ADDR     ""
+#define ARMS_DM_DEBUG_SRV_LWM2M_ADDR   ""
+#define ARMS_DM_COMM_SRV_MQTT_ADDR     "arms-mqtt-useast1.a-tracs.com"
+#define ARMS_DM_COMM_SRV_UDP_ADDR      ""
+#define ARMS_DM_COMM_SRV_LWM2M_ADDR    ""
+
+
+static ARMSARGVST g_stArmsArgv =
+{
+	.nArgvSrv = 0
+};
+
+static struct option const arms_argv_options[] = {
+	//log
+	{"level",			required_argument,	NULL, 'l'},
+	{"mode",			required_argument,	NULL, 'm'},
+	{"path",			required_argument,	NULL, 'p'},	
+	{"size",			required_argument,	NULL, 's'},
+	
+	//network	
+	{"server",			required_argument,	NULL, 't'},
+	{"imei",			required_argument,	NULL, 'i'},
+	{"intf",			required_argument,	NULL, 'n'},		
+	{"dmid",			required_argument,	NULL, 'a'},
+	{"dmpw",			required_argument,	NULL, 'b'},
+	{"fotaid",			required_argument,	NULL, 'c'},
+	{"fotapw",			required_argument,	NULL, 'd'},
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+	{"instance",		required_argument,	NULL, 'M'},
+	{"stop",			no_argument,		NULL, 'K'},
+	{"wait",			required_argument,	NULL, 'W'},
+	{"interval",		required_argument,	NULL, 'I'},
+	{"pernum",			required_argument,	NULL, 'N'},
+	{"random",			required_argument,	NULL, 'R'},
+#endif
+
+	//help
+	{"help",			no_argument,		NULL, 'h'},		
+	{NULL,			0, NULL, 0},
+};
+
+static void arms_argv_show_usage(void)
+{
+	printf("Log Options:\n");
+	printf(" -l, --level=(0-4)         The log outpt level error, warning, info etc.\n");
+	printf(" -m, --mode=(0-1)          The log output approach stdio or file.\n");
+	printf(" -p, --path=PATH           The log path in file mode.\n");
+	printf(" -s, --size=ROTATE SIZE    The log rotate size in file mode.\n");
+
+#ifdef ARMS_SUPPORT_ARGV
+	printf("Running Options:\n");
+	printf(" -t, --server=(1-2)        The target server either test or commerical.\n");
+	printf(" -i, --imei=IMEI           The device imei.\n");
+	printf(" -n, --intf=ETHERNET INTF  The ethernet adpater interface name.\n");
+	printf(" -a, --dmid=MDL            The access id for DM.\n");
+	printf(" -b, --dmpw=PASSWORD       The access password for DM.\n");
+	printf(" -c, --fotaid=FOTA         The access id for FOTA.\n");
+	printf(" -d, --fotapw=PASSWORD     The access password for FOTA.\n");
+		
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+	printf(" -M, --instance=num        The multiple instance number.(If need this, it must be the first param!)\n");
+	printf(" -K, --stop                Stop all instance.\n");
+	printf(" -W, --wait=30             Wait 30(sec) to exit the current instance.\n");
+	printf(" -I, --interval=200        The interval(msec) between instance creation.\n");
+	printf(" -N, --pernum=n            Create n instances onetime. (-R, --random should not set)\n");
+	printf(" -R, --random=0            Default 0: no random(create all instances onetime), n: range of create random instances onetime(Minimum 100 units)\n");
+#endif
+
+#endif
+}
+
+PARMSARGVST arms_argv_get_io_pointer(void)
+{
+	return &g_stArmsArgv;	
+}
+
+#ifdef ARMS_SUPPORT_ARGV
+int arms_argv_get_server(void)
+{
+	PARMSARGVST pArgvIO = arms_argv_get_io_pointer();
+
+	if ((pArgvIO->nArgvSrv != ARMS_ARGV_SRV_DEBUG)
+		&& (pArgvIO->nArgvSrv != ARMS_ARGV_SRV_COMM))
+		return 0;
+
+	return pArgvIO->nArgvSrv;
+}
+
+int arms_argv_get_udp_url(char* pBuf, int nSize)
+{
+	int nSrvType;
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	nSrvType = arms_argv_get_server();
+	if (nSrvType <= 0)
+		return 0;
+
+	if (nSrvType == ARMS_ARGV_SRV_COMM)
+	{
+		strncpy(pBuf, ARMS_DM_COMM_SRV_UDP_ADDR, nSize - 1);
+	}
+	else
+	{
+		strncpy(pBuf, ARMS_DM_DEBUG_SRV_UDP_ADDR, nSize - 1);
+	}
+
+	return 1;
+}
+
+int arms_argv_get_mqtt_url(char* pBuf, int nSize)
+{
+	int nSrvType;
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	nSrvType = arms_argv_get_server();
+	if (nSrvType <= 0)
+		return 0;
+
+	if (nSrvType == ARMS_ARGV_SRV_COMM)
+	{
+		strncpy(pBuf, ARMS_DM_COMM_SRV_MQTT_ADDR, nSize - 1);
+	}
+	else
+	{
+		strncpy(pBuf, ARMS_DM_DEBUG_SRV_MQTT_ADDR, nSize - 1);
+	}
+
+	return 1;
+}
+
+int arms_argv_get_lwm2m_url(char* pBuf, int nSize)
+{
+	int nSrvType;
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	nSrvType = arms_argv_get_server();
+	if (nSrvType <= 0)
+		return 0;
+
+	if (nSrvType == ARMS_ARGV_SRV_COMM)
+	{
+		strncpy(pBuf, ARMS_DM_COMM_SRV_LWM2M_ADDR, nSize - 1);
+	}
+	else
+	{
+		strncpy(pBuf, ARMS_DM_DEBUG_SRV_LWM2M_ADDR, nSize - 1);
+	}
+
+	return 1;
+}
+
+int arms_argv_get_fota_url(int nHttps, char* pBuf, int nSize)
+{
+	int nSrvType;
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	nSrvType = arms_argv_get_server();
+	if (nSrvType <= 0)
+		return 0;
+
+	if (nSrvType == ARMS_ARGV_SRV_COMM)
+	{
+		if (nHttps)
+			strncpy(pBuf, ARMS_FOTA_COMM_SRV_HTTPS_ADDR, nSize - 1);
+		else
+			strncpy(pBuf, ARMS_FOTA_COMM_SRV_HTTP_ADDR, nSize - 1);
+	}
+	else
+	{
+		if (nHttps)
+			strncpy(pBuf, ARMS_FOTA_DEBUG_SRV_HTTPS_ADDR, nSize - 1);
+		else
+			strncpy(pBuf, ARMS_FOTA_DEBUG_SRV_HTTP_ADDR, nSize - 1);
+	}
+
+	return 1;
+}
+
+int arms_argv_get_imei(char* pBuf, int nSize)
+{
+	PARMSARGVST pArgvIO = arms_argv_get_io_pointer();
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	if (arms_argv_get_server() <= 0)
+		return 0;
+
+	if (strlen(pArgvIO->szArgvIMEI) <= 0)
+		return -2;
+
+	strncpy(pBuf, pArgvIO->szArgvIMEI, nSize - 1);
+
+	return 1;
+}
+
+int arms_argv_get_intf(char* pBuf, int nSize)
+{
+	PARMSARGVST pArgvIO = arms_argv_get_io_pointer();
+
+	if ((nSize <= 1) || (pBuf == NULL))
+		return -1;
+
+	if (arms_argv_get_server() <= 0)
+		return 0;
+
+	if (strlen(pArgvIO->szArgvINTF) <= 0)
+		return -2;
+
+	strncpy(pBuf, pArgvIO->szArgvINTF, nSize - 1);
+
+	return 1;
+}
+
+int arms_argv_get_dm(unsigned long* pID, char* pPWBuf, int nPWSize)
+{
+	PARMSARGVST pArgvIO = arms_argv_get_io_pointer();
+
+	if ((pID == NULL) || (nPWSize <= 1) || (pPWBuf == NULL))
+		return -1;
+
+	if (arms_argv_get_server() <= 0)
+		return 0;
+
+	if ((strlen(pArgvIO->szArgvDMID) <= 0)
+		|| (strlen(pArgvIO->szArgvDMPW) <= 0))
+		return -2;
+
+	*pID = atol(pArgvIO->szArgvDMID);
+	strncpy(pPWBuf, pArgvIO->szArgvDMPW, nPWSize - 1);
+
+	return 1;
+}
+
+int arms_argv_get_fota(char* pIDBuf, int nIDSize, char* pPWBuf, int nPWSize)
+{
+	PARMSARGVST pArgvIO = arms_argv_get_io_pointer();
+
+	if ((nIDSize <= 1) || (pIDBuf == NULL)
+		|| (nPWSize <= 1) || (pPWBuf == NULL))
+		return -1;
+
+	if (arms_argv_get_server() <= 0)
+		return 0;
+
+	if ((strlen(pArgvIO->szArgvFOTAID) <= 0)
+		|| (strlen(pArgvIO->szArgvFOTAPW) <= 0))
+		return -2;
+
+	strncpy(pIDBuf, pArgvIO->szArgvFOTAID, nIDSize - 1);
+	strncpy(pPWBuf, pArgvIO->szArgvFOTAPW, nPWSize - 1);
+
+	return 1;
+}
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+int arms_argv_run_multi_instance(unsigned int nInstNum,int argc, char *argv[])
+{
+	PARMSARGVST pRunST = &g_stArmsArgv;
+	int i = 0;
+	char strCmd[512] = {0};
+	char strSelfPath[256] = {0};
+	char strParam[128] = {0};
+	char strTmp[32] = {0};
+
+	int nWaitTime = 30;
+	int nInterval_ms = 200;
+	int nTargetNum = 0;
+	int nRandom = 0;
+
+	if(nInstNum <=0 || nInstNum > 100000)
+		return -1;
+
+	while((i = getopt(argc, argv, "l:t:i:n:a:b:c:d:W:I:N:R:")) != EOF)
+	{
+		switch (i)
+		{
+			case 'l':
+			case 't':
+			case 'n':
+			case 'a':
+			case 'b':
+			case 'c':
+			case 'd':
+			case 'W':
+			{
+				memset(strTmp, 0, sizeof(strTmp));
+				sprintf(strTmp, " -%c %s",i,optarg);
+				strcat(strParam, strTmp);
+				if('W' == i)
+				{
+					nWaitTime = atoi(optarg);
+					if(nWaitTime < 30)
+						nWaitTime = 30;
+				}
+			}
+			break;
+			case 'i':
+			{
+				strncpy(pRunST->szArgvIMEI,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+			case 'I':
+			{
+				nInterval_ms = atoi(optarg); 
+				if(nInterval_ms < 0)
+					nInterval_ms = 200;
+			}
+			break;
+			case 'N':
+			{
+				nTargetNum = atoi(optarg); 
+				
+				if(nTargetNum < 0 || nTargetNum > nInstNum)
+					nTargetNum = 0;
+			}
+			case 'R':
+			{
+				nRandom = atoi(optarg); 
+				
+				if(nRandom < 0 || nRandom > nInstNum)
+					nRandom = 0;
+			}
+			break;
+		}
+	}
+
+	printf("%s(%d) imei [%s]\n",__FUNCTION__,__LINE__,pRunST->szArgvIMEI);
+
+	if(strlen(pRunST->szArgvIMEI) != 15)
+		return -2;
+
+	printf("%s(%d) comm param [%s]\n",__FUNCTION__,__LINE__,strParam);
+
+	if(strlen(strParam) > 0)
+	{
+		
+		if(readlink("/proc/self/exe",strSelfPath,256) < 0)
+			strcpy(strSelfPath, "./apparms");
+		printf("%s(%d) selfPath [%s]\n",__FUNCTION__,__LINE__,strSelfPath);
+		
+		for(i = 0; i<nInstNum; i++)
+		{
+			sprintf(strCmd, "%s -i %015llu%s &", strSelfPath, (atoll(pRunST->szArgvIMEI) + i), strParam);
+			printf("%s(%d) cmd [%s]\n",__FUNCTION__,__LINE__,strCmd);
+			system(strCmd);
+
+			if(nInterval_ms > 0)
+				usleep(nInterval_ms*1000);
+
+			if(nTargetNum > 0 || nRandom > 0)
+			{
+				if((i+1) >= nTargetNum)
+				{
+					if(0 != nTargetNum)
+					{
+						printf("%s(%d) [%d] wait %d sec.\n",__FUNCTION__,__LINE__,nTargetNum,nWaitTime);
+						sleep(nWaitTime);
+					}
+
+					if(nRandom > 0)
+					{
+						srand((unsigned)time(NULL));
+						nTargetNum = (rand() % nRandom);
+						if(nTargetNum < 100)	//avoid too small
+							nTargetNum += 100;
+					}
+
+					nTargetNum += i;
+				}
+			}
+		}
+		
+	}
+
+	return 0;
+}
+
+int arms_argv_create_signo_timer_sec(timer_t *timerid, int delay, int re_delay, int signum)
+{
+	struct sigevent evp;  
+	memset(&evp, 0, sizeof(struct sigevent));
+	evp.sigev_signo = signum;
+	evp.sigev_notify = SIGEV_SIGNAL;
+
+	if (timer_create(CLOCK_MONOTONIC, &evp, timerid) == -1)  
+	{  
+		return 0; 
+	}  
+
+	struct itimerspec it;  
+	it.it_interval.tv_sec = re_delay;  
+	it.it_interval.tv_nsec = 0;  
+	it.it_value.tv_sec = delay;  
+	it.it_value.tv_nsec = 0;  
+
+	if (timer_settime(*timerid, 0, &it, NULL) == -1)  
+	{  
+		return 0; 
+	}
+
+	return 1;
+}
+
+#endif
+#endif
+
+void arms_argv_parse_cmdargs(int argc, char *argv[])
+{
+	int i, option_index = 0;
+	PARMSARGVST pRunST = &g_stArmsArgv;
+	PARMSLOGIO pLogIO = arms_log_get_io_pointer();
+
+	pLogIO->arms_log_fd = -1;
+	memset(pLogIO->arms_log_path, 0, ARMS_LOG_PATH_SIZE);
+	memset(&g_stArmsArgv, 0, sizeof(ARMSARGVST));
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+	while((i = getopt_long(argc, argv, "l:m:p:s:t:i:n:a:b:c:d:M:W:I:N:R:Kh", arms_argv_options, &option_index)) != EOF)
+#else	
+	while((i = getopt_long(argc, argv, "l:m:p:s:t:i:n:a:b:c:d:h", arms_argv_options, &option_index)) != EOF)
+#endif
+	{
+		switch (i)
+		{
+			case 'l':
+			{
+				pLogIO->arms_log_level = atoi(optarg);
+				
+				if (pLogIO->arms_log_level < ARMS_LOG_LEVEL_ERROR)
+				{
+					pLogIO->arms_log_level = ARMS_LOG_LEVEL_ERROR;
+				}
+				else if (pLogIO->arms_log_level > ARMS_LOG_LEVEL_ALL)
+				{
+					pLogIO->arms_log_level = ARMS_LOG_LEVEL_ALL;
+				}
+			}
+			break;
+			
+			case 'm':
+			{
+				pLogIO->arms_log_mode = atoi(optarg);
+
+				if ((pLogIO->arms_log_mode > ARMS_LOG_MODE_FILE)
+						|| (pLogIO->arms_log_mode < ARMS_LOG_MODE_STDOUT))
+						pLogIO->arms_log_mode = ARMS_LOG_MODE_STDOUT;
+			}
+			break;			
+			
+			case 'p':
+			{
+				strncpy(pLogIO->arms_log_path, optarg, ARMS_LOG_PATH_SIZE - 1);
+			}
+			break;
+
+			case 's':
+			{
+				pLogIO->arms_log_rotate_size = atoi(optarg);
+
+				if (pLogIO->arms_log_rotate_size == 0)
+				{
+					pLogIO->arms_log_rotate_size = ARMS_LOG_ROTATE_SIZE;
+				}
+				else
+				{
+					pLogIO->arms_log_rotate_size = pLogIO->arms_log_rotate_size * 1024;
+				}
+			}
+			break;
+			
+			case 't':
+			{
+				pRunST->nArgvSrv = atoi(optarg);
+
+				if ((pRunST->nArgvSrv != ARMS_ARGV_SRV_DEBUG)
+					&& (pRunST->nArgvSrv != ARMS_ARGV_SRV_COMM))
+					pRunST->nArgvSrv = ARMS_ARGV_SRV_DEBUG;
+			}
+			break;
+
+			case 'i':
+			{
+				strncpy(pRunST->szArgvIMEI,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+
+			case 'n':
+			{
+				strncpy(pRunST->szArgvINTF,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+
+			case 'a':
+			{
+				strncpy(pRunST->szArgvDMID,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+
+			case 'b':
+			{
+				strncpy(pRunST->szArgvDMPW,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+
+			case 'c':
+			{
+				strncpy(pRunST->szArgvFOTAID,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;
+
+			case 'd':
+			{
+				strncpy(pRunST->szArgvFOTAPW,optarg, ARMS_ARGV_PARA_BUF_SIZE - 1);
+			}
+			break;	
+
+#ifdef ARMS_SUPPORT_TEST_MULTI_INSTANCE
+			case 'M':
+			{
+				unsigned int nInstNum = atoi(optarg);
+				if (nInstNum > 100000)
+					nInstNum = 100000;
+				else if (nInstNum <= 0)
+					nInstNum = 1;
+
+				arms_argv_run_multi_instance(nInstNum, argc, argv);
+				exit(0);
+			}
+			break;
+
+			case 'K':
+			{
+				system("killall apparms 1>/dev/null  2>&1;sleep 1");
+				exit(0);
+			}
+			break;
+
+			case 'W':
+			{
+				timer_t timerid;
+				int wait_sec = 30;
+
+				wait_sec = atoi(optarg);
+				if(wait_sec < 30)
+					wait_sec = 30;
+
+				if(arms_argv_create_signo_timer_sec(&timerid,wait_sec,0,SIGTERM) != 1)
+				{  
+					printf("%s(%d) [%s] fail create timer !\n",__FUNCTION__,__LINE__,pRunST->szArgvIMEI);
+					exit(0);
+				}
+
+				printf("%s(%d) Start a 'SIGTERM' timer, timeout: %d sec !\n",__FUNCTION__,__LINE__,wait_sec);
+			}
+			break;	
+#endif
+
+			case 'h':
+			{
+				arms_argv_show_usage();
+				exit(0);
+			}
+			break;	
+			
+			default:
+			break;
+		}
+	}
+}
+
diff --git a/lynq/S300/ap/app/apparms/argv/apparms_argv.h b/lynq/S300/ap/app/apparms/argv/apparms_argv.h
new file mode 100755
index 0000000..7ff74f5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/argv/apparms_argv.h
@@ -0,0 +1,72 @@
+
+#ifndef _APPARMS_ARGV
+#define _APPARMS_ARGV 1
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+//#include <syslog.h> 
+#include <termios.h> 
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sys/poll.h> 
+#include <stdlib.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <semaphore.h>
+#include <errno.h>
+
+#define ARMS_ARGV_SRV_DEBUG 1
+#define ARMS_ARGV_SRV_COMM 2
+
+#define ARMS_ARGV_PARA_BUF_SIZE 256
+
+typedef struct tagARMSArgvST
+{
+	unsigned int nArgvSrv;
+	char szArgvIMEI[ARMS_ARGV_PARA_BUF_SIZE];
+	char szArgvINTF[ARMS_ARGV_PARA_BUF_SIZE];
+	char szArgvDMID[ARMS_ARGV_PARA_BUF_SIZE];
+	char szArgvDMPW[ARMS_ARGV_PARA_BUF_SIZE];
+	char szArgvFOTAID[ARMS_ARGV_PARA_BUF_SIZE];
+	char szArgvFOTAPW[ARMS_ARGV_PARA_BUF_SIZE];
+} ARMSARGVST, *PARMSARGVST;
+
+PARMSARGVST arms_argv_get_io_pointer(void);
+#ifdef ARMS_SUPPORT_ARGV
+int arms_argv_get_server(void);
+int arms_argv_get_udp_url(char* pBuf, int nSize);
+int arms_argv_get_mqtt_url(char* pBuf, int nSize);
+int arms_argv_get_lwm2m_url(char* pBuf, int nSize);
+int arms_argv_get_fota_url(int nHttps, char* pBuf, int nSize);
+int arms_argv_get_imei(char* pBuf, int nSize);
+int arms_argv_get_intf(char* pBuf, int nSize);
+int arms_argv_get_dm(unsigned long* pID, char* pPWBuf, int nPWSize);
+int arms_argv_get_fota(char* pIDBuf, int nIDSize, char* pPWBuf, int nPWSize);
+#endif
+void arms_argv_parse_cmdargs(int argc, char *argv[]);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/ipatc/Makefile b/lynq/S300/ap/app/apparms/ipatc/Makefile
new file mode 100755
index 0000000..857da78
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/ipatc/Makefile
@@ -0,0 +1,14 @@
+
+IPATC_STATIC_LIB = libapparmsipatc.a
+IPATC_LIB_OBJS = apparms_ipatc.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g -I../ -I../log
+
+all: $(IPATC_STATIC_LIB)
+
+$(IPATC_STATIC_LIB): $(IPATC_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(IPATC_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.c b/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.c
new file mode 100755
index 0000000..def7866
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.c
@@ -0,0 +1,725 @@
+
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/epoll.h>
+#include <sys/un.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <syslog.h>
+#include <sys/queue.h>
+#include <sys/ioctl.h>
+#include <errno.h> 
+#include "apparms_log.h"
+#include "apparms_ipatc.h"
+
+static int arms_ipatc_close_fd(volatile int * pFd)
+{
+	if (pFd == NULL)
+		return -1;
+
+	if (*pFd != APPARMS_IPATC_INVALID_HANDLE)
+	{
+		ARMS_LOG_ERROR(" %s(%d) close fd= [%d]\n",__FUNCTION__,__LINE__, *pFd);				
+		close(*pFd);
+		*pFd = APPARMS_IPATC_INVALID_HANDLE;		
+	}
+
+	return 0;
+}
+
+int arms_ipatc_close_all_client_fd(PSOCKIPATC pTCPPollPara, int nEnd)
+{
+	int nIndex;
+	
+	if (pTCPPollPara == NULL)
+		return -1;
+	
+	if (pTCPPollPara->pIPCCltArr == NULL)
+		return -2;
+	
+	pthread_mutex_lock(&pTCPPollPara->mtx);
+	for (nIndex = 0; nIndex < pTCPPollPara->uMaxclient; nIndex++)
+	{
+		if (pTCPPollPara->pIPCCltArr[nIndex].bUse)
+		{
+			arms_ipatc_close_fd(&pTCPPollPara->pIPCCltArr[nIndex].nCltFd);
+			pTCPPollPara->pIPCCltArr[nIndex].bUse = 0;
+		}
+	}
+	pTCPPollPara->gNumActive = 0;
+	pthread_mutex_unlock(&pTCPPollPara->mtx);
+
+	if (nEnd)
+	{		
+		//if (pTCPPollPara->bDynamimode)
+		{
+			for (nIndex = 0; nIndex < pTCPPollPara->uMaxclient; nIndex++)
+				pthread_cancel(pTCPPollPara->pIPCCltArr[nIndex].ipcclt_thread_handle);
+		}
+		
+		#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+		for (nIndex = 0; nIndex < pTCPPollPara->uMaxclient; nIndex++)
+		{
+
+			sem_destroy(&pTCPPollPara->pIPCCltArr[nIndex].ipcclt_thread_sem);
+		}
+		#endif
+		
+		free(pTCPPollPara->pIPCCltArr);
+		pTCPPollPara->pIPCCltArr = NULL;
+	}
+
+	return 0;
+}
+
+
+static int arms_ipatc_poll_fd(int nFd, int Timeout)
+{
+	int ret, nCount = 1;
+	struct pollfd fds;
+
+	memset(&fds, 0, sizeof(struct pollfd));
+	fds.fd = nFd;
+	fds.events = POLLIN;
+	fds.revents =  0;
+
+	while (nCount > 0)
+	{
+		fds.revents = 0;
+		ret = poll(&fds, 1, Timeout);
+		
+		if (ret < 0)
+		{
+			int nErrno = errno;
+			if (nErrno == EINTR)
+				continue;
+			
+			ARMS_LOG_ERROR(" %s(%d) fd=%d is PollSocketData nErrno=%d. \n",__FUNCTION__,__LINE__, nFd, nErrno);
+			return -2;
+		}
+		else if(ret == 0)
+		{
+			//cusapp_base_printf(CUSAPP_BASE_LOG_LEVEL_1, " %s(%d) PollSocketData nFd=%d, timeoutcount=%d. \n",__FUNCTION__,__LINE__, nFd, nCount);
+			nCount--;
+		}
+		else
+		{		
+			//cusapp_base_printf(CUSAPP_BASE_LOG_LEVEL_5, " %s(%d) PollSocketData fd=%d evntcomes=%d. \n",__FUNCTION__,__LINE__, nFd, fds.revents);
+			
+			if(fds.revents & POLLIN)
+			{
+				return 1;
+			}
+		}
+	}
+
+	return ret;
+}
+
+static int  apparms_ipatc_client_thread_handle(PSOCKIPATC pTCPPollPara, int cfd)
+{
+	int  n = 0, ret = 0;
+
+	if (pTCPPollPara->pSrvTCPCB == NULL)
+	{
+		return -1;
+	}
+	
+	for (n = 0; n < 30; n++)
+	{
+		if (!pTCPPollPara->nLoop)
+			break;
+		
+		ret = arms_ipatc_poll_fd(cfd, 5000);
+		if (ret < 0)
+		{
+			break;
+		}
+		else if (ret == 0)
+		{
+			
+		}
+		else
+		{
+			ret = (*pTCPPollPara->pSrvTCPCB)(cfd);
+			if (ret < 0)
+			{
+				break;
+			}
+
+			n = 0;
+		}
+	}
+	ARMS_LOG_ERROR(" %s(%d) exit n=%d \n",__FUNCTION__,__LINE__, n);
+	
+	return ret ;
+}
+
+//#if defined(SUPPORT_THREAD_POOL_FOR_CLIENT) || defined(SUPPORT_DYNAMIC_OPEN_PORT)
+int arms_ipatc_sem_wait(sem_t* pSem,int nWatiSec)
+{
+	int i, nSegRet, nErrNum;
+	struct timespec segts;
+
+	if (pSem == NULL)
+		return -1;
+
+	if (nWatiSec <= 0)
+		nWatiSec = 1;
+
+	for (i = 0; i < 3; i++)
+	{
+		clock_gettime(CLOCK_REALTIME, &segts);
+		segts.tv_sec += nWatiSec;
+		nSegRet = sem_timedwait(pSem, &segts);
+		nErrNum = errno;
+		if (nSegRet == -1)
+		{
+			if (nErrNum == EINTR)
+			{
+				i = 0;
+				continue;
+			}
+
+			if (nErrNum == ETIMEDOUT)
+				return 0;
+
+			return nErrNum;
+		}
+		
+		break;
+	}
+
+	return 1;
+}
+//#endif
+
+//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+int arms_ipatc_listen_set(PSOCKIPATC pTCPPollPara, int nEnable)
+{	
+	if (pTCPPollPara == NULL)
+		return -1;
+
+	ARMS_LOG_ERROR(" %s(%d) nEnable=%d \n",__FUNCTION__,__LINE__,nEnable);
+	
+	pTCPPollPara->bListenReady = nEnable;
+
+	if (nEnable)
+	{
+		sem_post(&pTCPPollPara->dmipc_thread_sem);
+	}
+	
+	return 0;
+}
+//#endif
+
+static void * arms_ipatc_client_thread_start(void *argument)
+{
+	int *int_args;
+	int  iIndex;
+	int ret;
+	PSOCKIPATC pTCPPollPara = NULL;
+	char szThreadNM[64] = {0};
+	
+	int_args = ((void**)argument)[0];
+	pTCPPollPara = ((void**)argument)[1];
+	iIndex = int_args[0];
+
+	sprintf(szThreadNM, "ipatc_clt_%d", iIndex);
+	prctl(PR_SET_NAME, szThreadNM);
+	
+	pthread_detach(pthread_self());
+
+	if (pTCPPollPara != NULL)
+	{
+		#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+		while (pTCPPollPara->nLoop)
+		{
+			ret = arms_ipatc_sem_wait(&pTCPPollPara->pIPCCltArr[iIndex].ipcclt_thread_sem, 300);
+			if (ret < 0)
+			{
+				ARMS_LOG_ERROR(" %s(%d) client arms_ipatc_sem_wait fail,ret=%d \n",__FUNCTION__,__LINE__,ret);
+				
+				pthread_mutex_lock(&pTCPPollPara->mtx);
+				pTCPPollPara->pIPCCltArr[iIndex].bThreadST = 0;
+				pTCPPollPara->gNumActive--;
+				arms_ipatc_close_fd(&pTCPPollPara->pIPCCltArr[iIndex].nCltFd);
+				pTCPPollPara->pIPCCltArr[iIndex].bUse = 0;
+				sem_destroy(&pTCPPollPara->pIPCCltArr[iIndex].ipcclt_thread_sem);
+				sem_init(&pTCPPollPara->pIPCCltArr[iIndex].ipcclt_thread_sem, 0, 0);
+				pthread_mutex_unlock(&pTCPPollPara->mtx);
+				break;
+			}
+
+			if ((pTCPPollPara->pIPCCltArr[iIndex].nCltFd == APPARMS_IPATC_INVALID_HANDLE) ||
+				(pTCPPollPara->pIPCCltArr[iIndex].bUse == 0))
+				continue;
+		#endif
+		
+			ret = apparms_ipatc_client_thread_handle(pTCPPollPara, pTCPPollPara->pIPCCltArr[iIndex].nCltFd);
+			if(ret != 0)
+				ARMS_LOG_ERROR(" %s(%d) libcusapp_server_ipatc_poll_fd fail,ret=%d \n",__FUNCTION__,__LINE__,ret);
+
+			pthread_mutex_lock(&pTCPPollPara->mtx);
+			pTCPPollPara->gNumActive--;
+			arms_ipatc_close_fd(&pTCPPollPara->pIPCCltArr[iIndex].nCltFd);
+			pTCPPollPara->pIPCCltArr[iIndex].bUse = 0;
+			pthread_mutex_unlock(&pTCPPollPara->mtx);
+			
+			ARMS_LOG_DEBUG(" %s(%d) gNumOfActiveThreads = %d, close iIndex = %d \n",__FUNCTION__,__LINE__, pTCPPollPara->gNumActive, iIndex);
+
+		#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+		}
+		#endif
+		
+	}
+	
+	ARMS_LOG_ERROR(" %s(%d) exit client id = %d \n",__FUNCTION__,__LINE__, iIndex);
+	
+	/* exit this thread  */
+	pthread_exit(NULL);
+	return NULL;
+}
+
+static int arms_ipatc_create_unix_path(PSOCKIPATC pTCPPollPara)
+{
+	struct sockaddr_un  serverAddr;    /* server's socket address          */
+	int local_fd = -1, sockAddrSize;  /* size of socket address structure */
+	unsigned int value = 0x1;
+
+	if (pTCPPollPara->pSrvTCPCB == NULL)
+	{
+		return -10;
+	}
+
+	sockAddrSize = sizeof (struct sockaddr_un);
+	bzero((char *)&serverAddr, sockAddrSize);
+	serverAddr.sun_family      = AF_LOCAL;
+	unlink(pTCPPollPara->szUnixPath);
+	strcpy(serverAddr.sun_path, pTCPPollPara->szUnixPath);
+
+	if((local_fd = socket (AF_UNIX, SOCK_STREAM, 0)) == -1)
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"socket error");
+		return -2;
+	}
+	ARMS_LOG_ERROR(" %s(%d) create local_fd=%d successful\n",__FUNCTION__,__LINE__, local_fd);
+
+	#if 0
+	if (fcntl(local_fd, F_SETFL, fcntl(local_fd, F_GETFD, 0) |O_NONBLOCK) == -1) 
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"Set NON BLock Error");
+		goto ERR_EXIT;
+	}
+	#endif
+	
+	setsockopt(local_fd,SOL_SOCKET,SO_REUSEADDR,(void *)&value,sizeof(value)); 	
+	if(bind (local_fd,(struct sockaddr *)&serverAddr, sockAddrSize) == -1)
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"bind error");
+		goto ERR_EXIT;
+    }
+
+	ARMS_LOG_DEBUG(" %s(%d) %s\n",__FUNCTION__,__LINE__,"start to wait for connection");
+	arms_ipatc_set_sock_buffer(local_fd);
+	if(listen(local_fd, pTCPPollPara->uMaxclient)== -1)
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"listen error");
+		goto ERR_EXIT;
+    }
+
+	pTCPPollPara->gNumActive = 0;
+	if( local_fd != APPARMS_IPATC_INVALID_HANDLE)
+	{
+		pTCPPollPara->nTcpfd = local_fd;
+	}
+
+	ARMS_LOG_DEBUG(" %s(%d) path=%s is finisehd with successful\n",__FUNCTION__,__LINE__, pTCPPollPara->szUnixPath);			
+	return local_fd;
+		
+ERR_EXIT:
+	arms_ipatc_close_fd(&local_fd);
+	
+	ARMS_LOG_DEBUG(" %s(%d) path=%s is finisehd with failed\n",__FUNCTION__,__LINE__, pTCPPollPara->szUnixPath);			
+	return -3;
+}
+
+static int arms_ipatc_create_tcp_path(PSOCKIPATC pTCPPollPara)
+{
+	struct addrinfo  hints;
+	struct addrinfo  *rp;
+	struct addrinfo  *result;
+	int lfd = -1;
+	int optval = 1;
+	int nRecvBuf=64*1024;
+	
+	memset(&hints,0,sizeof(struct addrinfo));
+	hints.ai_family = AF_INET;    /* Allow IPv4 only */
+	hints.ai_socktype = SOCK_STREAM; /* Stream socket */
+   	hints.ai_flags = AI_PASSIVE;    /* For wildcard IP address */
+   	hints.ai_protocol = 0;          /* Any protocol */
+	hints.ai_canonname = NULL;
+   	hints.ai_addr = NULL;
+	hints.ai_next = NULL;
+	
+	if (pTCPPollPara->pSrvTCPCB == NULL)
+	{
+		return -10;
+	}
+
+	arms_ipatc_close_fd(&pTCPPollPara->nTcpfd);
+
+	if (getaddrinfo(NULL, pTCPPollPara->szPort, &hints, &result) != 0)
+	{
+		ARMS_LOG_ERROR( " %s(%d) can't get addrinfo \n",__FUNCTION__,__LINE__);
+		return -2;
+	}
+	
+	for (rp = result; rp != NULL; rp = rp->ai_next) 
+	{
+		lfd = socket(rp->ai_family,rp->ai_socktype,rp->ai_protocol);
+		if (lfd == APPARMS_IPATC_INVALID_HANDLE)
+		{	
+			ARMS_LOG_ERROR(" %s(%d) create socket error \n",__FUNCTION__,__LINE__);
+			continue;   /*  try another socket address  */ 
+		}
+		
+		if (setsockopt(lfd,SOL_SOCKET,SO_REUSEADDR, &optval, sizeof(optval))  == APPARMS_IPATC_INVALID_HANDLE)
+		{
+			ARMS_LOG_ERROR( " %s(%d) can't set socket options (reuse address) \n",__FUNCTION__,__LINE__);
+			arms_ipatc_close_fd(&lfd);
+			return -3;
+		}
+		
+		setsockopt(lfd, SOL_SOCKET, SO_RCVBUF, (const char*)&nRecvBuf, sizeof(int));
+        
+		if (bind(lfd, rp->ai_addr, rp->ai_addrlen) == 0)
+			break;                  /* Success binding socket*/
+		
+		arms_ipatc_close_fd(&lfd);
+	}
+    
+	if (rp == NULL)
+	{
+		ARMS_LOG_ERROR(" %s(%d) can't bind socket  \n",__FUNCTION__,__LINE__);
+		return -4;
+	}
+
+	arms_ipatc_set_sock_buffer(lfd);
+	
+	if (listen(lfd,(pTCPPollPara->uMaxclient)) == -1)
+	{
+		ARMS_LOG_ERROR(" %s(%d) can't listen to socke \n",__FUNCTION__,__LINE__);
+		arms_ipatc_close_fd(&lfd);
+		return -5;
+	}
+
+	pTCPPollPara->gNumActive = 0;
+	if( lfd != APPARMS_IPATC_INVALID_HANDLE)
+	{
+		pTCPPollPara->nTcpfd = lfd;
+	}
+
+	ARMS_LOG_ERROR(" %s(%d) success create server port with fd=%d \n",__FUNCTION__,__LINE__, pTCPPollPara->nTcpfd);
+	freeaddrinfo(result);
+
+	return 0;
+}
+
+static int arms_ipatc_create_path(PSOCKIPATC pTCPPollPara)
+{
+	if (pTCPPollPara == NULL)
+		return -1;
+	
+	if (pTCPPollPara->bUnixmode)
+		return arms_ipatc_create_unix_path(pTCPPollPara);
+
+	return arms_ipatc_create_tcp_path(pTCPPollPara);
+}
+
+static int arms_ipatc_accept_tcp_fd(PSOCKIPATC pTCPPollPara)
+{
+	int cfd;
+	socklen_t addrlen;
+	struct sockaddr_storage claddr;
+	
+	addrlen = sizeof(struct sockaddr_storage);
+	cfd = accept(pTCPPollPara->nTcpfd,(struct sockaddr *)&claddr,&addrlen);
+
+	return cfd;
+}
+
+static int arms_ipatc_accept_unix_fd(PSOCKIPATC pTCPPollPara)
+{
+	int cfd;
+	struct sockaddr_in clientaddr;
+	socklen_t clilen;
+
+	clilen = sizeof(clientaddr);
+	cfd = accept(pTCPPollPara->nTcpfd, (struct sockaddr *)&clientaddr, &clilen);
+
+	return cfd;
+}
+
+static int arms_ipatc_accept_fd(PSOCKIPATC pTCPPollPara)
+{
+	if (pTCPPollPara == NULL)
+		return -1;
+	
+	if (pTCPPollPara->bUnixmode)
+		return arms_ipatc_accept_unix_fd(pTCPPollPara);
+
+	return arms_ipatc_accept_tcp_fd(pTCPPollPara);
+}
+
+static int arms_ipatc_create_client_thread(PSOCKIPATC pTCPPollPara,int i)
+{
+	int rc;
+	void *thread_args[2];
+
+	if (pTCPPollPara == NULL)
+		return -1;
+	
+	thread_args[0] = &i;
+	thread_args[1] = pTCPPollPara;
+	rc = pthread_create(&pTCPPollPara->pIPCCltArr[i].ipcclt_thread_handle, NULL, arms_ipatc_client_thread_start, (void *)thread_args);
+	ARMS_LOG_ERROR( " %s(%d) try to create client thread index=%d, rc = %d \n",__FUNCTION__,__LINE__, i, rc);
+
+#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+	if (rc == 0)
+	{
+		pTCPPollPara->pIPCCltArr[i].bThreadST = 1;
+	}
+	else
+	{
+		pTCPPollPara->pIPCCltArr[i].bThreadST = 0;
+	}
+#endif
+
+	sleep(1);
+
+	return rc;
+}
+
+static void* arms_ipatc_main_loop_handle(void* pIPCSock)
+{	
+	int cfd, iTry, nIndex;
+	PSOCKIPATC pTCPPollPara = (PSOCKIPATC)pIPCSock;
+	//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+	int ret;
+	//#endif
+
+	prctl(PR_SET_NAME, "ipatc_srv");
+
+	if (pTCPPollPara == NULL)
+		return 0;
+	
+	while (pTCPPollPara->nLoop)
+	{
+		//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+		if ((!pTCPPollPara->bListenReady) && pTCPPollPara->bDynamimode) 
+		{
+			ret = arms_ipatc_sem_wait(&pTCPPollPara->dmipc_thread_sem, 300);
+			if (ret < 0)
+			{		
+				sleep(3);
+				continue;
+			}
+		}		
+		//#endif
+		
+		if (pTCPPollPara->nTcpfd == APPARMS_IPATC_INVALID_HANDLE)
+		{
+			//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+				if ((!pTCPPollPara->bListenReady) && pTCPPollPara->bDynamimode)
+					continue;
+			//#endif		
+			
+			/*create socket path first*/
+			for (iTry = 0; iTry < 10; iTry++)
+			{
+				if (arms_ipatc_create_path(pTCPPollPara) >=0)
+					break;
+			}
+			
+			ARMS_LOG_ERROR(" %s(%d) create ipatc succeed iTry=%d, with fd=%d\n",__FUNCTION__,__LINE__, iTry, pTCPPollPara->nTcpfd);
+			if (iTry >= 10)
+			{
+				/*create listen port failed, sleep five mintues and try*/
+				sleep(300);
+				continue;
+			}
+		}
+		
+		cfd = arms_ipatc_accept_fd(pTCPPollPara);
+		ARMS_LOG_ERROR(" %s(%d) accept active = %d, cfd = %d \n",__FUNCTION__,__LINE__, pTCPPollPara->gNumActive, cfd);
+		if (cfd == APPARMS_IPATC_INVALID_HANDLE)
+		{
+			arms_ipatc_close_fd(&pTCPPollPara->nTcpfd);
+			sleep(3);
+			ARMS_LOG_ERROR(" %s(%d) Got error on call to accept(...) \n",__FUNCTION__,__LINE__);
+			continue;
+		}
+
+		do
+		{
+			struct sockaddr_in connectedAddr, peerAddr;
+			socklen_t connectedAddrLen, peerLen;
+			char ipAddr[32] = {0};
+
+			connectedAddrLen = sizeof(connectedAddr);
+			getsockname(cfd, (struct sockaddr *)&connectedAddr, &connectedAddrLen);
+			ARMS_LOG_INFO("conn srv addr = %s:%d\n", inet_ntoa(connectedAddr.sin_addr), ntohs(connectedAddr.sin_port));
+
+			peerLen = sizeof(peerAddr);
+			getpeername(cfd, (struct sockaddr *)&peerAddr, &peerLen); 
+			ARMS_LOG_INFO("conn peer addr = %s:%d\n", inet_ntop(AF_INET, &peerAddr.sin_addr, ipAddr, sizeof(ipAddr)), ntohs(peerAddr.sin_port));
+		}while(0);
+
+		//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+		if ((!pTCPPollPara->bListenReady) && pTCPPollPara->bDynamimode)
+		{
+			arms_ipatc_close_fd(&cfd);
+			arms_ipatc_close_fd(&pTCPPollPara->nTcpfd);
+			sleep(1);
+			continue;
+		}
+		//#endif
+
+		if (fcntl(cfd, F_SETFL, fcntl(cfd, F_GETFD, 0) | O_NONBLOCK) == -1)
+		{
+			ARMS_LOG_ERROR("%s(%d) change accept fd to NONBLOCK failed\n",__FUNCTION__,__LINE__);
+			arms_ipatc_close_fd(&cfd);
+			sleep(1);
+			continue;
+		}
+
+		pthread_mutex_lock(&pTCPPollPara->mtx);
+		if ((pTCPPollPara->gNumActive < pTCPPollPara->uMaxclient)
+			&& (pTCPPollPara->pIPCCltArr != NULL))
+		{
+			for (nIndex = 0; nIndex < pTCPPollPara->uMaxclient; nIndex++)
+			{
+				#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+				/* for some reason, there is exception in thread, recreate*/
+				if (pTCPPollPara->pIPCCltArr[nIndex].bThreadST == 0)
+				{
+					if (0 != arms_ipatc_create_client_thread(pTCPPollPara, nIndex))
+						continue;
+				}
+				#endif
+				
+				if (pTCPPollPara->pIPCCltArr[nIndex].bUse == 0)
+				{
+					pTCPPollPara->gNumActive++;
+					pTCPPollPara->pIPCCltArr[nIndex].bUse = 1;
+					pTCPPollPara->pIPCCltArr[nIndex].nCltFd = cfd;
+					break;
+				}
+			}	
+		}
+		else
+		{
+			nIndex = pTCPPollPara->uMaxclient;
+		}
+		pthread_mutex_unlock(&pTCPPollPara->mtx);
+		
+		ARMS_LOG_DEBUG(" %s(%d) gNumOfActiveThreads = %d, nIndex = %d \n",__FUNCTION__,__LINE__, pTCPPollPara->gNumActive, nIndex);
+
+		if (nIndex < pTCPPollPara->uMaxclient)
+		{
+			int rc;
+			
+			#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+			rc = sem_post(&pTCPPollPara->pIPCCltArr[nIndex].ipcclt_thread_sem);
+			#else
+			rc = arms_ipatc_create_client_thread(pTCPPollPara, nIndex);
+			#endif
+			if (rc == 0)
+				continue;
+		
+		}
+			
+		ARMS_LOG_ERROR(" %s(%d) Too many open connections - ignoring connection from\n",__FUNCTION__,__LINE__);
+		arms_ipatc_close_fd(&cfd);
+	}
+
+	return 0;
+}
+
+int arms_ipatc_start_loop(PSOCKIPATC pTCPPollPara, APPARMSIPATCCLIENTFDCB pCB)
+{
+	int i;
+	
+	if ((pTCPPollPara == NULL) || (pCB == NULL))
+		return -1;
+	
+	pTCPPollPara->pIPCCltArr = malloc(sizeof(SOCKIPATCCLT) * pTCPPollPara->uMaxclient + 1);
+	if (pTCPPollPara->pIPCCltArr == NULL)
+		return -2;
+	
+	pTCPPollPara->nLoop = 1;
+	pTCPPollPara->pSrvTCPCB = pCB;
+	pTCPPollPara->nTcpfd = APPARMS_IPATC_INVALID_HANDLE;
+	pTCPPollPara->gNumActive = 0;
+	pthread_mutex_init(&pTCPPollPara->mtx, NULL);
+
+	//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+	if (pTCPPollPara->bDynamimode)
+	{
+		pTCPPollPara->bListenReady = 0;
+		sem_init(&pTCPPollPara->dmipc_thread_sem, 0, 0);
+	}
+	//#endif
+	
+	for (i = 0; i < pTCPPollPara->uMaxclient; i++)
+	{
+		pTCPPollPara->pIPCCltArr[i].bUse = 0;
+		pTCPPollPara->pIPCCltArr[i].nCltFd = -1;	
+#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+		sem_init(&pTCPPollPara->pIPCCltArr[i].ipcclt_thread_sem, 0, 0);
+		arms_ipatc_create_client_thread(pTCPPollPara, i);
+#endif
+	}
+
+	pthread_attr_init(&pTCPPollPara->dmipc_thread_attr);
+	pthread_attr_setdetachstate (&pTCPPollPara->dmipc_thread_attr, PTHREAD_CREATE_DETACHED);
+	pthread_create(&pTCPPollPara->dmipc_thread_handle, &pTCPPollPara->dmipc_thread_attr, arms_ipatc_main_loop_handle, pTCPPollPara);
+
+	return 0;
+}
+
+int arms_ipatc_stop_loop(PSOCKIPATC pTCPPollPara)
+{	
+	if (pTCPPollPara == NULL)
+		return -1;
+
+	if (pTCPPollPara->nLoop == 0)
+		return -2;
+	
+	pTCPPollPara->nLoop = 0;
+	pthread_cancel(pTCPPollPara->dmipc_thread_handle);	
+	arms_ipatc_close_fd(&pTCPPollPara->nTcpfd);
+	arms_ipatc_close_all_client_fd(pTCPPollPara, 1);
+
+	if (pTCPPollPara->bDynamimode)
+		sem_destroy(&pTCPPollPara->dmipc_thread_sem);
+	
+	pthread_mutex_destroy(&pTCPPollPara->mtx);
+	return 0;
+}
+
+
+
diff --git a/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.h b/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.h
new file mode 100755
index 0000000..271c17a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/ipatc/apparms_ipatc.h
@@ -0,0 +1,98 @@
+#ifndef _APPARMS_IPATC_H
+#define _APPARMS_IPATC_H
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <termios.h> 
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sys/poll.h> 
+#include <stdlib.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/prctl.h>
+
+#define SUPPORT_THREAD_POOL_FOR_CLIENT 1
+//#define SUPPORT_DYNAMIC_OPEN_PORT 1
+
+#define APPARMS_IPATC_INVALID_HANDLE (-1)
+
+#define arms_ipatc_set_sock_buffer(sockfd)  do{  \
+	int nRecvBuf=32*1024; \
+	int nSendBuf=32*1024; \
+	setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,(const char*)&nSendBuf,sizeof(int));  \
+	setsockopt(sockfd,SOL_SOCKET,SO_RCVBUF,(const char*)&nRecvBuf,sizeof(int));  \
+} while(0)
+
+typedef struct tagSOCKIPCATCLIENT
+{
+	volatile unsigned char bUse;
+	volatile int nCltFd;
+	pthread_t ipcclt_thread_handle;	
+#ifdef SUPPORT_THREAD_POOL_FOR_CLIENT
+	volatile unsigned char bThreadST;
+	sem_t ipcclt_thread_sem;
+#endif
+}SOCKIPATCCLT, *PSOCKIPATCCLT;
+
+typedef int (*APPARMSIPATCCLIENTFDCB)(int);
+typedef struct tagSOCKIPATC
+{
+	unsigned char bUnixmode;
+	unsigned char bDynamimode;
+	char szPort[6];
+	char szUnixPath[128];
+	volatile int uMaxclient;
+	
+	int nTcpfd;
+	volatile int nLoop;
+	
+	pthread_attr_t dmipc_thread_attr;
+	pthread_t dmipc_thread_handle;
+	pthread_mutex_t  mtx;
+	volatile int gNumActive;
+	APPARMSIPATCCLIENTFDCB pSrvTCPCB;
+
+	PSOCKIPATCCLT pIPCCltArr;
+
+//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+	volatile unsigned char bListenReady;
+	sem_t dmipc_thread_sem;
+//#endif	
+}SOCKIPATC, *PSOCKIPATC;
+
+int arms_ipatc_start_loop(PSOCKIPATC pTCPPollPara, APPARMSIPATCCLIENTFDCB pCB);
+int arms_ipatc_stop_loop(PSOCKIPATC pTCPPollPara);
+
+int arms_ipatc_close_all_client_fd(PSOCKIPATC pTCPPollPara, int nEnd);
+
+//#ifdef SUPPORT_DYNAMIC_OPEN_PORT
+int arms_ipatc_listen_set(PSOCKIPATC pTCPPollPara, int nEnable);
+//#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/.clang-format b/lynq/S300/ap/app/apparms/json-c/.clang-format
new file mode 100755
index 0000000..365efb2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/.clang-format
@@ -0,0 +1,55 @@
+BasedOnStyle:  LLVM
+# If true, clang-format will attempt to re-flow comments
+ReflowComments: false
+# The column limit.
+ColumnLimit: 100
+# Indent width for line continuations.
+ContinuationIndentWidth: 4
+# The number of columns to use for indentation.
+IndentWidth: 8
+# The number of columns used for tab stops.
+TabWidth: 8
+UseTab: ForIndentation
+
+# Options for aligning backslashes in escaped newlines.
+AlignEscapedNewlines: Left
+# Short Block Style
+AllowShortBlocksOnASingleLine:  true
+# If true, short case labels will be contracted to a single line.
+AllowShortCaseLabelsOnASingleLine: true
+# Dependent on the value, int f() { return 0; } can be put on a single line.
+AllowShortFunctionsOnASingleLine:  Empty
+# The brace breaking style to use.
+BreakBeforeBraces: Custom
+# Control of individual brace wrapping cases.
+BraceWrapping:
+  # Wrap brackets inside of a case
+  AfterCaseLabel: true
+  # Wrap class definition.
+  AfterClass: true
+  # Wrap control statements
+  AfterControlStatement: true
+  # Wrap enum definitions.
+  AfterEnum: true
+  # Wrap function definitions.
+  AfterFunction: true
+  # Wrap namespace definitions.
+  AfterNamespace: true
+  # Wrap struct definitions.
+  AfterStruct: true
+  # Wrap union definitions.
+  AfterUnion: true
+  # Wrap extern blocks.
+  AfterExternBlock: false
+  # Wrap before catch.
+  BeforeCatch: true
+  # Wrap before else.
+  BeforeElse: true
+  # Indent the wrapped braces themselves.
+  IndentBraces:  false
+  # If false, empty function body can be put on a single line.
+  SplitEmptyFunction:  false
+  # If false, empty record (e.g. class, struct or union) body can be put on a single line.
+  SplitEmptyRecord:  false
+  # If false, empty namespace body can be put on a single line.
+  SplitEmptyNamespace:  false
diff --git a/lynq/S300/ap/app/apparms/json-c/.editorconfig b/lynq/S300/ap/app/apparms/json-c/.editorconfig
new file mode 100755
index 0000000..e7fd7e4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/.editorconfig
@@ -0,0 +1,15 @@
+# EditorConfig
+# https://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# LF end-of-line, insert an empty new line and UTF-8
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+
+# Tab indentation
+[makefile,Makefile]
+indent_style = tab
diff --git a/lynq/S300/ap/app/apparms/json-c/.github/ISSUE_TEMPLATE/bug_report.md b/lynq/S300/ap/app/apparms/json-c/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100755
index 0000000..54bed91
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,23 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+Note: for general questions and comments, please use the forums at:
+https://groups.google.com/g/json-c
+
+**Describe the bug**
+A clear and concise description of what the bug is, and any information about where you're running into the bug that you feel might be relevant.
+
+**Steps To Reproduce**
+List the steps to reproduce the behavior.
+If possible, please attach a sample json file and/or a minimal code example.
+
+**Version and Platform**
+- json-c version: [e.g. json-c-0.14, or a specific commit hash]
+- OS: [e.g. Ubuntu 20.04, Debian Buster, NetBSD 9, etc...]
+- Custom cmake/build flags, if any
diff --git a/lynq/S300/ap/app/apparms/json-c/.gitignore b/lynq/S300/ap/app/apparms/json-c/.gitignore
new file mode 100755
index 0000000..4b7da9f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/.gitignore
@@ -0,0 +1,95 @@
+# Temp files
+*~
+*.swp
+*.bak
+*.backup
+\#*
+.\#*
+*\#
+*.sav
+*.save
+*.autosav
+*.autosave
+
+# Tests
+/tests/Makefile
+/tests/test1
+/tests/test1Formatted
+/tests/test2
+/tests/test2Formatted
+/tests/test4
+/tests/testReplaceExisting
+/tests/testSubDir
+/tests/test_cast
+/tests/test_charcase
+/tests/test_compare
+/tests/test_deep_copy
+/tests/test_double_serializer
+/tests/test_float
+/tests/test_int_add
+/tests/test_int_get
+/tests/test_json_pointer
+/tests/test_locale
+/tests/test_null
+/tests/test_parse
+/tests/test_parse_int64
+/tests/test_printbuf
+/tests/test_set_serializer
+/tests/test_set_value
+/tests/test_util_file
+/tests/test_visit
+/tests/*.vg.out
+/tests/*.log
+/tests/*.trs
+
+# Generated folders
+/build
+/Debug
+/Release
+/*/Debug
+/*/Release
+
+# Archives
+*.zip
+*.tar.*
+*.tgz
+*.gz
+*.bz2
+*.xz
+*.lz
+*.lzma
+*.7z
+*.dll
+*.deb
+*.rpm
+*.apk
+*.exe
+*.msi
+*.dmg
+*.ipa
+
+# It's not good practice to build directly in the source tree
+# but ignore cmake auto-generated files anyway:
+/json_config.h
+/json.h
+/config.h
+/json-c.pc
+/Makefile
+/CMakeCache.txt
+/CMakeFiles
+/CMakeDoxyfile.in
+/*.cmake
+/DartConfiguration.tcl
+/tests/CMakeFiles/
+/tests/*.cmake
+/Testing/
+
+# ...and build artifacts.
+/doc/html
+/libjson-c.a
+/libjson-c.so
+/libjson-c.so.*
+
+# Benchmarking input and output
+/bench/data
+/bench/work
diff --git a/lynq/S300/ap/app/apparms/json-c/.travis.yml b/lynq/S300/ap/app/apparms/json-c/.travis.yml
new file mode 100755
index 0000000..769bf4f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/.travis.yml
@@ -0,0 +1,147 @@
+language: cpp
+matrix:
+  include:
+
+#   ubuntu xenial 16.04
+#   gcc 5 is the default on xenial
+    - os: linux
+      dist: xenial
+      compiler: gcc
+      addons:
+        apt:
+          packages:
+            - valgrind
+            - cppcheck
+            - doxygen
+            - cmake
+      env: CHECK="true"
+
+#   ubuntu bionic 18.04
+#   gcc 7 is the default on bionic
+    - os: linux
+      dist: bionic
+      compiler: gcc
+      addons:
+        apt:
+          packages:
+            - valgrind
+            - cppcheck
+            - doxygen
+            - cmake
+      env: CHECK="true"
+
+#   ubuntu focal fossa 20.04
+#   gcc 9 is the default on bionic
+    - os: linux
+      dist: focal
+      compiler: gcc
+      addons:
+        apt:
+          packages:
+            - valgrind
+            - cppcheck
+            - doxygen
+            - cmake
+      env: CHECK="true"
+
+# clang
+#   xenial
+    - os: linux
+      dist: xenial
+      compiler: clang
+      addons:
+        apt:
+          sources:
+            - llvm-toolchain-xenial-6.0
+          packages:
+            - clang-6.0
+            - cmake
+      env: MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
+
+    # clang-7 is the default on focal, xenial and bionic
+    - os: linux
+      dist: focal
+      compiler: clang
+      addons:
+        apt:
+          packages:
+            - valgrind
+            - cppcheck
+            - doxygen
+            - cmake
+      env: CHECK="true"
+
+# osx
+    - os: osx
+      osx_image: xcode13.4
+      env: XCODE="true" CHECK="true"
+
+# run coveralls
+    - os: linux
+      dist: xenial
+      compiler: gcc
+      addons:
+        apt:
+          packages:
+            - lcov
+      env: CHECK="true"
+      before_install:
+        - sudo gem install coveralls-lcov
+        - echo $CC
+        - echo $LANG
+        - echo $LC_ALL
+        - set -e
+        - if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+            eval "${MATRIX_EVAL}";
+            if [ -n "$MATRIX_EVAL" ] && [ "$TRAVIS_COMPILER" != "clang" ]; then
+              sudo apt-get install -y $CC;
+            fi;
+          fi
+      before_script:
+        - export CFLAGS="-fprofile-arcs -ftest-coverage"
+        - mkdir build && cd build && cmake ..
+      script:
+        - make
+        - make test
+      after_success:
+        - cd ..
+        - lcov -d build/ -b . -c -o build/all_coverage.info
+        - lcov -r build/all_coverage.info '/usr/*' '*CMakeFiles*' '*fuzz*' '*test*' -o build/coverage.info
+        - coveralls-lcov --verbose build/coverage.info
+
+#  allow_failures:
+#    - os: osx
+
+before_install:
+  - echo $CC
+  - echo $LANG
+  - echo $LC_ALL
+  - set -e
+  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+      eval "${MATRIX_EVAL}";
+      if [ -n "$MATRIX_EVAL" ] && [ "$TRAVIS_COMPILER" != "clang" ]; then
+        sudo apt-get install -y $CC;
+      fi;
+    fi
+
+before_script:
+  # XXX osx on travis doesn't work w/ set -e, so turn it off :(
+  - set +e
+  - mkdir -p build || echo "Failed to mkdir build"
+  - cd build || echo "Failed to cd build"
+  - cmake .. || echo "Failed to run cmake"
+
+script:
+  - make
+  # when using bionic, Travis seems to ignore the "addons" section, so installing the packages with apt-get...
+  - if [ -n "$CHECK" ]; then
+      if [ "$TRAVIS_OS_NAME" = "osx" ]; then
+        brew install doxygen;
+      else
+        if [ "$TRAVIS_DIST" = "bionic" ]; then
+          sudo apt-get install -y valgrind cppcheck doxygen;
+        fi;
+      fi;
+      make distcheck;
+      if type cppcheck &> /dev/null ; then cppcheck --error-exitcode=1 --quiet *.h *.c tests/ ; fi;
+    fi
diff --git a/lynq/S300/ap/app/apparms/json-c/AUTHORS b/lynq/S300/ap/app/apparms/json-c/AUTHORS
new file mode 100755
index 0000000..b36fa9b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/AUTHORS
@@ -0,0 +1,61 @@
+Alan Coopersmith <alan.coopersmith@oracle.com>
+Alexander Dahl <post@lespocky.de>
+Alexandru Ardelean <ardeleanalex@gmail.com>
+andy5995 <andy400-dev@yahoo.com>
+Aram Poghosyan <Aram.Poghosyan@teamviewer.com>
+Björn Esser <besser82@fedoraproject.org>
+BonsaY <bonsay@posteo.de>
+changyong guo <guo1487@163.com>
+chenguoping <chenguopingdota@163.com>
+Chris Lamb <lamby@debian.org>
+Christopher Head <chead@chead.ca>
+Chris Wolfe <chriswwolfe@gmail.com>
+C. Watford (christopher.watford@gmail.com)
+Darjan Krijan <darjan_krijan@gmx.de>
+David McCann <mccannd@uk.ibm.com>
+DeX77 <dex@dragonslave.de>
+dota17 <chenguopingdota@163.com>
+Eric Haszlakiewicz <erh+git@nimenees.com>
+Eric Hawicz <erh+git@nimenees.com>
+Even Rouault <even.rouault@spatialys.com>
+Gianluigi Tiesi <sherpya@netfarm.it>
+grdowns <grdowns@microsoft.com>
+Hex052 <elijahiff@gmail.com>
+hofnarr <hofnarr@hofnarr.fi>
+ihsinme <61293369+ihsinme@users.noreply.github.com>
+Ivan Romanov <drizt@land.ru>
+Jaap Keuter <jaap.keuter@xs4all.nl>
+Jakov Smolic <jakov.smolic@sartura.hr>
+janczer <menshikov.ivn@gmail.com>
+Jehan <jehan@girinstud.io>
+Jehiah Czebotar <jehiah@gmail.com>
+Jonathan Wiens <j.wiens@teles.com>
+Jose Bollo <jose.bollo@iot.bzh>
+José Bollo <jose.bollo@iot.bzh>
+Juuso Alasuutari <juuso.alasuutari@gmail.com>
+Keith Holman <keith.holman@windriver.com>
+Kizuna-Meraki <z9@kizunameraki.de>
+Leon Gross <leon.gross@rub.de>
+Liang, Gao <liang.gao@intel.com>
+Marc <34656315+MarcT512@users.noreply.github.com>
+max <mpano91@gmail.com>
+Micah Snyder <micasnyd@cisco.com>
+Michael Clark <michael@metaparadigm.com>
+myd7349 <myd7349@gmail.com>
+Pascal Cuoq <cuoq@trust-in-soft.com>
+Pawday <pawday@mail.ru>
+Philosoph228 <philosoph228@gmail.com>
+Pierce Lopez <pierce.lopez@gmail.com>
+Po-Chuan Hsieh <sunpoet@sunpoet.net>
+Ramiro Polla <ramiro.polla@gmail.com>
+Rikard Falkeborn <rikard.falkeborn@gmail.com>
+Robert Bielik <robert.bielik@dirac.com>
+Robert <roby_p97@yahoo.com>
+Rosen Penev <rosenp@gmail.com>
+Rubasri Kalidas <rubasri.kalidas@intel.com>
+Simon McVittie <smcv@collabora.com>
+ssrlive <30760636+ssrlive@users.noreply.github.com>
+Tobias Nießen <tniessen@users.noreply.github.com>
+Tobias Stoeckmann <tobias@stoeckmann.org>
+Tudor Brindus <me@tbrindus.ca>
+Unmanned Player <36690541+unmanned-player@users.noreply.github.com>
diff --git a/lynq/S300/ap/app/apparms/json-c/Android.configure.mk b/lynq/S300/ap/app/apparms/json-c/Android.configure.mk
new file mode 100755
index 0000000..9b09f44
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/Android.configure.mk
@@ -0,0 +1,49 @@
+# This file is the top android makefile for all sub-modules.
+#
+# Suggested settings to build for Android:
+#
+# export PATH=$PATH:/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/
+# export SYSROOT=/opt/android-ndk/platforms/android-9/arch-arm/usr/
+# export LD=arm-linux-androideabi-ld
+# export CC="arm-linux-androideabi-gcc --sysroot=/opt/android-ndk/platforms/android-9/arch-arm"
+#
+# Then run autogen.sh, configure and make.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+json_c_TOP := $(LOCAL_PATH)
+
+JSON_C_BUILT_SOURCES := Android.mk
+
+JSON_C_BUILT_SOURCES := $(patsubst %, $(abspath $(json_c_TOP))/%, $(JSON_C_BUILT_SOURCES))
+
+.PHONY: json-c-configure json-c-configure-real
+json-c-configure-real:
+	echo $(JSON_C_BUILT_SOURCES)
+	cd $(json_c_TOP) ; \
+	$(abspath $(json_c_TOP))/autogen.sh && \
+	CC="$(CONFIGURE_CC)" \
+	CFLAGS="$(CONFIGURE_CFLAGS)" \
+	LD=$(TARGET_LD) \
+	LDFLAGS="$(CONFIGURE_LDFLAGS)" \
+	CPP=$(CONFIGURE_CPP) \
+	CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \
+	PKG_CONFIG_LIBDIR=$(CONFIGURE_PKG_CONFIG_LIBDIR) \
+	PKG_CONFIG_TOP_BUILD_DIR=/ \
+	ac_cv_func_malloc_0_nonnull=yes \
+	ac_cv_func_realloc_0_nonnull=yes \
+	$(abspath $(json_c_TOP))/$(CONFIGURE) --host=$(CONFIGURE_HOST) \
+	--prefix=/system \
+	&& \
+	for file in $(JSON_C_BUILT_SOURCES); do \
+		rm -f $$file && \
+		make -C $$(dirname $$file) $$(basename $$file) ; \
+	done
+
+json-c-configure: json-c-configure-real
+
+PA_CONFIGURE_TARGETS += json-c-configure
+
+-include $(json_c_TOP)/Android.mk
diff --git a/lynq/S300/ap/app/apparms/json-c/CMakeLists.txt b/lynq/S300/ap/app/apparms/json-c/CMakeLists.txt
new file mode 100755
index 0000000..2be027d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/CMakeLists.txt
@@ -0,0 +1,575 @@
+# Many projects still are stuck using CMake 2.8 is several places so it's good to provide backward support too. This is
+# specially true in old embedded systems (OpenWRT and friends) where CMake isn't necessarily upgraded.
+cmake_minimum_required(VERSION 2.8)
+
+if(POLICY CMP0048)
+	cmake_policy(SET CMP0048 NEW)
+endif()
+
+# JSON-C library is C only project.
+if (CMAKE_VERSION VERSION_LESS 3.0)
+	project(json-c)
+	set(PROJECT_VERSION_MAJOR "0")
+	set(PROJECT_VERSION_MINOR "16")
+	set(PROJECT_VERSION_PATCH "99")
+	set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+else()
+	project(json-c LANGUAGES C VERSION 0.16.99)
+endif()
+
+# If we've got 3.0 then it's good, let's provide support. Otherwise, leave it be.
+if(POLICY CMP0038)
+  # Policy CMP0038 introduced was in CMake 3.0
+  cmake_policy(SET CMP0038 NEW)
+endif()
+
+if(POLICY CMP0054)
+    cmake_policy(SET CMP0054 NEW)
+endif()
+
+# set default build type if not specified by user
+if(NOT CMAKE_BUILD_TYPE)
+	set(CMAKE_BUILD_TYPE debug)
+endif()
+
+set(CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} -O2")
+
+# Include file check macros honor CMAKE_REQUIRED_LIBRARIES
+# i.e. the check_include_file() calls will include -lm when checking.
+if(POLICY CMP0075)
+	cmake_policy(SET CMP0075 NEW)
+endif()
+
+include(CTest)
+
+# Set some packaging variables.
+set(CPACK_PACKAGE_NAME              "${PROJECT_NAME}")
+set(CPACK_PACKAGE_VERSION_MAJOR     "${PROJECT_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR     "${PROJECT_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH     "${PROJECT_VERSION_PATCH}")
+set(JSON_C_BUGREPORT                "json-c@googlegroups.com")
+set(CPACK_SOURCE_IGNORE_FILES
+        ${PROJECT_SOURCE_DIR}/build
+        ${PROJECT_SOURCE_DIR}/cmake-build-debug
+        ${PROJECT_SOURCE_DIR}/pack
+        ${PROJECT_SOURCE_DIR}/.idea
+        ${PROJECT_SOURCE_DIR}/.DS_Store
+        ${PROJECT_SOURCE_DIR}/.git
+        ${PROJECT_SOURCE_DIR}/.vscode)
+
+include(CheckSymbolExists)
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckCSourceCompiles)
+include(CheckTypeSize)
+include(CPack)
+include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
+
+option(BUILD_SHARED_LIBS  "Default to building shared libraries" ON)
+option(BUILD_STATIC_LIBS  "Default to building static libraries" ON)
+
+if (BUILD_SHARED_LIBS)
+    add_definitions(-D JSON_C_DLL)
+endif()
+
+# Generate a release merge and test it to verify the correctness of republishing the package.
+ADD_CUSTOM_TARGET(distcheck
+COMMAND make package_source
+    COMMAND tar -xvf "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source.tar.gz"
+    COMMAND mkdir "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
+    COMMAND cmake "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/" -B"./${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build/"
+    COMMAND make -C "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
+    COMMAND make test -C "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
+    COMMAND rm -rf "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source"
+)
+
+# Enable or disable features. By default, all features are turned off.
+option(DISABLE_BSYMBOLIC              "Avoid linking with -Bsymbolic-function."               OFF)
+option(DISABLE_THREAD_LOCAL_STORAGE   "Disable using Thread-Local Storage (HAVE___THREAD)."   OFF)
+option(DISABLE_WERROR                 "Avoid treating compiler warnings as fatal errors."     OFF)
+option(ENABLE_RDRAND                  "Enable RDRAND Hardware RNG Hash Seed."                 OFF)
+option(ENABLE_THREADING               "Enable partial threading support."                     OFF)
+option(OVERRIDE_GET_RANDOM_SEED       "Override json_c_get_random_seed() with custom code."   OFF)
+option(DISABLE_EXTRA_LIBS             "Avoid linking against extra libraries, such as libbsd." OFF)
+option(DISABLE_JSON_POINTER           "Disable JSON pointer (RFC6901) support."               OFF)
+
+
+if (UNIX OR MINGW OR CYGWIN)
+    list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+endif()
+
+if (UNIX)
+    list(APPEND CMAKE_REQUIRED_LIBRARIES   m)
+endif()
+
+if (MSVC)
+    list(APPEND CMAKE_REQUIRED_DEFINITIONS /D_CRT_SECURE_NO_DEPRECATE)
+    list(APPEND CMAKE_REQUIRED_FLAGS /wd4996)
+endif()
+
+if (NOT DISABLE_STATIC_FPIC)
+    # Use '-fPIC'/'-fPIE' option.
+    # This will allow other libraries to statically link in libjson-c.a
+    # which in turn prevents crashes in downstream apps that may use
+    # a different JSON library with identical symbol names.
+    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif()
+
+check_include_file("fcntl.h"        HAVE_FCNTL_H)
+check_include_file("inttypes.h"     HAVE_INTTYPES_H)
+check_include_file(stdarg.h         HAVE_STDARG_H)
+check_include_file(strings.h        HAVE_STRINGS_H)
+check_include_file(string.h         HAVE_STRING_H)
+check_include_file(syslog.h         HAVE_SYSLOG_H)
+
+
+check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+
+check_include_file(unistd.h         HAVE_UNISTD_H)
+check_include_file(sys/types.h      HAVE_SYS_TYPES_H)
+check_include_file(sys/resource.h   HAVE_SYS_RESOURCE_H) # for getrusage
+
+check_include_file("dlfcn.h"        HAVE_DLFCN_H)
+check_include_file("endian.h"       HAVE_ENDIAN_H)
+check_include_file("limits.h"       HAVE_LIMITS_H)
+check_include_file("locale.h"       HAVE_LOCALE_H)
+check_include_file("memory.h"       HAVE_MEMORY_H)
+
+check_include_file(stdint.h         HAVE_STDINT_H)
+check_include_file(stdlib.h         HAVE_STDLIB_H)
+check_include_file(sys/cdefs.h      HAVE_SYS_CDEFS_H)
+check_include_file(sys/param.h      HAVE_SYS_PARAM_H)
+check_include_file(sys/random.h     HAVE_SYS_RANDOM_H)
+check_include_file(sys/stat.h       HAVE_SYS_STAT_H)
+check_include_file(xlocale.h        HAVE_XLOCALE_H)
+
+if (HAVE_INTTYPES_H)
+	# Set a json-c specific var to stamp into json_config.h
+	# in a way that hopefully won't conflict with other
+	# projects that use json-c.
+    set(JSON_C_HAVE_INTTYPES_H 1)
+endif()
+
+check_symbol_exists(_isnan          "float.h" HAVE_DECL__ISNAN)
+check_symbol_exists(_finite         "float.h" HAVE_DECL__FINITE)
+
+if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX)
+    check_symbol_exists(INFINITY    "math.h" HAVE_DECL_INFINITY)
+    check_symbol_exists(isinf       "math.h" HAVE_DECL_ISINF)
+    check_symbol_exists(isnan       "math.h" HAVE_DECL_ISNAN)
+    check_symbol_exists(nan         "math.h" HAVE_DECL_NAN)
+endif()
+
+check_symbol_exists(_doprnt         "stdio.h" HAVE_DOPRNT)
+if (UNIX OR MINGW OR CYGWIN)
+    check_symbol_exists(snprintf    "stdio.h" HAVE_SNPRINTF)
+endif()
+check_symbol_exists(vasprintf       "stdio.h" HAVE_VASPRINTF)
+check_symbol_exists(vsnprintf       "stdio.h" HAVE_VSNPRINTF)
+check_symbol_exists(vprintf         "stdio.h" HAVE_VPRINTF)
+
+check_symbol_exists(arc4random      "stdlib.h" HAVE_ARC4RANDOM)
+if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
+    check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
+    if (HAVE_BSD_STDLIB_H)
+		list(APPEND CMAKE_REQUIRED_LIBRARIES "bsd")
+		unset(HAVE_ARC4RANDOM CACHE)
+        check_symbol_exists(arc4random   "bsd/stdlib.h" HAVE_ARC4RANDOM)
+        if (NOT HAVE_ARC4RANDOM)
+			list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "bsd")
+        endif()
+    endif()
+endif()
+
+if (HAVE_FCNTL_H)
+    check_symbol_exists(open        "fcntl.h" HAVE_OPEN)
+endif()
+if (HAVE_STDLIB_H)
+    check_symbol_exists(realloc     "stdlib.h" HAVE_REALLOC)
+endif()
+if (HAVE_LOCALE_H)
+    check_symbol_exists(setlocale   "locale.h" HAVE_SETLOCALE)
+    check_symbol_exists(uselocale   "locale.h" HAVE_USELOCALE)
+endif()
+
+# uClibc *intentionally* crashes in duplocale(), at least as of:
+# https://github.com/ffainelli/uClibc/blob/266bdc1/libc/misc/locale/locale.c#L1322
+# So, if it looks like we're compiling for a system like that just disable 
+# locale handling entirely.
+exec_program(${CMAKE_C_COMPILER} ARGS -dumpmachine OUTPUT_VARIABLE CMAKE_GNU_C_MACHINE)
+if (CMAKE_GNU_C_MACHINE MATCHES "uclibc")
+	message(STATUS "Detected uClibc compiler, disabling locale handling")
+	set(HAVE_SETLOCALE 0)
+	set(HAVE_USELOCALE 0)
+endif()
+
+if (HAVE_STRINGS_H)
+    check_symbol_exists(strcasecmp  "strings.h" HAVE_STRCASECMP)
+    check_symbol_exists(strncasecmp "strings.h" HAVE_STRNCASECMP)
+endif()
+if (HAVE_STRING_H)
+    check_symbol_exists(strdup      "string.h" HAVE_STRDUP)
+    check_symbol_exists(strerror    "string.h" HAVE_STRERROR)
+endif()
+if (HAVE_SYSLOG_H)
+    check_symbol_exists(vsyslog     "syslog.h" HAVE_VSYSLOG)
+endif()
+if (HAVE_SYS_RANDOM_H)
+    check_symbol_exists(getrandom   "sys/random.h" HAVE_GETRANDOM)
+endif()
+if (HAVE_SYS_RESOURCE_H)
+    check_symbol_exists(getrusage   "sys/resource.h" HAVE_GETRUSAGE)
+endif()
+
+check_symbol_exists(strtoll     "stdlib.h" HAVE_STRTOLL)
+check_symbol_exists(strtoull    "stdlib.h" HAVE_STRTOULL)
+
+set(json_c_strtoll "strtoll")
+if (NOT HAVE_STRTOLL)
+# Use _strtoi64 if strtoll is not available.
+check_symbol_exists(_strtoi64 "stdlib.h" __have_strtoi64)
+if (__have_strtoi64)
+    #set(HAVE_STRTOLL 1)
+    set(json_c_strtoll "_strtoi64")
+endif()
+endif()
+
+set(json_c_strtoull "strtoull")
+if (NOT HAVE_STRTOULL)
+# Use _strtoui64 if strtoull is not available.
+check_symbol_exists(_strtoui64 "stdlib.h" __have_strtoui64)
+if (__have_strtoui64)
+    #set(HAVE_STRTOULL 1)
+    set(json_c_strtoull "_strtoui64")
+endif()
+endif()
+
+
+check_type_size(int                 SIZEOF_INT)
+check_type_size(int64_t             SIZEOF_INT64_T)
+check_type_size(long                SIZEOF_LONG)
+check_type_size("long long"         SIZEOF_LONG_LONG)
+check_type_size("size_t"            SIZEOF_SIZE_T)
+if (MSVC)
+list(APPEND CMAKE_EXTRA_INCLUDE_FILES BaseTsd.h)
+check_type_size("SSIZE_T"           SIZEOF_SSIZE_T)
+else()
+check_type_size("ssize_t"           SIZEOF_SSIZE_T)
+endif()
+
+check_c_source_compiles(
+"
+extern void json_object_get();
+__asm__(\".section .gnu.json_object_get\\n\\t.ascii \\\"Please link against libjson-c instead of libjson\\\"\\n\\t.text\");
+int main(int c, char *v) { return 0;}
+"
+HAS_GNU_WARNING_LONG)
+
+check_c_source_compiles(
+  "int main() { int i, x = 0; i = __sync_add_and_fetch(&x,1); return x; }"
+  HAVE_ATOMIC_BUILTINS)
+
+if (NOT DISABLE_THREAD_LOCAL_STORAGE)
+  check_c_source_compiles(
+    "__thread int x = 0; int main() { return 0; }"
+    HAVE___THREAD)
+
+  if (HAVE___THREAD)
+      set(SPEC___THREAD __thread)
+  elseif (MSVC)
+      set(SPEC___THREAD __declspec(thread))
+  endif()
+endif()
+
+# Hardware random number is not available on Windows? Says, config.h.win32. Best to preserve compatibility.
+if (WIN32)
+    set(ENABLE_RDRAND 0)
+endif()
+
+# Once we've done basic symbol/header searches let's add them in.
+configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in        ${PROJECT_BINARY_DIR}/config.h)
+message(STATUS "Wrote ${PROJECT_BINARY_DIR}/config.h")
+configure_file(${PROJECT_SOURCE_DIR}/cmake/json_config.h.in   ${PROJECT_BINARY_DIR}/json_config.h)
+message(STATUS "Wrote ${PROJECT_BINARY_DIR}/json_config.h")
+
+if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
+	if ("${DISABLE_WERROR}" STREQUAL "OFF")
+	    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Werror")
+	endif()
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wall")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wcast-qual")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wextra")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wwrite-strings")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wno-unused-parameter")
+    if (NOT WIN32)
+        set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} -Wstrict-prototypes")
+    endif()
+
+    add_definitions(-D_GNU_SOURCE)
+elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /DEBUG")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4100")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4996")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4244")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4706")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4702")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4127")
+    set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4701")
+endif()
+
+if (NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"))
+	check_c_source_compiles(
+	"
+	/* uClibc toolchains without threading barf when _REENTRANT is defined */
+	#define _REENTRANT 1
+	#include <sys/types.h>
+	int main (void)
+	{
+	  return 0;
+	}
+	"
+	REENTRANT_WORKS
+	)
+	if (REENTRANT_WORKS)
+		add_compile_options("-D_REENTRANT")
+	endif()
+
+	# OSX Mach-O doesn't support linking with '-Bsymbolic-functions'.
+	# Others may not support it, too.
+	list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions")
+	check_c_source_compiles(
+	"
+	int main (void)
+	{
+	  return 0;
+	}
+	"
+	BSYMBOLIC_WORKS
+	)
+	list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions")
+	if (DISABLE_BSYMBOLIC STREQUAL "OFF" AND BSYMBOLIC_WORKS)
+		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
+		# XXX need cmake>=3.13 for this:
+		#add_link_options("-Wl,-Bsymbolic-functions")
+	endif()
+
+	file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym" "TEST { global: *; };")
+	list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym")
+	check_c_source_compiles(
+	"
+	int main (void)
+	{
+	  return 0;
+	}
+	"
+	VERSION_SCRIPT_WORKS
+	)
+	list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym")
+	if (VERSION_SCRIPT_WORKS)
+		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/json-c.sym")
+	endif()
+endif()
+
+if ($ENV{VALGRIND})
+	# Build so that valgrind doesn't complain about linkhash.c
+    add_definitions(-DVALGRIND=1)
+endif()
+
+set(JSON_C_PUBLIC_HEADERS
+    # Note: config.h is _not_ included here
+    ${PROJECT_BINARY_DIR}/json_config.h
+
+    ${PROJECT_BINARY_DIR}/json.h
+    ${PROJECT_SOURCE_DIR}/arraylist.h
+    ${PROJECT_SOURCE_DIR}/debug.h
+    ${PROJECT_SOURCE_DIR}/json_c_version.h
+    ${PROJECT_SOURCE_DIR}/json_inttypes.h
+    ${PROJECT_SOURCE_DIR}/json_object.h
+    ${PROJECT_SOURCE_DIR}/json_object_iterator.h
+    ${PROJECT_SOURCE_DIR}/json_tokener.h
+    ${PROJECT_SOURCE_DIR}/json_types.h
+    ${PROJECT_SOURCE_DIR}/json_util.h
+    ${PROJECT_SOURCE_DIR}/json_visit.h
+    ${PROJECT_SOURCE_DIR}/linkhash.h
+    ${PROJECT_SOURCE_DIR}/printbuf.h
+)
+
+set(JSON_C_HEADERS
+    ${JSON_C_PUBLIC_HEADERS}
+    ${PROJECT_SOURCE_DIR}/json_object_private.h
+    ${PROJECT_SOURCE_DIR}/random_seed.h
+    ${PROJECT_SOURCE_DIR}/strerror_override.h
+    ${PROJECT_SOURCE_DIR}/strerror_override_private.h
+    ${PROJECT_SOURCE_DIR}/math_compat.h
+    ${PROJECT_SOURCE_DIR}/snprintf_compat.h
+    ${PROJECT_SOURCE_DIR}/strdup_compat.h
+    ${PROJECT_SOURCE_DIR}/vasprintf_compat.h
+)
+
+set(JSON_C_SOURCES
+    ${PROJECT_SOURCE_DIR}/arraylist.c
+    ${PROJECT_SOURCE_DIR}/debug.c
+    ${PROJECT_SOURCE_DIR}/json_c_version.c
+    ${PROJECT_SOURCE_DIR}/json_object.c
+    ${PROJECT_SOURCE_DIR}/json_object_iterator.c
+    ${PROJECT_SOURCE_DIR}/json_tokener.c
+    ${PROJECT_SOURCE_DIR}/json_util.c
+    ${PROJECT_SOURCE_DIR}/json_visit.c
+    ${PROJECT_SOURCE_DIR}/linkhash.c
+    ${PROJECT_SOURCE_DIR}/printbuf.c
+    ${PROJECT_SOURCE_DIR}/random_seed.c
+    ${PROJECT_SOURCE_DIR}/strerror_override.c
+)
+
+if (NOT DISABLE_JSON_POINTER)
+    set(JSON_C_PUBLIC_HEADERS   ${JSON_C_PUBLIC_HEADERS}  ${PROJECT_SOURCE_DIR}/json_pointer.h)
+    set(JSON_C_SOURCES          ${JSON_C_SOURCES}         ${PROJECT_SOURCE_DIR}/json_pointer.c)
+    set(JSON_H_JSON_POINTER "#include \"json_pointer.h\"")
+else()
+    set(JSON_H_JSON_POINTER "")
+endif()
+
+configure_file(json.h.cmakein ${PROJECT_BINARY_DIR}/json.h @ONLY)
+
+include_directories(${PROJECT_SOURCE_DIR})
+include_directories(${PROJECT_BINARY_DIR})
+
+add_subdirectory(doc)
+
+# "uninstall" custom target for make generators in unix like operating systems
+# and if that target is not present
+if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+    if(NOT TARGET uninstall)
+        add_custom_target(uninstall
+                COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm
+                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                )
+    endif()
+endif()
+
+# XXX for a normal full distribution we'll need to figure out
+# XXX how to build both shared and static libraries.
+# Probably leverage that to build a local VALGRIND=1 library for testing too.
+add_library(${PROJECT_NAME}
+    ${JSON_C_SOURCES}
+    ${JSON_C_HEADERS}
+)
+set_target_properties(${PROJECT_NAME} PROPERTIES
+    VERSION 5.2.0
+    SOVERSION 5)
+list(APPEND CMAKE_TARGETS ${PROJECT_NAME})
+# If json-c is used as subroject it set to target correct interface -I flags and allow
+# to build external target without extra include_directories(...)
+target_include_directories(${PROJECT_NAME}
+    PUBLIC
+        $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+        $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
+)
+
+target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_REQUIRED_LIBRARIES})
+
+# Allow to build static and shared libraries at the same time
+if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
+    set(STATIC_LIB ${PROJECT_NAME}-static)
+    add_library(${STATIC_LIB} STATIC
+        ${JSON_C_SOURCES}
+        ${JSON_C_HEADERS}
+    )
+    target_include_directories(${PROJECT_NAME}-static
+        PUBLIC
+            $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+            $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
+    )
+
+	target_link_libraries(${PROJECT_NAME}-static PUBLIC ${CMAKE_REQUIRED_LIBRARIES})
+
+    # rename the static library
+    if (NOT MSVC)
+    set_target_properties(${STATIC_LIB} PROPERTIES
+        OUTPUT_NAME ${PROJECT_NAME}
+    )
+    endif()
+    list(APPEND CMAKE_TARGETS ${STATIC_LIB})
+endif ()
+
+# Always create new install dirs with 0755 permissions, regardless of umask
+set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+	OWNER_READ
+	OWNER_WRITE
+	OWNER_EXECUTE
+	GROUP_READ
+	GROUP_EXECUTE
+	WORLD_READ
+	WORLD_EXECUTE
+   )
+
+install(TARGETS ${CMAKE_TARGETS}
+    EXPORT ${PROJECT_NAME}-targets
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/json-c
+)
+
+install(EXPORT ${PROJECT_NAME}-targets
+    FILE ${PROJECT_NAME}-targets.cmake
+    NAMESPACE ${PROJECT_NAME}::
+    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+)
+
+configure_package_config_file(
+    "cmake/Config.cmake.in"
+    ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
+    INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
+)
+
+install(
+    FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
+    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+)
+
+if (UNIX OR MINGW OR CYGWIN)
+    SET(prefix ${CMAKE_INSTALL_PREFIX})
+    # exec_prefix is prefix by default and CMake does not have the
+    # concept.
+    SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
+    SET(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
+    SET(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+    SET(VERSION ${PROJECT_VERSION})
+
+	# Linking against the static json-c requires
+	# dependent packages to include additional libs:
+	SET(LIBS_LIST ${CMAKE_REQUIRED_LIBRARIES})
+
+	# Note: We would need cmake >= 3.12 in order to use list(TRANSFORM ...)
+	function(list_transform_prepend var prefix)
+		set(temp "")
+		foreach(f ${${var}})
+			list(APPEND temp "${prefix}${f}")
+		endforeach()
+		set(${var} "${temp}" PARENT_SCOPE)
+	endfunction()
+	list_transform_prepend(LIBS_LIST "-l")
+
+	string(REPLACE ";" " " LIBS "${LIBS_LIST}")
+
+    configure_file(json-c.pc.in json-c.pc @ONLY)
+    set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
+    install(FILES ${PROJECT_BINARY_DIR}/json-c.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
+endif ()
+
+install(FILES ${JSON_C_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/json-c)
+
+if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING AND
+   (NOT MSVC OR NOT (MSVC_VERSION LESS 1800)) # Tests need at least VS2013
+   )
+add_subdirectory(tests)
+endif()
+
+if (NOT MSVC)  # cmd line apps don't built on Windows currently.
+add_subdirectory(apps)
+endif()
+
diff --git a/lynq/S300/ap/app/apparms/json-c/COPYING b/lynq/S300/ap/app/apparms/json-c/COPYING
new file mode 100755
index 0000000..740d125
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/COPYING
@@ -0,0 +1,42 @@
+
+Copyright (c) 2009-2012 Eric Haszlakiewicz
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+----------------------------------------------------------------
+
+Copyright (c) 2004, 2005 Metaparadigm Pte Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/lynq/S300/ap/app/apparms/json-c/ChangeLog b/lynq/S300/ap/app/apparms/json-c/ChangeLog
new file mode 100755
index 0000000..5108a9e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/ChangeLog
@@ -0,0 +1,605 @@
+
+0.17 (future release)
+========================================
+
+Deprecated and removed features:
+--------------------------------
+* ...
+
+New features
+------------
+* ...
+
+Significant changes and bug fixes
+---------------------------------
+* When serializing with JSON_C_TO_STRING_PRETTY set, keep the opening and 
+  closing curly or square braces on same line for empty objects or arrays.
+* Disable locale handling when targeting a uClibc system due to problems
+  with its duplocale() function.
+* When parsing with JSON_TOKENER_STRICT set, integer overflow/underflow
+  now result in a json_tokener_error_parse_number.  Without that flag
+  values are capped at INT64_MIN/UINT64_MAX.
+
+
+0.16 (up to commit 66dcdf5, 2022-04-13)
+========================================
+
+Deprecated and removed features:
+--------------------------------
+* JSON_C_OBJECT_KEY_IS_CONSTANT is deprecated in favor of
+  JSON_C_OBJECT_ADD_CONSTANT_KEY
+* Direct access to lh_table and lh_entry structure members is deprecated.  
+  Use access functions instead, lh_table_head(), lh_entry_next(), etc...
+* Drop REFCOUNT_DEBUG code.
+
+New features
+------------
+* The 0.16 release introduces no new features
+
+Build changes
+-------------
+* Add a DISABLE_EXTRA_LIBS option to skip using libbsd
+* Add a DISABLE_JSON_POINTER option to skip compiling in json_pointer support.
+
+Significant changes and bug fixes
+---------------------------------
+* Cap string length at INT_MAX to avoid various issues with very long strings.
+* json_object_deep_copy: fix deep copy of strings containing '\0'
+* Fix read past end of buffer in the "json_parse" command
+* Avoid out of memory accesses in the locally provided vasprintf() function
+  (for those platforms that use it)
+* Handle allocation failure in json_tokener_new_ex
+* Fix use-after-free in json_tokener_new_ex() in the event of printbuf_new() returning NULL
+* printbuf_memset(): set gaps to zero - areas within the print buffer which
+  have not been initialized by using printbuf_memset
+* printbuf: return -1 on invalid arguments (len < 0 or total buffer > INT_MAX)
+* sprintbuf(): propagate printbuf_memappend errors back to the caller
+
+Optimizations
+--------------
+* Speed up parsing by replacing ctype functions with simplified, faster 
+  non-locale-sensitive ones in json_tokener and json_object_to_json_string.
+* Neither vertical tab nor formfeed are considered whitespace per the JSON spec
+* json_object: speed up creation of objects, calloc() -> malloc() + set fields
+* Avoid needless extra strlen() call in json_c_shallow_copy_default() and
+  json_object_equal() when the object is known to be a json_type_string.
+
+Other changes
+-------------
+* Validate size arguments in arraylist functions.
+* Use getrandom() if available; with GRND_NONBLOCK to allow use of json-c
+  very early during boot, such as part of cryptsetup.
+* Use arc4random() if it's available.
+* random_seed: on error, continue to next method instead of exiting the process
+* Close file when unable to read from /dev/urandom in get_dev_random_seed()
+
+***
+
+0.15 (up to commit 870965e, 2020/07/26)
+========================================
+
+Deprecated and removed features:
+--------------------------------
+* Deprecate `array_list_new()` in favor of `array_list_new2()`
+* Remove the THIS_FUNCTION_IS_DEPRECATED define.
+* Remove config.h.win32
+
+New features
+------------
+* Add a `JSON_TOKENER_ALLOW_TRAILING_CHARS` flag to allow multiple objects
+  to be parsed even when `JSON_TOKENER_STRICT` is set.
+* Add `json_object_new_array_ext(int)` and `array_list_new_2(int)` to allow
+   arrays to be allocated with the exact size needed, when known.
+* Add `json_object_array_shrink()` (and `array_list_shrink()`) and use it in 
+   json_tokener to minimize the amount of memory used.
+* Add a json_parse binary, for use in testing changes (not installed, but 
+   available in the apps directory).
+
+Build changes
+-------------
+* #639/#621 - Add symbol versions to all exported symbols
+* #508/#634 - Always enable -fPIC to allow use of the json-c static library in
+   other libraries
+* Build both static and shared libraries at the same time.
+* #626 - Restore compatibility with cmake 2.8 
+* #471 - Always create directories with mode 0755, regardless of umask.
+* #606/#604 - Improve support for OSes like AIX and IBM i, as well as for
+   MINGW32 and old versions of MSVC
+* #451/#617 - Add a DISABLE_THREAD_LOCAL_STORAGE cmake option to disable 
+   the use of thread-local storage.
+
+Significant changes and bug fixes
+---------------------------------
+* Split the internal json_object structure into several sub-types, one for
+   each json_type (json_object_object, json_object_string, etc...).
+  This improves memory usage and speed, with the benchmark under
+   bench/ report 5.8% faster test time and 6%(max RSS)-12%(peak heap)
+   less memory usage.
+  Memory used just for json_object structures decreased 27%, so use cases
+   with fewer arrays and/or strings would benefit more.
+* Minimize memory usage in array handling in json_tokener by shrinking
+   arrays to the exact number of elements parsed.  On bench/ benchmark:
+   9% faster test time, 39%(max RSS)-50%(peak heap) less memory usage.
+   Add json_object_array_shrink() and array_list_shrink() functions.
+* #616 - Parsing of surrogate pairs in unicode escapes now properly handles
+   incremental parsing.
+* Fix incremental parsing of numbers, especially those with exponents, e.g.
+   so parsing "[0", "e+", "-]" now properly returns an error.
+  Strict mode now rejects missing exponents ("0e").
+* Successfully return number objects at the top level even when they are
+   followed by a "-", "." or "e".  This makes parsing things like "123-45"
+   behave consistently with things like "123xyz".
+
+Other changes
+-------------
+* #589 - Detect broken RDRAND during initialization; also, fix segfault
+    in the CPUID check.
+* #592 - Fix integer overflows to prevert out of bounds write on large input.
+* Protect against division by zero in linkhash, when created with zero size.
+* #602 - Fix json_parse_uint64() internal error checking, leaving the retval
+    untouched in more failure cases.
+* #614 - Prevent truncation when custom double formatters insert extra \0's
+
+
+***
+
+0.14 (up to commit 9ed00a6, 2020/04/14)
+=========================================
+
+Deprecated and removed features:
+--------------------------------
+* bits.h has been removed
+* lh_abort() has been removed
+* lh_table_lookup() has been removed, use lh_table_lookup_ex() instead.
+* Remove TRUE and FALSE defines, use 1 and 0 instead.
+
+Build changes:
+--------------
+## Deprecated and removed features:
+* bits.h has been removed
+* lh_abort() has been removed
+* lh_table_lookup() has been removed, use lh_table_lookup_ex() instead.
+* Remove TRUE and FALSE defines, use 1 and 0 instead.
+* autoconf support, including autogen.sh, has been removed.  See details about cmake, below.
+* With the addition of json_tokener_get_parse_end(), access to internal fields of json_tokener, as well as use of many other symbols and types in json_tokener.h, is deprecated now.
+* The use of Android.configure.mk to build for Android no longer works, and it is unknown how (or if) the new cmake-based build machinery can be used.
+    * Reports of success, or pull requests to correct issues are welcome.
+
+## Notable improvements and new features
+
+### Builds and documentation
+* Build machinery has been switched to CMake.  See README.md for details about how to build.
+    * TL;DR: `mkdir build ; cd build ; cmake -DCMAKE_INSTALL_PREFIX=/some/path ../json-c ; make all test install`
+    * To ease the transition, there is a `cmake-configure` wrapper that emulates the old autoconf-based configure script.
+    * This has enabled improvements to the build on Windows system; also all public functions have been fixed to be properly exported.  For best results, use Visual Studio 2015 or newer.
+* The json-c style guide has been updated to specify the use of clang-format, and all code has been reformatted.
+    * Since many lines of code have trivial changes now, when using git blame, be sure to specify -w
+* Numerous improvements have been made to the documentation including function effects on refcounts, when passing a NULL is safe, and so on.
+
+### json_tokener changes
+* Added a json_tokener_get_parse_end() function to replace direct access of tok->char_offset.
+    * The char_offset field, and the rest of the json_tokener structure remain exposed for now, but expect a future release to hide it like is done with json_object_private.h
+* json_tokener_parse_ex() now accepts a new JSON_TOKENER_VALIDATE_UTF8 flag to validate that input is UTF8.
+    * If validation fails, json_tokener_get_error(tok) will return json_tokener_error_parse_utf8_string (see enum json_tokener_error).
+
+### Other changes and additions
+* Add support for unsigned 64-bit integers, uint64_t, to gain one extra bit of magnitude for positive ints.
+    * json_tokener will now parse values up to UINT64_MAX (18446744073709551615)
+    * Existing methods returning int32_t or int64_t will cap out-of-range values at INT32_MAX or INT64_MAX, preserving existing behavior.
+    * The implementation includes the possibility of easily extending this to larger sizes in the future.
+* A total of 7 new functions were added:
+    * json_object_get_uint64 ( struct json_object const* jso )
+    * json_object_new_uint64 ( uint64_t i )
+    * json_object_set_uint64 ( struct json_object* jso, uint64_t new_value )
+    * json_parse_uint64 ( char const* buf, uint64_t* retval )
+        * See description of uint64 support, above.
+    * json_tokener_get_parse_end ( struct json_tokener* tok )
+        * See details under "json_tokener changes", above.
+    * json_object_from_fd_ex ( int fd, int in_depth )
+        * Allows the max nesting depth to be specified.
+    * json_object_new_null ( )
+        * Simply returns NULL.  Its use is not recommended.
+* The size of struct json_object has decreased from 96 bytes to 88 bytes.
+
+### Testing
+* Many updates were made to test cases, increasing code coverage.
+* There is now a quick way (JSONC_TEST_TRACE=1) to turn on shell tracing in tests.
+* To run tests, use `make test`; the old "check" target no longer exists.
+
+## Significant bug fixes
+For the full list of issues and pull requests since the previous release, please see issues_closed_for_0.14.md
+
+* [Issue #389](https://github.com/json-c/json-c/issues/389): Add an assert to explicitly crash when _ref_count is corrupted, instead of a later "double free" error.
+* [Issue #407](https://github.com/json-c/json-c/issues/407): fix incorrect casts in calls to ctype functions (isdigit and isspace) so we don't crash when asserts are enabled on certain platforms and characters > 128 are parsed.
+* [Issue #418](https://github.com/json-c/json-c/issues/418): Fix docs for json_util_from_fd and json_util_from_file to say that they return NULL on failures.
+* [Issue #422](https://github.com/json-c/json-c/issues/422): json_object.c:set errno in json_object_get_double() when called on a json_type_string object with bad content.
+* [Issue #453](https://github.com/json-c/json-c/issues/453): Fixed misalignment in JSON serialization when JSON_C_TO_STRING_SPACED and JSON_C_TO_STRING_PRETTY are used together.
+* [Issue #463](https://github.com/json-c/json-c/issues/463): fix newlocale() call to use LC_NUMERIC_MASK instead of LC_NUMERIC, and remove incorrect comment.
+* [Issue #486](https://github.com/json-c/json-c/issues/486): append a missing ".0" to negative double values to ensure they are serialized as floating point numbers.
+* [Issue #488](https://github.com/json-c/json-c/issues/488): use JSON_EXPORT on functions so they are properly exported on Windows.
+* [Issue #539](https://github.com/json-c/json-c/issues/539): use an internal-only serializer function in json_object_new_double_s() to avoid potential conflicts with user code that uses the json_object_userdata_to_json_string serializer.
+
+***
+
+0.13.1 (up to commit 0f814e5, 2018/03/04)
+=========================================
+
+* Bump the major version of the .so library generated up to 4.0 to avoid
+  conflicts because some downstream packagers of json-c had already done
+  their own bump to ".so.3" for a much older 0.12 release.
+* Add const size_t json_c_object_sizeof()
+* Avoid invalid free (and thus a segfault) when ref_count gets < 0
+* PR#394: fix handling of custom double formats that include a ".0"
+* Avoid uninitialized variable warnings in json_object_object_foreach
+* Issue #396: fix build for certain uClibc based systems.
+* Add a top level fuzz directory for fuzzers run by OSS-Fuzz
+
+
+0.13 (up to commit 5dae561, 2017/11/29)
+=================================
+
+This release, being three and a half years after the 0.12 branch (f84d9c),
+   has quite a number of changes included.  The following is a sampling of
+   the most significant ones.
+
+Since the 0.12 release, 250 issues and pull requests have been closed.
+See issues_closed_for_0.13.md for a complete list.
+
+
+Deprecated and removed features:
+--------------------------------
+* All internal use of bits.h has been eliminated.  The file will be removed.
+	Do not use: hexdigit(), error_ptr(), error_descrition() and it_error()
+* lh_abort() is deprecated.  It will be removed.
+
+Behavior changes:
+-----------------
+* Tighten the number parsing algorithm to raise errors instead of truncating
+     the results.  For example 12.3.4 or 2015-01-15, which now return null.
+	 See commit 99d8fc
+
+* Use size_t for array length and size.  Platforms where sizeof(size_t) != sizeof(int) may not be backwards compatible
+	See commits 45c56b, 92e9a5 and others.
+
+* Check for failure when allocating memory, returning NULL and errno=ENOMEM.
+	 See commit 2149a04.
+
+* Change json_object_object_add() return type from void to int, and will return -1 on failures, instead of exiting. (Note: this is not an ABI change)
+
+New features:
+-------------
+* We're aiming to follow RFC 7159 now.
+
+* Add a couple of additional option to json_object_to_json_string_ext:
+	JSON_C_TO_STRING_PRETTY_TAB
+	JSON_C_TO_STRING_NOSLASHESCAPE
+
+* Add a json_object_object_add_ex() function to allow for performance
+	improvements when certain constraints are known to be true.
+
+* Make serialization format of doubles configurable, in two different ways:
+	Call json_object_set_serializer with json_object_double_to_json_string and a custom
+	 format on each double object, or
+	Call json_c_set_serialization_double_format() to set a global or thread-wide format.
+
+* Add utility function for comparing json_objects - json_object_equal()
+
+* Add a way to copy entire object trees: json_object_deep_copy()
+* Add json_object_set_<type> function to modify the value of existing json_object's
+ without the need to recreate them.  Also add a json_object_int_inc function to
+ adjust an int's value.
+* Add support for JSON pointer, RFC 6901.  See json_pointer.h
+* Add a json_util_get_last_err() function to retrieve the string describing the
+ cause of errors, instead of printing to stderr.
+* Add perllike hash function for strings, and json_global_set_string_hash() 8f8d03d
+* Add a json_c_visit() function to provide a way to iterate over a tree of json-c objects.
+
+Notable bug fixes and other improvements:
+-----------------------------------------
+* Make reference increment and decrement atomic to allow passing json objects between threads.
+* Fix json_object_object_foreach to avoid uninitialized variable warnings.
+* Improve performance by removing unneeded data items from hashtable code and reducing duplicate hash computation.
+* Improve performance by storing small strings inside json_object
+* Improve performance of json_object_to_json_string by removing variadic printf. commit 9ff0f49
+* Issue #371: fix parsing of "-Infinity", and avoid needlessly copying the input when doing so.
+* Fix stack buffer overflow in json_object_double_to_json_string_format() - commit 2c2deb87
+* Fix various potential null ptr deref and int32 overflows
+* Issue #332: fix a long-standing bug in array_list_put_idx() where it would attempt to free previously free'd entries due to not checking the current array length.
+* Issue #195: use uselocale() instead of setlocale() in json_tokener to behave better in threaded environments.
+* Issue #275: fix out of bounds read when handling unicode surrogate pairs.
+* Ensure doubles that happen to be a whole number are emitted with ".0" - commit ca7a19
+* PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the string is terminated.
+* Fix double to int cast overflow in json_object_get_int64.
+* Clamp double to int32 when narrowing in json_object_get_int.
+* Use strtoll() to parse ints - instead of sscanf
+* Miscellaneous smaller changes, including removing unused variables, fixing warning
+ about uninitialized variables adding const qualifiers, reformatting code, etc...
+
+Build changes:
+--------------
+* Add Appveyor and Travis build support
+* Switch to using CMake when building on Windows with Visual Studio.
+	A dynamic .dll is generated instead of a .lib
+	config.h is now generated, config.h.win32 should no longer be manually copied
+* Add support for MacOS through CMake too.
+* Enable silent build by default
+* Link against libm when needed
+* Add support for building with AddressSanitizer
+* Add support for building with Clang
+* Add a --enable-threading configure option, and only use the (slower) __sync_add_and_fetch()/__sync_sub_and_fetch() function when it is specified.
+
+List of new functions added:
+----------------------------
+### json_object.h
+* array_list_bsearch()
+* array_list_del_idx()
+* json_object_to_json_string_length()
+* json_object_get_userdata()
+* json_object_set_userdata()
+* json_object_object_add_ex()
+* json_object_array_bsearch()
+* json_object_array_del_idx()
+* json_object_set_boolean()
+* json_object_set_int()
+* json_object_int_inc()
+* json_object_set_int64()
+* json_c_set_serialization_double_format()
+* json_object_double_to_json_string()
+* json_object_set_double()
+* json_object_set_string()
+* json_object_set_string_len()
+* json_object_equal()
+* json_object_deep_copy()
+
+### json_pointer.h
+* json_pointer_get()
+* json_pointer_getf()
+* json_pointer_set()
+* json_pointer_setf()
+
+### json_util.h
+* json_object_from_fd()
+* json_object_to_fd()
+* json_util_get_last_err()
+
+### json_visit.h
+* json_c_visit()
+
+### linkhash.h
+* json_global_set_string_hash()
+* lh_table_resize()
+
+### printbuf.h
+* printbuf_strappend()
+
+
+0.12.1
+======
+
+  * Minimal changes to address compile issues.
+
+0.12
+====
+
+  * Address security issues:
+    * CVE-2013-6371: hash collision denial of service
+    * CVE-2013-6370: buffer overflow if size_t is larger than int
+
+  * Avoid potential overflow in json_object_get_double
+
+  * Eliminate the mc_abort() function and MC_ABORT macro.
+
+  * Make the json_tokener_errors array local.  It has been deprecated for
+     a while, and json_tokener_error_desc() should be used instead.
+
+  * change the floating point output format to %.17g so values with
+     more than 6 digits show up in the output.
+
+  * Remove the old libjson.so name compatibility support.  The library is
+      only created as libjson-c.so now and headers are only installed
+      into the ${prefix}/json-c directory.
+
+  * When supported by the linker, add the -Bsymbolic-functions flag.
+
+  * Various changes to fix the build on MSVC.
+
+  * Make strict mode more strict:
+    * number must not start with 0
+    * no single-quote strings
+    * no comments
+    * trailing char not allowed
+    * only allow lowercase literals
+
+  * Added a json_object_new_double_s() convenience function to allow
+    an exact string representation of a double to be specified when
+    creating the object and use it in json_tokener_parse_ex() so
+    a re-serialized object more exactly matches the input.
+
+  * Add support NaN and Infinity
+
+
+0.11
+====
+
+  * IMPORTANT: the name of the library has changed to libjson-c.so and
+     the header files are now in include/json-c.
+     The pkgconfig name has also changed from json to json-c.
+     You should change your build to use appropriate -I and -l options.
+     A compatibility shim is in place so builds using the old name will
+     continue to work, but that will be removed in the next release.
+  * Maximum recursion depth is now a runtime option.
+     json_tokener_new() is provided for compatibility.
+     json_tokener_new_ex(depth)
+  * Include json_object_iterator.h in the installed headers.
+  * Add support for building on Android.
+  * Rewrite json_object_object_add to replace just the value if the key already exists so keys remain valid.
+  * Make it safe to delete keys while iterating with the json_object_object_foreach macro.
+  * Add a json_set_serializer() function to allow the string output of a json_object to be customized.
+  * Make float parsing locale independent.
+  * Add a json_tokener_set_flags() function and a JSON_TOKENER_STRICT flag.
+  * Enable -Werror when building.
+  * speed improvements to parsing 64-bit integers on systems with working sscanf
+  * Add a json_object_object_length function.
+  * Fix a bug (buffer overrun) when expanding arrays to more than 64 entries.
+
+0.10
+====
+
+  * Add a json_object_to_json_string_ext() function to allow output to be
+     formatted in a more human readable form.
+  * Add json_object_object_get_ex(), a NULL-safe get object method, to be able
+     to distinguish between a key not present and the value being NULL.
+  * Add an alternative iterator implementation, see json_object_iterator.h
+  * Make json_object_iter public to enable external use of the
+     json_object_object_foreachC macro.
+  * Add a printbuf_memset() function to provide an efficient way to set and
+     append things like whitespace indentation.
+  * Adjust json_object_is_type and json_object_get_type so they return
+      json_type_null for NULL objects and handle NULL passed to
+      json_objct_object_get().
+  * Rename boolean type to json_bool.
+  * Fix various compile issues for Visual Studio and MinGW.
+  * Allow json_tokener_parse_ex() to be re-used to parse multiple object.
+     Also, fix some parsing issues with capitalized hexadecimal numbers and
+     number in E notation.
+  * Add json_tokener_get_error() and json_tokener_error_desc() to better
+     encapsulate the process of retrieving errors while parsing.
+  * Various improvements to the documentation of many functions.
+  * Add new json_object_array_sort() function.
+  * Fix a bug in json_object_get_int(), which would incorrectly return 0
+    when called on a string type object.
+    Eric Haszlakiewicz
+  * Add a json_type_to_name() function.
+    Eric Haszlakiewicz
+  * Add a json_tokener_parse_verbose() function.
+    Jehiah Czebotar
+  * Improve support for null bytes within JSON strings.
+    Jehiah Czebotar
+  * Fix file descriptor leak if memory allocation fails in json_util
+    Zachary Blair, zack_blair at hotmail dot com
+  * Add int64 support. Two new functions json_object_net_int64 and
+    json_object_get_int64. Binary compatibility preserved.
+    Eric Haszlakiewicz, EHASZLA at transunion com
+    Rui Miguel Silva Seabra, rms at 1407 dot org
+  * Fix subtle bug in linkhash where lookup could hang after all slots
+    were filled then successively freed.
+    Spotted by Jean-Marc Naud, j dash m at newtraxtech dot com
+  * Make json_object_from_file take const char *filename
+    Spotted by Vikram Raj V, vsagar at attinteractive dot com
+  * Add handling of surrogate pairs (json_tokener.c, test4.c, Makefile.am)
+    Brent Miller, bdmiller at yahoo dash inc dot com
+  * Correction to comment describing printbuf_memappend in printbuf.h
+    Brent Miller, bdmiller at yahoo dash inc dot com
+
+0.9
+===
+  * Add README.html README-WIN32.html config.h.win32 to Makefile.am
+    Michael Clark, <michael@metaparadigm.com>
+  * Add const qualifier to the json_tokener_parse functions
+    Eric Haszlakiewicz, EHASZLA at transunion dot com
+  * Rename min and max so we can never clash with C or C++ std library
+    Ian Atha, thatha at yahoo dash inc dot com
+  * Fix any noticeable spelling or grammar errors.
+  * Make sure every va_start has a va_end.
+  * Check all pointers for validity.
+    Erik Hovland, erik at hovland dot org
+  * Fix json_object_get_boolean to return false for empty string
+    Spotted by Vitaly Kruglikov, Vitaly dot Kruglikov at palm dot com
+  * optimizations to json_tokener_parse_ex(), printbuf_memappend()
+    Brent Miller, bdmiller at yahoo dash inc dot com
+  * Disable REFCOUNT_DEBUG by default in json_object.c
+  * Don't use this as a variable, so we can compile with a C++ compiler
+  * Add casts from void* to type of assignment when using malloc
+  * Add #ifdef __cplusplus guards to all of the headers
+  * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table
+    Michael Clark, <michael@metaparadigm.com>
+  * Null pointer dereference fix. Fix json_object_get_boolean strlen test
+    to not return TRUE for zero length string. Remove redundant includes.
+    Erik Hovland, erik at hovland dot org
+  * Fixed warning reported by adding -Wstrict-prototypes
+    -Wold-style-definition to the compilatin flags.
+    Dotan Barak, dotanba at gmail dot com
+  * Add const correctness to public interfaces
+    Gerard Krol, g dot c dot krol at student dot tudelft dot nl
+
+0.8
+===
+  * Add va_end for every va_start
+    Dotan Barak, dotanba at gmail dot com
+  * Add macros to enable compiling out debug code
+    Geoffrey Young, geoff at modperlcookbook dot org
+  * Fix bug with use of capital E in numbers with exponents
+    Mateusz Loskot, mateusz at loskot dot net
+  * Add stddef.h include
+  * Patch allows for json-c compile with -Werror and not fail due to
+    -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
+    Geoffrey Young, geoff at modperlcookbook dot org
+
+0.7
+===
+  * Add escaping of backslash to json output
+  * Add escaping of forward slash on tokenizing and output
+  * Changes to internal tokenizer from using recursion to
+    using a depth state structure to allow incremental parsing
+
+0.6
+===
+  * Fix bug in escaping of control characters
+    Johan Björklund, johbjo09 at kth dot se
+  * Remove include "config.h" from headers (should only
+    be included from .c files)
+    Michael Clark <michael@metaparadigm.com>
+
+0.5
+===
+  * Make headers C++ compatible by change *this to *obj
+  * Add ifdef C++ extern "C" to headers
+  * Use simpler definition of min and max in bits.h
+    Larry Lansing, llansing at fuzzynerd dot com
+
+  * Remove automake 1.6 requirement
+  * Move autogen commands into autogen.sh. Update README
+  * Remove error pointer special case for Windows
+  * Change license from LGPL to MIT
+    Michael Clark <michael@metaparadigm.com>
+
+0.4
+===
+  * Fix additional error case in object parsing
+  * Add back sign reversal in nested object parse as error pointer
+    value is negative, while error value is positive.
+    Michael Clark <michael@metaparadigm.com>
+
+0.3
+===
+  * fix pointer arithmetic bug for error pointer check in is_error() macro
+  * fix type passed to printbuf_memappend in json_tokener
+  * update autotools bootstrap instructions in README
+    Michael Clark <michael@metaparadigm.com>
+
+0.2
+===
+  * printbuf.c - C. Watford (christopher.watford@gmail.com)
+    Added a Win32/Win64 compliant implementation of vasprintf
+  * debug.c - C. Watford (christopher.watford@gmail.com)
+    Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
+    by a configure script
+  * json_object.c - C. Watford (christopher.watford@gmail.com)
+    Added scope operator to wrap usage of json_object_object_foreach, this
+    needs to be rethought to be more ANSI C friendly
+  * json_object.h - C. Watford (christopher.watford@gmail.com)
+    Added Microsoft C friendly version of json_object_object_foreach
+  * json_tokener.c - C. Watford (christopher.watford@gmail.com)
+    Added a Win32/Win64 compliant implementation of strndup
+  * json_util.c - C. Watford (christopher.watford@gmail.com)
+    Added cast and mask to suffice size_t v. unsigned int conversion
+    correctness
+  * json_tokener.c - sign reversal issue on error info for nested object parse
+    spotted by Johan Björklund (johbjo09 at kth.se)
+  * json_object.c - escape " in json_escape_str
+  * Change to automake and libtool to build shared and static library
+    Michael Clark <michael@metaparadigm.com>
+
+0.1
+===
+  * initial release
diff --git a/lynq/S300/ap/app/apparms/json-c/INSTALL b/lynq/S300/ap/app/apparms/json-c/INSTALL
new file mode 100755
index 0000000..d8575d3
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/INSTALL
@@ -0,0 +1,2 @@
+
+See README.md for installation instructions.
diff --git a/lynq/S300/ap/app/apparms/json-c/NEWS b/lynq/S300/ap/app/apparms/json-c/NEWS
new file mode 100755
index 0000000..5798fb4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/NEWS
@@ -0,0 +1 @@
+See the git repo.
diff --git a/lynq/S300/ap/app/apparms/json-c/README b/lynq/S300/ap/app/apparms/json-c/README
new file mode 100755
index 0000000..e257745
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/README
@@ -0,0 +1 @@
+See README.md or README.html
diff --git a/lynq/S300/ap/app/apparms/json-c/README.html b/lynq/S300/ap/app/apparms/json-c/README.html
new file mode 100755
index 0000000..483e407
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/README.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+	<head>
+		<title>JSON-C - A JSON implementation in C</title>
+		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+	</head>
+	<body>
+		<h2>JSON-C - A JSON implementation in C</h2>
+
+		<h3>Overview</h3>
+		<p>JSON-C implements a reference counting object model that allows you to easily
+		construct JSON objects in C, output them as JSON formatted strings and parse
+		JSON formatted strings back into the C representation of JSON objects.
+		It aims to conform to <a href="https://tools.ietf.org/html/rfc7159">RFC 7159</a>.
+		</p>
+
+		<h3>Building</h3>
+		<p>To setup JSON-C to build on your system please run <tt>configure</tt> and <tt>make</tt>.</p>
+		<p>If you are on Win32 cmake is required, generally:</p>
+		<ul>
+		<li>mkdir build</li>
+		<li>cd build</li>
+		<li>cmake ..</li>
+		<li>msbuild "json-c.vcxproj" /m /verbosity:normal /p:OutDir=lib\</li>
+		<li>Or, open the project in Visual Studio</li>
+		</ul>
+
+		<h3>Documentation</h3>
+		<P>Doxygen generated documentation exists <a href="https://json-c.github.io/json-c/">here</a>.</P>
+
+		<h3><a href="https://github.com/json-c/json-c">GIT Reposository</a></h3>
+		<p><strong><code>git clone https://github.com/json-c/json-c.git</code></strong></p>
+
+		<h3><a href="https://groups.google.com/group/json-c">Mailing List</a></h3>
+                <pi>Send email to <strong><code>json-c <i>&lt;at&gt;</i> googlegroups <i>&lt;dot&gt;</i> com</code></strong></p>
+
+		<h3><a href="COPYING">License</a></h3>
+		<p>This program is free software; you can redistribute it and/or modify it under the terms of the MIT License.</p>
+		<hr/>
+	</body>
+</html>
diff --git a/lynq/S300/ap/app/apparms/json-c/README.md b/lynq/S300/ap/app/apparms/json-c/README.md
new file mode 100755
index 0000000..d16cd47
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/README.md
@@ -0,0 +1,321 @@
+\mainpage
+
+`json-c`
+========
+
+1. [Overview and Build Status](#overview)
+2. [Getting Help](#gettinghelp)
+3. [Building on Unix](#buildunix)
+    * [Prerequisites](#installprereq)
+    * [Build commands](#buildcmds)
+4. [CMake options](#CMake)
+5. [Testing](#testing)
+6. [Building with `vcpkg`](#buildvcpkg)
+7. [Linking to libjson-c](#linking)
+8. [Using json-c](#using)
+
+JSON-C - A JSON implementation in C <a name="overview"></a>
+-----------------------------------
+
+JSON-C implements a reference counting object model that allows you to easily
+construct JSON objects in C, output them as JSON formatted strings and parse
+JSON formatted strings back into the C representation of JSON objects.
+It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159).
+
+Skip down to [Using json-c](#using)
+or check out the [API docs](https://json-c.github.io/json-c/),
+if you already have json-c installed and ready to use.
+
+Home page for json-c: https://github.com/json-c/json-c/wiki
+
+Getting Help <a name="gettinghelp"></a>
+------------
+
+If you have questions about using json-c, please start a thread on
+our forums at: https://groups.google.com/forum/#!forum/json-c
+
+If you believe you've discovered a bug, report it at 
+(https://github.com/json-c/json-c/issues).  Please be sure to include
+the version of json-c you're using, the OS you're running on, and any
+other relevant details.  Fully reproducible test cases and/or patches
+to fix problems are greatly appreciated.
+
+Fixes for bugs, or small new features can be directly submitted as a 
+[pull request](https://github.com/json-c/json-c/pulls).  For major new
+features or large changes of any kind, please first start a discussion
+on the [forums](https://groups.google.com/forum/#!forum/json-c).
+
+
+Building on Unix with `git`, `gcc` and `cmake` <a name="buildunix"></a>
+--------------------------------------------------
+
+If you already have json-c installed, see [Linking to `libjson-c`](#linking)
+for how to build and link your program against it.
+
+Build Status
+* [AppVeyor Build](https://ci.appveyor.com/project/hawicz/json-c) ![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/json-c/json-c?branch=master&svg=true)
+* [Travis Build](https://app.travis-ci.com/github/json-c/json-c) ![Travis Build Status](https://api.travis-ci.com/json-c/json-c.svg?branch=master)
+
+Test Status
+* [Coveralls](https://coveralls.io/github/json-c/json-c?branch=master) [![Coverage Status](https://coveralls.io/repos/github/json-c/json-c/badge.svg?branch=master)](https://coveralls.io/github/json-c/json-c?branch=master)
+
+### Prerequisites: <a name="installprereq"></a>
+
+ - `gcc`, `clang`, or another C compiler
+
+ - `cmake>=2.8`, `>=3.16` recommended, `cmake=>3.1` for tests
+
+To generate docs you'll also need:
+ - `doxygen>=1.8.13`
+
+If you are on a relatively modern system, you'll likely be able to install
+the prerequisites using your OS's packaging system.
+
+### Install using apt (e.g. Ubuntu 16.04.2 LTS)
+```sh
+sudo apt install git
+sudo apt install cmake
+sudo apt install doxygen  # optional
+sudo apt install valgrind # optional
+```
+
+### Build instructions:  <a name="buildcmds"></a>
+
+`json-c` GitHub repo: https://github.com/json-c/json-c
+
+```sh
+$ git clone https://github.com/json-c/json-c.git
+$ mkdir json-c-build
+$ cd json-c-build
+$ cmake ../json-c   # See CMake section below for custom arguments
+```
+
+Note: it's also possible to put your build directory inside the json-c
+source directory, or even not use a separate build directory at all, but
+certain things might not work quite right (notably, `make distcheck`)
+
+Then:
+
+```sh
+$ make
+$ make test
+$ make USE_VALGRIND=0 test   # optionally skip using valgrind
+$ sudo make install          # it could be necessary to execute make install
+```
+
+
+### Generating documentation with Doxygen:
+
+The library documentation can be generated directly from the source code using Doxygen tool:
+
+```sh
+# in build directory
+make doc
+google-chrome doc/html/index.html
+```
+
+
+CMake Options <a name="CMake"></a>
+--------------------
+
+The json-c library is built with [CMake](https://cmake.org/cmake-tutorial/),
+which can take a few options.
+
+Variable                     | Type   | Description
+-----------------------------|--------|--------------
+CMAKE_INSTALL_PREFIX         | String | The install location.
+CMAKE_BUILD_TYPE             | String | Defaults to "debug".
+BUILD_SHARED_LIBS            | Bool   | The default build generates a dynamic (dll/so) library.  Set this to OFF to create a static library only.
+BUILD_STATIC_LIBS            | Bool   | The default build generates a static (lib/a) library.  Set this to OFF to create a shared library only.
+DISABLE_STATIC_FPIC          | Bool   | The default builds position independent code.  Set this to OFF to create a shared library only.
+DISABLE_BSYMBOLIC            | Bool   | Disable use of -Bsymbolic-functions.
+DISABLE_THREAD_LOCAL_STORAGE | Bool   | Disable use of Thread-Local Storage (HAVE___THREAD).
+DISABLE_WERROR               | Bool   | Disable use of -Werror.
+DISABLE_EXTRA_LIBS           | Bool   | Disable use of extra libraries, libbsd
+DISABLE_JSON_POINTER         | Bool   | Omit json_pointer support from the build.
+ENABLE_RDRAND                | Bool   | Enable RDRAND Hardware RNG Hash Seed.
+ENABLE_THREADING             | Bool   | Enable partial threading support.
+OVERRIDE_GET_RANDOM_SEED     | String | A block of code to use instead of the default implementation of json_c_get_random_seed(), e.g. on embedded platforms where not even the fallback to time() works.  Must be a single line.
+
+Pass these options as `-D` on CMake's command-line.
+
+```sh
+# build a static library only
+cmake -DBUILD_SHARED_LIBS=OFF ..
+```
+
+### Building with partial threading support
+
+Although json-c does not support fully multi-threaded access to
+object trees, it has some code to help make its use in threaded programs
+a bit safer.  Currently, this is limited to using atomic operations for
+json_object_get() and json_object_put().
+
+Since this may have a performance impact, of at least 3x slower
+according to https://stackoverflow.com/a/11609063, it is disabled by
+default.  You may turn it on by adjusting your cmake command with:
+   -DENABLE_THREADING=ON
+
+Separately, the default hash function used for object field keys,
+lh_char_hash, uses a compare-and-swap operation to ensure the random
+seed is only generated once.  Because this is a one-time operation, it
+is always compiled in when the compare-and-swap operation is available.
+
+
+### cmake-configure wrapper script
+
+For those familiar with the old autoconf/autogen.sh/configure method,
+there is a `cmake-configure` wrapper script to ease the transition to cmake.
+
+```sh
+mkdir build
+cd build
+../cmake-configure --prefix=/some/install/path
+make
+```
+
+cmake-configure can take a few options.
+
+| options | Description|
+| ---- | ---- |
+| prefix=PREFIX |  install architecture-independent files in PREFIX |
+| enable-threading |  Enable code to support partly multi-threaded use |
+| enable-rdrand | Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms. |
+| enable-shared  |  build shared libraries [default=yes] |
+| enable-static  |  build static libraries [default=yes] |
+| disable-Bsymbolic |  Avoid linking with -Bsymbolic-function |
+| disable-werror |  Avoid treating compiler warnings as fatal errors |
+
+
+Testing:  <a name="testing"></a>
+----------
+
+By default, if valgrind is available running tests uses it.
+That can slow the tests down considerably, so to disable it use:
+```sh
+export USE_VALGRIND=0
+```
+
+To run tests a separate build directory is recommended:
+```sh
+mkdir build-test
+cd build-test
+# VALGRIND=1 causes -DVALGRIND=1 to be passed when compiling code
+# which uses slightly slower, but valgrind-safe code.
+VALGRIND=1 cmake ..
+make
+
+make test
+# By default, if valgrind is available running tests uses it.
+make USE_VALGRIND=0 test   # optionally skip using valgrind
+```
+
+If a test fails, check `Testing/Temporary/LastTest.log`,
+`tests/testSubDir/${testname}/${testname}.vg.out`, and other similar files.
+If there is insufficient output try:
+```sh
+VERBOSE=1 CTEST_OUTPUT_ON_FAILURE=1 make test
+```
+or
+```sh
+JSONC_TEST_TRACE=1 make test
+```
+and check the log files again.
+
+
+Building on Unix and Windows with `vcpkg` <a name="buildvcpkg"></a>
+--------------------------------------------------
+
+You can download and install JSON-C using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
+
+    git clone https://github.com/Microsoft/vcpkg.git
+    cd vcpkg
+    ./bootstrap-vcpkg.sh
+    ./vcpkg integrate install
+    vcpkg install json-c
+
+The JSON-C port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
+
+
+Linking to `libjson-c` <a name="linking">
+----------------------
+
+If your system has `pkgconfig`,
+then you can just add this to your `makefile`:
+
+```make
+CFLAGS += $(shell pkg-config --cflags json-c)
+LDFLAGS += $(shell pkg-config --libs json-c)
+```
+
+Without `pkgconfig`, you might do something like this:
+
+```make
+JSON_C_DIR=/path/to/json_c/install
+CFLAGS += -I$(JSON_C_DIR)/include/json-c
+# Or to use lines like: #include <json-c/json_object.h>
+#CFLAGS += -I$(JSON_C_DIR)/include
+LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
+```
+
+If your project uses cmake:
+
+* Add to your CMakeLists.txt file:
+
+```cmake
+find_package(json-c CONFIG)
+target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c)
+```
+
+* Then you might run in your project:
+
+```sh
+cd build
+cmake -DCMAKE_PREFIX_PATH=/path/to/json_c/install/lib64/cmake ..
+```
+
+Using json-c <a name="using">
+------------
+
+To use json-c you can either include json.h, or preferably, one of the
+following more specific header files:
+
+* json_object.h  - Core types and methods.
+* json_tokener.h - Methods for parsing and serializing json-c object trees.
+* json_pointer.h - JSON Pointer (RFC 6901) implementation for retrieving
+                   objects from a json-c object tree.
+* json_object_iterator.h - Methods for iterating over single json_object instances.  (See also `json_object_object_foreach()` in json_object.h)
+* json_visit.h   - Methods for walking a tree of json-c objects.
+* json_util.h    - Miscellaneous utility functions.
+
+For a full list of headers see [files.html](https://json-c.github.io/json-c/json-c-current-release/doc/html/files.html)
+
+The primary type in json-c is json_object.  It describes a reference counted
+tree of json objects which are created by either parsing text with a
+json_tokener (i.e. `json_tokener_parse_ex()`), or by creating
+(with `json_object_new_object()`, `json_object_new_int()`, etc...) and adding
+(with `json_object_object_add()`, `json_object_array_add()`, etc...) them 
+individually.
+Typically, every object in the tree will have one reference, from its parent.
+When you are done with the tree of objects, you call json_object_put() on just
+the root object to free it, which recurses down through any child objects
+calling json_object_put() on each one of those in turn.
+
+You can get a reference to a single child 
+(`json_object_object_get()` or `json_object_array_get_idx()`)
+and use that object as long as its parent is valid.  
+If you need a child object to live longer than its parent, you can
+increment the child's refcount (`json_object_get()`) to allow it to survive
+the parent being freed or it being removed from its parent
+(`json_object_object_del()` or `json_object_array_del_idx()`)
+
+When parsing text, the json_tokener object is independent from the json_object
+that it returns.  It can be allocated (`json_tokener_new()`)
+used one or multiple times (`json_tokener_parse_ex()`, and
+freed (`json_tokener_free()`) while the json_object objects live on.
+
+A json_object tree can be serialized back into a string with 
+`json_object_to_json_string_ext()`.  The string that is returned 
+is only valid until the next "to_json_string" call on that same object.
+Also, it is freed when the json_object is freed.
+
diff --git a/lynq/S300/ap/app/apparms/json-c/RELEASE_CHECKLIST.txt b/lynq/S300/ap/app/apparms/json-c/RELEASE_CHECKLIST.txt
new file mode 100755
index 0000000..4848676
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/RELEASE_CHECKLIST.txt
@@ -0,0 +1,180 @@
+
+# Release checklist:
+
+## Pre-release tasks
+
+* Figure out whether a release is worthwhile to do.
+* Analyze the previous release branch to see if anything should have been
+  applied to master.
+* Collect changes and assemble tentative release notes.
+    * Identify previous release branch point
+    * Check commit logs between previous branch point and now for
+       notable changes worth mentioning
+    * Create a new issues_closed_for_X.Y.md file
+        * Include notable entries from here in the release notes.
+    * Analyze APIs between previous release branch and master to produce list of
+      changes (added/removed/updated funcs, etc...), and detect backwards compat
+      issues.
+        * https://github.com/lvc/abi-compliance-checker
+        * If the new release is not backwards compatible, then this is a MAJOR release.
+        * Mention removed features in ChangeLog
+		* Consider re-adding backwards compatible support, through symbol
+		  aliases and appropriate entries in json-c.sym
+		* Be sure any new symbols are listed in json-c.sym as part of
+		  the _new_ release version.
+    * Update the AUTHORS file
+
+        PREV=$(git tag | tail -1)
+        ( git log -r ${PREV}..HEAD | grep Author: | sed -e's/Author: //' ; cat AUTHORS ) | sort -u > A1
+        mv A1 AUTHORS
+
+    * Exclude mentioning changes that have already been included in a point 
+      release of the previous release branch.
+
+* Update ChangeLog with relevant notes before branching.
+
+* Check that the compile works on Linux - automatic through Travis
+* Check that the compile works on NetBSD
+* Check that the compile works on Windows - automatic through AppVeyor
+
+## Release creation
+
+Start creating the new release:
+    release=0.16
+    git clone https://github.com/json-c/json-c json-c-${release}
+
+    mkdir distcheck
+    cd distcheck
+    # Note, the build directory *must* be entirely separate from
+    # the source tree for distcheck to work properly.
+    cmake -DCMAKE_BUILD_TYPE=Release ../json-c-${release}
+    make distcheck
+    cd ..
+
+Make any fixes/changes *before* branching.
+
+    cd json-c-${release}
+    git branch json-c-${release}
+    git checkout json-c-${release}
+
+------------
+
+Using ${release}:
+	Update the version in json_c_version.h
+	Update the version in CMakeLists.txt (VERSION in the project(...) line)
+
+Update the set_target_properties() line in CmakeLists.txt to set the shared
+library version.  Generally, unless we're doing a major release, change:
+	VERSION x.y.z
+to
+	VERSION x.y+1.z
+
+    git commit -a -m "Bump version to ${release}"
+
+If we're doing a major release (SONAME bump), also bump the version
+ of ALL symbols in json-c.sym.
+ See explanation at https://github.com/json-c/json-c/issues/621
+ More info at: https://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf
+
+------------
+
+Generate the doxygen documentation:
+
+    (cd ../distcheck && make doc)
+    cp -r -p ../distcheck/doc/{html,Doxyfile} doc/.
+	rm doc/Doxyfile   # Remove generated file w/ hardcoded paths
+    git add -f doc
+    git commit doc -m "Generate docs for the ${release} release"
+
+------------
+
+Create the release tarballs:
+
+    cd ..
+    echo .git > excludes
+    tar -czf json-c-${release}.tar.gz -X excludes json-c-${release}
+
+    echo 'doc/*' >> excludes
+    tar -czf json-c-${release}-nodoc.tar.gz -X excludes json-c-${release}
+
+------------
+
+Tag the branch:
+
+    cd json-c-${release}
+    git tag -a json-c-${release}-$(date +%Y%m%d) -m "Release json-c-${release}"
+
+    git push origin json-c-${release}
+    git push --tags
+
+------------
+
+Go to Amazon S3 service at:
+    https://console.aws.amazon.com/s3/
+
+Upload the two tarballs in the json-c_releases/releases folder.
+* Expand "Permissions", pick "Grant public-read access"
+* Expand "Properties", ensure "Standard" storage class is picked.
+
+Logout of Amazon S3, and verify that the files are visible.
+    https://s3.amazonaws.com/json-c_releases/releases/index.html
+
+===================================
+
+Post-release checklist:
+
+    git checkout master
+
+Add new section to ChangeLog for ${release}+1
+
+Use ${release}.99 to indicate a version "newer" than anything on the branch:
+	Update the version in json_c_version.h
+	Update the version in CMakeLists.txt
+
+Update RELEASE_CHECKLIST.txt, set release=${release}+1
+
+Add a new empty section to the json-c.sym file, for ${release}+1
+
+Update the set_target_properties() line in CmakeLists.txt to match the release branch.
+
+    git commit -a -m "Update the master branch to version ${release}.99"
+    git push
+
+------------
+
+Update the gh-pages branch with new docs:
+
+    cd json-c-${release}
+    git checkout json-c-${release}
+    cd ..
+
+    git clone -b gh-pages https://github.com/json-c/json-c json-c-pages
+    cd json-c-pages
+    mkdir json-c-${release}
+    cp -R ../json-c-${release}/doc json-c-${release}/.
+    git add json-c-${release}
+    rm json-c-current-release
+    ln -s json-c-${release} json-c-current-release
+    git commit -a -m "Add the ${release} docs."
+
+    vi index.html
+    # Add/change links to current release.
+
+    git commit -a -m "Update the doc links to point at ${release}"
+
+    git push
+
+------------
+
+Update checksums on wiki page.
+
+    cd ..
+    openssl sha -sha256 json-c*gz
+    openssl md5 json-c*gz
+
+Copy and paste this output into the wiki page at:
+	https://github.com/json-c/json-c/wiki
+
+------------
+
+Send an email to the mailing list.
diff --git a/lynq/S300/ap/app/apparms/json-c/STYLE.txt b/lynq/S300/ap/app/apparms/json-c/STYLE.txt
new file mode 100755
index 0000000..4e5d75a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/STYLE.txt
@@ -0,0 +1,31 @@
+In general:
+For minor changes to a function, copy the existing formatting.
+When changing the style, commit that separately from other changes.
+For new code and major changes to a function, switch to the official json-c style.
+
+Official json-c style:
+
+Aim for readability, not strict conformance to fixed style rules.
+Formatting is tab based; previous attempts at proper alignment with
+spaces for continuation lines have been abandoned in favor of the
+convenience of using clang-format.
+Refer to the .clang-format file for details, and run the tool before commit:
+
+    clang-format -i somefile.c foo.h
+
+For sections of code that would be significantly negatively impacted, surround
+them with magic comments to disable formatting:
+
+    /* clang-format off */
+    ...code...
+    /* clang-format on */
+
+
+Naming:
+Words within function and variable names are separated with underscores.  Avoid camel case.
+Prefer longer, more descriptive names, but not excessively so.  No single letter variable names.
+
+Other:
+Variables should be defined for the smallest scope needed.
+Functions should be defined static when possible.
+When possible, avoid exposing internals in the public API.
diff --git a/lynq/S300/ap/app/apparms/json-c/apps/CMakeLists.txt b/lynq/S300/ap/app/apparms/json-c/apps/CMakeLists.txt
new file mode 100755
index 0000000..f7c9dec
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/apps/CMakeLists.txt
@@ -0,0 +1,122 @@
+
+cmake_minimum_required(VERSION 2.8)  # see ../CMakeLists.txt for why 2.8
+
+if(POLICY CMP0075)
+    cmake_policy(SET CMP0075 NEW)
+endif()
+
+include(CheckSymbolExists)
+include(CheckIncludeFile)
+include(CMakePackageConfigHelpers)
+
+# First, sort out whether we're running inside a json-c build,
+#  or standalone, such as part of a benchmark build.
+
+if ("${PROJECT_NAME}" STREQUAL "json-c")
+# Part of an overall json-c build
+set(APPS_LINK_LIBS "${PROJECT_NAME}")
+
+# We know we have this in our current sources:
+set(HAVE_JSON_TOKENER_GET_PARSE_END)
+
+else()
+
+# Standalone mode, using an already installed json-c library, somewhere.
+# The path to the json-c install must be specified with -DCMAKE_PREFIX_PATH=...
+
+project(apps)
+find_package(PkgConfig)
+
+# PkgConfig is supposed to include CMAKE_PREFIX_PATH in the PKG_CONFIG_PATH
+#  that's used when running pkg-config, but it just doesn't work :(
+# https://gitlab.kitware.com/cmake/cmake/issues/18150
+#set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
+
+# Instead, we handle it explicitly here and update PKG_CONFIG_PATH ourselves.
+if (NOT CMAKE_PREFIX_PATH)
+	message(FATAL_ERROR "Please specify -DCMAKE_PREFIX_PATH=... when running cmake.")
+endif()
+
+# Note: find_file isn't recursive :(
+find_file(PC_FILE_PATH "json-c.pc"
+	PATHS "${CMAKE_PREFIX_PATH}/lib64" "${CMAKE_PREFIX_PATH}/lib"
+	PATH_SUFFIXES "pkgconfig"
+	NO_DEFAULT_PATH)
+get_filename_component(PC_DIR_PATH "${PC_FILE_PATH}" DIRECTORY)
+set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${PC_DIR_PATH}")
+message(STATUS "PC_FILE_PATH=${PC_FILE_PATH}")
+message(STATUS "PC_DIR_PATH=${PC_DIR_PATH}")
+
+pkg_check_modules(PC_JSONC json-c)
+if (PC_JSONC_FOUND)
+	message(STATUS "Found json-c using pkg-config: ${PC_JSONC_PREFIX}")
+	message(STATUS " PC_JSONC_INCLUDE_DIRS=${PC_JSONC_INCLUDE_DIRS}")
+	message(STATUS " PC_JSONC_LIBRARIES=${PC_JSONC_LIBRARIES}")
+	message(STATUS " PC_JSONC_LIBRARY_DIRS=${PC_JSONC_LIBRARY_DIRS}")
+	link_directories(${PC_JSONC_LIBRARY_DIRS})
+	include_directories(${PC_JSONC_INCLUDE_DIRS})
+	# for target_link_libraries(...)
+	set(APPS_INCLUDE_DIRS ${PC_JSONC_INCLUDE_DIRS})
+	set(APPS_LINK_DIRS ${PC_JSONC_LIBRARY_DIRS})
+	set(APPS_LINK_LIBS ${PC_JSONC_LIBRARIES})
+else()
+	message(STATUS "Using find_package to locate json-c")
+
+	# Note: find_package needs CMAKE_PREFIX_PATH set appropriately.
+	# XXX json-c's installed cmake files don't actually set up what's
+	#  needed to use find_package() by itself, so we're just using it
+	#  to confirm the top of the install location.
+	find_package(json-c CONFIG)  # sets json-c_DIR
+
+	# Assume json-c-config.cmake is in lib64/cmake/json-c/
+	get_filename_component(json-c_TOP "${json-c_DIR}/../../.." ABSOLUTE)
+	get_filename_component(json-c_LIBDIR "${json-c_DIR}/../.." ABSOLUTE)
+
+	message(STATUS " json-c_TOP=${json-c_TOP}")
+	message(STATUS " json-c_DIR=${json-c_DIR}")
+	message(STATUS " json-c_LIBDIR=${json-c_LIBDIR}")
+
+	link_directories(${json-c_LIBDIR})
+	include_directories(${json-c_TOP}/include)
+	include_directories(${json-c_TOP}/include/json-c)
+	set(APPS_LINK_DIRS "${json-c_LIBDIR}")
+	set(APPS_INCLUDE_DIRS "${json-c_TOP}/include;${json-c_TOP}/include/json-c")
+
+	set(APPS_LINK_LIBS json-c)
+endif()
+
+set(CMAKE_REQUIRED_LINK_OPTIONS "-L${APPS_LINK_DIRS}")
+set(CMAKE_REQUIRED_LIBRARIES ${APPS_LINK_LIBS})
+set(CMAKE_REQUIRED_INCLUDES ${APPS_INCLUDE_DIRS})
+check_symbol_exists(json_tokener_get_parse_end "json_tokener.h" HAVE_JSON_TOKENER_GET_PARSE_END)
+
+endif() # end "standalone mode" block
+
+# ---------------------------------
+
+check_include_file(sys/resource.h   HAVE_SYS_RESOURCE_H) # for getrusage
+if (HAVE_SYS_RESOURCE_H)
+    check_symbol_exists(getrusage   "sys/resource.h" HAVE_GETRUSAGE)
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apps_config.h.in
+               ${PROJECT_BINARY_DIR}/apps_config.h)
+message(STATUS "Wrote ${PROJECT_BINARY_DIR}/apps_config.h")
+
+# ---------------------------------
+
+include_directories(PUBLIC ${CMAKE_SOURCE_DIR})
+include_directories(${PROJECT_SOURCE_DIR})
+include_directories(${PROJECT_BINARY_DIR})
+
+# ---------------------------------
+
+# Now, finally, the actual executables we're building:
+
+add_executable(json_parse json_parse.c)
+target_link_libraries(json_parse PRIVATE ${APPS_LINK_LIBS})
+
+# Note: it is intentional that there are no install instructions here yet.
+# When/if the interface of the app(s) listed here settles down enough to
+# publish as part of a regular build that will be added.
+
diff --git a/lynq/S300/ap/app/apparms/json-c/apps/cmake/apps_config.h.in b/lynq/S300/ap/app/apparms/json-c/apps/cmake/apps_config.h.in
new file mode 100755
index 0000000..a77ee8c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/apps/cmake/apps_config.h.in
@@ -0,0 +1,8 @@
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#cmakedefine HAVE_SYS_RESOURCE_H
+
+/* Define if you have the `getrusage' function. */
+#cmakedefine HAVE_GETRUSAGE
+
+#cmakedefine HAVE_JSON_TOKENER_GET_PARSE_END
diff --git a/lynq/S300/ap/app/apparms/json-c/apps/json_parse.c b/lynq/S300/ap/app/apparms/json-c/apps/json_parse.c
new file mode 100755
index 0000000..c62e727
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/apps/json_parse.c
@@ -0,0 +1,201 @@
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "apps_config.h"
+
+/* XXX for a regular program, these should be <json-c/foo.h>
+ * but that's inconvenient when building in the json-c source tree.
+ */
+#include "json_object.h"
+#include "json_tokener.h"
+#include "json_util.h"
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#include <sys/time.h>
+#endif
+
+#ifndef JSON_NORETURN
+#if defined(_MSC_VER)
+#define JSON_NORETURN __declspec(noreturn)
+#elif defined(__OS400__)
+#define JSON_NORETURN
+#else
+/* 'cold' attribute is for optimization, telling the computer this code
+ * path is unlikely.
+ */
+#define JSON_NORETURN __attribute__((noreturn, cold))
+#endif
+#endif
+
+static int formatted_output = 0;
+static int show_output = 1;
+static int strict_mode = 0;
+static const char *fname = NULL;
+
+#ifndef HAVE_JSON_TOKENER_GET_PARSE_END
+#define json_tokener_get_parse_end(tok) ((tok)->char_offset)
+#endif
+
+JSON_NORETURN static void usage(const char *argv0, int exitval, const char *errmsg);
+static void showmem(void);
+static int parseit(int fd, int (*callback)(struct json_object *));
+static int showobj(struct json_object *new_obj);
+
+static void showmem(void)
+{
+#ifdef HAVE_GETRUSAGE
+	struct rusage rusage;
+	memset(&rusage, 0, sizeof(rusage));
+	getrusage(RUSAGE_SELF, &rusage);
+	printf("maxrss: %ld KB\n", rusage.ru_maxrss);
+#endif
+}
+
+static int parseit(int fd, int (*callback)(struct json_object *))
+{
+	struct json_object *obj;
+	char buf[32768];
+	ssize_t ret;
+	int depth = JSON_TOKENER_DEFAULT_DEPTH;
+	json_tokener *tok;
+
+	tok = json_tokener_new_ex(depth);
+	if (!tok)
+	{
+		fprintf(stderr, "unable to allocate json_tokener: %s\n", strerror(errno));
+		return 1;
+	}
+	json_tokener_set_flags(tok, JSON_TOKENER_STRICT
+#ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
+		 | JSON_TOKENER_ALLOW_TRAILING_CHARS
+#endif
+	);
+
+	// XXX push this into some kind of json_tokener_parse_fd API?
+	//  json_object_from_fd isn't flexible enough, and mirroring
+	//   everything you can do with a tokener into json_util.c seems
+	//   like the wrong approach.
+	size_t total_read = 0;
+	while ((ret = read(fd, buf, sizeof(buf))) > 0)
+	{
+		size_t retu = (size_t)ret;  // We know it's positive
+		total_read += retu;
+		size_t start_pos = 0;
+		while (start_pos != retu)
+		{
+			obj = json_tokener_parse_ex(tok, &buf[start_pos], retu - start_pos);
+			enum json_tokener_error jerr = json_tokener_get_error(tok);
+			size_t parse_end = json_tokener_get_parse_end(tok);
+			if (obj == NULL && jerr != json_tokener_continue)
+			{
+				const char *aterr = (start_pos + parse_end < (int)sizeof(buf)) ?
+					&buf[start_pos + parse_end] : "";
+				fflush(stdout);
+				size_t fail_offset = total_read - retu + start_pos + parse_end;
+				fprintf(stderr, "Failed at offset %lu: %s %c\n", (unsigned long)fail_offset,
+				        json_tokener_error_desc(jerr), aterr[0]);
+				json_tokener_free(tok);
+				return 1;
+			}
+			if (obj != NULL)
+			{
+				int cb_ret = callback(obj);
+				json_object_put(obj);
+				if (cb_ret != 0)
+				{
+					json_tokener_free(tok);
+					return 1;
+				}
+			}
+			start_pos += json_tokener_get_parse_end(tok);
+			assert(start_pos <= retu);
+		}
+	}
+	if (ret < 0)
+	{
+		fprintf(stderr, "error reading fd %d: %s\n", fd, strerror(errno));
+	}
+
+	json_tokener_free(tok);
+	return 0;
+}
+
+static int showobj(struct json_object *new_obj)
+{
+	if (new_obj == NULL)
+	{
+		fprintf(stderr, "%s: Failed to parse\n", fname);
+		return 1;
+	}
+
+	printf("Successfully parsed object from %s\n", fname);
+
+	if (show_output)
+	{
+		const char *output;
+		if (formatted_output)
+			output = json_object_to_json_string(new_obj);
+		else
+			output = json_object_to_json_string_ext(new_obj, JSON_C_TO_STRING_PRETTY);
+		printf("%s\n", output);
+	}
+
+	showmem();
+	return 0;
+}
+
+static void usage(const char *argv0, int exitval, const char *errmsg)
+{
+	FILE *fp = stdout;
+	if (exitval != 0)
+		fp = stderr;
+	if (errmsg != NULL)
+		fprintf(fp, "ERROR: %s\n\n", errmsg);
+	fprintf(fp, "Usage: %s [-f] [-n] [-s]\n", argv0);
+	fprintf(fp, "  -f - Format the output with JSON_C_TO_STRING_PRETTY\n");
+	fprintf(fp, "  -n - No output\n");
+	fprintf(fp, "  -s - Parse in strict mode, flags:\n");
+	fprintf(fp, "       JSON_TOKENER_STRICT|JSON_TOKENER_ALLOW_TRAILING_CHARS\n");
+
+	fprintf(fp, "\nWARNING WARNING WARNING\n");
+	fprintf(fp, "This is a prototype, it may change or be removed at any time!\n");
+	exit(exitval);
+}
+
+int main(int argc, char **argv)
+{
+	int opt;
+
+	while ((opt = getopt(argc, argv, "fhns")) != -1)
+	{
+		switch (opt)
+		{
+		case 'f': formatted_output = 1; break;
+		case 'n': show_output = 0; break;
+		case 's': strict_mode = 1; break;
+		case 'h': usage(argv[0], 0, NULL);
+		default: /* '?' */ usage(argv[0], EXIT_FAILURE, "Unknown arguments");
+		}
+	}
+	if (optind >= argc)
+	{
+		usage(argv[0], EXIT_FAILURE, "Expected argument after options");
+	}
+	fname = argv[optind];
+
+	int fd = open(argv[optind], O_RDONLY, 0);
+	showmem();
+	if (parseit(fd, showobj) != 0)
+		exit(EXIT_FAILURE);
+	showmem();
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/appveyor.yml b/lynq/S300/ap/app/apparms/json-c/appveyor.yml
new file mode 100755
index 0000000..e0349f6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/appveyor.yml
@@ -0,0 +1,125 @@
+version: '{branch}.{build}'
+
+image:
+# b_toolset: v143
+  - Visual Studio 2022
+
+  # VS2015 also used for earlier VS builds
+  # aka os: Windows Server 2012 R2
+  - Visual Studio 2015
+
+  # aka os: Windows Server 2016
+# b_toolset: v141
+  - Visual Studio 2017
+
+  # aka os: Windows Server 2019
+# b_toolset: v142
+  - Visual Studio 2019
+
+platform: x64
+
+environment:
+  matrix:
+    - b_toolset: Windows7.1SDK
+
+    - b_toolset: v120
+
+    - b_toolset: v140
+
+    - b_toolset: v141
+
+    - b_toolset: v142
+
+    - b_toolset: v143
+
+configuration:
+  - Debug
+  - Release
+
+build_script:
+- cmake -T %b_toolset% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=t_install .
+- cmake --build . --target install
+
+matrix:
+  exclude:
+    #  Skip release builds for all except the newest image
+    - image: Visual Studio 2015
+      configuration: Release
+
+    # In the "old" image, new toolsets aren't available:
+    - image: Visual Studio 2015
+      b_toolset: v141
+
+    - image: Visual Studio 2015
+      b_toolset: v142
+
+    - image: Visual Studio 2015
+      b_toolset: v143
+
+    # ----
+
+    - image: Visual Studio 2017
+      configuration: Release
+
+    # In the "new" images, exclude all toolsets except the relevant
+    #  one for that image:
+
+    - image: Visual Studio 2017
+      b_toolset: Windows7.1SDK
+
+    - image: Visual Studio 2017
+      b_toolset: v120
+
+    - image: Visual Studio 2017
+      b_toolset: v140
+
+    - image: Visual Studio 2017
+      b_toolset: v142
+
+    - image: Visual Studio 2017
+      b_toolset: v143
+
+    # ----
+
+    - image: Visual Studio 2019
+      configuration: Release
+
+    - image: Visual Studio 2019
+      b_toolset: Windows7.1SDK
+
+    - image: Visual Studio 2019
+      b_toolset: v120
+
+    - image: Visual Studio 2019
+      b_toolset: v140
+
+    - image: Visual Studio 2019
+      b_toolset: v141
+
+    - image: Visual Studio 2019
+      b_toolset: v143
+
+    # ----
+
+    - image: Visual Studio 2022
+      b_toolset: Windows7.1SDK
+
+    - image: Visual Studio 2022
+      b_toolset: v120
+
+    - image: Visual Studio 2022
+      b_toolset: v140
+
+    - image: Visual Studio 2022
+      b_toolset: v141
+
+    - image: Visual Studio 2022
+      b_toolset: v142
+
+after_build:
+- cd t_install
+- 7z a ../json-c.win32.%b_toolset%.%CONFIGURATION%.zip *
+
+artifacts:
+- path: json-c.win32.%b_toolset%.%CONFIGURATION%.zip
+  name: json-c.win32.%b_toolset%.%CONFIGURATION%.zip
diff --git a/lynq/S300/ap/app/apparms/json-c/arraylist.c b/lynq/S300/ap/app/apparms/json-c/arraylist.c
new file mode 100755
index 0000000..d8e12d1
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/arraylist.c
@@ -0,0 +1,205 @@
+/*
+ * $Id: arraylist.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+
+#include <limits.h>
+
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <string.h>
+#endif /* STDC_HEADERS */
+
+#if defined(HAVE_STRINGS_H) && !defined(_STRING_H) && !defined(__USE_BSD)
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
+
+#ifndef SIZE_T_MAX
+#if SIZEOF_SIZE_T == SIZEOF_INT
+#define SIZE_T_MAX UINT_MAX
+#elif SIZEOF_SIZE_T == SIZEOF_LONG
+#define SIZE_T_MAX ULONG_MAX
+#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
+#define SIZE_T_MAX ULLONG_MAX
+#else
+#error Unable to determine size of size_t
+#endif
+#endif
+
+#include "arraylist.h"
+
+struct array_list *array_list_new(array_list_free_fn *free_fn)
+{
+	return array_list_new2(free_fn, ARRAY_LIST_DEFAULT_SIZE);
+}
+
+struct array_list *array_list_new2(array_list_free_fn *free_fn, int initial_size)
+{
+	struct array_list *arr;
+
+	if (initial_size < 0 || (size_t)initial_size >= SIZE_T_MAX / sizeof(void *))
+		return NULL;
+	arr = (struct array_list *)malloc(sizeof(struct array_list));
+	if (!arr)
+		return NULL;
+	arr->size = initial_size;
+	arr->length = 0;
+	arr->free_fn = free_fn;
+	if (!(arr->array = (void **)malloc(arr->size * sizeof(void *))))
+	{
+		free(arr);
+		return NULL;
+	}
+	return arr;
+}
+
+extern void array_list_free(struct array_list *arr)
+{
+	size_t i;
+	for (i = 0; i < arr->length; i++)
+		if (arr->array[i])
+			arr->free_fn(arr->array[i]);
+	free(arr->array);
+	free(arr);
+}
+
+void *array_list_get_idx(struct array_list *arr, size_t i)
+{
+	if (i >= arr->length)
+		return NULL;
+	return arr->array[i];
+}
+
+static int array_list_expand_internal(struct array_list *arr, size_t max)
+{
+	void *t;
+	size_t new_size;
+
+	if (max < arr->size)
+		return 0;
+	/* Avoid undefined behaviour on size_t overflow */
+	if (arr->size >= SIZE_T_MAX / 2)
+		new_size = max;
+	else
+	{
+		new_size = arr->size << 1;
+		if (new_size < max)
+			new_size = max;
+	}
+	if (new_size > (~((size_t)0)) / sizeof(void *))
+		return -1;
+	if (!(t = realloc(arr->array, new_size * sizeof(void *))))
+		return -1;
+	arr->array = (void **)t;
+	arr->size = new_size;
+	return 0;
+}
+
+int array_list_shrink(struct array_list *arr, size_t empty_slots)
+{
+	void *t;
+	size_t new_size;
+
+	if (empty_slots >= SIZE_T_MAX / sizeof(void *) - arr->length)
+		return -1;
+	new_size = arr->length + empty_slots;
+	if (new_size == arr->size)
+		return 0;
+	if (new_size > arr->size)
+		return array_list_expand_internal(arr, new_size);
+	if (new_size == 0)
+		new_size = 1;
+
+	if (!(t = realloc(arr->array, new_size * sizeof(void *))))
+		return -1;
+	arr->array = (void **)t;
+	arr->size = new_size;
+	return 0;
+}
+
+//static inline int _array_list_put_idx(struct array_list *arr, size_t idx, void *data)
+int array_list_put_idx(struct array_list *arr, size_t idx, void *data)
+{
+	if (idx > SIZE_T_MAX - 1)
+		return -1;
+	if (array_list_expand_internal(arr, idx + 1))
+		return -1;
+	if (idx < arr->length && arr->array[idx])
+		arr->free_fn(arr->array[idx]);
+	arr->array[idx] = data;
+	if (idx > arr->length)
+	{
+		/* Zero out the arraylist slots in between the old length
+		   and the newly added entry so we know those entries are
+		   empty.
+		   e.g. when setting array[7] in an array that used to be 
+		   only 5 elements longs, array[5] and array[6] need to be
+		   set to 0.
+		 */
+		memset(arr->array + arr->length, 0, (idx - arr->length) * sizeof(void *));
+	}
+	if (arr->length <= idx)
+		arr->length = idx + 1;
+	return 0;
+}
+
+int array_list_add(struct array_list *arr, void *data)
+{
+	/* Repeat some of array_list_put_idx() so we can skip several
+	   checks that we know are unnecessary when appending at the end
+	 */
+	size_t idx = arr->length;
+	if (idx > SIZE_T_MAX - 1)
+		return -1;
+	if (array_list_expand_internal(arr, idx + 1))
+		return -1;
+	arr->array[idx] = data;
+	arr->length++;
+	return 0;
+}
+
+void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *))
+{
+	qsort(arr->array, arr->length, sizeof(arr->array[0]), compar);
+}
+
+void *array_list_bsearch(const void **key, struct array_list *arr,
+                         int (*compar)(const void *, const void *))
+{
+	return bsearch(key, arr->array, arr->length, sizeof(arr->array[0]), compar);
+}
+
+size_t array_list_length(struct array_list *arr)
+{
+	return arr->length;
+}
+
+int array_list_del_idx(struct array_list *arr, size_t idx, size_t count)
+{
+	size_t i, stop;
+
+	/* Avoid overflow in calculation with large indices. */
+	if (idx > SIZE_T_MAX - count)
+		return -1;
+	stop = idx + count;
+	if (idx >= arr->length || stop > arr->length)
+		return -1;
+	for (i = idx; i < stop; ++i)
+	{
+		// Because put_idx can skip entries, we need to check if
+		// there's actually anything in each slot we're erasing.
+		if (arr->array[i])
+			arr->free_fn(arr->array[i]);
+	}
+	memmove(arr->array + idx, arr->array + stop, (arr->length - stop) * sizeof(void *));
+	arr->length -= count;
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/arraylist.h b/lynq/S300/ap/app/apparms/json-c/arraylist.h
new file mode 100755
index 0000000..f541706
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/arraylist.h
@@ -0,0 +1,88 @@
+/*
+ * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Internal methods for working with json_type_array objects.
+ *        Although this is exposed by the json_object_get_array() method,
+ *        it is not recommended for direct use.
+ */
+#ifndef _json_c_arraylist_h_
+#define _json_c_arraylist_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+
+#define ARRAY_LIST_DEFAULT_SIZE 32
+
+typedef void(array_list_free_fn)(void *data);
+
+struct array_list
+{
+	void **array;
+	size_t length;
+	size_t size;
+	array_list_free_fn *free_fn;
+};
+typedef struct array_list array_list;
+
+/**
+ * Allocate an array_list of the default size (32).
+ * @deprecated Use array_list_new2() instead.
+ */
+extern struct array_list *array_list_new(array_list_free_fn *free_fn);
+
+/**
+ * Allocate an array_list of the desired size.
+ *
+ * If possible, the size should be chosen to closely match
+ * the actual number of elements expected to be used.
+ * If the exact size is unknown, there are tradeoffs to be made:
+ * - too small - the array_list code will need to call realloc() more
+ *   often (which might incur an additional memory copy).
+ * - too large - will waste memory, but that can be mitigated
+ *   by calling array_list_shrink() once the final size is known.
+ *
+ * @see array_list_shrink
+ */
+extern struct array_list *array_list_new2(array_list_free_fn *free_fn, int initial_size);
+
+extern void array_list_free(struct array_list *al);
+
+extern void *array_list_get_idx(struct array_list *al, size_t i);
+
+extern int array_list_put_idx(struct array_list *al, size_t i, void *data);
+
+extern int array_list_add(struct array_list *al, void *data);
+
+extern size_t array_list_length(struct array_list *al);
+
+extern void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *));
+
+extern void *array_list_bsearch(const void **key, struct array_list *arr,
+                                int (*compar)(const void *, const void *));
+
+extern int array_list_del_idx(struct array_list *arr, size_t idx, size_t count);
+
+/**
+ * Shrink the array list to just enough to fit the number of elements in it,
+ * plus empty_slots.
+ */
+extern int array_list_shrink(struct array_list *arr, size_t empty_slots);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/bench/README.bench.md b/lynq/S300/ap/app/apparms/json-c/bench/README.bench.md
new file mode 100755
index 0000000..c37cb1a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/bench/README.bench.md
@@ -0,0 +1,80 @@
+
+Benchmark tests for json-c
+
+General strategy:
+-------------------
+
+* Identify "after" commit hash
+    * Use provided directory
+    * Use provided commit hash
+    * Local changes in current working directory
+    * ${cur_branch}
+* Identify "before" commit hash, in order of preference
+    * Use provided directory
+    * Use provided commit hash
+    * Use origin/${cur_branch}, if different from ${after_commit}
+    * Use previous release
+
+* If not using existing dir, clone to src-${after_commit}
+    * or, checkout appropriate commit in existing src-${after_commit}
+* Create build & install dirs for ${after_commit}
+* Build & install ${after_commit}
+* Compile benchmark programs against install-${after_commit}
+
+* If not using existing dir, clone to src-${before_commit}
+    * or, checkout appropriate commit in existing src-${before_commit}
+* Create build & install dirs for ${before_commit}
+* Build & install ${before_commit}
+* Compile benchmark programs against install-${before_commit}
+
+* Run benchmark in each location
+* Compare results
+
+heaptrack memory profiler
+---------------------------
+
+https://milianw.de/blog/heaptrack-a-heap-memory-profiler-for-linux.html
+
+
+```
+yum install libdwarf-devel elfutils boost-devel libunwind-devel
+
+git clone git://anongit.kde.org/heaptrack
+cd heaptrack
+mkdir build
+cd build
+cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+	-DCMAKE_INSTALL_PREFIX=$HOME/heaptrack-install ..
+make install
+```
+
+
+Issues
+--------
+
+* jc-bench.sh is incomplete.
+
+* valgrind massif misreports "extra-heap" bytes?
+
+    "json_parse -n canada.json" shows 38640 KB maxrss.
+
+    Using valgrind --tool=massif, a large amount of memory is listed as
+     wasted "extra-heap" bytes.  (~5.6MB)
+
+    ```
+    valgrind --tool=massif --massif-out-file=massif.out ./json_parse -n ~/canada.json
+    ms_print massif.out
+    ```
+
+
+    Using heaptrack, and analyzing the histogram, only shows ~2.6MB
+    ```
+    heaptrack ./json_parse -n canada.json
+    heaptrack --analyze heaptrack*gz -H histogram.out
+    awk ' { s=$1; count=$2; ru=(int((s+ 15) / 16)) * 16; wasted = ((ru-s)*count); print s, count, ru-s, wasted; total=total+wasted} END { print "Total: ", total }' histogram.out
+    ```
+
+ With the (unreleased) arraylist trimming changes, maxrss reported by
+  getrusage() goes down, but massif claims *more* total usage, and a HUGE 
+  extra-heap amount (50% of total).
+
diff --git a/lynq/S300/ap/app/apparms/json-c/bench/jc-bench.sh b/lynq/S300/ap/app/apparms/json-c/bench/jc-bench.sh
new file mode 100755
index 0000000..06a0242
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/bench/jc-bench.sh
@@ -0,0 +1,284 @@
+#!/bin/sh
+#
+# Benchmarking harness for json-c
+#
+# Use this to compare the behavior of two different versions of the library,
+# such as json-c-0.14 release vs master, master vs local changes, etc...
+#
+
+set -e
+
+trap 'echo "FAILED!"' EXIT
+
+RUNDIR=$(dirname "$0")
+RUNDIR=$(cd "$RUNDIR" && pwd)
+
+TOP=$(cd "$RUNDIR/.." && pwd)
+
+usage()
+{
+	exitval=$1
+	errmsg=$2
+	if [ $exitval -ne 0 ] ; then
+		exec 1>&2
+	fi
+	if [ ! -z "$errmsg" ] ; then
+		echo "ERROR: $errmsg" 1>&2
+	fi
+	cat <<EOF
+Usage: $0 [-h] [-v] [--build] [--run] [--compare] ...XAX...
+EOF
+
+	exit $extival
+}
+
+before_arg=
+after_arg=
+do_all=1
+do_build=0
+do_run=0
+do_compare=0
+
+while [ $# -gt 0 ] ; do
+	case "$1" in
+	--before)
+		before_arg=$2
+		shift
+		;;
+	--after)
+		after_arg=$2
+		shift
+		;;
+	--build)
+		do_all=0
+		do_build=1
+		;;
+	--run)
+		do_all=0
+		do_run=1
+		;;
+	--compare)
+		do_all=0
+		do_compare=1
+		;;
+	-h)
+		usage 0 ""
+		;;
+	-v)
+		set -x
+		;;
+	*)
+		usage 1 "Unknown args: $*"
+		;;
+	esac
+	shift
+done
+
+WORK="${RUNDIR}/work"
+mkdir -p "${WORK}"
+
+DATA="${RUNDIR}/data"
+mkdir -p "${DATA}"
+
+for file in citm_catalog.json twitter.json canada.json ; do
+	if [ ! -r "${DATA}/${file}" ] ; then
+		echo "Fetching ${file} from github.com/mloskot/json_benchmark"
+		URL="https://github.com/mloskot/json_benchmark/raw/master/data/${file}"
+		curl -s -L -o "${DATA}/${file}" "$URL"
+	fi
+done
+echo
+
+# Identify "after" commit hash, in order of preference
+if [ ! -z "$after_arg" -a -d "$after_arg" ] ; then
+	# Use provided directory
+	after_src_dir="$after_arg"
+	after_commit=
+	echo "Using provided directory [$after_arg] as 'after'"
+else
+	_commit=
+	if [ ! -z "$after_arg" ] ; then
+		# Use provided commit hash
+		_commit=$(git rev-parse --verify "$after_arg")
+	fi
+	if [ ! -z "$_commit" ] ;then
+		after_src_dir=  # i.e. current tree
+		after_commit="$_commit"
+		echo "Using provided commit [$after_arg => $_commit] as 'after'"
+	else
+		# Local changes in current working directory
+		# ${cur_branch}
+		after_src_dir=$TOP
+		after_commit=
+		echo "Using local changes in $TOP as 'after'"
+	fi
+fi
+
+# Identify "before" commit hash, in order of preference
+if [ ! -z "$before_arg" -a -d "$before_arg" ] ; then
+   	# Use provided directory
+	before_src_dir="$before_arg"
+	before_commit=
+	echo "Using provided directory [$before_arg] as 'before'"
+else
+	_commit=
+	if [ ! -z "$before_arg" ] ; then
+		# Use provided commit hash
+		_commit=$(git rev-parse --verify "$before_arg")
+	fi
+	if [ ! -z "$_commit" ] ;then
+		before_src_dir=  # i.e. current tree
+		before_commit="$_commit"
+		echo "Using provided commit [$before_arg => $_commit] as 'before'"
+	else
+		# Use origin/${cur_branch}, if different from ${after_commit}
+		_cur_branch=$(git rev-parse --abbrev-ref HEAD)
+		_commit=
+		if [ ! -z "${_cur_branch}" ] ; then
+			_commit=$(git rev-parse --verify "origin/${_cur_branch}")
+			echo "Using origin/${_cur_branch} [$_commit] as 'before'"
+		fi
+		if [ "$_commit" = "${after_commit}" ] ; then
+			_commit=
+		fi
+	fi
+
+	if [ ! -z "$_commit" ] ; then
+		before_src_dir=  # i.e. current tree
+		before_commit="$_commit"
+	else
+		# Use previous release
+		before_src_dir=  # i.e. current tree
+		before_commit="$(git tag | sort | tail -1)"
+		echo "Using previous release [$before_commit] as 'before'"
+	fi
+fi
+
+echo
+
+compile_benchmark()
+{
+	local bname=$1
+	local src_dir="$2"
+	local src_commit="$3"
+
+	local build_dir="${WORK}/$bname/build"
+	local inst_dir="${WORK}/$bname/install"
+	local bench_dir="${WORK}/$bname/bench"
+
+	echo
+	echo "=========== $bname ==========="
+	echo
+
+	mkdir -p "${build_dir}"
+	mkdir -p "${inst_dir}"
+	mkdir -p "${bench_dir}"
+
+	if [ ! -z "$src_commit" ] ; then
+		# Resolve the short hash, tag or branch name to full hash
+		src_commit=$(git rev-parse $src_commit)
+	fi
+
+	# No src dir specified, clone and checkout $src_commit
+	if [ -z "$src_dir" ] ; then
+		src_dir="${WORK}/$bname/src"
+		echo "=== Using sources in $src_dir"
+		mkdir -p "$src_dir"
+		at_commit=$(git --git-dir="$src_dir/.git" rev-parse HEAD 2> /dev/null || true)
+		echo "at_commit: $at_commit"
+		if [ -z "$at_commit" ] ; then
+			# Assume it's an empty dir
+			git clone -n "$TOP" "$src_dir"
+		fi
+		git -C "$src_dir" --git-dir="$src_dir/.git" checkout "$src_commit"
+	fi
+	# else, use the provided $src_dir
+
+	if [ -e "${src_dir}/CMakeLists.txt" ] ; then
+		cd "${build_dir}"
+		cmake -DCMAKE_INSTALL_PREFIX="${inst_dir}" "${src_dir}"
+	else
+		# Old versions of json-c used automake/autoconf
+		cd "${src_dir}"
+		sh autogen.sh   # always run it, configure doesn't always work
+		cd "${build_dir}"
+		"${src_dir}/configure" --prefix="${inst_dir}"
+	fi
+	make all install
+
+	cd "${bench_dir}"
+	cmake -DCMAKE_PREFIX_PATH="${inst_dir}" "${TOP}/apps"
+	make all
+}
+
+# XXX TODO: name "after" and "before" uniquely using the dir & commit
+
+if [ $do_all -ne 0 -o $do_build -ne 0 ] ; then
+	sleep 5   # Wait slightly, to allow the human to read the message
+	          #  about what exactly we're doing to benchmark.
+	compile_benchmark "after" "${after_src_dir}" "${after_commit}"
+	compile_benchmark "before" "${before_src_dir}" "${before_commit}"
+fi
+
+run_benchmark()
+{
+	local bname=$1
+	local inst_dir="${WORK}/$bname/install"
+	local bench_dir="${WORK}/$bname/bench"
+
+	local INPUT=${DATA}/canada.json
+
+	cd "${bench_dir}"
+	mkdir -p results
+	(time ./json_parse -n "${INPUT}") > results/basic_timing.out 2>&1
+	valgrind --tool=massif --massif-out-file=massif.out ./json_parse -n "${INPUT}"
+	ms_print massif.out > results/ms_print.out
+	heaptrack -o heaptrack_out ./json_parse -n "${INPUT}"
+	heaptrack --analyze heaptrack_out.gz -H histogram.out > results/heaptrack.out
+	awk ' { s=$1; count=$2; ru=(int((s+ 15) / 16)) * 16; wasted = ((ru-s)*count); print s, count, ru-s, wasted; total=total+wasted} END { print "Total: ", total }' histogram.out > results/histogram2.out
+
+	# XXX stamp some info about what was built & run into ./results/.
+
+	echo "DONE with $bname"
+}
+
+if [ $do_all -ne 0 -o $do_run -ne 0 ] ; then
+	run_benchmark "after"
+	run_benchmark "before"
+fi
+
+if [ $do_compare -ne 0 ] ; then
+	# XXX this needs better analysis
+	cd "${WORK}"
+	diff -udr before/bench/results after/bench/results || true
+else
+	echo "To compare results, run:"
+	echo "$0 --compare"
+fi
+
+trap '' EXIT
+
+:<<=cut
+
+Benchmarks to run:
+
+* Parse JSON strings, of various sizes and characteristics
+    * Flags: STRICT vs. non-STRICT, validate UTF8
+
+* Serialization time
+    * plain, spaces, pretty
+
+* json_c_visit tests
+* JSON pointer tests
+
+Things to record and compare:
+
+* Running time
+* Peak memory usage
+* Useful bytes vs. overhead for memory allocations
+* Total number of allocations
+* Average allocation size
+* Log of all allocation sizes
+
+=cut
+
diff --git a/lynq/S300/ap/app/apparms/json-c/cmake-configure b/lynq/S300/ap/app/apparms/json-c/cmake-configure
new file mode 100755
index 0000000..7110bd0
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/cmake-configure
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+# Wrapper around cmake to emulate useful options
+# from the previous autoconf-based configure script.
+
+RUNDIR=$(dirname "$0")
+RUNDIR=$(cd "$RUNDIR" && pwd)
+CURDIR=$(pwd)
+
+FLAGS=()
+
+usage()
+{
+	exitval="$1"
+	errmsg="$2"
+
+	if [ $exitval -ne 0 ] ; then
+		exec 1>&2
+	fi
+	if [ ! -z "$errmsg" ] ; then
+		echo "ERROR: $errmsg" 1>&2
+	fi
+	cat <<EOF
+$0 [<configure_options>] [-- [<cmake options>]]
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+  --enable-threading      Enable code to support partly multi-threaded use
+  --enable-rdrand         Enable RDRAND Hardware RNG Hash Seed generation on
+                          supported x86/x64 platforms.
+  --enable-shared         build shared libraries [default=yes]
+  --enable-static         build static libraries [default=yes]
+  --disable-Bsymbolic     Avoid linking with -Bsymbolic-function
+  --disable-werror        Avoid treating compiler warnings as fatal errors
+  --disable-extra-libs    Avoid linking against extra libraries, such as libbsd
+
+EOF
+	exit
+}
+
+if [ "$CURDIR" = "$RUNDIR" ] ; then
+	usage 1 "Please mkdir some other build directory, and run this script from there."
+fi
+
+if ! cmake --version ; then
+	usage 1 "Unable to find a working cmake, please be sure you have it installed and on your PATH"
+fi
+
+while [ $# -gt 0 ] ; do
+	case "$1" in
+	-h|--help)
+		usage 0
+		;;
+	--prefix)
+		FLAGS+=(-DCMAKE_INSTALL_PREFIX="$2")
+		shift
+		;;
+	--prefix=*)
+		FLAGS+=(-DCMAKE_INSTALL_PREFIX="${1##--prefix=}")
+		;;
+	--enable-threading)
+		FLAGS+=(-DENABLE_THREADING=ON)
+		;;
+	--enable-rdrand)
+		FLAGS+=(-DENABLE_RDRAND=ON)
+		;;
+	--enable-shared)
+		FLAGS+=(-DBUILD_SHARED_LIBS=ON)
+		;;
+	--disable-shared)
+		FLAGS+=(-DBUILD_SHARED_LIBS=OFF)
+		;;
+	--enable-static)
+		FLAGS+=(-DBUILD_STATIC_LIBS=ON)
+		;;
+	--disable-static)
+		FLAGS+=(-DBUILD_STATIC_LIBS=OFF)
+		;;
+	--disable-Bsymbolic)
+		FLAGS+=(-DDISABLE_BSYMBOLIC=ON)
+		;;
+	--disable-werror)
+		FLAGS+=(-DDISABLE_WERROR=ON)
+		;;
+	--disable-extra-libs)
+		FLAGS+=(-DDISABLE_EXTRA_LIBS=ON)
+		;;
+	--)
+		shift
+		break
+		;;
+	-*)
+		usage 1 "Unknown arguments: $*"
+		;;
+	*)
+		break
+		;;
+	esac
+	shift
+done
+
+exec cmake "${FLAGS[@]}" "$@" "${RUNDIR}"
diff --git a/lynq/S300/ap/app/apparms/json-c/cmake/Config.cmake.in b/lynq/S300/ap/app/apparms/json-c/cmake/Config.cmake.in
new file mode 100755
index 0000000..035dc0f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/cmake/Config.cmake.in
@@ -0,0 +1,4 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
+check_required_components("@PROJECT_NAME@")
diff --git a/lynq/S300/ap/app/apparms/json-c/cmake/config.h.in b/lynq/S300/ap/app/apparms/json-c/cmake/config.h.in
new file mode 100755
index 0000000..be0202a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/cmake/config.h.in
@@ -0,0 +1,228 @@
+
+/* Enable RDRAND Hardware RNG Hash Seed */
+#cmakedefine ENABLE_RDRAND "@ENABLE_RDRAND@"
+
+/* Override json_c_get_random_seed() with custom code */
+#cmakedefine OVERRIDE_GET_RANDOM_SEED @OVERRIDE_GET_RANDOM_SEED@
+
+/* Enable partial threading support */
+#cmakedefine ENABLE_THREADING "@@"
+
+/* Define if .gnu.warning accepts long strings. */
+#cmakedefine HAS_GNU_WARNING_LONG "@@"
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <endian.h> header file. */
+#cmakedefine HAVE_ENDIAN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#cmakedefine HAVE_FCNTL_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#cmakedefine HAVE_LIMITS_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#cmakedefine HAVE_LOCALE_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#cmakedefine HAVE_STDARG_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#cmakedefine HAVE_SYSLOG_H @HAVE_SYSLOG_H@
+
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#cmakedefine HAVE_SYS_CDEFS_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#cmakedefine HAVE_SYS_PARAM_H @HAVE_SYS_PARAM_H@
+
+/* Define to 1 if you have the <sys/random.h> header file. */
+#cmakedefine HAVE_SYS_RANDOM_H
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#cmakedefine HAVE_SYS_RESOURCE_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
+
+/* Define to 1 if you have the <xlocale.h> header file. */
+#cmakedefine HAVE_XLOCALE_H
+
+/* Define to 1 if you have the <bsd/stdlib.h> header file. */
+#cmakedefine HAVE_BSD_STDLIB_H
+
+/* Define to 1 if you have `arc4random' */
+#cmakedefine HAVE_ARC4RANDOM
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#cmakedefine HAVE_DOPRNT
+
+/* Has atomic builtins */
+#cmakedefine HAVE_ATOMIC_BUILTINS
+
+/* Define to 1 if you have the declaration of `INFINITY', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_INFINITY
+
+/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
+   */
+#cmakedefine HAVE_DECL_ISINF
+
+/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
+   */
+#cmakedefine HAVE_DECL_ISNAN
+
+/* Define to 1 if you have the declaration of `nan', and to 0 if you don't. */
+#cmakedefine HAVE_DECL_NAN
+
+/* Define to 1 if you have the declaration of `_finite', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL__FINITE
+
+/* Define to 1 if you have the declaration of `_isnan', and to 0 if you don't.
+   */
+#cmakedefine HAVE_DECL__ISNAN
+
+/* Define to 1 if you have the `open' function. */
+#cmakedefine HAVE_OPEN
+
+/* Define to 1 if you have the `realloc' function. */
+#cmakedefine HAVE_REALLOC
+
+/* Define to 1 if you have the `setlocale' function. */
+#cmakedefine HAVE_SETLOCALE
+
+/* Define to 1 if you have the `snprintf' function. */
+#cmakedefine HAVE_SNPRINTF
+
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#cmakedefine HAVE_STRCASECMP @HAVE_STRCASECMP@
+
+/* Define to 1 if you have the `strdup' function. */
+#cmakedefine HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#cmakedefine HAVE_STRERROR
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#cmakedefine HAVE_STRNCASECMP @HAVE_STRNCASECMP@
+
+/* Define to 1 if you have the `uselocale' function. */
+#cmakedefine HAVE_USELOCALE
+
+/* Define to 1 if you have the `vasprintf' function. */
+#cmakedefine HAVE_VASPRINTF
+
+/* Define to 1 if you have the `vprintf' function. */
+#cmakedefine HAVE_VPRINTF
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#cmakedefine HAVE_VSNPRINTF
+
+/* Define to 1 if you have the `vsyslog' function. */
+#cmakedefine HAVE_VSYSLOG @HAVE_VSYSLOG@
+
+/* Define if you have the `getrandom' function. */
+#cmakedefine HAVE_GETRANDOM
+
+/* Define if you have the `getrusage' function. */
+#cmakedefine HAVE_GETRUSAGE
+
+#cmakedefine HAVE_STRTOLL
+#if !defined(HAVE_STRTOLL)
+#define strtoll @json_c_strtoll@
+/* #cmakedefine json_c_strtoll @json_c_strtoll@*/
+#endif
+
+#cmakedefine HAVE_STRTOULL
+#if !defined(HAVE_STRTOULL)
+#define strtoull @json_c_strtoull@
+/* #cmakedefine json_c_strtoull @json_c_strtoull@ */
+#endif
+
+/* Have __thread */
+#cmakedefine HAVE___THREAD
+
+/* Public define for json_inttypes.h */
+#cmakedefine JSON_C_HAVE_INTTYPES_H @JSON_C_HAVE_INTTYPES_H@
+
+/* Name of package */
+#define PACKAGE "@PROJECT_NAME@"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "@JSON_C_BUGREPORT@"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "@PROJECT_NAME@"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "@PROJECT_NAME@ @CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "@PROJECT_NAME@"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "https://github.com/json-c/json-c"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
+
+/* The number of bytes in type int */
+#cmakedefine SIZEOF_INT @SIZEOF_INT@
+
+/* The number of bytes in type int64_t */
+#cmakedefine SIZEOF_INT64_T @SIZEOF_INT64_T@
+
+/* The number of bytes in type long */
+#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
+
+/* The number of bytes in type long long */
+#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
+
+/* The number of bytes in type size_t */
+#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
+
+/* The number of bytes in type ssize_t */
+#cmakedefine SIZEOF_SSIZE_T @SIZEOF_SSIZE_T@
+
+/* Specifier for __thread */
+#cmakedefine SPEC___THREAD @SPEC___THREAD@
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS
+
+/* Version number of package */
+#define VERSION "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#cmakedefine const
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#cmakedefine size_t
diff --git a/lynq/S300/ap/app/apparms/json-c/cmake/json_config.h.in b/lynq/S300/ap/app/apparms/json-c/cmake/json_config.h.in
new file mode 100755
index 0000000..f30d8a6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/cmake/json_config.h.in
@@ -0,0 +1,2 @@
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine JSON_C_HAVE_INTTYPES_H @JSON_C_HAVE_INTTYPES_H@
diff --git a/lynq/S300/ap/app/apparms/json-c/debug.c b/lynq/S300/ap/app/apparms/json-c/debug.c
new file mode 100755
index 0000000..7971744
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/debug.c
@@ -0,0 +1,96 @@
+/*
+ * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if HAVE_SYSLOG_H
+#include <syslog.h>
+#endif /* HAVE_SYSLOG_H */
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
+
+#include "debug.h"
+
+static int _syslog = 0;
+static int _debug = 0;
+
+void mc_set_debug(int debug)
+{
+	_debug = debug;
+}
+int mc_get_debug(void)
+{
+	return _debug;
+}
+
+extern void mc_set_syslog(int syslog)
+{
+	_syslog = syslog;
+}
+
+void mc_debug(const char *msg, ...)
+{
+	va_list ap;
+	if (_debug)
+	{
+		va_start(ap, msg);
+#if HAVE_VSYSLOG
+		if (_syslog)
+		{
+			vsyslog(LOG_DEBUG, msg, ap);
+		}
+		else
+#endif
+			vprintf(msg, ap);
+		va_end(ap);
+	}
+}
+
+void mc_error(const char *msg, ...)
+{
+	va_list ap;
+	va_start(ap, msg);
+#if HAVE_VSYSLOG
+	if (_syslog)
+	{
+		vsyslog(LOG_ERR, msg, ap);
+	}
+	else
+#endif
+		vfprintf(stderr, msg, ap);
+	va_end(ap);
+}
+
+void mc_info(const char *msg, ...)
+{
+	va_list ap;
+	va_start(ap, msg);
+#if HAVE_VSYSLOG
+	if (_syslog)
+	{
+		vsyslog(LOG_INFO, msg, ap);
+	}
+	else
+#endif
+		vfprintf(stderr, msg, ap);
+	va_end(ap);
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/debug.h b/lynq/S300/ap/app/apparms/json-c/debug.h
new file mode 100755
index 0000000..4af0ba9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/debug.h
@@ -0,0 +1,98 @@
+/*
+ * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+#ifndef _JSON_C_DEBUG_H_
+#define _JSON_C_DEBUG_H_
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+JSON_EXPORT void mc_set_debug(int debug);
+JSON_EXPORT int mc_get_debug(void);
+
+JSON_EXPORT void mc_set_syslog(int syslog);
+
+JSON_EXPORT void mc_debug(const char *msg, ...);
+JSON_EXPORT void mc_error(const char *msg, ...);
+JSON_EXPORT void mc_info(const char *msg, ...);
+
+#ifndef __STRING
+#define __STRING(x) #x
+#endif
+
+#ifndef PARSER_BROKEN_FIXED
+
+#define JASSERT(cond) \
+	do            \
+	{             \
+	} while (0)
+
+#else
+
+#define JASSERT(cond)                                                                              \
+	do                                                                                         \
+	{                                                                                          \
+		if (!(cond))                                                                       \
+		{                                                                                  \
+			mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", \
+			         __FILE__, __LINE__);                                              \
+			*(int *)0 = 1;                                                             \
+			abort();                                                                   \
+		}                                                                                  \
+	} while (0)
+
+#endif
+
+#define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
+
+#ifdef MC_MAINTAINER_MODE
+#define MC_SET_DEBUG(x) mc_set_debug(x)
+#define MC_GET_DEBUG() mc_get_debug()
+#define MC_SET_SYSLOG(x) mc_set_syslog(x)
+#define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
+#define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
+#else
+#define MC_SET_DEBUG(x) \
+	if (0)          \
+	mc_set_debug(x)
+#define MC_GET_DEBUG() (0)
+#define MC_SET_SYSLOG(x) \
+	if (0)           \
+	mc_set_syslog(x)
+#define MC_DEBUG(x, ...) \
+	if (0)           \
+	mc_debug(x, ##__VA_ARGS__)
+#define MC_INFO(x, ...) \
+	if (0)          \
+	mc_info(x, ##__VA_ARGS__)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/doc/CMakeLists.txt b/lynq/S300/ap/app/apparms/json-c/doc/CMakeLists.txt
new file mode 100755
index 0000000..4872d8e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/doc/CMakeLists.txt
@@ -0,0 +1,16 @@
+# generate doxygen documentation for json-c API
+
+find_package(Doxygen)
+
+if (DOXYGEN_FOUND)
+
+	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
+	  ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+	message(STATUS "Wrote ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
+
+	add_custom_target(doc
+	COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+
+else (DOXYGEN_FOUND)
+	message("Warning: doxygen not found, the 'doc' target will not be included")
+endif(DOXYGEN_FOUND)
diff --git a/lynq/S300/ap/app/apparms/json-c/doc/Doxyfile.in b/lynq/S300/ap/app/apparms/json-c/doc/Doxyfile.in
new file mode 100755
index 0000000..46fc76e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/doc/Doxyfile.in
@@ -0,0 +1,2366 @@
+# Doxyfile 1.8.8
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See https://www.gnu.org/software/libiconv
+# for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME           = json-c
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER         = @PROJECT_VERSION@
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
+# the documentation. The maximum height of the logo should not exceed 55 pixels
+# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
+# to the output directory.
+
+PROJECT_LOGO           =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS         = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES    = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES        = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
+# new page for each member. If set to NO, the documentation of a member will be
+# part of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines.
+
+ALIASES                =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST              =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See https://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT       = YES
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by by putting a % sign in front of the word
+# or globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# https://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES  = NO
+
+# This flag is only useful for Objective-C code. When set to YES local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO these classes will be included in the various overviews. This option has
+# no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO these declarations will be
+# included in the documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES     = NO
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC  = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the
+# todo list. This list is created by putting \todo commands in the
+# documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the
+# test list. This list is created by putting \test commands in the
+# documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES the list
+# will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE            =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES         =
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS               = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO doxygen will only warn about wrong or incomplete parameter
+# documentation, but not about the absence of documentation.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE           =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces.
+# Note: If this tag is empty the current directory is searched.
+
+INPUT                  = @CMAKE_SOURCE_DIR@ @CMAKE_BINARY_DIR@
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: https://www.gnu.org/software/libiconv) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank the
+# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
+# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
+# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
+# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
+# *.qsf, *.as and *.js.
+
+FILE_PATTERNS          = *.h \
+                         *.md
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = \
+	*/json_object_private.h \
+	*/debug.h \
+	*/*config.h \
+	*/random_seed.h \
+	*/strerror_*h \
+	*/*compat.h
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS        = \
+	_json_c_* \
+	_LH_* \
+	_printbuf_* \
+	__STRING
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+
+INPUT_FILTER           = @CMAKE_CURRENT_SOURCE_DIR@/fixup_markdown.sh
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER ) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE = README.md
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION    = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES, then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS        = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see https://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS       = NO
+
+# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
+# clang parser (see: https://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# compiled with the --with-libclang option.
+# The default value is: NO.
+
+#CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+#CLANG_OPTIONS          =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX     = NO
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX          =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET        =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra stylesheet files is of importance (e.g. the last
+# stylesheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET  =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the stylesheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: https://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See
+# https://developer.apple.com/library/archive/featuredarticles/DoxygenXcode/
+# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET        = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP      = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE               =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler ( hhc.exe). If non-empty
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION           =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated (
+# YES) or that it should be included in the master .chm file ( NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI           = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING     =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated (
+# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# https://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using prerendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# https://docs.mathjax.org/en/latest/output/) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdn.mathjax.org/mathjax/latest.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH        = https://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS     =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: https://docs.mathjax.org/en/latest/output/) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE       =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL       =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID     =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS  =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. To get the times font for
+# instance you can specify
+# EXTRA_PACKAGES=times
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty string,
+# for the replacement values of the other commands the user is referred to
+# HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER           =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER           =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES      =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE        = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES     = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE    =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION          = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR             =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT             = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK       = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT         = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen
+# Definitions (see http://autogen.sf.net) file that captures the structure of
+# the code including all documentation. Note that this feature is still
+# experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names
+# in the source code. If set to NO only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION        = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF     = YES
+
+# If the SEARCH_INCLUDES tag is set to YES the includes files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH           =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED             = \
+	_LH_INLINE=inline \
+	JSON_C_CONST_FUNCTION(func)=func
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES all external class will be listed in the
+# class index. If set to NO only the inherited external classes will be listed.
+# The default value is: NO.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in
+# the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS        = YES
+
+# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES         = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# https://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH               =
+
+# If set to YES, the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# https://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: YES.
+
+HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS        = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH          = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot.
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
+# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
+# gif:cairo:gd, gif:gd, gif:gd:gd and svg.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG        = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS           =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS           =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS           =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+PLANTUML_JAR_PATH      =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP            = YES
diff --git a/lynq/S300/ap/app/apparms/json-c/doc/fixup_markdown.sh b/lynq/S300/ap/app/apparms/json-c/doc/fixup_markdown.sh
new file mode 100755
index 0000000..452eb78
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/doc/fixup_markdown.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+# Doxygen markdown doesn't support triple-backticks like github does.
+# Convert all of those to space-prefixed blocks instead.
+#
+awk '/```/ { prefix=!prefix; print ""; next; } { if (prefix) { printf "    "; } print $0; } ' "$@"
diff --git a/lynq/S300/ap/app/apparms/json-c/fuzz/README.md b/lynq/S300/ap/app/apparms/json-c/fuzz/README.md
new file mode 100755
index 0000000..237c1da
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/fuzz/README.md
@@ -0,0 +1,6 @@
+# Fuzzers
+
+This directory contains fuzzers that
+target [llvm's LibFuzzer](https://llvm.org/docs/LibFuzzer.html). They are built
+and run automatically by
+Google's [OSS-Fuzz](https://github.com/google/oss-fuzz/) infrastructure.
diff --git a/lynq/S300/ap/app/apparms/json-c/fuzz/build.sh b/lynq/S300/ap/app/apparms/json-c/fuzz/build.sh
new file mode 100755
index 0000000..7a42e0b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/fuzz/build.sh
@@ -0,0 +1,52 @@
+#!/bin/bash -eu
+# Copyright 2018 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+################################################################################
+
+# This should be run from the top of the json-c source tree.
+
+mkdir build
+cd build
+cmake -DBUILD_SHARED_LIBS=OFF ..
+make -j$(nproc)
+
+LIB=$(pwd)/libjson-c.a
+cd ..
+
+# These seem to be set externally, but let's assign defaults to
+# make it possible to at least partially test this standalone.
+: ${SRC:=$(dirname "$0")}
+: ${OUT:=$SRC/out}
+: ${CXX:=gcc}
+: ${CXXFLAGS:=}
+
+[ -d "$OUT" ] || mkdir "$OUT"
+cp $SRC/*.dict $OUT/.
+
+# XXX this doesn't seem to make much sense, since $SRC is presumably
+# the "fuzz" directory, which is _inside_ the json-c repo, rather than
+# the other way around, but I'm just preserving existing behavior. -erh
+INCS=$SRC/json-c
+# Compat when testing standalone
+[ -e "${INCS}" ] || ln -s .. "${INCS}"
+
+set -x
+set -v
+for f in $SRC/*_fuzzer.cc; do
+    fuzzer=$(basename "$f" _fuzzer.cc)
+    $CXX $CXXFLAGS -std=c++11 -I$INCS \
+         $SRC/${fuzzer}_fuzzer.cc -o $OUT/${fuzzer}_fuzzer \
+         -lFuzzingEngine $LIB
+done
diff --git a/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.cc b/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.cc
new file mode 100755
index 0000000..f058e0f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.cc
@@ -0,0 +1,20 @@
+#include <stdint.h>
+
+#include <json.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+	const char *data1 = reinterpret_cast<const char *>(data);
+	json_tokener *tok = json_tokener_new();
+	json_object *obj = json_tokener_parse_ex(tok, data1, size);
+	
+	json_object_object_foreach(jobj, key, val) {
+		(void)json_object_get_type(val);
+		(void)json_object_get_string(val);
+	}
+	(void)json_object_to_json_string(obj, JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED);
+	
+	json_object_put(obj);
+	json_tokener_free(tok);
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.dict b/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.dict
new file mode 100755
index 0000000..23c6fa2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/fuzz/tokener_parse_ex_fuzzer.dict
@@ -0,0 +1,18 @@
+"{"
+"}"
+","
+"["
+"]"
+","
+":"
+"e"
+"e+"
+"e-"
+"E"
+"E+"
+"E-"
+"\""
+"null"
+"1"
+"1.234"
+"3e4"
diff --git a/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.13.md b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.13.md
new file mode 100755
index 0000000..f3e932c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.13.md
@@ -0,0 +1,270 @@
+
+This list was created with:
+
+```
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=1" > issues1.out
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=2" > issues2.out
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2014-04-10+created%3A<2017-12-01&sort=created&order=asc&per_page=400&page=3" > issues3.out
+jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out  > issues.md
+sed -e's,^\[ *\(.*\)\](https://api.github.com/.*/\([0-9].*\)),[Issue #\2](https://github.com/json-c/json-c/issues/\2) - \1,' -i issues.md
+#... manual editing ...
+```
+
+----
+
+Issues and Pull Requests closed for the 0.13 release
+(since commit f84d9c, the 0.12 branch point, 2014-04-10)
+
+
+* [Issue #61](https://github.com/json-c/json-c/issues/61) - Make json_object_object_add() indicate success or failure, test fix \
+* [Issue #113](https://github.com/json-c/json-c/issues/113) - Build fixes (make dist and make distcheck) \
+* [Issue #124](https://github.com/json-c/json-c/issues/124) - Fixing build \
+* [Issue #125](https://github.com/json-c/json-c/issues/125) - Fix compile error(variable size set but not used) on g++4.6 \
+* [Issue #126](https://github.com/json-c/json-c/issues/126) - Removed unused size variable. \
+* [Issue #127](https://github.com/json-c/json-c/issues/127) - remove unused `size` variable \
+* [Issue #128](https://github.com/json-c/json-c/issues/128) - Remove unused variable from json_tokenizer.c \
+* [Issue #130](https://github.com/json-c/json-c/issues/130) - Failed to compile under Ubuntu 13.10 32bit \
+* [Issue #131](https://github.com/json-c/json-c/issues/131) - undefined symbol: __sync_val_compare_and_swap_4 \
+* [Issue #132](https://github.com/json-c/json-c/issues/132) - Remove unused variable 'size' \
+* [Issue #133](https://github.com/json-c/json-c/issues/133) - Update and rename README to README.md \
+* [Issue #134](https://github.com/json-c/json-c/issues/134) - Must remove variable size... \
+* [Issue #135](https://github.com/json-c/json-c/issues/135) - bits.h uses removed json_tokener_errors\[error\] \
+* [Issue #136](https://github.com/json-c/json-c/issues/136) - Error when running make check \
+* [Issue #137](https://github.com/json-c/json-c/issues/137) - config.h.in should not be in git \
+* [Issue #138](https://github.com/json-c/json-c/issues/138) - Can't build on RHEL 6.5 due to dependency on automake-1.14 \
+* [Issue #140](https://github.com/json-c/json-c/issues/140) - Code bug in random_test.c evaluating same expression twice \
+* [Issue #141](https://github.com/json-c/json-c/issues/141) - Removed duplicate check in random_seed test - bug #140 \
+* [Issue #142](https://github.com/json-c/json-c/issues/142) - Please undeprecate json_object_object_get \
+* [Issue #144](https://github.com/json-c/json-c/issues/144) - Introduce json_object_from_fd \
+* [Issue #145](https://github.com/json-c/json-c/issues/145) - Handle % character properly \
+* [Issue #146](https://github.com/json-c/json-c/issues/146) - TAGS rename \
+* [Issue #148](https://github.com/json-c/json-c/issues/148) - Bump the soname \
+* [Issue #149](https://github.com/json-c/json-c/issues/149) - SONAME bump \
+* [Issue #150](https://github.com/json-c/json-c/issues/150) - Fix build using MinGW. \
+* [Issue #151](https://github.com/json-c/json-c/issues/151) - Remove json_type enum trailing comma \
+* [Issue #152](https://github.com/json-c/json-c/issues/152) - error while compiling json-c library version 0.11 \
+* [Issue #153](https://github.com/json-c/json-c/issues/153) - improve doc for json_object_to_json_string() \
+* [Issue #154](https://github.com/json-c/json-c/issues/154) - double precision \
+* [Issue #155](https://github.com/json-c/json-c/issues/155) - add bsearch for arrays \
+* [Issue #156](https://github.com/json-c/json-c/issues/156) - Remove trailing whitespaces \
+* [Issue #157](https://github.com/json-c/json-c/issues/157) - JSON-C shall not exit on calloc fail. \
+* [Issue #158](https://github.com/json-c/json-c/issues/158) - while using json-c 0.11, I am facing strange crash issue in json_object_put. \
+* [Issue #159](https://github.com/json-c/json-c/issues/159) - json_tokener.c compile error \
+* [Issue #160](https://github.com/json-c/json-c/issues/160) - missing header file on windows?? \
+* [Issue #161](https://github.com/json-c/json-c/issues/161) - Is there a way to append to file? \
+* [Issue #162](https://github.com/json-c/json-c/issues/162) - json_util: add directory check for POSIX distros \
+* [Issue #163](https://github.com/json-c/json-c/issues/163) - Fix Win32 build problems \
+* [Issue #164](https://github.com/json-c/json-c/issues/164) - made it compile and link on Widnows (as static library) \
+* [Issue #165](https://github.com/json-c/json-c/issues/165) - json_object_to_json_string_ext length \
+* [Issue #167](https://github.com/json-c/json-c/issues/167) - Can't build on Windows with Visual Studio 2010 \
+* [Issue #168](https://github.com/json-c/json-c/issues/168) - Tightening the number parsing algorithm \
+* [Issue #169](https://github.com/json-c/json-c/issues/169) - Doesn't compile on ubuntu 14.04, 64bit \
+* [Issue #170](https://github.com/json-c/json-c/issues/170) - Generated files in repository \
+* [Issue #171](https://github.com/json-c/json-c/issues/171) - Update configuration for VS2010 and win64 \
+* [Issue #172](https://github.com/json-c/json-c/issues/172) - Adding support for parsing octal numbers \
+* [Issue #173](https://github.com/json-c/json-c/issues/173) - json_parse_int64 doesn't work correctly at illumos \
+* [Issue #174](https://github.com/json-c/json-c/issues/174) - Adding JSON_C_TO_STRING_PRETTY_TAB flag \
+* [Issue #175](https://github.com/json-c/json-c/issues/175) - make check fails 4 tests with overflows when built with ASAN \
+* [Issue #176](https://github.com/json-c/json-c/issues/176) - Possible to delete an array element at a given idx ? \
+* [Issue #177](https://github.com/json-c/json-c/issues/177) - Fix compiler warnings \
+* [Issue #178](https://github.com/json-c/json-c/issues/178) - Unable to compile on CentOS5 \
+* [Issue #179](https://github.com/json-c/json-c/issues/179) - Added array_list_del_idx and json_object_array_del_idx \
+* [Issue #180](https://github.com/json-c/json-c/issues/180) - Enable silent build by default \
+* [Issue #181](https://github.com/json-c/json-c/issues/181) - json_tokener_parse_ex accepts invalid JSON \
+* [Issue #182](https://github.com/json-c/json-c/issues/182) - Link against libm when needed \
+* [Issue #183](https://github.com/json-c/json-c/issues/183) - Apply compile warning fix to master branch \
+* [Issue #184](https://github.com/json-c/json-c/issues/184) - Use only GCC-specific flags when compiling with GCC \
+* [Issue #185](https://github.com/json-c/json-c/issues/185) - compile error \
+* [Issue #186](https://github.com/json-c/json-c/issues/186) - Syntax error \
+* [Issue #187](https://github.com/json-c/json-c/issues/187) - array_list_get_idx and negative indexes. \
+* [Issue #188](https://github.com/json-c/json-c/issues/188) - json_object_object_foreach warnings \
+* [Issue #189](https://github.com/json-c/json-c/issues/189) - noisy json_object_from_file: error opening file \
+* [Issue #190](https://github.com/json-c/json-c/issues/190) - warning: initialization discards const qualifier from pointer target type \[enabled by default\] \
+* [Issue #192](https://github.com/json-c/json-c/issues/192) - json_tokener_parse  accepts invalid JSON {"key": "value" ,  } \
+* [Issue #193](https://github.com/json-c/json-c/issues/193) - Make serialization format of doubles configurable \
+* [Issue #194](https://github.com/json-c/json-c/issues/194) - Add utility function for comparing json_objects \
+* [Issue #195](https://github.com/json-c/json-c/issues/195) - Call uselocale instead of setlocale \
+* [Issue #196](https://github.com/json-c/json-c/issues/196) - Performance improvements \
+* [Issue #197](https://github.com/json-c/json-c/issues/197) - Time for a new release? \
+* [Issue #198](https://github.com/json-c/json-c/issues/198) - Fix possible memory leak and remove superfluous NULL checks before free() \
+* [Issue #199](https://github.com/json-c/json-c/issues/199) - Fix build in Visual Studio \
+* [Issue #200](https://github.com/json-c/json-c/issues/200) - Add build scripts for CI platforms \
+* [Issue #201](https://github.com/json-c/json-c/issues/201) - disable forward-slash escaping? \
+* [Issue #202](https://github.com/json-c/json-c/issues/202) - Array with objects support \
+* [Issue #203](https://github.com/json-c/json-c/issues/203) - Add source position/coordinates to API \
+* [Issue #204](https://github.com/json-c/json-c/issues/204) - json-c/json.h not found \
+* [Issue #205](https://github.com/json-c/json-c/issues/205) - json-c Compiled with Visual Studios \
+* [Issue #206](https://github.com/json-c/json-c/issues/206) - what do i use in place of json_object_object_get? \
+* [Issue #207](https://github.com/json-c/json-c/issues/207) - Add support for property pairs directly added to arrays \
+* [Issue #208](https://github.com/json-c/json-c/issues/208) - Performance enhancements (mainly) to json_object_to_json_string() \
+* [Issue #209](https://github.com/json-c/json-c/issues/209) - fix regression from 2d549662be832da838aa063da2efa78ee3b99668 \
+* [Issue #210](https://github.com/json-c/json-c/issues/210) - Use size_t for arrays \
+* [Issue #211](https://github.com/json-c/json-c/issues/211) - Atomic updates for the refcount \
+* [Issue #212](https://github.com/json-c/json-c/issues/212) - Refcount doesn't work between threads \
+* [Issue #213](https://github.com/json-c/json-c/issues/213) - fix to compile with microsoft visual c++ 2010 \
+* [Issue #214](https://github.com/json-c/json-c/issues/214) - Some non-GNU systems support __sync_val_compare_and_swap \
+* [Issue #215](https://github.com/json-c/json-c/issues/215) - Build json-c for window 64 bit. \
+* [Issue #216](https://github.com/json-c/json-c/issues/216) - configure: check realloc with AC_CHECK_FUNCS() to fix cross-compilation. \
+* [Issue #217](https://github.com/json-c/json-c/issues/217) - Checking for functions in float.h \
+* [Issue #218](https://github.com/json-c/json-c/issues/218) - Use a macro to indicate C99 to the compiler \
+* [Issue #219](https://github.com/json-c/json-c/issues/219) - Fix various potential null ptr deref and int32 overflows \
+* [Issue #220](https://github.com/json-c/json-c/issues/220) - Add utility function for comparing json_objects \
+* [Issue #221](https://github.com/json-c/json-c/issues/221) - JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly \
+* [Issue #222](https://github.com/json-c/json-c/issues/222) - Fix issue #221: JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly \
+* [Issue #223](https://github.com/json-c/json-c/issues/223) - Clarify json_object_get_string documentation of NULL handling & return \
+* [Issue #224](https://github.com/json-c/json-c/issues/224) - json_tokener.c - all warnings being treated as errors \
+* [Issue #225](https://github.com/json-c/json-c/issues/225) - Hi, will you support clib as a "registry"? \
+* [Issue #227](https://github.com/json-c/json-c/issues/227) - Bump SOVERSION to 3 \
+* [Issue #228](https://github.com/json-c/json-c/issues/228) - avoid double slashes from json \
+* [Issue #229](https://github.com/json-c/json-c/issues/229) - configure fails: checking size of size_t... configure: error: cannot determine a size for size_t \
+* [Issue #230](https://github.com/json-c/json-c/issues/230) - Use stdint.h to check for size_t size \
+* [Issue #231](https://github.com/json-c/json-c/issues/231) - Fix size_t size check for first-time builds \
+* [Issue #232](https://github.com/json-c/json-c/issues/232) - tests/tests1: fix printf format for size_t arguments \
+* [Issue #233](https://github.com/json-c/json-c/issues/233) - Include stddef.h in json_object.h \
+* [Issue #234](https://github.com/json-c/json-c/issues/234) - Add public API to use userdata independently of custom serializer \
+* [Issue #235](https://github.com/json-c/json-c/issues/235) - Undefined symbols Error for architecture x86_64 on Mac \
+* [Issue #236](https://github.com/json-c/json-c/issues/236) - Building a project which uses json-c with flag -Wcast-qual causes compilation errors \
+* [Issue #237](https://github.com/json-c/json-c/issues/237) - handle escaped utf-8 \
+* [Issue #238](https://github.com/json-c/json-c/issues/238) - linkhash.c: optimised the table_free path \
+* [Issue #239](https://github.com/json-c/json-c/issues/239) - initialize null terminator of new printbuf \
+* [Issue #240](https://github.com/json-c/json-c/issues/240) - Compile error: Variable set but not used \
+* [Issue #241](https://github.com/json-c/json-c/issues/241) - getting error in date string 19\/07\/2016, fixed for error 19/07/2016 \
+* [Issue #242](https://github.com/json-c/json-c/issues/242) - json_tokener_parse error \
+* [Issue #243](https://github.com/json-c/json-c/issues/243) - Fix #165 \
+* [Issue #244](https://github.com/json-c/json-c/issues/244) - Error while compiling source from RHEL5, could you please help me to fix this \
+* [Issue #245](https://github.com/json-c/json-c/issues/245) - json-c compile in window xp \
+* [Issue #246](https://github.com/json-c/json-c/issues/246) - Mac: uselocale failed to build \
+* [Issue #247](https://github.com/json-c/json-c/issues/247) - json_object_array_del_idx function has segment fault error? \
+* [Issue #248](https://github.com/json-c/json-c/issues/248) - Minor changes in C source code \
+* [Issue #249](https://github.com/json-c/json-c/issues/249) - Improving README \
+* [Issue #250](https://github.com/json-c/json-c/issues/250) - Improving .gitignore \
+* [Issue #251](https://github.com/json-c/json-c/issues/251) - Adding a file for EditorConfig \
+* [Issue #252](https://github.com/json-c/json-c/issues/252) - Very minor changes not related to C source code \
+* [Issue #253](https://github.com/json-c/json-c/issues/253) - Adding a test with cppcheck for Travis CI \
+* [Issue #254](https://github.com/json-c/json-c/issues/254) - Very minor changes to some tests \
+* [Issue #255](https://github.com/json-c/json-c/issues/255) - Minor changes in C source code \
+* [Issue #256](https://github.com/json-c/json-c/issues/256) - Mailing list dead? \
+* [Issue #257](https://github.com/json-c/json-c/issues/257) - Defining a coding style \
+* [Issue #258](https://github.com/json-c/json-c/issues/258) - Enable CI services \
+* [Issue #259](https://github.com/json-c/json-c/issues/259) - Fails to parse valid json \
+* [Issue #260](https://github.com/json-c/json-c/issues/260) - Adding an object to itself \
+* [Issue #261](https://github.com/json-c/json-c/issues/261) - Lack of proper documentation \
+* [Issue #262](https://github.com/json-c/json-c/issues/262) - Add Cmakefile and fix compiler warning. \
+* [Issue #263](https://github.com/json-c/json-c/issues/263) - Compiler Warnings with VS2015 \
+* [Issue #264](https://github.com/json-c/json-c/issues/264) - successed in simple test   while failed in my project \
+* [Issue #265](https://github.com/json-c/json-c/issues/265) - Conformance report for reference \
+* [Issue #266](https://github.com/json-c/json-c/issues/266) - crash perhaps related to reference counting \
+* [Issue #267](https://github.com/json-c/json-c/issues/267) - Removes me as Win32 maintainer, because I'm not. \
+* [Issue #268](https://github.com/json-c/json-c/issues/268) - Documentation of json_object_to_json_string gives no information about memory management \
+* [Issue #269](https://github.com/json-c/json-c/issues/269) - json_object_<type>_set(json_object *o,<type> value) API for value setting in json object private structure \
+* [Issue #270](https://github.com/json-c/json-c/issues/270) - new API json_object_new_double_f(doubel d,const char * fmt); \
+* [Issue #271](https://github.com/json-c/json-c/issues/271) - Cannot compile using CMake on macOS \
+* [Issue #273](https://github.com/json-c/json-c/issues/273) - fixed wrong object name in json_object_all_values_equal \
+* [Issue #274](https://github.com/json-c/json-c/issues/274) - Support for 64 bit pointers on Windows \
+* [Issue #275](https://github.com/json-c/json-c/issues/275) - Out-of-bounds read in json_tokener_parse_ex \
+* [Issue #276](https://github.com/json-c/json-c/issues/276) - ./configure for centos release 6.7(final) failure \
+* [Issue #277](https://github.com/json-c/json-c/issues/277) - Json object set xxx \
+* [Issue #278](https://github.com/json-c/json-c/issues/278) - Serialization of double with no fractional component drops trailing zero \
+* [Issue #279](https://github.com/json-c/json-c/issues/279) - Segmentation fault in array_list_length() \
+* [Issue #280](https://github.com/json-c/json-c/issues/280) - Should json_object_array_get_idx  check whether input obj is array? \
+* [Issue #281](https://github.com/json-c/json-c/issues/281) - how to pretty print json-c? \
+* [Issue #282](https://github.com/json-c/json-c/issues/282) - ignore temporary files \
+* [Issue #283](https://github.com/json-c/json-c/issues/283) - json_pointer: add first revision based on RFC 6901 \
+* [Issue #284](https://github.com/json-c/json-c/issues/284) - Resusing  json_tokener object \
+* [Issue #285](https://github.com/json-c/json-c/issues/285) - Revert "compat/strdup.h: move common compat check for strdup() to own \
+* [Issue #286](https://github.com/json-c/json-c/issues/286) - json_tokener_parse_ex() returns json_tokener_continue on zero-length string \
+* [Issue #287](https://github.com/json-c/json-c/issues/287) - json_pointer: extend setter & getter with printf() style arguments \
+* [Issue #288](https://github.com/json-c/json-c/issues/288) - Fix _GNU_SOURCE define for vasprintf \
+* [Issue #289](https://github.com/json-c/json-c/issues/289) - bugfix: floating point representaion without fractional part \
+* [Issue #290](https://github.com/json-c/json-c/issues/290) - duplicate an json_object \
+* [Issue #291](https://github.com/json-c/json-c/issues/291) - isspace assert error \
+* [Issue #292](https://github.com/json-c/json-c/issues/292) - configure error  "./configure: line 13121: syntax error near unexpected token `-Wall'" \
+* [Issue #293](https://github.com/json-c/json-c/issues/293) - how to make with bitcode for ios \
+* [Issue #294](https://github.com/json-c/json-c/issues/294) - Adding UTF-8 validation.  Fixes #122 \
+* [Issue #295](https://github.com/json-c/json-c/issues/295) - cross compile w/ mingw \
+* [Issue #296](https://github.com/json-c/json-c/issues/296) - Missing functions header in json_object.h \
+* [Issue #297](https://github.com/json-c/json-c/issues/297) - could not parse string to Json object? Like string str=\"helloworld;E\\test\\log\\;end\" \
+* [Issue #298](https://github.com/json-c/json-c/issues/298) - Building using CMake doesn't work \
+* [Issue #299](https://github.com/json-c/json-c/issues/299) - Improve json_object -> string performance \
+* [Issue #300](https://github.com/json-c/json-c/issues/300) - Running tests with MinGW build \
+* [Issue #301](https://github.com/json-c/json-c/issues/301) - How to deep copy  json_object in C++ ? \
+* [Issue #302](https://github.com/json-c/json-c/issues/302) - json_tokener_parse_ex doesn't parse JSON values \
+* [Issue #303](https://github.com/json-c/json-c/issues/303) - fix doc in tokener header file \
+* [Issue #304](https://github.com/json-c/json-c/issues/304) - (.text+0x72846): undefined reference to `is_error' \
+* [Issue #305](https://github.com/json-c/json-c/issues/305) - Fix compilation without C-99 option \
+* [Issue #306](https://github.com/json-c/json-c/issues/306) - ./configure: line 12748 -error=deprecated-declarations \
+* [Issue #307](https://github.com/json-c/json-c/issues/307) - Memory leak in json_tokener_parse \
+* [Issue #308](https://github.com/json-c/json-c/issues/308) - AM_PROG_LIBTOOL not found on Linux \
+* [Issue #309](https://github.com/json-c/json-c/issues/309) - GCC 7 reports various -Wimplicit-fallthrough= errors \
+* [Issue #310](https://github.com/json-c/json-c/issues/310) - Add FALLTHRU comment to handle GCC7 warnings. \
+* [Issue #311](https://github.com/json-c/json-c/issues/311) - Fix error C3688 when compiling on Visual Studio 2015 \
+* [Issue #312](https://github.com/json-c/json-c/issues/312) - Fix CMake Build process improved for MinGW and MSYS2 \
+* [Issue #313](https://github.com/json-c/json-c/issues/313) - VERBOSE=1 make check; tests/test_util_file.test.c and tests/test_util_file.expected out of sync \
+* [Issue #315](https://github.com/json-c/json-c/issues/315) - Passing -1 to json_tokener_parse_ex is possibly unsafe \
+* [Issue #316](https://github.com/json-c/json-c/issues/316) - Memory Returned by json_object_to_json_string not freed \
+* [Issue #317](https://github.com/json-c/json-c/issues/317) - json_object_get_string gives segmentation error \
+* [Issue #318](https://github.com/json-c/json-c/issues/318) - PVS-Studio static analyzer analyze results \
+* [Issue #319](https://github.com/json-c/json-c/issues/319) - Windows: Fix dynamic library build with Visual Studio \
+* [Issue #320](https://github.com/json-c/json-c/issues/320) - Can't compile in Mac OS X El Capitan \
+* [Issue #321](https://github.com/json-c/json-c/issues/321) - build,cmake: fix vasprintf implicit definition and generate both static & shared libs \
+* [Issue #322](https://github.com/json-c/json-c/issues/322) - can not link with libjson-c.a \
+* [Issue #323](https://github.com/json-c/json-c/issues/323) - implicit fallthrough detected by gcc 7.1 \
+* [Issue #324](https://github.com/json-c/json-c/issues/324) - JsonPath like function? \
+* [Issue #325](https://github.com/json-c/json-c/issues/325) - Fix stack buffer overflow in json_object_double_to_json_string_format() \
+* [Issue #327](https://github.com/json-c/json-c/issues/327) - why json-c so hard to compile \
+* [Issue #328](https://github.com/json-c/json-c/issues/328) - json_object: implement json_object_deep_copy() function \
+* [Issue #329](https://github.com/json-c/json-c/issues/329) - build,cmake: build,cmake: rename libjson-c-static.a to libjson-c.a \
+* [Issue #330](https://github.com/json-c/json-c/issues/330) - tests: symlink basic tests to a single file that has the common code \
+* [Issue #331](https://github.com/json-c/json-c/issues/331) - Safe use of snprintf() / vsnprintf() for Visual studio, and thread-safety fix \
+* [Issue #332](https://github.com/json-c/json-c/issues/332) - Valgrind: invalid read after json_object_array_del_idx. \
+* [Issue #333](https://github.com/json-c/json-c/issues/333) - Replace obsolete AM_PROG_LIBTOOL \
+* [Issue #335](https://github.com/json-c/json-c/issues/335) - README.md: show build status tag from travis-ci.org \
+* [Issue #336](https://github.com/json-c/json-c/issues/336) - tests: fix tests in travis-ci.org \
+* [Issue #337](https://github.com/json-c/json-c/issues/337) - Synchronize "potentially racy" random seed in lh_char_hash() \
+* [Issue #338](https://github.com/json-c/json-c/issues/338) - implement json_object_int_inc(json_object *, int64_t) \
+* [Issue #339](https://github.com/json-c/json-c/issues/339) - Json schema validation \
+* [Issue #340](https://github.com/json-c/json-c/issues/340) - strerror_override: add extern "C" and JSON_EXPORT specifiers for Visual C++ compilers \
+* [Issue #341](https://github.com/json-c/json-c/issues/341) - character "/" parse as "\/" \
+* [Issue #342](https://github.com/json-c/json-c/issues/342) - No such file or directory "/usr/include/json.h" \
+* [Issue #343](https://github.com/json-c/json-c/issues/343) - Can't parse json \
+* [Issue #344](https://github.com/json-c/json-c/issues/344) - Fix Mingw build \
+* [Issue #345](https://github.com/json-c/json-c/issues/345) - Fix make dist and make distcheck \
+* [Issue #346](https://github.com/json-c/json-c/issues/346) - Clamp double to int32 when narrowing in json_object_get_int. \
+* [Issue #347](https://github.com/json-c/json-c/issues/347) - MSVC linker error json_c_strerror \
+* [Issue #348](https://github.com/json-c/json-c/issues/348) - why \
+* [Issue #349](https://github.com/json-c/json-c/issues/349) - `missing` is missing? \
+* [Issue #350](https://github.com/json-c/json-c/issues/350) - stderror-override and disable-shared \
+* [Issue #351](https://github.com/json-c/json-c/issues/351) - SIZE_T_MAX redefined from limits.h \
+* [Issue #352](https://github.com/json-c/json-c/issues/352) - `INSTALL` overrides an automake script. \
+* [Issue #353](https://github.com/json-c/json-c/issues/353) - Documentation issues \
+* [Issue #354](https://github.com/json-c/json-c/issues/354) - Fixes #351 #352 #353 \
+* [Issue #355](https://github.com/json-c/json-c/issues/355) - 1.make it can been compiled with Visual Studio 2010 by modify the CMakeList.txt and others \
+* [Issue #356](https://github.com/json-c/json-c/issues/356) - VS2008 test  test_util_file.cpp err! \
+* [Issue #357](https://github.com/json-c/json-c/issues/357) - __json_c_strerror incompatibility with link-time optimization \
+* [Issue #358](https://github.com/json-c/json-c/issues/358) - make issue \
+* [Issue #359](https://github.com/json-c/json-c/issues/359) - update CMakeLists.txt for compile with visual studio at least 2010 \
+* [Issue #360](https://github.com/json-c/json-c/issues/360) - Use strtoll() to parse ints \
+* [Issue #361](https://github.com/json-c/json-c/issues/361) - Fix double to int cast overflow in json_object_get_int64. \
+* [Issue #362](https://github.com/json-c/json-c/issues/362) - CMake Package Config \
+* [Issue #363](https://github.com/json-c/json-c/issues/363) - Issue #338, add json_object_add_int functions \
+* [Issue #364](https://github.com/json-c/json-c/issues/364) - Cmake is Errir \
+* [Issue #365](https://github.com/json-c/json-c/issues/365) - added fallthrough for gcc7 \
+* [Issue #366](https://github.com/json-c/json-c/issues/366) - how to check  the json string,crash! \
+* [Issue #367](https://github.com/json-c/json-c/issues/367) - Is json-c support "redirect" semantic? \
+* [Issue #368](https://github.com/json-c/json-c/issues/368) - Add examples \
+* [Issue #369](https://github.com/json-c/json-c/issues/369) - How to build json-c library for android? \
+* [Issue #370](https://github.com/json-c/json-c/issues/370) - Compiling using clang-cl \
+* [Issue #371](https://github.com/json-c/json-c/issues/371) - Invalid parsing for Infinity with json-c 0.12 \
+* [Issue #372](https://github.com/json-c/json-c/issues/372) - Json-c 0.12: Fixed Infinity bug \
+* [Issue #373](https://github.com/json-c/json-c/issues/373) - build: fix build on appveyor CI \
+* [Issue #374](https://github.com/json-c/json-c/issues/374) - Undefined symbols for architecture x86_64: \
+* [Issue #375](https://github.com/json-c/json-c/issues/375) - what would happened when json_object_object_add add the same key \
+* [Issue #376](https://github.com/json-c/json-c/issues/376) - Eclipse error \
+* [Issue #377](https://github.com/json-c/json-c/issues/377) - on gcc 7.2.0 on my linux distribution with json-c  2013-04-02 source \
+* [Issue #378](https://github.com/json-c/json-c/issues/378) - Eclipse: library (libjson-c) not found, but configured \
+* [Issue #379](https://github.com/json-c/json-c/issues/379) - error: this statement may fall through \[-Werror=implicit-fallthrough=\] \
+* [Issue #380](https://github.com/json-c/json-c/issues/380) - Build on Windows \
+* [Issue #381](https://github.com/json-c/json-c/issues/381) - Fix makedist \
+* [Issue #382](https://github.com/json-c/json-c/issues/382) - Memory leak for json_tokener_parse_ex for version 0.12.1 \
+* [Issue #383](https://github.com/json-c/json-c/issues/383) - Fix a compiler warning. \
+* [Issue #384](https://github.com/json-c/json-c/issues/384) - Fix a VS 2015 compiler warnings. \
diff --git a/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.14.md b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.14.md
new file mode 100755
index 0000000..65096f0
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.14.md
@@ -0,0 +1,202 @@
+This list was created with:
+
+```
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=1" > issues1.out
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=2" > issues2.out
+curl https://api.github.com/search/issues?q="repo%3Ajson-c%2Fjson-c+closed%3A>2017-12-07+created%3A<2020-04-17&sort=created&order=asc&per_page=400&page=3" > issues3.out
+jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out > issues.md
+sed -e's,^\[ *\(.*\)\](https://api.github.com/.*/\([0-9].*\)),[Issue #\2](https://github.com/json-c/json-c/issues/\2) - \1,' -i issues.md
+#... manual editing ...
+```
+
+----
+
+Issues and Pull Requests closed for the 0.14 release (since commit d582d3a(2017-12-07) to a911439(2020-04-17))
+
+
+* [Issue #122](https://github.com/json-c/json-c/issues/122) - Add utf-8 validation when parsing strings. \
+* [Issue #139](https://github.com/json-c/json-c/issues/139) - json_object_from_file cannot accept max_depth \
+* [Issue #143](https://github.com/json-c/json-c/issues/143) - RFE / enhancement for full 64-bit signed/unsigned support \
+* [Issue #147](https://github.com/json-c/json-c/issues/147) - Please introduce soname bump if API changed \
+* [Issue #166](https://github.com/json-c/json-c/issues/166) - Need a way to specify nesting depth when opening JSON file \
+* [Issue #226](https://github.com/json-c/json-c/issues/226) - There is no json_object_new_null() \
+* [Issue #314](https://github.com/json-c/json-c/issues/314) - new release ? \
+* [Issue #326](https://github.com/json-c/json-c/issues/326) - Please extend api json_object_get_uint64 \
+* [Issue #334](https://github.com/json-c/json-c/issues/334) - Switch json-c builds to use CMake \
+* [Issue #386](https://github.com/json-c/json-c/issues/386) - Makefile: Add ACLOCAL_AMFLAGS \
+* [Issue #387](https://github.com/json-c/json-c/issues/387) - doc: Use other doxygen feature to specify mainpage \
+* [Issue #388](https://github.com/json-c/json-c/issues/388) - json_object: Add size_t json_object_sizeof() \
+* [Issue #389](https://github.com/json-c/json-c/issues/389) - json_object: Avoid double free (and thus a segfault) when ref_count gets < 0 \
+* [Issue #390](https://github.com/json-c/json-c/issues/390) - json_object: Add const size_t json_c_object_sizeof() \
+* [Issue #391](https://github.com/json-c/json-c/issues/391) - Fix non-GNUC define for JSON_C_CONST_FUNCTION \
+* [Issue #392](https://github.com/json-c/json-c/issues/392) - json_object: Avoid invalid free (and thus a segfault) when ref_count gets < 0 \
+* [Issue #393](https://github.com/json-c/json-c/issues/393) - json_object_private: Use unsigned 32-bit integer type for refcount \
+* [Issue #394](https://github.com/json-c/json-c/issues/394) - Problem serializing double \
+* [Issue #395](https://github.com/json-c/json-c/issues/395) - Key gets modified if it contains "\" \
+* [Issue #396](https://github.com/json-c/json-c/issues/396) - Build failure with no threads uClibc toolchain \
+* [Issue #397](https://github.com/json-c/json-c/issues/397) - update json object with key. \
+* [Issue #398](https://github.com/json-c/json-c/issues/398) - Build failed. \
+* [Issue #399](https://github.com/json-c/json-c/issues/399) - Avoid uninitialized variable warnings \
+* [Issue #400](https://github.com/json-c/json-c/issues/400) - How to generate static lib (.a) \
+* [Issue #401](https://github.com/json-c/json-c/issues/401) - Warnings with Valgrind \
+* [Issue #402](https://github.com/json-c/json-c/issues/402) - Add fuzzers from OSS-Fuzz \
+* [Issue #403](https://github.com/json-c/json-c/issues/403) - Segmentation fault when double quotes is used \
+* [Issue #404](https://github.com/json-c/json-c/issues/404) - valgrind: memory leak \
+* [Issue #405](https://github.com/json-c/json-c/issues/405) - Missing API to determine an object is empty \
+* [Issue #406](https://github.com/json-c/json-c/issues/406) - Undefine NDEBUG for tests \
+* [Issue #407](https://github.com/json-c/json-c/issues/407) - json_tokener_parse is crash \
+* [Issue #408](https://github.com/json-c/json-c/issues/408) - bug in array_list_del_idx when array_list_length()==1 \
+* [Issue #410](https://github.com/json-c/json-c/issues/410) - Fixed typos \
+* [Issue #411](https://github.com/json-c/json-c/issues/411) - Crash- signal SIGSEGV, Segmentation fault. ../sysdeps/x86_64/strlen.S: No such file or directory. \
+* [Issue #412](https://github.com/json-c/json-c/issues/412) - json_type changes during inter process communication. \
+* [Issue #413](https://github.com/json-c/json-c/issues/413) - how to read object of type `json_object *` in c++ \
+* [Issue #414](https://github.com/json-c/json-c/issues/414) - [Question] How JSON-c stores the serialized data in memory? \
+* [Issue #415](https://github.com/json-c/json-c/issues/415) - Resolve windows name conflict \
+* [Issue #416](https://github.com/json-c/json-c/issues/416) - segmentation fault  in json_tokener_parse \
+* [Issue #417](https://github.com/json-c/json-c/issues/417) - json_tokener_parse  json_object_object_get_ex with string value which is json string \
+* [Issue #418](https://github.com/json-c/json-c/issues/418) - json_object_from_* return value documented incorrectly \
+* [Issue #419](https://github.com/json-c/json-c/issues/419) - Suggestion: document (and define) that json_object_put() accepts NULL pointer to object \
+* [Issue #420](https://github.com/json-c/json-c/issues/420) - arraylist: Fixed names of parameters for callback function \
+* [Issue #421](https://github.com/json-c/json-c/issues/421) - install json_object_iterator.h header file \
+* [Issue #422](https://github.com/json-c/json-c/issues/422) - json_object_get_double() does not set errno when there is no valid conversion \
+* [Issue #423](https://github.com/json-c/json-c/issues/423) - memory leak \
+* [Issue #424](https://github.com/json-c/json-c/issues/424) - Parse string contains "\" or "/" errors \
+* [Issue #425](https://github.com/json-c/json-c/issues/425) - what this is? \
+* [Issue #426](https://github.com/json-c/json-c/issues/426) - __deprecated not supported on clang. \
+* [Issue #427](https://github.com/json-c/json-c/issues/427) - CMake: builds involving this target will not be correct \
+* [Issue #430](https://github.com/json-c/json-c/issues/430) - json_object_object_del() and Segmentation fault \
+* [Issue #431](https://github.com/json-c/json-c/issues/431) - cmake: Bump required version \
+* [Issue #432](https://github.com/json-c/json-c/issues/432) - The real CMake support. \
+* [Issue #433](https://github.com/json-c/json-c/issues/433) - The real CMake support. \
+* [Issue #434](https://github.com/json-c/json-c/issues/434) - The real CMake support \
+* [Issue #435](https://github.com/json-c/json-c/issues/435) - json_object_object_del() segmentation fault \
+* [Issue #436](https://github.com/json-c/json-c/issues/436) - Improve pkgconfig setting \
+* [Issue #437](https://github.com/json-c/json-c/issues/437) - Bad link in README.md \
+* [Issue #438](https://github.com/json-c/json-c/issues/438) - Bad link in README.html \
+* [Issue #439](https://github.com/json-c/json-c/issues/439) - reserved identifier violation \
+* [Issue #440](https://github.com/json-c/json-c/issues/440) - Use of angle brackets around file names for include statements \
+* [Issue #441](https://github.com/json-c/json-c/issues/441) - fix c flag loss during cmake building \
+* [Issue #442](https://github.com/json-c/json-c/issues/442) - error  in configure file \
+* [Issue #443](https://github.com/json-c/json-c/issues/443) - remove pretty spaces when using pretty tabs \
+* [Issue #444](https://github.com/json-c/json-c/issues/444) - Document refcount of json_tokener_parse_ex return \
+* [Issue #445](https://github.com/json-c/json-c/issues/445) - Add missing "make check" target to cmake config \
+* [Issue #446](https://github.com/json-c/json-c/issues/446) - Forward slashes get escaped \
+* [Issue #448](https://github.com/json-c/json-c/issues/448) - Buffer overflow in json-c \
+* [Issue #449](https://github.com/json-c/json-c/issues/449) - Need of json_type_int64 returned by json_object_get_type() \
+* [Issue #450](https://github.com/json-c/json-c/issues/450) - Allow use json-c cmake as subproject \
+* [Issue #452](https://github.com/json-c/json-c/issues/452) - Update README.md \
+* [Issue #453](https://github.com/json-c/json-c/issues/453) - Fixed misalignment in JSON string due to space after \n being printed... \
+* [Issue #454](https://github.com/json-c/json-c/issues/454) - json_object_private: save 8 bytes in struct json_object in 64-bit arc… \
+* [Issue #455](https://github.com/json-c/json-c/issues/455) - index.html:fix dead link \
+* [Issue #456](https://github.com/json-c/json-c/issues/456) - STYLE.txt:remove executable permissions \
+* [Issue #457](https://github.com/json-c/json-c/issues/457) - .gitignore:add build directory \
+* [Issue #458](https://github.com/json-c/json-c/issues/458) - README.md:fix dead "file.html" link \
+* [Issue #459](https://github.com/json-c/json-c/issues/459) - README.html:fix link to Doxygen docs, remove WIN32 link \
+* [Issue #460](https://github.com/json-c/json-c/issues/460) - No docs for json_object_new_string_len() \
+* [Issue #461](https://github.com/json-c/json-c/issues/461) - json_object.c:set errno in json_object_get_double() \
+* [Issue #462](https://github.com/json-c/json-c/issues/462) - json_object.h:document json_object_new_string_len() \
+* [Issue #463](https://github.com/json-c/json-c/issues/463) - please check newlocale api first argument valuse. \
+* [Issue #465](https://github.com/json-c/json-c/issues/465) - CMakeLists.txt doesn't contain json_object_iterator.h which json.h includes \
+* [Issue #466](https://github.com/json-c/json-c/issues/466) - configure:3610: error: C compiler cannot create executables \
+* [Issue #467](https://github.com/json-c/json-c/issues/467) - Fix compiler warnings \
+* [Issue #468](https://github.com/json-c/json-c/issues/468) - Fix compiler warnings \
+* [Issue #469](https://github.com/json-c/json-c/issues/469) - Build under alpine with pecl install & docker-php-ext-enable? \
+* [Issue #470](https://github.com/json-c/json-c/issues/470) - cfuhash_foreach_remove doesn't upate cfuhash_num_entries \
+* [Issue #472](https://github.com/json-c/json-c/issues/472) - Segmentation fault in json_object_iter_begin \
+* [Issue #473](https://github.com/json-c/json-c/issues/473) - Convert ChangeLog to valid UTF-8 encoding. \
+* [Issue #474](https://github.com/json-c/json-c/issues/474) - Installation directories empty with CMake in pkg-config. \
+* [Issue #475](https://github.com/json-c/json-c/issues/475) - improvement proposal for json_object_object_foreach \
+* [Issue #477](https://github.com/json-c/json-c/issues/477) - Hang/Crash with large strings \
+* [Issue #478](https://github.com/json-c/json-c/issues/478) - json_object_get_string_len returns 0 when value is number \
+* [Issue #479](https://github.com/json-c/json-c/issues/479) - I want to use it in iOS or Android but I can't compile \
+* [Issue #480](https://github.com/json-c/json-c/issues/480) - json-c-0.12.1  failed making from source code \
+* [Issue #481](https://github.com/json-c/json-c/issues/481) - error while loading shared libraries: libjson-c.so.4 \
+* [Issue #482](https://github.com/json-c/json-c/issues/482) - Error "double free or corruption" after free() \
+* [Issue #483](https://github.com/json-c/json-c/issues/483) - compatible with rarely-used Chinese characters in GBK charset \
+* [Issue #485](https://github.com/json-c/json-c/issues/485) - Install CMake module files \
+* [Issue #486](https://github.com/json-c/json-c/issues/486) - In the case of negative double value, it is formatted without including ".0" \
+* [Issue #488](https://github.com/json-c/json-c/issues/488) - Some APIs are not exported when built as shared lib on Win32 \
+* [Issue #489](https://github.com/json-c/json-c/issues/489) - Don't use -Werror by default \
+* [Issue #490](https://github.com/json-c/json-c/issues/490) - do not compile with -Werror by default \
+* [Issue #491](https://github.com/json-c/json-c/issues/491) - build: add option --disable-werror to configure \
+* [Issue #492](https://github.com/json-c/json-c/issues/492) - lack some quick usage in readme \
+* [Issue #494](https://github.com/json-c/json-c/issues/494) - Code generator? \
+* [Issue #495](https://github.com/json-c/json-c/issues/495) - README.md:fix 2 typos \
+* [Issue #496](https://github.com/json-c/json-c/issues/496) - json_pointer.h:suggest minor grammar improvement for pointer doc \
+* [Issue #497](https://github.com/json-c/json-c/issues/497) - add common header for all tests \
+* [Issue #498](https://github.com/json-c/json-c/issues/498) - double_serializer_test fails (with valgrind) \
+* [Issue #499](https://github.com/json-c/json-c/issues/499) - .travis.yml:test on more recent clang and gcc versions \
+* [Issue #500](https://github.com/json-c/json-c/issues/500) - test/Makefile.am:add missing deps for test1 and test2 \
+* [Issue #501](https://github.com/json-c/json-c/issues/501) - undefine NDEBUG for tests \
+* [Issue #502](https://github.com/json-c/json-c/issues/502) - configure error \
+* [Issue #503](https://github.com/json-c/json-c/issues/503) - json-c retuns OK when Invalid json string is passed \
+* [Issue #504](https://github.com/json-c/json-c/issues/504) - json_object_put coredump \
+* [Issue #505](https://github.com/json-c/json-c/issues/505) - Add vcpkg installation instructions \
+* [Issue #506](https://github.com/json-c/json-c/issues/506) - Cannot parse more than one object \
+* [Issue #509](https://github.com/json-c/json-c/issues/509) - Sometimes a double value is not serialized \
+* [Issue #510](https://github.com/json-c/json-c/issues/510) - Bump so-name and improve CMake \
+* [Issue #511](https://github.com/json-c/json-c/issues/511) - Reduce lines for better optimization \
+* [Issue #512](https://github.com/json-c/json-c/issues/512) - Properly append to CMAKE_C_FLAGS string \
+* [Issue #513](https://github.com/json-c/json-c/issues/513) - What does `userdata` means?And what is the case we can use it? \
+* [Issue #514](https://github.com/json-c/json-c/issues/514) - Json c 0.13 \
+* [Issue #515](https://github.com/json-c/json-c/issues/515) - Mies suomesta fixes segfaults and logic errors \
+* [Issue #516](https://github.com/json-c/json-c/issues/516) - Lja slight mods \
+* [Issue #518](https://github.com/json-c/json-c/issues/518) - Escape character  "\\003\", get unexpected value \
+* [Issue #519](https://github.com/json-c/json-c/issues/519) - Add test case obj token \
+* [Issue #520](https://github.com/json-c/json-c/issues/520) - Adding type uint64 \
+* [Issue #521](https://github.com/json-c/json-c/issues/521) - build cmake windows 10 \
+* [Issue #522](https://github.com/json-c/json-c/issues/522) - update json_visit testcase \
+* [Issue #523](https://github.com/json-c/json-c/issues/523) - update tsetcase for tokener_c \
+* [Issue #524](https://github.com/json-c/json-c/issues/524) - Increase coverage \
+* [Issue #525](https://github.com/json-c/json-c/issues/525) - update pointer test case \
+* [Issue #526](https://github.com/json-c/json-c/issues/526) - Increased the test coverage of printbuf.c 82% to 92%. \
+* [Issue #527](https://github.com/json-c/json-c/issues/527) - Arraylist testcase \
+* [Issue #528](https://github.com/json-c/json-c/issues/528) - Solve issue #108. Skip \u0000 while parsing. \
+* [Issue #529](https://github.com/json-c/json-c/issues/529) - Increased the test coverage of json_c_version.c 0% to 100%. \
+* [Issue #530](https://github.com/json-c/json-c/issues/530) - validate utf-8 string before parse \
+* [Issue #531](https://github.com/json-c/json-c/issues/531) - validate utf-8 string \
+* [Issue #532](https://github.com/json-c/json-c/issues/532) - json_object_object_get_ex returning the original object \
+* [Issue #533](https://github.com/json-c/json-c/issues/533) - Fix "make check" \
+* [Issue #535](https://github.com/json-c/json-c/issues/535) - short string optimization: excessive array length \
+* [Issue #536](https://github.com/json-c/json-c/issues/536) - add json_object_new_null() \
+* [Issue #538](https://github.com/json-c/json-c/issues/538) - update shortstring and arraylist parameters \
+* [Issue #539](https://github.com/json-c/json-c/issues/539) - double serializes to the old value after set_double \
+* [Issue #541](https://github.com/json-c/json-c/issues/541) - add coveralls auto tool to json-c \
+* [Issue #542](https://github.com/json-c/json-c/issues/542) - add uint64 data to json-c \
+* [Issue #543](https://github.com/json-c/json-c/issues/543) - Readme \
+* [Issue #544](https://github.com/json-c/json-c/issues/544) - Increase distcheck target in cmake \
+* [Issue #545](https://github.com/json-c/json-c/issues/545) - add doc target in cmake \
+* [Issue #546](https://github.com/json-c/json-c/issues/546) - Add uninstall target in cmake \
+* [Issue #547](https://github.com/json-c/json-c/issues/547) - modify json-c default build type, and fix up the assert() errors in t… \
+* [Issue #548](https://github.com/json-c/json-c/issues/548) - Solve some problems about cmake build type (debug/release) \
+* [Issue #549](https://github.com/json-c/json-c/issues/549) - lib installation issues \
+* [Issue #550](https://github.com/json-c/json-c/issues/550) - Format codes with clang-format tool? \
+* [Issue #551](https://github.com/json-c/json-c/issues/551) - Allow hexadecimal number format convention parsing \
+* [Issue #553](https://github.com/json-c/json-c/issues/553) - Fix/clang ubsan \
+* [Issue #554](https://github.com/json-c/json-c/issues/554) - RFC 8259 compatibility mode \
+* [Issue #555](https://github.com/json-c/json-c/issues/555) - Format json-c with clang-format tool \
+* [Issue #556](https://github.com/json-c/json-c/issues/556) - Fixes various Wreturn-type and Wimplicit-fallthrough errors on Mingw-w64 \
+* [Issue #557](https://github.com/json-c/json-c/issues/557) - Add option in CMAKE to not build documentation \
+* [Issue #558](https://github.com/json-c/json-c/issues/558) - modify the doc target message \
+* [Issue #559](https://github.com/json-c/json-c/issues/559) - json_c_visit() not exported on Windows \
+* [Issue #560](https://github.com/json-c/json-c/issues/560) - error: implicit declaration of function '_strtoi64' \
+* [Issue #561](https://github.com/json-c/json-c/issues/561) - add the badge in README.md and test the coveralls \
+* [Issue #562](https://github.com/json-c/json-c/issues/562) - Bugfix and testcases supplements \
+* [Issue #563](https://github.com/json-c/json-c/issues/563) - Changed order of calloc args to match stdlib \
+* [Issue #564](https://github.com/json-c/json-c/issues/564) - Remove autogenerated files \
+* [Issue #565](https://github.com/json-c/json-c/issues/565) - test the CI and ignore this PR \
+* [Issue #566](https://github.com/json-c/json-c/issues/566) - add the json_types.h to Makefile.am \
+* [Issue #567](https://github.com/json-c/json-c/issues/567) - Install json_types.h with autotools build as well. \
+* [Issue #568](https://github.com/json-c/json-c/issues/568) - Adding better support to MinGW \
+* [Issue #569](https://github.com/json-c/json-c/issues/569) - Handling of -Bsymbolic-function in CMakeLists.txt is deficient \
+* [Issue #571](https://github.com/json-c/json-c/issues/571) - CMake: Bump SONAME to 5. \
+* [Issue #572](https://github.com/json-c/json-c/issues/572) - Small fixes to CMakeLists \
+* [Issue #573](https://github.com/json-c/json-c/issues/573) - Fix coveralls submission. \
+* [Issue #574](https://github.com/json-c/json-c/issues/574) - autogen.sh missing from repository \
+* [Issue #575](https://github.com/json-c/json-c/issues/575) - Small cosmetics. \
+* [Issue #576](https://github.com/json-c/json-c/issues/576) - Test coverage for json_c_version. \
+* [Issue #577](https://github.com/json-c/json-c/issues/577) - Be verbose on failing json_c_version test. \
+* [Issue #578](https://github.com/json-c/json-c/issues/578) - CMake: Install pkgconfig file in proper location by default \
+* [Issue #579](https://github.com/json-c/json-c/issues/579) - Enforce strict prototypes. \
+* [Issue #580](https://github.com/json-c/json-c/issues/580) - Fix CMake tests for enforced strict prototypes. \
+* [Issue #581](https://github.com/json-c/json-c/issues/581) - CMakeLists: do not enforce strict prototypes on Windows. \
diff --git a/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.15.md b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.15.md
new file mode 100755
index 0000000..8c7f2f6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.15.md
@@ -0,0 +1,85 @@
+This list was created with:
+
+```
+curl "https://api.github.com/search/issues?q=repo%3Ajson-c%2Fjson-c+closed%3A>2020-04-18+created%3A<2020-07-23&sort=created&order=asc&per_page=100&page=1" > issues1.out
+jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out > issues.md
+sed -e's,^\[ *\(.*\)\](https://api.github.com/.*/\([0-9].*\)),* [Issue #\2](https://github.com/json-c/json-c/issues/\2) - \1,' -i issues.md
+#... manual editing ...
+
+```
+
+----
+
+Issues and Pull Requests closed for the 0.15 release
+(since commit 31ab57ca, the 0.14 branch point, 2020-04-19)
+
+* [Issue #428](https://github.com/json-c/json-c/issues/428) - Added new_null() function
+* [Issue #429](https://github.com/json-c/json-c/issues/429) - Conflict of interest between JSON_C_TO_STRING_SPACED and JSON_C_TO_STRING_PRETTY
+* [Issue #451](https://github.com/json-c/json-c/issues/451) - Add option to disable HAVE___THREAD
+* [Issue #471](https://github.com/json-c/json-c/issues/471) - create folders with mode 0755 when building
+* [Issue #476](https://github.com/json-c/json-c/issues/476) - Add new function named json_object_new_string_noalloc
+* [Issue #484](https://github.com/json-c/json-c/issues/484) - Add support for uint64
+* [Issue #487](https://github.com/json-c/json-c/issues/487) - Any plans to make new release? (0.14)
+* [Issue #493](https://github.com/json-c/json-c/issues/493) - Kdopen rename library
+* [Issue #507](https://github.com/json-c/json-c/issues/507) - Double value -1.0 converts to integer in json_object_to_json_string()
+* [Issue #508](https://github.com/json-c/json-c/issues/508) - Recommend enabling the `-fPIC` compiler flag by default
+* [Issue #517](https://github.com/json-c/json-c/issues/517) - Lja mods
+* [Issue #534](https://github.com/json-c/json-c/issues/534) - Both json-c and json-glib have json_object_get_type()
+* [Issue #584](https://github.com/json-c/json-c/issues/584) - CMake: SOVERSION and the major library VERSION need to be in lockstep.
+* [Issue #585](https://github.com/json-c/json-c/issues/585) - CMake: Do not install config.h, as it is not a public header file.
+* [Issue #586](https://github.com/json-c/json-c/issues/586) - 10796 Segmentation fault
+* [Issue #588](https://github.com/json-c/json-c/issues/588) - Broken RDRAND causes infinite looping
+* [Issue #589](https://github.com/json-c/json-c/issues/589) - Detect broken RDRAND during initialization
+* [Issue #590](https://github.com/json-c/json-c/issues/590) - Fix segmentation fault in CPUID check
+* [Issue #591](https://github.com/json-c/json-c/issues/591) - Update README.md
+* [Issue #592](https://github.com/json-c/json-c/issues/592) - Prevent out of boundary write on malicious input
+* [Issue #593](https://github.com/json-c/json-c/issues/593) - Building both static and shared libraries
+* [Issue #594](https://github.com/json-c/json-c/issues/594) - Some subsequent call of lh_get_hash not working
+* [Issue #595](https://github.com/json-c/json-c/issues/595) - Support to build both static and shared libraries
+* [Issue #596](https://github.com/json-c/json-c/issues/596) - QA Notice: Package triggers severe warnings
+* [Issue #597](https://github.com/json-c/json-c/issues/597) - json_parse demo: fix and use usage() function
+* [Issue #598](https://github.com/json-c/json-c/issues/598) - Turning off shared libs causes target duplication or build error
+* [Issue #599](https://github.com/json-c/json-c/issues/599) - cannot add more than 11 objects. Is this a known issue?
+* [Issue #600](https://github.com/json-c/json-c/issues/600) - Library name conflicts on Windows are back again
+* [Issue #601](https://github.com/json-c/json-c/issues/601) - json_tokener_parse() in master sets errno=1 "Operation not permitted"
+* [Issue #602](https://github.com/json-c/json-c/issues/602) - fix json_parse_uint64() internal error checking with errno
+* [Issue #603](https://github.com/json-c/json-c/issues/603) - Backport of fixes from master branch.
+* [Issue #604](https://github.com/json-c/json-c/issues/604) - commit f2e991a3419ee4078e8915e840b1a0d9003b349e breaks cross-compilation with mingw
+* [Issue #605](https://github.com/json-c/json-c/issues/605) - Update to 0.15 release
+* [Issue #606](https://github.com/json-c/json-c/issues/606) - Improved support for IBM operating systems
+* [Issue #607](https://github.com/json-c/json-c/issues/607) - json-c-0.13.x: Fix CVE-2020-12762 - json-c through 0.14 has an integer overflow and out-of-bounds write ...
+* [Issue #608](https://github.com/json-c/json-c/issues/608) - json-c-0.14: Fix CVE-2020-12762 - json-c through 0.14 has an integer overflow and out-of-bounds write ...
+* [Issue #609](https://github.com/json-c/json-c/issues/609) - use unsigned types for sizes in lh_table and entries
+* [Issue #610](https://github.com/json-c/json-c/issues/610) - let's not call lh_table_resize with INT_MAX
+* [Issue #611](https://github.com/json-c/json-c/issues/611) - json-c-0.12.x: Fix CVE-2020-12762 - json-c through 0.14 has an integer overflow and out-of-bounds write ...
+* [Issue #613](https://github.com/json-c/json-c/issues/613) - json-c-0.10: Fix CVE-2020-12762 - json-c through 0.14 has an integer overflow and out-of-bounds write ...
+* [Issue #614](https://github.com/json-c/json-c/issues/614) - Prevent truncation on custom double formatters.
+* [Issue #615](https://github.com/json-c/json-c/issues/615) - New release with security fix
+* [Issue #616](https://github.com/json-c/json-c/issues/616) - Parsing fails if UTF-16 low surrogate pair is not in same chunk is the high pair
+* [Issue #617](https://github.com/json-c/json-c/issues/617) - Add an option to disable the use of thread-local storage.
+* [Issue #618](https://github.com/json-c/json-c/issues/618) - test_deep_copy: Fix assertion value.
+* [Issue #619](https://github.com/json-c/json-c/issues/619) - CMake: Fix out-of-tree build for Doxygen documentation.
+* [Issue #621](https://github.com/json-c/json-c/issues/621) - json-c and jansson libraries have symbol conflicts
+* [Issue #622](https://github.com/json-c/json-c/issues/622) - doc: Move Doxyfile into doc subdir.
+* [Issue #623](https://github.com/json-c/json-c/issues/623) - json_tokener_parse : Segmentation fault
+* [Issue #626](https://github.com/json-c/json-c/issues/626) - Fixes for cmake 2.8.12 + link issue on AIX 6.1/cc 11.01
+* [Issue #627](https://github.com/json-c/json-c/issues/627) - Compat fixes
+* [Issue #628](https://github.com/json-c/json-c/issues/628) - get_cryptgenrandom_seed: compat with old windows + fallback
+* [Issue #629](https://github.com/json-c/json-c/issues/629) - [0.12] Remove the Visual Studio project file
+* [Issue #630](https://github.com/json-c/json-c/issues/630) - Linking with Windows MINGW not working
+* [Issue #632](https://github.com/json-c/json-c/issues/632) - Json object split
+* [Issue #633](https://github.com/json-c/json-c/issues/633) - fix issue 616: support the surrogate pair in split file.
+* [Issue #634](https://github.com/json-c/json-c/issues/634) - Issue #508: `-fPIC` to link libjson-c.a with libs
+* [Issue #635](https://github.com/json-c/json-c/issues/635) - expression has no effect warning in json_tokener.c
+* [Issue #636](https://github.com/json-c/json-c/issues/636) - json_object_get_string free str memory
+* [Issue #637](https://github.com/json-c/json-c/issues/637) - json_object_put()  has 'double free or corruption (out) '
+* [Issue #638](https://github.com/json-c/json-c/issues/638) - json-c/json_object.c:50:2: error: #error Unable to determine size of ssize_t
+* [Issue #639](https://github.com/json-c/json-c/issues/639) - build: Add a symbol version to all exported symbols
+* [Issue #640](https://github.com/json-c/json-c/issues/640) - Fix build issues with SSIZE_MAX on 64bit Linux
+* [Issue #641](https://github.com/json-c/json-c/issues/641) - Formal verification of your test suite
+* [Issue #642](https://github.com/json-c/json-c/issues/642) - Please provide more precise informations about when to call json_object_put
+* [Issue #643](https://github.com/json-c/json-c/issues/643) - not able to compare with string
+* [Issue #644](https://github.com/json-c/json-c/issues/644) - Why src->_userdata not checked before calling strdup?
+* [Issue #645](https://github.com/json-c/json-c/issues/645) - Misuse of tolower() in json_tokener.c
+* [Issue #646](https://github.com/json-c/json-c/issues/646) - Cast to unsigned char instead of int when calling tolower (Fixes #645)
+
diff --git a/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.16.md b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.16.md
new file mode 100755
index 0000000..290967d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/issues_closed_for_0.16.md
@@ -0,0 +1,107 @@
+This list was created with:
+
+```
+PREV=2020-07-23
+NOW=2022-04-13
+curl "https://api.github.com/search/issues?q=repo%3Ajson-c%2Fjson-c+closed%3A>${PREV}+created%3A<${NOW}&sort=created&order=asc&per_page=100&page=1" > issues1.out
+jq -r '.items[] | "[" + .title + "](" + .url + ")" | tostring' issues?.out > issues.md
+sed -e's,^\[ *\(.*\)\](https://api.github.com/.*/\([0-9].*\)),* [Issue #\2](https://github.com/json-c/json-c/issues/\2) - \1,' -i issues.md
+cat issues.md >> issues_closed_for_0.16.md
+```
+
+* [Issue #464](https://github.com/json-c/json-c/issues/464) - Speed up parsing and object creation
+* [Issue #540](https://github.com/json-c/json-c/issues/540) - request: json_init_library
+* [Issue #631](https://github.com/json-c/json-c/issues/631) - New 0.14 release requests
+* [Issue #647](https://github.com/json-c/json-c/issues/647) - "cmake -DCMAKE_BUILD_TYPE=Release" fails with error: 'cint64' may be used uninitialized
+* [Issue #648](https://github.com/json-c/json-c/issues/648) - Fix "may be used uninitialized" Release build failure
+* [Issue #649](https://github.com/json-c/json-c/issues/649) - json-c tag 0.15 tarball contains a file doc/Doxyfile and generated doxygen files in doc/html
+* [Issue #650](https://github.com/json-c/json-c/issues/650) - README: fix spelling errors
+* [Issue #651](https://github.com/json-c/json-c/issues/651) - Getrandom
+* [Issue #652](https://github.com/json-c/json-c/issues/652) - Waste memory
+* [Issue #653](https://github.com/json-c/json-c/issues/653) - Make the documentation build reproducibly
+* [Issue #654](https://github.com/json-c/json-c/issues/654) - A stack-buffer-overflow in json_parse.c:89:44
+* [Issue #655](https://github.com/json-c/json-c/issues/655) - json_parse: Fix read past end of buffer
+* [Issue #656](https://github.com/json-c/json-c/issues/656) - Fixed warnings
+* [Issue #657](https://github.com/json-c/json-c/issues/657) - Use GRND_NONBLOCK with getrandom.
+* [Issue #658](https://github.com/json-c/json-c/issues/658) - json_object_get_boolean() returns wrong result for objects and arrays
+* [Issue #659](https://github.com/json-c/json-c/issues/659) - fix json_object_get_boolean() to behave like documented
+* [Issue #660](https://github.com/json-c/json-c/issues/660) - Validate size arguments in arraylist functions.
+* [Issue #661](https://github.com/json-c/json-c/issues/661) - Cleanup of some code parts
+* [Issue #662](https://github.com/json-c/json-c/issues/662) - Prevent signed overflow in get_time_seed
+* [Issue #663](https://github.com/json-c/json-c/issues/663) - Properly format errnos in _json_c_strerror
+* [Issue #664](https://github.com/json-c/json-c/issues/664) - Limit strings at INT_MAX length
+* [Issue #665](https://github.com/json-c/json-c/issues/665) - Handle more allocation failures in json_tokener* functions
+* [Issue #666](https://github.com/json-c/json-c/issues/666) - test1 json_object_new_array_ext test is failing
+* [Issue #667](https://github.com/json-c/json-c/issues/667) - Fixed test1 regression.
+* [Issue #670](https://github.com/json-c/json-c/issues/670) - Created Stone-Paper-Scissor Game by C language
+* [Issue #672](https://github.com/json-c/json-c/issues/672) - Calling exit() after failure to generate random seed
+* [Issue #673](https://github.com/json-c/json-c/issues/673) - switchcasemenuproject
+* [Issue #674](https://github.com/json-c/json-c/issues/674) - random_seed: on error, continue to next method
+* [Issue #682](https://github.com/json-c/json-c/issues/682) - libjson-c-dev vs libjson-c3
+* [Issue #683](https://github.com/json-c/json-c/issues/683) - [Question] Is it possible to clear a ptr of json_object?
+* [Issue #684](https://github.com/json-c/json-c/issues/684) - json_tokener_parse_verbose failed with core dump
+* [Issue #685](https://github.com/json-c/json-c/issues/685) - json_tokener_parse memory leak?
+* [Issue #689](https://github.com/json-c/json-c/issues/689) - fix compilation with clang
+* [Issue #690](https://github.com/json-c/json-c/issues/690) - "1," produces an object with int 1; "1" produces a null object
+* [Issue #691](https://github.com/json-c/json-c/issues/691) - failed tests
+* [Issue #692](https://github.com/json-c/json-c/issues/692) - patch to add arc4random
+* [Issue #693](https://github.com/json-c/json-c/issues/693) - Optional parameter for packing as array
+* [Issue #694](https://github.com/json-c/json-c/issues/694) - fix invalid unsigned arithmetic.
+* [Issue #695](https://github.com/json-c/json-c/issues/695) - /tmp/json-c/random_seed.c:327:6: error
+* [Issue #696](https://github.com/json-c/json-c/issues/696) - To avoid target exe file export JSON functions.
+* [Issue #697](https://github.com/json-c/json-c/issues/697) - json_object_get_string() return value truncated when assigning it to a pointer type in Win32 App
+* [Issue #698](https://github.com/json-c/json-c/issues/698) - Feature request: set allocator
+* [Issue #699](https://github.com/json-c/json-c/issues/699) - Linking to libjson-c Issue
+* [Issue #700](https://github.com/json-c/json-c/issues/700) - Fix unused variable for Win32 build in random_seed.c
+* [Issue #701](https://github.com/json-c/json-c/issues/701) - [RFC] json_pointer: allow the feature to be disabled
+* [Issue #703](https://github.com/json-c/json-c/issues/703) - Fix vasprintf fallback
+* [Issue #706](https://github.com/json-c/json-c/issues/706) - Check __STDC_VERSION__ is defined before checking its value
+* [Issue #707](https://github.com/json-c/json-c/issues/707) - How to build json-c-0.15 for arm arch
+* [Issue #708](https://github.com/json-c/json-c/issues/708) - direct access to elements
+* [Issue #709](https://github.com/json-c/json-c/issues/709) - Include guards not namespaced / build errors for debug.h with openNDS
+* [Issue #710](https://github.com/json-c/json-c/issues/710) - 'file system sandbox blocked mmap()' error on iOS
+* [Issue #711](https://github.com/json-c/json-c/issues/711) - creating a json object 
+* [Issue #712](https://github.com/json-c/json-c/issues/712) - building json-c using cmake for ESP32
+* [Issue #713](https://github.com/json-c/json-c/issues/713) - When value converted to char* can not compare it with another value
+* [Issue #714](https://github.com/json-c/json-c/issues/714) - Add AfterCaseLabel to .clang-format
+* [Issue #716](https://github.com/json-c/json-c/issues/716) - Fixed cmake command
+* [Issue #717](https://github.com/json-c/json-c/issues/717) - Cmake is able delete all files by "clean" target
+* [Issue #718](https://github.com/json-c/json-c/issues/718) - CMake create uninstall target if unix generator is used
+* [Issue #719](https://github.com/json-c/json-c/issues/719) - Parsing multiple JSON strings
+* [Issue #722](https://github.com/json-c/json-c/issues/722) - Fix use-after-free in json_tokener_new_ex()
+* [Issue #723](https://github.com/json-c/json-c/issues/723) - if set __stdcall (/Gz)
+* [Issue #724](https://github.com/json-c/json-c/issues/724) - #723
+* [Issue #725](https://github.com/json-c/json-c/issues/725) - json_object_from_file()  execution segment error
+* [Issue #726](https://github.com/json-c/json-c/issues/726) - fix cmake version for tests
+* [Issue #727](https://github.com/json-c/json-c/issues/727) - Really use prefix JSON_C_OBJECT_ADD_
+* [Issue #728](https://github.com/json-c/json-c/issues/728) - DRAFT PROPOSAL - Add option JSON_C_OBJECT_ADD_IF_NOT_NULL
+* [Issue #729](https://github.com/json-c/json-c/issues/729) - * don't assume includedir
+* [Issue #731](https://github.com/json-c/json-c/issues/731) - Json-c Error
+* [Issue #732](https://github.com/json-c/json-c/issues/732) - Fix/static include dirs
+* [Issue #734](https://github.com/json-c/json-c/issues/734) - Newer appveyor config for VS2022 etc...
+* [Issue #735](https://github.com/json-c/json-c/issues/735) - Add policy_max to minimum required cmake version
+* [Issue #736](https://github.com/json-c/json-c/issues/736) - json_object.c:308: json_object_put: Assertion `jso->_ref_count > 0' failed
+* [Issue #737](https://github.com/json-c/json-c/issues/737) - Fix typo in README
+* [Issue #738](https://github.com/json-c/json-c/issues/738) - General question - Is there an SLA for handling newly detected security issues?
+* [Issue #739](https://github.com/json-c/json-c/issues/739) - json_escape_str(): avoid harmless unsigned integer overflow
+* [Issue #741](https://github.com/json-c/json-c/issues/741) - json_type_to_name(): use correct printf() formatter
+* [Issue #742](https://github.com/json-c/json-c/issues/742) - json_object_copy_serializer_data(): add assertion
+* [Issue #743](https://github.com/json-c/json-c/issues/743) - Cmd adb root
+* [Issue #744](https://github.com/json-c/json-c/issues/744) - Close file on error path.
+* [Issue #745](https://github.com/json-c/json-c/issues/745) - vasprintf(): avoid out of memory accesses
+* [Issue #746](https://github.com/json-c/json-c/issues/746) - Fix typos in code comments and ChangeLog
+* [Issue #747](https://github.com/json-c/json-c/issues/747) - json_object_put: Assertion `jso->_ref_count > 0' failed
+* [Issue #748](https://github.com/json-c/json-c/issues/748) - sprintbuf(): test for all vsnprintf error values
+* [Issue #749](https://github.com/json-c/json-c/issues/749) - sprintbuf(): handle printbuf_memappend errors
+* [Issue #750](https://github.com/json-c/json-c/issues/750) - printbuf_memset(): set gaps to zero
+* [Issue #751](https://github.com/json-c/json-c/issues/751) - printbuf: do not allow invalid arguments
+* [Issue #752](https://github.com/json-c/json-c/issues/752) - Fix typos
+* [Issue #753](https://github.com/json-c/json-c/issues/753) - CTest failed in MSVC build
+* [Issue #754](https://github.com/json-c/json-c/issues/754) - Minor improvements to documentation
+* [Issue #755](https://github.com/json-c/json-c/issues/755) - Fix error messages
+* [Issue #758](https://github.com/json-c/json-c/issues/758) - Preserve context if out of memory
+* [Issue #760](https://github.com/json-c/json-c/issues/760) - Code style: removed unneeded double-quotes
+* [Issue #761](https://github.com/json-c/json-c/issues/761) - Last commit merged to master breaks compilation
+* [Issue #762](https://github.com/json-c/json-c/issues/762) - how to merge two jsons by json-c
+* [Issue #763](https://github.com/json-c/json-c/issues/763) - Question: sort_fn arguments
+* [Issue #764](https://github.com/json-c/json-c/issues/764) - Make test fail on test case test_util_file
diff --git a/lynq/S300/ap/app/apparms/json-c/json-c.pc.in b/lynq/S300/ap/app/apparms/json-c/json-c.pc.in
new file mode 100755
index 0000000..79d9a5e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json-c.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: json-c
+Description: A JSON implementation in C
+Version: @VERSION@
+Requires:
+Libs.private: @LIBS@
+Libs: -L${libdir} -ljson-c
+Cflags: -I${includedir} -I${includedir}/json-c
diff --git a/lynq/S300/ap/app/apparms/json-c/json-c.sym b/lynq/S300/ap/app/apparms/json-c/json-c.sym
new file mode 100755
index 0000000..1942acd
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json-c.sym
@@ -0,0 +1,175 @@
+
+/*
+ * Symbol versioning for libjson-c.
+ * All exported symbols must be listed here.
+ *
+ * See 
+ *   https://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf
+ */
+
+/*
+ * Symbols in JSONC_PRIVATE are exported for historical
+ * reasons, but should not be used outside of json-c.
+ */
+JSONC_PRIVATE {
+    array_list_add;
+    array_list_del_idx;
+    array_list_free;
+    array_list_new;
+    array_list_put_idx;
+    array_list_sort;
+    json_hex_chars;
+    json_parse_double;
+    json_parse_int64;
+    json_parse_uint64;
+    lh_table_delete;
+    lh_table_delete_entry;
+    lh_table_free;
+    lh_table_insert;
+    lh_table_insert_w_hash;
+    lh_table_new;
+    lh_table_resize;
+    mc_debug;
+    mc_error;
+    mc_get_debug;
+    mc_info;
+    mc_set_debug;
+    mc_set_syslog;
+    printbuf_free;
+    printbuf_memappend;
+    printbuf_memset;
+    printbuf_new;
+    printbuf_reset;
+    sprintbuf;
+};
+
+JSONC_0.14 {
+  global:
+    array_list_bsearch;
+    array_list_get_idx;
+    array_list_length;
+    json_c_get_random_seed;
+    json_c_object_sizeof;
+    json_c_set_serialization_double_format;
+    json_c_shallow_copy_default;
+    json_c_version;
+    json_c_version_num;
+    json_c_visit;
+    json_global_set_string_hash;
+    json_number_chars;
+    json_object_array_add;
+    json_object_array_bsearch;
+    json_object_array_del_idx;
+    json_object_array_get_idx;
+    json_object_array_length;
+    json_object_array_put_idx;
+    json_object_array_sort;
+    json_object_deep_copy;
+    json_object_double_to_json_string;
+    json_object_equal;
+    json_object_free_userdata;
+    json_object_from_fd;
+    json_object_from_fd_ex;
+    json_object_from_file;
+    json_object_get;
+    json_object_get_array;
+    json_object_get_boolean;
+    json_object_get_double;
+    json_object_get_int64;
+    json_object_get_int;
+    json_object_get_object;
+    json_object_get_string;
+    json_object_get_string_len;
+    json_object_get_type;
+    json_object_get_uint64;
+    json_object_get_userdata;
+    json_object_int_inc;
+    json_object_is_type;
+    json_object_iter_begin;
+    json_object_iter_end;
+    json_object_iter_equal;
+    json_object_iter_init_default;
+    json_object_iter_next;
+    json_object_iter_peek_name;
+    json_object_iter_peek_value;
+    json_object_new_array;
+    json_object_new_boolean;
+    json_object_new_double;
+    json_object_new_double_s;
+    json_object_new_int64;
+    json_object_new_int;
+    json_object_new_null;
+    json_object_new_object;
+    json_object_new_string;
+    json_object_new_string_len;
+    json_object_new_uint64;
+    json_object_object_add;
+    json_object_object_add_ex;
+    json_object_object_del;
+    json_object_object_get;
+    json_object_object_get_ex;
+    json_object_object_length;
+    json_object_put;
+    json_object_set_boolean;
+    json_object_set_double;
+    json_object_set_int64;
+    json_object_set_int;
+    json_object_set_serializer;
+    json_object_set_string;
+    json_object_set_string_len;
+    json_object_set_uint64;
+    json_object_set_userdata;
+    json_object_to_fd;
+    json_object_to_file;
+    json_object_to_file_ext;
+    json_object_to_json_string;
+    json_object_to_json_string_ext;
+    json_object_to_json_string_length;
+    json_object_userdata_to_json_string;
+    json_pointer_get;
+    json_pointer_getf;
+    json_pointer_set;
+    json_pointer_setf;
+    json_tokener_error_desc;
+    json_tokener_free;
+    json_tokener_get_error;
+    json_tokener_get_parse_end;
+    json_tokener_new;
+    json_tokener_new_ex;
+    json_tokener_parse;
+    json_tokener_parse_ex;
+    json_tokener_parse_verbose;
+    json_tokener_reset;
+    json_tokener_set_flags;
+    json_type_to_name;
+    json_util_get_last_err;
+    lh_char_equal;
+    lh_kchar_table_new;
+    lh_kptr_table_new;
+    lh_ptr_equal;
+    lh_table_length;
+    lh_table_lookup_entry;
+    lh_table_lookup_entry_w_hash;
+    lh_table_lookup_ex;
+
+  local:
+    *;
+};
+
+JSONC_0.15 {
+  global:
+    array_list_new2;
+    array_list_shrink;
+    json_object_array_shrink;
+    json_object_new_array_ext;
+} JSONC_0.14;
+
+JSONC_0.16 {
+#  global:
+#      ...new symbols here...
+} JSONC_0.15;
+
+JSONC_0.17 {
+#  global:
+#      ...new symbols here...
+} JSONC_0.16;
diff --git a/lynq/S300/ap/app/apparms/json-c/json.h.cmakein b/lynq/S300/ap/app/apparms/json-c/json.h.cmakein
new file mode 100755
index 0000000..4fed013
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json.h.cmakein
@@ -0,0 +1,38 @@
+/*
+ * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief A convenience header that may be included instead of other individual ones.
+ */
+#ifndef _json_h_
+#define _json_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "arraylist.h"
+#include "debug.h"
+#include "json_c_version.h"
+#include "json_object.h"
+#include "json_object_iterator.h"
+@JSON_H_JSON_POINTER@
+#include "json_tokener.h"
+#include "json_util.h"
+#include "linkhash.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_c_version.c b/lynq/S300/ap/app/apparms/json-c/json_c_version.c
new file mode 100755
index 0000000..9b21db4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_c_version.c
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012 Eric Haszlakiewicz
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+#include "config.h"
+
+#include "json_c_version.h"
+
+const char *json_c_version(void)
+{
+	return JSON_C_VERSION;
+}
+
+int json_c_version_num(void)
+{
+	return JSON_C_VERSION_NUM;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_c_version.h b/lynq/S300/ap/app/apparms/json-c/json_c_version.h
new file mode 100755
index 0000000..f0e8d67
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_c_version.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012,2017 Eric Haszlakiewicz
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+
+/**
+ * @file
+ * @brief Methods for retrieving the json-c version.
+ */
+#ifndef _json_c_version_h_
+#define _json_c_version_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JSON_C_MAJOR_VERSION 0
+#define JSON_C_MINOR_VERSION 16
+#define JSON_C_MICRO_VERSION 99
+#define JSON_C_VERSION_NUM \
+	((JSON_C_MAJOR_VERSION << 16) | (JSON_C_MINOR_VERSION << 8) | JSON_C_MICRO_VERSION)
+#define JSON_C_VERSION "0.16.99"
+
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+/**
+ * @see JSON_C_VERSION
+ * @return the version of the json-c library as a string
+ */
+JSON_EXPORT const char *json_c_version(void); /* Returns JSON_C_VERSION */
+
+/**
+ * The json-c version encoded into an int, with the low order 8 bits
+ * being the micro version, the next higher 8 bits being the minor version
+ * and the next higher 8 bits being the major version.
+ * For example, 7.12.99 would be 0x00070B63.
+ *
+ * @see JSON_C_VERSION_NUM
+ * @return the version of the json-c library as an int
+ */
+JSON_EXPORT int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_config.h.in b/lynq/S300/ap/app/apparms/json-c/json_config.h.in
new file mode 100755
index 0000000..7888e02
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_config.h.in
@@ -0,0 +1,3 @@
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef JSON_C_HAVE_INTTYPES_H
diff --git a/lynq/S300/ap/app/apparms/json-c/json_config.h.win32 b/lynq/S300/ap/app/apparms/json-c/json_config.h.win32
new file mode 100755
index 0000000..9c542a4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_config.h.win32
@@ -0,0 +1,5 @@
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#define JSON_C_HAVE_INTTYPES_H 1
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_inttypes.h b/lynq/S300/ap/app/apparms/json-c/json_inttypes.h
new file mode 100755
index 0000000..a901a8e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_inttypes.h
@@ -0,0 +1,29 @@
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+#ifndef _json_inttypes_h_
+#define _json_inttypes_h_
+
+#include "json_config.h"
+
+#ifdef JSON_C_HAVE_INTTYPES_H
+/* inttypes.h includes stdint.h */
+#include <inttypes.h>
+
+#else
+#include <stdint.h>
+
+#define PRId64 "I64d"
+#define SCNd64 "I64d"
+#define PRIu64 "I64u"
+
+#endif
+
+#if defined(_MSC_VER)
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_object.c b/lynq/S300/ap/app/apparms/json-c/json_object.c
new file mode 100755
index 0000000..04ec23c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_object.c
@@ -0,0 +1,1816 @@
+/*
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+
+#include "strerror_override.h"
+
+#include <assert.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#include <math.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "arraylist.h"
+#include "debug.h"
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_object_private.h"
+#include "json_util.h"
+#include "linkhash.h"
+#include "math_compat.h"
+#include "printbuf.h"
+#include "snprintf_compat.h"
+#include "strdup_compat.h"
+
+/* Avoid ctype.h and locale overhead */
+#define is_plain_digit(c) ((c) >= '0' && (c) <= '9')
+
+#if SIZEOF_LONG_LONG != SIZEOF_INT64_T
+#error The long long type is not 64-bits
+#endif
+
+#ifndef SSIZE_T_MAX
+#if SIZEOF_SSIZE_T == SIZEOF_INT
+#define SSIZE_T_MAX INT_MAX
+#elif SIZEOF_SSIZE_T == SIZEOF_LONG
+#define SSIZE_T_MAX LONG_MAX
+#elif SIZEOF_SSIZE_T == SIZEOF_LONG_LONG
+#define SSIZE_T_MAX LLONG_MAX
+#else
+#error Unable to determine size of ssize_t
+#endif
+#endif
+
+const char *json_hex_chars = "0123456789abcdefABCDEF";
+
+static void json_object_generic_delete(struct json_object *jso);
+
+#if defined(_MSC_VER) && (_MSC_VER <= 1800)
+/* VS2013 doesn't know about "inline" */
+#define inline __inline
+#elif defined(AIX_CC)
+#define inline
+#endif
+
+#ifdef __GNUC__
+#undef isnan
+#undef isinf
+#define isnan(x) __builtin_isnan(x)
+#define isinf(x) __builtin_isinf(x)
+#endif
+
+/*
+ * Helper functions to more safely cast to a particular type of json_object
+ */
+static inline struct json_object_object *JC_OBJECT(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_object *JC_OBJECT_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+static inline struct json_object_array *JC_ARRAY(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_array *JC_ARRAY_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+static inline struct json_object_boolean *JC_BOOL(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_boolean *JC_BOOL_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+static inline struct json_object_double *JC_DOUBLE(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_double *JC_DOUBLE_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+static inline struct json_object_int *JC_INT(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_int *JC_INT_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+static inline struct json_object_string *JC_STRING(struct json_object *jso)
+{
+	return (void *)jso;
+}
+static inline const struct json_object_string *JC_STRING_C(const struct json_object *jso)
+{
+	return (const void *)jso;
+}
+
+#define JC_CONCAT(a, b) a##b
+#define JC_CONCAT3(a, b, c) a##b##c
+
+#define JSON_OBJECT_NEW(jtype)                                                           \
+	(struct JC_CONCAT(json_object_, jtype) *)json_object_new(                        \
+	    JC_CONCAT(json_type_, jtype), sizeof(struct JC_CONCAT(json_object_, jtype)), \
+	    &JC_CONCAT3(json_object_, jtype, _to_json_string))
+
+static inline struct json_object *json_object_new(enum json_type o_type, size_t alloc_size,
+                                                  json_object_to_json_string_fn *to_json_string);
+
+static void json_object_object_delete(struct json_object *jso_base);
+static void json_object_string_delete(struct json_object *jso);
+static void json_object_array_delete(struct json_object *jso);
+
+static json_object_to_json_string_fn json_object_object_to_json_string;
+static json_object_to_json_string_fn json_object_boolean_to_json_string;
+static json_object_to_json_string_fn json_object_double_to_json_string_default;
+static json_object_to_json_string_fn json_object_int_to_json_string;
+static json_object_to_json_string_fn json_object_string_to_json_string;
+static json_object_to_json_string_fn json_object_array_to_json_string;
+static json_object_to_json_string_fn _json_object_userdata_to_json_string;
+
+#ifndef JSON_NORETURN
+#if defined(_MSC_VER)
+#define JSON_NORETURN __declspec(noreturn)
+#elif defined(__OS400__)
+#define JSON_NORETURN
+#else
+/* 'cold' attribute is for optimization, telling the computer this code
+ * path is unlikely.
+ */
+#define JSON_NORETURN __attribute__((noreturn, cold))
+#endif
+#endif
+/**
+ * Abort and optionally print a message on standard error.
+ * This should be used rather than assert() for unconditional abortion
+ * (in particular for code paths which are never supposed to be run).
+ * */
+JSON_NORETURN static void json_abort(const char *message);
+
+/* helper for accessing the optimized string data component in json_object
+ */
+static inline char *get_string_component_mutable(struct json_object *jso)
+{
+	if (JC_STRING_C(jso)->len < 0)
+	{
+		/* Due to json_object_set_string(), we might have a pointer */
+		return JC_STRING(jso)->c_string.pdata;
+	}
+	return JC_STRING(jso)->c_string.idata;
+}
+static inline const char *get_string_component(const struct json_object *jso)
+{
+	return get_string_component_mutable((void *)(uintptr_t)(const void *)jso);
+}
+
+/* string escaping */
+
+static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int flags)
+{
+	size_t pos = 0, start_offset = 0;
+	unsigned char c;
+	while (len)
+	{
+		--len;
+		c = str[pos];
+		switch (c)
+		{
+		case '\b':
+		case '\n':
+		case '\r':
+		case '\t':
+		case '\f':
+		case '"':
+		case '\\':
+		case '/':
+			if ((flags & JSON_C_TO_STRING_NOSLASHESCAPE) && c == '/')
+			{
+				pos++;
+				break;
+			}
+
+			if (pos > start_offset)
+				printbuf_memappend(pb, str + start_offset, pos - start_offset);
+
+			if (c == '\b')
+				printbuf_memappend(pb, "\\b", 2);
+			else if (c == '\n')
+				printbuf_memappend(pb, "\\n", 2);
+			else if (c == '\r')
+				printbuf_memappend(pb, "\\r", 2);
+			else if (c == '\t')
+				printbuf_memappend(pb, "\\t", 2);
+			else if (c == '\f')
+				printbuf_memappend(pb, "\\f", 2);
+			else if (c == '"')
+				printbuf_memappend(pb, "\\\"", 2);
+			else if (c == '\\')
+				printbuf_memappend(pb, "\\\\", 2);
+			else if (c == '/')
+				printbuf_memappend(pb, "\\/", 2);
+
+			start_offset = ++pos;
+			break;
+		default:
+			if (c < ' ')
+			{
+				char sbuf[7];
+				if (pos > start_offset)
+					printbuf_memappend(pb, str + start_offset,
+					                   pos - start_offset);
+				snprintf(sbuf, sizeof(sbuf), "\\u00%c%c", json_hex_chars[c >> 4],
+				         json_hex_chars[c & 0xf]);
+				printbuf_memappend_fast(pb, sbuf, (int)sizeof(sbuf) - 1);
+				start_offset = ++pos;
+			}
+			else
+				pos++;
+		}
+	}
+	if (pos > start_offset)
+		printbuf_memappend(pb, str + start_offset, pos - start_offset);
+	return 0;
+}
+
+/* reference counting */
+
+struct json_object *json_object_get(struct json_object *jso)
+{
+	if (!jso)
+		return jso;
+
+	// Don't overflow the refcounter.
+	assert(jso->_ref_count < UINT32_MAX);
+
+#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
+	__sync_add_and_fetch(&jso->_ref_count, 1);
+#else
+	++jso->_ref_count;
+#endif
+
+	return jso;
+}
+
+int json_object_put(struct json_object *jso)
+{
+	if (!jso)
+		return 0;
+
+	/* Avoid invalid free and crash explicitly instead of (silently)
+	 * segfaulting.
+	 */
+	assert(jso->_ref_count > 0);
+
+#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
+	/* Note: this only allow the refcount to remain correct
+	 * when multiple threads are adjusting it.  It is still an error
+	 * for a thread to decrement the refcount if it doesn't "own" it,
+	 * as that can result in the thread that loses the race to 0
+	 * operating on an already-freed object.
+	 */
+	if (__sync_sub_and_fetch(&jso->_ref_count, 1) > 0)
+		return 0;
+#else
+	if (--jso->_ref_count > 0)
+		return 0;
+#endif
+
+	if (jso->_user_delete)
+		jso->_user_delete(jso, jso->_userdata);
+	switch (jso->o_type)
+	{
+	case json_type_object: json_object_object_delete(jso); break;
+	case json_type_array: json_object_array_delete(jso); break;
+	case json_type_string: json_object_string_delete(jso); break;
+	default: json_object_generic_delete(jso); break;
+	}
+	return 1;
+}
+
+/* generic object construction and destruction parts */
+
+static void json_object_generic_delete(struct json_object *jso)
+{
+	printbuf_free(jso->_pb);
+	free(jso);
+}
+
+static inline struct json_object *json_object_new(enum json_type o_type, size_t alloc_size,
+                                                  json_object_to_json_string_fn *to_json_string)
+{
+	struct json_object *jso;
+
+	jso = (struct json_object *)malloc(alloc_size);
+	if (!jso)
+		return NULL;
+
+	jso->o_type = o_type;
+	jso->_ref_count = 1;
+	jso->_to_json_string = to_json_string;
+	jso->_pb = NULL;
+	jso->_user_delete = NULL;
+	jso->_userdata = NULL;
+	//jso->...   // Type-specific fields must be set by caller
+
+	return jso;
+}
+
+/* type checking functions */
+
+int json_object_is_type(const struct json_object *jso, enum json_type type)
+{
+	if (!jso)
+		return (type == json_type_null);
+	return (jso->o_type == type);
+}
+
+enum json_type json_object_get_type(const struct json_object *jso)
+{
+	if (!jso)
+		return json_type_null;
+	return jso->o_type;
+}
+
+void *json_object_get_userdata(json_object *jso)
+{
+	return jso ? jso->_userdata : NULL;
+}
+
+void json_object_set_userdata(json_object *jso, void *userdata, json_object_delete_fn *user_delete)
+{
+	// Can't return failure, so abort if we can't perform the operation.
+	assert(jso != NULL);
+
+	// First, clean up any previously existing user info
+	if (jso->_user_delete)
+		jso->_user_delete(jso, jso->_userdata);
+
+	jso->_userdata = userdata;
+	jso->_user_delete = user_delete;
+}
+
+/* set a custom conversion to string */
+
+void json_object_set_serializer(json_object *jso, json_object_to_json_string_fn *to_string_func,
+                                void *userdata, json_object_delete_fn *user_delete)
+{
+	json_object_set_userdata(jso, userdata, user_delete);
+
+	if (to_string_func == NULL)
+	{
+		// Reset to the standard serialization function
+		switch (jso->o_type)
+		{
+		case json_type_null: jso->_to_json_string = NULL; break;
+		case json_type_boolean:
+			jso->_to_json_string = &json_object_boolean_to_json_string;
+			break;
+		case json_type_double:
+			jso->_to_json_string = &json_object_double_to_json_string_default;
+			break;
+		case json_type_int: jso->_to_json_string = &json_object_int_to_json_string; break;
+		case json_type_object:
+			jso->_to_json_string = &json_object_object_to_json_string;
+			break;
+		case json_type_array:
+			jso->_to_json_string = &json_object_array_to_json_string;
+			break;
+		case json_type_string:
+			jso->_to_json_string = &json_object_string_to_json_string;
+			break;
+		}
+		return;
+	}
+
+	jso->_to_json_string = to_string_func;
+}
+
+/* extended conversion to string */
+
+const char *json_object_to_json_string_length(struct json_object *jso, int flags, size_t *length)
+{
+	const char *r = NULL;
+	size_t s = 0;
+
+	if (!jso)
+	{
+		s = 4;
+		r = "null";
+	}
+	else if ((jso->_pb) || (jso->_pb = printbuf_new()))
+	{
+		printbuf_reset(jso->_pb);
+
+		if (jso->_to_json_string(jso, jso->_pb, 0, flags) >= 0)
+		{
+			s = (size_t)jso->_pb->bpos;
+			r = jso->_pb->buf;
+		}
+	}
+
+	if (length)
+		*length = s;
+	return r;
+}
+
+const char *json_object_to_json_string_ext(struct json_object *jso, int flags)
+{
+	return json_object_to_json_string_length(jso, flags, NULL);
+}
+
+/* backwards-compatible conversion to string */
+
+const char *json_object_to_json_string(struct json_object *jso)
+{
+	return json_object_to_json_string_ext(jso, JSON_C_TO_STRING_SPACED);
+}
+
+static void indent(struct printbuf *pb, int level, int flags)
+{
+	if (flags & JSON_C_TO_STRING_PRETTY)
+	{
+		if (flags & JSON_C_TO_STRING_PRETTY_TAB)
+		{
+			printbuf_memset(pb, -1, '\t', level);
+		}
+		else
+		{
+			printbuf_memset(pb, -1, ' ', level * 2);
+		}
+	}
+}
+
+/* json_object_object */
+
+static int json_object_object_to_json_string(struct json_object *jso, struct printbuf *pb,
+                                             int level, int flags)
+{
+	int had_children = 0;
+	struct json_object_iter iter;
+
+	printbuf_strappend(pb, "{" /*}*/);
+	json_object_object_foreachC(jso, iter)
+	{
+		if (had_children)
+		{
+			printbuf_strappend(pb, ",");
+		}
+		if (flags & JSON_C_TO_STRING_PRETTY)
+			printbuf_strappend(pb, "\n");
+		had_children = 1;
+		if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
+			printbuf_strappend(pb, " ");
+		indent(pb, level + 1, flags);
+		printbuf_strappend(pb, "\"");
+		json_escape_str(pb, iter.key, strlen(iter.key), flags);
+		if (flags & JSON_C_TO_STRING_SPACED)
+			printbuf_strappend(pb, "\": ");
+		else
+			printbuf_strappend(pb, "\":");
+		if (iter.val == NULL)
+			printbuf_strappend(pb, "null");
+		else if (iter.val->_to_json_string(iter.val, pb, level + 1, flags) < 0)
+			return -1;
+	}
+	if ((flags & JSON_C_TO_STRING_PRETTY) && had_children)
+	{
+		printbuf_strappend(pb, "\n");
+		indent(pb, level, flags);
+	}
+	if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
+		return printbuf_strappend(pb, /*{*/ " }");
+	else
+		return printbuf_strappend(pb, /*{*/ "}");
+}
+
+static void json_object_lh_entry_free(struct lh_entry *ent)
+{
+	if (!lh_entry_k_is_constant(ent))
+		free(lh_entry_k(ent));
+	json_object_put((struct json_object *)lh_entry_v(ent));
+}
+
+static void json_object_object_delete(struct json_object *jso_base)
+{
+	lh_table_free(JC_OBJECT(jso_base)->c_object);
+	json_object_generic_delete(jso_base);
+}
+
+struct json_object *json_object_new_object(void)
+{
+	struct json_object_object *jso = JSON_OBJECT_NEW(object);
+	if (!jso)
+		return NULL;
+	jso->c_object =
+	    lh_kchar_table_new(JSON_OBJECT_DEF_HASH_ENTRIES, &json_object_lh_entry_free);
+	if (!jso->c_object)
+	{
+		json_object_generic_delete(&jso->base);
+		errno = ENOMEM;
+		return NULL;
+	}
+	return &jso->base;
+}
+
+struct lh_table *json_object_get_object(const struct json_object *jso)
+{
+	if (!jso)
+		return NULL;
+	switch (jso->o_type)
+	{
+	case json_type_object: return JC_OBJECT_C(jso)->c_object;
+	default: return NULL;
+	}
+}
+
+int json_object_object_add_ex(struct json_object *jso, const char *const key,
+                              struct json_object *const val, const unsigned opts)
+{
+	struct json_object *existing_value = NULL;
+	struct lh_entry *existing_entry;
+	unsigned long hash;
+
+	assert(json_object_get_type(jso) == json_type_object);
+
+	// We lookup the entry and replace the value, rather than just deleting
+	// and re-adding it, so the existing key remains valid.
+	hash = lh_get_hash(JC_OBJECT(jso)->c_object, (const void *)key);
+	existing_entry =
+	    (opts & JSON_C_OBJECT_ADD_KEY_IS_NEW)
+	        ? NULL
+	        : lh_table_lookup_entry_w_hash(JC_OBJECT(jso)->c_object, (const void *)key, hash);
+
+	// The caller must avoid creating loops in the object tree, but do a
+	// quick check anyway to make sure we're not creating a trivial loop.
+	if (jso == val)
+		return -1;
+
+	if (!existing_entry)
+	{
+		const void *const k =
+		    (opts & JSON_C_OBJECT_ADD_CONSTANT_KEY) ? (const void *)key : strdup(key);
+		if (k == NULL)
+			return -1;
+		return lh_table_insert_w_hash(JC_OBJECT(jso)->c_object, k, val, hash, opts);
+	}
+	existing_value = (json_object *)lh_entry_v(existing_entry);
+	if (existing_value)
+		json_object_put(existing_value);
+	lh_entry_set_val(existing_entry, val);
+	return 0;
+}
+
+int json_object_object_add(struct json_object *jso, const char *key, struct json_object *val)
+{
+	return json_object_object_add_ex(jso, key, val, 0);
+}
+
+int json_object_object_length(const struct json_object *jso)
+{
+	assert(json_object_get_type(jso) == json_type_object);
+	return lh_table_length(JC_OBJECT_C(jso)->c_object);
+}
+
+size_t json_c_object_sizeof(void)
+{
+	return sizeof(struct json_object);
+}
+
+struct json_object *json_object_object_get(const struct json_object *jso, const char *key)
+{
+	struct json_object *result = NULL;
+	json_object_object_get_ex(jso, key, &result);
+	return result;
+}
+
+json_bool json_object_object_get_ex(const struct json_object *jso, const char *key,
+                                    struct json_object **value)
+{
+	if (value != NULL)
+		*value = NULL;
+
+	if (NULL == jso)
+		return 0;
+
+	switch (jso->o_type)
+	{
+	case json_type_object:
+		return lh_table_lookup_ex(JC_OBJECT_C(jso)->c_object, (const void *)key,
+		                          (void **)value);
+	default:
+		if (value != NULL)
+			*value = NULL;
+		return 0;
+	}
+}
+
+void json_object_object_del(struct json_object *jso, const char *key)
+{
+	assert(json_object_get_type(jso) == json_type_object);
+	lh_table_delete(JC_OBJECT(jso)->c_object, key);
+}
+
+/* json_object_boolean */
+
+static int json_object_boolean_to_json_string(struct json_object *jso, struct printbuf *pb,
+                                              int level, int flags)
+{
+	if (JC_BOOL(jso)->c_boolean)
+		return printbuf_strappend(pb, "true");
+	return printbuf_strappend(pb, "false");
+}
+
+struct json_object *json_object_new_boolean(json_bool b)
+{
+	struct json_object_boolean *jso = JSON_OBJECT_NEW(boolean);
+	if (!jso)
+		return NULL;
+	jso->c_boolean = b;
+	return &jso->base;
+}
+
+json_bool json_object_get_boolean(const struct json_object *jso)
+{
+	if (!jso)
+		return 0;
+	switch (jso->o_type)
+	{
+	case json_type_boolean: return JC_BOOL_C(jso)->c_boolean;
+	case json_type_int:
+		switch (JC_INT_C(jso)->cint_type)
+		{
+		case json_object_int_type_int64: return (JC_INT_C(jso)->cint.c_int64 != 0);
+		case json_object_int_type_uint64: return (JC_INT_C(jso)->cint.c_uint64 != 0);
+		default: json_abort("invalid cint_type");
+		}
+	case json_type_double: return (JC_DOUBLE_C(jso)->c_double != 0);
+	case json_type_string: return (JC_STRING_C(jso)->len != 0);
+	default: return 0;
+	}
+}
+
+int json_object_set_boolean(struct json_object *jso, json_bool new_value)
+{
+	if (!jso || jso->o_type != json_type_boolean)
+		return 0;
+	JC_BOOL(jso)->c_boolean = new_value;
+	return 1;
+}
+
+/* json_object_int */
+
+static int json_object_int_to_json_string(struct json_object *jso, struct printbuf *pb, int level,
+                                          int flags)
+{
+	/* room for 19 digits, the sign char, and a null term */
+	char sbuf[21];
+	if (JC_INT(jso)->cint_type == json_object_int_type_int64)
+		snprintf(sbuf, sizeof(sbuf), "%" PRId64, JC_INT(jso)->cint.c_int64);
+	else
+		snprintf(sbuf, sizeof(sbuf), "%" PRIu64, JC_INT(jso)->cint.c_uint64);
+	return printbuf_memappend(pb, sbuf, strlen(sbuf));
+}
+
+struct json_object *json_object_new_int(int32_t i)
+{
+	return json_object_new_int64(i);
+}
+
+int32_t json_object_get_int(const struct json_object *jso)
+{
+	int64_t cint64 = 0;
+	double cdouble;
+	enum json_type o_type;
+
+	if (!jso)
+		return 0;
+
+	o_type = jso->o_type;
+	if (o_type == json_type_int)
+	{
+		const struct json_object_int *jsoint = JC_INT_C(jso);
+		if (jsoint->cint_type == json_object_int_type_int64)
+		{
+			cint64 = jsoint->cint.c_int64;
+		}
+		else
+		{
+			if (jsoint->cint.c_uint64 >= INT64_MAX)
+				cint64 = INT64_MAX;
+			else
+				cint64 = (int64_t)jsoint->cint.c_uint64;
+		}
+	}
+	else if (o_type == json_type_string)
+	{
+		/*
+		 * Parse strings into 64-bit numbers, then use the
+		 * 64-to-32-bit number handling below.
+		 */
+		if (json_parse_int64(get_string_component(jso), &cint64) != 0)
+			return 0; /* whoops, it didn't work. */
+		o_type = json_type_int;
+	}
+
+	switch (o_type)
+	{
+	case json_type_int:
+		/* Make sure we return the correct values for out of range numbers. */
+		if (cint64 <= INT32_MIN)
+			return INT32_MIN;
+		if (cint64 >= INT32_MAX)
+			return INT32_MAX;
+		return (int32_t)cint64;
+	case json_type_double:
+		cdouble = JC_DOUBLE_C(jso)->c_double;
+		if (cdouble <= INT32_MIN)
+			return INT32_MIN;
+		if (cdouble >= INT32_MAX)
+			return INT32_MAX;
+		return (int32_t)cdouble;
+	case json_type_boolean: return JC_BOOL_C(jso)->c_boolean;
+	default: return 0;
+	}
+}
+
+int json_object_set_int(struct json_object *jso, int new_value)
+{
+	return json_object_set_int64(jso, (int64_t)new_value);
+}
+
+struct json_object *json_object_new_int64(int64_t i)
+{
+	struct json_object_int *jso = JSON_OBJECT_NEW(int);
+	if (!jso)
+		return NULL;
+	jso->cint.c_int64 = i;
+	jso->cint_type = json_object_int_type_int64;
+	return &jso->base;
+}
+
+struct json_object *json_object_new_uint64(uint64_t i)
+{
+	struct json_object_int *jso = JSON_OBJECT_NEW(int);
+	if (!jso)
+		return NULL;
+	jso->cint.c_uint64 = i;
+	jso->cint_type = json_object_int_type_uint64;
+	return &jso->base;
+}
+
+int64_t json_object_get_int64(const struct json_object *jso)
+{
+	int64_t cint;
+
+	if (!jso)
+		return 0;
+	switch (jso->o_type)
+	{
+	case json_type_int:
+	{
+		const struct json_object_int *jsoint = JC_INT_C(jso);
+		switch (jsoint->cint_type)
+		{
+		case json_object_int_type_int64: return jsoint->cint.c_int64;
+		case json_object_int_type_uint64:
+			if (jsoint->cint.c_uint64 >= INT64_MAX)
+				return INT64_MAX;
+			return (int64_t)jsoint->cint.c_uint64;
+		default: json_abort("invalid cint_type");
+		}
+	}
+	case json_type_double:
+		// INT64_MAX can't be exactly represented as a double
+		// so cast to tell the compiler it's ok to round up.
+		if (JC_DOUBLE_C(jso)->c_double >= (double)INT64_MAX)
+			return INT64_MAX;
+		if (JC_DOUBLE_C(jso)->c_double <= INT64_MIN)
+			return INT64_MIN;
+		return (int64_t)JC_DOUBLE_C(jso)->c_double;
+	case json_type_boolean: return JC_BOOL_C(jso)->c_boolean;
+	case json_type_string:
+		if (json_parse_int64(get_string_component(jso), &cint) == 0)
+			return cint;
+		/* FALLTHRU */
+	default: return 0;
+	}
+}
+
+uint64_t json_object_get_uint64(const struct json_object *jso)
+{
+	uint64_t cuint;
+
+	if (!jso)
+		return 0;
+	switch (jso->o_type)
+	{
+	case json_type_int:
+	{
+		const struct json_object_int *jsoint = JC_INT_C(jso);
+		switch (jsoint->cint_type)
+		{
+		case json_object_int_type_int64:
+			if (jsoint->cint.c_int64 < 0)
+				return 0;
+			return (uint64_t)jsoint->cint.c_int64;
+		case json_object_int_type_uint64: return jsoint->cint.c_uint64;
+		default: json_abort("invalid cint_type");
+		}
+	}
+	case json_type_double:
+		// UINT64_MAX can't be exactly represented as a double
+		// so cast to tell the compiler it's ok to round up.
+		if (JC_DOUBLE_C(jso)->c_double >= (double)UINT64_MAX)
+			return UINT64_MAX;
+		if (JC_DOUBLE_C(jso)->c_double < 0)
+			return 0;
+		return (uint64_t)JC_DOUBLE_C(jso)->c_double;
+	case json_type_boolean: return JC_BOOL_C(jso)->c_boolean;
+	case json_type_string:
+		if (json_parse_uint64(get_string_component(jso), &cuint) == 0)
+			return cuint;
+		/* FALLTHRU */
+	default: return 0;
+	}
+}
+
+int json_object_set_int64(struct json_object *jso, int64_t new_value)
+{
+	if (!jso || jso->o_type != json_type_int)
+		return 0;
+	JC_INT(jso)->cint.c_int64 = new_value;
+	JC_INT(jso)->cint_type = json_object_int_type_int64;
+	return 1;
+}
+
+int json_object_set_uint64(struct json_object *jso, uint64_t new_value)
+{
+	if (!jso || jso->o_type != json_type_int)
+		return 0;
+	JC_INT(jso)->cint.c_uint64 = new_value;
+	JC_INT(jso)->cint_type = json_object_int_type_uint64;
+	return 1;
+}
+
+int json_object_int_inc(struct json_object *jso, int64_t val)
+{
+	struct json_object_int *jsoint;
+	if (!jso || jso->o_type != json_type_int)
+		return 0;
+	jsoint = JC_INT(jso);
+	switch (jsoint->cint_type)
+	{
+	case json_object_int_type_int64:
+		if (val > 0 && jsoint->cint.c_int64 > INT64_MAX - val)
+		{
+			jsoint->cint.c_uint64 = (uint64_t)jsoint->cint.c_int64 + (uint64_t)val;
+			jsoint->cint_type = json_object_int_type_uint64;
+		}
+		else if (val < 0 && jsoint->cint.c_int64 < INT64_MIN - val)
+		{
+			jsoint->cint.c_int64 = INT64_MIN;
+		}
+		else
+		{
+			jsoint->cint.c_int64 += val;
+		}
+		return 1;
+	case json_object_int_type_uint64:
+		if (val > 0 && jsoint->cint.c_uint64 > UINT64_MAX - (uint64_t)val)
+		{
+			jsoint->cint.c_uint64 = UINT64_MAX;
+		}
+		else if (val < 0 && jsoint->cint.c_uint64 < (uint64_t)(-val))
+		{
+			jsoint->cint.c_int64 = (int64_t)jsoint->cint.c_uint64 + val;
+			jsoint->cint_type = json_object_int_type_int64;
+		}
+		else if (val < 0 && jsoint->cint.c_uint64 >= (uint64_t)(-val))
+		{
+			jsoint->cint.c_uint64 -= (uint64_t)(-val);
+		}
+		else
+		{
+			jsoint->cint.c_uint64 += val;
+		}
+		return 1;
+	default: json_abort("invalid cint_type");
+	}
+}
+
+/* json_object_double */
+
+#if defined(HAVE___THREAD)
+// i.e. __thread or __declspec(thread)
+static SPEC___THREAD char *tls_serialization_float_format = NULL;
+#endif
+static char *global_serialization_float_format = NULL;
+
+int json_c_set_serialization_double_format(const char *double_format, int global_or_thread)
+{
+	if (global_or_thread == JSON_C_OPTION_GLOBAL)
+	{
+#if defined(HAVE___THREAD)
+		if (tls_serialization_float_format)
+		{
+			free(tls_serialization_float_format);
+			tls_serialization_float_format = NULL;
+		}
+#endif
+		if (global_serialization_float_format)
+			free(global_serialization_float_format);
+		if (double_format)
+		{
+			char *p = strdup(double_format);
+			if (p == NULL)
+			{
+				_json_c_set_last_err("json_c_set_serialization_double_format: "
+				                     "out of memory\n");
+				return -1;
+			}
+			global_serialization_float_format = p;
+		}
+		else
+		{
+			global_serialization_float_format = NULL;
+		}
+	}
+	else if (global_or_thread == JSON_C_OPTION_THREAD)
+	{
+#if defined(HAVE___THREAD)
+		if (tls_serialization_float_format)
+		{
+			free(tls_serialization_float_format);
+			tls_serialization_float_format = NULL;
+		}
+		if (double_format)
+		{
+			char *p = strdup(double_format);
+			if (p == NULL)
+			{
+				_json_c_set_last_err("json_c_set_serialization_double_format: "
+				                     "out of memory\n");
+				return -1;
+			}
+			tls_serialization_float_format = p;
+		}
+		else
+		{
+			tls_serialization_float_format = NULL;
+		}
+#else
+		_json_c_set_last_err("json_c_set_serialization_double_format: not compiled "
+		                     "with __thread support\n");
+		return -1;
+#endif
+	}
+	else
+	{
+		_json_c_set_last_err("json_c_set_serialization_double_format: invalid "
+		                     "global_or_thread value: %d\n", global_or_thread);
+		return -1;
+	}
+	return 0;
+}
+
+static int json_object_double_to_json_string_format(struct json_object *jso, struct printbuf *pb,
+                                                    int level, int flags, const char *format)
+{
+	struct json_object_double *jsodbl = JC_DOUBLE(jso);
+	char buf[128], *p, *q;
+	int size;
+	/* Although JSON RFC does not support
+	 * NaN or Infinity as numeric values
+	 * ECMA 262 section 9.8.1 defines
+	 * how to handle these cases as strings
+	 */
+	if (isnan(jsodbl->c_double))
+	{
+		size = snprintf(buf, sizeof(buf), "NaN");
+	}
+	else if (isinf(jsodbl->c_double))
+	{
+		if (jsodbl->c_double > 0)
+			size = snprintf(buf, sizeof(buf), "Infinity");
+		else
+			size = snprintf(buf, sizeof(buf), "-Infinity");
+	}
+	else
+	{
+		const char *std_format = "%.17g";
+		int format_drops_decimals = 0;
+		int looks_numeric = 0;
+
+		if (!format)
+		{
+#if defined(HAVE___THREAD)
+			if (tls_serialization_float_format)
+				format = tls_serialization_float_format;
+			else
+#endif
+			    if (global_serialization_float_format)
+				format = global_serialization_float_format;
+			else
+				format = std_format;
+		}
+		size = snprintf(buf, sizeof(buf), format, jsodbl->c_double);
+
+		if (size < 0)
+			return -1;
+
+		p = strchr(buf, ',');
+		if (p)
+			*p = '.';
+		else
+			p = strchr(buf, '.');
+
+		if (format == std_format || strstr(format, ".0f") == NULL)
+			format_drops_decimals = 1;
+
+		looks_numeric = /* Looks like *some* kind of number */
+		    is_plain_digit(buf[0]) || (size > 1 && buf[0] == '-' && is_plain_digit(buf[1]));
+
+		if (size < (int)sizeof(buf) - 2 && looks_numeric && !p && /* Has no decimal point */
+		    strchr(buf, 'e') == NULL && /* Not scientific notation */
+		    format_drops_decimals)
+		{
+			// Ensure it looks like a float, even if snprintf didn't,
+			//  unless a custom format is set to omit the decimal.
+			strcat(buf, ".0");
+			size += 2;
+		}
+		if (p && (flags & JSON_C_TO_STRING_NOZERO))
+		{
+			/* last useful digit, always keep 1 zero */
+			p++;
+			for (q = p; *q; q++)
+			{
+				if (*q != '0')
+					p = q;
+			}
+			/* drop trailing zeroes */
+			if (*p != 0)
+				*(++p) = 0;
+			size = p - buf;
+		}
+	}
+	// although unlikely, snprintf can fail
+	if (size < 0)
+		return -1;
+
+	if (size >= (int)sizeof(buf))
+		// The standard formats are guaranteed not to overrun the buffer,
+		// but if a custom one happens to do so, just silently truncate.
+		size = sizeof(buf) - 1;
+	printbuf_memappend(pb, buf, size);
+	return size;
+}
+
+static int json_object_double_to_json_string_default(struct json_object *jso, struct printbuf *pb,
+                                                     int level, int flags)
+{
+	return json_object_double_to_json_string_format(jso, pb, level, flags, NULL);
+}
+
+int json_object_double_to_json_string(struct json_object *jso, struct printbuf *pb, int level,
+                                      int flags)
+{
+	return json_object_double_to_json_string_format(jso, pb, level, flags,
+	                                                (const char *)jso->_userdata);
+}
+
+struct json_object *json_object_new_double(double d)
+{
+	struct json_object_double *jso = JSON_OBJECT_NEW(double);
+	if (!jso)
+		return NULL;
+	jso->base._to_json_string = &json_object_double_to_json_string_default;
+	jso->c_double = d;
+	return &jso->base;
+}
+
+struct json_object *json_object_new_double_s(double d, const char *ds)
+{
+	char *new_ds;
+	struct json_object *jso = json_object_new_double(d);
+	if (!jso)
+		return NULL;
+
+	new_ds = strdup(ds);
+	if (!new_ds)
+	{
+		json_object_generic_delete(jso);
+		errno = ENOMEM;
+		return NULL;
+	}
+	json_object_set_serializer(jso, _json_object_userdata_to_json_string, new_ds,
+	                           json_object_free_userdata);
+	return jso;
+}
+
+/*
+ * A wrapper around json_object_userdata_to_json_string() used only
+ * by json_object_new_double_s() just so json_object_set_double() can
+ * detect when it needs to reset the serializer to the default.
+ */
+static int _json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb,
+                                                int level, int flags)
+{
+	return json_object_userdata_to_json_string(jso, pb, level, flags);
+}
+
+int json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb, int level,
+                                        int flags)
+{
+	int userdata_len = strlen((const char *)jso->_userdata);
+	printbuf_memappend(pb, (const char *)jso->_userdata, userdata_len);
+	return userdata_len;
+}
+
+void json_object_free_userdata(struct json_object *jso, void *userdata)
+{
+	free(userdata);
+}
+
+double json_object_get_double(const struct json_object *jso)
+{
+	double cdouble;
+	char *errPtr = NULL;
+
+	if (!jso)
+		return 0.0;
+	switch (jso->o_type)
+	{
+	case json_type_double: return JC_DOUBLE_C(jso)->c_double;
+	case json_type_int:
+		switch (JC_INT_C(jso)->cint_type)
+		{
+		case json_object_int_type_int64: return JC_INT_C(jso)->cint.c_int64;
+		case json_object_int_type_uint64: return JC_INT_C(jso)->cint.c_uint64;
+		default: json_abort("invalid cint_type");
+		}
+	case json_type_boolean: return JC_BOOL_C(jso)->c_boolean;
+	case json_type_string:
+		errno = 0;
+		cdouble = strtod(get_string_component(jso), &errPtr);
+
+		/* if conversion stopped at the first character, return 0.0 */
+		if (errPtr == get_string_component(jso))
+		{
+			errno = EINVAL;
+			return 0.0;
+		}
+
+		/*
+		 * Check that the conversion terminated on something sensible
+		 *
+		 * For example, { "pay" : 123AB } would parse as 123.
+		 */
+		if (*errPtr != '\0')
+		{
+			errno = EINVAL;
+			return 0.0;
+		}
+
+		/*
+		 * If strtod encounters a string which would exceed the
+		 * capacity of a double, it returns +/- HUGE_VAL and sets
+		 * errno to ERANGE. But +/- HUGE_VAL is also a valid result
+		 * from a conversion, so we need to check errno.
+		 *
+		 * Underflow also sets errno to ERANGE, but it returns 0 in
+		 * that case, which is what we will return anyway.
+		 *
+		 * See CERT guideline ERR30-C
+		 */
+		if ((HUGE_VAL == cdouble || -HUGE_VAL == cdouble) && (ERANGE == errno))
+			cdouble = 0.0;
+		return cdouble;
+	default: errno = EINVAL; return 0.0;
+	}
+}
+
+int json_object_set_double(struct json_object *jso, double new_value)
+{
+	if (!jso || jso->o_type != json_type_double)
+		return 0;
+	JC_DOUBLE(jso)->c_double = new_value;
+	if (jso->_to_json_string == &_json_object_userdata_to_json_string)
+		json_object_set_serializer(jso, NULL, NULL, NULL);
+	return 1;
+}
+
+/* json_object_string */
+
+static int json_object_string_to_json_string(struct json_object *jso, struct printbuf *pb,
+                                             int level, int flags)
+{
+	ssize_t len = JC_STRING(jso)->len;
+	printbuf_strappend(pb, "\"");
+	json_escape_str(pb, get_string_component(jso), len < 0 ? -(ssize_t)len : len, flags);
+	printbuf_strappend(pb, "\"");
+	return 0;
+}
+
+static void json_object_string_delete(struct json_object *jso)
+{
+	if (JC_STRING(jso)->len < 0)
+		free(JC_STRING(jso)->c_string.pdata);
+	json_object_generic_delete(jso);
+}
+
+static struct json_object *_json_object_new_string(const char *s, const size_t len)
+{
+	size_t objsize;
+	struct json_object_string *jso;
+
+	/*
+	 * Structures           Actual memory layout
+	 * -------------------  --------------------
+	 * [json_object_string  [json_object_string
+	 *  [json_object]        [json_object]
+	 *  ...other fields...   ...other fields...
+	 *  c_string]            len
+	 *                       bytes
+	 *                       of
+	 *                       string
+	 *                       data
+	 *                       \0]
+	 */
+	if (len > (SSIZE_T_MAX - (sizeof(*jso) - sizeof(jso->c_string)) - 1))
+		return NULL;
+	objsize = (sizeof(*jso) - sizeof(jso->c_string)) + len + 1;
+	if (len < sizeof(void *))
+		// We need a minimum size to support json_object_set_string() mutability
+		// so we can stuff a pointer into pdata :(
+		objsize += sizeof(void *) - len;
+
+	jso = (struct json_object_string *)json_object_new(json_type_string, objsize,
+	                                                   &json_object_string_to_json_string);
+
+	if (!jso)
+		return NULL;
+	jso->len = len;
+	memcpy(jso->c_string.idata, s, len);
+	// Cast below needed for Clang UB sanitizer
+	((char *)jso->c_string.idata)[len] = '\0';
+	return &jso->base;
+}
+
+struct json_object *json_object_new_string(const char *s)
+{
+	return _json_object_new_string(s, strlen(s));
+}
+
+struct json_object *json_object_new_string_len(const char *s, const int len)
+{
+	return _json_object_new_string(s, len);
+}
+
+const char *json_object_get_string(struct json_object *jso)
+{
+	if (!jso)
+		return NULL;
+	switch (jso->o_type)
+	{
+	case json_type_string: return get_string_component(jso);
+	default: return json_object_to_json_string(jso);
+	}
+}
+
+static inline ssize_t _json_object_get_string_len(const struct json_object_string *jso)
+{
+	ssize_t len;
+	len = jso->len;
+	return (len < 0) ? -(ssize_t)len : len;
+}
+int json_object_get_string_len(const struct json_object *jso)
+{
+	if (!jso)
+		return 0;
+	switch (jso->o_type)
+	{
+	case json_type_string: return _json_object_get_string_len(JC_STRING_C(jso));
+	default: return 0;
+	}
+}
+
+static int _json_object_set_string_len(json_object *jso, const char *s, size_t len)
+{
+	char *dstbuf;
+	ssize_t curlen;
+	ssize_t newlen;
+	if (jso == NULL || jso->o_type != json_type_string)
+		return 0;
+
+	if (len >= INT_MAX - 1)
+		// jso->len is a signed ssize_t, so it can't hold the
+		// full size_t range. json_object_get_string_len returns
+		// length as int, cap length at INT_MAX.
+		return 0;
+
+	curlen = JC_STRING(jso)->len;
+	if (curlen < 0) {
+		if (len == 0) {
+			free(JC_STRING(jso)->c_string.pdata);
+			JC_STRING(jso)->len = curlen = 0;
+		} else {
+			curlen = -curlen;
+		}
+	}
+
+	newlen = len;
+	dstbuf = get_string_component_mutable(jso);
+
+	if ((ssize_t)len > curlen)
+	{
+		// We have no way to return the new ptr from realloc(jso, newlen)
+		// and we have no way of knowing whether there's extra room available
+		// so we need to stuff a pointer in to pdata :(
+		dstbuf = (char *)malloc(len + 1);
+		if (dstbuf == NULL)
+			return 0;
+		if (JC_STRING(jso)->len < 0)
+			free(JC_STRING(jso)->c_string.pdata);
+		JC_STRING(jso)->c_string.pdata = dstbuf;
+		newlen = -(ssize_t)len;
+	}
+	else if (JC_STRING(jso)->len < 0)
+	{
+		// We've got enough room in the separate allocated buffer,
+		// so use it as-is and continue to indicate that pdata is used.
+		newlen = -(ssize_t)len;
+	}
+
+	memcpy(dstbuf, (const void *)s, len);
+	dstbuf[len] = '\0';
+	JC_STRING(jso)->len = newlen;
+	return 1;
+}
+
+int json_object_set_string(json_object *jso, const char *s)
+{
+	return _json_object_set_string_len(jso, s, strlen(s));
+}
+
+int json_object_set_string_len(json_object *jso, const char *s, int len)
+{
+	return _json_object_set_string_len(jso, s, len);
+}
+
+/* json_object_array */
+
+static int json_object_array_to_json_string(struct json_object *jso, struct printbuf *pb, int level,
+                                            int flags)
+{
+	int had_children = 0;
+	size_t ii;
+
+	printbuf_strappend(pb, "[");
+	for (ii = 0; ii < json_object_array_length(jso); ii++)
+	{
+		struct json_object *val;
+		if (had_children)
+		{
+			printbuf_strappend(pb, ",");
+		}
+		if (flags & JSON_C_TO_STRING_PRETTY)
+			printbuf_strappend(pb, "\n");
+		had_children = 1;
+		if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
+			printbuf_strappend(pb, " ");
+		indent(pb, level + 1, flags);
+		val = json_object_array_get_idx(jso, ii);
+		if (val == NULL)
+			printbuf_strappend(pb, "null");
+		else if (val->_to_json_string(val, pb, level + 1, flags) < 0)
+			return -1;
+	}
+	if ((flags & JSON_C_TO_STRING_PRETTY) && had_children)
+	{
+		printbuf_strappend(pb, "\n");
+		indent(pb, level, flags);
+	}
+
+	if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
+		return printbuf_strappend(pb, " ]");
+	return printbuf_strappend(pb, "]");
+}
+
+static void json_object_array_entry_free(void *data)
+{
+	json_object_put((struct json_object *)data);
+}
+
+static void json_object_array_delete(struct json_object *jso)
+{
+	array_list_free(JC_ARRAY(jso)->c_array);
+	json_object_generic_delete(jso);
+}
+
+struct json_object *json_object_new_array(void)
+{
+	return json_object_new_array_ext(ARRAY_LIST_DEFAULT_SIZE);
+}
+struct json_object *json_object_new_array_ext(int initial_size)
+{
+	struct json_object_array *jso = JSON_OBJECT_NEW(array);
+	if (!jso)
+		return NULL;
+	jso->c_array = array_list_new2(&json_object_array_entry_free, initial_size);
+	if (jso->c_array == NULL)
+	{
+		free(jso);
+		return NULL;
+	}
+	return &jso->base;
+}
+
+struct array_list *json_object_get_array(const struct json_object *jso)
+{
+	if (!jso)
+		return NULL;
+	switch (jso->o_type)
+	{
+	case json_type_array: return JC_ARRAY_C(jso)->c_array;
+	default: return NULL;
+	}
+}
+
+void json_object_array_sort(struct json_object *jso, int (*sort_fn)(const void *, const void *))
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	array_list_sort(JC_ARRAY(jso)->c_array, sort_fn);
+}
+
+struct json_object *json_object_array_bsearch(const struct json_object *key,
+                                              const struct json_object *jso,
+                                              int (*sort_fn)(const void *, const void *))
+{
+	struct json_object **result;
+
+	assert(json_object_get_type(jso) == json_type_array);
+	result = (struct json_object **)array_list_bsearch((const void **)(void *)&key,
+	                                                   JC_ARRAY_C(jso)->c_array, sort_fn);
+
+	if (!result)
+		return NULL;
+	return *result;
+}
+
+size_t json_object_array_length(const struct json_object *jso)
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	return array_list_length(JC_ARRAY_C(jso)->c_array);
+}
+
+int json_object_array_add(struct json_object *jso, struct json_object *val)
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	return array_list_add(JC_ARRAY(jso)->c_array, val);
+}
+
+int json_object_array_put_idx(struct json_object *jso, size_t idx, struct json_object *val)
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	return array_list_put_idx(JC_ARRAY(jso)->c_array, idx, val);
+}
+
+int json_object_array_del_idx(struct json_object *jso, size_t idx, size_t count)
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	return array_list_del_idx(JC_ARRAY(jso)->c_array, idx, count);
+}
+
+struct json_object *json_object_array_get_idx(const struct json_object *jso, size_t idx)
+{
+	assert(json_object_get_type(jso) == json_type_array);
+	return (struct json_object *)array_list_get_idx(JC_ARRAY_C(jso)->c_array, idx);
+}
+
+static int json_array_equal(struct json_object *jso1, struct json_object *jso2)
+{
+	size_t len, i;
+
+	len = json_object_array_length(jso1);
+	if (len != json_object_array_length(jso2))
+		return 0;
+
+	for (i = 0; i < len; i++)
+	{
+		if (!json_object_equal(json_object_array_get_idx(jso1, i),
+		                       json_object_array_get_idx(jso2, i)))
+			return 0;
+	}
+	return 1;
+}
+
+int json_object_array_shrink(struct json_object *jso, int empty_slots)
+{
+	if (empty_slots < 0)
+		json_abort("json_object_array_shrink called with negative empty_slots");
+	return array_list_shrink(JC_ARRAY(jso)->c_array, empty_slots);
+}
+
+struct json_object *json_object_new_null(void)
+{
+	return NULL;
+}
+
+static int json_object_all_values_equal(struct json_object *jso1, struct json_object *jso2)
+{
+	struct json_object_iter iter;
+	struct json_object *sub;
+
+	assert(json_object_get_type(jso1) == json_type_object);
+	assert(json_object_get_type(jso2) == json_type_object);
+	/* Iterate over jso1 keys and see if they exist and are equal in jso2 */
+	json_object_object_foreachC(jso1, iter)
+	{
+		if (!lh_table_lookup_ex(JC_OBJECT(jso2)->c_object, (void *)iter.key,
+		                        (void **)(void *)&sub))
+			return 0;
+		if (!json_object_equal(iter.val, sub))
+			return 0;
+	}
+
+	/* Iterate over jso2 keys to see if any exist that are not in jso1 */
+	json_object_object_foreachC(jso2, iter)
+	{
+		if (!lh_table_lookup_ex(JC_OBJECT(jso1)->c_object, (void *)iter.key,
+		                        (void **)(void *)&sub))
+			return 0;
+	}
+
+	return 1;
+}
+
+int json_object_equal(struct json_object *jso1, struct json_object *jso2)
+{
+	if (jso1 == jso2)
+		return 1;
+
+	if (!jso1 || !jso2)
+		return 0;
+
+	if (jso1->o_type != jso2->o_type)
+		return 0;
+
+	switch (jso1->o_type)
+	{
+	case json_type_boolean: return (JC_BOOL(jso1)->c_boolean == JC_BOOL(jso2)->c_boolean);
+
+	case json_type_double: return (JC_DOUBLE(jso1)->c_double == JC_DOUBLE(jso2)->c_double);
+
+	case json_type_int:
+	{
+		struct json_object_int *int1 = JC_INT(jso1);
+		struct json_object_int *int2 = JC_INT(jso2);
+		if (int1->cint_type == json_object_int_type_int64)
+		{
+			if (int2->cint_type == json_object_int_type_int64)
+				return (int1->cint.c_int64 == int2->cint.c_int64);
+			if (int1->cint.c_int64 < 0)
+				return 0;
+			return ((uint64_t)int1->cint.c_int64 == int2->cint.c_uint64);
+		}
+		// else jso1 is a uint64
+		if (int2->cint_type == json_object_int_type_uint64)
+			return (int1->cint.c_uint64 == int2->cint.c_uint64);
+		if (int2->cint.c_int64 < 0)
+			return 0;
+		return (int1->cint.c_uint64 == (uint64_t)int2->cint.c_int64);
+	}
+
+	case json_type_string:
+	{
+		return (_json_object_get_string_len(JC_STRING(jso1)) ==
+		            _json_object_get_string_len(JC_STRING(jso2)) &&
+		        memcmp(get_string_component(jso1), get_string_component(jso2),
+		               _json_object_get_string_len(JC_STRING(jso1))) == 0);
+	}
+
+	case json_type_object: return json_object_all_values_equal(jso1, jso2);
+
+	case json_type_array: return json_array_equal(jso1, jso2);
+
+	case json_type_null: return 1;
+	};
+
+	return 0;
+}
+
+static int json_object_copy_serializer_data(struct json_object *src, struct json_object *dst)
+{
+	if (!src->_userdata && !src->_user_delete)
+		return 0;
+
+	if (dst->_to_json_string == json_object_userdata_to_json_string ||
+	    dst->_to_json_string == _json_object_userdata_to_json_string)
+	{
+		char *p;
+		assert(src->_userdata);
+		p = strdup(src->_userdata);
+		if (p == NULL)
+		{
+			_json_c_set_last_err("json_object_copy_serializer_data: out of memory\n");
+			return -1;
+		}
+		dst->_userdata = p;
+	}
+	// else if ... other supported serializers ...
+	else
+	{
+		_json_c_set_last_err(
+		    "json_object_copy_serializer_data: unable to copy unknown serializer data: "
+		    "%p\n", (void *)dst->_to_json_string);
+		return -1;
+	}
+	dst->_user_delete = src->_user_delete;
+	return 0;
+}
+
+/**
+ * The default shallow copy implementation.  Simply creates a new object of the same
+ * type but does *not* copy over _userdata nor retain any custom serializer.
+ * If custom serializers are in use, json_object_deep_copy() must be passed a shallow copy
+ * implementation that is aware of how to copy them.
+ *
+ * This always returns -1 or 1.  It will never return 2 since it does not copy the serializer.
+ */
+int json_c_shallow_copy_default(json_object *src, json_object *parent, const char *key,
+                                size_t index, json_object **dst)
+{
+	switch (src->o_type)
+	{
+	case json_type_boolean: *dst = json_object_new_boolean(JC_BOOL(src)->c_boolean); break;
+
+	case json_type_double: *dst = json_object_new_double(JC_DOUBLE(src)->c_double); break;
+
+	case json_type_int:
+		switch (JC_INT(src)->cint_type)
+		{
+		case json_object_int_type_int64:
+			*dst = json_object_new_int64(JC_INT(src)->cint.c_int64);
+			break;
+		case json_object_int_type_uint64:
+			*dst = json_object_new_uint64(JC_INT(src)->cint.c_uint64);
+			break;
+		default: json_abort("invalid cint_type");
+		}
+		break;
+
+	case json_type_string:
+		*dst = json_object_new_string_len(get_string_component(src),
+		                                  _json_object_get_string_len(JC_STRING(src)));
+		break;
+
+	case json_type_object: *dst = json_object_new_object(); break;
+
+	case json_type_array: *dst = json_object_new_array(); break;
+
+	default: errno = EINVAL; return -1;
+	}
+
+	if (!*dst)
+	{
+		errno = ENOMEM;
+		return -1;
+	}
+	(*dst)->_to_json_string = src->_to_json_string;
+	// _userdata and _user_delete are copied later
+	return 1;
+}
+
+/*
+ * The actual guts of json_object_deep_copy(), with a few additional args
+ * needed so we can keep track of where we are within the object tree.
+ *
+ * Note: caller is responsible for freeing *dst if this fails and returns -1.
+ */
+static int json_object_deep_copy_recursive(struct json_object *src, struct json_object *parent,
+                                           const char *key_in_parent, size_t index_in_parent,
+                                           struct json_object **dst,
+                                           json_c_shallow_copy_fn *shallow_copy)
+{
+	struct json_object_iter iter;
+	size_t src_array_len, ii;
+
+	int shallow_copy_rc = 0;
+	shallow_copy_rc = shallow_copy(src, parent, key_in_parent, index_in_parent, dst);
+	/* -1=error, 1=object created ok, 2=userdata set */
+	if (shallow_copy_rc < 1)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+	assert(*dst != NULL);
+
+	switch (src->o_type)
+	{
+	case json_type_object:
+		json_object_object_foreachC(src, iter)
+		{
+			struct json_object *jso = NULL;
+			/* This handles the `json_type_null` case */
+			if (!iter.val)
+				jso = NULL;
+			else if (json_object_deep_copy_recursive(iter.val, src, iter.key, UINT_MAX,
+			                                         &jso, shallow_copy) < 0)
+			{
+				json_object_put(jso);
+				return -1;
+			}
+
+			if (json_object_object_add(*dst, iter.key, jso) < 0)
+			{
+				json_object_put(jso);
+				return -1;
+			}
+		}
+		break;
+
+	case json_type_array:
+		src_array_len = json_object_array_length(src);
+		for (ii = 0; ii < src_array_len; ii++)
+		{
+			struct json_object *jso = NULL;
+			struct json_object *jso1 = json_object_array_get_idx(src, ii);
+			/* This handles the `json_type_null` case */
+			if (!jso1)
+				jso = NULL;
+			else if (json_object_deep_copy_recursive(jso1, src, NULL, ii, &jso,
+			                                         shallow_copy) < 0)
+			{
+				json_object_put(jso);
+				return -1;
+			}
+
+			if (json_object_array_add(*dst, jso) < 0)
+			{
+				json_object_put(jso);
+				return -1;
+			}
+		}
+		break;
+
+	default:
+		break;
+		/* else, nothing to do, shallow_copy already did. */
+	}
+
+	if (shallow_copy_rc != 2)
+		return json_object_copy_serializer_data(src, *dst);
+
+	return 0;
+}
+
+int json_object_deep_copy(struct json_object *src, struct json_object **dst,
+                          json_c_shallow_copy_fn *shallow_copy)
+{
+	int rc;
+
+	/* Check if arguments are sane ; *dst must not point to a non-NULL object */
+	if (!src || !dst || *dst)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (shallow_copy == NULL)
+		shallow_copy = json_c_shallow_copy_default;
+
+	rc = json_object_deep_copy_recursive(src, NULL, NULL, UINT_MAX, dst, shallow_copy);
+	if (rc < 0)
+	{
+		json_object_put(*dst);
+		*dst = NULL;
+	}
+
+	return rc;
+}
+
+static void json_abort(const char *message)
+{
+	if (message != NULL)
+		fprintf(stderr, "json-c aborts with error: %s\n", message);
+	abort();
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_object.h b/lynq/S300/ap/app/apparms/json-c/json_object.h
new file mode 100755
index 0000000..e22392f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_object.h
@@ -0,0 +1,1077 @@
+/*
+ * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Core json-c API.  Start here, or with json_tokener.h
+ */
+#ifndef _json_object_h_
+#define _json_object_h_
+
+#ifdef __GNUC__
+#define JSON_C_CONST_FUNCTION(func) func __attribute__((const))
+#else
+#define JSON_C_CONST_FUNCTION(func) func
+#endif
+
+#include "json_inttypes.h"
+#include "json_types.h"
+#include "printbuf.h"
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JSON_OBJECT_DEF_HASH_ENTRIES 16
+
+/**
+ * A flag for the json_object_to_json_string_ext() and
+ * json_object_to_file_ext() functions which causes the output
+ * to have no extra whitespace or formatting applied.
+ */
+#define JSON_C_TO_STRING_PLAIN 0
+/**
+ * A flag for the json_object_to_json_string_ext() and
+ * json_object_to_file_ext() functions which causes the output to have
+ * minimal whitespace inserted to make things slightly more readable.
+ */
+#define JSON_C_TO_STRING_SPACED (1 << 0)
+/**
+ * A flag for the json_object_to_json_string_ext() and
+ * json_object_to_file_ext() functions which causes
+ * the output to be formatted.
+ *
+ * See the "Two Space Tab" option at https://jsonformatter.curiousconcept.com/
+ * for an example of the format.
+ */
+#define JSON_C_TO_STRING_PRETTY (1 << 1)
+/**
+ * A flag for the json_object_to_json_string_ext() and
+ * json_object_to_file_ext() functions which causes
+ * the output to be formatted.
+ *
+ * Instead of a "Two Space Tab" this gives a single tab character.
+ */
+#define JSON_C_TO_STRING_PRETTY_TAB (1 << 3)
+/**
+ * A flag to drop trailing zero for float values
+ */
+#define JSON_C_TO_STRING_NOZERO (1 << 2)
+
+/**
+ * Don't escape forward slashes.
+ */
+#define JSON_C_TO_STRING_NOSLASHESCAPE (1 << 4)
+
+/**
+ * A flag for the json_object_object_add_ex function which
+ * causes the value to be added without a check if it already exists.
+ * Note: it is the responsibility of the caller to ensure that no
+ * key is added multiple times. If this is done, results are
+ * unpredictable. While this option is somewhat dangerous, it
+ * permits potentially large performance savings in code that
+ * knows for sure the key values are unique (e.g. because the
+ * code adds a well-known set of constant key values).
+ */
+#define JSON_C_OBJECT_ADD_KEY_IS_NEW (1 << 1)
+/**
+ * A flag for the json_object_object_add_ex function which
+ * flags the key as being constant memory. This means that
+ * the key will NOT be copied via strdup(), resulting in a
+ * potentially huge performance win (malloc, strdup and
+ * free are usually performance hogs). It is acceptable to
+ * use this flag for keys in non-constant memory blocks if
+ * the caller ensure that the memory holding the key lives
+ * longer than the corresponding json object. However, this
+ * is somewhat dangerous and should only be done if really
+ * justified.
+ * The general use-case for this flag is cases where the
+ * key is given as a real constant value in the function
+ * call, e.g. as in
+ *   json_object_object_add_ex(obj, "ip", json,
+ *       JSON_C_OBJECT_ADD_CONSTANT_KEY);
+ */
+#define JSON_C_OBJECT_ADD_CONSTANT_KEY (1 << 2)
+/**
+ * This flag is an alias to JSON_C_OBJECT_ADD_CONSTANT_KEY.
+ * Historically, this flag was used first and the new name
+ * JSON_C_OBJECT_ADD_CONSTANT_KEY was introduced for version
+ * 0.16.00 in order to have regular naming.
+ * Use of this flag is now legacy.
+ */
+#define JSON_C_OBJECT_KEY_IS_CONSTANT  JSON_C_OBJECT_ADD_CONSTANT_KEY
+
+/**
+ * Set the global value of an option, which will apply to all
+ * current and future threads that have not set a thread-local value.
+ *
+ * @see json_c_set_serialization_double_format
+ */
+#define JSON_C_OPTION_GLOBAL (0)
+/**
+ * Set a thread-local value of an option, overriding the global value.
+ * This will fail if json-c is not compiled with threading enabled, and
+ * with the __thread specifier (or equivalent) available.
+ *
+ * @see json_c_set_serialization_double_format
+ */
+#define JSON_C_OPTION_THREAD (1)
+
+/* reference counting functions */
+
+/**
+ * Increment the reference count of json_object, thereby taking ownership of it.
+ *
+ * Cases where you might need to increase the refcount include:
+ * - Using an object field or array index (retrieved through
+ *    `json_object_object_get()` or `json_object_array_get_idx()`)
+ *    beyond the lifetime of the parent object.
+ * - Detaching an object field or array index from its parent object
+ *    (using `json_object_object_del()` or `json_object_array_del_idx()`)
+ * - Sharing a json_object with multiple (not necessarily parallel) threads
+ *    of execution that all expect to free it (with `json_object_put()`) when
+ *    they're done.
+ *
+ * @param obj the json_object instance
+ * @see json_object_put()
+ * @see json_object_object_get()
+ * @see json_object_array_get_idx()
+ */
+JSON_EXPORT struct json_object *json_object_get(struct json_object *obj);
+
+/**
+ * Decrement the reference count of json_object and free if it reaches zero.
+ *
+ * You must have ownership of obj prior to doing this or you will cause an
+ * imbalance in the reference count, leading to a classic use-after-free bug.
+ * In particular, you normally do not need to call `json_object_put()` on the
+ * json_object returned by `json_object_object_get()` or `json_object_array_get_idx()`.
+ *
+ * Just like after calling `free()` on a block of memory, you must not use
+ * `obj` after calling `json_object_put()` on it or any object that it
+ * is a member of (unless you know you've called `json_object_get(obj)` to
+ * explicitly increment the refcount).
+ *
+ * NULL may be passed, which which case this is a no-op.
+ *
+ * @param obj the json_object instance
+ * @returns 1 if the object was freed.
+ * @see json_object_get()
+ */
+JSON_EXPORT int json_object_put(struct json_object *obj);
+
+/**
+ * Check if the json_object is of a given type
+ * @param obj the json_object instance
+ * @param type one of:
+     json_type_null (i.e. obj == NULL),
+     json_type_boolean,
+     json_type_double,
+     json_type_int,
+     json_type_object,
+     json_type_array,
+     json_type_string
+ */
+JSON_EXPORT int json_object_is_type(const struct json_object *obj, enum json_type type);
+
+/**
+ * Get the type of the json_object.  See also json_type_to_name() to turn this
+ * into a string suitable, for instance, for logging.
+ *
+ * @param obj the json_object instance
+ * @returns type being one of:
+     json_type_null (i.e. obj == NULL),
+     json_type_boolean,
+     json_type_double,
+     json_type_int,
+     json_type_object,
+     json_type_array,
+     json_type_string
+ */
+JSON_EXPORT enum json_type json_object_get_type(const struct json_object *obj);
+
+/** Stringify object to json format.
+ * Equivalent to json_object_to_json_string_ext(obj, JSON_C_TO_STRING_SPACED)
+ * The pointer you get is an internal of your json object. You don't
+ * have to free it, later use of json_object_put() should be sufficient.
+ * If you can not ensure there's no concurrent access to *obj use
+ * strdup().
+ * @param obj the json_object instance
+ * @returns a string in JSON format
+ */
+JSON_EXPORT const char *json_object_to_json_string(struct json_object *obj);
+
+/** Stringify object to json format
+ * @see json_object_to_json_string() for details on how to free string.
+ * @param obj the json_object instance
+ * @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants
+ * @returns a string in JSON format
+ */
+JSON_EXPORT const char *json_object_to_json_string_ext(struct json_object *obj, int flags);
+
+/** Stringify object to json format
+ * @see json_object_to_json_string() for details on how to free string.
+ * @param obj the json_object instance
+ * @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants
+ * @param length a pointer where, if not NULL, the length (without null) is stored
+ * @returns a string in JSON format and the length if not NULL
+ */
+JSON_EXPORT const char *json_object_to_json_string_length(struct json_object *obj, int flags,
+                                                          size_t *length);
+
+/**
+ * Returns the userdata set by json_object_set_userdata() or
+ * json_object_set_serializer()
+ *
+ * @param jso the object to return the userdata for
+ */
+JSON_EXPORT void *json_object_get_userdata(json_object *jso);
+
+/**
+ * Set an opaque userdata value for an object
+ *
+ * The userdata can be retrieved using json_object_get_userdata().
+ *
+ * If custom userdata is already set on this object, any existing user_delete
+ * function is called before the new one is set.
+ *
+ * The user_delete parameter is optional and may be passed as NULL, even if
+ * the userdata parameter is non-NULL.  It will be called just before the
+ * json_object is deleted, after it's reference count goes to zero
+ * (see json_object_put()).
+ * If this is not provided, it is up to the caller to free the userdata at
+ * an appropriate time. (i.e. after the json_object is deleted)
+ *
+ * Note: Objects created by parsing strings may have custom serializers set
+ * which expect the userdata to contain specific data (due to use of
+ * json_object_new_double_s()). In this case, json_object_set_serialiser() with
+ * NULL as to_string_func should be used instead to set the userdata and reset
+ * the serializer to its default value.
+ *
+ * @param jso the object to set the userdata for
+ * @param userdata an optional opaque cookie
+ * @param user_delete an optional function from freeing userdata
+ */
+JSON_EXPORT void json_object_set_userdata(json_object *jso, void *userdata,
+                                          json_object_delete_fn *user_delete);
+
+/**
+ * Set a custom serialization function to be used when this particular object
+ * is converted to a string by json_object_to_json_string.
+ *
+ * If custom userdata is already set on this object, any existing user_delete
+ * function is called before the new one is set.
+ *
+ * If to_string_func is NULL the default behaviour is reset (but the userdata
+ * and user_delete fields are still set).
+ *
+ * The userdata parameter is optional and may be passed as NULL. It can be used
+ * to provide additional data for to_string_func to use. This parameter may
+ * be NULL even if user_delete is non-NULL.
+ *
+ * The user_delete parameter is optional and may be passed as NULL, even if
+ * the userdata parameter is non-NULL.  It will be called just before the
+ * json_object is deleted, after it's reference count goes to zero
+ * (see json_object_put()).
+ * If this is not provided, it is up to the caller to free the userdata at
+ * an appropriate time. (i.e. after the json_object is deleted)
+ *
+ * Note that the userdata is the same as set by json_object_set_userdata(), so
+ * care must be taken not to overwrite the value when both a custom serializer
+ * and json_object_set_userdata() are used.
+ *
+ * @param jso the object to customize
+ * @param to_string_func the custom serialization function
+ * @param userdata an optional opaque cookie
+ * @param user_delete an optional function from freeing userdata
+ */
+JSON_EXPORT void json_object_set_serializer(json_object *jso,
+                                            json_object_to_json_string_fn *to_string_func,
+                                            void *userdata, json_object_delete_fn *user_delete);
+
+#ifdef __clang__
+/*
+ * Clang doesn't pay attention to the parameters defined in the
+ * function typedefs used here, so turn off spurious doc warnings.
+ * {
+ */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdocumentation"
+#endif
+
+/**
+ * Simply call free on the userdata pointer.
+ * Can be used with json_object_set_serializer().
+ *
+ * @param jso unused
+ * @param userdata the pointer that is passed to free().
+ */
+JSON_EXPORT json_object_delete_fn json_object_free_userdata;
+
+/**
+ * Copy the jso->_userdata string over to pb as-is.
+ * Can be used with json_object_set_serializer().
+ *
+ * @param jso The object whose _userdata is used.
+ * @param pb The destination buffer.
+ * @param level Ignored.
+ * @param flags Ignored.
+ */
+JSON_EXPORT json_object_to_json_string_fn json_object_userdata_to_json_string;
+
+#ifdef __clang__
+/* } */
+#pragma clang diagnostic pop
+#endif
+
+/* object type methods */
+
+/** Create a new empty object with a reference count of 1.  The caller of
+ * this object initially has sole ownership.  Remember, when using
+ * json_object_object_add or json_object_array_put_idx, ownership will
+ * transfer to the object/array.  Call json_object_get if you want to maintain
+ * shared ownership or also add this object as a child of multiple objects or
+ * arrays.  Any ownerships you acquired but did not transfer must be released
+ * through json_object_put.
+ *
+ * @returns a json_object of type json_type_object
+ */
+JSON_EXPORT struct json_object *json_object_new_object(void);
+
+/** Get the hashtable of a json_object of type json_type_object
+ * @param obj the json_object instance
+ * @returns a linkhash
+ */
+JSON_EXPORT struct lh_table *json_object_get_object(const struct json_object *obj);
+
+/** Get the size of an object in terms of the number of fields it has.
+ * @param obj the json_object whose length to return
+ */
+JSON_EXPORT int json_object_object_length(const struct json_object *obj);
+
+/** Get the sizeof (struct json_object).
+ * @returns a size_t with the sizeof (struct json_object)
+ */
+JSON_C_CONST_FUNCTION(JSON_EXPORT size_t json_c_object_sizeof(void));
+
+/** Add an object field to a json_object of type json_type_object
+ *
+ * The reference count of `val` will *not* be incremented, in effect
+ * transferring ownership that object to `obj`, and thus `val` will be
+ * freed when `obj` is.  (i.e. through `json_object_put(obj)`)
+ *
+ * If you want to retain a reference to the added object, independent
+ * of the lifetime of obj, you must increment the refcount with
+ * `json_object_get(val)` (and later release it with json_object_put()).
+ *
+ * Since ownership transfers to `obj`, you must make sure
+ * that you do in fact have ownership over `val`.  For instance,
+ * json_object_new_object() will give you ownership until you transfer it,
+ * whereas json_object_object_get() does not.
+ *
+ * Any previous object stored under `key` in `obj` will have its refcount
+ * decremented, and be freed normally if that drops to zero.
+ *
+ * @param obj the json_object instance
+ * @param key the object field name (a private copy will be duplicated)
+ * @param val a json_object or NULL member to associate with the given field
+ *
+ * @return On success, <code>0</code> is returned.
+ * 	On error, a negative value is returned.
+ */
+JSON_EXPORT int json_object_object_add(struct json_object *obj, const char *key,
+                                       struct json_object *val);
+
+/** Add an object field to a json_object of type json_type_object
+ *
+ * The semantics are identical to json_object_object_add, except that an
+ * additional flag fields gives you more control over some detail aspects
+ * of processing. See the description of JSON_C_OBJECT_ADD_* flags for more
+ * details.
+ *
+ * @param obj the json_object instance
+ * @param key the object field name (a private copy will be duplicated)
+ * @param val a json_object or NULL member to associate with the given field
+ * @param opts process-modifying options. To specify multiple options, use
+ *             (OPT1|OPT2)
+ */
+JSON_EXPORT int json_object_object_add_ex(struct json_object *obj, const char *const key,
+                                          struct json_object *const val, const unsigned opts);
+
+/** Get the json_object associate with a given object field.
+ * Deprecated/discouraged: used json_object_object_get_ex instead.
+ *
+ * This returns NULL if the field is found but its value is null, or if
+ *  the field is not found, or if obj is not a json_type_object.  If you
+ *  need to distinguish between these cases, use json_object_object_get_ex().
+ *
+ * *No* reference counts will be changed.  There is no need to manually adjust
+ * reference counts through the json_object_put/json_object_get methods unless
+ * you need to have the child (value) reference maintain a different lifetime
+ * than the owning parent (obj). Ownership of the returned value is retained
+ * by obj (do not do json_object_put unless you have done a json_object_get).
+ * If you delete the value from obj (json_object_object_del) and wish to access
+ * the returned reference afterwards, make sure you have first gotten shared
+ * ownership through json_object_get (& don't forget to do a json_object_put
+ * or transfer ownership to prevent a memory leak).
+ *
+ * @param obj the json_object instance
+ * @param key the object field name
+ * @returns the json_object associated with the given field name
+ */
+JSON_EXPORT struct json_object *json_object_object_get(const struct json_object *obj,
+                                                       const char *key);
+
+/** Get the json_object associated with a given object field.
+ *
+ * This returns true if the key is found, false in all other cases (including
+ * if obj isn't a json_type_object).
+ *
+ * *No* reference counts will be changed.  There is no need to manually adjust
+ * reference counts through the json_object_put/json_object_get methods unless
+ * you need to have the child (value) reference maintain a different lifetime
+ * than the owning parent (obj).  Ownership of value is retained by obj.
+ *
+ * @param obj the json_object instance
+ * @param key the object field name
+ * @param value a pointer where to store a reference to the json_object
+ *              associated with the given field name.
+ *
+ *              It is safe to pass a NULL value.
+ * @returns whether or not the key exists
+ */
+JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object *obj, const char *key,
+                                                struct json_object **value);
+
+/** Delete the given json_object field
+ *
+ * The reference count will be decremented for the deleted object.  If there
+ * are no more owners of the value represented by this key, then the value is
+ * freed.  Otherwise, the reference to the value will remain in memory.
+ *
+ * @param obj the json_object instance
+ * @param key the object field name
+ */
+JSON_EXPORT void json_object_object_del(struct json_object *obj, const char *key);
+
+/**
+ * Iterate through all keys and values of an object.
+ *
+ * Adding keys to the object while iterating is NOT allowed.
+ *
+ * Deleting an existing key, or replacing an existing key with a
+ * new value IS allowed.
+ *
+ * @param obj the json_object instance
+ * @param key the local name for the char* key variable defined in the body
+ * @param val the local name for the json_object* object variable defined in
+ *            the body
+ */
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+
+#define json_object_object_foreach(obj, key, val)                                \
+	char *key = NULL;                                                        \
+	struct json_object *val __attribute__((__unused__)) = NULL;              \
+	for (struct lh_entry *entry##key = lh_table_head(json_object_get_object(obj)),    \
+	                     *entry_next##key = NULL;                            \
+	     ({                                                                  \
+		     if (entry##key)                                             \
+		     {                                                           \
+			     key = (char *)lh_entry_k(entry##key);               \
+			     val = (struct json_object *)lh_entry_v(entry##key); \
+			     entry_next##key = lh_entry_next(entry##key);        \
+		     };                                                          \
+		     entry##key;                                                 \
+	     });                                                                 \
+	     entry##key = entry_next##key)
+
+#else /* ANSI C or MSC */
+
+#define json_object_object_foreach(obj, key, val)                              \
+	char *key = NULL;                                                      \
+	struct json_object *val = NULL;                                        \
+	struct lh_entry *entry##key;                                           \
+	struct lh_entry *entry_next##key = NULL;                               \
+	for (entry##key = lh_table_head(json_object_get_object(obj));          \
+	     (entry##key ? (key = (char *)lh_entry_k(entry##key),              \
+	                   val = (struct json_object *)lh_entry_v(entry##key), \
+	                   entry_next##key = lh_entry_next(entry##key), entry##key)     \
+	                 : 0);                                                 \
+	     entry##key = entry_next##key)
+
+#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
+
+/** Iterate through all keys and values of an object (ANSI C Safe)
+ * @param obj the json_object instance
+ * @param iter the object iterator, use type json_object_iter
+ */
+#define json_object_object_foreachC(obj, iter)                                                  \
+	for (iter.entry = lh_table_head(json_object_get_object(obj));                                    \
+	     (iter.entry ? (iter.key = (char *)lh_entry_k(iter.entry),                          \
+	                   iter.val = (struct json_object *)lh_entry_v(iter.entry), iter.entry) \
+	                 : 0);                                                                  \
+	     iter.entry = lh_entry_next(iter.entry))
+
+/* Array type methods */
+
+/** Create a new empty json_object of type json_type_array
+ * with 32 slots allocated.
+ * If you know the array size you'll need ahead of time, use
+ * json_object_new_array_ext() instead.
+ * @see json_object_new_array_ext()
+ * @see json_object_array_shrink()
+ * @returns a json_object of type json_type_array
+ */
+JSON_EXPORT struct json_object *json_object_new_array(void);
+
+/** Create a new empty json_object of type json_type_array
+ * with the desired number of slots allocated.
+ * @see json_object_array_shrink()
+ * @param initial_size the number of slots to allocate
+ * @returns a json_object of type json_type_array
+ */
+JSON_EXPORT struct json_object *json_object_new_array_ext(int initial_size);
+
+/** Get the arraylist of a json_object of type json_type_array
+ * @param obj the json_object instance
+ * @returns an arraylist
+ */
+JSON_EXPORT struct array_list *json_object_get_array(const struct json_object *obj);
+
+/** Get the length of a json_object of type json_type_array
+ * @param obj the json_object instance
+ * @returns an int
+ */
+JSON_EXPORT size_t json_object_array_length(const struct json_object *obj);
+
+/** Sorts the elements of jso of type json_type_array
+*
+* Pointers to the json_object pointers will be passed as the two arguments
+* to sort_fn
+*
+* @param jso the json_object instance
+* @param sort_fn a sorting function
+*/
+JSON_EXPORT void json_object_array_sort(struct json_object *jso,
+                                        int (*sort_fn)(const void *, const void *));
+
+/** Binary search a sorted array for a specified key object.
+ *
+ * It depends on your compare function what's sufficient as a key.
+ * Usually you create some dummy object with the parameter compared in
+ * it, to identify the right item you're actually looking for.
+ *
+ * @see json_object_array_sort() for hints on the compare function.
+ *
+ * @param key a dummy json_object with the right key
+ * @param jso the array object we're searching
+ * @param sort_fn the sort/compare function
+ *
+ * @return the wanted json_object instance
+ */
+JSON_EXPORT struct json_object *
+json_object_array_bsearch(const struct json_object *key, const struct json_object *jso,
+                          int (*sort_fn)(const void *, const void *));
+
+/** Add an element to the end of a json_object of type json_type_array
+ *
+ * The reference count will *not* be incremented. This is to make adding
+ * fields to objects in code more compact. If you want to retain a reference
+ * to an added object you must wrap the passed object with json_object_get
+ *
+ * @param obj the json_object instance
+ * @param val the json_object to be added
+ */
+JSON_EXPORT int json_object_array_add(struct json_object *obj, struct json_object *val);
+
+/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
+ *
+ * The reference count will *not* be incremented. This is to make adding
+ * fields to objects in code more compact. If you want to retain a reference
+ * to an added object you must wrap the passed object with json_object_get
+ *
+ * The reference count of a replaced object will be decremented.
+ *
+ * The array size will be automatically be expanded to the size of the
+ * index if the index is larger than the current size.
+ *
+ * @param obj the json_object instance
+ * @param idx the index to insert the element at
+ * @param val the json_object to be added
+ */
+JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx,
+                                          struct json_object *val);
+
+/** Get the element at specified index of array `obj` (which must be a json_object of type json_type_array)
+ *
+ * *No* reference counts will be changed, and ownership of the returned
+ * object remains with `obj`.  See json_object_object_get() for additional
+ * implications of this behavior.
+ *
+ * Calling this with anything other than a json_type_array will trigger
+ * an assert.
+ *
+ * @param obj the json_object instance
+ * @param idx the index to get the element at
+ * @returns the json_object at the specified index (or NULL)
+ */
+JSON_EXPORT struct json_object *json_object_array_get_idx(const struct json_object *obj,
+                                                          size_t idx);
+
+/** Delete an elements from a specified index in an array (a json_object of type json_type_array)
+ *
+ * The reference count will be decremented for each of the deleted objects.  If there
+ * are no more owners of an element that is being deleted, then the value is
+ * freed.  Otherwise, the reference to the value will remain in memory.
+ *
+ * @param obj the json_object instance
+ * @param idx the index to start deleting elements at
+ * @param count the number of elements to delete
+ * @returns 0 if the elements were successfully deleted
+ */
+JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count);
+
+/**
+ * Shrink the internal memory allocation of the array to just
+ * enough to fit the number of elements in it, plus empty_slots.
+ *
+ * @param jso the json_object instance, must be json_type_array
+ * @param empty_slots the number of empty slots to leave allocated
+ */
+JSON_EXPORT int json_object_array_shrink(struct json_object *jso, int empty_slots);
+
+/* json_bool type methods */
+
+/** Create a new empty json_object of type json_type_boolean
+ * @param b a json_bool 1 or 0
+ * @returns a json_object of type json_type_boolean
+ */
+JSON_EXPORT struct json_object *json_object_new_boolean(json_bool b);
+
+/** Get the json_bool value of a json_object
+ *
+ * The type is coerced to a json_bool if the passed object is not a json_bool.
+ * integer and double objects will return 0 if there value is zero
+ * or 1 otherwise. If the passed object is a string it will return
+ * 1 if it has a non zero length. 
+ * If any other object type is passed 0 will be returned, even non-empty
+ *  json_type_array and json_type_object objects.
+ *
+ * @param obj the json_object instance
+ * @returns a json_bool
+ */
+JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj);
+
+/** Set the json_bool value of a json_object
+ *
+ * The type of obj is checked to be a json_type_boolean and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_boolean
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_boolean(struct json_object *obj, json_bool new_value);
+
+/* int type methods */
+
+/** Create a new empty json_object of type json_type_int
+ * Note that values are stored as 64-bit values internally.
+ * To ensure the full range is maintained, use json_object_new_int64 instead.
+ * @param i the integer
+ * @returns a json_object of type json_type_int
+ */
+JSON_EXPORT struct json_object *json_object_new_int(int32_t i);
+
+/** Create a new empty json_object of type json_type_int
+ * @param i the integer
+ * @returns a json_object of type json_type_int
+ */
+JSON_EXPORT struct json_object *json_object_new_int64(int64_t i);
+
+/** Create a new empty json_object of type json_type_uint
+ * @param i the integer
+ * @returns a json_object of type json_type_uint
+ */
+JSON_EXPORT struct json_object *json_object_new_uint64(uint64_t i);
+
+/** Get the int value of a json_object
+ *
+ * The type is coerced to a int if the passed object is not a int.
+ * double objects will return their integer conversion. Strings will be
+ * parsed as an integer. If no conversion exists then 0 is returned
+ * and errno is set to EINVAL. null is equivalent to 0 (no error values set)
+ *
+ * Note that integers are stored internally as 64-bit values.
+ * If the value of too big or too small to fit into 32-bit, INT32_MAX or
+ * INT32_MIN are returned, respectively.
+ *
+ * @param obj the json_object instance
+ * @returns an int
+ */
+JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj);
+
+/** Set the int value of a json_object
+ *
+ * The type of obj is checked to be a json_type_int and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_int
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_int(struct json_object *obj, int new_value);
+
+/** Increment a json_type_int object by the given amount, which may be negative.
+ *
+ * If the type of obj is not json_type_int then 0 is returned with no further
+ * action taken.
+ * If the addition would result in a overflow, the object value
+ * is set to INT64_MAX.
+ * If the addition would result in a underflow, the object value
+ * is set to INT64_MIN.
+ * Neither overflow nor underflow affect the return value.
+ *
+ * @param obj the json_object instance
+ * @param val the value to add
+ * @returns 1 if the increment succeeded, 0 otherwise
+ */
+JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val);
+
+/** Get the int value of a json_object
+ *
+ * The type is coerced to a int64 if the passed object is not a int64.
+ * double objects will return their int64 conversion. Strings will be
+ * parsed as an int64. If no conversion exists then 0 is returned.
+ *
+ * NOTE: Set errno to 0 directly before a call to this function to determine
+ * whether or not conversion was successful (it does not clear the value for
+ * you).
+ *
+ * @param obj the json_object instance
+ * @returns an int64
+ */
+JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj);
+
+/** Get the uint value of a json_object
+ *
+ * The type is coerced to a uint64 if the passed object is not a uint64.
+ * double objects will return their uint64 conversion. Strings will be
+ * parsed as an uint64. If no conversion exists then 0 is returned.
+ *
+ * NOTE: Set errno to 0 directly before a call to this function to determine
+ * whether or not conversion was successful (it does not clear the value for
+ * you).
+ *
+ * @param obj the json_object instance
+ * @returns an uint64
+ */
+JSON_EXPORT uint64_t json_object_get_uint64(const struct json_object *obj);
+
+/** Set the int64_t value of a json_object
+ *
+ * The type of obj is checked to be a json_type_int and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_int
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_int64(struct json_object *obj, int64_t new_value);
+
+/** Set the uint64_t value of a json_object
+ *
+ * The type of obj is checked to be a json_type_uint and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_uint
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_uint64(struct json_object *obj, uint64_t new_value);
+
+/* double type methods */
+
+/** Create a new empty json_object of type json_type_double
+ *
+ * @see json_object_double_to_json_string() for how to set a custom format string.
+ *
+ * @param d the double
+ * @returns a json_object of type json_type_double
+ */
+JSON_EXPORT struct json_object *json_object_new_double(double d);
+
+/**
+ * Create a new json_object of type json_type_double, using
+ * the exact serialized representation of the value.
+ *
+ * This allows for numbers that would otherwise get displayed
+ * inefficiently (e.g. 12.3 => "12.300000000000001") to be
+ * serialized with the more convenient form.
+ *
+ * Notes:
+ *
+ * This is used by json_tokener_parse_ex() to allow for
+ * an exact re-serialization of a parsed object.
+ *
+ * The userdata field is used to store the string representation, so it
+ * can't be used for other data if this function is used.
+ *
+ * A roughly equivalent sequence of calls, with the difference being that
+ *  the serialization function won't be reset by json_object_set_double(), is:
+ * @code
+ *   jso = json_object_new_double(d);
+ *   json_object_set_serializer(jso, json_object_userdata_to_json_string,
+ *       strdup(ds), json_object_free_userdata);
+ * @endcode
+ *
+ * @param d the numeric value of the double.
+ * @param ds the string representation of the double.  This will be copied.
+ */
+JSON_EXPORT struct json_object *json_object_new_double_s(double d, const char *ds);
+
+/**
+ * Set a global or thread-local json-c option, depending on whether
+ *  JSON_C_OPTION_GLOBAL or JSON_C_OPTION_THREAD is passed.
+ * Thread-local options default to undefined, and inherit from the global
+ *  value, even if the global value is changed after the thread is created.
+ * Attempting to set thread-local options when threading is not compiled in
+ *  will result in an error.  Be sure to check the return value.
+ *
+ * double_format is a "%g" printf format, such as "%.20g"
+ *
+ * @return -1 on errors, 0 on success.
+ */
+JSON_EXPORT int json_c_set_serialization_double_format(const char *double_format,
+                                                       int global_or_thread);
+
+/** Serialize a json_object of type json_type_double to a string.
+ *
+ * This function isn't meant to be called directly. Instead, you can set a
+ * custom format string for the serialization of this double using the
+ * following call (where "%.17g" actually is the default):
+ *
+ * @code
+ *   jso = json_object_new_double(d);
+ *   json_object_set_serializer(jso, json_object_double_to_json_string,
+ *       "%.17g", NULL);
+ * @endcode
+ *
+ * @see printf(3) man page for format strings
+ *
+ * @param jso The json_type_double object that is serialized.
+ * @param pb The destination buffer.
+ * @param level Ignored.
+ * @param flags Ignored.
+ */
+JSON_EXPORT int json_object_double_to_json_string(struct json_object *jso, struct printbuf *pb,
+                                                  int level, int flags);
+
+/** Get the double floating point value of a json_object
+ *
+ * The type is coerced to a double if the passed object is not a double.
+ * integer objects will return their double conversion. Strings will be
+ * parsed as a double. If no conversion exists then 0.0 is returned and
+ * errno is set to EINVAL. null is equivalent to 0 (no error values set)
+ *
+ * If the value is too big to fit in a double, then the value is set to
+ * the closest infinity with errno set to ERANGE. If strings cannot be
+ * converted to their double value, then EINVAL is set & NaN is returned.
+ *
+ * Arrays of length 0 are interpreted as 0 (with no error flags set).
+ * Arrays of length 1 are effectively cast to the equivalent object and
+ * converted using the above rules.  All other arrays set the error to
+ * EINVAL & return NaN.
+ *
+ * NOTE: Set errno to 0 directly before a call to this function to
+ * determine whether or not conversion was successful (it does not clear
+ * the value for you).
+ *
+ * @param obj the json_object instance
+ * @returns a double floating point number
+ */
+JSON_EXPORT double json_object_get_double(const struct json_object *obj);
+
+/** Set the double value of a json_object
+ *
+ * The type of obj is checked to be a json_type_double and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_double
+ * the object value is changed to new_value
+ *
+ * If the object was created with json_object_new_double_s(), the serialization
+ * function is reset to the default and the cached serialized value is cleared.
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_double(struct json_object *obj, double new_value);
+
+/* string type methods */
+
+/** Create a new empty json_object of type json_type_string
+ *
+ * A copy of the string is made and the memory is managed by the json_object
+ *
+ * @param s the string
+ * @returns a json_object of type json_type_string
+ * @see json_object_new_string_len()
+ */
+JSON_EXPORT struct json_object *json_object_new_string(const char *s);
+
+/** Create a new empty json_object of type json_type_string and allocate
+ * len characters for the new string.
+ *
+ * A copy of the string is made and the memory is managed by the json_object
+ *
+ * @param s the string
+ * @param len max length of the new string
+ * @returns a json_object of type json_type_string
+ * @see json_object_new_string()
+ */
+JSON_EXPORT struct json_object *json_object_new_string_len(const char *s, const int len);
+
+/** Get the string value of a json_object
+ *
+ * If the passed object is of type json_type_null (i.e. obj == NULL),
+ * NULL is returned.
+ *
+ * If the passed object of type json_type_string, the string contents
+ * are returned.
+ *
+ * Otherwise the JSON representation of the object is returned.
+ *
+ * The returned string memory is managed by the json_object and will
+ * be freed when the reference count of the json_object drops to zero.
+ *
+ * @param obj the json_object instance
+ * @returns a string or NULL
+ */
+JSON_EXPORT const char *json_object_get_string(struct json_object *obj);
+
+/** Get the string length of a json_object
+ *
+ * If the passed object is not of type json_type_string then zero
+ * will be returned.
+ *
+ * @param obj the json_object instance
+ * @returns int
+ */
+JSON_EXPORT int json_object_get_string_len(const struct json_object *obj);
+
+/** Set the string value of a json_object with zero terminated strings
+ * equivalent to json_object_set_string_len (obj, new_value, strlen(new_value))
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_string(json_object *obj, const char *new_value);
+
+/** Set the string value of a json_object str
+ *
+ * The type of obj is checked to be a json_type_string and 0 is returned
+ * if it is not without any further actions. If type of obj is json_type_string
+ * the object value is changed to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set; Since string length is given in len this need not be zero terminated
+ * @param len the length of new_value
+ * @returns 1 if value is set correctly, 0 otherwise
+ */
+JSON_EXPORT int json_object_set_string_len(json_object *obj, const char *new_value, int len);
+
+/** This method exists only to provide a complementary function
+ * along the lines of the other json_object_new_* functions.
+ * It always returns NULL, and it is entirely acceptable to simply use NULL directly.
+ */
+JSON_EXPORT struct json_object *json_object_new_null(void);
+
+/** Check if two json_object's are equal
+ *
+ * If the passed objects are equal 1 will be returned.
+ * Equality is defined as follows:
+ * - json_objects of different types are never equal
+ * - json_objects of the same primitive type are equal if the
+ *   c-representation of their value is equal
+ * - json-arrays are considered equal if all values at the same
+ *   indices are equal (same order)
+ * - Complex json_objects are considered equal if all
+ *   contained objects referenced by their key are equal,
+ *   regardless their order.
+ *
+ * @param obj1 the first json_object instance
+ * @param obj2 the second json_object instance
+ * @returns whether both objects are equal or not
+ */
+JSON_EXPORT int json_object_equal(struct json_object *obj1, struct json_object *obj2);
+
+/**
+ * Perform a shallow copy of src into *dst as part of an overall json_object_deep_copy().
+ *
+ * If src is part of a containing object or array, parent will be non-NULL,
+ * and key or index will be provided.
+ * When shallow_copy is called *dst will be NULL, and must be non-NULL when it returns.
+ * src will never be NULL.
+ *
+ * If shallow_copy sets the serializer on an object, return 2 to indicate to
+ *  json_object_deep_copy that it should not attempt to use the standard userdata
+ *  copy function.
+ *
+ * @return On success 1 or 2, -1 on errors
+ */
+typedef int(json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key,
+                                    size_t index, json_object **dst);
+
+/**
+ * The default shallow copy implementation for use with json_object_deep_copy().
+ * This simply calls the appropriate json_object_new_<type>() function and
+ * copies over the serializer function (_to_json_string internal field of
+ * the json_object structure) but not any _userdata or _user_delete values.
+ *
+ * If you're writing a custom shallow_copy function, perhaps because you're using
+ * your own custom serializer, you can call this first to create the new object
+ * before customizing it with json_object_set_serializer().
+ *
+ * @return 1 on success, -1 on errors, but never 2.
+ */
+JSON_EXPORT json_c_shallow_copy_fn json_c_shallow_copy_default;
+
+/**
+ * Copy the contents of the JSON object.
+ * The destination object must be initialized to NULL,
+ * to make sure this function won't overwrite an existing JSON object.
+ *
+ * This does roughly the same thing as
+ * `json_tokener_parse(json_object_get_string(src))`.
+ *
+ * @param src source JSON object whose contents will be copied
+ * @param dst pointer to the destination object where the contents of `src`;
+ *            make sure this pointer is initialized to NULL
+ * @param shallow_copy an optional function to copy individual objects, needed
+ *                     when custom serializers are in use.  See also
+ *                     json_object set_serializer.
+ *
+ * @returns 0 if the copy went well, -1 if an error occurred during copy
+ *          or if the destination pointer is non-NULL
+ */
+
+JSON_EXPORT int json_object_deep_copy(struct json_object *src, struct json_object **dst,
+                                      json_c_shallow_copy_fn *shallow_copy);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_object_iterator.c b/lynq/S300/ap/app/apparms/json-c/json_object_iterator.c
new file mode 100755
index 0000000..db8488a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_object_iterator.c
@@ -0,0 +1,153 @@
+/**
+*******************************************************************************
+* @file json_object_iterator.c
+*
+* Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
+*
+* This library is free software; you can redistribute it and/or modify
+* it under the terms of the MIT license. See COPYING for details.
+*
+*******************************************************************************
+*/
+#include "config.h"
+
+#include <stddef.h>
+
+#include "json.h"
+#include "json_object_private.h"
+
+#include "json_object_iterator.h"
+
+/**
+ * How It Works
+ *
+ * For each JSON Object, json-c maintains a linked list of zero
+ * or more lh_entry (link-hash entry) structures inside the
+ * Object's link-hash table (lh_table).
+ *
+ * Each lh_entry structure on the JSON Object's linked list
+ * represents a single name/value pair.  The "next" field of the
+ * last lh_entry in the list is set to NULL, which terminates
+ * the list.
+ *
+ * We represent a valid iterator that refers to an actual
+ * name/value pair via a pointer to the pair's lh_entry
+ * structure set as the iterator's opaque_ field.
+ *
+ * We follow json-c's current pair list representation by
+ * representing a valid "end" iterator (one that refers past the
+ * last pair) with a NULL value in the iterator's opaque_ field.
+ *
+ * A JSON Object without any pairs in it will have the "head"
+ * field of its lh_table structure set to NULL.  For such an
+ * object, json_object_iter_begin will return an iterator with
+ * the opaque_ field set to NULL, which is equivalent to the
+ * "end" iterator.
+ *
+ * When iterating, we simply update the iterator's opaque_ field
+ * to point to the next lh_entry structure in the linked list.
+ * opaque_ will become NULL once we iterate past the last pair
+ * in the list, which makes the iterator equivalent to the "end"
+ * iterator.
+ */
+
+/// Our current representation of the "end" iterator;
+///
+/// @note May not always be NULL
+static const void *kObjectEndIterValue = NULL;
+
+/**
+ * ****************************************************************************
+ */
+struct json_object_iterator json_object_iter_begin(struct json_object *obj)
+{
+	struct json_object_iterator iter;
+	struct lh_table *pTable;
+
+	/// @note json_object_get_object will return NULL if passed NULL
+	///       or a non-json_type_object instance
+	pTable = json_object_get_object(obj);
+	JASSERT(NULL != pTable);
+
+	/// @note For a pair-less Object, head is NULL, which matches our
+	///       definition of the "end" iterator
+	iter.opaque_ = lh_table_head(pTable);
+	return iter;
+}
+
+/**
+ * ****************************************************************************
+ */
+struct json_object_iterator json_object_iter_end(const struct json_object *obj)
+{
+	struct json_object_iterator iter;
+
+	JASSERT(NULL != obj);
+	JASSERT(json_object_is_type(obj, json_type_object));
+
+	iter.opaque_ = kObjectEndIterValue;
+
+	return iter;
+}
+
+/**
+ * ****************************************************************************
+ */
+void json_object_iter_next(struct json_object_iterator *iter)
+{
+	JASSERT(NULL != iter);
+	JASSERT(kObjectEndIterValue != iter->opaque_);
+
+	iter->opaque_ = lh_entry_next(((const struct lh_entry *)iter->opaque_));
+}
+
+/**
+ * ****************************************************************************
+ */
+const char *json_object_iter_peek_name(const struct json_object_iterator *iter)
+{
+	JASSERT(NULL != iter);
+	JASSERT(kObjectEndIterValue != iter->opaque_);
+
+	return (const char *)(((const struct lh_entry *)iter->opaque_)->k);
+}
+
+/**
+ * ****************************************************************************
+ */
+struct json_object *json_object_iter_peek_value(const struct json_object_iterator *iter)
+{
+	JASSERT(NULL != iter);
+	JASSERT(kObjectEndIterValue != iter->opaque_);
+
+	return (struct json_object *)lh_entry_v((const struct lh_entry *)iter->opaque_);
+}
+
+/**
+ * ****************************************************************************
+ */
+json_bool json_object_iter_equal(const struct json_object_iterator *iter1,
+                                 const struct json_object_iterator *iter2)
+{
+	JASSERT(NULL != iter1);
+	JASSERT(NULL != iter2);
+
+	return (iter1->opaque_ == iter2->opaque_);
+}
+
+/**
+ * ****************************************************************************
+ */
+struct json_object_iterator json_object_iter_init_default(void)
+{
+	struct json_object_iterator iter;
+
+	/**
+	 * @note Make this a negative, invalid value, such that
+	 *       accidental access to it would likely be trapped by the
+	 *       hardware as an invalid address.
+	 */
+	iter.opaque_ = NULL;
+
+	return iter;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_object_iterator.h b/lynq/S300/ap/app/apparms/json-c/json_object_iterator.h
new file mode 100755
index 0000000..a9b1433
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_object_iterator.h
@@ -0,0 +1,228 @@
+/**
+*******************************************************************************
+* @file json_object_iterator.h
+*
+* Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
+*
+* This library is free software; you can redistribute it and/or modify
+* it under the terms of the MIT license. See COPYING for details.
+*
+* @brief  An API for iterating over json_type_object objects,
+*         styled to be familiar to C++ programmers.
+*         Unlike json_object_object_foreach() and
+*         json_object_object_foreachC(), this avoids the need to expose
+*         json-c internals like lh_entry.
+*
+* API attributes: <br>
+*   * Thread-safe: NO<br>
+*   * Reentrant: NO
+*
+*******************************************************************************
+*/
+
+#ifndef JSON_OBJECT_ITERATOR_H
+#define JSON_OBJECT_ITERATOR_H
+
+#include "json_types.h"
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Forward declaration for the opaque iterator information.
+ */
+struct json_object_iter_info_;
+
+/**
+ * The opaque iterator that references a name/value pair within
+ * a JSON Object instance or the "end" iterator value.
+ */
+struct json_object_iterator
+{
+	const void *opaque_;
+};
+
+/**
+ * forward declaration of json-c's JSON value instance structure
+ */
+struct json_object;
+
+/**
+ * Initializes an iterator structure to a "default" value that
+ * is convenient for initializing an iterator variable to a
+ * default state (e.g., initialization list in a class'
+ * constructor).
+ *
+ * @code
+ * struct json_object_iterator iter = json_object_iter_init_default();
+ * MyClass() : iter_(json_object_iter_init_default())
+ * @endcode
+ *
+ * @note The initialized value doesn't reference any specific
+ *       pair, is considered an invalid iterator, and MUST NOT
+ *       be passed to any json-c API that expects a valid
+ *       iterator.
+ *
+ * @note User and internal code MUST NOT make any assumptions
+ *       about and dependencies on the value of the "default"
+ *       iterator value.
+ *
+ * @return json_object_iterator
+ */
+JSON_EXPORT struct json_object_iterator json_object_iter_init_default(void);
+
+/** Retrieves an iterator to the first pair of the JSON Object.
+ *
+ * @warning 	Any modification of the underlying pair invalidates all
+ * 		iterators to that pair.
+ *
+ * @param obj	JSON Object instance (MUST be of type json_object)
+ *
+ * @return json_object_iterator If the JSON Object has at
+ *              least one pair, on return, the iterator refers
+ *              to the first pair. If the JSON Object doesn't
+ *              have any pairs, the returned iterator is
+ *              equivalent to the "end" iterator for the same
+ *              JSON Object instance.
+ *
+ * @code
+ * struct json_object_iterator it;
+ * struct json_object_iterator itEnd;
+ * struct json_object* obj;
+ *
+ * obj = json_tokener_parse("{'first':'george', 'age':100}");
+ * it = json_object_iter_begin(obj);
+ * itEnd = json_object_iter_end(obj);
+ *
+ * while (!json_object_iter_equal(&it, &itEnd)) {
+ *     printf("%s\n",
+ *            json_object_iter_peek_name(&it));
+ *     json_object_iter_next(&it);
+ * }
+ *
+ * @endcode
+ */
+JSON_EXPORT struct json_object_iterator json_object_iter_begin(struct json_object *obj);
+
+/** Retrieves the iterator that represents the position beyond the
+ *  last pair of the given JSON Object instance.
+ *
+ *  @warning Do NOT write code that assumes that the "end"
+ *        iterator value is NULL, even if it is so in a
+ *        particular instance of the implementation.
+ *
+ *  @note The reason we do not (and MUST NOT) provide
+ *        "json_object_iter_is_end(json_object_iterator* iter)"
+ *        type of API is because it would limit the underlying
+ *        representation of name/value containment (or force us
+ *        to add additional, otherwise unnecessary, fields to
+ *        the iterator structure). The "end" iterator and the
+ *        equality test method, on the other hand, permit us to
+ *        cleanly abstract pretty much any reasonable underlying
+ *        representation without burdening the iterator
+ *        structure with unnecessary data.
+ *
+ *  @note For performance reasons, memorize the "end" iterator prior
+ *        to any loop.
+ *
+ * @param obj JSON Object instance (MUST be of type json_object)
+ *
+ * @return json_object_iterator On return, the iterator refers
+ *              to the "end" of the Object instance's pairs
+ *              (i.e., NOT the last pair, but "beyond the last
+ *              pair" value)
+ */
+JSON_EXPORT struct json_object_iterator json_object_iter_end(const struct json_object *obj);
+
+/** Returns an iterator to the next pair, if any
+ *
+ * @warning	Any modification of the underlying pair
+ *       	invalidates all iterators to that pair.
+ *
+ * @param iter [IN/OUT] Pointer to iterator that references a
+ *         name/value pair; MUST be a valid, non-end iterator.
+ *         WARNING: bad things will happen if invalid or "end"
+ *         iterator is passed. Upon return will contain the
+ *         reference to the next pair if there is one; if there
+ *         are no more pairs, will contain the "end" iterator
+ *         value, which may be compared against the return value
+ *         of json_object_iter_end() for the same JSON Object
+ *         instance.
+ */
+JSON_EXPORT void json_object_iter_next(struct json_object_iterator *iter);
+
+/** Returns a const pointer to the name of the pair referenced
+ *  by the given iterator.
+ *
+ * @param iter pointer to iterator that references a name/value
+ *             pair; MUST be a valid, non-end iterator.
+ *
+ * @warning	bad things will happen if an invalid or
+ *             	"end" iterator is passed.
+ *
+ * @return const char* Pointer to the name of the referenced
+ *         name/value pair.  The name memory belongs to the
+ *         name/value pair, will be freed when the pair is
+ *         deleted or modified, and MUST NOT be modified or
+ *         freed by the user.
+ */
+JSON_EXPORT const char *json_object_iter_peek_name(const struct json_object_iterator *iter);
+
+/** Returns a pointer to the json-c instance representing the
+ *  value of the referenced name/value pair, without altering
+ *  the instance's reference count.
+ *
+ * @param iter 	pointer to iterator that references a name/value
+ *             	pair; MUST be a valid, non-end iterator.
+ *
+ * @warning	bad things will happen if invalid or
+ *             "end" iterator is passed.
+ *
+ * @return struct json_object* Pointer to the json-c value
+ *         instance of the referenced name/value pair;  the
+ *         value's reference count is not changed by this
+ *         function: if you plan to hold on to this json-c node,
+ *         take a look at json_object_get() and
+ *         json_object_put(). IMPORTANT: json-c API represents
+ *         the JSON Null value as a NULL json_object instance
+ *         pointer.
+ */
+JSON_EXPORT struct json_object *
+json_object_iter_peek_value(const struct json_object_iterator *iter);
+
+/** Tests two iterators for equality.  Typically used to test
+ *  for end of iteration by comparing an iterator to the
+ *  corresponding "end" iterator (that was derived from the same
+ *  JSON Object instance).
+ *
+ *  @note The reason we do not (and MUST NOT) provide
+ *        "json_object_iter_is_end(json_object_iterator* iter)"
+ *        type of API is because it would limit the underlying
+ *        representation of name/value containment (or force us
+ *        to add additional, otherwise unnecessary, fields to
+ *        the iterator structure). The equality test method, on
+ *        the other hand, permits us to cleanly abstract pretty
+ *        much any reasonable underlying representation.
+ *
+ * @param iter1 Pointer to first valid, non-NULL iterator
+ * @param iter2 POinter to second valid, non-NULL iterator
+ *
+ * @warning	if a NULL iterator pointer or an uninitialized
+ *       	or invalid iterator, or iterators derived from
+ *       	different JSON Object instances are passed, bad things
+ *       	will happen!
+ *
+ * @return json_bool non-zero if iterators are equal (i.e., both
+ *         reference the same name/value pair or are both at
+ *         "end"); zero if they are not equal.
+ */
+JSON_EXPORT json_bool json_object_iter_equal(const struct json_object_iterator *iter1,
+                                             const struct json_object_iterator *iter2);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JSON_OBJECT_ITERATOR_H */
diff --git a/lynq/S300/ap/app/apparms/json-c/json_object_private.h b/lynq/S300/ap/app/apparms/json-c/json_object_private.h
new file mode 100755
index 0000000..e143b46
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_object_private.h
@@ -0,0 +1,107 @@
+/*
+ * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+#ifndef _json_object_private_h_
+#define _json_object_private_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct json_object;
+#include "json_inttypes.h"
+#include "json_types.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef _MSC_VER
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
+/* json object int type, support extension*/
+typedef enum json_object_int_type
+{
+	json_object_int_type_int64,
+	json_object_int_type_uint64
+} json_object_int_type;
+
+struct json_object
+{
+	enum json_type o_type;
+	uint32_t _ref_count;
+	json_object_to_json_string_fn *_to_json_string;
+	struct printbuf *_pb;
+	json_object_delete_fn *_user_delete;
+	void *_userdata;
+	// Actually longer, always malloc'd as some more-specific type.
+	// The rest of a struct json_object_${o_type} follows
+};
+
+struct json_object_object
+{
+	struct json_object base;
+	struct lh_table *c_object;
+};
+struct json_object_array
+{
+	struct json_object base;
+	struct array_list *c_array;
+};
+
+struct json_object_boolean
+{
+	struct json_object base;
+	json_bool c_boolean;
+};
+struct json_object_double
+{
+	struct json_object base;
+	double c_double;
+};
+struct json_object_int
+{
+	struct json_object base;
+	enum json_object_int_type cint_type;
+	union
+	{
+		int64_t c_int64;
+		uint64_t c_uint64;
+	} cint;
+};
+struct json_object_string
+{
+	struct json_object base;
+	ssize_t len; // Signed b/c negative lengths indicate data is a pointer
+	// Consider adding an "alloc" field here, if json_object_set_string calls
+	// to expand the length of a string are common operations to perform.
+	union
+	{
+		char idata[1]; // Immediate data.  Actually longer
+		char *pdata;   // Only when len < 0
+	} c_string;
+};
+
+void _json_c_set_last_err(const char *err_fmt, ...);
+
+extern const char *json_hex_chars;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_pointer.c b/lynq/S300/ap/app/apparms/json-c/json_pointer.c
new file mode 100755
index 0000000..5abccdb
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_pointer.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2016 Alexandru Ardelean.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+
+#include "strerror_override.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json_pointer.h"
+#include "strdup_compat.h"
+#include "vasprintf_compat.h"
+
+/* Avoid ctype.h and locale overhead */
+#define is_plain_digit(c) ((c) >= '0' && (c) <= '9')
+
+/**
+ * JavaScript Object Notation (JSON) Pointer
+ *   RFC 6901 - https://tools.ietf.org/html/rfc6901
+ */
+
+static void string_replace_all_occurrences_with_char(char *s, const char *occur, char repl_char)
+{
+	size_t slen = strlen(s);
+	size_t skip = strlen(occur) - 1; /* length of the occurrence, minus the char we're replacing */
+	char *p = s;
+	while ((p = strstr(p, occur)))
+	{
+		*p = repl_char;
+		p++;
+		slen -= skip;
+		memmove(p, (p + skip), slen - (p - s) + 1); /* includes null char too */
+	}
+}
+
+static int is_valid_index(struct json_object *jo, const char *path, size_t *idx)
+{
+	size_t i, len = strlen(path);
+	long int idx_val = -1;
+	/* this code-path optimizes a bit, for when we reference the 0-9 index range
+	 * in a JSON array and because leading zeros not allowed
+	 */
+	if (len == 1)
+	{
+		if (is_plain_digit(path[0]))
+		{
+			*idx = (path[0] - '0');
+			goto check_oob;
+		}
+		errno = EINVAL;
+		return 0;
+	}
+	/* leading zeros not allowed per RFC */
+	if (path[0] == '0')
+	{
+		errno = EINVAL;
+		return 0;
+	}
+	/* RFC states base-10 decimals */
+	for (i = 0; i < len; i++)
+	{
+		if (!is_plain_digit(path[i]))
+		{
+			errno = EINVAL;
+			return 0;
+		}
+	}
+
+	idx_val = strtol(path, NULL, 10);
+	if (idx_val < 0)
+	{
+		errno = EINVAL;
+		return 0;
+	}
+	*idx = idx_val;
+
+check_oob:
+	len = json_object_array_length(jo);
+	if (*idx >= len)
+	{
+		errno = ENOENT;
+		return 0;
+	}
+
+	return 1;
+}
+
+static int json_pointer_get_single_path(struct json_object *obj, char *path,
+                                        struct json_object **value)
+{
+	if (json_object_is_type(obj, json_type_array))
+	{
+		size_t idx;
+		if (!is_valid_index(obj, path, &idx))
+			return -1;
+		obj = json_object_array_get_idx(obj, idx);
+		if (obj)
+		{
+			if (value)
+				*value = obj;
+			return 0;
+		}
+		/* Entry not found */
+		errno = ENOENT;
+		return -1;
+	}
+
+	/* RFC states that we first must eval all ~1 then all ~0 */
+	string_replace_all_occurrences_with_char(path, "~1", '/');
+	string_replace_all_occurrences_with_char(path, "~0", '~');
+
+	if (!json_object_object_get_ex(obj, path, value))
+	{
+		errno = ENOENT;
+		return -1;
+	}
+
+	return 0;
+}
+
+static int json_pointer_set_single_path(struct json_object *parent, const char *path,
+                                        struct json_object *value)
+{
+	if (json_object_is_type(parent, json_type_array))
+	{
+		size_t idx;
+		/* RFC (Chapter 4) states that '-' may be used to add new elements to an array */
+		if (path[0] == '-' && path[1] == '\0')
+			return json_object_array_add(parent, value);
+		if (!is_valid_index(parent, path, &idx))
+			return -1;
+		return json_object_array_put_idx(parent, idx, value);
+	}
+
+	/* path replacements should have been done in json_pointer_get_single_path(),
+	 * and we should still be good here
+	 */
+	if (json_object_is_type(parent, json_type_object))
+		return json_object_object_add(parent, path, value);
+
+	/* Getting here means that we tried to "dereference" a primitive JSON type
+	 * (like string, int, bool).i.e. add a sub-object to it
+	 */
+	errno = ENOENT;
+	return -1;
+}
+
+static int json_pointer_get_recursive(struct json_object *obj, char *path,
+                                      struct json_object **value)
+{
+	char *endp;
+	int rc;
+
+	/* All paths (on each recursion level must have a leading '/' */
+	if (path[0] != '/')
+	{
+		errno = EINVAL;
+		return -1;
+	}
+	path++;
+
+	endp = strchr(path, '/');
+	if (endp)
+		*endp = '\0';
+
+	/* If we err-ed here, return here */
+	if ((rc = json_pointer_get_single_path(obj, path, &obj)))
+		return rc;
+
+	if (endp)
+	{
+		/* Put the slash back, so that the sanity check passes on next recursion level */
+		*endp = '/';
+		return json_pointer_get_recursive(obj, endp, value);
+	}
+
+	/* We should be at the end of the recursion here */
+	if (value)
+		*value = obj;
+
+	return 0;
+}
+
+int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res)
+{
+	char *path_copy = NULL;
+	int rc;
+
+	if (!obj || !path)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (path[0] == '\0')
+	{
+		if (res)
+			*res = obj;
+		return 0;
+	}
+
+	/* pass a working copy to the recursive call */
+	if (!(path_copy = strdup(path)))
+	{
+		errno = ENOMEM;
+		return -1;
+	}
+	rc = json_pointer_get_recursive(obj, path_copy, res);
+	free(path_copy);
+
+	return rc;
+}
+
+int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...)
+{
+	char *path_copy = NULL;
+	int rc = 0;
+	va_list args;
+
+	if (!obj || !path_fmt)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	va_start(args, path_fmt);
+	rc = vasprintf(&path_copy, path_fmt, args);
+	va_end(args);
+
+	if (rc < 0)
+		return rc;
+
+	if (path_copy[0] == '\0')
+	{
+		if (res)
+			*res = obj;
+		goto out;
+	}
+
+	rc = json_pointer_get_recursive(obj, path_copy, res);
+out:
+	free(path_copy);
+
+	return rc;
+}
+
+int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value)
+{
+	const char *endp;
+	char *path_copy = NULL;
+	struct json_object *set = NULL;
+	int rc;
+
+	if (!obj || !path)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (path[0] == '\0')
+	{
+		json_object_put(*obj);
+		*obj = value;
+		return 0;
+	}
+
+	if (path[0] != '/')
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* If there's only 1 level to set, stop here */
+	if ((endp = strrchr(path, '/')) == path)
+	{
+		path++;
+		return json_pointer_set_single_path(*obj, path, value);
+	}
+
+	/* pass a working copy to the recursive call */
+	if (!(path_copy = strdup(path)))
+	{
+		errno = ENOMEM;
+		return -1;
+	}
+	path_copy[endp - path] = '\0';
+	rc = json_pointer_get_recursive(*obj, path_copy, &set);
+	free(path_copy);
+
+	if (rc)
+		return rc;
+
+	endp++;
+	return json_pointer_set_single_path(set, endp, value);
+}
+
+int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt,
+                      ...)
+{
+	char *endp;
+	char *path_copy = NULL;
+	struct json_object *set = NULL;
+	va_list args;
+	int rc = 0;
+
+	if (!obj || !path_fmt)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* pass a working copy to the recursive call */
+	va_start(args, path_fmt);
+	rc = vasprintf(&path_copy, path_fmt, args);
+	va_end(args);
+
+	if (rc < 0)
+		return rc;
+
+	if (path_copy[0] == '\0')
+	{
+		json_object_put(*obj);
+		*obj = value;
+		goto out;
+	}
+
+	if (path_copy[0] != '/')
+	{
+		errno = EINVAL;
+		rc = -1;
+		goto out;
+	}
+
+	/* If there's only 1 level to set, stop here */
+	if ((endp = strrchr(path_copy, '/')) == path_copy)
+	{
+		set = *obj;
+		goto set_single_path;
+	}
+
+	*endp = '\0';
+	rc = json_pointer_get_recursive(*obj, path_copy, &set);
+
+	if (rc)
+		goto out;
+
+set_single_path:
+	endp++;
+	rc = json_pointer_set_single_path(set, endp, value);
+out:
+	free(path_copy);
+	return rc;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_pointer.h b/lynq/S300/ap/app/apparms/json-c/json_pointer.h
new file mode 100755
index 0000000..06c395b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_pointer.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2016 Alexadru Ardelean.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief JSON Pointer (RFC 6901) implementation for retrieving
+ *        objects from a json-c object tree.
+ */
+#ifndef _json_pointer_h_
+#define _json_pointer_h_
+
+#include "json_object.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Retrieves a JSON sub-object from inside another JSON object
+ * using the JSON pointer notation as defined in RFC 6901
+ *   https://tools.ietf.org/html/rfc6901
+ *
+ * The returned JSON sub-object is equivalent to parsing manually the
+ * 'obj' JSON tree ; i.e. it's not a new object that is created, but rather
+ * a pointer inside the JSON tree.
+ *
+ * Internally, this is equivalent to doing a series of 'json_object_object_get()'
+ * and 'json_object_array_get_idx()' along the given 'path'.
+ *
+ * Note that the 'path' string supports 'printf()' type arguments, so, whatever
+ * is added after the 'res' param will be treated as an argument for 'path'
+ * Example: json_pointer_get(obj, "/foo/%d/%s", &res, 0, bar)
+ * This means, that you need to escape '%' with '%%' (just like in printf())
+ *
+ * @param obj the json_object instance/tree from where to retrieve sub-objects
+ * @param path a (RFC6901) string notation for the sub-object to retrieve
+ * @param res a pointer that stores a reference to the json_object
+ *              associated with the given path
+ *
+ * @return negative if an error (or not found), or 0 if succeeded
+ */
+JSON_EXPORT int json_pointer_get(struct json_object *obj, const char *path,
+                                 struct json_object **res);
+
+/**
+ * This is a variant of 'json_pointer_get()' that supports printf() style arguments.
+ *
+ * Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, bak)
+ * This also means that you need to escape '%' with '%%' (just like in printf())
+ *
+ * Please take into consideration all recommended 'printf()' format security
+ * aspects when using this function.
+ *
+ * @param obj the json_object instance/tree to which to add a sub-object
+ * @param res a pointer that stores a reference to the json_object
+ *              associated with the given path
+ * @param path_fmt a printf() style format for the path
+ *
+ * @return negative if an error (or not found), or 0 if succeeded
+ */
+JSON_EXPORT int json_pointer_getf(struct json_object *obj, struct json_object **res,
+                                  const char *path_fmt, ...);
+
+/**
+ * Sets JSON object 'value' in the 'obj' tree at the location specified
+ * by the 'path'. 'path' is JSON pointer notation as defined in RFC 6901
+ *   https://tools.ietf.org/html/rfc6901
+ *
+ * Note that 'obj' is a double pointer, mostly for the "" (empty string)
+ * case, where the entire JSON object would be replaced by 'value'.
+ * In the case of the "" path, the object at '*obj' will have it's refcount
+ * decremented with 'json_object_put()' and the 'value' object will be assigned to it.
+ *
+ * For other cases (JSON sub-objects) ownership of 'value' will be transferred into
+ * '*obj' via 'json_object_object_add()' & 'json_object_array_put_idx()', so the
+ * only time the refcount should be decremented for 'value' is when the return value of
+ * 'json_pointer_set()' is negative (meaning the 'value' object did not get set into '*obj').
+ *
+ * That also implies that 'json_pointer_set()' does not do any refcount incrementing.
+ * (Just that single decrement that was mentioned above).
+ *
+ * Note that the 'path' string supports 'printf()' type arguments, so, whatever
+ * is added after the 'value' param will be treated as an argument for 'path'
+ * Example: json_pointer_set(obj, "/foo/%d/%s", value, 0, bak)
+ * This means, that you need to escape '%' with '%%' (just like in printf())
+ *
+ * @param obj the json_object instance/tree to which to add a sub-object
+ * @param path a (RFC6901) string notation for the sub-object to set in the tree
+ * @param value object to set at path
+ *
+ * @return negative if an error (or not found), or 0 if succeeded
+ */
+JSON_EXPORT int json_pointer_set(struct json_object **obj, const char *path,
+                                 struct json_object *value);
+
+/**
+ * This is a variant of 'json_pointer_set()' that supports printf() style arguments.
+ *
+ * Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, bak)
+ * This also means that you need to escape '%' with '%%' (just like in printf())
+ *
+ * Please take into consideration all recommended 'printf()' format security
+ * aspects when using this function.
+ *
+ * @param obj the json_object instance/tree to which to add a sub-object
+ * @param value object to set at path
+ * @param path_fmt a printf() style format for the path
+ *
+ * @return negative if an error (or not found), or 0 if succeeded
+ */
+JSON_EXPORT int json_pointer_setf(struct json_object **obj, struct json_object *value,
+                                  const char *path_fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_tokener.c b/lynq/S300/ap/app/apparms/json-c/json_tokener.c
new file mode 100755
index 0000000..753d4f2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_tokener.c
@@ -0,0 +1,1311 @@
+/*
+ * $Id: json_tokener.c,v 1.20 2006/07/25 03:24:50 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ *
+ * Copyright (c) 2008-2009 Yahoo! Inc.  All rights reserved.
+ * The copyrights to the contents of this file are licensed under the MIT License
+ * (https://www.opensource.org/licenses/mit-license.php)
+ */
+
+#include "config.h"
+
+#include "math_compat.h"
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <math.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "debug.h"
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_object_private.h"
+#include "json_tokener.h"
+#include "json_util.h"
+#include "printbuf.h"
+#include "strdup_compat.h"
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif /* HAVE_LOCALE_H */
+#ifdef HAVE_XLOCALE_H
+#include <xlocale.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
+
+#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x)&7) + 9)
+
+#if !HAVE_STRNCASECMP && defined(_MSC_VER)
+/* MSC has the version as _strnicmp */
+#define strncasecmp _strnicmp
+#elif !HAVE_STRNCASECMP
+#error You do not have strncasecmp on your system.
+#endif /* HAVE_STRNCASECMP */
+
+#if defined(_MSC_VER) && (_MSC_VER <= 1800)
+/* VS2013 doesn't know about "inline" */
+#define inline __inline
+#elif defined(AIX_CC)
+#define inline
+#endif
+
+/* The following helper functions are used to speed up parsing. They
+ * are faster than their ctype counterparts because they assume that
+ * the input is in ASCII and that the locale is set to "C". The
+ * compiler will also inline these functions, providing an additional
+ * speedup by saving on function calls.
+ */
+static inline int is_ws_char(char c)
+{
+	return c == ' '
+	    || c == '\t'
+	    || c == '\n'
+	    || c == '\r';
+}
+
+static inline int is_hex_char(char c)
+{
+	return (c >= '0' && c <= '9')
+	    || (c >= 'A' && c <= 'F')
+	    || (c >= 'a' && c <= 'f');
+}
+
+/* Use C99 NAN by default; if not available, nan("") should work too. */
+#ifndef NAN
+#define NAN nan("")
+#endif /* !NAN */
+
+static const char json_null_str[] = "null";
+static const int json_null_str_len = sizeof(json_null_str) - 1;
+static const char json_inf_str[] = "Infinity";
+/* Swapped case "Infinity" to avoid need to call tolower() on input chars: */
+static const char json_inf_str_invert[] = "iNFINITY";
+static const unsigned int json_inf_str_len = sizeof(json_inf_str) - 1;
+static const char json_nan_str[] = "NaN";
+static const int json_nan_str_len = sizeof(json_nan_str) - 1;
+static const char json_true_str[] = "true";
+static const int json_true_str_len = sizeof(json_true_str) - 1;
+static const char json_false_str[] = "false";
+static const int json_false_str_len = sizeof(json_false_str) - 1;
+
+/* clang-format off */
+static const char *json_tokener_errors[] = {
+	"success",
+	"continue",
+	"nesting too deep",
+	"unexpected end of data",
+	"unexpected character",
+	"null expected",
+	"boolean expected",
+	"number expected",
+	"array value separator ',' expected",
+	"quoted object property name expected",
+	"object property name separator ':' expected",
+	"object value separator ',' expected",
+	"invalid string sequence",
+	"expected comment",
+	"invalid utf-8 string",
+	"buffer size overflow"
+};
+/* clang-format on */
+
+/**
+ * validete the utf-8 string in strict model.
+ * if not utf-8 format, return err.
+ */
+static json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes);
+
+static int json_tokener_parse_double(const char *buf, int len, double *retval);
+
+const char *json_tokener_error_desc(enum json_tokener_error jerr)
+{
+	int jerr_int = (int)jerr;
+	if (jerr_int < 0 ||
+	    jerr_int >= (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0])))
+		return "Unknown error, "
+		       "invalid json_tokener_error value passed to json_tokener_error_desc()";
+	return json_tokener_errors[jerr];
+}
+
+enum json_tokener_error json_tokener_get_error(struct json_tokener *tok)
+{
+	return tok->err;
+}
+
+/* Stuff for decoding unicode sequences */
+#define IS_HIGH_SURROGATE(uc) (((uc)&0xFC00) == 0xD800)
+#define IS_LOW_SURROGATE(uc) (((uc)&0xFC00) == 0xDC00)
+#define DECODE_SURROGATE_PAIR(hi, lo) ((((hi)&0x3FF) << 10) + ((lo)&0x3FF) + 0x10000)
+static unsigned char utf8_replacement_char[3] = {0xEF, 0xBF, 0xBD};
+
+struct json_tokener *json_tokener_new_ex(int depth)
+{
+	struct json_tokener *tok;
+
+	tok = (struct json_tokener *)calloc(1, sizeof(struct json_tokener));
+	if (!tok)
+		return NULL;
+	tok->stack = (struct json_tokener_srec *)calloc(depth, sizeof(struct json_tokener_srec));
+	if (!tok->stack)
+	{
+		free(tok);
+		return NULL;
+	}
+	tok->pb = printbuf_new();
+	if (!tok->pb)
+	{
+		free(tok->stack);
+		free(tok);
+		return NULL;
+	}
+	tok->max_depth = depth;
+	json_tokener_reset(tok);
+	return tok;
+}
+
+struct json_tokener *json_tokener_new(void)
+{
+	return json_tokener_new_ex(JSON_TOKENER_DEFAULT_DEPTH);
+}
+
+void json_tokener_free(struct json_tokener *tok)
+{
+	json_tokener_reset(tok);
+	if (tok->pb)
+		printbuf_free(tok->pb);
+	free(tok->stack);
+	free(tok);
+}
+
+static void json_tokener_reset_level(struct json_tokener *tok, int depth)
+{
+	tok->stack[depth].state = json_tokener_state_eatws;
+	tok->stack[depth].saved_state = json_tokener_state_start;
+	json_object_put(tok->stack[depth].current);
+	tok->stack[depth].current = NULL;
+	free(tok->stack[depth].obj_field_name);
+	tok->stack[depth].obj_field_name = NULL;
+}
+
+void json_tokener_reset(struct json_tokener *tok)
+{
+	int i;
+	if (!tok)
+		return;
+
+	for (i = tok->depth; i >= 0; i--)
+		json_tokener_reset_level(tok, i);
+	tok->depth = 0;
+	tok->err = json_tokener_success;
+}
+
+struct json_object *json_tokener_parse(const char *str)
+{
+	enum json_tokener_error jerr_ignored;
+	struct json_object *obj;
+	obj = json_tokener_parse_verbose(str, &jerr_ignored);
+	return obj;
+}
+
+struct json_object *json_tokener_parse_verbose(const char *str, enum json_tokener_error *error)
+{
+	struct json_tokener *tok;
+	struct json_object *obj;
+
+	tok = json_tokener_new();
+	if (!tok)
+		return NULL;
+	obj = json_tokener_parse_ex(tok, str, -1);
+	*error = tok->err;
+	if (tok->err != json_tokener_success
+#if 0
+		/* This would be a more sensible default, and cause parsing
+		 * things like "null123" to fail when the caller can't know
+		 * where the parsing left off, but starting to fail would
+		 * be a notable behaviour change.  Save for a 1.0 release.
+		 */
+	    || json_tokener_get_parse_end(tok) != strlen(str)
+#endif
+	)
+
+	{
+		if (obj != NULL)
+			json_object_put(obj);
+		obj = NULL;
+	}
+
+	json_tokener_free(tok);
+	return obj;
+}
+
+#define state tok->stack[tok->depth].state
+#define saved_state tok->stack[tok->depth].saved_state
+#define current tok->stack[tok->depth].current
+#define obj_field_name tok->stack[tok->depth].obj_field_name
+
+/* Optimization:
+ * json_tokener_parse_ex() consumed a lot of CPU in its main loop,
+ * iterating character-by character.  A large performance boost is
+ * achieved by using tighter loops to locally handle units such as
+ * comments and strings.  Loops that handle an entire token within
+ * their scope also gather entire strings and pass them to
+ * printbuf_memappend() in a single call, rather than calling
+ * printbuf_memappend() one char at a time.
+ *
+ * PEEK_CHAR() and ADVANCE_CHAR() macros are used for code that is
+ * common to both the main loop and the tighter loops.
+ */
+
+/* PEEK_CHAR(dest, tok) macro:
+ *   Peeks at the current char and stores it in dest.
+ *   Returns 1 on success, sets tok->err and returns 0 if no more chars.
+ *   Implicit inputs:  str, len, nBytesp vars
+ */
+#define PEEK_CHAR(dest, tok)                                                 \
+	(((tok)->char_offset == len)                                         \
+	     ? (((tok)->depth == 0 && state == json_tokener_state_eatws &&   \
+	         saved_state == json_tokener_state_finish)                   \
+	            ? (((tok)->err = json_tokener_success), 0)               \
+	            : (((tok)->err = json_tokener_continue), 0))             \
+	     : (((tok->flags & JSON_TOKENER_VALIDATE_UTF8) &&                \
+	         (!json_tokener_validate_utf8(*str, nBytesp)))               \
+	            ? ((tok->err = json_tokener_error_parse_utf8_string), 0) \
+	            : (((dest) = *str), 1)))
+
+/* ADVANCE_CHAR() macro:
+ *   Increments str & tok->char_offset.
+ *   For convenience of existing conditionals, returns the old value of c (0 on eof)
+ *   Implicit inputs:  c var
+ */
+#define ADVANCE_CHAR(str, tok) (++(str), ((tok)->char_offset)++, c)
+
+/* End optimization macro defs */
+
+struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *str, int len)
+{
+	struct json_object *obj = NULL;
+	char c = '\1';
+	unsigned int nBytes = 0;
+	unsigned int *nBytesp = &nBytes;
+
+#ifdef HAVE_USELOCALE
+	locale_t oldlocale = uselocale(NULL);
+	locale_t newloc;
+#elif defined(HAVE_SETLOCALE)
+	char *oldlocale = NULL;
+#endif
+
+	tok->char_offset = 0;
+	tok->err = json_tokener_success;
+
+	/* this interface is presently not 64-bit clean due to the int len argument
+	 * and the internal printbuf interface that takes 32-bit int len arguments
+	 * so the function limits the maximum string size to INT32_MAX (2GB).
+	 * If the function is called with len == -1 then strlen is called to check
+	 * the string length is less than INT32_MAX (2GB)
+	 */
+	if ((len < -1) || (len == -1 && strlen(str) > INT32_MAX))
+	{
+		tok->err = json_tokener_error_size;
+		return NULL;
+	}
+
+#ifdef HAVE_USELOCALE
+	{
+		locale_t duploc = duplocale(oldlocale);
+		newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
+		if (newloc == NULL)
+		{
+			freelocale(duploc);
+			return NULL;
+		}
+		uselocale(newloc);
+	}
+#elif defined(HAVE_SETLOCALE)
+	{
+		char *tmplocale;
+		tmplocale = setlocale(LC_NUMERIC, NULL);
+		if (tmplocale)
+			oldlocale = strdup(tmplocale);
+		setlocale(LC_NUMERIC, "C");
+	}
+#endif
+
+	while (PEEK_CHAR(c, tok)) // Note: c might be '\0' !
+	{
+
+	redo_char:
+		switch (state)
+		{
+
+		case json_tokener_state_eatws:
+			/* Advance until we change state */
+			while (is_ws_char(c))
+			{
+				if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok)))
+					goto out;
+			}
+			if (c == '/' && !(tok->flags & JSON_TOKENER_STRICT))
+			{
+				printbuf_reset(tok->pb);
+				printbuf_memappend_fast(tok->pb, &c, 1);
+				state = json_tokener_state_comment_start;
+			}
+			else
+			{
+				state = saved_state;
+				goto redo_char;
+			}
+			break;
+
+		case json_tokener_state_start:
+			switch (c)
+			{
+			case '{':
+				state = json_tokener_state_eatws;
+				saved_state = json_tokener_state_object_field_start;
+				current = json_object_new_object();
+				if (current == NULL)
+					goto out;
+				break;
+			case '[':
+				state = json_tokener_state_eatws;
+				saved_state = json_tokener_state_array;
+				current = json_object_new_array();
+				if (current == NULL)
+					goto out;
+				break;
+			case 'I':
+			case 'i':
+				state = json_tokener_state_inf;
+				printbuf_reset(tok->pb);
+				tok->st_pos = 0;
+				goto redo_char;
+			case 'N':
+			case 'n':
+				state = json_tokener_state_null; // or NaN
+				printbuf_reset(tok->pb);
+				tok->st_pos = 0;
+				goto redo_char;
+			case '\'':
+				if (tok->flags & JSON_TOKENER_STRICT)
+				{
+					/* in STRICT mode only double-quote are allowed */
+					tok->err = json_tokener_error_parse_unexpected;
+					goto out;
+				}
+				/* FALLTHRU */
+			case '"':
+				state = json_tokener_state_string;
+				printbuf_reset(tok->pb);
+				tok->quote_char = c;
+				break;
+			case 'T':
+			case 't':
+			case 'F':
+			case 'f':
+				state = json_tokener_state_boolean;
+				printbuf_reset(tok->pb);
+				tok->st_pos = 0;
+				goto redo_char;
+			case '0':
+			case '1':
+			case '2':
+			case '3':
+			case '4':
+			case '5':
+			case '6':
+			case '7':
+			case '8':
+			case '9':
+			case '-':
+				state = json_tokener_state_number;
+				printbuf_reset(tok->pb);
+				tok->is_double = 0;
+				goto redo_char;
+			default: tok->err = json_tokener_error_parse_unexpected; goto out;
+			}
+			break;
+
+		case json_tokener_state_finish:
+			if (tok->depth == 0)
+				goto out;
+			obj = json_object_get(current);
+			json_tokener_reset_level(tok, tok->depth);
+			tok->depth--;
+			goto redo_char;
+
+		case json_tokener_state_inf: /* aka starts with 'i' (or 'I', or "-i", or "-I") */
+		{
+			/* If we were guaranteed to have len set, then we could (usually) handle
+			 * the entire "Infinity" check in a single strncmp (strncasecmp), but
+			 * since len might be -1 (i.e. "read until \0"), we need to check it
+			 * a character at a time.
+			 * Trying to handle it both ways would make this code considerably more
+			 * complicated with likely little performance benefit.
+			 */
+			int is_negative = 0;
+
+			/* Note: tok->st_pos must be 0 when state is set to json_tokener_state_inf */
+			while (tok->st_pos < (int)json_inf_str_len)
+			{
+				char inf_char = *str;
+				if (inf_char != json_inf_str[tok->st_pos] &&
+				    ((tok->flags & JSON_TOKENER_STRICT) ||
+				      inf_char != json_inf_str_invert[tok->st_pos])
+				   )
+				{
+					tok->err = json_tokener_error_parse_unexpected;
+					goto out;
+				}
+				tok->st_pos++;
+				(void)ADVANCE_CHAR(str, tok);
+				if (!PEEK_CHAR(c, tok))
+				{
+					/* out of input chars, for now at least */
+					goto out;
+				}
+			}
+			/* We checked the full length of "Infinity", so create the object.
+			 * When handling -Infinity, the number parsing code will have dropped
+			 * the "-" into tok->pb for us, so check it now.
+			 */
+			if (printbuf_length(tok->pb) > 0 && *(tok->pb->buf) == '-')
+			{
+				is_negative = 1;
+			}
+			current = json_object_new_double(is_negative ? -INFINITY : INFINITY);
+			if (current == NULL)
+				goto out;
+			saved_state = json_tokener_state_finish;
+			state = json_tokener_state_eatws;
+			goto redo_char;
+		}
+		break;
+		case json_tokener_state_null: /* aka starts with 'n' */
+		{
+			int size;
+			int size_nan;
+			printbuf_memappend_fast(tok->pb, &c, 1);
+			size = json_min(tok->st_pos + 1, json_null_str_len);
+			size_nan = json_min(tok->st_pos + 1, json_nan_str_len);
+			if ((!(tok->flags & JSON_TOKENER_STRICT) &&
+			     strncasecmp(json_null_str, tok->pb->buf, size) == 0) ||
+			    (strncmp(json_null_str, tok->pb->buf, size) == 0))
+			{
+				if (tok->st_pos == json_null_str_len)
+				{
+					current = NULL;
+					saved_state = json_tokener_state_finish;
+					state = json_tokener_state_eatws;
+					goto redo_char;
+				}
+			}
+			else if ((!(tok->flags & JSON_TOKENER_STRICT) &&
+			          strncasecmp(json_nan_str, tok->pb->buf, size_nan) == 0) ||
+			         (strncmp(json_nan_str, tok->pb->buf, size_nan) == 0))
+			{
+				if (tok->st_pos == json_nan_str_len)
+				{
+					current = json_object_new_double(NAN);
+					if (current == NULL)
+						goto out;
+					saved_state = json_tokener_state_finish;
+					state = json_tokener_state_eatws;
+					goto redo_char;
+				}
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_null;
+				goto out;
+			}
+			tok->st_pos++;
+		}
+		break;
+
+		case json_tokener_state_comment_start:
+			if (c == '*')
+			{
+				state = json_tokener_state_comment;
+			}
+			else if (c == '/')
+			{
+				state = json_tokener_state_comment_eol;
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_comment;
+				goto out;
+			}
+			printbuf_memappend_fast(tok->pb, &c, 1);
+			break;
+
+		case json_tokener_state_comment:
+		{
+			/* Advance until we change state */
+			const char *case_start = str;
+			while (c != '*')
+			{
+				if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					goto out;
+				}
+			}
+			printbuf_memappend_fast(tok->pb, case_start, 1 + str - case_start);
+			state = json_tokener_state_comment_end;
+		}
+		break;
+
+		case json_tokener_state_comment_eol:
+		{
+			/* Advance until we change state */
+			const char *case_start = str;
+			while (c != '\n')
+			{
+				if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					goto out;
+				}
+			}
+			printbuf_memappend_fast(tok->pb, case_start, str - case_start);
+			MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf);
+			state = json_tokener_state_eatws;
+		}
+		break;
+
+		case json_tokener_state_comment_end:
+			printbuf_memappend_fast(tok->pb, &c, 1);
+			if (c == '/')
+			{
+				MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf);
+				state = json_tokener_state_eatws;
+			}
+			else
+			{
+				state = json_tokener_state_comment;
+			}
+			break;
+
+		case json_tokener_state_string:
+		{
+			/* Advance until we change state */
+			const char *case_start = str;
+			while (1)
+			{
+				if (c == tok->quote_char)
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					current =
+					    json_object_new_string_len(tok->pb->buf, tok->pb->bpos);
+					if (current == NULL)
+						goto out;
+					saved_state = json_tokener_state_finish;
+					state = json_tokener_state_eatws;
+					break;
+				}
+				else if (c == '\\')
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					saved_state = json_tokener_state_string;
+					state = json_tokener_state_string_escape;
+					break;
+				}
+				if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					goto out;
+				}
+			}
+		}
+		break;
+
+		case json_tokener_state_string_escape:
+			switch (c)
+			{
+			case '"':
+			case '\\':
+			case '/':
+				printbuf_memappend_fast(tok->pb, &c, 1);
+				state = saved_state;
+				break;
+			case 'b':
+			case 'n':
+			case 'r':
+			case 't':
+			case 'f':
+				if (c == 'b')
+					printbuf_memappend_fast(tok->pb, "\b", 1);
+				else if (c == 'n')
+					printbuf_memappend_fast(tok->pb, "\n", 1);
+				else if (c == 'r')
+					printbuf_memappend_fast(tok->pb, "\r", 1);
+				else if (c == 't')
+					printbuf_memappend_fast(tok->pb, "\t", 1);
+				else if (c == 'f')
+					printbuf_memappend_fast(tok->pb, "\f", 1);
+				state = saved_state;
+				break;
+			case 'u':
+				tok->ucs_char = 0;
+				tok->st_pos = 0;
+				state = json_tokener_state_escape_unicode;
+				break;
+			default: tok->err = json_tokener_error_parse_string; goto out;
+			}
+			break;
+
+			// ===================================================
+
+		case json_tokener_state_escape_unicode:
+		{
+			/* Handle a 4-byte \uNNNN sequence, or two sequences if a surrogate pair */
+			while (1)
+			{
+				if (!c || !is_hex_char(c))
+				{
+					tok->err = json_tokener_error_parse_string;
+					goto out;
+				}
+				tok->ucs_char |=
+				    ((unsigned int)jt_hexdigit(c) << ((3 - tok->st_pos) * 4));
+				tok->st_pos++;
+				if (tok->st_pos >= 4)
+					break;
+
+				(void)ADVANCE_CHAR(str, tok);
+				if (!PEEK_CHAR(c, tok))
+				{
+					/*
+					 * We're out of characters in the current call to
+					 * json_tokener_parse(), but a subsequent call might
+					 * provide us with more, so leave our current state
+					 * as-is (including tok->high_surrogate) and return.
+					 */
+					goto out;
+				}
+			}
+			tok->st_pos = 0;
+
+			/* Now, we have a full \uNNNN sequence in tok->ucs_char */
+
+			/* If the *previous* sequence was a high surrogate ... */
+			if (tok->high_surrogate)
+			{
+				if (IS_LOW_SURROGATE(tok->ucs_char))
+				{
+					/* Recalculate the ucs_char, then fall thru to process normally */
+					tok->ucs_char = DECODE_SURROGATE_PAIR(tok->high_surrogate,
+					                                      tok->ucs_char);
+				}
+				else
+				{
+					/* High surrogate was not followed by a low surrogate
+					 * Replace the high and process the rest normally
+					 */
+					printbuf_memappend_fast(tok->pb,
+					                        (char *)utf8_replacement_char, 3);
+				}
+				tok->high_surrogate = 0;
+			}
+
+			if (tok->ucs_char < 0x80)
+			{
+				unsigned char unescaped_utf[1];
+				unescaped_utf[0] = tok->ucs_char;
+				printbuf_memappend_fast(tok->pb, (char *)unescaped_utf, 1);
+			}
+			else if (tok->ucs_char < 0x800)
+			{
+				unsigned char unescaped_utf[2];
+				unescaped_utf[0] = 0xc0 | (tok->ucs_char >> 6);
+				unescaped_utf[1] = 0x80 | (tok->ucs_char & 0x3f);
+				printbuf_memappend_fast(tok->pb, (char *)unescaped_utf, 2);
+			}
+			else if (IS_HIGH_SURROGATE(tok->ucs_char))
+			{
+				/*
+				 * The next two characters should be \u, HOWEVER,
+				 * we can't simply peek ahead here, because the
+				 * characters we need might not be passed to us
+				 * until a subsequent call to json_tokener_parse.
+				 * Instead, transition through a couple of states.
+				 * (now):
+				 *   _escape_unicode => _unicode_need_escape
+				 * (see a '\\' char):
+				 *   _unicode_need_escape => _unicode_need_u
+				 * (see a 'u' char):
+				 *   _unicode_need_u => _escape_unicode
+				 *      ...and we'll end up back around here.
+				 */
+				tok->high_surrogate = tok->ucs_char;
+				tok->ucs_char = 0;
+				state = json_tokener_state_escape_unicode_need_escape;
+				break;
+			}
+			else if (IS_LOW_SURROGATE(tok->ucs_char))
+			{
+				/* Got a low surrogate not preceded by a high */
+				printbuf_memappend_fast(tok->pb, (char *)utf8_replacement_char, 3);
+			}
+			else if (tok->ucs_char < 0x10000)
+			{
+				unsigned char unescaped_utf[3];
+				unescaped_utf[0] = 0xe0 | (tok->ucs_char >> 12);
+				unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 6) & 0x3f);
+				unescaped_utf[2] = 0x80 | (tok->ucs_char & 0x3f);
+				printbuf_memappend_fast(tok->pb, (char *)unescaped_utf, 3);
+			}
+			else if (tok->ucs_char < 0x110000)
+			{
+				unsigned char unescaped_utf[4];
+				unescaped_utf[0] = 0xf0 | ((tok->ucs_char >> 18) & 0x07);
+				unescaped_utf[1] = 0x80 | ((tok->ucs_char >> 12) & 0x3f);
+				unescaped_utf[2] = 0x80 | ((tok->ucs_char >> 6) & 0x3f);
+				unescaped_utf[3] = 0x80 | (tok->ucs_char & 0x3f);
+				printbuf_memappend_fast(tok->pb, (char *)unescaped_utf, 4);
+			}
+			else
+			{
+				/* Don't know what we got--insert the replacement char */
+				printbuf_memappend_fast(tok->pb, (char *)utf8_replacement_char, 3);
+			}
+			state = saved_state; // i.e. _state_string or _state_object_field
+		}
+		break;
+
+		case json_tokener_state_escape_unicode_need_escape:
+			// We get here after processing a high_surrogate
+			// require a '\\' char
+			if (!c || c != '\\')
+			{
+				/* Got a high surrogate without another sequence following
+				 * it.  Put a replacement char in for the high surrogate
+				 * and pop back up to _state_string or _state_object_field.
+				 */
+				printbuf_memappend_fast(tok->pb, (char *)utf8_replacement_char, 3);
+				tok->high_surrogate = 0;
+				tok->ucs_char = 0;
+				tok->st_pos = 0;
+				state = saved_state;
+				goto redo_char;
+			}
+			state = json_tokener_state_escape_unicode_need_u;
+			break;
+
+		case json_tokener_state_escape_unicode_need_u:
+			/* We already had a \ char, check that it's \u */
+			if (!c || c != 'u')
+			{
+				/* Got a high surrogate with some non-unicode escape
+				 * sequence following it.
+				 * Put a replacement char in for the high surrogate
+				 * and handle the escape sequence normally.
+				 */
+				printbuf_memappend_fast(tok->pb, (char *)utf8_replacement_char, 3);
+				tok->high_surrogate = 0;
+				tok->ucs_char = 0;
+				tok->st_pos = 0;
+				state = json_tokener_state_string_escape;
+				goto redo_char;
+			}
+			state = json_tokener_state_escape_unicode;
+			break;
+
+			// ===================================================
+
+		case json_tokener_state_boolean:
+		{
+			int size1, size2;
+			printbuf_memappend_fast(tok->pb, &c, 1);
+			size1 = json_min(tok->st_pos + 1, json_true_str_len);
+			size2 = json_min(tok->st_pos + 1, json_false_str_len);
+			if ((!(tok->flags & JSON_TOKENER_STRICT) &&
+			     strncasecmp(json_true_str, tok->pb->buf, size1) == 0) ||
+			    (strncmp(json_true_str, tok->pb->buf, size1) == 0))
+			{
+				if (tok->st_pos == json_true_str_len)
+				{
+					current = json_object_new_boolean(1);
+					if (current == NULL)
+						goto out;
+					saved_state = json_tokener_state_finish;
+					state = json_tokener_state_eatws;
+					goto redo_char;
+				}
+			}
+			else if ((!(tok->flags & JSON_TOKENER_STRICT) &&
+			          strncasecmp(json_false_str, tok->pb->buf, size2) == 0) ||
+			         (strncmp(json_false_str, tok->pb->buf, size2) == 0))
+			{
+				if (tok->st_pos == json_false_str_len)
+				{
+					current = json_object_new_boolean(0);
+					if (current == NULL)
+						goto out;
+					saved_state = json_tokener_state_finish;
+					state = json_tokener_state_eatws;
+					goto redo_char;
+				}
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_boolean;
+				goto out;
+			}
+			tok->st_pos++;
+		}
+		break;
+
+		case json_tokener_state_number:
+		{
+			/* Advance until we change state */
+			const char *case_start = str;
+			int case_len = 0;
+			int is_exponent = 0;
+			int neg_sign_ok = 1;
+			int pos_sign_ok = 0;
+			if (printbuf_length(tok->pb) > 0)
+			{
+				/* We don't save all state from the previous incremental parse
+				   so we need to re-generate it based on the saved string so far.
+				 */
+				char *e_loc = strchr(tok->pb->buf, 'e');
+				if (!e_loc)
+					e_loc = strchr(tok->pb->buf, 'E');
+				if (e_loc)
+				{
+					char *last_saved_char =
+					    &tok->pb->buf[printbuf_length(tok->pb) - 1];
+					is_exponent = 1;
+					pos_sign_ok = neg_sign_ok = 1;
+					/* If the "e" isn't at the end, we can't start with a '-' */
+					if (e_loc != last_saved_char)
+					{
+						neg_sign_ok = 0;
+						pos_sign_ok = 0;
+					}
+					// else leave it set to 1, i.e. start of the new input
+				}
+			}
+
+			while (c && ((c >= '0' && c <= '9') ||
+			             (!is_exponent && (c == 'e' || c == 'E')) ||
+			             (neg_sign_ok && c == '-') || (pos_sign_ok && c == '+') ||
+			             (!tok->is_double && c == '.')))
+			{
+				pos_sign_ok = neg_sign_ok = 0;
+				++case_len;
+
+				/* non-digit characters checks */
+				/* note: since the main loop condition to get here was
+				 * an input starting with 0-9 or '-', we are
+				 * protected from input starting with '.' or
+				 * e/E.
+				 */
+				switch (c)
+				{
+				case '.':
+					tok->is_double = 1;
+					pos_sign_ok = 1;
+					neg_sign_ok = 1;
+					break;
+				case 'e': /* FALLTHRU */
+				case 'E':
+					is_exponent = 1;
+					tok->is_double = 1;
+					/* the exponent part can begin with a negative sign */
+					pos_sign_ok = neg_sign_ok = 1;
+					break;
+				default: break;
+				}
+
+				if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
+				{
+					printbuf_memappend_fast(tok->pb, case_start, case_len);
+					goto out;
+				}
+			}
+			/*
+				Now we know c isn't a valid number char, but check whether
+				it might have been intended to be, and return a potentially
+				more understandable error right away.
+				However, if we're at the top-level, use the number as-is
+			    because c can be part of a new object to parse on the
+				next call to json_tokener_parse().
+			 */
+			if (tok->depth > 0 && c != ',' && c != ']' && c != '}' && c != '/' &&
+			    c != 'I' && c != 'i' && !is_ws_char(c))
+			{
+				tok->err = json_tokener_error_parse_number;
+				goto out;
+			}
+			if (case_len > 0)
+				printbuf_memappend_fast(tok->pb, case_start, case_len);
+
+			// Check for -Infinity
+			if (tok->pb->buf[0] == '-' && case_len <= 1 && (c == 'i' || c == 'I'))
+			{
+				state = json_tokener_state_inf;
+				tok->st_pos = 0;
+				goto redo_char;
+			}
+			if (tok->is_double && !(tok->flags & JSON_TOKENER_STRICT))
+			{
+				/* Trim some chars off the end, to allow things
+				   like "123e+" to parse ok. */
+				while (printbuf_length(tok->pb) > 1)
+				{
+					char last_char = tok->pb->buf[printbuf_length(tok->pb) - 1];
+					if (last_char != 'e' && last_char != 'E' &&
+					    last_char != '-' && last_char != '+')
+					{
+						break;
+					}
+					tok->pb->buf[printbuf_length(tok->pb) - 1] = '\0';
+					printbuf_length(tok->pb)--;
+				}
+			}
+		}
+			{
+				int64_t num64;
+				uint64_t numuint64;
+				double numd;
+				if (!tok->is_double && tok->pb->buf[0] == '-' &&
+				    json_parse_int64(tok->pb->buf, &num64) == 0)
+				{
+					if (errno == ERANGE && (tok->flags & JSON_TOKENER_STRICT))
+					{
+						tok->err = json_tokener_error_parse_number;
+						goto out;
+					}
+					current = json_object_new_int64(num64);
+					if (current == NULL)
+						goto out;
+				}
+				else if (!tok->is_double && tok->pb->buf[0] != '-' &&
+				         json_parse_uint64(tok->pb->buf, &numuint64) == 0)
+				{
+					if (errno == ERANGE && (tok->flags & JSON_TOKENER_STRICT))
+					{
+						tok->err = json_tokener_error_parse_number;
+						goto out;
+					}
+					if (numuint64 && tok->pb->buf[0] == '0' &&
+					    (tok->flags & JSON_TOKENER_STRICT))
+					{
+						tok->err = json_tokener_error_parse_number;
+						goto out;
+					}
+					if (numuint64 <= INT64_MAX)
+					{
+						num64 = (uint64_t)numuint64;
+						current = json_object_new_int64(num64);
+						if (current == NULL)
+							goto out;
+					}
+					else
+					{
+						current = json_object_new_uint64(numuint64);
+						if (current == NULL)
+							goto out;
+					}
+				}
+				else if (tok->is_double &&
+				         json_tokener_parse_double(
+				             tok->pb->buf, printbuf_length(tok->pb), &numd) == 0)
+				{
+					current = json_object_new_double_s(numd, tok->pb->buf);
+					if (current == NULL)
+						goto out;
+				}
+				else
+				{
+					tok->err = json_tokener_error_parse_number;
+					goto out;
+				}
+				saved_state = json_tokener_state_finish;
+				state = json_tokener_state_eatws;
+				goto redo_char;
+			}
+			break;
+
+		case json_tokener_state_array_after_sep:
+		case json_tokener_state_array:
+			if (c == ']')
+			{
+				// Minimize memory usage; assume parsed objs are unlikely to be changed
+				json_object_array_shrink(current, 0);
+
+				if (state == json_tokener_state_array_after_sep &&
+				    (tok->flags & JSON_TOKENER_STRICT))
+				{
+					tok->err = json_tokener_error_parse_unexpected;
+					goto out;
+				}
+				saved_state = json_tokener_state_finish;
+				state = json_tokener_state_eatws;
+			}
+			else
+			{
+				if (tok->depth >= tok->max_depth - 1)
+				{
+					tok->err = json_tokener_error_depth;
+					goto out;
+				}
+				state = json_tokener_state_array_add;
+				tok->depth++;
+				json_tokener_reset_level(tok, tok->depth);
+				goto redo_char;
+			}
+			break;
+
+		case json_tokener_state_array_add:
+			if (json_object_array_add(current, obj) != 0)
+				goto out;
+			saved_state = json_tokener_state_array_sep;
+			state = json_tokener_state_eatws;
+			goto redo_char;
+
+		case json_tokener_state_array_sep:
+			if (c == ']')
+			{
+				// Minimize memory usage; assume parsed objs are unlikely to be changed
+				json_object_array_shrink(current, 0);
+
+				saved_state = json_tokener_state_finish;
+				state = json_tokener_state_eatws;
+			}
+			else if (c == ',')
+			{
+				saved_state = json_tokener_state_array_after_sep;
+				state = json_tokener_state_eatws;
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_array;
+				goto out;
+			}
+			break;
+
+		case json_tokener_state_object_field_start:
+		case json_tokener_state_object_field_start_after_sep:
+			if (c == '}')
+			{
+				if (state == json_tokener_state_object_field_start_after_sep &&
+				    (tok->flags & JSON_TOKENER_STRICT))
+				{
+					tok->err = json_tokener_error_parse_unexpected;
+					goto out;
+				}
+				saved_state = json_tokener_state_finish;
+				state = json_tokener_state_eatws;
+			}
+			else if (c == '"' || c == '\'')
+			{
+				tok->quote_char = c;
+				printbuf_reset(tok->pb);
+				state = json_tokener_state_object_field;
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_object_key_name;
+				goto out;
+			}
+			break;
+
+		case json_tokener_state_object_field:
+		{
+			/* Advance until we change state */
+			const char *case_start = str;
+			while (1)
+			{
+				if (c == tok->quote_char)
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					obj_field_name = strdup(tok->pb->buf);
+					saved_state = json_tokener_state_object_field_end;
+					state = json_tokener_state_eatws;
+					break;
+				}
+				else if (c == '\\')
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					saved_state = json_tokener_state_object_field;
+					state = json_tokener_state_string_escape;
+					break;
+				}
+				if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
+				{
+					printbuf_memappend_fast(tok->pb, case_start,
+					                        str - case_start);
+					goto out;
+				}
+			}
+		}
+		break;
+
+		case json_tokener_state_object_field_end:
+			if (c == ':')
+			{
+				saved_state = json_tokener_state_object_value;
+				state = json_tokener_state_eatws;
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_object_key_sep;
+				goto out;
+			}
+			break;
+
+		case json_tokener_state_object_value:
+			if (tok->depth >= tok->max_depth - 1)
+			{
+				tok->err = json_tokener_error_depth;
+				goto out;
+			}
+			state = json_tokener_state_object_value_add;
+			tok->depth++;
+			json_tokener_reset_level(tok, tok->depth);
+			goto redo_char;
+
+		case json_tokener_state_object_value_add:
+			json_object_object_add(current, obj_field_name, obj);
+			free(obj_field_name);
+			obj_field_name = NULL;
+			saved_state = json_tokener_state_object_sep;
+			state = json_tokener_state_eatws;
+			goto redo_char;
+
+		case json_tokener_state_object_sep:
+			/* { */
+			if (c == '}')
+			{
+				saved_state = json_tokener_state_finish;
+				state = json_tokener_state_eatws;
+			}
+			else if (c == ',')
+			{
+				saved_state = json_tokener_state_object_field_start_after_sep;
+				state = json_tokener_state_eatws;
+			}
+			else
+			{
+				tok->err = json_tokener_error_parse_object_value_sep;
+				goto out;
+			}
+			break;
+		}
+		(void)ADVANCE_CHAR(str, tok);
+		if (!c) // This is the char *before* advancing
+			break;
+	} /* while(PEEK_CHAR) */
+
+out:
+	if ((tok->flags & JSON_TOKENER_VALIDATE_UTF8) && (nBytes != 0))
+	{
+		tok->err = json_tokener_error_parse_utf8_string;
+	}
+	if (c && (state == json_tokener_state_finish) && (tok->depth == 0) &&
+	    (tok->flags & (JSON_TOKENER_STRICT | JSON_TOKENER_ALLOW_TRAILING_CHARS)) ==
+	        JSON_TOKENER_STRICT)
+	{
+		/* unexpected char after JSON data */
+		tok->err = json_tokener_error_parse_unexpected;
+	}
+	if (!c)
+	{
+		/* We hit an eof char (0) */
+		if (state != json_tokener_state_finish && saved_state != json_tokener_state_finish)
+			tok->err = json_tokener_error_parse_eof;
+	}
+
+#ifdef HAVE_USELOCALE
+	uselocale(oldlocale);
+	freelocale(newloc);
+#elif defined(HAVE_SETLOCALE)
+	setlocale(LC_NUMERIC, oldlocale);
+	free(oldlocale);
+#endif
+
+	if (tok->err == json_tokener_success)
+	{
+		json_object *ret = json_object_get(current);
+		int ii;
+
+		/* Partially reset, so we parse additional objects on subsequent calls. */
+		for (ii = tok->depth; ii >= 0; ii--)
+			json_tokener_reset_level(tok, ii);
+		return ret;
+	}
+
+	MC_DEBUG("json_tokener_parse_ex: error %s at offset %d\n", json_tokener_errors[tok->err],
+	         tok->char_offset);
+	return NULL;
+}
+
+static json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes)
+{
+	unsigned char chr = c;
+	if (*nBytes == 0)
+	{
+		if (chr >= 0x80)
+		{
+			if ((chr & 0xe0) == 0xc0)
+				*nBytes = 1;
+			else if ((chr & 0xf0) == 0xe0)
+				*nBytes = 2;
+			else if ((chr & 0xf8) == 0xf0)
+				*nBytes = 3;
+			else
+				return 0;
+		}
+	}
+	else
+	{
+		if ((chr & 0xC0) != 0x80)
+			return 0;
+		(*nBytes)--;
+	}
+	return 1;
+}
+
+void json_tokener_set_flags(struct json_tokener *tok, int flags)
+{
+	tok->flags = flags;
+}
+
+size_t json_tokener_get_parse_end(struct json_tokener *tok)
+{
+	assert(tok->char_offset >= 0); /* Drop this line when char_offset becomes a size_t */
+	return (size_t)tok->char_offset;
+}
+
+static int json_tokener_parse_double(const char *buf, int len, double *retval)
+{
+	char *end;
+	*retval = strtod(buf, &end);
+	if (buf + len == end)
+		return 0; // It worked
+	return 1;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_tokener.h b/lynq/S300/ap/app/apparms/json-c/json_tokener.h
new file mode 100755
index 0000000..a07e12c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_tokener.h
@@ -0,0 +1,328 @@
+/*
+ * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Methods to parse an input string into a tree of json_object objects.
+ */
+#ifndef _json_tokener_h_
+#define _json_tokener_h_
+
+#include "json_object.h"
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum json_tokener_error
+{
+	json_tokener_success,
+	json_tokener_continue,
+	json_tokener_error_depth,
+	json_tokener_error_parse_eof,
+	json_tokener_error_parse_unexpected,
+	json_tokener_error_parse_null,
+	json_tokener_error_parse_boolean,
+	json_tokener_error_parse_number,
+	json_tokener_error_parse_array,
+	json_tokener_error_parse_object_key_name,
+	json_tokener_error_parse_object_key_sep,
+	json_tokener_error_parse_object_value_sep,
+	json_tokener_error_parse_string,
+	json_tokener_error_parse_comment,
+	json_tokener_error_parse_utf8_string,
+	json_tokener_error_size
+};
+
+/**
+ * @deprecated Don't use this outside of json_tokener.c, it will be made private in a future release.
+ */
+enum json_tokener_state
+{
+	json_tokener_state_eatws,
+	json_tokener_state_start,
+	json_tokener_state_finish,
+	json_tokener_state_null,
+	json_tokener_state_comment_start,
+	json_tokener_state_comment,
+	json_tokener_state_comment_eol,
+	json_tokener_state_comment_end,
+	json_tokener_state_string,
+	json_tokener_state_string_escape,
+	json_tokener_state_escape_unicode,
+	json_tokener_state_escape_unicode_need_escape,
+	json_tokener_state_escape_unicode_need_u,
+	json_tokener_state_boolean,
+	json_tokener_state_number,
+	json_tokener_state_array,
+	json_tokener_state_array_add,
+	json_tokener_state_array_sep,
+	json_tokener_state_object_field_start,
+	json_tokener_state_object_field,
+	json_tokener_state_object_field_end,
+	json_tokener_state_object_value,
+	json_tokener_state_object_value_add,
+	json_tokener_state_object_sep,
+	json_tokener_state_array_after_sep,
+	json_tokener_state_object_field_start_after_sep,
+	json_tokener_state_inf
+};
+
+/**
+ * @deprecated Don't use this outside of json_tokener.c, it will be made private in a future release.
+ */
+struct json_tokener_srec
+{
+	enum json_tokener_state state, saved_state;
+	struct json_object *obj;
+	struct json_object *current;
+	char *obj_field_name;
+};
+
+#define JSON_TOKENER_DEFAULT_DEPTH 32
+
+/**
+ * Internal state of the json parser.
+ * Do not access any fields of this structure directly.
+ * Its definition is published due to historical limitations
+ * in the json tokener API, and will be changed to be an opaque
+ * type in the future.
+ */
+struct json_tokener
+{
+	/**
+	 * @deprecated Do not access any of these fields outside of json_tokener.c
+	 */
+	char *str;
+	struct printbuf *pb;
+	int max_depth, depth, is_double, st_pos;
+	/**
+	 * @deprecated See json_tokener_get_parse_end() instead.
+	 */
+	int char_offset;
+	/**
+	 * @deprecated See json_tokener_get_error() instead.
+	 */
+	enum json_tokener_error err;
+	unsigned int ucs_char, high_surrogate;
+	char quote_char;
+	struct json_tokener_srec *stack;
+	int flags;
+};
+
+/**
+ * Return the offset of the byte after the last byte parsed
+ * relative to the start of the most recent string passed in
+ * to json_tokener_parse_ex().  i.e. this is where parsing
+ * would start again if the input contains another JSON object
+ * after the currently parsed one.
+ *
+ * Note that when multiple parse calls are issued, this is *not* the
+ * total number of characters parsed.
+ *
+ * In the past this would have been accessed as tok->char_offset.
+ *
+ * See json_tokener_parse_ex() for an example of how to use this.
+ */
+JSON_EXPORT size_t json_tokener_get_parse_end(struct json_tokener *tok);
+
+/**
+ * @deprecated Unused in json-c code
+ */
+typedef struct json_tokener json_tokener;
+
+/**
+ * Be strict when parsing JSON input.  Use caution with
+ * this flag as what is considered valid may become more
+ * restrictive from one release to the next, causing your
+ * code to fail on previously working input.
+ *
+ * Note that setting this will also effectively disable parsing
+ * of multiple json objects in a single character stream
+ * (e.g. {"foo":123}{"bar":234}); if you want to allow that
+ * also set JSON_TOKENER_ALLOW_TRAILING_CHARS
+ *
+ * This flag is not set by default.
+ *
+ * @see json_tokener_set_flags()
+ */
+#define JSON_TOKENER_STRICT 0x01
+
+/**
+ * Use with JSON_TOKENER_STRICT to allow trailing characters after the
+ * first parsed object.
+ *
+ * @see json_tokener_set_flags()
+ */
+#define JSON_TOKENER_ALLOW_TRAILING_CHARS 0x02
+
+/**
+ * Cause json_tokener_parse_ex() to validate that input is UTF8.
+ * If this flag is specified and validation fails, then
+ * json_tokener_get_error(tok) will return
+ * json_tokener_error_parse_utf8_string
+ *
+ * This flag is not set by default.
+ *
+ * @see json_tokener_set_flags()
+ */
+#define JSON_TOKENER_VALIDATE_UTF8 0x10
+
+/**
+ * Given an error previously returned by json_tokener_get_error(),
+ * return a human readable description of the error.
+ *
+ * @return a generic error message is returned if an invalid error value is provided.
+ */
+JSON_EXPORT const char *json_tokener_error_desc(enum json_tokener_error jerr);
+
+/**
+ * Retrieve the error caused by the last call to json_tokener_parse_ex(),
+ * or json_tokener_success if there is no error.
+ *
+ * When parsing a JSON string in pieces, if the tokener is in the middle
+ * of parsing this will return json_tokener_continue.
+ *
+ * @see json_tokener_error_desc().
+ */
+JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
+
+/**
+ * Allocate a new json_tokener.
+ * When done using that to parse objects, free it with json_tokener_free().
+ * See json_tokener_parse_ex() for usage details.
+ */
+JSON_EXPORT struct json_tokener *json_tokener_new(void);
+
+/**
+ * Allocate a new json_tokener with a custom max nesting depth.
+ * @see JSON_TOKENER_DEFAULT_DEPTH
+ */
+JSON_EXPORT struct json_tokener *json_tokener_new_ex(int depth);
+
+/**
+ * Free a json_tokener previously allocated with json_tokener_new().
+ */
+JSON_EXPORT void json_tokener_free(struct json_tokener *tok);
+
+/**
+ * Reset the state of a json_tokener, to prepare to parse a 
+ * brand new JSON object.
+ */
+JSON_EXPORT void json_tokener_reset(struct json_tokener *tok);
+
+/**
+ * Parse a json_object out of the string `str`.
+ *
+ * If you need more control over how the parsing occurs,
+ * see json_tokener_parse_ex().
+ */
+JSON_EXPORT struct json_object *json_tokener_parse(const char *str);
+
+/**
+ * Parser a json_object out of the string `str`, but if it fails
+ * return the error in `*error`.
+ * @see json_tokener_parse()
+ * @see json_tokener_parse_ex()
+ */
+JSON_EXPORT struct json_object *json_tokener_parse_verbose(const char *str,
+                                                           enum json_tokener_error *error);
+
+/**
+ * Set flags that control how parsing will be done.
+ */
+JSON_EXPORT void json_tokener_set_flags(struct json_tokener *tok, int flags);
+
+/**
+ * Parse a string and return a non-NULL json_object if a valid JSON value
+ * is found.  The string does not need to be a JSON object or array;
+ * it can also be a string, number or boolean value.
+ *
+ * A partial JSON string can be parsed.  If the parsing is incomplete,
+ * NULL will be returned and json_tokener_get_error() will return
+ * json_tokener_continue.
+ * json_tokener_parse_ex() can then be called with additional bytes in str
+ * to continue the parsing.
+ *
+ * If json_tokener_parse_ex() returns NULL and the error is anything other than
+ * json_tokener_continue, a fatal error has occurred and parsing must be
+ * halted.  Then, the tok object must not be reused until json_tokener_reset()
+ * is called.
+ *
+ * When a valid JSON value is parsed, a non-NULL json_object will be
+ * returned, with a reference count of one which belongs to the caller.  Also,
+ * json_tokener_get_error() will return json_tokener_success. Be sure to check
+ * the type with json_object_is_type() or json_object_get_type() before using
+ * the object.
+ *
+ * Trailing characters after the parsed value do not automatically cause an
+ * error.  It is up to the caller to decide whether to treat this as an
+ * error or to handle the additional characters, perhaps by parsing another
+ * json value starting from that point.
+ *
+ * If the caller knows that they are at the end of their input, the length
+ * passed MUST include the final '\0' character, so values with no inherent
+ * end (i.e. numbers) can be properly parsed, rather than just returning
+ * json_tokener_continue.
+ *
+ * Extra characters can be detected by comparing the value returned by
+ * json_tokener_get_parse_end() against
+ * the length of the last len parameter passed in.
+ *
+ * The tokener does \b not maintain an internal buffer so the caller is
+ * responsible for a subsequent call to json_tokener_parse_ex with an 
+ * appropriate str parameter starting with the extra characters.
+ *
+ * This interface is presently not 64-bit clean due to the int len argument
+ * so the function limits the maximum string size to INT32_MAX (2GB).
+ * If the function is called with len == -1 then strlen is called to check
+ * the string length is less than INT32_MAX (2GB)
+ *
+ * Example:
+ * @code
+json_object *jobj = NULL;
+const char *mystring = NULL;
+int stringlen = 0;
+enum json_tokener_error jerr;
+do {
+	mystring = ...  // get JSON string, e.g. read from file, etc...
+	stringlen = strlen(mystring);
+	if (end_of_input)
+		stringlen++;  // Include the '\0' if we know we're at the end of input
+	jobj = json_tokener_parse_ex(tok, mystring, stringlen);
+} while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue);
+if (jerr != json_tokener_success)
+{
+	fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
+	// Handle errors, as appropriate for your application.
+}
+if (json_tokener_get_parse_end(tok) < stringlen)
+{
+	// Handle extra characters after parsed object as desired.
+	// e.g. issue an error, parse another object from that point, etc...
+}
+// Success, use jobj here.
+
+@endcode
+ *
+ * @param tok a json_tokener previously allocated with json_tokener_new()
+ * @param str an string with any valid JSON expression, or portion of.  This does not need to be null terminated.
+ * @param len the length of str
+ */
+JSON_EXPORT struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *str,
+                                                      int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_types.h b/lynq/S300/ap/app/apparms/json-c/json_types.h
new file mode 100755
index 0000000..b7e55ad
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_types.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2020 Eric Hawicz
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+
+#ifndef _json_types_h_
+#define _json_types_h_
+
+/**
+ * @file
+ * @brief Basic types used in a few places in json-c, but you should include "json_object.h" instead.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+struct printbuf;
+
+/**
+ * A structure to use with json_object_object_foreachC() loops.
+ * Contains key, val and entry members.
+ */
+struct json_object_iter
+{
+	char *key;
+	struct json_object *val;
+	struct lh_entry *entry;
+};
+typedef struct json_object_iter json_object_iter;
+
+typedef int json_bool;
+
+/**
+ * @brief The core type for all type of JSON objects handled by json-c
+ */
+typedef struct json_object json_object;
+
+/**
+ * Type of custom user delete functions.  See json_object_set_serializer.
+ */
+typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata);
+
+/**
+ * Type of a custom serialization function.  See json_object_set_serializer.
+ */
+typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level,
+                                           int flags);
+
+/* supported object types */
+
+typedef enum json_type
+{
+	/* If you change this, be sure to update json_type_to_name() too */
+	json_type_null,
+	json_type_boolean,
+	json_type_double,
+	json_type_int,
+	json_type_object,
+	json_type_array,
+	json_type_string
+} json_type;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_util.c b/lynq/S300/ap/app/apparms/json-c/json_util.c
new file mode 100755
index 0000000..0f570f2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_util.c
@@ -0,0 +1,315 @@
+/*
+ * $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+#undef realloc
+
+#include "strerror_override.h"
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <io.h>
+#include <windows.h>
+#endif /* defined(WIN32) */
+
+#if !defined(HAVE_OPEN) && defined(WIN32)
+#define open _open
+#endif
+
+#include "snprintf_compat.h"
+
+#include "debug.h"
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_tokener.h"
+#include "json_util.h"
+#include "printbuf.h"
+
+static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const char *filename);
+
+static char _last_err[256] = "";
+
+const char *json_util_get_last_err(void)
+{
+	if (_last_err[0] == '\0')
+		return NULL;
+	return _last_err;
+}
+
+void _json_c_set_last_err(const char *err_fmt, ...)
+{
+	va_list ap;
+	va_start(ap, err_fmt);
+	// Ignore (attempted) overruns from snprintf
+	(void)vsnprintf(_last_err, sizeof(_last_err), err_fmt, ap);
+	va_end(ap);
+}
+
+struct json_object *json_object_from_fd(int fd)
+{
+	return json_object_from_fd_ex(fd, -1);
+}
+struct json_object *json_object_from_fd_ex(int fd, int in_depth)
+{
+	struct printbuf *pb;
+	struct json_object *obj;
+	char buf[JSON_FILE_BUF_SIZE];
+	ssize_t ret;
+	int depth = JSON_TOKENER_DEFAULT_DEPTH;
+	json_tokener *tok;
+
+	if (!(pb = printbuf_new()))
+	{
+		_json_c_set_last_err("json_object_from_fd_ex: printbuf_new failed\n");
+		return NULL;
+	}
+
+	if (in_depth != -1)
+		depth = in_depth;
+	tok = json_tokener_new_ex(depth);
+	if (!tok)
+	{
+		_json_c_set_last_err(
+		    "json_object_from_fd_ex: unable to allocate json_tokener(depth=%d): %s\n",
+		    depth, strerror(errno));
+		printbuf_free(pb);
+		return NULL;
+	}
+
+	while ((ret = read(fd, buf, sizeof(buf))) > 0)
+	{
+		if (printbuf_memappend(pb, buf, ret) < 0)
+		{
+#if JSON_FILE_BUF_SIZE > INT_MAX
+#error "Can't append more than INT_MAX bytes at a time"
+#endif
+			_json_c_set_last_err(
+		    	"json_object_from_fd_ex: failed to printbuf_memappend after reading %d+%d bytes: %s", printbuf_length(pb), (int)ret, strerror(errno));
+			json_tokener_free(tok);
+			printbuf_free(pb);
+			return NULL;
+		}
+	}
+	if (ret < 0)
+	{
+		_json_c_set_last_err("json_object_from_fd_ex: error reading fd %d: %s\n", fd,
+		                     strerror(errno));
+		json_tokener_free(tok);
+		printbuf_free(pb);
+		return NULL;
+	}
+
+	obj = json_tokener_parse_ex(tok, pb->buf, printbuf_length(pb));
+	if (obj == NULL)
+		_json_c_set_last_err("json_tokener_parse_ex failed: %s\n",
+		                     json_tokener_error_desc(json_tokener_get_error(tok)));
+
+	json_tokener_free(tok);
+	printbuf_free(pb);
+	return obj;
+}
+
+struct json_object *json_object_from_file(const char *filename)
+{
+	struct json_object *obj;
+	int fd;
+
+	if ((fd = open(filename, O_RDONLY)) < 0)
+	{
+		_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n",
+		                     filename, strerror(errno));
+		return NULL;
+	}
+	obj = json_object_from_fd(fd);
+	close(fd);
+	return obj;
+}
+
+/* extended "format and write to file" function */
+
+int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags)
+{
+	int fd, ret;
+	int saved_errno;
+
+	if (!obj)
+	{
+		_json_c_set_last_err("json_object_to_file_ext: object is null\n");
+		return -1;
+	}
+
+	if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0)
+	{
+		_json_c_set_last_err("json_object_to_file_ext: error opening file %s: %s\n",
+		                     filename, strerror(errno));
+		return -1;
+	}
+	ret = _json_object_to_fd(fd, obj, flags, filename);
+	saved_errno = errno;
+	close(fd);
+	errno = saved_errno;
+	return ret;
+}
+
+int json_object_to_fd(int fd, struct json_object *obj, int flags)
+{
+	if (!obj)
+	{
+		_json_c_set_last_err("json_object_to_fd: object is null\n");
+		return -1;
+	}
+
+	return _json_object_to_fd(fd, obj, flags, NULL);
+}
+static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const char *filename)
+{
+	ssize_t ret;
+	const char *json_str;
+	size_t wpos, wsize;
+
+	filename = filename ? filename : "(fd)";
+
+	if (!(json_str = json_object_to_json_string_ext(obj, flags)))
+	{
+		return -1;
+	}
+
+	wsize = strlen(json_str);
+	wpos = 0;
+	while (wpos < wsize)
+	{
+		if ((ret = write(fd, json_str + wpos, wsize - wpos)) < 0)
+		{
+			_json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n",
+			                     filename, strerror(errno));
+			return -1;
+		}
+
+		/* because of the above check for ret < 0, we can safely cast and add */
+		wpos += (size_t)ret;
+	}
+
+	return 0;
+}
+
+// backwards compatible "format and write to file" function
+
+int json_object_to_file(const char *filename, struct json_object *obj)
+{
+	return json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN);
+}
+
+// Deprecated json_parse_double function.  See json_tokener_parse_double instead.
+int json_parse_double(const char *buf, double *retval)
+{
+	char *end;
+	*retval = strtod(buf, &end);
+	return end == buf ? 1 : 0;
+}
+
+int json_parse_int64(const char *buf, int64_t *retval)
+{
+	char *end = NULL;
+	int64_t val;
+
+	errno = 0;
+	val = strtoll(buf, &end, 10);
+	if (end != buf)
+		*retval = val;
+	if ((val == 0 && errno != 0) || (end == buf))
+	{
+		errno = EINVAL;
+		return 1;
+	}
+	return 0;
+}
+
+int json_parse_uint64(const char *buf, uint64_t *retval)
+{
+	char *end = NULL;
+	uint64_t val;
+
+	errno = 0;
+	while (*buf == ' ')
+		buf++;
+	if (*buf == '-')
+		return 1; /* error: uint cannot be negative */
+
+	val = strtoull(buf, &end, 10);
+	if (end != buf)
+		*retval = val;
+	if ((val == 0 && errno != 0) || (end == buf))
+	{
+		errno = EINVAL;
+		return 1;
+	}
+	return 0;
+}
+
+#ifndef HAVE_REALLOC
+void *rpl_realloc(void *p, size_t n)
+{
+	if (n == 0)
+		n = 1;
+	if (p == 0)
+		return malloc(n);
+	return realloc(p, n);
+}
+#endif
+
+#define NELEM(a) (sizeof(a) / sizeof(a[0]))
+/* clang-format off */
+static const char *json_type_name[] = {
+	/* If you change this, be sure to update the enum json_type definition too */
+	"null",
+	"boolean",
+	"double",
+	"int",
+	"object",
+	"array",
+	"string",
+};
+/* clang-format on */
+
+const char *json_type_to_name(enum json_type o_type)
+{
+	int o_type_int = (int)o_type;
+	if (o_type_int < 0 || o_type_int >= (int)NELEM(json_type_name))
+	{
+		_json_c_set_last_err("json_type_to_name: type %d is out of range [0,%u]\n", o_type,
+		                     (unsigned)NELEM(json_type_name));
+		return NULL;
+	}
+	return json_type_name[o_type];
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_util.h b/lynq/S300/ap/app/apparms/json-c/json_util.h
new file mode 100755
index 0000000..62ad688
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_util.h
@@ -0,0 +1,130 @@
+/*
+ * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Miscllaneous utility functions and macros.
+ */
+#ifndef _json_util_h_
+#define _json_util_h_
+
+#include "json_object.h"
+
+#ifndef json_min
+#define json_min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef json_max
+#define json_max(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JSON_FILE_BUF_SIZE 4096
+
+/* utility functions */
+/**
+ * Read the full contents of the given file, then convert it to a
+ * json_object using json_tokener_parse().
+ *
+ * Returns NULL on failure.  See json_util_get_last_err() for details.
+ */
+JSON_EXPORT struct json_object *json_object_from_file(const char *filename);
+
+/**
+ * Create a JSON object from already opened file descriptor.
+ *
+ * This function can be helpful, when you opened the file already,
+ * e.g. when you have a temp file.
+ * Note, that the fd must be readable at the actual position, i.e.
+ * use lseek(fd, 0, SEEK_SET) before.
+ *
+ * The depth argument specifies the maximum object depth to pass to
+ * json_tokener_new_ex().  When depth == -1, JSON_TOKENER_DEFAULT_DEPTH
+ * is used instead.
+ *
+ * Returns NULL on failure.  See json_util_get_last_err() for details.
+ */
+JSON_EXPORT struct json_object *json_object_from_fd_ex(int fd, int depth);
+
+/**
+ * Create a JSON object from an already opened file descriptor, using
+ * the default maximum object depth. (JSON_TOKENER_DEFAULT_DEPTH)
+ *
+ * See json_object_from_fd_ex() for details.
+ */
+JSON_EXPORT struct json_object *json_object_from_fd(int fd);
+
+/**
+ * Equivalent to:
+ *   json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN);
+ *
+ * Returns -1 if something fails.  See json_util_get_last_err() for details.
+ */
+JSON_EXPORT int json_object_to_file(const char *filename, struct json_object *obj);
+
+/**
+ * Open and truncate the given file, creating it if necessary, then
+ * convert the json_object to a string and write it to the file.
+ *
+ * Returns -1 if something fails.  See json_util_get_last_err() for details.
+ */
+JSON_EXPORT int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
+
+/**
+ * Convert the json_object to a string and write it to the file descriptor.
+ * Handles partial writes and will keep writing until done, or an error
+ * occurs.
+ *
+ * @param fd an open, writable file descriptor to write to
+ * @param obj the object to serializer and write
+ * @param flags flags to pass to json_object_to_json_string_ext()
+ * @return -1 if something fails.  See json_util_get_last_err() for details.
+ */
+JSON_EXPORT int json_object_to_fd(int fd, struct json_object *obj, int flags);
+
+/**
+ * Return the last error from various json-c functions, including:
+ * json_object_to_file{,_ext}, json_object_to_fd() or
+ * json_object_from_{file,fd}, or NULL if there is none.
+ */
+JSON_EXPORT const char *json_util_get_last_err(void);
+
+/**
+ * A parsing helper for integer values.  Returns 0 on success,
+ * with the parsed value assigned to *retval.  Overflow/underflow
+ * are NOT considered errors, but errno will be set to ERANGE,
+ * just like the strtol/strtoll functions do.
+ */
+JSON_EXPORT int json_parse_int64(const char *buf, int64_t *retval);
+/**
+ * A parsing help for integer values, providing one extra bit of 
+ * magnitude beyond json_parse_int64().
+ */
+JSON_EXPORT int json_parse_uint64(const char *buf, uint64_t *retval);
+/**
+ * @deprecated
+ */
+JSON_EXPORT int json_parse_double(const char *buf, double *retval);
+
+/**
+ * Return a string describing the type of the object.
+ * e.g. "int", or "object", etc...
+ */
+JSON_EXPORT const char *json_type_to_name(enum json_type o_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/json_visit.c b/lynq/S300/ap/app/apparms/json-c/json_visit.c
new file mode 100755
index 0000000..fb16fa6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_visit.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2016 Eric Haszlakiewicz
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+
+#include <stdio.h>
+
+#include "config.h"
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_visit.h"
+#include "linkhash.h"
+
+static int _json_c_visit(json_object *jso, json_object *parent_jso, const char *jso_key,
+                         size_t *jso_index, json_c_visit_userfunc *userfunc, void *userarg);
+
+int json_c_visit(json_object *jso, int future_flags, json_c_visit_userfunc *userfunc, void *userarg)
+{
+	int ret = _json_c_visit(jso, NULL, NULL, NULL, userfunc, userarg);
+	switch (ret)
+	{
+	case JSON_C_VISIT_RETURN_CONTINUE:
+	case JSON_C_VISIT_RETURN_SKIP:
+	case JSON_C_VISIT_RETURN_POP:
+	case JSON_C_VISIT_RETURN_STOP: return 0;
+	default: return JSON_C_VISIT_RETURN_ERROR;
+	}
+}
+static int _json_c_visit(json_object *jso, json_object *parent_jso, const char *jso_key,
+                         size_t *jso_index, json_c_visit_userfunc *userfunc, void *userarg)
+{
+	int userret = userfunc(jso, 0, parent_jso, jso_key, jso_index, userarg);
+	switch (userret)
+	{
+	case JSON_C_VISIT_RETURN_CONTINUE: break;
+	case JSON_C_VISIT_RETURN_SKIP:
+	case JSON_C_VISIT_RETURN_POP:
+	case JSON_C_VISIT_RETURN_STOP:
+	case JSON_C_VISIT_RETURN_ERROR: return userret;
+	default:
+		fprintf(stderr, "ERROR: invalid return value from json_c_visit userfunc: %d\n",
+		        userret);
+		return JSON_C_VISIT_RETURN_ERROR;
+	}
+
+	switch (json_object_get_type(jso))
+	{
+	case json_type_null:
+	case json_type_boolean:
+	case json_type_double:
+	case json_type_int:
+	case json_type_string:
+		// we already called userfunc above, move on to the next object
+		return JSON_C_VISIT_RETURN_CONTINUE;
+
+	case json_type_object:
+	{
+		json_object_object_foreach(jso, key, child)
+		{
+			userret = _json_c_visit(child, jso, key, NULL, userfunc, userarg);
+			if (userret == JSON_C_VISIT_RETURN_POP)
+				break;
+			if (userret == JSON_C_VISIT_RETURN_STOP ||
+			    userret == JSON_C_VISIT_RETURN_ERROR)
+				return userret;
+			if (userret != JSON_C_VISIT_RETURN_CONTINUE &&
+			    userret != JSON_C_VISIT_RETURN_SKIP)
+			{
+				fprintf(stderr, "INTERNAL ERROR: _json_c_visit returned %d\n",
+				        userret);
+				return JSON_C_VISIT_RETURN_ERROR;
+			}
+		}
+		break;
+	}
+	case json_type_array:
+	{
+		size_t array_len = json_object_array_length(jso);
+		size_t ii;
+		for (ii = 0; ii < array_len; ii++)
+		{
+			json_object *child = json_object_array_get_idx(jso, ii);
+			userret = _json_c_visit(child, jso, NULL, &ii, userfunc, userarg);
+			if (userret == JSON_C_VISIT_RETURN_POP)
+				break;
+			if (userret == JSON_C_VISIT_RETURN_STOP ||
+			    userret == JSON_C_VISIT_RETURN_ERROR)
+				return userret;
+			if (userret != JSON_C_VISIT_RETURN_CONTINUE &&
+			    userret != JSON_C_VISIT_RETURN_SKIP)
+			{
+				fprintf(stderr, "INTERNAL ERROR: _json_c_visit returned %d\n",
+				        userret);
+				return JSON_C_VISIT_RETURN_ERROR;
+			}
+		}
+		break;
+	}
+	default:
+		fprintf(stderr, "INTERNAL ERROR: _json_c_visit found object of unknown type: %d\n",
+		        json_object_get_type(jso));
+		return JSON_C_VISIT_RETURN_ERROR;
+	}
+
+	// Call userfunc for the second type on container types, after all
+	//  members of the container have been visited.
+	// Non-container types will have already returned before this point.
+
+	userret = userfunc(jso, JSON_C_VISIT_SECOND, parent_jso, jso_key, jso_index, userarg);
+	switch (userret)
+	{
+	case JSON_C_VISIT_RETURN_SKIP:
+	case JSON_C_VISIT_RETURN_POP:
+		// These are not really sensible during JSON_C_VISIT_SECOND,
+		// but map them to JSON_C_VISIT_CONTINUE anyway.
+		// FALLTHROUGH
+	case JSON_C_VISIT_RETURN_CONTINUE: return JSON_C_VISIT_RETURN_CONTINUE;
+	case JSON_C_VISIT_RETURN_STOP:
+	case JSON_C_VISIT_RETURN_ERROR: return userret;
+	default:
+		fprintf(stderr, "ERROR: invalid return value from json_c_visit userfunc: %d\n",
+		        userret);
+		return JSON_C_VISIT_RETURN_ERROR;
+	}
+	// NOTREACHED
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/json_visit.h b/lynq/S300/ap/app/apparms/json-c/json_visit.h
new file mode 100755
index 0000000..35c46f5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/json_visit.h
@@ -0,0 +1,101 @@
+
+#ifndef _json_c_json_visit_h_
+#define _json_c_json_visit_h_
+
+/**
+ * @file
+ * @brief Methods for walking a tree of objects.
+ */
+#include "json_object.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int(json_c_visit_userfunc)(json_object *jso, int flags, json_object *parent_jso,
+                                   const char *jso_key, size_t *jso_index, void *userarg);
+
+/**
+ * Visit each object in the JSON hierarchy starting at jso.
+ * For each object, userfunc is called, passing the object and userarg.
+ * If the object has a parent (i.e. anything other than jso itself)
+ * its parent will be passed as parent_jso, and either jso_key or jso_index
+ * will be set, depending on whether the parent is an object or an array.
+ *
+ * Nodes will be visited depth first, but containers (arrays and objects)
+ * will be visited twice, the second time with JSON_C_VISIT_SECOND set in
+ * flags.
+ *
+ * userfunc must return one of the defined return values, to indicate
+ * whether and how to continue visiting nodes, or one of various ways to stop.
+ *
+ * Returns 0 if nodes were visited successfully, even if some were
+ *  intentionally skipped due to what userfunc returned.
+ * Returns <0 if an error occurred during iteration, including if
+ *  userfunc returned JSON_C_VISIT_RETURN_ERROR.
+ */
+JSON_EXPORT int json_c_visit(json_object *jso, int future_flags, json_c_visit_userfunc *userfunc,
+                             void *userarg);
+
+/**
+ * Passed to json_c_visit_userfunc as one of the flags values to indicate
+ * that this is the second time a container (array or object) is being
+ * called, after all of it's members have been iterated over.
+ */
+#define JSON_C_VISIT_SECOND 0x02
+
+/**
+ * This json_c_visit_userfunc return value indicates that iteration
+ * should proceed normally.
+ */
+#define JSON_C_VISIT_RETURN_CONTINUE 0
+
+/**
+ * This json_c_visit_userfunc return value indicates that iteration
+ * over the members of the current object should be skipped.
+ * If the current object isn't a container (array or object), this
+ * is no different than JSON_C_VISIT_RETURN_CONTINUE.
+ */
+#define JSON_C_VISIT_RETURN_SKIP 7547
+
+/**
+ * This json_c_visit_userfunc return value indicates that iteration
+ * of the fields/elements of the <b>containing</b> object should stop
+ * and continue "popped up" a level of the object hierarchy.
+ * For example, returning this when handling arg will result in
+ * arg3 and any other fields being skipped.   The next call to userfunc
+ * will be the JSON_C_VISIT_SECOND call on "foo", followed by a userfunc
+ * call on "bar".
+ * <pre>
+ * {
+ *   "foo": {
+ *     "arg1": 1,
+ *     "arg2": 2,
+ *     "arg3": 3,
+ *     ...
+ *   },
+ *   "bar": {
+ *     ...
+ *   }
+ * }
+ * </pre>
+ */
+#define JSON_C_VISIT_RETURN_POP 767
+
+/**
+ * This json_c_visit_userfunc return value indicates that iteration
+ * should stop immediately, and cause json_c_visit to return success.
+ */
+#define JSON_C_VISIT_RETURN_STOP 7867
+
+/**
+ * This json_c_visit_userfunc return value indicates that iteration
+ * should stop immediately, and cause json_c_visit to return an error.
+ */
+#define JSON_C_VISIT_RETURN_ERROR -1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _json_c_json_visit_h_ */
diff --git a/lynq/S300/ap/app/apparms/json-c/libjson.c b/lynq/S300/ap/app/apparms/json-c/libjson.c
new file mode 100755
index 0000000..83d0a87
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/libjson.c
@@ -0,0 +1,26 @@
+
+/* dummy source file for compatibility purposes */
+
+#if defined(HAVE_CDEFS_H)
+#include <sys/cdefs.h>
+#endif
+
+#ifndef __warn_references
+
+#if defined(__GNUC__) && defined(HAS_GNU_WARNING_LONG)
+
+#define __warn_references(sym, msg) \
+	__asm__(".section .gnu" #sym ",\n\t.ascii \"" msg "\"\n\t.text");
+
+#else
+#define __warn_references(sym, msg) /* nothing */
+#endif
+
+#endif
+
+#include "json_object.h"
+
+__warn_references(json_object_get, "Warning: please link against libjson-c instead of libjson");
+
+/*        __asm__(".section .gnu.warning." __STRING(sym)  \
+            " ; .ascii \"" msg "\" ; .text") */
diff --git a/lynq/S300/ap/app/apparms/json-c/linkhash.c b/lynq/S300/ap/app/apparms/json-c/linkhash.c
new file mode 100755
index 0000000..5e12c51
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/linkhash.c
@@ -0,0 +1,716 @@
+/*
+ * $Id: linkhash.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "config.h"
+
+#include <assert.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_ENDIAN_H
+#include <endian.h> /* attempt to define endianness */
+#endif
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h> /* Get InterlockedCompareExchange */
+#endif
+
+#include "linkhash.h"
+#include "random_seed.h"
+
+/* hash functions */
+static unsigned long lh_char_hash(const void *k);
+static unsigned long lh_perllike_str_hash(const void *k);
+static lh_hash_fn *char_hash_fn = lh_char_hash;
+
+/* comparison functions */
+int lh_char_equal(const void *k1, const void *k2);
+int lh_ptr_equal(const void *k1, const void *k2);
+
+int json_global_set_string_hash(const int h)
+{
+	switch (h)
+	{
+	case JSON_C_STR_HASH_DFLT: char_hash_fn = lh_char_hash; break;
+	case JSON_C_STR_HASH_PERLLIKE: char_hash_fn = lh_perllike_str_hash; break;
+	default: return -1;
+	}
+	return 0;
+}
+
+static unsigned long lh_ptr_hash(const void *k)
+{
+	/* CAW: refactored to be 64bit nice */
+	return (unsigned long)((((ptrdiff_t)k * LH_PRIME) >> 4) & ULONG_MAX);
+}
+
+int lh_ptr_equal(const void *k1, const void *k2)
+{
+	return (k1 == k2);
+}
+
+/*
+ * hashlittle from lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+ * https://burtleburtle.net/bob/c/lookup3.c
+ * minor modifications to make functions static so no symbols are exported
+ * minor modifications to compile with -Werror
+ */
+
+/*
+-------------------------------------------------------------------------------
+lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+
+These are functions for producing 32-bit hashes for hash table lookup.
+hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
+are externally useful functions.  Routines to test the hash are included
+if SELF_TEST is defined.  You can use this free for any purpose.  It's in
+the public domain.  It has no warranty.
+
+You probably want to use hashlittle().  hashlittle() and hashbig()
+hash byte arrays.  hashlittle() is faster than hashbig() on
+little-endian machines.  Intel and AMD are little-endian machines.
+On second thought, you probably want hashlittle2(), which is identical to
+hashlittle() except it returns two 32-bit hashes for the price of one.
+You could implement hashbig2() if you wanted but I haven't bothered here.
+
+If you want to find a hash of, say, exactly 7 integers, do
+  a = i1;  b = i2;  c = i3;
+  mix(a,b,c);
+  a += i4; b += i5; c += i6;
+  mix(a,b,c);
+  a += i7;
+  final(a,b,c);
+then use c as the hash value.  If you have a variable length array of
+4-byte integers to hash, use hashword().  If you have a byte array (like
+a character string), use hashlittle().  If you have several byte arrays, or
+a mix of things, see the comments above hashlittle().
+
+Why is this so big?  I read 12 bytes at a time into 3 4-byte integers,
+then mix those integers.  This is fast (you can do a lot more thorough
+mixing with 12*3 instructions on 3 integers than you can with 3 instructions
+on 1 byte), but shoehorning those bytes into integers efficiently is messy.
+-------------------------------------------------------------------------------
+*/
+
+/*
+ * My best guess at if you are big-endian or little-endian.  This may
+ * need adjustment.
+ */
+#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
+    (defined(i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) ||          \
+     defined(__i686__) || defined(vax) || defined(MIPSEL))
+#define HASH_LITTLE_ENDIAN 1
+#define HASH_BIG_ENDIAN 0
+#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN) || \
+    (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
+#define HASH_LITTLE_ENDIAN 0
+#define HASH_BIG_ENDIAN 1
+#else
+#define HASH_LITTLE_ENDIAN 0
+#define HASH_BIG_ENDIAN 0
+#endif
+
+#define hashsize(n) ((uint32_t)1 << (n))
+#define hashmask(n) (hashsize(n) - 1)
+#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
+
+/*
+-------------------------------------------------------------------------------
+mix -- mix 3 32-bit values reversibly.
+
+This is reversible, so any information in (a,b,c) before mix() is
+still in (a,b,c) after mix().
+
+If four pairs of (a,b,c) inputs are run through mix(), or through
+mix() in reverse, there are at least 32 bits of the output that
+are sometimes the same for one pair and different for another pair.
+This was tested for:
+* pairs that differed by one bit, by two bits, in any combination
+  of top bits of (a,b,c), or in any combination of bottom bits of
+  (a,b,c).
+* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
+  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
+  is commonly produced by subtraction) look like a single 1-bit
+  difference.
+* the base values were pseudorandom, all zero but one bit set, or
+  all zero plus a counter that starts at zero.
+
+Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
+satisfy this are
+    4  6  8 16 19  4
+    9 15  3 18 27 15
+   14  9  3  7 17  3
+Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
+for "differ" defined as + with a one-bit base and a two-bit delta.  I
+used https://burtleburtle.net/bob/hash/avalanche.html to choose
+the operations, constants, and arrangements of the variables.
+
+This does not achieve avalanche.  There are input bits of (a,b,c)
+that fail to affect some output bits of (a,b,c), especially of a.  The
+most thoroughly mixed value is c, but it doesn't really even achieve
+avalanche in c.
+
+This allows some parallelism.  Read-after-writes are good at doubling
+the number of bits affected, so the goal of mixing pulls in the opposite
+direction as the goal of parallelism.  I did what I could.  Rotates
+seem to cost as much as shifts on every machine I could lay my hands
+on, and rotates are much kinder to the top and bottom bits, so I used
+rotates.
+-------------------------------------------------------------------------------
+*/
+/* clang-format off */
+#define mix(a,b,c) \
+{ \
+	a -= c;  a ^= rot(c, 4);  c += b; \
+	b -= a;  b ^= rot(a, 6);  a += c; \
+	c -= b;  c ^= rot(b, 8);  b += a; \
+	a -= c;  a ^= rot(c,16);  c += b; \
+	b -= a;  b ^= rot(a,19);  a += c; \
+	c -= b;  c ^= rot(b, 4);  b += a; \
+}
+/* clang-format on */
+
+/*
+-------------------------------------------------------------------------------
+final -- final mixing of 3 32-bit values (a,b,c) into c
+
+Pairs of (a,b,c) values differing in only a few bits will usually
+produce values of c that look totally different.  This was tested for
+* pairs that differed by one bit, by two bits, in any combination
+  of top bits of (a,b,c), or in any combination of bottom bits of
+  (a,b,c).
+* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
+  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
+  is commonly produced by subtraction) look like a single 1-bit
+  difference.
+* the base values were pseudorandom, all zero but one bit set, or
+  all zero plus a counter that starts at zero.
+
+These constants passed:
+ 14 11 25 16 4 14 24
+ 12 14 25 16 4 14 24
+and these came close:
+  4  8 15 26 3 22 24
+ 10  8 15 26 3 22 24
+ 11  8 15 26 3 22 24
+-------------------------------------------------------------------------------
+*/
+/* clang-format off */
+#define final(a,b,c) \
+{ \
+	c ^= b; c -= rot(b,14); \
+	a ^= c; a -= rot(c,11); \
+	b ^= a; b -= rot(a,25); \
+	c ^= b; c -= rot(b,16); \
+	a ^= c; a -= rot(c,4);  \
+	b ^= a; b -= rot(a,14); \
+	c ^= b; c -= rot(b,24); \
+}
+/* clang-format on */
+
+/*
+-------------------------------------------------------------------------------
+hashlittle() -- hash a variable-length key into a 32-bit value
+  k       : the key (the unaligned variable-length array of bytes)
+  length  : the length of the key, counting by bytes
+  initval : can be any 4-byte value
+Returns a 32-bit value.  Every bit of the key affects every bit of
+the return value.  Two keys differing by one or two bits will have
+totally different hash values.
+
+The best hash table sizes are powers of 2.  There is no need to do
+mod a prime (mod is sooo slow!).  If you need less than 32 bits,
+use a bitmask.  For example, if you need only 10 bits, do
+  h = (h & hashmask(10));
+In which case, the hash table should have hashsize(10) elements.
+
+If you are hashing n strings (uint8_t **)k, do it like this:
+  for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
+
+By Bob Jenkins, 2006.  bob_jenkins@burtleburtle.net.  You may use this
+code any way you wish, private, educational, or commercial.  It's free.
+
+Use for hash table lookup, or anything where one collision in 2^^32 is
+acceptable.  Do NOT use for cryptographic purposes.
+-------------------------------------------------------------------------------
+*/
+
+/* clang-format off */
+static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
+{
+	uint32_t a,b,c; /* internal state */
+	union
+	{
+		const void *ptr;
+		size_t i;
+	} u; /* needed for Mac Powerbook G4 */
+
+	/* Set up the internal state */
+	a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
+
+	u.ptr = key;
+	if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
+		const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
+
+		/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
+		while (length > 12)
+		{
+			a += k[0];
+			b += k[1];
+			c += k[2];
+			mix(a,b,c);
+			length -= 12;
+			k += 3;
+		}
+
+		/*----------------------------- handle the last (probably partial) block */
+		/*
+		 * "k[2]&0xffffff" actually reads beyond the end of the string, but
+		 * then masks off the part it's not allowed to read.  Because the
+		 * string is aligned, the masked-off tail is in the same word as the
+		 * rest of the string.  Every machine with memory protection I've seen
+		 * does it on word boundaries, so is OK with this.  But VALGRIND will
+		 * still catch it and complain.  The masking trick does make the hash
+		 * noticeably faster for short strings (like English words).
+		 * AddressSanitizer is similarly picky about overrunning
+		 * the buffer. (https://clang.llvm.org/docs/AddressSanitizer.html)
+		 */
+#ifdef VALGRIND
+#define PRECISE_MEMORY_ACCESS 1
+#elif defined(__SANITIZE_ADDRESS__) /* GCC's ASAN */
+#define PRECISE_MEMORY_ACCESS 1
+#elif defined(__has_feature)
+#if __has_feature(address_sanitizer) /* Clang's ASAN */
+#define PRECISE_MEMORY_ACCESS 1
+#endif
+#endif
+#ifndef PRECISE_MEMORY_ACCESS
+
+		switch(length)
+		{
+		case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
+		case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
+		case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
+		case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
+		case 8 : b+=k[1]; a+=k[0]; break;
+		case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
+		case 6 : b+=k[1]&0xffff; a+=k[0]; break;
+		case 5 : b+=k[1]&0xff; a+=k[0]; break;
+		case 4 : a+=k[0]; break;
+		case 3 : a+=k[0]&0xffffff; break;
+		case 2 : a+=k[0]&0xffff; break;
+		case 1 : a+=k[0]&0xff; break;
+		case 0 : return c; /* zero length strings require no mixing */
+		}
+
+#else /* make valgrind happy */
+
+		const uint8_t  *k8 = (const uint8_t *)k;
+		switch(length)
+		{
+		case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
+		case 11: c+=((uint32_t)k8[10])<<16;  /* fall through */
+		case 10: c+=((uint32_t)k8[9])<<8;    /* fall through */
+		case 9 : c+=k8[8];                   /* fall through */
+		case 8 : b+=k[1]; a+=k[0]; break;
+		case 7 : b+=((uint32_t)k8[6])<<16;   /* fall through */
+		case 6 : b+=((uint32_t)k8[5])<<8;    /* fall through */
+		case 5 : b+=k8[4];                   /* fall through */
+		case 4 : a+=k[0]; break;
+		case 3 : a+=((uint32_t)k8[2])<<16;   /* fall through */
+		case 2 : a+=((uint32_t)k8[1])<<8;    /* fall through */
+		case 1 : a+=k8[0]; break;
+		case 0 : return c;
+		}
+
+#endif /* !valgrind */
+
+	}
+	else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0))
+	{
+		const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
+		const uint8_t  *k8;
+
+		/*--------------- all but last block: aligned reads and different mixing */
+		while (length > 12)
+		{
+			a += k[0] + (((uint32_t)k[1])<<16);
+			b += k[2] + (((uint32_t)k[3])<<16);
+			c += k[4] + (((uint32_t)k[5])<<16);
+			mix(a,b,c);
+			length -= 12;
+			k += 6;
+		}
+
+		/*----------------------------- handle the last (probably partial) block */
+		k8 = (const uint8_t *)k;
+		switch(length)
+		{
+		case 12: c+=k[4]+(((uint32_t)k[5])<<16);
+			 b+=k[2]+(((uint32_t)k[3])<<16);
+			 a+=k[0]+(((uint32_t)k[1])<<16);
+			 break;
+		case 11: c+=((uint32_t)k8[10])<<16;     /* fall through */
+		case 10: c+=k[4];
+			 b+=k[2]+(((uint32_t)k[3])<<16);
+			 a+=k[0]+(((uint32_t)k[1])<<16);
+			 break;
+		case 9 : c+=k8[8];                      /* fall through */
+		case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
+			 a+=k[0]+(((uint32_t)k[1])<<16);
+			 break;
+		case 7 : b+=((uint32_t)k8[6])<<16;      /* fall through */
+		case 6 : b+=k[2];
+			 a+=k[0]+(((uint32_t)k[1])<<16);
+			 break;
+		case 5 : b+=k8[4];                      /* fall through */
+		case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
+			 break;
+		case 3 : a+=((uint32_t)k8[2])<<16;      /* fall through */
+		case 2 : a+=k[0];
+			 break;
+		case 1 : a+=k8[0];
+			 break;
+		case 0 : return c;                     /* zero length requires no mixing */
+		}
+
+	}
+	else
+	{
+		/* need to read the key one byte at a time */
+		const uint8_t *k = (const uint8_t *)key;
+
+		/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
+		while (length > 12)
+		{
+			a += k[0];
+			a += ((uint32_t)k[1])<<8;
+			a += ((uint32_t)k[2])<<16;
+			a += ((uint32_t)k[3])<<24;
+			b += k[4];
+			b += ((uint32_t)k[5])<<8;
+			b += ((uint32_t)k[6])<<16;
+			b += ((uint32_t)k[7])<<24;
+			c += k[8];
+			c += ((uint32_t)k[9])<<8;
+			c += ((uint32_t)k[10])<<16;
+			c += ((uint32_t)k[11])<<24;
+			mix(a,b,c);
+			length -= 12;
+			k += 12;
+		}
+
+		/*-------------------------------- last block: affect all 32 bits of (c) */
+		switch(length) /* all the case statements fall through */
+		{
+		case 12: c+=((uint32_t)k[11])<<24; /* FALLTHRU */
+		case 11: c+=((uint32_t)k[10])<<16; /* FALLTHRU */
+		case 10: c+=((uint32_t)k[9])<<8; /* FALLTHRU */
+		case 9 : c+=k[8]; /* FALLTHRU */
+		case 8 : b+=((uint32_t)k[7])<<24; /* FALLTHRU */
+		case 7 : b+=((uint32_t)k[6])<<16; /* FALLTHRU */
+		case 6 : b+=((uint32_t)k[5])<<8; /* FALLTHRU */
+		case 5 : b+=k[4]; /* FALLTHRU */
+		case 4 : a+=((uint32_t)k[3])<<24; /* FALLTHRU */
+		case 3 : a+=((uint32_t)k[2])<<16; /* FALLTHRU */
+		case 2 : a+=((uint32_t)k[1])<<8; /* FALLTHRU */
+		case 1 : a+=k[0];
+			 break;
+		case 0 : return c;
+		}
+	}
+
+	final(a,b,c);
+	return c;
+}
+/* clang-format on */
+
+/* a simple hash function similar to what perl does for strings.
+ * for good results, the string should not be excessively large.
+ */
+static unsigned long lh_perllike_str_hash(const void *k)
+{
+	const char *rkey = (const char *)k;
+	unsigned hashval = 1;
+
+	while (*rkey)
+		hashval = hashval * 33 + *rkey++;
+
+	return hashval;
+}
+
+static unsigned long lh_char_hash(const void *k)
+{
+#if defined _MSC_VER || defined __MINGW32__
+#define RANDOM_SEED_TYPE LONG
+#else
+#define RANDOM_SEED_TYPE int
+#endif
+	static volatile RANDOM_SEED_TYPE random_seed = -1;
+
+	if (random_seed == -1)
+	{
+		RANDOM_SEED_TYPE seed;
+		/* we can't use -1 as it is the uninitialized sentinel */
+		while ((seed = json_c_get_random_seed()) == -1) {}
+#if SIZEOF_INT == 8 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#define USE_SYNC_COMPARE_AND_SWAP 1
+#endif
+#if SIZEOF_INT == 4 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#define USE_SYNC_COMPARE_AND_SWAP 1
+#endif
+#if SIZEOF_INT == 2 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+#define USE_SYNC_COMPARE_AND_SWAP 1
+#endif
+#if defined USE_SYNC_COMPARE_AND_SWAP
+		(void)__sync_val_compare_and_swap(&random_seed, -1, seed);
+#elif defined _MSC_VER || defined __MINGW32__
+		InterlockedCompareExchange(&random_seed, seed, -1);
+#else
+		//#warning "racy random seed initialization if used by multiple threads"
+		random_seed = seed; /* potentially racy */
+#endif
+	}
+
+	return hashlittle((const char *)k, strlen((const char *)k), (uint32_t)random_seed);
+}
+
+int lh_char_equal(const void *k1, const void *k2)
+{
+	return (strcmp((const char *)k1, (const char *)k2) == 0);
+}
+
+struct lh_table *lh_table_new(int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn,
+                              lh_equal_fn *equal_fn)
+{
+	int i;
+	struct lh_table *t;
+
+	/* Allocate space for elements to avoid divisions by zero. */
+	assert(size > 0);
+	t = (struct lh_table *)calloc(1, sizeof(struct lh_table));
+	if (!t)
+		return NULL;
+
+	t->count = 0;
+	t->size = size;
+	t->table = (struct lh_entry *)calloc(size, sizeof(struct lh_entry));
+	if (!t->table)
+	{
+		free(t);
+		return NULL;
+	}
+	t->free_fn = free_fn;
+	t->hash_fn = hash_fn;
+	t->equal_fn = equal_fn;
+	for (i = 0; i < size; i++)
+		t->table[i].k = LH_EMPTY;
+	return t;
+}
+
+struct lh_table *lh_kchar_table_new(int size, lh_entry_free_fn *free_fn)
+{
+	return lh_table_new(size, free_fn, char_hash_fn, lh_char_equal);
+}
+
+struct lh_table *lh_kptr_table_new(int size, lh_entry_free_fn *free_fn)
+{
+	return lh_table_new(size, free_fn, lh_ptr_hash, lh_ptr_equal);
+}
+
+int lh_table_resize(struct lh_table *t, int new_size)
+{
+	struct lh_table *new_t;
+	struct lh_entry *ent;
+
+	new_t = lh_table_new(new_size, NULL, t->hash_fn, t->equal_fn);
+	if (new_t == NULL)
+		return -1;
+
+	for (ent = t->head; ent != NULL; ent = ent->next)
+	{
+		unsigned long h = lh_get_hash(new_t, ent->k);
+		unsigned int opts = 0;
+		if (ent->k_is_constant)
+			opts = JSON_C_OBJECT_ADD_CONSTANT_KEY;
+		if (lh_table_insert_w_hash(new_t, ent->k, ent->v, h, opts) != 0)
+		{
+			lh_table_free(new_t);
+			return -1;
+		}
+	}
+	free(t->table);
+	t->table = new_t->table;
+	t->size = new_size;
+	t->head = new_t->head;
+	t->tail = new_t->tail;
+	free(new_t);
+
+	return 0;
+}
+
+void lh_table_free(struct lh_table *t)
+{
+	struct lh_entry *c;
+	if (t->free_fn)
+	{
+		for (c = t->head; c != NULL; c = c->next)
+			t->free_fn(c);
+	}
+	free(t->table);
+	free(t);
+}
+
+int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, const unsigned long h,
+                           const unsigned opts)
+{
+	unsigned long n;
+
+	if (t->count >= t->size * LH_LOAD_FACTOR)
+	{
+		/* Avoid signed integer overflow with large tables. */
+		int new_size = (t->size > INT_MAX / 2) ? INT_MAX : (t->size * 2);
+		if (t->size == INT_MAX || lh_table_resize(t, new_size) != 0)
+			return -1;
+	}
+
+	n = h % t->size;
+
+	while (1)
+	{
+		if (t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED)
+			break;
+		if ((int)++n == t->size)
+			n = 0;
+	}
+
+	t->table[n].k = k;
+	t->table[n].k_is_constant = (opts & JSON_C_OBJECT_ADD_CONSTANT_KEY);
+	t->table[n].v = v;
+	t->count++;
+
+	if (t->head == NULL)
+	{
+		t->head = t->tail = &t->table[n];
+		t->table[n].next = t->table[n].prev = NULL;
+	}
+	else
+	{
+		t->tail->next = &t->table[n];
+		t->table[n].prev = t->tail;
+		t->table[n].next = NULL;
+		t->tail = &t->table[n];
+	}
+
+	return 0;
+}
+int lh_table_insert(struct lh_table *t, const void *k, const void *v)
+{
+	return lh_table_insert_w_hash(t, k, v, lh_get_hash(t, k), 0);
+}
+
+struct lh_entry *lh_table_lookup_entry_w_hash(struct lh_table *t, const void *k,
+                                              const unsigned long h)
+{
+	unsigned long n = h % t->size;
+	int count = 0;
+
+	while (count < t->size)
+	{
+		if (t->table[n].k == LH_EMPTY)
+			return NULL;
+		if (t->table[n].k != LH_FREED && t->equal_fn(t->table[n].k, k))
+			return &t->table[n];
+		if ((int)++n == t->size)
+			n = 0;
+		count++;
+	}
+	return NULL;
+}
+
+struct lh_entry *lh_table_lookup_entry(struct lh_table *t, const void *k)
+{
+	return lh_table_lookup_entry_w_hash(t, k, lh_get_hash(t, k));
+}
+
+json_bool lh_table_lookup_ex(struct lh_table *t, const void *k, void **v)
+{
+	struct lh_entry *e = lh_table_lookup_entry(t, k);
+	if (e != NULL)
+	{
+		if (v != NULL)
+			*v = lh_entry_v(e);
+		return 1; /* key found */
+	}
+	if (v != NULL)
+		*v = NULL;
+	return 0; /* key not found */
+}
+
+int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e)
+{
+	/* CAW: fixed to be 64bit nice, still need the crazy negative case... */
+	ptrdiff_t n = (ptrdiff_t)(e - t->table);
+
+	/* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */
+	if (n < 0)
+	{
+		return -2;
+	}
+
+	if (t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED)
+		return -1;
+	t->count--;
+	if (t->free_fn)
+		t->free_fn(e);
+	t->table[n].v = NULL;
+	t->table[n].k = LH_FREED;
+	if (t->tail == &t->table[n] && t->head == &t->table[n])
+	{
+		t->head = t->tail = NULL;
+	}
+	else if (t->head == &t->table[n])
+	{
+		t->head->next->prev = NULL;
+		t->head = t->head->next;
+	}
+	else if (t->tail == &t->table[n])
+	{
+		t->tail->prev->next = NULL;
+		t->tail = t->tail->prev;
+	}
+	else
+	{
+		t->table[n].prev->next = t->table[n].next;
+		t->table[n].next->prev = t->table[n].prev;
+	}
+	t->table[n].next = t->table[n].prev = NULL;
+	return 0;
+}
+
+int lh_table_delete(struct lh_table *t, const void *k)
+{
+	struct lh_entry *e = lh_table_lookup_entry(t, k);
+	if (!e)
+		return -1;
+	return lh_table_delete_entry(t, e);
+}
+
+int lh_table_length(struct lh_table *t)
+{
+	return t->count;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/linkhash.h b/lynq/S300/ap/app/apparms/json-c/linkhash.h
new file mode 100755
index 0000000..5e5e240
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/linkhash.h
@@ -0,0 +1,447 @@
+/*
+ * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Internal methods for working with json_type_object objects.  Although
+ *        this is exposed by the json_object_get_object() function and within the
+ *        json_object_iter type, it is not recommended for direct use.
+ */
+#ifndef _json_c_linkhash_h_
+#define _json_c_linkhash_h_
+
+#include "json_object.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * golden prime used in hash functions
+ */
+#define LH_PRIME 0x9e370001UL
+
+/**
+ * The fraction of filled hash buckets until an insert will cause the table
+ * to be resized.
+ * This can range from just above 0 up to 1.0.
+ */
+#define LH_LOAD_FACTOR 0.66
+
+/**
+ * sentinel pointer value for empty slots
+ */
+#define LH_EMPTY (void *)-1
+
+/**
+ * sentinel pointer value for freed slots
+ */
+#define LH_FREED (void *)-2
+
+/**
+ * default string hash function
+ */
+#define JSON_C_STR_HASH_DFLT 0
+
+/**
+ * perl-like string hash function
+ */
+#define JSON_C_STR_HASH_PERLLIKE 1
+
+/**
+ * This function sets the hash function to be used for strings.
+ * Must be one of the JSON_C_STR_HASH_* values.
+ * @returns 0 - ok, -1 if parameter was invalid
+ */
+int json_global_set_string_hash(const int h);
+
+struct lh_entry;
+
+/**
+ * callback function prototypes
+ */
+typedef void(lh_entry_free_fn)(struct lh_entry *e);
+/**
+ * callback function prototypes
+ */
+typedef unsigned long(lh_hash_fn)(const void *k);
+/**
+ * callback function prototypes
+ */
+typedef int(lh_equal_fn)(const void *k1, const void *k2);
+
+/**
+ * An entry in the hash table.  Outside of linkhash.c, treat this as opaque.
+ */
+struct lh_entry
+{
+	/**
+	 * The key.
+	 * @deprecated Use lh_entry_k() instead of accessing this directly.
+	 */
+	const void *k;
+	/**
+	 * A flag for users of linkhash to know whether or not they
+	 * need to free k.
+	 * @deprecated use lh_entry_k_is_constant() instead.
+	 */
+	int k_is_constant;
+	/**
+	 * The value.
+	 * @deprecated Use lh_entry_v() instead of accessing this directly.
+	 */
+	const void *v;
+	/**
+	 * The next entry.
+	 * @deprecated Use lh_entry_next() instead of accessing this directly.
+	 */
+	struct lh_entry *next;
+	/**
+	 * The previous entry.
+	 * @deprecated Use lh_entry_prev() instead of accessing this directly.
+	 */
+	struct lh_entry *prev;
+};
+
+/**
+ * The hash table structure.  Outside of linkhash.c, treat this as opaque.
+ */
+struct lh_table
+{
+	/**
+	 * Size of our hash.
+	 * @deprecated do not use outside of linkhash.c
+	 */
+	int size;
+	/**
+	 * Numbers of entries.
+	 * @deprecated Use lh_table_length() instead.
+	 */
+	int count;
+
+	/**
+	 * The first entry.
+	 * @deprecated Use lh_table_head() instead.
+	 */
+	struct lh_entry *head;
+
+	/**
+	 * The last entry.
+	 * @deprecated Do not use, may be removed in a future release.
+	 */
+	struct lh_entry *tail;
+
+	/**
+	 * Internal storage of the actual table of entries.
+	 * @deprecated do not use outside of linkhash.c
+	 */
+	struct lh_entry *table;
+
+	/**
+	 * A pointer to the function responsible for freeing an entry.
+	 * @deprecated do not use outside of linkhash.c
+	 */
+	lh_entry_free_fn *free_fn;
+	/**
+	 * @deprecated do not use outside of linkhash.c
+	 */
+	lh_hash_fn *hash_fn;
+	/**
+	 * @deprecated do not use outside of linkhash.c
+	 */
+	lh_equal_fn *equal_fn;
+};
+typedef struct lh_table lh_table;
+
+/**
+ * Convenience list iterator.
+ */
+#define lh_foreach(table, entry) for (entry = lh_table_head(table); entry; entry = lh_entry_next(entry))
+
+/**
+ * lh_foreach_safe allows calling of deletion routine while iterating.
+ *
+ * @param table a struct lh_table * to iterate over
+ * @param entry a struct lh_entry * variable to hold each element
+ * @param tmp a struct lh_entry * variable to hold a temporary pointer to the next element
+ */
+#define lh_foreach_safe(table, entry, tmp) \
+	for (entry = lh_table_head(table); entry && ((tmp = lh_entry_next(entry)) || 1); entry = tmp)
+
+/**
+ * Create a new linkhash table.
+ *
+ * @param size initial table size. The table is automatically resized
+ * although this incurs a performance penalty.
+ * @param free_fn callback function used to free memory for entries
+ * when lh_table_free or lh_table_delete is called.
+ * If NULL is provided, then memory for keys and values
+ * must be freed by the caller.
+ * @param hash_fn  function used to hash keys. 2 standard ones are defined:
+ * lh_ptr_hash and lh_char_hash for hashing pointer values
+ * and C strings respectively.
+ * @param equal_fn comparison function to compare keys. 2 standard ones defined:
+ * lh_ptr_hash and lh_char_hash for comparing pointer values
+ * and C strings respectively.
+ * @return On success, a pointer to the new linkhash table is returned.
+ * 	On error, a null pointer is returned.
+ */
+extern struct lh_table *lh_table_new(int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn,
+                                     lh_equal_fn *equal_fn);
+
+/**
+ * Convenience function to create a new linkhash table with char keys.
+ *
+ * @param size initial table size.
+ * @param free_fn callback function used to free memory for entries.
+ * @return On success, a pointer to the new linkhash table is returned.
+ * 	On error, a null pointer is returned.
+ */
+extern struct lh_table *lh_kchar_table_new(int size, lh_entry_free_fn *free_fn);
+
+/**
+ * Convenience function to create a new linkhash table with ptr keys.
+ *
+ * @param size initial table size.
+ * @param free_fn callback function used to free memory for entries.
+ * @return On success, a pointer to the new linkhash table is returned.
+ * 	On error, a null pointer is returned.
+ */
+extern struct lh_table *lh_kptr_table_new(int size, lh_entry_free_fn *free_fn);
+
+/**
+ * Free a linkhash table.
+ *
+ * If a lh_entry_free_fn callback free function was provided then it is
+ * called for all entries in the table.
+ *
+ * @param t table to free.
+ */
+extern void lh_table_free(struct lh_table *t);
+
+/**
+ * Insert a record into the table.
+ *
+ * @param t the table to insert into.
+ * @param k a pointer to the key to insert.
+ * @param v a pointer to the value to insert.
+ *
+ * @return On success, <code>0</code> is returned.
+ * 	On error, a negative value is returned.
+ */
+extern int lh_table_insert(struct lh_table *t, const void *k, const void *v);
+
+/**
+ * Insert a record into the table using a precalculated key hash.
+ *
+ * The hash h, which should be calculated with lh_get_hash() on k, is provided by
+ *  the caller, to allow for optimization when multiple operations with the same
+ *  key are known to be needed.
+ *
+ * @param t the table to insert into.
+ * @param k a pointer to the key to insert.
+ * @param v a pointer to the value to insert.
+ * @param h hash value of the key to insert
+ * @param opts if set to JSON_C_OBJECT_ADD_CONSTANT_KEY, sets lh_entry.k_is_constant
+ *             so t's free function knows to avoid freeing the key.
+ */
+extern int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v,
+                                  const unsigned long h, const unsigned opts);
+
+/**
+ * Lookup a record in the table.
+ *
+ * @param t the table to lookup
+ * @param k a pointer to the key to lookup
+ * @return a pointer to the record structure of the value or NULL if it does not exist.
+ */
+extern struct lh_entry *lh_table_lookup_entry(struct lh_table *t, const void *k);
+
+/**
+ * Lookup a record in the table using a precalculated key hash.
+ *
+ * The hash h, which should be calculated with lh_get_hash() on k, is provided by
+ *  the caller, to allow for optimization when multiple operations with the same
+ *  key are known to be needed.
+ *
+ * @param t the table to lookup
+ * @param k a pointer to the key to lookup
+ * @param h hash value of the key to lookup
+ * @return a pointer to the record structure of the value or NULL if it does not exist.
+ */
+extern struct lh_entry *lh_table_lookup_entry_w_hash(struct lh_table *t, const void *k,
+                                                     const unsigned long h);
+
+/**
+ * Lookup a record in the table.
+ *
+ * @param t the table to lookup
+ * @param k a pointer to the key to lookup
+ * @param v a pointer to a where to store the found value (set to NULL if it doesn't exist).
+ * @return whether or not the key was found
+ */
+extern json_bool lh_table_lookup_ex(struct lh_table *t, const void *k, void **v);
+
+/**
+ * Delete a record from the table.
+ *
+ * If a callback free function is provided then it is called for the
+ * for the item being deleted.
+ * @param t the table to delete from.
+ * @param e a pointer to the entry to delete.
+ * @return 0 if the item was deleted.
+ * @return -1 if it was not found.
+ */
+extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
+
+/**
+ * Delete a record from the table.
+ *
+ * If a callback free function is provided then it is called for the
+ * for the item being deleted.
+ * @param t the table to delete from.
+ * @param k a pointer to the key to delete.
+ * @return 0 if the item was deleted.
+ * @return -1 if it was not found.
+ */
+extern int lh_table_delete(struct lh_table *t, const void *k);
+
+/**
+ * Return the number of entries in the table.
+ */
+extern int lh_table_length(struct lh_table *t);
+
+/**
+ * Resizes the specified table.
+ *
+ * @param t Pointer to table to resize.
+ * @param new_size New table size. Must be positive.
+ *
+ * @return On success, <code>0</code> is returned.
+ * 	On error, a negative value is returned.
+ */
+int lh_table_resize(struct lh_table *t, int new_size);
+
+/**
+ * @deprecated Don't use this outside of linkhash.h:
+ */
+#if (defined(AIX_CC) || (defined(_MSC_VER) && (_MSC_VER <= 1800)) )
+/* VS2010 can't handle inline funcs, so skip it there */
+#define _LH_INLINE
+#else
+#define _LH_INLINE inline
+#endif
+
+/**
+ * Return the first entry in the lh_table.
+ * @see lh_entry_next()
+ */
+static _LH_INLINE struct lh_entry *lh_table_head(const lh_table *t)
+{
+	return t->head;
+}
+
+/**
+ * Calculate the hash of a key for a given table.
+ *
+ * This is an extension to support functions that need to calculate
+ * the hash several times and allows them to do it just once and then pass
+ * in the hash to all utility functions. Depending on use case, this can be a
+ * considerable performance improvement.
+ * @param t the table (used to obtain hash function)
+ * @param k a pointer to the key to lookup
+ * @return the key's hash
+ */
+static _LH_INLINE unsigned long lh_get_hash(const struct lh_table *t, const void *k)
+{
+	return t->hash_fn(k);
+}
+
+
+/**
+ * @deprecated Don't use this outside of linkhash.h:
+ */
+#ifdef __UNCONST
+#define _LH_UNCONST(a) __UNCONST(a)
+#else
+#define _LH_UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
+#endif
+
+/**
+ * Return a non-const version of lh_entry.k.
+ *
+ * lh_entry.k is const to indicate and help ensure that linkhash itself doesn't modify
+ * it, but callers are allowed to do what they want with it.
+ * @see lh_entry_k_is_constant()
+ */
+static _LH_INLINE void *lh_entry_k(const struct lh_entry *e)
+{
+	return _LH_UNCONST(e->k);
+}
+
+/**
+ * Returns 1 if the key for the given entry is constant, and thus
+ *  does not need to be freed when the lh_entry is freed.
+ * @see lh_table_insert_w_hash()
+ */
+static _LH_INLINE int lh_entry_k_is_constant(const struct lh_entry *e)
+{
+	return e->k_is_constant;
+}
+
+/**
+ * Return a non-const version of lh_entry.v.
+ *
+ * v is const to indicate and help ensure that linkhash itself doesn't modify
+ * it, but callers are allowed to do what they want with it.
+ */
+static _LH_INLINE void *lh_entry_v(const struct lh_entry *e)
+{
+	return _LH_UNCONST(e->v);
+}
+
+/**
+ * Change the value for an entry.  The caller is responsible for freeing
+ *  the previous value.
+ */
+static _LH_INLINE void lh_entry_set_val(struct lh_entry *e, void *newval)
+{
+	e->v = newval;
+}
+
+/**
+ * Return the next element, or NULL if there is no next element.
+ * @see lh_table_head()
+ * @see lh_entry_prev()
+ */
+static _LH_INLINE struct lh_entry *lh_entry_next(const struct lh_entry *e)
+{
+	return e->next;
+}
+
+/**
+ * Return the previous element, or NULL if there is no previous element.
+ * @see lh_table_head()
+ * @see lh_entry_next()
+ */
+static _LH_INLINE struct lh_entry *lh_entry_prev(const struct lh_entry *e)
+{
+	return e->prev;
+}
+
+#undef _LH_INLINE
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/math_compat.h b/lynq/S300/ap/app/apparms/json-c/math_compat.h
new file mode 100755
index 0000000..2382fe1
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/math_compat.h
@@ -0,0 +1,43 @@
+#ifndef __math_compat_h
+#define __math_compat_h
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+/* Define isnan, isinf, infinity and nan on Windows/MSVC */
+
+#ifndef HAVE_DECL_ISNAN
+#ifdef HAVE_DECL__ISNAN
+#include <float.h>
+#define isnan(x) _isnan(x)
+#else
+/* On platforms like AIX and "IBM i" we need to provide our own isnan */
+#define isnan(x) ((x) != (x))
+#endif
+#endif
+
+#ifndef HAVE_DECL_ISINF
+#ifdef HAVE_DECL__FINITE
+#include <float.h>
+#define isinf(x) (!_finite(x))
+#else
+#include <float.h>
+/* On platforms like AIX and "IBM i" we need to provide our own isinf */
+#define isinf(x) ((x) < -DBL_MAX || (x) > DBL_MAX)
+#endif
+#endif
+
+#ifndef HAVE_DECL_INFINITY
+#include <float.h>
+#define INFINITY (DBL_MAX + DBL_MAX)
+#define HAVE_DECL_INFINITY
+#endif
+
+#ifndef HAVE_DECL_NAN
+#define NAN (INFINITY - INFINITY)
+#define HAVE_DECL_NAN
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/printbuf.c b/lynq/S300/ap/app/apparms/json-c/printbuf.c
new file mode 100755
index 0000000..12d3b33
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/printbuf.c
@@ -0,0 +1,192 @@
+/*
+ * $Id: printbuf.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ *
+ * Copyright (c) 2008-2009 Yahoo! Inc.  All rights reserved.
+ * The copyrights to the contents of this file are licensed under the MIT License
+ * (https://www.opensource.org/licenses/mit-license.php)
+ */
+
+#include "config.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#else /* !HAVE_STDARG_H */
+#error Not enough var arg support!
+#endif /* HAVE_STDARG_H */
+
+#include "debug.h"
+#include "printbuf.h"
+#include "snprintf_compat.h"
+#include "vasprintf_compat.h"
+
+static int printbuf_extend(struct printbuf *p, int min_size);
+
+struct printbuf *printbuf_new(void)
+{
+	struct printbuf *p;
+
+	p = (struct printbuf *)calloc(1, sizeof(struct printbuf));
+	if (!p)
+		return NULL;
+	p->size = 32;
+	p->bpos = 0;
+	if (!(p->buf = (char *)malloc(p->size)))
+	{
+		free(p);
+		return NULL;
+	}
+	p->buf[0] = '\0';
+	return p;
+}
+
+/**
+ * Extend the buffer p so it has a size of at least min_size.
+ *
+ * If the current size is large enough, nothing is changed.
+ *
+ * If extension failed, errno is set to indicate the error.
+ *
+ * Note: this does not check the available space!  The caller
+ *  is responsible for performing those calculations.
+ */
+static int printbuf_extend(struct printbuf *p, int min_size)
+{
+	char *t;
+	int new_size;
+
+	if (p->size >= min_size)
+		return 0;
+	/* Prevent signed integer overflows with large buffers. */
+	if (min_size > INT_MAX - 8)
+	{
+		errno = EFBIG;
+		return -1;
+	}
+	if (p->size > INT_MAX / 2)
+		new_size = min_size + 8;
+	else {
+		new_size = p->size * 2;
+		if (new_size < min_size + 8)
+			new_size = min_size + 8;
+	}
+#ifdef PRINTBUF_DEBUG
+	MC_DEBUG("printbuf_extend: realloc "
+	         "bpos=%d min_size=%d old_size=%d new_size=%d\n",
+	         p->bpos, min_size, p->size, new_size);
+#endif /* PRINTBUF_DEBUG */
+	if (!(t = (char *)realloc(p->buf, new_size)))
+		return -1;
+	p->size = new_size;
+	p->buf = t;
+	return 0;
+}
+
+int printbuf_memappend(struct printbuf *p, const char *buf, int size)
+{
+	/* Prevent signed integer overflows with large buffers. */
+	if (size < 0 || size > INT_MAX - p->bpos - 1)
+	{
+		errno = EFBIG;
+		return -1;
+	}
+	if (p->size <= p->bpos + size + 1)
+	{
+		if (printbuf_extend(p, p->bpos + size + 1) < 0)
+			return -1;
+	}
+	memcpy(p->buf + p->bpos, buf, size);
+	p->bpos += size;
+	p->buf[p->bpos] = '\0';
+	return size;
+}
+
+int printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len)
+{
+	int size_needed;
+
+	if (offset == -1)
+		offset = pb->bpos;
+	/* Prevent signed integer overflows with large buffers. */
+	if (len < 0 || offset < -1 || len > INT_MAX - offset)
+	{
+		errno = EFBIG;
+		return -1;
+	}
+	size_needed = offset + len;
+	if (pb->size < size_needed)
+	{
+		if (printbuf_extend(pb, size_needed) < 0)
+			return -1;
+	}
+
+	if (pb->bpos < offset)
+		memset(pb->buf + pb->bpos, '\0', offset - pb->bpos);
+	memset(pb->buf + offset, charvalue, len);
+	if (pb->bpos < size_needed)
+		pb->bpos = size_needed;
+
+	return 0;
+}
+
+int sprintbuf(struct printbuf *p, const char *msg, ...)
+{
+	va_list ap;
+	char *t;
+	int size;
+	char buf[128];
+
+	/* use stack buffer first */
+	va_start(ap, msg);
+	size = vsnprintf(buf, 128, msg, ap);
+	va_end(ap);
+	/* if string is greater than stack buffer, then use dynamic string
+	 * with vasprintf.  Note: some implementations of vsnprintf return -1
+	 * if output is truncated whereas some return the number of bytes that
+	 * would have been written - this code handles both cases.
+	 */
+	if (size < 0 || size > 127)
+	{
+		va_start(ap, msg);
+		if ((size = vasprintf(&t, msg, ap)) < 0)
+		{
+			va_end(ap);
+			return -1;
+		}
+		va_end(ap);
+		size = printbuf_memappend(p, t, size);
+		free(t);
+	}
+	else
+	{
+		size = printbuf_memappend(p, buf, size);
+	}
+	return size;
+}
+
+void printbuf_reset(struct printbuf *p)
+{
+	p->buf[0] = '\0';
+	p->bpos = 0;
+}
+
+void printbuf_free(struct printbuf *p)
+{
+	if (p)
+	{
+		free(p->buf);
+		free(p);
+	}
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/printbuf.h b/lynq/S300/ap/app/apparms/json-c/printbuf.h
new file mode 100755
index 0000000..8dbf2c6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/printbuf.h
@@ -0,0 +1,131 @@
+/*
+ * $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ *
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ *
+ * Copyright (c) 2008-2009 Yahoo! Inc.  All rights reserved.
+ * The copyrights to the contents of this file are licensed under the MIT License
+ * (https://www.opensource.org/licenses/mit-license.php)
+ */
+
+/**
+ * @file
+ * @brief Internal string buffer handling.  Unless you're writing a
+ *        json_object_to_json_string_fn implementation for use with
+ *        json_object_set_serializer() direct use of this is not
+ *        recommended.
+ */
+#ifndef _json_c_printbuf_h_
+#define _json_c_printbuf_h_
+
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct printbuf
+{
+	char *buf;
+	int bpos;
+	int size;
+};
+typedef struct printbuf printbuf;
+
+JSON_EXPORT struct printbuf *printbuf_new(void);
+
+/* As an optimization, printbuf_memappend_fast() is defined as a macro
+ * that handles copying data if the buffer is large enough; otherwise
+ * it invokes printbuf_memappend() which performs the heavy
+ * lifting of realloc()ing the buffer and copying data.
+ *
+ * Your code should not use printbuf_memappend() directly unless it
+ * checks the return code. Use printbuf_memappend_fast() instead.
+ */
+JSON_EXPORT int printbuf_memappend(struct printbuf *p, const char *buf, int size);
+
+#define printbuf_memappend_fast(p, bufptr, bufsize)                  \
+	do                                                           \
+	{                                                            \
+		if ((p->size - p->bpos) > bufsize)                   \
+		{                                                    \
+			memcpy(p->buf + p->bpos, (bufptr), bufsize); \
+			p->bpos += bufsize;                          \
+			p->buf[p->bpos] = '\0';                      \
+		}                                                    \
+		else                                                 \
+		{                                                    \
+			printbuf_memappend(p, (bufptr), bufsize);    \
+		}                                                    \
+	} while (0)
+
+#define printbuf_length(p) ((p)->bpos)
+
+/**
+ * Results in a compile error if the argument is not a string literal.
+ */
+#define _printbuf_check_literal(mystr) ("" mystr)
+
+/**
+ * This is an optimization wrapper around printbuf_memappend() that is useful
+ * for appending string literals. Since the size of string constants is known
+ * at compile time, using this macro can avoid a costly strlen() call. This is
+ * especially helpful when a constant string must be appended many times. If
+ * you got here because of a compilation error caused by passing something
+ * other than a string literal, use printbuf_memappend_fast() in conjunction
+ * with strlen().
+ *
+ * See also:
+ *   printbuf_memappend_fast()
+ *   printbuf_memappend()
+ *   sprintbuf()
+ */
+#define printbuf_strappend(pb, str) \
+	printbuf_memappend((pb), _printbuf_check_literal(str), sizeof(str) - 1)
+
+/**
+ * Set len bytes of the buffer to charvalue, starting at offset offset.
+ * Similar to calling memset(x, charvalue, len);
+ *
+ * The memory allocated for the buffer is extended as necessary.
+ *
+ * If offset is -1, this starts at the end of the current data in the buffer.
+ */
+JSON_EXPORT int printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
+
+/**
+ * Formatted print to printbuf.
+ *
+ * This function is the most expensive of the available functions for appending
+ * string data to a printbuf and should be used only where convenience is more
+ * important than speed. Avoid using this function in high performance code or
+ * tight loops; in these scenarios, consider using snprintf() with a static
+ * buffer in conjunction with one of the printbuf_*append() functions.
+ *
+ * See also:
+ *   printbuf_memappend_fast()
+ *   printbuf_memappend()
+ *   printbuf_strappend()
+ */
+JSON_EXPORT int sprintbuf(struct printbuf *p, const char *msg, ...);
+
+JSON_EXPORT void printbuf_reset(struct printbuf *p);
+
+JSON_EXPORT void printbuf_free(struct printbuf *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/random_seed.c b/lynq/S300/ap/app/apparms/json-c/random_seed.c
new file mode 100755
index 0000000..5b2155d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/random_seed.c
@@ -0,0 +1,356 @@
+/*
+ * random_seed.c
+ *
+ * Copyright (c) 2013 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+#include "random_seed.h"
+#include "config.h"
+#include "strerror_override.h"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_BSD_STDLIB_H
+#include <bsd/stdlib.h>
+#endif
+
+#define DEBUG_SEED(s)
+
+#if defined(__APPLE__) || defined(__unix__) || defined(__linux__)
+#define HAVE_DEV_RANDOM 1
+#endif
+
+#ifdef HAVE_ARC4RANDOM
+#undef HAVE_GETRANDOM
+#undef HAVE_DEV_RANDOM
+#undef HAVE_CRYPTGENRANDOM
+#endif
+
+#if defined ENABLE_RDRAND
+
+/* cpuid */
+
+#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
+#define HAS_X86_CPUID 1
+
+static void do_cpuid(int regs[], int h)
+{
+	/* clang-format off */
+    __asm__ __volatile__("cpuid"
+                         : "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
+                         : "a"(h));
+	/* clang-format on */
+}
+
+#elif defined _MSC_VER
+
+#define HAS_X86_CPUID 1
+#define do_cpuid __cpuid
+
+#endif
+
+/* has_rdrand */
+
+#if HAS_X86_CPUID
+
+static int get_rdrand_seed(void);
+
+/* Valid values are -1 (haven't tested), 0 (no), and 1 (yes). */
+static int _has_rdrand = -1;
+
+static int has_rdrand(void)
+{
+	if (_has_rdrand != -1)
+	{
+		return _has_rdrand;
+	}
+
+	/* CPUID.01H:ECX.RDRAND[bit 30] == 1 */
+	int regs[4];
+	do_cpuid(regs, 1);
+	if (!(regs[2] & (1 << 30)))
+	{
+		_has_rdrand = 0;
+		return 0;
+	}
+
+	/*
+	 * Some CPUs advertise RDRAND in CPUID, but return 0xFFFFFFFF
+	 * unconditionally. To avoid locking up later, test RDRAND here. If over
+	 * 3 trials RDRAND has returned the same value, declare it broken.
+	 * Example CPUs are AMD Ryzen 3000 series
+	 * and much older AMD APUs, such as the E1-1500
+	 * https://github.com/systemd/systemd/issues/11810
+	 * https://linuxreviews.org/RDRAND_stops_returning_random_values_on_older_AMD_CPUs_after_suspend
+	 */
+	_has_rdrand = 0;
+	int prev = get_rdrand_seed();
+	for (int i = 0; i < 3; i++)
+	{
+		int temp = get_rdrand_seed();
+		if (temp != prev)
+		{
+			_has_rdrand = 1;
+			break;
+		}
+
+		prev = temp;
+	}
+
+	return _has_rdrand;
+}
+
+#endif
+
+/* get_rdrand_seed - GCC x86 and X64 */
+
+#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
+
+#define HAVE_RDRAND 1
+
+static int get_rdrand_seed(void)
+{
+	DEBUG_SEED("get_rdrand_seed");
+	int _eax;
+	/* rdrand eax */
+	/* clang-format off */
+	__asm__ __volatile__("1: .byte 0x0F\n"
+	                     "   .byte 0xC7\n"
+	                     "   .byte 0xF0\n"
+	                     "   jnc 1b;\n"
+	                     : "=a" (_eax));
+	/* clang-format on */
+	return _eax;
+}
+
+#endif
+
+#if defined _MSC_VER
+
+#if _MSC_VER >= 1700
+#define HAVE_RDRAND 1
+
+/* get_rdrand_seed - Visual Studio 2012 and above */
+
+static int get_rdrand_seed(void)
+{
+	DEBUG_SEED("get_rdrand_seed");
+	int r;
+	while (_rdrand32_step(&r) == 0)
+		;
+	return r;
+}
+
+#elif defined _M_IX86
+#define HAVE_RDRAND 1
+
+/* get_rdrand_seed - Visual Studio 2010 and below - x86 only */
+
+/* clang-format off */
+static int get_rdrand_seed(void)
+{
+	DEBUG_SEED("get_rdrand_seed");
+	int _eax;
+retry:
+	/* rdrand eax */
+	__asm _emit 0x0F __asm _emit 0xC7 __asm _emit 0xF0
+	__asm jnc retry
+	__asm mov _eax, eax
+	return _eax;
+}
+/* clang-format on */
+
+#endif
+#endif
+
+#endif /* defined ENABLE_RDRAND */
+
+#ifdef HAVE_GETRANDOM
+
+#include <stdlib.h>
+#ifdef HAVE_SYS_RANDOM_H
+#include <sys/random.h>
+#endif
+
+static int get_getrandom_seed(int *seed)
+{
+	DEBUG_SEED("get_getrandom_seed");
+
+	ssize_t ret;
+
+	do
+	{
+		ret = getrandom(seed, sizeof(*seed), GRND_NONBLOCK);
+	} while ((ret == -1) && (errno == EINTR));
+
+	if (ret == -1)
+	{
+		if (errno == ENOSYS) /* syscall not available in kernel */
+			return -1;
+		if (errno == EAGAIN) /* entropy not yet initialized */
+			return -1;
+
+		fprintf(stderr, "error from getrandom(): %s", strerror(errno));
+		return -1;
+	}
+
+	if (ret != sizeof(*seed))
+		return -1;
+
+	return 0;
+}
+#endif /* defined HAVE_GETRANDOM */
+
+/* get_dev_random_seed */
+
+#ifdef HAVE_DEV_RANDOM
+
+#include <fcntl.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <stdlib.h>
+#include <sys/stat.h>
+
+static const char *dev_random_file = "/dev/urandom";
+
+static int get_dev_random_seed(int *seed)
+{
+	DEBUG_SEED("get_dev_random_seed");
+
+	struct stat buf;
+	if (stat(dev_random_file, &buf))
+		return -1;
+	if ((buf.st_mode & S_IFCHR) == 0)
+		return -1;
+
+	int fd = open(dev_random_file, O_RDONLY);
+	if (fd < 0)
+	{
+		fprintf(stderr, "error opening %s: %s", dev_random_file, strerror(errno));
+		return -1;
+	}
+
+	ssize_t nread = read(fd, seed, sizeof(*seed));
+
+	close(fd);
+
+	if (nread != sizeof(*seed))
+	{
+		fprintf(stderr, "error short read %s: %s", dev_random_file, strerror(errno));
+		return -1;
+	}
+
+	return 0;
+}
+
+#endif
+
+/* get_cryptgenrandom_seed */
+
+#ifdef WIN32
+
+#define HAVE_CRYPTGENRANDOM 1
+
+/* clang-format off */
+#include <windows.h>
+
+/* Caution: these blank lines must remain so clang-format doesn't reorder
+   includes to put windows.h after wincrypt.h */
+
+#include <wincrypt.h>
+/* clang-format on */
+#ifndef __GNUC__
+#pragma comment(lib, "advapi32.lib")
+#endif
+
+static int get_cryptgenrandom_seed(int *seed)
+{
+	HCRYPTPROV hProvider = 0;
+	DWORD dwFlags = CRYPT_VERIFYCONTEXT;
+
+	DEBUG_SEED("get_cryptgenrandom_seed");
+
+	/* WinNT 4 and Win98 do no support CRYPT_SILENT */
+	if (LOBYTE(LOWORD(GetVersion())) > 4)
+		dwFlags |= CRYPT_SILENT;
+
+	if (!CryptAcquireContextA(&hProvider, 0, 0, PROV_RSA_FULL, dwFlags))
+	{
+		fprintf(stderr, "error CryptAcquireContextA 0x%08lx", GetLastError());
+		return -1;
+	}
+	else
+	{
+		BOOL ret = CryptGenRandom(hProvider, sizeof(*seed), (BYTE *)seed);
+		CryptReleaseContext(hProvider, 0);
+		if (!ret)
+		{
+			fprintf(stderr, "error CryptGenRandom 0x%08lx", GetLastError());
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+#endif
+
+/* get_time_seed */
+
+#ifndef HAVE_ARC4RANDOM
+#include <time.h>
+
+static int get_time_seed(void)
+{
+	DEBUG_SEED("get_time_seed");
+
+	/* coverity[store_truncates_time_t] */
+	return (unsigned)time(NULL) * 433494437;
+}
+#endif
+
+/* json_c_get_random_seed */
+
+int json_c_get_random_seed(void)
+{
+#ifdef OVERRIDE_GET_RANDOM_SEED
+	OVERRIDE_GET_RANDOM_SEED;
+#endif
+#if defined HAVE_RDRAND && HAVE_RDRAND
+	if (has_rdrand())
+		return get_rdrand_seed();
+#endif
+#ifdef HAVE_ARC4RANDOM
+	/* arc4random never fails, so use it if it's available */
+	return arc4random();
+#else
+#ifdef HAVE_GETRANDOM
+	{
+		int seed = 0;
+		if (get_getrandom_seed(&seed) == 0)
+			return seed;
+	}
+#endif
+#if defined HAVE_DEV_RANDOM && HAVE_DEV_RANDOM
+	{
+		int seed = 0;
+		if (get_dev_random_seed(&seed) == 0)
+			return seed;
+	}
+#endif
+#if defined HAVE_CRYPTGENRANDOM && HAVE_CRYPTGENRANDOM
+	{
+		int seed = 0;
+		if (get_cryptgenrandom_seed(&seed) == 0)
+			return seed;
+	}
+#endif
+	return get_time_seed();
+#endif /* !HAVE_ARC4RANDOM */
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/random_seed.h b/lynq/S300/ap/app/apparms/json-c/random_seed.h
new file mode 100755
index 0000000..72ee5f6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/random_seed.h
@@ -0,0 +1,29 @@
+/*
+ * random_seed.h
+ *
+ * Copyright (c) 2013 Metaparadigm Pte. Ltd.
+ * Michael Clark <michael@metaparadigm.com>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ *
+ */
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+#ifndef seed_h
+#define seed_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int json_c_get_random_seed(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/snprintf_compat.h b/lynq/S300/ap/app/apparms/json-c/snprintf_compat.h
new file mode 100755
index 0000000..76f7a6c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/snprintf_compat.h
@@ -0,0 +1,41 @@
+#ifndef __snprintf_compat_h
+#define __snprintf_compat_h
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+/*
+ * Microsoft's _vsnprintf and _snprint don't always terminate
+ * the string, so use wrappers that ensure that.
+ */
+
+#include <stdarg.h>
+
+#if !defined(HAVE_SNPRINTF) && (defined(_MSC_VER) || defined(__MINGW32__))
+static int json_c_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+{
+	int ret;
+	ret = _vsnprintf(str, size, format, ap);
+	str[size - 1] = '\0';
+	return ret;
+}
+#define vsnprintf json_c_vsnprintf
+
+static int json_c_snprintf(char *str, size_t size, const char *format, ...)
+{
+	va_list ap;
+	int ret;
+	va_start(ap, format);
+	ret = json_c_vsnprintf(str, size, format, ap);
+	va_end(ap);
+	return ret;
+}
+#define snprintf json_c_snprintf
+
+#elif !defined(HAVE_SNPRINTF) /* !HAVE_SNPRINTF */
+#error Need vsnprintf!
+#endif /* !HAVE_SNPRINTF && defined(WIN32) */
+
+#endif /* __snprintf_compat_h */
diff --git a/lynq/S300/ap/app/apparms/json-c/strdup_compat.h b/lynq/S300/ap/app/apparms/json-c/strdup_compat.h
new file mode 100755
index 0000000..2f2df65
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/strdup_compat.h
@@ -0,0 +1,16 @@
+#ifndef __strdup_compat_h
+#define __strdup_compat_h
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
+/* MSC has the version as _strdup */
+#define strdup _strdup
+#elif !defined(HAVE_STRDUP)
+#error You do not have strdup on your system.
+#endif /* HAVE_STRDUP */
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/strerror_override.c b/lynq/S300/ap/app/apparms/json-c/strerror_override.c
new file mode 100755
index 0000000..a3dd377
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/strerror_override.c
@@ -0,0 +1,110 @@
+#define STRERROR_OVERRIDE_IMPL 1
+#include "strerror_override.h"
+
+/*
+ * Override strerror() to get consistent output across platforms.
+ */
+
+static struct
+{
+	int errno_value;
+	const char *errno_str;
+} errno_list[] = {
+/* clang-format off */
+#define STRINGIFY(x) #x
+#define ENTRY(x) {x, &STRINGIFY(undef_ ## x)[6]}
+	ENTRY(EPERM),
+	ENTRY(ENOENT),
+	ENTRY(ESRCH),
+	ENTRY(EINTR),
+	ENTRY(EIO),
+	ENTRY(ENXIO),
+	ENTRY(E2BIG),
+#ifdef ENOEXEC
+	ENTRY(ENOEXEC),
+#endif
+	ENTRY(EBADF),
+	ENTRY(ECHILD),
+	ENTRY(EDEADLK),
+	ENTRY(ENOMEM),
+	ENTRY(EACCES),
+	ENTRY(EFAULT),
+#ifdef ENOTBLK
+	ENTRY(ENOTBLK),
+#endif
+	ENTRY(EBUSY),
+	ENTRY(EEXIST),
+	ENTRY(EXDEV),
+	ENTRY(ENODEV),
+	ENTRY(ENOTDIR),
+	ENTRY(EISDIR),
+	ENTRY(EINVAL),
+	ENTRY(ENFILE),
+	ENTRY(EMFILE),
+	ENTRY(ENOTTY),
+#ifdef ETXTBSY
+	ENTRY(ETXTBSY),
+#endif
+	ENTRY(EFBIG),
+	ENTRY(ENOSPC),
+	ENTRY(ESPIPE),
+	ENTRY(EROFS),
+	ENTRY(EMLINK),
+	ENTRY(EPIPE),
+	ENTRY(EDOM),
+	ENTRY(ERANGE),
+	ENTRY(EAGAIN),
+	{ 0, (char *)0 }
+};
+/* clang-format on */
+
+// Enabled during tests
+static int _json_c_strerror_enable = 0;
+extern char *getenv(const char *name); // Avoid including stdlib.h
+
+#define PREFIX "ERRNO="
+static char errno_buf[128] = PREFIX;
+char *_json_c_strerror(int errno_in)
+{
+	int start_idx;
+	char digbuf[20];
+	int ii, jj;
+
+	if (!_json_c_strerror_enable)
+		_json_c_strerror_enable = (getenv("_JSON_C_STRERROR_ENABLE") == NULL) ? -1 : 1;
+	if (_json_c_strerror_enable == -1)
+		return strerror(errno_in);
+
+	// Avoid standard functions, so we don't need to include any
+	// headers, or guess at signatures.
+
+	for (ii = 0; errno_list[ii].errno_str != (char *)0; ii++)
+	{
+		const char *errno_str = errno_list[ii].errno_str;
+		if (errno_list[ii].errno_value != errno_in)
+			continue;
+
+		for (start_idx = sizeof(PREFIX) - 1, jj = 0; errno_str[jj] != '\0';
+		     jj++, start_idx++)
+		{
+			errno_buf[start_idx] = errno_str[jj];
+		}
+		errno_buf[start_idx] = '\0';
+		return errno_buf;
+	}
+
+	// It's not one of the known errno values, return the numeric value.
+	for (ii = 0; errno_in >= 10; errno_in /= 10, ii++)
+	{
+		digbuf[ii] = "0123456789"[(errno_in % 10)];
+	}
+	digbuf[ii] = "0123456789"[(errno_in % 10)];
+
+	// Reverse the digits
+	for (start_idx = sizeof(PREFIX) - 1; ii >= 0; ii--, start_idx++)
+	{
+		errno_buf[start_idx] = digbuf[ii];
+	}
+	errno_buf[start_idx] = '\0';
+	return errno_buf;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/strerror_override.h b/lynq/S300/ap/app/apparms/json-c/strerror_override.h
new file mode 100755
index 0000000..0b04eb4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/strerror_override.h
@@ -0,0 +1,30 @@
+#ifndef _json_strerror_override_h_
+#define _json_strerror_override_h_
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+#include "config.h"
+#include <errno.h>
+
+#include "json_object.h" /* for JSON_EXPORT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+JSON_EXPORT char *_json_c_strerror(int errno_in);
+
+#ifndef STRERROR_OVERRIDE_IMPL
+#define strerror _json_c_strerror
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _json_strerror_override_h_ */
diff --git a/lynq/S300/ap/app/apparms/json-c/strerror_override_private.h b/lynq/S300/ap/app/apparms/json-c/strerror_override_private.h
new file mode 100755
index 0000000..8726e59
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/strerror_override_private.h
@@ -0,0 +1,14 @@
+#ifndef __json_strerror_override_private_h__
+#define __json_strerror_override_private_h__
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+#include "json_types.h"
+
+/* Used by tests to get consistent output */
+JSON_EXPORT int _json_c_strerror_enable;
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/CMakeLists.txt b/lynq/S300/ap/app/apparms/json-c/tests/CMakeLists.txt
new file mode 100755
index 0000000..beef00a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/CMakeLists.txt
@@ -0,0 +1,65 @@
+cmake_minimum_required(VERSION 3.1)
+add_executable(test1Formatted test1.c parse_flags.c parse_flags.h)
+target_compile_definitions(test1Formatted PRIVATE TEST_FORMATTED=1)
+target_link_libraries(test1Formatted PRIVATE ${PROJECT_NAME})
+
+add_executable(test2Formatted test2.c parse_flags.c parse_flags.h)
+target_compile_definitions(test2Formatted PRIVATE TEST_FORMATTED=1)
+target_link_libraries(test2Formatted PRIVATE ${PROJECT_NAME})
+
+# https://cmake.org/cmake/help/v3.0/command/add_test.html
+# https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
+
+include_directories(PUBLIC ${CMAKE_SOURCE_DIR})
+
+set(ALL_TEST_NAMES
+    test1
+    test2
+    test4
+    testReplaceExisting
+    test_cast
+    test_charcase
+    test_compare
+    test_deep_copy
+    test_double_serializer
+    test_float
+    test_int_add
+    test_int_get
+    test_locale
+    test_null
+    test_parse
+    test_parse_int64
+    test_printbuf
+    test_set_serializer
+    test_set_value
+    test_strerror
+    test_util_file
+    test_visit
+    test_object_iterator)
+
+if (NOT DISABLE_JSON_POINTER)
+    set(ALL_TEST_NAMES ${ALL_TEST_NAMES} test_json_pointer)
+endif()
+
+foreach(TESTNAME ${ALL_TEST_NAMES})
+
+add_executable(${TESTNAME} ${TESTNAME}.c)
+if(${TESTNAME} STREQUAL test_strerror OR ${TESTNAME} STREQUAL test_util_file)
+# For output consistency, we need _json_c_strerror() in some tests:
+target_sources(${TESTNAME} PRIVATE ../strerror_override.c)
+endif()
+add_test(NAME ${TESTNAME} COMMAND ${PROJECT_SOURCE_DIR}/tests/${TESTNAME}.test)
+
+# XXX using the non-target_ versions of these doesn't work :(
+target_include_directories(
+  ${TESTNAME}
+  PUBLIC
+    ${CMAKE_CURRENT_LIST_DIR}
+  )
+target_link_libraries(
+  ${TESTNAME}
+  PRIVATE
+    ${PROJECT_NAME}
+  )
+
+endforeach(TESTNAME)
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.c b/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.c
new file mode 100755
index 0000000..6224ca3
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.c
@@ -0,0 +1,55 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "json.h"
+#include "parse_flags.h"
+
+#if !defined(HAVE_STRCASECMP) && defined(_MSC_VER)
+#define strcasecmp _stricmp
+#elif !defined(HAVE_STRCASECMP)
+#error You do not have strcasecmp on your system.
+#endif /* HAVE_STRNCASECMP */
+
+static struct
+{
+	const char *arg;
+	int flag;
+} format_args[] = {
+    {"plain", JSON_C_TO_STRING_PLAIN},
+    {"spaced", JSON_C_TO_STRING_SPACED},
+    {"pretty", JSON_C_TO_STRING_PRETTY},
+    {"pretty_tab", JSON_C_TO_STRING_PRETTY_TAB},
+};
+
+#ifndef NELEM
+#define NELEM(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+int parse_flags(int argc, char **argv)
+{
+	int arg_idx;
+	int sflags = 0;
+	for (arg_idx = 1; arg_idx < argc; arg_idx++)
+	{
+		int jj;
+		for (jj = 0; jj < (int)NELEM(format_args); jj++)
+		{
+			if (strcasecmp(argv[arg_idx], format_args[jj].arg) == 0)
+			{
+				sflags |= format_args[jj].flag;
+				break;
+			}
+		}
+		if (jj == NELEM(format_args))
+		{
+			printf("Unknown arg: %s\n", argv[arg_idx]);
+			exit(1);
+		}
+	}
+	return sflags;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.h b/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.h
new file mode 100755
index 0000000..c5e2f41
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/parse_flags.h
@@ -0,0 +1,4 @@
+#ifndef __parse_flags_h
+#define __parse_flags_h
+int parse_flags(int argc, char **argv);
+#endif
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test-defs.sh b/lynq/S300/ap/app/apparms/json-c/tests/test-defs.sh
new file mode 100755
index 0000000..8c5b521
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test-defs.sh
@@ -0,0 +1,139 @@
+#!/bin/sh
+
+if [ ! -z "$JSONC_TEST_TRACE" ] ; then
+	VERBOSE=1
+	set -x
+	set -v
+fi
+# Make sure srcdir is an absolute path.  Supply the variable
+# if it does not exist.  We want to be able to run the tests
+# stand-alone!!
+#
+srcdir=${srcdir-.}
+if test ! -d $srcdir ; then
+    echo "test-defs.sh: installation error" 1>&2
+    exit 1
+fi
+
+# Use absolute paths
+case "$srcdir" in
+    /* | [A-Za-z]:\\*) ;;
+    *) srcdir=`\cd $srcdir && pwd` ;;
+esac
+
+case "$top_builddir" in
+    /* | [A-Za-z]:\\*) ;;
+    *) top_builddir=`\cd ${top_builddir-..} && pwd` ;;
+esac
+
+top_builddir=${top_builddir}/tests
+
+progname=`echo "$0" | sed 's,^.*/,,'`
+testname=`echo "$progname" | sed 's,-.*$,,'`
+testsubdir=${testsubdir-testSubDir}
+testsubdir=${testsubdir}/${progname}
+
+# User can set VERBOSE to cause output redirection
+case "$VERBOSE" in
+[Nn]|[Nn][Oo]|0|"")
+	VERBOSE=0
+	exec > /dev/null
+	;;
+[Yy]|[Yy][Ee][Ss])
+	VERBOSE=1
+	;;
+esac
+
+rm -rf "$testsubdir" > /dev/null 2>&1
+mkdir -p "$testsubdir"
+CURDIR=$(pwd)
+cd "$testsubdir" \
+   || { echo "Cannot make or change into $testsubdir"; exit 1; }
+
+echo "=== Running test $progname"
+
+CMP="${CMP-cmp}"
+
+use_valgrind=${USE_VALGRIND-1}
+case "${use_valgrind}" in
+	[0Nn]*)
+		use_valgrind=0
+		;;
+	*)
+		use_valgrind=1
+		;;
+esac
+valgrind_path=$(which valgrind 2> /dev/null)
+if [ -z "${valgrind_path}" -o ! -x "${valgrind_path}" ] ; then
+	use_valgrind=0
+fi
+
+#
+# This is a common function to check the results of a test program
+# that is intended to generate consistent output across runs.
+#
+# ${top_builddir} must be set to the top level build directory.
+#
+# Output will be written to the current directory.
+#
+# It must be passed the name of the test command to run, which must be present
+#  in the ${top_builddir} directory.
+#
+# It will compare the output of running that against <name of command>.expected
+#
+run_output_test()
+{
+	if [ "$1" = "-o" ] ; then
+		TEST_OUTPUT="$2"
+		shift
+		shift
+	fi
+	TEST_COMMAND="$1"
+	shift
+	if [ -z "${TEST_OUTPUT}" ] ; then
+		TEST_OUTPUT=${TEST_COMMAND}
+	fi
+
+	REDIR_OUTPUT="> \"${TEST_OUTPUT}.out\""
+	if [ $VERBOSE -gt 1 ] ; then
+		REDIR_OUTPUT="| tee \"${TEST_OUTPUT}.out\""
+	fi
+
+	if [ $use_valgrind -eq 1 ] ; then
+		eval valgrind --tool=memcheck \
+			--trace-children=yes \
+			--demangle=yes \
+			--log-file="${TEST_OUTPUT}.vg.out" \
+			--leak-check=full \
+			--show-reachable=yes \
+			--run-libc-freeres=yes \
+		"\"${top_builddir}/${TEST_COMMAND}\"" \"\$@\" ${REDIR_OUTPUT}
+		err=$?
+
+	else
+		eval "\"${top_builddir}/${TEST_COMMAND}"\" \"\$@\" ${REDIR_OUTPUT}
+		err=$?
+	fi
+
+	if [ $err -ne 0 ] ; then
+		echo "ERROR: \"${TEST_COMMAND} $@\" exited with non-zero exit status: $err" 1>&2
+	fi
+
+	if [ $use_valgrind -eq 1 ] ; then
+		if ! tail -1 "${TEST_OUTPUT}.vg.out" | grep -q "ERROR SUMMARY: 0 errors" ; then
+			echo "ERROR: valgrind found errors during execution:" 1>&2
+			cat "${TEST_OUTPUT}.vg.out"
+			err=1
+		fi
+	fi
+
+	if ! "$CMP" -s "${srcdir}/${TEST_OUTPUT}.expected" "${TEST_OUTPUT}.out" ; then
+		echo "ERROR: \"${TEST_COMMAND} $@\" (${TEST_OUTPUT}) failed (set VERBOSE=1 to see full output):" 1>&2
+		(cd "${CURDIR}" ; set -x ; diff "${srcdir}/${TEST_OUTPUT}.expected" "$testsubdir/${TEST_OUTPUT}.out")
+		echo "cp \"$testsubdir/${TEST_OUTPUT}.out\" \"${srcdir}/${TEST_OUTPUT}.expected\"" 1>&2
+
+		err=1
+	fi
+
+	return $err
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1.c b/lynq/S300/ap/app/apparms/json-c/tests/test1.c
new file mode 100755
index 0000000..d28811b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1.c
@@ -0,0 +1,349 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+
+#include "json.h"
+#include "parse_flags.h"
+
+static int sort_fn(const void *j1, const void *j2)
+{
+	json_object *const *jso1, *const *jso2;
+	int i1, i2;
+
+	jso1 = (json_object *const *)j1;
+	jso2 = (json_object *const *)j2;
+	if (!*jso1 && !*jso2)
+		return 0;
+	if (!*jso1)
+		return -1;
+	if (!*jso2)
+		return 1;
+
+	i1 = json_object_get_int(*jso1);
+	i2 = json_object_get_int(*jso2);
+
+	return i1 - i2;
+}
+
+#ifdef TEST_FORMATTED
+static const char *to_json_string(json_object *obj, int flags)
+{
+	size_t length;
+	char *copy;
+	const char *result;
+
+	result = json_object_to_json_string_length(obj, flags, &length);
+	copy = strdup(result);
+	if (copy == NULL)
+		printf("to_json_string: Allocation failed!\n");
+	else
+	{
+		result = json_object_to_json_string_ext(obj, flags);
+		if (length != strlen(result))
+			printf("to_json_string: Length mismatch!\n");
+		if (strcmp(copy, result) != 0)
+			printf("to_json_string: Comparison Failed!\n");
+		free(copy);
+	}
+	return result;
+}
+#define json_object_to_json_string(obj) to_json_string(obj, sflags)
+#else
+/* no special define */
+#endif
+
+json_object *make_array(void);
+json_object *make_array(void)
+{
+	json_object *my_array;
+
+	my_array = json_object_new_array();
+	json_object_array_add(my_array, json_object_new_int(1));
+	json_object_array_add(my_array, json_object_new_int(2));
+	json_object_array_add(my_array, json_object_new_int(3));
+	json_object_array_put_idx(my_array, 4, json_object_new_int(5));
+	json_object_array_put_idx(my_array, 3, json_object_new_int(4));
+	json_object_array_put_idx(my_array, 6, json_object_new_int(7));
+
+	return my_array;
+}
+
+void test_array_del_idx(void);
+void test_array_del_idx(void)
+{
+	int rc;
+	size_t ii;
+	size_t orig_array_len;
+	json_object *my_array;
+#ifdef TEST_FORMATTED
+	int sflags = 0;
+#endif
+
+	my_array = make_array();
+	orig_array_len = json_object_array_length(my_array);
+
+	printf("my_array=\n");
+	for (ii = 0; ii < json_object_array_length(my_array); ii++)
+	{
+		json_object *obj = json_object_array_get_idx(my_array, ii);
+		printf("\t[%d]=%s\n", (int)ii, json_object_to_json_string(obj));
+	}
+	printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
+
+	for (ii = 0; ii < orig_array_len; ii++)
+	{
+		rc = json_object_array_del_idx(my_array, 0, 1);
+		printf("after del_idx(0,1)=%d, my_array.to_string()=%s\n", rc,
+		       json_object_to_json_string(my_array));
+	}
+
+	/* One more time, with the empty array: */
+	rc = json_object_array_del_idx(my_array, 0, 1);
+	printf("after del_idx(0,1)=%d, my_array.to_string()=%s\n", rc,
+	       json_object_to_json_string(my_array));
+
+	json_object_put(my_array);
+
+	/* Delete all array indexes at once */
+	my_array = make_array();
+	rc = json_object_array_del_idx(my_array, 0, orig_array_len);
+	printf("after del_idx(0,%d)=%d, my_array.to_string()=%s\n", (int)orig_array_len, rc,
+	       json_object_to_json_string(my_array));
+
+	json_object_put(my_array);
+
+	/* Delete *more* than all array indexes at once */
+	my_array = make_array();
+	rc = json_object_array_del_idx(my_array, 0, orig_array_len + 1);
+	printf("after del_idx(0,%d)=%d, my_array.to_string()=%s\n", (int)(orig_array_len + 1), rc,
+	       json_object_to_json_string(my_array));
+
+	json_object_put(my_array);
+
+	/* Delete some array indexes, then add more */
+	my_array = make_array();
+	rc = json_object_array_del_idx(my_array, 0, orig_array_len - 1);
+	printf("after del_idx(0,%d)=%d, my_array.to_string()=%s\n", (int)(orig_array_len - 1), rc,
+	       json_object_to_json_string(my_array));
+	json_object_array_add(my_array, json_object_new_string("s1"));
+	json_object_array_add(my_array, json_object_new_string("s2"));
+	json_object_array_add(my_array, json_object_new_string("s3"));
+
+	printf("after adding more entries, my_array.to_string()=%s\n",
+	       json_object_to_json_string(my_array));
+	json_object_put(my_array);
+}
+
+void test_array_list_expand_internal(void);
+void test_array_list_expand_internal(void)
+{
+	int rc;
+	size_t ii;
+	size_t idx;
+	json_object *my_array;
+#ifdef TEST_FORMATTED
+	int sflags = 0;
+#endif
+
+	my_array = make_array();
+	printf("my_array=\n");
+	for (ii = 0; ii < json_object_array_length(my_array); ii++)
+	{
+		json_object *obj = json_object_array_get_idx(my_array, ii);
+		printf("\t[%d]=%s\n", (int)ii, json_object_to_json_string(obj));
+	}
+	printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
+
+	/* Put iNdex < array->size, no expand. */
+	rc = json_object_array_put_idx(my_array, 5, json_object_new_int(6));
+	printf("put_idx(5,6)=%d\n", rc);
+
+	/* array->size < Put Index < array->size * 2 <= SIZE_T_MAX, the size = array->size * 2. */
+	idx = ARRAY_LIST_DEFAULT_SIZE * 2 - 1;
+	rc = json_object_array_put_idx(my_array, idx, json_object_new_int(0));
+	printf("put_idx(%d,0)=%d\n", (int)(idx), rc);
+
+	/* array->size * 2 < Put Index, the size = Put Index. */
+	idx = ARRAY_LIST_DEFAULT_SIZE * 2 * 2 + 1;
+	rc = json_object_array_put_idx(my_array, idx, json_object_new_int(0));
+	printf("put_idx(%d,0)=%d\n", (int)(idx), rc);
+
+	/* SIZE_T_MAX <= Put Index, it will fail and the size will no change. */
+	idx = SIZE_MAX; // SIZE_MAX = SIZE_T_MAX
+	json_object *tmp = json_object_new_int(10);
+	rc = json_object_array_put_idx(my_array, idx, tmp);
+	printf("put_idx(SIZE_T_MAX,0)=%d\n", rc);
+	if (rc == -1)
+	{
+		json_object_put(tmp);
+	}
+
+	json_object_put(my_array);
+}
+
+int main(int argc, char **argv)
+{
+	json_object *my_string, *my_int, *my_null, *my_object, *my_array;
+	size_t i;
+#ifdef TEST_FORMATTED
+	int sflags = 0;
+#endif
+
+	MC_SET_DEBUG(1);
+
+#ifdef TEST_FORMATTED
+	sflags = parse_flags(argc, argv);
+#endif
+
+	my_string = json_object_new_string("\t");
+	printf("my_string=%s\n", json_object_get_string(my_string));
+	printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+	json_object_put(my_string);
+
+	my_string = json_object_new_string("\\");
+	printf("my_string=%s\n", json_object_get_string(my_string));
+	printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+	json_object_put(my_string);
+
+	my_string = json_object_new_string("/");
+	printf("my_string=%s\n", json_object_get_string(my_string));
+	printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+	printf("my_string.to_string(NOSLASHESCAPE)=%s\n",
+	       json_object_to_json_string_ext(my_string, JSON_C_TO_STRING_NOSLASHESCAPE));
+	json_object_put(my_string);
+
+	my_string = json_object_new_string("/foo/bar/baz");
+	printf("my_string=%s\n", json_object_get_string(my_string));
+	printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+	printf("my_string.to_string(NOSLASHESCAPE)=%s\n",
+	       json_object_to_json_string_ext(my_string, JSON_C_TO_STRING_NOSLASHESCAPE));
+	json_object_put(my_string);
+
+	my_string = json_object_new_string("foo");
+	printf("my_string=%s\n", json_object_get_string(my_string));
+	printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+
+	my_int = json_object_new_int(9);
+	printf("my_int=%d\n", json_object_get_int(my_int));
+	printf("my_int.to_string()=%s\n", json_object_to_json_string(my_int));
+
+	my_null = json_object_new_null();
+	printf("my_null.to_string()=%s\n", json_object_to_json_string(my_null));
+
+	my_array = json_object_new_array();
+	json_object_array_add(my_array, json_object_new_int(1));
+	json_object_array_add(my_array, json_object_new_int(2));
+	json_object_array_add(my_array, json_object_new_int(3));
+	json_object_array_put_idx(my_array, 4, json_object_new_int(5));
+	printf("my_array=\n");
+	for (i = 0; i < json_object_array_length(my_array); i++)
+	{
+		json_object *obj = json_object_array_get_idx(my_array, i);
+		printf("\t[%d]=%s\n", (int)i, json_object_to_json_string(obj));
+	}
+	printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
+
+	json_object_put(my_array);
+
+	test_array_del_idx();
+	test_array_list_expand_internal();
+
+	my_array = json_object_new_array_ext(5);
+	json_object_array_add(my_array, json_object_new_int(3));
+	json_object_array_add(my_array, json_object_new_int(1));
+	json_object_array_add(my_array, json_object_new_int(2));
+	json_object_array_put_idx(my_array, 4, json_object_new_int(0));
+	printf("my_array=\n");
+	for (i = 0; i < json_object_array_length(my_array); i++)
+	{
+		json_object *obj = json_object_array_get_idx(my_array, i);
+		printf("\t[%d]=%s\n", (int)i, json_object_to_json_string(obj));
+	}
+	printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
+	json_object_array_sort(my_array, sort_fn);
+	printf("my_array=\n");
+	for (i = 0; i < json_object_array_length(my_array); i++)
+	{
+		json_object *obj = json_object_array_get_idx(my_array, i);
+		printf("\t[%d]=%s\n", (int)i, json_object_to_json_string(obj));
+	}
+	printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
+
+	json_object *one = json_object_new_int(1);
+	json_object *result = json_object_array_bsearch(one, my_array, sort_fn);
+	printf("find json_object(1) in my_array successfully: %s\n",
+	       json_object_to_json_string(result));
+	json_object_put(one);
+
+	my_object = json_object_new_object();
+	int rc = json_object_object_add(my_object, "abc", my_object);
+	if (rc != -1)
+	{
+		printf("ERROR: able to successfully add object to itself!\n");
+		fflush(stdout);
+	}
+	json_object_object_add(my_object, "abc", json_object_new_int(12));
+	json_object_object_add(my_object, "foo", json_object_new_string("bar"));
+	json_object_object_add(my_object, "bool0", json_object_new_boolean(0));
+	json_object_object_add(my_object, "bool1", json_object_new_boolean(1));
+	json_object_object_add(my_object, "baz", json_object_new_string("bang"));
+
+	json_object *baz_obj = json_object_new_string("fark");
+	json_object_get(baz_obj);
+	json_object_object_add(my_object, "baz", baz_obj);
+	json_object_object_del(my_object, "baz");
+
+	/* baz_obj should still be valid */
+	printf("baz_obj.to_string()=%s\n", json_object_to_json_string(baz_obj));
+	json_object_put(baz_obj);
+
+	/*json_object_object_add(my_object, "arr", my_array);*/
+	printf("my_object=\n");
+	json_object_object_foreach(my_object, key, val)
+	{
+		printf("\t%s: %s\n", key, json_object_to_json_string(val));
+	}
+
+	json_object *empty_array = json_object_new_array();
+	json_object *empty_obj = json_object_new_object();
+	json_object_object_add(my_object, "empty_array", empty_array);
+	json_object_object_add(my_object, "empty_obj", empty_obj);
+	printf("my_object.to_string()=%s\n", json_object_to_json_string(my_object));
+
+	json_object_put(my_array);
+	my_array = json_object_new_array_ext(INT_MIN + 1);
+	if (my_array != NULL)
+	{
+		printf("ERROR: able to allocate an array of negative size!\n");
+		fflush(stdout);
+		json_object_put(my_array);
+		my_array = NULL;
+	}
+
+#if SIZEOF_SIZE_T == SIZEOF_INT
+	my_array = json_object_new_array_ext(INT_MAX / 2 + 2);
+	if (my_array != NULL)
+	{
+		printf("ERROR: able to allocate an array of insufficient size!\n");
+		fflush(stdout);
+		json_object_put(my_array);
+		my_array = NULL;
+	}
+#endif
+
+	json_object_put(my_string);
+	json_object_put(my_int);
+	json_object_put(my_null);
+	json_object_put(my_object);
+	json_object_put(my_array);
+
+	return EXIT_SUCCESS;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1.expected
new file mode 100755
index 0000000..b473a8b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1.expected
@@ -0,0 +1,78 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[ 1, 2, 3, null, 5 ]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[ 1, 2, 3, 4, 5, null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ 2, 3, 4, 5, null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ 3, 4, 5, null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ 4, 5, null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ 5, null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ null, 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ 7 ]
+after del_idx(0,1)=0, my_array.to_string()=[ ]
+after del_idx(0,1)=-1, my_array.to_string()=[ ]
+after del_idx(0,7)=0, my_array.to_string()=[ ]
+after del_idx(0,8)=-1, my_array.to_string()=[ 1, 2, 3, 4, 5, null, 7 ]
+after del_idx(0,6)=0, my_array.to_string()=[ 7 ]
+after adding more entries, my_array.to_string()=[ 7, "s1", "s2", "s3" ]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[ 1, 2, 3, 4, 5, null, 7 ]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[ 3, 1, 2, null, 0 ]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[ null, 0, 1, 2, 3 ]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1.test b/lynq/S300/ap/app/apparms/json-c/tests/test1.test
new file mode 100755
index 0000000..0331f98
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1.test
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+run_output_test test1
+_err=$?
+
+for flag in plain spaced pretty ; do
+	run_output_test -o test1Formatted_${flag} test1Formatted ${flag}
+	_err2=$?
+	if [ $_err -eq 0 ] ; then
+		_err=$_err2
+	fi
+done
+
+# Spaced and pretty JSON string
+run_output_test -o test1Formatted_spaced_pretty \
+					test1Formatted spaced pretty
+_err2=$?
+if [ $_err -eq 0 ] ; then
+	_err=$_err2
+fi
+
+# Spaced and pretty JSON string using tabs
+run_output_test -o test1Formatted_spaced_pretty_pretty_tab \
+					test1Formatted spaced pretty pretty_tab
+_err2=$?
+if [ $_err -eq 0 ] ; then
+	_err=$_err2
+fi
+
+exit $_err
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_plain.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_plain.expected
new file mode 100755
index 0000000..ad12d99
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_plain.expected
@@ -0,0 +1,78 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[1,2,3,null,5]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[null,7]
+after del_idx(0,1)=0, my_array.to_string()=[7]
+after del_idx(0,1)=0, my_array.to_string()=[]
+after del_idx(0,1)=-1, my_array.to_string()=[]
+after del_idx(0,7)=0, my_array.to_string()=[]
+after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,6)=0, my_array.to_string()=[7]
+after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[3,1,2,null,0]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[null,0,1,2,3]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={"abc":12,"foo":"bar","bool0":false,"bool1":true,"empty_array":[],"empty_obj":{}}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_pretty.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_pretty.expected
new file mode 100755
index 0000000..ab2cc78
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_pretty.expected
@@ -0,0 +1,103 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[
+  1,
+  2,
+  3,
+  null,
+  5
+]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[null,7]
+after del_idx(0,1)=0, my_array.to_string()=[7]
+after del_idx(0,1)=0, my_array.to_string()=[]
+after del_idx(0,1)=-1, my_array.to_string()=[]
+after del_idx(0,7)=0, my_array.to_string()=[]
+after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,6)=0, my_array.to_string()=[7]
+after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[
+  3,
+  1,
+  2,
+  null,
+  0
+]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[
+  null,
+  0,
+  1,
+  2,
+  3
+]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={
+  "abc":12,
+  "foo":"bar",
+  "bool0":false,
+  "bool1":true,
+  "empty_array":[],
+  "empty_obj":{}
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced.expected
new file mode 100755
index 0000000..f57bd05
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced.expected
@@ -0,0 +1,78 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[ 1, 2, 3, null, 5 ]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[null,7]
+after del_idx(0,1)=0, my_array.to_string()=[7]
+after del_idx(0,1)=0, my_array.to_string()=[]
+after del_idx(0,1)=-1, my_array.to_string()=[]
+after del_idx(0,7)=0, my_array.to_string()=[]
+after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,6)=0, my_array.to_string()=[7]
+after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[ 3, 1, 2, null, 0 ]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[ null, 0, 1, 2, 3 ]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty.expected
new file mode 100755
index 0000000..c88729f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty.expected
@@ -0,0 +1,103 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[
+  1,
+  2,
+  3,
+  null,
+  5
+]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[null,7]
+after del_idx(0,1)=0, my_array.to_string()=[7]
+after del_idx(0,1)=0, my_array.to_string()=[]
+after del_idx(0,1)=-1, my_array.to_string()=[]
+after del_idx(0,7)=0, my_array.to_string()=[]
+after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,6)=0, my_array.to_string()=[7]
+after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[
+  3,
+  1,
+  2,
+  null,
+  0
+]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[
+  null,
+  0,
+  1,
+  2,
+  3
+]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={
+  "abc": 12,
+  "foo": "bar",
+  "bool0": false,
+  "bool1": true,
+  "empty_array": [],
+  "empty_obj": {}
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty_pretty_tab.expected b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty_pretty_tab.expected
new file mode 100755
index 0000000..bab239f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test1Formatted_spaced_pretty_pretty_tab.expected
@@ -0,0 +1,103 @@
+my_string=	
+my_string.to_string()="\t"
+my_string=\
+my_string.to_string()="\\"
+my_string=/
+my_string.to_string()="\/"
+my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
+my_string=foo
+my_string.to_string()="foo"
+my_int=9
+my_int.to_string()=9
+my_null.to_string()=null
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=null
+	[4]=5
+my_array.to_string()=[
+	1,
+	2,
+	3,
+	null,
+	5
+]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
+after del_idx(0,1)=0, my_array.to_string()=[null,7]
+after del_idx(0,1)=0, my_array.to_string()=[7]
+after del_idx(0,1)=0, my_array.to_string()=[]
+after del_idx(0,1)=-1, my_array.to_string()=[]
+after del_idx(0,7)=0, my_array.to_string()=[]
+after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
+after del_idx(0,6)=0, my_array.to_string()=[7]
+after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
+my_array=
+	[0]=1
+	[1]=2
+	[2]=3
+	[3]=4
+	[4]=5
+	[5]=null
+	[6]=7
+my_array.to_string()=[1,2,3,4,5,null,7]
+put_idx(5,6)=0
+put_idx(63,0)=0
+put_idx(129,0)=0
+put_idx(SIZE_T_MAX,0)=-1
+my_array=
+	[0]=3
+	[1]=1
+	[2]=2
+	[3]=null
+	[4]=0
+my_array.to_string()=[
+	3,
+	1,
+	2,
+	null,
+	0
+]
+my_array=
+	[0]=null
+	[1]=0
+	[2]=1
+	[3]=2
+	[4]=3
+my_array.to_string()=[
+	null,
+	0,
+	1,
+	2,
+	3
+]
+find json_object(1) in my_array successfully: 1
+baz_obj.to_string()="fark"
+my_object=
+	abc: 12
+	foo: "bar"
+	bool0: false
+	bool1: true
+my_object.to_string()={
+	"abc": 12,
+	"foo": "bar",
+	"bool0": false,
+	"bool1": true,
+	"empty_array": [],
+	"empty_obj": {}
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2.c b/lynq/S300/ap/app/apparms/json-c/tests/test2.c
new file mode 100755
index 0000000..0a5f315
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2.c
@@ -0,0 +1,42 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json.h"
+#include "parse_flags.h"
+
+#ifdef TEST_FORMATTED
+#define json_object_to_json_string(obj) json_object_to_json_string_ext(obj, sflags)
+#else
+/* no special define */
+#endif
+
+int main(int argc, char **argv)
+{
+	json_object *new_obj;
+#ifdef TEST_FORMATTED
+	int sflags = 0;
+#endif
+
+	MC_SET_DEBUG(1);
+
+#ifdef TEST_FORMATTED
+	sflags = parse_flags(argc, argv);
+#endif
+
+	new_obj = json_tokener_parse(
+	    "/* more difficult test case */"
+	    "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", "
+	    "\"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard "
+	    "Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", "
+	    "\"GlossDef\": \"A meta-markup language, used to create markup languages such as "
+	    "DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }");
+	printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+	json_object_put(new_obj);
+
+	return EXIT_SUCCESS;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2.expected
new file mode 100755
index 0000000..0b740a9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2.expected
@@ -0,0 +1 @@
+new_obj.to_string()={ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML", "markup" ] } ] } } }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2.test b/lynq/S300/ap/app/apparms/json-c/tests/test2.test
new file mode 100755
index 0000000..b5330fe
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2.test
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+run_output_test test2
+_err=$?
+
+for flag in plain spaced pretty ; do
+	run_output_test -o test2Formatted_${flag} test2Formatted ${flag}
+	_err2=$?
+	if [ $_err -eq 0 ] ; then
+		_err=$_err2
+	fi
+done
+
+# Spaced and pretty JSON string
+run_output_test -o test2Formatted_spaced_pretty \
+					test2Formatted spaced pretty
+_err2=$?
+if [ $_err -eq 0 ] ; then
+	_err=$_err2
+fi
+
+# Spaced and pretty JSON string using tabs
+run_output_test -o test2Formatted_spaced_pretty_pretty_tab \
+					test2Formatted spaced pretty pretty_tab
+_err2=$?
+if [ $_err -eq 0 ] ; then
+	_err=$_err2
+fi
+
+exit $_err
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_plain.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_plain.expected
new file mode 100755
index 0000000..cc587e9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_plain.expected
@@ -0,0 +1 @@
+new_obj.to_string()={"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":[{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML","markup"]}]}}}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_pretty.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_pretty.expected
new file mode 100755
index 0000000..8d6d740
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_pretty.expected
@@ -0,0 +1,23 @@
+new_obj.to_string()={
+  "glossary":{
+    "title":"example glossary",
+    "GlossDiv":{
+      "title":"S",
+      "GlossList":[
+        {
+          "ID":"SGML",
+          "SortAs":"SGML",
+          "GlossTerm":"Standard Generalized Markup Language",
+          "Acronym":"SGML",
+          "Abbrev":"ISO 8879:1986",
+          "GlossDef":"A meta-markup language, used to create markup languages such as DocBook.",
+          "GlossSeeAlso":[
+            "GML",
+            "XML",
+            "markup"
+          ]
+        }
+      ]
+    }
+  }
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced.expected
new file mode 100755
index 0000000..0b740a9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced.expected
@@ -0,0 +1 @@
+new_obj.to_string()={ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML", "markup" ] } ] } } }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty.expected
new file mode 100755
index 0000000..49f9ef2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty.expected
@@ -0,0 +1,23 @@
+new_obj.to_string()={
+  "glossary": {
+    "title": "example glossary",
+    "GlossDiv": {
+      "title": "S",
+      "GlossList": [
+        {
+          "ID": "SGML",
+          "SortAs": "SGML",
+          "GlossTerm": "Standard Generalized Markup Language",
+          "Acronym": "SGML",
+          "Abbrev": "ISO 8879:1986",
+          "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.",
+          "GlossSeeAlso": [
+            "GML",
+            "XML",
+            "markup"
+          ]
+        }
+      ]
+    }
+  }
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty_pretty_tab.expected b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty_pretty_tab.expected
new file mode 100755
index 0000000..0296b9c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test2Formatted_spaced_pretty_pretty_tab.expected
@@ -0,0 +1,23 @@
+new_obj.to_string()={
+	"glossary": {
+		"title": "example glossary",
+		"GlossDiv": {
+			"title": "S",
+			"GlossList": [
+				{
+					"ID": "SGML",
+					"SortAs": "SGML",
+					"GlossTerm": "Standard Generalized Markup Language",
+					"Acronym": "SGML",
+					"Abbrev": "ISO 8879:1986",
+					"GlossDef": "A meta-markup language, used to create markup languages such as DocBook.",
+					"GlossSeeAlso": [
+						"GML",
+						"XML",
+						"markup"
+					]
+				}
+			]
+		}
+	}
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test4.c b/lynq/S300/ap/app/apparms/json-c/tests/test4.c
new file mode 100755
index 0000000..1e136e5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test4.c
@@ -0,0 +1,88 @@
+/*
+ * gcc -o utf8 utf8.c -I/home/y/include -L./.libs -ljson
+ */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_tokener.h"
+#include "snprintf_compat.h"
+
+void print_hex(const char *s)
+{
+	const char *iter = s;
+	unsigned char ch;
+	while ((ch = *iter++) != 0)
+	{
+		if (',' != ch)
+			printf("%x ", ch);
+		else
+			printf(",");
+	}
+	putchar('\n');
+}
+
+static void test_lot_of_adds(void);
+static void test_lot_of_adds(void)
+{
+	int ii;
+	char key[50];
+	json_object *jobj = json_object_new_object();
+	assert(jobj != NULL);
+	for (ii = 0; ii < 500; ii++)
+	{
+		snprintf(key, sizeof(key), "k%d", ii);
+		json_object *iobj = json_object_new_int(ii);
+		assert(iobj != NULL);
+		if (json_object_object_add(jobj, key, iobj))
+		{
+			fprintf(stderr, "FAILED to add object #%d\n", ii);
+			abort();
+		}
+	}
+	printf("%s\n", json_object_to_json_string(jobj));
+	assert(json_object_object_length(jobj) == 500);
+	json_object_put(jobj);
+}
+
+int main(void)
+{
+	const char *input = "\"\\ud840\\udd26,\\ud840\\udd27,\\ud800\\udd26,\\ud800\\udd27\"";
+	const char *expected =
+	    "\xF0\xA0\x84\xA6,\xF0\xA0\x84\xA7,\xF0\x90\x84\xA6,\xF0\x90\x84\xA7";
+	struct json_object *parse_result = json_tokener_parse(input);
+	const char *unjson = json_object_get_string(parse_result);
+
+	printf("input: %s\n", input);
+
+	int strings_match = !strcmp(expected, unjson);
+	int retval = 0;
+	if (strings_match)
+	{
+		printf("JSON parse result is correct: %s\n", unjson);
+		puts("PASS");
+	}
+	else
+	{
+		printf("JSON parse result doesn't match expected string\n");
+		printf("expected string bytes: ");
+		print_hex(expected);
+		printf("parsed string bytes:   ");
+		print_hex(unjson);
+		puts("FAIL");
+		retval = 1;
+	}
+	json_object_put(parse_result);
+
+	test_lot_of_adds();
+
+	return retval;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test4.expected b/lynq/S300/ap/app/apparms/json-c/tests/test4.expected
new file mode 100755
index 0000000..cb27440
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test4.expected
@@ -0,0 +1,4 @@
+input: "\ud840\udd26,\ud840\udd27,\ud800\udd26,\ud800\udd27"
+JSON parse result is correct: 𠄦,𠄧,𐄦,𐄧
+PASS
+{ "k0": 0, "k1": 1, "k2": 2, "k3": 3, "k4": 4, "k5": 5, "k6": 6, "k7": 7, "k8": 8, "k9": 9, "k10": 10, "k11": 11, "k12": 12, "k13": 13, "k14": 14, "k15": 15, "k16": 16, "k17": 17, "k18": 18, "k19": 19, "k20": 20, "k21": 21, "k22": 22, "k23": 23, "k24": 24, "k25": 25, "k26": 26, "k27": 27, "k28": 28, "k29": 29, "k30": 30, "k31": 31, "k32": 32, "k33": 33, "k34": 34, "k35": 35, "k36": 36, "k37": 37, "k38": 38, "k39": 39, "k40": 40, "k41": 41, "k42": 42, "k43": 43, "k44": 44, "k45": 45, "k46": 46, "k47": 47, "k48": 48, "k49": 49, "k50": 50, "k51": 51, "k52": 52, "k53": 53, "k54": 54, "k55": 55, "k56": 56, "k57": 57, "k58": 58, "k59": 59, "k60": 60, "k61": 61, "k62": 62, "k63": 63, "k64": 64, "k65": 65, "k66": 66, "k67": 67, "k68": 68, "k69": 69, "k70": 70, "k71": 71, "k72": 72, "k73": 73, "k74": 74, "k75": 75, "k76": 76, "k77": 77, "k78": 78, "k79": 79, "k80": 80, "k81": 81, "k82": 82, "k83": 83, "k84": 84, "k85": 85, "k86": 86, "k87": 87, "k88": 88, "k89": 89, "k90": 90, "k91": 91, "k92": 92, "k93": 93, "k94": 94, "k95": 95, "k96": 96, "k97": 97, "k98": 98, "k99": 99, "k100": 100, "k101": 101, "k102": 102, "k103": 103, "k104": 104, "k105": 105, "k106": 106, "k107": 107, "k108": 108, "k109": 109, "k110": 110, "k111": 111, "k112": 112, "k113": 113, "k114": 114, "k115": 115, "k116": 116, "k117": 117, "k118": 118, "k119": 119, "k120": 120, "k121": 121, "k122": 122, "k123": 123, "k124": 124, "k125": 125, "k126": 126, "k127": 127, "k128": 128, "k129": 129, "k130": 130, "k131": 131, "k132": 132, "k133": 133, "k134": 134, "k135": 135, "k136": 136, "k137": 137, "k138": 138, "k139": 139, "k140": 140, "k141": 141, "k142": 142, "k143": 143, "k144": 144, "k145": 145, "k146": 146, "k147": 147, "k148": 148, "k149": 149, "k150": 150, "k151": 151, "k152": 152, "k153": 153, "k154": 154, "k155": 155, "k156": 156, "k157": 157, "k158": 158, "k159": 159, "k160": 160, "k161": 161, "k162": 162, "k163": 163, "k164": 164, "k165": 165, "k166": 166, "k167": 167, "k168": 168, "k169": 169, "k170": 170, "k171": 171, "k172": 172, "k173": 173, "k174": 174, "k175": 175, "k176": 176, "k177": 177, "k178": 178, "k179": 179, "k180": 180, "k181": 181, "k182": 182, "k183": 183, "k184": 184, "k185": 185, "k186": 186, "k187": 187, "k188": 188, "k189": 189, "k190": 190, "k191": 191, "k192": 192, "k193": 193, "k194": 194, "k195": 195, "k196": 196, "k197": 197, "k198": 198, "k199": 199, "k200": 200, "k201": 201, "k202": 202, "k203": 203, "k204": 204, "k205": 205, "k206": 206, "k207": 207, "k208": 208, "k209": 209, "k210": 210, "k211": 211, "k212": 212, "k213": 213, "k214": 214, "k215": 215, "k216": 216, "k217": 217, "k218": 218, "k219": 219, "k220": 220, "k221": 221, "k222": 222, "k223": 223, "k224": 224, "k225": 225, "k226": 226, "k227": 227, "k228": 228, "k229": 229, "k230": 230, "k231": 231, "k232": 232, "k233": 233, "k234": 234, "k235": 235, "k236": 236, "k237": 237, "k238": 238, "k239": 239, "k240": 240, "k241": 241, "k242": 242, "k243": 243, "k244": 244, "k245": 245, "k246": 246, "k247": 247, "k248": 248, "k249": 249, "k250": 250, "k251": 251, "k252": 252, "k253": 253, "k254": 254, "k255": 255, "k256": 256, "k257": 257, "k258": 258, "k259": 259, "k260": 260, "k261": 261, "k262": 262, "k263": 263, "k264": 264, "k265": 265, "k266": 266, "k267": 267, "k268": 268, "k269": 269, "k270": 270, "k271": 271, "k272": 272, "k273": 273, "k274": 274, "k275": 275, "k276": 276, "k277": 277, "k278": 278, "k279": 279, "k280": 280, "k281": 281, "k282": 282, "k283": 283, "k284": 284, "k285": 285, "k286": 286, "k287": 287, "k288": 288, "k289": 289, "k290": 290, "k291": 291, "k292": 292, "k293": 293, "k294": 294, "k295": 295, "k296": 296, "k297": 297, "k298": 298, "k299": 299, "k300": 300, "k301": 301, "k302": 302, "k303": 303, "k304": 304, "k305": 305, "k306": 306, "k307": 307, "k308": 308, "k309": 309, "k310": 310, "k311": 311, "k312": 312, "k313": 313, "k314": 314, "k315": 315, "k316": 316, "k317": 317, "k318": 318, "k319": 319, "k320": 320, "k321": 321, "k322": 322, "k323": 323, "k324": 324, "k325": 325, "k326": 326, "k327": 327, "k328": 328, "k329": 329, "k330": 330, "k331": 331, "k332": 332, "k333": 333, "k334": 334, "k335": 335, "k336": 336, "k337": 337, "k338": 338, "k339": 339, "k340": 340, "k341": 341, "k342": 342, "k343": 343, "k344": 344, "k345": 345, "k346": 346, "k347": 347, "k348": 348, "k349": 349, "k350": 350, "k351": 351, "k352": 352, "k353": 353, "k354": 354, "k355": 355, "k356": 356, "k357": 357, "k358": 358, "k359": 359, "k360": 360, "k361": 361, "k362": 362, "k363": 363, "k364": 364, "k365": 365, "k366": 366, "k367": 367, "k368": 368, "k369": 369, "k370": 370, "k371": 371, "k372": 372, "k373": 373, "k374": 374, "k375": 375, "k376": 376, "k377": 377, "k378": 378, "k379": 379, "k380": 380, "k381": 381, "k382": 382, "k383": 383, "k384": 384, "k385": 385, "k386": 386, "k387": 387, "k388": 388, "k389": 389, "k390": 390, "k391": 391, "k392": 392, "k393": 393, "k394": 394, "k395": 395, "k396": 396, "k397": 397, "k398": 398, "k399": 399, "k400": 400, "k401": 401, "k402": 402, "k403": 403, "k404": 404, "k405": 405, "k406": 406, "k407": 407, "k408": 408, "k409": 409, "k410": 410, "k411": 411, "k412": 412, "k413": 413, "k414": 414, "k415": 415, "k416": 416, "k417": 417, "k418": 418, "k419": 419, "k420": 420, "k421": 421, "k422": 422, "k423": 423, "k424": 424, "k425": 425, "k426": 426, "k427": 427, "k428": 428, "k429": 429, "k430": 430, "k431": 431, "k432": 432, "k433": 433, "k434": 434, "k435": 435, "k436": 436, "k437": 437, "k438": 438, "k439": 439, "k440": 440, "k441": 441, "k442": 442, "k443": 443, "k444": 444, "k445": 445, "k446": 446, "k447": 447, "k448": 448, "k449": 449, "k450": 450, "k451": 451, "k452": 452, "k453": 453, "k454": 454, "k455": 455, "k456": 456, "k457": 457, "k458": 458, "k459": 459, "k460": 460, "k461": 461, "k462": 462, "k463": 463, "k464": 464, "k465": 465, "k466": 466, "k467": 467, "k468": 468, "k469": 469, "k470": 470, "k471": 471, "k472": 472, "k473": 473, "k474": 474, "k475": 475, "k476": 476, "k477": 477, "k478": 478, "k479": 479, "k480": 480, "k481": 481, "k482": 482, "k483": 483, "k484": 484, "k485": 485, "k486": 486, "k487": 487, "k488": 488, "k489": 489, "k490": 490, "k491": 491, "k492": 492, "k493": 493, "k494": 494, "k495": 495, "k496": 496, "k497": 497, "k498": 498, "k499": 499 }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test4.test b/lynq/S300/ap/app/apparms/json-c/tests/test4.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test4.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.c b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.c
new file mode 100755
index 0000000..60a194a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.c
@@ -0,0 +1,81 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json.h"
+
+int main(int argc, char **argv)
+{
+	MC_SET_DEBUG(1);
+
+	/*
+	 * Check that replacing an existing object keeps the key valid,
+	 * and that it keeps the order the same.
+	 */
+	json_object *my_object = json_object_new_object();
+	json_object_object_add(my_object, "foo1", json_object_new_string("bar1"));
+	json_object_object_add(my_object, "foo2", json_object_new_string("bar2"));
+	json_object_object_add(my_object, "deleteme", json_object_new_string("bar2"));
+	json_object_object_add(my_object, "foo3", json_object_new_string("bar3"));
+
+	printf("==== delete-in-loop test starting ====\n");
+
+	int orig_count = 0;
+	json_object_object_foreach(my_object, key0, val0)
+	{
+		printf("Key at index %d is [%s] %d", orig_count, key0, (val0 == NULL));
+		if (strcmp(key0, "deleteme") == 0)
+		{
+			json_object_object_del(my_object, key0);
+			printf(" (deleted)\n");
+		}
+		else
+			printf(" (kept)\n");
+		orig_count++;
+	}
+
+	printf("==== replace-value first loop starting ====\n");
+
+	const char *original_key = NULL;
+	orig_count = 0;
+	json_object_object_foreach(my_object, key, val)
+	{
+		printf("Key at index %d is [%s] %d\n", orig_count, key, (val == NULL));
+		orig_count++;
+		if (strcmp(key, "foo2") != 0)
+			continue;
+		printf("replacing value for key [%s]\n", key);
+		original_key = key;
+		json_object_object_add(my_object, key, json_object_new_string("zzz"));
+	}
+
+	printf("==== second loop starting ====\n");
+
+	int new_count = 0;
+	int retval = 0;
+	json_object_object_foreach(my_object, key2, val2)
+	{
+		printf("Key at index %d is [%s] %d\n", new_count, key2, (val2 == NULL));
+		new_count++;
+		if (strcmp(key2, "foo2") != 0)
+			continue;
+		printf("pointer for key [%s] does %smatch\n", key2,
+		       (key2 == original_key) ? "" : "NOT ");
+		if (key2 != original_key)
+			retval = 1;
+	}
+	if (new_count != orig_count)
+	{
+		printf("mismatch between original count (%d) and new count (%d)\n", orig_count,
+		       new_count);
+		retval = 1;
+	}
+
+	json_object_put(my_object);
+
+	return retval;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.expected b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.expected
new file mode 100755
index 0000000..57ef190
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.expected
@@ -0,0 +1,15 @@
+==== delete-in-loop test starting ====
+Key at index 0 is [foo1] 0 (kept)
+Key at index 1 is [foo2] 0 (kept)
+Key at index 2 is [deleteme] 0 (deleted)
+Key at index 3 is [foo3] 0 (kept)
+==== replace-value first loop starting ====
+Key at index 0 is [foo1] 0
+Key at index 1 is [foo2] 0
+replacing value for key [foo2]
+Key at index 2 is [foo3] 0
+==== second loop starting ====
+Key at index 0 is [foo1] 0
+Key at index 1 is [foo2] 0
+pointer for key [foo2] does match
+Key at index 2 is [foo3] 0
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.test b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/testReplaceExisting.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_basic.test b/lynq/S300/ap/app/apparms/json-c/tests/test_basic.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_basic.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_cast.c b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.c
new file mode 100755
index 0000000..02e19ea
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.c
@@ -0,0 +1,118 @@
+/*
+ * Tests if casting within the json_object_get_* functions work correctly.
+ * Also checks the json_object_get_type and json_object_is_type functions.
+ */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_tokener.h"
+#include "json_util.h"
+
+static void getit(struct json_object *new_obj, const char *field);
+static void checktype_header(void);
+static void checktype(struct json_object *new_obj, const char *field);
+
+int main(int argc, char **argv)
+{
+	const char *input = "{\n\
+		\"string_of_digits\": \"123\",\n\
+		\"regular_number\": 222,\n\
+		\"decimal_number\": 99.55,\n\
+		\"boolean_true\": true,\n\
+		\"boolean_false\": false,\n\
+		\"int64_number\": 2147483649,\n\
+		\"negative_number\": -321321321,\n\
+		\"a_null\": null,\n\
+		\"empty_array\": [],\n\
+		\"nonempty_array\": [ 123 ],\n\
+		\"array_with_zero\": [ 0 ],\n\
+		\"empty_object\": {},\n\
+		\"nonempty_object\": { \"a\": 123 },\n\
+	}";
+	/* Note: 2147483649 = INT_MAX + 2 */
+	/* Note: 9223372036854775809 = INT64_MAX + 2 */
+	/* Note: 18446744073709551617 = UINT64_MAX + 2 */
+
+	struct json_object *new_obj;
+
+	new_obj = json_tokener_parse(input);
+	printf("Parsed input: %s\n", input);
+	printf("Result is %s\n", (new_obj == NULL) ? "NULL (error!)" : "not NULL");
+	if (!new_obj)
+		return 1; // oops, we failed.
+
+	getit(new_obj, "string_of_digits");
+	getit(new_obj, "regular_number");
+	getit(new_obj, "decimal_number");
+	getit(new_obj, "boolean_true");
+	getit(new_obj, "boolean_false");
+	getit(new_obj, "int64_number");
+	getit(new_obj, "negative_number");
+	getit(new_obj, "a_null");
+	getit(new_obj, "empty_array");
+	getit(new_obj, "nonempty_array");
+	getit(new_obj, "array_with_zero");
+	getit(new_obj, "empty_object");
+	getit(new_obj, "nonempty_object");
+
+	// Now check the behaviour of the json_object_is_type() function.
+	printf("\n================================\n");
+	checktype_header();
+	checktype(new_obj, NULL);
+	checktype(new_obj, "string_of_digits");
+	checktype(new_obj, "regular_number");
+	checktype(new_obj, "decimal_number");
+	checktype(new_obj, "boolean_true");
+	checktype(new_obj, "boolean_false");
+	checktype(new_obj, "int64_number");
+	checktype(new_obj, "negative_number");
+	checktype(new_obj, "a_null");
+
+	json_object_put(new_obj);
+
+	return 0;
+}
+
+static void getit(struct json_object *new_obj, const char *field)
+{
+	struct json_object *o = NULL;
+	if (!json_object_object_get_ex(new_obj, field, &o))
+		printf("Field %s does not exist\n", field);
+
+	enum json_type o_type = json_object_get_type(o);
+	printf("new_obj.%s json_object_get_type()=%s\n", field, json_type_to_name(o_type));
+	printf("new_obj.%s json_object_get_int()=%d\n", field, json_object_get_int(o));
+	printf("new_obj.%s json_object_get_int64()=%" PRId64 "\n", field, json_object_get_int64(o));
+	printf("new_obj.%s json_object_get_uint64()=%" PRIu64 "\n", field,
+	       json_object_get_uint64(o));
+	printf("new_obj.%s json_object_get_boolean()=%d\n", field, json_object_get_boolean(o));
+	printf("new_obj.%s json_object_get_double()=%f\n", field, json_object_get_double(o));
+}
+
+static void checktype_header(void)
+{
+	printf("json_object_is_type: %s,%s,%s,%s,%s,%s,%s\n", json_type_to_name(json_type_null),
+	       json_type_to_name(json_type_boolean), json_type_to_name(json_type_double),
+	       json_type_to_name(json_type_int), json_type_to_name(json_type_object),
+	       json_type_to_name(json_type_array), json_type_to_name(json_type_string));
+}
+static void checktype(struct json_object *new_obj, const char *field)
+{
+	struct json_object *o = new_obj;
+	if (field && !json_object_object_get_ex(new_obj, field, &o))
+		printf("Field %s does not exist\n", field);
+
+	printf("new_obj%s%-18s: %d,%d,%d,%d,%d,%d,%d\n", field ? "." : " ", field ? field : "",
+	       json_object_is_type(o, json_type_null), json_object_is_type(o, json_type_boolean),
+	       json_object_is_type(o, json_type_double), json_object_is_type(o, json_type_int),
+	       json_object_is_type(o, json_type_object), json_object_is_type(o, json_type_array),
+	       json_object_is_type(o, json_type_string));
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_cast.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.expected
new file mode 100755
index 0000000..6a19de9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.expected
@@ -0,0 +1,106 @@
+Parsed input: {
+		"string_of_digits": "123",
+		"regular_number": 222,
+		"decimal_number": 99.55,
+		"boolean_true": true,
+		"boolean_false": false,
+		"int64_number": 2147483649,
+		"negative_number": -321321321,
+		"a_null": null,
+		"empty_array": [],
+		"nonempty_array": [ 123 ],
+		"array_with_zero": [ 0 ],
+		"empty_object": {},
+		"nonempty_object": { "a": 123 },
+	}
+Result is not NULL
+new_obj.string_of_digits json_object_get_type()=string
+new_obj.string_of_digits json_object_get_int()=123
+new_obj.string_of_digits json_object_get_int64()=123
+new_obj.string_of_digits json_object_get_uint64()=123
+new_obj.string_of_digits json_object_get_boolean()=1
+new_obj.string_of_digits json_object_get_double()=123.000000
+new_obj.regular_number json_object_get_type()=int
+new_obj.regular_number json_object_get_int()=222
+new_obj.regular_number json_object_get_int64()=222
+new_obj.regular_number json_object_get_uint64()=222
+new_obj.regular_number json_object_get_boolean()=1
+new_obj.regular_number json_object_get_double()=222.000000
+new_obj.decimal_number json_object_get_type()=double
+new_obj.decimal_number json_object_get_int()=99
+new_obj.decimal_number json_object_get_int64()=99
+new_obj.decimal_number json_object_get_uint64()=99
+new_obj.decimal_number json_object_get_boolean()=1
+new_obj.decimal_number json_object_get_double()=99.550000
+new_obj.boolean_true json_object_get_type()=boolean
+new_obj.boolean_true json_object_get_int()=1
+new_obj.boolean_true json_object_get_int64()=1
+new_obj.boolean_true json_object_get_uint64()=1
+new_obj.boolean_true json_object_get_boolean()=1
+new_obj.boolean_true json_object_get_double()=1.000000
+new_obj.boolean_false json_object_get_type()=boolean
+new_obj.boolean_false json_object_get_int()=0
+new_obj.boolean_false json_object_get_int64()=0
+new_obj.boolean_false json_object_get_uint64()=0
+new_obj.boolean_false json_object_get_boolean()=0
+new_obj.boolean_false json_object_get_double()=0.000000
+new_obj.int64_number json_object_get_type()=int
+new_obj.int64_number json_object_get_int()=2147483647
+new_obj.int64_number json_object_get_int64()=2147483649
+new_obj.int64_number json_object_get_uint64()=2147483649
+new_obj.int64_number json_object_get_boolean()=1
+new_obj.int64_number json_object_get_double()=2147483649.000000
+new_obj.negative_number json_object_get_type()=int
+new_obj.negative_number json_object_get_int()=-321321321
+new_obj.negative_number json_object_get_int64()=-321321321
+new_obj.negative_number json_object_get_uint64()=0
+new_obj.negative_number json_object_get_boolean()=1
+new_obj.negative_number json_object_get_double()=-321321321.000000
+new_obj.a_null json_object_get_type()=null
+new_obj.a_null json_object_get_int()=0
+new_obj.a_null json_object_get_int64()=0
+new_obj.a_null json_object_get_uint64()=0
+new_obj.a_null json_object_get_boolean()=0
+new_obj.a_null json_object_get_double()=0.000000
+new_obj.empty_array json_object_get_type()=array
+new_obj.empty_array json_object_get_int()=0
+new_obj.empty_array json_object_get_int64()=0
+new_obj.empty_array json_object_get_uint64()=0
+new_obj.empty_array json_object_get_boolean()=0
+new_obj.empty_array json_object_get_double()=0.000000
+new_obj.nonempty_array json_object_get_type()=array
+new_obj.nonempty_array json_object_get_int()=0
+new_obj.nonempty_array json_object_get_int64()=0
+new_obj.nonempty_array json_object_get_uint64()=0
+new_obj.nonempty_array json_object_get_boolean()=0
+new_obj.nonempty_array json_object_get_double()=0.000000
+new_obj.array_with_zero json_object_get_type()=array
+new_obj.array_with_zero json_object_get_int()=0
+new_obj.array_with_zero json_object_get_int64()=0
+new_obj.array_with_zero json_object_get_uint64()=0
+new_obj.array_with_zero json_object_get_boolean()=0
+new_obj.array_with_zero json_object_get_double()=0.000000
+new_obj.empty_object json_object_get_type()=object
+new_obj.empty_object json_object_get_int()=0
+new_obj.empty_object json_object_get_int64()=0
+new_obj.empty_object json_object_get_uint64()=0
+new_obj.empty_object json_object_get_boolean()=0
+new_obj.empty_object json_object_get_double()=0.000000
+new_obj.nonempty_object json_object_get_type()=object
+new_obj.nonempty_object json_object_get_int()=0
+new_obj.nonempty_object json_object_get_int64()=0
+new_obj.nonempty_object json_object_get_uint64()=0
+new_obj.nonempty_object json_object_get_boolean()=0
+new_obj.nonempty_object json_object_get_double()=0.000000
+
+================================
+json_object_is_type: null,boolean,double,int,object,array,string
+new_obj                   : 0,0,0,0,1,0,0
+new_obj.string_of_digits  : 0,0,0,0,0,0,1
+new_obj.regular_number    : 0,0,0,1,0,0,0
+new_obj.decimal_number    : 0,0,1,0,0,0,0
+new_obj.boolean_true      : 0,1,0,0,0,0,0
+new_obj.boolean_false     : 0,1,0,0,0,0,0
+new_obj.int64_number      : 0,0,0,1,0,0,0
+new_obj.negative_number   : 0,0,0,1,0,0,0
+new_obj.a_null            : 1,0,0,0,0,0,0
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_cast.test b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_cast.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.c b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.c
new file mode 100755
index 0000000..8ffcb68
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.c
@@ -0,0 +1,45 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json.h"
+#include "json_tokener.h"
+
+static void test_case_parse(void);
+
+int main(int argc, char **argv)
+{
+	MC_SET_DEBUG(1);
+
+	test_case_parse();
+
+	return 0;
+}
+
+/* make sure only lowercase forms are parsed in strict mode */
+static void test_case_parse(void)
+{
+	struct json_tokener *tok;
+	json_object *new_obj;
+
+	tok = json_tokener_new();
+	json_tokener_set_flags(tok, JSON_TOKENER_STRICT);
+
+	new_obj = json_tokener_parse_ex(tok, "True", 4);
+	assert(new_obj == NULL);
+
+	new_obj = json_tokener_parse_ex(tok, "False", 5);
+	assert(new_obj == NULL);
+
+	new_obj = json_tokener_parse_ex(tok, "Null", 4);
+	assert(new_obj == NULL);
+
+	printf("OK\n");
+
+	json_tokener_free(tok);
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.expected
new file mode 100755
index 0000000..d86bac9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.expected
@@ -0,0 +1 @@
+OK
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.test b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_charcase.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_compare.c b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.c
new file mode 100755
index 0000000..ed697cd
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.c
@@ -0,0 +1,260 @@
+/*
+* Tests if json_object_equal behaves correct.
+*/
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+
+#include "json_inttypes.h"
+#include "json_object.h"
+
+int main(int argc, char **argv)
+{
+	/* integer tests */
+	struct json_object *int1 = json_object_new_int(0);
+	struct json_object *int2 = json_object_new_int(1);
+	struct json_object *int3 = json_object_new_int(1);
+	struct json_object *int4 = json_object_new_int(-1);
+	struct json_object *uint1 = json_object_new_uint64(0);
+	struct json_object *uint2 = json_object_new_uint64(1);
+	struct json_object *uint3 = json_object_new_uint64(1);
+	struct json_object *uint4 = json_object_new_uint64((uint64_t)INT64_MAX + 100);
+
+	if (!json_object_equal(int1, int2))
+		printf("JSON integer comparison is correct\n");
+	else
+		printf("JSON integer comparison failed\n");
+
+	if (json_object_equal(int1, int1))
+		printf("JSON same object comparison is correct\n");
+	else
+		printf("JSON same object comparison failed\n");
+
+	if (json_object_equal(int2, int3))
+		printf("JSON same integer comparison is correct\n");
+	else
+		printf("JSON same integer comparison failed\n");
+
+	if (!json_object_equal(uint1, uint2))
+		printf("JSON usigned integer comparison is correct\n");
+	else
+		printf("JSON usigned integer comparison failed\n");
+
+	if (json_object_equal(uint1, uint1))
+		printf("JSON same usigned object comparison is correct\n");
+	else
+		printf("JSON same usigned object comparison failed\n");
+
+	if (json_object_equal(uint2, uint3))
+		printf("JSON same usigned integer comparison is correct\n");
+	else
+		printf("JSON same usigned integer comparison failed\n");
+
+	if (json_object_equal(int2, uint2))
+		printf("JSON integer & usigned integer comparison is correct\n");
+	else
+		printf("JSON integer & usigned integer comparison failed\n");
+
+	if (!json_object_equal(int2, uint4))
+		printf("JSON integer & usigned integer comparison is correct\n");
+	else
+		printf("JSON integer & usigned integer comparison failed\n");
+
+	if (!json_object_equal(int4, uint2))
+		printf("JSON integer & usigned integer comparison is correct\n");
+	else
+		printf("JSON integer & usigned integer comparison failed\n");
+
+	if (!json_object_equal(int4, uint4))
+		printf("JSON integer & usigned integer comparison is correct\n");
+	else
+		printf("JSON integer & usigned integer comparison failed\n");
+
+	if (json_object_equal(uint2, int2))
+		printf("JSON usigned integer & integer comparison is correct\n");
+	else
+		printf("JSON usigned integer & integer comparison failed\n");
+
+	if (!json_object_equal(uint2, int4))
+		printf("JSON usigned integer & integer comparison is correct\n");
+	else
+		printf("JSON usigned integer & integer comparison failed\n");
+
+	if (!json_object_equal(uint4, int2))
+		printf("JSON usigned integer & integer comparison is correct\n");
+	else
+		printf("JSON usigned integer & integer comparison failed\n");
+
+	if (!json_object_equal(uint4, int4))
+		printf("JSON usigned integer & integer comparison is correct\n");
+	else
+		printf("JSON usigned integer & integer comparison failed\n");
+
+	json_object_put(int1);
+	json_object_put(int2);
+	json_object_put(int3);
+	json_object_put(int4);
+	json_object_put(uint1);
+	json_object_put(uint2);
+	json_object_put(uint3);
+	json_object_put(uint4);
+
+	/* string tests */
+	struct json_object *str1 = json_object_new_string("TESTSTRING");
+	struct json_object *str2 = json_object_new_string("TESTSTRING");
+	struct json_object *str3 = json_object_new_string("DIFFERENT");
+
+	if (json_object_equal(str1, str2))
+		printf("Comparing equal strings is correct\n");
+	else
+		printf("Comparing equal strings failed\n");
+
+	if (!json_object_equal(str1, str3))
+		printf("Comparing different strings is correct\n");
+	else
+		printf("Comparing different strings failed\n");
+
+	json_object_put(str1);
+	json_object_put(str2);
+	json_object_put(str3);
+
+	/* double tests */
+	struct json_object *dbl1 = json_object_new_double(3.14159);
+	struct json_object *dbl2 = json_object_new_double(3.14159);
+	struct json_object *dbl3 = json_object_new_double(3.0);
+
+	if (json_object_equal(dbl1, dbl2))
+		printf("Comparing equal doubles is correct\n");
+	else
+		printf("Comparing equal doubles failed\n");
+
+	if (!json_object_equal(dbl1, dbl3))
+		printf("Comparing different doubles is correct\n");
+	else
+		printf("Comparing different doubles failed\n");
+
+	json_object_put(dbl1);
+	json_object_put(dbl2);
+	json_object_put(dbl3);
+
+	/* array tests */
+	struct json_object *ar1 = json_object_new_array();
+	struct json_object *ar2 = json_object_new_array();
+	struct json_object *ar3 = json_object_new_array();
+	struct json_object *ar4 = json_object_new_array();
+
+	json_object_array_add(ar1, json_object_new_int(1));
+	json_object_array_add(ar1, json_object_new_int(2));
+
+	json_object_array_add(ar2, json_object_new_int(1));
+	json_object_array_add(ar2, json_object_new_int(2));
+
+	json_object_array_add(ar3, json_object_new_int(1));
+	json_object_array_add(ar3, json_object_new_int(1));
+
+	if (json_object_equal(ar1, ar2))
+		printf("Comparing equal arrays is correct\n");
+	else
+		printf("Comparing equal arrays failed\n");
+
+	json_object_array_add(ar2, json_object_new_int(1));
+	if (!json_object_equal(ar1, ar2))
+		printf("Comparing arrays of different len is correct\n");
+	else
+		printf("Comparing arrays of different len failed\n");
+
+	if (!json_object_equal(ar1, ar3))
+		printf("Comparing different arrays is correct\n");
+	else
+		printf("Comparing different arrays failed\n");
+
+	if (!json_object_equal(ar1, ar4))
+		printf("Comparing different arrays (one empty) is correct\n");
+	else
+		printf("Comparing different arrays (one empty) failed\n");
+
+	json_object_put(ar1);
+	json_object_put(ar2);
+	json_object_put(ar3);
+	json_object_put(ar4);
+
+	/* object tests */
+	struct json_object *obj1 = json_object_new_object();
+	struct json_object *obj2 = json_object_new_object();
+
+	json_object_object_add(obj1, "test1", json_object_new_int(123));
+	json_object_object_add(obj1, "test2", json_object_new_int(321));
+	json_object_object_add(obj1, "test3", json_object_new_int(320));
+	json_object_object_add(obj1, "test4", json_object_new_int(319));
+	json_object_object_add(obj1, "test5", json_object_new_int(318));
+
+	json_object_object_add(obj2, "test5", json_object_new_int(318));
+	json_object_object_add(obj2, "test4", json_object_new_int(319));
+	json_object_object_add(obj2, "test3", json_object_new_int(320));
+	json_object_object_add(obj2, "test2", json_object_new_int(321));
+	json_object_object_add(obj2, "test1", json_object_new_int(123));
+
+	/* key-order is different between obj1 and obj2, should still be equal */
+	if (json_object_equal(obj1, obj2))
+		printf("Comparing JSON object with different key order is correct\n");
+	else
+		printf("Comparing JSON object with different key order is incorrect\n");
+
+	/* make obj2 look different to obj1 */
+	json_object_object_add(obj2, "test3", json_object_new_int(234));
+	if (!json_object_equal(obj1, obj2))
+		printf("Comparing different objects is correct\n");
+	else
+		printf("Comparing different objects is incorrect\n");
+
+	/* iterate over jso2 keys to see if any exist that are not in jso1 */
+	json_object_object_add(obj2, "test3", json_object_new_int(320));
+	json_object_object_add(obj2, "test6", json_object_new_int(321));
+	if (!json_object_equal(obj1, obj2))
+		printf("Comparing different objects is correct\n");
+	else
+		printf("Comparing different objects is incorrect\n");
+
+	/* iterate over jso1 keys and see if they exist in jso1 */
+	json_object_object_add(obj1, "test6", json_object_new_int(321));
+	if (json_object_equal(obj1, obj2))
+		printf("Comparing different objects is correct\n");
+	else
+		printf("Comparing different objects is incorrect\n");
+	json_object_object_add(obj1, "test7", json_object_new_int(322));
+	if (!json_object_equal(obj1, obj2))
+		printf("Comparing different objects is correct\n");
+	else
+		printf("Comparing different objects is incorrect\n");
+
+	json_object_put(obj1);
+	json_object_put(obj2);
+
+	/* different types tests */
+	struct json_object *int5 = json_object_new_int(0);
+	struct json_object *dbl5 = json_object_new_double(3.14159);
+
+	if (!json_object_equal(int5, NULL))
+		printf("JSON integer and NULL comparison is correct\n");
+	else
+		printf("JSON integer and NULL comparison failed\n");
+
+	if (!json_object_equal(NULL, dbl5))
+		printf("JSON NULL and double comparison is correct\n");
+	else
+		printf("JSON NULL and double comparison failed\n");
+
+	if (!json_object_equal(int5, dbl5))
+		printf("JSON integer and double comparison is correct\n");
+	else
+		printf("JSON integer and double comparison failed\n");
+
+	json_object_put(int5);
+	json_object_put(dbl5);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_compare.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.expected
new file mode 100755
index 0000000..51366d9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.expected
@@ -0,0 +1,30 @@
+JSON integer comparison is correct
+JSON same object comparison is correct
+JSON same integer comparison is correct
+JSON usigned integer comparison is correct
+JSON same usigned object comparison is correct
+JSON same usigned integer comparison is correct
+JSON integer & usigned integer comparison is correct
+JSON integer & usigned integer comparison is correct
+JSON integer & usigned integer comparison is correct
+JSON integer & usigned integer comparison is correct
+JSON usigned integer & integer comparison is correct
+JSON usigned integer & integer comparison is correct
+JSON usigned integer & integer comparison is correct
+JSON usigned integer & integer comparison is correct
+Comparing equal strings is correct
+Comparing different strings is correct
+Comparing equal doubles is correct
+Comparing different doubles is correct
+Comparing equal arrays is correct
+Comparing arrays of different len is correct
+Comparing different arrays is correct
+Comparing different arrays (one empty) is correct
+Comparing JSON object with different key order is correct
+Comparing different objects is correct
+Comparing different objects is correct
+Comparing different objects is correct
+Comparing different objects is correct
+JSON integer and NULL comparison is correct
+JSON NULL and double comparison is correct
+JSON integer and double comparison is correct
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_compare.test b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_compare.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.c b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.c
new file mode 100755
index 0000000..5f03829
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.c
@@ -0,0 +1,261 @@
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <errno.h>
+#include <time.h>
+
+#include "json.h"
+#include "printbuf.h"
+
+static void do_benchmark(json_object *src1);
+
+static const char *json_str1 =
+    "{"
+    "    \"glossary\": {"
+    "        \"title\": \"example glossary\","
+    "        \"GlossDiv\": {"
+    "            \"number\": 16446744073709551615,"
+    "            \"title\": \"S\","
+    "            \"null_obj\": null, "
+    "            \"exist\": false,"
+    "            \"quantity\":20,"
+    "            \"univalent\":19.8,"
+    "            \"GlossList\": {"
+    "                \"GlossEntry\": {"
+    "                    \"ID\": \"SGML\","
+    "                    \"SortAs\": \"SGML\","
+    "                    \"GlossTerm\": \"Standard Generalized Markup Language\","
+    "                    \"Acronym\": \"SGML\","
+    "                    \"Abbrev\": \"ISO 8879:1986\","
+    "                    \"GlossDef\": {"
+    "                        \"para\": \"A meta-markup language, used to create markup languages "
+    "such as DocBook.\","
+    "                        \"GlossSeeAlso\": [\"GML\", \"XML\"]"
+    "                    },"
+    "                    \"GlossSee\": \"markup\""
+    "                }"
+    "            }"
+    "        }"
+    "    }"
+    "}";
+
+static const char *json_str2 =
+    "{\"menu\": {"
+    "    \"header\": \"SVG Viewer\","
+    "    \"items\": ["
+    "        {\"id\": \"Open\"},"
+    "        {\"id\": \"OpenNew\", \"label\": \"Open New\"},"
+    "        null,"
+    "        {\"id\": \"ZoomIn\", \"label\": \"Zoom In\"},"
+    "        {\"id\": \"ZoomOut\", \"label\": \"Zoom Out\"},"
+    "        {\"id\": \"OriginalView\", \"label\": \"Original View\"},"
+    "        null,"
+    "        {\"id\": \"Quality\", \"another_null\": null},"
+    "        {\"id\": \"Pause\"},"
+    "        {\"id\": \"Mute\"},"
+    "        null,"
+    "        {\"id\": \"Find\", \"label\": \"Find...\"},"
+    "        {\"id\": \"FindAgain\", \"label\": \"Find Again\"},"
+    "        {\"id\": \"Copy\"},"
+    "        {\"id\": \"CopyAgain\", \"label\": \"Copy Again\"},"
+    "        {\"id\": \"CopySVG\", \"label\": \"Copy SVG\"},"
+    "        {\"id\": \"ViewSVG\", \"label\": \"View SVG\"},"
+    "        {\"id\": \"ViewSource\", \"label\": \"View Source\"},"
+    "        {\"id\": \"SaveAs\", \"label\": \"Save As\"},"
+    "        null,"
+    "        {\"id\": \"Help\"},"
+    "        {\"id\": \"About\", \"label\": \"About Adobe CVG Viewer...\"}"
+    "    ]"
+    "}}";
+
+static const char *json_str3 = "{\"menu\": {"
+                               "  \"id\": \"file\","
+                               "  \"value\": \"File\","
+                               "  \"popup\": {"
+                               "    \"menuitem\": ["
+                               "      {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},"
+                               "      {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},"
+                               "      {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}"
+                               "    ]"
+                               "  }"
+                               "}}";
+
+json_object_to_json_string_fn my_custom_serializer;
+int my_custom_serializer(struct json_object *jso, struct printbuf *pb, int level, int flags)
+{
+	sprintbuf(pb, "OTHER");
+	return 0;
+}
+
+json_c_shallow_copy_fn my_shallow_copy;
+int my_shallow_copy(json_object *src, json_object *parent, const char *key, size_t index,
+                    json_object **dst)
+{
+	int rc;
+	rc = json_c_shallow_copy_default(src, parent, key, index, dst);
+	if (rc < 0)
+		return rc;
+	if (key != NULL && strcmp(key, "with_serializer") == 0)
+	{
+		printf("CALLED: my_shallow_copy on with_serializer object\n");
+		void *userdata = json_object_get_userdata(src);
+		json_object_set_serializer(*dst, my_custom_serializer, userdata, NULL);
+		return 2;
+	}
+	return rc;
+}
+
+int main(int argc, char **argv)
+{
+	struct json_object *src1, *src2, *src3;
+	struct json_object *dst1 = NULL, *dst2 = NULL, *dst3 = NULL;
+	int benchmark = 0;
+
+	if (argc > 1 && strcmp(argv[1], "--benchmark") == 0)
+	{
+		benchmark = 1;
+	}
+
+	src1 = json_tokener_parse(json_str1);
+	src2 = json_tokener_parse(json_str2);
+	src3 = json_tokener_parse(json_str3);
+
+	assert(src1 != NULL);
+	assert(src2 != NULL);
+	assert(src3 != NULL);
+
+	printf("PASSED - loaded input data\n");
+
+	/* do this 3 times to make sure overwriting it works */
+	assert(0 == json_object_deep_copy(src1, &dst1, NULL));
+	assert(0 == json_object_deep_copy(src2, &dst2, NULL));
+	assert(0 == json_object_deep_copy(src3, &dst3, NULL));
+
+	printf("PASSED - all json_object_deep_copy() returned successful\n");
+
+	assert(-1 == json_object_deep_copy(src1, &dst1, NULL));
+	assert(errno == EINVAL);
+	assert(-1 == json_object_deep_copy(src2, &dst2, NULL));
+	assert(errno == EINVAL);
+	assert(-1 == json_object_deep_copy(src3, &dst3, NULL));
+	assert(errno == EINVAL);
+
+	printf("PASSED - all json_object_deep_copy() returned EINVAL for non-null pointer\n");
+
+	assert(1 == json_object_equal(src1, dst1));
+	assert(1 == json_object_equal(src2, dst2));
+	assert(1 == json_object_equal(src3, dst3));
+
+	printf("PASSED - all json_object_equal() tests returned successful\n");
+
+	assert(0 == strcmp(json_object_to_json_string_ext(src1, JSON_C_TO_STRING_PRETTY),
+	                   json_object_to_json_string_ext(dst1, JSON_C_TO_STRING_PRETTY)));
+	assert(0 == strcmp(json_object_to_json_string_ext(src2, JSON_C_TO_STRING_PRETTY),
+	                   json_object_to_json_string_ext(dst2, JSON_C_TO_STRING_PRETTY)));
+	assert(0 == strcmp(json_object_to_json_string_ext(src3, JSON_C_TO_STRING_PRETTY),
+	                   json_object_to_json_string_ext(dst3, JSON_C_TO_STRING_PRETTY)));
+
+	printf("PASSED - comparison of string output\n");
+
+	json_object_get(dst1);
+	assert(-1 == json_object_deep_copy(src1, &dst1, NULL));
+	assert(errno == EINVAL);
+	json_object_put(dst1);
+
+	printf("PASSED - trying to overrwrite an object that has refcount > 1");
+
+	printf("\nPrinting JSON objects for visual inspection\n");
+	printf("------------------------------------------------\n");
+	printf(" JSON1\n");
+	printf("%s\n", json_object_to_json_string_ext(dst1, JSON_C_TO_STRING_PRETTY));
+	printf("------------------------------------------------\n");
+
+	printf("------------------------------------------------\n");
+	printf(" JSON2\n");
+	printf("%s\n", json_object_to_json_string_ext(dst2, JSON_C_TO_STRING_PRETTY));
+	printf("------------------------------------------------\n");
+
+	printf("------------------------------------------------\n");
+	printf(" JSON3\n");
+	printf("------------------------------------------------\n");
+	printf("%s\n", json_object_to_json_string_ext(dst3, JSON_C_TO_STRING_PRETTY));
+	printf("------------------------------------------------\n");
+
+	json_object_put(dst1);
+	json_object_put(dst2);
+	json_object_put(dst3);
+
+	printf("\nTesting deep_copy with a custom serializer set\n");
+	json_object *with_serializer = json_object_new_string("notemitted");
+
+	char udata[] = "dummy userdata";
+	json_object_set_serializer(with_serializer, my_custom_serializer, udata, NULL);
+	json_object_object_add(src1, "with_serializer", with_serializer);
+	dst1 = NULL;
+	/* With a custom serializer in use, a custom shallow_copy function must also be used */
+	assert(-1 == json_object_deep_copy(src1, &dst1, NULL));
+	assert(0 == json_object_deep_copy(src1, &dst1, my_shallow_copy));
+
+	json_object *dest_with_serializer = json_object_object_get(dst1, "with_serializer");
+	assert(dest_with_serializer != NULL);
+	char *dst_userdata = json_object_get_userdata(dest_with_serializer);
+	assert(strcmp(dst_userdata, "dummy userdata") == 0);
+
+	const char *special_output = json_object_to_json_string(dest_with_serializer);
+	assert(strcmp(special_output, "OTHER") == 0);
+	printf("\ndeep_copy with custom serializer worked OK.\n");
+	json_object_put(dst1);
+
+	if (benchmark)
+	{
+		do_benchmark(src2);
+	}
+
+	json_object_put(src1);
+	json_object_put(src2);
+	json_object_put(src3);
+
+	return 0;
+}
+
+static void do_benchmark(json_object *src2)
+{
+	json_object *dst2 = NULL;
+
+	int ii;
+	/**
+	 * The numbers that I got are:
+	 * BENCHMARK - 1000000 iterations of 'dst2 = json_tokener_parse(json_object_get_string(src2))' took 71 seconds
+	 * BENCHMARK - 1000000 iterations of 'json_object_deep_copy(src2, &dst2, NULL)' took 29 seconds
+	 */
+
+	int iterations = 1000000;
+	time_t start = time(NULL);
+
+	start = time(NULL);
+	for (ii = 0; ii < iterations; ii++)
+	{
+		dst2 = json_tokener_parse(json_object_get_string(src2));
+		json_object_put(dst2);
+	}
+	printf("BENCHMARK - %d iterations of 'dst2 = "
+	       "json_tokener_parse(json_object_get_string(src2))' took %d seconds\n",
+	       iterations, (int)(time(NULL) - start));
+
+	start = time(NULL);
+	dst2 = NULL;
+	for (ii = 0; ii < iterations; ii++)
+	{
+		json_object_deep_copy(src2, &dst2, NULL);
+		json_object_put(dst2);
+		dst2 = NULL;
+	}
+	printf("BENCHMARK - %d iterations of 'json_object_deep_copy(src2, &dst2, NULL)' took %d "
+	       "seconds\n",
+	       iterations, (int)(time(NULL) - start));
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.expected
new file mode 100755
index 0000000..3bd4462
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.expected
@@ -0,0 +1,152 @@
+PASSED - loaded input data
+PASSED - all json_object_deep_copy() returned successful
+PASSED - all json_object_deep_copy() returned EINVAL for non-null pointer
+PASSED - all json_object_equal() tests returned successful
+PASSED - comparison of string output
+PASSED - trying to overrwrite an object that has refcount > 1
+Printing JSON objects for visual inspection
+------------------------------------------------
+ JSON1
+{
+  "glossary":{
+    "title":"example glossary",
+    "GlossDiv":{
+      "number":16446744073709551615,
+      "title":"S",
+      "null_obj":null,
+      "exist":false,
+      "quantity":20,
+      "univalent":19.8,
+      "GlossList":{
+        "GlossEntry":{
+          "ID":"SGML",
+          "SortAs":"SGML",
+          "GlossTerm":"Standard Generalized Markup Language",
+          "Acronym":"SGML",
+          "Abbrev":"ISO 8879:1986",
+          "GlossDef":{
+            "para":"A meta-markup language, used to create markup languages such as DocBook.",
+            "GlossSeeAlso":[
+              "GML",
+              "XML"
+            ]
+          },
+          "GlossSee":"markup"
+        }
+      }
+    }
+  }
+}
+------------------------------------------------
+------------------------------------------------
+ JSON2
+{
+  "menu":{
+    "header":"SVG Viewer",
+    "items":[
+      {
+        "id":"Open"
+      },
+      {
+        "id":"OpenNew",
+        "label":"Open New"
+      },
+      null,
+      {
+        "id":"ZoomIn",
+        "label":"Zoom In"
+      },
+      {
+        "id":"ZoomOut",
+        "label":"Zoom Out"
+      },
+      {
+        "id":"OriginalView",
+        "label":"Original View"
+      },
+      null,
+      {
+        "id":"Quality",
+        "another_null":null
+      },
+      {
+        "id":"Pause"
+      },
+      {
+        "id":"Mute"
+      },
+      null,
+      {
+        "id":"Find",
+        "label":"Find..."
+      },
+      {
+        "id":"FindAgain",
+        "label":"Find Again"
+      },
+      {
+        "id":"Copy"
+      },
+      {
+        "id":"CopyAgain",
+        "label":"Copy Again"
+      },
+      {
+        "id":"CopySVG",
+        "label":"Copy SVG"
+      },
+      {
+        "id":"ViewSVG",
+        "label":"View SVG"
+      },
+      {
+        "id":"ViewSource",
+        "label":"View Source"
+      },
+      {
+        "id":"SaveAs",
+        "label":"Save As"
+      },
+      null,
+      {
+        "id":"Help"
+      },
+      {
+        "id":"About",
+        "label":"About Adobe CVG Viewer..."
+      }
+    ]
+  }
+}
+------------------------------------------------
+------------------------------------------------
+ JSON3
+------------------------------------------------
+{
+  "menu":{
+    "id":"file",
+    "value":"File",
+    "popup":{
+      "menuitem":[
+        {
+          "value":"New",
+          "onclick":"CreateNewDoc()"
+        },
+        {
+          "value":"Open",
+          "onclick":"OpenDoc()"
+        },
+        {
+          "value":"Close",
+          "onclick":"CloseDoc()"
+        }
+      ]
+    }
+  }
+}
+------------------------------------------------
+
+Testing deep_copy with a custom serializer set
+CALLED: my_shallow_copy on with_serializer object
+
+deep_copy with custom serializer worked OK.
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.test b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_deep_copy.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.c b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.c
new file mode 100755
index 0000000..59e95c2
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.c
@@ -0,0 +1,113 @@
+/*
+* Tests if the format string for double serialization is handled correctly
+*/
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <stdio.h>
+
+#include "json_object.h"
+#include "json_object_private.h"
+
+/* Avoid compiler warnings about diving by constant zero */
+double zero_dot_zero = 0.0;
+
+int main(int argc, char **argv)
+{
+	struct json_object *obj = json_object_new_double(0.5);
+	char udata[] = "test";
+
+	printf("Test default serializer:\n");
+	printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj));
+
+	printf("Test default serializer with custom userdata:\n");
+	obj->_userdata = udata;
+	printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj));
+
+	printf("Test explicit serializer with custom userdata:\n");
+	json_object_set_serializer(obj, json_object_double_to_json_string, udata, NULL);
+	printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj));
+
+	printf("Test reset serializer:\n");
+	json_object_set_serializer(obj, NULL, NULL, NULL);
+	printf("obj.to_string(reset)=%s\n", json_object_to_json_string(obj));
+
+	json_object_put(obj);
+	printf("Test no zero reset serializer:\n");
+	obj = json_object_new_double(3.1415000);
+	char data[] = "%.17g";
+	json_object_set_serializer(obj, json_object_double_to_json_string, data, NULL);
+	printf("obj.to_string(reset)=%s\n", json_object_to_json_string_ext(obj, 4));
+
+	json_object_put(obj);
+	obj = json_object_new_double(0.52381);
+
+	printf("obj.to_string(default format)=%s\n", json_object_to_json_string(obj));
+	if (json_c_set_serialization_double_format("x%0.3fy", JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj.to_string(with global format)=%s\n", json_object_to_json_string(obj));
+#ifdef HAVE___THREAD
+	if (json_c_set_serialization_double_format("T%0.2fX", JSON_C_OPTION_THREAD) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj.to_string(with thread format)=%s\n", json_object_to_json_string(obj));
+	if (json_c_set_serialization_double_format("Ttttttttttttt%0.2fxxxxxxxxxxxxxxxxxxX",
+	                                           JSON_C_OPTION_THREAD) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj.to_string(long thread format)=%s\n", json_object_to_json_string(obj));
+	if (json_c_set_serialization_double_format(NULL, JSON_C_OPTION_THREAD) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj.to_string(back to global format)=%s\n", json_object_to_json_string(obj));
+#else
+	// Just fake it up, so the output matches.
+	printf("obj.to_string(with thread format)=%s\n", "T0.52X");
+	printf("obj.to_string(long thread format)=%s\n", "Ttttttttttttt0.52xxxxxxxxxxxxxxxxxxX");
+	printf("obj.to_string(back to global format)=%s\n", "x0.524y");
+#endif
+	if (json_c_set_serialization_double_format(NULL, JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj.to_string(back to default format)=%s\n", json_object_to_json_string(obj));
+
+	json_object_put(obj);
+
+	obj = json_object_new_double(12.0);
+	printf("obj(12.0).to_string(default format)=%s\n", json_object_to_json_string(obj));
+	if (json_c_set_serialization_double_format("%.0f", JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj(12.0).to_string(%%.0f)=%s\n", json_object_to_json_string(obj));
+
+	if (json_c_set_serialization_double_format("%.0g", JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj(12.0).to_string(%%.0g)=%s\n", json_object_to_json_string(obj));
+
+	if (json_c_set_serialization_double_format("%.2g", JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+	printf("obj(12.0).to_string(%%.1g)=%s\n", json_object_to_json_string(obj));
+
+	// Reset to default to free memory
+	if (json_c_set_serialization_double_format(NULL, JSON_C_OPTION_GLOBAL) < 0)
+		printf("ERROR: json_c_set_serialization_double_format() failed");
+
+	json_object_put(obj);
+
+	obj = json_object_new_double(-12.0);
+	printf("obj(-12.0).to_string(default format)=%s\n", json_object_to_json_string(obj));
+	json_object_put(obj);
+
+	/* Test NaN handling */
+	obj = json_object_new_double(zero_dot_zero / zero_dot_zero);
+	printf("obj(0.0/0.0)=%s\n", json_object_to_json_string(obj));
+	json_object_put(obj);
+
+	/* Test Infinity and -Infinity handling */
+	obj = json_object_new_double(1.0 / zero_dot_zero);
+	printf("obj(1.0/0.0)=%s\n", json_object_to_json_string(obj));
+	json_object_put(obj);
+
+	obj = json_object_new_double(-1.0 / zero_dot_zero);
+	printf("obj(-1.0/0.0)=%s\n", json_object_to_json_string(obj));
+	json_object_put(obj);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.expected
new file mode 100755
index 0000000..8e3b7e4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.expected
@@ -0,0 +1,24 @@
+Test default serializer:
+obj.to_string(standard)=0.5
+Test default serializer with custom userdata:
+obj.to_string(userdata)=0.5
+Test explicit serializer with custom userdata:
+obj.to_string(custom)=test
+Test reset serializer:
+obj.to_string(reset)=0.5
+Test no zero reset serializer:
+obj.to_string(reset)=3.1415000000000002
+obj.to_string(default format)=0.52381
+obj.to_string(with global format)=x0.524y
+obj.to_string(with thread format)=T0.52X
+obj.to_string(long thread format)=Ttttttttttttt0.52xxxxxxxxxxxxxxxxxxX
+obj.to_string(back to global format)=x0.524y
+obj.to_string(back to default format)=0.52381
+obj(12.0).to_string(default format)=12.0
+obj(12.0).to_string(%.0f)=12
+obj(12.0).to_string(%.0g)=1e+01
+obj(12.0).to_string(%.1g)=12.0
+obj(-12.0).to_string(default format)=-12.0
+obj(0.0/0.0)=NaN
+obj(1.0/0.0)=Infinity
+obj(-1.0/0.0)=-Infinity
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.test b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_double_serializer.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_float.c b/lynq/S300/ap/app/apparms/json-c/tests/test_float.c
new file mode 100755
index 0000000..68a763d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_float.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2016 by Rainer Gerhards
+ * Released under ASL 2.0 */
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include "json_object.h"
+#include "json_tokener.h"
+#include <stdio.h>
+int main(void)
+{
+	json_object *json;
+
+	json = json_object_new_double(1.0);
+	printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+	json_object_put(json);
+
+	json = json_object_new_double(-1.0);
+	printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+	json_object_put(json);
+	json = json_object_new_double(1.23);
+	printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+	json_object_put(json);
+	json = json_object_new_double(123456789.0);
+	printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+	json_object_put(json);
+	json = json_object_new_double(123456789.123);
+	printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
+	json_object_put(json);
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_float.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_float.expected
new file mode 100755
index 0000000..7ca5916
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_float.expected
@@ -0,0 +1,5 @@
+json = 1.0
+json = -1.0
+json = 1.23
+json = 123456789.0
+json = 123456789.123
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_float.test b/lynq/S300/ap/app/apparms/json-c/tests/test_float.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_float.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.c b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.c
new file mode 100755
index 0000000..142feac
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.c
@@ -0,0 +1,74 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stdio.h>
+
+#include "json.h"
+
+int main(int argc, char **argv)
+{
+	json_object *tmp = json_object_new_int(123);
+	json_object_int_inc(tmp, 123);
+	assert(json_object_get_int(tmp) == 246);
+	json_object_put(tmp);
+	printf("INT ADD PASSED\n");
+	tmp = json_object_new_int(INT32_MAX);
+	json_object_int_inc(tmp, 100);
+	assert(json_object_get_int(tmp) == INT32_MAX);
+	assert(json_object_get_int64(tmp) == (int64_t)INT32_MAX + 100L);
+	json_object_put(tmp);
+	printf("INT ADD OVERFLOW PASSED\n");
+	tmp = json_object_new_int(INT32_MIN);
+	json_object_int_inc(tmp, -100);
+	assert(json_object_get_int(tmp) == INT32_MIN);
+	assert(json_object_get_int64(tmp) == (int64_t)INT32_MIN - 100L);
+	json_object_put(tmp);
+	printf("INT ADD UNDERFLOW PASSED\n");
+	tmp = json_object_new_int64(321321321);
+	json_object_int_inc(tmp, 321321321);
+	assert(json_object_get_int(tmp) == 642642642);
+	json_object_put(tmp);
+	printf("INT64 ADD PASSED\n");
+	tmp = json_object_new_int64(INT64_MAX);
+	json_object_int_inc(tmp, 100);
+	assert(json_object_get_int64(tmp) == INT64_MAX);
+	assert(json_object_get_uint64(tmp) == (uint64_t)INT64_MAX + 100U);
+	json_object_int_inc(tmp, -100);
+	assert(json_object_get_int64(tmp) == INT64_MAX);
+	assert(json_object_get_uint64(tmp) == (uint64_t)INT64_MAX);
+	json_object_put(tmp);
+	printf("INT64 ADD OVERFLOW PASSED\n");
+	tmp = json_object_new_int64(INT64_MIN);
+	json_object_int_inc(tmp, -100);
+	assert(json_object_get_int64(tmp) == INT64_MIN);
+	json_object_int_inc(tmp, 100);
+	assert(json_object_get_int64(tmp) != INT64_MIN);
+	json_object_put(tmp);
+	printf("INT64 ADD UNDERFLOW PASSED\n");
+	// uint64 + negative int64--> negative int64
+	tmp = json_object_new_uint64(400);
+	json_object_int_inc(tmp, -200);
+	assert(json_object_get_int64(tmp) == 200);
+	assert(json_object_get_uint64(tmp) == 200);
+	json_object_int_inc(tmp, 200);
+	assert(json_object_get_int64(tmp) == 400);
+	assert(json_object_get_uint64(tmp) == 400);
+	json_object_put(tmp);
+	printf("UINT64 ADD PASSED\n");
+	tmp = json_object_new_uint64(UINT64_MAX-50);
+	json_object_int_inc(tmp, 100);
+	assert(json_object_get_int64(tmp) == INT64_MAX);
+	assert(json_object_get_uint64(tmp) == UINT64_MAX);
+	json_object_put(tmp);
+	printf("UINT64 ADD OVERFLOW PASSED\n");
+	tmp = json_object_new_uint64(100);
+	json_object_int_inc(tmp, -200);
+	assert(json_object_get_int64(tmp) == -100);
+	assert(json_object_get_uint64(tmp) == 0);
+	json_object_put(tmp);
+	printf("UINT64 ADD UNDERFLOW PASSED\n");
+
+	printf("PASSED\n");
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.expected
new file mode 100755
index 0000000..f9348d4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.expected
@@ -0,0 +1,10 @@
+INT ADD PASSED
+INT ADD OVERFLOW PASSED
+INT ADD UNDERFLOW PASSED
+INT64 ADD PASSED
+INT64 ADD OVERFLOW PASSED
+INT64 ADD UNDERFLOW PASSED
+UINT64 ADD PASSED
+UINT64 ADD OVERFLOW PASSED
+UINT64 ADD UNDERFLOW PASSED
+PASSED
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.test b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_add.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.c b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.c
new file mode 100755
index 0000000..be30364
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.c
@@ -0,0 +1,65 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "json.h"
+
+#define I64_MAX_S "9223372036854775807"
+#define I64_OVER  "9223372036854775808"
+#define I64_MIN_S "-9223372036854775808"
+#define I64_UNDER "-9223372036854775809"
+#define U64_MAX_S "18446744073709551615"
+#define U64_OUT_S "18446744073709551616"
+
+#define CHECK_GET(GET_F, J, EXPECTED)     { struct json_object *jtmp = J; errno = 0; assert(GET_F(jtmp) == EXPECTED); json_object_put(jtmp); }
+#define CHECK_GET_INT(J, EXPECTED)        CHECK_GET(json_object_get_int,    J, EXPECTED)
+#define CHECK_GET_INT64(J, EXPECTED)      CHECK_GET(json_object_get_int64,  J, EXPECTED)
+#define CHECK_GET_UINT64(J, EXPECTED)     CHECK_GET(json_object_get_uint64, J, EXPECTED)
+
+#define CHECK_BASE(J, EXPECTED)						CHECK_GET_INT(J, EXPECTED); CHECK_GET_INT64(J, EXPECTED); CHECK_GET_UINT64(J, EXPECTED)
+
+#define N_INT     json_object_new_int
+#define N_I64     json_object_new_int64
+#define N_U64     json_object_new_uint64
+#define N_STR     json_object_new_string
+
+int main(int argc, char **argv)
+{
+	CHECK_BASE(N_INT(5), 5);
+	CHECK_BASE(N_INT(0), 0);
+	CHECK_BASE(N_STR("0"), 0);
+	CHECK_BASE(N_STR("00000"), 0);
+	CHECK_BASE(N_STR("000004568789"), 4568789);
+	CHECK_BASE(N_STR("0xFF"), 0 && errno == 0); // Hex-string values being parsed as 0 is the intended behavior
+	CHECK_BASE(N_STR("333this_seems_a_valid_string"), 333);
+	CHECK_BASE(N_STR("this_is_not_a_number"), 0 && errno == EINVAL);
+	CHECK_BASE(N_STR("B0"), 0 && errno == EINVAL);
+	printf("BASE CHECK PASSED\n");
+
+	CHECK_GET_INT(N_I64(INT32_MAX), INT32_MAX && errno == 0);
+	CHECK_GET_INT(N_I64(INT32_MIN), INT32_MIN && errno == 0);
+	CHECK_GET_INT(N_I64(INT64_MAX), INT32_MAX && errno == 0);
+	CHECK_GET_INT(N_I64(INT64_MIN), INT32_MIN && errno == 0);
+	CHECK_GET_INT(N_STR(I64_MAX_S), INT32_MAX && errno == 0);
+	CHECK_GET_INT(N_STR(I64_MIN_S), INT32_MIN && errno == 0);
+	printf("INT GET PASSED\n");
+
+	CHECK_GET_INT64(N_I64(INT64_MAX), INT64_MAX && errno == 0);
+	CHECK_GET_INT64(N_I64(INT64_MIN), INT64_MIN && errno == 0);
+	CHECK_GET_INT64(N_STR(I64_MAX_S), INT64_MAX && errno == 0);
+	CHECK_GET_INT64(N_STR(I64_MIN_S), INT64_MIN && errno == 0);
+	CHECK_GET_INT64(N_STR(I64_OVER),  INT64_MAX && errno == ERANGE);
+	CHECK_GET_INT64(N_STR(I64_UNDER), INT64_MIN && errno == ERANGE);
+	printf("INT64 GET PASSED\n");
+
+	CHECK_GET_UINT64(N_U64(UINT64_MAX), UINT64_MAX && errno == 0);
+	CHECK_GET_UINT64(N_U64(-1),         UINT64_MAX && errno == 0);
+	CHECK_GET_UINT64(N_STR(U64_OUT_S),  UINT64_MAX && errno == ERANGE);
+	printf("UINT64 GET PASSED\n");
+
+	printf("PASSED\n");
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.expected
new file mode 100755
index 0000000..a9d78bf
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.expected
@@ -0,0 +1,5 @@
+BASE CHECK PASSED
+INT GET PASSED
+INT64 GET PASSED
+UINT64 GET PASSED
+PASSED
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.test b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_int_get.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.c b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.c
new file mode 100755
index 0000000..4ac78cb
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.c
@@ -0,0 +1,328 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "json.h"
+
+static void test_example_int(struct json_object *jo1, const char *json_pointer, int expected_int)
+{
+	struct json_object *jo2 = NULL;
+	assert(0 == json_pointer_get(jo1, json_pointer, NULL));
+	assert(0 == json_pointer_get(jo1, json_pointer, &jo2));
+	assert(json_object_is_type(jo2, json_type_int));
+	assert(expected_int == json_object_get_int(jo2));
+	printf("PASSED - GET -  %s == %d\n", json_pointer, expected_int);
+}
+
+static const char *input_json_str = "{ "
+                                    "'foo': ['bar', 'baz'], "
+                                    "'': 0, "
+                                    "'a/b': 1, "
+                                    "'c%d': 2, "
+                                    "'e^f': 3, "
+                                    "'g|h': 4, "
+                                    "'i\\\\j': 5, "
+                                    "'k\\\"l': 6, "
+                                    "' ': 7, "
+                                    "'m~n': 8 "
+                                    "}";
+
+/* clang-format off */
+static const char *rec_input_json_str =
+    "{"
+	    "'arr' : ["
+		    "{"
+			    "'obj': ["
+				    "{},{},"
+					"{"
+					    "'obj1': 0,"
+					    "'obj2': \"1\""
+				    "}"
+			    "]"
+		    "}"
+	    "],"
+	    "'obj' : {"
+		    "'obj': {"
+			    "'obj': ["
+				    "{"
+					    "'obj1': 0,"
+					    "'obj2': \"1\""
+				    "}"
+			    "]"
+		    "}"
+	    "}"
+    "}";
+/* clang-format on */
+
+/* Example from RFC */
+static void test_example_get(void)
+{
+	int i;
+	struct json_object *jo1, *jo2, *jo3;
+	struct json_pointer_map_s_i
+	{
+		const char *s;
+		int i;
+	};
+	/* Create a map to iterate over for the ints */
+	/* clang-format off */
+	struct json_pointer_map_s_i json_pointers[] = {
+		{ "/", 0 },
+		{ "/a~1b", 1 },
+		{"/c%d", 2 },
+		{"/e^f", 3 },
+		{ "/g|h", 4 },
+		{ "/i\\j", 5 },
+		{ "/k\"l", 6 },
+		{ "/ ", 7 },
+		{ "/m~0n", 8 },
+		{ NULL, 0}
+	};
+	/* clang-format on */
+
+	jo1 = json_tokener_parse(input_json_str);
+	assert(NULL != jo1);
+	printf("PASSED - GET - LOADED TEST JSON\n");
+	printf("%s\n", json_object_get_string(jo1));
+
+	/* Test empty string returns entire object */
+	jo2 = NULL;
+	/* For each test, we're trying to see that NULL **value works (does no segfault) */
+	assert(0 == json_pointer_get(jo1, "", NULL));
+	assert(0 == json_pointer_get(jo1, "", &jo2));
+	assert(json_object_equal(jo2, jo1));
+	printf("PASSED - GET - ENTIRE OBJECT WORKED\n");
+
+	/* Test /foo == ['bar', 'baz']  */
+	jo3 = json_object_new_array();
+	json_object_array_add(jo3, json_object_new_string("bar"));
+	json_object_array_add(jo3, json_object_new_string("baz"));
+
+	jo2 = NULL;
+	assert(0 == json_pointer_get(jo1, "/foo", NULL));
+	assert(0 == json_pointer_get(jo1, "/foo", &jo2));
+	assert(NULL != jo2);
+	assert(json_object_equal(jo2, jo3));
+	json_object_put(jo3);
+	printf("PASSED - GET - /foo == ['bar', 'baz']\n");
+
+	/* Test /foo/0 == 'bar' */
+	jo2 = NULL;
+	assert(0 == json_pointer_get(jo1, "/foo/0", NULL));
+	assert(0 == json_pointer_get(jo1, "/foo/0", &jo2));
+	assert(NULL != jo2);
+	assert(0 == strcmp("bar", json_object_get_string(jo2)));
+	printf("PASSED - GET - /foo/0 == 'bar'\n");
+
+	for (i = 0; json_pointers[i].s; i++)
+		test_example_int(jo1, json_pointers[i].s, json_pointers[i].i);
+
+	json_object_put(jo1);
+}
+
+/* I'm not too happy with the RFC example to test the recursion of the json_pointer_get() function */
+static void test_recursion_get(void)
+{
+	struct json_object *jo2, *jo1 = json_tokener_parse(rec_input_json_str);
+
+	jo2 = NULL;
+	assert(jo1 != NULL);
+	printf("%s\n", json_object_get_string(jo1));
+	assert(0 == json_pointer_get(jo1, "/arr/0/obj/2/obj1", &jo2));
+	assert(json_object_is_type(jo2, json_type_int));
+	assert(0 == json_object_get_int(jo2));
+
+	assert(0 == json_pointer_get(jo1, "/arr/0/obj/2/obj2", &jo2));
+	assert(json_object_is_type(jo2, json_type_string));
+	assert(0 == strcmp("1", json_object_get_string(jo2)));
+
+	assert(0 == json_pointer_getf(jo1, &jo2, "/%s/%d/%s/%d/%s", "arr", 0, "obj", 2, "obj2"));
+	assert(json_object_is_type(jo2, json_type_string));
+	assert(0 == strcmp("1", json_object_get_string(jo2)));
+
+	assert(jo1 != NULL);
+	assert(0 == json_pointer_get(jo1, "/obj/obj/obj/0/obj1", &jo2));
+	assert(json_object_is_type(jo2, json_type_int));
+	assert(0 == json_object_get_int(jo2));
+
+	assert(0 == json_pointer_get(jo1, "/obj/obj/obj/0/obj2", &jo2));
+	assert(json_object_is_type(jo2, json_type_string));
+	assert(0 == strcmp("1", json_object_get_string(jo2)));
+
+	assert(0 == json_pointer_getf(jo1, &jo2, "%s", "\0"));
+
+	printf("PASSED - GET - RECURSION TEST\n");
+
+	json_object_put(jo1);
+}
+
+static void test_wrong_inputs_get(void)
+{
+	struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
+
+	assert(NULL != jo1);
+	printf("PASSED - GET - LOADED TEST JSON\n");
+	printf("%s\n", json_object_get_string(jo1));
+
+	/* Test leading '/' missing */
+	jo2 = NULL;
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "foo/bar", NULL));
+	assert(0 != json_pointer_get(jo1, "foo/bar", &jo2));
+	assert(errno == EINVAL);
+	assert(jo2 == NULL);
+	printf("PASSED - GET - MISSING /\n");
+
+	/* Test combinations of NULL params for input json & path */
+	errno = 0;
+	assert(0 != json_pointer_get(NULL, "foo/bar", NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_get(NULL, NULL, NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_getf(NULL, NULL, NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, NULL, NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_getf(jo1, NULL, NULL));
+	assert(errno == EINVAL);
+	printf("PASSED - GET - NULL INPUTS\n");
+
+	/* Test invalid indexes for array */
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "/foo/a", NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "/foo/01", NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_getf(jo1, NULL, "/%s/a", "foo"));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "/foo/-", NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	/* Test optimized array path */
+	assert(0 != json_pointer_get(jo1, "/foo/4", NULL));
+	assert(errno == ENOENT);
+	errno = 0;
+	/* Test non-optimized array path */
+	assert(0 != json_pointer_getf(jo1, NULL, "%s", "/foo/22"));
+	assert(errno == ENOENT);
+	errno = 0;
+	assert(0 != json_pointer_getf(jo1, NULL, "/%s/%d", "foo", 22));
+	assert(errno == ENOENT);
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "/foo/-1", NULL));
+	assert(errno == EINVAL);
+	errno = 0;
+	assert(0 != json_pointer_get(jo1, "/foo/10", NULL));
+	assert(errno == ENOENT);
+	printf("PASSED - GET - INVALID INDEXES\n");
+
+	json_object_put(jo1);
+}
+
+static void test_example_set(void)
+{
+	struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
+
+	assert(jo1 != NULL);
+	printf("PASSED - SET - LOADED TEST JSON\n");
+	printf("%s\n", json_object_get_string(jo1));
+
+	assert(0 == json_pointer_set(&jo1, "/foo/1", json_object_new_string("cod")));
+	assert(0 == strcmp("cod", json_object_get_string(json_object_array_get_idx(
+	                              json_object_object_get(jo1, "foo"), 1))));
+	printf("PASSED - SET - 'cod' in /foo/1\n");
+	assert(0 != json_pointer_set(&jo1, "/fud/gaw", (jo2 = json_tokener_parse("[1,2,3]"))));
+	assert(errno == ENOENT);
+	printf("PASSED - SET - non-existing /fud/gaw\n");
+	assert(0 == json_pointer_set(&jo1, "/fud", json_object_new_object()));
+	printf("PASSED - SET - /fud == {}\n");
+	assert(0 == json_pointer_set(&jo1, "/fud/gaw", jo2)); /* re-using jo2 from above */
+	printf("PASSED - SET - /fug/gaw == [1,2,3]\n");
+	assert(0 == json_pointer_set(&jo1, "/fud/gaw/0", json_object_new_int(0)));
+	assert(0 == json_pointer_setf(&jo1, json_object_new_int(0), "%s%s/%d", "/fud", "/gaw", 0));
+	printf("PASSED - SET - /fug/gaw == [0,2,3]\n");
+	assert(0 == json_pointer_set(&jo1, "/fud/gaw/-", json_object_new_int(4)));
+	printf("PASSED - SET - /fug/gaw == [0,2,3,4]\n");
+	assert(0 == json_pointer_set(&jo1, "/", json_object_new_int(9)));
+	printf("PASSED - SET - / == 9\n");
+
+	jo2 = json_tokener_parse(
+	    "{ 'foo': [ 'bar', 'cod' ], '': 9, 'a/b': 1, 'c%d': 2, 'e^f': 3, 'g|h': 4, 'i\\\\j': "
+	    "5, 'k\\\"l': 6, ' ': 7, 'm~n': 8, 'fud': { 'gaw': [ 0, 2, 3, 4 ] } }");
+	assert(json_object_equal(jo2, jo1));
+	printf("PASSED - SET - Final JSON is: %s\n", json_object_get_string(jo1));
+	json_object_put(jo2);
+
+	assert(0 == json_pointer_set(&jo1, "", json_object_new_int(10)));
+	assert(10 == json_object_get_int(jo1));
+	printf("%s\n", json_object_get_string(jo1));
+
+	json_object_put(jo1);
+}
+
+static void test_wrong_inputs_set(void)
+{
+	struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
+
+	assert(jo1 != NULL);
+	printf("PASSED - SET - LOADED TEST JSON\n");
+	printf("%s\n", json_object_get_string(jo1));
+
+	assert(0 != json_pointer_set(NULL, NULL, NULL));
+	assert(0 != json_pointer_setf(NULL, NULL, NULL));
+	assert(0 != json_pointer_set(&jo1, NULL, NULL));
+	assert(0 != json_pointer_setf(&jo1, NULL, NULL));
+	printf("PASSED - SET - failed with NULL params for input json & path\n");
+
+	assert(0 != json_pointer_set(&jo1, "foo/bar", (jo2 = json_object_new_string("cod"))));
+	printf("PASSED - SET - failed 'cod' with path 'foo/bar'\n");
+	json_object_put(jo2);
+
+	assert(0 !=
+	       json_pointer_setf(&jo1, (jo2 = json_object_new_string("cod")), "%s", "foo/bar"));
+	printf("PASSED - SET - failed 'cod' with path 'foo/bar'\n");
+	json_object_put(jo2);
+
+	assert(0 != json_pointer_set(&jo1, "0", (jo2 = json_object_new_string("cod"))));
+	printf("PASSED - SET - failed with invalid array index'\n");
+	json_object_put(jo2);
+
+	jo2 = json_object_new_string("whatever");
+	assert(0 != json_pointer_set(&jo1, "/fud/gaw", jo2));
+	assert(0 == json_pointer_set(&jo1, "/fud", json_object_new_object()));
+	assert(0 == json_pointer_set(&jo1, "/fud/gaw", jo2)); /* re-using jo2 from above */
+	// ownership of jo2 transferred into jo1
+
+	jo2 = json_object_new_int(0);
+	assert(0 != json_pointer_set(&jo1, "/fud/gaw/0", jo2));
+	json_object_put(jo2);
+	jo2 = json_object_new_int(0);
+	assert(0 != json_pointer_set(&jo1, "/fud/gaw/", jo2));
+	json_object_put(jo2);
+	printf("PASSED - SET - failed to set index to non-array\n");
+
+	assert(0 == json_pointer_setf(&jo1, json_object_new_string("cod"), "%s", "\0"));
+
+	json_object_put(jo1);
+}
+
+int main(int argc, char **argv)
+{
+	test_example_get();
+	test_recursion_get();
+	test_wrong_inputs_get();
+	test_example_set();
+	test_wrong_inputs_set();
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.expected
new file mode 100755
index 0000000..7cb158e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.expected
@@ -0,0 +1,39 @@
+PASSED - GET - LOADED TEST JSON
+{ "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 }
+PASSED - GET - ENTIRE OBJECT WORKED
+PASSED - GET - /foo == ['bar', 'baz']
+PASSED - GET - /foo/0 == 'bar'
+PASSED - GET -  / == 0
+PASSED - GET -  /a~1b == 1
+PASSED - GET -  /c%d == 2
+PASSED - GET -  /e^f == 3
+PASSED - GET -  /g|h == 4
+PASSED - GET -  /i\j == 5
+PASSED - GET -  /k"l == 6
+PASSED - GET -  /  == 7
+PASSED - GET -  /m~0n == 8
+{ "arr": [ { "obj": [ { }, { }, { "obj1": 0, "obj2": "1" } ] } ], "obj": { "obj": { "obj": [ { "obj1": 0, "obj2": "1" } ] } } }
+PASSED - GET - RECURSION TEST
+PASSED - GET - LOADED TEST JSON
+{ "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 }
+PASSED - GET - MISSING /
+PASSED - GET - NULL INPUTS
+PASSED - GET - INVALID INDEXES
+PASSED - SET - LOADED TEST JSON
+{ "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 }
+PASSED - SET - 'cod' in /foo/1
+PASSED - SET - non-existing /fud/gaw
+PASSED - SET - /fud == {}
+PASSED - SET - /fug/gaw == [1,2,3]
+PASSED - SET - /fug/gaw == [0,2,3]
+PASSED - SET - /fug/gaw == [0,2,3,4]
+PASSED - SET - / == 9
+PASSED - SET - Final JSON is: { "foo": [ "bar", "cod" ], "": 9, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8, "fud": { "gaw": [ 0, 2, 3, 4 ] } }
+10
+PASSED - SET - LOADED TEST JSON
+{ "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 }
+PASSED - SET - failed with NULL params for input json & path
+PASSED - SET - failed 'cod' with path 'foo/bar'
+PASSED - SET - failed 'cod' with path 'foo/bar'
+PASSED - SET - failed with invalid array index'
+PASSED - SET - failed to set index to non-array
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.test b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_json_pointer.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_locale.c b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.c
new file mode 100755
index 0000000..79f6c2c
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.c
@@ -0,0 +1,64 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+#include "json.h"
+#include "json_tokener.h"
+#include "snprintf_compat.h"
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif /* HAVE_LOCALE_H */
+#ifdef HAVE_XLOCALE_H
+#include <xlocale.h>
+#endif
+
+int main(int argc, char **argv)
+{
+	json_object *new_obj;
+#ifdef HAVE_SETLOCALE
+	setlocale(LC_NUMERIC, "de_DE");
+#endif
+
+	char buf1[10], buf2[10];
+	// Should result in "0,1", if the locale is installed.
+	// Regardless of what it generates, we check that it's
+	// consistent below.
+	(void)snprintf(buf1, sizeof(buf1), "%f", 0.1);
+
+	MC_SET_DEBUG(1);
+
+	new_obj = json_tokener_parse("[1.2,3.4,123456.78,5.0,2.3e10]");
+
+	(void)snprintf(buf2, sizeof(buf2), "%f", 0.1);
+	if (strcmp(buf1, buf2) != 0)
+		printf("ERROR: Original locale not restored \"%s\" != \"%s\"", buf1, buf2);
+
+#ifdef HAVE_SETLOCALE
+	setlocale(LC_NUMERIC, "C");
+#endif
+
+	// Explicitly print each value, to avoid having the "special"
+	// serialization done for parsed doubles simply re-emit the original
+	// string that was parsed.  (see json_object_new_double_s())
+	printf("new_obj.to_string()=[");
+	unsigned int ii;
+	for (ii = 0; ii < json_object_array_length(new_obj); ii++)
+	{
+		json_object *val = json_object_array_get_idx(new_obj, ii);
+		printf("%s%.2lf", (ii > 0) ? "," : "", json_object_get_double(val));
+	}
+	printf("]\n");
+
+	printf("new_obj.to_string()=%s\n",
+	       json_object_to_json_string_ext(new_obj, JSON_C_TO_STRING_NOZERO));
+	json_object_put(new_obj);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_locale.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.expected
new file mode 100755
index 0000000..3579ef1
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.expected
@@ -0,0 +1,2 @@
+new_obj.to_string()=[1.20,3.40,123456.78,5.00,23000000000.00]
+new_obj.to_string()=[1.2,3.4,123456.78,5.0,2.3e10]
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_locale.test b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_locale.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_null.c b/lynq/S300/ap/app/apparms/json-c/tests/test_null.c
new file mode 100755
index 0000000..d2a0ddc
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_null.c
@@ -0,0 +1,62 @@
+/*
+ * Tests if binary strings are supported.
+ */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+
+#include "json_inttypes.h"
+#include "json_object.h"
+#include "json_tokener.h"
+
+int main(void)
+{
+	/* this test has a space after the null character. check that it's still included */
+	const char *input = " \0 ";
+	const char *expected = "\" \\u0000 \"";
+	struct json_object *string = json_object_new_string_len(input, 3);
+	const char *json = json_object_to_json_string(string);
+
+	int strings_match = !strcmp(expected, json);
+	int retval = 0;
+	if (strings_match)
+	{
+		printf("JSON write result is correct: %s\n", json);
+		puts("PASS");
+	}
+	else
+	{
+		puts("JSON write result doesn't match expected string");
+		printf("expected string: ");
+		puts(expected);
+		printf("parsed string:   ");
+		puts(json);
+		puts("FAIL");
+		retval = 1;
+	}
+	json_object_put(string);
+
+	struct json_object *parsed_str = json_tokener_parse(expected);
+	if (parsed_str)
+	{
+		int parsed_len = json_object_get_string_len(parsed_str);
+		const char *parsed_cstr = json_object_get_string(parsed_str);
+		int ii;
+		printf("Re-parsed object string len=%d, chars=[", parsed_len);
+		for (ii = 0; ii < parsed_len; ii++)
+		{
+			printf("%s%d", (ii ? ", " : ""), (int)parsed_cstr[ii]);
+		}
+		puts("]");
+		json_object_put(parsed_str);
+	}
+	else
+	{
+		puts("ERROR: failed to parse");
+	}
+	return retval;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_null.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_null.expected
new file mode 100755
index 0000000..52d2890
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_null.expected
@@ -0,0 +1,3 @@
+JSON write result is correct: " \u0000 "
+PASS
+Re-parsed object string len=3, chars=[32, 0, 32]
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_null.test b/lynq/S300/ap/app/apparms/json-c/tests/test_null.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_null.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.c b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.c
new file mode 100755
index 0000000..4928088
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.c
@@ -0,0 +1,44 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json_object.h"
+#include "json_object_iterator.h"
+#include "json_tokener.h"
+
+int main(int atgc, char **argv)
+{
+	const char *input = "{\n\
+		\"string_of_digits\": \"123\",\n\
+		\"regular_number\": 222,\n\
+		\"decimal_number\": 99.55,\n\
+		\"boolean_true\": true,\n\
+		\"boolean_false\": false,\n\
+		\"big_number\": 2147483649,\n\
+		\"a_null\": null,\n\
+		}";
+
+	struct json_object *new_obj;
+	struct json_object_iterator it;
+	struct json_object_iterator itEnd;
+
+	it = json_object_iter_init_default();
+	new_obj = json_tokener_parse(input);
+	it = json_object_iter_begin(new_obj);
+	itEnd = json_object_iter_end(new_obj);
+
+	while (!json_object_iter_equal(&it, &itEnd))
+	{
+		printf("%s\n", json_object_iter_peek_name(&it));
+		printf("%s\n", json_object_to_json_string(json_object_iter_peek_value(&it)));
+		json_object_iter_next(&it);
+	}
+
+	json_object_put(new_obj);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.expected
new file mode 100755
index 0000000..e56e288
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.expected
@@ -0,0 +1,14 @@
+string_of_digits
+"123"
+regular_number
+222
+decimal_number
+99.55
+boolean_true
+true
+boolean_false
+false
+big_number
+2147483649
+a_null
+null
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.test b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_object_iterator.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse.c b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.c
new file mode 100755
index 0000000..92d822a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.c
@@ -0,0 +1,697 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json.h"
+#include "json_tokener.h"
+#include "json_visit.h"
+
+static void test_basic_parse(void);
+static void test_utf8_parse(void);
+static void test_verbose_parse(void);
+static void test_incremental_parse(void);
+
+int main(void)
+{
+	MC_SET_DEBUG(1);
+
+	static const char separator[] = "==================================";
+	test_basic_parse();
+	puts(separator);
+	test_utf8_parse();
+	puts(separator);
+	test_verbose_parse();
+	puts(separator);
+	test_incremental_parse();
+	puts(separator);
+
+	return 0;
+}
+
+static json_c_visit_userfunc clear_serializer;
+static void do_clear_serializer(json_object *jso);
+
+static void single_incremental_parse(const char *test_string, int clear_serializer)
+{
+	size_t ii;
+	int chunksize = atoi(getenv("TEST_PARSE_CHUNKSIZE"));
+	struct json_tokener *tok;
+	enum json_tokener_error jerr;
+	json_object *all_at_once_obj, *new_obj;
+	const char *all_at_once_str, *new_str;
+
+	new_obj = NULL;
+	assert(chunksize > 0);
+	all_at_once_obj = json_tokener_parse(test_string);
+	if (clear_serializer)
+		do_clear_serializer(all_at_once_obj);
+	all_at_once_str = json_object_to_json_string(all_at_once_obj);
+
+	tok = json_tokener_new();
+	size_t test_string_len = strlen(test_string) + 1; // Including '\0' !
+	for (ii = 0; ii < test_string_len; ii += chunksize)
+	{
+		int len_to_parse = chunksize;
+		if (ii + chunksize > test_string_len)
+			len_to_parse = test_string_len - ii;
+
+		if (getenv("TEST_PARSE_DEBUG") != NULL)
+			printf(" chunk: %.*s\n", len_to_parse, &test_string[ii]);
+		new_obj = json_tokener_parse_ex(tok, &test_string[ii], len_to_parse);
+		jerr = json_tokener_get_error(tok);
+		if (jerr != json_tokener_continue || new_obj)
+			break;
+	}
+	if (clear_serializer && new_obj)
+		do_clear_serializer(new_obj);
+	new_str = json_object_to_json_string(new_obj);
+
+	if (strcmp(all_at_once_str, new_str) != 0)
+	{
+		printf("ERROR: failed to parse (%s) in %d byte chunks: %s != %s\n", test_string,
+		       chunksize, all_at_once_str, new_str);
+	}
+	json_tokener_free(tok);
+	if (all_at_once_obj)
+		json_object_put(all_at_once_obj);
+	if (new_obj)
+		json_object_put(new_obj);
+}
+
+static void single_basic_parse(const char *test_string, int clear_serializer)
+{
+	json_object *new_obj;
+
+	new_obj = json_tokener_parse(test_string);
+	if (clear_serializer)
+		do_clear_serializer(new_obj);
+	printf("new_obj.to_string(%s)=%s\n", test_string, json_object_to_json_string(new_obj));
+	json_object_put(new_obj);
+
+	if (getenv("TEST_PARSE_CHUNKSIZE") != NULL)
+		single_incremental_parse(test_string, clear_serializer);
+}
+static void test_basic_parse(void)
+{
+	single_basic_parse("\"\003\"", 0);
+	single_basic_parse("/* hello */\"foo\"", 0);
+	single_basic_parse("// hello\n\"foo\"", 0);
+	single_basic_parse("\"foo\"blue", 0);
+	single_basic_parse("\'foo\'", 0);
+	single_basic_parse("\"\\u0041\\u0042\\u0043\"", 0);
+	single_basic_parse("\"\\u4e16\\u754c\\u00df\"", 0);
+	single_basic_parse("\"\\u4E16\"", 0);
+	single_basic_parse("\"\\u4e1\"", 0);
+	single_basic_parse("\"\\u4e1@\"", 0);
+	single_basic_parse("\"\\ud840\\u4e16\"", 0);
+	single_basic_parse("\"\\ud840\"", 0);
+	single_basic_parse("\"\\udd27\"", 0);
+	// Test with a "short" high surrogate
+	single_basic_parse("[9,'\\uDAD", 0);
+	single_basic_parse("null", 0);
+	single_basic_parse("NaN", 0);
+	single_basic_parse("-NaN", 0); /* non-sensical, returns null */
+
+	single_basic_parse("Inf", 0); /* must use full string, returns null */
+	single_basic_parse("inf", 0); /* must use full string, returns null */
+	single_basic_parse("Infinity", 0);
+	single_basic_parse("infinity", 0);
+	single_basic_parse("-Infinity", 0);
+	single_basic_parse("-infinity", 0);
+	single_basic_parse("{ \"min\": Infinity, \"max\": -Infinity}", 0);
+
+	single_basic_parse("Infinity!", 0);
+	single_basic_parse("Infinitynull", 0);
+	single_basic_parse("InfinityXXXX", 0);
+	single_basic_parse("-Infinitynull", 0);
+	single_basic_parse("-InfinityXXXX", 0);
+	single_basic_parse("Infinoodle", 0);
+	single_basic_parse("InfinAAA", 0);
+	single_basic_parse("-Infinoodle", 0);
+	single_basic_parse("-InfinAAA", 0);
+
+	single_basic_parse("True", 0);
+	single_basic_parse("False", 0);
+
+	/* not case sensitive */
+	single_basic_parse("tRue", 0);
+	single_basic_parse("fAlse", 0);
+	single_basic_parse("nAn", 0);
+	single_basic_parse("iNfinity", 0);
+
+	single_basic_parse("12", 0);
+	single_basic_parse("12.3", 0);
+
+	/* Even though, when using json_tokener_parse() there's no way to
+	 *  know when there is more data after the parsed object,
+	 *  an object is successfully returned anyway (in some cases)
+	 */
+
+	single_basic_parse("12.3.4", 0);
+	single_basic_parse("2015-01-15", 0);
+	single_basic_parse("12.3xxx", 0);
+	single_basic_parse("12.3{\"a\":123}", 0);
+	single_basic_parse("12.3\n", 0);
+	single_basic_parse("12.3 ", 0);
+
+	single_basic_parse("{\"FoO\"  :   -12.3E512}", 0);
+	single_basic_parse("{\"FoO\"  :   -12.3e512}", 0);
+	single_basic_parse("{\"FoO\"  :   -12.3E51.2}", 0);   /* non-sensical, returns null */
+	single_basic_parse("{\"FoO\"  :   -12.3E512E12}", 0); /* non-sensical, returns null */
+	single_basic_parse("[\"\\n\"]", 0);
+	single_basic_parse("[\"\\nabc\\n\"]", 0);
+	single_basic_parse("[null]", 0);
+	single_basic_parse("[]", 0);
+	single_basic_parse("[false]", 0);
+	single_basic_parse("[\"abc\",null,\"def\",12]", 0);
+	single_basic_parse("{}", 0);
+	single_basic_parse("{ \"foo\": \"bar\" }", 0);
+	single_basic_parse("{ \'foo\': \'bar\' }", 0);
+	single_basic_parse("{ \"foo\": \"bar\", \"baz\": null, \"bool0\": true }", 0);
+	single_basic_parse("{ \"foo\": [null, \"foo\"] }", 0);
+	single_basic_parse("{ \"abc\": 12, \"foo\": \"bar\", \"bool0\": false, \"bool1\": true, "
+	                   "\"arr\": [ 1, 2, 3, null, 5 ] }",
+	                   0);
+	single_basic_parse("{ \"abc\": \"blue\nred\\ngreen\" }", 0);
+
+	// Clear serializer for these tests so we see the actual parsed value.
+	single_basic_parse("null", 1);
+	single_basic_parse("false", 1);
+	single_basic_parse("[0e]", 1);
+	single_basic_parse("[0e+]", 1);
+	single_basic_parse("[0e+-1]", 1);
+	single_basic_parse("\"hello world!\"", 1);
+
+	// uint64/int64 range test
+	single_basic_parse("[9223372036854775806]", 1);
+	single_basic_parse("[9223372036854775807]", 1);
+	single_basic_parse("[9223372036854775808]", 1);
+	single_basic_parse("[-9223372036854775807]", 1);
+	single_basic_parse("[-9223372036854775808]", 1);
+	single_basic_parse("[-9223372036854775809]", 1);
+	single_basic_parse("[18446744073709551614]", 1);
+	single_basic_parse("[18446744073709551615]", 1);
+	single_basic_parse("[18446744073709551616]", 1);
+}
+
+static void test_utf8_parse(void)
+{
+	// json_tokener_parse doesn't support checking for byte order marks.
+	// It's the responsibility of the caller to detect and skip a BOM.
+	// Both of these checks return null.
+	const char *utf8_bom = "\xEF\xBB\xBF";
+	const char *utf8_bom_and_chars = "\xEF\xBB\xBF{}";
+	single_basic_parse(utf8_bom, 0);
+	single_basic_parse(utf8_bom_and_chars, 0);
+}
+
+// Clear the re-serialization information that the tokener
+// saves to ensure that the output reflects the actual
+// values we parsed, rather than just the original input.
+static void do_clear_serializer(json_object *jso)
+{
+	json_c_visit(jso, 0, clear_serializer, NULL);
+}
+
+static int clear_serializer(json_object *jso, int flags, json_object *parent_jso,
+                            const char *jso_key, size_t *jso_index, void *userarg)
+{
+	if (jso)
+		json_object_set_serializer(jso, NULL, NULL, NULL);
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static void test_verbose_parse(void)
+{
+	json_object *new_obj;
+	enum json_tokener_error error = json_tokener_success;
+
+	new_obj = json_tokener_parse_verbose("{ foo }", &error);
+	assert(error == json_tokener_error_parse_object_key_name);
+	assert(new_obj == NULL);
+
+	new_obj = json_tokener_parse("{ foo }");
+	assert(new_obj == NULL);
+
+	new_obj = json_tokener_parse("foo");
+	assert(new_obj == NULL);
+	new_obj = json_tokener_parse_verbose("foo", &error);
+	assert(new_obj == NULL);
+
+	/* b/c the string starts with 'f' parsing return a boolean error */
+	assert(error == json_tokener_error_parse_boolean);
+
+	puts("json_tokener_parse_verbose() OK");
+}
+
+struct incremental_step
+{
+	const char *string_to_parse;
+	int length;
+	int char_offset;
+	enum json_tokener_error expected_error;
+	int reset_tokener; /* Set to 1 to call json_tokener_reset() after parsing */
+	int tok_flags;     /* JSON_TOKENER_* flags to pass to json_tokener_set_flags() */
+} incremental_steps[] = {
+
+    /* Check that full json messages can be parsed, both w/ and w/o a reset */
+    {"{ \"foo\": 123 }", -1, -1, json_tokener_success, 0, 0},
+    {"{ \"foo\": 456 }", -1, -1, json_tokener_success, 1, 0},
+    {"{ \"foo\": 789 }", -1, -1, json_tokener_success, 1, 0},
+
+    /* Check the comment parse*/
+    {"/* hello */{ \"foo\"", -1, -1, json_tokener_continue, 0, 0},
+    {"/* hello */:/* hello */", -1, -1, json_tokener_continue, 0, 0},
+    {"\"bar\"/* hello */", -1, -1, json_tokener_continue, 0, 0},
+    {"}/* hello */", -1, -1, json_tokener_success, 1, 0},
+    {"/ hello ", -1, 1, json_tokener_error_parse_comment, 1, 0},
+    {"/* hello\"foo\"", -1, -1, json_tokener_continue, 1, 0},
+    {"/* hello*\"foo\"", -1, -1, json_tokener_continue, 1, 0},
+    {"// hello\"foo\"", -1, -1, json_tokener_continue, 1, 0},
+
+    /*  Check a basic incremental parse */
+    {"{ \"foo", -1, -1, json_tokener_continue, 0, 0},
+    {"\": {\"bar", -1, -1, json_tokener_continue, 0, 0},
+    {"\":13}}", -1, -1, json_tokener_success, 1, 0},
+
+    /* Check the UTF-16 surrogate pair handling in various ways.
+	 * Note: \ud843\udd1e is u+1D11E, Musical Symbol G Clef
+	 * Your terminal may not display these correctly, in particular
+	 *  PuTTY doesn't currently show this character.
+	 */
+    /* parse one char at every time */
+    {"\"\\", -1, -1, json_tokener_continue, 0, 0},
+    {"u", -1, -1, json_tokener_continue, 0, 0},
+    {"d", -1, -1, json_tokener_continue, 0, 0},
+    {"8", -1, -1, json_tokener_continue, 0, 0},
+    {"3", -1, -1, json_tokener_continue, 0, 0},
+    {"4", -1, -1, json_tokener_continue, 0, 0},
+    {"\\", -1, -1, json_tokener_continue, 0, 0},
+    {"u", -1, -1, json_tokener_continue, 0, 0},
+    {"d", -1, -1, json_tokener_continue, 0, 0},
+    {"d", -1, -1, json_tokener_continue, 0, 0},
+    {"1", -1, -1, json_tokener_continue, 0, 0},
+    {"e\"", -1, -1, json_tokener_success, 1, 0},
+    /* parse two char at every time */
+    {"\"\\u", -1, -1, json_tokener_continue, 0, 0},
+    {"d8", -1, -1, json_tokener_continue, 0, 0},
+    {"34", -1, -1, json_tokener_continue, 0, 0},
+    {"\\u", -1, -1, json_tokener_continue, 0, 0},
+    {"dd", -1, -1, json_tokener_continue, 0, 0},
+    {"1e\"", -1, -1, json_tokener_success, 1, 0},
+    /* check the low surrogate pair */
+    {"\"\\ud834", -1, -1, json_tokener_continue, 0, 0},
+    {"\\udd1e\"", -1, -1, json_tokener_success, 1, 0},
+    {"\"\\ud834\\", -1, -1, json_tokener_continue, 0, 0},
+    {"udd1e\"", -1, -1, json_tokener_success, 1, 0},
+    {"\"\\ud834\\u", -1, -1, json_tokener_continue, 0, 0},
+    {"dd1e\"", -1, -1, json_tokener_success, 1, 0},
+    {"\"fff \\ud834\\ud", -1, -1, json_tokener_continue, 0, 0},
+    {"d1e bar\"", -1, -1, json_tokener_success, 1, 0},
+    {"\"fff \\ud834\\udd", -1, -1, json_tokener_continue, 0, 0},
+    {"1e bar\"", -1, -1, json_tokener_success, 1, 0},
+
+    /* \ud83d\ude00 is U+1F600, Grinning Face
+	 * Displays fine in PuTTY, though you may need "less -r"
+	 */
+    {"\"fff \\ud83d\\ude", -1, -1, json_tokener_continue, 0, 0},
+    {"00 bar\"", -1, -1, json_tokener_success, 1, 0},
+
+    /* Check that json_tokener_reset actually resets */
+    {"{ \"foo", -1, -1, json_tokener_continue, 1, 0},
+    {": \"bar\"}", -1, 0, json_tokener_error_parse_unexpected, 1, 0},
+
+    /* Check incremental parsing with trailing characters */
+    {"{ \"foo", -1, -1, json_tokener_continue, 0, 0},
+    {"\": {\"bar", -1, -1, json_tokener_continue, 0, 0},
+    {"\":13}}XXXX", 10, 6, json_tokener_success, 0, 0},
+    {"XXXX", 4, 0, json_tokener_error_parse_unexpected, 1, 0},
+
+    /* Check that trailing characters can change w/o a reset */
+    {"{\"x\": 123 }\"X\"", -1, 11, json_tokener_success, 0, 0},
+    {"\"Y\"", -1, -1, json_tokener_success, 1, 0},
+
+    /* Trailing characters should cause a failure in strict mode */
+    {"{\"foo\":9}{\"bar\":8}", -1, 9, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+
+    /* ... unless explicitly allowed. */
+    {"{\"foo\":9}{\"bar\":8}", -1, 9, json_tokener_success, 0,
+     JSON_TOKENER_STRICT | JSON_TOKENER_ALLOW_TRAILING_CHARS},
+    {"{\"b\":8}ignored garbage", -1, 7, json_tokener_success, 1,
+     JSON_TOKENER_STRICT | JSON_TOKENER_ALLOW_TRAILING_CHARS},
+
+    /* To stop parsing a number we need to reach a non-digit, e.g. a \0 */
+    {"1", 1, 1, json_tokener_continue, 0, 0},
+    /* This should parse as the number 12, since it continues the "1" */
+    {"2", 2, 1, json_tokener_success, 0, 0},
+    {"12{", 3, 2, json_tokener_success, 1, 0},
+    /* Parse number in strict mode */
+    {"[02]", -1, 3, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+
+    {"0e+0", 5, 4, json_tokener_success, 1, 0},
+    {"[0e+0]", -1, -1, json_tokener_success, 1, 0},
+
+    /* The behavior when missing the exponent varies slightly */
+    {"0e", 2, 2, json_tokener_continue, 1, 0},
+    {"0e", 3, 2, json_tokener_success, 1, 0},
+    {"0e", 3, 2, json_tokener_error_parse_eof, 1, JSON_TOKENER_STRICT},
+    {"[0e]", -1, -1, json_tokener_success, 1, 0},
+    {"[0e]", -1, 3, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+
+    {"0e+", 3, 3, json_tokener_continue, 1, 0},
+    {"0e+", 4, 3, json_tokener_success, 1, 0},
+    {"0e+", 4, 3, json_tokener_error_parse_eof, 1, JSON_TOKENER_STRICT},
+    {"[0e+]", -1, -1, json_tokener_success, 1, 0},
+    {"[0e+]", -1, 4, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+
+    {"0e-", 3, 3, json_tokener_continue, 1, 0},
+    {"0e-", 4, 3, json_tokener_success, 1, 0},
+    {"0e-", 4, 3, json_tokener_error_parse_eof, 1, JSON_TOKENER_STRICT},
+    {"[0e-]", -1, -1, json_tokener_success, 1, 0},
+    {"[0e-]", -1, 4, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+
+    /* You might expect this to fail, but it won't because
+	   it's a valid partial parse; note the char_offset: */
+    {"0e+-", 5, 3, json_tokener_success, 1, 0},
+    {"0e+-", 5, 3, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+    {"[0e+-]", -1, 4, json_tokener_error_parse_number, 1, 0},
+
+    /* Similar tests for other kinds of objects: */
+    /* These could all return success immediately, since regardless of
+	   what follows the false/true/null token we *will* return a json object,
+       but it currently doesn't work that way.  hmm... */
+    {"false", 5, 5, json_tokener_continue, 1, 0},
+    {"false", 6, 5, json_tokener_success, 1, 0},
+    {"true", 4, 4, json_tokener_continue, 1, 0},
+    {"true", 5, 4, json_tokener_success, 1, 0},
+    {"null", 4, 4, json_tokener_continue, 1, 0},
+    {"null", 5, 4, json_tokener_success, 1, 0},
+
+    {"Infinity", 9, 8, json_tokener_success, 1, 0},
+    {"infinity", 9, 8, json_tokener_success, 1, 0},
+    {"-infinity", 10, 9, json_tokener_success, 1, 0},
+    {"infinity", 9, 0, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+    {"-infinity", 10, 1, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+
+    {"inf", 3, 3, json_tokener_continue, 0, 0},
+    {"inity", 6, 5, json_tokener_success, 1, 0},
+    {"-inf", 4, 4, json_tokener_continue, 0, 0},
+    {"inity", 6, 5, json_tokener_success, 1, 0},
+
+    {"i", 1, 1, json_tokener_continue, 0, 0},
+    {"n", 1, 1, json_tokener_continue, 0, 0},
+    {"f", 1, 1, json_tokener_continue, 0, 0},
+    {"i", 1, 1, json_tokener_continue, 0, 0},
+    {"n", 1, 1, json_tokener_continue, 0, 0},
+    {"i", 1, 1, json_tokener_continue, 0, 0},
+    {"t", 1, 1, json_tokener_continue, 0, 0},
+    {"y", 1, 1, json_tokener_continue, 0, 0},
+    {"", 1, 0, json_tokener_success, 1, 0},
+
+    {"-", 1, 1, json_tokener_continue, 0, 0},
+    {"inf", 3, 3, json_tokener_continue, 0, 0},
+    {"ini", 3, 3, json_tokener_continue, 0, 0},
+    {"ty", 3, 2, json_tokener_success, 1, 0},
+
+    {"-", 1, 1, json_tokener_continue, 0, 0},
+    {"i", 1, 1, json_tokener_continue, 0, 0},
+    {"nfini", 5, 5, json_tokener_continue, 0, 0},
+    {"ty", 3, 2, json_tokener_success, 1, 0},
+
+    {"-i", 2, 2, json_tokener_continue, 0, 0},
+    {"nfinity", 8, 7, json_tokener_success, 1, 0},
+
+    {"InfinityX", 10, 8, json_tokener_success, 0, 0},
+    {"X", 1, 0, json_tokener_error_parse_unexpected, 1, 0},
+
+    {"Infinity1234", 13, 8, json_tokener_success, 0, 0},
+    {"1234", 5, 4, json_tokener_success, 1, 0},
+
+    {"Infinity9999", 8, 8, json_tokener_continue, 0, 0},
+
+    /* returns the Infinity loaded up by the previous call: */
+    {"1234", 5, 0, json_tokener_success, 0, 0},
+    {"1234", 5, 4, json_tokener_success, 1, 0},
+
+	/* INT64_MAX */
+	{"[9223372036854775807]", 22, 21, json_tokener_success, 1, 0},
+	/* INT64_MAX+1 => parsed as uint64 */
+	{"[9223372036854775808]", 22, 21, json_tokener_success, 1, 0},
+
+	/* INT64_MIN */
+	{"[-9223372036854775808]", 23, 22, json_tokener_success, 1, 0},
+
+	/* INT64_MIN-1 => success, but value ends up capped */
+	{"[-9223372036854775809]", 23, 22, json_tokener_success, 1, 0},
+
+	/* INT64_MIN-1 => failure due to underflow detected */
+	{"[-9223372036854775809]", 23, 21, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
+
+	/* UINT64_MAX */
+	{"[18446744073709551615]", 23, 22, json_tokener_success, 1, 0}, 
+
+	/* UINT64_MAX+1 => success, but value ends up capped */
+	{"[18446744073709551616]", 23, 22, json_tokener_success, 1, 0}, 
+
+	/* UINT64_MAX+1 => failure due to overflow detected */
+	{"[18446744073709551616]", 23, 21, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT}, 
+
+	/* XXX this seems like a bug, should fail with _error_parse_number instead */
+	{"18446744073709551616", 21, 20, json_tokener_error_parse_eof, 1, JSON_TOKENER_STRICT}, 
+
+	/* Exceeding integer limits as double parse OK */
+	{"[9223372036854775808.0]", 24, 23, json_tokener_success, 1, 0},
+	{"[-9223372036854775809.0]", 25, 24, json_tokener_success, 1, JSON_TOKENER_STRICT},
+	{"[18446744073709551615.0]", 25, 24, json_tokener_success, 1, 0}, 
+	{"[18446744073709551616.0]", 25, 24, json_tokener_success, 1, JSON_TOKENER_STRICT}, 
+
+    /* offset=1 because "n" is the start of "null".  hmm... */
+    {"noodle", 7, 1, json_tokener_error_parse_null, 1, 0},
+    /* offset=2 because "na" is the start of "nan".  hmm... */
+    {"naodle", 7, 2, json_tokener_error_parse_null, 1, 0},
+    /* offset=2 because "tr" is the start of "true".  hmm... */
+    {"track", 6, 2, json_tokener_error_parse_boolean, 1, 0},
+    {"fail", 5, 2, json_tokener_error_parse_boolean, 1, 0},
+
+    /* Although they may initially look like they should fail,
+	 * the next few tests check that parsing multiple sequential
+	 * json objects in the input works as expected
+	 */
+    {"null123", 8, 4, json_tokener_success, 0, 0},
+    {&"null123"[4], 4, 3, json_tokener_success, 1, 0},
+    {"nullx", 6, 4, json_tokener_success, 0, 0},
+    {&"nullx"[4], 2, 0, json_tokener_error_parse_unexpected, 1, 0},
+    {"{\"a\":1}{\"b\":2}", 15, 7, json_tokener_success, 0, 0},
+    {&"{\"a\":1}{\"b\":2}"[7], 8, 7, json_tokener_success, 1, 0},
+
+    /*
+	 * Though this may seem invalid at first glance, it
+	 * parses as three separate numbers, 2015, -1 and -15
+	 * Of course, simply pasting together a stream of arbitrary
+	 * positive numbers won't work, since there'll be no way to
+     * tell where in e.g. "2015015" the next number stats, so
+	 * a reliably parsable stream must not include json_type_int
+	 * or json_type_double objects without some other delimiter.
+	 * e.g. whitespace
+	 */
+    {&"2015-01-15"[0], 11, 4, json_tokener_success, 1, 0},
+    {&"2015-01-15"[4], 7, 3, json_tokener_success, 1, 0},
+    {&"2015-01-15"[7], 4, 3, json_tokener_success, 1, 0},
+    {&"2015 01 15"[0], 11, 5, json_tokener_success, 1, 0},
+    {&"2015 01 15"[4], 7, 4, json_tokener_success, 1, 0},
+    {&"2015 01 15"[7], 4, 3, json_tokener_success, 1, 0},
+
+    /* Strings have a well defined end point, so we can stop at the quote */
+    {"\"blue\"", -1, -1, json_tokener_success, 0, 0},
+
+    /* Check each of the escape sequences defined by the spec */
+    {"\"\\\"\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\\\\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\b\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\f\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\n\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\r\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\t\"", -1, -1, json_tokener_success, 0, 0},
+    {"\"\\/\"", -1, -1, json_tokener_success, 0, 0},
+    // Escaping a forward slash is optional
+    {"\"/\"", -1, -1, json_tokener_success, 0, 0},
+    /* Check wrong escape sequences */
+    {"\"\\a\"", -1, 2, json_tokener_error_parse_string, 1, 0},
+
+    /* Check '\'' in strict model */
+    {"\'foo\'", -1, 0, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+
+    /* Parse array/object */
+    {"[1,2,3]", -1, -1, json_tokener_success, 0, 0},
+    {"[1,2,3}", -1, 6, json_tokener_error_parse_array, 1, 0},
+    {"{\"a\"}", -1, 4, json_tokener_error_parse_object_key_sep, 1, 0},
+    {"{\"a\":1]", -1, 6, json_tokener_error_parse_object_value_sep, 1, 0},
+    {"{\"a\"::1}", -1, 5, json_tokener_error_parse_unexpected, 1, 0},
+    {"{\"a\":}", -1, 5, json_tokener_error_parse_unexpected, 1, 0},
+    {"{\"a\":1,\"a\":2}", -1, -1, json_tokener_success, 1, 0},
+    {"\"a\":1}", -1, 3, json_tokener_success, 1, 0},
+    {"{\"a\":1", -1, -1, json_tokener_continue, 1, 0},
+    {"[,]", -1, 1, json_tokener_error_parse_unexpected, 1, 0},
+    {"[,1]", -1, 1, json_tokener_error_parse_unexpected, 1, 0},
+
+    /* This behaviour doesn't entirely follow the json spec, but until we have
+	 * a way to specify how strict to be we follow Postel's Law and be liberal
+	 * in what we accept (up to a point).
+	 */
+    {"[1,2,3,]", -1, -1, json_tokener_success, 0, 0},
+    {"[1,2,,3,]", -1, 5, json_tokener_error_parse_unexpected, 0, 0},
+
+    {"[1,2,3,]", -1, 7, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+    {"{\"a\":1,}", -1, 7, json_tokener_error_parse_unexpected, 1, JSON_TOKENER_STRICT},
+
+    // utf-8 test
+    // acsll encoding
+    {"\x22\x31\x32\x33\x61\x73\x63\x24\x25\x26\x22", -1, -1, json_tokener_success, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\x31\x32\x33\x61\x73\x63\x24\x25\x26\x22", -1, -1, json_tokener_success, 1, 0},
+    // utf-8 encoding
+    {"\x22\xe4\xb8\x96\xe7\x95\x8c\x22", -1, -1, json_tokener_success, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\xe4\xb8", -1, 3, json_tokener_error_parse_utf8_string, 0, JSON_TOKENER_VALIDATE_UTF8},
+    {"\x96\xe7\x95\x8c\x22", -1, 0, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\xe4\xb8\x96\xe7\x95\x8c\x22", -1, -1, json_tokener_success, 1, 0},
+    {"\x22\xcf\x80\xcf\x86\x22", -1, -1, json_tokener_success, 1, JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\xf0\xa5\x91\x95\x22", -1, -1, json_tokener_success, 1, JSON_TOKENER_VALIDATE_UTF8},
+    // wrong utf-8 encoding
+    {"\x22\xe6\x9d\x4e\x22", -1, 3, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\xe6\x9d\x4e\x22", -1, 5, json_tokener_success, 1, 0},
+    // GBK encoding
+    {"\x22\xc0\xee\xc5\xf4\x22", -1, 2, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\xc0\xee\xc5\xf4\x22", -1, 6, json_tokener_success, 1, 0},
+    // char after space
+    {"\x20\x20\x22\xe4\xb8\x96\x22", -1, -1, json_tokener_success, 1, JSON_TOKENER_VALIDATE_UTF8},
+    {"\x20\x20\x81\x22\xe4\xb8\x96\x22", -1, 2, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x5b\x20\x81\x31\x5d", -1, 2, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    // char in state inf
+    {"\x49\x6e\x66\x69\x6e\x69\x74\x79", 9, 8, json_tokener_success, 1, 0},
+    {"\x49\x6e\x66\x81\x6e\x69\x74\x79", -1, 3, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    // char in escape unicode
+    {"\x22\x5c\x75\x64\x38\x35\x35\x5c\x75\x64\x63\x35\x35\x22", 15, 14, json_tokener_success, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\x5c\x75\x64\x38\x35\x35\xc0\x75\x64\x63\x35\x35\x22", -1, 8,
+     json_tokener_error_parse_utf8_string, 1, JSON_TOKENER_VALIDATE_UTF8},
+    {"\x22\x5c\x75\x64\x30\x30\x33\x31\xc0\x22", -1, 9, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    // char in number
+    {"\x31\x31\x81\x31\x31", -1, 2, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+    // char in object
+    {"\x7b\x22\x31\x81\x22\x3a\x31\x7d", -1, 3, json_tokener_error_parse_utf8_string, 1,
+     JSON_TOKENER_VALIDATE_UTF8},
+
+    {NULL, -1, -1, json_tokener_success, 0, 0},
+};
+
+static void test_incremental_parse(void)
+{
+	json_object *new_obj;
+	enum json_tokener_error jerr;
+	struct json_tokener *tok;
+	const char *string_to_parse;
+	int ii;
+	int num_ok, num_error;
+
+	num_ok = 0;
+	num_error = 0;
+
+	printf("Starting incremental tests.\n");
+	printf("Note: quotes and backslashes seen in the output here are literal values passed\n");
+	printf("     to the parse functions.  e.g. this is 4 characters: \"\\f\"\n");
+
+	string_to_parse = "{ \"foo"; /* } */
+	printf("json_tokener_parse(%s) ... ", string_to_parse);
+	new_obj = json_tokener_parse(string_to_parse);
+	if (new_obj == NULL)
+		puts("got error as expected");
+
+	/* test incremental parsing in various forms */
+	tok = json_tokener_new();
+	for (ii = 0; incremental_steps[ii].string_to_parse != NULL; ii++)
+	{
+		int this_step_ok = 0;
+		struct incremental_step *step = &incremental_steps[ii];
+		int length = step->length;
+		size_t expected_char_offset;
+
+		json_tokener_set_flags(tok, step->tok_flags);
+
+		if (length == -1)
+			length = (int)strlen(step->string_to_parse);
+		if (step->char_offset == -1)
+			expected_char_offset = length;
+		else
+			expected_char_offset = step->char_offset;
+
+		printf("json_tokener_parse_ex(tok, %-12s, %3d) ... ", step->string_to_parse,
+		       length);
+		new_obj = json_tokener_parse_ex(tok, step->string_to_parse, length);
+
+		jerr = json_tokener_get_error(tok);
+		if (step->expected_error != json_tokener_success)
+		{
+			if (new_obj != NULL)
+				printf("ERROR: invalid object returned: %s\n",
+				       json_object_to_json_string(new_obj));
+			else if (jerr != step->expected_error)
+				printf("ERROR: got wrong error: %s\n",
+				       json_tokener_error_desc(jerr));
+			else if (json_tokener_get_parse_end(tok) != expected_char_offset)
+				printf("ERROR: wrong char_offset %zu != expected %zu\n",
+				       json_tokener_get_parse_end(tok), expected_char_offset);
+			else
+			{
+				printf("OK: got correct error: %s\n",
+				       json_tokener_error_desc(jerr));
+				this_step_ok = 1;
+			}
+		}
+		else
+		{
+			if (new_obj == NULL &&
+			    !(step->length >= 4 && strncmp(step->string_to_parse, "null", 4) == 0))
+				printf("ERROR: expected valid object, instead: %s\n",
+				       json_tokener_error_desc(jerr));
+			else if (json_tokener_get_parse_end(tok) != expected_char_offset)
+				printf("ERROR: wrong char_offset %zu != expected %zu\n",
+				       json_tokener_get_parse_end(tok), expected_char_offset);
+			else
+			{
+				printf("OK: got object of type [%s]: %s\n",
+				       json_type_to_name(json_object_get_type(new_obj)),
+				       json_object_to_json_string(new_obj));
+				this_step_ok = 1;
+			}
+		}
+
+		if (new_obj)
+			json_object_put(new_obj);
+
+		if (step->reset_tokener & 1)
+			json_tokener_reset(tok);
+
+		if (this_step_ok)
+			num_ok++;
+		else
+			num_error++;
+	}
+
+	json_tokener_free(tok);
+
+	printf("End Incremental Tests OK=%d ERROR=%d\n", num_ok, num_error);
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.expected
new file mode 100755
index 0000000..50fb6d8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.expected
@@ -0,0 +1,292 @@
+new_obj.to_string("")="\u0003"
+new_obj.to_string(/* hello */"foo")="foo"
+new_obj.to_string(// hello
+"foo")="foo"
+new_obj.to_string("foo"blue)="foo"
+new_obj.to_string('foo')="foo"
+new_obj.to_string("\u0041\u0042\u0043")="ABC"
+new_obj.to_string("\u4e16\u754c\u00df")="世界ß"
+new_obj.to_string("\u4E16")="世"
+new_obj.to_string("\u4e1")=null
+new_obj.to_string("\u4e1@")=null
+new_obj.to_string("\ud840\u4e16")="�世"
+new_obj.to_string("\ud840")="�"
+new_obj.to_string("\udd27")="�"
+new_obj.to_string([9,'\uDAD)=null
+new_obj.to_string(null)=null
+new_obj.to_string(NaN)=NaN
+new_obj.to_string(-NaN)=null
+new_obj.to_string(Inf)=null
+new_obj.to_string(inf)=null
+new_obj.to_string(Infinity)=Infinity
+new_obj.to_string(infinity)=Infinity
+new_obj.to_string(-Infinity)=-Infinity
+new_obj.to_string(-infinity)=-Infinity
+new_obj.to_string({ "min": Infinity, "max": -Infinity})={ "min": Infinity, "max": -Infinity }
+new_obj.to_string(Infinity!)=Infinity
+new_obj.to_string(Infinitynull)=Infinity
+new_obj.to_string(InfinityXXXX)=Infinity
+new_obj.to_string(-Infinitynull)=-Infinity
+new_obj.to_string(-InfinityXXXX)=-Infinity
+new_obj.to_string(Infinoodle)=null
+new_obj.to_string(InfinAAA)=null
+new_obj.to_string(-Infinoodle)=null
+new_obj.to_string(-InfinAAA)=null
+new_obj.to_string(True)=true
+new_obj.to_string(False)=false
+new_obj.to_string(tRue)=true
+new_obj.to_string(fAlse)=false
+new_obj.to_string(nAn)=NaN
+new_obj.to_string(iNfinity)=Infinity
+new_obj.to_string(12)=12
+new_obj.to_string(12.3)=12.3
+new_obj.to_string(12.3.4)=12.3
+new_obj.to_string(2015-01-15)=2015
+new_obj.to_string(12.3xxx)=12.3
+new_obj.to_string(12.3{"a":123})=12.3
+new_obj.to_string(12.3
+)=12.3
+new_obj.to_string(12.3 )=12.3
+new_obj.to_string({"FoO"  :   -12.3E512})={ "FoO": -12.3E512 }
+new_obj.to_string({"FoO"  :   -12.3e512})={ "FoO": -12.3e512 }
+new_obj.to_string({"FoO"  :   -12.3E51.2})=null
+new_obj.to_string({"FoO"  :   -12.3E512E12})=null
+new_obj.to_string(["\n"])=[ "\n" ]
+new_obj.to_string(["\nabc\n"])=[ "\nabc\n" ]
+new_obj.to_string([null])=[ null ]
+new_obj.to_string([])=[ ]
+new_obj.to_string([false])=[ false ]
+new_obj.to_string(["abc",null,"def",12])=[ "abc", null, "def", 12 ]
+new_obj.to_string({})={ }
+new_obj.to_string({ "foo": "bar" })={ "foo": "bar" }
+new_obj.to_string({ 'foo': 'bar' })={ "foo": "bar" }
+new_obj.to_string({ "foo": "bar", "baz": null, "bool0": true })={ "foo": "bar", "baz": null, "bool0": true }
+new_obj.to_string({ "foo": [null, "foo"] })={ "foo": [ null, "foo" ] }
+new_obj.to_string({ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3, null, 5 ] })={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3, null, 5 ] }
+new_obj.to_string({ "abc": "blue
+red\ngreen" })={ "abc": "blue\nred\ngreen" }
+new_obj.to_string(null)=null
+new_obj.to_string(false)=false
+new_obj.to_string([0e])=[ 0.0 ]
+new_obj.to_string([0e+])=[ 0.0 ]
+new_obj.to_string([0e+-1])=null
+new_obj.to_string("hello world!")="hello world!"
+new_obj.to_string([9223372036854775806])=[ 9223372036854775806 ]
+new_obj.to_string([9223372036854775807])=[ 9223372036854775807 ]
+new_obj.to_string([9223372036854775808])=[ 9223372036854775808 ]
+new_obj.to_string([-9223372036854775807])=[ -9223372036854775807 ]
+new_obj.to_string([-9223372036854775808])=[ -9223372036854775808 ]
+new_obj.to_string([-9223372036854775809])=[ -9223372036854775808 ]
+new_obj.to_string([18446744073709551614])=[ 18446744073709551614 ]
+new_obj.to_string([18446744073709551615])=[ 18446744073709551615 ]
+new_obj.to_string([18446744073709551616])=[ 18446744073709551615 ]
+==================================
+new_obj.to_string()=null
+new_obj.to_string({})=null
+==================================
+json_tokener_parse_verbose() OK
+==================================
+Starting incremental tests.
+Note: quotes and backslashes seen in the output here are literal values passed
+     to the parse functions.  e.g. this is 4 characters: "\f"
+json_tokener_parse({ "foo) ... got error as expected
+json_tokener_parse_ex(tok, { "foo": 123 },  14) ... OK: got object of type [object]: { "foo": 123 }
+json_tokener_parse_ex(tok, { "foo": 456 },  14) ... OK: got object of type [object]: { "foo": 456 }
+json_tokener_parse_ex(tok, { "foo": 789 },  14) ... OK: got object of type [object]: { "foo": 789 }
+json_tokener_parse_ex(tok, /* hello */{ "foo",  18) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, /* hello */:/* hello */,  23) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, "bar"/* hello */,  16) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, }/* hello */,  12) ... OK: got object of type [object]: { "foo": "bar" }
+json_tokener_parse_ex(tok, / hello     ,   8) ... OK: got correct error: expected comment
+json_tokener_parse_ex(tok, /* hello"foo",  13) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, /* hello*"foo",  14) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, // hello"foo",  13) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, { "foo      ,   6) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ": {"bar    ,   8) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ":13}}      ,   6) ... OK: got object of type [object]: { "foo": { "bar": 13 } }
+json_tokener_parse_ex(tok, "\          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, u           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, d           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 8           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 3           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 4           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, \           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, u           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, d           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, d           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 1           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, e"          ,   2) ... OK: got object of type [string]: "𝄞"
+json_tokener_parse_ex(tok, "\u         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, d8          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 34          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, \u          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, dd          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 1e"         ,   3) ... OK: got object of type [string]: "𝄞"
+json_tokener_parse_ex(tok, "\ud834     ,   7) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, \udd1e"     ,   7) ... OK: got object of type [string]: "𝄞"
+json_tokener_parse_ex(tok, "\ud834\    ,   8) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, udd1e"      ,   6) ... OK: got object of type [string]: "𝄞"
+json_tokener_parse_ex(tok, "\ud834\u   ,   9) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, dd1e"       ,   5) ... OK: got object of type [string]: "𝄞"
+json_tokener_parse_ex(tok, "fff \ud834\ud,  14) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, d1e bar"    ,   8) ... OK: got object of type [string]: "fff 𝄞 bar"
+json_tokener_parse_ex(tok, "fff \ud834\udd,  15) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 1e bar"     ,   7) ... OK: got object of type [string]: "fff 𝄞 bar"
+json_tokener_parse_ex(tok, "fff \ud83d\ude,  15) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 00 bar"     ,   7) ... OK: got object of type [string]: "fff 😀 bar"
+json_tokener_parse_ex(tok, { "foo      ,   6) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, : "bar"}    ,   8) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, { "foo      ,   6) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ": {"bar    ,   8) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ":13}}XXXX  ,  10) ... OK: got object of type [object]: { "foo": { "bar": 13 } }
+json_tokener_parse_ex(tok, XXXX        ,   4) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"x": 123 }"X",  14) ... OK: got object of type [object]: { "x": 123 }
+json_tokener_parse_ex(tok, "Y"         ,   3) ... OK: got object of type [string]: "Y"
+json_tokener_parse_ex(tok, {"foo":9}{"bar":8},  18) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"foo":9}{"bar":8},  18) ... OK: got object of type [object]: { "foo": 9 }
+json_tokener_parse_ex(tok, {"b":8}ignored garbage,  22) ... OK: got object of type [object]: { "b": 8 }
+json_tokener_parse_ex(tok, 1           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 2           ,   2) ... OK: got object of type [int]: 12
+json_tokener_parse_ex(tok, 12{         ,   3) ... OK: got object of type [int]: 12
+json_tokener_parse_ex(tok, [02]        ,   4) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, 0e+0        ,   5) ... OK: got object of type [double]: 0e+0
+json_tokener_parse_ex(tok, [0e+0]      ,   6) ... OK: got object of type [array]: [ 0e+0 ]
+json_tokener_parse_ex(tok, 0e          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 0e          ,   3) ... OK: got object of type [double]: 0
+json_tokener_parse_ex(tok, 0e          ,   3) ... OK: got correct error: unexpected end of data
+json_tokener_parse_ex(tok, [0e]        ,   4) ... OK: got object of type [array]: [ 0 ]
+json_tokener_parse_ex(tok, [0e]        ,   4) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, 0e+         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 0e+         ,   4) ... OK: got object of type [double]: 0
+json_tokener_parse_ex(tok, 0e+         ,   4) ... OK: got correct error: unexpected end of data
+json_tokener_parse_ex(tok, [0e+]       ,   5) ... OK: got object of type [array]: [ 0 ]
+json_tokener_parse_ex(tok, [0e+]       ,   5) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, 0e-         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 0e-         ,   4) ... OK: got object of type [double]: 0
+json_tokener_parse_ex(tok, 0e-         ,   4) ... OK: got correct error: unexpected end of data
+json_tokener_parse_ex(tok, [0e-]       ,   5) ... OK: got object of type [array]: [ 0 ]
+json_tokener_parse_ex(tok, [0e-]       ,   5) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, 0e+-        ,   5) ... OK: got object of type [double]: 0
+json_tokener_parse_ex(tok, 0e+-        ,   5) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, [0e+-]      ,   6) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, false       ,   5) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, false       ,   6) ... OK: got object of type [boolean]: false
+json_tokener_parse_ex(tok, true        ,   4) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, true        ,   5) ... OK: got object of type [boolean]: true
+json_tokener_parse_ex(tok, null        ,   4) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, null        ,   5) ... OK: got object of type [null]: null
+json_tokener_parse_ex(tok, Infinity    ,   9) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, infinity    ,   9) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, -infinity   ,  10) ... OK: got object of type [double]: -Infinity
+json_tokener_parse_ex(tok, infinity    ,   9) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, -infinity   ,  10) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, inf         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, inity       ,   6) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, -inf        ,   4) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, inity       ,   6) ... OK: got object of type [double]: -Infinity
+json_tokener_parse_ex(tok, i           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, n           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, f           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, i           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, n           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, i           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, t           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, y           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok,             ,   1) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, -           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, inf         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ini         ,   3) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ty          ,   3) ... OK: got object of type [double]: -Infinity
+json_tokener_parse_ex(tok, -           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, i           ,   1) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, nfini       ,   5) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, ty          ,   3) ... OK: got object of type [double]: -Infinity
+json_tokener_parse_ex(tok, -i          ,   2) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, nfinity     ,   8) ... OK: got object of type [double]: -Infinity
+json_tokener_parse_ex(tok, InfinityX   ,  10) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, X           ,   1) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, Infinity1234,  13) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, 1234        ,   5) ... OK: got object of type [int]: 1234
+json_tokener_parse_ex(tok, Infinity9999,   8) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, 1234        ,   5) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, 1234        ,   5) ... OK: got object of type [int]: 1234
+json_tokener_parse_ex(tok, [9223372036854775807],  22) ... OK: got object of type [array]: [ 9223372036854775807 ]
+json_tokener_parse_ex(tok, [9223372036854775808],  22) ... OK: got object of type [array]: [ 9223372036854775808 ]
+json_tokener_parse_ex(tok, [-9223372036854775808],  23) ... OK: got object of type [array]: [ -9223372036854775808 ]
+json_tokener_parse_ex(tok, [-9223372036854775809],  23) ... OK: got object of type [array]: [ -9223372036854775808 ]
+json_tokener_parse_ex(tok, [-9223372036854775809],  23) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, [18446744073709551615],  23) ... OK: got object of type [array]: [ 18446744073709551615 ]
+json_tokener_parse_ex(tok, [18446744073709551616],  23) ... OK: got object of type [array]: [ 18446744073709551615 ]
+json_tokener_parse_ex(tok, [18446744073709551616],  23) ... OK: got correct error: number expected
+json_tokener_parse_ex(tok, 18446744073709551616,  21) ... OK: got correct error: unexpected end of data
+json_tokener_parse_ex(tok, [9223372036854775808.0],  24) ... OK: got object of type [array]: [ 9223372036854775808.0 ]
+json_tokener_parse_ex(tok, [-9223372036854775809.0],  25) ... OK: got object of type [array]: [ -9223372036854775809.0 ]
+json_tokener_parse_ex(tok, [18446744073709551615.0],  25) ... OK: got object of type [array]: [ 18446744073709551615.0 ]
+json_tokener_parse_ex(tok, [18446744073709551616.0],  25) ... OK: got object of type [array]: [ 18446744073709551616.0 ]
+json_tokener_parse_ex(tok, noodle      ,   7) ... OK: got correct error: null expected
+json_tokener_parse_ex(tok, naodle      ,   7) ... OK: got correct error: null expected
+json_tokener_parse_ex(tok, track       ,   6) ... OK: got correct error: boolean expected
+json_tokener_parse_ex(tok, fail        ,   5) ... OK: got correct error: boolean expected
+json_tokener_parse_ex(tok, null123     ,   8) ... OK: got object of type [null]: null
+json_tokener_parse_ex(tok, 123         ,   4) ... OK: got object of type [int]: 123
+json_tokener_parse_ex(tok, nullx       ,   6) ... OK: got object of type [null]: null
+json_tokener_parse_ex(tok, x           ,   2) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"a":1}{"b":2},  15) ... OK: got object of type [object]: { "a": 1 }
+json_tokener_parse_ex(tok, {"b":2}     ,   8) ... OK: got object of type [object]: { "b": 2 }
+json_tokener_parse_ex(tok, 2015-01-15  ,  11) ... OK: got object of type [int]: 2015
+json_tokener_parse_ex(tok, -01-15      ,   7) ... OK: got object of type [int]: -1
+json_tokener_parse_ex(tok, -15         ,   4) ... OK: got object of type [int]: -15
+json_tokener_parse_ex(tok, 2015 01 15  ,  11) ... OK: got object of type [int]: 2015
+json_tokener_parse_ex(tok,  01 15      ,   7) ... OK: got object of type [int]: 1
+json_tokener_parse_ex(tok,  15         ,   4) ... OK: got object of type [int]: 15
+json_tokener_parse_ex(tok, "blue"      ,   6) ... OK: got object of type [string]: "blue"
+json_tokener_parse_ex(tok, "\""        ,   4) ... OK: got object of type [string]: "\""
+json_tokener_parse_ex(tok, "\\"        ,   4) ... OK: got object of type [string]: "\\"
+json_tokener_parse_ex(tok, "\b"        ,   4) ... OK: got object of type [string]: "\b"
+json_tokener_parse_ex(tok, "\f"        ,   4) ... OK: got object of type [string]: "\f"
+json_tokener_parse_ex(tok, "\n"        ,   4) ... OK: got object of type [string]: "\n"
+json_tokener_parse_ex(tok, "\r"        ,   4) ... OK: got object of type [string]: "\r"
+json_tokener_parse_ex(tok, "\t"        ,   4) ... OK: got object of type [string]: "\t"
+json_tokener_parse_ex(tok, "\/"        ,   4) ... OK: got object of type [string]: "\/"
+json_tokener_parse_ex(tok, "/"         ,   3) ... OK: got object of type [string]: "\/"
+json_tokener_parse_ex(tok, "\a"        ,   4) ... OK: got correct error: invalid string sequence
+json_tokener_parse_ex(tok, 'foo'       ,   5) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, [1,2,3]     ,   7) ... OK: got object of type [array]: [ 1, 2, 3 ]
+json_tokener_parse_ex(tok, [1,2,3}     ,   7) ... OK: got correct error: array value separator ',' expected
+json_tokener_parse_ex(tok, {"a"}       ,   5) ... OK: got correct error: object property name separator ':' expected
+json_tokener_parse_ex(tok, {"a":1]     ,   7) ... OK: got correct error: object value separator ',' expected
+json_tokener_parse_ex(tok, {"a"::1}    ,   8) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"a":}      ,   6) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"a":1,"a":2},  13) ... OK: got object of type [object]: { "a": 2 }
+json_tokener_parse_ex(tok, "a":1}      ,   6) ... OK: got object of type [string]: "a"
+json_tokener_parse_ex(tok, {"a":1      ,   6) ... OK: got correct error: continue
+json_tokener_parse_ex(tok, [,]         ,   3) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, [,1]        ,   4) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, [1,2,3,]    ,   8) ... OK: got object of type [array]: [ 1, 2, 3 ]
+json_tokener_parse_ex(tok, [1,2,,3,]   ,   9) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, [1,2,3,]    ,   8) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, {"a":1,}    ,   8) ... OK: got correct error: unexpected character
+json_tokener_parse_ex(tok, "123asc$%&" ,  11) ... OK: got object of type [string]: "123asc$%&"
+json_tokener_parse_ex(tok, "123asc$%&" ,  11) ... OK: got object of type [string]: "123asc$%&"
+json_tokener_parse_ex(tok, "世界"    ,   8) ... OK: got object of type [string]: "世界"
+json_tokener_parse_ex(tok, "ä¸         ,   3) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, –界"       ,   5) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, "世界"    ,   8) ... OK: got object of type [string]: "世界"
+json_tokener_parse_ex(tok, "πφ"      ,   6) ... OK: got object of type [string]: "πφ"
+json_tokener_parse_ex(tok, "𥑕"      ,   6) ... OK: got object of type [string]: "𥑕"
+json_tokener_parse_ex(tok, "æN"       ,   5) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, "æN"       ,   5) ... OK: got object of type [string]: "æN"
+json_tokener_parse_ex(tok, "ÀîÅô"      ,   6) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, "ÀîÅô"      ,   6) ... OK: got object of type [string]: "ÀîÅô"
+json_tokener_parse_ex(tok,   "世"     ,   7) ... OK: got object of type [string]: "世"
+json_tokener_parse_ex(tok,   "世"    ,   8) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, [ 1]       ,   5) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, Infinity    ,   9) ... OK: got object of type [double]: Infinity
+json_tokener_parse_ex(tok, Infnity    ,   8) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, "\ud855\udc55",  15) ... OK: got object of type [string]: "𥑕"
+json_tokener_parse_ex(tok, "\ud855Àudc55",  14) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, "\ud0031À"  ,  10) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, 1111       ,   5) ... OK: got correct error: invalid utf-8 string
+json_tokener_parse_ex(tok, {"1":1}    ,   8) ... OK: got correct error: invalid utf-8 string
+End Incremental Tests OK=198 ERROR=0
+==================================
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse.test b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.c b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.c
new file mode 100755
index 0000000..5710b08
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.c
@@ -0,0 +1,192 @@
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <stdio.h>
+#include <string.h>
+
+#include "config.h"
+
+#include "json_inttypes.h"
+#include "json_util.h"
+
+void checkit(const char *buf)
+{
+	int64_t cint64 = -666;
+
+	int retval = json_parse_int64(buf, &cint64);
+	printf("buf=%s parseit=%d, value=%" PRId64 " \n", buf, retval, cint64);
+}
+
+void checkit_uint(const char *buf)
+{
+	uint64_t cuint64 = 666;
+
+	int retval = json_parse_uint64(buf, &cuint64);
+	printf("buf=%s parseit=%d, value=%" PRIu64 " \n", buf, retval, cuint64);
+}
+
+/**
+ * This test calls json_parse_int64 and json_parse_int64 with a variety
+ * of different strings. It's purpose is to ensure that the results are
+ * consistent across all different environments that it might be executed in.
+ *
+ * This always exits with a 0 exit value.  The output should be compared
+ * against previously saved expected output.
+ */
+int main(int argc, char **argv)
+{
+	char buf[100];
+
+	printf("==========json_parse_int64() test===========\n");
+	checkit("x");
+
+	checkit("0");
+	checkit("-0");
+
+	checkit("00000000");
+	checkit("-00000000");
+
+	checkit("1");
+
+	strcpy(buf, "2147483647"); // aka INT32_MAX
+	checkit(buf);
+
+	strcpy(buf, "-1");
+	checkit(buf);
+
+	strcpy(buf, "   -1");
+	checkit(buf);
+
+	strcpy(buf, "00001234");
+	checkit(buf);
+
+	strcpy(buf, "0001234x");
+	checkit(buf);
+
+	strcpy(buf, "-00001234");
+	checkit(buf);
+
+	strcpy(buf, "-00001234x");
+	checkit(buf);
+
+	strcpy(buf, "4294967295"); // aka UINT32_MAX
+	checkit(buf);
+
+	strcpy(buf, "4294967296"); // aka UINT32_MAX + 1
+	checkit(buf);
+
+	strcpy(buf, "21474836470"); // INT32_MAX * 10
+	checkit(buf);
+
+	strcpy(buf, "31474836470"); // INT32_MAX * 10 + a bunch
+	checkit(buf);
+
+	strcpy(buf, "-2147483647"); // INT32_MIN + 1
+	checkit(buf);
+
+	strcpy(buf, "-2147483648"); // INT32_MIN
+	checkit(buf);
+
+	strcpy(buf, "-2147483649"); // INT32_MIN - 1
+	checkit(buf);
+
+	strcpy(buf, "-21474836480"); // INT32_MIN * 10
+	checkit(buf);
+
+	strcpy(buf, "9223372036854775806"); // INT64_MAX - 1
+	checkit(buf);
+
+	strcpy(buf, "9223372036854775807"); // INT64_MAX
+	checkit(buf);
+
+	strcpy(buf, "9223372036854775808"); // INT64_MAX + 1
+	checkit(buf);
+
+	strcpy(buf, "-9223372036854775808"); // INT64_MIN
+	checkit(buf);
+
+	strcpy(buf, "-9223372036854775809"); // INT64_MIN - 1
+	checkit(buf);
+
+	strcpy(buf, "18446744073709551614"); // UINT64_MAX - 1
+	checkit(buf);
+
+	strcpy(buf, "18446744073709551615"); // UINT64_MAX
+	checkit(buf);
+
+	strcpy(buf, "18446744073709551616"); // UINT64_MAX + 1
+	checkit(buf);
+
+	strcpy(buf, "-18446744073709551616"); // -UINT64_MAX
+	checkit(buf);
+
+	// Ensure we can still parse valid numbers after parsing out of range ones.
+	strcpy(buf, "123");
+	checkit(buf);
+
+	printf("\n==========json_parse_uint64() test===========\n");
+	checkit_uint("x");
+
+	checkit_uint("0");
+	checkit_uint("-0");
+
+	checkit_uint("00000000");
+	checkit_uint("-00000000");
+
+	checkit_uint("1");
+
+	strcpy(buf, "2147483647"); // aka INT32_MAX
+	checkit_uint(buf);
+
+	strcpy(buf, "-1");
+	checkit_uint(buf);
+
+	strcpy(buf, "-9223372036854775808");
+	checkit_uint(buf);
+
+	strcpy(buf, "   1");
+	checkit_uint(buf);
+
+	strcpy(buf, "00001234");
+	checkit_uint(buf);
+
+	strcpy(buf, "0001234x");
+	checkit_uint(buf);
+
+	strcpy(buf, "4294967295"); // aka UINT32_MAX
+	checkit_uint(buf);
+
+	strcpy(buf, "4294967296"); // aka UINT32_MAX + 1
+	checkit_uint(buf);
+
+	strcpy(buf, "21474836470"); // INT32_MAX * 10
+	checkit_uint(buf);
+
+	strcpy(buf, "31474836470"); // INT32_MAX * 10 + a bunch
+	checkit_uint(buf);
+
+	strcpy(buf, "9223372036854775806"); // INT64_MAX - 1
+	checkit_uint(buf);
+
+	strcpy(buf, "9223372036854775807"); // INT64_MAX
+	checkit_uint(buf);
+
+	strcpy(buf, "9223372036854775808"); // INT64_MAX + 1
+	checkit_uint(buf);
+
+	strcpy(buf, "18446744073709551614"); // UINT64_MAX - 1
+	checkit_uint(buf);
+
+	strcpy(buf, "18446744073709551615"); // UINT64_MAX
+	checkit_uint(buf);
+
+	strcpy(buf, "18446744073709551616"); // UINT64_MAX + 1
+	checkit_uint(buf);
+
+	// Ensure we can still parse valid numbers after parsing out of range ones.
+	strcpy(buf, "123");
+	checkit_uint(buf);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.expected
new file mode 100755
index 0000000..6dca94b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.expected
@@ -0,0 +1,57 @@
+==========json_parse_int64() test===========
+buf=x parseit=1, value=-666 
+buf=0 parseit=0, value=0 
+buf=-0 parseit=0, value=0 
+buf=00000000 parseit=0, value=0 
+buf=-00000000 parseit=0, value=0 
+buf=1 parseit=0, value=1 
+buf=2147483647 parseit=0, value=2147483647 
+buf=-1 parseit=0, value=-1 
+buf=   -1 parseit=0, value=-1 
+buf=00001234 parseit=0, value=1234 
+buf=0001234x parseit=0, value=1234 
+buf=-00001234 parseit=0, value=-1234 
+buf=-00001234x parseit=0, value=-1234 
+buf=4294967295 parseit=0, value=4294967295 
+buf=4294967296 parseit=0, value=4294967296 
+buf=21474836470 parseit=0, value=21474836470 
+buf=31474836470 parseit=0, value=31474836470 
+buf=-2147483647 parseit=0, value=-2147483647 
+buf=-2147483648 parseit=0, value=-2147483648 
+buf=-2147483649 parseit=0, value=-2147483649 
+buf=-21474836480 parseit=0, value=-21474836480 
+buf=9223372036854775806 parseit=0, value=9223372036854775806 
+buf=9223372036854775807 parseit=0, value=9223372036854775807 
+buf=9223372036854775808 parseit=0, value=9223372036854775807 
+buf=-9223372036854775808 parseit=0, value=-9223372036854775808 
+buf=-9223372036854775809 parseit=0, value=-9223372036854775808 
+buf=18446744073709551614 parseit=0, value=9223372036854775807 
+buf=18446744073709551615 parseit=0, value=9223372036854775807 
+buf=18446744073709551616 parseit=0, value=9223372036854775807 
+buf=-18446744073709551616 parseit=0, value=-9223372036854775808 
+buf=123 parseit=0, value=123 
+
+==========json_parse_uint64() test===========
+buf=x parseit=1, value=666 
+buf=0 parseit=0, value=0 
+buf=-0 parseit=1, value=666 
+buf=00000000 parseit=0, value=0 
+buf=-00000000 parseit=1, value=666 
+buf=1 parseit=0, value=1 
+buf=2147483647 parseit=0, value=2147483647 
+buf=-1 parseit=1, value=666 
+buf=-9223372036854775808 parseit=1, value=666 
+buf=   1 parseit=0, value=1 
+buf=00001234 parseit=0, value=1234 
+buf=0001234x parseit=0, value=1234 
+buf=4294967295 parseit=0, value=4294967295 
+buf=4294967296 parseit=0, value=4294967296 
+buf=21474836470 parseit=0, value=21474836470 
+buf=31474836470 parseit=0, value=31474836470 
+buf=9223372036854775806 parseit=0, value=9223372036854775806 
+buf=9223372036854775807 parseit=0, value=9223372036854775807 
+buf=9223372036854775808 parseit=0, value=9223372036854775808 
+buf=18446744073709551614 parseit=0, value=18446744073709551614 
+buf=18446744073709551615 parseit=0, value=18446744073709551615 
+buf=18446744073709551616 parseit=0, value=18446744073709551615 
+buf=123 parseit=0, value=123 
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.test b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_parse_int64.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.c b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.c
new file mode 100755
index 0000000..3b1540f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.c
@@ -0,0 +1,189 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "debug.h"
+#include "printbuf.h"
+
+static void test_basic_printbuf_memset(void);
+static void test_printbuf_memset_length(void);
+
+#ifndef __func__
+/* VC++ compat */
+#define __func__ __FUNCTION__
+#endif
+
+static void test_basic_printbuf_memset(void)
+{
+	struct printbuf *pb;
+
+	printf("%s: starting test\n", __func__);
+	pb = printbuf_new();
+	sprintbuf(pb, "blue:%d", 1);
+	printbuf_memset(pb, -1, 'x', 52);
+	printf("Buffer contents:%.*s\n", printbuf_length(pb), pb->buf);
+	printbuf_free(pb);
+	printf("%s: end test\n", __func__);
+}
+
+static void test_printbuf_memset_length(void)
+{
+	struct printbuf *pb;
+
+	printf("%s: starting test\n", __func__);
+	pb = printbuf_new();
+	printbuf_memset(pb, -1, ' ', 0);
+	printbuf_memset(pb, -1, ' ', 0);
+	printbuf_memset(pb, -1, ' ', 0);
+	printbuf_memset(pb, -1, ' ', 0);
+	printbuf_memset(pb, -1, ' ', 0);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+	printbuf_memset(pb, -1, ' ', 2);
+	printbuf_memset(pb, -1, ' ', 4);
+	printbuf_memset(pb, -1, ' ', 6);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+	printbuf_memset(pb, -1, ' ', 6);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+	printbuf_memset(pb, -1, ' ', 8);
+	printbuf_memset(pb, -1, ' ', 10);
+	printbuf_memset(pb, -1, ' ', 10);
+	printbuf_memset(pb, -1, ' ', 10);
+	printbuf_memset(pb, -1, ' ', 20);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+
+	// No length change should occur
+	printbuf_memset(pb, 0, 'x', 30);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+
+	// This should extend it by one.
+	printbuf_memset(pb, 0, 'x', printbuf_length(pb) + 1);
+	printf("Buffer length: %d\n", printbuf_length(pb));
+
+	printbuf_free(pb);
+	printf("%s: end test\n", __func__);
+}
+
+static void test_printbuf_memappend(int *before_resize);
+static void test_printbuf_memappend(int *before_resize)
+{
+	struct printbuf *pb;
+	int initial_size;
+
+	printf("%s: starting test\n", __func__);
+	pb = printbuf_new();
+	printf("Buffer length: %d\n", printbuf_length(pb));
+
+	initial_size = pb->size;
+
+	while (pb->size == initial_size)
+	{
+		printbuf_memappend_fast(pb, "x", 1);
+	}
+	*before_resize = printbuf_length(pb) - 1;
+	printf("Appended %d bytes for resize: [%s]\n", *before_resize + 1, pb->buf);
+
+	printbuf_reset(pb);
+	printbuf_memappend_fast(pb, "bluexyz123", 3);
+	printf("Partial append: %d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	char with_nulls[] = {'a', 'b', '\0', 'c'};
+	printbuf_reset(pb);
+	printbuf_memappend_fast(pb, with_nulls, (int)sizeof(with_nulls));
+	printf("With embedded \\0 character: %d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	printbuf_free(pb);
+	pb = printbuf_new();
+	char *data = malloc(*before_resize);
+	memset(data, 'X', *before_resize);
+	printbuf_memappend_fast(pb, data, *before_resize);
+	printf("Append to just before resize: %d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	free(data);
+	printbuf_free(pb);
+
+	pb = printbuf_new();
+	data = malloc(*before_resize + 1);
+	memset(data, 'X', *before_resize + 1);
+	printbuf_memappend_fast(pb, data, *before_resize + 1);
+	printf("Append to just after resize: %d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	free(data);
+	printbuf_free(pb);
+
+#define SA_TEST_STR "XXXXXXXXXXXXXXXX"
+	pb = printbuf_new();
+	printbuf_strappend(pb, SA_TEST_STR);
+	printf("Buffer size after printbuf_strappend(): %d, [%s]\n", printbuf_length(pb), pb->buf);
+	printbuf_free(pb);
+#undef SA_TEST_STR
+
+	printf("%s: end test\n", __func__);
+}
+
+static void test_sprintbuf(int before_resize);
+static void test_sprintbuf(int before_resize)
+{
+	struct printbuf *pb;
+	const char *max_char =
+	    "if string is greater than stack buffer, then use dynamic string"
+	    " with vasprintf.  Note: some implementation of vsnprintf return -1 "
+	    " if output is truncated whereas some return the number of bytes that "
+	    " would have been written - this code handles both cases.";
+
+	printf("%s: starting test\n", __func__);
+	pb = printbuf_new();
+	printf("Buffer length: %d\n", printbuf_length(pb));
+
+	char *data = malloc(before_resize + 1 + 1);
+	memset(data, 'X', before_resize + 1 + 1);
+	data[before_resize + 1] = '\0';
+	sprintbuf(pb, "%s", data);
+	free(data);
+	printf("sprintbuf to just after resize(%d+1): %d, [%s], strlen(buf)=%d\n", before_resize,
+	       printbuf_length(pb), pb->buf, (int)strlen(pb->buf));
+
+	printbuf_reset(pb);
+	sprintbuf(pb, "plain");
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	sprintbuf(pb, "%d", 1);
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	sprintbuf(pb, "%d", INT_MAX);
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	sprintbuf(pb, "%d", INT_MIN);
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	sprintbuf(pb, "%s", "%s");
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+
+	sprintbuf(pb, max_char);
+	printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
+	printbuf_free(pb);
+	printf("%s: end test\n", __func__);
+}
+
+int main(int argc, char **argv)
+{
+	int before_resize = 0;
+
+	MC_SET_DEBUG(1);
+
+	test_basic_printbuf_memset();
+	printf("========================================\n");
+	test_printbuf_memset_length();
+	printf("========================================\n");
+	test_printbuf_memappend(&before_resize);
+	printf("========================================\n");
+	test_sprintbuf(before_resize);
+	printf("========================================\n");
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.expected
new file mode 100755
index 0000000..a4ebc2a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.expected
@@ -0,0 +1,34 @@
+test_basic_printbuf_memset: starting test
+Buffer contents:blue:1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+test_basic_printbuf_memset: end test
+========================================
+test_printbuf_memset_length: starting test
+Buffer length: 0
+Buffer length: 12
+Buffer length: 18
+Buffer length: 76
+Buffer length: 76
+Buffer length: 77
+test_printbuf_memset_length: end test
+========================================
+test_printbuf_memappend: starting test
+Buffer length: 0
+Appended 32 bytes for resize: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
+Partial append: 3, [blu]
+With embedded \0 character: 4, [ab]
+Append to just before resize: 31, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
+Append to just after resize: 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
+Buffer size after printbuf_strappend(): 16, [XXXXXXXXXXXXXXXX]
+test_printbuf_memappend: end test
+========================================
+test_sprintbuf: starting test
+Buffer length: 0
+sprintbuf to just after resize(31+1): 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX], strlen(buf)=32
+5, [plain]
+6, [plain1]
+16, [plain12147483647]
+27, [plain12147483647-2147483648]
+29, [plain12147483647-2147483648%s]
+284, [plain12147483647-2147483648%sif string is greater than stack buffer, then use dynamic string with vasprintf.  Note: some implementation of vsnprintf return -1  if output is truncated whereas some return the number of bytes that  would have been written - this code handles both cases.]
+test_sprintbuf: end test
+========================================
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.test b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_printbuf.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.c b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.c
new file mode 100755
index 0000000..27598f4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.c
@@ -0,0 +1,87 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "json.h"
+#include "printbuf.h"
+
+struct myinfo
+{
+	int value;
+};
+
+static int freeit_was_called = 0;
+static void freeit(json_object *jso, void *userdata)
+{
+	struct myinfo *info = userdata;
+	printf("freeit, value=%d\n", info->value);
+	// Don't actually free anything here, the userdata is stack allocated.
+	freeit_was_called = 1;
+}
+static int custom_serializer(struct json_object *o, struct printbuf *pb, int level, int flags)
+{
+	sprintbuf(pb, "Custom Output");
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	json_object *my_object, *my_sub_object;
+
+	MC_SET_DEBUG(1);
+
+	printf("Test setting, then resetting a custom serializer:\n");
+	my_object = json_object_new_object();
+	json_object_object_add(my_object, "abc", json_object_new_int(12));
+	json_object_object_add(my_object, "foo", json_object_new_string("bar"));
+
+	printf("my_object.to_string(standard)=%s\n", json_object_to_json_string(my_object));
+
+	struct myinfo userdata = {.value = 123};
+	json_object_set_serializer(my_object, custom_serializer, &userdata, freeit);
+
+	printf("my_object.to_string(custom serializer)=%s\n",
+	       json_object_to_json_string(my_object));
+
+	printf("Next line of output should be from the custom freeit function:\n");
+	freeit_was_called = 0;
+	json_object_set_serializer(my_object, NULL, NULL, NULL);
+	assert(freeit_was_called);
+
+	printf("my_object.to_string(standard)=%s\n", json_object_to_json_string(my_object));
+
+	json_object_put(my_object);
+
+	// ============================================
+
+	my_object = json_object_new_object();
+	printf("Check that the custom serializer isn't free'd until the last json_object_put:\n");
+	json_object_set_serializer(my_object, custom_serializer, &userdata, freeit);
+	json_object_get(my_object);
+	json_object_put(my_object);
+	printf("my_object.to_string(custom serializer)=%s\n",
+	       json_object_to_json_string(my_object));
+	printf("Next line of output should be from the custom freeit function:\n");
+
+	freeit_was_called = 0;
+	json_object_put(my_object);
+	assert(freeit_was_called);
+
+	// ============================================
+
+	my_object = json_object_new_object();
+	my_sub_object = json_object_new_double(1.0);
+	json_object_object_add(my_object, "double", my_sub_object);
+	printf("Check that the custom serializer does not include nul byte:\n");
+#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
+	json_object_set_serializer(my_sub_object, json_object_double_to_json_string, UNCONST("%125.0f"), NULL);
+	printf("my_object.to_string(custom serializer)=%s\n",
+	       json_object_to_json_string_ext(my_object, JSON_C_TO_STRING_NOZERO));
+
+	json_object_put(my_object);
+
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.expected
new file mode 100755
index 0000000..9a13512
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.expected
@@ -0,0 +1,12 @@
+Test setting, then resetting a custom serializer:
+my_object.to_string(standard)={ "abc": 12, "foo": "bar" }
+my_object.to_string(custom serializer)=Custom Output
+Next line of output should be from the custom freeit function:
+freeit, value=123
+my_object.to_string(standard)={ "abc": 12, "foo": "bar" }
+Check that the custom serializer isn't free'd until the last json_object_put:
+my_object.to_string(custom serializer)=Custom Output
+Next line of output should be from the custom freeit function:
+freeit, value=123
+Check that the custom serializer does not include nul byte:
+my_object.to_string(custom serializer)={"double":                                                                                                                            1}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.test b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_serializer.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.c b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.c
new file mode 100755
index 0000000..a8ebbfe
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.c
@@ -0,0 +1,116 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "json.h"
+
+int main(int argc, char **argv)
+{
+	json_object *tmp = json_object_new_int(123);
+	assert(json_object_get_int(tmp) == 123);
+	json_object_set_int(tmp, 321);
+	assert(json_object_get_int(tmp) == 321);
+	printf("INT PASSED\n");
+	json_object_set_int64(tmp, (int64_t)321321321);
+	assert(json_object_get_int64(tmp) == 321321321);
+	json_object_put(tmp);
+	printf("INT64 PASSED\n");
+	tmp = json_object_new_uint64(123);
+	assert(json_object_get_boolean(tmp) == 1);
+	assert(json_object_get_int(tmp) == 123);
+	assert(json_object_get_int64(tmp) == 123);
+	assert(json_object_get_uint64(tmp) == 123);
+	assert(json_object_get_double(tmp) == 123.000000);
+	json_object_set_uint64(tmp, (uint64_t)321321321);
+	assert(json_object_get_uint64(tmp) == 321321321);
+	json_object_set_uint64(tmp, 9223372036854775808U);
+	assert(json_object_get_int(tmp) == INT32_MAX);
+	assert(json_object_get_uint64(tmp) == 9223372036854775808U);
+	json_object_put(tmp);
+	printf("UINT64 PASSED\n");
+	tmp = json_object_new_boolean(1);
+	assert(json_object_get_boolean(tmp) == 1);
+	json_object_set_boolean(tmp, 0);
+	assert(json_object_get_boolean(tmp) == 0);
+	json_object_set_boolean(tmp, 1);
+	assert(json_object_get_boolean(tmp) == 1);
+	json_object_put(tmp);
+	printf("BOOL PASSED\n");
+	tmp = json_object_new_double(12.34);
+	assert(json_object_get_double(tmp) == 12.34);
+	json_object_set_double(tmp, 34.56);
+	assert(json_object_get_double(tmp) == 34.56);
+	json_object_set_double(tmp, 6435.34);
+	assert(json_object_get_double(tmp) == 6435.34);
+	json_object_set_double(tmp, 2e21);
+	assert(json_object_get_int(tmp) == INT32_MAX);
+	assert(json_object_get_int64(tmp) == INT64_MAX);
+	assert(json_object_get_uint64(tmp) == UINT64_MAX);
+	json_object_set_double(tmp, -2e21);
+	assert(json_object_get_int(tmp) == INT32_MIN);
+	assert(json_object_get_int64(tmp) == INT64_MIN);
+	assert(json_object_get_uint64(tmp) == 0);
+	json_object_put(tmp);
+	printf("DOUBLE PASSED\n");
+#define SHORT "SHORT"
+#define MID "A MID STRING"
+//             12345678901234567890123456789012....
+#define HUGE "A string longer than 32 chars as to check non local buf codepath"
+	tmp = json_object_new_string(MID);
+	assert(strcmp(json_object_get_string(tmp), MID) == 0);
+	assert(strcmp(json_object_to_json_string(tmp), "\"" MID "\"") == 0);
+	json_object_set_string(tmp, SHORT);
+	assert(strcmp(json_object_get_string(tmp), SHORT) == 0);
+	assert(strcmp(json_object_to_json_string(tmp), "\"" SHORT "\"") == 0);
+	json_object_set_string(tmp, HUGE);
+	assert(strcmp(json_object_get_string(tmp), HUGE) == 0);
+	assert(strcmp(json_object_to_json_string(tmp), "\"" HUGE "\"") == 0);
+	json_object_set_string(tmp, SHORT);
+	assert(strcmp(json_object_get_string(tmp), SHORT) == 0);
+	assert(strcmp(json_object_to_json_string(tmp), "\"" SHORT "\"") == 0);
+
+	// Set an empty string a couple times to try to trigger
+	// a case that used to leak memory.
+	json_object_set_string(tmp, "");
+	json_object_set_string(tmp, HUGE);
+	json_object_set_string(tmp, "");
+	json_object_set_string(tmp, HUGE);
+
+	json_object_put(tmp);
+	printf("STRING PASSED\n");
+
+#define STR "STR"
+#define DOUBLE "123.123"
+#define DOUBLE_E "12E+3"
+#define DOUBLE_STR "123.123STR"
+#define DOUBLE_OVER "1.8E+308"
+#define DOUBLE_OVER_NEGATIVE "-1.8E+308"
+	tmp = json_object_new_string(STR);
+	assert(json_object_get_double(tmp) == 0.0);
+	json_object_set_string(tmp, DOUBLE);
+	assert(json_object_get_double(tmp) == 123.123000);
+	json_object_set_string(tmp, DOUBLE_E);
+	assert(json_object_get_double(tmp) == 12000.000000);
+	json_object_set_string(tmp, DOUBLE_STR);
+	assert(json_object_get_double(tmp) == 0.0);
+	json_object_set_string(tmp, DOUBLE_OVER);
+	assert(json_object_get_double(tmp) == 0.0);
+	json_object_set_string(tmp, DOUBLE_OVER_NEGATIVE);
+	assert(json_object_get_double(tmp) == 0.0);
+	json_object_put(tmp);
+	printf("STRINGTODOUBLE PASSED\n");
+
+	tmp = json_tokener_parse("1.234");
+	json_object_set_double(tmp, 12.3);
+	const char *serialized = json_object_to_json_string(tmp);
+	fprintf(stderr, "%s\n", serialized);
+	assert(strncmp(serialized, "12.3", 4) == 0);
+	json_object_put(tmp);
+	printf("PARSE AND SET PASSED\n");
+
+	printf("PASSED\n");
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.expected
new file mode 100755
index 0000000..7b43eec
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.expected
@@ -0,0 +1,9 @@
+INT PASSED
+INT64 PASSED
+UINT64 PASSED
+BOOL PASSED
+DOUBLE PASSED
+STRING PASSED
+STRINGTODOUBLE PASSED
+PARSE AND SET PASSED
+PASSED
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.test b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_set_value.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.c b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.c
new file mode 100755
index 0000000..57b051f
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.c
@@ -0,0 +1,14 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "strerror_override.h"
+#include "strerror_override_private.h"
+
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+	puts(strerror(10000));
+	puts(strerror(999));
+	return 0;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.expected
new file mode 100755
index 0000000..b6b3bb6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.expected
@@ -0,0 +1,2 @@
+ERRNO=10000
+ERRNO=999
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.test b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_strerror.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.c b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.c
new file mode 100755
index 0000000..27a097e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.c
@@ -0,0 +1,306 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include "strerror_override.h"
+#include "strerror_override_private.h"
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <io.h>
+#include <windows.h>
+#endif /* defined(WIN32) */
+#include <fcntl.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <assert.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "json.h"
+#include "json_util.h"
+#include "snprintf_compat.h"
+
+static void test_read_valid_with_fd(const char *testdir);
+static void test_read_valid_nested_with_fd(const char *testdir);
+static void test_read_nonexistant(void);
+static void test_read_closed(void);
+
+static void test_write_to_file(void);
+static void stat_and_cat(const char *file);
+static void test_read_fd_equal(const char *testdir);
+
+#ifndef PATH_MAX
+#define PATH_MAX 256
+#endif
+
+static void test_write_to_file(void)
+{
+	json_object *jso;
+
+	jso = json_tokener_parse("{"
+	                         "\"foo\":1234,"
+	                         "\"foo1\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo2\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo3\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo4\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo5\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo6\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo7\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo8\":\"abcdefghijklmnopqrstuvwxyz\","
+	                         "\"foo9\":\"abcdefghijklmnopqrstuvwxyz\""
+	                         "}");
+	const char *outfile = "json.out";
+	int rv = json_object_to_file(outfile, jso);
+	printf("%s: json_object_to_file(%s, jso)=%d\n", (rv == 0) ? "OK" : "FAIL", outfile, rv);
+	if (rv == 0)
+		stat_and_cat(outfile);
+
+	putchar('\n');
+
+	const char *outfile2 = "json2.out";
+	rv = json_object_to_file_ext(outfile2, jso, JSON_C_TO_STRING_PRETTY);
+	printf("%s: json_object_to_file_ext(%s, jso, JSON_C_TO_STRING_PRETTY)=%d\n",
+	       (rv == 0) ? "OK" : "FAIL", outfile2, rv);
+	if (rv == 0)
+		stat_and_cat(outfile2);
+
+	const char *outfile3 = "json3.out";
+	int d = open(outfile3, O_WRONLY | O_CREAT, 0600);
+	if (d < 0)
+	{
+		printf("FAIL: unable to open %s %s\n", outfile3, strerror(errno));
+		return;
+	}
+	rv = json_object_to_fd(d, jso, JSON_C_TO_STRING_PRETTY);
+	printf("%s: json_object_to_fd(%s, jso, JSON_C_TO_STRING_PRETTY)=%d\n",
+	       (rv == 0) ? "OK" : "FAIL", outfile3, rv);
+	// Write the same object twice
+	rv = json_object_to_fd(d, jso, JSON_C_TO_STRING_PLAIN);
+	printf("%s: json_object_to_fd(%s, jso, JSON_C_TO_STRING_PLAIN)=%d\n",
+	       (rv == 0) ? "OK" : "FAIL", outfile3, rv);
+	close(d);
+	if (rv == 0)
+		stat_and_cat(outfile3);
+
+	json_object_put(jso);
+}
+
+static void stat_and_cat(const char *file)
+{
+	struct stat sb;
+	int d = open(file, O_RDONLY);
+	if (d < 0)
+	{
+		printf("FAIL: unable to open %s: %s\n", file, strerror(errno));
+		return;
+	}
+	if (fstat(d, &sb) < 0)
+	{
+		printf("FAIL: unable to stat %s: %s\n", file, strerror(errno));
+		close(d);
+		return;
+	}
+	char *buf = malloc(sb.st_size + 1);
+	if (!buf)
+	{
+		printf("FAIL: unable to allocate memory\n");
+		close(d);
+		return;
+	}
+	if (read(d, buf, sb.st_size) < sb.st_size)
+	{
+		printf("FAIL: unable to read all of %s: %s\n", file, strerror(errno));
+		free(buf);
+		close(d);
+		return;
+	}
+	buf[sb.st_size] = '\0';
+	printf("file[%s], size=%d, contents=%s\n", file, (int)sb.st_size, buf);
+	free(buf);
+	close(d);
+}
+
+int main(int argc, char **argv)
+{
+	//	json_object_to_file(file, obj);
+	//	json_object_to_file_ext(file, obj, flags);
+
+	const char *testdir;
+	if (argc < 2)
+	{
+		fprintf(stderr,
+		        "Usage: %s <testdir>\n"
+		        "  <testdir> is the location of input files\n",
+		        argv[0]);
+		return EXIT_FAILURE;
+	}
+	testdir = argv[1];
+
+	//	Test json_c_version.c
+	if (strncmp(json_c_version(), JSON_C_VERSION, sizeof(JSON_C_VERSION)))
+	{
+		printf("FAIL: Output from json_c_version(): %s "
+		       "does not match %s",
+		       json_c_version(), JSON_C_VERSION);
+		return EXIT_FAILURE;
+	}
+	if (json_c_version_num() != JSON_C_VERSION_NUM)
+	{
+		printf("FAIL: Output from json_c_version_num(): %d "
+		       "does not match %d",
+		       json_c_version_num(), JSON_C_VERSION_NUM);
+		return EXIT_FAILURE;
+	}
+
+	test_read_valid_with_fd(testdir);
+	test_read_valid_nested_with_fd(testdir);
+	test_read_nonexistant();
+	test_read_closed();
+	test_write_to_file();
+	test_read_fd_equal(testdir);
+	return EXIT_SUCCESS;
+}
+
+static void test_read_valid_with_fd(const char *testdir)
+{
+	char filename[PATH_MAX];
+	(void)snprintf(filename, sizeof(filename), "%s/valid.json", testdir);
+
+	int d = open(filename, O_RDONLY);
+	if (d < 0)
+	{
+		fprintf(stderr, "FAIL: unable to open %s: %s\n", filename, strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+	json_object *jso = json_object_from_fd(d);
+	if (jso != NULL)
+	{
+		printf("OK: json_object_from_fd(valid.json)=%s\n", json_object_to_json_string(jso));
+		json_object_put(jso);
+	}
+	else
+	{
+		fprintf(stderr, "FAIL: unable to parse contents of %s: %s\n", filename,
+		        json_util_get_last_err());
+	}
+	close(d);
+}
+
+static void test_read_valid_nested_with_fd(const char *testdir)
+{
+	char filename[PATH_MAX];
+	(void)snprintf(filename, sizeof(filename), "%s/valid_nested.json", testdir);
+
+	int d = open(filename, O_RDONLY);
+	if (d < 0)
+	{
+		fprintf(stderr, "FAIL: unable to open %s: %s\n", filename, strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+	assert(NULL == json_object_from_fd_ex(d, -2));
+	json_object *jso = json_object_from_fd_ex(d, 20);
+	if (jso != NULL)
+	{
+		printf("OK: json_object_from_fd_ex(valid_nested.json, 20)=%s\n",
+		       json_object_to_json_string(jso));
+		json_object_put(jso);
+	}
+	else
+	{
+		fprintf(stderr, "FAIL: unable to parse contents of %s: %s\n", filename,
+		        json_util_get_last_err());
+	}
+
+	(void)lseek(d, SEEK_SET, 0);
+
+	jso = json_object_from_fd_ex(d, 3);
+	if (jso != NULL)
+	{
+		printf("FAIL: json_object_from_fd_ex(%s, 3)=%s\n", filename,
+		       json_object_to_json_string(jso));
+		json_object_put(jso);
+	}
+	else
+	{
+		printf("OK: correctly unable to parse contents of valid_nested.json with low max "
+		       "depth: %s\n",
+		       json_util_get_last_err());
+	}
+	close(d);
+}
+
+static void test_read_nonexistant(void)
+{
+	const char *filename = "./not_present.json";
+
+	json_object *jso = json_object_from_file(filename);
+	if (jso != NULL)
+	{
+		printf("FAIL: json_object_from_file(%s) returned %p when NULL expected\n", filename,
+		       (void *)jso);
+		json_object_put(jso);
+	}
+	else
+	{
+		printf("OK: json_object_from_file(%s) correctly returned NULL: %s\n", filename,
+		       json_util_get_last_err());
+	}
+}
+
+static void test_read_closed(void)
+{
+	// Test reading from a closed fd
+	int d = open("/dev/null", O_RDONLY);
+	if (d < 0)
+	{
+		puts("FAIL: unable to open");
+	}
+	// Copy over to a fixed fd number so test output is consistent.
+	int fixed_d = 10;
+	if (dup2(d, fixed_d) < 0)
+	{
+		printf("FAIL: unable to dup to fd %d", fixed_d);
+	}
+	close(d);
+	close(fixed_d);
+
+	json_object *jso = json_object_from_fd(fixed_d);
+	if (jso != NULL)
+	{
+		printf("FAIL: read from closed fd returning non-NULL: %p\n", (void *)jso);
+		fflush(stdout);
+		printf("  jso=%s\n", json_object_to_json_string(jso));
+		json_object_put(jso);
+		return;
+	}
+	printf("OK: json_object_from_fd(closed_fd), "
+	       "expecting NULL, EBADF, got:NULL, %s\n",
+	       json_util_get_last_err());
+}
+
+static void test_read_fd_equal(const char *testdir)
+{
+	char filename[PATH_MAX];
+	(void)snprintf(filename, sizeof(filename), "%s/valid_nested.json", testdir);
+
+	json_object *jso = json_object_from_file(filename);
+
+	int d = open(filename, O_RDONLY);
+	if (d < 0)
+	{
+		fprintf(stderr, "FAIL: unable to open %s: %s\n", filename, strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+	json_object *new_jso = json_object_from_fd(d);
+	close(d);
+
+	printf("OK: json_object_from_file(valid.json)=%s\n", json_object_to_json_string(jso));
+	printf("OK: json_object_from_fd(valid.json)=%s\n", json_object_to_json_string(new_jso));
+	json_object_put(jso);
+	json_object_put(new_jso);
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.expected
new file mode 100755
index 0000000..4a8aea5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.expected
@@ -0,0 +1,40 @@
+OK: json_object_from_fd(valid.json)={ "foo": 123 }
+OK: json_object_from_fd_ex(valid_nested.json, 20)={ "foo": 123, "obj2": { "obj3": { "obj4": { "foo": 999 } } } }
+OK: correctly unable to parse contents of valid_nested.json with low max depth: json_tokener_parse_ex failed: nesting too deep
+
+OK: json_object_from_file(./not_present.json) correctly returned NULL: json_object_from_file: error opening file ./not_present.json: ERRNO=ENOENT
+
+OK: json_object_from_fd(closed_fd), expecting NULL, EBADF, got:NULL, json_object_from_fd_ex: error reading fd 10: ERRNO=EBADF
+
+OK: json_object_to_file(json.out, jso)=0
+file[json.out], size=336, contents={"foo":1234,"foo1":"abcdefghijklmnopqrstuvwxyz","foo2":"abcdefghijklmnopqrstuvwxyz","foo3":"abcdefghijklmnopqrstuvwxyz","foo4":"abcdefghijklmnopqrstuvwxyz","foo5":"abcdefghijklmnopqrstuvwxyz","foo6":"abcdefghijklmnopqrstuvwxyz","foo7":"abcdefghijklmnopqrstuvwxyz","foo8":"abcdefghijklmnopqrstuvwxyz","foo9":"abcdefghijklmnopqrstuvwxyz"}
+
+OK: json_object_to_file_ext(json2.out, jso, JSON_C_TO_STRING_PRETTY)=0
+file[json2.out], size=367, contents={
+  "foo":1234,
+  "foo1":"abcdefghijklmnopqrstuvwxyz",
+  "foo2":"abcdefghijklmnopqrstuvwxyz",
+  "foo3":"abcdefghijklmnopqrstuvwxyz",
+  "foo4":"abcdefghijklmnopqrstuvwxyz",
+  "foo5":"abcdefghijklmnopqrstuvwxyz",
+  "foo6":"abcdefghijklmnopqrstuvwxyz",
+  "foo7":"abcdefghijklmnopqrstuvwxyz",
+  "foo8":"abcdefghijklmnopqrstuvwxyz",
+  "foo9":"abcdefghijklmnopqrstuvwxyz"
+}
+OK: json_object_to_fd(json3.out, jso, JSON_C_TO_STRING_PRETTY)=0
+OK: json_object_to_fd(json3.out, jso, JSON_C_TO_STRING_PLAIN)=0
+file[json3.out], size=703, contents={
+  "foo":1234,
+  "foo1":"abcdefghijklmnopqrstuvwxyz",
+  "foo2":"abcdefghijklmnopqrstuvwxyz",
+  "foo3":"abcdefghijklmnopqrstuvwxyz",
+  "foo4":"abcdefghijklmnopqrstuvwxyz",
+  "foo5":"abcdefghijklmnopqrstuvwxyz",
+  "foo6":"abcdefghijklmnopqrstuvwxyz",
+  "foo7":"abcdefghijklmnopqrstuvwxyz",
+  "foo8":"abcdefghijklmnopqrstuvwxyz",
+  "foo9":"abcdefghijklmnopqrstuvwxyz"
+}{"foo":1234,"foo1":"abcdefghijklmnopqrstuvwxyz","foo2":"abcdefghijklmnopqrstuvwxyz","foo3":"abcdefghijklmnopqrstuvwxyz","foo4":"abcdefghijklmnopqrstuvwxyz","foo5":"abcdefghijklmnopqrstuvwxyz","foo6":"abcdefghijklmnopqrstuvwxyz","foo7":"abcdefghijklmnopqrstuvwxyz","foo8":"abcdefghijklmnopqrstuvwxyz","foo9":"abcdefghijklmnopqrstuvwxyz"}
+OK: json_object_from_file(valid.json)={ "foo": 123, "obj2": { "obj3": { "obj4": { "foo": 999 } } } }
+OK: json_object_from_fd(valid.json)={ "foo": 123, "obj2": { "obj3": { "obj4": { "foo": 999 } } } }
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.test b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_util_file.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_visit.c b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.c
new file mode 100755
index 0000000..3283a55
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.c
@@ -0,0 +1,152 @@
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <assert.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "json.h"
+#include "json_tokener.h"
+#include "json_visit.h"
+
+static json_c_visit_userfunc emit_object;
+static json_c_visit_userfunc skip_arrays;
+static json_c_visit_userfunc pop_and_stop;
+static json_c_visit_userfunc err_on_subobj2;
+static json_c_visit_userfunc pop_array;
+static json_c_visit_userfunc stop_array;
+static json_c_visit_userfunc err_return;
+
+int main(void)
+{
+	MC_SET_DEBUG(1);
+
+	const char *input = "{\
+		\"obj1\": 123,\
+		\"obj2\": {\
+			\"subobj1\": \"aaa\",\
+			\"subobj2\": \"bbb\",\
+			\"subobj3\": [ \"elem1\", \"elem2\", true ],\
+		},\
+		\"obj3\": 1.234,\
+		\"obj4\": [ true, false, null ]\
+	}";
+
+	json_object *jso = json_tokener_parse(input);
+	printf("jso.to_string()=%s\n", json_object_to_json_string(jso));
+
+	int rv;
+	rv = json_c_visit(jso, 0, emit_object, NULL);
+	printf("json_c_visit(emit_object)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, skip_arrays, NULL);
+	printf("json_c_visit(skip_arrays)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, pop_and_stop, NULL);
+	printf("json_c_visit(pop_and_stop)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, err_on_subobj2, NULL);
+	printf("json_c_visit(err_on_subobj2)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, pop_array, NULL);
+	printf("json_c_visit(pop_array)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, stop_array, NULL);
+	printf("json_c_visit(stop_array)=%d\n", rv);
+	printf("================================\n\n");
+
+	rv = json_c_visit(jso, 0, err_return, NULL);
+	printf("json_c_visit(err_return)=%d\n", rv);
+	printf("================================\n\n");
+
+	json_object_put(jso);
+
+	return 0;
+}
+
+static int emit_object(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                       size_t *jso_index, void *userarg)
+{
+	printf("flags: 0x%x, key: %s, index: %ld, value: %s\n", flags,
+	       (jso_key ? jso_key : "(null)"), (jso_index ? (long)*jso_index : -1L),
+	       json_object_to_json_string(jso));
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int skip_arrays(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                       size_t *jso_index, void *userarg)
+{
+	(void)emit_object(jso, flags, parent_jso, jso_key, jso_index, userarg);
+	if (json_object_get_type(jso) == json_type_array)
+		return JSON_C_VISIT_RETURN_SKIP;
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int pop_and_stop(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                        size_t *jso_index, void *userarg)
+{
+	(void)emit_object(jso, flags, parent_jso, jso_key, jso_index, userarg);
+	if (jso_key != NULL && strcmp(jso_key, "subobj1") == 0)
+	{
+		printf("POP after handling subobj1\n");
+		return JSON_C_VISIT_RETURN_POP;
+	}
+	if (jso_key != NULL && strcmp(jso_key, "obj3") == 0)
+	{
+		printf("STOP after handling obj3\n");
+		return JSON_C_VISIT_RETURN_STOP;
+	}
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int err_on_subobj2(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                          size_t *jso_index, void *userarg)
+{
+	(void)emit_object(jso, flags, parent_jso, jso_key, jso_index, userarg);
+	if (jso_key != NULL && strcmp(jso_key, "subobj2") == 0)
+	{
+		printf("ERROR after handling subobj1\n");
+		return JSON_C_VISIT_RETURN_ERROR;
+	}
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int pop_array(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                     size_t *jso_index, void *userarg)
+{
+	(void)emit_object(jso, flags, parent_jso, jso_key, jso_index, userarg);
+	if (jso_index != NULL && (*jso_index == 0))
+	{
+		printf("POP after handling array[0]\n");
+		return JSON_C_VISIT_RETURN_POP;
+	}
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int stop_array(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                      size_t *jso_index, void *userarg)
+{
+	(void)emit_object(jso, flags, parent_jso, jso_key, jso_index, userarg);
+	if (jso_index != NULL && (*jso_index == 0))
+	{
+		printf("STOP after handling array[1]\n");
+		return JSON_C_VISIT_RETURN_STOP;
+	}
+	return JSON_C_VISIT_RETURN_CONTINUE;
+}
+
+static int err_return(json_object *jso, int flags, json_object *parent_jso, const char *jso_key,
+                      size_t *jso_index, void *userarg)
+{
+	printf("flags: 0x%x, key: %s, index: %ld, value: %s\n", flags,
+	       (jso_key ? jso_key : "(null)"), (jso_index ? (long)*jso_index : -1L),
+	       json_object_to_json_string(jso));
+	return 100;
+}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_visit.expected b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.expected
new file mode 100755
index 0000000..5f32317
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.expected
@@ -0,0 +1,89 @@
+jso.to_string()={ "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+flags: 0x0, key: subobj2, index: -1, value: "bbb"
+flags: 0x0, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x0, key: (null), index: 0, value: "elem1"
+flags: 0x0, key: (null), index: 1, value: "elem2"
+flags: 0x0, key: (null), index: 2, value: true
+flags: 0x2, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x2, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: obj3, index: -1, value: 1.234
+flags: 0x0, key: obj4, index: -1, value: [ true, false, null ]
+flags: 0x0, key: (null), index: 0, value: true
+flags: 0x0, key: (null), index: 1, value: false
+flags: 0x0, key: (null), index: 2, value: null
+flags: 0x2, key: obj4, index: -1, value: [ true, false, null ]
+flags: 0x2, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+json_c_visit(emit_object)=0
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+flags: 0x0, key: subobj2, index: -1, value: "bbb"
+flags: 0x0, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x2, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: obj3, index: -1, value: 1.234
+flags: 0x0, key: obj4, index: -1, value: [ true, false, null ]
+flags: 0x2, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+json_c_visit(skip_arrays)=0
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+POP after handling subobj1
+flags: 0x2, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: obj3, index: -1, value: 1.234
+STOP after handling obj3
+json_c_visit(pop_and_stop)=0
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+flags: 0x0, key: subobj2, index: -1, value: "bbb"
+ERROR after handling subobj1
+json_c_visit(err_on_subobj2)=-1
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+flags: 0x0, key: subobj2, index: -1, value: "bbb"
+flags: 0x0, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x0, key: (null), index: 0, value: "elem1"
+POP after handling array[0]
+flags: 0x2, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x2, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: obj3, index: -1, value: 1.234
+flags: 0x0, key: obj4, index: -1, value: [ true, false, null ]
+flags: 0x0, key: (null), index: 0, value: true
+POP after handling array[0]
+flags: 0x2, key: obj4, index: -1, value: [ true, false, null ]
+flags: 0x2, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+json_c_visit(pop_array)=0
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+flags: 0x0, key: obj1, index: -1, value: 123
+flags: 0x0, key: obj2, index: -1, value: { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }
+flags: 0x0, key: subobj1, index: -1, value: "aaa"
+flags: 0x0, key: subobj2, index: -1, value: "bbb"
+flags: 0x0, key: subobj3, index: -1, value: [ "elem1", "elem2", true ]
+flags: 0x0, key: (null), index: 0, value: "elem1"
+STOP after handling array[1]
+json_c_visit(stop_array)=0
+================================
+
+flags: 0x0, key: (null), index: -1, value: { "obj1": 123, "obj2": { "subobj1": "aaa", "subobj2": "bbb", "subobj3": [ "elem1", "elem2", true ] }, "obj3": 1.234, "obj4": [ true, false, null ] }
+json_c_visit(err_return)=-1
+================================
+
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/test_visit.test b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.test
new file mode 100755
index 0000000..474e7a8
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/test_visit.test
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export _JSON_C_STRERROR_ENABLE=1
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+filename=$(basename "$0")
+filename="${filename%.*}"
+
+# This is only for the test_util_file.test ;
+# more stuff could be extended
+cp -f "$srcdir/valid.json" .
+
+run_output_test $filename "$srcdir"
+exit $?
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/valid.json b/lynq/S300/ap/app/apparms/json-c/tests/valid.json
new file mode 100755
index 0000000..bde58e7
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/valid.json
@@ -0,0 +1 @@
+{"foo":123}
diff --git a/lynq/S300/ap/app/apparms/json-c/tests/valid_nested.json b/lynq/S300/ap/app/apparms/json-c/tests/valid_nested.json
new file mode 100755
index 0000000..3e1a0cf
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/tests/valid_nested.json
@@ -0,0 +1 @@
+{"foo":123, "obj2": { "obj3": { "obj4": { "foo": 999 } } } }
diff --git a/lynq/S300/ap/app/apparms/json-c/vasprintf_compat.h b/lynq/S300/ap/app/apparms/json-c/vasprintf_compat.h
new file mode 100755
index 0000000..59b2e96
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/json-c/vasprintf_compat.h
@@ -0,0 +1,67 @@
+#ifndef __vasprintf_compat_h
+#define __vasprintf_compat_h
+
+/**
+ * @file
+ * @brief Do not use, json-c internal, may be changed or removed at any time.
+ */
+
+#include "snprintf_compat.h"
+
+#ifndef WIN32
+#include <stdarg.h>
+#endif /* !defined(WIN32) */
+#include <stdint.h>
+#include <stdlib.h>
+
+#if !defined(HAVE_VASPRINTF)
+/* CAW: compliant version of vasprintf */
+static int vasprintf(char **buf, const char *fmt, va_list ap)
+{
+#ifndef WIN32
+	static char _T_emptybuffer = '\0';
+	va_list ap2;
+#endif /* !defined(WIN32) */
+	int chars;
+	char *b;
+
+	if (!buf)
+	{
+		return -1;
+	}
+
+#ifdef WIN32
+	chars = _vscprintf(fmt, ap);
+#else  /* !defined(WIN32) */
+	/* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
+	 * our buffer like on some 64bit sun systems... but hey, it's time to move on
+	 */
+	va_copy(ap2, ap);
+	chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap2);
+	va_end(ap2);
+#endif /* defined(WIN32) */
+	if (chars < 0 || (size_t)chars + 1 > SIZE_MAX / sizeof(char))
+	{
+		return -1;
+	}
+
+	b = (char *)malloc(sizeof(char) * ((size_t)chars + 1));
+	if (!b)
+	{
+		return -1;
+	}
+
+	if ((chars = vsprintf(b, fmt, ap)) < 0)
+	{
+		free(b);
+	}
+	else
+	{
+		*buf = b;
+	}
+
+	return chars;
+}
+#endif /* !HAVE_VASPRINTF */
+
+#endif /* __vasprintf_compat_h */
diff --git a/lynq/S300/ap/app/apparms/list/Makefile b/lynq/S300/ap/app/apparms/list/Makefile
new file mode 100755
index 0000000..48e7de9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/list/Makefile
@@ -0,0 +1,14 @@
+
+LOG_STATIC_LIB = libapparmslist.a
+LOG_LIB_OBJS = apparms_list.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g
+
+all: $(LOG_STATIC_LIB)
+
+$(LOG_STATIC_LIB): $(LOG_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(LOG_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/list/apparms_list.c b/lynq/S300/ap/app/apparms/list/apparms_list.c
new file mode 100755
index 0000000..e7e8d00
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/list/apparms_list.c
@@ -0,0 +1,247 @@
+
+#include "apparms_list.h"
+
+int arms_list_init_msg_event(PMSGMTXSEM pMtxSem)
+{
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+	
+	pthread_mutex_init(&pMtxSem->defaultsignalmutex, NULL);		
+	INIT_LIST_HEAD(&pMtxSem->defaultsignallist);	
+	sem_init(&pMtxSem->defmuxsem, 0, 0);
+	pMtxSem->defmsgcnt = 0;
+
+	return 0;
+}
+
+int arms_list_get_msg_cnt(PMSGMTXSEM pMtxSem)
+{
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+	
+	return pMtxSem->defmsgcnt;
+}
+
+int arms_list_destroy_msg_event(PMSGMTXSEM pMtxSem)
+{
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+	
+	pthread_mutex_destroy(&pMtxSem->defaultsignalmutex);
+	sem_destroy(&pMtxSem->defmuxsem);
+
+	return 0;
+}
+
+int arms_list_add_msg_event(PMSGMTXSEM pMtxSem,int nSig, char* pData, int nDataSize, int nFD)
+{
+	PMSGSIGDATA pTmpSig = NULL;
+	
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+
+	if (nSig == ARMS_INVALID_SIGNAL)
+		return ARMS_LIST_INVALID_SIGNAL_ERROR;
+
+	//malloc new signal
+	pTmpSig = malloc(sizeof(MSGSIGDATA));
+	if (pTmpSig == NULL)
+		return ARMS_LIST_POINT_NULL_ERROR;
+	memset(pTmpSig,0,sizeof(MSGSIGDATA));
+
+	//init all the parameters
+	INIT_LIST_HEAD(&pTmpSig->list);
+	pTmpSig->sig = nSig;
+	pTmpSig->nFd = nFD;
+	pTmpSig->data_size = 0;
+	pTmpSig->user_data = NULL;
+
+	//contain the data
+	if ((pData != NULL) && (nDataSize > 0))
+	{
+		pTmpSig->user_data = malloc(nDataSize);
+		if (pTmpSig->user_data == NULL)
+		{
+			free(pTmpSig);
+			return ARMS_LIST_POINT_NULL_ERROR;
+		}
+		
+		pTmpSig->data_size = nDataSize;
+		memcpy(pTmpSig->user_data, pData, nDataSize);
+	}
+
+
+	//enter mutex and add to tail
+	pthread_mutex_lock(&pMtxSem->defaultsignalmutex);
+	list_add_tail(&pTmpSig->list, &pMtxSem->defaultsignallist);
+	pMtxSem->defmsgcnt++;
+	pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+
+	arms_list_post_msg_event(pMtxSem);
+	
+	return 0;
+	
+}
+
+int arms_list_get_msg_event(PMSGMTXSEM pMtxSem, int* pSign, char* pRecv, int* pRecvSize, char **pNewMaclloc)
+{	
+	PMSGSIGDATA tmp_cmsignal = NULL, tmpsingal2 = NULL;
+
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+
+	pthread_mutex_lock(&pMtxSem->defaultsignalmutex);
+	if (!list_empty(&pMtxSem->defaultsignallist))
+	{
+		//Only get one signal every time
+		list_for_each_entry_safe(tmp_cmsignal, tmpsingal2, &pMtxSem->defaultsignallist, list)
+		{	
+			*pSign = tmp_cmsignal->sig;
+			if ((tmp_cmsignal->data_size > 0) && (tmp_cmsignal->user_data != NULL))
+			{
+				//recv buffer is not enough big, use new buffer
+				if (tmp_cmsignal->data_size > *pRecvSize)
+				{
+					*pNewMaclloc = malloc(tmp_cmsignal->data_size);
+					if (*pNewMaclloc == NULL)
+					{					
+						pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+						return ARMS_LIST_POINT_NULL_ERROR;
+					}
+					memcpy((*pNewMaclloc), tmp_cmsignal->user_data, tmp_cmsignal->data_size);
+					//(*pNewMaclloc)[tmp_cmsignal->data_size] = '\0';
+				}
+				else
+				{
+					*pNewMaclloc = NULL;
+					memset(pRecv, 0, *pRecvSize);
+					memcpy(pRecv, tmp_cmsignal->user_data, tmp_cmsignal->data_size);
+					//pRecv[tmp_cmsignal->data_size] = '\0';
+				}				
+				*pRecvSize = tmp_cmsignal->data_size;
+				
+				free(tmp_cmsignal->user_data);
+			}
+			else
+			{
+				*pRecvSize = 0;
+			}
+			
+			list_del_init(&tmp_cmsignal->list);
+			pMtxSem->defmsgcnt--;
+			free(tmp_cmsignal);
+			
+			pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+			return 0;
+		}
+	}	
+	pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+
+	return ARMS_LIST_MSG_EMPTY_ERROR;
+}
+
+int arms_list_get_msg_event_with_fd(PMSGMTXSEM pMtxSem, int* pSign, char* pRecv, int* pRecvSize, char **pNewMaclloc, int* pFD)
+{	
+	PMSGSIGDATA tmp_cmsignal = NULL, tmpsingal2 = NULL;
+
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+	
+	pthread_mutex_lock(&pMtxSem->defaultsignalmutex);
+	if (!list_empty(&pMtxSem->defaultsignallist))
+	{
+		//Only get one signal every time
+		list_for_each_entry_safe(tmp_cmsignal, tmpsingal2, &pMtxSem->defaultsignallist, list)
+		{	
+			*pSign = tmp_cmsignal->sig;
+			*pFD = tmp_cmsignal->nFd;
+			if ((tmp_cmsignal->data_size > 0) && (tmp_cmsignal->user_data != NULL))
+			{
+				//recv buffer is not enough big, use new buffer
+				if (tmp_cmsignal->data_size > *pRecvSize)
+				{
+					*pNewMaclloc = malloc(tmp_cmsignal->data_size);
+					if (*pNewMaclloc == NULL)
+					{					
+						pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+						return ARMS_LIST_POINT_NULL_ERROR;
+					}
+					memcpy((*pNewMaclloc), tmp_cmsignal->user_data, tmp_cmsignal->data_size);
+					//(*pNewMaclloc)[tmp_cmsignal->data_size] = '\0';
+				}
+				else
+				{
+					*pNewMaclloc = NULL;
+					memset(pRecv, 0, *pRecvSize);
+					memcpy(pRecv, tmp_cmsignal->user_data, tmp_cmsignal->data_size);
+					//pRecv[tmp_cmsignal->data_size] = '\0';
+				}				
+				*pRecvSize = tmp_cmsignal->data_size;
+				
+				free(tmp_cmsignal->user_data);
+			}
+			else
+			{
+				*pRecvSize = 0;
+			}
+			
+			list_del_init(&tmp_cmsignal->list);
+			pMtxSem->defmsgcnt--;
+			free(tmp_cmsignal);
+			
+			pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+			return 0;
+		}
+	}	
+	pthread_mutex_unlock(&pMtxSem->defaultsignalmutex);
+
+	return ARMS_LIST_MSG_EMPTY_ERROR;
+}
+
+int arms_list_post_msg_event(PMSGMTXSEM pMtxSem)
+{
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+	
+	sem_post(&pMtxSem->defmuxsem);
+	return 0;
+}
+
+int arms_list_wait_msg_event(PMSGMTXSEM pMtxSem,int nWatiSec)
+{
+	int i, nSegRet, nErrNum;
+	struct timespec segts;
+
+	if (pMtxSem == NULL)
+		return ARMS_LIST_MAIN_ENTRY_ERROR;
+
+	if (nWatiSec <= 0)
+		nWatiSec = 1;
+
+	for (i = 0; i < 3; i++)
+	{
+		clock_gettime(CLOCK_REALTIME, &segts);
+		segts.tv_sec += nWatiSec;
+		nSegRet = sem_timedwait(&pMtxSem->defmuxsem, &segts);
+		nErrNum = errno;
+		if (nSegRet == -1)
+		{
+			if (nErrNum == EINTR)
+			{
+				i = 0;
+				continue;
+			}
+
+			if (nErrNum == ETIMEDOUT)
+				break;
+
+			return nErrNum;
+		}
+		
+		break;
+	}
+
+	return 0;
+}
+
+
diff --git a/lynq/S300/ap/app/apparms/list/apparms_list.h b/lynq/S300/ap/app/apparms/list/apparms_list.h
new file mode 100755
index 0000000..f245dbc
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/list/apparms_list.h
@@ -0,0 +1,520 @@
+#ifndef _APPARMS_COMM_LIST_H
+#define _APPARMS_COMM_LIST_H
+
+#if defined(WIN32) && !defined(__cplusplus)
+#define inline __inline
+#endif
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <errno.h>
+
+#define ARMS_INVALID_SIGNAL (-1)
+#define ARMS_LIST_MAIN_ENTRY_ERROR (-1000)
+#define ARMS_LIST_POINT_NULL_ERROR (-1001)
+#define ARMS_LIST_INVALID_SIGNAL_ERROR (-1002)
+#define ARMS_LIST_MSG_EMPTY_ERROR (-1003)
+/*
+ * These are non-NULL pointers that will result in page faults
+ * under normal circumstances, used to verify that nobody uses
+ * non-initialized list entries.
+ */
+#define LIST_POISON1  ((void *) 0x00100100)
+#define LIST_POISON2  ((void *) 0x00200200)
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+	struct list_head name = LIST_HEAD_INIT(name)
+
+#define INIT_LIST_HEAD(ptr) do { \
+	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+			      struct list_head *prev,
+			      struct list_head *next)
+{
+	next->prev = new;
+	new->next = next;
+	new->prev = prev;
+	prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+	__list_add(new, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+	__list_add(new, head->prev, head);
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add_rcu(struct list_head * new,
+		struct list_head * prev, struct list_head * next)
+{
+	new->next = next;
+	new->prev = prev;
+	next->prev = new;
+	prev->next = new;
+}
+
+/**
+ * list_add_rcu - add a new entry to rcu-protected list
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ *
+ * The caller must take whatever precautions are necessary
+ * (such as holding appropriate locks) to avoid racing
+ * with another list-mutation primitive, such as list_add_rcu()
+ * or list_del_rcu(), running on this same list.
+ * However, it is perfectly legal to run concurrently with
+ * the _rcu list-traversal primitives, such as
+ * list_for_each_entry_rcu().
+ */
+static inline void list_add_rcu(struct list_head *new, struct list_head *head)
+{
+	__list_add_rcu(new, head, head->next);
+}
+
+/**
+ * list_add_tail_rcu - add a new entry to rcu-protected list
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ *
+ * The caller must take whatever precautions are necessary
+ * (such as holding appropriate locks) to avoid racing
+ * with another list-mutation primitive, such as list_add_tail_rcu()
+ * or list_del_rcu(), running on this same list.
+ * However, it is perfectly legal to run concurrently with
+ * the _rcu list-traversal primitives, such as
+ * list_for_each_entry_rcu().
+ */
+static inline void list_add_tail_rcu(struct list_head *new,
+					struct list_head *head)
+{
+	__list_add_rcu(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+	next->prev = prev;
+	prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	entry->next = LIST_POISON1;
+	entry->prev = LIST_POISON2;
+}
+
+/**
+ * list_del_rcu - deletes entry from list without re-initialization
+ * @entry: the element to delete from the list.
+ *
+ * Note: list_empty on entry does not return true after this,
+ * the entry is in an undefined state. It is useful for RCU based
+ * lockfree traversal.
+ *
+ * In particular, it means that we can not poison the forward
+ * pointers that may still be used for walking the list.
+ *
+ * The caller must take whatever precautions are necessary
+ * (such as holding appropriate locks) to avoid racing
+ * with another list-mutation primitive, such as list_del_rcu()
+ * or list_add_rcu(), running on this same list.
+ * However, it is perfectly legal to run concurrently with
+ * the _rcu list-traversal primitives, such as
+ * list_for_each_entry_rcu().
+ *
+ * Note that the caller is not permitted to immediately free
+ * the newly deleted entry.  Instead, either synchronize_kernel()
+ * or call_rcu() must be used to defer freeing until an RCU
+ * grace period has elapsed.
+ */
+static inline void list_del_rcu(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	entry->prev = LIST_POISON2;
+}
+
+/*
+ * list_replace_rcu - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * The old entry will be replaced with the new entry atomically.
+ */
+static inline void list_replace_rcu(struct list_head *old, struct list_head *new){
+	new->next = old->next;
+	new->prev = old->prev;
+	new->next->prev = new;
+	new->prev->next = new;
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+        __list_del(list->prev, list->next);
+        list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+				  struct list_head *head)
+{
+        __list_del(list->prev, list->next);
+        list_add_tail(list, head);
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+	return head->next == head;
+}
+
+/**
+ * list_empty_careful - tests whether a list is
+ * empty _and_ checks that no other CPU might be
+ * in the process of still modifying either member
+ *
+ * NOTE: using list_empty_careful() without synchronization
+ * can only be safe if the only activity that can happen
+ * to the list entry is list_del_init(). Eg. it cannot be used
+ * if another CPU could re-list_add() it.
+ *
+ * @head: the list to test.
+ */
+static inline int list_empty_careful(const struct list_head *head)
+{
+	struct list_head *next = head->next;
+	return (next == head) && (next == head->prev);
+}
+
+static inline void __list_splice(struct list_head *list,
+				 struct list_head *head)
+{
+	struct list_head *first = list->next;
+	struct list_head *last = list->prev;
+	struct list_head *at = head->next;
+
+	first->prev = head;
+	head->next = first;
+
+	last->next = at;
+	at->prev = last;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+	if (!list_empty(list))
+		__list_splice(list, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_init(struct list_head *list,
+				    struct list_head *head)
+{
+	if (!list_empty(list)) {
+		__list_splice(list, head);
+		INIT_LIST_HEAD(list);
+	}
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:	the &struct list_head pointer.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+   ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+/**
+ * list_for_each	-	iterate over a list
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ */
+#define list_for_each(pos, head) \
+	for (pos = (head)->next; pos != (head); \
+        	pos = pos->next)
+
+/**
+ * __list_for_each	-	iterate over a list
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+	for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev	-	iterate over a list backwards
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+	for (pos = (head)->prev; pos != (head); \
+        	pos = pos->prev)
+
+/**
+ * list_for_each_safe	-	iterate over a list safe against removal of list entry
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @n:		another &struct list_head to use as temporary storage
+ * @head:	the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+	for (pos = (head)->next, n = pos->next; pos != (head); \
+		pos = n, n = pos->next)
+
+/**
+ * list_for_each_entry	-	iterate over list of given type
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member)				\
+	for (pos = list_entry((head)->next, typeof(*pos), member);	\
+	     &pos->member != (head); 	\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member)			\
+	for (pos = list_entry((head)->prev, typeof(*pos), member);	\
+	     &pos->member != (head); 	\
+	     pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_prepare_entry - prepare a pos entry for use as a start point in
+ *			list_for_each_entry_continue
+ * @pos:	the type * to use as a start point
+ * @head:	the head of the list
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_prepare_entry(pos, head, member) \
+	((pos) ? : list_entry(head, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue -	iterate over list of given type
+ *			continuing after existing point
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_continue(pos, head, member) 		\
+	for (pos = list_entry(pos->member.next, typeof(*pos), member);	\
+	     &pos->member != (head);	\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:	the type * to use as a loop counter.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member),	\
+		n = list_entry(pos->member.next, typeof(*pos), member);	\
+	     &pos->member != (head); 					\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_rcu	-	iterate over an rcu-protected list
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as list_add_rcu()
+ * as long as the traversal is guarded by rcu_read_lock().
+ */
+#define list_for_each_rcu(pos, head) \
+	for (pos = (head)->next; pos != (head); \
+        	pos = rcu_dereference(pos->next))
+
+#define __list_for_each_rcu(pos, head) \
+	for (pos = (head)->next; pos != (head); \
+        	pos = rcu_dereference(pos->next))
+
+/**
+ * list_for_each_safe_rcu	-	iterate over an rcu-protected list safe
+ *					against removal of list entry
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @n:		another &struct list_head to use as temporary storage
+ * @head:	the head for your list.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as list_add_rcu()
+ * as long as the traversal is guarded by rcu_read_lock().
+ */
+#define list_for_each_safe_rcu(pos, n, head) \
+	for (pos = (head)->next, n = pos->next; pos != (head); \
+		pos = rcu_dereference(n), n = pos->next)
+
+/**
+ * list_for_each_entry_rcu	-	iterate over rcu list of given type
+ * @pos:	the type * to use as a loop counter.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as list_add_rcu()
+ * as long as the traversal is guarded by rcu_read_lock().
+ */
+#define list_for_each_entry_rcu(pos, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member);	\
+	     &pos->member != (head); 	\
+	     pos = rcu_dereference(list_entry(pos->member.next, 	\
+					typeof(*pos), member)))
+
+
+/**
+ * list_for_each_continue_rcu	-	iterate over an rcu-protected list
+ *			continuing after existing point.
+ * @pos:	the &struct list_head to use as a loop counter.
+ * @head:	the head for your list.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as list_add_rcu()
+ * as long as the traversal is guarded by rcu_read_lock().
+ */
+#define list_for_each_continue_rcu(pos, head) \
+	for ((pos) = (pos)->next; (pos) != (head); \
+        	(pos) = rcu_dereference((pos)->next))
+
+typedef struct tagMSGMTXSEM
+{
+	pthread_mutex_t defaultsignalmutex;
+	struct list_head defaultsignallist;
+	sem_t defmuxsem;
+	int defmsgcnt;
+}MSGMTXSEM, *PMSGMTXSEM;
+
+typedef struct tagMSGSIGDATA
+{
+	int sig;
+	int nFd;
+	char *user_data;
+	int data_size;
+	struct list_head list;
+}MSGSIGDATA, *PMSGSIGDATA;
+
+int arms_list_init_msg_event(PMSGMTXSEM pDMMtxSem);
+int arms_list_get_msg_cnt(PMSGMTXSEM pMtxSem);
+int arms_list_destroy_msg_event(PMSGMTXSEM pDMMtxSem);
+int arms_list_add_msg_event(PMSGMTXSEM pDMMtxSem, int nSig, char* pData, int nDataSize, int nFD);
+int arms_list_get_msg_event_with_fd(PMSGMTXSEM pMtxSem, int* pSign, char* pRecv, int* pRecvSize, char **pNewMaclloc, int* pFD);
+int arms_list_get_msg_event(PMSGMTXSEM pDMMtxSem, int* pSign, char* pRecv, int* pRecvSize, char **pNewMaclloc);
+int arms_list_post_msg_event(PMSGMTXSEM pDMMtxSem);
+int arms_list_wait_msg_event(PMSGMTXSEM pDMMtxSem, int nWatiSec);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/log/Makefile b/lynq/S300/ap/app/apparms/log/Makefile
new file mode 100755
index 0000000..6fab6be
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/log/Makefile
@@ -0,0 +1,14 @@
+
+LOG_STATIC_LIB = libapparmslog.a
+LOG_LIB_OBJS = apparms_log.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g
+
+all: $(LOG_STATIC_LIB)
+
+$(LOG_STATIC_LIB): $(LOG_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(LOG_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/log/apparms_log.c b/lynq/S300/ap/app/apparms/log/apparms_log.c
new file mode 100755
index 0000000..fe459f6
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/log/apparms_log.c
@@ -0,0 +1,168 @@
+
+#include "apparms_log.h"
+
+static ARMSLOGIO g_stArmsLog =
+{ 
+	.arms_log_fd = -1,
+	.arms_log_rotate_size = ARMS_LOG_ROTATE_SIZE,
+	.arms_log_level = ARMS_LOG_LEVEL_INFO, 
+	.arms_log_mode = ARMS_LOG_MODE_STDOUT,
+	.arms_log_path = {0}
+};
+
+PARMSLOGIO arms_log_get_io_pointer(void)
+{
+	return &g_stArmsLog;
+}
+
+static int arms_log_open_file(char* pLogPath)
+{
+	if ((pLogPath == NULL) || (strlen(pLogPath) <= 0))
+		return -1;
+
+	return open(pLogPath, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
+}
+
+static void arms_log_close_file(int *pFd)
+{
+	if (pFd == NULL)
+		return;
+
+	if (*pFd != -1)
+	{
+		close(*pFd);	
+		*pFd = -1;
+	}
+}
+
+static int arms_log_rotate(void)
+{
+	int i;
+	struct stat stbuf;
+	char oldname[ARMS_LOG_PATH_SIZE + 4];
+	char newname[ARMS_LOG_PATH_SIZE + 4];
+	PARMSLOGIO pAppLogIO = arms_log_get_io_pointer();
+
+	 if (pAppLogIO->arms_log_fd < 0)
+	 	return -1;
+
+	if (fstat(pAppLogIO->arms_log_fd, &stbuf) < 0)
+		return -2;
+
+	if (stbuf.st_size >= pAppLogIO->arms_log_rotate_size)
+	{
+		arms_log_close();
+
+		for (i = (ARMS_LOG_ROTATE_NUM - 1); i > 0; i--) 
+		{
+			sprintf(oldname, "%s.%d", pAppLogIO->arms_log_path, i - 1);
+			sprintf(newname, "%s.%d", pAppLogIO->arms_log_path, i);
+			rename(oldname, newname);
+		}
+
+		sprintf(newname, "%s.%d", pAppLogIO->arms_log_path, 0);
+		rename(pAppLogIO->arms_log_path, newname);
+
+		arms_log_open();
+	}
+
+	return 0;
+}
+
+void arms_log_set_level(ARMS_LOG_LEVEL nLvl)
+{
+	PARMSLOGIO pAppLogIO = arms_log_get_io_pointer();
+
+	if(nLvl >= ARMS_LOG_LEVEL_ERROR && nLvl <= ARMS_LOG_LEVEL_ALL)
+		pAppLogIO->arms_log_level = nLvl;
+}
+
+int arms_log_open(void)
+{
+	PARMSLOGIO pLogIO = arms_log_get_io_pointer();
+
+	if (pLogIO->arms_log_mode == ARMS_LOG_MODE_FILE)
+	{
+		if (strlen(pLogIO->arms_log_path) <= 0)
+		{
+			strcpy(pLogIO->arms_log_path, ARMS_LOG_DEF_PATH);
+		}
+		
+		pLogIO->arms_log_fd = arms_log_open_file(pLogIO->arms_log_path);
+		return pLogIO->arms_log_fd;
+	}
+	
+	return 0;
+}
+
+void arms_log_close(void)
+{
+	PARMSLOGIO pAppLogIO = arms_log_get_io_pointer();
+
+	if (pAppLogIO->arms_log_mode == ARMS_LOG_MODE_FILE)
+	{
+		arms_log_close_file(&pAppLogIO->arms_log_fd);
+	}
+}
+
+void arms_log_printf(int nLevel, const char *format, ...)
+{
+	PARMSLOGIO pAppLogIO = arms_log_get_io_pointer();
+	if (nLevel <=  pAppLogIO->arms_log_level)
+	{		
+		va_list ap;
+		time_t timep;		
+		struct tm *p;
+		char curren_time[64] = {0};
+		
+		switch (pAppLogIO->arms_log_mode)
+		{
+			case ARMS_LOG_MODE_FILE:
+			{
+				char log_file_buf[ARMS_LOG_BUF_SIZE] = {0} ;	
+				char tmp_buf[ARMS_LOG_BUF_SIZE] = {0} ;
+				
+				time(&timep);
+				p=localtime(&timep);
+				if(p != NULL)
+				{			
+					sprintf(curren_time,"[%02d-%02d %02d:%02d:%02d] ", 
+							(1+p->tm_mon),p->tm_mday, p->tm_hour, 
+							p->tm_min, p->tm_sec);
+				}
+				va_start(ap, format);
+				vsnprintf ( tmp_buf, ARMS_LOG_BUF_SIZE-64, format, ap ); //MaxSize: sizeof(tmp_buf)-sizeof(curren_time)
+				va_end(ap);
+				strcpy(log_file_buf,curren_time);
+				strcat(log_file_buf,tmp_buf);
+
+				if(pAppLogIO->arms_log_fd != -1)
+				{
+					write(pAppLogIO->arms_log_fd, log_file_buf, strlen(log_file_buf));
+					arms_log_rotate();
+				}
+			}
+			break;
+				
+			case ARMS_LOG_MODE_STDOUT:
+			default:
+			{
+				time(&timep);
+				p = localtime(&timep);
+				if(p != NULL)
+				{
+					sprintf(curren_time,"[%02d-%02d %02d:%02d:%02d]", 
+							(1+p->tm_mon),p->tm_mday,p->tm_hour, 
+							p->tm_min, p->tm_sec);
+				}
+			
+				fprintf(stderr, "%s ",curren_time);
+				va_start(ap, format);
+				vfprintf(stderr, format, ap);
+				va_end(ap);
+			}
+			break;
+		}
+	}
+}
+
diff --git a/lynq/S300/ap/app/apparms/log/apparms_log.h b/lynq/S300/ap/app/apparms/log/apparms_log.h
new file mode 100755
index 0000000..71c3e6e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/log/apparms_log.h
@@ -0,0 +1,109 @@
+
+#ifndef _APPARMS_LOG
+#define _APPARMS_LOG 1
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+//#include <syslog.h> 
+#include <termios.h> 
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sys/poll.h> 
+#include <stdlib.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <semaphore.h>
+#include <errno.h>
+
+#define ARMS_LOG 1
+#define ARMS_LOG_BUF_SIZE (1024*2)
+#define ARMS_LOG_DEF_PATH "/tmp/apparms.log"
+#define ARMS_LOG_PATH_SIZE (128)
+#define ARMS_LOG_ROTATE_NUM (2)
+#define ARMS_LOG_ROTATE_SIZE (200*1024)
+
+typedef enum _ARMS_LOG_LEVEL_
+{
+	ARMS_LOG_LEVEL_ERROR,
+	ARMS_LOG_LEVEL_WARN,
+	ARMS_LOG_LEVEL_INFO,
+	ARMS_LOG_LEVEL_DEBUG,
+	ARMS_LOG_LEVEL_ALL	
+}ARMS_LOG_LEVEL;
+
+typedef enum _ARMS_LOG_MODE_
+{
+	ARMS_LOG_MODE_STDOUT,	
+	ARMS_LOG_MODE_FILE
+}ARMS_LOG_MODE;
+
+typedef struct tagARMSLogIO
+{
+	int arms_log_fd;
+	unsigned int arms_log_rotate_size;
+	ARMS_LOG_LEVEL arms_log_level;
+	ARMS_LOG_MODE arms_log_mode;
+	char arms_log_path[ARMS_LOG_PATH_SIZE];
+} ARMSLOGIO, *PARMSLOGIO;
+
+PARMSLOGIO arms_log_get_io_pointer(void);
+void arms_log_set_level(ARMS_LOG_LEVEL nLvl);
+void arms_log_parse_cmdargs(int argc, char *argv[]);
+int arms_log_open(void);
+void arms_log_close(void);
+void arms_log_printf(int nLevel, const char *format, ...);
+
+#ifndef ARMS_LOG
+#define ARMS_LOG_ERROR(fmt, args...)
+#define ARMS_LOG_INFO(fmt, args...)
+#define ARMS_LOG_DEBUG(fmt, args...)
+#define ARMS_LOG_FUNC_ENTRY
+#define ARMS_LOG_FUNC_EXIT
+#define ARMS_LOG_FUNC_EXIT_RC(x) { return x; }
+#else
+#define ARMS_LOG_ERROR(fmt, args...) arms_log_printf(ARMS_LOG_LEVEL_ERROR,fmt,##args)
+#define ARMS_LOG_INFO(fmt, args...)  arms_log_printf(ARMS_LOG_LEVEL_INFO,fmt,##args)
+#define ARMS_LOG_DEBUG(fmt, args...) arms_log_printf(ARMS_LOG_LEVEL_DEBUG,fmt,##args)
+#define ARMS_LOG_FUNC_ENTRY    \
+	{\
+	arms_log_printf(ARMS_LOG_LEVEL_ALL, "FUNC_ENTRY:   %s L#%d \n", __func__, __LINE__);  \
+	}
+
+#define ARMS_LOG_FUNC_EXIT    \
+	{\
+	arms_log_printf(ARMS_LOG_LEVEL_ALL, "FUNC_EXIT:   %s L#%d \n", __func__, __LINE__);  \
+	}
+
+#define ARMS_LOG_FUNC_EXIT_RC(x)    \
+	{\
+	arms_log_printf(ARMS_LOG_LEVEL_ALL, "FUNC_EXIT:   %s L#%d Return Code : %d \n", __func__, __LINE__, x);  \
+	return x; \
+	}
+
+#endif
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqnet/Makefile b/lynq/S300/ap/app/apparms/mqnet/Makefile
new file mode 100755
index 0000000..f07ad60
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/Makefile
@@ -0,0 +1,31 @@
+
+APPARMS_DEFS ?=
+MQNET_STATIC_LIB = libapparmsmqnet.a
+
+APPARMS_MQNET_DIR = ./
+APPARMS_MQNET_SRC_FILES += $(shell find $(APPARMS_MQNET_DIR) -name '*.c')
+
+MQNET_LIB_OBJS = $(APPARMS_MQNET_SRC_FILES:.c=.o)
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g -I../ -I../log
+
+# TCP option
+#ifeq ($(SUPPORT_TCP),TRUE)
+CFLAGS += -I../sock
+#endif
+
+# TLS option
+ifeq ($(SUPPORT_TLS),TRUE)
+CFLAGS += -I../mbedTLS/include
+endif
+
+CFLAGS += $(APPARMS_DEFS)
+
+all: $(MQNET_STATIC_LIB)
+
+$(MQNET_STATIC_LIB): $(MQNET_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(MQNET_STATIC_LIB) $(MQNET_LIB_OBJS) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_error.h b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_error.h
new file mode 100755
index 0000000..3fd730d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_error.h
@@ -0,0 +1,129 @@
+#ifndef _APPARMS_MQTT_API_ERROR_
+#define _APPARMS_MQTT_API_ERROR_
+
+#define ARMS_MQTT_API_UNUSED(x) (void)(x)
+
+typedef enum 
+{
+	/** Returned when the Network physical layer is connected */
+			NETWORK_PHYSICAL_LAYER_CONNECTED = 6,
+	/** Returned when the Network is manually disconnected */
+			NETWORK_MANUALLY_DISCONNECTED = 5,
+	/** Returned when the Network is disconnected and the reconnect attempt is in progress */
+			NETWORK_ATTEMPTING_RECONNECT = 4,
+	/** Return value of yield function to indicate auto-reconnect was successful */
+			NETWORK_RECONNECTED = 3,
+	/** Returned when a read attempt is made on the TLS buffer and it is empty */
+			MQTT_NOTHING_TO_READ = 2,
+	/** Returned when a connection request is successful and packet response is connection accepted */
+			MQTT_CONNACK_CONNECTION_ACCEPTED = 1,
+	/** Success return value - no error occurred */
+			SUCCESS = 0,
+	/** A generic error. Not enough information for a specific error code */
+			FAILURE = -1,
+	/** A required parameter was passed as null */
+			NULL_VALUE_ERROR = -2,
+	/** The TCP socket could not be established */
+			TCP_CONNECTION_ERROR = -3,
+	/** The TLS handshake failed */
+			SSL_CONNECTION_ERROR = -4,
+	/** Error associated with setting up the parameters of a Socket */
+			TCP_SETUP_ERROR = -5,
+	/** A timeout occurred while waiting for the TLS handshake to complete. */
+			NETWORK_SSL_CONNECT_TIMEOUT_ERROR = -6,
+	/** A Generic write error based on the platform used */
+			NETWORK_SSL_WRITE_ERROR = -7,
+	/** SSL initialization error at the TLS layer */
+			NETWORK_SSL_INIT_ERROR = -8,
+	/** An error occurred when loading the certificates.  The certificates could not be located or are incorrectly formatted. */
+			NETWORK_SSL_CERT_ERROR = -9,
+	/** SSL Write times out */
+			NETWORK_SSL_WRITE_TIMEOUT_ERROR = -10,
+	/** SSL Read times out */
+			NETWORK_SSL_READ_TIMEOUT_ERROR = -11,
+	/** A Generic error based on the platform used */
+			NETWORK_SSL_READ_ERROR = -12,
+	/** Returned when the Network is disconnected and reconnect is either disabled or physical layer is disconnected */
+			NETWORK_DISCONNECTED_ERROR = -13,
+	/** Returned when the Network is disconnected and the reconnect attempt has timed out */
+			NETWORK_RECONNECT_TIMED_OUT_ERROR = -14,
+	/** Returned when the Network is already connected and a connection attempt is made */
+			NETWORK_ALREADY_CONNECTED_ERROR = -15,
+	/** Network layer Error Codes */
+	/** Network layer Random number generator seeding failed */
+			NETWORK_MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED = -16,
+	/** A generic error code for Network layer errors */
+			NETWORK_SSL_UNKNOWN_ERROR = -17,
+	/** Returned when the physical layer is disconnected */
+			NETWORK_PHYSICAL_LAYER_DISCONNECTED = -18,
+	/** Returned when the root certificate is invalid */
+			NETWORK_X509_ROOT_CRT_PARSE_ERROR = -19,
+	/** Returned when the device certificate is invalid */
+			NETWORK_X509_DEVICE_CRT_PARSE_ERROR = -20,
+	/** Returned when the private key failed to parse */
+			NETWORK_PK_PRIVATE_KEY_PARSE_ERROR = -21,
+	/** Returned when the network layer failed to open a socket */
+			NETWORK_ERR_NET_SOCKET_FAILED = -22,
+	/** Returned when the server is unknown */
+			NETWORK_ERR_NET_UNKNOWN_HOST = -23,
+	/** Returned when connect request failed */
+			NETWORK_ERR_NET_CONNECT_FAILED = -24,
+	/** Returned when there is nothing to read in the TLS read buffer */
+			NETWORK_SSL_NOTHING_TO_READ = -25,
+	/** A connection could not be established. */
+			MQTT_CONNECTION_ERROR = -26,
+	/** A timeout occurred while waiting for the TLS handshake to complete */
+			MQTT_CONNECT_TIMEOUT_ERROR = -27,
+	/** A timeout occurred while waiting for the TLS request complete */
+			MQTT_REQUEST_TIMEOUT_ERROR = -28,
+	/** The current client state does not match the expected value */
+			MQTT_UNEXPECTED_CLIENT_STATE_ERROR = -29,
+	/** The client state is not idle when request is being made */
+			MQTT_CLIENT_NOT_IDLE_ERROR = -30,
+	/** The MQTT RX buffer received corrupt or unexpected message  */
+			MQTT_RX_MESSAGE_PACKET_TYPE_INVALID_ERROR = -31,
+	/** The MQTT RX buffer received a bigger message. The message will be dropped  */
+			MQTT_RX_BUFFER_TOO_SHORT_ERROR = -32,
+	/** The MQTT TX buffer is too short for the outgoing message. Request will fail  */
+			MQTT_TX_BUFFER_TOO_SHORT_ERROR = -33,
+	/** The client is subscribed to the maximum possible number of subscriptions  */
+			MQTT_MAX_SUBSCRIPTIONS_REACHED_ERROR = -34,
+	/** Failed to decode the remaining packet length on incoming packet */
+			MQTT_DECODE_REMAINING_LENGTH_ERROR = -35,
+	/** Connect request failed with the server returning an unknown error */
+			MQTT_CONNACK_UNKNOWN_ERROR = -36,
+	/** Connect request failed with the server returning an unacceptable protocol version error */
+			MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR = -37,
+	/** Connect request failed with the server returning an identifier rejected error */
+			MQTT_CONNACK_IDENTIFIER_REJECTED_ERROR = -38,
+	/** Connect request failed with the server returning an unavailable error */
+			MQTT_CONNACK_SERVER_UNAVAILABLE_ERROR = -39,
+	/** Connect request failed with the server returning a bad userdata error */
+			MQTT_CONNACK_BAD_USERDATA_ERROR = -40,
+	/** Connect request failed with the server failing to authenticate the request */
+			MQTT_CONNACK_NOT_AUTHORIZED_ERROR = -41,
+	/** An error occurred while parsing the JSON string.  Usually malformed JSON. */
+			JSON_PARSE_ERROR = -42,
+	/** Shadow: The response Ack table is currently full waiting for previously published updates */
+			SHADOW_WAIT_FOR_PUBLISH = -43,
+	/** Any time an snprintf writes more than size value, this error will be returned */
+			SHADOW_JSON_BUFFER_TRUNCATED = -44,
+	/** Any time an snprintf encounters an encoding error or not enough space in the given buffer */
+			SHADOW_JSON_ERROR = -45,
+	/** Mutex initialization failed */
+			MUTEX_INIT_ERROR = -46,
+	/** Mutex lock request failed */
+			MUTEX_LOCK_ERROR = -47,
+	/** Mutex unlock request failed */
+			MUTEX_UNLOCK_ERROR = -48,
+	/** Mutex destroy failed */
+			MUTEX_DESTROY_ERROR = -49,
+	/** Input argument exceeded the allowed maximum size */
+			MAX_SIZE_ERROR = -50,
+	/** Some limit has been exceeded, e.g. the maximum number of subscriptions has been reached */
+			LIMIT_EXCEEDED_ERROR = -51,
+	/** Invalid input topic type */
+			INVALID_TOPIC_TYPE_ERROR = -52
+} ARMS_MQTT_ERROR_T;
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.c b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.c
new file mode 100755
index 0000000..931032e
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.c
@@ -0,0 +1,646 @@
+#include "apparms_log.h"
+#include "apparms_mqtt_api_net.h"
+
+/* This is the value used for ssl read timeout */
+#define ARMS_MQTT_SSL_READ_TIMEOUT 3000
+#define ARMS_MQTT_TCP_READ_TIMEOUT 3000
+
+/* This defines the value of the debug buffer that gets allocated.
+ * The value can be altered based on memory constraints
+ */
+#ifdef ENABLE_ARMS_LOG_DEBUG
+#define MBEDTLS_DEBUG_BUFFER_SIZE 2048
+#endif
+
+static void arms_mqtt_api_tls_set_connect_params(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
+								 char *pDevicePrivateKeyLocation, char *pDestinationURL,
+								 uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) 
+{
+	pNetwork->tlsConnectParams.DestinationPort = destinationPort;
+	pNetwork->tlsConnectParams.pDestinationURL = pDestinationURL;
+	pNetwork->tlsConnectParams.pDeviceCertLocation = pDeviceCertLocation;
+	pNetwork->tlsConnectParams.pDevicePrivateKeyLocation = pDevicePrivateKeyLocation;
+	pNetwork->tlsConnectParams.pRootCALocation = pRootCALocation;
+	pNetwork->tlsConnectParams.timeout_ms = timeout_ms;
+	pNetwork->tlsConnectParams.ServerVerificationFlag = ServerVerificationFlag;
+}
+
+#ifdef ARMS_AUTH_X509
+static int arms_mqtt_api_tls_verify_cert(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags) 
+{
+	char buf[1024];
+	((void) data);
+
+	ARMS_LOG_DEBUG("\nVerify requested for (Depth %d):\n", depth);
+	mbedtls_x509_crt_info(buf, sizeof(buf) - 1, "", crt);
+	ARMS_LOG_DEBUG("%s", buf);
+
+	if((*flags) == 0) 
+	{
+		ARMS_LOG_DEBUG("  This certificate has no flags\n");
+	} 
+	else 
+	{
+		ARMS_LOG_DEBUG(buf, sizeof(buf), "  ! ", *flags);
+		ARMS_LOG_DEBUG("%s\n", buf);
+	}
+
+	return 0;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_is_connected(Network *pNetwork) 
+{
+	/* Use this to add implementation which can check for physical layer disconnect */
+	TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
+
+	if(tlsDataParams->server_fd.fd > 0)
+		return SUCCESS;
+	else
+		return FAILURE;
+}
+
+#ifdef SSL_DEBUG_LOG //For SSL Debug
+static void my_debug( void *ctx, int level,
+                      const char *file, int line,
+                      const char *str )
+{
+    ((void) level);
+
+	ARMS_LOG_DEBUG("%s(%d):%s",file, line, str );
+
+    fflush(  (FILE *) ctx  );
+}
+#endif
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_connect(Network *pNetwork, TLSConnectParams *params) 
+{
+	int ret = 0;
+	const char *pers = "arms_api_tls";
+	TLSDataParams *tlsDataParams = NULL;
+	char portBuffer[6];
+	char vrfy_buf[512];
+	const char *alpnProtocols[] = { "x-amzn-mqtt-ca", NULL };
+
+#ifdef ENABLE_ARMS_LOG_DEBUG
+	unsigned char buf[MBEDTLS_DEBUG_BUFFER_SIZE];
+#endif
+
+	if(NULL == pNetwork) 
+	{
+		return NULL_VALUE_ERROR;
+	}
+
+	if(NULL != params) 
+	{
+		arms_mqtt_api_tls_set_connect_params(pNetwork, params->pRootCALocation, params->pDeviceCertLocation,
+									params->pDevicePrivateKeyLocation, params->pDestinationURL,
+									params->DestinationPort, params->timeout_ms, params->ServerVerificationFlag);
+	}
+
+	tlsDataParams = &(pNetwork->tlsDataParams);
+
+	mbedtls_net_init(&(tlsDataParams->server_fd));
+	if(pNetwork->tlsMode)
+	{
+		mbedtls_ssl_init(&(tlsDataParams->ssl));
+		mbedtls_ssl_config_init(&(tlsDataParams->conf));
+		mbedtls_ctr_drbg_init(&(tlsDataParams->ctr_drbg));
+		mbedtls_x509_crt_init(&(tlsDataParams->cacert));
+		mbedtls_x509_crt_init(&(tlsDataParams->clicert));
+		mbedtls_pk_init(&(tlsDataParams->pkey));
+
+#ifdef SSL_DEBUG_LOG //For SSL Debug
+		mbedtls_debug_set_threshold( 5 );
+		mbedtls_ssl_conf_dbg( &(tlsDataParams->conf), my_debug, stdout );
+#endif
+
+		ARMS_LOG_DEBUG("\n  . Seeding the random number generator...");
+		mbedtls_entropy_init(&(tlsDataParams->entropy));
+		if((ret = mbedtls_ctr_drbg_seed(&(tlsDataParams->ctr_drbg), mbedtls_entropy_func, &(tlsDataParams->entropy),
+										(const unsigned char *) pers, strlen(pers))) != 0) 
+		{
+			ARMS_LOG_ERROR(" failed\n  ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret);
+			return NETWORK_MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
+		}
+
+		if(pNetwork->tlsConnectParams.pRootCALocation)
+		{
+			ARMS_LOG_DEBUG("  . Loading the CA root certificate ...");
+			ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->cacert), pNetwork->tlsConnectParams.pRootCALocation);
+			if(ret < 0) 
+			{
+				ARMS_LOG_ERROR(" failed\n  !  mbedtls_x509_crt_parse returned -0x%x while parsing root cert\n\n", -ret);
+				return NETWORK_X509_ROOT_CRT_PARSE_ERROR;
+			}
+			ARMS_LOG_DEBUG(" ok (%d skipped)\n", ret);
+		}
+
+		if(pNetwork->tlsConnectParams.pDeviceCertLocation)
+		{
+			ARMS_LOG_DEBUG("  . Loading the client cert...");
+			ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->clicert), pNetwork->tlsConnectParams.pDeviceCertLocation);
+			if(ret != 0) 
+			{
+				ARMS_LOG_ERROR(" failed\n  !  mbedtls_x509_crt_parse returned -0x%x while parsing device cert\n\n", -ret);
+				return NETWORK_X509_DEVICE_CRT_PARSE_ERROR;
+			}
+		}
+
+		if(pNetwork->tlsConnectParams.pDevicePrivateKeyLocation)
+		{
+			ARMS_LOG_DEBUG("  . Loading the client key...");
+			ret = mbedtls_pk_parse_keyfile(&(tlsDataParams->pkey), pNetwork->tlsConnectParams.pDevicePrivateKeyLocation, "");
+			if(ret != 0) 
+			{
+				ARMS_LOG_ERROR(" failed\n  !  mbedtls_pk_parse_key returned -0x%x while parsing private key\n\n", -ret);
+				ARMS_LOG_DEBUG(" path : %s ", pNetwork->tlsConnectParams.pDevicePrivateKeyLocation);
+				return NETWORK_PK_PRIVATE_KEY_PARSE_ERROR;
+			}
+			ARMS_LOG_DEBUG(" ok\n");
+		}
+	}
+	snprintf(portBuffer, 6, "%d", pNetwork->tlsConnectParams.DestinationPort);
+	ARMS_LOG_DEBUG("  . Connecting to %s/%s...", pNetwork->tlsConnectParams.pDestinationURL, portBuffer);
+	if((ret = mbedtls_net_connect(&(tlsDataParams->server_fd), pNetwork->tlsConnectParams.pDestinationURL,
+								  portBuffer, MBEDTLS_NET_PROTO_TCP)) != 0) 
+	{
+		ARMS_LOG_ERROR(" failed\n  ! mbedtls_net_connect returned -0x%x\n\n", -ret);
+		switch(ret) 
+		{
+			case MBEDTLS_ERR_NET_SOCKET_FAILED:
+				return NETWORK_ERR_NET_SOCKET_FAILED;
+				
+			case MBEDTLS_ERR_NET_UNKNOWN_HOST:
+				return NETWORK_ERR_NET_UNKNOWN_HOST;
+				
+			case MBEDTLS_ERR_NET_CONNECT_FAILED:
+			default:
+				return NETWORK_ERR_NET_CONNECT_FAILED;
+		};
+	}
+
+	ret = mbedtls_net_set_block(&(tlsDataParams->server_fd));
+	if(ret != 0) 
+	{
+		ARMS_LOG_ERROR(" failed\n  ! net_set_(non)block() returned -0x%x\n\n", -ret);
+		return SSL_CONNECTION_ERROR;
+	} 
+	ARMS_LOG_DEBUG(" ok\n");
+
+	if(pNetwork->tlsMode)
+	{
+		ARMS_LOG_DEBUG("  . Setting up the SSL/TLS structure...");
+		if((ret = mbedtls_ssl_config_defaults(&(tlsDataParams->conf), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM,
+											  MBEDTLS_SSL_PRESET_DEFAULT)) != 0) 
+		{
+			ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_config_defaults returned -0x%x\n\n", -ret);
+			return SSL_CONNECTION_ERROR;
+		}
+
+		mbedtls_ssl_conf_verify(&(tlsDataParams->conf), arms_mqtt_api_tls_verify_cert, NULL);
+		if(pNetwork->tlsConnectParams.ServerVerificationFlag == true) 
+		{
+			mbedtls_ssl_conf_authmode(&(tlsDataParams->conf), MBEDTLS_SSL_VERIFY_REQUIRED);
+		} 
+		else 
+		{
+			mbedtls_ssl_conf_authmode(&(tlsDataParams->conf), MBEDTLS_SSL_VERIFY_OPTIONAL);
+		}
+		mbedtls_ssl_conf_rng(&(tlsDataParams->conf), mbedtls_ctr_drbg_random, &(tlsDataParams->ctr_drbg));
+
+		mbedtls_ssl_conf_ca_chain(&(tlsDataParams->conf), &(tlsDataParams->cacert), NULL);
+		if((ret = mbedtls_ssl_conf_own_cert(&(tlsDataParams->conf), &(tlsDataParams->clicert), &(tlsDataParams->pkey))) !=
+		   0) 
+		{
+			ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret);
+			return SSL_CONNECTION_ERROR;
+		}
+
+		mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), pNetwork->tlsConnectParams.timeout_ms);
+
+		if(443 == pNetwork->tlsConnectParams.DestinationPort) 
+		{
+			if((ret = mbedtls_ssl_conf_alpn_protocols(&(tlsDataParams->conf), alpnProtocols)) != 0) 
+			{
+				ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_conf_alpn_protocols returned -0x%x\n\n", -ret);
+				return SSL_CONNECTION_ERROR;
+			}
+		}
+
+		/* Assign the resulting configuration to the SSL context. */
+		if((ret = mbedtls_ssl_setup(&(tlsDataParams->ssl), &(tlsDataParams->conf))) != 0) 
+		{
+			ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_setup returned -0x%x\n\n", -ret);
+			return SSL_CONNECTION_ERROR;
+		}
+		
+		if((ret = mbedtls_ssl_set_hostname(&(tlsDataParams->ssl), pNetwork->tlsConnectParams.pDestinationURL)) != 0) 
+		{
+			ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_set_hostname returned %d\n\n", ret);
+			return SSL_CONNECTION_ERROR;
+		}
+		ARMS_LOG_DEBUG("\n\nSSL state connect : %d ", tlsDataParams->ssl.state);
+		mbedtls_ssl_set_bio(&(tlsDataParams->ssl), &(tlsDataParams->server_fd), mbedtls_net_send, NULL,
+							mbedtls_net_recv_timeout);
+		ARMS_LOG_DEBUG(" ok\n");
+
+		ARMS_LOG_DEBUG("\n\nSSL state connect : %d ", tlsDataParams->ssl.state);
+		ARMS_LOG_DEBUG("  . Performing the SSL/TLS handshake...");
+		while((ret = mbedtls_ssl_handshake(&(tlsDataParams->ssl))) != 0) 
+		{
+			if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) 
+			{
+				ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_handshake returned -0x%x\n", -ret);
+				if(ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) 
+				{
+					ARMS_LOG_ERROR("    Unable to verify the server's certificate. "
+								  "Either it is invalid,\n"
+								  "    or you didn't set ca_file or ca_path "
+								  "to an appropriate value.\n"
+								  "    Alternatively, you may want to use "
+								  "auth_mode=optional for testing purposes.\n");
+				}
+				return SSL_CONNECTION_ERROR;
+			}
+		}
+
+		ARMS_LOG_DEBUG(" ok\n    [ Protocol is %s ]\n    [ Ciphersuite is %s ]\n", mbedtls_ssl_get_version(&(tlsDataParams->ssl)),
+			  mbedtls_ssl_get_ciphersuite(&(tlsDataParams->ssl)));
+		if((ret = mbedtls_ssl_get_record_expansion(&(tlsDataParams->ssl))) >= 0) 
+		{
+			ARMS_LOG_DEBUG("    [ Record expansion is %d ]\n", ret);
+		}
+		else 
+		{
+			ARMS_LOG_DEBUG("    [ Record expansion is unknown (compression) ]\n");
+		}
+
+		ARMS_LOG_DEBUG("  . Verifying peer X.509 certificate...");
+
+		if(pNetwork->tlsConnectParams.ServerVerificationFlag == true) 
+		{
+			if((tlsDataParams->flags = mbedtls_ssl_get_verify_result(&(tlsDataParams->ssl))) != 0) 
+			{
+				ARMS_LOG_ERROR(" failed\n");
+				mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), "  ! ", tlsDataParams->flags);
+				ARMS_LOG_ERROR("%s\n", vrfy_buf);
+				ret = SSL_CONNECTION_ERROR;
+			} 
+			else 
+			{
+				ARMS_LOG_DEBUG(" ok\n");
+				ret = SUCCESS;
+			}
+		} 
+		else 
+		{
+			ARMS_LOG_DEBUG(" Server Verification skipped\n");
+			ret = SUCCESS;
+		}
+
+	#ifdef ENABLE_ARMS_LOG_DEBUG
+		if (mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)) != NULL) 
+		{
+			ARMS_LOG_DEBUG("  . Peer certificate information    ...\n");
+			mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, "      ", mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)));
+			ARMS_LOG_DEBUG("%s\n", buf);
+		}
+	#endif
+
+		mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), ARMS_MQTT_SSL_READ_TIMEOUT);
+	}
+	return (ARMS_MQTT_ERROR_T) ret;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_write(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *written_len) 
+{
+	size_t written_so_far;
+	bool isErrorFlag = false;
+	int frags;
+	int ret = 0;
+	TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
+
+	for(written_so_far = 0, frags = 0;
+		written_so_far < len && !arms_mqtt_api_timer_expired(timer); written_so_far += ret, frags++) 
+	{
+		if(pNetwork->tlsMode)
+		{
+			while(!arms_mqtt_api_timer_expired(timer) &&
+				  (ret = mbedtls_ssl_write(&(tlsDataParams->ssl), pMsg + written_so_far, len - written_so_far)) <= 0) 
+			{
+				if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) 
+				{
+					ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_write returned -0x%x\n\n", -ret);
+					/* All other negative return values indicate connection needs to be reset.
+					* Will be caught in ping request so ignored here */
+					isErrorFlag = true;
+					break;
+				}
+			}
+		}
+		else
+		{
+			while(!arms_mqtt_api_timer_expired(timer) &&
+				  (ret = mbedtls_net_send(&(tlsDataParams->server_fd), pMsg + written_so_far, len - written_so_far)) <= 0) 
+			{
+				if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) 
+				{
+					ARMS_LOG_ERROR(" failed\n  ! mbedtls_ssl_write returned -0x%x\n\n", -ret);
+					/* All other negative return values indicate connection needs to be reset.
+					* Will be caught in ping request so ignored here */
+					isErrorFlag = true;
+					break;
+				}
+			}
+		}
+
+		if(isErrorFlag) 
+		{
+			break;
+		}
+	}
+
+	*written_len = written_so_far;
+
+	if(isErrorFlag) 
+	{
+		return NETWORK_SSL_WRITE_ERROR;
+	}
+	
+	if(arms_mqtt_api_timer_expired(timer) && written_so_far != len) 
+	{
+		return NETWORK_SSL_WRITE_TIMEOUT_ERROR;
+	}
+
+	return SUCCESS;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_read(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *read_len) 
+{
+	mbedtls_ssl_context *ssl = &(pNetwork->tlsDataParams.ssl);
+	size_t rxLen = 0;
+	TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
+	int ret;
+
+	while (len > 0) 
+	{
+		if(pNetwork->tlsMode)
+		{
+			ret = mbedtls_ssl_read(ssl, pMsg, len);
+		}
+		else
+		{
+			ret = mbedtls_net_recv_timeout(&(tlsDataParams->server_fd), pMsg, len, ARMS_MQTT_SSL_READ_TIMEOUT);
+		}
+
+		if (ret > 0) 
+		{
+			rxLen += ret;
+			pMsg += ret;
+			len -= ret;
+		} 
+		else if (ret == 0 || (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_TIMEOUT)) 
+		{
+			return NETWORK_SSL_READ_ERROR;
+		}
+
+		// Evaluate timeout after the read to make sure read is done at least once
+		if (arms_mqtt_api_timer_expired(timer)) 
+		{
+			break;
+		}
+	}
+
+	*read_len = rxLen;
+
+	if (len == 0) 
+	{
+		return SUCCESS;
+	}
+
+	if (rxLen == 0) 
+	{
+		return NETWORK_SSL_NOTHING_TO_READ;
+	} 
+
+	return NETWORK_SSL_READ_TIMEOUT_ERROR;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_disconnect(Network *pNetwork) 
+{
+	mbedtls_ssl_context *ssl = &(pNetwork->tlsDataParams.ssl);
+	int ret = 0;
+
+	if(pNetwork->tlsMode)
+	{
+		do 
+		{
+			ret = mbedtls_ssl_close_notify(ssl);
+		} while(ret == MBEDTLS_ERR_SSL_WANT_WRITE);
+	}
+
+	return SUCCESS;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_tls_destroy(Network *pNetwork) 
+{
+	TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
+
+	mbedtls_net_free(&(tlsDataParams->server_fd));
+
+	if(pNetwork->tlsMode)
+	{
+		mbedtls_x509_crt_free(&(tlsDataParams->clicert));
+		mbedtls_x509_crt_free(&(tlsDataParams->cacert));
+		mbedtls_pk_free(&(tlsDataParams->pkey));
+		mbedtls_ssl_free(&(tlsDataParams->ssl));
+		mbedtls_ssl_config_free(&(tlsDataParams->conf));
+		mbedtls_ctr_drbg_free(&(tlsDataParams->ctr_drbg));
+		mbedtls_entropy_free(&(tlsDataParams->entropy));
+	}
+
+	return SUCCESS;
+}
+#else
+static ARMS_MQTT_ERROR_T arms_mqtt_api_is_connected(Network *pNetwork) 
+{
+	/* Use this to add implementation which can check for physical layer disconnect */
+	return NETWORK_PHYSICAL_LAYER_CONNECTED;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_connect(Network *pNetwork, TLSConnectParams *params) 
+{
+	int ret = 0;
+	char portBuffer[6];
+
+	if(NULL == pNetwork) 
+	{
+		return NULL_VALUE_ERROR;
+	}
+
+	if(NULL != params) 
+	{
+		arms_mqtt_api_tls_set_connect_params(pNetwork, params->pRootCALocation, params->pDeviceCertLocation,
+									params->pDevicePrivateKeyLocation, params->pDestinationURL,
+									params->DestinationPort, params->timeout_ms, params->ServerVerificationFlag);
+	}
+
+	snprintf(portBuffer, 6, "%d", pNetwork->tlsConnectParams.DestinationPort);
+	pNetwork->server_fd = arms_sock_tcp_open(&pNetwork->server_fd,pNetwork->tlsConnectParams.pDestinationURL,portBuffer);
+	if (pNetwork->server_fd == -1)
+	{			
+		ARMS_LOG_ERROR("%s(%d) open tcp addr=[%s] port = [%s] failed\n",__FUNCTION__,__LINE__,pNetwork->tlsConnectParams.pDestinationURL,portBuffer);
+		return TCP_CONNECTION_ERROR;
+	}
+
+	ret = arms_sock_tcp_set_block(pNetwork->server_fd);
+
+	if(ret != 0) 
+	{
+		ARMS_LOG_ERROR("%s(%d) set tcp socket to block failed\n",__FUNCTION__,__LINE__);
+		return TCP_CONNECTION_ERROR;
+	} 
+	
+	ARMS_LOG_DEBUG(" ok\n");
+	
+	return (ARMS_MQTT_ERROR_T) ret;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_write(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *written_len) 
+{
+	size_t written_so_far;
+	bool isErrorFlag = false;
+	int frags;
+	int ret = 0;
+
+	for(written_so_far = 0, frags = 0;
+		written_so_far < len && !arms_mqtt_api_timer_expired(timer); written_so_far += ret, frags++) 
+	{
+		{
+			while(!arms_mqtt_api_timer_expired(timer) &&
+				  (ret = arms_sock_tcp_send(pNetwork->server_fd, (const char *)pMsg + written_so_far, len - written_so_far)) <= 0) 
+			{
+				if(ret <= 0) 
+				{
+					ARMS_LOG_ERROR("%s(%d) TCP sock Send failed\n",__FUNCTION__,__LINE__);
+					/* All other negative return values indicate connection needs to be reset.
+					* Will be caught in ping request so ignored here */
+					isErrorFlag = true;
+					break;
+				}
+			}
+		}
+
+		if(isErrorFlag) 
+		{
+			break;
+		}
+	}
+
+	*written_len = written_so_far;
+
+	if(isErrorFlag) 
+	{
+		return NETWORK_SSL_WRITE_ERROR;
+	}
+	
+	if(arms_mqtt_api_timer_expired(timer) && written_so_far != len) 
+	{
+		return NETWORK_SSL_WRITE_TIMEOUT_ERROR;
+	}
+
+	return SUCCESS;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_read(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *read_len) 
+{
+	size_t rxLen = 0;
+	int ret;
+	size_t rLen = len;
+
+	while (len > 0) 
+	{
+
+		ret = arms_sock_tcp_poll(pNetwork->server_fd, ARMS_MQTT_TCP_READ_TIMEOUT);
+
+		if(ret > 0)
+		{
+			ARMS_LOG_DEBUG("%s(%d) TCP Sock Receiving...\n",__FUNCTION__,__LINE__);
+			ret = arms_sock_tcp_recv(pNetwork->server_fd, (char *)pMsg, (int *)&rLen);
+		}
+
+		if (ret > 0) 
+		{
+			rxLen += rLen;
+			pMsg += rLen;
+			len -= rLen;
+		} 
+		else if (ret < 0) 
+		{
+			return NETWORK_SSL_READ_ERROR;
+		}
+
+		// Evaluate timeout after the read to make sure read is done at least once
+		if (arms_mqtt_api_timer_expired(timer)) 
+		{
+			break;
+		}
+	}
+
+	if (len == 0) 
+	{
+		*read_len = rxLen;
+		return SUCCESS;
+	}
+
+	if (rxLen == 0) 
+	{
+		return NETWORK_SSL_NOTHING_TO_READ;
+	} 
+
+	return NETWORK_SSL_READ_TIMEOUT_ERROR;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_disconnect(Network *pNetwork) 
+{
+	return SUCCESS;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_api_destroy(Network *pNetwork) 
+{
+	arms_sock_tcp_close(&(pNetwork->server_fd));
+
+	return SUCCESS;
+}
+
+#endif
+
+ARMS_MQTT_ERROR_T arms_mqtt_api_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
+						 char *pDevicePrivateKeyLocation, char *pDestinationURL,
+						 uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) 
+{
+
+	arms_mqtt_api_tls_set_connect_params(pNetwork, pRootCALocation, pDeviceCertLocation, pDevicePrivateKeyLocation,
+								pDestinationURL, destinationPort, timeout_ms, ServerVerificationFlag);
+
+#ifdef ARMS_AUTH_X509
+	pNetwork->connect = arms_mqtt_api_tls_connect;
+	pNetwork->read = arms_mqtt_api_tls_read;
+	pNetwork->write = arms_mqtt_api_tls_write;
+	pNetwork->disconnect = arms_mqtt_api_tls_disconnect;
+	pNetwork->isConnected = arms_mqtt_api_tls_is_connected;
+	pNetwork->destroy = arms_mqtt_api_tls_destroy;
+
+	pNetwork->tlsDataParams.flags = 0;
+#else
+	pNetwork->connect = arms_mqtt_api_connect;
+	pNetwork->read = arms_mqtt_api_read;
+	pNetwork->write = arms_mqtt_api_write;
+	pNetwork->disconnect = arms_mqtt_api_disconnect;
+	pNetwork->isConnected = arms_mqtt_api_is_connected;
+	pNetwork->destroy = arms_mqtt_api_destroy;
+#endif
+	return SUCCESS;
+}
+
+
diff --git a/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.h b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.h
new file mode 100755
index 0000000..9ec305d
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_net.h
@@ -0,0 +1,74 @@
+#ifndef _APPARMS_NET_API_
+#define _APPARMS_NET_API_
+
+#ifdef ARMS_AUTH_X509
+#include "mbedtls/config.h"
+#include "mbedtls/platform.h"
+#include "mbedtls/net.h"
+#include "mbedtls/ssl.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/certs.h"
+#include "mbedtls/x509.h"
+#include "mbedtls/error.h"
+#include "mbedtls/debug.h"
+#include "mbedtls/timing.h"
+#else
+#include "apparms_sock_tcp.h"
+#endif
+
+#include "apparms_mqtt_api_error.h"
+#include "apparms_mqtt_api_timer.h"
+
+#ifdef ARMS_AUTH_X509
+typedef struct _TLSDataParams
+{
+	mbedtls_entropy_context entropy;
+	mbedtls_ctr_drbg_context ctr_drbg;
+	mbedtls_ssl_context ssl;
+	mbedtls_ssl_config conf;
+	uint32_t flags;
+	mbedtls_x509_crt cacert;
+	mbedtls_x509_crt clicert;
+	mbedtls_pk_context pkey;
+	mbedtls_net_context server_fd;
+}TLSDataParams;
+#endif
+
+typedef struct _TLSConnectParams
+{
+	char *pRootCALocation;                ///< Pointer to string containing the filename (including path) of the root CA file.
+	char *pDeviceCertLocation;            ///< Pointer to string containing the filename (including path) of the device certificate.
+	char *pDevicePrivateKeyLocation;    ///< Pointer to string containing the filename (including path) of the device private key file.
+	char *pDestinationURL;                ///< Pointer to string containing the endpoint of the MQTT service.
+	uint16_t DestinationPort;            ///< Integer defining the connection port of the MQTT service.
+	uint32_t timeout_ms;                ///< Unsigned integer defining the TLS handshake timeout value in milliseconds.
+	bool ServerVerificationFlag;        ///< Boolean.  True = perform server certificate hostname validation.  False = skip validation \b NOT recommended.
+} TLSConnectParams;
+
+typedef struct Network Network;
+
+struct Network 
+{
+	ARMS_MQTT_ERROR_T (*connect)(Network *, TLSConnectParams *);
+
+	ARMS_MQTT_ERROR_T (*read)(Network *, unsigned char *, size_t, Timer *, size_t *);    ///< Function pointer pointing to the network function to read from the network
+	ARMS_MQTT_ERROR_T (*write)(Network *, unsigned char *, size_t, Timer *, size_t *);    ///< Function pointer pointing to the network function to write to the network
+	ARMS_MQTT_ERROR_T (*disconnect)(Network *);    ///< Function pointer pointing to the network function to disconnect from the network
+	ARMS_MQTT_ERROR_T (*isConnected)(Network *);    ///< Function pointer pointing to the network function to check if TLS is connected
+	ARMS_MQTT_ERROR_T (*destroy)(Network *);        ///< Function pointer pointing to the network function to destroy the network object
+
+	TLSConnectParams tlsConnectParams;        ///< TLSConnect params structure containing the common connection parameters
+
+#ifdef ARMS_AUTH_X509
+	TLSDataParams tlsDataParams;            ///< TLSData params structure containing the connection data parameters that are specific to the library being used
+#else
+	int server_fd;
+#endif
+	bool tlsMode;
+};
+
+ARMS_MQTT_ERROR_T arms_mqtt_api_tls_init(Network *pNetwork, char *pRootCALocation, char *pDeviceCertLocation,
+						 char *pDevicePrivateKeyLocation, char *pDestinationURL,
+						 uint16_t DestinationPort, uint32_t timeout_ms, bool ServerVerificationFlag);
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.c b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.c
new file mode 100755
index 0000000..5b48c34
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.c
@@ -0,0 +1,162 @@
+
+#include "apparms_mqtt_api_timer.h"
+
+#ifdef USE_CLOCK_UPTIME
+#include <stdio.h>
+#include <unistd.h>  
+#include <fcntl.h>
+#endif
+
+#ifdef USE_CLOCK_UPTIME
+int arms_mqtt_api_timer_getuptime(struct timeval *tv)
+{
+	int fd = -1;
+	int size = 0 ;
+	double tmppwon,tmpidle;
+	unsigned char buf[64];	
+
+	memset(buf,0,64);
+	fd = open("/proc/uptime",O_RDONLY);
+	if(fd != -1)
+	{
+		size = read(fd,buf,sizeof(buf));
+		close(fd);
+		if(size > 0)
+		{
+			sscanf((const char*)buf,"%lf %lf",&tmppwon,&tmpidle);
+
+			tv->tv_sec = (long)tmppwon;
+			tv->tv_usec = (tmppwon - tv->tv_sec) * 1000 * 1000;
+			return 0 ;	
+		}	
+	}	 
+	return -1;
+}
+#endif
+
+#ifdef USE_CLOCK_MONOTONIC_TIME
+double arms_mqtt_api_timer_elapsed_ms(struct timespec* start,struct timespec* stop)
+{
+	double delta_s, delta_ns, delta_result;
+	
+	if ((stop->tv_nsec - start->tv_nsec) < 0)
+	{
+		delta_s = stop->tv_sec - start->tv_sec - 1;
+		delta_ns = stop->tv_nsec - start->tv_nsec + 1000000000;
+	}
+	else
+	{
+		delta_s = stop->tv_sec - start->tv_sec;
+		delta_ns = stop->tv_nsec - start->tv_nsec;
+	}
+
+	delta_result = delta_s * 1000 + delta_ns / 1000000;
+
+	return delta_result;
+}
+#endif
+
+bool arms_mqtt_api_timer_expired(Timer *timer) 
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME
+	double elapsed_ms;
+	struct timespec now;
+	
+	clock_gettime(CLOCK_MONOTONIC, &now);
+	elapsed_ms = arms_mqtt_api_timer_elapsed_ms(&timer->time_slot, &now);
+	if (elapsed_ms < 0)
+	{
+		clock_gettime(CLOCK_MONOTONIC, &timer->time_slot);
+		return 0;
+	}
+
+	if (elapsed_ms < timer->time_delta_ms)
+		return 0;
+	return 1;
+#else
+	struct timeval now, res;
+#ifdef USE_CLOCK_UPTIME
+	arms_mqtt_api_timer_getuptime(&now);
+#else
+	gettimeofday(&now, NULL);
+#endif
+	timersub(&timer->end_time, &now, &res);
+	return res.tv_sec < 0 || (res.tv_sec == 0 && res.tv_usec <= 0);
+#endif	
+}
+
+void arms_mqtt_api_timer_countdown_ms(Timer *timer, uint32_t timeout) 
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME
+	clock_gettime(CLOCK_MONOTONIC, &timer->time_slot);
+	timer->time_delta_ms = timeout;
+#else	
+	struct timeval now;
+	struct timeval interval = {timeout / 1000, (int)((timeout % 1000) * 1000)};
+#ifdef USE_CLOCK_UPTIME
+	arms_mqtt_api_timer_getuptime(&now);
+#else
+	gettimeofday(&now, NULL);
+#endif
+	timeradd(&now, &interval, &timer->end_time);
+#endif	
+}
+
+uint32_t arms_mqtt_api_timer_left_ms(Timer *timer)
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME
+	double elapsed_ms;
+	struct timespec now;
+	
+	clock_gettime(CLOCK_MONOTONIC, &now);
+	elapsed_ms = arms_mqtt_api_timer_elapsed_ms(&timer->time_slot, &now);
+	if ((elapsed_ms >= 0) && (elapsed_ms < timer->time_delta_ms))
+	{
+		return timer->time_delta_ms - elapsed_ms;
+	}
+
+	return 0;
+
+#else
+	struct timeval now, res;
+	uint32_t result_ms = 0;
+#ifdef USE_CLOCK_UPTIME
+	arms_mqtt_api_timer_getuptime(&now);
+#else
+	gettimeofday(&now, NULL);
+#endif	
+	timersub(&timer->end_time, &now, &res);
+	if(res.tv_sec >= 0)
+	{
+		result_ms = (uint32_t) (res.tv_sec * 1000 + res.tv_usec / 1000);
+	}
+	return result_ms;
+#endif	
+}
+
+void arms_mqtt_api_timercountdown_sec(Timer *timer, uint32_t timeout) 
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME
+	clock_gettime(CLOCK_MONOTONIC, &timer->time_slot);
+	timer->time_delta_ms = timeout * 1000;
+#else
+	struct timeval now;
+	struct timeval interval = {timeout, 0};
+#ifdef USE_CLOCK_UPTIME
+	arms_mqtt_api_timer_getuptime(&now);
+#else
+	gettimeofday(&now, NULL);
+#endif
+	timeradd(&now, &interval, &timer->end_time);
+#endif
+}
+
+void arms_mqtt_api_timer_init(Timer *timer)
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME
+	timer->time_delta_ms = 0;
+#else
+	timer->end_time = (struct timeval) {0, 0};
+#endif
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.h b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.h
new file mode 100755
index 0000000..790fb11
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqnet/apparms_mqtt_api_timer.h
@@ -0,0 +1,32 @@
+
+#ifndef _APPARMS_MQTT_API_TIMER_
+#define _APPARMS_MQTT_API_TIMER_
+
+#include <sys/time.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <time.h>
+
+#define USE_CLOCK_MONOTONIC_TIME 1
+//#define USE_CLOCK_UPTIME 1
+
+typedef struct tagTimer 
+{
+#ifdef USE_CLOCK_MONOTONIC_TIME	
+	struct timespec time_slot;
+	long time_delta_ms;
+#else
+	struct timeval end_time;
+#endif
+}Timer;
+
+bool arms_mqtt_api_timer_expired(Timer *timer);
+void arms_mqtt_api_timer_countdown_ms(Timer *timer, uint32_t timeout);
+uint32_t arms_mqtt_api_timer_left_ms(Timer *timer);
+void arms_mqtt_api_timercountdown_sec(Timer *timer, uint32_t timeout);
+void arms_mqtt_api_timer_init(Timer *timer);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqtt/Makefile b/lynq/S300/ap/app/apparms/mqtt/Makefile
new file mode 100755
index 0000000..c719d25
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/Makefile
@@ -0,0 +1,36 @@
+
+APPARMS_DEFS ?=
+APPARMS_MQTT_STATIC_LIB = libapparmsmqtt.a
+
+APPARMS_MQTT_DIR = ./
+APPARMS_MQTT_SRC_FILES += $(shell find $(APPARMS_MQTT_DIR)/src/ -name '*.c')
+
+APPARMS_MQTT_LIB_OBJS = $(APPARMS_MQTT_SRC_FILES:.c=.o)
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g -I./ -I./inc -I./common -I../log
+
+# TCP option
+#ifeq ($(SUPPORT_TCP),TRUE)
+CFLAGS += -I../sock
+#endif
+
+#MQNET option
+#ifeq ($(SUPPORT_MQNET),TRUE)
+CFLAGS += -I../mqnet
+#endif
+
+# TLS option
+ifeq ($(SUPPORT_TLS),TRUE)
+CFLAGS += -I../mbedTLS/include
+endif
+
+CFLAGS += $(APPARMS_DEFS)
+
+all: $(APPARMS_MQTT_STATIC_LIB)
+
+$(APPARMS_MQTT_STATIC_LIB): $(APPARMS_MQTT_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(APPARMS_MQTT_STATIC_LIB) $(APPARMS_MQTT_LIB_OBJS) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/mqtt/apparms_sock_mqtt.h b/lynq/S300/ap/app/apparms/mqtt/apparms_sock_mqtt.h
new file mode 100755
index 0000000..876af19
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/apparms_sock_mqtt.h
@@ -0,0 +1,6 @@
+#ifndef _APPARMS_SOCK_MQTT_H
+#define _APPARMS_SOCK_MQTT_H
+
+#include "apparms_mqtt.h"
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt.h b/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt.h
new file mode 100755
index 0000000..8c58e47
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt.h
@@ -0,0 +1,236 @@
+#ifndef _APPARMS_MQTT_
+#define _APPARMS_MQTT_
+
+#include "apparms_mqtt_api_net.h"
+
+#define MAX_PACKET_ID 65535
+
+#define ARMS_MQTT_PING_TIMEOUT 30
+#define ARMS_MQTT_TX_BUF_LEN (8*1024)
+#define ARMS_MQTT_RX_BUF_LEN (2*1024)
+#define ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS 5 ///< Maximum number of topic filters the MQTT client can handle at any given time. This should be increased appropriately when using Thing Shadow
+
+// Auto Reconnect specific config
+#define ARMS_MQTT_MIN_RECONNECT_WAIT_INTERVAL 1000 ///< Minimum time before the First reconnect attempt is made as part of the exponential back-off algorithm
+#define ARMS_MQTT_MAX_RECONNECT_WAIT_INTERVAL 5000 ///< Maximum time interval after which exponential back-off will stop attempting to reconnect.
+
+#define DISABLE_METRICS false ///< Disable the collection of metrics by setting this to true
+
+typedef struct _Client ARMS_MQTT_Client;
+
+typedef enum QoS 
+{
+	QOS0 = 0,
+	QOS1 = 1
+} QoS;
+
+typedef struct 
+{
+	QoS qos;		///< Message Quality of Service
+	uint8_t isRetained;	///< Retained messages are
+	uint8_t isDup;		///< Is this message a duplicate QoS > 0 message?  Handled automatically by the MQTT client.
+	uint16_t id;		///< Message sequence identifier.  Handled automatically by the MQTT client.
+	void *payload;		///< Pointer to MQTT message payload (bytes).
+	size_t payloadLen;	///< Length of MQTT payload.
+} MQTT_Publish_Message_Params;
+
+typedef enum 
+{
+	MQTT_3_1_1 = 4    ///< MQTT 3.1.1 (protocol message byte = 4)
+} MQTT_Ver_t;
+
+typedef struct 
+{
+	char struct_id[4];		///< The eyecatcher for this structure.  must be MQTW
+	char *pTopicName;		///< The LWT topic to which the LWT message will be published
+	uint16_t topicNameLen;		///< The length of the LWT topic, 16 bit unsinged integer
+	char *pMessage;			///< Message to be delivered as LWT
+	uint16_t msgLen;		///< The length of the Message, 16 bit unsinged integer
+	bool isRetained;		///< NOT supported. The retained flag for the LWT message (see MQTTAsync_message.retained)
+	QoS qos;			///< QoS of LWT message
+} MQTT_Will_Options;
+
+extern const MQTT_Will_Options MqttWillOptionsDefault;
+
+#define MQTT_Will_Options_Initializer { {'M', 'Q', 'T', 'W'}, NULL, 0, NULL, 0, false, QOS0 }
+
+typedef struct 
+{
+	char struct_id[4];			///< The eyecatcher for this structure.  must be MQTC
+	MQTT_Ver_t MQTTVersion;			///< Desired MQTT version used during connection
+	char *pClientID;                	///< Pointer to a string defining the MQTT client ID
+	uint16_t clientIDLen;			///< Client Id Length. 16 bit unsigned integer
+	uint16_t keepAliveIntervalInSec;	///< MQTT keep alive interval in seconds.  Defines inactivity time allowed before determining the connection has been lost.
+	bool isCleanSession;			///< MQTT clean session.  True = this session is to be treated as clean.  Previous server state is cleared and no stated is retained from this connection.
+	bool isWillMsgPresent;			///< Is there a LWT associated with this connection?
+	MQTT_Will_Options will;		///< MQTT LWT parameters.
+	char *pUsername;	
+	uint16_t usernameLen;			///< Username Length. 16 bit unsigned integer
+	char *pPassword;
+	uint16_t passwordLen;			///< Password Length. 16 bit unsigned integer
+} MQTT_Connect_Params;
+
+extern const MQTT_Connect_Params ClientConnectParamsDefault;
+
+#define MQTT_Connect_Params_initializer { {'M', 'Q', 'T', 'C'}, MQTT_3_1_1, NULL, 0, 60, true, false, \
+        MQTT_Will_Options_Initializer, NULL, 0, NULL, 0 }
+
+/**
+ * @brief Disconnect Callback Handler Type
+ *
+ * Defining a TYPE for definition of disconnect callback function pointers.
+ *
+ */
+typedef void (*mqtt_disconnect_handler)(ARMS_MQTT_Client *, void *);
+
+
+typedef struct 
+{
+	bool enableAutoReconnect;			///< Set to true to enable auto reconnect
+	char *pHostURL;					///< Pointer to a string defining the endpoint for the MQTT service
+	uint16_t port;					///< MQTT service listening port
+	char *pRootCALocation;				///< Pointer to a string defining the Root CA file (full file, not path)
+	char *pDeviceCertLocation;			///< Pointer to a string defining the device identity certificate file (full file, not path)
+	char *pDevicePrivateKeyLocation;        	///< Pointer to a string defining the device private key file (full file, not path)
+	uint32_t mqttPacketTimeout_ms;			///< Timeout for reading a complete MQTT packet. In milliseconds
+	uint32_t mqttCommandTimeout_ms;			///< Timeout for MQTT blocking calls. In milliseconds
+	uint32_t tlsHandshakeTimeout_ms;		///< TLS handshake timeout.  In milliseconds
+	bool isSSLHostnameVerify;			///< Client should perform server certificate hostname validation
+	mqtt_disconnect_handler disconnectHandler;	///< Callback to be invoked upon connection loss
+	void *disconnectHandlerData;			///< Data to pass as argument when disconnect handler is called
+} MQTT_Init_Params;
+extern const MQTT_Init_Params ClientInitParamsDefault;
+
+
+#define Client_Init_Params_initializer { true, NULL, 0, NULL, NULL, NULL, 2000, 20000, 5000, true, NULL, NULL }
+
+typedef enum _ClientState 
+{
+	CLIENT_STATE_INVALID = 0,
+	CLIENT_STATE_INITIALIZED = 1,
+	CLIENT_STATE_CONNECTING = 2,
+	CLIENT_STATE_CONNECTED_IDLE = 3,
+	CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS = 4,
+	CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS = 5,
+	CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS = 6,
+	CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS = 7,
+	CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS = 8,
+	CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN = 9,
+	CLIENT_STATE_DISCONNECTING = 10,
+	CLIENT_STATE_DISCONNECTED_ERROR = 11,
+	CLIENT_STATE_DISCONNECTED_MANUALLY = 12,
+	CLIENT_STATE_PENDING_RECONNECT = 13
+} ClientState;
+
+/**
+ * @brief Application Callback Handler Type
+ *
+ * Defining a TYPE for definition of application callback function pointers.
+ * Used to send incoming data to the application
+ *
+ */
+typedef void (*pApplicationHandler_t)(ARMS_MQTT_Client *pClient, char *pTopicName, uint16_t topicNameLen,
+									  MQTT_Publish_Message_Params *pParams, void *pClientData);
+
+typedef struct _MessageHandlers 
+{
+	const char *topicName;
+	uint16_t topicNameLen;
+	QoS qos;
+	pApplicationHandler_t pApplicationHandler;
+	void *pApplicationHandlerData;
+} MessageHandlers;   /* Message handlers are indexed by subscription topic */
+
+
+typedef struct _ClientStatus 
+{
+	ClientState clientState;
+	bool isPingOutstanding;
+	bool isAutoReconnectEnabled;
+} ClientStatus;
+
+typedef struct _ClientData 
+{
+	uint16_t nextPacketId;
+
+	uint32_t packetTimeoutMs;
+	uint32_t commandTimeoutMs;
+	uint16_t keepAliveInterval;
+	uint32_t currentReconnectWaitInterval;
+	uint32_t counterNetworkDisconnected;
+
+	/* The below values are initialized with the
+	 * lengths of the TX/RX buffers and never modified
+	 * afterwards */
+	size_t writeBufSize;
+	size_t readBufSize;
+    size_t readBufIndex;
+	unsigned char writeBuf[ARMS_MQTT_TX_BUF_LEN];
+	unsigned char readBuf[ARMS_MQTT_RX_BUF_LEN];
+
+	MQTT_Connect_Params options;
+
+	MessageHandlers messageHandlers[ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS];
+	mqtt_disconnect_handler disconnectHandler;
+
+	void *disconnectHandlerData;
+} ClientData;
+
+/**
+ * @brief MQTT Client
+ *
+ * Defining a type for MQTT Client
+ *
+ */
+struct _Client 
+{
+	Timer pingTimer;
+	Timer reconnectDelayTimer;
+
+	ClientStatus clientStatus;
+	ClientData clientData;
+	Network networkStack;
+};
+
+uint16_t arms_mqtt_get_next_packet_id(ARMS_MQTT_Client *pClient);
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_connect_params(ARMS_MQTT_Client *pClient, MQTT_Connect_Params *pNewConnectParams);
+
+bool arms_mqtt_is_client_connected(ARMS_MQTT_Client *pClient);
+
+ClientState arms_mqtt_get_client_state(ARMS_MQTT_Client *pClient);
+
+bool arms_mqtt_is_autoreconnect_enabled(ARMS_MQTT_Client *pClient);
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_disconnect_handler(ARMS_MQTT_Client *pClient, mqtt_disconnect_handler pDisconnectHandler,
+												void *pDisconnectHandlerData);
+
+ARMS_MQTT_ERROR_T arms_mqtt_autoreconnect_set_status(ARMS_MQTT_Client *pClient, bool newStatus);
+
+uint32_t arms_mqtt_get_network_disconnected_count(ARMS_MQTT_Client *pClient);
+
+void arms_mqtt_reset_network_disconnected_count(ARMS_MQTT_Client *pClient);
+
+
+ARMS_MQTT_ERROR_T arms_mqtt_init(ARMS_MQTT_Client *pClient, MQTT_Init_Params *pInitParams);
+
+ARMS_MQTT_ERROR_T arms_mqtt_connect(ARMS_MQTT_Client *pClient, MQTT_Connect_Params *pConnectParams);
+
+ARMS_MQTT_ERROR_T arms_mqtt_publish(ARMS_MQTT_Client *pClient, const char *pTopicName, uint16_t topicNameLen,
+								 MQTT_Publish_Message_Params *pParams);
+
+ARMS_MQTT_ERROR_T arms_mqtt_subscribe(ARMS_MQTT_Client *pClient, const char *pTopicName, uint16_t topicNameLen,
+								   QoS qos, pApplicationHandler_t pApplicationHandler, void *pApplicationHandlerData);
+
+ARMS_MQTT_ERROR_T arms_mqtt_resubscribe(ARMS_MQTT_Client *pClient);
+
+ARMS_MQTT_ERROR_T arms_mqtt_unsubscribe(ARMS_MQTT_Client *pClient, const char *pTopicFilter, uint16_t topicFilterLen);
+
+ARMS_MQTT_ERROR_T arms_mqtt_disconnect(ARMS_MQTT_Client *pClient);
+
+ARMS_MQTT_ERROR_T arms_mqtt_yield(ARMS_MQTT_Client *pClient, uint32_t timeout_ms);
+
+ARMS_MQTT_ERROR_T arms_mqtt_reconnect(ARMS_MQTT_Client *pClient);
+
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt_internal.h b/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt_internal.h
new file mode 100755
index 0000000..bdde944
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/inc/apparms_mqtt_internal.h
@@ -0,0 +1,72 @@
+#ifndef _APPARMS_MQTT_INTERNAL_
+#define _APPARMS_MQTT_INTERNAL_
+
+#include "apparms_log.h"
+#include "apparms_mqtt.h"
+
+typedef enum msgTypes 
+{
+	UNKNOWN = -1,
+	CONNECT = 1,
+	CONNACK = 2,
+	PUBLISH = 3,
+	PUBACK = 4,
+	PUBREC = 5,
+	PUBREL = 6,
+	PUBCOMP = 7,
+	SUBSCRIBE = 8,
+	SUBACK = 9,
+	UNSUBSCRIBE = 10,
+	UNSUBACK = 11,
+	PINGREQ = 12,
+	PINGRESP = 13,
+	DISCONNECT = 14
+} MessageTypes;
+
+#define MQTT_HEADER_FIELD_TYPE(_byte)	((_byte >> 4) & 0x0F)
+#define MQTT_HEADER_FIELD_DUP(_byte)	((_byte & (1 << 3)) >> 3)
+#define MQTT_HEADER_FIELD_QOS(_byte)	((_byte & (3 << 1)) >> 1)
+#define MQTT_HEADER_FIELD_RETAIN(_byte)	((_byte & (1 << 0)) >> 0)
+
+typedef union 
+{
+	unsigned char byte;				/**< the whole byte */
+} MQTTHeader;
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_init_header(MQTTHeader *pHeader, MessageTypes message_type,
+											  QoS qos, uint8_t dup, uint8_t retained);
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_serialize_ack(unsigned char *pTxBuf, size_t txBufLen,
+												MessageTypes msgType, uint8_t dup, uint16_t packetId,
+												uint32_t *pSerializedLen);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_deserialize_ack(unsigned char *, unsigned char *,
+												  uint16_t *, unsigned char *, size_t);
+
+uint32_t arms_mqtt_internal_get_final_packet_length_from_remaining_length(uint32_t rem_len);
+
+size_t arms_mqtt_internal_write_len_to_buffer(unsigned char *buf, uint32_t length);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_decode_remaining_length_from_buffer(unsigned char *buf, uint32_t *decodedLen,
+																	  uint32_t *readBytesLen);
+
+uint16_t arms_mqtt_internal_read_uint16_t(unsigned char **pptr);
+void arms_mqtt_internal_write_uint_16(unsigned char **pptr, uint16_t anInt);
+
+unsigned char arms_mqtt_internal_read_char(unsigned char **pptr);
+void arms_mqtt_internal_write_char(unsigned char **pptr, unsigned char c);
+void arms_mqtt_internal_write_utf8_string(unsigned char **pptr, const char *string, uint16_t stringLen);
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_flushBuffers( ARMS_MQTT_Client *pClient );
+ARMS_MQTT_ERROR_T arms_mqtt_internal_send_packet(ARMS_MQTT_Client *pClient, size_t length, Timer *pTimer);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_cycle_read(ARMS_MQTT_Client *pClient, Timer *pTimer, uint8_t *pPacketType);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_wait_for_read(ARMS_MQTT_Client *pClient, uint8_t packetType, Timer *pTimer);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_serialize_zero(unsigned char *pTxBuf, size_t txBufLen,
+												 MessageTypes packetType, size_t *pSerializedLength);
+ARMS_MQTT_ERROR_T arms_mqtt_internal_deserialize_publish(uint8_t *dup, QoS *qos,
+													  uint8_t *retained, uint16_t *pPacketId,
+													  char **pTopicName, uint16_t *topicNameLen,
+													  unsigned char **payload, size_t *payloadLen,
+													  unsigned char *pRxBuf, size_t rxBufLen);
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_client_state(ARMS_MQTT_Client *pClient, ClientState expectedCurrentState,
+										  ClientState newState);
+#endif
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt.c
new file mode 100755
index 0000000..df9c8b9
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt.c
@@ -0,0 +1,254 @@
+#include "apparms_mqtt_internal.h"
+
+#define VERSION_MAJOR 3
+#define VERSION_MINOR 0
+#define VERSION_PATCH 1
+#define VERSION_TAG ""
+
+//#if !DISABLE_METRICS
+#define SDK_METRICS_LEN 25
+#define SDK_METRICS_TEMPLATE "?SDK=C&Version=%d.%d.%d"
+static char pUsernameTemp[SDK_METRICS_LEN] = {0};
+//#endif
+
+const MQTT_Init_Params ClientInitParamsDefault = Client_Init_Params_initializer;
+const MQTT_Will_Options MqttWillOptionsDefault = MQTT_Will_Options_Initializer;
+const MQTT_Connect_Params ClientConnectParamsDefault = MQTT_Connect_Params_initializer;
+
+ClientState arms_mqtt_get_client_state(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient) 
+	{
+		return CLIENT_STATE_INVALID;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(pClient->clientStatus.clientState);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_client_state(ARMS_MQTT_Client *pClient, ClientState expectedCurrentState,
+										  ClientState newState) 
+{
+	ARMS_MQTT_ERROR_T rc;
+	
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(expectedCurrentState == arms_mqtt_get_client_state(pClient)) 
+	{
+		pClient->clientStatus.clientState = newState;
+		rc = SUCCESS;
+	} 
+	else 
+	{
+		rc = MQTT_UNEXPECTED_CLIENT_STATE_ERROR;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_connect_params(ARMS_MQTT_Client *pClient, MQTT_Connect_Params *pNewConnectParams) 
+{
+	ARMS_LOG_FUNC_ENTRY;
+	
+	if(NULL == pClient || NULL == pNewConnectParams) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	pClient->clientData.options.isWillMsgPresent = pNewConnectParams->isWillMsgPresent;
+	pClient->clientData.options.MQTTVersion = pNewConnectParams->MQTTVersion;
+	pClient->clientData.options.pClientID = pNewConnectParams->pClientID;
+	pClient->clientData.options.clientIDLen = pNewConnectParams->clientIDLen;
+
+//#if !DISABLE_METRICS
+	if (pClient->networkStack.tlsMode)
+	{
+		if (0 == strlen(pUsernameTemp))
+		{
+			snprintf(pUsernameTemp, SDK_METRICS_LEN, SDK_METRICS_TEMPLATE, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+		}
+		pClient->clientData.options.pUsername = (char*)&pUsernameTemp[0];
+		pClient->clientData.options.usernameLen = strlen(pUsernameTemp);
+	}
+	else
+//#else
+	{
+		pClient->clientData.options.pUsername = pNewConnectParams->pUsername;
+		pClient->clientData.options.usernameLen = pNewConnectParams->usernameLen;
+	}
+//#endif
+	pClient->clientData.options.pPassword = pNewConnectParams->pPassword;
+	pClient->clientData.options.passwordLen = pNewConnectParams->passwordLen;
+	pClient->clientData.options.will.pTopicName = pNewConnectParams->will.pTopicName;
+	pClient->clientData.options.will.topicNameLen = pNewConnectParams->will.topicNameLen;
+	pClient->clientData.options.will.pMessage = pNewConnectParams->will.pMessage;
+	pClient->clientData.options.will.msgLen = pNewConnectParams->will.msgLen;
+	pClient->clientData.options.will.qos = pNewConnectParams->will.qos;
+	pClient->clientData.options.will.isRetained = pNewConnectParams->will.isRetained;
+	pClient->clientData.options.keepAliveIntervalInSec = pNewConnectParams->keepAliveIntervalInSec;
+	pClient->clientData.options.isCleanSession = pNewConnectParams->isCleanSession;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_init(ARMS_MQTT_Client *pClient, MQTT_Init_Params *pInitParams) 
+{
+	uint32_t i;
+	ARMS_MQTT_ERROR_T rc;
+	MQTT_Connect_Params default_options = MQTT_Connect_Params_initializer;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient || NULL == pInitParams || NULL == pInitParams->pHostURL || 0 == pInitParams->port) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(pClient->networkStack.tlsMode)
+	{
+		if(NULL == pInitParams->pRootCALocation || NULL == pInitParams->pDevicePrivateKeyLocation || NULL == pInitParams->pDeviceCertLocation)
+		{
+			ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+		}
+	}
+
+	for(i = 0; i < ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS; ++i) 
+	{
+		pClient->clientData.messageHandlers[i].topicName = NULL;
+		pClient->clientData.messageHandlers[i].pApplicationHandler = NULL;
+		pClient->clientData.messageHandlers[i].pApplicationHandlerData = NULL;
+		pClient->clientData.messageHandlers[i].qos = QOS0;
+	}
+
+	pClient->clientData.packetTimeoutMs = pInitParams->mqttPacketTimeout_ms;
+	pClient->clientData.commandTimeoutMs = pInitParams->mqttCommandTimeout_ms;
+	pClient->clientData.writeBufSize = ARMS_MQTT_TX_BUF_LEN;
+	pClient->clientData.readBufSize = ARMS_MQTT_RX_BUF_LEN;
+	pClient->clientData.counterNetworkDisconnected = 0;
+	pClient->clientData.disconnectHandler = pInitParams->disconnectHandler;
+	pClient->clientData.disconnectHandlerData = pInitParams->disconnectHandlerData;
+	pClient->clientData.nextPacketId = 1;
+
+	/* Initialize default connection options */
+	rc = arms_mqtt_set_connect_params(pClient, &default_options);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	pClient->clientStatus.isPingOutstanding = 0;
+	pClient->clientStatus.isAutoReconnectEnabled = pInitParams->enableAutoReconnect;
+
+	rc = arms_mqtt_api_tls_init(&(pClient->networkStack), pInitParams->pRootCALocation, pInitParams->pDeviceCertLocation,
+					  pInitParams->pDevicePrivateKeyLocation, pInitParams->pHostURL, pInitParams->port,
+					  pInitParams->tlsHandshakeTimeout_ms, pInitParams->isSSLHostnameVerify);
+
+	if(SUCCESS != rc) 
+	{
+		pClient->clientStatus.clientState = CLIENT_STATE_INVALID;
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	arms_mqtt_api_timer_init(&(pClient->pingTimer));
+	arms_mqtt_api_timer_init(&(pClient->reconnectDelayTimer));
+
+	pClient->clientStatus.clientState = CLIENT_STATE_INITIALIZED;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+uint16_t arms_mqtt_get_next_packet_id(ARMS_MQTT_Client *pClient) 
+{
+	return pClient->clientData.nextPacketId = (uint16_t) ((MAX_PACKET_ID == pClient->clientData.nextPacketId) ? 1 : (
+			pClient->clientData.nextPacketId + 1));
+}
+
+bool arms_mqtt_is_client_connected(ARMS_MQTT_Client *pClient) 
+{
+	bool isConnected;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(false);
+	}
+
+	switch(pClient->clientStatus.clientState) 
+	{
+		case CLIENT_STATE_INVALID:
+		case CLIENT_STATE_INITIALIZED:
+		case CLIENT_STATE_CONNECTING:
+			isConnected = false;
+			break;
+		case CLIENT_STATE_CONNECTED_IDLE:
+		case CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN:
+			isConnected = true;
+			break;
+		case CLIENT_STATE_DISCONNECTING:
+		case CLIENT_STATE_DISCONNECTED_ERROR:
+		case CLIENT_STATE_DISCONNECTED_MANUALLY:
+		case CLIENT_STATE_PENDING_RECONNECT:
+		default:
+			isConnected = false;
+			break;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(isConnected);
+}
+
+bool arms_mqtt_is_autoreconnect_enabled(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(false);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(pClient->clientStatus.isAutoReconnectEnabled);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_autoreconnect_set_status(ARMS_MQTT_Client *pClient, bool newStatus) 
+{
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+	pClient->clientStatus.isAutoReconnectEnabled = newStatus;
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_set_disconnect_handler(ARMS_MQTT_Client *pClient, mqtt_disconnect_handler pDisconnectHandler,
+												void *pDisconnectHandlerData)
+{
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient || NULL == pDisconnectHandler) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	pClient->clientData.disconnectHandler = pDisconnectHandler;
+	pClient->clientData.disconnectHandlerData = pDisconnectHandlerData;
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+uint32_t arms_mqtt_get_network_disconnected_count(ARMS_MQTT_Client *pClient) 
+{
+	return pClient->clientData.counterNetworkDisconnected;
+}
+
+void arms_mqtt_reset_network_disconnected_count(ARMS_MQTT_Client *pClient) 
+{
+	pClient->clientData.counterNetworkDisconnected = 0;
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_connect.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_connect.c
new file mode 100755
index 0000000..2d112cb
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_connect.c
@@ -0,0 +1,548 @@
+#include "apparms_mqtt_internal.h"
+
+typedef union 
+{
+	uint8_t all;    /**< all connect flags */
+#if defined(REVERSED)
+	struct
+	{
+		unsigned int username : 1;		/**< 3.1 user name */
+		unsigned int password : 1;		/**< 3.1 password */
+		unsigned int willRetain : 1;	/**< will retain setting */
+		unsigned int willQoS : 2;		/**< will QoS value */
+		unsigned int will : 1;			/**< will flag */
+		unsigned int cleansession : 1;	/**< clean session flag */
+		unsigned int : 1;				/**< unused */
+	} bits;
+#else
+	struct 
+	{
+		unsigned int : 1;
+		/**< unused */
+		unsigned int cleansession : 1;
+		/**< cleansession flag */
+		unsigned int will : 1;
+		/**< will flag */
+		unsigned int willQoS : 2;
+		/**< will QoS value */
+		unsigned int willRetain : 1;
+		/**< will retain setting */
+		unsigned int password : 1;
+		/**< 3.1 password */
+		unsigned int username : 1;        /**< 3.1 user name */
+	} bits;
+#endif
+} MQTT_Connect_Header_Flags;
+/**< connect flags byte */
+
+typedef union 
+{
+	uint8_t all;                            /**< all connack flags */
+#if defined(REVERSED)
+	struct
+	{
+		unsigned int sessionpresent : 1;	/**< session present flag */
+		unsigned int : 7;					/**< unused */
+	} bits;
+#else
+	struct {
+		unsigned int : 7;
+		/**< unused */
+		unsigned int sessionpresent : 1;    /**< session present flag */
+	} bits;
+#endif
+} MQTT_Connack_Header_Flags;
+/**< connack flags byte */
+
+typedef enum 
+{
+	CONNACK_CONNECTION_ACCEPTED = 0,
+	CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR = 1,
+	CONNACK_IDENTIFIER_REJECTED_ERROR = 2,
+	CONNACK_SERVER_UNAVAILABLE_ERROR = 3,
+	CONNACK_BAD_USERDATA_ERROR = 4,
+	CONNACK_NOT_AUTHORIZED_ERROR = 5
+} MQTT_Connack_Return_Codes;    /**< Connect request response codes from server */
+
+static uint32_t arms_mqtt_connect_get_packet_length(MQTT_Connect_Params *pConnectParams) 
+{
+	uint32_t len;
+	/* Enable when adding further MQTT versions */
+	/*size_t len = 0;
+	switch(pConnectParams->MQTTVersion) {
+		case MQTT_3_1_1:
+			len = 10;
+			break;
+	}*/
+	ARMS_LOG_FUNC_ENTRY;
+
+	len = 10; // Len = 10 for MQTT_3_1_1
+	len = len + pConnectParams->clientIDLen + 2;
+
+	if(pConnectParams->isWillMsgPresent) 
+	{
+		len = len + pConnectParams->will.topicNameLen + 2 + pConnectParams->will.msgLen + 2;
+	}
+
+	if(NULL != pConnectParams->pUsername) 
+	{
+		len = len + pConnectParams->usernameLen + 2;
+	}
+
+	if(NULL != pConnectParams->pPassword) 
+	{
+		len = len + pConnectParams->passwordLen + 2;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(len);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_connect_serialize(unsigned char *pTxBuf, size_t txBufLen,
+												   MQTT_Connect_Params *pConnectParams,
+												   size_t *pSerializedLen) 
+{
+	unsigned char *ptr;
+	uint32_t len;
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+	MQTT_Connect_Header_Flags flags = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pTxBuf || NULL == pConnectParams || NULL == pSerializedLen ||
+	   (NULL == pConnectParams->pClientID && 0 != pConnectParams->clientIDLen) ||
+	   (NULL != pConnectParams->pClientID && 0 == pConnectParams->clientIDLen)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* Check needed here before we start writing to the Tx buffer */
+	switch(pConnectParams->MQTTVersion) 
+	{
+		case MQTT_3_1_1:
+			break;
+		default:
+			return MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR;
+	}
+
+	ptr = pTxBuf;
+	len = arms_mqtt_connect_get_packet_length(pConnectParams);
+	if(arms_mqtt_internal_get_final_packet_length_from_remaining_length(len) > txBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	rc = arms_mqtt_internal_init_header(&header, CONNECT, QOS0, 0, 0);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	arms_mqtt_internal_write_char(&ptr, header.byte); /* write header */
+
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, len); /* write remaining length */
+
+	// Enable if adding support for more versions
+	//if(MQTT_3_1_1 == pConnectParams->MQTTVersion) {
+	arms_mqtt_internal_write_utf8_string(&ptr, "MQTT", 4);
+	arms_mqtt_internal_write_char(&ptr, (unsigned char) pConnectParams->MQTTVersion);
+	//}
+
+	flags.all = 0;
+	if (pConnectParams->isCleanSession)
+	{
+		flags.all |= 1 << 1;
+	}
+
+	if (pConnectParams->isWillMsgPresent)
+	{
+		flags.all |= 1 << 2;
+		flags.all |= pConnectParams->will.qos << 3;
+		flags.all |= pConnectParams->will.isRetained << 5;
+	}
+
+	if(pConnectParams->pPassword) {
+		flags.all |= 1 << 6;
+	}
+
+	if(pConnectParams->pUsername) {
+		flags.all |= 1 << 7;
+	}
+
+	arms_mqtt_internal_write_char(&ptr, flags.all);
+	arms_mqtt_internal_write_uint_16(&ptr, pConnectParams->keepAliveIntervalInSec);
+
+	/* If the code have passed the check for incorrect values above, no client id was passed as argument */
+	if(NULL == pConnectParams->pClientID) 
+	{
+		arms_mqtt_internal_write_uint_16(&ptr, 0);
+	} 
+	else 
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pConnectParams->pClientID, pConnectParams->clientIDLen);
+	}
+
+	if(pConnectParams->isWillMsgPresent) 
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pConnectParams->will.pTopicName,
+												pConnectParams->will.topicNameLen);
+		arms_mqtt_internal_write_utf8_string(&ptr, pConnectParams->will.pMessage, pConnectParams->will.msgLen);
+	}
+
+	if(pConnectParams->pUsername) 
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pConnectParams->pUsername, pConnectParams->usernameLen);
+	}
+
+	if(pConnectParams->pPassword) 
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pConnectParams->pPassword, pConnectParams->passwordLen);
+	}
+
+	*pSerializedLen = (size_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_connect_deserialize_connack(unsigned char *pSessionPresent, ARMS_MQTT_ERROR_T *pConnackRc,
+													 unsigned char *pRxBuf, size_t rxBufLen) 
+{
+	unsigned char *curdata, *enddata;
+	unsigned char connack_rc_char;
+	uint32_t decodedLen, readBytesLen;
+	ARMS_MQTT_ERROR_T rc;
+	MQTT_Connack_Header_Flags flags = {0};
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pSessionPresent || NULL == pConnackRc || NULL == pRxBuf) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* CONNACK header size is fixed at two bytes for fixed and 2 bytes for variable,
+	 * using that as minimum size
+	 * MQTT v3.1.1 Specification 3.2.1 */
+	if(4 > rxBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_RX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	curdata = pRxBuf;
+	enddata = NULL;
+	decodedLen = 0;
+	readBytesLen = 0;
+
+	header.byte = arms_mqtt_internal_read_char(&curdata);
+	if(CONNACK != MQTT_HEADER_FIELD_TYPE(header.byte)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	/* read remaining length */
+	rc = arms_mqtt_internal_decode_remaining_length_from_buffer(curdata, &decodedLen, &readBytesLen);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* CONNACK remaining length should always be 2 as per MQTT 3.1.1 spec */
+	curdata += (readBytesLen);
+	enddata = curdata + decodedLen;
+	if(2 != (enddata - curdata)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_DECODE_REMAINING_LENGTH_ERROR);
+	}
+
+	flags.all = arms_mqtt_internal_read_char(&curdata);
+	*pSessionPresent = flags.bits.sessionpresent;
+	connack_rc_char = arms_mqtt_internal_read_char(&curdata);
+	switch(connack_rc_char) 
+	{
+		case CONNACK_CONNECTION_ACCEPTED:
+			*pConnackRc = MQTT_CONNACK_CONNECTION_ACCEPTED;
+			break;
+		case CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR:
+			*pConnackRc = MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR;
+			break;
+		case CONNACK_IDENTIFIER_REJECTED_ERROR:
+			*pConnackRc = MQTT_CONNACK_IDENTIFIER_REJECTED_ERROR;
+			break;
+		case CONNACK_SERVER_UNAVAILABLE_ERROR:
+			*pConnackRc = MQTT_CONNACK_SERVER_UNAVAILABLE_ERROR;
+			break;
+		case CONNACK_BAD_USERDATA_ERROR:
+			*pConnackRc = MQTT_CONNACK_BAD_USERDATA_ERROR;
+			break;
+		case CONNACK_NOT_AUTHORIZED_ERROR:
+			*pConnackRc = MQTT_CONNACK_NOT_AUTHORIZED_ERROR;
+			break;
+		default:
+			*pConnackRc = MQTT_CONNACK_UNKNOWN_ERROR;
+			break;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static bool arms_mqtt_connect_is_client_state_valid(ClientState clientState) 
+{
+	bool isValid = false;
+
+	switch(clientState) 
+	{
+		case CLIENT_STATE_INVALID:
+			isValid = false;
+			break;
+		case CLIENT_STATE_INITIALIZED:
+			isValid = true;
+			break;
+		case CLIENT_STATE_CONNECTING:
+		case CLIENT_STATE_CONNECTED_IDLE:
+		case CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS:
+		case CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN:
+		case CLIENT_STATE_DISCONNECTING:
+			isValid = false;
+			break;
+		case CLIENT_STATE_DISCONNECTED_ERROR:
+		case CLIENT_STATE_DISCONNECTED_MANUALLY:
+		case CLIENT_STATE_PENDING_RECONNECT:
+			isValid = true;
+			break;
+		default:
+			break;
+	}
+
+	return isValid;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_connect_entry(ARMS_MQTT_Client *pClient, MQTT_Connect_Params *pConnectParams)
+{
+	Timer connect_timer;
+	ARMS_MQTT_ERROR_T connack_rc = FAILURE;
+	char sessionPresent = 0;
+	size_t len = 0;
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL != pConnectParams) 
+	{
+		/* override default options if new options were supplied */
+		rc = arms_mqtt_set_connect_params(pClient, pConnectParams);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(MQTT_CONNECTION_ERROR);
+		}
+	}
+
+	rc = pClient->networkStack.connect(&(pClient->networkStack), NULL);
+	if(SUCCESS != rc) 
+	{
+		/* TLS Connect failed, return error */
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	arms_mqtt_api_timer_init(&connect_timer);
+	arms_mqtt_api_timer_countdown_ms(&connect_timer, pClient->clientData.commandTimeoutMs);
+
+	pClient->clientData.keepAliveInterval = pClient->clientData.options.keepAliveIntervalInSec;
+	rc = arms_mqtt_connect_serialize(pClient->clientData.writeBuf, pClient->clientData.writeBufSize,
+										 &(pClient->clientData.options), &len);
+	if(SUCCESS != rc || 0 >= len) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* send the connect packet */
+	rc = arms_mqtt_internal_send_packet(pClient, len, &connect_timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* this will be a blocking call, wait for the CONNACK */
+	rc = arms_mqtt_internal_wait_for_read(pClient, CONNACK, &connect_timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* Received CONNACK, check the return code */
+	rc = arms_mqtt_connect_deserialize_connack((unsigned char *) &sessionPresent, &connack_rc, pClient->clientData.readBuf,
+										   pClient->clientData.readBufSize);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	if(MQTT_CONNACK_CONNECTION_ACCEPTED != connack_rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(connack_rc);
+	}
+
+	pClient->clientStatus.isPingOutstanding = false;
+	arms_mqtt_api_timercountdown_sec(&pClient->pingTimer, pClient->clientData.keepAliveInterval);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_connect(ARMS_MQTT_Client *pClient, MQTT_Connect_Params *pConnectParams) 
+{
+	ARMS_MQTT_ERROR_T rc, disconRc;
+	ClientState clientState;
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+    arms_mqtt_internal_flushBuffers( pClient );
+	clientState = arms_mqtt_get_client_state(pClient);
+
+	if(false == arms_mqtt_connect_is_client_state_valid(clientState)) 
+	{
+		/* Don't send connect packet again if we are already connected
+		 * or in the process of connecting/disconnecting */
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_ALREADY_CONNECTED_ERROR);
+	}
+
+	arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTING);
+
+	rc = arms_mqtt_connect_entry(pClient, pConnectParams);
+
+	if(SUCCESS != rc) 
+	{
+		pClient->networkStack.disconnect(&(pClient->networkStack));
+		disconRc = pClient->networkStack.destroy(&(pClient->networkStack));
+		if (SUCCESS != disconRc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+		}
+		arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTING, CLIENT_STATE_DISCONNECTED_ERROR);
+	} 
+	else 
+	{
+		arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTING, CLIENT_STATE_CONNECTED_IDLE);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_disconnect_entry(ARMS_MQTT_Client *pClient) 
+{
+	/* We might wait for incomplete incoming publishes to complete */
+	Timer timer;
+	size_t serialized_len = 0;
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	rc = arms_mqtt_internal_serialize_zero(pClient->clientData.writeBuf, pClient->clientData.writeBufSize,
+											  DISCONNECT,
+											  &serialized_len);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	arms_mqtt_api_timer_init(&timer);
+	arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+
+	/* send the disconnect packet */
+	if(serialized_len > 0) 
+	{
+		(void)arms_mqtt_internal_send_packet(pClient, serialized_len, &timer);
+	}
+
+	/* Clean network stack */
+	pClient->networkStack.disconnect(&(pClient->networkStack));
+	rc = pClient->networkStack.destroy(&(pClient->networkStack));
+	if(0 != rc) 
+	{
+		/* TLS Destroy failed, return error */
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_disconnect(ARMS_MQTT_Client *pClient) 
+{
+	ClientState clientState;
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	clientState = arms_mqtt_get_client_state(pClient);
+	if(!arms_mqtt_is_client_connected(pClient)) 
+	{
+		/* Network is already disconnected. Do nothing */
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+	}
+
+	rc = arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_DISCONNECTING);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	rc = arms_mqtt_disconnect_entry(pClient);
+
+	if(SUCCESS != rc) 
+	{
+		pClient->clientStatus.clientState = clientState;
+	} 
+	else 
+	{
+		/* If called from Keepalive, this gets set to CLIENT_STATE_DISCONNECTED_ERROR */
+		pClient->clientStatus.clientState = CLIENT_STATE_DISCONNECTED_MANUALLY;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_reconnect(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(arms_mqtt_is_client_connected(pClient)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_ALREADY_CONNECTED_ERROR);
+	}
+
+	/* Ignoring return code. failures expected if network is disconnected */
+	rc = arms_mqtt_connect(pClient, NULL);
+
+	/* If still disconnected handle disconnect */
+	if(CLIENT_STATE_CONNECTED_IDLE != arms_mqtt_get_client_state(pClient)) 
+	{
+		arms_mqtt_set_client_state(pClient, CLIENT_STATE_DISCONNECTED_ERROR, CLIENT_STATE_PENDING_RECONNECT);
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_ATTEMPTING_RECONNECT);
+	}
+
+	rc = arms_mqtt_resubscribe(pClient);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(NETWORK_RECONNECTED);
+}
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_internal.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_internal.c
new file mode 100755
index 0000000..f046d20
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_internal.c
@@ -0,0 +1,671 @@
+#include "apparms_mqtt_internal.h"
+
+#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4
+
+size_t arms_mqtt_internal_write_len_to_buffer(unsigned char *buf, uint32_t length) 
+{
+	size_t outLen = 0;
+	unsigned char encodedByte;
+
+	ARMS_LOG_FUNC_ENTRY;
+	do 
+	{
+		encodedByte = (unsigned char) (length % 128);
+		length /= 128;
+		/* if there are more digits to encode, set the top bit of this digit */
+		if(length > 0) 
+		{
+			encodedByte |= 0x80;
+		}
+		buf[outLen++] = encodedByte;
+	} while(length > 0);
+
+	ARMS_LOG_FUNC_EXIT_RC(outLen);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_decode_remaining_length_from_buffer(unsigned char *buf, uint32_t *decodedLen,
+																	  uint32_t *readBytesLen) 
+{
+	unsigned char encodedByte;
+	uint32_t multiplier, len;
+	ARMS_LOG_FUNC_ENTRY;
+
+	multiplier = 1;
+	len = 0;
+	*decodedLen = 0;
+
+	do 
+	{
+		if(++len > MAX_NO_OF_REMAINING_LENGTH_BYTES) 
+		{
+			/* bad data */
+			ARMS_LOG_FUNC_EXIT_RC(MQTT_DECODE_REMAINING_LENGTH_ERROR);
+		}
+		encodedByte = *buf;
+		buf++;
+		*decodedLen += (encodedByte & 127) * multiplier;
+		multiplier *= 128;
+	} while((encodedByte & 128) != 0);
+
+	*readBytesLen = len;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+uint32_t arms_mqtt_internal_get_final_packet_length_from_remaining_length(uint32_t rem_len) 
+{
+	rem_len += 1; /* header byte */
+	/* now remaining_length field (MQTT 3.1.1 - 2.2.3)*/
+	if(rem_len < 128) 
+	{
+		rem_len += 1;
+	} 
+	else if(rem_len < 16384) 
+	{
+		rem_len += 2;
+	} 
+	else if(rem_len < 2097152) 
+	{
+		rem_len += 3;
+	} 
+	else 
+	{
+		rem_len += 4;
+	}
+	return rem_len;
+}
+
+uint16_t arms_mqtt_internal_read_uint16_t(unsigned char **pptr) 
+{
+	unsigned char *ptr = *pptr;
+	uint16_t len = 0;
+	uint8_t firstByte = (uint8_t) (*ptr);
+	uint8_t secondByte = (uint8_t) (*(ptr + 1));
+	len = (uint16_t) (secondByte + (256 * firstByte));
+
+	*pptr += 2;
+	return len;
+}
+
+void arms_mqtt_internal_write_uint_16(unsigned char **pptr, uint16_t anInt) 
+{
+	**pptr = (unsigned char) (anInt / 256);
+	(*pptr)++;
+	**pptr = (unsigned char) (anInt % 256);
+	(*pptr)++;
+}
+
+unsigned char arms_mqtt_internal_read_char(unsigned char **pptr) 
+{
+	unsigned char c = **pptr;
+	(*pptr)++;
+	return c;
+}
+
+void arms_mqtt_internal_write_char(unsigned char **pptr, unsigned char c) 
+{
+	**pptr = c;
+	(*pptr)++;
+}
+
+void arms_mqtt_internal_write_utf8_string(unsigned char **pptr, const char *string, uint16_t stringLen) 
+{
+	/* Nothing that calls this function will have a stringLen with a size larger than 2 bytes (MQTT 3.1.1 - 1.5.3) */
+	arms_mqtt_internal_write_uint_16(pptr, stringLen);
+	if(stringLen > 0) {
+		memcpy(*pptr, string, stringLen);
+		*pptr += stringLen;
+	}
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_init_header(MQTTHeader *pHeader, MessageTypes message_type,
+											  QoS qos, uint8_t dup, uint8_t retained) 
+{
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pHeader) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* Set all bits to zero */
+	pHeader->byte = 0;
+	uint8_t type = 0;
+	switch(message_type) 
+	{
+		case UNKNOWN:
+			/* Should never happen */
+			return FAILURE;
+		case CONNECT:
+			type = 0x01;
+			break;
+		case CONNACK:
+			type = 0x02;
+			break;
+		case PUBLISH:
+			type = 0x03;
+			break;
+		case PUBACK:
+			type = 0x04;
+			break;
+		case PUBREC:
+			type = 0x05;
+			break;
+		case PUBREL:
+			type = 0x06;
+			break;
+		case PUBCOMP:
+			type = 0x07;
+			break;
+		case SUBSCRIBE:
+			type = 0x08;
+			break;
+		case SUBACK:
+			type = 0x09;
+			break;
+		case UNSUBSCRIBE:
+			type = 0x0A;
+			break;
+		case UNSUBACK:
+			type = 0x0B;
+			break;
+		case PINGREQ:
+			type = 0x0C;
+			break;
+		case PINGRESP:
+			type = 0x0D;
+			break;
+		case DISCONNECT:
+			type = 0x0E;
+			break;
+		default:
+			/* Should never happen */
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	pHeader->byte = type << 4;
+	pHeader->byte |= dup << 3;
+
+	switch(qos) 
+	{
+		case QOS0:
+			break;
+		case QOS1:
+			pHeader->byte |= 1 << 1;
+			break;
+		default:
+			/* Using QOS0 as default */
+			break;
+	}
+
+	pHeader->byte |= (1 == retained) ? 0x01 : 0x00;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_send_packet(ARMS_MQTT_Client *pClient, size_t length, Timer *pTimer) 
+{
+
+	size_t sentLen, sent;
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient || NULL == pTimer) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(length >= pClient->clientData.writeBufSize) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	sentLen = 0;
+	sent = 0;
+
+	while(sent < length && !arms_mqtt_api_timer_expired(pTimer)) 
+	{
+		rc = pClient->networkStack.write(&(pClient->networkStack),
+						 &pClient->clientData.writeBuf[sent],
+						 (length - sent),
+						 pTimer,
+						 &sentLen);
+		if(SUCCESS != rc) 
+		{
+			/* there was an error writing the data */
+			break;
+		}
+		sent += sentLen;
+	}
+
+	if(sent == length) 
+	{
+		/* record the fact that we have successfully sent the packet */
+		//countdown_sec(&c->pingTimer, c->clientData.keepAliveInterval);
+		ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc) 
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_internal_readWrapper( ARMS_MQTT_Client *pClient, size_t offset, size_t size, Timer *pTimer, size_t * read_len ) {
+    ARMS_MQTT_ERROR_T rc;
+    int byteToRead;
+    size_t byteRead = 0;
+
+    byteToRead = ( offset + size ) - pClient->clientData.readBufIndex;
+
+    if ( byteToRead > 0 )
+    {
+        rc = pClient->networkStack.read( &( pClient->networkStack ),
+            pClient->clientData.readBuf + pClient->clientData.readBufIndex,
+            (size_t)byteToRead,
+            pTimer,
+            &byteRead );
+        pClient->clientData.readBufIndex += byteRead;
+
+        /* refresh byte to read */
+        byteToRead = ( offset + size ) - ((int)pClient->clientData.readBufIndex);
+        *read_len = size - (size_t)byteToRead;
+    }
+    else
+    {
+        *read_len = size;
+        rc = SUCCESS;
+    }
+
+ 
+
+    return rc;
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_internal_decode_packet_remaining_len(ARMS_MQTT_Client *pClient, size_t * offset,
+																	  size_t *rem_len, Timer *pTimer) 
+{
+	size_t multiplier, len;
+	ARMS_MQTT_ERROR_T rc;
+    size_t read_len;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	multiplier = 1;
+	len = 0;
+	*rem_len = 0;
+
+	do 
+	{
+		if(++len > MAX_NO_OF_REMAINING_LENGTH_BYTES) 
+		{
+			/* bad data */
+			ARMS_LOG_FUNC_EXIT_RC(MQTT_DECODE_REMAINING_LENGTH_ERROR);
+		}
+        rc = arms_mqtt_internal_readWrapper( pClient, len, 1, pTimer, &read_len );
+
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+
+		*rem_len += (( pClient->clientData.readBuf[len] & 127) * multiplier);
+		multiplier *= 128;
+	} while(( pClient->clientData.readBuf[len] & 128) != 0);
+    *offset = len + 1;
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_internal_read_packet(ARMS_MQTT_Client *pClient, Timer *pTimer, uint8_t *pPacketType) 
+{
+	size_t rem_len, total_bytes_read, bytes_to_be_read, read_len;
+	ARMS_MQTT_ERROR_T rc;
+    size_t offset = 0;
+	MQTTHeader header = {0};
+	Timer packetTimer;
+	arms_mqtt_api_timer_init(&packetTimer);
+	arms_mqtt_api_timer_countdown_ms(&packetTimer, pClient->clientData.packetTimeoutMs);
+
+	rem_len = 0;
+	total_bytes_read = 0;
+	bytes_to_be_read = 0;
+	read_len = 0;
+
+    rc = arms_mqtt_internal_readWrapper( pClient, offset, 1, pTimer, &read_len );
+	/* 1. read the header byte.  This has the packet type in it */
+	if(NETWORK_SSL_NOTHING_TO_READ == rc) 
+	{
+		return MQTT_NOTHING_TO_READ;
+	} 
+	else if(SUCCESS != rc) 
+	{
+		return rc;
+	}
+
+	/* 2. read the remaining length.  This is variable in itself */
+	rc = arms_mqtt_internal_decode_packet_remaining_len(pClient, &offset, &rem_len, pTimer);
+	if(SUCCESS != rc) 
+	{
+		return rc;
+	} 
+     
+	/* if the buffer is too short then the message will be dropped silently */
+	if((rem_len + offset) >= pClient->clientData.readBufSize) 
+	{
+		bytes_to_be_read = pClient->clientData.readBufSize;
+		do 
+		{
+			rc = pClient->networkStack.read(&(pClient->networkStack), pClient->clientData.readBuf, bytes_to_be_read,
+											pTimer, &read_len);
+			if(SUCCESS == rc) 
+			{
+				total_bytes_read += read_len;
+				if((rem_len - total_bytes_read) >= pClient->clientData.readBufSize) 
+				{
+					bytes_to_be_read = pClient->clientData.readBufSize;
+				} 
+				else 
+				{
+					bytes_to_be_read = rem_len - total_bytes_read;
+				}
+			}
+		} while(total_bytes_read < rem_len && SUCCESS == rc);
+
+        /* Check buffer was correctly emptied, otherwise, return error message. */
+        if ( total_bytes_read == rem_len )
+        {
+            arms_mqtt_internal_flushBuffers( pClient );
+            return MQTT_RX_BUFFER_TOO_SHORT_ERROR;
+        }
+        else
+        {
+            return rc;
+        }
+	}
+
+	/* 3. read the rest of the buffer using a callback to supply the rest of the data */
+	if(rem_len > 0) 
+	{
+        rc = arms_mqtt_internal_readWrapper( pClient, offset, rem_len, pTimer, &read_len );
+		if(SUCCESS != rc || read_len != rem_len) 
+		{
+			return FAILURE;
+		}
+	}
+
+    /* Pack has been received, we can flush the buffers for next call. */
+    arms_mqtt_internal_flushBuffers( pClient );
+	header.byte = pClient->clientData.readBuf[0];
+	*pPacketType = MQTT_HEADER_FIELD_TYPE(header.byte);
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static bool arms_mqtt_internal_is_topic_matched(char *pTopicFilter, char *pTopicName, uint16_t topicNameLen) 
+{
+
+	char *curf, *curn, *curn_end;
+
+	if(NULL == pTopicFilter || NULL == pTopicName) 
+	{
+		return false;
+	}
+
+	curf = pTopicFilter;
+	curn = pTopicName;
+	curn_end = curn + topicNameLen;
+
+	while(*curf && (curn < curn_end)) 
+	{
+		if(*curn == '/' && *curf != '/') 
+		{
+			break;
+		}
+		
+		if(*curf != '+' && *curf != '#' && *curf != *curn) 
+		{
+			break;
+		}
+		
+		if(*curf == '+') 
+		{
+			/* skip until we meet the next separator, or end of string */
+			char *nextpos = curn + 1;
+			while(nextpos < curn_end && *nextpos != '/')
+				nextpos = ++curn + 1;
+		} 
+		else if(*curf == '#') 
+		{
+			/* skip until end of string */
+			curn = curn_end - 1;
+		}
+
+		curf++;
+		curn++;
+	};
+
+	return (curn == curn_end) && (*curf == '\0');
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_internal_deliver_message(ARMS_MQTT_Client *pClient, char *pTopicName,
+														  uint16_t topicNameLen,
+														  MQTT_Publish_Message_Params *pMessageParams) 
+{
+	uint32_t itr;
+	ARMS_MQTT_ERROR_T rc;
+	ClientState clientState;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pTopicName) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* This function can be called from all MQTT APIs
+	 * But while callback return is in progress, Yield should not be called.
+	 * The state for CB_RETURN accomplishes that, as yield cannot be called while in that state */
+	clientState = arms_mqtt_get_client_state(pClient);
+	arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN);
+
+	/* Find the right message handler - indexed by topic */
+	for(itr = 0; itr < ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS; ++itr) 
+	{
+		if(NULL != pClient->clientData.messageHandlers[itr].topicName) 
+		{
+			if(((topicNameLen == pClient->clientData.messageHandlers[itr].topicNameLen)
+				&&
+				(strncmp(pTopicName, (char *) pClient->clientData.messageHandlers[itr].topicName, topicNameLen) == 0))
+			   || arms_mqtt_internal_is_topic_matched((char *) pClient->clientData.messageHandlers[itr].topicName,
+														  pTopicName, topicNameLen)) 
+			{
+				if(NULL != pClient->clientData.messageHandlers[itr].pApplicationHandler) 
+				{
+					pClient->clientData.messageHandlers[itr].pApplicationHandler(pClient, pTopicName, topicNameLen,
+																				 pMessageParams,
+																				 pClient->clientData.messageHandlers[itr].pApplicationHandlerData);
+				}
+			}
+		}
+	}
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN, clientState);
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_internal_handle_publish(ARMS_MQTT_Client *pClient, Timer *pTimer) {
+	char *topicName;
+	uint16_t topicNameLen;
+	uint32_t len;
+	ARMS_MQTT_ERROR_T rc;
+	MQTT_Publish_Message_Params msg;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	topicName = NULL;
+	topicNameLen = 0;
+	len = 0;
+
+	rc = arms_mqtt_internal_deserialize_publish(&msg.isDup, &msg.qos, &msg.isRetained,
+												   &msg.id, &topicName, &topicNameLen,
+												   (unsigned char **) &msg.payload, &msg.payloadLen,
+												   pClient->clientData.readBuf,
+												   pClient->clientData.readBufSize);
+
+	if(SUCCESS != rc) {
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	rc = arms_mqtt_internal_deliver_message(pClient, topicName, topicNameLen, &msg);
+	if(SUCCESS != rc) {
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	if(QOS0 == msg.qos) {
+		/* No further processing required for QoS0 */
+		ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+	}
+
+	/* Message assumed to be QoS1 since we do not support QoS2 at this time */
+	rc = arms_mqtt_internal_serialize_ack(pClient->clientData.writeBuf, pClient->clientData.writeBufSize,
+											 PUBACK, 0, msg.id, &len);
+
+	if(SUCCESS != rc) {
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	rc = arms_mqtt_internal_send_packet(pClient, len, pTimer);
+	if(SUCCESS != rc) {
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_cycle_read(ARMS_MQTT_Client *pClient, Timer *pTimer, uint8_t *pPacketType) 
+{
+	ARMS_MQTT_ERROR_T rc;
+
+	if(NULL == pClient || NULL == pTimer) 
+	{
+		return NULL_VALUE_ERROR;
+	}
+	
+	/* read the socket, see what work is due */
+	rc = arms_mqtt_internal_read_packet(pClient, pTimer, pPacketType);
+
+	if(MQTT_NOTHING_TO_READ == rc) 
+	{
+		/* Nothing to read, not a cycle failure */
+		return SUCCESS;
+	} 
+	else if(SUCCESS != rc) 
+	{
+		return rc;
+	}
+
+	switch(*pPacketType) 
+	{
+		case CONNACK:
+		case PUBACK:
+		case SUBACK:
+		case UNSUBACK:
+			/* SDK is blocking, these responses will be forwarded to calling function to process */
+			break;
+		case PUBLISH: 
+		{
+			rc = arms_mqtt_internal_handle_publish(pClient, pTimer);
+			break;
+		}
+		case PUBREC:
+		case PUBCOMP:
+			/* QoS2 not supported at this time */
+			break;
+		case PINGRESP: 
+		{
+			pClient->clientStatus.isPingOutstanding = 0;
+			arms_mqtt_api_timercountdown_sec(&pClient->pingTimer, pClient->clientData.keepAliveInterval);
+			break;
+		}
+		default: 
+		{
+			/* Either unknown packet type or Failure occurred
+             * Should not happen */
+			rc = MQTT_RX_MESSAGE_PACKET_TYPE_INVALID_ERROR;
+			break;
+		}
+	}
+
+	return rc;
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_flushBuffers( ARMS_MQTT_Client *pClient ) 
+{
+    pClient->clientData.readBufIndex = 0;
+    return SUCCESS;
+}
+
+/* only used in single-threaded mode where one command at a time is in process */
+ARMS_MQTT_ERROR_T arms_mqtt_internal_wait_for_read(ARMS_MQTT_Client *pClient, uint8_t packetType, Timer *pTimer) 
+{
+	ARMS_MQTT_ERROR_T rc;
+	uint8_t read_packet_type;
+
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pClient || NULL == pTimer) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	read_packet_type = 0;
+	do 
+	{
+		if(arms_mqtt_api_timer_expired(pTimer)) 
+		{
+			/* we timed out */
+			rc = MQTT_REQUEST_TIMEOUT_ERROR;
+			break;
+		}
+		rc = arms_mqtt_internal_cycle_read(pClient, pTimer, &read_packet_type);
+	} while(((SUCCESS == rc) || (MQTT_NOTHING_TO_READ == rc)) && (read_packet_type != packetType));
+
+	/* If rc is SUCCESS, we have received the expected
+	 * MQTT packet. Otherwise rc tells the error. */
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_serialize_zero(unsigned char *pTxBuf, size_t txBufLen, MessageTypes packetType,
+												 size_t *pSerializedLength)
+{
+	unsigned char *ptr;
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pTxBuf || NULL == pSerializedLength) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* Buffer should have at least 2 bytes for the header */
+	if(4 > txBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	ptr = pTxBuf;
+
+	rc = arms_mqtt_internal_init_header(&header, packetType, QOS0, 0, 0);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* write header */
+	arms_mqtt_internal_write_char(&ptr, header.byte);
+
+	/* write remaining length */
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, 0);
+	*pSerializedLength = (uint32_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_publish.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_publish.c
new file mode 100755
index 0000000..dc804ea
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_publish.c
@@ -0,0 +1,327 @@
+#include "apparms_mqtt_internal.h"
+
+static ARMS_MQTT_ERROR_T arms_mqtt_publish_read_string_with_len(char **stringVar, uint16_t *stringLen,
+													  unsigned char **pptr, unsigned char *enddata) 
+{
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+
+	ARMS_LOG_FUNC_ENTRY;
+	/* the first two bytes are the length of the string */
+	/* enough length to read the integer? */
+	if(enddata - (*pptr) > 1) 
+	{
+		*stringLen = arms_mqtt_internal_read_uint16_t(pptr); /* increments pptr to point past length */
+		if(&(*pptr)[*stringLen] <= enddata) 
+		{
+			*stringVar = (char *) *pptr;
+			*pptr += *stringLen;
+			rc = SUCCESS;
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_publish_serialize(unsigned char *pTxBuf, size_t txBufLen, uint8_t dup,
+															QoS qos, uint8_t retained, uint16_t packetId,
+															const char *pTopicName, uint16_t topicNameLen,
+															const unsigned char *pPayload, size_t payloadLen,
+															uint32_t *pSerializedLen) 
+{
+	unsigned char *ptr;
+	uint32_t rem_len;
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pTxBuf || NULL == pPayload || NULL == pSerializedLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	ptr = pTxBuf;
+	rem_len = 0;
+
+	rem_len += (uint32_t) (topicNameLen + payloadLen + 2);
+	if(qos > 0) 
+	{
+		rem_len += 2; /* packetId */
+	}
+	
+	if(arms_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len) > txBufLen) {
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	rc = arms_mqtt_internal_init_header(&header, PUBLISH, qos, dup, retained);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	arms_mqtt_internal_write_char(&ptr, header.byte); /* write header */
+
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, rem_len); /* write remaining length */;
+
+	arms_mqtt_internal_write_utf8_string(&ptr, pTopicName, topicNameLen);
+
+	if(qos > 0) 
+	{
+		arms_mqtt_internal_write_uint_16(&ptr, packetId);
+	}
+
+	memcpy(ptr, pPayload, payloadLen);
+	ptr += payloadLen;
+
+	*pSerializedLen = (uint32_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_publish_entry(ARMS_MQTT_Client *pClient, const char *pTopicName,
+												  uint16_t topicNameLen, MQTT_Publish_Message_Params *pParams) 
+{
+	Timer timer;
+	uint32_t len = 0;
+	uint16_t packet_id;
+	unsigned char dup, type;
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	arms_mqtt_api_timer_init(&timer);
+	arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+
+	if(QOS1 == pParams->qos) 
+	{
+		pParams->id = arms_mqtt_get_next_packet_id(pClient);
+	}
+
+	rc = arms_mqtt_publish_serialize(pClient->clientData.writeBuf, pClient->clientData.writeBufSize, 0,
+												  pParams->qos, pParams->isRetained, pParams->id, pTopicName,
+												  topicNameLen, (unsigned char *) pParams->payload,
+												  pParams->payloadLen, &len);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* send the publish packet */
+	rc = arms_mqtt_internal_send_packet(pClient, len, &timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* Wait for ack if QoS1 */
+	if(QOS1 == pParams->qos) 
+	{
+		rc = arms_mqtt_internal_wait_for_read(pClient, PUBACK, &timer);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+
+		rc = arms_mqtt_internal_deserialize_ack(&type, &dup, &packet_id, pClient->clientData.readBuf,
+												   pClient->clientData.readBufSize);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_publish(ARMS_MQTT_Client *pClient, const char *pTopicName, uint16_t topicNameLen,
+								 MQTT_Publish_Message_Params *pParams) 
+{
+	ARMS_MQTT_ERROR_T rc, pubRc;
+	ClientState clientState;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient || NULL == pTopicName || 0 == topicNameLen || NULL == pParams) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(!arms_mqtt_is_client_connected(pClient)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+	}
+
+	clientState = arms_mqtt_get_client_state(pClient);
+	if(CLIENT_STATE_CONNECTED_IDLE != clientState && CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN != clientState) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_CLIENT_NOT_IDLE_ERROR);
+	}
+
+	rc = arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	pubRc = arms_mqtt_publish_entry(pClient, pTopicName, topicNameLen, pParams);
+
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS, clientState);
+	if(SUCCESS == pubRc && SUCCESS != rc) 
+	{
+		pubRc = rc;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(pubRc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_deserialize_publish(uint8_t *dup, QoS *qos,
+													  uint8_t *retained, uint16_t *pPacketId,
+													  char **pTopicName, uint16_t *topicNameLen,
+													  unsigned char **payload, size_t *payloadLen,
+													  unsigned char *pRxBuf, size_t rxBufLen) 
+{
+	unsigned char *curData = pRxBuf;
+	unsigned char *endData = NULL;
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+	uint32_t decodedLen = 0;
+	uint32_t readBytesLen = 0;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == dup || NULL == qos || NULL == retained || NULL == pPacketId) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	/* Publish header size is at least four bytes.
+	 * Fixed header is two bytes.
+	 * Variable header size depends on QoS And Topic Name.
+	 * QoS level 0 doesn't have a message identifier (0 - 2 bytes)
+	 * Topic Name length fields decide size of topic name field (at least 2 bytes)
+	 * MQTT v3.1.1 Specification 3.3.1 */
+	if(4 > rxBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_RX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	header.byte = arms_mqtt_internal_read_char(&curData);
+	if(PUBLISH != MQTT_HEADER_FIELD_TYPE(header.byte)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	*dup = MQTT_HEADER_FIELD_DUP(header.byte);
+	*qos = (QoS) MQTT_HEADER_FIELD_QOS(header.byte);
+	*retained = MQTT_HEADER_FIELD_RETAIN(header.byte);
+
+	/* read remaining length */
+	rc = arms_mqtt_internal_decode_remaining_length_from_buffer(curData, &decodedLen, &readBytesLen);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	curData += (readBytesLen);
+	endData = curData + decodedLen;
+
+	/* do we have enough data to read the protocol version byte? */
+	if(SUCCESS != arms_mqtt_publish_read_string_with_len(pTopicName, topicNameLen, &curData, endData)
+	   || (0 > (endData - curData))) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	if(QOS0 != *qos) 
+	{
+		*pPacketId = arms_mqtt_internal_read_uint16_t(&curData);
+	}
+
+	*payloadLen = (size_t) (endData - curData);
+	*payload = curData;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_deserialize_ack(unsigned char *pPacketType, unsigned char *dup,
+												  uint16_t *pPacketId, unsigned char *pRxBuf,
+												  size_t rxBuflen) {
+	ARMS_MQTT_ERROR_T rc = FAILURE;
+	unsigned char *curdata = pRxBuf;
+	unsigned char *enddata = NULL;
+	uint32_t decodedLen = 0;
+	uint32_t readBytesLen = 0;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pPacketType || NULL == dup || NULL == pPacketId || NULL == pRxBuf) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	/* PUBACK fixed header size is two bytes, variable header is 2 bytes, MQTT v3.1.1 Specification 3.4.1 */
+	if(4 > rxBuflen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_RX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+
+	header.byte = arms_mqtt_internal_read_char(&curdata);
+	*dup = MQTT_HEADER_FIELD_DUP(header.byte);
+	*pPacketType = MQTT_HEADER_FIELD_TYPE(header.byte);
+
+	/* read remaining length */
+	rc = arms_mqtt_internal_decode_remaining_length_from_buffer(curdata, &decodedLen, &readBytesLen);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	curdata += (readBytesLen);
+	enddata = curdata + decodedLen;
+
+	if(enddata - curdata < 2) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	*pPacketId = arms_mqtt_internal_read_uint16_t(&curdata);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_internal_serialize_ack(unsigned char *pTxBuf, size_t txBufLen,
+												MessageTypes msgType, uint8_t dup, uint16_t packetId,
+												uint32_t *pSerializedLen) 
+{
+	unsigned char *ptr;
+	QoS requestQoS;
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pTxBuf || pSerializedLen == NULL) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	ptr = pTxBuf;
+
+	/* Minimum byte length required by ACK headers is
+	 * 2 for fixed and 2 for variable part */
+	if(4 > txBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	requestQoS = (PUBREL == msgType) ? QOS1 : QOS0;
+	rc = arms_mqtt_internal_init_header(&header, msgType, requestQoS, dup, 0);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	arms_mqtt_internal_write_char(&ptr, header.byte); /* write header */
+
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, 2); /* write remaining length */
+	arms_mqtt_internal_write_uint_16(&ptr, packetId);
+	*pSerializedLen = (uint32_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_subscribe.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_subscribe.c
new file mode 100755
index 0000000..f80edb5
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_subscribe.c
@@ -0,0 +1,342 @@
+
+#include "apparms_mqtt_internal.h"
+
+static ARMS_MQTT_ERROR_T arms_mqtt_subscribe_serialize(unsigned char *pTxBuf, size_t txBufLen,
+													 unsigned char dup, uint16_t packetId, uint32_t topicCount,
+													 const char **pTopicNameList, uint16_t *pTopicNameLenList,
+													 QoS *pRequestedQoSs, uint32_t *pSerializedLen) {
+	unsigned char *ptr;
+	uint32_t itr, rem_len;
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pTxBuf || NULL == pSerializedLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	ptr = pTxBuf;
+	rem_len = 2; /* packetId */
+
+	for(itr = 0; itr < topicCount; ++itr) 
+	{
+		rem_len += (uint32_t) (pTopicNameLenList[itr] + 2 + 1); /* topic + length + req_qos */
+	}
+
+	if(arms_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len) > txBufLen) {
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	rc = arms_mqtt_internal_init_header(&header, SUBSCRIBE, QOS1, dup, 0);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	/* write header */
+	arms_mqtt_internal_write_char(&ptr, header.byte);
+
+	/* write remaining length */
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, rem_len);
+
+	arms_mqtt_internal_write_uint_16(&ptr, packetId);
+
+	for(itr = 0; itr < topicCount; ++itr)
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pTopicNameList[itr], pTopicNameLenList[itr]);
+		arms_mqtt_internal_write_char(&ptr, (unsigned char) pRequestedQoSs[itr]);
+	}
+
+	*pSerializedLen = (uint32_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_subscribe_deserialize_suback(uint16_t *pPacketId, uint32_t maxExpectedQoSCount,
+													uint32_t *pGrantedQoSCount, QoS *pGrantedQoSs,
+													unsigned char *pRxBuf, size_t rxBufLen) 
+{
+	unsigned char *curData, *endData;
+	uint32_t decodedLen, readBytesLen;
+	ARMS_MQTT_ERROR_T decodeRc;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+	if(NULL == pPacketId || NULL == pGrantedQoSCount || NULL == pGrantedQoSs) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	curData = pRxBuf;
+	endData = NULL;
+	decodeRc = FAILURE;
+	decodedLen = 0;
+	readBytesLen = 0;
+
+	if(5 > rxBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_RX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	header.byte = arms_mqtt_internal_read_char(&curData);
+	if(SUBACK != MQTT_HEADER_FIELD_TYPE(header.byte)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	/* read remaining length */
+	decodeRc = arms_mqtt_internal_decode_remaining_length_from_buffer(curData, &decodedLen, &readBytesLen);
+	if(SUCCESS != decodeRc)
+	{
+		ARMS_LOG_FUNC_EXIT_RC(decodeRc);
+	}
+
+	curData += (readBytesLen);
+	endData = curData + decodedLen;
+	if(endData - curData < 2) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	*pPacketId = arms_mqtt_internal_read_uint16_t(&curData);
+
+	*pGrantedQoSCount = 0;
+	while(curData < endData)
+	{
+		if(*pGrantedQoSCount > maxExpectedQoSCount) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+		}
+		pGrantedQoSs[(*pGrantedQoSCount)++] = (QoS) arms_mqtt_internal_read_char(&curData);
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static uint32_t arms_mqtt_subscribe_get_free_message_handler_index(ARMS_MQTT_Client *pClient) 
+{
+	uint32_t itr;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	for(itr = 0; itr < ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS; itr++) 
+	{
+		if(pClient->clientData.messageHandlers[itr].topicName == NULL) 
+		{
+			break;
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(itr);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_subscribe_entry(ARMS_MQTT_Client *pClient, const char *pTopicName,
+													uint16_t topicNameLen, QoS qos,
+													pApplicationHandler_t pApplicationHandler,
+													void *pApplicationHandlerData) 
+{
+	uint16_t txPacketId, rxPacketId;
+	uint32_t serializedLen, indexOfFreeMessageHandler, count;
+	ARMS_MQTT_ERROR_T rc;
+	Timer timer;
+	QoS grantedQoS[3] = {QOS0, QOS0, QOS0};
+
+	ARMS_LOG_FUNC_ENTRY;
+	arms_mqtt_api_timer_init(&timer);
+	arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+
+	serializedLen = 0;
+	count = 0;
+	txPacketId = arms_mqtt_get_next_packet_id(pClient);
+	rxPacketId = 0;
+
+	rc = arms_mqtt_subscribe_serialize(pClient->clientData.writeBuf, pClient->clientData.writeBufSize, 0,
+										   txPacketId, 1, &pTopicName, &topicNameLen, &qos, &serializedLen);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	indexOfFreeMessageHandler = arms_mqtt_subscribe_get_free_message_handler_index(pClient);
+	if(ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS <= indexOfFreeMessageHandler) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_MAX_SUBSCRIPTIONS_REACHED_ERROR);
+	}
+
+	/* send the subscribe packet */
+	rc = arms_mqtt_internal_send_packet(pClient, serializedLen, &timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* wait for suback */
+	rc = arms_mqtt_internal_wait_for_read(pClient, SUBACK, &timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* Granted QoS can be 0, 1 or 2 */
+	rc = arms_mqtt_subscribe_deserialize_suback(&rxPacketId, 1, &count, grantedQoS, pClient->clientData.readBuf,
+										  pClient->clientData.readBufSize);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	
+	pClient->clientData.messageHandlers[indexOfFreeMessageHandler].topicName =
+			pTopicName;
+	pClient->clientData.messageHandlers[indexOfFreeMessageHandler].topicNameLen =
+			topicNameLen;
+	pClient->clientData.messageHandlers[indexOfFreeMessageHandler].pApplicationHandler =
+			pApplicationHandler;
+	pClient->clientData.messageHandlers[indexOfFreeMessageHandler].pApplicationHandlerData =
+			pApplicationHandlerData;
+	pClient->clientData.messageHandlers[indexOfFreeMessageHandler].qos = qos;
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_subscribe(ARMS_MQTT_Client *pClient, const char *pTopicName, uint16_t topicNameLen,
+								   QoS qos, pApplicationHandler_t pApplicationHandler, void *pApplicationHandlerData) 
+{
+	ClientState clientState;
+	ARMS_MQTT_ERROR_T rc, subRc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient || NULL == pTopicName || NULL == pApplicationHandler) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(!arms_mqtt_is_client_connected(pClient)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+	}
+
+	clientState = arms_mqtt_get_client_state(pClient);
+	if(CLIENT_STATE_CONNECTED_IDLE != clientState && CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN != clientState) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_CLIENT_NOT_IDLE_ERROR);
+	}
+
+	rc = arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	subRc = arms_mqtt_subscribe_entry(pClient, pTopicName, topicNameLen, qos,
+											 pApplicationHandler, pApplicationHandlerData);
+
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS, clientState);
+	if(SUCCESS == subRc && SUCCESS != rc) 
+	{
+		subRc = rc;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(subRc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_resubscribe_entry(ARMS_MQTT_Client *pClient) {
+	uint16_t packetId;
+	uint32_t len, count, existingSubCount, itr;
+	ARMS_MQTT_ERROR_T rc;
+	Timer timer;
+	QoS grantedQoS[3] = {QOS0, QOS0, QOS0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	packetId = 0;
+	len = 0;
+	count = 0;
+	existingSubCount = arms_mqtt_subscribe_get_free_message_handler_index(pClient);
+
+	for(itr = 0; itr < existingSubCount; itr++) 
+	{
+		if(pClient->clientData.messageHandlers[itr].topicName == NULL) 
+		{
+			continue;
+		}
+
+		arms_mqtt_api_timer_init(&timer);
+		arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+
+		rc = arms_mqtt_subscribe_serialize(pClient->clientData.writeBuf, pClient->clientData.writeBufSize, 0,
+											   arms_mqtt_get_next_packet_id(pClient), 1,
+											   &(pClient->clientData.messageHandlers[itr].topicName),
+											   &(pClient->clientData.messageHandlers[itr].topicNameLen),
+											   &(pClient->clientData.messageHandlers[itr].qos), &len);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+
+		/* send the subscribe packet */
+		rc = arms_mqtt_internal_send_packet(pClient, len, &timer);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+
+		/* wait for suback */
+		rc = arms_mqtt_internal_wait_for_read(pClient, SUBACK, &timer);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+
+		/* Granted QoS can be 0, 1 or 2 */
+		rc = arms_mqtt_subscribe_deserialize_suback(&packetId, 1, &count, grantedQoS, pClient->clientData.readBuf,
+											  pClient->clientData.readBufSize);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_resubscribe(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_MQTT_ERROR_T rc, resubRc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(false == arms_mqtt_is_client_connected(pClient)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+	}
+
+	if(CLIENT_STATE_CONNECTED_IDLE != arms_mqtt_get_client_state(pClient)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_CLIENT_NOT_IDLE_ERROR);
+	}
+
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_IDLE,
+									   CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	resubRc = arms_mqtt_resubscribe_entry(pClient);
+
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS,
+									   CLIENT_STATE_CONNECTED_IDLE);
+	if(SUCCESS == resubRc && SUCCESS != rc) 
+	{
+		resubRc = rc;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(resubRc);
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_unsubscribe.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_unsubscribe.c
new file mode 100755
index 0000000..5af291a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_unsubscribe.c
@@ -0,0 +1,179 @@
+
+#include "apparms_mqtt_internal.h"
+
+static ARMS_MQTT_ERROR_T arms_mqtt_unsubscribe_serialize(unsigned char *pTxBuf, size_t txBufLen,
+													   uint8_t dup, uint16_t packetId,
+													   uint32_t count, const char **pTopicNameList,
+													   uint16_t *pTopicNameLenList, uint32_t *pSerializedLen) 
+{
+	unsigned char *ptr = pTxBuf;
+	uint32_t i = 0;
+	uint32_t rem_len = 2; /* packetId */
+	ARMS_MQTT_ERROR_T rc;
+	MQTTHeader header = {0};
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	for(i = 0; i < count; ++i) 
+	{
+		rem_len += (uint32_t) (pTopicNameLenList[i] + 2); /* topic + length */
+	}
+
+	if(arms_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len) > txBufLen) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(MQTT_TX_BUFFER_TOO_SHORT_ERROR);
+	}
+
+	rc = arms_mqtt_internal_init_header(&header, UNSUBSCRIBE, QOS1, dup, 0);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+	arms_mqtt_internal_write_char(&ptr, header.byte); /* write header */
+
+	ptr += arms_mqtt_internal_write_len_to_buffer(ptr, rem_len); /* write remaining length */
+
+	arms_mqtt_internal_write_uint_16(&ptr, packetId);
+
+	for(i = 0; i < count; ++i) 
+	{
+		arms_mqtt_internal_write_utf8_string(&ptr, pTopicNameList[i], pTopicNameLenList[i]);
+	}
+
+	*pSerializedLen = (uint32_t) (ptr - pTxBuf);
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_unsubscribe_deserialize_unsuback(uint16_t *pPacketId, unsigned char *pRxBuf, size_t rxBufLen) 
+{
+	unsigned char type = 0;
+	unsigned char dup = 0;
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	rc = arms_mqtt_internal_deserialize_ack(&type, &dup, pPacketId, pRxBuf, rxBufLen);
+	if(SUCCESS == rc && UNSUBACK != type) 
+	{
+		rc = FAILURE;
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_unsubscribe_entry(ARMS_MQTT_Client *pClient, const char *pTopicFilter,
+													  uint16_t topicFilterLen) 
+{
+	/* No NULL checks because this is a static internal function */
+
+	Timer timer;
+
+	uint16_t packet_id;
+	uint32_t serializedLen = 0;
+	uint32_t i = 0;
+	ARMS_MQTT_ERROR_T rc;
+	bool subscriptionExists = false;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	/* Remove from message handler array */
+	for(i = 0; i < ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS; ++i) 
+	{
+		if(pClient->clientData.messageHandlers[i].topicName != NULL &&
+		   (strcmp(pClient->clientData.messageHandlers[i].topicName, pTopicFilter) == 0)) 
+		{
+			subscriptionExists = true;
+            break;
+		}
+	}
+
+	if(false == subscriptionExists) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(FAILURE);
+	}
+
+	arms_mqtt_api_timer_init(&timer);
+	arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+
+	rc = arms_mqtt_unsubscribe_serialize(pClient->clientData.writeBuf, pClient->clientData.writeBufSize, 0,
+											 arms_mqtt_get_next_packet_id(pClient), 1, &pTopicFilter,
+											 &topicFilterLen, &serializedLen);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* send the unsubscribe packet */
+	rc = arms_mqtt_internal_send_packet(pClient, serializedLen, &timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	rc = arms_mqtt_internal_wait_for_read(pClient, UNSUBACK, &timer);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	rc = arms_mqtt_unsubscribe_deserialize_unsuback(&packet_id, pClient->clientData.readBuf, pClient->clientData.readBufSize);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* Remove from message handler array */
+	for(i = 0; i < ARMS_MQTT_NUM_SUBSCRIBE_HANDLERS; ++i) 
+	{
+		if(pClient->clientData.messageHandlers[i].topicName != NULL &&
+		   (strcmp(pClient->clientData.messageHandlers[i].topicName, pTopicFilter) == 0)) 
+		{
+			pClient->clientData.messageHandlers[i].topicName = NULL;
+			/* We don't want to break here, in case the same topic is registered
+             * with 2 callbacks. Unlikely scenario */
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_unsubscribe(ARMS_MQTT_Client *pClient, const char *pTopicFilter, uint16_t topicFilterLen) 
+{
+	ARMS_MQTT_ERROR_T rc, unsubRc;
+	ClientState clientState;
+
+	if(NULL == pClient || NULL == pTopicFilter) 
+	{
+		return NULL_VALUE_ERROR;
+	}
+
+	if(!arms_mqtt_is_client_connected(pClient)) 
+	{
+		return NETWORK_DISCONNECTED_ERROR;
+	}
+
+	clientState = arms_mqtt_get_client_state(pClient);
+	if(CLIENT_STATE_CONNECTED_IDLE != clientState && CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN != clientState)
+	{
+		return MQTT_CLIENT_NOT_IDLE_ERROR;
+	}
+
+	rc = arms_mqtt_set_client_state(pClient, clientState, CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS);
+	if(SUCCESS != rc) 
+	{
+		rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS, clientState);
+		return rc;
+	}
+
+	unsubRc = arms_mqtt_unsubscribe_entry(pClient, pTopicFilter, topicFilterLen);
+
+	rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS, clientState);
+	if(SUCCESS == unsubRc && SUCCESS != rc) 
+	{
+		unsubRc = rc;
+	}
+
+	return unsubRc;
+}
+
diff --git a/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_yield.c b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_yield.c
new file mode 100755
index 0000000..ec92672
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/mqtt/src/apparms_mqtt_yield.c
@@ -0,0 +1,264 @@
+#include "apparms_mqtt_internal.h"
+
+static void arms_mqtt_yield_force_client_disconnect(ARMS_MQTT_Client *pClient) 
+{
+	pClient->clientStatus.clientState = CLIENT_STATE_DISCONNECTED_ERROR;
+	pClient->networkStack.disconnect(&(pClient->networkStack));
+	pClient->networkStack.destroy(&(pClient->networkStack));
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_yield_handle_disconnect(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	rc = arms_mqtt_disconnect(pClient);
+	if(rc != SUCCESS) 
+	{
+		arms_mqtt_yield_force_client_disconnect(pClient);
+	}
+
+	if(NULL != pClient->clientData.disconnectHandler) 
+	{
+		pClient->clientData.disconnectHandler(pClient, pClient->clientData.disconnectHandlerData);
+	}
+
+	pClient->clientStatus.clientState = CLIENT_STATE_DISCONNECTED_ERROR;
+	ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+}
+
+
+static ARMS_MQTT_ERROR_T arms_mqtt_yield_handle_reconnect(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_MQTT_ERROR_T rc;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(!arms_mqtt_api_timer_expired(&(pClient->reconnectDelayTimer))) 
+	{
+		/* Timer has not expired. Not time to attempt reconnect yet.
+		 * Return attempting reconnect */
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_ATTEMPTING_RECONNECT);
+	}
+
+	rc = NETWORK_PHYSICAL_LAYER_DISCONNECTED;
+	if(NULL != pClient->networkStack.isConnected) {
+		rc = pClient->networkStack.isConnected(&(pClient->networkStack));
+	}
+
+	if(NETWORK_PHYSICAL_LAYER_CONNECTED == rc) 
+	{
+		rc = arms_mqtt_reconnect(pClient);
+		if(NETWORK_RECONNECTED == rc) 
+		{
+			rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_IDLE,
+											   CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS);
+			if(SUCCESS != rc) 
+			{
+				ARMS_LOG_FUNC_EXIT_RC(rc);
+			}
+			ARMS_LOG_FUNC_EXIT_RC(NETWORK_RECONNECTED);
+		}
+	}
+
+	pClient->clientData.currentReconnectWaitInterval *= 2;
+
+	if(ARMS_MQTT_MAX_RECONNECT_WAIT_INTERVAL < pClient->clientData.currentReconnectWaitInterval) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_RECONNECT_TIMED_OUT_ERROR);
+	}
+	arms_mqtt_api_timer_countdown_ms(&(pClient->reconnectDelayTimer), pClient->clientData.currentReconnectWaitInterval);
+	ARMS_LOG_FUNC_EXIT_RC(rc);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_yield_keep_alive(ARMS_MQTT_Client *pClient) 
+{
+	ARMS_MQTT_ERROR_T rc = SUCCESS;
+	Timer timer;
+	size_t serialized_len;
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	if(NULL == pClient) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	if(0 == pClient->clientData.keepAliveInterval) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+	}
+
+	if(!arms_mqtt_api_timer_expired(&pClient->pingTimer)) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+	}
+
+	if(pClient->clientStatus.isPingOutstanding) 
+	{
+		rc = arms_mqtt_yield_handle_disconnect(pClient);
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* there is no ping outstanding - send one */
+	arms_mqtt_api_timer_init(&timer);
+
+	arms_mqtt_api_timer_countdown_ms(&timer, pClient->clientData.commandTimeoutMs);
+	serialized_len = 0;
+	rc = arms_mqtt_internal_serialize_zero(pClient->clientData.writeBuf, pClient->clientData.writeBufSize,
+											  PINGREQ, &serialized_len);
+	if(SUCCESS != rc) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	/* send the ping packet */
+	rc = arms_mqtt_internal_send_packet(pClient, serialized_len, &timer);
+	if(SUCCESS != rc) 
+	{
+		//If sending a PING fails we can no longer determine if we are connected.  In this case we decide we are disconnected and begin reconnection attempts
+		rc = arms_mqtt_yield_handle_disconnect(pClient);
+		ARMS_LOG_FUNC_EXIT_RC(rc);
+	}
+
+	pClient->clientStatus.isPingOutstanding = true;
+	/* start a timer to wait for PINGRESP from server */
+	//arms_mqtt_api_timercountdown_sec(&pClient->pingTimer, pClient->clientData.keepAliveInterval);
+	arms_mqtt_api_timercountdown_sec(&pClient->pingTimer, ((ARMS_MQTT_PING_TIMEOUT < pClient->clientData.keepAliveInterval) ? ARMS_MQTT_PING_TIMEOUT : pClient->clientData.keepAliveInterval));
+
+	ARMS_LOG_FUNC_EXIT_RC(SUCCESS);
+}
+
+static ARMS_MQTT_ERROR_T arms_mqtt_yield_entry(ARMS_MQTT_Client *pClient, uint32_t timeout_ms) 
+{
+	ARMS_MQTT_ERROR_T yieldRc = SUCCESS;
+
+	uint8_t packet_type;
+	ClientState clientState;
+	Timer timer;
+	arms_mqtt_api_timer_init(&timer);
+	arms_mqtt_api_timer_countdown_ms(&timer, timeout_ms);
+
+	ARMS_LOG_FUNC_ENTRY;
+
+	// evaluate timeout at the end of the loop to make sure the actual yield runs at least once
+	do 
+	{
+		clientState = arms_mqtt_get_client_state(pClient);
+		if(CLIENT_STATE_PENDING_RECONNECT == clientState) 
+		{
+			if(ARMS_MQTT_MAX_RECONNECT_WAIT_INTERVAL < pClient->clientData.currentReconnectWaitInterval) 
+			{
+				yieldRc = NETWORK_RECONNECT_TIMED_OUT_ERROR;
+				break;
+			}
+			yieldRc = arms_mqtt_yield_handle_reconnect(pClient);
+			/* Network reconnect attempted, check if yield timer expired before
+			 * doing anything else */
+			continue;
+		}
+
+		yieldRc = arms_mqtt_internal_cycle_read(pClient, &timer, &packet_type);
+		if(SUCCESS == yieldRc) 
+		{
+			yieldRc = arms_mqtt_yield_keep_alive(pClient);
+		} 
+		else 
+		{
+			// SSL read and write errors are terminal, connection must be closed and retried
+			if(NETWORK_SSL_READ_ERROR == yieldRc || NETWORK_SSL_WRITE_ERROR == yieldRc || NETWORK_SSL_WRITE_TIMEOUT_ERROR == yieldRc) 
+			{
+				yieldRc = arms_mqtt_yield_handle_disconnect(pClient);
+			}
+		}
+
+		if(NETWORK_DISCONNECTED_ERROR == yieldRc) 
+		{
+			pClient->clientData.counterNetworkDisconnected++;
+			if(1 == pClient->clientStatus.isAutoReconnectEnabled) 
+			{
+				yieldRc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_DISCONNECTED_ERROR,
+														CLIENT_STATE_PENDING_RECONNECT);
+				if(SUCCESS != yieldRc) 
+				{
+					ARMS_LOG_FUNC_EXIT_RC(yieldRc);
+				}
+
+				pClient->clientData.currentReconnectWaitInterval = ARMS_MQTT_MIN_RECONNECT_WAIT_INTERVAL;
+				arms_mqtt_api_timer_countdown_ms(&(pClient->reconnectDelayTimer), pClient->clientData.currentReconnectWaitInterval);
+				/* Depending on timer values, it is possible that yield timer has expired
+				 * Set to rc to attempting reconnect to inform client that autoreconnect
+				 * attempt has started */
+				yieldRc = NETWORK_ATTEMPTING_RECONNECT;
+			} 
+			else 
+			{
+				break;
+			}
+		} 
+		else if(SUCCESS != yieldRc) 
+		{
+			break;
+		}
+	} while(!arms_mqtt_api_timer_expired(&timer));
+
+	ARMS_LOG_FUNC_EXIT_RC(yieldRc);
+}
+
+ARMS_MQTT_ERROR_T arms_mqtt_yield(ARMS_MQTT_Client *pClient, uint32_t timeout_ms) 
+{
+	ARMS_MQTT_ERROR_T rc, yieldRc;
+	ClientState clientState;
+
+	if(NULL == pClient || 0 == timeout_ms) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NULL_VALUE_ERROR);
+	}
+
+	clientState = arms_mqtt_get_client_state(pClient);
+	/* Check if network was manually disconnected */
+	if(CLIENT_STATE_DISCONNECTED_MANUALLY == clientState) 
+	{
+		ARMS_LOG_FUNC_EXIT_RC(NETWORK_MANUALLY_DISCONNECTED);
+	}
+
+	/* If we are in the pending reconnect state, skip other checks.
+	 * Pending reconnect state is only set when auto-reconnect is enabled */
+	if(CLIENT_STATE_PENDING_RECONNECT != clientState) 
+	{
+		/* Check if network is disconnected and auto-reconnect is not enabled */
+		if(!arms_mqtt_is_client_connected(pClient)) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(NETWORK_DISCONNECTED_ERROR);
+		}
+
+		/* Check if client is idle, if not another operation is in progress and we should return */
+		if(CLIENT_STATE_CONNECTED_IDLE != clientState) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(MQTT_CLIENT_NOT_IDLE_ERROR);
+		}
+
+		rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_IDLE,
+										   CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS);
+		if(SUCCESS != rc) 
+		{
+			ARMS_LOG_FUNC_EXIT_RC(rc);
+		}
+	}
+
+	yieldRc = arms_mqtt_yield_entry(pClient, timeout_ms);
+
+	if(NETWORK_DISCONNECTED_ERROR != yieldRc && NETWORK_ATTEMPTING_RECONNECT != yieldRc) 
+	{
+		rc = arms_mqtt_set_client_state(pClient, CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS,
+										   CLIENT_STATE_CONNECTED_IDLE);
+		if(SUCCESS == yieldRc && SUCCESS != rc) 
+		{
+			yieldRc = rc;
+		}
+	}
+
+	ARMS_LOG_FUNC_EXIT_RC(yieldRc);
+}
+
diff --git a/lynq/S300/ap/app/apparms/sock/Makefile b/lynq/S300/ap/app/apparms/sock/Makefile
new file mode 100755
index 0000000..07267dd
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/Makefile
@@ -0,0 +1,26 @@
+
+UDP_STATIC_LIB = libapparmsudp.a
+UDP_LIB_OBJS = apparms_sock_udp.o apparms_sock_intf.o
+
+TCP_STATIC_LIB = libapparmstcp.a
+TCP_LIB_OBJS = apparms_sock_tcp.o apparms_sock_intf.o
+
+UNIX_STATIC_LIB = libapparmsunix.a
+UNIX_LIB_OBJS = apparms_sock_unix.o apparms_sock_intf.o
+
+#SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g -I../ -I../log
+
+all: $(UDP_STATIC_LIB) $(TCP_STATIC_LIB) $(UNIX_STATIC_LIB)
+
+$(UDP_STATIC_LIB): $(UDP_LIB_OBJS)
+	$(AR) cr $@ $^
+
+$(TCP_STATIC_LIB): $(TCP_LIB_OBJS)
+	$(AR) cr $@ $^
+
+$(UNIX_STATIC_LIB): $(UNIX_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(TCP_STATIC_LIB) $(UDP_STATIC_LIB) $(UNIX_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.c b/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.c
new file mode 100755
index 0000000..e0f2ce4
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.c
@@ -0,0 +1,203 @@
+
+#include "apparms_sock_intf.h"
+#include "apparms_log.h"
+
+/*
+ * Set the socket blocking or non-blocking
+ */
+int arms_sock_intf_set_block( int sockfd )
+{
+    return( fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL ) & ~O_NONBLOCK ) );
+}
+
+int arms_sock_intf_set_nonblock( int sockfd )
+{
+    return( fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL ) | O_NONBLOCK ) );
+}
+
+void arms_sock_intf_close(int *pFd)
+{
+	if (pFd == NULL)
+		return;
+	
+	ARMS_LOG_DEBUG(" %s(%d) fd = %d closed \n",__FUNCTION__,__LINE__, *pFd);				
+	
+	if (-1 != *pFd)
+	{		
+		close(*pFd);
+		*pFd = -1;
+	}
+}
+
+int arms_sock_intf_send(int sockfd, const char* buffer, int buflen)
+{
+	int tmp, nAgainCnt = 0;
+	int total = buflen;
+	const char *p = buffer;
+	int en;
+
+	ARMS_LOG_DEBUG(" %s(%d) sockfd=%d\n",__FUNCTION__,__LINE__, sockfd);
+
+	if ((sockfd < 0) ||( buffer == NULL) || (buflen <= 0))
+	{
+		ARMS_LOG_ERROR(" %s(%d) invalid parameter fd=%d, buflen=%d\n",__FUNCTION__,__LINE__, sockfd, buflen);
+		return 0;
+	}
+
+	while(1)
+	{
+	        tmp = send(sockfd, p, total, 0);
+			en = errno;
+			ARMS_LOG_DEBUG(" %s(%d) send return=%d, error=%d\n",__FUNCTION__,__LINE__, tmp, en);
+
+	        if(tmp < 0)
+	        {
+	                if(en == EINTR)
+	                {
+	                        usleep(1000);
+	                        ARMS_LOG_DEBUG(" %s(%d) send is EINTR\n",__FUNCTION__,__LINE__);
+	                        continue;
+	                }
+
+	                if ((EAGAIN == en) || (EWOULDBLOCK == en))
+	                {
+							/*try maxinum 30 seconds*/
+							if ((nAgainCnt++) > 1000)
+								return -2;
+			
+	                        usleep(10000);
+	                        continue;
+	                }
+
+	                ARMS_LOG_ERROR(" %s(%d) sockfd = %d, socket errno=[%d]\n",__FUNCTION__,__LINE__, sockfd, en);
+	                return -1;
+	        }	
+	        
+	        if(tmp >= total)
+	        {
+	                return buflen;
+	        }
+
+	        total -= tmp;
+	        p += tmp;
+
+	nAgainCnt = 0;
+	}
+
+	ARMS_LOG_DEBUG(" %s(%d) send finish with successful\n",__FUNCTION__,__LINE__);
+
+	return buflen;
+}
+
+int arms_sock_intf_poll(int nFd, unsigned int Timeout)
+{
+	int ret, nCount = 1;
+	struct pollfd fds;
+
+	memset(&fds, 0, sizeof(struct pollfd));
+	fds.fd = nFd;
+	fds.events = POLLIN;
+	fds.revents =  0;
+
+	while (nCount > 0)
+	{
+		fds.revents = 0;
+		ret = poll(&fds, 1, Timeout);
+		
+		if (ret < 0)
+		{
+			int nErrno = errno;
+			if (nErrno == EINTR)
+				continue;
+			
+			ARMS_LOG_ERROR(" %s(%d) fd=%d is PollSocketData nErrno=%d. \n",__FUNCTION__,__LINE__, nFd, nErrno);
+			return -1;
+		}
+		else if(ret == 0)
+		{
+			//ARMS_LOG_DEBUG(" %s(%d) PollSocketData nFd=%d, timeoutcount=%d. \n",__FUNCTION__,__LINE__, nFd, nCount);
+			nCount--;
+		}
+		else
+		{		
+			ARMS_LOG_DEBUG(" %s(%d) PollSocketData fd=%d evntcomes=%d. \n",__FUNCTION__,__LINE__, nFd, fds.revents);
+			
+			if(fds.revents & POLLIN)
+			{
+				break;
+			}
+		}
+	}
+
+	return ret;
+}
+
+int arms_sock_intf_recv(int sockfd, char*puffer, int* buflen)
+{
+	int nRet, nBufPos = 0, nLefBufLen, nTotalBuf;
+	int en;
+	int nLoglen = *buflen;
+	
+	if ((puffer == NULL) || (buflen == NULL))
+	{
+		ARMS_LOG_ERROR(" %s(%d) invalid parameters 1\n",__FUNCTION__,__LINE__);
+		return 0;
+	}
+
+	if ((sockfd < 0) || (*buflen <= 0))
+	{
+		ARMS_LOG_ERROR(" %s(%d).  invalid parameters sockfd=%d,buflen=%d\n",__FUNCTION__,__LINE__, sockfd, *buflen);
+		return 0;
+	}
+	
+	ARMS_LOG_DEBUG(" %s(%d) fd=%d\n",__FUNCTION__,__LINE__, sockfd);	
+
+	//fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL ) | O_NONBLOCK );
+
+	nTotalBuf = *buflen;
+	*buflen = 0;
+	do
+	{
+		nLefBufLen = nTotalBuf - nBufPos;
+
+		/*Buffer is not enough*/
+		if (nLefBufLen <= 0)
+			return 2;
+
+		nRet = recv(sockfd, puffer + nBufPos, nLefBufLen, 0);
+		en = errno;
+		
+		ARMS_LOG_DEBUG(" %s(%d) recv return=%d, error=%d\n",__FUNCTION__,__LINE__, nRet, en);	
+		
+		if (nRet == 0)
+		{			
+			ARMS_LOG_ERROR(" %s(%d) socket sockfd=%d closed by peer\n",__FUNCTION__,__LINE__, sockfd);
+			return -1;
+		}
+		else if (nRet < 0)
+		{
+			if (EINTR == en)
+			{
+				continue;
+			}
+			else if ((EAGAIN == en) || (EWOULDBLOCK == en))
+			{
+				break;
+			}			
+			ARMS_LOG_ERROR(" %s(%d) ###*******#########sockfd=%d, socket err=[%d]\n",__FUNCTION__,__LINE__, sockfd, en);
+			return -2;
+		}
+		else
+		{
+			nBufPos += nRet;
+			*buflen = nBufPos;
+		}
+	}while(1);
+
+	if(nLoglen > 256)
+        nLoglen = 256;
+
+	ARMS_LOG_DEBUG(" %s(%d) recv finish with successful\n",__FUNCTION__,__LINE__);
+
+	return 1;
+}
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.h b/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.h
new file mode 100755
index 0000000..542f0f1
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_intf.h
@@ -0,0 +1,53 @@
+#ifndef _APPARMS_SOCK_INTF_H
+#define _APPARMS_SOCK_INTF_H
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <termios.h> 
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sys/poll.h> 
+#include <stdlib.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+
+#define arms_sock_intf_set_buffer(sockfd, send, recv)  do{  \
+	int nRecvBuf=recv; \
+	int nSendBuf=send; \
+	setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,(const char*)&nSendBuf,sizeof(int));  \
+	setsockopt(sockfd,SOL_SOCKET,SO_RCVBUF,(const char*)&nRecvBuf,sizeof(int));  \
+} while(0)
+
+int arms_sock_intf_set_block( int sockfd );
+int arms_sock_intf_set_nonblock( int sockfd );
+void arms_sock_intf_close(int *pFd);
+int arms_sock_intf_send(int sockfd, const char* buffer, int buflen);
+int arms_sock_intf_poll(int nFd, unsigned int Timeout);
+int arms_sock_intf_recv(int sockfd, char*puffer, int* buflen);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.c b/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.c
new file mode 100755
index 0000000..7c5f223
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.c
@@ -0,0 +1,83 @@
+
+#include "apparms_sock_tcp.h"
+#include "apparms_log.h"
+
+int arms_sock_tcp_open(int* pFd, char *server, char *port)
+{
+	int ret;
+	struct addrinfo hints, *addr_list, *cur;
+	unsigned int value = 0x1;
+	
+	/* Do name resolution with both IPv6 and IPv4 */
+	memset( &hints, 0, sizeof( hints ) );
+	hints.ai_family = AF_UNSPEC;
+	hints.ai_socktype = SOCK_STREAM;
+	hints.ai_protocol = IPPROTO_TCP;
+	
+	if( getaddrinfo( server, port, &hints, &addr_list ) != 0 )
+		return -1;
+	
+	/* Try the sockaddrs until a connection succeeds */
+	ret = -2;
+	for( cur = addr_list; cur != NULL; cur = cur->ai_next )
+	{
+		*pFd = (int) socket( cur->ai_family, cur->ai_socktype,
+					cur->ai_protocol );
+		if(*pFd < 0 )
+		{
+			ret = -3;
+			continue;
+		}
+	
+		if( connect( *pFd, cur->ai_addr, cur->ai_addrlen ) == 0 )
+		{
+			ret = 0;
+			break;
+		}
+	
+		arms_sock_tcp_close( pFd );
+		ret = -4;
+	}
+	
+	freeaddrinfo( addr_list );
+
+	if (fcntl(*pFd, F_SETFL, fcntl(*pFd, F_GETFD, 0) |O_NONBLOCK) == -1) 
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"Set NON BLock Error");
+		ret = -5;
+	}
+	
+	setsockopt(*pFd,SOL_SOCKET,SO_REUSEADDR,(void *)&value,sizeof(value));
+
+	return (ret == 0 ? *pFd : ret);
+}
+
+int arms_sock_tcp_set_block( int sockfd )
+{
+	return arms_sock_intf_set_block(sockfd);
+}
+
+int arms_sock_tcp_set_nonblock( int sockfd )
+{
+	return arms_sock_intf_set_nonblock(sockfd);
+}
+
+void arms_sock_tcp_close(int *pFd)
+{
+	return arms_sock_intf_close(pFd);
+}
+
+int arms_sock_tcp_send(int sockfd, const char* buffer, int buflen)
+{
+	return arms_sock_intf_send(sockfd, buffer, buflen);
+}
+
+int arms_sock_tcp_poll(int nFd, unsigned int Timeout)
+{
+	return arms_sock_intf_poll(nFd, Timeout);
+}
+
+int arms_sock_tcp_recv(int sockfd, char*puffer, int* buflen)
+{
+	return arms_sock_intf_recv(sockfd, puffer, buflen);
+}
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.h b/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.h
new file mode 100755
index 0000000..641e43a
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_tcp.h
@@ -0,0 +1,14 @@
+#ifndef _APPARMS_SOCK_TCP_H
+#define _APPARMS_SOCK_TCP_H
+
+#include "apparms_sock_intf.h"
+
+int arms_sock_tcp_open(int* pFd, char *server, char *port);
+void arms_sock_tcp_close(int *pFd);
+int arms_sock_tcp_send(int sockfd, const char* buffer, int buflen);
+int arms_sock_tcp_poll(int nFd, unsigned int Timeout);
+int arms_sock_tcp_recv(int sockfd, char*puffer, int* buflen);
+int arms_sock_tcp_set_block( int sockfd );
+int arms_sock_tcp_set_nonblock( int sockfd );
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.c b/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.c
new file mode 100755
index 0000000..3beb368
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.c
@@ -0,0 +1,246 @@
+
+#include "apparms_sock_udp.h"
+#include "apparms_log.h"
+
+int arms_sock_udp_open_s(int* pFd, char *server, int nPort)
+{
+	int ret;
+	struct addrinfo hints, *addr_list, *cur;
+	char port[8] = {0};
+	
+	/* Do name resolution with both IPv6 and IPv4 */
+	memset( &hints, 0, sizeof( hints ) );
+	hints.ai_family = AF_UNSPEC;
+	hints.ai_socktype = SOCK_DGRAM;
+	hints.ai_protocol = IPPROTO_UDP;
+
+	sprintf(port,"%d",nPort);
+	if( getaddrinfo( server, port, &hints, &addr_list ) != 0 )
+		return -1;
+	
+	/* Try the sockaddrs until a connection succeeds */
+	ret = -2;
+	for( cur = addr_list; cur != NULL; cur = cur->ai_next )
+	{
+		*pFd = (int) socket( cur->ai_family, cur->ai_socktype,
+					cur->ai_protocol );
+		if(*pFd < 0 )
+		{
+			ret = -3;
+			continue;
+		}
+	
+		if( connect( *pFd, cur->ai_addr, cur->ai_addrlen ) == 0 )
+		{
+			ret = 0;
+			break;
+		}
+	
+		arms_sock_udp_close( pFd );
+		ret = -4;
+	}
+	
+	freeaddrinfo( addr_list );
+
+	if (fcntl(*pFd, F_SETFL, fcntl(*pFd, F_GETFD, 0) |O_NONBLOCK) == -1) 
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"Set NON BLock Error");
+		ret = -5;
+	}
+
+	return (ret == 0 ? *pFd : ret);
+}
+
+int arms_sock_udp_open(int* pFd)
+{
+	int local_fd = -1; 
+	unsigned int value = 0x1;
+
+	if (pFd == NULL)
+		return -1;
+
+	if((local_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"socket error");
+		return -2;
+	}
+	
+	ARMS_LOG_DEBUG(" %s(%d) create local_fd=%d successful\n",__FUNCTION__,__LINE__, local_fd);
+
+	if (fcntl(local_fd, F_SETFL, fcntl(local_fd, F_GETFD, 0) |O_NONBLOCK) == -1) 
+	{
+		ARMS_LOG_ERROR(" %s(%d) %s\n",__FUNCTION__,__LINE__,"Set NON BLock Error");
+		goto ERR_EXIT;
+	}
+	
+	setsockopt(local_fd,SOL_SOCKET,SO_REUSEADDR,(void *)&value,sizeof(value)); 	
+
+	*pFd = local_fd;
+	
+	return local_fd;
+		
+ERR_EXIT:
+	arms_sock_udp_close(&local_fd);
+	
+	return -3;
+}
+
+int arms_sock_udp_sendto(int sockfd, char* pSrvAddr, int nPort, const char* buffer, int buflen)
+{
+	int tmp, nAgainCnt = 0;
+	int total = buflen;
+	const char *p = buffer;
+	int en;
+	struct sockaddr_in  serverAddr;    /* server's socket address          */
+	int sockAddrSize;  /* size of socket address structure */
+	
+	ARMS_LOG_DEBUG( " %s(%d) sockfd=%d\n",__FUNCTION__,__LINE__, sockfd);
+		
+	if ((sockfd < 0) ||( buffer == NULL) || (buflen <= 0) || pSrvAddr == NULL)
+	{
+		ARMS_LOG_ERROR(" %s(%d) invalid parameter fd=%d, buflen=%d\n",__FUNCTION__,__LINE__, sockfd, buflen);
+		return 0;
+	}
+
+	sockAddrSize = sizeof (struct sockaddr_in);
+	bzero((char *)&serverAddr, sockAddrSize);
+	serverAddr.sin_family      = AF_INET;
+	serverAddr.sin_addr.s_addr = inet_addr(pSrvAddr);
+	serverAddr.sin_port = htons(nPort);
+
+	while(1)
+	{
+		tmp = sendto(sockfd, p, total, 0,(struct sockaddr *)&serverAddr, sockAddrSize);
+		en = errno;
+		ARMS_LOG_DEBUG("%s(%d) send return=%d, error=%d\n",__FUNCTION__,__LINE__, tmp, en);
+
+		if(tmp < 0)
+		{
+			if(en == EINTR)
+			{
+			    usleep(1000);
+			    ARMS_LOG_DEBUG("%s(%d) send is EINTR\n",__FUNCTION__,__LINE__);
+			    continue;
+			}
+
+			if ((EAGAIN == en) || (EWOULDBLOCK == en))
+			{
+				/*try maxinum 30 seconds*/
+				if ((nAgainCnt++) > 1000)
+				return -2;
+
+			    usleep(10000);
+			    continue;
+			}
+
+			ARMS_LOG_ERROR(" %s(%d) sockfd = %d, socket errno=[%d]\n",__FUNCTION__,__LINE__, sockfd, en);
+			return -1;
+		}	
+
+		if(tmp >= total)
+		{
+			return buflen;
+		}
+
+		total -= tmp;
+		p += tmp;
+
+		nAgainCnt = 0;
+	}
+
+	ARMS_LOG_DEBUG(" %s(%d) send finish with successful\n",__FUNCTION__,__LINE__);
+	return buflen;
+}
+
+int arms_sock_udp_recvfrom(int sockfd, char* pSrvAddr, int nPort, char*puffer, int* buflen)
+{
+	int nRet, nBufPos = 0, nLefBufLen, nTotalBuf;
+	int en;
+	struct sockaddr_in  serverAddr;    /* server's socket address          */
+	int sockAddrSize;  /* size of socket address structure */
+	
+	if ((puffer == NULL) || (buflen == NULL) || pSrvAddr == NULL)
+	{
+		ARMS_LOG_ERROR("%s(%d) invalid parameters\n",__FUNCTION__,__LINE__);
+		return 0;
+	}
+
+	if ((sockfd < 0) || (*buflen <= 0))
+	{
+		ARMS_LOG_ERROR("%s(%d).  invalid parameters sockfd=%d,buflen=%d\n",__FUNCTION__,__LINE__, sockfd, *buflen);
+		return 0;
+	}
+	
+	ARMS_LOG_DEBUG(" %s(%d) fd=%d\n",__FUNCTION__,__LINE__, sockfd);
+
+	sockAddrSize = sizeof (struct sockaddr_in);
+	bzero((char *)&serverAddr, sockAddrSize);
+	serverAddr.sin_family      = AF_INET;
+	serverAddr.sin_addr.s_addr = inet_addr(pSrvAddr);
+	serverAddr.sin_port = htons(nPort);
+
+	nTotalBuf = *buflen;
+	*buflen = 0;
+	do
+	{
+		nLefBufLen = nTotalBuf - nBufPos;
+
+		/*Buffer is not enough*/
+		if (nLefBufLen <= 0)
+			return 2;
+
+		nRet = recvfrom(sockfd, puffer + nBufPos, nLefBufLen, 0, (struct sockaddr *)&serverAddr, (socklen_t *)&sockAddrSize);
+		en = errno;
+		
+		ARMS_LOG_DEBUG("%s(%d) recv return=%d, error=%d\n",__FUNCTION__,__LINE__, nRet, en);	
+		
+		if (nRet == 0)
+		{			
+			ARMS_LOG_ERROR(" %s(%d) socket sockfd=%d closed by peer\n",__FUNCTION__,__LINE__, sockfd);
+			return -1;
+		}
+		else if (nRet < 0)
+		{
+			if (EINTR == en)
+			{
+				continue;
+			}
+			else if ((EAGAIN == en) || (EWOULDBLOCK == en))
+			{
+				break;
+			}			
+			ARMS_LOG_ERROR(" %s(%d) ###*******#########sockfd=%d, socket err=[%d]\n",__FUNCTION__,__LINE__, sockfd, en);
+			return -2;
+		}
+		else
+		{
+			nBufPos += nRet;
+			*buflen = nBufPos;
+		}
+	}while(1);
+
+	ARMS_LOG_DEBUG("%s(%d) recv finish with successful\n",__FUNCTION__,__LINE__);
+	return 1;
+}
+
+
+void arms_sock_udp_close(int *pFd)
+{
+	arms_sock_intf_close(pFd);
+}
+
+int arms_sock_udp_poll(int sockfd, unsigned int Timeout)
+{
+	return arms_sock_intf_poll(sockfd, Timeout);
+}
+
+int arms_sock_udp_send(int sockfd, const char* buffer, int buflen)
+{
+	return arms_sock_intf_send(sockfd, buffer, buflen);
+}
+
+int arms_sock_udp_recv(int sockfd, char*puffer, int* buflen)
+{
+	return arms_sock_intf_recv(sockfd, puffer, buflen);
+}
+
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.h b/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.h
new file mode 100755
index 0000000..dbbb150
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_udp.h
@@ -0,0 +1,16 @@
+#ifndef _APPARMS_SOCK_UDP_H
+#define _APPARMS_SOCK_UDP_H
+
+#include "apparms_sock_intf.h"
+
+int arms_sock_udp_open(int* pFd);
+int arms_sock_udp_open_s(int* pFd, char *server, int nPort);
+int arms_sock_udp_sendto(int sockfd, char* pSrvAddr, int nPort, const char* buffer, int buflen);
+int arms_sock_udp_recvfrom(int sockfd, char* pSrvAddr, int nPort, char*puffer, int* buflen);
+
+void arms_sock_udp_close(int *pFd);
+int arms_sock_udp_poll(int sockfd, unsigned int Timeout);
+int arms_sock_udp_send(int sockfd, const char* buffer, int buflen);
+int arms_sock_udp_recv(int sockfd, char*puffer, int* buflen);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.c b/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.c
new file mode 100755
index 0000000..042f88b
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.c
@@ -0,0 +1,70 @@
+
+#include "apparms_sock_unix.h"
+#include "apparms_log.h"
+
+int arms_sock_unix_open(int* pFd, char *sockPath)
+{
+	int nErroNo = 0, sock_type = SOCK_STREAM;
+	socklen_t addr_len;
+	struct sockaddr_un	sockaddr;
+
+	if ((pFd == NULL) || (sockPath == NULL))
+		return -1;
+
+	addr_len = sizeof(sockaddr);
+	memset(&sockaddr, 0, addr_len);
+	strcpy(sockaddr.sun_path, sockPath);
+	sockaddr.sun_family = AF_UNIX;
+	*pFd = socket(AF_UNIX, sock_type, 0);
+	
+	if (-1 == *pFd)
+	{
+		ARMS_LOG_ERROR(" %s(%d) create sock on ch_index=%s failed\n",__FUNCTION__,__LINE__, sockPath);
+		return -3;
+	}
+
+	if (arms_sock_intf_set_nonblock(*pFd) == -1)
+	{
+		nErroNo = -4;
+		ARMS_LOG_ERROR (" %s(%d) fd=%d set nonblock failed errno=%d\n",__FUNCTION__,__LINE__, *pFd, nErroNo);
+	}
+
+	arms_sock_intf_set_buffer(*pFd, 32000, 32000);
+	if (-1 == connect(*pFd, (struct sockaddr *)&sockaddr, addr_len))
+	{
+		nErroNo = -5;
+		ARMS_LOG_ERROR(" %s(%d) connect to server sockPath failed=%s\n",__FUNCTION__,__LINE__, sockPath);				
+	}
+
+	if (nErroNo != 0)
+	{
+		arms_sock_intf_close(pFd);
+		return nErroNo;
+	}
+	
+	ARMS_LOG_INFO(" %s(%d) connect to server sockPath success=%s\n",__FUNCTION__,__LINE__, sockPath);
+
+	return *pFd;
+}	
+
+
+void arms_sock_unix_close(int *pFd)
+{
+	return arms_sock_intf_close(pFd);
+}
+
+int arms_sock_unix_send(int sockfd, const char* buffer, int buflen)
+{
+	return arms_sock_intf_send(sockfd, buffer, buflen);
+}
+
+int arms_sock_unix_poll(int nFd, unsigned int Timeout)
+{
+	return arms_sock_intf_poll(nFd, Timeout);
+}
+
+int arms_sock_unix_recv(int sockfd, char*puffer, int* buflen)
+{
+	return arms_sock_intf_recv(sockfd, puffer, buflen);
+}
+
diff --git a/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.h b/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.h
new file mode 100755
index 0000000..92ac403
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/sock/apparms_sock_unix.h
@@ -0,0 +1,12 @@
+#ifndef _APPARMS_SOCK_UNIX_H
+#define _APPARMS_SOCK_UNIX_H
+
+#include "apparms_sock_intf.h"
+
+int arms_sock_unix_open(int* pFd, char *sockPath);
+void arms_sock_unix_close(int *pFd);
+int arms_sock_unix_send(int sockfd, const char* buffer, int buflen);
+int arms_sock_unix_poll(int nFd, unsigned int Timeout);
+int arms_sock_unix_recv(int sockfd, char*puffer, int* buflen);
+
+#endif
diff --git a/lynq/S300/ap/app/apparms/test.txt b/lynq/S300/ap/app/apparms/test.txt
new file mode 100755
index 0000000..0539ab7
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/test.txt
@@ -0,0 +1,12 @@
+
+test procedure:
+1.start rpc handle
+./apprpctest
+
+2. start apparms with memeory check
+valgrind --tool=memcheck --leak-check=full --log-file=./log.txt  ./apparms
+
+3. push message from ARMS
+
+4. start direction connection test 
+socat tcp-connect:127.0.0.1:5588 stdio
diff --git a/lynq/S300/ap/app/apparms/util/Makefile b/lynq/S300/ap/app/apparms/util/Makefile
new file mode 100755
index 0000000..3685096
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/util/Makefile
@@ -0,0 +1,14 @@
+
+LOG_STATIC_LIB = libapparmsutil.a
+LOG_LIB_OBJS = apparms_util.o
+
+SRCS = $(wildcard *.c)
+CFLAGS += -Wall -Werror -g
+
+all: $(LOG_STATIC_LIB)
+
+$(LOG_STATIC_LIB): $(LOG_LIB_OBJS)
+	$(AR) cr $@ $^
+	
+clean: 
+	-rm -f $(LOG_STATIC_LIB) *.elf *.gdb *.o *.i *.s
diff --git a/lynq/S300/ap/app/apparms/util/apparms_util.c b/lynq/S300/ap/app/apparms/util/apparms_util.c
new file mode 100755
index 0000000..9a3a520
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/util/apparms_util.c
@@ -0,0 +1,236 @@
+
+#include"apparms_util.h"
+
+int arms_util_open_file(char* pLogPath)
+{
+	if ((pLogPath == NULL) || (strlen(pLogPath) <= 0))
+		return -1;
+
+	return open(pLogPath, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
+}
+
+void arms_util_close_file(int *pFd)
+{
+	if (pFd == NULL)
+		return;
+
+	if (*pFd != -1)
+	{
+		close(*pFd);	
+		*pFd = -1;
+	}
+}
+
+int  arms_util_convert_hex_value(unsigned char cSrc, unsigned char* cDest)
+{
+    if (NULL == cDest)
+        return 0;
+
+    if (cSrc >= '0' && cSrc <= '9')
+    {
+        *cDest = cSrc - 0x30;
+    }
+    else if (cSrc >= 'a' && cSrc <= 'f')
+    {
+        *cDest = cSrc - 0x57;
+    }
+    else if (cSrc >= 'A' && cSrc <= 'F')
+    {
+        *cDest = cSrc - 0x37;
+    }
+    else
+        return 0;
+    return 1;
+}
+
+
+int arms_util_convert_hexchar_value(unsigned char* cSrc, unsigned char* cDest)
+{
+    unsigned char cTmp1 = 0;
+    unsigned char cTmp2 = 0;
+
+    if (NULL == cSrc || NULL == cDest)
+        return 0;
+
+    if ((0 == arms_util_convert_hex_value(cSrc[0], &cTmp1)) || (0 == arms_util_convert_hex_value(cSrc[1], &cTmp2)))
+        return 0;
+    *cDest = cTmp1 * 16 + cTmp2;
+    return 1;
+}
+
+int arms_util_convert_hexstr_value(unsigned char* pSrc, unsigned char* pDest, int nLen)
+{
+    int index = 0;
+    unsigned char cTmp = 0;
+
+    if (NULL == pSrc || NULL == pDest)
+        return 0;
+
+    for (index = 0; index < (nLen / 2); index++)
+    {
+        if (0 == arms_util_convert_hexchar_value(pSrc + (index * 2), &cTmp))
+            return 0;
+		
+        pDest[index] = cTmp;
+    }
+
+    return 1;
+}
+
+int arms_util_convert_halfbyte2Str(int nLen, char* pSrc, char* pDest)
+{
+    unsigned char c = 0;
+    int i = 0;
+
+    for (i = 0; i < nLen; i++)
+    {
+        c = (pSrc[i] >> 4) & 0x0F;
+        pDest[2 * i] = c + ((c < 0x0A) ? '0' : ('A' - 0x0A));
+        c = pSrc[i] & 0x0F;
+        pDest[2 * i + 1] = c + ((c < 0x0A) ? '0' : ('A' - 0x0A));
+    }
+
+    return nLen;
+}
+
+int arms_util_create_timer_msec(timer_t *timerid, void (*timer_cb)(int signo), int mdelay, int re_mdelay, int signum)
+{
+	struct sigaction act;
+	memset(&act, 0, sizeof(struct sigaction));
+	act.sa_handler = timer_cb;
+	act.sa_flags = 0;
+	sigemptyset(&act.sa_mask);
+	if(sigaction(signum,&act,NULL) == -1)
+	{
+		return 0;
+	}
+
+	struct sigevent evp;  
+	memset(&evp, 0, sizeof(struct sigevent));
+	evp.sigev_signo = signum;
+	evp.sigev_notify = SIGEV_SIGNAL;
+
+	if (timer_create(CLOCK_MONOTONIC, &evp, timerid) == -1)  
+	{  
+		return 0; 
+	}  
+
+	struct itimerspec it;  
+	it.it_interval.tv_sec = re_mdelay/1000;  
+	it.it_interval.tv_nsec = (re_mdelay%1000)*1000000;  
+	it.it_value.tv_sec = mdelay/1000;  
+	it.it_value.tv_nsec = (mdelay%1000)*1000000;  
+
+	if (timer_settime(*timerid, 0, &it, NULL) == -1)  
+	{  
+		return 0; 
+	}
+
+	return 1;
+}
+
+int arms_util_modify_timer_msec(timer_t *timerid, int mdelay, int re_mdelay)
+{	
+	struct itimerspec mod_it; 
+	mod_it.it_interval.tv_sec = re_mdelay/1000;  
+	mod_it.it_interval.tv_nsec = (re_mdelay%1000)*1000000;  
+	mod_it.it_value.tv_sec = mdelay/1000;  
+	mod_it.it_value.tv_nsec = (mdelay%1000)*1000000;
+
+	if (timerid == NULL)
+		return -1;
+
+	if (timer_settime(*timerid, 0, &mod_it, NULL) == -1)  
+	{  
+		return 0;  
+	}
+
+	return 1;
+}
+
+void arms_util_destroy_timer_msec(timer_t *timerid)
+{
+	if (timerid != NULL)
+		timer_delete(*timerid);
+}
+
+int arms_util_get_if_ip(char* pIF, char* pIPAddr)
+{
+	struct ifreq ifr;
+	int ret = -3, fd;
+
+	if ((pIF == NULL) || (pIPAddr == NULL))
+		return -1;
+
+	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+		return -2;
+
+	strncpy(ifr.ifr_name, pIF, IF_NAMESIZE-1);
+	if (ioctl(fd, SIOCGIFADDR, &ifr) >= 0)
+	{
+		strcpy(pIPAddr, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
+		ret = 0;
+	}
+
+	close(fd);
+	return ret;
+}
+
+int arms_util_readConfigValue(char* pFilePath, const char *str, char* outBuf)
+{
+	char buf[256] = {0};
+	char tmpbuf[128] = {0};
+	FILE *fp = NULL;
+	int bstatus = 0;
+	struct stat statbuf;
+
+	if(pFilePath == NULL || str == NULL || outBuf == NULL)
+		return 0;
+
+	if(stat(pFilePath,&statbuf)==0)
+	{
+		if(statbuf.st_size <= 0)
+		{
+			printf("********* %s(%d) [%s] not ready, size %ld, wait 0.1 sec###########\n",__FUNCTION__,__LINE__,pFilePath,statbuf.st_size);
+			usleep(100000);
+		}
+	}
+
+	fp = fopen(pFilePath, "r");
+
+	if (fp == NULL)
+	{
+		sleep(3);
+		fp = fopen(pFilePath, "r");
+	}
+	
+	if (fp != NULL)
+	{
+		while (fgets(buf, sizeof(buf), fp) != NULL) 
+		{
+			//INFO("buf:%s",buf);
+			memset(tmpbuf,0,128);
+			sscanf(buf, "%*[^:]: %[^\n]\n", tmpbuf);	
+			if(strstr(buf, str))
+			{
+				//INFO("tmpbuf:%s",tmpbuf);
+				if(strcmp(tmpbuf,"")==0 || strcmp(tmpbuf," ") == 0)
+				{
+					bstatus = 0;
+				}
+				else
+				{
+					strcpy(outBuf,tmpbuf);
+					bstatus = 1;
+				}
+				break;
+			}
+			memset(buf,0,256);
+		}
+		fclose(fp);
+	}
+	
+	return bstatus;
+}
+
+
diff --git a/lynq/S300/ap/app/apparms/util/apparms_util.h b/lynq/S300/ap/app/apparms/util/apparms_util.h
new file mode 100755
index 0000000..dce7549
--- /dev/null
+++ b/lynq/S300/ap/app/apparms/util/apparms_util.h
@@ -0,0 +1,59 @@
+
+#ifndef _APPARMS_UTIL
+#define _APPARMS_UTIL 1
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+//#include <syslog.h> 
+#include <termios.h> 
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sys/poll.h> 
+#include <stdlib.h>
+#include <sys/un.h>
+#include <time.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <semaphore.h>
+#include <errno.h>
+#include "../../include/cfg_api.h"
+
+int arms_util_open_file(char* pLogPath);
+void arms_util_close_file(int *pFd);
+
+int arms_util_convert_hex_value(unsigned char cSrc, unsigned char* cDest);
+int arms_util_convert_hexchar_value(unsigned char* cSrc, unsigned char* cDest);
+int arms_util_convert_hexstr_value(unsigned char* pSrc, unsigned char* pDest, int nLen);
+int arms_util_convert_halfbyte2Str(int nLen, char* pSrc, char* pDest);
+
+int arms_util_create_timer_msec(timer_t *timerid, void (*timer_cb)(int signo), int mdelay, int re_mdelay, int signum);
+int arms_util_modify_timer_msec(timer_t *timerid, int mdelay, int re_mdelay);
+void arms_util_destroy_timer_msec(timer_t *timerid);
+
+int arms_util_get_if_ip(char* pIF, char* pIPAddr);
+int arms_util_readConfigValue(char* pFilePath, const char *str, char* outBuf);
+
+
+#endif
diff --git a/lynq/S300AI/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin b/lynq/S300AI/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
index e675e3a..add9da2 100644
--- a/lynq/S300AI/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
+++ b/lynq/S300AI/allbins/zx297520v3/prj_cpe/nv_230a/Ref_nvrw_0x26C00.bin
Binary files differ
diff --git a/lynq/S300AI/ap/app/zte_webui/js/ext/set_realtek.js b/lynq/S300AI/ap/app/zte_webui/js/ext/set_realtek.js
index f22f4bd..f822155 100755
--- a/lynq/S300AI/ap/app/zte_webui/js/ext/set_realtek.js
+++ b/lynq/S300AI/ap/app/zte_webui/js/ext/set_realtek.js
@@ -81,6 +81,23 @@
                 name: '3G Only',

                 value: 'Only_WCDMA'

             }

+        ],

+        batteryVoiceSetModes: [{

+                name: "Always on",

+                value: "0"

+            }, {

+                name: "3600 mV",

+                value: "3600"

+            }, {

+                name: "3700 mV",

+                value: "3700"

+            }, {

+                name: "3800 mV",

+                value: "3800"

+            }, {

+                name: "3900 mV",

+                value: "3900"

+            }

         ]

     };

 

diff --git a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/build/config.mk b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/build/config.mk
index bca1d1b..c240c69 100755
--- a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/build/config.mk
+++ b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/build/config.mk
@@ -45,6 +45,7 @@
 CUSTOM_MACRO += -DPRODUCT_PHONE=1

 CUSTOM_MACRO += -DPRODUCT_DATACARD=2

 CUSTOM_MACRO += -DPRODUCT_TYPE=PRODUCT_MIFI_CPE

+CUSTOM_MACRO += -DPRODUCT_NOT_USE_RTC

 

 ifeq ($(CONFIG_MMI_LCD),no)

 CUSTOM_MACRO += -DDISABLE_LCD

diff --git a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/config/normal/config.linux b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
index 7f7328e..365c21f 100755
--- a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
+++ b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
@@ -1388,6 +1388,7 @@
 # CONFIG_THERMAL is not set
 CONFIG_WATCHDOG=y
 CONFIG_WATCHDOG_CORE=y
+CONFIG_WATCHDOG_RESTART=y
 # CONFIG_WATCHDOG_NOWAYOUT is not set
 
 #
diff --git a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/fs/normal/rootfs/etc_ro/default/default_parameter_user b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/fs/normal/rootfs/etc_ro/default/default_parameter_user
index 0e10fb5..602b35a 100755
--- a/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/lynq/wifi/S300AI/rtl8192cd_92fs/ap/project/zx297520v3/prj_cpe/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -557,3 +557,4 @@
 call_csp_number=
 #for voice end
 wifi_switch_status=
+battery_voice_voltage=3600