blob: eb0afc7decb84e848eed335e325d7caf92d83dbe [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include <sys/types.h>
6#include <errno.h>
7#include <fcntl.h>
LUOJian60136c32023-11-24 13:59:45 +08008#include "mbtk_fota.h"
liubin281ac462023-07-19 14:22:54 +08009
liubin281ac462023-07-19 14:22:54 +080010
11int ql_fota_init(fota_callback cb)
12{
LUOJian60136c32023-11-24 13:59:45 +080013 return mbtk_fota_init(cb);
liubin281ac462023-07-19 14:22:54 +080014}
15
liubin281ac462023-07-19 14:22:54 +080016/*******************************************************************************
17* @brief write firmware package, the firmware package is written in segments.
18 and The result of the write is output by calling the callback function.
19 the firmware package size must less than 32MB
20 @param
21 fname: firmware package file
22 segment_size: the length of once write, recommending 3*1024*1024 bytes
23 @return
24 if success return 0, else return -1
25 *******************************************************************************/
26int ql_fota_fw_write(char* fname, int segment_size)
27{
LUOJian60136c32023-11-24 13:59:45 +080028 return mbtk_fota_fw_write(fname, segment_size);
liubin281ac462023-07-19 14:22:54 +080029}
30
31
32/*******************************************************************************
33* @brief download firmware by url, and write firmware package, the firmware
34 package is written in segments. The result of the write is output by
35 calling the callback function. the firmware package size must less than
36 32MB
37 @param
38 url: [IN] the address of download firmware package file, the url
39 support http or https protocol.
40 segment_size: [IN] the length of once write, recommending 3*1024*1024 bytes
41 conn_timeout: [IN] timeout to connect to the server, if set 0 that means
42 switch to the default build-in connection timeout(300s)
43 download_timeout: [IN] timeout for download the firmware file. if set 0 that means
44 it never time out
45 @return
46 if success return 0, else return -1
47 *******************************************************************************/
48int ql_fota_fw_write_by_url(char* url, int segment_size,
49 int conn_timeout, int download_timeout)
50{
LUOJian60136c32023-11-24 13:59:45 +080051 return mbtk_fota_fw_write_by_url(url, segment_size,conn_timeout, download_timeout);
liubin281ac462023-07-19 14:22:54 +080052}
53/*******************************************************************************
54* @brief reboot system and clear env
55 @param
56 is_reboot: if set 1, after fota success, reboot system
57 @return
58 if success return 0, else return -1
59 *******************************************************************************/
60int ql_fota_done(int is_reboot)
61{
luojian7f418ae2024-05-30 10:24:01 +080062 return mbtk_fota_done1(is_reboot);
liubin281ac462023-07-19 14:22:54 +080063}