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#include "tuya_matop.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
40OPERATE_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);
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);
55OPERATE_RET httpc_common_post_raw(IN CONST CHAR_T *url, IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
56 IN CONST CHAR_T *uuid, IN CONST CHAR_T *aes_key, IN CONST CHAR_T *devid,
57 IN CHAR_T *post_data, IN UINT_T data_total_len, IN CONST CHAR_T *p_head_other,
58 OUT ty_cJSON **pp_result);
59
60OPERATE_RET httpc_common_post_session(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);
61
62OPERATE_RET httpc_common_post_sesssion_raw(
63 IN CONST CHAR_T *url,
64 IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
65 IN CONST CHAR_T *uuid, IN CONST CHAR_T *aes_key, IN CONST CHAR_T *devid,
66 IN CHAR_T *post_data, IN UINT_T data_total_len,IN CONST CHAR_T *p_head_other,
67 OUT ty_cJSON **pp_result, BOOL_T is_session);
68
76OPERATE_RET http_gw_get_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result);
77
85OPERATE_RET http_gw_notify_timer_cnt(IN CONST INT_T lastFetchTime, OUT ty_cJSON **result);
86
96OPERATE_RET http_gw_get_timer_content(IN CONST INT_T offset, IN CONST INT_T limit, OUT ty_cJSON **result);
97
105OPERATE_RET httpc_gw_extra_erro_code_tranfer(char *ErroValu);
106
112OPERATE_RET http_gw_reset(IN CONST GW_WORK_STAT_T stat);
113
121
130OPERATE_RET http_iot_dns_get_fast_cloud_url(CHAR_T *env);
131
137
146OPERATE_RET http_iot_dns_get_host_ip(IN CONST CHAR_T *domain, OUT ty_cJSON **result);
147
157OPERATE_RET http_gw_register_V41(OUT ty_cJSON **result);
158
166OPERATE_RET http_gw_active_v41(OUT ty_cJSON **result);
167
175OPERATE_RET http_gw_active_mesh(IN CONST CHAR_T *data, OUT ty_cJSON **result);
176
185
194OPERATE_RET http_ffs_pre_active(IN CONST CHAR_T *wss_token, IN CONST CHAR_T*gw_endpoint);
195
196typedef OPERATE_RET(*HTTP_GW_GET_FILE_DATA_CB)(IN PVOID_T priv_data, IN CONST UINT_T total_len, IN CONST UINT_T offset, \
197 IN CONST BYTE_T *data, IN CONST UINT_T len, OUT UINT_T *remain_len);
212OPERATE_RET httpc_get_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len,
213 IN CONST HTTP_GW_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data,
214 IN CONST UINT_T total_len, IN CONST UINT_T offset,
215 IN CONST BYTE_T *p_key, IN CONST UINT_T key_len, INOUT BYTE_T file_hmac[32]);
216#define http_gw_download_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, p_key, key_len, file_hmac) \
217 httpc_get_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, 0, p_key, key_len, file_hmac)
218
219
227OPERATE_RET http_pskkey_get(OUT ty_cJSON **result);
228
234OPERATE_RET http_put_rst_log(VOID);
235
239typedef enum {
247 HTTP_DYNAMIC_CFG_ALL = 0xFFFF
249
258OPERATE_RET http_dynamic_cfg_get(IN CONST HTTP_DYNAMIC_CFG_TYPE type, OUT ty_cJSON **result);
259
269OPERATE_RET http_dynamic_cfg_ack_v20(IN CONST CHAR_T* timezone_ackId, IN CONST CHAR_T* rateRule_actId, IN CONST CHAR_T* ability_actId);
270
278OPERATE_RET http_put_cloud_config(IN CONST CHAR_T *data);
279
287OPERATE_RET http_gw_property_save(IN CONST CHAR_T *data);
288
292typedef enum {
302
311
317OPERATE_RET http_gw_dev_sync_proc(VOID_T);
318
327OPERATE_RET httpc_iot_certificate_get_v10(OUT ty_cJSON **result, IN CONST CHAR_T *url_msg);
328
337
346OPERATE_RET http_gw_custom_cfg_get(IN CONST INT_T biztype, OUT ty_cJSON **result);
347
355OPERATE_RET http_gw_get_active_info(OUT ty_cJSON **result);
363OPERATE_RET http_gw_location_info_get(OUT ty_cJSON **result);
364
365typedef PVOID_T RAW_HTTP_S;
376OPERATE_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);
377
387INT_T httpc_raw_read_content(IN RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len);
388
399INT_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);
400
408OPERATE_RET httpc_raw_close(IN RAW_HTTP_S p_raw_http);
409
419OPERATE_RET httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
420
431#define httpc_raw_get(p_url, pp_raw_http, offset, total_len) \
432 httpc_raw_get_with_head(p_url, pp_raw_http, offset, total_len, NULL, NULL) \
433
446OPERATE_RET httpc_raw_get_with_head(IN CONST CHAR_T *p_url, INOUT RAW_HTTP_S *pp_raw_http,
447 IN UINT_T offset, IN UINT_T total_len,
448 IN HTTP_HEAD_ADD_CB add_head_cb,
449 IN VOID* add_head_data);
450
460OPERATE_RET httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT RAW_HTTP_S *pp_raw_http);
461
469OPERATE_RET http_get_dev_token_create_v20(OUT ty_cJSON **result);
470
476CHAR_T *http_active_url(VOID);
477
483CHAR_T *http_url(VOID);
484
494OPERATE_RET httpc_active_shorturl_get(char *uuid, char *appid, ty_cJSON **result);
495
502OPERATE_RET tuya_get_ble_beacon_key(OUT CHAR_T **beaconKey);
503OPERATE_RET http_inf_client_post_field_psk_mode(IN CONST CHAR_T *url,
504 IN CONST HTTP_INF_CB callback,
505 IN CONST BYTE_T *data,
506 IN CONST UINT_T len,
507 IN HTTP_HEAD_ADD_CB add_head_cb,
508 IN VOID* add_head_data,
509 IN CONST CHAR_T *p_decode_key,
510 INOUT PVOID_T *pri_data,
511 IN CONST http_hdr_field_sel_t field_flags);
512
513OPERATE_RET httpc_dev_ext_module_report(OUT ty_cJSON **result);
514
518typedef enum {
519 ATOP_TYPE_ONLINE_DEBUG_LOG, // "atop.online.debug.log"
520 ATOP_TYPE_GET_DYNAMIC_CFG, // "tuya.device.dynamic.config.get"
521 ATOP_TYPE_GET_TIMER_COUNT, // "tuya.device.timer.count"
522 ATOP_TYPE_GET_UPGRADE_SILENT, // "tuya.device.upgrade.silent.get"
523 ATOP_TYPE_GET_NEWEST_SCHEMA, // "tuya.device.schema.newest.get"
524 ATOP_TYPE_UPDATE_VERSION // "tuya.device.versions.update"
526
527typedef enum {
528 ATOP_ACCESS_DISABLE,
529 ATOP_ACCESS_ENABLE
530} ATOP_ACCESS_E;
531
540OPERATE_RET tuya_set_atop_access(ATOP_TYPE_E type, ATOP_ACCESS_E access);
541
547VOID httpc_update_localtime_set(BOOL_T is_auto_update);
548
556OPERATE_RET httpc_gw_get_device_auth(CHAR_T *product_id, CHAR_T *product_secret, CHAR_T * client_id, ty_cJSON **result);
557
558#ifdef __cplusplus
559}
560#endif
561#endif
562
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, IN CONST CHAR_T *ability_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:292
@ DEV_STATUS_ENABLE
Definition: iot_httpc.h:300
@ DEV_STATUS_UNKNOWN
Definition: iot_httpc.h:294
@ DEV_STATUS_RESET
Definition: iot_httpc.h:296
@ DEV_STATUS_RESET_FACTORY
Definition: iot_httpc.h:298
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
VOID httpc_update_localtime_set(BOOL_T is_auto_update)
Enable or disable time update from httpc (enable by default)
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_gw_get_device_auth(CHAR_T *product_id, CHAR_T *product_secret, CHAR_T *client_id, ty_cJSON **result)
Retrieve UUID and authkey
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:239
@ HTTP_DYNAMIC_CFG_TZ
Definition: iot_httpc.h:241
@ HTTP_DYNAMIC_CFG_ALL
Definition: iot_httpc.h:247
@ HTTP_DYNAMIC_CFG_RATERULE
Definition: iot_httpc.h:243
@ HTTP_DYNAMIC_CFG_SENIOR_ABILITY
Definition: iot_httpc.h:245
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:518
Definition: ty_cJSON.h:104