[Feature][R306][task-view-515]Determine the calibration parameter version number and compare all parameters

    Only Configure: Yes
    Affected branch: master
    Affected module: wifi
    Is it affected on both ZXIC and MTK: only ZXIC
    Self-test: Yes
    Doc Update: No

Change-Id: Idc34db4a4957ea007204673b11175df4960bdcff
diff --git a/lynq/CPE_COMMON/ap/app/nvro/Makefile b/lynq/CPE_COMMON/ap/app/nvro/Makefile
new file mode 100755
index 0000000..1608992
--- /dev/null
+++ b/lynq/CPE_COMMON/ap/app/nvro/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+include $(zte_app_mak)

+

+##############USER COMIZE BEGIN################

+EXEC = nvro

+C_SOURCE = $(wildcard ./*.c)

+OBJS = $(subst .c,.o,$(C_SOURCE))

+

+CFLAGS += -I$(zte_app_path)/include

+CFLAGS += -I$(zte_lib_path)/libnvram

+CFLAGS += -I$(zte_lib_path)/libsqlite

+CFLAGS += -I$(zte_lib_path)/libnetapi

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/pal/dm

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui

+CFLAGS += -g

+CFLAGS += -Wextra -Wall

+#CFLAGS += -I../../../linux-3.4.x

+CFLAGS += -I$(LINUX_DIR)/include

+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv

+CFLAGS += -I$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include

+endif

+LDLIBS = -lpthread -lm

+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram

+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv

+LDLIBS += -lamt -L$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa

+endif

+

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -D_USE_VOICE_SUPPORT

+endif

+

+#wifi

+ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+CFLAGS	 += -D__SSV_6X5X_CHIP__

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -D__AIC_8800DW_CHIP__

+endif

+

+##############USER COMIZE END##################

+

+#*******************************************************************************

+# targets

+#*******************************************************************************

+all: $(EXEC)

+

+$(EXEC): $(OBJS)

+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group

+	@cp $@ $@.elf

+

+romfs:

+	$(ROMFSINST) $(EXEC) /bin/$(EXEC)

+

+clean:

+	-rm -f $(EXEC) *.elf *.gdb *.o

diff --git a/lynq/CPE_COMMON/ap/app/nvro/nvro.c b/lynq/CPE_COMMON/ap/app/nvro/nvro.c
new file mode 100644
index 0000000..fe48f6d
--- /dev/null
+++ b/lynq/CPE_COMMON/ap/app/nvro/nvro.c
@@ -0,0 +1,22 @@
+#include <stdio.h>  
+#include <stdlib.h>  
+#include <string.h>  
+#include <fcntl.h>  
+#include <unistd.h>
+#include "amtnv.h"
+  
+int main(int argc, char *argv[]) {  
+    if(argc == 2 && strlen(argv[1]) < 10)
+    {
+        amt_nvro_user_write(0,10,argv[1]);
+    }
+    else
+    {
+        char nvro_read[10];
+        amt_nvro_user_read(0,10,nvro_read);
+        printf("nvro_read :%s\n",nvro_read);
+        return strtol(nvro_read,NULL,10);
+    }
+  
+    return 0;  
+}
\ No newline at end of file
diff --git a/lynq/CPE_COMMON/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/CPE_COMMON/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
index 3b3f9f8..9e774e2 100755
--- a/lynq/CPE_COMMON/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
+++ b/lynq/CPE_COMMON/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -689,15 +689,23 @@
 

 int ext_at_wlan_calibrate_func(char *at_paras, void ** res_msg)

 {

-	int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

-	if(exit_status == 0)

-		return AT_END;

-	else if (WEXITSTATUS(exit_status) == 1)

+	char *at_str = malloc(64);

+	int v1 = WEXITSTATUS(system("nvro"));

+	int v2 = WEXITSTATUS(system("/sbin/rtl8192_calibrate.sh 3"));

+	if(v1 < v2)

 	{

-		*res_msg = at_err_build(0);

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"ERROR");

+	}

+	else if(v1 > v2)

+	{

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"OK");

 	}

 	else

-		*res_msg = at_err_build(ATERR_PROC_FAILED);

+	{

+		int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,exit_status == 0 ?"OK":"ERROR");

+	}

+	*res_msg = at_str;

 	return AT_END;

 }

 

diff --git a/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk b/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
index 1f911ed..2a23cd1 100755
--- a/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
+++ b/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
@@ -4,7 +4,7 @@
 			Script \

 			fota_upi \

 			zte_amt \

-			zte_webui clatd cwmp

+			zte_webui clatd cwmp nvro

 

 #yes only when klocwork static analysis 

 ifneq ($(KW_SKIP),yes)

diff --git a/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh b/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
index 8ff95ef..c5427cf 100755
--- a/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
+++ b/lynq/CPE_COMMON/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
@@ -1,4 +1,5 @@
 #!/bin/sh
+CALI_VERSION=1
 CALi_HW_TX_POWER_CCK_A=2D2D2E2E2E2D2D2D2E2E2E2D2D2D
 CALi_HW_TX_POWER_CCK_B=2C2C2D2D2D2A2A2A2D2D2D2E2E2E
 CALi_HW_TX_POWER_HT40_1S_A=2B2B2B2B2B2B2B2B2B2B2B2B2B2B
@@ -84,6 +85,14 @@
 		echo Repeated calibration
 		exit 0;
 	fi
+	nvro
+	result=$?
+	if [[ ${result} -gt  ${CALI_VERSION} ]];then
+		nv set wifi_calibrated=1
+		nv save
+		echo Already calibrated by a higher version
+		exit 0;
+	fi
 	sleep 20
 	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
 		echo wlan0 down
@@ -106,6 +115,7 @@
 		iwpriv wlan0 efuse_set HW_11N_THER=${CALi_HW_11N_THER}
 		iwpriv wlan0 efuse_set HW_11N_XCAP=${CALi_HW_11N_XCAP}
 		iwpriv wlan0 efuse_sync   #发完这个指令之后才是最终写入
+		nvro ${CALI_VERSION}
 		sleep 2
 		wifi_calibrate_check
 		result=$?
@@ -117,6 +127,7 @@
 		##
 		echo calibrated
 	else
+		nvro ${CALI_VERSION}
 		nv set wifi_calibrated=1
 		nv save
 		echo Repeated calibration
@@ -142,4 +153,8 @@
 	iwpriv wlan0 efuse_get HW_11N_THER
 	iwpriv wlan0 efuse_get HW_11N_XCAP
 fi
+
+if [ $1 -eq 3 ];then #Get VERSION
+	exit ${CALI_VERSION}
+fi
 exit 0
diff --git a/lynq/CPE_TELKOMSEL/ap/app/nvro/Makefile b/lynq/CPE_TELKOMSEL/ap/app/nvro/Makefile
new file mode 100755
index 0000000..1608992
--- /dev/null
+++ b/lynq/CPE_TELKOMSEL/ap/app/nvro/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+include $(zte_app_mak)

+

+##############USER COMIZE BEGIN################

+EXEC = nvro

+C_SOURCE = $(wildcard ./*.c)

+OBJS = $(subst .c,.o,$(C_SOURCE))

+

+CFLAGS += -I$(zte_app_path)/include

+CFLAGS += -I$(zte_lib_path)/libnvram

+CFLAGS += -I$(zte_lib_path)/libsqlite

+CFLAGS += -I$(zte_lib_path)/libnetapi

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/pal/dm

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui

+CFLAGS += -g

+CFLAGS += -Wextra -Wall

+#CFLAGS += -I../../../linux-3.4.x

+CFLAGS += -I$(LINUX_DIR)/include

+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv

+CFLAGS += -I$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include

+endif

+LDLIBS = -lpthread -lm

+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram

+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv

+LDLIBS += -lamt -L$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa

+endif

+

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -D_USE_VOICE_SUPPORT

+endif

+

+#wifi

+ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+CFLAGS	 += -D__SSV_6X5X_CHIP__

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -D__AIC_8800DW_CHIP__

+endif

+

+##############USER COMIZE END##################

+

+#*******************************************************************************

+# targets

+#*******************************************************************************

+all: $(EXEC)

+

+$(EXEC): $(OBJS)

+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group

+	@cp $@ $@.elf

+

+romfs:

+	$(ROMFSINST) $(EXEC) /bin/$(EXEC)

+

+clean:

+	-rm -f $(EXEC) *.elf *.gdb *.o

diff --git a/lynq/CPE_TELKOMSEL/ap/app/nvro/nvro.c b/lynq/CPE_TELKOMSEL/ap/app/nvro/nvro.c
new file mode 100644
index 0000000..fe48f6d
--- /dev/null
+++ b/lynq/CPE_TELKOMSEL/ap/app/nvro/nvro.c
@@ -0,0 +1,22 @@
+#include <stdio.h>  
+#include <stdlib.h>  
+#include <string.h>  
+#include <fcntl.h>  
+#include <unistd.h>
+#include "amtnv.h"
+  
+int main(int argc, char *argv[]) {  
+    if(argc == 2 && strlen(argv[1]) < 10)
+    {
+        amt_nvro_user_write(0,10,argv[1]);
+    }
+    else
+    {
+        char nvro_read[10];
+        amt_nvro_user_read(0,10,nvro_read);
+        printf("nvro_read :%s\n",nvro_read);
+        return strtol(nvro_read,NULL,10);
+    }
+  
+    return 0;  
+}
\ No newline at end of file
diff --git a/lynq/CPE_TELKOMSEL/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/CPE_TELKOMSEL/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
index 3b3f9f8..9e774e2 100755
--- a/lynq/CPE_TELKOMSEL/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
+++ b/lynq/CPE_TELKOMSEL/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -689,15 +689,23 @@
 

 int ext_at_wlan_calibrate_func(char *at_paras, void ** res_msg)

 {

-	int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

-	if(exit_status == 0)

-		return AT_END;

-	else if (WEXITSTATUS(exit_status) == 1)

+	char *at_str = malloc(64);

+	int v1 = WEXITSTATUS(system("nvro"));

+	int v2 = WEXITSTATUS(system("/sbin/rtl8192_calibrate.sh 3"));

+	if(v1 < v2)

 	{

-		*res_msg = at_err_build(0);

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"ERROR");

+	}

+	else if(v1 > v2)

+	{

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"OK");

 	}

 	else

-		*res_msg = at_err_build(ATERR_PROC_FAILED);

+	{

+		int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,exit_status == 0 ?"OK":"ERROR");

+	}

+	*res_msg = at_str;

 	return AT_END;

 }

 

diff --git a/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk b/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
index 1cbe479..75f1e53 100755
--- a/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
+++ b/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
@@ -4,7 +4,7 @@
 			Script \

 			fota_upi \

 			zte_amt \

-			zte_webui clatd cwmp stun

+			zte_webui clatd cwmp stun nvro

 

 #yes only when klocwork static analysis 

 ifneq ($(KW_SKIP),yes)

diff --git a/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh b/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
index 8ff95ef..c5427cf 100755
--- a/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
+++ b/lynq/CPE_TELKOMSEL/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
@@ -1,4 +1,5 @@
 #!/bin/sh
+CALI_VERSION=1
 CALi_HW_TX_POWER_CCK_A=2D2D2E2E2E2D2D2D2E2E2E2D2D2D
 CALi_HW_TX_POWER_CCK_B=2C2C2D2D2D2A2A2A2D2D2D2E2E2E
 CALi_HW_TX_POWER_HT40_1S_A=2B2B2B2B2B2B2B2B2B2B2B2B2B2B
@@ -84,6 +85,14 @@
 		echo Repeated calibration
 		exit 0;
 	fi
+	nvro
+	result=$?
+	if [[ ${result} -gt  ${CALI_VERSION} ]];then
+		nv set wifi_calibrated=1
+		nv save
+		echo Already calibrated by a higher version
+		exit 0;
+	fi
 	sleep 20
 	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
 		echo wlan0 down
@@ -106,6 +115,7 @@
 		iwpriv wlan0 efuse_set HW_11N_THER=${CALi_HW_11N_THER}
 		iwpriv wlan0 efuse_set HW_11N_XCAP=${CALi_HW_11N_XCAP}
 		iwpriv wlan0 efuse_sync   #发完这个指令之后才是最终写入
+		nvro ${CALI_VERSION}
 		sleep 2
 		wifi_calibrate_check
 		result=$?
@@ -117,6 +127,7 @@
 		##
 		echo calibrated
 	else
+		nvro ${CALI_VERSION}
 		nv set wifi_calibrated=1
 		nv save
 		echo Repeated calibration
@@ -142,4 +153,8 @@
 	iwpriv wlan0 efuse_get HW_11N_THER
 	iwpriv wlan0 efuse_get HW_11N_XCAP
 fi
+
+if [ $1 -eq 3 ];then #Get VERSION
+	exit ${CALI_VERSION}
+fi
 exit 0
diff --git a/lynq/R306/ap/app/nvro/Makefile b/lynq/R306/ap/app/nvro/Makefile
new file mode 100755
index 0000000..1608992
--- /dev/null
+++ b/lynq/R306/ap/app/nvro/Makefile
@@ -0,0 +1,62 @@
+#*******************************************************************************

+# include ZTE application makefile

+#*******************************************************************************

+include $(zte_app_mak)

+

+##############USER COMIZE BEGIN################

+EXEC = nvro

+C_SOURCE = $(wildcard ./*.c)

+OBJS = $(subst .c,.o,$(C_SOURCE))

+

+CFLAGS += -I$(zte_app_path)/include

+CFLAGS += -I$(zte_lib_path)/libnvram

+CFLAGS += -I$(zte_lib_path)/libsqlite

+CFLAGS += -I$(zte_lib_path)/libnetapi

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/pal/dm

+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui

+CFLAGS += -g

+CFLAGS += -Wextra -Wall

+#CFLAGS += -I../../../linux-3.4.x

+CFLAGS += -I$(LINUX_DIR)/include

+CFLAGS += -I/$(TOPDIR)/pub/project/$(CHIP_NAME)/include/nv

+CFLAGS += -I$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -I$(zte_lib_path)/libtinyalsa/include

+endif

+LDLIBS = -lpthread -lm

+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram

+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap

+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer

+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv

+LDLIBS += -lamt -L$(zte_lib_path)/libamt

+ifeq ($(USE_VOICE_SUPPORT),yes)

+LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa

+endif

+

+ifeq ($(USE_VOICE_SUPPORT),yes)

+CFLAGS += -D_USE_VOICE_SUPPORT

+endif

+

+#wifi

+ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)

+CFLAGS	 += -D__SSV_6X5X_CHIP__

+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)

+CFLAGS	 += -D__AIC_8800DW_CHIP__

+endif

+

+##############USER COMIZE END##################

+

+#*******************************************************************************

+# targets

+#*******************************************************************************

+all: $(EXEC)

+

+$(EXEC): $(OBJS)

+	$(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group

+	@cp $@ $@.elf

+

+romfs:

+	$(ROMFSINST) $(EXEC) /bin/$(EXEC)

+

+clean:

+	-rm -f $(EXEC) *.elf *.gdb *.o

diff --git a/lynq/R306/ap/app/nvro/nvro.c b/lynq/R306/ap/app/nvro/nvro.c
new file mode 100644
index 0000000..fe48f6d
--- /dev/null
+++ b/lynq/R306/ap/app/nvro/nvro.c
@@ -0,0 +1,22 @@
+#include <stdio.h>  
+#include <stdlib.h>  
+#include <string.h>  
+#include <fcntl.h>  
+#include <unistd.h>
+#include "amtnv.h"
+  
+int main(int argc, char *argv[]) {  
+    if(argc == 2 && strlen(argv[1]) < 10)
+    {
+        amt_nvro_user_write(0,10,argv[1]);
+    }
+    else
+    {
+        char nvro_read[10];
+        amt_nvro_user_read(0,10,nvro_read);
+        printf("nvro_read :%s\n",nvro_read);
+        return strtol(nvro_read,NULL,10);
+    }
+  
+    return 0;  
+}
\ No newline at end of file
diff --git a/lynq/R306/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/R306/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
index 3b3f9f8..9e774e2 100755
--- a/lynq/R306/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
+++ b/lynq/R306/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -689,15 +689,23 @@
 

 int ext_at_wlan_calibrate_func(char *at_paras, void ** res_msg)

 {

-	int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

-	if(exit_status == 0)

-		return AT_END;

-	else if (WEXITSTATUS(exit_status) == 1)

+	char *at_str = malloc(64);

+	int v1 = WEXITSTATUS(system("nvro"));

+	int v2 = WEXITSTATUS(system("/sbin/rtl8192_calibrate.sh 3"));

+	if(v1 < v2)

 	{

-		*res_msg = at_err_build(0);

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"ERROR");

+	}

+	else if(v1 > v2)

+	{

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,"OK");

 	}

 	else

-		*res_msg = at_err_build(ATERR_PROC_FAILED);

+	{

+		int exit_status = system("/sbin/rtl8192_calibrate.sh 0");

+		sprintf(at_str, "\r\n%d,%d\r\n%s\r\n", v1,v2,exit_status == 0 ?"OK":"ERROR");

+	}

+	*res_msg = at_str;

 	return AT_END;

 }

 

diff --git a/lynq/R306/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk b/lynq/R306/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
index 1f911ed..2a23cd1 100755
--- a/lynq/R306/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
+++ b/lynq/R306/ap/project/zx297520v3/prj_mifi_min/config/normal/config_app.mk
@@ -4,7 +4,7 @@
 			Script \

 			fota_upi \

 			zte_amt \

-			zte_webui clatd cwmp

+			zte_webui clatd cwmp nvro

 

 #yes only when klocwork static analysis 

 ifneq ($(KW_SKIP),yes)

diff --git a/lynq/R306/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh b/lynq/R306/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
index 8ff95ef..c5427cf 100755
--- a/lynq/R306/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
+++ b/lynq/R306/ap/project/zx297520v3/prj_mifi_min/fs/normal/rootfs/sbin/rtl8192_calibrate.sh
@@ -1,4 +1,5 @@
 #!/bin/sh
+CALI_VERSION=1
 CALi_HW_TX_POWER_CCK_A=2D2D2E2E2E2D2D2D2E2E2E2D2D2D
 CALi_HW_TX_POWER_CCK_B=2C2C2D2D2D2A2A2A2D2D2D2E2E2E
 CALi_HW_TX_POWER_HT40_1S_A=2B2B2B2B2B2B2B2B2B2B2B2B2B2B
@@ -84,6 +85,14 @@
 		echo Repeated calibration
 		exit 0;
 	fi
+	nvro
+	result=$?
+	if [[ ${result} -gt  ${CALI_VERSION} ]];then
+		nv set wifi_calibrated=1
+		nv save
+		echo Already calibrated by a higher version
+		exit 0;
+	fi
 	sleep 20
 	if [ $(cat /sys/class/net/wlan0/operstate | grep -i down | wc -l) -eq 1 ];then
 		echo wlan0 down
@@ -106,6 +115,7 @@
 		iwpriv wlan0 efuse_set HW_11N_THER=${CALi_HW_11N_THER}
 		iwpriv wlan0 efuse_set HW_11N_XCAP=${CALi_HW_11N_XCAP}
 		iwpriv wlan0 efuse_sync   #发完这个指令之后才是最终写入
+		nvro ${CALI_VERSION}
 		sleep 2
 		wifi_calibrate_check
 		result=$?
@@ -117,6 +127,7 @@
 		##
 		echo calibrated
 	else
+		nvro ${CALI_VERSION}
 		nv set wifi_calibrated=1
 		nv save
 		echo Repeated calibration
@@ -142,4 +153,8 @@
 	iwpriv wlan0 efuse_get HW_11N_THER
 	iwpriv wlan0 efuse_get HW_11N_XCAP
 fi
+
+if [ $1 -eq 3 ];then #Get VERSION
+	exit ${CALI_VERSION}
+fi
 exit 0