TuyaOS
http_manager.h
浏览该文件的文档.
1
11#ifndef __HTTP_MANAGER_H_
12#define __HTTP_MANAGER_H_
13
14#include "tuya_cloud_types.h"
15#include "httpc.h"
16#include "tal_mutex.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#define MAX_HTTP_SESSION_NUM 16 // max number of active session
23#define INVALID_HTTP_SESSION_ID 0xFFFFFFFF // invalid HTTP session handle
24#define MAX_HTTP_URL_LEN 256 // max len of url
25
29typedef enum {
30 HTTP_FREE = 0, // session is free
31 HTTP_DISCONNECT, // session is disconnected
32 HTTP_CONNECTING, // session is connecting
33 HTTP_CONNECTED, // session is connected and ready to send/recv
34 HTTP_UPLOADING, // session has sent data and is ready to recv
36
40typedef struct {
42 http_session_t s;
43
46
49
51 CHAR_T url[MAX_HTTP_URL_LEN];
52
55
59
61
70typedef SESSION_ID(*FUNC_HTTP_SESSION_CREATE)(IN CONST CHAR_T *url, BOOL_T is_persistent);
71
81typedef OPERATE_RET(*FUNC_HTTP_SESSION_SEND)(IN CONST SESSION_ID session, IN CONST http_req_t *req, http_hdr_field_sel_t field_flags);
82
94typedef OPERATE_RET(*FUNC_HTTP_SESSION_RECEIVE)(SESSION_ID session, http_resp_t **resp);
95
103typedef OPERATE_RET(*FUNC_HTTP_SESSION_DESTORY)(SESSION_ID session);
104
114typedef OPERATE_RET(*FUNC_HTTP_SESSION_RECEIVE_DATA)(SESSION_ID session, http_resp_t *pResp, BYTE_T** pDataOut);
115
119typedef struct {
121 S_HTTP_SESSION *session[MAX_HTTP_SESSION_NUM];
123 MUTEX_HANDLE mutex;
124
126 BOOL_T inited;
127
139
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif
OPERATE_RET(* FUNC_HTTP_SESSION_DESTORY)(SESSION_ID session)
This API is used to destroy HTTP session
Definition: http_manager.h:103
OPERATE_RET(* FUNC_HTTP_SESSION_SEND)(IN CONST SESSION_ID session, IN CONST http_req_t *req, http_hdr_field_sel_t field_flags)
This API is used to send HTTP session request
Definition: http_manager.h:81
E_HTTP_SESSION_STATE
Definition of HTTP session state
Definition: http_manager.h:29
SESSION_ID(* FUNC_HTTP_SESSION_CREATE)(IN CONST CHAR_T *url, BOOL_T is_persistent)
This API is used to create HTTP session
Definition: http_manager.h:70
OPERATE_RET(* FUNC_HTTP_SESSION_RECEIVE_DATA)(SESSION_ID session, http_resp_t *pResp, BYTE_T **pDataOut)
This API is used to recv response content from HTTP session.
Definition: http_manager.h:114
OPERATE_RET(* FUNC_HTTP_SESSION_RECEIVE)(SESSION_ID session, http_resp_t **resp)
This API is used to recv response header from HTTP session
Definition: http_manager.h:94
S_HTTP_MANAGER * get_http_manager_instance(VOID_T)
Retrieve instance of HTTP session manager
HTTP Client Module
http_hdr_field_sel_t
Definition: httpc.h:94
The HTTP session manager structure.
Definition: http_manager.h:119
BOOL_T inited
Definition: http_manager.h:126
FUNC_HTTP_SESSION_CREATE create_http_session
Definition: http_manager.h:129
FUNC_HTTP_SESSION_RECEIVE receive_http_response
Definition: http_manager.h:133
FUNC_HTTP_SESSION_RECEIVE_DATA receive_http_data
Definition: http_manager.h:137
MUTEX_HANDLE mutex
Definition: http_manager.h:123
FUNC_HTTP_SESSION_SEND send_http_request
Definition: http_manager.h:131
FUNC_HTTP_SESSION_DESTORY destory_http_session
Definition: http_manager.h:135
The HTTP session's Request structure
Definition: http_manager.h:40
http_req_t req
Definition: http_manager.h:54
http_hdr_field_sel_t flags
Definition: http_manager.h:48
BOOL_T is_persistent
Definition: http_manager.h:45
E_HTTP_SESSION_STATE state
Definition: http_manager.h:57
http_session_t s
Definition: http_manager.h:42
Definition: httpc.h:154
Definition: httpc.h:182
Common process - adapter the mutex api provide by OS