[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/lynq/packages/apps/lynq-broadcast-receive/src/LICENSE b/src/lynq/packages/apps/lynq-broadcast-receive/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-receive/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c b/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c
new file mode 100644
index 0000000..da8b6b3
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c
@@ -0,0 +1,86 @@
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <log/log.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+#include "liblynq-broadcast/broadcast_receiver.h"
+
+
+static void CallbackByName( char*broadcast_name, int data_length,const char*data)
+{
+ printf("CallbackByName,str_arg:%s,data_length:%d,int_arg:%s\n", broadcast_name,data_length,data);
+
+ return;
+}
+static void CallbackByName1( char*broadcast_name, int data_length,const char*data)
+{
+ printf("CallbackByName1,str_arg:%s,data_length:%d,int_arg:%s\n", broadcast_name,data_length,data);
+
+ return;
+}
+static void CallbackById(int id, int data_length,const char*data)
+{
+ printf("CallbackById,id:%d,data_length:%d,data:%s\n", id,data_length,data);
+
+ return;
+}
+static void CallbackById1(int id, int data_length,const char*data)
+{
+ printf("CallbackById1,id:%d,data_length:%d,data:%s\n", id,data_length,data);
+
+ return;
+}
+static void callbackPrameUnfixed(char*broadcast_name,GVariant *parameters)
+{
+ gchar *out_a;
+ gchar *out_b;
+ gchar *out_c;
+ guchar out_d;
+ gboolean out_e;
+ gint16 out_f;
+ guint16 out_g;
+ gint out_h;
+ guint out_i;
+ gint64 out_j;
+ guint64 out_k;
+ gdouble out_l;
+
+ g_variant_get (parameters,
+ "(sogybnqiuxtd)",
+ &out_a,
+ &out_b,
+ &out_c,
+ &out_d,
+ &out_e,
+ &out_f,
+ &out_g,
+ &out_h,
+ &out_i,
+ &out_j,
+ &out_k,
+ &out_l);
+ printf("SignalCallback11111,,broadcast_name:%s\n", broadcast_name);
+ printf("%s,%s,%s,%u,%d,%.2fF\n", out_a,out_b,out_c,out_d,out_e,out_l);
+
+ return;
+}
+int main(int argc, char** argv)
+{
+ char data[] = "BrcastA";
+ char data1[] = "BrcastB";
+ GVariant *ret_struct;
+ register_broadcast_loop();
+//BOOL ServiceIsReady(void);
+ receive_callback_by_name(data, CallbackByName);
+ receive_callback_by_name(data1, CallbackByName1);
+ receive_callback_by_id(120, CallbackById);
+ receive_callback_by_id(128, CallbackById1);
+ while (1) {
+ sleep(10);
+ }
+
+
+}
diff --git "a/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp" "b/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/src/lynq/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ guint set_result = -1;
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE); /** create main loop, but do not start it.*/
+ c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ GPIO_SERVICE, /* bus name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface name */
+ "setGpio", /* method name */
+ g_variant_new ("(sii)", mode,gpio_numb,param), /* parameters */
+ G_VARIANT_TYPE ("(i)"), /* return type */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "((i))", &(set_result));
+ g_variant_unref (result);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+ return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ guint parm=0;
+ const gchar *set_result;
+ const gchar *mode ="gpio";
+ if(set_gpio(mode,gpio_numb,parm)== -1)
+ {
+ RLOGD("get_gpio number error");
+ return -1;
+ }
+ c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ GPIO_SERVICE, /* bus name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface name */
+ "getGpio", /* method name */
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(s)"), /* return type */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "((s))", &(set_result));
+ RLOGD("get_gpio,%s",set_result);
+ g_variant_unref (result);
+ return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+ GError *error;
+
+ error = NULL;
+ proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+ if (proxy == NULL) {
+ RLOGE("create proxy fail");
+ return ;
+ }
+ RLOGD("proxy is ready");
+ gulong signal_handler_id;
+
+ // signal_handler_id = g_signal_connect(proxy, "g-signal",
+ // G_CALLBACK (proxy_signals_on_signal), NULL);
+ // if (signal_handler_id == 0) {
+ // RLOGE("listen singal fail!");
+ // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+ /* all the tests rely on a shared main loop */
+ loop = g_main_loop_new(NULL, FALSE);
+
+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL, /* GDBusInterfaceInfo */
+ GPIO_SERVICE, /* name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface */
+ NULL, /* GCancellable */
+ proxy_ready,
+ NULL);
+
+ g_main_loop_run(loop);
+
+ RLOGD("data gdbus main loop run()");
+ if(proxy != NULL) {
+ g_object_unref (proxy);
+ }
+ if(loop != NULL) {
+ g_main_loop_unref(loop);
+ }
+}
+
+
+void startGdbusLoop(void)
+{
+ pthread_t gpioThread;
+
+ RLOGD("startGdbusLoop()");
+ // pthread_mutex_lock(&s_startupMutex);
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+ if (result != 0) {
+ RLOGW("Failed to create gdbus thread: %s", strerror(result));
+ //goto done;
+ }
+//done:
+ // pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/src/lynq/packages/apps/lynq-broadcast-receive/src/makefile b/src/lynq/packages/apps/lynq-broadcast-receive/src/makefile
new file mode 100644
index 0000000..b287a12
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-receive/src/makefile
@@ -0,0 +1,68 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -D__LINUX_OS__ \
+ -DECALL_SUPPORT
+
+CXXFLAGS = -fpermissive
+LOCAL_PATH = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH) \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(includedir)/liblynq-broadcast \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -lpthread \
+ -lpal \
+ -llynq-broadcast \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -lapn \
+ -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-broadcast-receive
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+ $(warning ----->build $<)
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-broadcast-send/src/LICENSE b/src/lynq/packages/apps/lynq-broadcast-send/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-send/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c b/src/lynq/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c
new file mode 100644
index 0000000..9b6396f
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c
@@ -0,0 +1,105 @@
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <log/log.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+#include "liblynq-broadcast/broadcast_send.h"
+#include <gio/gio.h>
+#include <glib.h>
+#define LOG_TAG "BROADCAST_SEND_APP"
+
+int main(int argc, char** argv)
+{
+ char data[] = "BrcastA comming";
+ char dataB[] = "BrcastB,comming";
+ char data1[] = "120,comming";
+ char data2[] = "128,comming";
+ int select_argvi = -1;
+ GVariant *ret_struct;
+ ret_struct = g_variant_new ("(sogybnqiuxtd)",
+ "this is a string",
+ "/this/is/a/path",
+ "sad",
+ 42,
+ TRUE,
+ -42,
+ 60000,
+ -44,
+ 100000,
+ -(G_GUINT64_CONSTANT(2)<<34),
+ G_GUINT64_CONSTANT(0xffffffffffffffff),
+ 42.5);
+
+ /****************test prame data **************/
+ /*
+ register_broadcast_send_loop();
+ RLOGD("register_broadcast_send_loop,start");
+ while(1){
+ char str[8192]={ 0 };
+ fgets(str, 8192, stdin);
+ str[strlen(str)-1]='\0';
+ send_broadcast_by_name("BrcastA",sizeof(str),str);
+ }
+ while (1) {
+ sleep(10);
+ */
+ /********************test prame data *************/
+
+
+ /*******************test Multiple broadcasts ******************/
+ /*
+ register_broadcast_send_loop();
+ RLOGD("register_broadcast_send_loop,start");
+ if(argv[1] != NULL)
+ {
+ select_argvi = atoi(argv[1]);
+ }
+ if (1 == select_argvi ){
+ for (int i=0;i<1000;i++)
+ {
+ send_broadcast_by_name("BrcastA",sizeof(data),data);
+ //send_broadcast_by_name("BrcastB",sizeof(dataB),dataB);
+ send_broadcast_by_id(120,sizeof(data1),data1);
+ //send_broadcast_by_id(128,sizeof(data2),data2);
+ //send_broadcast_param_unfixed("Brcastc",ret_struct);
+
+ }
+ }
+ else {
+ for (int i=0;i<1000;i++)
+ {
+ //send_broadcast_by_name("BrcastA",sizeof(data),data);
+ send_broadcast_by_name("BrcastB",sizeof(dataB),dataB);
+ //send_broadcast_by_id(120,sizeof(data1),data1);
+ send_broadcast_by_id(128,sizeof(data2),data2);
+ //send_broadcast_param_unfixed("Brcastc",ret_struct);
+
+ }
+ }
+
+ while (1) {
+ sleep(10);
+ }*/
+ /**********************test Multiple broadcasts ********************/
+
+
+
+ register_broadcast_send();
+
+ RLOGD("register_broadcast_send,ok");
+ for (int i=0;i<1000;i++)
+ {
+ send_broadcast_by_name("BrcastA",sizeof(data),data);
+ send_broadcast_by_id("BrcastB",sizeof(dataB),dataB);
+ //send_broadcast_param_unfixed("Brcastc",ret_struct);
+ }
+ //send_broadcast_by_id(120,sizeof(data1),data1);
+ while(1){
+ sleep(10);
+ }
+ /**********************test Remove thread ********************/
+
+}
diff --git a/src/lynq/packages/apps/lynq-broadcast-send/src/makefile b/src/lynq/packages/apps/lynq-broadcast-send/src/makefile
new file mode 100644
index 0000000..d1d2886
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-broadcast-send/src/makefile
@@ -0,0 +1,68 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -D__LINUX_OS__ \
+ -DECALL_SUPPORT
+
+CXXFLAGS = -fpermissive
+LOCAL_PATH = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH) \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/liblynq-broadcast \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -lpthread \
+ -lpal \
+ -llynq-broadcast \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -lapn \
+ -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-broadcast-send
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+ $(warning ----->build $<)
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.cpp
new file mode 100644
index 0000000..f0786e9
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.cpp
@@ -0,0 +1,270 @@
+#include <memory>
+#include "AutoFactoryTest.h"
+#include <log/log.h>
+#include "common.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "ResulTest.h"
+#include <cutils/properties.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#include "result.h"
+
+#ifdef __cplusplus
+}
+#endif
+using namespace std;
+AutoFactoryTest* AutoFactoryTest::m_instance = NULL;
+std::mutex AutoFactoryTest::mMutex;
+#undef LOG_TAG
+#define LOG_TAG "AutoFactoryTest"
+AutoFactoryTest::AutoFactoryTest()
+:wifiCommand(NULL),
+simCommand(NULL),
+sim2Command(NULL),
+adc0Command(NULL),
+usbCommand(NULL),
+audioThread(0)
+
+{
+}
+AutoFactoryTest::~AutoFactoryTest() {
+ RLOGD("RfDesenseTxTest destroyed\n");
+}
+
+int AutoFactoryTest::hasPrame(const char* nv_name){
+ int mGetNvData = get_prop_by_int(nv_name);
+ if(mGetNvData)
+ {
+ return 1;
+ }
+ else
+ {
+ printf("parameter:%s not set\n",nv_name);
+ return 0;
+ }
+
+}
+int AutoFactoryTest::getPrame(const char* nv_name){
+ int data =get_prop_by_int(nv_name);
+ RLOGD("getPrame data:%d\n",data);
+ return data;
+}
+
+void AutoFactoryTest::adc0Test()
+{
+int small,large;
+ if((hasPrame(ADC_TIMES_NV))&&
+ (hasPrame(ADC0_SCOPE_SMALL))&&
+ (hasPrame(ADC0_SCOPE_LARGER)))
+ {
+ if(adc0Command==NULL)
+ {
+ adc0ModuleBase = Adc0Test::getInstance();
+ adc0Command = new CommandBase();
+ adc0Command->open(adc0ModuleBase,ADC0_M);
+ }
+ small =getPrame(ADC0_SCOPE_SMALL);
+ large = getPrame(ADC0_SCOPE_LARGER);
+ RLOGD("adc0Test small,large:%d,%d\n",small,large);
+ adc0Command->getCheckResult(small,large);
+ adc0Command->timeOut(getPrame(ADC_TIMES_NV));
+ adc0Command->startTest();
+ }
+
+}
+
+void AutoFactoryTest:: adc0Scope(int smallData,int largerData)
+{
+ if (smallData>largerData)
+ {
+ saveDataToProp(ADC0_SCOPE_SMALL,largerData);
+ saveDataToProp(ADC0_SCOPE_LARGER,smallData);
+ }
+ else
+ {
+ saveDataToProp(ADC0_SCOPE_SMALL,smallData);
+ saveDataToProp(ADC0_SCOPE_LARGER,largerData);
+ }
+ LYVERBLOG("+[adc_Scope]:%d,%d\n",smallData,largerData);
+
+}
+void AutoFactoryTest::adcTimes(int e)
+{
+ saveDataToProp(ADC_TIMES_NV,e);
+ LYVERBLOG("+[adc_Times]:%d\n",e);
+}
+
+
+
+void AutoFactoryTest::simTest()
+{
+ if(hasPrame(SIM_TIMEOUT_NV))
+ {
+ if(simCommand==NULL)
+ {
+ simModuleBase = SimTest::getInstance();
+ simCommand = new CommandBase();
+ simCommand->open(simModuleBase,SIM_M);
+ }
+ simCommand->timeOut(getPrame(SIM_TIMEOUT_NV));
+ simCommand->startTest();
+ }
+}
+void AutoFactoryTest::sim2Test()
+{
+ if(hasPrame(SIM_TIMEOUT_NV))
+ {
+ if(sim2Command==NULL)
+ {
+ sim2ModuleBase = Sim2Test::getInstance();
+ sim2Command = new CommandBase();
+ sim2Command->open(sim2ModuleBase,SIM2_M);
+ }
+ sim2Command->timeOut(getPrame(SIM_TIMEOUT_NV));
+ sim2Command->startTest();
+ }
+}
+void AutoFactoryTest::simTimeout(int e)
+{
+ saveDataToProp(SIM_TIMEOUT_NV,e);
+ LYVERBLOG("+[sim_Time]:%d\n",e);
+
+}
+
+void AutoFactoryTest::wifiTest()
+{
+ if(hasPrame(WIFI_TIMEOUT_NV))
+ {
+ RLOGD("AutoFactoryTest,wifiTest start\n");
+ if(wifiCommand==NULL)
+ {
+ RLOGD("AutoFactoryTest,wifiTest create\n");
+
+ wifiModuleBase = WifiTest::getInstance();
+ wifiCommand = new CommandBase();
+ wifiCommand->open(wifiModuleBase,WIFI_M);
+ }
+ RLOGD("AutoFactoryTest,wifiTest\n");
+ wifiCommand->timeOut(getPrame(WIFI_TIMEOUT_NV));
+ wifiCommand->startTest();
+ }
+}
+void AutoFactoryTest::wifiTimeout(int e)
+{
+ saveDataToProp(WIFI_TIMEOUT_NV,e);
+ LYVERBLOG("+[wifi_Time]:%d\n",e);
+}
+
+
+void AutoFactoryTest::usbTest()
+{
+ if(hasPrame(USB_TIMEOUT_NV))
+ {
+ if(usbCommand==NULL)
+ {
+ usbModuleBase = UsbTest::getInstance();
+ usbCommand = new CommandBase();
+ usbCommand->open(usbModuleBase,USB30_M);
+ }
+ usbCommand->timeOut(getPrame(USB_TIMEOUT_NV));
+ usbCommand->startTest();
+ }
+
+}
+void AutoFactoryTest::usbTimeout(int e)
+{
+ saveDataToProp(USB_TIMEOUT_NV,e);
+ LYVERBLOG("+[usb_Time]:%d\n",e);
+
+}
+void AutoFactoryTest::gpsTest()
+{
+ if(hasPrame(GPS_TIMEOUT_NV))
+ {
+ GpsCommand::getInstance()->timeOut(getPrame(GPS_TIMEOUT_NV));
+ GpsCommand::getInstance()->startTest();
+ }
+}
+void AutoFactoryTest::gpsTimeout(int e)
+{
+ saveDataToProp(GPS_TIMEOUT_NV,e);
+ LYVERBLOG("+[gps_Time]:%d\n",e);
+
+}
+void AutoFactoryTest::gpsGetResult(int result)
+{
+ GpsCommand::getInstance()->getResult(result);
+}
+void AutoFactoryTest::inputCommand(const char* mCommand)
+ {
+ char csname[27] = {0};
+ char cmd[256];
+ RLOGD("startTest\n");
+ sprintf(cmd, mCommand, csname);
+ system(cmd);
+
+}
+
+void *AutoFactoryTest::CommandThread(void *arg)
+{
+ LYVERBLOG("+[audio_test]:start\n");
+ pthread_detach(pthread_self());
+ AutoFactoryTest *disThread = (AutoFactoryTest *) arg;
+ disThread->inputCommand(audioComand1);
+ usleep(10);
+ disThread->inputCommand(audioComand2);
+ usleep(10);
+ RLOGD("CommandThread audio start\n");
+ disThread->inputCommand(audioComand3);
+ RLOGD("CommandThread audio end\n");
+ pthread_exit(0);
+}
+void AutoFactoryTest::audioTest(){
+ int ret = pthread_create(&audioThread, NULL, AutoFactoryTest::CommandThread, (void *)this);
+}
+void AutoFactoryTest::audioGetResult(int result)
+{
+ ResulTest::getInstance()->getTestResult(AUDIO_M, result);
+ RLOGD("audioGetResult start\n");
+ system("kill $(ps aux | grep '[a]play' | awk '{print $2}')");
+ RLOGD("audioGetResult record end\n");
+ // pthread_join(audioThread, NULL);
+ RLOGD("audioGetResult end\n");
+
+}
+void AutoFactoryTest::getCurrentResult()
+{
+ ResulTest::getInstance()->getCurrentResult();
+}
+void AutoFactoryTest::getNvCurrentResult()
+{
+ ResulTest::getInstance()->getNVResult();
+}
+void AutoFactoryTest::resetResult()
+{
+ ResulTest::getInstance()->resetResult();
+}
+void AutoFactoryTest::init()
+{
+ register_factory_auto_hook_raw(m_instance);
+}
+AutoFactoryTest* AutoFactoryTest::getInstance()
+{
+ if(!m_instance)
+ {
+ mMutex.lock();
+ if(!m_instance)
+ {
+ m_instance = new AutoFactoryTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+}
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.h b/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.h
new file mode 100644
index 0000000..a5b641d
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/AutoFactoryTest.h
@@ -0,0 +1,101 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ *
+ * MediaTek Inc. (C) 2016. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+
+#ifndef LYNQ_AUTOFACTORYTEST_H_
+#define LYNQ_AUTOFACTORYTEST_H_
+#include <mutex>
+#include <utils/RefBase.h>
+#include "GpsCommand.h"
+#include "UsbTest.h"
+#include "SimTest.h"
+#include "Sim2Test.h"
+#include "Adc0Test.h"
+#include <ResulTest.h>
+#include "WifiTest.h"
+#include <pthread.h>
+using namespace std;
+using ::android::sp;
+using ::android::RefBase;
+static const char *audioComand1 ="echo write_reg,0x002c,0x0008 > /sys/kernel/debug/mtksocaudio";
+static const char *audioComand2 ="echo write_reg,0x0030,0x0010 > /sys/kernel/debug/mtksocaudio";
+static const char *audioComand3 ="arecord -D plughw:0,1 --buffer-size=1024 -r 16000 -f S16_LE -c1 | aplay -D plughw:0,7 --buffer-size=1024 -r 16000 -f S16_LE -c1";
+class AutoFactoryTest: public android::RefBase {
+public:
+ AutoFactoryTest();
+ virtual ~AutoFactoryTest();
+ void handle_request(int module,int e =-1);
+ void wifiTest();
+ void wifiTimeout(int e);
+ void gpsTest();
+ void gpsTimeout(int e);
+ void gpsGetResult(int result);
+ void adc0Test();
+ void adcTimes(int e);
+ void adc0Scope(int smallData,int largerData);
+ void simTest();
+ void sim2Test();
+ void getCurrentResult();
+ void getNvCurrentResult();
+ void resetResult();
+ void simTimeout(int e);
+ void audioTest();
+ void audioGetResult(int result);
+ void inputCommand(const char* mCommand);
+ void usbTest();
+ void usbTimeout(int e);
+ static AutoFactoryTest* getInstance();
+ private:
+ static AutoFactoryTest* m_instance;
+ static std::mutex mMutex;
+ sp<ResulTest> resultTest;
+ sp<CommandBase> wifiCommand;
+ sp<CommandBase> simCommand;
+ sp<CommandBase> sim2Command;
+ sp<CommandBase> adc0Command;
+ sp<CommandBase> usbCommand;
+ sp<ModuleBase> wifiModuleBase;
+ sp<ModuleBase> simModuleBase;
+ sp<ModuleBase> sim2ModuleBase;
+ sp<ModuleBase> adc0ModuleBase;
+ sp<ModuleBase> usbModuleBase;
+
+ pthread_t audioThread;
+
+ int hasPrame(const char* nv_name);
+ int getPrame(const char* nv_name);
+ static void *CommandThread(void *arg);
+ void init();
+};
+#endif /* AUTOFACTOYRTEST_H_ */
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.cpp b/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.cpp
new file mode 100644
index 0000000..42e376b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.cpp
@@ -0,0 +1,78 @@
+#include "CommandBase.h"
+#include "ResulTest.h"
+#include <log/log.h>
+#undef LOG_TAG
+#define LOG_TAG "CommandBase"
+using namespace std;
+
+ CommandBase::CommandBase():mResultTest(ResulTest::getInstance()),
+ mModuleId(-1)
+ {
+
+
+
+
+ }
+ CommandBase::~CommandBase()
+ {
+
+ }
+ int CommandBase::open(const sp<ModuleBase> module,int moduleId)
+ {
+ mModuleBase = module;
+ mRfAutomaticTest = RfAutomaticTest::Create(mModuleBase,mResultTest);
+ mModuleId = moduleId;
+ return 1;
+ }
+ /*
+ void CommandBase::getAutomaticTest()
+ {
+ printf("GpsCommand startTest\n");
+ mRfAutomaticTest->startTest();
+ return 1;
+
+ }*/
+ int CommandBase::startTest()
+ {
+ RLOGD("GpsCommand startTest\n");
+ if(timeout<0)
+ {
+ printf("time not set\n");
+ return -1;
+ }
+ mRfAutomaticTest->handlerStartTest(mModuleId);
+ return 1;
+
+ }
+ int CommandBase:: getCheckResult(int smallData,int largerData)
+ {
+ RLOGD("GpsCommand ,smallData:%d,largerData:%d\n");
+ if(smallData>largerData)
+ {
+ mRfAutomaticTest->handlerGetCheck(largerData,smallData);
+ return 1;
+ }
+ else if(smallData<largerData)
+ {
+ mRfAutomaticTest->handlerGetCheck(smallData,largerData);
+ return 1;
+ }
+ else
+ {
+ printf("Scope data error\n");
+ return 0;
+ }
+
+ }
+ int CommandBase::timeOut(int timeout)//sec
+ {
+ RLOGD("CommandBase timeout:%d\n",timeout);
+ this->timeout = timeout;
+ RLOGD("CommandBase mRfAutomaticTest timeout start:%d\n",timeout);
+ mRfAutomaticTest->handlerTimeout(timeout);
+ RLOGD("CommandBase mRfAutomaticTest timeout end:%d\n",timeout);
+ return 1;
+ }
+
+
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.h b/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.h
new file mode 100644
index 0000000..9435ffe
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/CommandBase.h
@@ -0,0 +1,32 @@
+#ifndef LYNQ_COMMANDBASE_H_
+#define LYNQ_COMMANDBASE_H_
+#include <utils/RefBase.h>
+#include "ResulTest.h"
+#include "rfAutomaticTest.h"
+#include "ModuleBase.h"
+using namespace std;
+using ::android::sp;
+using ::android::RefBase;
+ class CommandBase: public android::RefBase{
+ public:
+ int startTest();
+ int timeOut(int e);
+ virtual int getResult(){ return -1; } //for gps
+ int getCheckResult(int smallData,int largerData);
+ CommandBase();
+ int open(const sp<ModuleBase> module,int moduleId);
+ int mModuleId;
+ protected:
+ sp<ResulTest> mResultTest;
+ sp<RfAutomaticTest> mRfAutomaticTest;
+ sp<ModuleBase> mModuleBase;
+ int timeout;
+
+ virtual ~CommandBase();
+ private:
+
+
+ };
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/FactoryBase.h b/src/lynq/packages/apps/lynq-factorytest/src/FactoryBase.h
new file mode 100644
index 0000000..a3a2377
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/FactoryBase.h
@@ -0,0 +1,19 @@
+#ifndef LYNQ_FACTORYBASE_H_
+#define LYNQ_FACTORYBASE_H_
+
+#include "moduleBase.h"
+using namespace std;
+class factoryBase
+{
+public:
+ virtual moduleBase *productGps()=0;
+ virtual moduleBase *productWifi()=0;
+protected:
+ virtual ~factoryBase(){};
+ factoryBase()
+ {
+ }
+
+};
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/LICENSE b/src/lynq/packages/apps/lynq-factorytest/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/ModuleBase.h b/src/lynq/packages/apps/lynq-factorytest/src/ModuleBase.h
new file mode 100644
index 0000000..6171b04
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/ModuleBase.h
@@ -0,0 +1,25 @@
+#ifndef LYNQ_MODULEBASE_H_
+#define LYNQ_MODULEBASE_H_
+#include <utils/RefBase.h>
+using namespace std;
+
+using ::android::RefBase;
+ class ModuleBase: public virtual RefBase
+ {
+ public:
+ // virtual int Open() { return -1; }
+ virtual int startTest(){ return -1; };
+ virtual int getResult() { return -1; }
+ virtual int endTest() { return -1; };
+ virtual int closeModule() { return -1; };
+
+ //virtual int getHandler(RfAutomaticTest *mRfAutomaticTest)=0;
+ ModuleBase(){}
+ virtual ~ModuleBase(){};
+ private:
+
+ };
+
+#endif
+
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.cpp
new file mode 100644
index 0000000..3dc4ff0
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.cpp
@@ -0,0 +1,176 @@
+#include <memory>
+#include "ResulTest.h"
+#include <log/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "result.h"
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+
+ResulTest* ResulTest::m_instance = NULL;
+std::mutex ResulTest::mMutex;
+#undef LOG_TAG
+#define LOG_TAG "ResulTest"
+
+ResulTest::ResulTest()
+ :gpsResult(1),
+ wifiResult(1),
+ simResult(1),
+ adc0Result(1),
+ usbResult(1),
+ audioResult(1)
+{
+
+}
+ResulTest::~ResulTest() {
+ RLOGD("RfDesenseTxTest destroyed");
+}
+
+void ResulTest::init()
+{
+
+}
+
+void ResulTest::getCurrentResult(){
+ char printBuf[8000];
+ sprintf(printBuf, "+[result][wifi]:%d",wifiResult);
+ sprintf(printBuf, "%s,[gps]:%d",printBuf,gpsResult);
+ sprintf(printBuf, "%s,[sim1]:%d",printBuf,simResult);
+ sprintf(printBuf, "%s,[sim2]:%d",printBuf,sim2Result);
+ sprintf(printBuf, "%s,[usb]:%d",printBuf,usbResult);
+ sprintf(printBuf, "%s,[adc0]:%d\n",printBuf,adc0Result);
+ sprintf(printBuf, "%s,[audio]:%d\n",printBuf,audioResult);
+ RLOGD( "resultGet:%s",printBuf);
+ // adc0_reult =get_prop_by_int(ADC0_NV);
+ LYVERBLOG( "current result:%s",printBuf);
+}
+void ResulTest::resetResult(){
+ gpsResult =1;
+ wifiResult =1;
+ simResult=1;
+ sim2Result = 1;
+ adc0Result=1;
+ usbResult=1;
+ audioResult=1;
+ saveDataToProp(WIFI_NV,1);
+ saveDataToProp(GPS_NV,1);
+ saveDataToProp(SIM_NV,1);
+ saveDataToProp(SIM2_NV,1);
+ saveDataToProp(USB_NV,1);
+ saveDataToProp(ADC0_NV,1);
+ saveDataToProp(AUDIO_NV,1);
+ LYVERBLOG("Reset ok\n");
+}
+
+
+void ResulTest::getNVResult(){
+int wifi_res,gps_res,sim_res,sim1_res,usb30_res,adc0_reult,audio_res;
+ //int adc0_reult;
+ char printBuf[8000];
+
+ wifi_res = get_prop_by_int(WIFI_NV);
+ sprintf(printBuf, "+[result][wifi]:%d",wifi_res);
+ gps_res = get_prop_by_int(GPS_NV);
+ sprintf(printBuf, "%s,[gps]:%d",printBuf,gps_res);
+ sim_res = get_prop_by_int(SIM_NV);
+ sprintf(printBuf, "%s,[sim1]:%d",printBuf,sim_res);
+ sim1_res = get_prop_by_int(SIM2_NV);
+ sprintf(printBuf, "%s,[sim2]:%d",printBuf,sim1_res);
+ usb30_res = get_prop_by_int(USB_NV);
+ sprintf(printBuf, "%s,[usb]:%d",printBuf,usb30_res);
+ adc0_reult =get_prop_by_int(ADC0_NV);
+ sprintf(printBuf, "%s,[adc0]:%d\n",printBuf,adc0_reult);
+ audio_res =get_prop_by_int(AUDIO_NV);
+ sprintf(printBuf, "%s,[audio]:%d\n",printBuf,audio_res);
+ RLOGD( "resultGetNV:%s",printBuf);
+ // adc0_reult =get_prop_by_int(ADC0_NV);
+ LYVERBLOG("NV,%s\n",printBuf);
+
+}
+
+void ResulTest::getTestResult(int moduleId,int e){
+ printf("ResulTest [%d]:%d\n",moduleId,e);
+ RLOGD("ResulTest [%d]:%d\n",moduleId,e);
+ switch (moduleId)
+ {
+ case GPS_M:
+ {
+ saveDataToProp(GPS_NV,e);
+ gpsResult = e;
+ LYVERBLOG("[gps][result],%d\n",e);
+ break;
+ }
+ case WIFI_M:
+ {
+ saveDataToProp(WIFI_NV,e);
+ LYVERBLOG("[wifi][result],%d\n",e);
+ wifiResult = e;
+
+ break;
+ }
+ case SIM_M:
+ {
+ saveDataToProp(SIM_NV,e);
+ LYVERBLOG("[sim1][result],%d\n",e);
+
+ simResult = e;
+ break;
+ }
+ case SIM2_M:
+ {
+ saveDataToProp(SIM2_NV,e);
+ LYVERBLOG("[sim2][result],%d\n",e);
+
+ sim2Result = e;
+ break;
+ }
+ case USB30_M:
+ {
+ saveDataToProp(USB_NV,e);
+ LYVERBLOG("[usb][result],%d\n",e);
+
+ usbResult = e;
+ break;
+ }
+ case ADC0_M:
+ {
+ saveDataToProp(ADC0_NV,e);
+ LYVERBLOG("[adc0][result],%d\n",e);
+
+ adc0Result = e;
+ break;
+ }
+ case AUDIO_M:
+ {
+ saveDataToProp(AUDIO_NV,e);
+ audioResult = e;
+ LYVERBLOG("[audio][result],%d\n",e);
+
+ break;
+ }
+ default:
+ RLOGD("not to do this\n");
+
+
+}
+
+}
+
+
+ResulTest* ResulTest::getInstance()
+{
+ if(!m_instance)
+ {
+ mMutex.lock();
+ if(!m_instance)
+ {
+ m_instance = new ResulTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.h b/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.h
new file mode 100644
index 0000000..4cf74f5
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/ResulTest.h
@@ -0,0 +1,65 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ *
+ * MediaTek Inc. (C) 2016. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+
+#ifndef LYNQ_RESULTEST_H_
+#define LYNQ_RESULTEST_H_
+#include <mutex>
+#include <utils/RefBase.h>
+using namespace std;
+using ::android::sp;
+using ::android::RefBase;
+class ResulTest: public android::RefBase {
+ public:
+ ResulTest();
+ virtual ~ResulTest();
+ void getTestResult(int moduleId,int e);
+ void resetResult();
+ void getCurrentResult();
+ void getNVResult();
+ static ResulTest* getInstance();
+ private:
+ static std::mutex mMutex;
+ static ResulTest* m_instance;
+ void init();
+ int gpsResult;
+ int wifiResult;
+ int simResult;
+ int sim2Result;
+ int adc0Result;
+ int usbResult;
+ int audioResult;
+};
+
+#endif /* AUTOFACTOYRTEST_H_ */
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/adc/Adc0Test.cpp b/src/lynq/packages/apps/lynq-factorytest/src/adc/Adc0Test.cpp
new file mode 100644
index 0000000..3c26734
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/adc/Adc0Test.cpp
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "Adc0Test.h"
+#include <sys/file.h>
+#include <log/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "liblog/lynq_deflog.h"
+
+#ifdef __cplusplus
+}
+#endif
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "Adc0Test"
+#endif
+
+using namespace std;
+
+ Adc0Test* Adc0Test::m_instance = NULL;
+ std::mutex Adc0Test::mMutex;
+
+ int Adc0Test::endTest(){
+ printf("Adc0Test endOpen\n");
+ return 1;
+
+ }
+
+ int Adc0Test::get_adc(const char* command)
+ {
+
+ char buff[128]={0};
+ FILE *cmd = popen(command, "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ LYVERBLOG("+[adc][get][error]\n");
+ return 0;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ pclose(cmd);
+ RLOGD("get_adc,%s\n",buff);
+ return atoi(buff);
+ }
+ }
+ int Adc0Test::getResult()
+ {
+ int adc = get_adc(CAT_ADC0);
+ return adc;
+ }
+
+ void Adc0Test::init(){
+
+ }
+ Adc0Test* Adc0Test::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new Adc0Test();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+ Adc0Test::~Adc0Test(){
+ }
+
+ Adc0Test::Adc0Test(){
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.c.tmp b/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.c.tmp
new file mode 100644
index 0000000..1e136c2
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.c.tmp
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "adc/adc_test.h"
+#include <log/log.h>
+#include <sys/file.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "adctest"
+#endif
+
+ int get_adc(char* command)
+ {
+
+ char buff[128]={0};
+ FILE *cmd = popen(command, "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ LYVERBLOG("+[adc][get][error]\n");
+ return -1;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ return atoi(buff);
+ pclose(cmd);
+ }
+ }
+ int get_adc0()
+ {
+ return get_adc(CAT_ADC0);
+ }
+ int get_adc1()
+ {
+ return get_adc(CAT_ADC1);
+ }
+ int get_adc2()
+ {
+ return get_adc(CAT_ADC2);
+ }
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.h.tmp b/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.h.tmp
new file mode 100644
index 0000000..9af08a8
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/adc/adc_test.h.tmp
@@ -0,0 +1,12 @@
+#ifndef __LYNQ_ADC_TEST_H__
+#define __LYNQ_ADC_TEST_H__
+static const char *CAT_ADC0 = "cat /sys/bus/iio/devices/iio:device0/in_voltage23_ADC0_input";
+static const char *CAT_ADC1 = "cat /sys/bus/iio/devices/iio:device0/in_voltage22_ADC1_input";
+static const char *CAT_ADC2 = "cat /sys/bus/iio/devices/iio:device0/in_voltage21_ADC2_input ";
+
+//static const char *usbUnknow ="UNKNOWN";
+ int get_adc0();
+ int get_adc1();
+ int get_adc2();
+#endif //
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/common.cpp b/src/lynq/packages/apps/lynq-factorytest/src/common.cpp
new file mode 100644
index 0000000..38d0d8e
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/common.cpp
@@ -0,0 +1,117 @@
+#include "common.h"
+#include <log/log.h>
+#include "result.h"
+#include <cutils/properties.h>
+
+AutoFactoryTest* m_RfDesense;
+int get_call(){
+ char property_value[PHONE_SIZE] = { 0 };
+ property_get(PHONE_NUMBER, property_value, "18964376469");
+ RLOGD("factory_manual,property_value:%s\n",property_value);
+ //RIL_Dial *mRIL_Dial = (RIL_Dial *)calloc(1, sizeof(RIL_Dial));
+ //mRIL_Dial->address = property_value;
+ //mRIL_Dial->clir = 0;
+ // return lynq_call(property_value);
+ return 1;
+}
+void register_factory_auto_hook_raw(AutoFactoryTest* rf){
+ if(!m_RfDesense) {
+ m_RfDesense = rf;
+ }
+}
+
+void unregister_factory_auto_hook_raw(){
+ if(m_RfDesense) {
+ m_RfDesense == NULL;
+ }
+}
+int getParameter(const int length, char* string, char* argv[])
+{
+ int num = 0;
+ int count = 0;
+ int i = 0;
+ char* pos= string;
+ //string++;
+ while (1)
+ {
+ if (*pos == '\0')
+ {
+ break;
+ }
+ argv[num++] = pos;
+ while (1)
+ {
+ if ((*pos == '\0'))
+ {
+ break;
+ }
+ if ((*pos == '|') && (*(pos - 1) != '\\'))
+ {
+ count++;
+ break;
+ }
+ pos++;
+ }
+ *pos++ = '\0';
+ }
+ /*
+ for (int i = 0;i < num-1;i++)
+ {
+ printf("agrv[%d]=%s\n", i, argv[i]);
+ }
+ */
+ if(count!=length)
+ {
+ return 0;
+ }
+ return count;
+}
+
+int removeFlag(int argc, char* argv[])
+{
+ char* temp = NULL;
+ char* temp1= NULL;
+ char** pos = argv;
+ for (int i = 0;i < argc+1;i++)
+ {
+ temp1 = pos[i];
+ while (1)
+ {
+ if (*pos[i] == '\0')
+ {
+ break;
+ }
+ if ((*pos[i] == '|') && (*(pos[i] - 1) == '\\'))
+ {
+ temp = pos[i];
+ while (1)
+ {
+ *(pos[i]-1) = *(pos[i]);
+ if (*(pos[i]) == '\0')
+ {
+ break;
+ }
+ pos[i]++;
+ }
+ pos[i] = temp;
+ }
+ pos[i]++;
+ }
+ pos[i] = temp1;
+ }
+ return 0;
+}
+int parseParam(const int length, char* string, char* argv[])
+{
+ int num = 0;
+ if(string ==NULL)
+ {
+ return 0;
+ }
+ if(num = getParameter(length, string, argv))
+ {
+ removeFlag(num,argv);
+ return num;
+ }
+ return 0;
+}
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/common.h b/src/lynq/packages/apps/lynq-factorytest/src/common.h
new file mode 100644
index 0000000..ad7fd74
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/common.h
@@ -0,0 +1,58 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ */
+/* MediaTek Inc. (C) 2010. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+#ifndef __LYNQ_FACTORY_COMMON__
+#define __LYNQ_FACTORY_COMMON__
+#include "AutoFactoryTest.h"
+extern AutoFactoryTest* m_RfDesense;
+static int32_t auto_reqId = 0;
+static int32_t manu_reqId = 0;
+#define PHONE_SIZE 20
+#define NUM_ITEMS(a) (sizeof (a) / sizeof (a)[0])
+#define FACTORY_SH 0
+#define FACTORY_SINGLE_SH 1
+
+typedef struct factory_arry_{
+ char *name; /* main test name. */
+ int subcnt;
+ struct factory_arry_ *subarray; /* Function to call to do the job. */
+ int param; //0 :no parame ,1:normal parame,2:memory data ,3: normal parame and memory data
+ int go_thread; //goto rita thread
+} factory_arry_t;
+int get_call();
+void register_factory_auto_hook_raw(AutoFactoryTest* rf);
+void unregister_factory_auto_hook_raw();
+int parseParam(const int length, char* string, char* argv[]);
+int emResultNotify(const char *str,int command);
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.cpp b/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.cpp
new file mode 100644
index 0000000..112be14
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.cpp
@@ -0,0 +1,91 @@
+# include <stdio.h>
+#include "factoryManual.h"
+#include <unistd.h>
+#include <log/log.h>
+//#include "libtel/lib_tele.h"
+//#include <libtel/lynq_call.h>
+//#include <libtel/lynq_sim.h>
+#include "gpio/gpio_test.h"
+#include<common.h>
+/*
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <gps/gps_test.h>
+#ifdef __cplusplus
+}
+#endif
+*/
+#include <string.h>
+
+#undef LOG_TAG
+#define LOG_TAG "FACTORY_MANUAL"
+//#include "Parcel.h"
+//extern void get_gps_test();
+
+
+int32_t factory_manual(int argc, int multicnt,int *item ,int command){
+
+ int propertyid = item[1];
+ int select = item[2];
+ int32_t token ;
+ /*
+ for (int i = 0;i<10;i++){
+ RLOGD("item%d: %d", i,item[i]);
+ }*/
+ switch (select) {
+ case 0:
+ {/*
+ int32_t status;
+ char output[1024] = {0};
+ const char *addr1 = "10086";
+ lynqCallList * test_call_info;
+ test_call_info = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(test_call_info,0,sizeof(lynqCallList));
+ test_call_info->addr=(char *)malloc(sizeof(char));
+ memset(test_call_info->addr,0,sizeof(char));
+ status = lynq_call(addr1,test_call_info);
+ //printf("status is %x\n",status);
+ printf("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d\n",
+ test_call_info->base.request,test_call_info->addr,test_call_info->base.token,test_call_info->base.e,
+ test_call_info->call_state);
+ //free(test_call_info);
+ sprintf(output, "Factory_result error_code:%d\ndone\n",test_call_info->base.e);
+ emResultNotify(output,command);*/
+ break;
+ }
+ case 1:
+ {/*
+ char output[1024] = {0};
+ static int32_t token;
+ simStatus * sim_status=NULL;
+ sim_status = (simStatus *)malloc(sizeof(simStatus));
+ token = lynq_get_sim_status(sim_status);
+ printf("test process token %x\n",token);
+ printf("card_status:%d,card_type:%d,pin_state:%d,error_code:%d,request:%d,token:%x\n",sim_status->card_status,
+ sim_status->card_type,sim_status->pin_state,sim_status->base.e,sim_status->base.request,sim_status->base.token);
+ sprintf(output, "Factory_result Sim status error_code:%d\ndone\n",sim_status->base.e);
+ emResultNotify(output,command);
+ free(sim_status);
+ sim_status=NULL;*/
+ break;
+ }
+ case 2:
+ {
+ // get_gps_test();
+ break;
+ }
+ case 3:
+ {
+ int result=set_gpio143();
+ if(result == -1)
+ RLOGE("set gpio error :%d",result);
+ // get_gpio143(command);
+ break;
+ }
+ default:
+ RLOGE("logic eror ");
+ return -1;
+ }
+ return token;
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.h b/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.h
new file mode 100644
index 0000000..218c65c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factoryManual.h
@@ -0,0 +1,8 @@
+#ifndef __LYNQ_FACTORY_MANUAL_API__
+#define __LYNQ_FACTORY_MANUAL_API__
+
+
+#include <sys/types.h>
+int factory_manual(int argc, int multicnt,int *item,int command);
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory.sh b/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory.sh
new file mode 100644
index 0000000..f493a6a
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory.sh
@@ -0,0 +1,109 @@
+#!/bin/bash
+#Copyright (c) 2016, MediaTek Inc. All rights reserved.
+#This software/firmware and related documentation ("MediaTek Software") are protected under relevant copyright laws.
+#The information contained herein is confidential and proprietary to MediaTek Inc. and/or its licensors.
+#Except as otherwise provided in the applicable licensing terms with MediaTek Inc. and/or its licensors, any reproduction,
+#modification, use or disclosure of MediaTek Software, and information contained herein, in whole or in part, shall be strictly prohibited.
+echo "FactoryTest"
+QUITSTRING=""
+EM_COMMAND="FACTORY"
+EM_LAST_COMMAND="FACTORY"
+
+recv_data() {
+ cat <&9 | while read line
+ do
+ result=${line}
+
+ catp=$(ps | grep cat | awk '{print $1}')
+ #echo -e "recv_data,line:$line,QUITSTRING:$QUITSTRING"
+ if [ "$line" != "" ];then
+ if [ "$line" != "stopemdone" -a "$line" != "done" -a "$line" != "only_em_message" ];then
+ echo $line
+ fi
+ if [ "$line" = "done" ];then
+ QUITSTRING="quit"
+ echo $QUITSTRING > /tmp/factory_test/done.temp
+ fi
+ if [ "$line" = "only_em_message" ];then
+ QUITSTRING="only_em_message"
+ echo $QUITSTRING > /tmp/factory_test/done.temp
+ fi
+ if [ "$catp" != "" ];then
+ kill $catp
+ fi
+ fi
+ done
+}
+#open a socket, communicated with Service.
+exec 9<> /dev/udp/127.0.0.1/8000
+
+if [ ! -d "/tmp/factory_test" ];then
+ mkdir /tmp/factory_test
+else
+ rm -rf /tmp/factory_test
+ mkdir /tmp/factory_test
+fi
+
+echo "$EM_COMMAND" >&9
+recv_data
+echo $QUITSTRING
+ISDONE="no"
+while [ "$QUITSTRING" != "quit" ]; do
+ read -p "Select menu:" name
+ if [ $(expr match "$name" ".*quit") != 0 ];then
+ #echo -e "while quit"
+ break
+ fi
+ if [ $(expr match "$name" ".*back") != 0 ];then
+
+ echo "" > /tmp/factory_test/done.temp
+ echo -e "EM_COMMAND:$EM_COMMAND"
+ EM_COMMAND=${EM_COMMAND% *}
+ #EM_COMMAND=$EM_LAST_COMMAND
+ # echo -e "while back,$EM_COMMAND,EM_LAST_COMMAND:$EM_LAST_COMMAND"
+ echo "$EM_COMMAND" >&9
+ recv_data
+ continue
+ fi
+
+ echo -e "\nselect item $name"
+ if [ -n "$name" ]
+ then
+ echo "$EM_COMMAND $name" >&9
+ recv_data
+ fi
+
+ if test -e /tmp/factory_test/done.temp
+ then
+ ISDONE=$(cat /tmp/factory_test/done.temp)
+ fi
+
+
+ if [ "$ISDONE" = "quit" -o "$name" = "" ];then
+ echo "" > /tmp/factory_test/done.temp
+ echo "$EM_COMMAND" >&9
+ recv_data
+ elif [ "$ISDONE" = "only_em_message" ]
+ then
+ while [ "$ISDONE" != "quit" ]
+ do
+ echo "" > /tmp/factory_test/done.temp
+ recv_data
+ done
+ echo "" > /tmp/factory_test/done.temp
+ echo "$EM_COMMAND" >&9
+ recv_data
+ else
+ EM_LAST_COMMAND=$EM_COMMAND
+
+ EM_COMMAND="$EM_LAST_COMMAND $name"
+ #echo -e "EM_LAST_COMMAND:$EM_LAST_COMMAND,EM_COMMAND:$EM_COMMAND"
+ fi
+done
+
+
+echo "recived results done!"
+#close socket R/W
+exec 9>&-
+exec 9<&-
+exit 0
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory_single.sh b/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory_single.sh
new file mode 100644
index 0000000..9c5d202
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factoryOpen/factory_single.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#Copyright (c) [2016], MediaTek Inc. All rights reserved.
+#This software/firmware and related documentation ("MediaTek Software") are protected under relevant copyright laws.
+#The information contained herein is confidential and proprietary to MediaTek Inc. and/or its licensors.
+#Except as otherwise provided in the applicable licensing terms with MediaTek Inc. and/or its licensors, any reproduction,
+#modification, use or disclosure of MediaTek Software, and information contained herein, in whole or in part, shall be strictly prohibited.
+
+echo "FACTORY"
+NAME_TEST=""
+Menu1=$1
+Menu2=$2
+Menu3=$3
+Menu4=$4
+Menu5=$5
+Menu6=$6
+
+
+
+#open a socket, communicated with Service.
+exec 9<> /dev/udp/127.0.0.1/8000
+b=$( tr '[a-z]' '[A-Z]' <<< $Menu1)
+#send Terminal response CMD
+echo "$b"
+echo "FACTORY $b $Menu2 $Menu3" >&9
+#sleep 1
+#close socket R/W
+exec 9>&-
+exec 9<&-
+exit 0
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factory_main.cpp b/src/lynq/packages/apps/lynq-factorytest/src/factory_main.cpp
new file mode 100644
index 0000000..b73592b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factory_main.cpp
Binary files differ
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/factory_main.h b/src/lynq/packages/apps/lynq-factorytest/src/factory_main.h
new file mode 100644
index 0000000..2a16bd1
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/factory_main.h
@@ -0,0 +1,96 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ */
+/* MediaTek Inc. (C) 2010. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+#ifndef __LYNQ_FACTORY_MAIN__
+#define __LYNQ_FACTORY_MAIN__
+#include <cutils/properties.h>
+#include <string>
+#include <vector>
+#include <sys/types.h>
+#include "common.h"
+#define SMS_MESSAGE "persist.factory.message"
+#define GPS_STATUS "persist.gps.status"
+static const int INDEX_PHONENUMB = 0;
+static const int INDEX_SMS_MESSAGE = 1;
+#define SERVER_PORT 8000
+#define BUFFER_SIZE 8192
+
+#define MAX_ARGS 101
+#define PRAME_NONE 0
+#define PARME_NORMAL 1
+#define PARME_DATA 2
+#define PRAME_NORMAL_DATA 3
+static const char *WIFI_CMD ="WIFI";
+static const char *WIFI_TIME_CMD ="WIFI_TIME";
+static const char *SIM1_CMD ="SIM1";
+static const char *SIM2_CMD ="SIM2";
+static const char *SIM_TIME_CMD ="SIM_TIME";
+static const char *GPS_CMD ="GPS";
+static const char *GPS_TIME_CMD ="GPS_TIME";
+
+static const char *USB30_CMD ="USB";
+static const char *USB30_TIME_CMD ="USB_TIME";
+static const char *ADC0_CMD ="ADC0";
+static const char *ADC0_TIMES_CMD ="ADC0_TIMES";
+static const char *ADC0_GET_SCOPE_CMD ="ADC0_SCOPE";
+static const char *ADC1_CMD ="ADC1";
+static const char *ADC2_CMD ="ADC2";
+static const char *AUDIO_CMD ="AUDIO";
+static const char *AUDIO_RESULT_CMD ="AUDIO_RESULT";
+static const char *GET_REUSLT ="RESULT_C";
+static const char *GET_REUSLT_NV ="RESULT_N";
+static const char *RESET_RESULT ="RESET";
+
+static const char *GPIO ="GPIO";
+typedef enum {
+ FACTORY_TEST = 0,
+ API_TEST,
+ DEMO_TEST,
+}TEST_MAIN_ITEM;
+
+/*
+typedef enum {
+ WIFI_OPEN = 1,
+ // WIFI_SCAN,
+ WIFI_CONNECT,
+ WIFI_CLOSE,
+}WIFI_API;*/
+
+
+int32_t getRequestId();
+void factory_init();
+void lynqStartEventLoop(void);
+
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/getRegister.cpp b/src/lynq/packages/apps/lynq-factorytest/src/getRegister.cpp
new file mode 100644
index 0000000..47a47e1
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/getRegister.cpp
@@ -0,0 +1,13 @@
+#include <memory>
+
+#include "AutoFactoryTest.h"
+#include "getRegister.h"
+
+
+static AutoFactoryTest* mTx = NULL;
+int factory_test_result() {
+ if(!mTx) {
+ mTx = AutoFactoryTest::getInstance();
+ }
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/getRegister.h b/src/lynq/packages/apps/lynq-factorytest/src/getRegister.h
new file mode 100644
index 0000000..6c5dc8b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/getRegister.h
@@ -0,0 +1,39 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ *
+ * MediaTek Inc. (C) 2016. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+
+#ifndef LYNQ_GETREGISTER_H_
+#define LYNQ_GETREGISTER_H_
+ int factory_test_result();
+#endif /* AUTOFACTOYRTEST_H_ */
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.cpp b/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.cpp
new file mode 100644
index 0000000..880ad97
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.cpp
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <log/log.h>
+#include "common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblynq-driver-control/libdriver.h"
+#ifdef __cplusplus
+}
+#endif
+#include "gpio/gpio_test.h"
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio143(){
+
+ int result;
+ result = lynq_set_gpio (GPIO_MODE,WIFI_LED_CONTROL,1);
+ return result;
+ // sprintf(output, "gpio set stauts %d\n",result);
+ // printf("%s",output);
+ // emResultNotify(output);
+}
+
+void get_gpio143(int command){
+ char output[1024] = {0};
+ char output1[2048] = {0};
+ lynq_get_gpio (WIFI_LED_CONTROL,output);
+ printf("get_gpio143,%s\n",output);
+ sprintf(output1, "Factory_result gpio143 set state:%s\n",output);
+ printf("%s",output1);
+ emResultNotify(output1,command);
+}
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.h b/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.h
new file mode 100644
index 0000000..9d7008c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gpio/gpio_test.h
@@ -0,0 +1,12 @@
+#ifndef __LYNQ_GPIO_CONTROL__
+#define __LYNQ_GPIO_CONTROL__
+
+#define GPIO_MODE "mode"
+#define GPIO_DIR "dir"
+#define GPIO_OUT "out"
+static constexpr int WIFI_LED_CONTROL = 143;
+int set_gpio143();
+void get_gpio143(int command);
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsCommand.cpp b/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsCommand.cpp
new file mode 100644
index 0000000..786a0df
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsCommand.cpp
@@ -0,0 +1,36 @@
+#include "GpsCommand.h"
+#include "GpsTest.h"
+
+#include "stdio.h"
+using namespace std;
+ GpsCommand* GpsCommand::m_instance = NULL;
+ std::mutex GpsCommand::mMutex;
+ void GpsCommand::init()
+ {
+ mModuleBase = GpsTest::getInstance();
+ open(mModuleBase,GPS_M);
+ }
+ GpsCommand* GpsCommand::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ m_instance = new GpsCommand();
+ m_instance->init();
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+ void GpsCommand::getResult(int result)
+ {
+ if(mRfAutomaticTest!=NULL)
+ {
+ mRfAutomaticTest->getResult(result);
+ }
+ }
+ GpsCommand::~GpsCommand(){
+ }
+
+ GpsCommand::GpsCommand(){
+
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsTest.cpp
new file mode 100644
index 0000000..4a579a4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gps/GpsTest.cpp
@@ -0,0 +1,61 @@
+#include "GpsTest.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "gps/gps_test.h"
+
+#ifdef __cplusplus
+}
+#endif
+#include "stdio.h"
+using namespace std;
+
+ GpsTest* GpsTest::m_instance = NULL;
+ std::mutex GpsTest::mMutex;
+
+
+ int GpsTest::startTest()
+ {
+ printf("gps start open\n");
+ get_gps_test();
+ return 1;
+
+ }
+
+ int GpsTest::endTest(){
+ printf("gps endOpen\n");
+ return 1;
+
+ }
+ int GpsTest::closeModule(){
+ printf("gps closeModule\n");
+ mnld_test_close_gnss_ext();
+ return 1;
+
+ }
+
+
+ void GpsTest::init(){
+
+ }
+ GpsTest* GpsTest::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new GpsTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+ GpsTest::~GpsTest(){
+ }
+
+ GpsTest::GpsTest(){
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_cb.c b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_cb.c
new file mode 100644
index 0000000..4dd28dc
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_cb.c
@@ -0,0 +1,325 @@
+#include<pthread.h>
+#include<stdio.h>
+#include<unistd.h>
+#include<errno.h>
+#include<string.h>
+//#include <sys/time.h>
+//#include <time.h>
+#include"gps/gps_test.h"
+#include <gps/gps_test.h>
+#include"mtk_lbs_utility.h"
+#include <log/log.h>
+#include"result.h"
+extern struct timespec mnld_test_gnss_open_tm;
+extern int mnld_test_ttff;
+extern int mnld_test_session_end;
+GpsLocation_ext location_rslt;
+mnld_test_result mnld_test_result_body;
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+void mnld_test_gps_location_callback(GpsLocation_ext* location)
+{
+
+// memset(&result,0,sizeof(mnld_test_result));
+ if(location->legacyLocation.size == sizeof(GpsLocation_ext))
+ {
+ char output[2048] = {0};
+ RLOGD("===============Update Location Info==================");
+ RLOGD("flags:0x%x", location->legacyLocation.flags);
+ RLOGD("zqc latitude:%.10lf", location->legacyLocation.latitude);
+ RLOGD("zqc longitude:%.10lf", location->legacyLocation.longitude);
+ RLOGD("zqc altitude:%.10lf", location->legacyLocation.altitude);
+ RLOGD("zqc speed:%f", location->legacyLocation.speed);
+ RLOGD("bearing:%f", location->legacyLocation.bearing);
+ RLOGD("timestamp:%d", location->legacyLocation.timestamp);
+ RLOGD("horizontalAccuracyMeters:%f", location->horizontalAccuracyMeters);
+ RLOGD("verticalAccuracyMeters:%f", location->verticalAccuracyMeters);
+ RLOGD("speedAccuracyMetersPerSecond:%f", location->speedAccuracyMetersPerSecond);
+ RLOGD("bearingAccuracyDegrees:%f", location->bearingAccuracyDegrees);
+ memcpy(&(mnld_test_result_body.location), location, sizeof(GpsLocation_ext));
+ sprintf(output, "gps success latitude:%.10lf,longitude:%.10lf\n",
+ location->legacyLocation.latitude,location->legacyLocation.longitude);
+
+ }else {
+ RLOGE("GpsLocation_ext size is wrong");
+ }
+#if 0
+ memcpy(&(result.location), location, sizeof(GpsLocation_ext));
+ if((location->flags & GPS_LOCATION_HAS_ACCURACY) && (mnld_test_ttff == 0))
+ {
+ struct timespec fix_tm;
+ if(clock_gettime(CLOCK_BOOTTIME,&fix_tm) == -1)
+ {
+ result.ttff = 0;
+ RLOGE("[%s]Fail to get time(%s)\r\n",__func__,strerror(errno));
+ }else{
+ RLOGD("Flags:0x%x,start time:%ds,%dns; ttff time:%ds,%dns\r\n",result.location.flags,mnld_test_gnss_open_tm.tv_sec,mnld_test_gnss_open_tm.tv_nsec,fix_tm.tv_sec,fix_tm.tv_nsec);
+ result.ttff = (fix_tm.tv_sec-mnld_test_gnss_open_tm.tv_sec)*1000+((fix_tm.tv_nsec-mnld_test_gnss_open_tm.tv_nsec)/1000000);
+ mnld_test_ttff = result.ttff;
+ RLOGD("TTFF:%dms",mnld_test_ttff);
+ }
+ }else{
+ result.ttff = mnld_test_ttff;
+ }
+ result.location.timestamp = location->timestamp;
+ RLOGD("ts:%d,result.timestamp:%ld\r\n",location->timestamp,result.location.timestamp);
+ mnld_test_show_test_result(&result);
+ }else{
+ RLOGE("[%s]size error!\r\n", __func__);
+ }
+#endif
+
+}
+
+void mnld_test_gps_status_callback(GpsStatus* status)
+{
+ if(status->size == sizeof(GpsStatus))
+ {
+ RLOGD("GPS Status:%d", status->status);
+ if(status->status == GPS_STATUS_SESSION_BEGIN)
+ {
+ mnld_test_ttff = 0;
+ mnld_test_session_end = 0;
+// usleep(500000);
+ mnld_test_get_mnl_ver();
+ #ifdef MNLD_TEST_TTFF_SESSION_BEGIN
+ if(clock_gettime(CLOCK_BOOTTIME,&mnld_test_gnss_open_tm) == -1)
+ {
+ RLOGE("Fail to get time(%s).", strerror(errno));
+ }
+ #endif
+ }
+ if(status->status == GPS_STATUS_SESSION_BEGIN){
+ mnld_test_result_body.gps_status = SUCCESS_F;
+ }else if(status->status == GPS_STATUS_NONE){
+ mnld_test_result_body.gps_status = ERROR_F;
+ }
+ RLOGD("gps_status:%d",mnld_test_result_body.gps_status);
+
+ if(status->status == GPS_STATUS_SESSION_END)
+ {
+ mnld_test_session_end = 1;
+ }
+ }else{
+ RLOGE("size error!");
+ }
+}
+
+void mnld_test_gps_sv_status_callback(GpsSvStatus* sv_info)
+{
+ RLOGD("gps sv status");
+}
+
+#define NMEA_GGA "GGA"
+#define NMEA_GSA "GSA"
+#define NMEA_GSV "GSV"
+#define NMEA_ACC "ACCURACY"
+extern int valid_ttff_cnt;
+extern int valid_ttff_sum;
+
+void snr_param(char *nmea,char *output,int counter)
+{
+ int i=0, j=0;
+ char *p=nmea;
+ char *buf=NULL;
+
+ while((char)(*p)!='\0')
+ {
+ if((char)(*p)==',')
+ {
+ if(i==counter)
+ {
+ buf=p+1;
+ while((char)(*buf)!='\0' && (char)(*buf)!=',')
+ {
+ j++;
+ buf++;
+ }
+ strncpy(output,p+1,j);
+ return;
+ }
+ i++;
+ }
+ p++;
+ }
+}
+
+
+void mnld_test_gps_nmea_callback(GpsUtcTime timestamp, const char* nmea, int length)
+{
+// RLOGD("%d",timestamp);
+
+ //$GPGSA,A,3,...
+
+ if( strncmp(nmea+3,NMEA_GSA,strlen(NMEA_GSA)) == 0 )
+ {
+ mnld_test_result_body.fix_type = *(nmea+9) - '0';
+ if(mnld_test_result_body.fix_type == 1)
+ {
+ mnld_test_result_body.fix_type = 0;
+ }
+
+ if((mnld_test_ttff == 0) && mnld_test_result_body.fix_type != 0)
+ {
+ struct timespec fix_tm;
+
+ if(clock_gettime(CLOCK_BOOTTIME,&fix_tm) == -1)
+ {
+ mnld_test_result_body.ttff[CURR] = 0;
+ RLOGE("[%s]Fail to get time(%s)\r\n",__func__,strerror(errno));
+ }else{
+ // RLOGD("Flags:0x%x,start time:%ds,%dns; ttff time:%ds,%dns\r\n",mnld_test_result_body.location.flags,mnld_test_gnss_open_tm.tv_sec,mnld_test_gnss_open_tm.tv_nsec,fix_tm.tv_sec,fix_tm.tv_nsec);
+ mnld_test_ttff = (fix_tm.tv_sec-mnld_test_gnss_open_tm.tv_sec)*1000+((fix_tm.tv_nsec-mnld_test_gnss_open_tm.tv_nsec)/1000000);
+ mnld_test_result_body.ttff[CURR] = mnld_test_ttff;
+ valid_ttff_cnt++;
+ valid_ttff_sum+=mnld_test_result_body.ttff[CURR];
+
+ mnld_test_result_body.ttff[MEAN] = valid_ttff_sum/valid_ttff_cnt;
+ //Find the MIN TTFF
+ if((mnld_test_result_body.ttff[MIN] == 0 ) || (mnld_test_result_body.ttff[MIN] > mnld_test_result_body.ttff[CURR]))
+ {
+ mnld_test_result_body.ttff[MIN] = mnld_test_result_body.ttff[CURR];
+ }
+ // Find the MAX TTFF
+ if(mnld_test_result_body.ttff[MAX] < mnld_test_result_body.ttff[CURR])
+ {
+ mnld_test_result_body.ttff[MAX] = mnld_test_result_body.ttff[CURR];
+ }
+ RLOGD("TTFF:%dms",mnld_test_ttff);
+ }
+
+ }else{
+ mnld_test_result_body.ttff[CURR] = mnld_test_ttff;
+ }
+ }
+
+ if(mnld_test_result_body.fix_type != 0)
+ {
+ //GNGGA,hhmmss.mss,...
+ if(strncmp(nmea+3,NMEA_GGA,strlen(NMEA_GGA)) == 0)
+ {
+ strncpy(mnld_test_result_body.utc_time, nmea+7, MNL_UTC_TIME_LEN);
+ mnld_test_result_body.utc_time[MNL_UTC_TIME_LEN-1] = '\0';
+ }
+ }else{
+ memset(mnld_test_result_body.utc_time, 0, MNL_UTC_TIME_LEN);
+ mnld_test_result_body.utc_time[0] = '-';
+ }
+
+ if(strncmp(nmea+3,NMEA_ACC,strlen(NMEA_ACC)) == 0)
+ {
+ mnld_test_result_body.location.legacyLocation.timestamp = timestamp;
+ mnld_test_show_test_result(&mnld_test_result_body);
+ //RLOGD("gps_status:%d,fix_type:%d",mnld_test_result_body.gps_status,mnld_test_result_body.fix_type);
+ if((mnld_test_result_body.gps_status==SUCCESS_F)&&(mnld_test_result_body.fix_type==CNR3))
+ {
+ mnld_get_gps_status(SUCCESS_F);
+ }
+ else
+ {
+ mnld_get_gps_status(ERROR_F);
+ }
+
+ }
+ if(strncmp(nmea+3,NMEA_GSV,strlen(NMEA_GSV)) == 0)
+ {
+ // char snr[8];
+ // char *test="GPGSV,4,1,13,03,00,234,,07,02,306,23,08,33,204,33,09,27,308,25*77";
+ // RLOGD("%s\n",test);
+ // LYVERBLOG("+[gps][snr][%s]\n",nmea);
+ RLOGD("+[gps][snr][%s]\n",nmea);
+ // snr_param(test,snr,7);
+ // RLOGD("zhouqunchao,%s\n",snr);
+
+ }
+
+
+}
+
+void mnld_test_gps_set_capabilities(uint32_t capabilities)
+{
+
+ RLOGD("gps set capabilities");
+}
+
+void mnld_test_gps_acquire_wakelock(void)
+{
+
+ RLOGD("gps acquire wakelock");
+}
+
+void mnld_test_gps_release_wakelock(void)
+{
+
+ RLOGD("gps release wakelock");
+}
+
+void mnld_test_gps_request_utc_time(void)
+{
+
+ RLOGD("gps request utc time");
+}
+
+void mnld_test_set_system_info_cb(const GnssSystemInfo* info)
+{
+ RLOGD("set system info");
+}
+
+void mnld_test_gnss_sv_status_cb(GnssSvStatus_ext* sv_info)
+{
+ RLOGD(" zqc gnss sv status");
+}
+
+pthread_t mnld_test_gps_create_thread(const char* name, void (*start)(void *), void* arg)
+{
+ pthread_t ntid = 0;
+ int ret = 0;
+ ret = pthread_create(&ntid, NULL, start, arg);
+
+ if(ret != 0)
+ {
+ RLOGE("thread %s create fail(%s)!", name, strerror(errno));
+ ntid = 0;
+ }else{
+ RLOGD("tread %s create success!", name);
+ }
+
+ return ntid;
+}
+
+void mnld_test_gnss_set_name_cb(const char* name, int length)
+{
+ RLOGD("gnss set name");
+}
+
+void mnld_test_gnss_request_location_cb(bool independentFromGnss)
+{
+ RLOGD("gnss request location");
+}
+
+GpsCallbacks_ext mnld_test_gps_callbacks = {
+ .size = sizeof(GpsCallbacks_ext),
+ .location_cb = mnld_test_gps_location_callback,
+ .status_cb = mnld_test_gps_status_callback,
+ .sv_status_cb = mnld_test_gps_sv_status_callback,
+ .nmea_cb = mnld_test_gps_nmea_callback,
+ .set_capabilities_cb = mnld_test_gps_set_capabilities,
+ .acquire_wakelock_cb = mnld_test_gps_acquire_wakelock,
+ .release_wakelock_cb = mnld_test_gps_release_wakelock,
+ .create_thread_cb = mnld_test_gps_create_thread,
+ .request_utc_time_cb = mnld_test_gps_request_utc_time,
+ .set_system_info_cb = mnld_test_set_system_info_cb,
+ .gnss_sv_status_cb = mnld_test_gnss_sv_status_cb,
+ .set_name_cb = mnld_test_gnss_set_name_cb,
+ .request_location_cb = mnld_test_gnss_request_location_cb,
+};
+
+GpsCallbacks_ext* mnld_test__get_gps_callbacks(void)
+{
+ return &mnld_test_gps_callbacks;
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.c b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.c
new file mode 100644
index 0000000..95ba31c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.c
@@ -0,0 +1,635 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "hal2mnl_interface.h"
+#include "gps_mtk.h"
+#include "gps/gps_test.h"
+#include "mtk_lbs_utility.h"
+#include <log/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "mnldtest"
+#endif
+
+
+#ifdef CONFIG_GPS_MT3303
+#define MNLD_TEST_CHIP_VER "MT3303"
+#else
+#define MNLD_TEST_CHIP_VER "MT6630"
+#endif
+#define MNLD_TEST_MNL_VER mnld_test_mnl_ver
+#define MNLD_TEST_CLOCK_TYPE 0xFF
+#define MNLD_TEST_CLOCK_BUFF 2
+
+/*Socket port nubmer*/
+#define PORT 7000
+/*The max length of socket receive buffer*/
+#define MNL_TEST_REC_BUFF_LEN 2048
+
+#define MNL_TEST_MNL_VER_PMTK "$PMTK705"
+#define mnld_test_printf printf
+
+GpsCallbacks_ext* mnld_test_cbs = NULL;
+GpsInterface_ext* mnld_test_gpsinfs = NULL;
+gpsStatusCb gps_status_cb = NULL;
+
+int valid_ttff_cnt = 0;
+int valid_ttff_sum = 0;
+
+int mnld_test_session_end = 0;
+int mnld_test_ttff = 0;
+int mnld_test_restart_cnt = 0;
+int mnld_test_restart_time = 0;
+int mnld_test_restart_interval = 0;
+
+int mnld_test_network_type = NETWORK_TYPE_WIFI;
+int mnld_test_network_on = 0;
+int mnld_test_network_roaming = 0;
+
+timer_t mnld_test_restart_timer = 0;
+MNLD_TEST_RESTART_TYPE mnld_test_restart_type = MNLD_TEST_RESTART_TYPE_HOT;
+struct timespec mnld_test_gnss_open_tm;
+char mnld_test_mnl_ver[MNL_VER_LEN];
+extern mnld_test_result mnld_test_result_body;
+
+clock_type mnld_test_clock_type[] = {
+ {0xFE,"Co-Clock"},
+ {0xFF,"TCXO"}
+};
+
+#define MNLD_TEST_NETWORK_TYPE_STR_LEN 8
+const char mnld_test_network_type_str[][MNLD_TEST_NETWORK_TYPE_STR_LEN] = {
+ {"mobile"},
+ {"wifi"}
+};
+
+void mnld_test_show_help(void)
+{
+ RLOGD("ZHOUQUNCHAO,START");
+ mnld_test_printf("MNLD client test :\r\n");
+ mnld_test_printf("------------------------------------------------------------------------------\r\n");
+ mnld_test_printf("The command to start GNSS test:\r\n");
+ mnld_test_printf("\tmnld_test start [start type] [restart times] [restart interval]\r\n");
+ mnld_test_printf("\t\t[start type]: \r\n\t\th/H: hot start;\r\n\t\tw/W: Warm start;\r\n\t\tc/C: Cold start;\r\n\t\tf/F: Full start\r\n");
+ mnld_test_printf("\t\t[restart times]: integer value, range is 0-1000, default is 0(no restart, always on). \r\n");
+ mnld_test_printf("\t\t[restart interval]: integer value, range is 0-3600, the unit is second; the default value is 60\r\n");
+ mnld_test_printf("------------------------------------------------------------------------------\r\n");
+ mnld_test_printf("The command to stop GNSS test:\r\n");
+ mnld_test_printf("\tmnld_test stop\r\n");
+ mnld_test_printf("------------------------------------------------------------------------------\r\n");
+ mnld_test_printf("The command to update network status:\r\n");
+ mnld_test_printf("\tmnld_test network [type] [roaming]\r\n");
+ mnld_test_printf("\t[type]: wifi, mobile, disable\r\n");
+ mnld_test_printf("\t[roaming]: roaming, the mobile network is in roaming state\r\n");
+}
+
+/*
+Function:mnld_test_socket_open
+Description:open and connect a INET socket by given port number
+Param:[IN] port, the port number of socket
+Param:[OUT] fd, the socket fd
+Return:NULL -- some thing is incorrect; Other value -- open and connect sokcet successfully
+*/
+int mnld_test_socket_open(int port)
+{
+ struct sockaddr_in servaddr;
+ int socketfd = 0;
+
+ if((socketfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ {
+ RLOGE("Create socket error:%d,%s\n", errno, strerror(errno));
+ return socketfd;
+ }
+
+ memset(&servaddr, 0, sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(port);
+ servaddr.sin_addr.s_addr = INADDR_ANY;
+
+ if( connect(socketfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0 )
+ {
+ RLOGE("connect error:%d,%s\n", errno, strerror(errno));
+ return -1;
+ }
+
+ return(socketfd);
+}
+
+#ifdef CONFIG_GPS_MT3303
+void mnld_test_get_mnl_ver(void )
+{
+ LOGI("GNSS chip is 3303, there is no MNL.");
+ strcpy(mnld_test_mnl_ver, "GNSS chip is 3303,there is no MNL");
+}
+#else
+#ifdef MTK_ADR_SUPPORT
+void mnld_test_get_mnl_ver(void )
+{
+ LOGI("ADR has used the port 7000, the mnl version is static.");
+ strcpy(mnld_test_mnl_ver, "MNL_VER_18070301ALPS05_5.5U_25");
+}
+#else
+void mnld_test_get_mnl_ver(void )
+{
+ int sock_fd = 0;
+ int rec_len = 0;
+ int raw_socket_connected = 1;
+ char rec_buff[MNL_TEST_REC_BUFF_LEN+1] = {0};
+ char *mnl_ver_addr = NULL;
+ int i = 0;
+ int got_mnl_ver = 0;
+ int retry_cnt = 0;
+
+ if((sock_fd = mnld_test_socket_open(PORT)) < 0 )
+ {
+ RLOGE("Socket open error\n");
+ strcpy(mnld_test_mnl_ver,"UNKNOWN");
+ //raw_socket_connected = 0;
+ }else// if(raw_socket_connected)
+ {
+ char *outbuff = "$PMTK605*31\r\n";
+ int cmd_sent = 0;
+ do{
+ // if((cmd_sent == 0) && send(sock_fd,outbuff,strlen(outbuff)+1, 0) == -1)
+ if((cmd_sent == 0) && hal2mnl_send_pmtk(outbuff,strlen(outbuff)) == -1)
+ {
+ cmd_sent = 0;
+ RLOGE("Socket send error(%s)\n",strerror(errno));
+ }else{
+ cmd_sent = 1;
+ if((rec_len = recv(sock_fd, rec_buff, MNL_TEST_REC_BUFF_LEN, 0)) < 0)
+ {
+ RLOGE("Recieve error(%d):%s\n",errno, strerror(errno));
+ usleep(20000);
+ }else{
+ rec_buff[rec_len] = '\0';
+ if(strncmp(rec_buff, MNL_TEST_MNL_VER_PMTK, strlen(MNL_TEST_MNL_VER_PMTK)) == 0)
+ {
+ mnl_ver_addr = strstr(rec_buff,"MNL_VER");
+ strncpy(mnld_test_mnl_ver, mnl_ver_addr, strlen(mnl_ver_addr));
+ for(i=0;i<strlen(mnld_test_mnl_ver);i++)
+ {
+ if(mnld_test_mnl_ver[i] == ',')
+ {
+ mnld_test_mnl_ver[i] = '\0';
+ break;
+ }
+ }
+ got_mnl_ver = 1;
+ RLOGD("\nRCV[%d]:%s\n", rec_len, rec_buff);
+ }
+ //Parser
+ }
+ }
+ if(retry_cnt ++ >= 5)
+ {
+ RLOGE("Get mnl version fail\r\n");
+ strcpy(mnld_test_mnl_ver,"UNKNOWN");
+ break;
+ }
+ }while(!got_mnl_ver);
+ close(sock_fd);
+ }
+}
+#endif
+#endif
+
+void mnld_test_open_gnss(MNLD_TEST_RESTART_TYPE restart_type, GpsInterface_ext* gps_interface, GpsCallbacks_ext* gps_cbs)
+{
+ GpsCallbacks_ext* cbs = gps_cbs;
+ GpsInterface_ext* gpsinterface = gps_interface;
+ switch(restart_type) {
+ case MNLD_TEST_RESTART_TYPE_HOT:
+ RLOGD("Hot Start\n");
+ hal2mnl_gps_delete_aiding_data(GPS_DELETE_RTI);
+ break;
+ case MNLD_TEST_RESTART_TYPE_WARM:
+ RLOGD("Warm Start\n");
+ hal2mnl_gps_delete_aiding_data(GPS_DELETE_EPHEMERIS);
+ break;
+ case MNLD_TEST_RESTART_TYPE_COLD:
+ RLOGD("Cold Start\n");
+ hal2mnl_gps_delete_aiding_data(GPS_DELETE_EPHEMERIS |
+ GPS_DELETE_POSITION | GPS_DELETE_TIME | GPS_DELETE_IONO |
+ GPS_DELETE_UTC | GPS_DELETE_HEALTH);
+ break;
+ case MNLD_TEST_RESTART_TYPE_FULL:
+ RLOGD("Full Start\n");
+ hal2mnl_gps_delete_aiding_data(GPS_DELETE_ALL);
+ break;
+ default:
+ RLOGE("ERR: read unhandled value=[%d]\n", restart_type);
+ return;
+ }
+ if(gpsinterface != NULL && cbs != NULL)
+ {
+ gpsinterface->init(cbs);
+ //hal2mnl_update_network_state(1,NETWORK_TYPE_WIFI,0,"NULL");
+ //hal2mnl_update_network_state(mnld_test_network_on,mnld_test_network_type,mnld_test_network_roaming,"NULL");
+ gpsinterface->start();
+ memset(&(mnld_test_result_body.location),0,sizeof(GpsLocation));
+ mnld_test_result_body.fix_type = 0;
+ mnld_test_ttff = 0;
+ mnld_test_session_end = 0;
+ // usleep(500000);
+ // mnld_test_connect_mnl();
+ #ifndef MNLD_TEST_TTFF_SESSION_BEGIN
+ if(clock_gettime(CLOCK_BOOTTIME,&mnld_test_gnss_open_tm) == -1)
+ {
+ RLOGE("Fail to get time(%s).",strerror(errno));
+ }
+ #endif
+ }else{
+ RLOGE("param error:%d, %d",gpsinterface, cbs);
+ }
+}
+
+void mnld_test_close_gnss(GpsInterface_ext* gps_interface)
+{
+ GpsInterface_ext* gpsinterface = gps_interface;
+// gpsinterface = gps_device__get_gps_interface("mnld_test stop");
+ if(gpsinterface != NULL)
+ {
+ gpsinterface->cleanup();
+ gpsinterface->stop();
+ }else{
+ RLOGE("[%s]param error\r\n",__func__);
+ }
+
+}
+int mnld_test_close_gnss_ext(){
+ mnld_test_close_gnss(mnld_test_gpsinfs);
+ //mnld_test_result_body = NULL;
+ memset(&mnld_test_result_body, 0, sizeof(mnld_test_result));
+ //free(mnld_test_result_body);
+ return 1;
+
+}
+void mnld_test_gnss_restart(void)
+{
+ int retry_cnt = 0;
+ if(mnld_test_restart_cnt < mnld_test_restart_time)
+ {
+ mnld_test_restart_cnt++;
+ mnld_test_close_gnss(mnld_test_gpsinfs);
+ while(!mnld_test_session_end)
+ {
+ if(retry_cnt++>500)
+ {
+ RLOGW("[%s] wait gnss close timeout\r\n",__func__);
+ break;
+ }
+ usleep(10000);
+ }
+ mnld_test_open_gnss(mnld_test_restart_type,mnld_test_gpsinfs,mnld_test_cbs);
+ start_timer(mnld_test_restart_timer,mnld_test_restart_interval*1000);
+ }else{
+ stop_timer(mnld_test_restart_timer);
+ }
+}
+
+char* mnld_test_get_clock_type_str(int clock_type_int)
+{
+ int i = 0;
+ int len = sizeof(mnld_test_clock_type)/sizeof(clock_type);
+
+ for(i=0;i<len;i++)
+ {
+ if(clock_type_int == mnld_test_clock_type[i].type_int)
+ {
+ break;
+ }
+ }
+
+ if(i < len)
+ {
+ return(mnld_test_clock_type[i].type_str);
+ }else{
+ return("Unknown");
+ }
+}
+
+void mnld_test_show_test_result(mnld_test_result* result)
+{
+ if(NULL != result)
+ {
+ memcpy(result->chip_ver,MNLD_TEST_CHIP_VER,sizeof(MNLD_TEST_CHIP_VER));
+ memcpy(result->mnl_ver,MNLD_TEST_MNL_VER,strlen(MNLD_TEST_MNL_VER));
+ result->clk_type = MNLD_TEST_CLOCK_TYPE;
+ result->clk_buff = MNLD_TEST_CLOCK_BUFF;
+
+ //system("clear");
+ RLOGD("---------------------------------------------");
+ RLOGD("Chip:%s",result->chip_ver);
+ RLOGD("MNL Version:%s",result->mnl_ver);
+ RLOGD("Clock Type:%s",mnld_test_get_clock_type_str(result->clk_type));
+ RLOGD("Clock Buffer:%d",result->clk_buff);
+ RLOGD("---------------------------------------------");
+ if(result->ttff[CURR] == 0)
+ {
+ RLOGD("TTFF: - ");
+ }else{
+ RLOGD("TTFF: %d ms",result->ttff[CURR]);
+ }
+
+ if(result->ttff[MIN] == 0)
+ {
+ RLOGD("TTFF min: - ");
+ }else{
+ RLOGD("TTFF min: %d ms",result->ttff[MIN]);
+ }
+
+ if(result->ttff[MAX] == 0)
+ {
+ RLOGD("TTFF max: - ");
+ }else{
+ RLOGD("TTFF max: %d ms",result->ttff[MAX]);
+ }
+
+ if(result->ttff[MEAN] == 0)
+ {
+ RLOGD("TTFF mean: - ");
+ }else{
+ RLOGD("TTFF mean: %d ms",result->ttff[MEAN]);
+ }
+ RLOGD("---------------------------------------------");
+ RLOGD("zqc Fix Type: %d",result->fix_type);
+ //LYVERBLOG("+[gps][cnr][%d]\n",result->fix_type);
+ RLOGD("+[gps][cnr][%d]\n",result->fix_type);
+ RLOGD("zqc Flags: 0x%x",result->location.legacyLocation.flags);
+ RLOGD("zqc Latitude: %.10lf",result->location.legacyLocation.latitude);
+ RLOGD("Longtitude: %.10lf",result->location.legacyLocation.longitude);
+ RLOGD("Altitude: %.10lf",result->location.legacyLocation.altitude);
+ RLOGD("Speed: %fm/s",result->location.legacyLocation.speed);
+ RLOGD("Bearing: %f",result->location.legacyLocation.bearing);
+// RLOGD("Time stamp: %d",result->location.timestamp);
+ RLOGD("horizontalAccuracyMeters: %f",result->location.horizontalAccuracyMeters);
+ RLOGD("verticalAccuracyMeters: %f",result->location.verticalAccuracyMeters);
+ RLOGD("speedAccuracyMetersPerSecond: %f",result->location.speedAccuracyMetersPerSecond);
+ RLOGD("bearingAccuracyDegrees: %f",result->location.bearingAccuracyDegrees);
+ RLOGD("Utc time: %s",result->utc_time);
+ RLOGD("---------------------------------------------");
+ RLOGD("GNSS testing(%d).",mnld_test_restart_cnt);
+ }
+}
+
+void get_gps_test(){
+ void *handle;
+ char *error;
+ struct gps_device_t_ext *gpsdev = NULL;
+ mnld_test_restart_time = 0;
+ mnld_test_restart_interval = 60;//Default is 60s
+ mnld_test_restart_type = MNLD_TEST_RESTART_TYPE_HOT;
+ handle = dlopen(LIB_GNSS_HAL_DIR"/libgpshal.so.0", RTLD_LAZY);
+ if (!handle) {
+ fprintf(stderr, "%s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+ gpsdev = (struct gps_device_t_ext *)dlsym(handle, "linux_gps_device");
+ if ((error = dlerror()) != NULL) {
+ fprintf(stderr, "%s\n", error);
+ exit(EXIT_FAILURE);
+ }
+ mnld_test_gpsinfs = (GpsInterface_ext*)gpsdev->get_gps_interface(gpsdev);
+ RLOGE("zhouqunchao,%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ mnld_test_cbs = mnld_test__get_gps_callbacks();//&mnld_test_gps_callbacks;
+ memset(&mnld_test_result_body,0,sizeof(mnld_test_result));
+ mnld_test_open_gnss(mnld_test_restart_type,mnld_test_gpsinfs,mnld_test_cbs);
+ if(mnld_test_restart_interval != 0)
+ {
+ mnld_test_restart_timer = init_timer(mnld_test_gnss_restart);
+ start_timer(mnld_test_restart_timer,mnld_test_restart_interval*1000);
+ }
+}
+
+
+
+void register_gps_callback(gpsStatusCb cb){
+ gps_status_cb = cb;
+}
+void mnld_get_gps_status(int result){
+ RLOGD("mnld_get_gps_status,%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ gps_status_cb(result);
+}
+/*
+void main(int argc, char** argv)
+{
+ struct sigaction actions;
+
+ actions.sa_handler = daemon_sighlr;
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ sigaction(SIGUSR1, &actions, NULL);
+ sigaction(SIGINT, &actions, NULL);
+ sigaction(SIGTTIN, &actions, NULL);
+ sigaction(SIGKILL, &actions, NULL);
+ sigaction(SIGTERM, &actions, NULL);
+ RLOGD("ZHOUQUNCHAO,START");
+ mnld_test_printf("main zhouqunchao:\r\n");
+ pthread_mutex_init(&main_mutex, NULL);
+ pthread_cond_init(&main_cond, NULL);
+
+ int exit_flag = 0;
+ int cnt = 0;
+ int index = 0;
+ int ret = 0;
+ char input_c = 0;
+ char *error;
+ struct gps_device_t_ext *gpsdev = NULL;
+ void *handle;
+ MNLD_TEST_ACTION action = MNLD_TEST_ACTION_UNKNOWN;
+ //Show the recieved command
+ RLOGD("ZHOUQUNCHAO,START");
+ for(index=0; index<argc; index++)
+ {
+ mnld_test_printf("%s ",argv[index]);
+ }
+ mnld_test_printf("\r\n");
+
+ if(argc >= 2 && argc <= MNLD_TEST_CMD_CNT_MAX)
+ {
+ if(!strncmp(argv[1], MNLD_TEST_CMD_OPEN, strlen(MNLD_TEST_CMD_OPEN)))//Open GNSS
+ {
+ action = MNLD_TEST_ACTION_GNSS_OPEN;
+ //re-init restart parameters
+ mnld_test_restart_time = 0;
+ mnld_test_restart_interval = 60;//Default is 60s
+ mnld_test_restart_type = MNLD_TEST_RESTART_TYPE_HOT;
+
+ switch(argc)
+ {
+ case 5://No break
+ mnld_test_restart_interval = atoi(&argv[4][0]);
+ case 4://No break
+ mnld_test_restart_time = atoi(&argv[3][0]);
+ case 3://No break
+ mnld_test_restart_type = mnld_test_get_restart_type(argv[2][0]);
+ case 2://No break
+ case 1://No break
+ default:
+ break;
+ }
+ RLOGD("mnld_test start.\r\n");
+ if(mnld_test_restart_time > 1000)
+ {
+ RLOGE("The max value of restart time is 1000, %d is over this range\r\n",mnld_test_restart_time);
+ mnld_test_restart_time = 1000;
+ }
+
+ if(mnld_test_restart_interval > 3600)
+ {
+ RLOGE("The max value of restart interval is 3600s(1h), %d is over this range\r\n",mnld_test_restart_interval);
+ mnld_test_restart_interval = 3600;
+ }
+
+ if(mnld_test_restart_time <= 0)//No restart
+ {
+ mnld_test_restart_interval = 0;
+ }
+ RLOGD("restart_time:%d, restart_interval:%ds,restart_type:%d\r\n",mnld_test_restart_time,mnld_test_restart_interval,mnld_test_restart_type);
+ exit_flag = 0;
+ }else if(!strncmp(argv[1],MNLD_TEST_CMD_CLOSE, strlen(MNLD_TEST_CMD_CLOSE))){//Close GNSS
+ action = MNLD_TEST_ACTION_GNSS_CLOSE;
+ RLOGD("mnld_test stop.\r\n");
+ exit_flag = 0;
+ }else if(!strncmp(argv[1], MNLD_TEST_CMD_NETWORK, strlen(MNLD_TEST_CMD_NETWORK))){
+ RLOGD("mnld_test set network.\r\n");
+ exit_flag = 0;
+ if(argc == 3)
+ {
+ if(!strncmp(argv[2], MNLD_TEST_NETWORK_WIFI, strlen(MNLD_TEST_NETWORK_WIFI)))
+ {
+ mnld_test_network_type = NETWORK_TYPE_WIFI;
+ mnld_test_network_on = 1;
+ mnld_test_network_roaming = 0;
+ }else if(!strncmp(argv[2],MNLD_TEST_NETWORK_MOBILE, strlen(MNLD_TEST_NETWORK_MOBILE))){
+ mnld_test_network_type = NETWORK_TYPE_MOBILE;
+ mnld_test_network_on = 1;
+ mnld_test_network_roaming = 0;
+ }else if(!strncmp(argv[2],MNLD_TEST_NETWORK_DISABLE, strlen(MNLD_TEST_NETWORK_DISABLE))) {
+ mnld_test_network_type = NETWORK_TYPE_WIFI;
+ mnld_test_network_on = 0;
+ mnld_test_network_roaming = 0;
+ }else{
+ LOGW("Network set fail!Unknown command!(%d)\r\n", argc);
+ mnld_test_show_help();
+ exit_flag = 1;
+ }
+ }else if(argc == 4){
+ if(!strncmp(argv[2],MNLD_TEST_NETWORK_MOBILE, strlen(MNLD_TEST_NETWORK_MOBILE)) && !strncmp(argv[3],MNLD_TEST_NETWORK_ROAMING, strlen(MNLD_TEST_NETWORK_ROAMING)))
+ {
+ mnld_test_network_type = NETWORK_TYPE_MOBILE;
+ mnld_test_network_on = 1;
+ mnld_test_network_roaming = 1;
+ }else{
+ LOGW("Network set fail!Unknown command!(%d)\r\n", argc);
+ mnld_test_show_help();
+ exit_flag = 1;
+ }
+ }else{
+ LOGW("Network set fail! Error cmd count(%d).\r\n",argc);
+ mnld_test_show_help();
+ exit_flag = 1;
+ }
+
+ RLOGD("network, type:%s, on:%d, roaming:%d.\r\n",mnld_test_network_type_str[mnld_test_network_type], mnld_test_network_on, mnld_test_network_roaming);
+ action = MNLD_TEST_ACTION_SET_NETWORK;
+ }else{
+ RLOGE("Unknown command!\r\n");
+ mnld_test_show_help();
+ exit_flag = 1;
+ }
+ }else{
+ RLOGE("Unknown command!\r\n");
+ mnld_test_show_help();
+ exit_flag = 1;
+ }
+
+ if(!exit_flag)
+ {
+ handle = dlopen(LIB_GNSS_HAL_DIR"/libgpshal.so.0", RTLD_LAZY);
+ if (!handle) {
+ fprintf(stderr, "%s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+
+ gpsdev = (struct gps_device_t_ext *)dlsym(handle, "linux_gps_device");
+ if ((error = dlerror()) != NULL) {
+ fprintf(stderr, "%s\n", error);
+ exit(EXIT_FAILURE);
+ }
+ mnld_test_gpsinfs = (GpsInterface_ext*)gpsdev->get_gps_interface(gpsdev);
+ RLOGE("zhouqunchao,%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ mnld_test_cbs = mnld_test__get_gps_callbacks();//&mnld_test_gps_callbacks;
+ switch(action)
+ {
+ case MNLD_TEST_ACTION_GNSS_OPEN:
+
+ valid_ttff_cnt = 0;
+ valid_ttff_sum = 0;
+
+ memset(&mnld_test_result_body,0,sizeof(mnld_test_result));
+ mnld_test_open_gnss(mnld_test_restart_type,mnld_test_gpsinfs,mnld_test_cbs);
+ //system("clear");
+ if(mnld_test_restart_interval != 0)
+ {
+ mnld_test_restart_timer = init_timer(mnld_test_gnss_restart);
+ start_timer(mnld_test_restart_timer,mnld_test_restart_interval*1000);
+ }
+ pthread_mutex_lock(&main_mutex);
+ while(main_running) {
+ LOGI("main thread going....\n");
+ pthread_cond_wait(&main_cond, &main_mutex);
+ LOGI("some signal catched, go to exit!!!\n");
+ }
+ pthread_mutex_unlock(&main_mutex);
+ exit_flag = 1;
+ break;
+
+ case MNLD_TEST_ACTION_GNSS_CLOSE:
+ mnld_test_close_gnss(mnld_test_gpsinfs);
+
+ exit_flag = 1;
+ break;
+
+ case MNLD_TEST_ACTION_SET_NETWORK:
+
+ ret = hal2mnl_update_network_state(mnld_test_network_on,mnld_test_network_type,mnld_test_network_roaming,"NULL");
+ if(-1 == ret)
+ {
+ RLOGE("Network set fail!\r\n");
+ }else{
+ RLOGD("Network set successfully! type: %s,on:%d,roaming:%d\r\n",mnld_test_network_type_str[mnld_test_network_type],mnld_test_network_on,mnld_test_network_roaming);
+ }
+ exit_flag = 1;
+ break;
+
+ default:
+ LOGW("Unknown action(%d)\r\n",action);
+ mnld_test_show_help();
+ break;
+ }
+
+ }
+ pthread_cond_destroy(&main_cond);
+ pthread_mutex_destroy(&main_mutex);
+}
+*/
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.h b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.h
new file mode 100644
index 0000000..e4a14bd
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/gps/gps_test.h
@@ -0,0 +1,89 @@
+#ifndef __LYNQ_GPS_TEST_H__
+#define __LYNQ_GPS_TEST_H__
+#include <gps_mtk.h>
+
+#define MNLD_TEST_CMD_OPEN "start"
+#define MNLD_TEST_CMD_CLOSE "stop"
+#define MNLD_TEST_CMD_NETWORK "network"
+#define MNLD_TEST_NETWORK_WIFI "wifi"
+#define MNLD_TEST_NETWORK_MOBILE "mobile"
+#define MNLD_TEST_NETWORK_ROAMING "roaming"
+#define MNLD_TEST_NETWORK_DISABLE "disable"
+
+#define MNL_VER_LEN 52
+#define MNL_UTC_TIME_LEN 11
+#define MNLD_TEST_TTFF_SESSION_BEGIN
+
+typedef enum{
+ MNLD_TEST_ACTION_UNKNOWN = -1,
+ MNLD_TEST_ACTION_GNSS_OPEN,
+ MNLD_TEST_ACTION_GNSS_CLOSE,
+ MNLD_TEST_ACTION_SET_NETWORK,
+ MNLD_TEST_ACTION_MAX
+} MNLD_TEST_ACTION;
+
+typedef enum{
+ MNLD_TEST_RESTART_TYPE_UNKNOWN = -1,
+ MNLD_TEST_RESTART_TYPE_HOT,
+ MNLD_TEST_RESTART_TYPE_WARM,
+ MNLD_TEST_RESTART_TYPE_COLD,
+ MNLD_TEST_RESTART_TYPE_FULL,
+ MNLD_TEST_RESTART_TYPE_MAX
+} MNLD_TEST_RESTART_TYPE;
+
+typedef enum{
+ CURR = 0,
+ MIN = 1,
+ MAX = 2,
+ MEAN = 3,
+ TTFF_NUM
+}MNLD_TEST_TTFF;
+typedef enum {
+ CNR1 = 1,
+ CNR2 = 2,
+ CNR3 = 3,
+ } CNR_DATA;
+typedef struct {
+ char chip_ver[12];
+ char mnl_ver[MNL_VER_LEN];
+ char clk_type;
+ char clk_buff;
+ int gps_status;
+ int ttff[TTFF_NUM];//time-to-first_fix in ms
+ int fix_type;
+ GpsLocation_ext location;
+ char utc_time[MNL_UTC_TIME_LEN];
+}mnld_test_result;
+
+typedef struct{
+ char type_int;
+ char type_str[10];
+}clock_type;
+
+#define MNLD_TEST_CMD_CNT_MAX 5
+#define GPS_DELETE_EPHEMERIS 0x0001
+#define GPS_DELETE_ALMANAC 0x0002
+#define GPS_DELETE_POSITION 0x0004
+#define GPS_DELETE_TIME 0x0008
+#define GPS_DELETE_IONO 0x0010
+#define GPS_DELETE_UTC 0x0020
+#define GPS_DELETE_HEALTH 0x0040
+#define GPS_DELETE_SVDIR 0x0080
+#define GPS_DELETE_SVSTEER 0x0100
+#define GPS_DELETE_SADATA 0x0200
+#define GPS_DELETE_RTI 0x0400
+#define GPS_DELETE_CELLDB_INFO 0x8000
+#define GPS_DELETE_ALL 0xFFFF
+typedef void *GPS_HANDLE;
+typedef void (*gpsStatusCb)(int stauts);
+GpsCallbacks_ext* mnld_test__get_gps_callbacks(void);
+//GpsInterface* gps_device__get_gps_interface(struct gps_device_t* device);
+
+void mnld_test_show_test_result(mnld_test_result* result);
+void mnld_test_get_mnl_ver(void);
+int mnld_test_close_gnss_ext();
+void register_gps_callback(gpsStatusCb cb);
+void get_gps_test();
+
+
+#endif //__MNLD_TEST_H__
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/Adc0Test.h b/src/lynq/packages/apps/lynq-factorytest/src/include/Adc0Test.h
new file mode 100644
index 0000000..5ba0231
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/Adc0Test.h
@@ -0,0 +1,25 @@
+
+#ifndef LYNQ_ADC0TEST_H_
+#define LYNQ_ADC0TEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+static const char *CAT_ADC0 = "cat /sys/bus/iio/devices/iio:device0/in_voltage23_ADC0_input";
+using namespace std;
+ class Adc0Test :public ModuleBase
+ {
+ public:
+ static Adc0Test* getInstance();
+ virtual int endTest();
+ virtual int getResult();
+ Adc0Test();
+ private:
+ ~Adc0Test();
+ void init();
+ int get_adc(const char* command);
+ static Adc0Test* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/GpsCommand.h b/src/lynq/packages/apps/lynq-factorytest/src/include/GpsCommand.h
new file mode 100644
index 0000000..348b623
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/GpsCommand.h
@@ -0,0 +1,29 @@
+
+#ifndef LYNQ_COMMAND_H_
+#define LYNQ_COMMAND_H_
+#include "CommandBase.h"
+#include "ModuleBase.h"
+
+#include <mutex>
+using namespace std;
+ class GpsCommand :public CommandBase
+ {
+ public:
+ static GpsCommand* getInstance();
+ // virtual int startTest();
+ // virtual int timeout();
+ void getResult(int result);
+
+ GpsCommand();
+ private:
+ ~GpsCommand();
+ void init();
+ int mTimeOut;
+ static GpsCommand* m_instance;
+ static std::mutex mMutex;
+
+ //sp<RfAutomaticTest> mRfAutomaticTest;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/GpsTest.h b/src/lynq/packages/apps/lynq-factorytest/src/include/GpsTest.h
new file mode 100644
index 0000000..30dcb82
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/GpsTest.h
@@ -0,0 +1,26 @@
+
+#ifndef LYNQ_GPSTEST_H_
+#define LYNQ_GPSTEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+
+using namespace std;
+ class GpsTest :public ModuleBase
+ {
+ public:
+ static GpsTest* getInstance();
+ virtual int startTest();
+ virtual int endTest();
+ virtual int closeModule() ;
+ int mTimeOut;
+ GpsTest();
+ private:
+ ~GpsTest();
+ void init();
+ static GpsTest* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/Sim2Test.h b/src/lynq/packages/apps/lynq-factorytest/src/include/Sim2Test.h
new file mode 100644
index 0000000..a96a459
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/Sim2Test.h
@@ -0,0 +1,27 @@
+
+#ifndef LYNQ_SIM2TEST_H_
+#define LYNQ_SIM2TEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+
+using namespace std;
+ class Sim2Test :public ModuleBase
+ {
+ public:
+ static Sim2Test* getInstance();
+ virtual int startTest();
+ virtual int endTest();
+ virtual int getResult();
+ int mTimeOut;
+ Sim2Test();
+ private:
+ ~Sim2Test();
+ int GetSimStatus();
+ void init();
+ static Sim2Test* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/SimTest.h b/src/lynq/packages/apps/lynq-factorytest/src/include/SimTest.h
new file mode 100644
index 0000000..5761dd4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/SimTest.h
@@ -0,0 +1,27 @@
+
+#ifndef LYNQ_SIMTEST_H_
+#define LYNQ_SIMTEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+
+using namespace std;
+ class SimTest :public ModuleBase
+ {
+ public:
+ static SimTest* getInstance();
+ virtual int startTest();
+ virtual int endTest();
+ virtual int getResult();
+ int mTimeOut;
+ SimTest();
+ private:
+ ~SimTest();
+ int GetSimStatus();
+ void init();
+ static SimTest* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/UsbTest.h b/src/lynq/packages/apps/lynq-factorytest/src/include/UsbTest.h
new file mode 100644
index 0000000..77ab5f4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/UsbTest.h
@@ -0,0 +1,27 @@
+
+#ifndef LYNQ_USBTEST_H_
+#define LYNQ_USBTEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+
+using namespace std;
+static const char *SUPER_SPEED = "super-speed";
+ class UsbTest :public ModuleBase
+ {
+ public:
+ static UsbTest* getInstance();
+ virtual int startTest();
+ virtual int endTest();
+ virtual int getResult();
+ virtual int closeModule() ;
+ UsbTest();
+ private:
+ ~UsbTest();
+ void init();
+ static UsbTest* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/include/WifiTest.h b/src/lynq/packages/apps/lynq-factorytest/src/include/WifiTest.h
new file mode 100644
index 0000000..d7a3456
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/include/WifiTest.h
@@ -0,0 +1,26 @@
+
+#ifndef LYNQ_WIFIEST_H_
+#define LYNQ_WIFIEST_H_
+
+#include "ModuleBase.h"
+#include <mutex>
+
+using namespace std;
+ class WifiTest :public ModuleBase
+ {
+ public:
+ static WifiTest* getInstance();
+ virtual int startTest();
+ virtual int getResult();
+ virtual int endTest();
+ virtual int closeModule() ;
+ WifiTest();
+ private:
+ ~WifiTest();
+ void init();
+ static WifiTest* m_instance;
+ static std::mutex mMutex;
+
+ };
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/main.cpp b/src/lynq/packages/apps/lynq-factorytest/src/main.cpp
new file mode 100644
index 0000000..b167fad
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/main.cpp
@@ -0,0 +1,63 @@
+/*
+* Copyright (C) 2014 MediaTek Inc.
+*
+* Modification based on code covered by the below mentioned copyright
+* and/or permission notice(s).
+*/
+
+/*
+**
+** Copyright 2006 The Android Open Source Project
+**
+** 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
+**
+** http://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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+//#include <vendor-ril/telephony/ril.h>
+#include <log/log.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+//#include <libtel/lib_tele.h>
+//#include "libtel/lynq_call.h"
+//#include "libtel/lynq_sim.h"
+#include <pthread.h>
+#include <sys/types.h>
+#include <factory_main.h>
+#include "common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+#define USER_LOG_TAG "FACTORY"
+#undef LOG_TAG
+#define LOG_TAG "FACTORY_TEST"
+int main(int argc, char **argv) {
+ RLOGD("main\n");
+ LYLOGEINIT(USER_LOG_TAG);
+ LYLOGSET(4);
+ factory_init();
+ lynqStartEventLoop();
+ while (true) {
+ sleep(UINT32_MAX);
+ }
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/makefile b/src/lynq/packages/apps/lynq-factorytest/src/makefile
new file mode 100644
index 0000000..4bc53c2
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/makefile
@@ -0,0 +1,96 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -D__LINUX_OS__ \
+ -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+ LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+ LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+ -DANDROID_MULTI_SIM \
+ -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+ LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+ -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+ -DMD_90_SUPPORT
+endif
+
+
+LOCAL_PATH = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH) \
+ -I$(LOCAL_PATH)/include \
+ -I$(ROOT)$(includedir)/liblynq-driver-control \
+ -I$(ROOT)$(includedir)/libtel \
+ -I$(ROOT)$(includedir)/liblog \
+ -I../gps_hal/inc \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I../gps_hal/inc/hardware \
+ -DLIB_GNSS_HAL_DIR='"$(libdir)"'
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -llynq-tele-ril \
+ -lbinder \
+ -lpthread \
+ -lrt \
+ -llynq-log \
+ -llynq-driver-control \
+ -lgpshal \
+ -lpal \
+
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp gps/*.cpp adc/*.cpp wifi/*.cpp usb/*.cpp gpio/*.cpp sim/*.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c gps/*.c adc/*.c usb/*.c wifi/*.c)
+EXECUTABLE = lynq-factorytest
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+ $(warning ----->build $<)
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/menu/api_menu.h b/src/lynq/packages/apps/lynq-factorytest/src/menu/api_menu.h
new file mode 100644
index 0000000..e4a84df
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/menu/api_menu.h
@@ -0,0 +1,96 @@
+#ifndef __LYNQ_TEST_MENU__
+#define __LYNQ_TEST_MENU__
+#include "common.h"
+/* module api test menu*/
+typedef enum {
+ RIL_API = 0,
+ GPIO_API,
+ WIFI_API,
+ GPS_API,
+ MQTT_API,
+}API_MENU;
+typedef enum {
+ SET_GPIO = 0,
+ GET_GPIO,
+}DRIVER_MENU;
+
+factory_arry_t call_api_menu[] ={
+ {"dail a call",0,NULL,1,0},
+ {"answer call",0,NULL,0,0},
+ {"hang up call",0,NULL,1,0},
+ {"reject call",0,NULL,0,0},
+ {"auto answer call",0,NULL,1,0},
+ {"set mute status",0,NULL,1,0},
+ {"get mute status",0,NULL,0,0},
+ {"set DTMF",0,NULL,1,0},
+ {"set DTMF volume",0,NULL,1,0},
+ {"do multi conference",0,NULL,0,0},
+ {"other call hold",0,NULL,1,0},
+ {"hang up waiting call",0,NULL,0,0},
+ {"hang up foreground and resume background",0,NULL,0,0},
+ {"switch waiting or holding and active ",0,NULL,0,0},
+ {"get last call fail cause",0,NULL,0,0},
+};
+factory_arry_t network_api_menu[] = {
+ {"query operator",0,NULL,0,0},
+ {"query network selection mode",0,NULL,0,0},
+ {"set network selection mode",0,NULL,1,0},
+ {"query available network",0,NULL,0,0},
+ {"query registration state",0,NULL,1,0},
+ {"query prefferred network type",0,NULL,0,0},
+ {"set prefferred network type",0,NULL,1,0},
+ {"query cell info",0,NULL,0,0},
+ {"set unsol cell info list rate",0,NULL,1,0},
+ {"query neighboring cell IDs",0,NULL,0,0},
+ {"set band mode",0,NULL,1,0},
+ {"query available band mode",0,NULL,0,0},
+ {"radio on",0,NULL,1,0},
+ {"query radio tech",0,NULL,0,0},
+ {"solicited signal strength",0,NULL,0,0},
+ {"modem on",0,NULL,1,0},
+};
+factory_arry_t data_api_menu[] ={
+ {"setup data call",0,NULL,0,0},
+ {"deactivte data call",0,NULL,0,0},
+ {"get data call list",0,NULL,0,0},
+
+};
+
+factory_arry_t sim_api_menu[] ={
+ {"get sim status",0,NULL,0,0},
+ {"get imsi",0,NULL,0,0},
+};
+
+factory_arry_t sms_api_menu[] ={
+ {"send sms",0,NULL,1,0},
+ {"ims send sms",0,NULL,1,0},
+ {"write sms to sim",0,NULL,1,0},
+ {"report sms memory status",0,NULL,1,0},
+ {"deleted sms on sim",0,NULL,1,0},
+ {"get smsc address",0,NULL,0,0},
+ {"set smsc address",0,NULL,1,0},
+};
+
+
+factory_arry_t ril_api_menu[] = {
+ {"CALL",NUM_ITEMS(call_api_menu),call_api_menu,1,0},
+ {"NETWORK",NUM_ITEMS(network_api_menu),network_api_menu,1,0},
+ {"DATA",NUM_ITEMS(data_api_menu),data_api_menu,1,0},
+ {"SMS",NUM_ITEMS(sms_api_menu),sms_api_menu,1,0},
+ {"SIM",NUM_ITEMS(sim_api_menu),sim_api_menu,1,0},
+};
+factory_arry_t gpio_api_menu[] = {
+ {"gpio set",0,NULL,1,0},
+ {"gpio get",0,NULL,1,0},
+};
+
+factory_arry_t api_menu[] = {
+ {"Ril",NUM_ITEMS(ril_api_menu),ril_api_menu,0,0},
+ {"gpio",NUM_ITEMS(gpio_api_menu),gpio_api_menu,0,0},
+ {"wifi",0,NULL,0,0},
+ {"gps",0,NULL,0,0},
+ {"mqtt",0,NULL,0,0},
+};
+
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/menu/demo_menu.h b/src/lynq/packages/apps/lynq-factorytest/src/menu/demo_menu.h
new file mode 100644
index 0000000..8f4b145
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/menu/demo_menu.h
@@ -0,0 +1,18 @@
+#ifndef __LYNQ_DEMO_MENU__
+#define __LYNQ_DEMO_MENU__
+#include "common.h"
+/* module api test menu*/
+typedef enum {
+ DEMO_TEST1 = 0,
+ DEMO_TEST2,
+ DEMO_TEST3,
+ DEMO_TEST4,
+}DEMO_ENUM;
+factory_arry_t demo_menu[] = {
+ {"demo1",0,NULL,0,0},
+ {"demo2",0,NULL,0,0},
+ {"demo3",0,NULL,0,0},
+ {"demo4",0,NULL,0,0},
+};
+
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/menu/factory_menu.h b/src/lynq/packages/apps/lynq-factorytest/src/menu/factory_menu.h
new file mode 100644
index 0000000..ffbc4d4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/menu/factory_menu.h
@@ -0,0 +1,27 @@
+#ifndef __LYNQ_FACTORY_MENU__
+#define __LYNQ_FACTORY_MENU__
+#include "common.h"
+factory_arry_t manual_menu[] ={
+ {"telephone test",0,NULL,0,0},
+ {"Sim test",0,NULL,0,0},
+ {"gps test",0,NULL,0,0},
+ {"gpio test",0,NULL,0,0},
+};
+
+factory_arry_t imei_menu[] ={
+ {"imei",0,NULL,0,0},
+};
+
+
+factory_arry_t set_get[] = {
+ {"get",0,NULL,0,0},
+ {"set",0,NULL,1,0},
+};
+factory_arry_t phone_menu[] ={
+ {"phone",NUM_ITEMS(imei_menu),imei_menu,0,0},
+};
+factory_arry_t config[] ={
+ {"Phone number",NUM_ITEMS(set_get),set_get,0,0},
+ {"SMS message",NUM_ITEMS(set_get),set_get,0,0},
+};
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/result.c b/src/lynq/packages/apps/lynq-factorytest/src/result.c
new file mode 100644
index 0000000..f30f11b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/result.c
@@ -0,0 +1,25 @@
+#include <cutils/properties.h>
+#include <log/log.h>
+#include "result.h"
+#include <stdio.h>
+
+void saveDataToProp(const char* nv_name,int data)
+{
+ char property_value[RESULT_SIZE] = { 0 };
+ char property_new[RESULT_SIZE] = { 0 };
+ property_get(nv_name, property_value, "0");
+ RLOGD( "save_prop,property_value:%s,data:%d\n",nv_name,data);
+ if(!(atoi(property_value) == data))
+ {
+ sprintf(property_new, "%d", data);
+ property_set(nv_name, property_new);
+ }
+}
+
+ int get_prop_by_int(const char* nv_name){
+ char property_value[RESULT_SIZE] = { 0 };
+ property_get(nv_name, property_value, "0");
+ RLOGD( "get_prop_by_int,property_value:%s,:%s\n",nv_name,property_value);
+ return (atoi(property_value));
+}
+
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/result.h b/src/lynq/packages/apps/lynq-factorytest/src/result.h
new file mode 100644
index 0000000..8761e58
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/result.h
@@ -0,0 +1,81 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ */
+/* MediaTek Inc. (C) 2010. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+#ifndef __LYNQ_RESULT_H__
+#define __LYNQ_RESULT_H__
+#define PHONE_NUMBER "persist.factory.phone"
+#define WIFI_NV "persist.factory.wifi"
+#define WIFI_TIMEOUT_NV "persist.factory.wifi_timeout"
+#define SIM_NV "persist.factory.sim"
+#define SIM2_NV "persist.factory.sim2"
+#define SIM_TIMEOUT_NV "persist.factory.sim_timeout"
+#define GPS_NV "persist.factory.gps"
+#define GPS_TIMEOUT_NV "persist.factory.gps_timeout"
+#define USB_NV "persist.factory.usb30"
+#define USB_TIMEOUT_NV "persist.factory.usb30.timeout"
+#define ADC0_NV "persist.factory.adc0"
+#define ADC_TIMES_NV "persist.factory.adc.times"
+#define ADC0_SCOPE_SMALL "persist.factory.adc.scope.small"
+#define ADC0_SCOPE_LARGER "persist.factory.adc.scope.larger"
+#define ADC1_NV "persist.factory.adc1"
+#define ADC2_NV "persist.factory.adc2"
+#define AUDIO_NV "persist.factory.audio"
+
+#define RESULT_SIZE 10
+typedef enum
+{
+ START_M = 1,
+ SET_TIMEOUT_M,
+ PUSH_RESULT_M,
+}TEST_COMMAND;
+typedef enum
+{
+ GPS_M = 1,
+ WIFI_M,
+ SIM_M,
+ SIM2_M,
+ USB30_M,
+ ADC0_M,
+ AUDIO_M,
+}TEST_MOUDLE;
+typedef enum
+{
+ NONE_F = 1,
+ SUCCESS_F = 2,
+ ERROR_F = 3,
+}TEST_RESULT;
+
+ void saveDataToProp(const char* nv_name,int result);
+ int get_prop_by_int(const char* nv_name);
+#endif
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.cpp
new file mode 100644
index 0000000..2ff564b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.cpp
@@ -0,0 +1,497 @@
+#include "rfAutomaticTest.h"
+#include "common.h"
+/*
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "gps/gps_test.h"
+#ifdef __cplusplus
+}
+#endif
+*/
+#include <log/log.h>
+#include <stdlib.h>
+#include <cutils/properties.h>
+//#include "libtel/lynq_call.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#include "result.h"
+
+#ifdef __cplusplus
+}
+#endif
+#undef LOG_TAG
+#define LOG_TAG "Factory_RfAutomaticTxTest"
+//extern void get_gps_test();
+//extern C lynq_get_sim_status();
+// Method implements of RequestHandleThread
+RfAutomaticTest::RequestHandleThread::RequestHandleThread(RfAutomaticTest* tx) : m_looper(NULL) {
+ mTx = tx;
+}
+
+RfAutomaticTest::RequestHandleThread::~RequestHandleThread() {
+ mTx = NULL;
+}
+RfAutomaticTest::RfRequestMessage::RfRequestMessage(RfAutomaticTest* tx) : mTx(tx),mMsgType(0),
+ e(2) {
+}
+
+RfAutomaticTest::RfRequestMessage::~RfRequestMessage() {
+}
+
+void RfAutomaticTest::RfRequestHandler::handleMessage(const Message& message) {
+ RLOGD( "handleMessage msg->mMsgType: %d", mMsg->mMsgType);
+ if(mTx != NULL) {
+ mTx->factory_result_save(mMsg);
+ } else {
+ RLOGD( "handleMessage mTx is null");
+ }
+}
+/*
+ void RfAutomaticTest::save_prop(char* nv_name,int result){
+ char property_value[RESULT_SIZE] = { 0 };
+ char property_new[RESULT_SIZE] = { 0 };
+ property_get(nv_name, property_value, "0");
+ RLOGD( "save_prop,property_value:%s,result:%d",nv_name,result);
+ LYVERBLOG("+[nv_name]:%s[result]:%d\n",nv_name,result);
+
+ if(!(atoi(property_value) == result))
+ {
+ sprintf(property_new, "%d", result);
+ property_set(nv_name, property_new);
+ }
+}
+ int RfAutomaticTest::get_prop_by_int(char* nv_name){
+ char property_value[RESULT_SIZE] = { 0 };
+ property_get(nv_name, property_value, "0");
+ RLOGD( "get_prop_by_int,property_value:%s,:%s",nv_name,property_value);
+ return (atoi(property_value));
+}
+
+ void RfAutomaticTest::resultGet(){
+ int wifi_res,gps_res,sim_res,usb30_res,adc0_reult;
+ //int adc0_reult;
+ char printBuf[8000];
+
+ wifi_res = get_prop_by_int(WIFI_NV);
+ sprintf(printBuf, "+[result][wifi]:%d",wifi_res);
+ gps_res = get_prop_by_int(GPS_NV);
+ sprintf(printBuf, "%s,[gps]:%d",printBuf,gps_res);
+ sim_res = get_prop_by_int(SIM_NV);
+ sprintf(printBuf, "%s,[sim]:%d",printBuf,sim_res);
+ usb30_res = get_prop_by_int(USB_NV);
+ sprintf(printBuf, "%s,[usb]:%d",printBuf,usb30_res);
+ adc0_reult =get_prop_by_int(ADC0_NV);
+ sprintf(printBuf, "%s,[adc0]:%d\n",printBuf,adc0_reult);
+ RLOGD( "resultGet:%s",printBuf);
+ // adc0_reult =get_prop_by_int(ADC0_NV);
+ LYVERBLOG("%s\n",printBuf);
+
+}
+
+ int RfAutomaticTest::resultReset(){
+ save_prop(WIFI_NV,0);
+ save_prop(SIM_NV,0);
+ save_prop(GPS_NV,0);
+ save_prop(USB_NV,0);
+ save_prop(ADC0_NV,0);
+ }
+
+
+ int RfAutomaticTest::GetWifiTimeout()
+{
+ char propertySimTimes[RESULT_SIZE] = { 0 };
+ property_get(WIFI_TIMEOUT_NV, propertySimTimes, "0");
+ RLOGD( "GetWifiTimeout:%s",propertySimTimes);
+ return atoi(propertySimTimes);
+
+}*/
+ void RfAutomaticTest::remove_message(int what)
+ {
+ if(mRequestHandleThread.get()) {
+ sp<Looper> looper = mRequestHandleThread->getLooper();
+ if(looper.get()) {
+ looper->removeMessages(mRfRequestHandler,what);
+ } else {
+ RLOGD( "looper fail");
+ }
+ } else {
+ RLOGD( "mRequestHandleThread fail");
+ }
+
+ }
+
+void RfAutomaticTest::testOver(int moduleId,int result)
+{
+ mmResulTest->getTestResult(moduleId,result);
+ state = TESTED;
+ frequency = mTimeout;
+ // moduleBase->closeModule();
+}
+void RfAutomaticTest::generallyMessage(sp<RfRequestMessage> msg)
+{
+ int result;
+ switch((msg->mMsgType)){
+ case START_Q:{
+ state =TESTING;
+ RLOGD( "START_Q,startTest");
+ moduleBase->startTest();
+ //frequency=mTimeout-3;
+ RLOGD( "START_Q,startTest end");
+ handle_request(REPEAT_Q);
+ break;
+ }
+ case REPEAT_Q:
+ {
+ result = moduleBase->getResult();
+ RLOGD( "WIFI_REPEAT_M,REPEAT_Q,result:%d,frequency:%d",result,frequency);
+ if(result == ERROR_F)
+ {
+ if(frequency > 0)
+ {
+ handle_delay(REPEAT_Q,1000);
+ frequency--;
+ break;
+ }
+ else
+ {
+ testOver(moduleId,ERROR_F);
+
+ break;
+ }
+ }
+ else if(result == SUCCESS_F)
+ {
+ testOver(moduleId,SUCCESS_F);
+ }
+ else
+ {
+ RLOGD("can not get this");
+ }
+ break;
+ }
+ default:
+ RLOGE("ERR: not reach this");
+
+
+ }
+}
+void RfAutomaticTest::gpsHandleMessage(sp<RfRequestMessage> msg)
+{
+ switch((msg->mMsgType))
+ {
+ case START_Q:{
+ moduleBase->startTest();
+ state =TESTING;
+ handle_delay(TIMEOUT_Q,mTimeout*1000);
+ RLOGD("factory_result_save,GPS_START_M,mTimeout:%d",mTimeout);
+ break;
+ }
+ case TIMEOUT_Q:{
+ testOver(moduleId,ERROR_F);
+ RLOGD("factory_result_save,GPS_TIMEOUT_M");
+ break;
+ }
+ case GETRESLUT:{
+ int result = msg->e;
+ if (msg->e==SUCCESS_F)
+ {
+ remove_message(GPS_TIMEOUT);
+ testOver(moduleId,SUCCESS_F);
+ }
+ break;
+ }
+ default:
+ RLOGE("ERR: gps not reach this");
+
+ }
+
+}
+
+void RfAutomaticTest::adcHandleMessage(sp<RfRequestMessage> msg)
+{
+ RLOGD("adcHandleMessage moduleId:%d,msg->mMsgType\n",moduleId,msg->mMsgType);
+
+ switch((msg->mMsgType)){
+ case START_Q:{
+ int adc;
+ state =TESTING;
+ adc = moduleBase->getResult();
+ if(adc)
+ adcTotalData = moduleBase->getResult();
+ else
+ testOver(moduleId,ERROR_F);
+ //frequency=mTimeout-3;
+ RLOGD( "START_Q,adcTotalData:result:%d",adcTotalData);
+ handle_delay(REPEAT_Q,10);
+ break;
+ }
+ case REPEAT_Q:
+ {
+ int adc = moduleBase->getResult();
+ if(adc)
+ {
+ adcTotalData = (moduleBase->getResult())+adcTotalData;
+ }
+ else
+ {
+ testOver(moduleId,ERROR_F);
+ }
+ RLOGD( "WIFI_REPEAT_M,REPEAT_Q,adcTotalData:%d,frequency:%d",adcTotalData,frequency);
+ if(frequency > 0)
+ {
+ handle_delay(REPEAT_Q,10);
+ frequency--;
+ break;
+ }
+ else
+ {
+ int a=adcTotalData/mTimeout;
+ RLOGD( "adcTotalData,%d,%d,%d,%d",a,mTimeout,adcScopeSmall,adcScopeLarge);
+ if((a>=adcScopeSmall)&&(a<=adcScopeLarge))
+ testOver(moduleId,SUCCESS_F);
+ else
+ testOver(moduleId,ERROR_F);
+ break;
+ }
+
+ }
+ default:
+ RLOGE("ERR: adc not reach this");
+
+
+ }
+}
+
+
+
+void RfAutomaticTest::factory_result_save(sp<RfRequestMessage> msg)
+{
+ RLOGD("factory_result_save moduleId:%d\n",moduleId);
+
+ switch (moduleId)
+ {
+ case GPS_M:
+ {
+ gpsHandleMessage(msg);
+ break;
+ }
+ case WIFI_M:
+ case SIM_M:
+ case SIM2_M:
+ case USB30_M:
+ {
+ generallyMessage(msg);
+ break;
+ }
+ case ADC0_M:
+ {
+ adcHandleMessage(msg);
+ break;
+ }
+ default:
+ RLOGE("ERR: module not reach this");
+ }
+}
+
+
+sp<RfAutomaticTest::RfRequestHandler> RfAutomaticTest::sendMessage(sp<RfRequestMessage> msg, int delayms) {
+ RLOGD( "sendMessage msg token=%d delayms=%d", msg->mMsgType, delayms);
+
+ mRfRequestHandler->mMsg = msg;
+ if(mRequestHandleThread.get()) {
+ sp<Looper> looper = mRequestHandleThread->getLooper();
+ if(looper.get()) {
+ if (delayms > 0) {
+ looper->sendMessageDelayed(ms2ns(delayms),mRfRequestHandler, mRfRequestHandler->m_dummyMsg);
+ } else {
+ looper->sendMessage(mRfRequestHandler, mRfRequestHandler->m_dummyMsg);
+ }
+ } else {
+ RLOGD( "looper fail");
+ }
+ } else {
+ RLOGD( "mRequestHandleThread fail");
+ }
+
+ return mRfRequestHandler;
+}
+
+RfAutomaticTest::RfRequestHandler:: ~RfRequestHandler() {
+ mTx = NULL;
+ RLOGD( "RfRequestHandler destroyed");
+}
+
+bool RfAutomaticTest::RequestHandleThread::threadLoop() {
+ RLOGD( "RequestHandleThread threadLoop");
+ // start message loop
+ m_looper = Looper::prepare(0);
+ int result;
+ do {
+ result = m_looper->pollAll(-1);
+ RLOGD( "RequestHandleThread threadLoop, pull message result = %d", result);
+ } while (result == Looper::POLL_WAKE || result == Looper::POLL_CALLBACK);
+ return true;
+}
+
+sp<Looper> RfAutomaticTest::RequestHandleThread::getLooper() {
+ return m_looper;
+}
+RfAutomaticTest::RfAutomaticTest(): mCurrentFlag(0),
+ frequency(5),
+ state(NOT_TEST)
+{
+ RLOGD("RfDesenseTxTest RfAutomaticTest\n");
+ // simFrequency = SIM_TIMES;
+
+}
+
+int RfAutomaticTest:: handlerStartTest(int module)
+{
+ RLOGD("RfDesenseTxTest startTest\n");
+ if(state == TESTING)
+ {
+ printf("already testing");
+ return 0;
+ }
+ moduleId = module;
+ RLOGD("RfDesenseTxTest moduleId:%d\n",moduleId);
+ handle_request(START_M);
+ return 1;
+}
+int RfAutomaticTest:: handlerTimeout(int sec)
+{
+ RLOGD("RfDesenseTxTest timeout\n");
+ if(state == TESTING)
+ {
+ printf("already testing");
+ return 0;
+ }
+ mTimeout = sec;
+ frequency = sec;
+ return 1;
+
+}
+
+
+int RfAutomaticTest::handlerGetCheck(int smallData,int largerData)
+{
+ RLOGD("RfDesenseTxTest handlerGetCheck\n");
+ RLOGD("RfDesenseTxTest smallData,largerData:%d,%d\n",smallData,largerData);
+ if(state == TESTING)
+ return 0;
+ adcScopeSmall = smallData;
+ adcScopeLarge = largerData;
+ RLOGD("RfDesenseTxTest adcScopeSmall,adcScopeLarge%d,%d\n",adcScopeSmall,adcScopeLarge);
+}
+int RfAutomaticTest:: getResult(int result)
+{
+ RLOGD("RfDesenseTxTest getResult\n");
+ if((state == TESTING)&&(result ==SUCCESS_F))
+ handle_request(GETRESLUT,result);
+ else
+ RLOGD("RfDesenseTxTest getResult,state:%d,result:%d\n",state,result);
+ return 1;
+}
+RfAutomaticTest::RfAutomaticTest(const sp<ModuleBase> &mModuleBase,const sp<ResulTest> &mResulTest)
+: moduleBase(mModuleBase),
+ mmResulTest(mResulTest),
+ mTimeout(-1),
+ frequency(5),
+ adcScopeSmall(-1),
+ adcScopeLarge(-1),
+ state(NOT_TEST),
+ commonHander(-1),
+ checkdata(-1)
+{
+}
+
+sp<RfAutomaticTest> RfAutomaticTest::Create(
+ const sp<ModuleBase> &mModuleBase,
+ const sp<ResulTest> &mResulTest)
+{
+ sp<RfAutomaticTest> mRfAutomaticTest = new RfAutomaticTest(
+ mModuleBase, mResulTest);
+ RLOGD("RfAutomaticTest Create\n");
+ mRfAutomaticTest->init();
+ return mRfAutomaticTest;
+
+}
+RfAutomaticTest::~RfAutomaticTest() {
+ RLOGD("RfDesenseTxTest destroyed\n");
+}
+
+void RfAutomaticTest::handle_request(int messageId,int e) {
+ sp<RfRequestMessage> msg = new RfRequestMessage(this);
+ RLOGD("RfDesenseTxTest handle_request\n");
+ msg->mMsgType = messageId;
+ msg->e = e;
+ sendMessage(msg, 0);
+}
+/*
+void RfAutomaticTest::gps_start() {
+ handle_delay(GPS_TIMEOUT_M,GPS_TIMEOUT);
+}
+void RfAutomaticTest::get_gps_result(int state) {
+
+ int gps_res = get_prop_by_int(GPS_NV);
+ if(gps_res==state)
+ return;
+ handle_request(GPS_M, state);
+ RLOGD("get_gps_result,GPS_M");
+
+}
+void RfAutomaticTest::set_gps_timout(int time) {
+
+ char mTime[RESULT_SIZE] = { 0 };
+ sprintf(mTime, "%d", time);
+ property_set(GPS_TIMEOUT_NV, mTime);
+ LYVERBLOG("+[wifi_timeout]:%s\n",mTime);
+
+}
+
+ void RfAutomaticTest::audio_result(int result) {
+ char mResult[RESULT_SIZE] = { 0 };
+ int audio_nv = get_prop_by_int(AUDIO_RESULT_NV);
+ if(audio_nv==result)
+ return;
+
+ sprintf(mResult, "%d", result);
+ property_set(AUDIO_RESULT_NV, mResult);
+ LYVERBLOG("+[audio_result]:%s\n",mResult);
+
+}
+void RfAutomaticTest::set_wifi_timeout(int sec) {
+ char time[RESULT_SIZE] = { 0 };
+ //wifiFrequency = sec;
+ sprintf(time, "%d", sec);
+ property_set(WIFI_TIMEOUT_NV, time);
+ LYVERBLOG("+[wifi_timeout]:%s\n",time);
+}
+
+void RfAutomaticTest::get_adc_sampling_times(int times) {
+ char mTimes[RESULT_SIZE] = { 0 };
+ //wifiFrequency = sec;
+ sprintf(mTimes, "%d", times);
+ property_set(ADC_TIMES_NV, mTimes);
+ LYVERBLOG("+[adc_times]:%s\n",mTimes);
+
+}*/
+void RfAutomaticTest::handle_delay(int module,int delayms) {
+ sp<RfRequestMessage> msg = new RfRequestMessage(this);
+ RLOGD("RfDesenseTxTest handle_request\n");
+ msg->mMsgType = module;
+ msg->e = -1;
+ sendMessage(msg, delayms);
+}
+void RfAutomaticTest::init() {
+ RLOGD("RfDesenseTxTest init\n");
+ mRequestHandleThread = new RequestHandleThread(this);
+ mRfRequestHandler = new RfRequestHandler(this);
+ mRequestHandleThread->run();
+ sleep(1);
+}
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.h b/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.h
new file mode 100644
index 0000000..b3c4aa1
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/rfAutomaticTest.h
@@ -0,0 +1,187 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ *
+ * MediaTek Inc. (C) 2016. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+
+#ifndef RFAUTOMATICTEST_H_
+#define RFAUTOMATICTEST_H_
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <mutex>
+#include <thread>
+#include <condition_variable>
+//#include <vendor-ril/telephony/ril.h>
+
+#include <utils/Looper.h>
+#include "ModuleBase.h"
+#include "ResulTest.h"
+#include <utils/Thread.h>
+#include <utils/RefBase.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#include"result.h"
+#ifdef __cplusplus
+}
+#endif
+//#include "libtel/lib_tele.h"
+using namespace std;
+using ::android::Looper;
+using ::android::Thread;
+using ::android::MessageHandler;
+using ::android::Message;
+using ::android::sp;
+using ::android::RefBase;
+
+static const int SIM_TIMES =13;
+static const int GPS_TIMEOUT =20000;
+class RfAutomaticTest: public android::RefBase {
+public:
+ RfAutomaticTest();
+ RfAutomaticTest(
+ const sp<ModuleBase> &mModuleBase,
+ const sp<ResulTest> &mResulTest);
+ static sp<RfAutomaticTest> Create(
+ const sp<ModuleBase> &mModuleBase,
+ const sp<ResulTest> &mResulTest);
+ virtual ~RfAutomaticTest();
+ int AutoFactoryStart();
+ class RequestHandleThread: public Thread {
+ public:
+ RequestHandleThread(RfAutomaticTest* tx);
+ virtual ~RequestHandleThread();
+ sp<Looper> getLooper();
+
+ protected:
+ RfAutomaticTest* mTx;
+ virtual bool threadLoop();
+ private:
+ sp<Looper> m_looper;
+ };
+
+ class RfRequestMessage: public RefBase {
+ public:
+ RfRequestMessage(RfAutomaticTest* tx);
+ virtual ~RfRequestMessage();
+ // void sendMessage(int delayms);
+ public:
+ int mMsgType;
+ int e; //parame
+ private:
+ RfAutomaticTest* mTx;
+ };
+
+ class RfRequestHandler: public MessageHandler {
+ public:
+ RfRequestHandler(RfAutomaticTest* tx): mTx(tx){}
+ virtual ~RfRequestHandler();
+
+ public:
+ // void sendMessage(sp<RfRequestMessage> msg, int delayms);
+ void handleMessage(const Message& message);
+ sp<RfRequestMessage> mMsg;
+ // dummy message that makes handler happy
+ Message m_dummyMsg;
+ private:
+ RfAutomaticTest* mTx;
+ };
+public:
+ int mCurrentFlag;
+ sp<RequestHandleThread> mRequestHandleThread;
+ sp<RfRequestHandler> mRfRequestHandler;
+
+ sp<RfRequestHandler> sendMessage(sp<RfRequestMessage> msg, int delayms);
+ void handle_request(int messageId,int e=-1);
+ void handle_delay(int module,int delayms);
+ void resultGet();
+ int handlerStartTest(int module);
+ int handlerGetCheck(int smallData,int largerData);
+ int handlerTimeout(int sec);
+ int getResult(int result);
+ int modulName;
+ //void clear();
+ int resultReset();
+ void factory_result_save(sp<RfRequestMessage> msg);
+ //int factory_test_result();
+
+private:
+
+ static std::mutex mMutex;
+private:
+
+ int moduleId;
+ int commonHander;
+ int mTimeout;
+ int state;
+ sp<ResulTest> mmResulTest;
+ int frequency;
+ int adcTotalData;
+ int adcScopeSmall;
+ int adcScopeLarge;
+ int checkdata; //get by test
+ void init();
+
+ sp<ModuleBase> moduleBase;
+
+
+ enum messageRequest {
+ START_Q = 1,
+ REPEAT_Q , //wifi,usb,adc
+ GETRESLUT,//gps
+ TIMEOUT_Q ,//gps
+ };
+ enum testState {
+ NOT_TEST = 0,
+ TESTING ,
+ TESTED,
+ };
+ void testOver(int moduleId,int result);
+ void gpsHandleMessage(sp<RfRequestMessage> msg);
+ void generallyMessage(sp<RfRequestMessage> msg);
+ void adcHandleMessage(sp<RfRequestMessage> msg);
+ void remove_message(int what);
+
+ //int GetSimStatus();
+ //void remove_message(int what);
+ //void get_gps_result(int state);
+ //int GetWifiTimeout();
+ //void save_prop(char* nv_name,int result);
+ //int get_prop_by_int(char* nv_name);
+
+
+};
+
+#endif /* RFDESENSETXTEST_H_ */
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/sim/Sim2Test.cpp b/src/lynq/packages/apps/lynq-factorytest/src/sim/Sim2Test.cpp
new file mode 100644
index 0000000..f86e85b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/sim/Sim2Test.cpp
@@ -0,0 +1,66 @@
+#include "Sim2Test.h"
+#include <stdlib.h>
+#include "stdio.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "libtel/lynq_sim.h"
+#include "result.h"
+
+
+#ifdef __cplusplus
+}
+#endif
+
+using namespace std;
+
+Sim2Test* Sim2Test::m_instance = NULL;
+std::mutex Sim2Test::mMutex;
+int Sim2Test::startTest()
+{
+ return lynq_set_default_sim_all(1);
+}
+
+ int Sim2Test::GetSimStatus()
+{
+ return lynq_get_sim_status_ext(1);
+
+}
+ int Sim2Test::getResult(){
+ int result = GetSimStatus();
+ //printf("Sim2Test GetSimStatus,status:%d\n",result);
+ if (result == 1)
+ return 2;
+ else
+ return 3;
+}
+
+
+ int Sim2Test::endTest(){
+ printf("gps endOpen\n");
+ return 1;
+}
+
+
+ void Sim2Test::init(){
+
+ }
+ Sim2Test* Sim2Test::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new Sim2Test();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+Sim2Test::~Sim2Test(){
+}
+Sim2Test::Sim2Test(){
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/sim/SimTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/sim/SimTest.cpp
new file mode 100644
index 0000000..4f3cf05
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/sim/SimTest.cpp
@@ -0,0 +1,67 @@
+#include "SimTest.h"
+#include <stdlib.h>
+#include "stdio.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "libtel/lynq_sim.h"
+#include "result.h"
+
+
+#ifdef __cplusplus
+}
+#endif
+
+using namespace std;
+
+SimTest* SimTest::m_instance = NULL;
+std::mutex SimTest::mMutex;
+int SimTest::startTest()
+{
+ return lynq_set_default_sim_all(0);
+}
+
+ int SimTest::GetSimStatus()
+{
+
+ int status = lynq_get_sim_status_ext(0);
+ // printf("SimTest GetSimStatus,status:%d\n",status);
+ if (status == 1)
+ return 2;
+ else
+ return 3;
+}
+ int SimTest::getResult(){
+ int result = GetSimStatus();
+ return result;
+ }
+
+
+ int SimTest::endTest(){
+ printf("gps endOpen\n");
+ return 1;
+}
+
+
+ void SimTest::init(){
+
+ }
+ SimTest* SimTest::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new SimTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+SimTest::~SimTest(){
+}
+SimTest::SimTest(){
+}
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/usb/UsbTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/usb/UsbTest.cpp
new file mode 100644
index 0000000..ba3af61
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/usb/UsbTest.cpp
@@ -0,0 +1,98 @@
+#include "UsbTest.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <log/log.h>
+#include <sys/file.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#include "result.h"
+
+#ifdef __cplusplus
+}
+#endif
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "Usbtest"
+#endif
+#include "stdio.h"
+using namespace std;
+
+UsbTest* UsbTest::m_instance = NULL;
+std::mutex UsbTest::mMutex;
+
+ int UsbTest::startTest()
+ {
+ char csname[27] = {0};
+ char cmd[256];
+ RLOGD("startTest\n");
+ sprintf(cmd, "usb_switch rndis,acm,p1", csname);
+ int ret = system(cmd);
+ return ret;
+ }
+int UsbTest::getResult()
+{
+ char buff[128]={0};
+ FILE *cmd = popen("cat /sys/devices/platform/soc/11261000.usb/udc/11261000.usb/current_speed", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return ERROR_F;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("+[usb][rat][%s],[%s]\n",buff,SUPER_SPEED);
+ if (strncmp(buff, SUPER_SPEED, strlen(SUPER_SPEED))==0)
+ {
+ RLOGD("getResult,SUCCESS_F\n");
+ return SUCCESS_F;
+ }
+ else
+ {
+ RLOGD("getResult,ERROR_F\n");
+ return ERROR_F;
+ }
+ pclose(cmd);
+ }
+ }
+
+ int UsbTest::endTest()
+ {
+ printf("gps endOpen\n");
+ return 1;
+
+}
+ int UsbTest::closeModule()
+ {
+ char csname[27] = {0};
+ char cmd[256];
+ sprintf(cmd, "usb_switch adb,acm p1", csname);
+ int ret = system(cmd);
+ return ret;
+}
+
+
+ void UsbTest::init(){
+
+ }
+ UsbTest* UsbTest::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new UsbTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+ UsbTest::~UsbTest(){
+ }
+
+ UsbTest::UsbTest(){
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.c.tmp b/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.c.tmp
new file mode 100644
index 0000000..516addf
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.c.tmp
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "usb/usb_test.h"
+#include <log/log.h>
+#include <sys/file.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "usbtest"
+#endif
+
+int open_usb30()
+{
+ char csname[27] = {0};
+ char cmd[256];
+ sprintf(cmd, "usb_switch rndis,acm,p1 PC", csname);
+ int ret = system(cmd);
+ return ret;
+}
+
+
+int close_usb30() {
+ char csname[27] = {0};
+ char cmd[256];
+ sprintf(cmd, "usb_switch adb,acm p1", csname);
+ int ret = system(cmd);
+ return ret;
+ }
+ int get_usb_rate() {
+
+ char buff[128]={0};
+ FILE *cmd = popen("cat /sys/devices/platform/soc/11261000.usb/udc/11261000.usb/current_speed", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 2;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("+[usb][rat][%s]\n",buff);
+ if(strcmp (buff, SUPER_SPEED) == 0)
+ {
+ return 1;
+
+ }
+ else
+ {
+ return 2;
+ }
+ pclose(cmd);
+
+ }
+ }
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.h.tmp b/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.h.tmp
new file mode 100644
index 0000000..1b39e81
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/usb/usb_test.h.tmp
@@ -0,0 +1,9 @@
+#ifndef __LYNQ_USB_TEST_H__
+#define __LYNQ_USB_TEST_H__
+static const char *SUPER_SPEED ="super-speed";
+//static const char *usbUnknow ="UNKNOWN";
+int open_usb30();
+int close_usb30();
+int get_usb_rate();
+#endif //
+
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/wifi/WifiTest.cpp b/src/lynq/packages/apps/lynq-factorytest/src/wifi/WifiTest.cpp
new file mode 100644
index 0000000..b482cce
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/wifi/WifiTest.cpp
@@ -0,0 +1,91 @@
+#include "WifiTest.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <log/log.h>
+#include <sys/file.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "liblog/lynq_deflog.h"
+#include "result.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "WifiTest"
+#endif
+
+using namespace std;
+
+ WifiTest* WifiTest::m_instance = NULL;
+ std::mutex WifiTest::mMutex;
+ int WifiTest::startTest()
+ {
+ printf("Wifi start open\n");
+ int ret = system("connmanctl scan wifi");
+ return ret;
+
+ }
+ int WifiTest::getResult()
+ {
+
+ char buff[128]={0};
+ FILE *cmd = popen("connmanctl services", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return ERROR_F;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ RLOGD("list_wifi, %s",buff);
+ LYVERBLOG("+[wifi][scan]:%s\n",buff);
+ pclose(cmd);
+ return SUCCESS_F;
+ }
+ pclose(cmd);
+ return ERROR_F;
+ }
+
+
+ int WifiTest::endTest(){
+ printf("Wifi endOpen\n");
+ return 1;
+
+ }
+ int WifiTest::closeModule(){
+ int ret = system("connmanctl disable wifi");
+ return ret;
+ //mnld_test_close_gnss_ext();
+
+
+ }
+
+
+ void WifiTest::init(){
+
+ }
+ WifiTest* WifiTest::getInstance()
+ {
+ if (!m_instance)
+ {
+ mMutex.lock();
+ if (!m_instance)
+ {
+ m_instance = new WifiTest();
+ m_instance->init();
+ }
+ mMutex.unlock();
+ }
+ return m_instance;
+ }
+
+ WifiTest::~WifiTest(){
+ }
+
+ WifiTest::WifiTest(){
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.c b/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.c
new file mode 100644
index 0000000..be269ee
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "wifi/wifi_test.h"
+#include <log/log.h>
+#include <sys/file.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "wifitest"
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+
+int open_wifi() {
+ int ret = system("connmanctl enable wifi");
+ return ret;
+ }
+int scan_wifi() {
+ int ret = system("connmanctl scan wifi");
+ return ret;
+ }
+int close_wifi() {
+ int ret = system("connmanctl disable wifi");
+ return ret;
+ }
+int list_wifi() {
+
+ char buff[128]={0};
+ FILE *cmd = popen("connmanctl services", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 2;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ RLOGD("list_wifi, %s",buff);
+ LYVERBLOG("+[wifi][scan]:%s\n",buff);
+ pclose(cmd);
+ return 1;
+ }
+ pclose(cmd);
+ return 2;
+ }
diff --git a/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.h b/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.h
new file mode 100644
index 0000000..991c381
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-factorytest/src/wifi/wifi_test.h
@@ -0,0 +1,8 @@
+#ifndef __LYNQ_WIFI_TEST_H__
+#define __LYNQ_WIFI_TEST_H__
+int open_wifi();
+int scan_wifi();
+int close_wifi();
+int list_wifi();
+
+#endif //__MNLD_TEST_H__
diff --git a/src/lynq/packages/apps/lynq-function-test/src/commands.h b/src/lynq/packages/apps/lynq-function-test/src/commands.h
new file mode 100644
index 0000000..71316d4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/commands.h
@@ -0,0 +1,60 @@
+/*=============================================================================
+** FileName: command.h
+** Desc: about function test
+** Author: Warren
+** Version: V1.0
+** LastChange: 2021-02-26
+** History:
+=============================================================================*/
+//call api
+{"dial",eventDial, "dial a call"},
+{"an",eventAnswer,"answer in coming call"},
+{"atan",eventAutoAnswer,"auto answer mode"},
+{"stme",eventSetMute, "set mute"},
+{"gtme",eventGetMute, "get mute status"},
+{"lcfc",eventLastCallFailCause, "last call fail cause"},
+{"hup",eventCallHangUp, "hang up a call"},
+{"udub",eventRejectCall, "hang up all call or reject a call"},
+{"dtmf",eventSetDTMF, "send DTMF number"},
+{"dtmfv",eventSetDTMFVolume, "set DTMF volume"},
+{"hwc",eventHangupWatingForCall, "hang up waiting or background call"},
+{"hfrb",eventHangupForegroundResumeBackground, "hang up foregound call and resume background call"},
+{"swha",eventSwitchWaitOrHoldAndActiveCall, "switch waiting or holding call to active"},
+{"dmc",eventDoMultiConference, "do multi conference"},
+{"och",eventOthercallHold, "separate conferece"},
+//data api
+{"edc",eventSetupDataCall, "enable data call"},
+{"ddc",eventDeactiveDataCall, "disable data call"},
+{"gdcl",eventGetDataCalllist,"get data call list"},
+//network
+{"qop",eventQueryOperator, "query operator"},
+{"qnsm",eventQueryNetSelectMode, "query network selection mode"},
+{"snsm",eventSetNetSelectMode,"set network selection mode"},
+{"qan",eventQueryAvailableNetwork, "query available network"},
+{"qrs",eventQueryRegistrationState, "query registration state"},
+{"gpnt",eventQueryPrefferredNetworkType,"get preferred network type"},
+{"spnt",eventSetPrefferredNetworkType, "set preferred network type"},
+{"gcil",eventQueryCellInfo, "get cell info list"},
+{"sucilr",eventSetUnsolCellInfoListrate,"set unsol cell info list rate"},
+{"gncid",eventQueryNeighboringCellids, "get neighboring cell IDs"},
+{"sbm",eventSetBandMode, "set band mode"},
+{"qabm",eventQueryAvailableBandmode,"query available band mode"},
+{"rpo",eventRadioOn,"set radio power on/off"},
+{"vrt",eventQueryRadioTech,"voice radio tech"},
+{"sst",eventSolicitedSignalStrength,"singal strength"},
+{"mpo",eventModemOn,"modem power"},
+//sim api
+{"gss",eventGetSimStatus, "get sim status"},
+{"gimsi",eventGetImsi, "get IMSI"},
+//sms api
+{"ssm",eventSendSms,"send sms"},
+{"iss",eventImsSendSms,"send sms over IMS"},
+{"wsts",eventWriteSmsToSim,"write sms to sim card"},
+{"rsms",eventReportSmsMemoryStatus,"report sms memory state"},
+{"dsos",eventDeletSmsOnSim,"delete sms on sim"},
+{"gsmsc",eventGetSmscAddress,"get smsc address"},
+{"ssmsc",eventSetSmscAddress,"set smsc address"},
+{"sstm",evenStoreSmsToMemory,"srore sms to memory"},
+{"gsfm",eventGetSmsFromMemory,"get sms from memory"},
+{"dmfm",eventDeleteMessageFromMemory,"delete sms from memory"},
+{(char *)NULL, NULL, (char *)NULL},
diff --git a/src/lynq/packages/apps/lynq-function-test/src/fota_test.cpp b/src/lynq/packages/apps/lynq-function-test/src/fota_test.cpp
new file mode 100644
index 0000000..adc004b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/fota_test.cpp
@@ -0,0 +1,280 @@
+/*=============================================================================
+** FileName: fota_test.c
+** Desc: about function test
+** Author: victor
+** Version: V1.0
+** LastChange: 2021-10-11
+** History:
+=============================================================================*/
+#include "function_common.h"
+#include <log/log.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "fota_test.h"
+#include "fcntl.h"
+#include "mtk_device_wrap.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "include/iot_rock.h"
+#include "ftp/lynq_ftp.h"
+#ifdef __cplusplus
+}
+#endif
+
+lynq_ftp_socker_info ftp_log_info;
+
+#define UPDATA_ADDR "/tmp/fota.delta"
+#define READ_BLOCK_SIZE 0x20000
+
+int lynq_fota_md5_flag = -1;
+
+#define FLASH_DEV_DELTA "/dev/disk/by-partlabel/delta"
+
+#if 0
+#define BUF_SIZE 1024
+int lynq_fota_str_arr(char *str, char *substr, char parts[][BUF_SIZE])
+{
+ char *p = NULL;
+ char *q = NULL;
+ char tmp[BUF_SIZE] = {0};
+ char end[BUF_SIZE] = {0};
+ int i = 0, j = 0, k = 0, par_num=0;
+
+ char *start = strdup(str);
+
+ while(*str != '\0')
+ {
+ p = str;
+ q = substr;
+ tmp[i] = *str;
+ i++;
+
+ while((*p == *q) && (*p != '\0') && (*q != '\0'))
+ {
+ p++;
+ q++;
+ }
+ if(*q == '\0')
+ {
+ memset(end, 0, sizeof(end));
+ strcpy(end, p);
+
+ memset(parts[j], 0, sizeof(parts[j]));
+
+ j == 0 ? memcpy(parts[j], tmp, strlen(tmp)-1) : memcpy(parts[j], tmp+1, strlen(tmp)-2) ;
+
+ j++;
+ memset(tmp, 0, sizeof(tmp));
+ i = 0;
+ par_num++;
+ }
+
+ str++;
+ }
+
+
+ if (!par_num) {
+ LYDBGLOG("[%s-%d] cmd is error!!!\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error \n");
+ return -1;
+ }
+
+
+ if (strcmp(end, "") != 0) {
+ memset(parts[j], 0, sizeof(parts[j]));
+ memcpy(parts[j], tmp+1, strlen(tmp)-2);
+ }
+
+ for (i = 0 ; i < par_num + 1 ; i++)
+ memcpy(parts[i], strchr(parts[i],'"')+1,strlen(parts[i]));
+
+ return par_num;
+}
+#endif
+
+int lynq_ftp_download_fota_package(char *string[])
+{
+
+ sprintf(ftp_log_info.sevname,"%s",string[1]);
+ LYVERBLOG("[+UP]: sevname:%s\n",ftp_log_info.sevname);
+ ftp_log_info.portnum = atoi(string[2]);
+ LYVERBLOG("[+UP]: portnum:%d\n",ftp_log_info.portnum);
+
+ sprintf(ftp_log_info.username,"%s",string[3]);
+ sprintf(ftp_log_info.pw,"%s",string[4]);
+LYVERBLOG("[+UP]: username:%s\n",ftp_log_info.username);
+LYVERBLOG("[+UP]: pw:%s\n",ftp_log_info.pw);
+
+ sprintf(ftp_log_info.is_pasv_mode,"%s",string[5]);
+ sprintf(ftp_log_info.file_type,"%s",string[6]);
+ sprintf(ftp_log_info.put_opt,"%s",string[7]);
+
+ sprintf(ftp_log_info.getfilename_path,"%s",string[8]);
+ sprintf(ftp_log_info.getfilename,"%s",string[9]);
+ LYVERBLOG("[+UP]: getfilename_path:%s\n",ftp_log_info.getfilename_path);
+
+ LYVERBLOG("[+UP]: Download the FTP data start\n");
+ lynq_ftp_login(&ftp_log_info);
+ lynq_ftp_download(&ftp_log_info);
+ LYVERBLOG("[+UP]: Download the FTP data end\n");
+
+ return 0;
+}
+
+int lynq_md5_fota_package(char *string[])
+{
+ int ret = 0;
+ int fd_down,size,fd_target;
+ char delta_data[READ_BLOCK_SIZE];
+ char input_md5_data[64] = {0};
+
+ sprintf(input_md5_data,"%s",string[0]);
+//LYVERBLOG("[+UP]: input_md5_data:%s\n",input_md5_data);
+ lynq_fota_md5_flag = lynq_md5_file_verfy(UPDATA_ADDR, input_md5_data);
+ if(lynq_fota_md5_flag == 0)
+ {
+ LYVERBLOG("[+UP]: md5 fota package success\n");
+ }
+ else
+ {
+ LYVERBLOG("[+UP]: md5 fota package fail\n");
+ return 1;
+ }
+
+ fd_down = open(UPDATA_ADDR,O_RDONLY);
+ if (fd_down < 0) {
+ LYVERBLOG("[+UP]: open source error\n");
+ return 1;
+ }
+
+ fd_target = mtk_device_wrap_open(FLASH_DEV_DELTA,O_RDWR);
+
+ if (fd_target < 0) {
+ close(fd_down);
+ LYERRLOG("+[UA]: open target error\n");
+ return 1;
+ }
+
+ LYVERBLOG("[+UP]: Get ftp data write to delta\n");
+ while(( size = read(fd_down,delta_data,READ_BLOCK_SIZE))>0) {
+ mtk_device_wrap_write(fd_target,delta_data,READ_BLOCK_SIZE);
+ memset(delta_data,0,READ_BLOCK_SIZE);
+ }
+
+ LYVERBLOG("[+UP]: Store upgrade data to delta success\n");
+
+ mtk_device_wrap_close(fd_target);
+ close(fd_down);
+
+ return 0;
+}
+
+#if 0
+int lynq_md5_fota_package_new(char *string[])
+{
+ int ret = 0;
+ int fd_down,size,fd_target;
+ int total_len = 0,pack_len = 0;
+ char delta_data[READ_BLOCK_SIZE];
+ char input_md5_data[64] = {0};
+
+ sprintf(input_md5_data,"%s",string[0]);
+ pack_len = atoi(string[1]);
+//LYVERBLOG("[+UP]: input_md5_data:%s\n",input_md5_data);
+ lynq_fota_md5_flag = md5_file_verfy_new(FLASH_DEV_DELTA, input_md5_data,pack_len);
+ if(lynq_fota_md5_flag == 0)
+ {
+ LYVERBLOG("[+UP]: md5 fota package success\n");
+ }
+ else
+ {
+ LYVERBLOG("[+UP]: md5 fota package fail\n");
+ return 1;
+ }
+
+ fd_down = open(UPDATA_ADDR,O_RDONLY);
+ if (fd_down < 0) {
+ LYVERBLOG("[+UP]: open source error\n");
+ return 1;
+ }
+
+ fd_target = mtk_device_wrap_open(FLASH_DEV_DELTA,O_RDWR);
+
+ if (fd_target < 0) {
+ close(fd_down);
+ LYERRLOG("+[UA]: open target error\n");
+ return 1;
+ }
+
+ LYVERBLOG("[+UP]: Get ftp data write to delta\n");
+ while(( size = read(fd_down,delta_data,READ_BLOCK_SIZE))>0) {
+ mtk_device_wrap_write(fd_target,delta_data,READ_BLOCK_SIZE);
+ memset(delta_data,0,READ_BLOCK_SIZE);
+ }
+ LYVERBLOG("[+UP]: Store upgrade data to delta success\n");
+
+ mtk_device_wrap_close(fd_target);
+ close(fd_down);
+
+ return 0;
+}
+#endif
+int lynq_fota_func_test(void)
+{
+ int first_run = 1;
+ LYVERBLOG("+[UA]: Upgrade to start\n");
+ if(lynq_fota_md5_flag == 0)
+ {
+ lynq_rock_main(first_run);
+ }
+ else
+ {
+ LYVERBLOG("+[UA]: MD5 verify fail\n");
+ return 1;
+ }
+ LYVERBLOG("+[UA]: Upgrade to end\n");
+ return 0;
+}
+
+int fota_test(char *api,char *string)
+{
+// char argv[20][BUF_SIZE] = {0};
+// int line = lynq_fota_str_arr(string, "\"&", argv)+1;
+ char *argv[100] = {0};
+ parseParameters(string,argv);
+ if(!strcmp(api, "download"))
+ {
+ if(!(strcmp(argv[0], "ftp")))
+ {
+ lynq_ftp_download_fota_package(argv);
+ }
+ else if(!(strcmp(argv[0], "http")))
+ {
+
+ }
+
+ }
+ else if(!(strcmp(api, "md5")))
+ {
+ lynq_md5_fota_package(argv);
+ }
+// else if(!(strcmp(api, "md5new")))
+// {
+// lynq_md5_fota_package_new(argv);
+// }
+ else if(!(strcmp(api, "upgrade")))
+ {
+ lynq_fota_func_test();
+ }
+ else
+ {
+ LYVERBLOG("+[fota][fota_test]: fota api error!!!\n");
+ }
+ return 0;
+}
+
+
diff --git a/src/lynq/packages/apps/lynq-function-test/src/fota_test.h b/src/lynq/packages/apps/lynq-function-test/src/fota_test.h
new file mode 100644
index 0000000..06187d8
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/fota_test.h
@@ -0,0 +1,4 @@
+#ifndef __FOTA_TEST_H__
+#define __FOTA_TEST_H__
+int fota_test(char *api,char *string);
+#endif //__FOTA_TEST_H__
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/function_common.cpp b/src/lynq/packages/apps/lynq-function-test/src/function_common.cpp
new file mode 100644
index 0000000..7d2f170
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/function_common.cpp
@@ -0,0 +1,220 @@
+/*=============================================================================
+** FileName: function_common.cpp
+** Desc: about function test
+** Author: Warren
+** Version: V1.0
+** LastChange: 2021-02-26
+** History:
+=============================================================================*/
+/*Get private menu,take only the first two parameters, and return the head pointer of the remaining string*/
+#include <stdio.h>
+#include <string.h>
+#include "function_common.h"
+#include <sys/time.h>
+#include <unistd.h>
+#include <stdlib.h>
+void set_timer(int it_interval_sec, int it_interval_usec,int it_value_sec,int it_value_usec)
+{
+ struct itimerval itv, oldtv;
+ itv.it_interval.tv_sec = it_interval_sec;
+ itv.it_interval.tv_usec = it_interval_usec;
+ itv.it_value.tv_sec = it_value_sec;
+ itv.it_value.tv_usec = it_value_usec;
+ setitimer(ITIMER_REAL, &itv, &oldtv);
+}
+
+int sleep_with_restart(int second)
+{
+ int left = second;
+ while (left > 0)
+ {
+ left = sleep(left);
+ }
+ return 0;
+}
+int millli_sleep_with_restart(int millisecond)
+{
+ int left = millisecond*1000;
+ while (left > 0)
+ {
+ left = usleep(left);
+ }
+
+ return 0;
+}
+//Get private menu,take only the first two parameters, and return the head pointer of the remaining string
+char* getMenu(char * str,char *argv[])
+{
+ char* pos = str;
+ int menu = 0;
+ int num = 0;
+ if (str == NULL)
+ {
+ return NULL;
+ }
+ while (1)
+ {
+ menu = 0;
+ if (num == 2)
+ {
+ break;
+ }
+ while (1)
+ {
+ if (*pos == '"')
+ {
+ if (menu == 0)
+ {
+ menu++;
+ argv[num++] = pos+1;
+ }
+ else if (menu == 1)
+ {
+ *pos++ = '\0';
+ break;
+ }
+ else
+ {
+ break;
+ }
+ }
+ pos++;
+ }
+
+ }
+ printf("moudle = %s\nAPI = %s\n", argv[0], argv[1]);
+ return pos;
+}
+/*parse the parameters,and then stroge every parameter to argv.*/
+/*return the number of parameters.*/
+int getParam(char * str,char *argv[])
+{
+ char* pos = str;
+ int num = 0;
+ if (str == NULL)
+ {
+ return 0;
+ }
+ while (1)
+ {
+ if (*pos == '\0')
+ {
+ break;
+ }
+ while (1)
+ {
+ if (*(pos - 1) == '=' && *pos == '"')// "="" as the basis for starting the parameter.
+ {
+ argv[num++] = pos+1;
+ }
+ else if (*(pos - 1) == '"' && *pos == '&')// "="" as the basis for the end of the parameter
+ {
+ *(pos - 1) = '\0';
+ pos++;
+ break;
+ }
+ else if (*pos == '\0'&&*(pos-1) == '"')//the string end.
+ {
+ *(pos - 1) = '\0';
+ break;
+ }
+ else if (*pos == '\0')//the string end.
+ {
+ break;
+ }
+ pos++;
+ }
+ }
+ // for (int i = 0;i < num;i++)
+ // {
+ // printf("argv[%d] = %s\n",i,argv[i]);
+ // }
+ return num;
+}
+
+/*remove the escape character '\'*/
+int removeTage(const int length,char* argv[])
+{
+ char* temp = NULL;
+ char* temp1 = NULL;
+ char** pos = argv;
+ for (int i = 0;i < length;i++)
+ {
+ temp1 = pos[i];
+ while (1)
+ {
+ if (*pos[i] == '\0')
+ {
+ break;
+ }
+ if ((*pos[i] == '"') && (*(pos[i] - 1) == '\\'))//Remove "\"" when encountering '\'
+ {
+ temp = pos[i];
+ while (1)
+ {
+ *(pos[i] - 1) = *(pos[i]);
+ if (*(pos[i]) == '\0')
+ {
+ break;
+ }
+ pos[i]++;
+ }
+ pos[i] = temp;
+ }
+ pos[i]++;
+ }
+ pos[i] = temp1;
+ }
+ return 0;
+}
+int parseParameters(char *str,char *argv[])
+{
+ int argc = 0;
+ argc = getParam(str,argv);
+ removeTage(argc,argv);
+ // for (int i = 0;i < argc; i++)
+ // {
+ // printf("param %d = %s\n",i, argv[i]);
+ // }
+ return 0;
+}
+RIL_COMMAND*find_command (char *name,RIL_COMMAND *Class)
+{
+ register int i;
+ for (i = 0; Class[i].name; i++)
+ if (strcmp (name, Class[i].name) == 0)
+ return (&Class[i]);
+ return ((RIL_COMMAND *)NULL);
+}
+
+int check_numScope(char **argv){
+ if(!strcmp(argv[0], "0"))
+ return 1;
+ if(!atoi(argv[0])){
+ return -1;
+ }
+ else{
+ int num = atoi(argv[0]);
+ if(num < 0 || num > 36)
+ return -1;
+ return 1;
+ }
+}
+int check_special(char **argv){
+ if(!strcmp(argv[0], "0"))
+ return 1;
+ if(!strcmp(argv[0], "#"))
+ return 1;
+ if(!strcmp(argv[0], "*"))
+ return 1;
+ if(!atoi(argv[0])){
+ return -1;
+ }
+ else{
+ int num = atoi(argv[0]);
+ if(num < 0 || num > 9)
+ return -1;
+ return 1;
+ }
+}
+
diff --git a/src/lynq/packages/apps/lynq-function-test/src/function_common.h b/src/lynq/packages/apps/lynq-function-test/src/function_common.h
new file mode 100644
index 0000000..d3d4141
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/function_common.h
@@ -0,0 +1,44 @@
+/*=============================================================================
+** FileName: function_common.h
+** Desc: about function test
+** Author: Warren
+** Version: V1.0
+** LastChange: 2021-02-26
+** History:
+=============================================================================*/
+#ifndef __FUNCTION_COMMON_H__
+#define __FUNCTION_COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "liblog/liblog.h"
+ #include "liblog/lynq_deflog.h"
+#ifdef __cplusplus
+}
+#endif
+typedef enum{
+ MENU_INPUT_ERROR=0,
+ MODULE_INPUT_ERROR,
+ API_INPUT_ERROR,
+ INVALID_CMD,
+}COMMAND_ERROR;
+typedef struct {
+ char *name; /* User printable name of the function. */
+ int (*func)(char **param); /* Function to call to do the job. */
+ char *doc; /* Documentation for this function. */
+} RIL_COMMAND;
+RIL_COMMAND*find_command (char *name,RIL_COMMAND *Class);
+
+void set_timer(int it_interval_sec, int it_interval_usec,int it_value_sec,int it_value_usec);
+int sleep_with_restart(int second);
+int millli_sleep_with_restart(int millisecond);
+
+int check_numScope(char **argv);
+int check_special(char **argv);
+char* getMenu(char * str,char *argv[]);
+int parseParameters(char *str,char *argv[]);
+//int getParam(char * str,char *argv[]);
+//int removeTage(const int length,char* argv[]);
+
+#endif
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/gpio_test.cpp b/src/lynq/packages/apps/lynq-function-test/src/gpio_test.cpp
new file mode 100644
index 0000000..837ab94
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/gpio_test.cpp
@@ -0,0 +1,99 @@
+/*=============================================================================
+** FileName: gpio_test.cpp
+** Desc: about function test
+** Author: zhou
+** Version: V1.0
+** LastChange: 2021-03-04
+** History:
+=============================================================================*/
+#include "function_common.h"
+#include <log/log.h>
+#include <stdio.h>
+#include "gpio_test.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblynq-driver-control/libdriver.h"
+#ifdef __cplusplus
+}
+#endif
+int check_mode(const char *mode)
+{
+if(!strcmp(mode, GPIO_DIR))
+{
+ return 1;
+}
+if(!strcmp(mode, GPIO_OUT))
+{
+ return 1;
+}
+if(!strcmp(mode, GPIO_MODE))
+{
+ return 1;
+}
+ return -1;
+}
+static int check_status(char **argv)
+{
+ if(!strcmp(argv[2],"0")){
+ return 1;
+ }
+ if(!atoi(argv[2])){
+ return -1;
+ }
+ int num = atoi(argv[2]);
+ if(num == 1)
+ return 1;
+ return -1;
+}
+int gpio_test(char *api,char *string) {
+ char *argv[100] = {0};
+ parseParameters(string,argv);
+ if(!strcmp(api, "get")){
+ char output1[1024] = {0};
+ int value = atoi(argv[0]);
+ lynq_get_gpio (value,output1);
+ // printf("Factory_result get %d gpio:%s \n",value,output1)
+ LYVERBLOG("+[gpio][get]: data = %s\n",output1);
+
+ }
+ else if(!strcmp(api, "set")){
+ int check_prame;
+ check_prame = check_status(argv);
+ if(check_prame == -1)
+ {
+ LYVERBLOG("+[gpio][set]: error num = %d \n",GPIO_PRAME_ERROR);
+ return 0;
+ }
+ int gpio_numb = atoi(argv[1]);
+
+ int gpio_statu = atoi(argv[2]);
+
+ check_prame = check_mode(argv[0]);
+ if(check_prame == -1)
+ {
+ LYVERBLOG("+[gpio][set]: error num = %d \n",GPIO_PRAME_ERROR);
+ return 0;
+ }
+
+ int result = lynq_set_gpio(argv[0], gpio_numb,gpio_statu);
+ if(result == -1)
+ {
+ LYVERBLOG("+[gpio][set]: error num = %d \n",GPIO_SET_ERROR);
+ return 0;
+ }
+ else
+ {
+ LYVERBLOG("+[gpio][set]: ok!!\n",result);
+ return 1;
+ }
+ }
+ else {
+ LYVERBLOG("+[gpio][lynq_set_gpio]: error num =%d\n",GPIO_PRAME_ERROR);
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/gpio_test.h b/src/lynq/packages/apps/lynq-function-test/src/gpio_test.h
new file mode 100644
index 0000000..204cfe0
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/gpio_test.h
@@ -0,0 +1,12 @@
+#ifndef __LYNQ_GPIO_TEST_H__
+#define __LYNQ_GPIO_TEST_H__
+#define GPIO_MODE "mode"
+#define GPIO_DIR "dir"
+#define GPIO_OUT "out"
+typedef enum {
+ GPIO_SET_SUCCESS = 0 ,
+ GPIO_PRAME_ERROR = 1,
+ GPIO_SET_ERROR = 2,
+}GPIO_SET_RESULT;
+int gpio_test(char *api,char *string);
+#endif //__LYNQ_GPIO_TEST_H__
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/main.cpp b/src/lynq/packages/apps/lynq-function-test/src/main.cpp
new file mode 100644
index 0000000..e75c768
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/main.cpp
@@ -0,0 +1,374 @@
+/* gets example */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libtel/lib_tele.h>
+#include "ril_test.h"
+#include "gpio_test.h"
+#include "fota_test.h"
+#include "function_common.h"
+//#include "exception_multicast.h"
+#include "usb_switch.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "liblynq-broadcast/broadcast_send.h"
+#include <gio/gio.h>
+#include <glib.h>
+#include "liblynq-driver-control/libdriver.h"
+#ifdef __cplusplus
+}
+#endif
+#define BUFFER_SIZE 8192
+#define USER_LOG_TAG "FUNCTION_TEST"
+#define MAX_ARGS 5
+typedef enum {
+ API_MENU = 1,
+ DEMO_MENU,
+}TEST_MAIN_ITEM;
+typedef enum{
+ API_RIL=0,
+ API_GPIO,
+ API_MQTT,
+ API_HTTP,
+ API_WIFI,
+ API_GNSS,
+ API_USB,
+ API_FOTA,
+} API_MOUDLE;
+
+
+void lynq_incoming_call_cb(RIL_SOCKET_ID soc_id,int index, char * addr, RIL_CallState state, int toa)
+{
+ // printf("[SIM%d]index is %d,addr is %s,state is %d,toa is %d\n",soc_id,index,addr,state,toa);
+ LYVERBLOG("[SIM%d]index is %d,addr is %s,state is %d,toa is %d\n",soc_id,index,addr,state,toa);
+}
+
+void lynq_recive_new_sms_cb(RIL_SOCKET_ID soc_id,char * num, char * smsc, char * msg, int charset)
+{
+ // printf("[SIM%d]num is %s,smsc is %s,msg is %s,charset is %d\n",soc_id,num,smsc,msg,charset);
+ LYVERBLOG("[SIM%d]num is %s,smsc is %s,msg is %s,charset is %d\n",soc_id,num,smsc,msg,charset);
+}
+static user_cb mytest={
+ lynq_recive_new_sms_cb,
+ lynq_incoming_call_cb
+};
+
+static void getCallback(const char* str_arg, int int_arg )
+{
+ //printf("SignalCallback,str_arg:%s,int_arg:%d\n", str_arg,int_arg);
+ LYVERBLOG("SignalCallback,str_arg:%s,int_arg:%d\n", str_arg,int_arg);
+
+ return;
+}
+
+void hold_on(){
+ char any[5]={ 0 };
+ printf("Press any key to return\n");
+ fgets(any, 5, stdin);
+}
+
+int parse_param(char *cmd, char *argv[], int max_args){
+ char *pos, *pos2;
+ int argc = 0;
+
+ pos = cmd;
+ while (1) {
+ // Trim the space characters.
+ while (*pos == ' ') {
+ pos++;
+ }
+
+ if (*pos == '\0') {
+ break;
+ }
+
+ // One token may start with '"' or other characters.
+ if (*pos == '"' && (pos2 = strchr(pos + 1, '"'))) {
+ argv[argc++] = pos + 1;
+ *pos2 = '\0';
+ pos = pos2 + 1;
+ if (*pos == '\n'){
+ *pos = '\0';
+ pos = pos + 1;
+ }
+ }
+ else {
+ argv[argc++] = pos;
+ while (*pos != '\0' && *pos != ' '&& *pos != '\n')
+ {
+ if (*pos == '"' && (pos2 = strchr(pos + 1, '"')))
+ {
+ pos = pos2 ;
+ }
+ else
+ pos++;
+ }
+ *pos++ = '\0';
+ }
+
+ // Check if the maximum of arguments is reached.
+ if (argc == max_args) {
+ break;
+ }
+ }
+
+ return argc;
+}
+int getRilModule(char *module)
+{
+ if (module==NULL)
+ {
+ //printf("[ERROR] Please input module,and try again!");
+ // LYVERBLOG("+[command error]:error num = %d\n",MODULE_INPUT_ERROR);
+ return -1;
+ }
+ if(!strcmp(module,"ril"))
+ {
+ return API_RIL;
+ }
+ else if(!strcmp(module,"gpio"))
+ {
+ return API_GPIO;
+ }
+ else if(!strcmp(module,"MQTT"))
+ {
+ return API_MQTT;
+ }
+ else if(!strcmp(module,"HTTP"))
+ {
+ return API_HTTP;
+ }
+ else if(!strcmp(module,"WIFI"))
+ {
+ return API_WIFI;
+ }
+ else if(!strcmp(module,"GNSS"))
+ {
+ return API_GNSS;
+ }
+ else if(!strcmp(module,"usb_switch"))
+ {
+ return API_USB;
+ }
+ else if(!strcmp(module, "fota"))
+ {
+ return API_FOTA;
+ }
+ else
+ {
+ LYVERBLOG("+[command error]:error num = %d\n",MODULE_INPUT_ERROR);
+ // printf("can not find %s API module ",module);
+ return -1;
+ }
+ return -1;
+}
+
+int api_start(int argc, char *argv[]){
+ LYDBGLOG("api_start,argc:%d\n",argc);
+ char *menu[2] = {0};// menu[0] is the "moudle",menu[1] is the "API"
+ char* argvHead=NULL;
+ int module = -1;
+ argvHead = getMenu(argv[2],menu);//find the "module" and the "API"
+ module = getRilModule(menu[0]);
+ // if(argvHead == NULL)
+ // {
+ // printf("pram api error\n");
+ // return 0;
+ // }
+ switch(module)
+ {
+ case API_RIL:
+ {
+ if(argvHead)
+ {
+ ril_test(menu[1],argvHead);
+ break;
+ }
+ }
+ /* Add the code of the owner modules below*/
+ case API_GPIO:
+ {
+ gpio_test(menu[1],argvHead);
+ break;
+ }
+ case API_USB:
+ {
+ usb_switch_test(menu[1],argvHead);
+ break;
+ }
+ case API_FOTA:
+ {
+ fota_test(menu[1],argvHead);
+ break;
+ }
+ case API_MQTT:
+ case API_HTTP:
+ case API_WIFI:
+ case API_GNSS:
+ break;
+ default:
+ // printf("pram module error\n");
+ LYVERBLOG("+[command error]:error num = %d\n",API_INPUT_ERROR);
+
+ break;
+ }
+ // hold_on(); //add by zhouqunchao delete help message
+ return 1;
+}
+
+int function_start(int argc, char *argv[])
+{
+ int select_menu = atoi(argv[0]);
+ int thread = atoi(argv[1]);
+ // printf("select_menu:%d,thread:%d\n",select_menu,thread);
+ switch(select_menu)
+ {
+ case API_MENU:
+ {
+ if (thread == 1)//rita add @2021.6.21 for threadhandle test
+ {
+ LYDBGLOG("[%s-%d] argv[2] = [%s]\n", __FUNCTION__, __LINE__, argv[2]);
+ if(strlen(argv[2])){//rita add @2021.6.21 for data error
+ LYDBGLOG("[%s-%d] argv[2] = [%s]\n", __FUNCTION__, __LINE__, argv[2]);
+ send_broadcast_by_name("function", strlen(argv[2]), argv[2]);
+ }
+ else{
+ LYVERBLOG("+[thhandle]: error num = %d\n", INVALID_CMD);
+ return INVALID_CMD;
+ }
+ }
+ else if(thread ==2){//rita add @2021.6.21 for local test
+ api_start(argc,argv);
+ }
+ else{
+ //printf("thread 1,local 2\n");
+ LYDBGLOG("thread 1,local 2\n");
+ }
+ break;
+ }
+ case DEMO_MENU:
+ {
+ //printf("DEMO_MENU\n");
+ LYDBGLOG("DEMO_MENU\n");
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+
+void help_display(){
+ printf("\n");
+ printf("*****************************************************************************\n");
+ printf("0:help ------- help\n");
+ printf("*****************************************************************************\n");
+ printf("1:API TEST\n" );
+ printf(" 1-1:Async api-\n" );
+ printf(" --MQTT\n" );
+ printf("\n");
+ printf(" --HTTP\n" );
+ printf(" 1-2:Sync api-\n" );
+ printf(" --GPIO\n" );
+ printf("\n");
+ printf(" --RIL\n" );
+ printf("\n");
+ printf(" --WIFI\n" );
+ printf("\n");
+ printf(" --GNSS\n" );
+ printf("\n");
+ printf(" --SERVICE\n" );
+ printf("*****************************************************************************\n");
+ printf("2:DEMO TEST:Subsequent updates\n" );
+ printf("*****************************************************************************\n");
+ printf("\n");
+ printf("1:API TEST The format is as follows :\n" );
+ printf("{menu}-{mode selection} moudle=\"{moudle}\"&API=\"{api interface}\"&session=\"{session id}\"\"¶meterA=\"{parameter A}\"\n" );
+ /*
+ printf("The main parameters are as follows:\n");
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("menu:1--API TEST,2--DEMO TEST\n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("mode selection:1--async api,2--sync api\n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("moudle:Test module--includes the following modules\n" );
+ printf("RIL, GPIO,MQTT,HTTP,WIFI,GNSS\n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("api interface:--Interface corresponding to module\n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("session id:--Used to distinguish different session groups of the same module\n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ printf("parameter A:--API parameter,Add format {\"¶meter_name=\"{parameter}\"} \n" );
+ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
+ */
+ printf("Select menu:\n");
+}
+void menu_display(){
+ printf("\n");
+ printf("**********************\n");
+ printf("0:help menu\n");
+ printf("1:API TEST\n");
+ printf("2:DEMO TEST\n");
+ printf("**********************\n");
+ printf("\n");
+ printf("Select menu:\n");
+}
+int main(int argc, char const *argv[])
+{
+
+
+ LYLOGEINIT(USER_LOG_TAG);
+ registerTriggerCallback(getCallback);
+ register_key_info();
+ lynqRegisterUnsolicitedResponse(&mytest);
+ lynq_ril_init();
+ sleep_with_restart(1);
+ register_broadcast_send();
+ while (1) {
+ char *argv[MAX_ARGS];
+ char str[BUFFER_SIZE]={ 0 };
+ menu_display();
+ fgets(str, BUFFER_SIZE, stdin);
+ LYDBGLOG("[%s-%d] str= [%s]\n", __FUNCTION__, __LINE__, str);
+ str[strlen(str)-1]='\0';
+ if(!strcmp(str, "0")){
+ help_display();
+ //hold_on(); //add by zhouqunchao delete help message
+ continue;
+ }
+ if(!strcmp(str,"quit"))
+ {
+ break;
+ }
+ if ((strncmp(str,"1-",2) == 0)||
+ (strncmp(str,"2-",2)== 0))
+ {
+ char* at_cmd = strstr(str, "-");
+ strncpy(at_cmd, " ", 1);
+ LYDBGLOG("[%s-%d] at_cmd = [%s]\n", __FUNCTION__, __LINE__, at_cmd);
+
+
+ int argc = parse_param(str, argv, MAX_ARGS);
+ //add by zqc Format error judgment start
+ if(argv[2] == NULL)
+ {
+ LYVERBLOG("+[command error]:error num = %d\n",MENU_INPUT_ERROR);
+ continue;
+ }
+ //add by zqc Format error judgment end
+ function_start(argc,argv);
+ continue;
+ }
+ else{
+ // printf("pram error\n");
+ LYVERBLOG("+[command error]:error num = %d\n",MENU_INPUT_ERROR);
+ continue;
+ }
+ }
+
+
+
+ return 0;
+}
+
diff --git a/src/lynq/packages/apps/lynq-function-test/src/makefile b/src/lynq/packages/apps/lynq-function-test/src/makefile
new file mode 100644
index 0000000..bfd29e9
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/makefile
@@ -0,0 +1,118 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -D__LINUX_OS__ \
+ -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+ LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+ LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+ -DANDROID_MULTI_SIM \
+ -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+ LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+ -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+ -DMD_90_SUPPORT
+endif
+
+
+LOCAL_PATH = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH) \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/ftp \
+ -I$(ROOT)$(includedir)/liblynq-broadcast \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/liblynq-driver-control \
+ -I$(ROOT)$(includedir)/libtel \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I../gps_hal/inc \
+ -I../gps_hal/inc/hardware \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+ -I$(ROOT)$(includedir)/include \
+ -DLIB_GNSS_HAL_DIR='"$(libdir)"'
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -lpower \
+ -lbinder \
+ -llynq-log \
+ -llynq-tele-ril \
+ -lpthread \
+ -lrt \
+ -llynq-driver-control \
+ -lgpshal \
+ -lpal \
+ -lgstreamer-1.0 \
+ -lglib-2.0 \
+ -lgstbase-1.0 \
+ -lgstreamer-1.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldtmf \
+ -lapn \
+ -ldbus-1 \
+ -llynq-broadcast \
+ -llynq-protcl \
+ -llynq-fota \
+ -lnandapi \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp gpio/*.cpp ril/*.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c gps/*.c)
+EXECUTABLE = lynq-function-test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+ $(warning ----->build $<)
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-function-test/src/ril_test.cpp b/src/lynq/packages/apps/lynq-function-test/src/ril_test.cpp
new file mode 100644
index 0000000..bdcb958
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/ril_test.cpp
@@ -0,0 +1,1799 @@
+/*=============================================================================
+** FileName: ril_test.cpp
+** Desc: about function test
+** Author: Warren
+** Version: V1.0
+** LastChange: 2021-02-26
+** History:
+=============================================================================*/
+#include "function_common.h"
+#include <log/log.h>
+#include <liblog/lynq_deflog.h>
+#include "libtel/lib_tele.h"
+#include <libtel/lynq_call.h>
+#include <libtel/lynq_sim.h>
+#include <libtel/lynq_network.h>
+#include <libtel/lynq_data.h>
+#include <libtel/lynq_sms.h>
+#include "ril_test.h"
+#include <cutils/properties.h>
+#include <string.h>
+#define MAX_P 1024
+RIL_COMMAND api_commands[] = {
+#include "commands.h"
+};
+static int check_status(char **argv)
+{
+ if(!strcmp(argv[0],"0")){
+ return 1;
+ }
+ if(!atoi(argv[0])){
+ return -1;
+ }
+ int num = atoi(argv[0]);
+ if(num == 1)
+ return 1;
+ return -1;
+}
+static int strUpper(char * str)
+{
+ int i=0;
+ while(1)
+ {
+ if(str[i]=='\0')
+ {
+ break;
+ }
+ if(str[i]>='a'&&str[i]<='z')
+ {
+ //printf("str %c\n",str[i]-32);
+ str[i]=str[i]-32;
+ }
+ i++;
+ }
+ return 0;
+}
+
+int eventDial(char **argv)
+{
+ int32_t token;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][dial]: Please input phony number,and try again\n");
+ return -1;
+ }
+ char* addr = argv[0];
+ char output[1024] = {0};
+ lynqCallList *msg = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(msg,0,sizeof(lynqCallList));
+ msg->addr=(char *)malloc(sizeof(char));
+ memset(msg->addr,0,sizeof(char));
+ token = lynq_call(addr, msg);
+ LYINFLOG("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d\n",
+ msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ if(msg->base.e!=0)
+ {
+ LYVERBLOG( "+[ril][dial]: error num = %d\n",msg->base.e);
+ }
+ else
+ {
+ LYVERBLOG( "+[ril][dial]: ok!!\n");
+ }
+ free(msg->addr);
+ msg->addr=NULL;
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+
+int eventAnswer(char **argv)
+{
+ int32_t token;
+ char output[1024] = {0};
+ lynqCallList *msg = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(msg,0,sizeof(lynqCallList));
+ msg->addr=(char *)malloc(sizeof(char));
+ memset(msg->addr,0,sizeof(char));
+ //printf("call start \n");
+ token = lynq_call_answer(msg);
+ //printf("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d\n",
+ //msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ LYINFLOG("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ msg->base.request,msg->addr,msg->base.request,msg->base.e,msg->call_state);
+ if(msg->base.e!=0)
+ {
+ LYVERBLOG( "+[ril][an]: error num = %d\n",msg->base.e);
+ }
+ else
+ {
+ LYVERBLOG( "+[ril][an]: ok!!\n");
+ }
+ //emResultNotify(output,command);
+ free(msg->addr);
+ msg->addr=NULL;
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventAutoAnswer(char **argv)
+{
+ int32_t token=0;
+ int mode=0;
+ char output[1024] = {0};
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][atan]: Please input auto answer mode value:0 or 1,and try again\n");
+ return -1;
+ }
+ int status = atoi(argv[0]);
+ if(!(status==1 ||status ==0))
+ {
+ LYERRLOG("+[ril][atan]: Please input auto answer mode value:0 or 1,and try again\n");
+ return -1;
+ }
+ token = lynq_set_auto_answercall(status,&mode);
+ if(mode!=status)
+ {
+ LYVERBLOG( "+[ril][atan]: error num = %d\n",RIL_E_GENERIC_FAILURE);
+ }
+ else
+ {
+ LYVERBLOG( "+[ril][atan]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetMute(char **argv)
+{
+ int32_t token = 0;
+ int status =0;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][stme]: Please input set mute mode:0 or 1,and try again!\n");
+ return -1;
+ }
+ int mute = atoi(argv[0]);
+ token = lynq_set_mute_mic(mute, &status);
+ LYINFLOG("set mute status is %s,current mute status is %s\n",mute>0?"mute on":"mute off",status>0?"mute on":"mute off");
+ if(mute!=status)
+ {
+ LYVERBLOG("+[ril][stme]: error num = %d\n",RIL_E_GENERIC_FAILURE);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][stme]: ok!!\n");
+ }
+ return 0;
+}
+int eventGetMute(char **argv)
+{
+ int32_t token = 0;
+ int status =0;
+ char output[1024] = {0};
+ token = lynq_get_mute_status(&status);
+ LYVERBLOG("+[ril][gtme]: status = %d\n",status>0?1:0);
+ LYVERBLOG("+[ril][gtme]: ok!!\n");
+ return 0;
+}
+int eventLastCallFailCause(char **argv)
+{
+ int32_t token = 0;
+ int status =0;
+ char output[1024] = {0};
+ lynqLastCallFailCause * msg = (lynqLastCallFailCause*)malloc(sizeof(lynqLastCallFailCause));
+ memset(msg,0,sizeof(lynqLastCallFailCause));
+ msg->vendor_cause = (char *)malloc(sizeof(char)*64);
+ memset(msg->vendor_cause,0,sizeof(char));
+ token = lynq_get_last_call_fail_cause(msg);
+ LYINFLOG("token is %x,request is %d,error_code is %d,cause_code is %d,vendor_cause is %s\n",msg->base.token,
+ msg->base.request,msg->base.e,msg->cause_code,msg->vendor_cause);
+ if(msg->base.e!=0)
+ {
+ LYVERBLOG("+[ril][lcfc]: error num = %d\n",msg->base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][lcfc]: cause_code = %d,vendor_cause = %s\n",msg->cause_code,msg->vendor_cause);
+ LYVERBLOG("+[ril][lcfc]: ok!!\n");
+ }
+ free(msg->vendor_cause);
+ free(msg);
+ return 0;
+}
+int eventCallHangUp(char **argv)
+{
+ lynqBase msg;
+ char output[1024] = {0};
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][hup]: Please input call index,and try again!\n");
+ return -1;
+ }
+ int index = atoi(argv[0]);
+ lynq_call_hang_up(index,&msg);
+ //printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][hup]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][hup]: ok!!\n");
+ }
+ return 0;
+}
+int eventRejectCall(char **argv)
+{
+ lynqBase msg;
+ char output[1024] = {0};
+ lynq_reject_call(&msg);
+ //printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][udub]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][udub]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetDTMF(char **argv)
+{
+ if(check_special(argv) == -1){
+ LYVERBLOG("+[ril][dtmf]: Please input DTMF value:0-9,8,#,and try again!\n");
+ return -1;
+ }
+ if(argv[0]==NULL || strlen(argv[0]) == 0)
+ {
+ LYVERBLOG("+[ril][dtmf]: Please input DTMF value:0-9,8,#,and try again!\n");
+ return -1;
+ }
+ lynqBase msg;
+ char output[1024] = {0};
+ char value = argv[0][0];
+ lynq_set_DTMF(value,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][dtmf]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][dtmf]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetDTMFVolume(char **argv)
+{
+ if(check_numScope(argv) == -1){
+ LYVERBLOG("+[ril][dtmfv]: Please input DTMF volume(0-36),and try again!\n");
+ return -1;
+ }
+ int32_t token =0;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][dtmfv]: Please input DTMF volume(0-36),and try again!\n");
+ return -1;
+ }
+ int volume = atoi(argv[0]);
+ token = lynq_set_DTMF_volume(volume);
+ LYVERBLOG("+[ril][dtmfv]: ok!!\n");
+ //printf("Factory_result set DTMF Volume is %s\n",(token>0?"success":"fail"));
+ return 0;
+}
+int eventDoMultiConference(char **argv)
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_do_multi_conference(&msg);
+ LYINFLOG("request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][dmc]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][dmc]: ok!!\n");
+ }
+ return 0;
+}
+int eventOthercallHold(char **argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][och]: Please input call id,and try again!\n");
+ return -1;
+ }
+ int call_id = atoi(argv[0]);
+ lynq_othercall_hold(call_id,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][och]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][och]: ok!!\n");
+ }
+ return 0;
+}
+int eventHangupWatingForCall(char **argv)
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_hangup_wating_for_call(&msg);
+ LYINFLOG("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][hwc]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][hwc]: ok!!\n");
+ }
+ return 0;
+}
+int eventHangupForegroundResumeBackground(char **argv)
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_hangup_foreground_resume_background(&msg);
+ LYINFLOG("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][hfrb]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][hfrb]: ok!!\n");
+ }
+ return 0;
+}
+int eventSwitchWaitOrHoldAndActiveCall(char ** argv)
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_switch_hold_and_active_call(&msg);
+ LYINFLOG("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][swha]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][swha]: ok!!\n");
+ }
+ return 0;
+}
+
+int eventQueryOperator(char ** argv)
+{
+ operatorInfo msg;
+ msg.OperatorFN=NULL;
+ msg.OperatorSH=NULL;
+ msg.MccMnc=NULL;
+ lynq_query_operater(&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qop]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qop]: OperatorFN = %s,OperatorSH = %s,MccMnc = %s\n",msg.OperatorFN,msg.OperatorSH,msg.MccMnc);
+ LYVERBLOG("+[ril][qop]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryNetSelectMode(char ** argv)
+{
+ networkSelecttionMode msg;
+ lynq_query_network_selection_mode(& msg);
+ //printf("request is %d,token is %x,error is %d,mode is %d\n",msg.base.request,msg.base.token,msg.base.e,msg.mode);
+ LYINFLOG("request is %d,token is %x,error is %d,mode is %d\n",msg.base.request,msg.base.token,msg.base.e,msg.mode);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qnsm]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qnsm]: mode = %d\n",msg.mode);
+ LYVERBLOG("+[ril][qnsm]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetNetSelectMode(char ** argv)
+{
+ char str[100]={0};
+ if(check_status(argv)==-1){
+ LYVERBLOG("+[ril][snsm]: Please input network selection mode,and try again!\n");
+ return -1;
+ }
+ if(argv[0]==NULL || strlen(argv[0]) == 0)
+ {
+ LYERRLOG("+[ril][snsm]: Please input network selection mode,and try again!\n");
+ return -1;
+ }
+ int mode = atoi(argv[0]);
+ const char * mccmnc = "46000";//just China Mobile Communications Group
+ lynqBase msg;
+ sprintf(str,"%s",(mode==0?"Auto":"Manual"));
+ if(mode==0)
+ {
+ lynq_set_network_selection_mode(str,NULL,&msg);
+ }
+ else if(mode ==1)
+ {
+ LYVERBLOG("+[ril][snsm]: You have selected manual mode, this command only supports CMCC SIM card temporarily");
+ lynq_set_network_selection_mode(str,mccmnc,&msg);
+ }
+ else
+ {
+ LYERRLOG("+[ril][snsm]: please input network selection mode:0 or 1,and try again\n");
+ return 0;
+ }
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][snsm]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][snsm]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryAvailableNetwork(char **argv)
+{
+ int32_t token=0;
+ availableNetwork msg;
+ msg.OperatorFN=NULL;
+ msg.OperatorSH=NULL;
+ msg.MccMnc=NULL;
+ msg.NetStatus=NULL;
+ lynq_query_available_network(&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qan]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qan]: OperatorFN = %s,OperatorSH = %s,MccMnc = %s,NetStatus = %s\n",msg.OperatorFN,msg.OperatorSH,msg.MccMnc,msg.NetStatus);
+ LYVERBLOG("+[ril][qan]: ok!!\n");
+ }
+ return 0;
+
+}
+ int eventQueryRegistrationState(char ** argv)
+{
+ registrationStateInfo msg;
+ msg.CID=NULL;
+ msg.LAC=NULL;
+ char str[10];
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][qrs]: Please input voice/data/ims,and try again!\n");
+ return -1;
+ }
+ char *type = argv[0];
+ if (strlen(type)>10)
+ {
+ LYERRLOG("+[ril][qrs]: the parameter is inavaliable !\n");
+ return -1;
+ }
+ memcpy(str,type,strlen(type)+1);
+ strUpper(str);
+ //printf("upper str is %s\n",str);
+ lynq_query_registration_state(str,&msg);
+ if(!strcmp(str,"VOICE")){
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qrs]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qrs]: registrationState = %d\n",msg.regState);
+ LYVERBLOG("+[ril][qrs]: ok!!\n");
+ }
+ }else if(!strcmp(str,"DATA")){
+
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qrs]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qrs]: registrationState = %d,LAC = %s,CID = %s,networkTyp = %d\n",msg.regState,msg.LAC,msg.CID,msg.netType);
+ LYVERBLOG("+[ril][qrs]: ok!!\n");
+ }
+ }else if(!strcmp(str,"IMS")){
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][qrs]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][qrs]: imsRegistrationState = %d,radioTechFamily = %d\n",msg.imsRegState,msg.radioTechFam);
+ LYVERBLOG("+[ril][qrs]: ok!!\n");
+ }
+ }else{
+ LYERRLOG("+[ril][qrs]: [%s][%d] query ims registration state about voice, data, and ims!!! \n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ return 0;
+ }
+ int eventQueryPrefferredNetworkType(char ** argv)
+{
+ prefferredNetworkType msg;
+ lynq_query_prefferred_networktype(&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][gpnt]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gpnt]: pnt = %d\n",msg.pnt);
+ LYVERBLOG("+[ril][gpnt]: ok!!\n");
+ }
+ return 0;
+}
+ int eventSetPrefferredNetworkType(char ** argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][spnt]: Please input prefferrend neteork type,and try again!\n");
+ return -1;
+ }
+ int type = atoi(argv[0]);
+ lynq_set_prefferred_networktype(type,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][spnt]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][spnt]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryCellInfo(char ** argv)
+{
+ cellInfoList **msg;
+ int num=5;
+ int realNum =0;
+ int32_t token=0;
+ msg = (cellInfoList **)malloc(sizeof(cellInfoList *)*num);
+ if(msg==NULL)
+ {
+ LYERRLOG("+[ril][gcil]: malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (cellInfoList*)malloc(sizeof(cellInfoList));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(cellInfoList));
+ }
+ token = lynq_query_cell_info(msg, num, &realNum);
+ LYINFLOG("+[ril][gcil]: request is %d,token is %x,e is %d\n",msg[0]->base.request,msg[0]->base.token,msg[0]->base.e);
+ if(msg[0]->base.e!=0)
+ {
+ LYVERBLOG("+[ril][gcil]: error num = %d\n",msg[0]->base.e);
+ }
+ else
+ {
+ for(int i = 0; i<realNum; i++)
+ {
+ LYVERBLOG("+[ril][gcil]: cellInfoType = %d,registered = %d,timeStampType = %d,timeStamp = %d\n",msg[i]->cellinfo.cellInfoType,msg[i]->cellinfo.registered,msg[i]->cellinfo.timeStampType,msg[i]->cellinfo.timeStamp);
+ switch(msg[i]->cellinfo.cellInfoType) {
+ case RIL_CELL_INFO_TYPE_GSM: {
+ LYVERBLOG("+[ril][gcil]: gsm_mcc = %d,gsm_mnc = %d,gsm_lac = %d,gsm_cid = %d,gsm_signalStrength = %d,gsm_bitErrorRate%d,gsm_timingAdvance = %d\n",
+ msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.mcc,
+ msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.mnc,
+ msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.lac,
+ msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.cid,
+ msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.signalStrength,
+ msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.bitErrorRate,
+ msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.timingAdvance);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_WCDMA: {
+ LYVERBLOG("+[ril][gcil]: wcdma_mcc = %d,wcdma_mnc = %d,wcdma_lac = %d,wcdma_cid = %d,wcdma_psc = %d,wcdma_signalStrength = %d,wcdma_bitErrorRate = %d\n",
+ msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mcc,
+ msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mnc,
+ msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.lac,
+ msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.cid,
+ msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.psc,
+ msg[i]->cellinfo.CellInfo.wcdma.signalStrengthWcdma.signalStrength,
+ msg[i]->cellinfo.CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_CDMA: {
+ LYVERBLOG("+[ril][gcil]: cdma_networkId = %d,cdma_systemId = %d,cdma_basestationId = %d,cdma_longitude = %d,cdma_latitude = %d,cdma_dbm = %d,cdma_ecio = %d,cdma_Evdo_dbm = %d,cdma_Evdo_ecio = %d,cdma_Evdo_signalNoiseRatio = %d\n",
+ msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.networkId,
+ msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.systemId,
+ msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.basestationId,
+ msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.longitude,
+ msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.latitude,
+ msg[i]->cellinfo.CellInfo.cdma.signalStrengthCdma.dbm,
+ msg[i]->cellinfo.CellInfo.cdma.signalStrengthCdma.ecio,
+ msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.dbm,
+ msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.ecio,
+ msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_LTE: {
+ LYVERBLOG("+[ril][gcil]: lte_mcc = %d,lte_mnc = %d,lte_ci = %d,lte_pci = %d,lte_tac = %d,lte_signalStrength = %d,lte_rsrp = %d,lte_rsrq = %d,lte_rssnr = %d,lte_cqi = %d,lte_timingAdvance = %d\n",
+ msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.mcc,
+ msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.mnc,
+ msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.ci,
+ msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.pci,
+ msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.tac,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.signalStrength,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rsrp,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rsrq,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rssnr,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.cqi,
+ msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.timingAdvance);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_TD_SCDMA: {
+ LYVERBLOG("+[ril][gcil]: tdscdma_mcc = %d,tdscdma_mnc = %d,tdscdma_lac = %d,tdscdma_cid = %d,tdscdma_cpid = %d,tdscdma_rscp = %d\n",
+ msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mcc,
+ msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mnc,
+ msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.lac,
+ msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cid,
+ msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cpid,
+ msg[i]->cellinfo.CellInfo.tdscdma.signalStrengthTdscdma.rscp);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ LYVERBLOG("+[ril][gcil]: ok!!\n");
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventSetUnsolCellInfoListrate(char ** argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][sucilr]:Please input unsolicited cell infomation list rate,and try again!\n");
+ return -1;
+ }
+ int rate = atoi(argv[0]);
+ lynq_set_unsol_cell_info_listrate(rate,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][sucilr]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][sucilr]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryNeighboringCellids(char ** argv)
+{
+ neighboringCellIDs **msg=NULL;
+ int num=5;
+ int realNum =0;
+ int32_t token=0;
+ msg = (neighboringCellIDs **)malloc(sizeof(neighboringCellIDs *)*num);
+ if(msg==NULL)
+ {
+ RLOGD("malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (neighboringCellIDs*)malloc(sizeof(neighboringCellIDs));
+ msg[i]->cid = (char*)malloc(sizeof(char));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]->cid);
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(neighboringCellIDs));
+ }
+ msg[0]->base.e=(RIL_Errno)(-1);
+ token = lynq_query_neighboring_cellids(msg, num, &realNum);
+ if(msg[0]->base.e!=0)
+ {
+ LYVERBLOG("+[ril][gncid]: error num = %d\n",msg[0]->base.e);
+ }
+ else
+ {
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg[0]->base.request,msg[0]->base.token,msg[0]->base.e);
+ for(int i =0;i<realNum;i++)
+ {
+ LYVERBLOG("+[ril][gncid]: cid = %s,rssi = %d\n",msg[i]->cid,msg[i]->rssi);
+ }
+ LYVERBLOG("+[ril][gncid]: ok!!\n");
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]->cid);
+ msg[i]->cid=NULL;
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventSetBandMode(char ** argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][sbm]: Please input band mode,and try again!\n");
+ return -1;
+ }
+ int mode = atoi(argv[0]);
+ lynq_set_band_mode(mode,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][sbm]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][sbm]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryAvailableBandmode(char ** argv)
+{
+ availableBandMode msg;
+ lynq_query_available_bandmode(&msg);
+ char buffer[256] = {0};
+ char element[256] = {0};
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.bandmode[0]>0)
+ {
+ for(int i =1;i<=msg.bandmode[0];i++)
+ {
+ sprintf(element,"%d,",msg.bandmode[i]);
+ strncat(buffer, element, strlen(element));
+ }
+ LYVERBLOG("+[ril][qabm]: availableBandMode = %s\n",buffer);
+ LYVERBLOG("+[ril][qabm]: ok!!\n",buffer);
+ return 0;
+ }
+ LYVERBLOG("+[ril][qabm]: error num = %d\n",msg.base.e);
+ LYINFLOG("available band mode is null");
+ return 0;
+}
+int eventRadioOn(char ** argv)
+{
+ lynqBase msg;
+ if(check_status(argv)==-1){
+ LYVERBLOG("+[ril][rpo]: Please input radio on value,0 or 1,and try again!\n");
+ return -1;
+ }
+ if(argv[0]==NULL || strlen(argv[0]) == 0)
+ {
+ LYVERBLOG("+[ril][rpo]: Please input radio on value,0 or 1,and try again!\n");
+ return -1;
+ }
+ int state = atoi(argv[0]);
+ lynq_radio_on(state,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][rpo]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][rpo]: ok!!\n");
+ }
+ return 0;
+}
+int eventQueryRadioTech(char ** argv)
+{
+ radioTechnology msg;
+ char output[1024] = {0};
+ lynq_query_radio_tech(&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][vrt]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][vrt]: RadioTech = %d\n",msg.radioTech);
+ LYVERBLOG("+[ril][vrt]: ok!!\n");
+ }
+ return 0;
+}
+int eventSolicitedSignalStrength(char ** argv)
+{
+ solicitedSignalStrength msg;
+ lynq_solicited_signal_strength(&msg);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][sst]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][sst]: GW_signalStrength = %d,GW_bitErrorRate = %d,GW_timingAdvance = %d\n",
+ msg.signalStrength.GW_SignalStrength.signalStrength,
+ msg.signalStrength.GW_SignalStrength.bitErrorRate,
+ msg.signalStrength.GW_SignalStrength.timingAdvance);
+ LYVERBLOG("+[ril][sst]: CDMA_dbm = %d,CDMA_ecio = %d\n",
+ msg.signalStrength.CDMA_SignalStrength.dbm,
+ msg.signalStrength.CDMA_SignalStrength.ecio);
+ LYVERBLOG("+[ril][sst]: EVDO_dbm = %d,EVDO_ecio = %d,EVDO_signalNoiseRatio = %d\n",
+ msg.signalStrength.EVDO_SignalStrength.dbm,
+ msg.signalStrength.EVDO_SignalStrength.ecio,
+ msg.signalStrength.EVDO_SignalStrength.signalNoiseRatio);
+ LYVERBLOG("+[ril][sst]: LTE_signalStrength = %d,LTE_rsrp = %d,LTE_rsrq = %d,LTE_rssnr = %d,LTE_cqi = %d,LTE_timingAdvance = %d\n",
+ msg.signalStrength.LTE_SignalStrength.signalStrength,
+ msg.signalStrength.LTE_SignalStrength.rsrp,
+ msg.signalStrength.LTE_SignalStrength.rsrq,
+ msg.signalStrength.LTE_SignalStrength.rssnr,
+ msg.signalStrength.LTE_SignalStrength.cqi,
+ msg.signalStrength.LTE_SignalStrength.timingAdvance);
+ LYVERBLOG("+[ril][sst]: TD_SCDMA_signalStrength = %d,TD_SCDMA_bitErrorRate = %d,TD_SCDMA_rscp = %d\n",
+ msg.signalStrength.TD_SCDMA_SignalStrength.signalStrength,
+ msg.signalStrength.TD_SCDMA_SignalStrength.bitErrorRate,
+ msg.signalStrength.TD_SCDMA_SignalStrength.rscp);
+ LYVERBLOG("+[ril][sst]: WCDMA_signalStrength = %d,WCDMA_bitErrorRate = %d,WCDMA_rscp = %d,WCDMA_ecno = %d\n",
+ msg.signalStrength.WCDMA_SignalStrength.signalStrength,
+ msg.signalStrength.WCDMA_SignalStrength.bitErrorRate,
+ msg.signalStrength.WCDMA_SignalStrength.rscp,
+ msg.signalStrength.WCDMA_SignalStrength.ecno);
+ LYVERBLOG("+[ril][sst]: ok!!\n");
+ }
+ return 0;
+}
+int eventModemOn(char **argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][mpo]: Please input mode on value,0 or 1,and try again!\n");
+ return -1;
+ }
+ int state = atoi(argv[0]);
+ lynq_modem_on(state,&msg);
+ //printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][mpo]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][mpo]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetupDataCall(char ** argv)
+{
+ int32_t token;
+ int state=0;
+ token = lynq_data_enable_data(&state);
+ //printf("pdn state is %s\n",state<0?"disconnect":"connect");
+ if(state<0)
+ {
+ LYVERBLOG("+[ril][edc]: error num = %d\n",RIL_E_GENERIC_FAILURE);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][edc]: ok!!\n");
+ }
+ return 0;
+}
+int eventDeactiveDataCall(char ** argv)
+{
+ int32_t token;
+ int state=0;
+ token = lynq_data_dectivate_data_call(&state);
+ LYVERBLOG("+[ril][ddc]: ok!!\n");
+ //printf("Factory_result pdn state is %s\n",state<0?"connect":"disconnect");
+ return 0;
+}
+int eventGetDataCalllist(char ** argv)
+{
+ int32_t token=0;
+ int num=5;
+ int realNum=0;
+ LYNQ_Data_Call_Response_v11 **msg=(LYNQ_Data_Call_Response_v11**)malloc(sizeof(LYNQ_Data_Call_Response_v11*)*num);
+ if (msg == NULL)
+ {
+ LYERRLOG("+[ril][gdcl]: malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (LYNQ_Data_Call_Response_v11*)malloc(sizeof(LYNQ_Data_Call_Response_v11));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(LYNQ_Data_Call_Response_v11));
+ }
+ token = lynq_get_data_call_list(msg, num,&realNum);
+ /*
+ for(int i = 0; i<realNum; i++)
+ {
+ printf("status is %d,\nsuggestedRetryTime is %d,\ncid is %d,\nactive is %d,\nmtu is %d\n",msg[i]->status,msg[i]->suggestedRetryTime,msg[i]->cid,msg[i]->active,msg[i]->mtu);
+ printf("type is %s\n",msg[i]->type);
+ printf("ifname is %s\n",msg[i]->ifname);
+ printf("addresses is %s\n",msg[i]->addresses);
+ printf("dnses is %s\n",msg[i]->dnses);
+ printf("gateways is %s\n",msg[i]->gateways);
+ printf("pcscf is %s\n",msg[i]->pcscf);
+ }
+ */
+ if(realNum>0)
+ {
+
+ //printf("Factory_result error code 1\n");
+ for(int i = 0; i<realNum; i++)
+ {
+ LYVERBLOG("+[ril][gdcl]: status = %d,suggestedRetryTime = %d,cid = %d,active = %d,mtu = %d\n",msg[i]->status,msg[i]->suggestedRetryTime,msg[i]->cid,msg[i]->active,msg[i]->mtu);
+ LYVERBLOG("+[ril][gdcl]: type = %s,ifname = %s,addresses = %s,dnses = %s,gateways = s%,pcscf = %s\n",msg[i]->type,msg[i]->ifname,msg[i]->addresses,msg[i]->dnses,msg[i]->gateways,msg[i]->pcscf);
+ }
+ LYVERBLOG("+[ril][gdcl]: ok!!\n");
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gdcl]: error num = %d\n",RIL_E_GENERIC_FAILURE);
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+
+int eventGetSimStatus(char ** argv)
+{
+ static int32_t token=0;
+ simStatus * sim_status=NULL;
+ sim_status = (simStatus *)malloc(sizeof(simStatus));
+ token = lynq_get_sim_status(sim_status);
+ LYINFLOG("card_status:%d,card_type:%d,pin_state:%d,error_code:%d,request:%d,token:%x\n",sim_status->card_status,
+ sim_status->card_type,sim_status->pin_state,sim_status->base.e,sim_status->base.request,sim_status->base.token);
+ if(sim_status->base.e!=0)
+ {
+ LYVERBLOG("+[ril][gss]: error num = %d\n",sim_status->base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gss]: card_status = %d,card_type = %d,pin_state = %d\n",sim_status->card_status,
+ sim_status->card_type,sim_status->pin_state);
+ LYVERBLOG("+[ril][gss]: ok!!\n");
+ }
+ if (sim_status->base.e==-1)
+ {
+ free(sim_status);
+ sim_status=NULL;
+ return -1;
+ }
+ free(sim_status);
+ sim_status=NULL;
+ return 0;
+}
+int eventGetImsi(char ** argv)
+{
+ simImsi msg;
+ lynq_get_imsi(&msg);
+ //printf("request is %d, token is %x,error_code %d,imsi is %s\n",msg.base.request,msg.base.token, msg.base.e,msg.imsi);
+ LYINFLOG("request is %d, token is %x,error_code %d,imsi is %s\n",msg.base.request,msg.base.token, msg.base.e,msg.imsi);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][gimsi]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gimsi]: imsi = %s\n",msg.imsi);
+ LYVERBLOG("+[ril][gimsi]: ok!!\n");
+ }
+ if (msg.base.e==-1)
+ {
+ return -1;
+ }
+ return 0;
+}
+int eventSendSms(char ** argv)
+{
+ int32_t token=0;
+ if(argv[0]==NULL||argv[1]==NULL)
+ {
+ LYERRLOG("+[ril][ssm: Please input telephonyNumber and message,and try again!\n");
+ return -1;
+ }
+ char *telephonyNumber = argv[0];
+ char *msgcont = argv[1];
+ smsResponse msg;
+ msg.smsResp.ackPDU=NULL;
+ //const char *telephonyNumber ="10086";
+ //const char * msgcont = "103";
+ token = lynq_send_sms(telephonyNumber, 0,msgcont, NULL,&msg);
+ //printf("request is %d,token is %x,error is %d,\nmessageRef is %d,ackPDU is %s,errorCode is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ //msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ LYINFLOG("request is %d,token is %x,error is %d,messageRef is %d,ackPDU is %s,errorCode is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][ssm]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][ssm]: ok!!\n");
+ }
+ return 0;
+}
+int eventImsSendSms(char ** argv)
+{
+ int32_t token=0;
+ smsResponse msg;
+ if(argv[0]==NULL||argv[1]==NULL)
+ {
+ LYERRLOG("+[ril][iss]:Please input telephonyNumber and message,and try again!\n");
+ return -1;
+ }
+ char *telephonyNumber = argv[0];
+ char *msgcont = argv[1];
+ msg.smsResp.ackPDU=NULL;
+ //const char *telephonyNumber ="10086";
+ //const char * msgcont = "103";
+ const char* retryNum ="0";
+ const char *messageRef = "201";
+ token = lynq_Ims_send_sms(telephonyNumber, 0,msgcont,retryNum,messageRef, NULL,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d,messageRef is %d,ackPDU is %s,errorCode is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][iss]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][iss]: ok!!\n");
+ }
+ return 0;
+}
+int eventWriteSmsToSim(char ** argv)
+{
+ int32_t token=0;
+ messageStoreInfo msg;
+ if(argv[0]==NULL||argv[1]==NULL||argv[2]==NULL)
+ {
+ LYERRLOG("+[ril][wsts]: Please input telephonyNumber,message and sms status,and try again!\n");
+ return -1;
+ }
+ const int smsStatus = atoi(argv[0]);
+ const char *recPhonNum = argv[1];
+ const char *msgcont = argv[2];
+ token = lynq_write_sms_to_sim(smsStatus,recPhonNum,0,msgcont,NULL,&msg);
+ LYINFLOG("request is %d,token is %x,error is %d,\nmessage strore index is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.msgStoreIndex);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][wsts]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][wsts]: ok!!\n");
+ }
+ return 0;
+}
+int eventReportSmsMemoryStatus(char **argv)
+{
+ lynqBase msg;
+ char output[1024] = {0};
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][rsms]: Please input memory status,0 or 1,and try again!\n");
+ return -1;
+ }
+ int value = atoi(argv[0]);
+ lynq_report_sms_memory_status(value,&msg);
+ //printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][rsms]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][rsms]: ok!!\n");
+ }
+ return 0;
+}
+int eventDeletSmsOnSim(char **argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][dsos]: Please input sms index,and try again!\n");
+ return -1;
+ }
+ int value = atoi(argv[0]);
+ lynq_delet_sms_on_sim(value,&msg);
+ //printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][dsos]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][dsos]: ok!!\n");
+ }
+ return 0;
+}
+int eventGetSmscAddress(char **argv)
+{
+ smscCbInfo msg;
+ lynq_get_smsc_address(&msg);
+ //printf("request is %d,token is %x,error is %d,smsc address is %s\n",msg.base.request,msg.base.token,msg.base.e,msg.smsc);
+ LYINFLOG("request is %d,token is %x,error is %d,smsc address is %s\n",msg.base.request,msg.base.token,msg.base.e,msg.smsc);
+ if(msg.base.e!=0)
+ {
+ LYVERBLOG("+[ril][gsmsc]: error num = %d\n",msg.base.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gsmsc]: smsc = %s\n",msg.smsc);
+ LYVERBLOG("+[ril][gsmsc]: ok!!\n");
+ }
+ return 0;
+}
+int eventSetSmscAddress(char **argv)
+{
+ lynqBase msg;
+ if(argv[0]==NULL)
+ {
+ LYERRLOG("+[ril][ssmsc]: Please input smsc address,and try again!\n");
+ return -1;
+ }
+ const char* serviceNumber = argv[0];
+ lynq_set_smsc_address(serviceNumber,&msg);
+ //printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ LYINFLOG("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][ssmsc]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][ssmsc]: ok!!\n");
+ }
+ return 0;
+}
+int evenStoreSmsToMemory(char **argv)
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ //printf("argv[2]%d,argv[3]%s,argv[4]%s\n",atoi(argv[2]), argv[3],argv[4]);
+ lynq_store_sms_to_memory(RIL_SOCKET_1,atoi(argv[0]), argv[1],argv[2],&msg);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][sstm]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][sstm]: ok!!\n");
+ }
+ return 0;
+}
+int eventGetSmsFromMemory(char **argv)
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ storeMessageInfo sms;
+ lynq_get_sms_from_memory(atoi(argv[0]),&sms, &msg);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][gstfm]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][gsfm]: Index = %d,Message = %s,Status = %d,teleNum= %s\n",sms.index,sms.message,sms.status,sms.teleNum);
+ LYVERBLOG("+[ril][gsfm]: ok!!\n");
+ }
+ return 0;
+}
+int eventDeleteMessageFromMemory(char **argv)
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ lynq_delete_message_from_memory(atoi(argv[0]), &msg);
+ if(msg.e!=0)
+ {
+ LYVERBLOG("+[ril][dmfm]: error num = %d\n",msg.e);
+ }
+ else
+ {
+ LYVERBLOG("+[ril][dmfm]: ok!!\n");
+ }
+ return 0;
+}
+
+//int callController(int *item, char *value,int command);
+//int networkcontroller(int *item, char *value,int command);
+//int datacontroller(int *item, char *value,int command);
+//int simcontroller(int *item, char *value,int command);
+//int smscontroller(int *item, char *value,int command);
+
+int ril_test(char *api,char *string) {
+ char *argv[MAX_P] = {0};
+ parseParameters(string,argv);
+ RIL_COMMAND *command = find_command(api,api_commands);
+ if(command)
+ {
+ (*(command->func)) (argv);
+ }
+ else
+ {
+ LYERRLOG("Can not find this command from function_test!!!\n");
+ }
+ /*
+ switch (module) {
+ case CALL_API:
+ {
+ callController(menu[1],argv);
+ break;
+ }
+ case NETWORK_API:
+ {
+ networkcontroller(menu[1],argv);
+ break;
+ }
+ case DATA_API:
+ {
+ datacontroller(menu[1],argv);
+ break;
+ }
+ case SMS_API:
+ {
+ smscontroller(menu[1],argv);
+ //RLOGD("test_api,RIL_API");
+ break;
+ }
+ case SIM_API:
+ {
+ simcontroller(menu[1],argv);
+ break;
+ }
+ default:
+ break;
+ }
+ */
+ return 0;
+}
+/*
+int callController(char *api,char **param)
+{
+ char output[1024] = {0};
+ RIL_COMMAND *command = find_command(api,api_commands);
+ (*(command->func)) (param);
+
+ switch(call_api_choice)
+ {
+ case DAIL:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventDial(argv[1],command);
+ }
+ else
+ {
+ printf("please input inavaliable call number,and try again!\n");
+ emResultNotify(output,command);
+ }
+
+ //eventDial(item[4],command);
+ //printf("please input inavaliable call number,and try again!\n");
+ //emResultNotify(output,command);
+
+ break;
+ }
+ case ANSWER_CALL:
+ {
+ eventAnswer(command);
+ break;
+ }
+ case HANGUP_CALL:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventCallHangUp(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ printf("please input call id,and try again!\n");
+ emResultNotify(output ,command);
+ }
+ break;
+ }
+ case REJECT_CALL:
+ {
+ eventRejectCall(command);
+ break;
+ }
+ case AUTO_ANSWER_CALL:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventAutoAnswer(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input auto answer mode value:0 or 1,and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case SET_MUTE_STATUS:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetMute(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input set mute mode:0 or 1,and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case GET_MUTE_STATUS:
+ {
+ eventGetMute(command);
+ break;
+ }
+ case SET_DTMF:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetDTMF(argv[1][0],command);
+ }
+ else
+ {
+ sprintf(output,"please input DTMF value:0-9,8,#,and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case SET_DTMF_V:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetDTMFVolume(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input volume value,0-36,and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case DO_MULTI_CONF:
+ {
+ eventDoMultiConference(command);
+ break;
+ }
+ case OTHER_CALL_HOLD:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventOthercallHold(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input call id, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case HANGUP_WAITING_CALL:
+ {
+ eventHangupWatingForCall(command);
+ break;
+ }
+ case HANGUP_FORE_RES_BACK:
+ {
+ eventHangupForegroundResumeBackground(command);
+ break;
+ }
+ case SWITCH_HOLD_AND_ACTIVE_CALL:
+ {
+ eventSwitchWaitOrHoldAndActiveCall(command);
+ break;
+ }
+ case GET_LAST_CALL_FAIL_CAUSE:
+ {
+ eventLastCallFailCause(command);
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+int networkcontroller(char *api,char **param)
+{
+ int network_api_choice = item[3];
+ char output[1024] = {0};
+ switch(network_api_choice)
+ {
+ case QUERY_OPERATOR:
+ {
+ eventQueryOperator(command);
+ break;
+ }
+ case QUERY_NETWORK_SELECTION_MODE:
+ {
+ eventQueryNetSelectMode(command);
+ break;
+ }
+ case SET_NETWORK_SELECTION_MODE:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetNetSelectMode(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input network selection mode 0 or 1, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case QUERY_AVAILABLE_NETWORKS:
+ {
+ eventQueryAvailableNetwork(command);
+ break;
+ }
+ case QUERY_REGISTRATION_STATE:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventQueryRegistrationState(argv[1],command);
+ }
+ else
+ {
+ sprintf(output,"please input type voice,data,or ims, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case GET_PREFERRED_NETWORK_TYPE:
+ {
+ eventQueryPrefferredNetworkType(command);
+ break;
+ }
+ case SET_PREFERRED_NETWORK_TYPE:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetPrefferredNetworkType(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input preferred network type value , and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case GET_CELL_INFO_LIST:
+ {
+ eventQueryCellInfo(command);
+ break;
+ }
+ case SET_UNSOL_CELL_INFO_LIST_RATE:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetUnsolCellInfoListrate(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input unsolicited cell infomation list rate , and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case GET_NEIGHBORING_CELL_IDS:
+ {
+ eventQueryNeighboringCellids(command);
+ break;
+ }
+ case SET_BAND_MODE:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetBandMode(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input band mode, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case QUERY_AVAILABLE_BAND_MODE:
+ {
+ eventQueryAvailableBandmode(command);
+ break;
+ }
+ case RADIO_POWER:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventRadioOn(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input radio power status value 0 or 1, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case VOICE_RADIO_TECH:
+ {
+ eventQueryRadioTech(command);
+ break;
+ }
+ case SIGNAL_STRENGTH:
+ {
+ eventSolicitedSignalStrength(command);
+ break;
+ }
+ case MODEM_POWER:
+ {
+ int num=0;
+ char *argv[2]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventModemOn(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input modem power status value 0 or 1, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+int datacontroller(char *api,char **param)
+{
+ int data_api_choice = item[3];
+ char output[1024] = {0};
+ switch(data_api_choice)
+ {
+ case SETUP_DATA_CALL:
+ {
+ eventSetupDataCall(command);
+ break;
+ }
+ case DEACTIVATE_DATA_CALL:
+ {
+ eventDeactiveDataCall(command);
+ break;
+ }
+ case GET_DATA_CALL_LIST:
+ {
+ eventGetDataCalllist(command);
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+int simcontroller(char *api,char **param)
+{
+ int sim_api_choice = item[3];
+ char output[1024] = {0};
+ switch(sim_api_choice)
+ {
+ case GET_SIM_STATUS:
+ {
+ eventGetSimStatus(command);
+ break;
+ }
+ case GET_IMSI:
+ {
+ eventGetImsi(command);
+ break;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+int smscontroller(int *item, char *value,int command)
+{
+ int sms_api_choice = item[3];
+ char output[1024] = {0};
+ switch(sms_api_choice)
+ {
+ case SEND_SMS:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(2, value,argv))
+ {
+ eventSendSms(argv[1], argv[2],command);
+ }
+ else
+ {
+ sprintf(output,"please input phone number and message, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case IMS_SEND_SMS:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(2, value,argv))
+ {
+ eventImsSendSms(argv[1], argv[2],command);
+ }
+ else
+ {
+ sprintf(output,"please input phone number and message, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case WRITE_SMS_TO_SIM:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(3, value,argv))
+ {
+ eventWriteSmsToSim(atoi(&argv[1][0]),argv[2], argv[3],command);
+ }
+ else
+ {
+ sprintf(output,"please input sms status,phone number and message, and try again!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case REPORT_SMS_MEMORY_STATUS:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventReportSmsMemoryStatus(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input memory status 0 or 1,and try agin!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case DELETE_SMS_ON_SIM:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventDeletSmsOnSim(atoi(&argv[1][0]),command);
+ }
+ else
+ {
+ sprintf(output,"please input sms index,and try agin!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ case GET_SMSC_ADDRESS:
+ {
+ eventGetSmscAddress(command);
+ break;
+ }
+ case SET_SMSC_ADDRESS:
+ {
+ int num=0;
+ char *argv[MAX_P]={0};
+ if(num==parseParam(1, value,argv))
+ {
+ eventSetSmscAddress(argv[1],command);
+ }
+ else
+ {
+ sprintf(output,"please input serviceNumber,and try agin!\n");
+ emResultNotify(output,command);
+ }
+ break;
+ }
+ }
+ return 0;
+}
+*/
+
+
diff --git a/src/lynq/packages/apps/lynq-function-test/src/ril_test.h b/src/lynq/packages/apps/lynq-function-test/src/ril_test.h
new file mode 100644
index 0000000..7b1aa66
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/ril_test.h
@@ -0,0 +1,130 @@
+/*=============================================================================
+** FileName: ril_test.h
+** Desc: about function test
+** Author: Warren
+** Version: V1.0
+** LastChange: 2021-02-26
+** History:
+=============================================================================*/
+
+#ifndef __LYNQ_RIL_TEST_H__
+#define __LYNQ_RIL_TEST_H__
+typedef enum {
+ SIM_API = 0,
+ CALL_API,
+ NETWORK_API,
+ DATA_API,
+ SMS_API,
+}RIL_API_MENU;
+
+typedef enum{
+ DAIL= 0,
+ ANSWER_CALL,
+ HANGUP_CALL,
+ REJECT_CALL,
+ AUTO_ANSWER_CALL,
+ SET_MUTE_STATUS,
+ GET_MUTE_STATUS,
+ SET_DTMF,
+ SET_DTMF_V,
+ DO_MULTI_CONF,
+ OTHER_CALL_HOLD,
+ HANGUP_WAITING_CALL,
+ HANGUP_FORE_RES_BACK,
+ SWITCH_HOLD_AND_ACTIVE_CALL,
+ GET_LAST_CALL_FAIL_CAUSE,
+}RIL_CALL_MENU;
+
+typedef enum
+{
+ QUERY_OPERATOR=0,
+ QUERY_NETWORK_SELECTION_MODE,
+ SET_NETWORK_SELECTION_MODE,
+ QUERY_AVAILABLE_NETWORKS,
+ QUERY_REGISTRATION_STATE,
+ GET_PREFERRED_NETWORK_TYPE,
+ SET_PREFERRED_NETWORK_TYPE,
+ GET_CELL_INFO_LIST,
+ SET_UNSOL_CELL_INFO_LIST_RATE,
+ GET_NEIGHBORING_CELL_IDS ,
+ SET_BAND_MODE,
+ QUERY_AVAILABLE_BAND_MODE,
+ RADIO_POWER,
+ VOICE_RADIO_TECH,
+ SIGNAL_STRENGTH,
+ MODEM_POWER,
+}RIL_NETWORK_MENU;
+
+typedef enum{
+ SETUP_DATA_CALL=0,
+ DEACTIVATE_DATA_CALL,
+ GET_DATA_CALL_LIST,
+}RIL_DATA_MENU;
+
+typedef enum{
+ GET_SIM_STATUS=0,
+ GET_IMSI,
+}RIL_SIM_MENU;
+
+typedef enum{
+ SEND_SMS=0,
+ IMS_SEND_SMS,
+ WRITE_SMS_TO_SIM,
+ REPORT_SMS_MEMORY_STATUS,
+ DELETE_SMS_ON_SIM,
+ GET_SMSC_ADDRESS,
+ SET_SMSC_ADDRESS,
+}RIL_SMS_MENU;
+int eventDial(char **argv);
+int eventAnswer(char **argv);
+int eventAutoAnswer(char **argv);
+int eventSetMute(char **argv);
+int eventGetMute(char **argv);
+int eventLastCallFailCause(char **argv);
+int eventCallHangUp(char **argv);
+int eventRejectCall(char **argv);
+int eventSetDTMF(char **argv);
+int eventSetDTMFVolume(char **argv);
+int eventDoMultiConference(char **argv);
+int eventOthercallHold(char **argv);
+int eventHangupWatingForCall(char **argv);
+int eventHangupForegroundResumeBackground(char **argv);
+int eventSwitchWaitOrHoldAndActiveCall(char ** argv);
+int eventQueryOperator(char ** argv);
+int eventQueryNetSelectMode(char ** argv);
+int eventSetNetSelectMode(char ** argv);
+int eventQueryAvailableNetwork(char **argv);
+int eventQueryRegistrationState(char ** argv);
+int eventQueryPrefferredNetworkType(char ** argv);
+int eventSetPrefferredNetworkType(char ** argv);
+int eventQueryCellInfo(char ** argv);
+int eventSetUnsolCellInfoListrate(char ** argv);
+int eventQueryNeighboringCellids(char ** argv);
+int eventSetBandMode(char ** argv);
+int eventQueryAvailableBandmode(char ** argv);
+int eventRadioOn(char ** argv);
+int eventQueryRadioTech(char ** argv);
+int eventSolicitedSignalStrength(char ** argv);
+int eventModemOn(char **argv);
+int eventSetupDataCall(char ** argv);
+int eventDeactiveDataCall(char ** argv);
+int eventGetDataCalllist(char ** argv);
+int eventGetSimStatus(char ** argv);
+int eventGetImsi(char ** argv);
+int eventSendSms(char ** argv);
+int eventImsSendSms(char ** argv);
+int eventWriteSmsToSim(char ** argv);
+int eventReportSmsMemoryStatus(char **argv);
+int eventDeletSmsOnSim(char **argv);
+int eventGetSmscAddress(char **argv);
+int eventSetSmscAddress(char **argv);
+int evenStoreSmsToMemory(char **argv);
+int eventGetSmsFromMemory(char **argv);
+int eventDeleteMessageFromMemory(char **argv);
+
+
+int ril_test(char *api,char *string);
+
+
+#endif //__LYNQ_RIL_TEST_H__
+
diff --git a/src/lynq/packages/apps/lynq-function-test/src/usb_commands.h b/src/lynq/packages/apps/lynq-function-test/src/usb_commands.h
new file mode 100644
index 0000000..cd6f381
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/usb_commands.h
@@ -0,0 +1,4 @@
+{"enable_gadget",enable_gadget, "enable_gadget"},
+{"tether_gadget_on",tether_gadget_on, "tether_gadget_on"},
+{"disable_gadget",disable_gadget, "disable_gadget"},
+{"tether_gadget_off",tether_gadget_off, "tether_gadget_off"},
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/usb_switch.cpp b/src/lynq/packages/apps/lynq-function-test/src/usb_switch.cpp
new file mode 100644
index 0000000..c037ab1
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/usb_switch.cpp
@@ -0,0 +1,88 @@
+#include "usb_switch.h"
+#define MAX_P 1024
+
+RIL_COMMAND usb_api_commands[] = {
+#include "usb_commands.h"
+};
+
+
+int usb_switch_test(char *api,char *string) {
+ char *argv[MAX_P] = {0};
+ parseParameters(string,argv);
+ RIL_COMMAND *command = find_command(api,usb_api_commands);
+ if(command)
+ {
+ (*(command->func)) (argv);
+ }
+ else
+ {
+ LYERRLOG("Can not find this command from function_test!!!\n");
+ }
+ return 0;
+}
+
+
+int enable_gadget(char **argv){
+ char buff[128]={0};
+ FILE *cmd = NULL;
+ cmd = popen("connmanctl enable gadget", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 0;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("enable gadget, %s",buff);
+
+ }
+ pclose(cmd);
+ return 0;
+}
+int tether_gadget_on(char **argv){
+ char buff[128]={0};
+ FILE *cmd = NULL;
+ cmd = popen("connmanctl tether gadget on", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 0;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("tether gadget on, %s",buff);
+
+ }
+ pclose(cmd);
+ return 0;
+}
+int disable_gadget(char **argv){
+ char buff[128]={0};
+ FILE *cmd = NULL;
+ cmd = popen("connmanctl disable gadget", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 0;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("disable gadget , %s",buff);
+
+ }
+ pclose(cmd);
+ return 0;
+}
+int tether_gadget_off(char **argv){
+ char buff[128]={0};
+ FILE *cmd = NULL;
+ cmd = popen("connmanctl tether gadget off", "r");
+ if (cmd == NULL) {
+ RLOGD("open pipe fail!\n");
+ return 0;
+ }
+ while(fgets(buff,127,cmd)!=NULL)
+ {
+ LYVERBLOG("tether gadget off, %s",buff);
+
+ }
+ pclose(cmd);
+ return 0;
+}
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-function-test/src/usb_switch.h b/src/lynq/packages/apps/lynq-function-test/src/usb_switch.h
new file mode 100644
index 0000000..1021e44
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-function-test/src/usb_switch.h
@@ -0,0 +1,17 @@
+#ifndef __USB_SWITCH_H__
+#define __USB_SWITCH_H__
+
+#include "function_common.h"
+#include <log/log.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+
+int usb_switch_test(char *api,char *string);
+int enable_gadget(char **argv);
+int tether_gadget_on(char **argv);
+int disable_gadget(char **argv);
+int tether_gadget_off(char **argv);
+#endif
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-tcpcli/lynq_tcpcli.c b/src/lynq/packages/apps/lynq-tcpcli/lynq_tcpcli.c
new file mode 100644
index 0000000..b131b76
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tcpcli/lynq_tcpcli.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <strings.h>
+#include<stdlib.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "TCPCLI"
+#define SA struct sockaddr
+#define BUF_LEN 128
+#define ERR_CMDVALID 2
+#define ERR_SOCK 3
+
+int main(int argc, const char *argv[])
+{
+ int sockfd;
+ char buf[BUF_LEN];
+ int ret_con;
+
+ LYLOGEINIT(USER_LOG_TAG);
+ if(argc<3)
+ {
+ LYDBGLOG("arg is wrong, please input ip and port\n");
+ LYVERBLOG("+[tcpcli]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+ sockfd=socket(AF_INET,SOCK_STREAM,0);
+
+ if(sockfd<0)
+ {
+ LYDBGLOG("fail to socket\n");
+ return ERR_SOCK;
+ }
+ struct sockaddr_in seraddr;
+ seraddr.sin_family=AF_INET;
+ seraddr.sin_port=htons(atoi(argv[2]));
+ seraddr.sin_addr.s_addr=inet_addr(argv[1]);
+
+
+ while(1)
+ {
+ ret_con=connect(sockfd,(SA *)&seraddr,sizeof(seraddr));
+ if(ret_con<0)
+ {
+ LYDBGLOG("fail to connect\n");
+ return ERR_SOCK;
+ }
+ while(1)
+ {
+ bzero(buf,sizeof(buf));
+ fgets(buf,sizeof(buf),stdin);
+
+ send(sockfd,buf,sizeof(buf),0);
+
+ bzero(buf,sizeof(buf));
+ recv(sockfd,buf,sizeof(buf),0);
+
+ LYVERBLOG("+[tcpcli]: cli_rcv = %s\n",buf);
+ }
+ }
+
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-tcpcli/makefile b/src/lynq/packages/apps/lynq-tcpcli/makefile
new file mode 100644
index 0000000..bd11f7c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tcpcli/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+
+
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -llynq-log \
+ -lssl \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-tcpcli
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-tcpser/lynq_tcpser.c b/src/lynq/packages/apps/lynq-tcpser/lynq_tcpser.c
new file mode 100644
index 0000000..fb97a16
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tcpser/lynq_tcpser.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <strings.h>
+#include <unistd.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "TCPSER"
+#define SA struct sockaddr
+#define BUF_LEN 128
+#define ERR_SOCK 3
+
+int main(int argc, const char *argv[])
+{
+ int sockfd,confd;
+ char buf[BUF_LEN];
+ int ret_recv;
+ int ret_bind;
+
+ LYLOGEINIT(USER_LOG_TAG);
+ sockfd=socket(AF_INET,SOCK_STREAM,0);
+
+ if(sockfd<0)
+ {
+ LYDBGLOG("fail to socket\n");
+ return ERR_SOCK;
+ }
+ struct sockaddr_in seraddr;
+ seraddr.sin_family=AF_INET;
+ seraddr.sin_port=htons(50000);
+ seraddr.sin_addr.s_addr=inet_addr("0.0.0.0");
+
+ ret_bind=bind(sockfd,(SA *)&seraddr,sizeof(seraddr));
+ if(ret_bind<0)
+ {
+ LYDBGLOG("fail to bind\n");
+ return ERR_SOCK;
+ }
+
+ listen(sockfd,5);
+
+ while(1)
+ {
+ confd=accept(sockfd,NULL,NULL);
+ //printf("confd =%d\n",confd);
+ if(confd<0)
+ {
+ LYDBGLOG("fail to accept\n");
+ return ERR_SOCK;
+ }
+
+ while(1)
+ {
+ bzero(buf,sizeof(buf));
+
+ ret_recv=recv(confd,buf,sizeof(buf),0);
+
+ if(ret_recv<0)
+ {
+ LYDBGLOG("fail to recv\n");
+ return ERR_SOCK;
+ }
+ if(ret_recv==0)
+ {
+ close(confd);
+ LYDBGLOG("closed,confd =%d\n",confd);
+ break;
+ }
+
+ LYVERBLOG("+[tcpser]: ser_rcv = %s\n",buf);
+ send(confd,buf,sizeof(buf),0);
+ }
+
+ }
+
+
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-tcpser/makefile b/src/lynq/packages/apps/lynq-tcpser/makefile
new file mode 100644
index 0000000..27153d5
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tcpser/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+
+
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -llynq-log \
+ -lssl \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-tcpser
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/LICENSE b/src/lynq/packages/apps/lynq-tele-cmd-test/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/call_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/call_commands.h
new file mode 100644
index 0000000..8038da4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/call_commands.h
@@ -0,0 +1,20 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+//Call controller
+{"DIAL",eventCallController::eventDial, "dial a call", LYNQ_DIAL},
+{"AN",eventCallController::eventAnswer,"answer in coming call",LYNQ_ANSWER_CALL},
+{"ATAN",eventCallController::eventAutoAnswer,"auto answer mode",LYNQ_AUTO_ANSWER_CALL},
+{"STME",eventCallController::eventSetMute, "set mute", LYNQ_SET_MUTE},
+{"GTME",eventCallController::eventGetMute, "get mute status", LYNQ_GET_MUTE},
+{"LCFC",eventCallController::eventLastCallFailCause, "last call fail cause", LYNQ_LAST_CALL_FAIL_CAUSE},
+{"HUP",eventCallController::eventCallHangUp, "hang up a call", LYNQ_REQUEST_HANGUP},
+{"UDUB",eventCallController::eventRejectCall, "hang up all call or reject a call", LYNQ_REQUEST_UDUB},
+{"DTMF",eventCallController::eventSetDTMF, "send DTMF number", LYNQ_REQUEST_DTMF},
+{"DTMFV",eventCallController::eventSetDTMFVolume, "set DTMF volume", LYNQ_SET_DTMF_VOLUME},
+{"HWC",eventCallController::eventHangupWatingForCall, "hang up waiting or background call", LYNQ_HANGUP_WAITING_OR_BACKGROUND},
+{"HFRB",eventCallController::eventHangupForegroundResumeBackground, "hang up foregound call and resume background call", LYNQ_HANGUP_FOREGROUND_RESUME_BACKGROUND},
+{"SWHA",eventCallController::eventSwitchWaitOrHoldAndActiveCall, "switch waiting or holding call to active", LYNQ_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE},
+{"DMC",eventCallController::eventDoMultiConference, "do multi conference", LYNQ_CONFERENCE},
+{"OCH",eventCallController::eventOthercallHold, "separate conferece", LYNQ_SEPARATE_CONNECTION},
+{(char *)NULL, NULL, (char *)NULL , -1},
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.cpp
new file mode 100644
index 0000000..2a18579
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.cpp
@@ -0,0 +1,222 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libtel/lynq_call.h>
+#include <string.h>
+#include <log/log.h>
+#include "cc.h"
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_DEMO_CC"
+eventCallController::eventCallController(){
+}
+eventCallController::~eventCallController(){
+}
+int eventCallController::eventDial(int argc, char *argv[])
+{
+ if(argc<3)
+ {
+ return -1;
+ }
+ int32_t token;
+ const char * addr = argv[2];
+ //callBackInfor msg;
+ lynqCallList *msg = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(msg,0,sizeof(lynqCallList));
+ msg->addr=(char *)malloc(sizeof(char));
+ memset(msg->addr,0,sizeof(char));
+ printf("call start \n");
+ token = lynq_call(addr, msg);
+ printf("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d\n",
+ msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ RLOGD("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+
+ free(msg->addr);
+ msg->addr=NULL;
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventCallController::eventAnswer(int argc, char * argv [ ])
+{
+ int32_t token;
+ //callBackInfor msg;
+ lynqCallList *msg = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(msg,0,sizeof(lynqCallList));
+ msg->addr=(char *)malloc(sizeof(char));
+ memset(msg->addr,0,sizeof(char));
+ printf("call start \n");
+ token = lynq_call_answer(msg);
+ printf("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d\n",
+ msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ RLOGD("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ msg->base.request,msg->addr,msg->base.request,msg->base.e,msg->call_state);
+
+ free(msg->addr);
+ msg->addr=NULL;
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventCallController::eventAutoAnswer(int argc, char * argv [ ])
+{
+ int32_t token=0;
+ int mode=0;
+ if(argc<3)
+ {
+ return -1;
+ }
+ token = lynq_set_auto_answercall(atoi(argv[2]),&mode);
+ RLOGD("Auto answer mode is %d",mode);
+ printf("Auto answer mode is %d\n",mode);
+ return 0;
+}
+int eventCallController::eventSetMute(int argc, char * argv [ ])
+{
+ int32_t token = 0;
+ int status =0;
+ if(argc<3)
+ {
+ return -1;
+ }
+ token = lynq_set_mute_mic(atoi(argv[2]), &status);
+ RLOGD("set mute status is %s,current mute status is %s",atoi(argv[2])>0?"mute on":"mute off",status>0?"mute on":"mute off");
+ printf("set mute status is %s,current mute status is %s\n",atoi(argv[2])>0?"mute on":"mute off",status>0?"mute on":"mute off");
+ return 0;
+}
+int eventCallController::eventGetMute(int argc, char * argv [ ])
+{
+ int32_t token = 0;
+ int status =0;
+ token = lynq_get_mute_status(&status);
+ RLOGD("current mute status is %s",status>0?"mute on":"mute off");
+ printf("current mute status is %s\n",status>0?"mute on":"mute off");
+ return 0;
+}
+int eventCallController::eventLastCallFailCause(int argc, char *argv[])
+{
+ int32_t token = 0;
+ int status =0;
+ lynqLastCallFailCause * msg = (lynqLastCallFailCause*)malloc(sizeof(lynqLastCallFailCause));
+ memset(msg,0,sizeof(lynqLastCallFailCause));
+ msg->vendor_cause = (char *)malloc(sizeof(char));
+ memset(msg->vendor_cause,0,sizeof(char));
+ token = lynq_get_last_call_fail_cause(msg);
+ RLOGD("token is %x,request is %d,error_code is %d,cause_code is %d,vendor_cause is %s",msg->base.token,
+ msg->base.request,msg->base.e,msg->cause_code,msg->vendor_cause);
+ printf("token is %x,request is %d,error_code is %d,cause_code is %d,vendor_cause is %s\n",msg->base.token,
+ msg->base.request,msg->base.e,msg->cause_code,msg->vendor_cause);
+ free(msg->vendor_cause);
+ free(msg);
+ return 0;
+}
+int eventCallController::eventCallHangUp(int argc, char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set band mode parameter is invalid!");
+ return -1;
+ }
+ lynq_call_hang_up(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventCallController::eventRejectCall(int argc, char *argv[])
+{
+ lynqBase msg;
+ lynq_reject_call(&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventCallController::eventSetDTMF(int argc, char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("send DTMF parameter is inavailable");
+ return -1;
+ }
+ lynq_set_DTMF(argv[2][0],&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventCallController::eventSetDTMFVolume(int argc, char *argv[])
+{
+ int32_t token =0;
+ if(argc<3)
+ {
+ RLOGD("set DTMF volume parameter is inavailable");
+ return -1;
+ }
+ token = lynq_set_DTMF_volume(atoi(argv[2]));
+ printf("set DTMF Volume is %s\n",(token>0?"success":"fail"));
+ return 0;
+}
+int eventCallController::eventDoMultiConference(int argc, char *argv[])
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_do_multi_conference(&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ //RLOGD("request is %d,token is %x,error is %d\n",msg.reqNumber,msg.token,msg.error_code);
+ printf("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.e,msg.base.e,msg.call_state);
+ RLOGD("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ return 0;
+}
+int eventCallController::eventOthercallHold(int argc, char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("separate conference call parameter is inavailable");
+ return -1;
+ }
+ lynq_othercall_hold(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventCallController::eventHangupWatingForCall(int argc, char *argv[])
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_hangup_wating_for_call(&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ //RLOGD("request is %d,token is %x,error is %d\n",msg.reqNumber,msg.token,msg.error_code);
+ printf("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ RLOGD("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ return 0;
+}
+int eventCallController::eventHangupForegroundResumeBackground(int argc, char *argv[])
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_hangup_foreground_resume_background(&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ //RLOGD("request is %d,token is %x,error is %d\n",msg.reqNumber,msg.token,msg.error_code);
+ printf("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ RLOGD("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ return 0;
+}
+int eventCallController::eventSwitchWaitOrHoldAndActiveCall(int argc, char *argv[])
+{
+ lynqCallList msg;
+ msg.addr=NULL;
+ lynq_switch_hold_and_active_call(&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ //RLOGD("request is %d,token is %x,error is %d\n",msg.reqNumber,msg.token,msg.error_code);
+ printf("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d\n",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ RLOGD("[MAIN_LOG] request is %d,call id is %d,phone number is %s,type of address is %d,token is %x,error is %d,call_state is %d",
+ msg.base.request,msg.call_id,msg.addr,msg.toa,msg.base.token,msg.base.e,msg.call_state);
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.h
new file mode 100644
index 0000000..1131e9d
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/cc/cc.h
@@ -0,0 +1,30 @@
+/*
+* Copyright (C) 2020 MobileTek Inc.
+*/
+//#include "lynq_ril.h"
+#ifndef __LYNQ_CALL_CONTROLLER_H__
+#define __LYNQ_CALL_CONTROLLER_H__
+class eventCallController
+{
+ public:
+ eventCallController();
+ ~eventCallController();
+ public:
+ static int eventDial(int argc, char *argv[]);
+ static int eventAnswer(int argc, char *argv[]);
+ static int eventAutoAnswer(int argc, char *argv[]);
+ static int eventSetMute(int argc, char *argv[]);
+ static int eventGetMute(int argc, char *argv[]);
+ static int eventLastCallFailCause(int argc, char *argv[]);
+ static int eventCallHangUp(int argc, char *argv[]);
+ static int eventRejectCall(int argc, char *argv[]);
+ static int eventSetDTMF(int argc, char *argv[]);
+ static int eventSetDTMFVolume(int argc, char *argv[]);
+ static int eventDoMultiConference(int argc, char *argv[]);
+ static int eventOthercallHold(int argc, char *argv[]);
+ static int eventHangupWatingForCall(int argc, char *argv[]);
+ static int eventHangupForegroundResumeBackground(int argc, char *argv[]);
+ static int eventSwitchWaitOrHoldAndActiveCall(int argc, char *argv[]);
+};
+#endif /* __LYNQ_CALL_CONTROLLER_H__ */
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.cpp
new file mode 100644
index 0000000..64eca32
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.cpp
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <log/log.h>
+#include "data.h"
+#include<libtel/lynq_data.h>
+#include <string.h>
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_DATA"
+
+eventDataController::eventDataController(){
+return ;
+}
+eventDataController::~eventDataController(){
+printf("enable\n");
+return;
+}
+int eventDataController::eventSetupDataCall(int argc, char * argv [ ])
+{
+ int32_t token;
+ int state=0;
+ token = lynq_data_enable_data(&state);
+ printf("pdn state is %s\n",state<0?"disconnect":"connect");
+ return 0;
+}
+int eventDataController::eventDeactiveDataCall(int argc, char * argv [ ])
+{
+ int32_t token;
+ int state=0;
+ token = lynq_data_dectivate_data_call(&state);
+ printf("pdn state is %s\n",state<0?"connect":"disconnect");
+ return 0;
+}
+int eventDataController::eventGetDataCalllist(int argc, char * argv [ ])
+{
+ int32_t token=0;
+ int num=5;
+ int realNum=0;
+ LYNQ_Data_Call_Response_v11 **msg=(LYNQ_Data_Call_Response_v11**)malloc(sizeof(LYNQ_Data_Call_Response_v11*)*num);
+ if (msg == NULL)
+ {
+ printf("malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (LYNQ_Data_Call_Response_v11*)malloc(sizeof(LYNQ_Data_Call_Response_v11));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(LYNQ_Data_Call_Response_v11));
+ }
+ token = lynq_get_data_call_list(msg, num,&realNum);
+ for(int i = 0; i<realNum; i++)
+ {
+ printf("data call list 001\n");
+ printf("status is %d,\nsuggestedRetryTime is %d,\ncid is %d,\nactive is %d,\nmtu is %d\n",msg[i]->status,msg[i]->suggestedRetryTime,msg[i]->cid,msg[i]->active,msg[i]->mtu);
+ printf("type is %s\n",msg[i]->type);
+ printf("ifname is %s\n",msg[i]->ifname);
+ printf("addresses is %s\n",msg[i]->addresses);
+ printf("dnses is %s\n",msg[i]->dnses);
+ printf("gateways is %s\n",msg[i]->gateways);
+ printf("pcscf is %s\n",msg[i]->pcscf);
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.h
new file mode 100644
index 0000000..c7a4972
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data.h
@@ -0,0 +1,19 @@
+/*
+* Copyright (C) 2020 MobileTek Inc.
+*/
+#ifndef __LYNQ_DATA_CONTROLLER_H__
+#define __LYNQ_DATA_CONTROLLER_H__
+class eventDataController
+{
+ public:
+ eventDataController();
+ ~eventDataController();
+
+ public:
+ static int eventSetupDataCall(int argc,char *argv[]);
+ static int eventDeactiveDataCall(int argc,char *argv[]);
+ static int eventGetDataCalllist(int argc,char *argv[]);
+};
+#endif /* __LYNQ_DATA_CONTROLLER_H__ */
+
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data_commands.h
new file mode 100644
index 0000000..5253710
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/data/data_commands.h
@@ -0,0 +1,8 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+// DATA information
+{"LYNQ_DC",eventDataController::eventSetupDataCall, "enable data call", LYNQ_SETUP_DATA_CALL},
+{"LYNQ_DEC",eventDataController::eventDeactiveDataCall, "enable data call", LYNQ_DEACTIVATE_DATA_CALL},
+{"LYNQ_GDL",eventDataController::eventGetDataCalllist,"get data call list",LYNQ_GET_DATA_CALL_LIST},
+{(char *)NULL, NULL, (char *)NULL , -1},
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_commands.h
new file mode 100644
index 0000000..d109e4d
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_commands.h
@@ -0,0 +1,12 @@
+//CC
+ {"LYNQ_CALL",eventController::dispatchCallEvent, "dispatch call event", LYNQ_CALL},
+//SIM
+ {"LYNQ_SIM",eventController::dispatchSimEvent, "dispatch sim event", LYNQ_SIM},
+//DATA
+ {"LYNQ_DATA",eventController::dispatchDataEvent,"dispatch data event",LYNQ_DATA},
+//NETWORK
+ {"LYNQ_NET",eventController::dispatchNetworkEvent,"dispatch network event",LYNQ_NETWORK},
+//SMS
+ {"LYNQ_SMS",eventController::dispatchSmsEvent,"dispatch SMS event",LYNQ_SMS},
+ {(char *)NULL, NULL, (char *)NULL , -1},
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_common.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_common.h
new file mode 100644
index 0000000..c85b78b
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_common.h
@@ -0,0 +1,6 @@
+typedef struct {
+ char *name; /* User printable name of the function. */
+ int (*func)(int argc, char *argv[]); /* Function to call to do the job. */
+ char *doc; /* Documentation for this function. */
+ int request;
+} COMMAND;
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.cpp
new file mode 100644
index 0000000..73b0ca5
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.cpp
@@ -0,0 +1,367 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <sys/prctl.h>
+
+#include "lynq_ril.h"
+#include <log/log.h>
+#include <string.h>
+#include <vendor-ril/telephony/ril.h>
+
+//#include <libtel/lynq_call.h>
+//#include <libtel/lynq_sim.h>
+
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_RIL"
+
+#define SERVER_PORT 8080
+#define BUFFER_SIZE 8192
+#define MAX_ARGS 101
+eventController::eventController()
+{
+ printf("initialize event controller!!\n");
+ RLOGD("initialize event controller!!");
+
+}
+eventController::~eventController()
+{
+ RLOGD("clean event controller!!");
+
+}
+
+/*
+ cat libs/telephony/ril_commands.h \
+ | egrep "^ *{RIL_" \
+ | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
+
+
+ cat libs/telephony/ril_unsol_commands.h \
+ | egrep "^ *{RIL_" \
+ | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
+
+
+*/
+const char * requestToString(int request) {
+ switch(request) {
+ case LYNQ_WIFI: return "WIFI";
+ case LYNQ_CALL: return "CALL";
+ case LYNQ_DATA:return "DATA";
+ case LYNQ_SIM:return "SIM";
+ case LYNQ_SMS:return "SMS";
+ case LYNQ_NETWORK:return "NETWORK";
+ case LYNQ_DIAL:return "DIAL";
+ case LYNQ_GET_SIM_STATUS:return "GET_SIM_STATUS";
+ case LYNQ_GET_IMSI:return "GET_IMSI";
+ case LYNQ_ANSWER_CALL:return "ANSWER";
+ case LYNQ_AUTO_ANSWER_CALL:return "AUTO_ANSWER";
+ case LYNQ_GET_MUTE:return "get mute status";
+ case LYNQ_SET_MUTE:return "set mute";
+ case LYNQ_SETUP_DATA_CALL:return "setup data call";
+ case LYNQ_DEACTIVATE_DATA_CALL:return "deactive data call";
+ default: return "<unknown request>";
+ }
+}
+
+
+//int eventController::dispatchCallEvent(int argc, char **argv);
+//int eventController::dispatchSimEvent(int argc, char **argv);
+
+COMMAND lynq_commands[] = {
+#include "lynq_commands.h"
+};
+COMMAND call_commands[]={
+#include "cc/call_commands.h"
+};
+COMMAND sim_commands[]={
+#include "sim/sim_commands.h"
+};
+COMMAND data_commands[]={
+#include "data/data_commands.h"
+};
+COMMAND net_commands[]={
+#include "network/net_commands.h"
+};
+COMMAND sms_commands[]={
+#include "sms/sms_commands.h"
+};
+
+COMMAND* eventController::find_command (char *name,COMMAND *Class)
+{
+ register int i;
+ for (i = 0; Class[i].name; i++)
+ if (strcmp (name, Class[i].name) == 0)
+ return (&Class[i]);
+
+ return ((COMMAND *)NULL);
+}
+int eventController::dispatchCallEvent(int argc, char **argv)
+{
+ if(argc<2)
+ {
+ return -1;
+ }
+ COMMAND *command = eventController::find_command(argv[1],call_commands);
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[1]);
+ return -1;
+ }
+
+ int32_t request;
+ request = command->request;
+ if(request == -1)
+ {
+ //(*(command->func)) (argc, argv);
+ printf("find call event fail\n");
+ return -1;
+ }
+ RLOGD("LYNQ_CALL_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ //printf("005\n");
+ return 0;
+}
+
+
+int eventController::dispatchSimEvent(int argc, char **argv)
+{
+ if(argc<2)
+ {
+ return -1;
+ }
+ COMMAND *command = eventController::find_command(argv[1],sim_commands);
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[1]);
+ return -1;
+ }
+
+ int32_t request;
+ request = command->request;
+ if(request == -1)
+ {
+ //(*(command->func)) (argc, argv);
+ printf("find sim event fail\n");
+ return -1;
+ }
+ RLOGD("LYNQ_SIM_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ //printf("006\n");
+ return 0;
+}
+
+int eventController::dispatchDataEvent(int argc, char * * argv)
+{
+ if(argc<2)
+ {
+ return -1;
+ }
+ COMMAND *command = eventController::find_command(argv[1],data_commands);
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[1]);
+ return -1;
+ }
+
+ int32_t request;
+ request = command->request;
+ if(request == -1)
+ {
+ //(*(command->func)) (argc, argv);
+ printf("find sim event fail\n");
+ return -1;
+ }
+ RLOGD("LYNQ_DATA_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ //printf("006\n");
+ return 0;
+
+}
+int eventController::dispatchNetworkEvent(int argc, char * * argv)
+{
+ if(argc<2)
+ {
+ return -1;
+ }
+ COMMAND *command = eventController::find_command(argv[1],net_commands);
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[1]);
+ return -1;
+ }
+
+ int32_t request;
+ request = command->request;
+ if(request == -1)
+ {
+ //(*(command->func)) (argc, argv);
+ printf("find network event fail\n");
+ return -1;
+ }
+ RLOGD("LYNQ_NETWORK_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ return 0;
+
+}
+int eventController::dispatchSmsEvent(int argc, char * * argv)
+{
+ if(argc<2)
+ {
+ return -1;
+ }
+ COMMAND *command = eventController::find_command(argv[1],sms_commands);
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[1]);
+ return -1;
+ }
+
+ int32_t request;
+ request = command->request;
+ if(request == -1)
+ {
+ //(*(command->func)) (argc, argv);
+ printf("find sms event fail\n");
+ return -1;
+ }
+ RLOGD("LYNQ_SMS_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ return 0;
+
+}
+
+int eventController::parse_param(char *cmd, char *argv[], int max_args){
+ char *pos, *pos2;
+ int argc = 0;
+ pos = cmd;
+ while (1) {
+ // Trim the space characters.
+ while (*pos == ' ') {
+ pos++;
+ }
+
+ if (*pos == '\0') {
+ break;
+ }
+
+ // One token may start with '"' or other characters.
+ if (*pos == '"' && (pos2 = strrchr(pos+1, '"'))) {
+ argv[argc++] = pos + 1;
+ *pos2 = '\0';
+ pos = pos2 + 1;
+ if(*pos == '\n'){
+ *pos = '\0';
+ pos = pos + 1;
+ }
+
+ } else {
+ argv[argc++] = pos;
+ while (*pos != '\0' && *pos != ' '&& *pos != '\n') {
+ pos++;
+ }
+ *pos++ = '\0';
+ }
+
+ // Check if the maximum of arguments is reached.
+ if (argc == max_args) {
+ break;
+ }
+ }
+
+ return argc;
+}
+
+
+void eventController::LYNQ_StartRevSocket()
+{
+ RLOGD("RIL_StartRevSocket start\n");
+ char *argv[MAX_ARGS];
+ int argc = 0;
+
+ prctl(PR_SET_NAME,(unsigned long)"LYNQ_UDP");
+ int server_socket_fd;
+ struct sockaddr_in client_addr;
+ /*listen UPD SOCKET port */
+ struct sockaddr_in server_addr;
+ bzero(&server_addr, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ server_addr.sin_port = htons(SERVER_PORT);
+ /* create socket */
+ //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if(server_socket_fd == -1)
+ {
+ RLOGE("LYNQ Create Socket Failed:");
+ exit(1);
+ }
+
+ /* bind socket port*/
+ if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
+ {
+ RLOGE("LYNQ Server Bind Failed:");
+ exit(1);
+ }
+
+ /* tranlate data */
+ while(true)
+ {
+ /* define address to catch the client addreess*/
+ //struct sockaddr_in client_addr;
+ socklen_t client_addr_length = sizeof(client_addr);
+
+ /* receive the data */
+ char buffer[BUFFER_SIZE];
+ bzero(buffer, BUFFER_SIZE);
+ //printf("001\n");
+ if(recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length) == -1)
+ {
+ RLOGE("Receive Data Failed:");
+ continue;
+ }
+ RLOGD("LYNQ_Demo:%s, receve: %s", inet_ntoa(client_addr.sin_addr), buffer);
+ int argc = parse_param(buffer, argv, MAX_ARGS);
+ if(argc < 1)
+ {
+ RLOGE("%s: error input.", buffer);
+ continue;
+ }
+ COMMAND *command = eventController::find_command(argv[0],lynq_commands);
+ ///printf("002\n");
+ if(!command)
+ {
+ RLOGE("%s: No such command for DemoApp", argv[0]);
+ continue;
+ }
+
+ int32_t request;
+
+ request = command->request;
+ if(request == -1)
+ {
+ (*(command->func)) (argc, argv);
+ continue;
+ }
+/*
+ if (request < 1 || (request >= (int32_t)NUM_ELEMS(s_commands) && request < RIL_REQUEST_VENDOR_BASE)) {
+ RLOGW("unsupported request code %d token %d", request);
+ // FIXME this should perhaps return a response
+ continue;
+ }
+*/
+ RLOGD("LYNQ_REQUEST: %s ParamterNum:%d", requestToString(request), argc);
+ //printf("003\n");
+ //Radio on/off only allow one thread operate.
+ (*(command->func)) (argc, argv);
+ //printf("004\n");
+ }
+
+ RLOGD("close socket fd");
+ close(server_socket_fd);
+ return ;
+}
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.h
new file mode 100644
index 0000000..76af98f
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_ril.h
@@ -0,0 +1,87 @@
+#include "lynq_common.h"
+#include "cc/cc.h"
+#include "sim/sim.h"
+#include "data/data.h"
+#include "network/network.h"
+#include "sms/sms.h"
+#define LYNQ_WIFI 1
+#define LYNQ_CALL 2
+#define LYNQ_SIM 3
+#define LYNQ_SMS 4
+#define LYNQ_DATA 5
+#define LYNQ_NETWORK 6
+#define LYNQ_DIAL 7
+#define LYNQ_GET_SIM_STATUS 8
+#define LYNQ_GET_IMSI 9
+#define LYNQ_ANSWER_CALL 10
+#define LYNQ_AUTO_ANSWER_CALL 11
+#define LYNQ_GET_MUTE 12
+#define LYNQ_SET_MUTE 13
+#define LYNQ_LAST_CALL_FAIL_CAUSE 14
+#define LYNQ_SETUP_DATA_CALL 15
+#define LYNQ_DEACTIVATE_DATA_CALL 16
+#define LYNQ_GET_DATA_CALL_LIST 17
+#define LYNQ_QUERY_OPERATOR 18
+#define LYNQ_QUERY_NETWORK_SELECTION_MODE 19
+#define LYNQ_SET_NETWORK_SELECTION_MODE 20
+#define LYNQ_QUERY_AVAILABLE_NETWORKS 21
+#define LYNQ_QUERY_REGISTRATION_STATE 22
+#define LYNQ_GET_PREFERRED_NETWORK_TYPE 23
+#define LYNQ_SET_PREFERRED_NETWORK_TYPE 24
+#define LYNQ_GET_CELL_INFO_LIST 25
+#define LYNQ_SET_UNSOL_CELL_INFO_LIST_RATE 26
+#define LYNQ_GET_NEIGHBORING_CELL_IDS 27
+#define LYNQ_SET_BAND_MODE 28
+#define LYNQ_QUERY_AVAILABLE_BAND_MODE 29
+#define LYNQ_RADIO_POWER 30
+#define LYNQ_VOICE_RADIO_TECH 31
+#define LYNQ_SIGNAL_STRENGTH 32
+#define LYNQ_MODEM_POWER 33
+#define LYNQ_SEND_SMS 34
+#define LYNQ_IMS_SEND_SMS 35
+#define LYNQ_WRITE_SMS_TO_SIM 37
+#define LYNQ_REPORT_SMS_MEMORY_STATUS 38
+#define LYNQ_DELETE_SMS_ON_SIM 39
+#define LYNQ_GET_SMSC_ADDRESS 40
+#define LYNQ_SET_SMSC_ADDRESS 41
+#define LYNQ_REQUEST_HANGUP 42
+#define LYNQ_REQUEST_UDUB 43
+#define LYNQ_REQUEST_DTMF 44
+#define LYNQ_SET_DTMF_VOLUME 45
+#define LYNQ_HANGUP_WAITING_OR_BACKGROUND 46
+#define LYNQ_HANGUP_FOREGROUND_RESUME_BACKGROUND 47
+#define LYNQ_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 48
+#define LYNQ_CONFERENCE 49
+#define LYNQ_SEPARATE_CONNECTION 50
+
+
+#define LYNQ_STORY_SMS_TO_MEMORY 51
+#define LYNQ_GET_SMS_FROM_MEMORY 52
+#define LYNQ_DELETE_SMS_FROM_MEMORY 53
+
+class eventController: private eventCallController, private eventDataController,private eventSimController,private eventNetworkController,private eventSMSController
+{
+ public:
+ eventController();
+ virtual ~eventController();
+ private:
+ int socketID=0;
+ static COMMAND* find_command (char *name,COMMAND *Class);
+ //COMMAND* find_sim_commands (char *name);
+ //COMMAND* find_call_commands (char *name);
+ public:
+ static int dispatchCallEvent(int argc, char **argv);
+ static int dispatchSimEvent(int argc, char **argv);
+ static int dispatchSmsEvent(int argc, char **argv);
+ static int dispatchDataEvent(int argc, char **argv);
+ static int dispatchNetworkEvent(int argc, char **argv);
+ static int dispatchWifiEvent(int argc, char **argv);
+ static int dispatchGpsEvent(int argc, char **argv);
+ static int dispatchBluetoothEvent(int argc, char **argv);
+ public:
+ int parse_param(char *cmd, char *argv[], int max_args);
+ void LYNQ_StartRevSocket();
+};
+
+
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_testprocess.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_testprocess.cpp
new file mode 100644
index 0000000..42b5f03
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/lynq_testprocess.cpp
@@ -0,0 +1,81 @@
+#include <stdlib.h>
+#include <string.h>
+//#include <ctype.h>
+//#include <sys/wait.h>
+#include <sys/msg.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include <errno.h>
+//#include <cmdril/lib_cmd.h>
+//#include <msgqril/lib_thread.h>
+//#include <msgqril/lib_msgQ.h>
+#include <libtel/lib_tele.h>
+//#include <libtel/lynq_sms.h>
+//#include <libtel/lynq_network.h>
+//#include <libtel/lynq_call.h>
+//#include <libtel/lynq_sim.h>
+#include <unistd.h>
+#include <log/log.h>
+#include "lynq_ril.h"
+#include "liblog/liblog.h"
+
+#define MAX_IMEI 20
+//#define SERVER_PORT 8000
+//#define ARC_RIL_PORT 17998
+#undef LOG_TAG
+#define LOG_TAG "MAIN_LOG"
+const char *
+failCauseToString(RIL_Errcode e) {
+ switch(e) {
+ case SUCCESS: return "E_SUCCESS";
+ case ERROR: return "ERROR";
+ default: return "<unknown error>";
+ }
+}
+//static void responseCallback(int32_t token,RIL_Errcode e,char *response) {
+static void responseCallback(int32_t token,RIL_Errcode e,char *response) {
+ RLOGD("responseCallback,response:%d,%s,%s,%d",token,failCauseToString(e),response);
+ printf("--------->[%s,%d] final response=%s \n",__FUNCTION__,__LINE__, response);
+ RLOGD("--------->[%s,%d] final response=%s \n",__FUNCTION__,__LINE__, response);
+}
+//extern void lynq_recive_new_sms_cb(RIL_SOCKET_ID soc_id,char * num, char * smsc, char * msg, int charset);
+
+//extern void lynq_incoming_call_cb(RIL_SOCKET_ID soc_id,int index, char * addr, RIL_CallState state, int toa);
+
+void lynq_incoming_call_cb(RIL_SOCKET_ID soc_id,int index, char * addr, RIL_CallState state, int toa)
+{
+ printf("[SIM%d]index is %d,addr is %s,state is %d,toa is %d\n",soc_id,index,addr,state,toa);
+}
+
+void lynq_recive_new_sms_cb(RIL_SOCKET_ID soc_id,char * num, char * smsc, char * msg, int charset)
+{
+ printf("[SIM%d]num is %s,smsc is %s,msg is %s,charset is %d\n",soc_id,num,smsc,msg,charset);
+}
+static user_cb mytest={
+ lynq_recive_new_sms_cb,
+ lynq_incoming_call_cb
+};
+static void unsolicitedCallback(char *response) {
+
+}
+int main(int argc, char const *argv[])
+{
+ printf("--------->[%s,%d] start \n",__FUNCTION__,__LINE__);
+ int32_t requestId;
+ int32_t status;
+
+// lynq_store_log_test();
+ lynq_read_set_log_test();
+ lynq_log_output(LOG_MQTT,LOG_WARNING,"factory_mqtt_test start\n");
+ lynqRegisterUnsolicitedResponse(&mytest);
+ RLOGD("responseCallback,%p \n",responseCallback);
+ lynq_ril_init();
+ eventController LYNQ;
+ LYNQ.LYNQ_StartRevSocket();
+ while(1){
+ sleep(1);
+ }
+
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/makefile b/src/lynq/packages/apps/lynq-tele-cmd-test/src/makefile
new file mode 100644
index 0000000..1d99bc2
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/makefile
@@ -0,0 +1,103 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+ LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+ LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+ -DANDROID_MULTI_SIM \
+ -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+ LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+ -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+ -DMD_90_SUPPORT
+endif
+
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH)/cc \
+ -I$(LOCAL_PATH)/sim \
+ -I$(LOCAL_PATH)/data \
+ -I$(LOCAL_PATH)/network \
+ -I$(LOCAL_PATH)/sms \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(ROOT)$(includedir)/libtel \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -lpower \
+ -lbinder \
+ -lpthread \
+ -llynq-tele-ril \
+ -llynq-log \
+ -lmtk_audio_mixer_ctrl \
+ -lasound \
+ -lpal \
+ -lgstreamer-1.0 \
+ -lglib-2.0 \
+ -lgstbase-1.0 \
+ -lgstreamer-1.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldtmf \
+ -lapn \
+ -ldbus-1 \
+
+SOURCES = $(wildcard *.cpp cc/*.cpp sim/*.cpp data/*.cpp network/*.cpp sms/*.cpp)
+
+EXECUTABLE = lynq-tele-cmd-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)
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/net_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/net_commands.h
new file mode 100644
index 0000000..7c71f39
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/net_commands.h
@@ -0,0 +1,45 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+// network information
+
+{"LYNQ_QOP",eventNetworkController::eventQueryOperator, "query operator", LYNQ_QUERY_OPERATOR},
+{"LYNQ_QNSM",eventNetworkController::eventQueryNetSelectMode, "query network selection mode", LYNQ_QUERY_NETWORK_SELECTION_MODE},
+{"LYNQ_SNSM",eventNetworkController::eventSetNetSelectMode,"set network selection mode",LYNQ_SET_NETWORK_SELECTION_MODE},
+{"LYNQ_QAN",eventNetworkController::eventQueryAvailableNetwork, "query available network", LYNQ_QUERY_AVAILABLE_NETWORKS},
+{"LYNQ_QRS",eventNetworkController::eventQueryRegistrationState, "query registration state", LYNQ_QUERY_REGISTRATION_STATE},
+{"LYNQ_GPNT",eventNetworkController::eventQueryPrefferredNetworkType,"get preferred network type",LYNQ_GET_PREFERRED_NETWORK_TYPE},
+{"LYNQ_SPNT",eventNetworkController::eventSetPrefferredNetworkType, "set preferred network type", LYNQ_SET_PREFERRED_NETWORK_TYPE},
+{"LYNQ_GCIL",eventNetworkController::eventQueryCellInfo, "get cell info list", LYNQ_GET_CELL_INFO_LIST},
+{"LYNQ_SUCILR",eventNetworkController::eventSetUnsolCellInfoListrate,"set unsol cell info list rate",LYNQ_SET_UNSOL_CELL_INFO_LIST_RATE},
+{"LYNQ_GNCID",eventNetworkController::eventQueryNeighboringCellids, "get neighboring cell IDs", LYNQ_GET_NEIGHBORING_CELL_IDS},
+{"LYNQ_SBM",eventNetworkController::eventSetBandMode, "set band mode", LYNQ_SET_BAND_MODE},
+{"LYNQ_QABM",eventNetworkController::eventQueryAvailableBandmode,"query available band mode",LYNQ_QUERY_AVAILABLE_BAND_MODE},
+{"LYNQ_RPO",eventNetworkController::eventRadioOn,"set radio power on/off",LYNQ_RADIO_POWER},
+{"LYNQ_VRT",eventNetworkController::eventQueryRadioTech,"voice radio tech",LYNQ_VOICE_RADIO_TECH},
+{"LYNQ_SST",eventNetworkController::eventSolicitedSignalStrength,"singal strength",LYNQ_SIGNAL_STRENGTH},
+{"LYNQ_MPO",eventNetworkController::eventModemOn,"modem power",LYNQ_MODEM_POWER},
+{(char *)NULL, NULL, (char *)NULL , -1},
+/*
+#define LYNQ_QUERY_OPERATOR 18
+#define LYNQ_QUERY_NETWORK_SELECTION_MODE 19
+#define LYNQ_SET_NETWORK_SELECTION_MODE 20
+#define LYNQ_QUERY_AVAILABLE_NETWORKS 21
+#define LYNQ_QUERY_REGISTRATION_STATE 22
+#define LYNQ_GET_PREFERRED_NETWORK_TYPE 23
+#define LYNQ_SET_PREFERRED_NETWORK_TYPE 24
+#define LYNQ_GET_CELL_INFO_LIST 25
+#define LYNQ_SET_UNSOL_CELL_INFO_LIST_RATE 26
+#define LYNQ_GET_NEIGHBORING_CELL_IDS 27
+#define LYNQ_SET_BAND_MODE 28
+#define LYNQ_QUERY_AVAILABLE_BAND_MODE 29
+#define LYNQ_RADIO_POWER 30
+#define LYNQ_VOICE_RADIO_TECH 31
+#define LYNQ_SIGNAL_STRENGTH 32
+#define LYNQ_MODEM_POWER 33
+
+
+
+
+*/
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.cpp
new file mode 100644
index 0000000..3c2880e
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.cpp
@@ -0,0 +1,432 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <log/log.h>
+#include "network.h"
+#include<libtel/lynq_network.h>
+#include <string.h>
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_NETWORK"
+static int strUpper(char * str)
+{
+ int i=0;
+ while(1)
+ {
+ if(str[i]=='\0')
+ {
+ break;
+ }
+ if(str[i]>='a'&&str[i]<='z')
+ {
+ //printf("str %c\n",str[i]-32);
+ str[i]=str[i]-32;
+ }
+ i++;
+ }
+ return 0;
+}
+
+eventNetworkController::eventNetworkController(){
+return ;
+}
+eventNetworkController::~eventNetworkController(){
+printf("enable\n");
+return;
+}
+int eventNetworkController::eventQueryOperator(int argc, char * argv [ ])
+{
+ operatorInfo msg;
+ msg.OperatorFN=NULL;
+ msg.OperatorSH=NULL;
+ msg.MccMnc=NULL;
+ lynq_query_operater(&msg);
+ printf("request is %d,token is %x,error is %d,OperatorFN is %s,OperatorSH is %s,MccMnc is %s\n",msg.base.request,msg.base.token,msg.base.e,msg.OperatorFN,msg.OperatorSH,msg.MccMnc);
+ RLOGD("request is %d,token is %x,error is %d\n",msg.base.request,msg.base.token,msg.base.e);
+ //printf("OperatorFN is %s,OperatorSH is %s,MccMnc is %s\n",msg.OperatorFN,msg.OperatorSH,msg.MccMnc);
+ RLOGD("OperatorFN is %s,OperatorSH is %s,MccMnc is %s\n",msg.OperatorFN,msg.OperatorSH,msg.MccMnc);
+ return 0;
+}
+int eventNetworkController::eventQueryNetSelectMode(int argc, char * argv [ ])
+{
+/*
+ int32_t token;
+ int state=0;
+ token = lynq_data_dectivate_data_call(&state);
+ printf("pdn state is %s\n",state<0?"connect":"disconnect");
+ */
+ networkSelecttionMode msg;
+ lynq_query_network_selection_mode(& msg);
+ printf("request is %d,token is %x,error is %d,mode is %d\n",msg.base.request,msg.base.token,msg.base.e,msg.mode);
+ RLOGD("request is %d,token is %x,error is %d,mode is %d",msg.base.request,msg.base.token,msg.base.e,msg.mode);
+ return 0;
+}
+int eventNetworkController::eventSetNetSelectMode(int argc, char * argv [ ])
+{
+ if(argc<3)
+ {
+ RLOGD("seting network selection mode parameter is invalid!");
+ return -1;
+ }
+ lynqBase msg;
+ lynq_set_network_selection_mode(argv[2],argv[3],&msg);//0:auto selection 1:manual selection
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventNetworkController::eventQueryAvailableNetwork(int argc, char * argv [ ])
+{
+ int32_t token=0;
+ availableNetwork msg;
+ msg.OperatorFN=NULL;
+ msg.OperatorSH=NULL;
+ msg.MccMnc=NULL;
+ msg.NetStatus=NULL;
+ lynq_query_available_network(&msg);
+ printf("request is %d,token is %x,error is %d,OperatorFN is %s,OperatorSH is %s,MccMnc is %s,Netstatus is %s\n",msg.base.request,msg.base.token,msg.base.e,msg.OperatorFN,msg.OperatorSH,msg.MccMnc,msg.NetStatus);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ //printf("OperatorFN is %s,OperatorSH is %s,MccMnc is %s\n",msg.OperatorFN,msg.OperatorSH,msg.MccMnc);
+ RLOGD("OperatorFN is %s,OperatorSH is %s,MccMnc is %s,NetStatus is %s",msg.OperatorFN,msg.OperatorSH,msg.MccMnc,msg.NetStatus);
+ return 0;
+
+}
+ int eventNetworkController::eventQueryRegistrationState(int argc,char *argv[])
+{
+ registrationStateInfo msg;
+ msg.CID=NULL;
+ msg.LAC=NULL;
+ char str[10];
+ if (strlen(argv[2])>10)
+ {
+ RLOGD("the parameter is inavaliable !");
+ return -1;
+ }
+ memcpy(str,argv[2],strlen(argv[2])+1);
+ strUpper(str);
+ printf("upper str is %s\n",str);
+
+ if(argc<3)
+ {
+ RLOGD("query registraion state parameter is invalid!");
+ return -1;
+ }
+ lynq_query_registration_state(argv[2],&msg);
+ if(!strcmp(str,"VOICE")){
+ printf("request is %d,token is %x,error is %d,registration state is %d\n",
+ msg.base.request,msg.base.token,msg.base.e,msg.regState);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("registration state is %d",msg.regState);
+ }else if(!strcmp(str,"DATA")){
+ printf("request is %d,token is %x,error is %d,registration state is %d,LAC is %s,CID is %s,network type is %d\n",
+ msg.base.request,msg.base.token,msg.base.e,msg.regState,msg.LAC,msg.CID,msg.netType);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("registration state is %d,LAC is %s,CID is %s,network type is %d",msg.regState,msg.LAC,msg.CID,msg.netType);
+ }else if(!strcmp(str,"IMS")){
+ printf("request is %d,token is %x,error is %d,ims registration state is %d,radio tech family is %d\n",
+ msg.base.request,msg.base.token,msg.base.e,msg.imsRegState,msg.radioTechFam);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("ims registration state is %d,radio tech family is %d",msg.imsRegState,msg.radioTechFam);
+ }else{
+ printf("--------->[%s,%d] query ims registration state about voice, data, and ims!!! \n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ return 0;
+ }
+ int eventNetworkController::eventQueryPrefferredNetworkType(int argc,char *argv[])
+{
+ prefferredNetworkType msg;
+ lynq_query_prefferred_networktype(&msg);
+ printf("request is %d,token is %x,error is %d,preffered network is %d\n",
+ msg.base.request,msg.base.token,msg.base.e,msg.pnt);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("preffered network is %d",msg.pnt);
+ return 0;
+}
+ int eventNetworkController::eventSetPrefferredNetworkType(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set preffered network parameter is invalid!");
+ return -1;
+ }
+ lynq_set_prefferred_networktype(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",
+ msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventNetworkController::eventQueryCellInfo(int argc,char *argv[])
+{
+ cellInfoList **msg;
+ int num=5;
+ int realNum =0;
+ int32_t token=0;
+ msg = (cellInfoList **)malloc(sizeof(cellInfoList *)*num);
+ if(msg==NULL)
+ {
+ RLOGD("malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (cellInfoList*)malloc(sizeof(cellInfoList));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(cellInfoList));
+ }
+ token = lynq_query_cell_info(msg, num, &realNum);
+ printf("request is %d,\ntoken is %x,\ne is %d\n",msg[0]->base.request,msg[0]->base.token,msg[0]->base.e);
+ for(int i = 0; i<realNum; i++)
+ {
+ //printf("request is %d,\ntoken is %x,\ne is %d\n",msg[i]->base.request,msg[i]->base.token,msg[i]->base.e);
+ printf("cellInfoType is %d\n",msg[i]->cellinfo.cellInfoType);
+ printf("registered is %d\n",msg[i]->cellinfo.registered);
+ printf("timeStampType is %d\n",msg[i]->cellinfo.timeStampType);
+ printf("timeStamp is %d\n",msg[i]->cellinfo.timeStamp);
+ switch(msg[i]->cellinfo.cellInfoType) {
+ case RIL_CELL_INFO_TYPE_GSM: {
+ printf("gsm.cellIdentityGsm.mcc is %d\n",msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.mcc);
+ printf("gsm.cellIdentityGsm.mnc is %d\n",msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.mnc);
+ printf("gsm.cellIdentityGsm.lac is %d\n",msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.lac);
+ printf("gsm.cellIdentityGsm.cid is %d\n",msg[i]->cellinfo.CellInfo.gsm.cellIdentityGsm.cid);
+ printf("gsm.signalStrengthGsm.signalStrength is %d\n",msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.signalStrength);
+ printf("gsm.signalStrengthGsm.bitErrorRate is %d\n",msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.bitErrorRate);
+ printf("gsm.signalStrengthGsm.timingAdvance is %d\n",msg[i]->cellinfo.CellInfo.gsm.signalStrengthGsm.timingAdvance);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_WCDMA: {
+ printf("wcdma.cellIdentityWcdma.mcc is %d\n",msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mcc);
+ printf("wcdma.cellIdentityWcdma.mnc is %d\n",msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mnc);
+ printf("wcdma.cellIdentityWcdma.lac is%d\n",msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.lac);
+ printf("wcdma.cellIdentityWcdma.cid is %d\n",msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.cid);
+ printf("wcdma.cellIdentityWcdma.psc is %d\n",msg[i]->cellinfo.CellInfo.wcdma.cellIdentityWcdma.psc);
+ printf("wcdma.signalStrengthWcdma.signalStrength is %d\n",msg[i]->cellinfo.CellInfo.wcdma.signalStrengthWcdma.signalStrength);
+ printf("wcdma.signalStrengthWcdma.bitErrorRate is %d\n",msg[i]->cellinfo.CellInfo.wcdma.signalStrengthWcdma.bitErrorRate);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_CDMA: {
+ printf("cdma.cellIdentityCdma.networkId is %d\n",msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.networkId);
+ printf("cdma.cellIdentityCdma.systemId is %d\n",msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.systemId);
+ printf("cdma.cellIdentityCdma.basestationId is %d\n",msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.basestationId);
+ printf("cdma.cellIdentityCdma.longitude is %d\n",msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.longitude);
+ printf("cdma.cellIdentityCdma.latitude is %d\n",msg[i]->cellinfo.CellInfo.cdma.cellIdentityCdma.latitude);
+ printf("cdma.signalStrengthCdma.dbm is %d\n",msg[i]->cellinfo.CellInfo.cdma.signalStrengthCdma.dbm);
+ printf("cdma.signalStrengthCdma.ecio is %d\n",msg[i]->cellinfo.CellInfo.cdma.signalStrengthCdma.ecio);
+ printf("cdma.signalStrengthEvdo.dbm is %d\n",msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.dbm);
+ printf("cdma.signalStrengthEvdo.ecio is %d\n",msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.ecio);
+ printf("cdma.signalStrengthEvdo.signalNoiseRatio is %d\n",msg[i]->cellinfo.CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_LTE: {
+ printf("lte.cellIdentityLte.mcc is %d\n",msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.mcc);
+ printf("lte.cellIdentityLte.mnc is %d\n",msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.mnc);
+ printf("lte.cellIdentityLte.ci is %d\n",msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.ci);
+ printf("lte.cellIdentityLte.pci is %d\n",msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.pci);
+ printf("lte.cellIdentityLte.tac is %d\n",msg[i]->cellinfo.CellInfo.lte.cellIdentityLte.tac);
+ printf("lte.signalStrengthLte.signalStrength is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.signalStrength);
+ printf("lte.signalStrengthLte.rsrp is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rsrp);
+ printf("lte.signalStrengthLte.rsrq is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rsrq);
+ printf("lte.signalStrengthLte.rssnr is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.rssnr);
+ printf("lte.signalStrengthLte.cqi is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.cqi);
+ printf("lte.signalStrengthLte.timingAdvance is %d\n",msg[i]->cellinfo.CellInfo.lte.signalStrengthLte.timingAdvance);
+ break;
+ }
+ case RIL_CELL_INFO_TYPE_TD_SCDMA: {
+ printf("tdscdma.cellIdentityTdscdma.mcc is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mcc);
+ printf("tdscdma.cellIdentityTdscdma.mnc is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mnc);
+ printf("tdscdma.cellIdentityTdscdma.lac is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.lac);
+ printf("tdscdma.cellIdentityTdscdma.cid is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cid);
+ printf("tdscdma.cellIdentityTdscdma.cpid is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cpid);
+ printf("tdscdma.signalStrengthTdscdma.rscp is %d\n",msg[i]->cellinfo.CellInfo.tdscdma.signalStrengthTdscdma.rscp);
+ break;
+ }
+ }
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventNetworkController::eventSetUnsolCellInfoListrate(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set unsolicted cell information list rate parameter is invalid!");
+ return -1;
+ }
+ lynq_set_unsol_cell_info_listrate(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",
+ msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventNetworkController::eventQueryNeighboringCellids(int argc,char *argv[])
+{
+ neighboringCellIDs **msg=NULL;
+ printf("neighboring celll ids\n");
+ int num=5;
+ int realNum =0;
+ int32_t token=0;
+ msg = (neighboringCellIDs **)malloc(sizeof(neighboringCellIDs *)*num);
+ if(msg==NULL)
+ {
+ RLOGD("malloc LYNQ_Data_Call_Response_v11 fail \n");
+ return -1;
+ }
+ for(int i =0;i<num;i++)
+ {
+ msg[i] = (neighboringCellIDs*)malloc(sizeof(neighboringCellIDs));
+ msg[i]->cid = (char*)malloc(sizeof(char));
+ if (msg[i]==NULL)
+ {
+ for (int n=0;n<i;n++)
+ {
+ free(msg[n]->cid);
+ free(msg[n]);
+ }
+ return -1;
+ }
+ memset(msg[i],0,sizeof(neighboringCellIDs));
+ }
+ token = lynq_query_neighboring_cellids(msg, num, &realNum);
+ printf("request is %d,token is %x,error is %d\n",
+ msg[0]->base.request,msg[0]->base.token,msg[0]->base.e);
+ for(int i =0;i<realNum;i++)
+ {
+ printf("request is %d,token is %x,error is %d,cid is %s,rssi is %d\n",
+ msg[i]->base.request,msg[i]->base.token,msg[i]->base.e,msg[i]->cid,msg[i]->rssi);
+ RLOGD("request is %d,token is %x,error is %d",msg[i]->base.request,msg[i]->base.token,msg[i]->base.e);
+ RLOGD("cid is %s,rssi is %d %d",msg[i]->cid,msg[i]->rssi);
+ }
+ for (int i = 0; i < num; i++)
+ {
+ if (msg[i]!=NULL)
+ {
+ free(msg[i]->cid);
+ msg[i]->cid=NULL;
+ free(msg[i]);
+ msg[i]=NULL;
+ }
+ }
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+int eventNetworkController::eventSetBandMode(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set band mode parameter is invalid!");
+ return -1;
+ }
+ lynq_set_band_mode(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+
+}
+int eventNetworkController::eventQueryAvailableBandmode(int argc,char *argv[])
+{
+ availableBandMode msg;
+ lynq_query_available_bandmode(&msg);
+ printf("request is %d,token is %x,error is %d,\n",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.bandmode[0]>0)
+ {
+ printf("available band mode is:");
+ for(int i =1;i<=msg.bandmode[0];i++)
+ {
+ printf("%d,",msg.bandmode[i]);
+ }
+ printf("\n");
+ }
+ RLOGD("available band mode is null");
+ return 0;
+}
+int eventNetworkController::eventRadioOn(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set band mode parameter is invalid!");
+ return -1;
+ }
+ lynq_radio_on(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventNetworkController::eventQueryRadioTech(int argc,char *argv[])
+{
+ radioTechnology msg;
+ lynq_query_radio_tech(&msg);
+ printf("request is %d,token is %x,error is %d,RadioTech is %d\n",
+ msg.base.request,msg.base.token,msg.base.e,msg.radioTech);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("RadioTech %d",msg.radioTech);
+ return 0;
+return 0;}
+int eventNetworkController::eventSolicitedSignalStrength(int argc,char *argv[])
+{
+ solicitedSignalStrength msg;
+ lynq_solicited_signal_strength(&msg);
+ printf("request is %d,token is %x,error is %d\n",
+ msg.base.request,msg.base.token,msg.base.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.base.request,msg.base.token,msg.base.e);
+ if(msg.base.e!=RIL_E_SUCCESS)
+ {
+ return -1;
+ }
+ printf("test sss 006\n");
+ printf("V5 GW signalStrength=%d\n", msg.signalStrength.GW_SignalStrength.signalStrength);
+ printf("GW bitErrorRate=%d\n", msg.signalStrength.GW_SignalStrength.bitErrorRate);
+ printf("GW timingAdvance=%d\n", msg.signalStrength.GW_SignalStrength.timingAdvance);
+ printf("CDMA dbm=%d\n", msg.signalStrength.CDMA_SignalStrength.dbm);
+ printf("CDMA ecio=%d\n", msg.signalStrength.CDMA_SignalStrength.ecio);
+ printf("EVDO dbm=%d\n", msg.signalStrength.EVDO_SignalStrength.dbm);
+ printf("EVDO ecio=%d\n", msg.signalStrength.EVDO_SignalStrength.ecio);
+ printf("EVDO signalNoiseRatio=%d\n", msg.signalStrength.EVDO_SignalStrength.signalNoiseRatio);
+ printf("V6 LTE signalStrength=%d\n", msg.signalStrength.LTE_SignalStrength.signalStrength);
+ printf("LTE rsrp=%d\n", msg.signalStrength.LTE_SignalStrength.rsrp);
+ printf("LTE rsrq=%d\n", msg.signalStrength.LTE_SignalStrength.rsrq);
+ printf("LTE rssnr=%d\n", msg.signalStrength.LTE_SignalStrength.rssnr);
+ printf("LTE cqi=%d\n", msg.signalStrength.LTE_SignalStrength.cqi);
+ printf("LTE timingAdvance=%d\n", msg.signalStrength.LTE_SignalStrength.timingAdvance);
+ printf("TD_SCDMA signalStrength=%d\n", msg.signalStrength.TD_SCDMA_SignalStrength.signalStrength);
+ printf("TD_SCDMA bitErrorRate=%d\n", msg.signalStrength.TD_SCDMA_SignalStrength.bitErrorRate);
+ printf("TD_SCDMA rscp=%d\n", msg.signalStrength.TD_SCDMA_SignalStrength.rscp);
+ printf("WCDMA signalStrength=%d\n", msg.signalStrength.WCDMA_SignalStrength.signalStrength);
+ printf("WCDMA bitErrorRate=%d\n", msg.signalStrength.WCDMA_SignalStrength.bitErrorRate);
+ printf("WCDMA rscp=%d\n", msg.signalStrength.WCDMA_SignalStrength.rscp);
+ printf("WCDMA ecno=%d\n", msg.signalStrength.WCDMA_SignalStrength.ecno);
+ printf("test sss 007\n");
+ return 0;
+}
+int eventNetworkController::eventModemOn(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("set band mode parameter is invalid!");
+ return -1;
+ }
+ lynq_modem_on(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.h
new file mode 100644
index 0000000..a202bbe
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/network/network.h
@@ -0,0 +1,33 @@
+/*
+* Copyright (C) 2020 MobileTek Inc.
+*/
+#ifndef __LYNQ_NETWORK_CONTROLLER_H__
+#define __LYNQ_NETWORK_CONTROLLER_H__
+class eventNetworkController
+{
+ public:
+ eventNetworkController();
+ ~eventNetworkController();
+
+ public:
+ static int eventQueryOperator(int argc,char *argv[]);
+ static int eventQueryNetSelectMode(int argc,char *argv[]);
+ static int eventSetNetSelectMode(int argc,char *argv[]);
+ static int eventQueryAvailableNetwork(int argc,char *argv[]);
+ static int eventQueryRegistrationState(int argc,char *argv[]);
+ static int eventQueryPrefferredNetworkType(int argc,char *argv[]);
+ static int eventSetPrefferredNetworkType(int argc,char *argv[]);
+ static int eventQueryCellInfo(int argc,char *argv[]);
+ static int eventSetUnsolCellInfoListrate(int argc,char *argv[]);
+ static int eventQueryNeighboringCellids(int argc,char *argv[]);
+ static int eventSetBandMode(int argc,char *argv[]);
+ static int eventQueryAvailableBandmode(int argc,char *argv[]);
+ static int eventRadioOn(int argc,char *argv[]);
+ static int eventQueryRadioTech(int argc,char *argv[]);
+ static int eventSolicitedSignalStrength(int argc,char *argv[]);
+ static int eventModemOn(int argc,char *argv[]);
+};
+#endif /* __LYNQ_NETWORK_CONTROLLER_H__ */
+
+
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.cpp
new file mode 100644
index 0000000..e40e6f2
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.cpp
@@ -0,0 +1,45 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+#include <stdio.h>
+#include <log/log.h>
+#include "sim.h"
+#include <libtel/lynq_sim.h>
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_SIM"
+eventSimController::eventSimController(){
+}
+eventSimController::~eventSimController(){
+}
+int eventSimController::eventGetSimStatus(int argc,char *argv[])
+{
+ static int32_t token;
+ simStatus * sim_status=NULL;
+ sim_status = (simStatus *)malloc(sizeof(simStatus));
+ token = lynq_get_sim_status(sim_status);
+ printf("card_status:%d,card_type:%d,pin_state:%d,error_code:%d,request:%d,token:%x\n",sim_status->card_status,
+ sim_status->card_type,sim_status->pin_state,sim_status->base.e,sim_status->base.request,sim_status->base.token);
+ RLOGD("card_status:%d,card_type:%d,pin_state:%d,error_code:%d,request:%d,token:%x",sim_status->card_status,
+ sim_status->card_type,sim_status->pin_state,sim_status->base.e,sim_status->base.request,sim_status->base.token);
+ if (sim_status->base.e==-1)
+ {
+ free(sim_status);
+ sim_status=NULL;
+ return -1;
+ }
+ free(sim_status);
+ sim_status=NULL;
+ return 0;
+}
+int eventSimController::eventGetImsi(int argc,char *argv[])
+{
+ simImsi msg;
+ lynq_get_imsi(&msg);
+ printf("request is %d, token is %x,error_code %d,imsi is %s\n",msg.base.request,msg.base.token, msg.base.e,msg.imsi);
+ RLOGD("request is %d, token is %x,error_code %d,imsi is %s",msg.base.request,msg.base.token, msg.base.e,msg.imsi);
+ if (msg.base.e==-1)
+ {
+ return -1;
+ }
+ return 0;
+}
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.h
new file mode 100644
index 0000000..172de33
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim.h
@@ -0,0 +1,16 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+//#include "lynq_ril.h"
+#ifndef __LYNQ_SIM_CONTROLLER_H__
+#define __LYNQ_SIM_CONTROLLER_H__
+class eventSimController
+{
+ public:
+ eventSimController();
+ ~eventSimController();
+ public:
+ static int eventGetSimStatus(int argc,char *argv[]);
+ static int eventGetImsi(int argc,char *argv[]);
+};
+#endif /* __LYNQ_SIM_CONTROLLER_H__ */
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim_commands.h
new file mode 100644
index 0000000..13279a2
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sim/sim_commands.h
@@ -0,0 +1,8 @@
+/*
+* Copyright (C) 2020 Mobiletek Inc.
+*/
+// SIM information
+{"LYNQ_GET_SIM_STATUS",eventSimController::eventGetSimStatus, "get sim status", LYNQ_GET_SIM_STATUS},
+{"LYNQ_GET_IMSI",eventSimController::eventGetImsi, "get IMSI", LYNQ_GET_SIM_STATUS},
+{(char *)NULL, NULL, (char *)NULL , -1},
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.cpp b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.cpp
new file mode 100644
index 0000000..7f5e8d4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.cpp
@@ -0,0 +1,196 @@
+#include<libtel/lynq_sms.h>
+#include"sms.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <log/log.h>
+#include <string.h>
+#undef LOG_TAG
+#define LOG_TAG "LYNQ_SMS"
+eventSMSController::eventSMSController()
+{}
+eventSMSController::~eventSMSController()
+{}
+ int eventSMSController::eventSendSms(int argc,char *argv[])
+{
+ int32_t token;
+ smsResponse msg;
+ msg.smsResp.ackPDU=NULL;
+ if(argc <5)
+ {
+ RLOGD("send sms paramter is inavailable!");
+ printf("send sms paramter is inavailable!\n");
+ return -1;
+ }
+ if(argc==5)
+ {
+ token = lynq_send_sms(argv[2], atoi(argv[3]),argv[4], NULL,&msg);
+ }
+ else if(argc==6)
+ {
+ token = lynq_send_sms(argv[2], atoi(argv[3]),argv[4], argv[5],&msg);
+ }
+ else
+ {
+ RLOGD("should not be here!");
+ return -1;
+ }
+ printf("request is %d,token is %x,error is %d,\nmessageRef is %d,ackPDU is %s,errorCode is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ RLOGD("request is %d,token is %x,error is %d,messageRef is %d,ackPDU is %s,errorCode is %d",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ return 0;
+}
+int eventSMSController::eventImsSendSms(int argc,char *argv[])
+{
+ int32_t token;
+ smsResponse msg;
+ msg.smsResp.ackPDU=NULL;
+ if(argc <7)
+ {
+ RLOGD("send IMS sms paramter is inavailable!");
+ printf("send IMS sms paramter is inavailable!\n");
+ return -1;
+ }
+ if(argc==7)
+ {
+ token = lynq_Ims_send_sms(argv[2], atoi(argv[3]),argv[4], argv[5],argv[6],NULL,&msg);
+ }
+ else if(argc==8)
+ {
+ token = lynq_Ims_send_sms(argv[2], atoi(argv[3]),argv[4], argv[5],argv[6],argv[7],&msg);
+ }
+ else
+ {
+ RLOGD("should not be here!");
+ return -1;
+ }
+ printf("request is %d,token is %x,error is %d,\nmessageRef is %d,ackPDU is %s,errorCode is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ RLOGD("request is %d,token is %x,error is %d,messageRef is %d,ackPDU is %s,errorCode is %d",msg.base.request,msg.base.token,msg.base.e,
+ msg.smsResp.messageRef,msg.smsResp.ackPDU,msg.smsResp.errorCode);
+ return 0;
+}
+int eventSMSController::eventWriteSmsToSim(int argc,char *argv[])
+{
+ int32_t token;
+ messageStoreInfo msg;
+ if(argc <6)
+ {
+ RLOGD("write sms to sim paramter is inavailable!");
+ printf("write sms to sim paramter is inavailable!\n");
+ return -1;
+ }
+ if(argc==6)
+ {
+ token = lynq_write_sms_to_sim(atoi(argv[2]), argv[3],atoi(argv[4]), argv[5],NULL,&msg);
+ }
+ else if(argc==7)
+ {
+ token = lynq_write_sms_to_sim(atoi(argv[2]), argv[3],atoi(argv[4]), argv[5],argv[6],&msg);
+ }
+ else
+ {
+ RLOGD("should not be here!");
+ return -1;
+ }
+ printf("request is %d,token is %x,error is %d,\nmessage strore index is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.msgStoreIndex);
+ RLOGD("request is %d,token is %x,error is %d,\nmessage strore index is %d\n",msg.base.request,msg.base.token,msg.base.e,
+ msg.msgStoreIndex);
+ return 0;
+}
+int eventSMSController::eventReportSmsMemoryStatus(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("report sms memory status parameter is inavailable!");
+ printf("report sms memory status parameter is inavailable!");
+ return -1;
+ }
+ lynq_report_sms_memory_status(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventSMSController::eventDeletSmsOnSim(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("report sms memory status parameter is inavailable!");
+ printf("report sms memory status parameter is inavailable!");
+ return -1;
+ }
+ lynq_delet_sms_on_sim(atoi(argv[2]),&msg);
+ printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+}
+int eventSMSController::eventGetSmscAddress(int argc,char *argv[])
+{
+ smscCbInfo msg;
+ lynq_get_smsc_address(&msg);
+ printf("request is %d,token is %x,error is %d,smsc address is %s\n",msg.base.request,msg.base.token,msg.base.e,msg.smsc);
+ RLOGD("request is %d,token is %x,error is %d,smsc address is %s",msg.base.request,msg.base.token,msg.base.e,msg.smsc);
+ return 0;
+}
+int eventSMSController::eventSetSmscAddress(int argc,char *argv[])
+{
+ lynqBase msg;
+ if(argc<3)
+ {
+ RLOGD("report sms memory status parameter is inavailable!");
+ printf("report sms memory status parameter is inavailable!");
+ return -1;
+ }
+ lynq_set_smsc_address(argv[2],&msg);
+ printf("request is %d,token is %x,error is %d,\n",msg.request,msg.token,msg.e);
+ RLOGD("request is %d,token is %x,error is %d",msg.request,msg.token,msg.e);
+ return 0;
+return 0;
+}
+int eventSMSController::evenStoreSmsToMemory(int argc,char *argv[])
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ if(argc<5)
+ {
+ RLOGD("store sms to memoryparameter is inavailable!");
+ printf("store sms to memoryparameter is inavailable!");
+ return -1;
+ }
+ //printf("argv[2]%d,argv[3]%s,argv[4]%s\n",atoi(argv[2]), argv[3],argv[4]);
+ lynq_store_sms_to_memory(RIL_SOCKET_1,atoi(argv[2]), argv[3],argv[4],&msg);
+ printf("+LYNQ_SSTM:Error_code:%d\n",msg.e);
+ return 0;
+}
+int eventSMSController::eventGetSmsFromMemory(int argc,char *argv[])
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ storeMessageInfo sms;
+ if(argc<3)
+ {
+ RLOGD("get sms from memoryparameter is inavailable!");
+ printf("get sms from memoryparameter is inavailable!");
+ return -1;
+ }
+ lynq_get_sms_from_memory(atoi(argv[2]),&sms, &msg);
+ printf("+LYNQ_GSFM:Error_code:%d,Index:%d,Message:%s,Status:%d,Telephony number:%s,Socket_id:%d\n",msg.e,sms.index,sms.message,sms.status,sms.teleNum,sms.soc_id);
+ return 0;
+}
+int eventSMSController::eventDeleteMessageFromMemory(int argc,char *argv[])
+{
+ lynqBase msg;
+ msg.e = (RIL_Errno)(-1);
+ if(argc<3)
+ {
+ RLOGD("get sms from memoryparameter is inavailable!");
+ printf("get sms from memoryparameter is inavailable!");
+ return -1;
+ }
+ lynq_delete_message_from_memory(atoi(argv[2]), &msg);
+ printf("+LYNQ_DMFM:Error_code:%d\n",msg.e);
+ return 0;
+}
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.h
new file mode 100644
index 0000000..6c25942
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms.h
@@ -0,0 +1,28 @@
+/*
+* Copyright (C) 2020 MobileTek Inc.
+*/
+#ifndef __LYNQ_SMS_CONTROLLER_H__
+#define __LYNQ_SMS_CONTROLLER_H__
+class eventSMSController
+{
+ public:
+ eventSMSController();
+ ~eventSMSController();
+
+ public:
+ static int eventSendSms(int argc,char *argv[]);
+ static int eventImsSendSms(int argc,char *argv[]);
+ static int eventWriteSmsToSim(int argc,char *argv[]);
+ static int eventReportSmsMemoryStatus(int argc,char *argv[]);
+ static int eventDeletSmsOnSim(int argc,char *argv[]);
+ static int eventGetSmscAddress(int argc,char *argv[]);
+ static int eventSetSmscAddress(int argc,char *argv[]);
+ static int evenStoreSmsToMemory(int argc,char *argv[]);
+ static int eventGetSmsFromMemory(int argc,char *argv[]);
+ static int eventDeleteMessageFromMemory(int argc,char *argv[]);
+
+};
+#endif /* __LYNQ_SMS_CONTROLLER_H__ */
+
+
+
diff --git a/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms_commands.h b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms_commands.h
new file mode 100644
index 0000000..ac70285
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-tele-cmd-test/src/sms/sms_commands.h
@@ -0,0 +1,11 @@
+{"LYNQ_SSM",eventSMSController::eventSendSms,"send sms",LYNQ_SEND_SMS},
+{"LYNQ_ISS",eventSMSController::eventImsSendSms,"send sms over IMS",LYNQ_IMS_SEND_SMS},
+{"LYNQ_WSTS",eventSMSController::eventWriteSmsToSim,"write sms to sim card",LYNQ_WRITE_SMS_TO_SIM},
+{"LYNQ_RSMS",eventSMSController::eventReportSmsMemoryStatus,"report sms memory state",LYNQ_REPORT_SMS_MEMORY_STATUS},
+{"LYNQ_DSOS",eventSMSController::eventDeletSmsOnSim,"delete sms on sim",LYNQ_DELETE_SMS_ON_SIM},
+{"LYNQ_GSMSC",eventSMSController::eventGetSmscAddress,"get smsc address",LYNQ_GET_SMSC_ADDRESS},
+{"LYNQ_SSMSC",eventSMSController::eventSetSmscAddress,"set smsc address",LYNQ_SET_SMSC_ADDRESS},
+{"LYNQ_SSTM",eventSMSController::evenStoreSmsToMemory,"store sms to memory",LYNQ_STORY_SMS_TO_MEMORY},
+{"LYNQ_GSFM",eventSMSController::eventGetSmsFromMemory,"get sms from memory",LYNQ_GET_SMS_FROM_MEMORY},
+{"LYNQ_DMFM",eventSMSController::eventDeleteMessageFromMemory,"delete sms from memory",LYNQ_DELETE_SMS_FROM_MEMORY},
+{(char *)NULL, NULL, (char *)NULL , -1},
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/common.h b/src/lynq/packages/apps/lynq-threadhandle/include/common.h
new file mode 100644
index 0000000..02fcdeb
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/common.h
@@ -0,0 +1,19 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+
+#define NO_ERROR 0
+#define ERR_VALID 70 //valid error
+#define ERR_CMDVALID 71 //cmd error
+#define ERR_SESSIONVALID 72 //session error
+#define ERR_MALLOCVALID 73 //malloc error
+#define ERR_INVOKE 74 //invoke error
+#define ERR_SYSTEM 75 //system error
+#define ERR_TIMEOUT 76 //time out error
+
+#define BUF_SIZE 8192
+//int th_error;
+
+int str_arr(char *str, char *substr, char parts[][BUF_SIZE]);
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/double_list.h b/src/lynq/packages/apps/lynq-threadhandle/include/double_list.h
new file mode 100644
index 0000000..b8682c0
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/double_list.h
@@ -0,0 +1,49 @@
+#ifndef __DOUBLE_LIST__H__
+#define __DOUBLE_LIST__H__
+
+
+#include "syn_primitive.h"
+
+
+typedef struct tag_d_list
+{
+ void *data;
+ unsigned int data_len;
+ struct tag_d_list *pre;
+ struct tag_d_list *next;
+}d_list_node_t;
+
+
+typedef struct
+{
+ unsigned int node_count;
+ d_list_node_t *head;
+ d_list_node_t *tail;
+
+ d_list_node_t *cur_idx;
+}d_list_t;
+
+
+typedef int (*compare_func)(void *usr_data, unsigned int udata_len, void *list_data, unsigned int ldata_len);
+
+BOOL is_empty_d_list(d_list_t *list);
+unsigned int get_d_list_node_count(d_list_t *list);
+d_list_t *create_d_list(void);
+void destroy_d_list(d_list_t *list);
+BOOL insert_d_list_head(d_list_t *list, void *data, unsigned int data_len);
+BOOL insert_d_list_tail(d_list_t *list, void *data, unsigned int data_len);
+BOOL insert_d_list_head_node(d_list_t *list, d_list_node_t *node);
+BOOL insert_d_list_tail_node(d_list_t *list, d_list_node_t *node);
+BOOL delete_d_list_head(d_list_t *list);
+BOOL delete_d_list_tail(d_list_t *list);
+BOOL delete_d_list_node_all(d_list_t *list);
+BOOL remove_d_list_node(d_list_t *list, d_list_node_t *node);
+d_list_node_t *remove_d_list_head_node(d_list_t *list);
+d_list_node_t *remove_d_list_tail_node(d_list_t *list);
+d_list_node_t *find_d_list_node(d_list_t *list, void *user_data, unsigned int data_len, compare_func func);
+d_list_node_t *get_d_list_node(d_list_t *list, int idx);
+d_list_node_t *get_next_node(d_list_t *list);
+
+#endif //__DOUBLE_LIST__H__
+
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/ftp_manager.h b/src/lynq/packages/apps/lynq-threadhandle/include/ftp_manager.h
new file mode 100644
index 0000000..bb833ab
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/ftp_manager.h
@@ -0,0 +1,29 @@
+#ifndef _FTP_MANAGER_H
+#define _FTP_MANAGER_H
+
+#include "thread_pool.h"
+#include "list.h"
+#include "ftp/lynq_ftp.h"
+#include "common.h"
+
+typedef struct
+{
+ int id;
+ char *action;
+ int (*ftp_action)(lynq_ftp_socker_info* FTP);
+}FTP_MAG_S;
+
+
+typedef struct FTP_LIST_LINK
+{
+ struct list_head list;
+ lynq_ftp_socker_info data;
+}FTP_LIST_LINK_S;
+
+
+void ftp_list_init(void);
+int ftp_list_locate(void);
+int ftp_param_verification(char result[][BUF_SIZE] , int line);
+int ftp_act_handler(thread_pool_t *pool);
+
+#endif
\ No newline at end of file
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/http_manager.h b/src/lynq/packages/apps/lynq-threadhandle/include/http_manager.h
new file mode 100644
index 0000000..21f5e70
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/http_manager.h
@@ -0,0 +1,26 @@
+#ifndef _HTTP_MANAGER_H
+#define _HTTP_MANAGER_H
+
+
+#include "http/lynq_http.h"
+#include "thread_pool.h"
+#include "list.h"
+#include "common.h"
+
+
+
+typedef struct
+{
+ struct list_head list;
+ lynq_http_client_t data;
+}HTTP_LIST_LINK_S;
+
+void http_list_init(void);
+int http_list_locate(void);
+int http_param_verification(char result[][BUF_SIZE], int line);
+int http_act_handler(thread_pool_t *pool);
+
+
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/list.h b/src/lynq/packages/apps/lynq-threadhandle/include/list.h
new file mode 100644
index 0000000..697ff6f
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/list.h
@@ -0,0 +1,122 @@
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) ((type *)((char *)ptr - offsetof(type,member)))
+#endif
+
+#define prefetch(x) ((void)x)
+#define LIST_POISON1 (NULL)
+#define LIST_POISON2 (NULL)
+
+struct list_head{
+ struct list_head *next, *prev;
+};
+
+struct hlist_node{
+ struct hlist_node *next, **pprev;
+};
+
+struct hlist_head{
+ struct hlist_node *first;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+static void INIT_LIST_HEAD(struct list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+
+static void __list_add(struct list_head *node,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = node;
+ node->next = next;
+ node->prev = prev;
+ prev->next = node;
+}
+
+static void list_add(struct list_head *node, struct list_head *head)
+{
+ __list_add(node, head, head->next);
+}
+
+
+static void list_add_tail(struct list_head *node, struct list_head *head)
+{
+ __list_add(node, 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 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 void __list_del_entry(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+}
+
+static void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = LIST_POISON1;
+ entry->prev = LIST_POISON2;
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; prefetch(pos->next), pos != (head); \
+ pos = pos->next)
+
+#define list_safe_reset_next(pos, n, member) \
+ n = list_entry(pos->member.next, typeof(*pos), member)
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/model_manager.h b/src/lynq/packages/apps/lynq-threadhandle/include/model_manager.h
new file mode 100644
index 0000000..78fb3c7
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/model_manager.h
@@ -0,0 +1,31 @@
+#ifndef _MODEL_MANAGER_H
+#define _MODEL_MANAGER_H
+
+#include "http_manager.h"
+#include "ftp_manager.h"
+#include "list.h"
+#include "thread_pool.h"
+#include <log/log.h>
+#include "ril_manager.h"
+#include "mqtt_manager.h"
+#include "common.h"
+
+typedef struct
+{
+ char *name;
+ void (*func_list_init)(void);
+ int (*func_param_verification)(char result[][BUF_SIZE], int line);
+ int (*func_list_locate)(void);
+ int (*func_act_handler)(thread_pool_t *pool);
+ int (*func_del)(void);
+ int (*func_get)(void);
+ int (*func_set)(void);
+ int (*func_next)(void);
+}MAG_LIST_S;
+
+
+MAG_LIST_S *list_manager_proc(const char *name);
+
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/mqtt_manager.h b/src/lynq/packages/apps/lynq-threadhandle/include/mqtt_manager.h
new file mode 100644
index 0000000..5f8cbee
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/mqtt_manager.h
@@ -0,0 +1,25 @@
+#ifndef _MQTT_MANAGER_H
+#define _MQTT_MANAGER_H
+
+#include "lynq_mqtt/lynq_mqtt.h"
+#include "thread_pool.h"
+#include "list.h"
+#include "common.h"
+
+
+
+typedef struct
+{
+ struct list_head list;
+ struct mqtt_set_parament data;
+}MQTT_LIST_LINK_S;
+
+
+void mqtt_list_init();
+int mqtt_param_verification(char result[][BUF_SIZE] , int line);
+int mqtt_list_locate();
+int mqtt_act_handler(thread_pool_t *pool);
+
+
+#endif
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/ril_manager.h b/src/lynq/packages/apps/lynq-threadhandle/include/ril_manager.h
new file mode 100644
index 0000000..c491cda
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/ril_manager.h
@@ -0,0 +1,7 @@
+#include "model_manager.h"
+#include "common.h"
+
+void ril_list_init();
+int ril_param_verification(char result[][BUF_SIZE] , int line);
+int ril_list_locate();
+int ril_act_handler(thread_pool_t *pool);
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/seq_queue.h b/src/lynq/packages/apps/lynq-threadhandle/include/seq_queue.h
new file mode 100644
index 0000000..2aed03e
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/seq_queue.h
@@ -0,0 +1,43 @@
+#ifndef __SEQ_QUEUE__H_
+#define __SEQ_QUEUE__H_
+
+#include "syn_primitive.h"
+
+
+#ifndef in
+#define in
+#define out
+#endif
+
+#define EXPAND_BLOCK_NUM 100
+
+typedef struct
+{
+ BOOL expandabilit;
+ unsigned int expand_blocks;
+
+ unsigned int block_size;
+ unsigned int total_block;
+
+ unsigned int current_block;
+ unsigned int tail_block;
+ unsigned int used_block;
+
+ void *block_buffer;
+
+ //mutex_handle task_queue_lock;
+ sem_handle task_queue_lock;
+
+}seq_queue_t;
+
+
+seq_queue_t *create_seq_queue(in unsigned int block_size, in unsigned int total_block, in BOOL expand);
+void destroy_seq_queue(in seq_queue_t *queue);
+BOOL en_seq_queue(in seq_queue_t *queue, in void *data);
+BOOL de_seq_queue(in seq_queue_t *queue, out void *data);
+unsigned int get_count_seq_queue(in seq_queue_t *queue);
+unsigned int get_total_seq_queue(in seq_queue_t *queue);
+
+
+#endif //__SEQ_QUEUE__H_
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/syn_primitive.h b/src/lynq/packages/apps/lynq-threadhandle/include/syn_primitive.h
new file mode 100644
index 0000000..77dc2d5
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/syn_primitive.h
@@ -0,0 +1,43 @@
+#ifndef __SYN_PRIMITIVE__H_
+#define __SYN_PRIMITIVE__H_
+
+#include <pthread.h>
+#include <semaphore.h>
+#include "typedefs.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+typedef pthread_t thread_id;
+typedef pthread_t thread_handle;
+typedef pthread_cond_t condition_handle;
+typedef pthread_mutex_t mutex_handle;
+typedef sem_t sem_handle;
+
+
+
+#define TIME_WAIT_INFINITE 0x7fffffff
+
+
+
+int init_condition_handle(condition_handle *cond);
+int destroy_condition_handle(condition_handle *cond);
+//int wait_condition(condition_handle *cond, mutex_handle *mutex);
+int wait_condition(condition_handle *cond, mutex_handle *mutex, unsigned int wait);
+int post_condition_signal(condition_handle *cond);
+int init_mutex_handle(mutex_handle *mutex);
+int mutex_lock(mutex_handle *mutex);
+int mutex_unlock(mutex_handle *mutex);
+int mutex_destroy(mutex_handle *mutex);
+int create_sem(sem_handle *sem, int init_count);
+int wait_sem(sem_handle *sem);
+int post_sem(sem_handle *sem);
+int destroy_sem(sem_handle *sem);
+
+
+
+#endif //__SYN_PRIMITIVE__H_
+
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/thread_pool.h b/src/lynq/packages/apps/lynq-threadhandle/include/thread_pool.h
new file mode 100644
index 0000000..cc2cd29
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/thread_pool.h
@@ -0,0 +1,83 @@
+#ifndef __THREAD_POOL__H_
+#define __THREAD_POOL__H_
+
+#include "syn_primitive.h"
+#include "double_list.h"
+#include "seq_queue.h"
+
+typedef enum {EThread_pool_unknown, EThread_pool_alloc, EThread_pool_init
+, EThread_pool_run, EThread_pool_exit, EThread_pool_MAX}EThread_pool_status;
+
+
+#define RELEASE_THREAD_INTERVAL 5*60
+
+
+typedef void (*THREAD_FUNC)(void *);
+typedef void (*USER_FUNC)(void *thread_para);
+
+
+typedef struct {
+ USER_FUNC timeout_callback;
+ unsigned long time_out;
+}time_out_t;
+
+typedef struct
+{
+ USER_FUNC process_func;
+ USER_FUNC release_func;
+ void *args;
+ time_out_t time_out_info;
+}thread_func_t;
+
+typedef struct
+{
+ thread_func_t thread_para;
+ unsigned int pri;
+
+ BOOL busy;
+ BOOL release;
+
+ unsigned long launch_time;
+ unsigned long time_out;
+
+ EThread_pool_status *pool_status;
+
+ thread_handle h_thread;
+ condition_handle thread_cond;
+ mutex_handle thread_lock;
+
+}thread_info_t;
+
+typedef struct
+{
+ unsigned int pri;
+ unsigned int min_thread_num;
+ unsigned int max_thread_num;
+
+ unsigned int pool_thread_num;
+
+ condition_handle manage_cond;
+ mutex_handle mange_lock;
+
+ unsigned long release_threads_interval;
+
+ d_list_t *idle_threads;
+ d_list_t *busy_threads;
+ seq_queue_t *task_queue;
+
+ sem_handle sem_inc;
+ thread_handle h_id;
+
+ EThread_pool_status status;
+}thread_pool_t;
+
+
+thread_pool_t *threadpool_create(unsigned int min_thread_num, unsigned int max_thread_num);
+void threadpool_destroy(thread_pool_t *pool);
+BOOL threadpool_add(thread_pool_t *pool, USER_FUNC process_func, void *args);
+BOOL threadpool_add_timeout(thread_pool_t *pool, USER_FUNC process_func
+ , USER_FUNC release_func, void *args, time_out_t *time_out);
+void tp_sleep(unsigned int ms);
+
+#endif //__THREAD_POOL__H_
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/include/typedefs.h b/src/lynq/packages/apps/lynq-threadhandle/include/typedefs.h
new file mode 100644
index 0000000..d205b1c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/include/typedefs.h
@@ -0,0 +1,21 @@
+#ifndef __TYPE_DEFS__H_
+#define __TYPE_DEFS__H_
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef BOOL
+#define BOOL unsigned char
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+#endif //__TYPE_DEFS__H_
diff --git a/src/lynq/packages/apps/lynq-threadhandle/makefile b/src/lynq/packages/apps/lynq-threadhandle/makefile
new file mode 100644
index 0000000..529bbd4
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/makefile
@@ -0,0 +1,62 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+
+
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(LOCAL_PATH)/include \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/libtel \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+ -I$(ROOT)$(includedir)/ftp \
+ -I$(ROOT)$(includedir)/http \
+ -I$(ROOT)$(includedir)/lynq_mqtt \
+ -I$(ROOT)$(includedir)/liblynq-broadcast \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -llynq-log \
+ -lssl \
+ -llynq-tele-ril \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldbus-1 \
+ -llynq-protcl \
+ -llog \
+ -llynq-broadcast \
+
+SOURCES = $(wildcard *.c src/*.c)
+
+EXECUTABLE = lynq-threadhandle
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/common.c b/src/lynq/packages/apps/lynq-threadhandle/src/common.c
new file mode 100644
index 0000000..e8a5968
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/common.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include "common.h"
+#include "liblog/lynq_deflog.h"
+
+int str_arr(char *str, char *substr, char parts[][BUF_SIZE])
+{
+ char *p = NULL;
+ char *q = NULL;
+ char tmp[BUF_SIZE] = "";
+ char end[BUF_SIZE] = "";
+ char *start = strdup(str);
+ int i = 0, j = 0, k = 0, par_num=0;
+
+
+ while(*str != '\0')
+ {
+ p = str;
+ q = substr;
+ tmp[i] = *str;
+ i++;
+
+ while((*p == *q) && (*p != '\0') && (*q != '\0'))
+ {
+ p++;
+ q++;
+ }
+ if(*q == '\0')
+ {
+ memset(end, 0, sizeof(end));
+ strcpy(end, p);
+
+ memset(parts[j], 0, sizeof(parts[j]));
+
+ j == 0 ? memcpy(parts[j], tmp, strlen(tmp)-1) : memcpy(parts[j], tmp+1, strlen(tmp)-2) ;
+
+ j++;
+ memset(tmp, 0, sizeof(tmp));
+ i = 0;
+ par_num++;
+ }
+
+ str++;
+ }
+
+
+ if (!par_num) {
+ LYDBGLOG("[%s-%d] cmd is error!!!\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+
+ if (strcmp(end, "") != 0) {
+ memset(parts[j], 0, sizeof(parts[j]));
+ memcpy(parts[j], tmp+1, strlen(tmp)-2);
+ }
+
+ for (i = 0 ; i < par_num + 1 ; i++)
+ memcpy(parts[i], strchr(parts[i],'"')+1,strlen(parts[i]));
+
+ return par_num;
+}
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/double_list.c b/src/lynq/packages/apps/lynq-threadhandle/src/double_list.c
new file mode 100644
index 0000000..030e677
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/double_list.c
@@ -0,0 +1,378 @@
+#include "double_list.h"
+
+
+BOOL is_empty_d_list(d_list_t *list) {
+ BOOL ret = FALSE;
+ if (list == NULL)
+ return FALSE;
+
+ if (list->node_count == 0 && list->head == NULL && list->tail == NULL)
+ ret = TRUE;
+
+ return ret;
+}
+
+
+unsigned int get_d_list_node_count(d_list_t *list) {
+ return list->node_count;
+}
+
+
+d_list_t *create_d_list(void) {
+ d_list_t *temp_list = (d_list_t *)malloc(sizeof(d_list_t));
+ if (temp_list) {
+ memset(temp_list, 0, sizeof(d_list_t));
+ }
+
+ return temp_list;
+}
+
+
+d_list_node_t *create_d_list_node(void *data, unsigned int data_len) {
+
+ d_list_node_t *temp_node = (d_list_node_t *)malloc(sizeof(d_list_node_t));
+ if (temp_node) {
+
+ memset(temp_node, 0, sizeof(d_list_node_t));
+ temp_node->data = data;
+ temp_node->data_len = data_len;
+ }
+
+ return temp_node;
+}
+
+
+d_list_node_t *insert_d_list_node_head_n(d_list_node_t *head, d_list_node_t *node) {
+
+ if (head && node) {
+ node->pre = head->pre;
+ node->next = head;
+
+ head->pre = node;
+ }
+
+ return node;
+}
+
+
+d_list_node_t *insert_d_list_node_tail_n(d_list_node_t *tail, d_list_node_t *node) {
+
+ if (tail && node) {
+
+ tail->next = node;
+ node->pre = tail;
+ node->next = NULL;
+ }
+
+ return node;
+}
+
+
+d_list_node_t *insert_d_list_node_head(d_list_node_t *head, void *data, unsigned int data_len) {
+
+ d_list_node_t *temp_node = create_d_list_node(data, data_len);
+
+ return insert_d_list_node_head_n(head, temp_node);
+}
+
+d_list_node_t *insert_d_list_node_tail(d_list_node_t *tail, void *data, unsigned int data_len) {
+
+ d_list_node_t *temp_node = create_d_list_node(data, data_len);
+
+ return insert_d_list_node_tail_n(tail, temp_node);
+}
+
+
+BOOL insert_d_list_head(d_list_t *list, void *data, unsigned int data_len) {
+
+ if (list) {
+
+ if (list->node_count == 0) {
+ list->head = insert_d_list_node_head(list->head, data, data_len);
+ list->tail = list->head;
+ } else {
+ list->head = insert_d_list_node_head(list->head, data, data_len);
+ }
+
+ list->node_count++;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+BOOL insert_d_list_head_node(d_list_t *list, d_list_node_t *node) {
+
+ if (list) {
+
+ node->next = NULL;
+ node->pre = NULL;
+ if (list->node_count == 0) {
+ list->head = insert_d_list_node_head_n(list->head, node);
+ list->tail = list->head;
+ } else {
+ list->head = insert_d_list_node_head_n(list->head, node);
+ }
+
+ list->node_count++;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+BOOL insert_d_list_tail(d_list_t *list, void *data, unsigned int data_len) {
+
+ if (list && data) {
+
+ if (list->node_count == 0) {
+ list->tail = insert_d_list_node_tail(list->tail, data, data_len);
+ list->head = list->tail;
+ } else {
+ list->tail = insert_d_list_node_tail(list->tail, data, data_len);
+ }
+
+ list->node_count++;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+BOOL insert_d_list_tail_node(d_list_t *list, d_list_node_t *node) {
+
+ BOOL ret = FALSE;
+ if (list) {
+
+ node->next = NULL;
+ node->pre = NULL;
+ if (list->node_count == 0) {
+ list->tail = insert_d_list_node_tail_n(list->tail, node);
+ list->head = list->tail;
+ } else {
+ list->tail = insert_d_list_node_tail_n(list->tail, node);
+ }
+ list->node_count++;
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+
+BOOL delete_d_list_head(d_list_t *list) {
+
+ BOOL ret = FALSE;
+ if (list == NULL)
+ return FALSE;
+
+ if (list->node_count > 0) {
+ d_list_node_t *temp_node = list->head;
+
+ list->head = list->head->next;
+ list->node_count--;
+ if (list->node_count == 0 && list->head == NULL) {
+ list->tail = NULL;
+ } else {
+ list->head->pre = NULL;
+ }
+
+ free(temp_node);
+ ret = TRUE;
+ }
+
+
+ return ret;
+}
+
+
+BOOL delete_d_list_tail(d_list_t *list) {
+
+ BOOL ret = FALSE;
+ if (list == NULL)
+ return FALSE;
+
+ if (list->node_count > 0) {
+ d_list_node_t *temp_node = list->tail;
+
+ list->tail = list->tail->pre;
+ list->node_count--;
+ if (list->node_count == 0 && list->tail == NULL) {
+ list->head = NULL;
+ } else {
+ list->tail->next = NULL;
+ }
+
+ free(temp_node);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+
+BOOL remove_d_list_node(d_list_t *list, d_list_node_t *node) {
+
+ if (node == NULL || list == NULL || list->node_count == 0)
+ return FALSE;
+
+ if (list->head == node) {
+ list->head = node->next;
+ if (list->head != NULL) {
+ node->next->pre = NULL;
+ } else {
+ list->tail = NULL;
+ }
+ } else {
+ node->pre->next = node->next;
+ if (node->next == NULL) {
+ list->tail = node->pre;
+ } else {
+ node->next->pre = node->pre;
+ }
+ }
+
+ node->next = NULL;
+ node->pre = NULL;
+ list->node_count--;
+
+ return TRUE;
+}
+
+
+d_list_node_t *remove_d_list_head_node(d_list_t *list) {
+
+ d_list_node_t *temp_node = NULL;
+ if (list == NULL)
+ return NULL;
+
+ if (list->head != NULL) {
+
+ temp_node = list->head;
+ list->head = list->head->next;
+ if (list->head == NULL)
+ list->tail = NULL;
+ else
+ list->head->pre = NULL;
+
+ list->node_count--;
+ }
+
+ return temp_node;
+}
+
+
+d_list_node_t *remove_d_list_tail_node(d_list_t *list) {
+
+ d_list_node_t *temp_node = NULL;
+ if (list == NULL)
+ return NULL;
+
+ if (list->tail != NULL) {
+
+ temp_node = list->tail;
+ list->tail = list->tail->pre;
+ if (list->tail == NULL)
+ list->head = NULL;
+ else
+ list->tail->next = NULL;
+
+ list->node_count--;
+ }
+
+ return temp_node;
+}
+
+
+BOOL delete_d_list_node_all(d_list_t *list) {
+
+ if (list) {
+ while (delete_d_list_head(list)) {
+
+ }
+
+ if (list->node_count == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void destroy_d_list(d_list_t *list) {
+ if (list == NULL)
+ return;
+
+ delete_d_list_node_all(list);
+ free(list);
+}
+
+
+d_list_node_t *find_d_list_node(d_list_t *list, void *user_data, unsigned int data_len, compare_func func) {
+
+ d_list_node_t *temp_node = NULL;
+ if (list == NULL)
+ return NULL;
+
+ if (list->node_count > 0) {
+ temp_node = list->head;
+ while (temp_node)
+ {
+ if (func(user_data, data_len, temp_node->data, temp_node->data_len) == 0) {
+ break;
+ }
+
+ temp_node = temp_node->next;
+ }
+ }
+
+ return temp_node;
+}
+
+
+d_list_node_t *get_d_list_node(d_list_t *list, int idx) {
+ d_list_node_t *temp_node = NULL;
+ if (list == NULL)
+ return NULL;
+
+ if (list->node_count >= (unsigned int)abs(idx) && idx != 0) {
+
+ if (idx > 0) {
+ temp_node = list->head;
+ while (--idx)
+ {
+ temp_node = temp_node->next;
+ }
+ } else {
+ temp_node = list->tail;
+ while (++idx)
+ {
+ temp_node = temp_node->pre;
+ }
+ }
+ }
+
+ return temp_node;
+}
+
+
+d_list_node_t *get_next_node(d_list_t *list) {
+
+ d_list_node_t *temp_node;
+ if (list == NULL)
+ return NULL;
+
+ temp_node = list->cur_idx;
+ if (temp_node == NULL)
+ list->cur_idx = list->head;
+ else
+ list->cur_idx = list->cur_idx->next;
+
+ return temp_node;
+}
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/ftp_manager.c b/src/lynq/packages/apps/lynq-threadhandle/src/ftp_manager.c
new file mode 100644
index 0000000..8f453cc
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/ftp_manager.c
@@ -0,0 +1,327 @@
+#include "ftp_manager.h"
+#include "common.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+
+enum FTP_ID {
+ FTP_LOGIN_ID = 0,
+ FTP_GET_ID,
+ FTP_UP_ID,
+ FTP_QUIT_ID,
+ FTP_LS_ID,
+ FTP_CD_ID = 5,
+ FTP_MKDIR_ID,
+ FTP_RMD_ID,
+ FTP_DELETE_ID
+};
+
+
+
+FTP_MAG_S ftp_manager[] = {
+ {FTP_LOGIN_ID, "login", lynq_ftp_login},
+ {FTP_GET_ID, "get", lynq_ftp_download},
+ {FTP_UP_ID, "up", lynq_ftp_up},
+ {FTP_QUIT_ID, "quit", lynq_ftp_quit},
+ {FTP_LS_ID, "ls", lynq_ftp_ls},
+ {FTP_CD_ID, "cd", lynq_ftp_cd},
+ {FTP_MKDIR_ID, "mkdir", lynq_ftp_creat_mkd},
+ {FTP_RMD_ID, "rmd", lynq_ftp_delete_mkd},
+ {FTP_DELETE_ID, "delete", lynq_ftp_deletefile_mkd},
+};
+
+
+static int ftp_init = 0;
+static struct list_head lynq_ftp_list;
+static FTP_LIST_LINK_S* ftp_slider;
+static lynq_ftp_socker_info ftp_cmd = {0};
+
+FTP_MAG_S *ftp_mag_ret = NULL;
+
+
+void *ftp_handler(void * list)
+{
+ FTP_LIST_LINK_S* pos_list = (FTP_LIST_LINK_S *)list;
+ int ftp_login = 0;
+ char cmpybuf[64] = "";
+
+ while(1)
+ {
+ if (pos_list->data.modify_thread != 1 && pos_list->data.add_thread != 1)
+ continue;
+
+ //LYDBGLOG("[%s-%d] rita thread_id %lu start.\n",__FUNCTION__, __LINE__, pthread_self());
+
+ pos_list->data.add_thread = 0;
+ pos_list->data.modify_thread = 0;
+#if 0
+ LYDBGLOG("**************************ftp_handler debug************************************\n");
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.session = %d\n", __FUNCTION__, __LINE__, pos_list->data.session);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.sevname = %s\n", __FUNCTION__, __LINE__, pos_list->data.sevname);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.username = %s\n", __FUNCTION__, __LINE__, pos_list->data.username);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.pw = %s\n", __FUNCTION__, __LINE__, pos_list->data.pw);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.is_pasv_mode = %s\n", __FUNCTION__, __LINE__, pos_list->data.is_pasv_mode);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.action = %s\n", __FUNCTION__, __LINE__, pos_list->data.action);
+ LYDBGLOG("[%s %d] ---------- > pos_list->data.id = %d\n", __FUNCTION__, __LINE__, pos_list->data.id);
+ LYDBGLOG("**************************debug end************************************\n");
+#endif
+ if (ftp_login == 0 && FTP_QUIT_ID != pos_list->data.id) {
+ ftp_login = lynq_ftp_login(&pos_list->data);
+ LYDBGLOG("[%s-%d] rita test for debuging ftp,ftp_login = %d\n", __FUNCTION__, __LINE__, ftp_login);
+ if(!ftp_login)//rita add @2021.7.19 for error connect,reconnect failure
+ {
+ LYDBGLOG("[%s-%d] rita test for debuging ftp,error!!!\n", __FUNCTION__, __LINE__);
+ list_del((struct list_head* )pos_list);
+ }
+ }
+ else {
+ LYDBGLOG("[%s-%d] +ftplogin: Device logged in before !!!\n", __FUNCTION__, __LINE__);
+ }
+
+ ftp_mag_ret->ftp_action(&pos_list->data);
+ }
+}
+
+
+int ftp_act_handler(thread_pool_t *pool)
+{
+ FTP_LIST_LINK_S* tmp_list = (FTP_LIST_LINK_S *)ftp_slider;
+ struct list_head* slider = NULL;
+ FTP_LIST_LINK_S* tmp = NULL;
+ if(tmp == NULL)
+ {
+ tmp = (FTP_LIST_LINK_S*)malloc(sizeof(FTP_LIST_LINK_S));
+ if(tmp == NULL)
+ {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_MALLOCVALID);
+ return ERR_MALLOCVALID;
+ }
+ }
+ memset(tmp, 0, sizeof(FTP_LIST_LINK_S));
+ LYDBGLOG("[%s-%d] ftp_cmd.id = %d\n", __FUNCTION__, __LINE__, ftp_cmd.id);
+
+ switch(ftp_cmd.id)
+ {
+ case FTP_LOGIN_ID:
+ case FTP_GET_ID:
+ case FTP_UP_ID:
+ case FTP_QUIT_ID:
+ case FTP_LS_ID:
+ case FTP_CD_ID:
+ case FTP_MKDIR_ID:
+ case FTP_RMD_ID:
+ case FTP_DELETE_ID:
+ if (tmp_list == NULL ) {
+ LYDBGLOG("[%s-%d] first time\n", __FUNCTION__, __LINE__);
+ tmp->data = ftp_cmd;
+ tmp->data.add_thread = 1;
+ list_add_tail(&tmp->list, &lynq_ftp_list);
+
+ ftp_list_locate();
+ if (!threadpool_add(pool, ftp_handler, (void *)ftp_slider)) {
+ LYDBGLOG("add error!!!\n");
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return ERR_INVOKE;
+ }
+ }
+ else {
+ LYDBGLOG("[%s-%d] change ftp_cmd.file_type = %s \n",__func__, __LINE__, ftp_cmd.file_type);
+ LYDBGLOG("[%s-%d] change ftp_cmd.is_pasv_mode = %s \n",__func__, __LINE__, ftp_cmd.is_pasv_mode);
+ LYDBGLOG("[%s-%d] tmp_list->data.control_sockfd = %d \n", __FUNCTION__, __LINE__, tmp_list->data.control_sockfd);
+
+ // Save sockfd. If you don't save it, it will be overridden to 0, resulting in unable to connect
+ ftp_cmd.control_sockfd = tmp_list->data.control_sockfd;
+ tmp_list->data = ftp_cmd;
+ tmp_list->data.modify_thread = 1;
+ }
+
+ break;
+ default:
+ LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+
+ if (tmp != NULL)
+ free(tmp);
+ return ERR_CMDVALID;
+ }
+
+ tmp = NULL;
+ return NO_ERROR;
+}
+
+
+FTP_MAG_S *ftp_manager_proc(const char *action)
+{
+ int type_num = sizeof(ftp_manager) / sizeof(FTP_MAG_S);
+ int i = 0;
+ for (i = 0; i < type_num; i++)
+ {
+ if (0 == strcmp(ftp_manager[i].action, action))
+ {
+ //LYDBGLOG("[%s-%d] action is ftp %s\n", __FUNCTION__, __LINE__, ftp_manager[i].action);//rita add @2021.07.19 for debug description
+ return &ftp_manager[i];
+ }
+ }
+ //LYDBGLOG("[%s-%d] error action %s\n", __FUNCTION__, __LINE__, action);
+ return NULL;
+}
+
+
+int ftp_param_verification(char result[][BUF_SIZE] , int line)
+{
+
+ for (int i = 0; i < line; i++) {
+ LYDBGLOG("[%s-%d]=======>rita,str[%d] = %s \n", __FUNCTION__, __LINE__, i, result[i]);
+ }
+
+ if (line < 3) {
+ LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+
+ memcpy(ftp_cmd.protocol, result[0], sizeof(ftp_cmd.protocol));//rita add @2021.07.19 for protocol type mismatch
+
+ if(!atoi(result[2])) {
+ LYDBGLOG("[%s %d] session error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_SESSIONVALID);
+ return ERR_SESSIONVALID;
+ }
+ ftp_cmd.session = atoi(result[2]);
+ memcpy(ftp_cmd.action, result[1], sizeof(ftp_cmd.action));//rita add @2021.07.19 for action type mismatch
+ strcpy(ftp_cmd.sevname, result[3]);
+
+ ftp_cmd.portnum = atoi(result[4]);
+ strcpy(ftp_cmd.username, result[5]);
+ strcpy(ftp_cmd.pw, result[6]);
+
+ //LYDBGLOG("[%s-%d] sevname=%s, portnum=%d, username=%s,pw=%s \n", __FUNCTION__, __LINE__, ftp_cmd.sevname, ftp_cmd.portnum, ftp_cmd.username, ftp_cmd.pw);
+
+ ftp_mag_ret = ftp_manager_proc(ftp_cmd.action);
+
+
+ ftp_cmd.id = ftp_mag_ret->id;
+
+ LYDBGLOG("[%s-%d] ftp_cmd.id = %d\n", __FUNCTION__, __LINE__, ftp_cmd.id);
+
+ switch (ftp_mag_ret->id)
+ {
+ case FTP_LOGIN_ID:
+ if(line != 7)
+ {
+ LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ break;
+
+ case FTP_GET_ID:
+ if(line != 12)
+ {
+ LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ strcpy(ftp_cmd.getfilename_path, result[9]);
+ strcpy(ftp_cmd.getfilename, result[10]);
+ case FTP_UP_ID:
+ if (line != 12) {
+ LYDBGLOG("[%s-%d] command error id = %d\n", __FUNCTION__, __LINE__, ftp_mag_ret->id);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ strcpy(ftp_cmd.file_type, result[7]);
+ strcpy(ftp_cmd.is_pasv_mode, result[8]);
+ strcpy(ftp_cmd.put_opt , result[11]);
+
+ if (ftp_mag_ret->id == FTP_UP_ID) {
+ strcpy(ftp_cmd.putfilename_path, result[9]);
+ strcpy(ftp_cmd.putfilename, result[10]);
+ }
+ break;
+
+ case FTP_QUIT_ID:
+ if (line < 8) {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ break;
+
+ case FTP_LS_ID:
+ if (line !=9) {
+ LYDBGLOG("[%s-%d] command error id = %d\n", __FUNCTION__, __LINE__, ftp_mag_ret->id);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+ strcpy(ftp_cmd.dir, result[8]);//rita add @2021.7.19 for ls bug
+ strcpy(ftp_cmd.is_pasv_mode, result[7]);
+ break;
+ case FTP_CD_ID:
+ case FTP_MKDIR_ID:
+ case FTP_RMD_ID:
+ case FTP_DELETE_ID:
+ if (line != 8) {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ strcpy(ftp_cmd.del_mkr_filename, result[7]);
+ //strcpy(ftp_cmd.is_pasv_mode, result[7]);
+ break;
+
+ default:
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ break;
+
+ }
+
+ return NO_ERROR;
+
+}
+
+
+int ftp_list_locate()
+{
+ struct list_head* slider = NULL;
+ ftp_slider = NULL;
+ list_for_each(slider, &lynq_ftp_list) {
+ ftp_slider = (FTP_LIST_LINK_S*)slider;
+ LYDBGLOG("[%s-%d] =============START====================== \n", __func__, __LINE__);
+ LYDBGLOG("[%s-%d] protocol : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.protocol);
+ LYDBGLOG("[%s-%d] session : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.session);
+ LYDBGLOG("[%s-%d] action : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.action);
+ LYDBGLOG("[%s-%d] port : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.portnum);
+ LYDBGLOG("[%s-%d] sevname : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.sevname);
+ LYDBGLOG("[%s-%d] username : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.username);
+ LYDBGLOG("[%s-%d] pw : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.pw);
+ LYDBGLOG("[%s-%d] index : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.index);
+ LYDBGLOG("[%s-%d] ==============END===================== \n", __func__, __LINE__);
+
+ if (!strcmp(ftp_slider->data.protocol, ftp_cmd.protocol) && ftp_slider->data.session == ftp_cmd.session) {
+ //LYDBGLOG("[%s-%d] Node found\n", __FUNCTION__, __LINE__);
+ if (strcmp(ftp_slider->data.sevname, ftp_cmd.sevname) != 0 || strcmp(ftp_slider->data.username, ftp_cmd.username) != 0 || strcmp(ftp_slider->data.pw, ftp_cmd.pw) != 0 || ftp_slider->data.portnum != ftp_cmd.portnum) {
+ LYDBGLOG("[%s-%d] sevname error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ LYDBGLOG("[%s-%d]=======> Node found\n", __FUNCTION__, __LINE__);
+ return NO_ERROR;
+ }
+ }
+ ftp_slider = NULL;
+
+ LYDBGLOG("[%s-%d] Not found\n", __FUNCTION__, __LINE__);
+ return NO_ERROR;
+}
+
+
+void ftp_list_init()
+{
+ if (ftp_init == 0) {
+ INIT_LIST_HEAD(&lynq_ftp_list);
+ ftp_init = 1;
+ }
+
+}
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/http_manager.c b/src/lynq/packages/apps/lynq-threadhandle/src/http_manager.c
new file mode 100644
index 0000000..259b10c
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/http_manager.c
@@ -0,0 +1,359 @@
+#include "http_manager.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+static struct list_head http_list;
+static HTTP_LIST_LINK_S* http_slider;
+static lynq_http_client_t http_cmd = {0};
+
+
+void *http_handler(void * list)
+{
+ int error_code = 0;
+ HTTP_LIST_LINK_S* pos_list = (HTTP_LIST_LINK_S *)list;
+
+ while(1)
+ {
+ if (pos_list->data.modify_thread != 1 && pos_list->data.add_thread != 1)
+ continue;
+
+ pos_list->data.add_thread = 0;
+ pos_list->data.modify_thread = 0;
+
+ if (!strcmp(pos_list->data.action, "init")) {}
+ else if (!strcmp(pos_list->data.action, "send")) {}
+ else if (!strcmp(pos_list->data.action, "get")) {
+ lynq_http_init();
+ lynq_http_client_t * http_data = lynq_http_new();
+
+ http_data->session = pos_list->data.session;
+ memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));//rita add @2021.7.19 for action type mismatch
+ lynq_http_sync_request(http_data , pos_list->data.url, M_GET, M_CLOSE);
+
+ error_code = lynq_http_get_error_code(http_data);
+ if(error_code!=0){
+ LYDBGLOG("[%s-%d] get error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error
+ LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);
+ }
+
+ if (pos_list->data.url)
+ free(pos_list->data.url);
+
+ if (pos_list->data.post_data)
+ free(pos_list->data.post_data);
+
+ list_del((struct list_head* )pos_list);
+ return NULL;
+ }
+
+ else if (!strcmp(pos_list->data.action, "getfile")) {//rita add @2021.7.19 for http get
+ lynq_http_init();
+ lynq_http_client_t * http_data = lynq_http_new();
+
+ http_data->session = pos_list->data.session;
+ memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));
+ lynq_http_sync_download_file(http_data, pos_list->data.url, "",M_GET, M_CLOSE);
+
+ error_code = lynq_http_get_error_code(http_data);
+ if(error_code!=0){
+ LYDBGLOG("[%s-%d] get file error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error
+ LYVERBLOG("[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);
+ }
+
+ if (pos_list->data.url) {
+ free(pos_list->data.url);
+ }
+
+ if (pos_list->data.post_data) {
+ free(pos_list->data.post_data);
+ }
+
+ list_del((struct list_head* )pos_list);
+ return NULL;
+ }
+ else if (!strcmp(pos_list->data.action, "post")) {
+ lynq_http_init();
+ lynq_http_client_t * http_data = lynq_http_new();
+
+ http_data->session = pos_list->data.session;
+ memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));
+ lynq_http_sync_post_request(http_data , pos_list->data.url, pos_list->data.post_data, M_POST, M_CLOSE);
+
+ error_code = lynq_http_get_error_code(http_data);
+ if(error_code!=0){
+ LYDBGLOG("[%s-%d] post error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error
+ LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);
+ }
+ if (pos_list->data.url) {
+ free(pos_list->data.url);
+ }
+
+ if (pos_list->data.post_data) {
+ free(pos_list->data.post_data);
+ }
+
+ list_del((struct list_head* )pos_list);
+ return NULL;
+ }
+
+ else if (!strcmp(pos_list->data.action, "lpost")) {
+ lynq_http_init();
+ lynq_http_client_t *http_data = lynq_http_new();
+
+ memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));
+ memcpy(http_data->protocol, pos_list->data.protocol, sizeof(http_data->protocol));
+ http_data->session = pos_list->data.session;
+
+ if (pos_list->data.index != 1) {
+ http_data->index = 1;
+ lynq_http_sync_post_request(http_data , pos_list->data.url, pos_list->data.post_data, M_POST, M_KEEP);
+ }
+ else {
+ http_data->fd = pos_list->data.fd;
+ http_data->url = pos_list->data.url;
+ http_data->post_data = pos_list->data.post_data;
+ http_data->post_data_len = pos_list->data.post_data_len;
+ http_data->method = M_POST;
+ http_data->conn_method= M_KEEP;
+
+ if( http_parser_parse_url(http_data->url, strlen(http_data->url), 0, &http_data->u) != 0 )
+ {
+ //printf("[%s-%d] \n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return NULL;
+ }
+
+ lynq_http_write_head_data(http_data);
+ }
+
+ error_code = lynq_http_get_error_code(http_data);
+ if(error_code != 0) {
+ LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);
+ if (pos_list->data.url)
+ free(pos_list->data.url);
+
+ if (pos_list->data.post_data)
+ free(pos_list->data.post_data);
+
+ list_del((struct list_head* )pos_list);
+ return NULL;
+ }
+
+ memcpy(&pos_list->data, http_data, sizeof(lynq_http_client_t));
+ pos_list->data.index = 1;
+ }
+
+ else if (!strcmp(pos_list->data.action, "close")) {
+ lynq_http_client_t *http_data = lynq_http_new();
+
+ http_data->session = pos_list->data.session;
+ memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));
+ http_data->fd = pos_list->data.fd;
+ http_data->url = pos_list->data.url;
+ http_data->conn_method = M_CLOSE;
+ http_data->post_data = pos_list->data.post_data;
+
+
+ pos_list->data.index = 0;
+ if( http_parser_parse_url(http_data->url, strlen(http_data->url), 0, &http_data->u) != 0 )
+ {
+ //printf("[%s-%d]\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return NULL;
+ }
+
+ lynq_http_write_head_data(http_data);
+ error_code = lynq_http_get_error_code(http_data);
+ if(error_code!=0)
+ LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);
+
+ lynq_http_data_send("close");
+
+ if (pos_list->data.url)
+ free(pos_list->data.url);
+
+ if (pos_list->data.post_data)
+ free(pos_list->data.post_data);
+
+ list_del((struct list_head* )pos_list);
+ return NULL;
+ }
+ }
+}
+
+
+
+int http_act_handler(thread_pool_t *pool)
+{
+ HTTP_LIST_LINK_S* tmp_list = (HTTP_LIST_LINK_S *)http_slider;
+ struct list_head* slider = NULL;
+ HTTP_LIST_LINK_S* tmp = NULL;
+ if(tmp == NULL)
+ {
+ tmp = (HTTP_LIST_LINK_S*)malloc(sizeof(HTTP_LIST_LINK_S));
+ if(tmp == NULL)
+ {
+ return ERR_MALLOCVALID;
+ }
+ }
+ memset(tmp, 0, sizeof(HTTP_LIST_LINK_S));
+
+ if (tmp_list == NULL ) {
+ if(!strcmp(http_cmd.action, "init") || !strcmp(http_cmd.action, "conn") || !strcmp(http_cmd.action, "send") || !strcmp(http_cmd.action, "get") || !strcmp(http_cmd.action, "post") || !strcmp(http_cmd.action, "lpost") || !strcmp(http_cmd.action, "getfile")) {
+ tmp->data = http_cmd;
+ if (http_cmd.url != NULL)
+ {
+
+ tmp->data.url = (char *)malloc(strlen(http_cmd.url)+1);
+ if (tmp->data.url == NULL)
+ return ERR_MALLOCVALID;
+
+ memset(tmp->data.url, 0x00, strlen(http_cmd.url)+1);
+ memcpy(tmp->data.url, http_cmd.url, strlen(http_cmd.url));
+ }
+
+ if (http_cmd.post_data != NULL)
+ {
+ tmp->data.post_data = (char *)malloc(strlen(http_cmd.post_data)+1);
+ if (tmp->data.post_data == NULL)
+ return ERR_MALLOCVALID;
+
+ memset(tmp->data.post_data, 0x00, strlen(http_cmd.post_data)+1);
+ memcpy(tmp->data.post_data, http_cmd.post_data, strlen(http_cmd.post_data));
+ }
+
+ tmp->data.add_thread = 1;
+ list_add_tail(&tmp->list, &http_list);
+ http_list_locate();
+
+ if (!threadpool_add(pool, http_handler, (void *)http_slider)) {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return ERR_INVOKE;
+ }
+ }
+ else {
+ LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ if (tmp != NULL)
+ free(tmp);
+ return ERR_CMDVALID;
+ }
+ }
+ else {
+ if(!strcmp(http_cmd.action, "send") || !strcmp(http_cmd.action, "lpost") || !strcmp(http_cmd.action, "close")) {
+ memcpy(tmp_list->data.action, http_cmd.action, sizeof(tmp_list->data.action));
+ memcpy(tmp_list->data.post_data, http_cmd.post_data, strlen(http_cmd.post_data));
+ tmp_list->data.modify_thread = 1;
+ }
+ else {
+ LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ }
+
+ tmp = NULL;
+ return NO_ERROR;
+}
+
+
+
+int http_param_verification(char result[][BUF_SIZE] , int line)
+{
+ if (line < 3) {
+ LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+ http_cmd.url = NULL;
+ http_cmd.post_data = NULL;
+ memcpy(http_cmd.protocol, result[0], sizeof(http_cmd.protocol));
+
+ if(!atoi(result[2])) { //session
+ LYDBGLOG("[%s-%d] session error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_SESSIONVALID);
+ return ERR_SESSIONVALID;
+ }
+
+ http_cmd.session = atoi(result[2]);
+ memcpy(http_cmd.action, result[1], sizeof(http_cmd.action));
+
+ if (!(strcmp(result[1], "post"))) {
+ http_cmd.url = result[3];
+ http_cmd.post_data = result[4];
+ }
+
+ else if (!(strcmp(result[1], "lpost"))) {
+ http_cmd.url = result[3];
+ http_cmd.post_data = result[4];
+ }
+
+ else if (!(strcmp(result[1], "get"))) {
+ strcat(result[3], result[4]);
+ http_cmd.url = result[3];
+ }
+
+ else if (!(strcmp(result[1], "getfile"))) {
+ http_cmd.url = result[3];
+ strcat(http_cmd.url, result[4]);//path
+
+ }
+
+ else if (!(strcmp(result[1], "close"))) {
+ http_cmd.conn_method = M_CLOSE;
+ http_cmd.post_data = "s=close";
+ }
+ else {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+ return NO_ERROR;
+}
+
+
+int http_list_locate()
+{
+ struct list_head* slider = NULL;
+ http_slider = NULL;
+ list_for_each(slider, &http_list)
+ {
+ http_slider = (HTTP_LIST_LINK_S*)slider;
+#if 0
+ LYDBGLOG("[%s-%d] =================================== \n", __func__, __LINE__);
+ LYDBGLOG("[%s-%d] protocol : %s \n", __FUNCTION__, __LINE__, http_slider->data.protocol);
+ LYDBGLOG("[%s-%d] session : %d \n", __FUNCTION__, __LINE__, http_slider->data.session);
+ LYDBGLOG("[%s-%d] action : %s \n", __FUNCTION__, __LINE__, http_slider->data.action);
+ LYDBGLOG("[%s-%d] index : %d \n", __FUNCTION__, __LINE__, http_slider->data.index);
+ LYDBGLOG("[%s-%d] =================================== \n", __func__, __LINE__);
+#endif
+
+ if (!strcmp(http_slider->data.protocol, http_cmd.protocol) && http_slider->data.session == http_cmd.session) {
+ if (strcmp(http_cmd.action, "close") != 0) {
+ if (strcmp(http_slider->data.url, http_cmd.url) != 0) {
+ //LYDBGLOG("[%s-%d] URL error\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+ }
+ return NO_ERROR;
+ }
+ }
+ http_slider = NULL;
+
+ return NO_ERROR;
+}
+
+
+static int http_init = 0;
+void http_list_init()
+{
+ if (http_init == 0) {
+ INIT_LIST_HEAD(&http_list);
+ http_init = 1;
+ }
+
+}
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/model_manager.c b/src/lynq/packages/apps/lynq-threadhandle/src/model_manager.c
new file mode 100644
index 0000000..0adb506
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/model_manager.c
@@ -0,0 +1,34 @@
+#include "model_manager.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+
+
+
+MAG_LIST_S list_manager[] = {
+ {"http", http_list_init, http_param_verification, http_list_locate, http_act_handler, NULL, NULL, NULL, NULL },
+ {"ftp", ftp_list_init, ftp_param_verification, ftp_list_locate, ftp_act_handler, NULL, NULL, NULL},
+ {"mqtt", mqtt_list_init, mqtt_param_verification, mqtt_list_locate, mqtt_act_handler, NULL, NULL, NULL,NULL},
+ {"ril", ril_list_init,ril_param_verification, ril_list_locate, ril_act_handler, NULL, NULL, NULL,NULL},
+};
+
+
+MAG_LIST_S *list_manager_proc(const char *name)
+{
+ int type_num = sizeof(list_manager) / sizeof(MAG_LIST_S);
+ int i = 0;
+ for (i = 0; i < type_num; i++)
+ {
+ if (0 == strcmp(list_manager[i].name, name))
+ {
+ LYDBGLOG("[%s-%d] recognized message type is %s\n", __FUNCTION__, __LINE__, list_manager[i].name);
+ return &list_manager[i];
+ }
+ }
+ LYDBGLOG("[%s-%d] Unrecognized message type %s\n", __FUNCTION__, __LINE__, name);
+
+ return NULL;
+}
+
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/mqtt_manager.c b/src/lynq/packages/apps/lynq-threadhandle/src/mqtt_manager.c
new file mode 100644
index 0000000..922a7e7
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/mqtt_manager.c
Binary files differ
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/ril_manager.c b/src/lynq/packages/apps/lynq-threadhandle/src/ril_manager.c
new file mode 100644
index 0000000..29ea6fe
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/ril_manager.c
@@ -0,0 +1,69 @@
+#include "model_manager.h"
+#include <libtel/lib_tele.h>
+#include <libtel/lynq_call.h>
+#include <log/log.h>
+#include "common.h"
+#define P_MAX 100
+static char **ril_param= NULL;
+int eventDial(const char *addr)
+{
+ int32_t token;
+ //const char* addr = "10086";
+ char output[1024] = {0};
+ lynqCallList *msg = (lynqCallList*)malloc(sizeof(lynqCallList));
+ memset(msg,0,sizeof(lynqCallList));
+ msg->addr=(char *)malloc(sizeof(char));
+ memset(msg->addr,0,sizeof(char));
+ //printf("call start \n");
+ token = lynq_call(addr, msg);
+ // RLOGD("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ // msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ // printf("[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ // msg->base.request,msg->addr,msg->base.token,msg->base.e,msg->call_state);
+ lynq_log_output(LOG_THREADHANDLE, LOG_DEBUG, "[MAIN_LOG] request is %d,phone number is %s,token is %x,error is %d,call_state is %d",
+ msg->base.request, msg->addr, msg->base.token, msg->base.e, msg->call_state);
+ //sprintf(output, "Factory_result error_code:%d\n",msg->base.e);
+ //emResultNotify(output);
+ free(msg->addr);
+ msg->addr=NULL;
+ free(msg);
+ msg=NULL;
+ return 0;
+}
+void *ril_handler(void *list)
+{
+ char *addr = (char*)list;
+ printf("addr = %s\n",addr);
+ eventDial(addr);
+ return NULL;
+}
+void ril_list_init()
+{
+ return;
+}
+int ril_param_verification(char result[][BUF_SIZE] , int line)
+{
+ ril_param = result;
+ for(int i =0;i<line;i++)
+ {
+ //printf("result =%s\n",ril_param[i]);
+ lynq_log_output(LOG_THREADHANDLE, LOG_DEBUG, "result =%s\n", ril_param[i]);
+ }
+ return 0;
+}
+int ril_list_locate()
+{
+ return 0;
+}
+int ril_act_handler(thread_pool_t *pool)
+{
+ //printf("ril_param[1] = %s\n",ril_param[1]);
+ lynq_log_output(LOG_THREADHANDLE, LOG_DEBUG, "ril_param[1] = %s\n", ril_param[1]);
+ //eventDial(ril_param[1]);
+ if (!threadpool_add(pool, ril_handler, (void *)ril_param[1])) {
+ printf("[%s-%d] error \n", __FUNCTION__, __LINE__);
+ return ERR_INVOKE;
+ }
+ return 0;
+}
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/seq_queue.c b/src/lynq/packages/apps/lynq-threadhandle/src/seq_queue.c
new file mode 100644
index 0000000..787a601
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/seq_queue.c
@@ -0,0 +1,132 @@
+#include "seq_queue.h"
+
+
+seq_queue_t *create_seq_queue(in unsigned int block_size, in unsigned int total_block, in BOOL expand) {
+
+ seq_queue_t *queue = (seq_queue_t *)malloc(sizeof(seq_queue_t));
+ if (queue) {
+
+ memset(queue, 0, sizeof(seq_queue_t));
+ queue->block_buffer = malloc(total_block * block_size);
+ if (queue->block_buffer == NULL) {
+ free(queue);
+ queue = NULL;
+ } else {
+ queue->block_size = block_size;
+ queue->total_block = total_block;
+ queue->expandabilit = expand;
+ queue->expand_blocks = EXPAND_BLOCK_NUM;
+
+ create_sem(&queue->task_queue_lock, 1);
+// init_mutex_handle(&queue->task_queue_lock);
+ }
+ }
+
+ return queue;
+}
+
+void destroy_seq_queue(in seq_queue_t *queue) {
+
+ if (queue == NULL)
+ return ;
+
+ destroy_sem(&queue->task_queue_lock);
+// mutex_destroy(&queue->task_queue_lock);
+ free(queue->block_buffer);
+ free(queue);
+}
+
+
+BOOL expand_seq_queue(in seq_queue_t *queue) {
+
+ void *new_buffer;
+ BOOL ret = FALSE;
+ if (queue == NULL || !queue->expandabilit)
+ return FALSE;
+
+ new_buffer = malloc((queue->total_block+queue->expand_blocks) * queue->block_size);
+ if (new_buffer) {
+ if (queue->current_block > queue->tail_block) {
+ memcpy(new_buffer, (char *)queue->block_buffer, queue->total_block * queue->block_size);
+ } else if (queue->current_block < queue->tail_block || (queue->current_block == queue->tail_block && queue->used_block != 0)) {
+ int head_block = queue->total_block - queue->tail_block;
+ int head_data_len = head_block * queue->block_size;
+ memcpy(new_buffer, (char *)queue->block_buffer + queue->tail_block * queue->block_size, head_data_len);
+ memcpy((char *)new_buffer + head_data_len, (char *)queue->block_buffer, queue->current_block * queue->block_size);
+ queue->tail_block = 0;
+ queue->current_block = head_block + queue->current_block;
+ } else if (queue->current_block == queue->tail_block){
+ queue->current_block = 0;
+ queue->tail_block = 0;
+ }
+
+ queue->total_block += queue->expand_blocks;
+
+ free(queue->block_buffer);
+ queue->block_buffer = new_buffer;
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+
+BOOL en_seq_queue(in seq_queue_t *queue, in void *data) {
+
+ if (queue == NULL || data == NULL)
+ return FALSE;
+
+ wait_sem(&queue->task_queue_lock);
+ //mutex_lock(&queue->task_queue_lock);
+ if (queue->used_block >= queue->total_block) {
+ static int times= 0;
+ times++;
+ if (!expand_seq_queue(queue)) {
+
+ return FALSE;
+ }
+ }
+
+ memcpy((char *)queue->block_buffer + queue->current_block * queue->block_size
+ , data, queue->block_size);
+ queue->current_block++;
+ queue->current_block = queue->current_block % queue->total_block;
+ queue->used_block++;
+
+ post_sem(&queue->task_queue_lock);
+ //mutex_unlock(&queue->task_queue_lock);
+
+ return TRUE;
+}
+
+BOOL de_seq_queue(in seq_queue_t *queue, out void *data) {
+
+ BOOL ret = FALSE;
+ if (queue == NULL)
+ return FALSE;
+
+ wait_sem(&queue->task_queue_lock);
+ //mutex_lock(&queue->task_queue_lock);
+ if (queue->used_block != 0) {
+ memcpy(data, (char *)queue->block_buffer + queue->tail_block * queue->block_size
+ , queue->block_size);
+ queue->tail_block++;
+ queue->tail_block = queue->tail_block % queue->total_block;
+ queue->used_block--;
+ ret = TRUE;
+ }
+ post_sem(&queue->task_queue_lock);
+ //mutex_unlock(&queue->task_queue_lock);
+
+ return ret;
+}
+
+unsigned int get_count_seq_queue(in seq_queue_t *queue) {
+ return queue->used_block;
+}
+
+unsigned int get_size_seq_queue(in seq_queue_t *queue) {
+ return queue->total_block;
+}
+
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/syn_primitive.c b/src/lynq/packages/apps/lynq-threadhandle/src/syn_primitive.c
new file mode 100644
index 0000000..9494df7
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/syn_primitive.c
@@ -0,0 +1,65 @@
+
+#include "syn_primitive.h"
+#define SEM_VALUE_MAX 32767
+
+int init_condition_handle(condition_handle *cond) {
+ return pthread_cond_init(cond, NULL);
+}
+
+
+int destroy_condition_handle(condition_handle *cond) {
+ return pthread_cond_destroy(cond);
+}
+
+
+int wait_condition(condition_handle *cond, mutex_handle *mutex, unsigned int wait) {
+ struct timespec wait_time;
+ if (wait == TIME_WAIT_INFINITE)
+ wait_time.tv_sec = TIME_WAIT_INFINITE;
+ else
+ wait_time.tv_sec = wait + time(0);
+ wait_time.tv_nsec = 0;
+
+ return pthread_cond_timedwait(cond, mutex, &wait_time);
+}
+
+
+int post_condition_signal(condition_handle *cond) {
+ return pthread_cond_signal(cond);
+}
+
+
+int init_mutex_handle(mutex_handle *mutex) {
+ return pthread_mutex_init(mutex, NULL);
+}
+
+int mutex_lock(mutex_handle *mutex) {
+ return pthread_mutex_lock(mutex);
+}
+
+int mutex_unlock(mutex_handle *mutex) {
+ return pthread_mutex_unlock(mutex);
+}
+
+int mutex_destroy(mutex_handle *mutex) {
+ return pthread_mutex_destroy(mutex);
+}
+
+
+int create_sem(sem_handle *sem, int init_count) {
+ return sem_init(sem, 0, init_count>SEM_VALUE_MAX ? SEM_VALUE_MAX:init_count );
+}
+
+
+int wait_sem(sem_handle *sem) {
+ return sem_wait(sem);
+}
+
+int post_sem(sem_handle *sem) {
+ return sem_post(sem);
+}
+
+int destroy_sem(sem_handle *sem) {
+ return sem_destroy(sem);
+}
+
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/thread_main.c b/src/lynq/packages/apps/lynq-threadhandle/src/thread_main.c
new file mode 100644
index 0000000..b7bfa97
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/thread_main.c
@@ -0,0 +1,86 @@
+#include "model_manager.h"
+#include "list.h"
+#include "thread_pool.h"
+#include "common.h"
+#include <signal.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <libtel/lib_tele.h>
+#include "liblynq-broadcast/broadcast_receiver.h"
+
+
+#define USER_LOG_TAG "THHANDLE"
+#define MIN_THR_NUM 10
+#define MAX_THR_NUM 100
+
+
+
+thread_pool_t *pool = NULL;
+char cmd_buf[BUF_SIZE] = "";
+
+static void CallbackByName( char*broadcast_name, int data_length,const char*data)
+{
+ LYDBGLOG("[%s-%d] str_arg = %s, data_length = %d, int_arg = %s\n", broadcast_name, data_length, data);
+ memcpy(cmd_buf, data, strlen(data));
+
+ return;
+}
+
+void *cmd_thread_func(void* argv_list)
+{
+ int runing = 1 ;
+ int ret = NO_ERROR;
+
+ while(runing)
+ {
+ char result[20][BUF_SIZE] = {0};
+ while (strcmp(cmd_buf, "") == 0) {
+ usleep(100);
+ }
+ LYDBGLOG("[%s-%d]========cmd_buf = %s\n", __FUNCTION__, __LINE__, cmd_buf );
+ int line = str_arr(cmd_buf, "\"&", result)+1;
+ memset(cmd_buf, 0, sizeof(cmd_buf));
+ LYDBGLOG("[%s-%d]========result[0] = %s\n", __FUNCTION__, __LINE__, result[0] );
+ MAG_LIST_S *list_manager = list_manager_proc(result[0]);
+ if (list_manager == NULL) {
+ memset(cmd_buf, 0, sizeof(cmd_buf));
+ continue;
+ }
+
+ ret = list_manager->func_param_verification(result, line);
+ if (ret != NO_ERROR){
+ memset(cmd_buf, 0, sizeof(cmd_buf));
+ continue;
+ }
+
+ list_manager->func_list_init();
+ ret = list_manager->func_list_locate();
+ if (ret != NO_ERROR)
+ continue;
+ list_manager->func_act_handler(pool);
+ }
+}
+
+
+int main(void)
+{
+ LYLOGEINIT(USER_LOG_TAG);
+ LYDBGLOG("======lynq-threadhandle start=======\n");
+ pool = threadpool_create(MIN_THR_NUM, MAX_THR_NUM);
+
+ register_broadcast_loop();
+ receive_callback_by_name("function", CallbackByName);//rita add @2021.6.21 for receive dbus info
+
+ if (!threadpool_add(pool, cmd_thread_func, NULL)) {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return 0;
+ }
+
+ while (1) {
+ usleep(100);
+ }
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-threadhandle/src/thread_pool.c b/src/lynq/packages/apps/lynq-threadhandle/src/thread_pool.c
new file mode 100644
index 0000000..50da0a9
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-threadhandle/src/thread_pool.c
@@ -0,0 +1,504 @@
+#include "thread_pool.h"
+#include <time.h>
+#include "common.h"
+
+EThread_pool_status get_threadpool_status(thread_pool_t *pool);
+void set_threadpool_status(thread_pool_t *pool, EThread_pool_status state);
+thread_info_t *create_thread_info(EThread_pool_status *pool_status);
+thread_handle pool_thread_create(THREAD_FUNC threadFun, int pri, void *para);
+BOOL init_threadpool(thread_pool_t *pool);
+thread_handle get_self_thread_id(void);
+
+#define THREAD_PRI_NOMAL_LEVEL 60
+#define THREAD_PRI_ABOVE_LEVEL 70
+#define THREAD_PRI_HIGH_LEVEL 80
+
+
+#define TASK_QUEUE_COUNT_MAX 100
+#define CONDITION_WAIT_TIME 1000
+#define INCRE_THREADS_UNIT 5
+
+
+
+thread_handle get_self_thread_id() {
+ return pthread_self();
+}
+
+void tp_sleep(unsigned int ms) {
+ struct timeval delay;
+
+ delay.tv_sec = ms/1000;
+ delay.tv_usec = (ms%1000) * 1000;
+ select(0, NULL, NULL, NULL, &delay);
+}
+
+
+unsigned long get_current_time(void) {
+ return time(NULL);
+}
+
+void force_exit_thread(thread_info_t *thread_info) {
+
+ int ret;
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ pthread_cancel(thread_info->h_thread);
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+
+ ret = destroy_condition_handle(&thread_info->thread_cond);
+ if (ret) {
+ post_condition_signal(&thread_info->thread_cond);
+ destroy_condition_handle(&thread_info->thread_cond);
+ }
+
+ ret = mutex_destroy(&thread_info->thread_lock);
+ if (ret) {
+ mutex_unlock(&thread_info->thread_lock);
+ mutex_destroy(&thread_info->thread_lock);
+ }
+}
+
+
+int compare_thread_id(void *usr_data, unsigned int sdata_len, void *list_data, unsigned int ldata_len) {
+ if (((thread_info_t *)usr_data)->h_thread == ((thread_info_t *)list_data)->h_thread) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+
+static void pool_thread_work(void *para)
+{
+ int ret = 0;
+
+ thread_info_t *thread_info = (thread_info_t *)para;
+ thread_func_t *thread_func;
+
+ if (thread_info == NULL) {
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ return;
+ }
+
+ while (*thread_info->pool_status != EThread_pool_exit) {
+ mutex_lock(&thread_info->thread_lock);
+ while (!thread_info->busy) {
+ ret = wait_condition(&thread_info->thread_cond, &thread_info->thread_lock, TIME_WAIT_INFINITE);
+ }
+
+ mutex_unlock(&thread_info->thread_lock);
+
+ if (*thread_info->pool_status == EThread_pool_exit || thread_info->release)
+ break;
+
+ thread_func = &thread_info->thread_para;
+ thread_info->time_out = thread_func->time_out_info.time_out;
+ thread_info->launch_time = get_current_time();
+ thread_info->thread_para.process_func(thread_info->thread_para.args);
+ if (thread_info->thread_para.release_func) {
+ thread_info->thread_para.release_func(thread_info->thread_para.args);
+ }
+ thread_info->launch_time = TIME_WAIT_INFINITE;
+
+ mutex_lock(&thread_info->thread_lock);
+ thread_info->busy = FALSE;
+ mutex_unlock(&thread_info->thread_lock);
+ }
+
+ LYDBGLOG(" thread %lu exit.\n", get_self_thread_id());
+
+ pthread_exit(0);
+}
+
+
+BOOL scan_idle_thread_from_busy(thread_pool_t *pool) {
+
+ BOOL ret = FALSE;
+
+ d_list_t *idle_list = pool->idle_threads;
+ d_list_t *busy_list = pool->busy_threads;
+
+ d_list_node_t *temp_node;
+ thread_info_t *info;
+ if (busy_list == NULL || idle_list == NULL)
+ return FALSE;
+
+ while ((temp_node = get_next_node(busy_list)) != NULL)
+ {
+ if (temp_node == NULL || temp_node->data == NULL)
+ break;
+
+ info = (thread_info_t *)temp_node->data;
+ if (!info->busy) {
+
+ if (remove_d_list_node(busy_list, temp_node)) {
+ insert_d_list_tail_node(idle_list, temp_node);
+ ret = TRUE;
+ //break;
+ }
+ } else {
+ if (info->time_out == 0 || info->launch_time == TIME_WAIT_INFINITE) {
+ continue;
+ }
+
+ if (get_current_time() - info->time_out > info->launch_time) {
+ //if (get_current_time() - info->launch_time > info->time_out) {
+ LYDBGLOG("[%s-%d] ####### time out , force exit thread. %lu #########\n", __FUNCTION__, __LINE__, info->h_thread);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_TIMEOUT);
+ if (remove_d_list_node(busy_list, temp_node)) {
+ force_exit_thread(info);
+
+ if (info->thread_para.time_out_info.timeout_callback) {
+ info->thread_para.time_out_info.timeout_callback(&info->thread_para);
+ }
+
+ init_condition_handle(&info->thread_cond);
+ init_mutex_handle(&info->thread_lock);
+
+ info->busy = FALSE;
+ info->release = FALSE;
+ info->launch_time = TIME_WAIT_INFINITE;
+ info->h_thread = pool_thread_create(pool_thread_work, info->pri, info);
+ if (info->h_thread < 0) {
+
+ free(info);
+ free(temp_node);
+ pool->pool_thread_num--;
+ } else {
+
+ insert_d_list_tail_node(idle_list, temp_node);
+ ret = TRUE;
+ }
+ }
+ }
+
+ }
+ }
+
+ return ret;
+}
+
+
+static void pool_thread_manage(void *para)
+{
+ thread_func_t thread_para;
+ d_list_node_t *list_node;
+ thread_info_t *thread_info;
+ thread_pool_t *pool = (thread_pool_t *)para;
+
+ if (pool == NULL) {
+ return;
+ }
+
+ while (get_threadpool_status(pool) != EThread_pool_exit) {
+
+ if (get_count_seq_queue(pool->task_queue) > 0) {
+
+ pool->release_threads_interval = 0;
+
+ list_node = remove_d_list_head_node(pool->idle_threads);
+ if (list_node && list_node->data) {
+
+ memset(&thread_para, 0, sizeof(thread_func_t));
+ if (de_seq_queue(pool->task_queue, &thread_para)) {
+
+ thread_info = (thread_info_t *)list_node->data;
+ post_sem(&pool->sem_inc);
+
+ mutex_lock(&thread_info->thread_lock);
+ memcpy(&thread_info->thread_para, &thread_para, sizeof(thread_func_t));
+ thread_info->busy = TRUE;
+ post_condition_signal(&thread_info->thread_cond);
+ mutex_unlock(&thread_info->thread_lock);
+
+ insert_d_list_tail_node(pool->busy_threads, list_node);
+
+ } else {
+
+ insert_d_list_head_node(pool->idle_threads, list_node);
+ }
+
+
+ } else {
+ if (scan_idle_thread_from_busy(pool))
+ continue;
+
+ if (pool->pool_thread_num < pool->max_thread_num) {
+
+ int i;
+ for (i=0; i<INCRE_THREADS_UNIT; i++) {
+ thread_info_t *thread_inf = create_thread_info(&pool->status);
+ insert_d_list_tail(pool->idle_threads, thread_inf, sizeof(thread_info_t));
+ pool->pool_thread_num++;
+ }
+
+ } else {
+ //continue;
+ }
+ }
+
+ } else {
+ if (get_d_list_node_count(pool->busy_threads) > 0) {
+ pool->release_threads_interval = 0;
+ scan_idle_thread_from_busy(pool);
+ } else {
+ BOOL is_release_threads = FALSE;
+ if (pool->release_threads_interval == 0) {
+ pool->release_threads_interval = get_current_time();
+ } else {
+ is_release_threads = (get_current_time() - pool->release_threads_interval) > RELEASE_THREAD_INTERVAL;
+ }
+
+ if (is_release_threads && get_d_list_node_count(pool->idle_threads) > pool->min_thread_num) {
+ //
+ list_node = remove_d_list_head_node(pool->idle_threads);
+ if (list_node && list_node->data) {
+ thread_info = (thread_info_t *)list_node->data;
+ if (!thread_info->busy) {
+ mutex_lock(&thread_info->thread_lock);
+ thread_info->release = TRUE;
+ mutex_unlock(&thread_info->thread_lock);
+ post_condition_signal(&thread_info->thread_cond);
+ pool->pool_thread_num--;
+ free(thread_info);
+ free(list_node);
+ } else {
+ insert_d_list_tail(pool->busy_threads, thread_info, sizeof(thread_info_t));
+ }
+ }
+
+ } else {
+ mutex_lock(&pool->mange_lock);
+ wait_condition(&pool->manage_cond, &pool->mange_lock, CONDITION_WAIT_TIME);
+ mutex_unlock(&pool->mange_lock);
+ }
+ }
+
+ }
+ }
+}
+
+
+thread_handle pool_thread_create(THREAD_FUNC threadFun, int pri, void *para) {
+
+ thread_handle h_thread;
+ pthread_attr_t attr;
+ struct sched_param p;
+
+ pthread_attr_init(&attr);
+ p.sched_priority = pri;
+
+ pthread_attr_setschedpolicy(&attr,SCHED_OTHER);
+ pthread_attr_setschedparam(&attr,&p);
+
+ pthread_create(&h_thread, &attr, (void *)threadFun, para);
+ return h_thread;
+}
+
+void pool_thread_release(thread_handle h_thread)
+{
+ pthread_join(h_thread, NULL);
+}
+
+EThread_pool_status get_threadpool_status(thread_pool_t *pool) {
+
+ if (pool) {
+ return pool->status;
+ } else {
+ return EThread_pool_unknown;
+ }
+}
+
+void set_threadpool_status(thread_pool_t *pool, EThread_pool_status state) {
+
+ if (pool) {
+ pool->status = state;
+ }
+}
+
+thread_pool_t *threadpool_create(unsigned int min_thread_num, unsigned int max_thread_num)
+{
+ thread_pool_t *pool = (thread_pool_t *)malloc(sizeof(thread_pool_t));
+
+ if (pool) {
+ memset(pool, 0, sizeof(thread_pool_t));
+ pool->min_thread_num = min_thread_num;
+ pool->max_thread_num = max_thread_num;
+ pool->pri = THREAD_PRI_HIGH_LEVEL;
+ pool->status = EThread_pool_alloc;
+
+ if (!init_threadpool(pool)) {
+ free(pool);
+ pool = NULL;
+ }
+ }
+
+ return pool;
+}
+
+thread_info_t *create_thread_info(EThread_pool_status *pool_status) {
+ thread_info_t *thread_inf = (thread_info_t *)malloc(sizeof(thread_info_t));
+ if (thread_inf == NULL)
+ return NULL;
+
+ memset(thread_inf, 0, sizeof(thread_info_t));
+
+ thread_inf->busy = FALSE;
+ thread_inf->release = FALSE;
+ thread_inf->pri = THREAD_PRI_ABOVE_LEVEL;
+ thread_inf->launch_time = TIME_WAIT_INFINITE;
+ thread_inf->pool_status = pool_status;
+
+ init_condition_handle(&thread_inf->thread_cond);
+ init_mutex_handle(&thread_inf->thread_lock);
+
+ thread_inf->h_thread = pool_thread_create(pool_thread_work, thread_inf->pri, thread_inf);
+ if (thread_inf->h_thread < 0) {
+ destroy_condition_handle(&thread_inf->thread_cond);
+ mutex_destroy(&thread_inf->thread_lock);
+
+ free(thread_inf);
+ thread_inf = NULL;
+ }
+
+ return thread_inf;
+}
+
+
+void destroy_thread_info(thread_info_t *thread_info) {
+ if (thread_info == NULL)
+ return;
+
+ thread_info->release = TRUE;
+ pool_thread_release(thread_info->h_thread);
+
+ destroy_condition_handle(&thread_info->thread_cond);
+ mutex_destroy(&thread_info->thread_lock);
+}
+
+BOOL init_threadpool(thread_pool_t *pool) {
+
+ unsigned int thread_num = 0;
+ if (pool == NULL)
+ return FALSE;
+
+ pool->busy_threads = create_d_list();
+ pool->idle_threads = create_d_list();
+ pool->task_queue = create_seq_queue(sizeof(thread_func_t), TASK_QUEUE_COUNT_MAX, TRUE);
+ if (pool->busy_threads == NULL || pool->idle_threads == NULL || pool->task_queue == NULL)
+ goto err_flag;
+
+ for (thread_num=0; thread_num<pool->min_thread_num; thread_num++) {
+ thread_info_t *thread_inf = create_thread_info(&pool->status);
+
+ if (!insert_d_list_tail(pool->idle_threads, thread_inf, sizeof(thread_info_t)))
+ goto err_flag;
+
+ }
+
+ create_sem(&pool->sem_inc, TASK_QUEUE_COUNT_MAX);
+ init_condition_handle(&pool->manage_cond);
+ init_mutex_handle(&pool->mange_lock);
+ pool->h_id = pool_thread_create(pool_thread_manage, pool->pri, pool);
+
+ pool->status = EThread_pool_init;
+ pool->pool_thread_num = pool->min_thread_num;
+
+ return TRUE;
+
+
+err_flag:
+ LYDBGLOG("[%s-%d]##################### err ################\n", __FUNCTION__, __LINE__);
+ LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);
+ threadpool_destroy(pool);
+
+ return FALSE;
+}
+
+void threadpool_destroy(thread_pool_t *pool)
+{
+ d_list_node_t *temp_node;
+ if (pool == NULL)
+ return;
+
+ set_threadpool_status(pool, EThread_pool_exit);
+
+ destroy_sem(&pool->sem_inc);
+ mutex_lock(&pool->mange_lock);
+ post_condition_signal(&pool->manage_cond);
+ mutex_unlock(&pool->mange_lock);
+ pool_thread_release(pool->h_id);
+
+ mutex_destroy(&pool->mange_lock);
+ destroy_condition_handle(&pool->manage_cond);
+
+ while ((temp_node = remove_d_list_head_node(pool->idle_threads))) {
+ thread_info_t *info = (thread_info_t *)temp_node->data;
+ post_condition_signal(&info->thread_cond);
+ destroy_thread_info(info);
+ free(info);
+ free(temp_node);
+ }
+
+ while ((temp_node = remove_d_list_head_node(pool->busy_threads))) {
+ thread_info_t *info = (thread_info_t *)temp_node->data;
+ post_condition_signal(&info->thread_cond);
+ destroy_thread_info(info);
+ free(info);
+ free(temp_node);
+ }
+
+ destroy_d_list(pool->busy_threads);
+ destroy_d_list(pool->idle_threads);
+ destroy_seq_queue(pool->task_queue);
+
+ free(pool);
+}
+
+BOOL threadpool_add(thread_pool_t *pool, USER_FUNC process_func, void *args)
+{
+ BOOL ret = FALSE;
+ thread_func_t function;
+
+ if (pool == NULL)
+ return FALSE;
+
+ memset(&function, 0, sizeof(thread_func_t));
+ function.process_func = process_func;
+ function.args = args;
+
+ wait_sem(&pool->sem_inc);
+ ret = en_seq_queue(pool->task_queue, &function);
+
+ mutex_lock(&pool->mange_lock);
+ post_condition_signal(&pool->manage_cond);
+ mutex_unlock(&pool->mange_lock);
+
+ return ret;
+}
+
+BOOL threadpool_add_timeout(thread_pool_t *pool, USER_FUNC process_func
+ , USER_FUNC release_func, void *args, time_out_t *time_out)
+{
+ BOOL ret = FALSE;
+ thread_func_t function;
+
+ if (pool == NULL)
+ return FALSE;
+
+ memset(&function, 0, sizeof(thread_func_t));
+ function.process_func = process_func;
+ function.release_func = release_func;
+ function.args = args;
+ memcpy(&function.time_out_info, time_out, sizeof(time_out_t));
+
+ wait_sem(&pool->sem_inc);
+ ret = en_seq_queue(pool->task_queue, &function);
+
+ mutex_lock(&pool->mange_lock);
+ post_condition_signal(&pool->manage_cond);
+ mutex_unlock(&pool->mange_lock);
+
+ return ret;
+}
+
+
diff --git a/src/lynq/packages/apps/lynq-udpcli/lynq_udpcli.c b/src/lynq/packages/apps/lynq-udpcli/lynq_udpcli.c
new file mode 100644
index 0000000..de42922
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-udpcli/lynq_udpcli.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include<stdlib.h>
+#include <netinet/in.h>
+#include <strings.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+
+#define USER_LOG_TAG "UDPCLI"
+#define BUF_LEN 128
+#define ERR_CMDVALID 2
+#define ERR_SOCK 3
+#define SA struct sockaddr
+
+int main(int argc, const char *argv[])
+{
+ int sockfd;
+ char buf[BUF_LEN];
+
+
+ LYLOGEINIT(USER_LOG_TAG);
+ if(argc!=3)
+ {
+ LYDBGLOG("argv is wrong, please input ip and port\n");
+ LYVERBLOG("+[udpcli]: error num = %d\n", ERR_CMDVALID);
+ return ERR_CMDVALID;
+ }
+
+ sockfd=socket(AF_INET,SOCK_DGRAM,0);
+
+ if(sockfd<0)
+ {
+ LYDBGLOG("fail to sockfd\n");
+ return ERR_SOCK;
+ }
+
+ struct sockaddr_in seraddr;
+ seraddr.sin_family=AF_INET;
+ seraddr.sin_port=htons(atoi(argv[2]));
+ seraddr.sin_addr.s_addr=inet_addr(argv[1]);
+
+ int len=sizeof(seraddr);
+
+ while(1)
+ {
+ bzero(buf,sizeof(buf));
+
+ fgets(buf,sizeof(buf),stdin);
+
+ sendto(sockfd,buf,sizeof(buf),0,(SA *)&seraddr,len);
+
+ recvfrom(sockfd,buf,sizeof(buf),0,NULL,NULL);
+
+ LYVERBLOG("+[udpcli]: cli_rcv = %s\n",buf);
+ }
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-udpcli/makefile b/src/lynq/packages/apps/lynq-udpcli/makefile
new file mode 100644
index 0000000..7feab39
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-udpcli/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+
+
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -llynq-log \
+ -lssl \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-udpcli
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq-udpser/lynq_udpser.c b/src/lynq/packages/apps/lynq-udpser/lynq_udpser.c
new file mode 100644
index 0000000..fba98b0
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-udpser/lynq_udpser.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <strings.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "UDPSER"
+#define BUF_LEN 128
+#define ERR_SOCK 3
+#define SA struct sockaddr
+
+int main(int argc, const char *argv[])
+{
+ int sockfd;
+ char buf[128];
+
+ LYLOGEINIT(USER_LOG_TAG);
+ sockfd=socket(AF_INET,SOCK_DGRAM,0);
+
+ if(sockfd<0)
+ {
+ LYDBGLOG("fail to sockfd\n");
+ return -1;
+ }
+
+ struct sockaddr_in seraddr,peeraddr;
+ seraddr.sin_family=AF_INET;
+ seraddr.sin_port=htons(50000);
+
+ seraddr.sin_addr.s_addr=inet_addr("0.0.0.0");
+
+ int ret_bind;
+ ret_bind=bind(sockfd,(struct sockaddr *)&seraddr,sizeof(seraddr));
+
+ if(ret_bind<0)
+ {
+ LYDBGLOG("fail to bind\n");
+ return -1;
+ }
+
+ int len=sizeof(peeraddr);
+
+ while(1)
+ {
+ bzero(buf,sizeof(buf));
+
+ recvfrom(sockfd,buf,sizeof(buf),0,(struct sockaddr*)&peeraddr,&len);
+
+ LYVERBLOG("+[udpser]: ser_rcv = %s\n", buf);
+ sendto(sockfd,buf,sizeof(buf),0,(SA *)&peeraddr,len);
+ }
+ return 0;
+}
diff --git a/src/lynq/packages/apps/lynq-udpser/makefile b/src/lynq/packages/apps/lynq-udpser/makefile
new file mode 100644
index 0000000..06cf753
--- /dev/null
+++ b/src/lynq/packages/apps/lynq-udpser/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+
+
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -llynq-log \
+ -lssl \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-udpser
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/packages/apps/lynq_dbus_test/src/LICENSE b/src/lynq/packages/apps/lynq_dbus_test/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/packages/apps/lynq_dbus_test/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c b/src/lynq/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c
new file mode 100644
index 0000000..8a4ea04
--- /dev/null
+++ b/src/lynq/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c
@@ -0,0 +1,263 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+
+#define TEST_SERVICE "test.lynq" /*well-known bus name */
+#define TEST_DATA_INTERFACE "test.lynq.Data" /*interface name*/
+#define TEST_DATA_PATH "/test/lynq/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "TEST_CONTROL"
+int test_decrease (int a,int b,int select_argvi){
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ GMainLoop *loop;
+ gint32 set_result = -1;
+ RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE);
+ error = NULL;
+ c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ g_assert_no_error (error);
+ error = NULL;
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ TEST_SERVICE, //bus name
+ TEST_DATA_PATH, //object path
+ TEST_DATA_INTERFACE, // interface name
+ "reduce", // method name
+ g_variant_new ("(ii)", a,select_argvi), //parameters
+ G_VARIANT_TYPE ("(i)"), // return type
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+
+
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "(i)", &(set_result));
+ g_variant_unref (result);
+ RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+ //g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ return set_result;
+}
+
+int test_add (int a,int b,int select_argvi){
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ GMainLoop *loop;
+ gint32 set_result = -1;
+ RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE);
+ error = NULL;
+ c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ g_assert_no_error (error);
+ error = NULL;
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ TEST_SERVICE, //bus name
+ TEST_DATA_PATH, //object path
+ TEST_DATA_INTERFACE, // interface name
+ "add", // method name
+ g_variant_new ("(ii)", a,select_argvi), //parameters
+ G_VARIANT_TYPE ("(i)"), // return type
+ G_DBUS_CALL_FLAGS_NONE,
+ 30000,
+ NULL,
+ &error);
+
+
+
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "(i)", &(set_result));
+ g_variant_unref (result);
+ RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+ //g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ return set_result;
+}
+int test_call (int state,int select_argvi){
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ GMainLoop *loop;
+ gint32 set_result = -1;
+ RLOGD("select_argvi %d,start %s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE);
+ error = NULL;
+ c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ g_assert_no_error (error);
+ error = NULL;
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ TEST_SERVICE, //bus name
+ TEST_DATA_PATH, //object path
+ TEST_DATA_INTERFACE, // interface name
+ "callstate",// method name
+ g_variant_new ("(i)", state,select_argvi),//parameters
+ G_VARIANT_TYPE ("(i)"), // return type
+ G_DBUS_CALL_FLAGS_NONE,
+ 30000,
+ NULL,
+ &error);
+
+
+
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "(i)", &(set_result));
+ g_variant_unref (result);
+ RLOGD("%s, %s, %d,hgh %d,state:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+ //g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ return set_result;
+}
+
+/*
+static GVariantBuilder *
+get_platform_data (void){
+GVariantBuilder builder;
+GVariant *value;
+RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+ RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+g_variant_builder_add (&builder, "s", "when");
+g_variant_builder_add (&builder, "s", "in");
+g_variant_builder_add (&builder, "s", "the");
+g_variant_builder_add (&builder, "s", "course");
+RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+//value = g_variant_builder_end (&builder);
+return g_variant_builder_end (&builder);
+}
+
+void gvariant_test(){
+ GVariant *value;
+ GVariantIter *iter;
+ gchar *str;
+ g_variant_get (get_platform_data(), "as", &iter);
+ while (g_variant_iter_loop (iter, "s", &str))
+ RLOGD("%s, %s, %d,%s\n", __FILE__, __FUNCTION__, __LINE__,str);
+ g_variant_iter_free (iter);
+}
+void gvariant_test2(int a,int b,int select_argvi,GVariant*parameters){
+ test_add (a, b, select_argvi,parameters);
+}
+int test_add (int a,int b,int select_argvi){
+ //,GVariant*parameters){
+ GDBusConnection *c1;
+ GVariant *result;
+ GVariantBuilder builder;
+ GError *error;
+ GMainLoop *loop;
+ gint32 set_result = -1;
+ RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+ //if(parameters == NULL)
+ //RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE);
+ error = NULL;
+ c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ g_assert_no_error (error);
+ error = NULL;
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+ RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ g_variant_builder_add (&builder, "s", "when");
+ g_variant_builder_add (&builder, "s", "in");
+ g_variant_builder_add (&builder, "s", "the");
+ g_variant_builder_add (&builder, "s", "course");
+ result = g_dbus_connection_call_sync (c1,
+ TEST_SERVICE, //bus name
+ TEST_DATA_PATH, //object path
+ TEST_DATA_INTERFACE, // interface name
+ "add", // method name
+ g_variant_new ("(as)", builder), //parameters
+ G_VARIANT_TYPE ("(i)"), // return type
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+
+
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "(i)", &(set_result));
+ g_variant_unref (result);
+ RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+ //g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ return set_result;
+}
+*/
+int main(int agrc, char** argv)
+{
+ int select_argvi = 99;
+ if(argv[1] != NULL)
+ {
+ select_argvi = atoi(argv[1]);
+ }
+ for(int i=1;i<agrc;i++)
+ {
+ printf("initGDBus:%d\n",atoi(argv[i]));
+ }
+ if(select_argvi == 1)
+ {
+ for(int i=0;i<10000;i++)
+ {
+ //gvariant_test2(i,5,select_argvi,get_platform_data());
+ test_add(i,5,select_argvi);
+ //gvariant_test();
+ }
+ }
+ else if(select_argvi == 0)
+ {
+ for(int i=0;i<10000;i++)
+ {
+ //gvariant_test2(i,5,select_argvi,get_platform_data());
+ test_decrease(i,5,select_argvi);
+ //gvariant_test();
+ }
+ }
+ else if(select_argvi == 2)
+ {
+ for(int i=0;i<10;i++)
+ {
+ //gvariant_test2(i,5,select_argvi,get_platform_data());
+ test_call(i,select_argvi);
+ //gvariant_test();
+ }
+ }
+ else
+ {
+ RLOGD("other test");
+ }
+ while(1){sleep(10);}
+ return 0;
+}
+
diff --git "a/src/lynq/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp" "b/src/lynq/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/src/lynq/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ guint set_result = -1;
+ g_type_init();
+ loop = g_main_loop_new(NULL, FALSE); /** create main loop, but do not start it.*/
+ c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ GPIO_SERVICE, /* bus name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface name */
+ "setGpio", /* method name */
+ g_variant_new ("(sii)", mode,gpio_numb,param), /* parameters */
+ G_VARIANT_TYPE ("(i)"), /* return type */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "((i))", &(set_result));
+ g_variant_unref (result);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+ return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+ GDBusConnection *c1;
+ GVariant *result;
+ GError *error;
+ guint parm=0;
+ const gchar *set_result;
+ const gchar *mode ="gpio";
+ if(set_gpio(mode,gpio_numb,parm)== -1)
+ {
+ RLOGD("get_gpio number error");
+ return -1;
+ }
+ c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_assert (c1 != NULL);
+ g_assert (!g_dbus_connection_is_closed (c1));
+ result = g_dbus_connection_call_sync (c1,
+ GPIO_SERVICE, /* bus name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface name */
+ "getGpio", /* method name */
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(s)"), /* return type */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (result != NULL);
+ g_variant_get(result, "((s))", &(set_result));
+ RLOGD("get_gpio,%s",set_result);
+ g_variant_unref (result);
+ return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+ GError *error;
+
+ error = NULL;
+ proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+ if (proxy == NULL) {
+ RLOGE("create proxy fail");
+ return ;
+ }
+ RLOGD("proxy is ready");
+ gulong signal_handler_id;
+
+ // signal_handler_id = g_signal_connect(proxy, "g-signal",
+ // G_CALLBACK (proxy_signals_on_signal), NULL);
+ // if (signal_handler_id == 0) {
+ // RLOGE("listen singal fail!");
+ // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+ /* all the tests rely on a shared main loop */
+ loop = g_main_loop_new(NULL, FALSE);
+
+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL, /* GDBusInterfaceInfo */
+ GPIO_SERVICE, /* name */
+ GPIO_DATA_PATH, /* object path */
+ GPIO_DATA_INTERFACE, /* interface */
+ NULL, /* GCancellable */
+ proxy_ready,
+ NULL);
+
+ g_main_loop_run(loop);
+
+ RLOGD("data gdbus main loop run()");
+ if(proxy != NULL) {
+ g_object_unref (proxy);
+ }
+ if(loop != NULL) {
+ g_main_loop_unref(loop);
+ }
+}
+
+
+void startGdbusLoop(void)
+{
+ pthread_t gpioThread;
+
+ RLOGD("startGdbusLoop()");
+ // pthread_mutex_lock(&s_startupMutex);
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+ if (result != 0) {
+ RLOGW("Failed to create gdbus thread: %s", strerror(result));
+ //goto done;
+ }
+//done:
+ // pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/src/lynq/packages/apps/lynq_dbus_test/src/makefile b/src/lynq/packages/apps/lynq_dbus_test/src/makefile
new file mode 100644
index 0000000..652910a
--- /dev/null
+++ b/src/lynq/packages/apps/lynq_dbus_test/src/makefile
@@ -0,0 +1,66 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -D__LINUX_OS__ \
+ -DECALL_SUPPORT
+
+CXXFLAGS = -fpermissive
+LOCAL_PATH = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH) \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/vendor-ril \
+ -I$(ROOT)$(includedir)/gstreamer-1.0 \
+ -I$(ROOT)$(includedir)/glib-2.0 \
+ -I$(ROOT)$(libdir)/glib-2.0/include \
+ -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+ -I$(ROOT)$(includedir)/dbus-1.0 \
+ -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lsncfg \
+ -lcutils \
+ -lutils \
+ -lpthread \
+ -lpal \
+ -lglib-2.0 \
+ -lgobject-2.0 \
+ -lgio-2.0 \
+ -lapn \
+ -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq_dbus_test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+ $(warning ----->build $<)
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)