24 #ifndef __AIOT_OTA_API_H__    25 #define __AIOT_OTA_API_H__    27 #if defined(__cplusplus)   243     aiot_download_recv_type_t 
type;
   592 int32_t 
aiot_ota_setopt(
void *handle, aiot_ota_option_t option, 
void *data);
   716 #define STATE_OTA_BASE                                              (-0x0900)   722 #define STATE_OTA_DIGEST_MATCH                                      (-0x0901)   728 #define STATE_OTA_REPORT_FAILED                                     (-0x0902)   734 #define STATE_DOWNLOAD_RECV_ERROR                                   (-0x0903)   744 #define STATE_OTA_DIGEST_MISMATCH                                   (-0x0904)   754 #define STATE_OTA_PARSE_JSON_ERROR                                  (-0x0905)   764 #define STATE_DOWNLOAD_SEND_REQUEST_FAILED                          (-0x0906)   774 #define STATE_DOWNLOAD_RANGE_FINISHED                               (-0x0907)   780 #define STATE_OTA_PARSE_JSON_MALLOC_FAILED                          (-0x0908)   786 #define STATE_OTA_DEINIT_HANDLE_IS_NULL                             (-0x0909)   792 #define STATE_OTA_SETOPT_HANDLE_IS_NULL                             (-0x090A)   798 #define STATE_OTA_SETOPT_DATA_IS_NULL                               (-0x090B)   804 #define STATE_DOWNLOAD_DEINIT_HANDLE_IS_NULL                        (-0x090C)   810 #define STATE_DOWNLOAD_SETOPT_HANDLE_IS_NULL                        (-0x090D)   816 #define STATE_DOWNLOAD_SETOPT_DATA_IS_NULL                          (-0x090E)   822 #define STATE_DOWNLOAD_SETOPT_COPIED_DATA_IS_NULL                   (-0x090F)   828 #define STATE_OTA_REPORT_HANDLE_IS_NULL                             (-0x0910)   834 #define STATE_OTA_REPORT_VERSION_IS_NULL                            (-0x0911)   840 #define STATE_OTA_REPORT_MQTT_HANDLE_IS_NULL                        (-0x0912)   846 #define STATE_OTA_REPORT_EXT_HANELD_IS_NULL                         (-0x0913)   852 #define STATE_OTA_REPORT_EXT_VERSION_NULL                           (-0x0914)   858 #define STATE_OTA_REPORT_EXT_PRODUCT_KEY_IS_NULL                    (-0x0915)   864 #define STATE_OTA_REPORT_EXT_DEVICE_NAME_IS_NULL                    (-0x0916)   870 #define STATE_OTA_REPORT_EXT_MQTT_HANDLE_IS_NULL                    (-0x0917)   876 #define STATE_DOWNLOAD_REPORT_HANDLE_IS_NULL                        (-0x0918)   882 #define STATE_DOWNLOAD_REPORT_TASK_DESC_IS_NULL                     (-0x0919)   888 #define STATE_DOWNLOAD_RECV_HANDLE_IS_NULL                          (-0x091A)   894 #define STATE_DOWNLOAD_REQUEST_HANDLE_IS_NULL                       (-0x091B)   900 #define STATE_DOWNLOAD_REQUEST_TASK_DESC_IS_NULL                    (-0x091C)   906 #define STATE_DOWNLOAD_REQUEST_URL_IS_NULL                          (-0x091D)   912 #define STATE_OTA_UNKNOWN_DIGEST_METHOD                             (-0x091E)   918 #define STATE_DOWNLOAD_FINISHED                                     (-0x091F)   924 #define STATE_DOWNLOAD_HTTPRSP_CODE_ERROR                           (-0x0920)   930 #define STATE_DOWNLOAD_HTTPRSP_HEADER_ERROR                         (-0x0921)   936 #define STATE_DOWNLOAD_RENEWAL_REQUEST_SENT                         (-0x0922)   942 #define STATE_DOWNLOAD_SETOPT_MALLOC_SHA256_CTX_FAILED              (-0x0923)   948 #define STATE_DOWNLOAD_SETOPT_MALLOC_MD5_CTX_FAILED                 (-0x0924)   954 #define STATE_OTA_PARSE_URL_HOST_IS_NULL                            (-0x0925)   960 #define STATE_OTA_PARSE_URL_PATH_IS_NULL                            (-0x0926)   968 #define STATE_DOWNLOAD_FETCH_TOO_MANY                               (-0x0927)   977 #define STATE_OTA_QUERY_FIRMWARE_HANDLE_IS_NULL                     (-0x0928)   985 #define STATE_OTA_HOST_STRING_OVERFLOW                              (-0x0929)   993 #define STATE_OTA_PATH_STRING_OVERFLOW                              (-0x092A)   995 #if defined(__cplusplus) 下载固件过程中收到的分片的报文的描述, 包括类型, 以及所存储的buffer地址, buffer的长度, 以及当前的下载进度 
Definition: aiot_ota_api.h:237
 
设置按照range下载的结束地址 
Definition: aiot_ota_api.h:470
 
设置处理OTA消息的用户回调函数 
Definition: aiot_ota_api.h:329
 
uint8_t * buffer
下载固件过程中, SDK分配出来的存储云端下行的固件内容的buffer地址.在回调函数结束后SDK就会主动释放.用户需要自行将报文拷贝保存. 
Definition: aiot_ota_api.h:251
 
void * aiot_ota_init()
创建一个OTA实例 
Definition: aiot_ota_api.c:64
 
与云端约定的设备下载出错的错误码描述 
Definition: aiot_ota_api.h:295
 
aiot_download_recv_type_t
下载固件过程中收到的分片的报文的类型 
Definition: aiot_ota_api.h:224
 
设置download实例句柄所包含下载任务的具体内容 
Definition: aiot_ota_api.h:444
 
uint32_t file_num
ota任务中总共的url数量 
Definition: aiot_ota_api.h:179
 
与云端约定的设备升级出错的错误描述 
Definition: aiot_ota_api.h:290
 
char * extra_data
当前下载信息中的扩展内容 
Definition: aiot_ota_api.h:169
 
设置按照range下载的起始地址 
Definition: aiot_ota_api.h:457
 
Definition: aiot_ota_api.h:94
 
char * device_name
待升级设备的device_name 
Definition: aiot_ota_api.h:113
 
与云端约定的烧写固件出错的错误码描述 
Definition: aiot_ota_api.h:305
 
下载OTA文件的方式为HTTPS 
Definition: aiot_ota_api.h:87
 
下载OTA文件的方式为MQTT 
Definition: aiot_ota_api.h:93
 
void(* aiot_ota_recv_handler_t)(void *handle, const aiot_ota_recv_t *const msg, void *userdata)
设备收到OTA的mqtt下行报文时的接收回调函数.用户在这个回调函数中可以看到待升级固件的版本号, 决定升级策略(是否升级, 何时升级等) 
Definition: aiot_ota_api.h:218
 
int32_t percent
当前的下载进度的百分比 
Definition: aiot_ota_api.h:263
 
用户需要SDK暂存的上下文 
Definition: aiot_ota_api.h:351
 
int32_t aiot_ota_setopt(void *handle, aiot_ota_option_t option, void *data)
设置ota句柄的参数 
Definition: aiot_ota_api.c:115
 
aiot_ota_recv_type_t
云端下行的OTA消息的类型, 分为固件升级和远程配置两种 
Definition: aiot_ota_api.h:40
 
HTTP 数据接收回调函数 
Definition: aiot_ota_api.h:420
 
uint32_t file_id
当前下载任务的序号 
Definition: aiot_ota_api.h:184
 
uint8_t digest_method
Definition: aiot_ota_api.h:140
 
uint32_t len
下载固件过程中, SDK分配出来的存储云端下行的固件内容的buffer的大小, 用户可以通过AIOT_DLOPT_BODY_BUFFER...
Definition: aiot_ota_api.h:257
 
aiot_ota_protocol_type_t
OTA下载升级文件的方式 
Definition: aiot_ota_api.h:81
 
通过HTTP接收固件内容时, 在协议栈花费的最长时间 
Definition: aiot_ota_api.h:411
 
aiot_download_option_t
调用 aiot_download_setopt 接口时, option参数的可用值 
Definition: aiot_ota_api.h:372
 
设备通过HTTP与固件服务器建联时, 网络使用的安全凭据 
Definition: aiot_ota_api.h:391
 
int32_t aiot_download_deinit(void **handle)
释放download实例句柄的资源 
Definition: aiot_ota_api.c:201
 
云端下行的OTA消息, 包括其消息类型(固件升级/远程配置)和升级任务的具体描述 
Definition: aiot_ota_api.h:196
 
当设备从固件下载服务器接收返回的http报文时, 每次从 aiot_download_recv_handler_t 回调函数中给出的body...
Definition: aiot_ota_api.h:480
 
设置MQTT的handle 
Definition: aiot_ota_api.h:340
 
与云端约定的固件校验数字签名时出错的错误码描述 
Definition: aiot_ota_api.h:300
 
收到的OTA固件的digest方法为SHA256 
Definition: aiot_ota_api.h:72
 
aiot_ota_digest_type_t
OTA过程中使用的digest方法类型, 分为MD5和SHA256两种 
Definition: aiot_ota_api.h:60
 
int32_t aiot_download_send_request(void *handle)
向云端发送GET固件报文请求 
Definition: aiot_ota_api.c:929
 
char * version
固件的版本信息. 如果为固件信息, 则这个version字段为固件的版本号. 如果为远程配置消息, 则为配置的configId 
Definition: aiot_ota_api.h:152
 
Definition: aiot_ota_api.h:73
 
aiot_ota_option_t
调用 aiot_ota_setopt 接口时, option参数的可用值 
Definition: aiot_ota_api.h:313
 
char * file_name
Definition: aiot_ota_api.h:174
 
char * expect_digest
Definition: aiot_ota_api.h:146
 
收到的OTA消息为固件升级消息 
Definition: aiot_ota_api.h:46
 
void(* aiot_download_recv_handler_t)(void *handle, const aiot_download_recv_t *packet, void *userdata)
升级开始后, 设备收到分成一段段的固件内容时的收包回调函数.当前默认是通过https报文下推分段后的固件内容...
Definition: aiot_ota_api.h:277
 
int32_t aiot_ota_report_version_ext(void *handle, char *product_key, char *device_name, char *version)
用于网关中的子设备上报版本号 
Definition: aiot_ota_api.c:366
 
如果当前ota是针对某个外接模块(mcu等), 需要通过该字段设置模块名 
Definition: aiot_ota_api.h:363
 
uint32_t size_total
Definition: aiot_ota_api.h:134
 
设备通过HTTP访问固件下载服务器的端口号 
Definition: aiot_ota_api.h:402
 
aiot_download_task_desc_t * task_desc
云端下推的固件升级任务的描述信息, 包括url, 大小, 签名等, 更多信息参考aiot_download_task_desc_t ...
Definition: aiot_ota_api.h:206
 
uint32_t stream_id
Definition: aiot_ota_api.h:124
 
aiot_ota_protocol_errcode_t
与云端约定的OTA过程中的错误码, 云端据此知道升级过程中出错在哪个环节 
Definition: aiot_ota_api.h:285
 
aiot_ota_protocol_type_t protocol_type
下载ota文件的协议 
Definition: aiot_ota_api.h:188
 
char * product_key
待升级设备的product_key 
Definition: aiot_ota_api.h:107
 
int32_t aiot_download_report_progress(void *handle, int32_t percent)
上报下载完成度的百分比或者错误码 
Definition: aiot_ota_api.c:436
 
int32_t aiot_ota_report_version(void *handle, char *version)
上报普通设备(非网关中的子设备)的版本号 
Definition: aiot_ota_api.c:326
 
int32_t aiot_ota_query_firmware(void *handle)
设备端主动向云端查询升级任务 
Definition: aiot_ota_api.c:405
 
用户需要SDK暂存的上下文 
Definition: aiot_ota_api.h:431
 
aiot_download_recv_type_t type
下载固件过程中收到的分片的报文的类型, 具体见aiot_download_recv_type_t 
Definition: aiot_ota_api.h:243
 
收到的OTA消息为远程配置消息 
Definition: aiot_ota_api.h:52
 
云端下推的固件升级任务的描述信息, 包括url, 大小, 签名等 
Definition: aiot_ota_api.h:101
 
int32_t aiot_download_recv(void *handle)
通过download实例句柄下载一段buffer 
Definition: aiot_ota_api.c:475
 
int32_t aiot_download_setopt(void *handle, aiot_download_option_t option, void *data)
设置download句柄参数 
Definition: aiot_ota_api.c:235
 
Definition: aiot_ota_api.h:481
 
aiot_ota_recv_type_t type
云端下行的OTA消息类型, 更多信息请参考aiot_ota_recv_type_t 
Definition: aiot_ota_api.h:201
 
收到的OTA固件的digest方法为MD5 
Definition: aiot_ota_api.h:66
 
void * mqtt_handle
*固件升级过程中需用往云端上报消息时需要用到的mqtt句柄 
Definition: aiot_ota_api.h:163
 
char * module
当前固件所都对应的模块 
Definition: aiot_ota_api.h:158
 
Definition: aiot_ota_api.h:364
 
uint32_t stream_file_id
Definition: aiot_ota_api.h:129
 
int32_t aiot_ota_deinit(void **handle)
销毁ota实例句柄 
Definition: aiot_ota_api.c:85
 
基于HTTP传输的固件分片报文 
Definition: aiot_ota_api.h:230
 
void * aiot_download_init()
初始化download实例并设置默认参数 
Definition: aiot_ota_api.c:161
 
char * url
Definition: aiot_ota_api.h:119