[feature]lynq-low-power

Change-Id: I7aeaced1cc3680d73556f29b8c9cabdf39d6ad61
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb.bak b/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb.bak
deleted file mode 100755
index f38b1ad..0000000
--- a/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb.bak
+++ /dev/null
@@ -1,26 +0,0 @@
-SUMMARY = "Lynq Package Group - MT2731"
-LICENSE = "MediaTekProprietary"
-
-inherit packagegroup
-
-RDEPENDS_packagegroup-lync-mt2731 = "\
-    lynq-system-service \     
-    liblynq-driver-control \
-    lynq-broadcast-receive \
-    lynq-broadcast-send \
-    liblynq-protcl \
-    lynq-tcpcli \
-    lynq-tcpser \
-    lynq-udpcli \
-    lynq-udpser \
-    liblynq-log \
-	liblynq-fota \
-	liblynq-sim \
-	liblynq-data \
-    lynq-function-test \
-	logrotate \
-	lynq-logrotate-service \
-	lynq-konoda-rock \
-    lynq-atsvc \
-    liblynq-logdata-handle \
-"
diff --git a/src/lynq/lib/liblynq-sim/include/lynq_sim.h b/src/lynq/lib/liblynq-sim/include/lynq_sim.h
index 846a1ec..c35ee8f 100755
--- a/src/lynq/lib/liblynq-sim/include/lynq_sim.h
+++ b/src/lynq/lib/liblynq-sim/include/lynq_sim.h
@@ -30,6 +30,14 @@
 int lynq_get_imei(char buf[]);
 
 /**
+ * @brief Radio on/off
+ * 
+ * @param data  0/1 0 is off, 1 is on
+ * @return int 
+ */
+int lynq_factory_radio(const int data);
+
+/**
  * @brief                   Request SIM I/O operation.
  *                          This is similar to the TS 27.007 "restricted SIM" operation
  *                          where it assumes all of the EF selection will be done by the callee.
diff --git a/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp b/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
index 1c9e500..84e0c3f 100755
--- a/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
+++ b/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
@@ -33,6 +33,7 @@
 #define RIL_REQUEST_OEM_HOOK_RAW 59
 #define RIL_REQUEST_SCREEN_STATE 61
 #define RIL_REQUEST_SIM_IO 28
+#define RIL_REQUEST_RADIO_POWER 23
 #define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL 8008
 #define MAX_LEN 1024*8
 #define MAX_NUM 10
@@ -796,6 +797,27 @@
     }
     return error1;
 }
+
+int lynq_factory_radio(const int data){
+    int ret = -1;
+    if(!judge(data))
+        return ret;
+    int send_num = 0;
+    char res_data[MAX_LEN] = {0};
+    int len = 0; 
+    client_t.request = RIL_REQUEST_RADIO_POWER;
+    client_t.paramLen = 1;
+    client_t.uToken = Global_uToken;
+    sprintf(client_t.param, "%d\n", data);
+    send_num = sendto(sock_fd, &client_t, sizeof(client_t), 0, (struct sockaddr *)&addr_serv, len_addr_serv);
+    if(send_num < 0)  
+    {  
+        RLOGD("sendto error:");  
+        return send_num;
+    }
+    return 0;
+}
+
 #if FLAG_TESS
 int lynq_query_operator(char buf[]){
     int32_t token = -1;
diff --git a/src/lynq/packages/apps/lynq-low-power/src/main.cpp b/src/lynq/packages/apps/lynq-low-power/src/main.cpp
index c2822aa..4b057b6 100755
--- a/src/lynq/packages/apps/lynq-low-power/src/main.cpp
+++ b/src/lynq/packages/apps/lynq-low-power/src/main.cpp
@@ -1,53 +1,34 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <pthread.h>
 #include <include/lynq_sim.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/*Quick accept array*/
-void * thread_test(void * arg)
-{
-    FILE *fp;
-    char buf[1024*3] = {0};
-    sprintf(buf, "echo 11 | emdlogger_ctrl 2>&1");
-    fp=popen(buf, "r");
-    if(!fp){
-        perror("popen:");
-    }
-    while(fgets(buf, 4072, fp) != NULL){}
-    pclose(fp);
-    return 0;
-}
+/**
+ * @brief only for factory test:flight mode
+ * 
+ * @return int 
+ */
 
 int main(void){
     lynq_sim_init(2022);
-    pthread_t thid = -1;
-    int ret = pthread_create(&thid, NULL, thread_test, NULL);
-    if(ret != 0){
-        printf("pthread_create error!!!");
-        return ret;
-    }
+    system("echo 11 | emdlogger_ctrl");
+    sleep(1);
     system("mdlogctl stop");
-    system("echo mem > /sys/power/autosleep");
     system("echo 0 > /dev/wmtWifi");
     system("echo 7 9 0 > /proc/driver/wmt_dbg");
-    /*Notify the modem to disable some URC reporting */
-    ret = lynq_screen(0);
-    printf("ret %d\n", ret);
-    /*Notify the modem to disable some URC reporting */
-    system("disown -a");
-    if(thid == -1)
-    {
-        return -1;
-    }
-    ret = pthread_join(thid,NULL);
-    if(ret != 0){
-        printf("pthread_join error!!!");
-        return ret;
-    }
+    sleep(1);
+    lynq_switch_card(1);
+    sleep(1);
+    lynq_factory_radio(0);
+    sleep(3);
+    lynq_switch_card(0);
+    sleep(1);
+    lynq_factory_radio(0);
+    sleep(3);
+    system("echo mem > /sys/power/autosleep");
     return 0;
 }
 #ifdef __cplusplus