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
77OPERATE_RET http_gw_notify_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result);
78
88OPERATE_RET http_gw_get_timer_content(IN CONST INT_T offset, IN CONST INT_T limit, OUT ty_cJSON **result);
89
97OPERATE_RET httpc_gw_extra_erro_code_tranfer(char *ErroValu);
98
104OPERATE_RET http_gw_reset(IN CONST GW_WORK_STAT_T stat);
105
113
122OPERATE_RET http_iot_dns_get_fast_cloud_url(CHAR_T *env);
123
129
138OPERATE_RET http_iot_dns_get_host_ip(IN CONST CHAR_T *domain, OUT ty_cJSON **result);
139
149OPERATE_RET http_gw_register_V41(OUT ty_cJSON **result);
150
158OPERATE_RET http_gw_active_v41(OUT ty_cJSON **result);
159
167OPERATE_RET http_gw_active_mesh(IN CONST CHAR_T *data, OUT ty_cJSON **result);
168
177
186OPERATE_RET http_ffs_pre_active(IN CONST CHAR_T *wss_token, IN CONST CHAR_T*gw_endpoint);
187
188typedef OPERATE_RET(*HTTP_GW_GET_FILE_DATA_CB)(IN PVOID_T priv_data, IN CONST UINT_T total_len, IN CONST UINT_T offset, \
189 IN CONST BYTE_T *data, IN CONST UINT_T len, OUT UINT_T *remain_len);
204OPERATE_RET httpc_get_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len,
205 IN CONST HTTP_GW_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data,
206 IN CONST UINT_T total_len, IN CONST UINT_T offset,
207 IN CONST BYTE_T *p_key, IN CONST UINT_T key_len, INOUT BYTE_T file_hmac[32]);
208#define http_gw_download_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, p_key, key_len, file_hmac) \
209 httpc_get_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, 0, p_key, key_len, file_hmac)
210
211
219OPERATE_RET http_pskkey_get(OUT ty_cJSON **result);
220
226OPERATE_RET http_put_rst_log(VOID);
227
231typedef enum {
239
248OPERATE_RET http_dynamic_cfg_get(IN CONST HTTP_DYNAMIC_CFG_TYPE type, OUT ty_cJSON **result);
249
258OPERATE_RET http_dynamic_cfg_ack_v20(IN CONST CHAR_T* timezone_ackId, IN CONST CHAR_T* rateRule_actId);
259
267OPERATE_RET http_put_cloud_config(IN CONST CHAR_T *data);
268
276OPERATE_RET http_gw_property_save(IN CONST CHAR_T *data);
277
281typedef enum {
291
300
306OPERATE_RET http_gw_dev_sync_proc(VOID_T);
307
316OPERATE_RET httpc_iot_certificate_get_v10(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg);
317
326
335OPERATE_RET http_gw_custom_cfg_get(IN CONST INT_T biztype, OUT ty_cJSON **result);
336
344OPERATE_RET http_gw_get_active_info(OUT ty_cJSON **result);
352OPERATE_RET http_gw_location_info_get(OUT ty_cJSON **result);
353
354typedef PVOID_T RAW_HTTP_S;
365OPERATE_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);
366
376INT_T httpc_raw_read_content(IN RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len);
377
388INT_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);
389
397OPERATE_RET httpc_raw_close(IN RAW_HTTP_S p_raw_http);
398
408OPERATE_RET httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
409
420#define httpc_raw_get(p_url, pp_raw_http, offset, total_len) \
421 httpc_raw_get_with_head(p_url, pp_raw_http, offset, total_len, NULL, NULL) \
422
435OPERATE_RET httpc_raw_get_with_head(IN CONST CHAR_T *p_url, INOUT RAW_HTTP_S *pp_raw_http,
436 IN UINT_T offset, IN UINT_T total_len,
437 IN HTTP_HEAD_ADD_CB add_head_cb,
438 IN VOID* add_head_data);
439
449OPERATE_RET httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
450
458OPERATE_RET http_get_dev_token_create_v20(OUT ty_cJSON **result);
459
465CHAR_T *http_active_url(VOID);
466
472CHAR_T *http_url(VOID);
473
483OPERATE_RET httpc_active_shorturl_get(char *uuid, char *appid, ty_cJSON **result);
484
491OPERATE_RET tuya_get_ble_beacon_key(OUT CHAR_T **beaconKey);
492OPERATE_RET http_inf_client_post_field_psk_mode(IN CONST CHAR_T *url,
493 IN CONST HTTP_INF_CB callback,
494 IN CONST BYTE_T *data,
495 IN CONST UINT_T len,
496 IN HTTP_HEAD_ADD_CB add_head_cb,
497 IN VOID* add_head_data,
498 IN CONST CHAR_T *p_decode_key,
499 INOUT PVOID_T *pri_data,
500 IN CONST http_hdr_field_sel_t field_flags);
501
502OPERATE_RET httpc_dev_ext_module_report(OUT ty_cJSON **result);
503
507typedef enum {
508 ATOP_TYPE_ALL, // all atop is under control
509 ATOP_TYPE_ONLINE_DEBUG_LOG, // "atop.online.debug.log"
510 ATOP_TYPE_GET_DYNAMIC_CFG, // "tuya.device.dynamic.config.get"
511 ATOP_TYPE_GET_TIMER_COUNT, // "tuya.device.timer.count"
512 ATOP_TYPE_GET_UPGRADE_SILENT, // "tuya.device.upgrade.silent.get"
513 ATOP_TYPE_GET_NEWEST_SCHEMA, // "tuya.device.schema.newest.get"
514 ATOP_TYPE_UPDATE_VERSION // "tuya.device.versions.update"
516
517typedef enum {
518 ATOP_ACCESS_DISABLE,
519 ATOP_ACCESS_ENABLE
520} ATOP_ACCESS_E;
521
530OPERATE_RET tuya_set_atop_access(ATOP_TYPE_E type, ATOP_ACCESS_E access);
531
532#ifdef __cplusplus
533}
534#endif
535#endif
536
Facility of DevOS definitions
Wrapper of HTTP request and response
OPERATE_RET(* HTTP_INF_CB)(HTTP_INF_H_S *hand)
This API is used to handle customized HTTP response
Definition: http_inf.h:60
http_hdr_field_sel_t
Definition: httpc.h:95
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_notify_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result)
Get the count of local timers, without flow limit
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:281
@ DEV_STATUS_ENABLE
Definition: iot_httpc.h:289
@ DEV_STATUS_UNKNOWN
Definition: iot_httpc.h:283
@ DEV_STATUS_RESET
Definition: iot_httpc.h:285
@ DEV_STATUS_RESET_FACTORY
Definition: iot_httpc.h:287
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 tuya_set_atop_access(ATOP_TYPE_E type, ATOP_ACCESS_E access)
set atop access enable or disable
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:231
@ HTTP_DYNAMIC_CFG_TZ
Definition: iot_httpc.h:235
@ HTTP_DYNAMIC_CFG_ALL
Definition: iot_httpc.h:233
@ HTTP_DYNAMIC_CFG_RATERULE
Definition: iot_httpc.h:237
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 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 httpc_get_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 UINT_T offset, IN CONST BYTE_T *p_key, IN CONST UINT_T key_len, INOUT BYTE_T file_hmac[32])
Download file
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_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
ATOP_TYPE_E
Definition of Atop Access enable
Definition: iot_httpc.h:507
Definition: ty_cJSON.h:104