TuyaOS
iot_httpc.h
浏览该文件的文档.
1
11#ifndef _IOT_HTTPC_H
12#define _IOT_HTTPC_H
13
14#include "tuya_cloud_types.h"
15#include "ty_cJSON.h"
16#include "gw_intf.h"
17#include "http_inf.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
39OPERATE_RET httpc_common_post_no_remalloc(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid, IN CHAR_T *post_data, IN UINT_T data_total_len, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result);
40
54OPERATE_RET httpc_common_post(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid, IN CHAR_T *post_data, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result);
55
56OPERATE_RET httpc_common_post_raw(IN CONST CHAR_T *url, IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
57 IN CONST CHAR_T *uuid, IN CONST CHAR_T *aes_key, IN CONST CHAR_T *devid,
58 IN CHAR_T *post_data, IN UINT_T data_total_len,IN CONST CHAR_T *p_head_other,
59 OUT ty_cJSON **pp_result);
60
68OPERATE_RET http_gw_get_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result);
69
79OPERATE_RET http_gw_get_timer_content(IN CONST INT_T offset, IN CONST INT_T limit, OUT ty_cJSON **result);
80
88OPERATE_RET httpc_gw_extra_erro_code_tranfer(char *ErroValu);
89
95OPERATE_RET http_gw_reset(IN CONST GW_WORK_STAT_T stat);
96
104
113OPERATE_RET http_iot_dns_get_fast_cloud_url(CHAR_T *env);
114
120
129OPERATE_RET http_iot_dns_get_host_ip(IN CONST CHAR_T *domain, OUT ty_cJSON **result);
130
140OPERATE_RET http_gw_register_V41(OUT ty_cJSON **result);
141
149OPERATE_RET http_gw_active_v41(OUT ty_cJSON **result);
150
158OPERATE_RET http_gw_active_mesh(IN CONST CHAR_T *data, OUT ty_cJSON **result);
159
168
177OPERATE_RET http_ffs_pre_active(IN CONST CHAR_T *wss_token, IN CONST CHAR_T*gw_endpoint);
178
179typedef OPERATE_RET(*HTTP_GW_GET_FILE_DATA_CB)(IN PVOID_T priv_data, IN CONST UINT_T total_len, IN CONST UINT_T offset, \
180 IN CONST BYTE_T *data, IN CONST UINT_T len, OUT UINT_T *remain_len);
195OPERATE_RET http_gw_download_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len, \
196 IN CONST HTTP_GW_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data, \
197 IN CONST UINT_T total_len, IN CONST BYTE_T *p_key, IN CONST UINT_T key_len, INOUT BYTE_T file_hmac[32]);
198
206OPERATE_RET http_pskkey_get(OUT ty_cJSON **result);
207
213OPERATE_RET http_put_rst_log(VOID);
214
218typedef enum {
226
235OPERATE_RET http_dynamic_cfg_get(IN CONST HTTP_DYNAMIC_CFG_TYPE type, OUT ty_cJSON **result);
236
245OPERATE_RET http_dynamic_cfg_ack_v20(IN CONST CHAR_T* timezone_ackId, IN CONST CHAR_T* rateRule_actId);
246
255OPERATE_RET httpc_domain_certs_get(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg);
256
264OPERATE_RET http_put_cloud_config(IN CONST CHAR_T *data);
265
273OPERATE_RET http_gw_property_save(IN CONST CHAR_T *data);
274
278typedef enum {
288
297
303OPERATE_RET http_gw_dev_sync_proc(VOID_T);
304
313OPERATE_RET httpc_iot_certificate_get_v10(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg);
314
323
332OPERATE_RET http_gw_custom_cfg_get(IN CONST INT_T biztype, OUT ty_cJSON **result);
333
341OPERATE_RET http_gw_get_active_info(OUT ty_cJSON **result);
349OPERATE_RET http_gw_location_info_get(OUT ty_cJSON **result);
350
351typedef PVOID_T RAW_HTTP_S;
362OPERATE_RET httpc_raw_read_resp_header(INOUT RAW_HTTP_S p_raw_http, OUT INT_T *p_status_code, OUT BOOL_T *p_chunked, OUT UINT_T *p_content_len);
363
373INT_T httpc_raw_read_content(IN RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len);
374
385INT_T httpc_raw_write_content(IN RAW_HTTP_S p_raw_http, IN CONST BYTE_T *buf, IN CONST UINT_T buf_len, BOOL_T chunked);
386
394OPERATE_RET httpc_raw_close(IN RAW_HTTP_S p_raw_http);
395
405OPERATE_RET httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
406
417#define httpc_raw_get(p_url, pp_raw_http, offset, total_len) \
418 httpc_raw_get_with_head(p_url, pp_raw_http, offset, total_len, NULL, NULL) \
419
432OPERATE_RET httpc_raw_get_with_head(IN CONST CHAR_T *p_url, INOUT RAW_HTTP_S *pp_raw_http,
433 IN UINT_T offset, IN UINT_T total_len,
434 IN HTTP_HEAD_ADD_CB add_head_cb,
435 IN VOID* add_head_data);
436
446OPERATE_RET httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
447
455OPERATE_RET http_get_dev_token_create_v20(OUT ty_cJSON **result);
456
462CHAR_T *http_active_url(VOID);
463
469CHAR_T *http_url(VOID);
470
480OPERATE_RET httpc_active_shorturl_get(char *uuid, char *appid, ty_cJSON **result);
481
482#if defined(BT_REMOTE_CTRL) && (BT_REMOTE_CTRL==1)
488OPERATE_RET http_meta_rpt_v10(VOID_T);
489#endif
490
497OPERATE_RET tuya_get_ble_beacon_key(OUT CHAR_T **beaconKey);
498
502typedef struct {
504 CHAR_T *host;
506 INT_T port;
508 BOOL_T need_ca;
510 BOOL_T need_ip;
512
522OPERATE_RET http_iot_dns_get_host_ca(IN DNS_QUERY_S *dns_arr, IN UINT_T arr_num, OUT ty_cJSON **result);
523
524OPERATE_RET httpc_meta_report(ty_cJSON *meta);
525
526#ifdef __cplusplus
527}
528#endif
529#endif
530
Facility of DevOS definitions
Wrapper of HTTP request and response
OPERATE_RET http_ble_actived_enable_wifi(VOID)
Enalbe wifi after activated by BLE
OPERATE_RET httpc_common_post(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid, IN CHAR_T *post_data, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result)
POST HTTP request
OPERATE_RET httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http)
Raw HTTP POST request
OPERATE_RET httpc_iot_certificate_get_v10(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg)
Retrieve certs of special domain
OPERATE_RET http_gw_dev_sync_proc(VOID_T)
Sync device status
OPERATE_RET http_gw_active_mesh(IN CONST CHAR_T *data, OUT ty_cJSON **result)
Dynamic mesh gw Register and active a device on TUYA cloud
OPERATE_RET http_get_dev_token_create_v20(OUT ty_cJSON **result)
Retrieve token from cloud
OPERATE_RET httpc_active_shorturl_get(char *uuid, char *appid, ty_cJSON **result)
Retrieve short url of QR active
OPERATE_RET http_gw_reset(IN CONST GW_WORK_STAT_T stat)
Reset device
OPERATE_RET http_gw_register_V41(OUT ty_cJSON **result)
Register a device on TUYA cloud
INT_T httpc_raw_read_content(IN RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len)
Read content of raw HTTP response
OPERATE_RET http_gw_property_save(IN CONST CHAR_T *data)
Save property to TUYA cloud
CHAR_T * http_active_url(VOID)
Retrieve active HTTP url of TUYA cloud
OPERATE_RET http_dynamic_cfg_ack_v20(IN CONST CHAR_T *timezone_ackId, IN CONST CHAR_T *rateRule_actId)
ACK of dynamic config(some configs need ack to ensure it is handled correctly)
OPERATE_RET http_gw_update_version_v41(VOID)
Update versions of device on TUYA cloud
OPERATE_RET http_gw_get_timer_content(IN CONST INT_T offset, IN CONST INT_T limit, OUT ty_cJSON **result)
Get content local timers
OPERATE_RET http_put_cloud_config(IN CONST CHAR_T *data)
Upload config to TUYA cloud
OPERATE_RET httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http)
Raw HTTP PUT request
DEV_SYNC_STATUS_E
Definition of status to check
Definition: iot_httpc.h:278
@ DEV_STATUS_ENABLE
Definition: iot_httpc.h:286
@ DEV_STATUS_UNKNOWN
Definition: iot_httpc.h:280
@ DEV_STATUS_RESET
Definition: iot_httpc.h:282
@ DEV_STATUS_RESET_FACTORY
Definition: iot_httpc.h:284
OPERATE_RET http_ffs_pre_active(IN CONST CHAR_T *wss_token, IN CONST CHAR_T *gw_endpoint)
Pre-active of FFS netcfg
OPERATE_RET http_gw_get_active_info(OUT ty_cJSON **result)
Register and active a device on TUYA cloud
OPERATE_RET http_dynamic_cfg_get(IN CONST HTTP_DYNAMIC_CFG_TYPE type, OUT ty_cJSON **result)
Retrieve dynamic config
OPERATE_RET http_gw_get_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result)
Get the count of local timers
OPERATE_RET http_gw_location_info_get(OUT ty_cJSON **result)
Retrieve location info
OPERATE_RET httpc_iot_cloud_storage_encrypt_key_get(OUT ty_cJSON **result)
Retrieve encrypt key of cloud storage
OPERATE_RET httpc_domain_certs_get(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg)
Retrieve certs of special domain
OPERATE_RET http_gw_active_v41(OUT ty_cJSON **result)
Register and active a device on TUYA cloud
HTTP_DYNAMIC_CFG_TYPE
Definition of dynamic config
Definition: iot_httpc.h:218
@ HTTP_DYNAMIC_CFG_TZ
Definition: iot_httpc.h:222
@ HTTP_DYNAMIC_CFG_ALL
Definition: iot_httpc.h:220
@ HTTP_DYNAMIC_CFG_RATERULE
Definition: iot_httpc.h:224
OPERATE_RET httpc_raw_get_with_head(IN CONST CHAR_T *p_url, INOUT RAW_HTTP_S *pp_raw_http, IN UINT_T offset, IN UINT_T total_len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data)
Raw HTTP GET request
OPERATE_RET http_iot_dns_get_host_ip(IN CONST CHAR_T *domain, OUT ty_cJSON **result)
Use TUYA IoT DNS service to translate domain to ip
OPERATE_RET httpc_raw_read_resp_header(INOUT RAW_HTTP_S p_raw_http, OUT INT_T *p_status_code, OUT BOOL_T *p_chunked, OUT UINT_T *p_content_len)
Read header of raw HTTP respose
OPERATE_RET http_iot_dns_get_host_ca(IN DNS_QUERY_S *dns_arr, IN UINT_T arr_num, OUT ty_cJSON **result)
Retrieve IPs and Certs of specific domains
OPERATE_RET httpc_gw_extra_erro_code_tranfer(char *ErroValu)
Transfer HTTP error string to error code
OPERATE_RET http_pskkey_get(OUT ty_cJSON **result)
Retrieve PSK key
CHAR_T * http_url(VOID)
Retrieve active HTTP url of TUYA cloud
INT_T httpc_raw_write_content(IN RAW_HTTP_S p_raw_http, IN CONST BYTE_T *buf, IN CONST UINT_T buf_len, BOOL_T chunked)
Write raw HTTP request
OPERATE_RET httpc_common_post_no_remalloc(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid, IN CHAR_T *post_data, IN UINT_T data_total_len, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result)
POST HTTP request without memory realloc
OPERATE_RET httpc_raw_close(IN RAW_HTTP_S p_raw_http)
Close raw HTTP request
OPERATE_RET http_iot_dns_get_cloud_url(VOID)
Retrieve URLs from TUYA IoT DNS service, device will use URLs to interact with TUYA cloud later on
OPERATE_RET http_gw_download_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len, IN CONST HTTP_GW_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data, IN CONST UINT_T total_len, IN CONST BYTE_T *p_key, IN CONST UINT_T key_len, INOUT BYTE_T file_hmac[32])
Download file
OPERATE_RET http_gw_custom_cfg_get(IN CONST INT_T biztype, OUT ty_cJSON **result)
Retrieve customized config
OPERATE_RET http_iot_dns_get_fast_cloud_url(CHAR_T *env)
Retrieve special URLs from TUYA IoT DNS service, device will use URLs to interact with TUYA cloud lat...
OPERATE_RET http_put_rst_log(VOID)
Upload information of device reset to TUYA cloud
OPERATE_RET http_gw_dev_sync_check(DEV_SYNC_STATUS_E *p_status)
Retrieve device status
VOID http_iot_dns_cache_cloud_url(VOID)
Load URLs and related Ips of TUYA cloud to DNS cache
Definition of domain's IP and cert structure
Definition: iot_httpc.h:502
CHAR_T * host
Definition: iot_httpc.h:504
BOOL_T need_ca
Definition: iot_httpc.h:508
INT_T port
Definition: iot_httpc.h:506
BOOL_T need_ip
Definition: iot_httpc.h:510
Definition: ty_cJSON.h:45