Add basic change for v1453
Change-Id: I9497a61bbc3717f66413794a4e7dee0347c0bc33
diff --git a/mbtk/liblynq_lib_rilv2/lynq_fota.c b/mbtk/liblynq_lib_rilv2/lynq_fota.c
new file mode 100755
index 0000000..9b12656
--- /dev/null
+++ b/mbtk/liblynq_lib_rilv2/lynq_fota.c
@@ -0,0 +1,113 @@
+#include "lynq-qser-fota.h"
+#include "mbtk_type.h"
+#include "mbtk_fota.h"
+#include "mbtk_log.h"
+
+
+char addr_buf[128]={0};
+int segment_size =0;
+
+
+int Process_flag = 0;
+
+
+int fota_cb(int status, int percent)
+{
+ LOGE("%d: percent: %d%%\n", percent/10, percent);
+ Process_flag = percent/10;
+ return 0;
+}
+
+int lynq_read_process(void)
+{
+ return Process_flag;
+}
+
+int lynq_rock_main(int first_run)
+{
+ UNUSED(first_run);
+ LOGE("%s, %d", __FUNCTION__, __LINE__);
+ int ret = 0;
+
+ LOGE("addr_buf:%s, segment_size:%d\n", addr_buf, segment_size);
+ ret = mbtk_fota_init(fota_cb);
+ if(strncmp(addr_buf, "http", 4) == 0)
+ {
+
+ ret = mbtk_fota_fw_write_by_url(addr_buf, segment_size,10, 600);
+ }
+ else
+ {
+ ret =mbtk_fota_fw_write(addr_buf, segment_size);
+ }
+
+ if(ret)
+ {
+ LOGE("lynq_rock_main fail\n");
+ return -1;
+ }
+
+ mbtk_fota_done1(1);
+
+
+ return 0;
+}
+
+int lynq_fota_set_addr_value(char *value,int size)
+{
+ UNUSED(value);
+ UNUSED(size);
+ LOGE("%s, %d", __FUNCTION__, __LINE__);
+
+ if(value == NULL)
+ {
+ return -1;
+ }
+
+ memset(addr_buf, 0, sizeof(addr_buf));
+ memcpy(addr_buf, value, strlen(value));
+ segment_size = size;
+
+ LOGE("addr_buf:%s, value:%s\n", addr_buf, value);
+ LOGE("segment_size:%d, size:%d\n", segment_size, size);
+
+ return 0;
+}
+
+int lynq_fota_nrestart(void)
+{
+ LOGE("%s, %d", __FUNCTION__, __LINE__);
+ int ret = 0;
+
+ LOGE("addr_buf:%s", addr_buf);
+ ret = mbtk_fota_init(fota_cb);
+ if(strncmp(addr_buf, "http", 4) == 0)
+ {
+ ret = mbtk_fota_fw_write_by_url(addr_buf, segment_size,10, 600);
+ }
+ else
+ {
+ ret =mbtk_fota_fw_write(addr_buf, segment_size);
+ }
+
+ if(ret)
+ {
+ LOGE("lynq_fota_nrestart fail\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int lynq_get_upgrade_status(void)
+{
+ LOGE("%s, %d", __FUNCTION__, __LINE__);
+
+ return mbtk_fota_status();
+}
+
+int lynq_get_reboot_upgrade_status(void)
+{
+ return mbtk_fota_get_asr_reboot_cnt_flag();
+}
+