liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | #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> |
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 8 | #include "mbtk_fota.h" |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 9 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 10 | |
| 11 | int ql_fota_init(fota_callback cb) |
| 12 | { |
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 13 | return mbtk_fota_init(cb); |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 14 | } |
| 15 | |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 16 | /******************************************************************************* |
| 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 | *******************************************************************************/ |
| 26 | int ql_fota_fw_write(char* fname, int segment_size) |
| 27 | { |
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 28 | return mbtk_fota_fw_write(fname, segment_size); |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 29 | } |
| 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 | *******************************************************************************/ |
| 48 | int ql_fota_fw_write_by_url(char* url, int segment_size, |
| 49 | int conn_timeout, int download_timeout) |
| 50 | { |
LUOJian | 60136c3 | 2023-11-24 13:59:45 +0800 | [diff] [blame] | 51 | return mbtk_fota_fw_write_by_url(url, segment_size,conn_timeout, download_timeout); |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 52 | } |
| 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 | *******************************************************************************/ |
| 60 | int ql_fota_done(int is_reboot) |
| 61 | { |
luojian | 7f418ae | 2024-05-30 10:24:01 +0800 | [diff] [blame] | 62 | return mbtk_fota_done1(is_reboot); |
liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 63 | } |