Merge "[Bugfix][T106BUG-271]when using demo input error num,will endless loop"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
index ed8ca40..612d968 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
@@ -139,6 +139,87 @@
     pull_sel : 0 - bias disable 1 - pull down 2 - pull up

     test_gpio_handle[gpio]:gpio handle get by init

 */

+void lynq_handle_gpioset(char *input)

+{

+/*1.gpio_num 0-135

+  2.direction_set //0 - in; 1 - out

+  3.value_set  

+  4.pullsel_set // 0 - bias disable; 1 - pull down; 2 - pull up

+*/

+    input = input + strlen("gpioset");

+    int gpio_configure[4];

+    int k = 0;

+    for (int i = 0; i < strlen(input) ; i++)

+    {

+        int num = 0;

+        for (; input[i] != ',' && input[i] != '\0'; i++)

+        {

+            if (input[i] >= '0' && input[i] <= '9')

+            {

+                num = num * 10 + (input[i] - '0');

+            }

+            else

+            {

+                handle_output("+GPIOSET:input error\r\n", strlen("+GPIOSET:input error\r\n"), Response);

+                lynq_response_error(100);

+                return;

+            }

+        }

+        if(k >= 4)

+        {

+            handle_output("+GPIOSET:Too many parameters\r\n", strlen("+GPIOSET:Too many parameters\r\n"), Response);

+            lynq_response_error(100);

+            return;

+        }

+        gpio_configure[k] = num;

+        k++;

+    }

+

+    int gpio = gpio_configure[0];

+    if(gpio < 0 || gpio > 135)

+    {

+        lynq_response_error(1);

+        return;

+    }

+    int direction_set = gpio_configure[1];

+    if(direction_set != 0 && direction_set != 1)

+    {

+        lynq_response_error(2);

+        return;

+    }

+    int value_set = gpio_configure[2];

+    if(value_set != 0 && value_set != 1)

+    {

+        lynq_response_error(3);

+        return;

+    }

+    int pullsel_set = gpio_configure[3];

+    if(pullsel_set != 0 && pullsel_set != 1 && pullsel_set != 2)

+    {

+        lynq_response_error(4);

+        return;

+    }

+

+    int ret;

+    test_gpio_handle[gpio] = sc_gpio_init(gpio, direction_set, value_set, pullsel_set);

+    if(test_gpio_handle[gpio] == NULL)

+    {

+        ALOGE("init%d fail\n",gpio);

+        lynq_response_error(100);

+        return;

+    }

+    ret = sc_gpio_uninit(test_gpio_handle[gpio]);

+    if(ret)

+    {

+        ALOGE("uninit%d fail\n",gpio);

+        lynq_response_error(100);

+        return;

+    }

+    test_gpio_handle[gpio] = NULL;

+    lynq_response_ok();

+    return;

+}

+

 int lynq_gpio_analysis(char *input,int *lynq_gpio_arr,int lynq_gpio_total_arr[],int total_length)

 {

     int j = 0;

@@ -747,6 +828,7 @@
 {

     {"adc",lynq_handle_adc},

     {"emmc",lynq_handle_emmc},

+    {"gpioset",lynq_handle_gpioset},

     {"gpio",lynq_handle_gpio},

     {"rmii",lynq_handle_rgmii},

     {"sdio",lynq_handle_sdio},