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#ifndef MAX_HTTP_SESSION_NUM
23#define MAX_HTTP_SESSION_NUM 16 // max number of active session
24#endif
25#define INVALID_HTTP_SESSION_ID 0xFFFFffff // invalid HTTP session handle
26#define MAX_HTTP_URL_LEN 256 // max len of url
27
31typedef enum {
32 HTTP_FREE = 0, // session is free
33 HTTP_DISCONNECT, // session is disconnected
34 HTTP_CONNECTING, // session is connecting
35 HTTP_CONNECTED, // session is connected and ready to send/recv
36 HTTP_UPLOADING, // session has sent data and is ready to recv
38
42typedef struct {
44 http_session_t s;
45
48
51
53 CHAR_T url[MAX_HTTP_URL_LEN];
54
57
61
63
72typedef SESSION_ID(*FUNC_HTTP_SESSION_CREATE)(IN CONST CHAR_T *url, BOOL_T is_persistent);
73
82typedef SESSION_ID(*FUNC_HTTP_SESSION_CREATE_TLS)(IN CONST CHAR_T *url, BOOL_T is_persistent, tuya_tls_config_t* config);
83
93typedef OPERATE_RET(*FUNC_HTTP_SESSION_SEND)(IN CONST SESSION_ID session, IN CONST http_req_t *req, http_hdr_field_sel_t field_flags);
94
106typedef OPERATE_RET(*FUNC_HTTP_SESSION_RECEIVE)(SESSION_ID session, http_resp_t **resp);
107
115typedef OPERATE_RET(*FUNC_HTTP_SESSION_DESTORY)(SESSION_ID session);
116
126typedef OPERATE_RET(*FUNC_HTTP_SESSION_RECEIVE_DATA)(SESSION_ID session, http_resp_t *pResp, BYTE_T** pDataOut);
127
131typedef struct {
133 S_HTTP_SESSION *session[MAX_HTTP_SESSION_NUM];
135 MUTEX_HANDLE mutex;
136
138 BOOL_T inited;
139
153
162
163#ifdef __cplusplus
164}
165#endif
166
167#endif
OPERATE_RET(* FUNC_HTTP_SESSION_DESTORY)(SESSION_ID session)
This API is used to destroy HTTP session
Definition: http_manager.h:115
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:93
E_HTTP_SESSION_STATE
Definition of HTTP session state
Definition: http_manager.h:31
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:72
SESSION_ID(* FUNC_HTTP_SESSION_CREATE_TLS)(IN CONST CHAR_T *url, BOOL_T is_persistent, tuya_tls_config_t *config)
This API is used to create HTTP session
Definition: http_manager.h:82
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:126
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:106
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:95
The HTTP session manager structure.
Definition: http_manager.h:131
BOOL_T inited
Definition: http_manager.h:138
FUNC_HTTP_SESSION_CREATE create_http_session
Definition: http_manager.h:141
FUNC_HTTP_SESSION_RECEIVE receive_http_response
Definition: http_manager.h:147
FUNC_HTTP_SESSION_RECEIVE_DATA receive_http_data
Definition: http_manager.h:151
MUTEX_HANDLE mutex
Definition: http_manager.h:135
FUNC_HTTP_SESSION_CREATE_TLS create_http_session_tls
Definition: http_manager.h:143
FUNC_HTTP_SESSION_SEND send_http_request
Definition: http_manager.h:145
FUNC_HTTP_SESSION_DESTORY destory_http_session
Definition: http_manager.h:149
The HTTP session's Request structure
Definition: http_manager.h:42
http_req_t req
Definition: http_manager.h:56
http_hdr_field_sel_t flags
Definition: http_manager.h:50
BOOL_T is_persistent
Definition: http_manager.h:47
E_HTTP_SESSION_STATE state
Definition: http_manager.h:59
http_session_t s
Definition: http_manager.h:44
Definition: httpc.h:157
Definition: httpc.h:185
Definition: tuya_tls.h:45
Common process - adapter the mutex api provide by OS