Link Kit C-SDK  4.0.0
aiot_mqtt_upload_api.h
浏览该文件的文档.
1 
8 #ifndef __AIOT_MQTT_UPLOAD_API_H__
9 #define __AIOT_MQTT_UPLOAD_API_H__
10 
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14 
18 #define STATE_MQTT_UPLOAD_BASE (-0x2100)
19 
23 #define STATE_MQTT_UPLOAD_MQTT_HANDLE_IS_NULL (-0x2101)
24 
29 #define STATE_MQTT_UPLOAD_FILENAME_IS_NULL (-0x2102)
30 
35 #define STATE_MQTT_UPLOAD_PARAMS_IS_NULL (-0x2103)
36 
41 #define STATE_MQTT_UPLOAD_FILE_DATA_IS_NULL (-0x2104)
42 
46 #define STATE_MQTT_UPLOAD_MQTT_SYSDEP_IS_NULL (-0x2105)
47 
51 #define STATE_MQTT_UPLOAD_PARSE_INIT_FAILED (-0x2106)
52 
56 #define STATE_MQTT_UPLOAD_PARSE_UPLOAD_REPLY_FAILED (-0x2107)
57 
61 #define STATE_MQTT_UPLOAD_PARSE_CANCEL_FAILED (-0x2108)
62 
66 #define STATE_MQTT_UPLOAD_PARSE_JSON_FAILED (-0x2109)
67 
71 #define STATE_MQTT_UPLOAD_RECV_FILE_INFO_ERROR (-0x210A)
72 
76 #define STATE_MQTT_UPLOAD_RECV_UPLOADID_ERROR (-0x210B)
77 
81 #define STATE_MQTT_UPLOAD_MALLOC_FAILED (-0x210C)
82 
86 #define STATE_MQTT_UPLOAD_UPTASK_IS_NULL (-0x210D)
87 
91 #define STATE_MQTT_UPLOAD_UPLOAD_REPLY_ERROR (-0x210E)
92 
96 #define STATE_MQTT_UPLOAD_HANDLE_DEINIT (-0x210F)
97 
101 #define STATE_MQTT_UPLOAD_FILE_RESTART_FAILED (-0x2110)
102 
107 #define STATE_MQTT_UPLOAD_BLOCK_SIZE_ERROR (-0x2111)
108 
113 #define STATE_MQTT_UPLOAD_READ_DATA_HANDLER_IS_NULL (-0x2112)
114 
118 #define STATE_MQTT_UPLOAD_HANDLE_INIT (-0x2113)
119 
123 #define STATE_MQTT_UPLOAD_PROCESS_REPLY_ERROR (-0x2114)
124 
129 #define STATE_MQTT_UPLOAD_NONE (-0x2115)
130 
135 #define STATE_MQTT_UPLOAD_REQUEST_INIT (-0x2116)
136 
141 #define STATE_MQTT_UPLOAD_IS_UPLOADING (-0x2117)
142 
147 #define STATE_MQTT_UPLOAD_REQUEST_CANCEL (-0x2118)
148 
153 #define STATE_MQTT_UPLOAD_CANCEL_SUCCESS (-0x2119)
154 
159 #define STATE_MQTT_UPLOAD_CANCEL_FAILED (-0x2120)
160 
165 #define STATE_MQTT_UPLOAD_FAILED (-0x2121)
166 
171 #define STATE_MQTT_UPLOAD_FAILED_TIMEOUT (-0x2122)
172 
177 #define STATE_MQTT_UPLOAD_FAILED_MESSAGE_LIGMIT (-0x2123)
178 
183 #define STATE_MQTT_UPLOAD_FAILED_WHOLE_CHECK (-0x2124)
184 
189 #define STATE_MQTT_UPLOAD_FINISHED (-0x2125)
190 
195 #define STATE_MQTT_UPLOAD_NO_UPLOAD_TASK (-0x2126)
196 
201 #define STATE_MQTT_UPLOAD_OPEN_INIT_FAILED (-0x2127)
202 
206 #define AIOT_MQTT_UPLOAD_FILE_MODE_OVERWRITE "overwrite"
207 
215 #define AIOT_MQTT_UPLOAD_FILE_MODE_APPEND "append"
216 
220 #define AIOT_MQTT_UPLOAD_FILE_MODE_FAIL "reject"
221 
225 #define MQTT_UPLOAD_DEFAULT_FILENAME_LEN (128)
226 
231 typedef enum {
237 
243 
249 
255 
261 
267 
273 
279 
285 
291 
297 
303 
309 
315 
321 
327 
329 
333 typedef enum {
350 
355 typedef struct {
360  char *file_name;
361 
365  uint32_t file_size;
366 
371  char *upload_id;
372 
376  uint32_t file_offset;
377 
381  uint32_t block_size;
382 
387 
391  char *message;
392 
396  uint8_t complete;
397 
399 
403 typedef struct {
408  aiot_mqtt_upload_recv_type_t type;
409 
416 
423 typedef enum {
424 
430 
435 
440 
445 
450 
452 
457 typedef struct
458 {
463  int32_t code;
464 
470 
472 
473 
487 typedef int32_t (*aiot_mqtt_upload_read_handler_t)(const aiot_mqtt_upload_recv_t *packet, uint8_t *data, uint32_t size, void *userdata);
488 
497 void *aiot_mqtt_upload_init(void);
498 
513 int32_t aiot_mqtt_upload_setopt(void *handle, aiot_mqtt_upload_option_t option, void *data);
514 
525 int32_t aiot_mqtt_upload_deinit(void **handle);
526 
547 int32_t aiot_mqtt_upload_open_stream(void *handle, char *file_name, uint32_t file_size,
548  const char *mode, void *digest, aiot_mqtt_upload_read_handler_t read_data_handler, void *userdata);
549 
561 int32_t aiot_mqtt_upload_cancel_stream(void *handle, char *file_name);
562 
582 
583 #if defined(__cplusplus)
584 }
585 #endif
586 
587 #endif /* __AIOT_MQTT_UPLOAD_API_H__ */
588 
MQTT UPLOAD模块收到服务端应答的报文信息, 通知用户的报文内容
Definition: aiot_mqtt_upload_api.h:403
文件上传正常
Definition: aiot_mqtt_upload_api.h:236
申请使用mqtt协议上传文件时,文件大小超过阈值16M
Definition: aiot_mqtt_upload_api.h:266
aiot_mqtt_upload_recv_type_t
MQTT UPLOAD模块收到从服务端应答的报文类型
Definition: aiot_mqtt_upload_api.h:333
uint8_t complete
服务端应答文件上传完成后才有的应答,complete true: 文件上传成功,false: 文件上传失败 ...
Definition: aiot_mqtt_upload_api.h:396
配置文件上传的分片长度,默认是2048byte, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:444
文件上传请求参数错误
Definition: aiot_mqtt_upload_api.h:254
设置MQTT的最大值,设置失败
Definition: aiot_mqtt_upload_api.h:449
uint32_t file_offset
已经上传文件的偏移量,偏移量的是相对于文件开始的起始点算起,可以用于回调函数中读取新分片文件的偏移量 ...
Definition: aiot_mqtt_upload_api.h:376
#define MQTT_UPLOAD_DEFAULT_FILENAME_LEN
MQTT上传文件名的最大长度
Definition: aiot_mqtt_upload_api.h:225
请求上传的payload格式非法,无法解析其中的json格式数据
Definition: aiot_mqtt_upload_api.h:242
uint32_t file_size
对应上传文件的总长度,用户调用 aiot_mqtt_upload_open_stream 传入的文件大小
Definition: aiot_mqtt_upload_api.h:365
接收到的服务端应答消息的报文信息
Definition: aiot_mqtt_upload_api.h:355
服务端其他异常
Definition: aiot_mqtt_upload_api.h:260
设备上传文件分片时,当前分片的offset与已上传至的服务端文件大小不一致
Definition: aiot_mqtt_upload_api.h:278
int32_t code
通过MQTT通过上传的情况
Definition: aiot_mqtt_upload_api.h:463
关联MQTT Handle会话,UPLOAD过程中使用MQTT的通道能力, 用以向服务端请求上传、发送分片文件、请求关闭通道...
Definition: aiot_mqtt_upload_api.h:429
同名文件已经存在,在追加模式 AIOT_MQTT_UPLOAD_FILE_MODE_APPEND 和拒绝模式 AIOT_MQTT_UPLOAD_FILE_MODE_...
Definition: aiot_mqtt_upload_api.h:302
aiot_mqtt_upload_result_t aiot_mqtt_upload_process(void *handle)
MQTT Upload 处理函数,处理超时和重发逻辑,返回对应文件的执行的状态
Definition: aiot_mqtt_upload_api.c:1275
文件上传过程中,消息限流
Definition: aiot_mqtt_upload_api.h:326
重传或网络断开造成文件写入重复,忽略
Definition: aiot_mqtt_upload_api.h:320
上传文件的任务不存在,用户需要发起新的上传请求调用 aiot_mqtt_upload_open_stream
Definition: aiot_mqtt_upload_api.h:296
int32_t aiot_mqtt_upload_setopt(void *handle, aiot_mqtt_upload_option_t option, void *data)
配置MQTT UPLOAD会话
Definition: aiot_mqtt_upload_api.c:1112
aiot_mqtt_upload_result_code_t
请求文件上传和文件传输过程中的服务端返回的文件信息
Definition: aiot_mqtt_upload_api.h:231
收到的服务端应答取消上传的报文应答
Definition: aiot_mqtt_upload_api.h:348
int32_t aiot_mqtt_upload_open_stream(void *handle, char *file_name, uint32_t file_size, const char *mode, void *digest, aiot_mqtt_upload_read_handler_t read_data_handler, void *userdata)
向MQTT UPLOAD 服务请求发送文件
Definition: aiot_mqtt_upload_api.c:1164
MQTT UPLOAD会话发送消息时,超时重发的最长时间间隔, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:434
文件上传任务已经完成,通知用户对应的文件上传已经完成,销毁对应的upload task释放内存资源 ...
Definition: aiot_mqtt_upload_api.h:308
int32_t(* aiot_mqtt_upload_read_handler_t)(const aiot_mqtt_upload_recv_t *packet, uint8_t *data, uint32_t size, void *userdata)
回调函数读取用户的本地文件或内存数据不能在回调函数中执行 aiot_mqtt_upload_open_stream 和 aiot_mqtt_up...
Definition: aiot_mqtt_upload_api.h:487
char * upload_id
服务端应答文件上传请求唯一识别信息,在文件上传的声明周期内uploadId唯一,有效时间24H ...
Definition: aiot_mqtt_upload_api.h:371
aiot_mqtt_upload_result_code_t code
服务端应答的错误编码,对应本次上传的状态
Definition: aiot_mqtt_upload_api.h:386
设备上传文件分片时,当前分片的CRC校验失败,SDK内会自动对当前分片进行重传
Definition: aiot_mqtt_upload_api.h:290
收到的服务端应答上传分片文件时的应答报文消息,通过回调反馈给用户,同时也会调用回调获取下一段分片文件 ...
Definition: aiot_mqtt_upload_api.h:343
char * file_name
服务端应答的文件名信息,用户调用 aiot_mqtt_upload_open_stream 传入的文件名,可用于回调函数中读取文件...
Definition: aiot_mqtt_upload_api.h:360
收到的服务端应答请求初始化时的报文信息,通过回调函数反馈给用户
Definition: aiot_mqtt_upload_api.h:338
aiot_mqtt_upload_recv_type_t type
收到服务端应答的报文类型
Definition: aiot_mqtt_upload_api.h:408
char * message
服务端应答,错误码对应的错误信息
Definition: aiot_mqtt_upload_api.h:391
设备上传文件分片时,当前分片的大小小于最小阈值,除最后一片文件外,传输过程中分片大小不得小于256Byte ...
Definition: aiot_mqtt_upload_api.h:284
aiot_mqtt_upload_desc_t desc
收到服务端应答的报文描述信息
Definition: aiot_mqtt_upload_api.h:414
aiot_mqtt_upload_option_t
aiot_mqtt_upload_setopt 接口的option参数可选值.
Definition: aiot_mqtt_upload_api.h:423
aiot_mqtt_upload_process 循环处理,返回对应文件的上传状态给到用户
Definition: aiot_mqtt_upload_api.h:457
配置MQTT文件上传单包发送超时时候的重试次数, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:439
void * aiot_mqtt_upload_init(void)
创建MQTT UPLOAD会话实例, 并以默认值配置会话参数
Definition: aiot_mqtt_upload_api.c:1046
uint32_t block_size
本次进行分片上传的分片长度
Definition: aiot_mqtt_upload_api.h:381
文件上传被限流
Definition: aiot_mqtt_upload_api.h:248
文件完整性校验失败,在调用 aiot_mqtt_upload_open_stream 时,如果传入 degist参数服务端会对文件完整性进...
Definition: aiot_mqtt_upload_api.h:314
int32_t aiot_mqtt_upload_cancel_stream(void *handle, char *file_name)
向mqtt_upload服务器请求关闭MQTT通道数据上传命令
Definition: aiot_mqtt_upload_api.c:1238
设备上传文件分片时,分片大小超过阈值128KB
Definition: aiot_mqtt_upload_api.h:272
int32_t aiot_mqtt_upload_deinit(void **handle)
结束MQTT UPLOAD会话, 销毁实例并回收资源
Definition: aiot_mqtt_upload_api.c:1076