blob: fab1d487f147ee1f00f5e59d30397fd551da0af9 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001/**
2 @file
3 ql_fota.h
4
5 @brief
6 This file provides the definitions for device, and declares the
7 API functions.
8
9*/
10/*============================================================================
11 Copyright (c) 2017 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
12 Quectel Wireless Solution Proprietary and Confidential.
13 =============================================================================*/
14/*===========================================================================
15
16 EDIT HISTORY FOR MODULE
17
18This section contains comments describing changes made to the module.
19Notice that changes are listed in reverse chronological order.
20
21
22WHEN WHO WHAT, WHERE, WHY
23---------- ------------ ----------------------------------------------------
2408/11/2019 baron.qian create
25=============================================================================*/
26#ifndef __QL_FOTA_H__
27#define __QL_FOTA_H__
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33enum {
34 QUEC_FOTA_OK, /*OK*/
35 QUEC_FOTA_FAILED /*failed*/
36}QL_FOTA_STATUS;
37
38/*callback function define, used to get upgrade state and rate of process*/
39typedef int(*fota_callback)(int state, int percent);
40
41/*******************************************************************************
42* @brief fota initialize
43 @param
44
45 fota_callback: callback function
46 @return
47 if success return 0, else return -1
48 *******************************************************************************/
49int ql_fota_init(fota_callback cb);
50
51/*******************************************************************************
52* @brief write firmware package, the firmware package is written in segments.
53 and The result of the write is output by calling the callback function.
54 the firmware package size must less than 32MB
55 @param
56 fname: firmware package file
57 segment_size: the length of once write, recommending 3*1024*1024 bytes
58 @return
59 if success return 0, else return -1
60 *******************************************************************************/
61int ql_fota_fw_write(char *fname, int segment_size);
62
63
64/*******************************************************************************
65* @brief download firmware by url, and write firmware package, the firmware
66 package is written in segments. The result of the write is output by
67 calling the callback function. the firmware package size must less than
68 32MB
69 @param
70 url: [IN] the address of download firmware package file, the url
71 support http or https protocol.
72 segment_size: [IN] the length of once write, recommending 3*1024*1024 bytes
73 conn_timeout: [IN] timeout to connect to the server, if set 0 that means
74 switch to the default build-in connection timeout(300s)
75 download_timeout: [IN] timeout for download the firmware file. if set 0 that means
76 it never time out
77 @return
78 if success return 0, else return -1
79 *******************************************************************************/
80int ql_fota_fw_write_by_url(char *url, int segment_size, int conn_timeout, int download_timeout);
81
82
83/*******************************************************************************
84* @brief reboot system and clear env
85 @param
86 is_reboot: if set 1, after fota success, reboot system
87 @return
88 if success return 0, else return -1
89 *******************************************************************************/
90int ql_fota_done(int is_reboot);
91
92#ifdef __cplusplus
93}
94#endif
95#endif //__QL_FOTA_H__