Link Kit C-SDK  4.1.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_WHOLE_CHECK (-0x2124)
178 
183 #define STATE_MQTT_UPLOAD_FINISHED (-0x2125)
184 
189 #define STATE_MQTT_UPLOAD_NO_UPLOAD_TASK (-0x2126)
190 
195 #define STATE_MQTT_UPLOAD_EXTRA_PARAMS_NOT_JSON (-0x2127)
196 
200 #define AIOT_MQTT_UPLOAD_FILE_MODE_OVERWRITE "overwrite"
201 
209 #define AIOT_MQTT_UPLOAD_FILE_MODE_APPEND "append"
210 
214 #define AIOT_MQTT_UPLOAD_FILE_MODE_FAIL "reject"
215 
219 #define MQTT_UPLOAD_DEFAULT_FILENAME_LEN (128)
220 
224 #define MQTT_UPLOAD_DEFAULT_CRC64_LEN (32)
225 
229 #define MQTT_UPLOAD_DEFAULT_UPLOAD_SIZE (64)
230 
235 typedef enum {
241 
247 
253 
259 
265 
271 
277 
283 
289 
295 
301 
307 
313 
319 
325 
331 
333 
337 typedef enum {
354 
359 typedef struct {
364  char *file_name;
365 
369  uint32_t file_size;
370 
375  char *upload_id;
376 
380  uint32_t file_offset;
381 
385  uint32_t block_size;
386 
391 
395  char *message;
396 
400  uint8_t complete;
401 
403 
407 typedef struct {
412  aiot_mqtt_upload_recv_type_t type;
413 
420 
427 typedef enum {
428 
434 
439 
444 
449 
458 
460 
465 typedef struct
466 {
471  int32_t status;
472 
477  int32_t err_code;
478 
484 
490 
492 
506 typedef int32_t (*aiot_mqtt_upload_read_handler_t)(const aiot_mqtt_upload_recv_t *packet, uint8_t *data, uint32_t size, void *userdata);
507 
514 typedef struct
515 {
516  char *file_name;
517  uint32_t file_size;
518  char *mode;
519  void *digest;
522  void *userdata;
524 
533 void *aiot_mqtt_upload_init(void);
534 
549 int32_t aiot_mqtt_upload_setopt(void *handle, aiot_mqtt_upload_option_t option, void *data);
550 
561 int32_t aiot_mqtt_upload_deinit(void **handle);
562 
576 int32_t aiot_mqtt_upload_open_stream(void *handle, char *file_name, aiot_mqtt_upload_recv_t *packet);
577 
590 int32_t aiot_mqtt_upload_cancel_stream(void *handle, char *file_name);
591 
610 
626 int32_t aiot_mqtt_upload_send_data(void *handle, char *file_name, uint8_t *data, uint32_t datalen, uint8_t is_complete);
627 
628 
629 #if defined(__cplusplus)
630 }
631 #endif
632 
633 #endif /* __AIOT_MQTT_UPLOAD_API_H__ */
634 
int32_t aiot_mqtt_upload_open_stream(void *handle, char *file_name, aiot_mqtt_upload_recv_t *packet)
向MQTT UPLOAD 服务请求发送文件
Definition: aiot_mqtt_upload_api.c:1454
MQTT UPLOAD模块收到服务端应答的报文信息, 通知用户的报文内容
Definition: aiot_mqtt_upload_api.h:407
文件上传正常
Definition: aiot_mqtt_upload_api.h:240
char * mode
Definition: aiot_mqtt_upload_api.h:518
申请使用mqtt协议上传文件时,文件大小超过阈值16M
Definition: aiot_mqtt_upload_api.h:270
aiot_mqtt_upload_recv_type_t
MQTT UPLOAD模块收到从服务端应答的报文类型
Definition: aiot_mqtt_upload_api.h:337
uint8_t complete
服务端应答文件上传完成后才有的应答,complete true: 文件上传成功,false: 文件上传失败 ...
Definition: aiot_mqtt_upload_api.h:400
配置文件上传的分片长度,默认是2048byte, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:448
文件上传请求参数错误
Definition: aiot_mqtt_upload_api.h:258
char * file_name
Definition: aiot_mqtt_upload_api.h:516
设置MQTT的最大值,设置失败
Definition: aiot_mqtt_upload_api.h:457
uint32_t file_offset
已经上传文件的偏移量,偏移量的是相对于文件开始的起始点算起,可以用于回调函数中读取新分片文件的偏移量 ...
Definition: aiot_mqtt_upload_api.h:380
#define MQTT_UPLOAD_DEFAULT_FILENAME_LEN
MQTT上传文件名的最大长度
Definition: aiot_mqtt_upload_api.h:219
请求上传的payload格式非法,无法解析其中的json格式数据
Definition: aiot_mqtt_upload_api.h:246
uint32_t file_size
对应上传文件的总长度,用户调用 aiot_mqtt_upload_open_stream 传入的文件大小
Definition: aiot_mqtt_upload_api.h:369
接收到的服务端应答消息的报文信息
Definition: aiot_mqtt_upload_api.h:359
服务端其他异常
Definition: aiot_mqtt_upload_api.h:264
设备上传文件分片时,当前分片的offset与已上传至的服务端文件大小不一致
Definition: aiot_mqtt_upload_api.h:282
关联MQTT Handle会话,UPLOAD过程中使用MQTT的通道能力, 用以向服务端请求上传、发送分片文件、请求关闭通道...
Definition: aiot_mqtt_upload_api.h:433
aiot_mqtt_upload_setopt 对应参数AIOT_MQTT_UPLOADOPT_FILE_OPTION的结构体
Definition: aiot_mqtt_upload_api.h:514
同名文件已经存在,在追加模式 AIOT_MQTT_UPLOAD_FILE_MODE_APPEND 和拒绝模式 AIOT_MQTT_UPLOAD_FILE_MODE_...
Definition: aiot_mqtt_upload_api.h:306
aiot_mqtt_upload_result_t aiot_mqtt_upload_process(void *handle)
MQTT Upload 处理函数,处理超时和重发逻辑,返回对应文件的执行的状态
Definition: aiot_mqtt_upload_api.c:1627
文件上传过程中,消息限流
Definition: aiot_mqtt_upload_api.h:330
int32_t err_code
云端应答的错误码,参考aiot_mqtt_upload_result_code_t
Definition: aiot_mqtt_upload_api.h:477
重传或网络断开造成文件写入重复,忽略
Definition: aiot_mqtt_upload_api.h:324
上传文件的任务不存在,用户需要发起新的上传请求调用 aiot_mqtt_upload_open_stream
Definition: aiot_mqtt_upload_api.h:300
int32_t aiot_mqtt_upload_setopt(void *handle, aiot_mqtt_upload_option_t option, void *data)
配置MQTT UPLOAD会话
Definition: aiot_mqtt_upload_api.c:1366
int32_t status
通过MQTT通过上传的情况
Definition: aiot_mqtt_upload_api.h:471
aiot_mqtt_upload_result_code_t
请求文件上传和文件传输过程中的服务端返回的文件信息
Definition: aiot_mqtt_upload_api.h:235
收到的服务端应答取消上传的报文应答
Definition: aiot_mqtt_upload_api.h:352
MQTT UPLOAD会话发送消息时,超时重发的最长时间间隔, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:438
文件上传任务已经完成,通知用户对应的文件上传已经完成,销毁对应的upload task释放内存资源 ...
Definition: aiot_mqtt_upload_api.h:312
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:506
int32_t aiot_mqtt_upload_send_data(void *handle, char *file_name, uint8_t *data, uint32_t datalen, uint8_t is_complete)
MQTT Upload 数据发送接口,如果没有配置aiot_mqtt_upload_read_handler_t时,使用该接口发送数据 ...
Definition: aiot_mqtt_upload_api.c:1565
uint32_t file_size
Definition: aiot_mqtt_upload_api.h:517
char * upload_id
服务端应答文件上传请求唯一识别信息,在文件上传的声明周期内uploadId唯一,有效时间24H ...
Definition: aiot_mqtt_upload_api.h:375
aiot_mqtt_upload_result_code_t code
服务端应答的错误编码,对应本次上传的状态
Definition: aiot_mqtt_upload_api.h:390
设备上传文件分片时,当前分片的CRC校验失败,SDK内会自动对当前分片进行重传
Definition: aiot_mqtt_upload_api.h:294
收到的服务端应答上传分片文件时的应答报文消息,通过回调反馈给用户,同时也会调用回调获取下一段分片文件 ...
Definition: aiot_mqtt_upload_api.h:347
char * file_name
服务端应答的文件名信息,用户调用 aiot_mqtt_upload_open_stream 传入的文件名,可用于回调函数中读取文件...
Definition: aiot_mqtt_upload_api.h:364
aiot_mqtt_upload_read_handler_t read_data_handler
Definition: aiot_mqtt_upload_api.h:521
收到的服务端应答请求初始化时的报文信息,通过回调函数反馈给用户
Definition: aiot_mqtt_upload_api.h:342
aiot_mqtt_upload_recv_type_t type
收到服务端应答的报文类型
Definition: aiot_mqtt_upload_api.h:412
char * message
服务端应答,错误码对应的错误信息
Definition: aiot_mqtt_upload_api.h:395
设备上传文件分片时,当前分片的大小小于最小阈值,除最后一片文件外,传输过程中分片大小不得小于256Byte ...
Definition: aiot_mqtt_upload_api.h:288
void * digest
Definition: aiot_mqtt_upload_api.h:519
aiot_mqtt_upload_desc_t desc
收到服务端应答的报文描述信息
Definition: aiot_mqtt_upload_api.h:418
aiot_mqtt_upload_option_t
aiot_mqtt_upload_setopt 接口的option参数可选值.
Definition: aiot_mqtt_upload_api.h:427
aiot_mqtt_upload_process 循环处理,返回对应文件的上传状态给到用户
Definition: aiot_mqtt_upload_api.h:465
配置MQTT文件上传单包发送超时时候的重试次数, 数据类型为(uint32_t *)
Definition: aiot_mqtt_upload_api.h:443
void * aiot_mqtt_upload_init(void)
创建MQTT UPLOAD会话实例, 并以默认值配置会话参数
Definition: aiot_mqtt_upload_api.c:1151
#define MQTT_UPLOAD_DEFAULT_UPLOAD_SIZE
UploadID的数据长度
Definition: aiot_mqtt_upload_api.h:229
uint32_t block_size
本次进行分片上传的分片长度
Definition: aiot_mqtt_upload_api.h:385
void * userdata
Definition: aiot_mqtt_upload_api.h:522
文件上传被限流
Definition: aiot_mqtt_upload_api.h:252
char * extra_params
Definition: aiot_mqtt_upload_api.h:520
文件完整性校验失败,在调用 aiot_mqtt_upload_open_stream 时,如果传入 degist参数服务端会对文件完整性进...
Definition: aiot_mqtt_upload_api.h:318
int32_t aiot_mqtt_upload_cancel_stream(void *handle, char *file_name)
向mqtt_upload服务器请求关闭MQTT通道数据上传命令
Definition: aiot_mqtt_upload_api.c:1527
设备上传文件分片时,分片大小超过阈值128KB
Definition: aiot_mqtt_upload_api.h:276
配置需要上传的文件,数据类型为aiot_mqtt_upload_file_opt_t
Definition: aiot_mqtt_upload_api.h:453
int32_t aiot_mqtt_upload_deinit(void **handle)
结束MQTT UPLOAD会话, 销毁实例并回收资源
Definition: aiot_mqtt_upload_api.c:1181