[Feature][ZXW-167]add lynq-at-test for using AT Command in uart
Only Configure: Yes
Affected branch: master
Affected module: unknown
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: yes
Doc Update:No
Change-Id: I28283c4835a23a6560332b9b1c5597c8ec1daea7
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
index 1bc5af2..b186409 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
@@ -286,6 +286,7 @@
lynq-gnss-update \
lynq-audio-demo \
lynq-adc-demo \
+ lynq-at-test \
"
zxic_app_open += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'rild', '', d)}"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/lynq-at-test.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/lynq-at-test.cpp
new file mode 100755
index 0000000..cbeab07
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/lynq-at-test.cpp
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "sc_at.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int check_cmd(char* cmd_str,char* check_str)
+{
+ int check_size = strlen(check_str);
+ for(int i = 0; i < check_size; i++)
+ {
+ // 输入包含非字母字符
+ if (!isalpha(cmd_str[i]))
+ {
+ return -1;
+ }
+ // 不匹配
+ if (tolower(cmd_str[i]) != check_str[i] && toupper(cmd_str[i]) != check_str[i])
+ {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ int i = 0;
+ char rsp[256] = {0};
+ char at_cmd[64] = {0};
+ char* check_str = "AT";
+ if(argc < 2)
+ {
+ printf("wrong input\r\n");
+ return -1;
+ }
+ ret = check_cmd(argv[1],check_str);
+ if(ret)
+ {
+ printf("wrong input\r\n");
+ return -1;
+ }
+ sprintf(at_cmd,"%s\n",argv[1]);
+ ret = sc_at_send(1,at_cmd,rsp,sizeof(rsp));
+ if(ret)
+ {
+ printf("at_send failed.the reason is: %s\r\n",rsp);
+ }
+ else
+ {
+ printf("AT RSP:%s\r\n",rsp);
+ }
+ return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/makefile
new file mode 100755
index 0000000..9ab87a1
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/files/makefile
@@ -0,0 +1,43 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -fPIC \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+$(warning lynq at-test ROOT = $(ROOT), includedir = $(includedir))
+LOCAL_PATH = .
+
+LOCAL_LIBS += \
+ -L. \
+ -lstdc++ \
+ -lpthread \
+ -latutils \
+ -lsctel \
+ -lsoftap \
+ -lsofttimer \
+ -lnvram \
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = lynq-at-test
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(EXECUTABLE)
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
+ $(RM) $(OBJECTS_TOOL) $(EXECUTABLE)
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/lynq-at-test.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/lynq-at-test.bb
new file mode 100755
index 0000000..23e1691
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-at-test/lynq-at-test.bb
@@ -0,0 +1,33 @@
+# Package summary
+SUMMARY = "lynq-at-test"
+# License, for example MIT
+LICENSE = "MIT"
+# License checksum file is always required
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "file://lynq-at-test.cpp file://makefile"
+DEPENDS += "libsctel libsoftap libatutils libsofttimer libnvram"
+SRC-DIR = "${S}/../lynq-at-test"
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'\"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
+LOCAL_C_INCLUDES = "-I."
+
+LOCAL_LIBS = "-L. -ldl -lstdc++"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+S = "${WORKDIR}"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-at-test ${D}${bindir}/
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
index b6164c5..2d9642b 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libsctel/at/sc_at.c
@@ -80,6 +80,11 @@
MSG_BUF rsp_msg = {0};
LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
int iRet = 0;
+ if(-1 != g_sync_moduleId){
+ SCLOGE("syn cmd already sent,waiting response...\n");
+ snprintf(rsp_buf, rsp_len-1, "%s", "syn cmd already sent,waiting response...\n");
+ return 1;
+ }
if(init_channel(&module_id,&my_handle) == -1){
SCLOGE("init_channel failed\n");
snprintf(rsp_buf, rsp_len-1, "%s", "init_channel failed\n");
@@ -108,11 +113,12 @@
}
if(MSG_CMD_AT_RSP == rsp_msg.usMsgCmd){
snprintf(rsp_buf, rsp_len-1, "%s", rsp_msg.aucDataBuf);
- SCLOGD("get rsp:%s!\n",rsp_msg.aucDataBuf);
+ //SCLOGD("get rsp:%s!\n",rsp_msg.aucDataBuf);
/*ɾ³ýͨµÀ*/
ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(my_handle,IPC_RMID,0) < 0)
SCLOGE("%d:%s",errno,strerror(errno));
+ g_sync_moduleId=-1;
return 0;
}else if(MSG_CMD_ATCHN_STOP == rsp_msg.usMsgCmd){
@@ -120,6 +126,7 @@
ipc_send_message(module_id, MODULE_ID_AT_CTL, MSG_CMD_DEL_MSG_IS_FD,0, NULL, 0);
if(msgctl(my_handle,IPC_RMID,0) < 0)
SCLOGE("%d:%s",errno,strerror(errno));
+ g_sync_moduleId=-1;
return 0;
}
}