[fota] add lynq_fota function

Change-Id: I2ed8d4e1383692424c0b36be5c583b635190ea0d
diff --git a/mbtk/mbtk_lib/src/mbtk_fota.c b/mbtk/mbtk_lib/src/mbtk_fota.c
index a26e2a6..424f64d 100755
--- a/mbtk/mbtk_lib/src/mbtk_fota.c
+++ b/mbtk/mbtk_lib/src/mbtk_fota.c
@@ -29,8 +29,10 @@
 static struct blob_buf b;

 static fota_callback fota_cb = NULL;

 sem_t sem;

-volatile int fota_dowload_flag = 0;

-

+volatile int fota_dowload_flag = -1;

+//3: upding

+//4: updata success

+//5: updata fail

 

 enum {

 	ATTR_SMSGPS,

@@ -96,17 +98,17 @@
 	notify_str = blobmsg_get_string(tb[ATTR_SMSGPS]);

     len = strlen(notify_str);

     fota_log("%s : %s\r\n", __FUNCTION__, notify_str);

-    printf("L11111%s : %s\r\n", __FUNCTION__, notify_str);

+//    printf("L11111%s : %s\r\n", __FUNCTION__, notify_str);

     if (strstr_n(notify_str, "start")) {

         fota_cb(0, 0);

     } else if (strstr_n(notify_str, "end[1]")) {

         fota_cb(0, 100);

-        fota_dowload_flag = 1;

+        fota_dowload_flag = 4;

 //        sem_post(&sem);

         printf("download firmware success!\r\n");

     } else if (strstr_n(notify_str, "end[0]")) {

         fota_cb(1, 100);

-        fota_dowload_flag = 2;

+        fota_dowload_flag = 5;

 //        sem_post(&sem);

         printf("download firmware fail!\r\n");

     }

@@ -140,7 +142,7 @@
  *******************************************************************************/

 int mbtk_fota_fw_write(char* fname, int segment_size)

 {

-    fota_dowload_flag =  0;

+    fota_dowload_flag =  3;

     printf("mbtk_fota_fw_write start2\n");

     int L = 1;

     int ret = -1;

@@ -162,23 +164,23 @@
     {

         if(L == 1)

         {

-            printf("%s, L:%d", __FUNCTION__,L);

+         //   printf("%s, L:%d", __FUNCTION__,L);

             L++;

         }

         /* V2¨´¡Á¡Â */

 //        sem_wait(&sem);

 //        break;

 

-        if(fota_dowload_flag != 0)

+        if(fota_dowload_flag != 3)

         {

-            printf("break while(), fota_dowload_flag:%d", fota_dowload_flag);

+       //     printf("break while(), fota_dowload_flag:%d", fota_dowload_flag);

             break;

         }

     }

 #endif

-    printf("%s, L:%d, fota_dowload_flag = :%d", __FUNCTION__,L, fota_dowload_flag);

-    printf("mbtk_fota_fw_write end \n");

-    if(fota_dowload_flag == 1)

+//    printf("%s, L:%d, fota_dowload_flag = :%d", __FUNCTION__,L, fota_dowload_flag);

+//    printf("mbtk_fota_fw_write end \n");

+    if(fota_dowload_flag == 4)

     {

         ret = 0;

     }

@@ -206,7 +208,7 @@
 {

     printf("mbtk_fota_fw_write_by_url start1\n");

     int ret = -1, L = 1;

-    fota_dowload_flag =  0;

+    fota_dowload_flag =  3;

     static struct ubus_request req;

     int _segment_size;

     blob_buf_init(&b, 0);

@@ -226,23 +228,23 @@
     {

         if(L == 1)

         {

-            printf("%s, L:%d", __FUNCTION__,L);

+      //      printf("%s, L:%d", __FUNCTION__,L);

             L++;

         }

         /* V2¨´¡Á¡Â */

 //        sem_wait(&sem);

 //        break;

 

-        if(fota_dowload_flag != 0)

+        if(fota_dowload_flag != 3)

         {

-            printf("break while(), fota_dowload_flag:%d", fota_dowload_flag);

+       //     printf("break while(), fota_dowload_flag:%d", fota_dowload_flag);

             break;

         }

     }

 

-    printf("%s, L:%d, fota_dowload_flag = :%d", __FUNCTION__,L, fota_dowload_flag);

-    printf("mbtk_fota_fw_write_by_url end \n");

-    if(fota_dowload_flag == 1)

+ //   printf("%s, L:%d, fota_dowload_flag = :%d", __FUNCTION__,L, fota_dowload_flag);

+ //   printf("mbtk_fota_fw_write_by_url end \n");

+    if(fota_dowload_flag == 4)

     {

         ret = 0;

     }

@@ -287,6 +289,16 @@
         system("reboot");

     }

     return 0;

+

+}

+

+int mbtk_fota_done1(int is_reboot)

+{

+    if (is_reboot) {

+        system("sync");

+        system("reboot");

+    }

+    return 0;

 }

 

 void* mbtk_fota_thread(void* argc)

@@ -351,3 +363,9 @@
     return 1;

 }

 

+int mbtk_fota_status(void)

+{

+    return fota_dowload_flag;

+}

+

+