led: add led api

Change-Id: I6d124e6ad583e897adb22371cac6a695eec3b0cb
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index a0f09d3..f5b6c4d 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -473,6 +473,20 @@
     uint32_t        oosPhase[3];   //单位为秒      
 } mbtk_oos_info;
 
+/**************led enum*********/
+typedef enum
+{
+    MBTK_LED_TYPE_NET,       //set net_led
+    MBTK_LED_TYPE_STATUS     //set status_led
+}mbtk_led_type;
+
+typedef enum
+{
+    MBTK_LED_STATUS_CLOSE,       //close led
+    MBTK_LED_STATUS_OPEN     //open led
+}mbtk_led_status;
+/**************led enum*********/
+
 mbtk_info_handle_t* mbtk_info_handle_get();
 
 int mbtk_info_handle_free(mbtk_info_handle_t** handle);
@@ -911,6 +925,8 @@
 //set dtmf character
 int mbtk_dtmf_send(mbtk_info_handle_t* handle, mbtk_call_dtmf_info_t *dtmf_character);
 
+//set led
+int mbtk_led_set(mbtk_info_handle_t* handle, mbtk_led_type type, mbtk_led_status status);
 /*
 * Set pdp state change callback function.
 */
diff --git a/mbtk/lynq_lib/src/lynq_net_light.c b/mbtk/lynq_lib/src/lynq_net_light.c
index 34394af..0d59348 100755
--- a/mbtk/lynq_lib/src/lynq_net_light.c
+++ b/mbtk/lynq_lib/src/lynq_net_light.c
@@ -1,17 +1,138 @@
 #include "lynq_led.h"
 #include "mbtk_type.h"
+#include "mbtk_log.h"
+#include "mbtk_info_api.h"
 
+/****************************DEFINE***************************************/
+#define QSER_RESULT_FAIL    -1
+#define QSER_RESULT_SUCCESS 0
+/****************************DEFINE***************************************/
+
+/****************************VARIABLE***************************************/
+extern mbtk_info_handle_t* qser_info_handle;
+extern int qser_info_handle_num;
+/****************************VARIABLE***************************************/
+
+
+/******************************FUNC*****************************************/
+static int qser_led_client_init(void)
+{
+    if(qser_info_handle == NULL)
+    {
+        qser_info_handle = mbtk_info_handle_get();
+        if(qser_info_handle)
+        {
+            qser_info_handle_num++;
+        } 
+        else
+        {
+            LOGE("[qser_led] mbtk_info_handle_get() fail.");
+            return QSER_RESULT_FAIL;
+        }
+    }
+    else
+    {
+        qser_info_handle_num++;
+    }
+
+    LOGE("[qser_led] mbtk_info_handle_get() success.");
+    return QSER_RESULT_SUCCESS;
+}
+
+static int qser_led_client_deinit(void)
+{
+    if(qser_info_handle)
+    {
+        LOGE("[qser_led] qser_info_handle_num = %d", qser_info_handle_num);
+        if(qser_info_handle_num == 1)
+        { // 最后一个引用,可释放。
+            int ret = mbtk_info_handle_free(&qser_info_handle);
+            if(ret)
+            {
+                LOGE("[qser_led] mbtk_info_handle_free() fail.");
+                return QSER_RESULT_FAIL;
+            }
+            else
+            {
+                qser_info_handle_num = 0;
+                qser_info_handle = NULL;
+            }
+        } 
+        else
+        {
+            qser_info_handle_num--;
+        }
+    }
+    else
+    {
+        LOGE("[qser_led] handle not inited.");
+        return QSER_RESULT_FAIL;
+    }
+
+    return QSER_RESULT_SUCCESS;
+}
+
+/******************************FUNC*****************************************/
+
+/****************************API***************************************/
 int lynq_set_netled_on(int led_mode)
 {
-    UNUSED(led_mode);
+    //UNUSED(led_mode);
 
-    return 0;
+    if(led_mode != 0 && led_mode != 1)
+    {
+        LOGE("[qser_led]param is fail.");
+        return QSER_RESULT_FAIL;
+    }
+
+    
+    int ret = qser_led_client_init();
+    if(ret != QSER_RESULT_SUCCESS)
+    {
+        LOGE("[qser_led]qser_led_client_init fail.");
+        return QSER_RESULT_FAIL;
+    }
+
+    ret = mbtk_led_set(qser_info_handle, MBTK_LED_TYPE_NET, led_mode);
+    if(ret != 0)
+    {
+        LOGE("[qser_led]mbtk_led_gpio_init fail.");
+        return QSER_RESULT_FAIL;
+    }
+
+    ret = qser_led_client_init();
+    
+    return QSER_RESULT_SUCCESS;
 }
 
 int lynq_set_statusled_on(int led_mode)
 {
-    UNUSED(led_mode);
+    //UNUSED(led_mode);
 
-    return 0;
+    if(led_mode != 0 && led_mode != 1)
+    {
+        LOGE("[qser_led]param is fail.");
+        return QSER_RESULT_FAIL;
+    }
+    
+    int ret = qser_led_client_init();
+    if(ret != QSER_RESULT_SUCCESS)
+    {
+        LOGE("[qser_led]qser_led_client_init fail.");
+        return QSER_RESULT_FAIL;
+    }
+
+    ret = mbtk_led_set(qser_info_handle, MBTK_LED_TYPE_STATUS, led_mode);
+    if(ret != 0)
+    {
+        LOGE("[qser_led]mbtk_led_gpio_init fail.");
+        return QSER_RESULT_FAIL;
+    }
+
+    ret = qser_led_client_init();
+    
+    return QSER_RESULT_SUCCESS;
 }
+/****************************API***************************************/
+
 
diff --git a/mbtk/mbtk_lib/inc/mbtk_info.h b/mbtk/mbtk_lib/inc/mbtk_info.h
index 1f035be..2f3b491 100755
--- a/mbtk/mbtk_lib/inc/mbtk_info.h
+++ b/mbtk/mbtk_lib/inc/mbtk_info.h
@@ -229,6 +229,12 @@
     MBTK_INFO_ID_OOS_STA_RSP,
 
     MBTK_INFO_ID_OOS_STA_END,
+	
+	//led
+    MBTK_INFO_ID_LED_BEGIN = 8000,
+    MBTK_INFO_ID_LED_REQ,
+    MBTK_INFO_ID_LED_RSP,
+    MBTK_INFO_ID_LED_END,
 
     // IND Information
     MBTK_INFO_ID_IND_BEGIN = 10000,
diff --git a/mbtk/mbtk_lib/src/mbtk_info.c b/mbtk/mbtk_lib/src/mbtk_info.c
index cdef2b2..ce870c8 100755
--- a/mbtk/mbtk_lib/src/mbtk_info.c
+++ b/mbtk/mbtk_lib/src/mbtk_info.c
@@ -293,6 +293,10 @@
         case MBTK_INFO_ID_PB_STATE_REQ:
         case MBTK_INFO_ID_PB_STATE_RSP:
             return "PB_STATE";
+        //led
+        case MBTK_INFO_ID_LED_REQ:
+        case MBTK_INFO_ID_LED_RSP:
+            return "LED";
         // IND Information
         // <uint8>  State
         case MBTK_INFO_ID_IND_NET_STATE_CHANGE:
@@ -430,6 +434,8 @@
             info_id == MBTK_INFO_ID_SMS_END ||
             info_id == MBTK_INFO_ID_PB_BEGIN ||
             info_id == MBTK_INFO_ID_PB_END ||
+            info_id == MBTK_INFO_ID_LED_BEGIN ||
+            info_id == MBTK_INFO_ID_LED_END ||
             info_id == MBTK_INFO_ID_WAKEUP_STA_BEGIN ||
             info_id == MBTK_INFO_ID_WAKEUP_STA_END ||
             info_id == MBTK_INFO_ID_OOS_STA_BEGIN ||
diff --git a/mbtk/mbtk_lib/src/mbtk_info_api.c b/mbtk/mbtk_lib/src/mbtk_info_api.c
index cae9d27..05b803a 100755
--- a/mbtk/mbtk_lib/src/mbtk_info_api.c
+++ b/mbtk/mbtk_lib/src/mbtk_info_api.c
@@ -2171,6 +2171,39 @@
 }
 
 /*
+* Set net led.
+*
+*/
+int mbtk_led_set(mbtk_info_handle_t* handle, mbtk_led_type type, mbtk_led_status status)
+{
+    if(handle == NULL)
+    {
+        LOGE("ARG error.");
+        return -1;
+    }
+
+    char buff[3] = {0};
+    if(type == MBTK_LED_TYPE_NET)
+    {
+        buff[0] = 0;
+    }
+    else
+    {
+        buff[0] = 1;
+    }
+
+    if(status == MBTK_LED_STATUS_CLOSE)
+    {
+        buff[1] = 0;
+    }
+    else
+    {
+        buff[1] = 1;
+    }
+    return info_item_process(handle, MBTK_INFO_ID_LED_REQ, buff, 2, NULL) ? handle->info_err : 0;
+}
+
+/*
 * Set pdp state change callback function.
 */
 int mbtk_pdp_state_change_cb_reg(mbtk_info_handle_t* handle, mbtk_info_callback_func cb)
diff --git a/mbtk/mbtk_ril/inc/mbtk_led.h b/mbtk/mbtk_ril/inc/mbtk_led.h
new file mode 100644
index 0000000..9d7996d
--- /dev/null
+++ b/mbtk/mbtk_ril/inc/mbtk_led.h
@@ -0,0 +1,29 @@
+#ifndef __MBTK_LED_H__
+#define __MBTK_LED_H__
+
+typedef enum
+{
+    MBTK_STATUS_LED_CLOSE = 0,     /*close status_led*/
+    MBTK_STATUS_LED_OPEN           /*open status_led*/
+}mbtk_status_led_type;
+
+typedef enum
+{
+    MBTK_NET_LED_SEARCH_NETWORK = 0,/*Searching the network or talking on the phone*/
+    MBTK_NET_LED_DATA_CONNECT,       /*Data connection successful*/
+    MBTK_NET_LED_NET_CONNECT,        /*Network connection successful*/
+    MBTK_NET_LED_POWER,               /*Turn off */
+    MBTK_NET_LED_SLEEP,             /* sleep */
+    MBTK_NET_LED_CLOSE,            /*close net_led*/
+    MBTK_NET_LED_OPEN              /*open net_led*/
+}mbtk_net_led_type;
+
+void mbtk_net_led_set(mbtk_net_led_type status);
+
+int status_led_set(mbtk_status_led_type status);
+
+int mbtk_led_init(void);
+
+#endif
+
+
diff --git a/mbtk/mbtk_ril/src/main.c b/mbtk/mbtk_ril/src/main.c
index 4ed52ce..eeabc7c 100755
--- a/mbtk/mbtk_ril/src/main.c
+++ b/mbtk/mbtk_ril/src/main.c
@@ -25,6 +25,7 @@
 #include "mbtk_ntp.h"

 #include "mbtk_net_control.h"

 #include "info_data.h"

+#include "mbtk_led.h"

 

 #define TEMP_FAILURE_RETRY(exp) ({         \

     typeof (exp) _rc;                      \

@@ -419,6 +420,14 @@
             data[1] = 0;  // GMS/WCDMA

         } else {

             data[1] = 1;  // LTE

+            if(data[0] == 1)

+            {

+                mbtk_net_led_set(MBTK_NET_LED_NET_CONNECT);

+            }

+            else

+            {

+                mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);

+            }

         }

 

         urc_msg_distribute(true, INFO_URC_MSG_NET_PS_REG_STATE, data, sizeof(data));

@@ -1804,6 +1813,10 @@
         LOGE("mbtk_info_server_start() fail.");

         return -1;

     }

+    

+#ifdef MBTK_PROJECT_T108

+    mbtk_led_init();

+#endif 

 

 #if 0

     if(uevent_main())

diff --git a/mbtk/mbtk_ril/src/mbtk_info_server.c b/mbtk/mbtk_ril/src/mbtk_info_server.c
index 861c64b..3fc1a86 100755
--- a/mbtk/mbtk_ril/src/mbtk_info_server.c
+++ b/mbtk/mbtk_ril/src/mbtk_info_server.c
@@ -19,6 +19,7 @@
 #include "mbtk_utils.h"
 #include "mbtk_ifc.h"
 #include "info_data.h"
+#include "mbtk_led.h"
 
 static int sock_listen_fd = -1;
 static int epoll_fd = -1;
@@ -5306,7 +5307,45 @@
                 }
                 break;
             }
+			case MBTK_INFO_ID_LED_REQ:
+            {
+                 if(pack->data_len == 0 || pack->data == NULL)
+                {
+                    err = MBTK_INFO_ERR_UNSUPPORTED;
+                    LOGE("led param is error.");
+                }
+                else
+                {
+                    char type = pack->data[0];
+                    char status = pack->data[1];
+                    LOGE("[set_led] = [%d], [status_led] = [%d].", type, status);
 
+                    if(type == MBTK_LED_TYPE_NET)
+                    {
+                        if(status == MBTK_LED_STATUS_CLOSE)
+                        {
+                            mbtk_net_led_set(MBTK_NET_LED_CLOSE);
+                        }
+                        else
+                        {
+                            mbtk_net_led_set(MBTK_NET_LED_OPEN);
+                        }
+                    }
+                    else
+                    {
+                        if(status == MBTK_LED_STATUS_CLOSE)
+                        {
+                            status_led_set(MBTK_STATUS_LED_CLOSE);
+                        }
+                        else
+                        {
+                            status_led_set(MBTK_STATUS_LED_OPEN);
+                        }
+                    }
+                    pack_rsp_send(cli_info->fd, MBTK_INFO_ID_LED_RSP, NULL, 0);
+                }
+                break;
+            }
             default:
             {
                 err = MBTK_INFO_ERR_REQ_UNKNOWN;
diff --git a/mbtk/mbtk_ril/src/mbtk_led.c b/mbtk/mbtk_ril/src/mbtk_led.c
new file mode 100644
index 0000000..5c11d5e
--- /dev/null
+++ b/mbtk/mbtk_ril/src/mbtk_led.c
@@ -0,0 +1,294 @@
+#if 1
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
+#include <string.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "mbtk_led.h"
+#include "mbtk_log.h"
+
+/****************************DEFINE***************************************/
+#define MBTK_RESULT_FAIL   -1
+#define MBTK_RESULT_SUCCESS 0
+
+#define MBTK_NET_LED 99
+#define MBTK_STATUS_LED 8
+/****************************DEFINE***************************************/
+
+/****************************VARIABLE***************************************/
+static mbtk_net_led_type mbtk_net_led_state = MBTK_NET_LED_SEARCH_NETWORK;
+static mbtk_net_led_type mbtk_net_led_prev_state = MBTK_NET_LED_SEARCH_NETWORK;
+static mbtk_status_led_type mbtk_status_led_state = MBTK_STATUS_LED_CLOSE;
+/****************************VARIABLE***************************************/
+
+/******************************FUNC*****************************************/
+int mbtk_read_ccinet(void) 
+{
+    FILE *fp;
+    int ret = 0;
+    char buffer[1024]; 
+    char type[10]={0};
+    
+    fp = popen("ifconfig", "r"); 
+    if (fp == NULL) {
+        printf("popen fail\n");
+        return -1;
+    }
+  
+    fread(buffer,1, sizeof(buffer) -1, fp);
+    //LOGE("[led]buffer:%s\n", buffer);
+    pclose(fp); // 
+
+    char *p1 = strstr(buffer, "ccinet");
+    if(p1 == NULL)
+    {
+    	LOGE("[led]read ccinet is null\n");
+    	return -1;
+    }
+
+    return 0;
+}
+
+int mbtk_net_led_get(void)
+{
+    if(mbtk_net_led_state == MBTK_NET_LED_OPEN)
+    {
+        mbtk_net_led_state = mbtk_net_led_prev_state;
+    }
+
+    int ret = -1;
+    if(mbtk_net_led_state == MBTK_NET_LED_NET_CONNECT)
+    {
+        ret = mbtk_read_ccinet();
+        if(ret == 0)
+        {
+            mbtk_net_led_state = MBTK_NET_LED_DATA_CONNECT;
+        }
+    }
+    return mbtk_net_led_state;
+}
+
+void mbtk_net_led_set(mbtk_net_led_type status)
+{
+    if(mbtk_net_led_state == MBTK_NET_LED_CLOSE)
+    {
+        if(status == MBTK_NET_LED_CLOSE || status == MBTK_NET_LED_OPEN)
+        {
+            //
+        }
+        else
+        {
+            mbtk_net_led_prev_state = status;
+        }
+    }
+    else
+    {
+        if(status == MBTK_NET_LED_CLOSE)
+        {
+            mbtk_net_led_prev_state = mbtk_net_led_state;
+        }
+    }
+
+    mbtk_net_led_state = status;
+}
+
+static int mbtk_led_gpio_init(int gpio)
+{
+    char buffer[50]= {0};
+    char pin_index_buffer[5]= {0};
+    int fd =-1;
+    int result = -1;
+
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio);
+    if(access(buffer , F_OK) != 0)
+    {
+        fd = open("/sys/class/gpio/export",O_WRONLY);
+        if(fd < -1)
+        {
+            LOGE("[led]Open export fail.", gpio);
+            return MBTK_RESULT_FAIL;
+        }
+
+        memset(pin_index_buffer,0,5);
+        sprintf(pin_index_buffer,"%d", gpio);
+        result = write(fd,pin_index_buffer,strlen(pin_index_buffer));
+        close(fd);
+        if(result < 0)
+        {
+            LOGE("[led]Gpio[%d] export fail.", gpio);
+            return MBTK_RESULT_FAIL;
+        }
+        fd = -1;
+    }
+
+    fd = open(buffer, O_WRONLY);
+    if(fd < -1)
+    {
+        LOGE("[led]Open gpio[%d] direct fail.", gpio);
+        return MBTK_RESULT_FAIL;
+    }
+
+    result = write(fd, "out",strlen("out"));
+    close(fd);
+    if(result < 0)
+    {
+        LOGE("[led]Set gpio[%d] direct fail.", gpio);
+        return MBTK_RESULT_FAIL;
+    }
+    return MBTK_RESULT_SUCCESS;
+}
+
+static int mbtk_led_gpio_level_set(int gpio, int value)
+{
+    char buffer[50]= {0};
+    int fd =-1;
+    int result =-1;
+
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/value", gpio);
+    fd = open(buffer,O_WRONLY);
+    if(fd < -1)
+    {
+        LOGE("[led]Open gpio[%d] value fail.", gpio);
+        return MBTK_RESULT_FAIL;
+    }
+    if(value == 0)
+    {
+        result = write(fd,"0",1);
+    }
+    else
+    {
+        result = write(fd,"1",1);
+    }
+    close(fd);
+    
+    if(result != 1)
+    {
+        LOGE("[led]Set gpio[%d] value fail.", gpio);
+        return MBTK_RESULT_FAIL;
+    }
+
+    return MBTK_RESULT_SUCCESS;
+}
+
+static void net_led_close(void)
+{
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 0);
+}
+
+static void net_led_open(void)
+{
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 1);
+}
+
+static void net_led_flicker_200ms(void)
+{
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 1);
+    usleep(200);
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 0);
+    usleep(200);
+}
+
+static void net_led_flicker_800ms(void)
+{
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 1);
+    usleep(800);
+    mbtk_led_gpio_level_set(MBTK_NET_LED, 0);
+    usleep(800);
+}
+
+static void* net_led_thread_run(void* arg)
+{
+    mbtk_net_led_type status = MBTK_NET_LED_CLOSE;
+    while(1)
+    {
+        status = mbtk_net_led_get();
+        //LOGE("[led] get net led status = [%d].", status);
+        switch(status)
+        {
+            case MBTK_NET_LED_CLOSE:
+            case MBTK_NET_LED_POWER:
+            {
+                net_led_close();
+                sleep(2);
+                break;
+            }
+            case MBTK_NET_LED_SEARCH_NETWORK:
+            {
+                net_led_open();
+                sleep(2);
+                break;
+            }
+            case MBTK_NET_LED_DATA_CONNECT:
+            {
+                net_led_flicker_200ms();
+                break;
+            }
+            case MBTK_NET_LED_NET_CONNECT:
+            {
+                net_led_flicker_800ms();
+                break;
+            }
+            default:
+            {
+                LOGE("[led]Uknown status.");
+                break;
+            }
+        }
+
+        sleep(1);
+    }
+    return NULL;
+}
+
+int status_led_set(mbtk_status_led_type status)
+{
+    int ret = MBTK_RESULT_FAIL;
+    ret = mbtk_led_gpio_level_set(MBTK_STATUS_LED, status);
+    if(ret != MBTK_RESULT_SUCCESS)
+    {
+        LOGE("[led]set status led fail.");
+        return MBTK_RESULT_FAIL;
+    }
+
+    mbtk_status_led_state = status;
+    return MBTK_RESULT_SUCCESS;
+}
+
+
+int mbtk_led_init(void)
+{
+    int ret = MBTK_RESULT_FAIL;
+
+    mbtk_led_gpio_init(MBTK_STATUS_LED);
+    mbtk_led_gpio_init(MBTK_NET_LED);
+    status_led_set(MBTK_STATUS_LED_OPEN);
+    mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);
+
+    pthread_attr_t thread_attr;
+    pthread_t net_led_thread_id;
+    pthread_t status_led_thread_id;
+    pthread_attr_init(&thread_attr);
+    if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
+    {
+        LOGE("[led] pthread_attr_setdetachstate() fail.");
+        return MBTK_RESULT_FAIL;
+    }
+
+    if(pthread_create(&net_led_thread_id, &thread_attr, net_led_thread_run, NULL))
+    {
+        LOGE("[led] pthread_create() fail.");
+        return MBTK_RESULT_FAIL;
+    }
+
+    pthread_attr_destroy(&thread_attr);
+    return MBTK_RESULT_SUCCESS;
+}
+/******************************FUNC*****************************************/
+
+#endif
diff --git a/mbtk/test/asr1806/qser_led_test.c b/mbtk/test/asr1806/qser_led_test.c
new file mode 100644
index 0000000..00edbde
--- /dev/null
+++ b/mbtk/test/asr1806/qser_led_test.c
@@ -0,0 +1,100 @@
+#include <stdio.h>
+#include <strings.h>
+#include<stdlib.h>
+
+#include "lynq_led.h"
+
+void user_help(void)
+{
+    printf("\t-1 exit\n"
+           "\t1 open net led\n"
+           "\t2 close net led \n"
+           "\t3 open status led\n"
+           "\t4 close status led\n"
+           "please input operator: >> \n");
+}
+
+
+int main(int argc, const char *argv[])
+{
+    int ret;
+    int opt = 0;
+    while(1)
+    {
+        printf("=========gnss main=========\n");
+        user_help();
+        scanf("%d", &opt);
+        switch (opt)
+        {
+            case -1:
+            {
+                printf("main exit\n");
+                return 0;
+            }
+            case 1:
+            {
+                ret = lynq_set_netled_on(1);
+                if(ret)
+                {
+                    printf("[%s-%d] lynq_set_netled_on error\n", __FUNCTION__, __LINE__);
+                    return -1;
+                }
+                else
+                {
+                    printf("open net led success.\n");
+                }
+                break;
+            }
+            case 2:
+            {
+                ret = lynq_set_netled_on(0);
+                if(ret)
+                {
+                    printf("[%s-%d] lynq_set_netled_on error\n", __FUNCTION__, __LINE__);
+                    return -1;
+                }
+                else
+                {
+                    printf("close net led success.\n");
+                }
+                break;
+            }
+            case 3:
+            {
+                ret = lynq_set_statusled_on(1);
+                if(ret)
+                {
+                    printf("[%s-%d] lynq_set_statusled_on error\n", __FUNCTION__, __LINE__);
+                    return -1;
+                }
+                else
+                {
+                    printf("open status led success.\n");
+                }
+                break;
+            }
+            case 4:
+            {
+                ret = lynq_set_statusled_on(0);
+                if(ret)
+                {
+                    printf("[%s-%d] lynq_set_statusled_on error\n", __FUNCTION__, __LINE__);
+                    return -1;
+                }
+                else
+                {
+                    printf("close status led success.\n");
+                }
+                break;
+            }
+            default:
+            {
+                printf("opt unkuown\n");
+                break;
+            }
+        }
+    }
+    
+    return 0;
+}
+