|
TuyaOS
|
HTTP APIs to interact with TUYA cloud 更多...
#include "tuya_cloud_types.h"#include "ty_cJSON.h"#include "gw_intf.h"#include "http_inf.h"#include "tuya_matop.h"
宏定义 | |
| #define | http_gw_download_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, p_key, key_len, file_hmac) httpc_get_file(url, mlk_buf_len, gfd_cb, priv_data, total_len, 0, p_key, key_len, file_hmac) |
| #define | httpc_raw_get(p_url, pp_raw_http, offset, total_len) httpc_raw_get_with_head(p_url, pp_raw_http, offset, total_len, NULL, NULL) \ |
| Raw HTTP GET request 更多... | |
枚举 | |
| enum | ATOP_ACCESS_E { ATOP_ACCESS_DISABLE , ATOP_ACCESS_ENABLE } |
| enum | ATOP_TYPE_E { ATOP_TYPE_ONLINE_DEBUG_LOG , ATOP_TYPE_GET_DYNAMIC_CFG , ATOP_TYPE_GET_TIMER_COUNT , ATOP_TYPE_GET_UPGRADE_SILENT , ATOP_TYPE_GET_NEWEST_SCHEMA , ATOP_TYPE_UPDATE_VERSION } |
| Definition of Atop Access enable | |
| enum | DEV_SYNC_STATUS_E { DEV_STATUS_UNKNOWN , DEV_STATUS_RESET , DEV_STATUS_RESET_FACTORY , DEV_STATUS_ENABLE } |
| Definition of status to check 更多... | |
| enum | HTTP_DYNAMIC_CFG_TYPE { HTTP_DYNAMIC_CFG_ALL , HTTP_DYNAMIC_CFG_TZ , HTTP_DYNAMIC_CFG_RATERULE } |
| Definition of dynamic config 更多... | |
函数 | |
| CHAR_T * | http_active_url (VOID) |
| Retrieve active HTTP url of TUYA cloud 更多... | |
| OPERATE_RET | http_ble_actived_enable_wifi (VOID) |
| Enalbe wifi after activated by BLE 更多... | |
| 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_dynamic_cfg_get (IN CONST HTTP_DYNAMIC_CFG_TYPE type, OUT ty_cJSON **result) |
| Retrieve dynamic config 更多... | |
| 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_get_dev_token_create_v20 (OUT ty_cJSON **result) |
| Retrieve token from cloud 更多... | |
| 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_gw_active_v41 (OUT ty_cJSON **result) |
| Register and active a device on TUYA cloud 更多... | |
| OPERATE_RET | http_gw_custom_cfg_get (IN CONST INT_T biztype, OUT ty_cJSON **result) |
| Retrieve customized config 更多... | |
| OPERATE_RET | http_gw_dev_sync_check (DEV_SYNC_STATUS_E *p_status) |
| Retrieve device status 更多... | |
| OPERATE_RET | http_gw_dev_sync_proc (VOID_T) |
| Sync device status 更多... | |
| OPERATE_RET | http_gw_get_active_info (OUT ty_cJSON **result) |
| Register and active a device on TUYA cloud 更多... | |
| 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_get_timer_content (IN CONST INT_T offset, IN CONST INT_T limit, OUT ty_cJSON **result) |
| Get content local timers 更多... | |
| OPERATE_RET | http_gw_location_info_get (OUT ty_cJSON **result) |
| Retrieve location info 更多... | |
| 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_property_save (IN CONST CHAR_T *data) |
| Save property to TUYA cloud 更多... | |
| OPERATE_RET | http_gw_register_V41 (OUT ty_cJSON **result) |
| Register a device on TUYA cloud 更多... | |
| OPERATE_RET | http_gw_reset (IN CONST GW_WORK_STAT_T stat) |
| Reset device 更多... | |
| OPERATE_RET | http_gw_update_version_v41 (VOID) |
| Update versions of device on TUYA cloud 更多... | |
| OPERATE_RET | http_inf_client_post_field_psk_mode (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, IN CONST BYTE_T *data, IN CONST UINT_T len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data, IN CONST CHAR_T *p_decode_key, INOUT PVOID_T *pri_data, IN CONST http_hdr_field_sel_t field_flags) |
| VOID | http_iot_dns_cache_cloud_url (VOID) |
| Load URLs and related Ips of TUYA cloud to DNS cache | |
| 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_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 later on 更多... | |
| 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 | http_pskkey_get (OUT ty_cJSON **result) |
| Retrieve PSK key 更多... | |
| OPERATE_RET | http_put_cloud_config (IN CONST CHAR_T *data) |
| Upload config to TUYA cloud 更多... | |
| OPERATE_RET | http_put_rst_log (VOID) |
| Upload information of device reset to TUYA cloud 更多... | |
| CHAR_T * | http_url (VOID) |
| Retrieve active HTTP url of TUYA cloud 更多... | |
| OPERATE_RET | httpc_active_shorturl_get (char *uuid, char *appid, ty_cJSON **result) |
| Retrieve short url of QR active 更多... | |
| 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_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_common_post_raw (IN CONST CHAR_T *url, IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CONST CHAR_T *uuid, IN CONST CHAR_T *aes_key, 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) |
| OPERATE_RET | httpc_dev_ext_module_report (OUT ty_cJSON **result) |
| 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 | httpc_gw_extra_erro_code_tranfer (char *ErroValu) |
| Transfer HTTP error string to error code 更多... | |
| OPERATE_RET | httpc_iot_certificate_get_v10 (OUT ty_cJSON **result, IN CONST CHAR_T *url_msg) |
| Retrieve certs of special domain 更多... | |
| OPERATE_RET | httpc_iot_cloud_storage_encrypt_key_get (OUT ty_cJSON **result) |
| Retrieve encrypt key of cloud storage 更多... | |
| OPERATE_RET | httpc_raw_close (IN RAW_HTTP_S p_raw_http) |
| Close raw HTTP request 更多... | |
| 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 | 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_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 更多... | |
| 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 | 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 更多... | |
| 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 更多... | |
| VOID | httpc_update_localtime_set (BOOL_T is_auto_update) |
| Enable or disable time update from httpc (enable by default) 更多... | |
| OPERATE_RET | tuya_get_ble_beacon_key (OUT CHAR_T **beaconKey) |
| OPERATE_RET | tuya_set_atop_access (ATOP_TYPE_E type, ATOP_ACCESS_E access) |
| set atop access enable or disable 更多... | |
HTTP APIs to interact with TUYA cloud
| #define httpc_raw_get | ( | p_url, | |
| pp_raw_http, | |||
| offset, | |||
| total_len | |||
| ) | httpc_raw_get_with_head(p_url, pp_raw_http, offset, total_len, NULL, NULL) \ |
Raw HTTP GET request
| [in] | p_url | URL to request |
| [in,out] | pp_raw_http | Pointer to RAW_HTTP_S |
| [in] | offset | Offset of buffer |
| [in] | total_len | Total length of buffer |
| enum DEV_SYNC_STATUS_E |
| CHAR_T * http_active_url | ( | VOID | ) |
Retrieve active HTTP url of TUYA cloud
| OPERATE_RET http_ble_actived_enable_wifi | ( | VOID | ) |
Enalbe wifi after activated by BLE
| 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)
| [in] | timezone_ackId | ACK id of timezone |
| [in] | rateRule_actId | ACK id of dp rate rule |
| OPERATE_RET http_dynamic_cfg_get | ( | IN CONST HTTP_DYNAMIC_CFG_TYPE | type, |
| OUT ty_cJSON ** | result | ||
| ) |
Retrieve dynamic config
| [in] | type | Defined by HTTP_DYNAMIC_CFG_TYPE |
| [out] | result | Json encoded result |
| OPERATE_RET http_ffs_pre_active | ( | IN CONST CHAR_T * | wss_token, |
| IN CONST CHAR_T * | gw_endpoint | ||
| ) |
Pre-active of FFS netcfg
| [in] | wss_token | wss token |
| [in] | gw_endpoint | gateway endpoint |
| OPERATE_RET http_get_dev_token_create_v20 | ( | OUT ty_cJSON ** | result | ) |
Retrieve token from cloud
| [out] | result | Json encoded result |
| 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
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_active_v41 | ( | OUT ty_cJSON ** | result | ) |
Register and active a device on TUYA cloud
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_custom_cfg_get | ( | IN CONST INT_T | biztype, |
| OUT ty_cJSON ** | result | ||
| ) |
Retrieve customized config
| [in] | biztype | Customized key |
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_dev_sync_check | ( | DEV_SYNC_STATUS_E * | p_status | ) |
Retrieve device status
| [out] | p_status | Device status on TUYA cloud, defined by DEV_SYNC_STATUS_E |
| OPERATE_RET http_gw_dev_sync_proc | ( | VOID_T | ) |
Sync device status
| OPERATE_RET http_gw_get_active_info | ( | OUT ty_cJSON ** | result | ) |
Register and active a device on TUYA cloud
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_get_timer_cnt | ( | IN CONST INT_T | lastFetchTime, |
| OUT ty_cJSON ** | result | ||
| ) |
Get the count of local timers
| [in] | lastFetchTime | Last fetch time returned |
| 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
| [in] | offset | Timer index |
| [in] | limit | Max count of timers |
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_location_info_get | ( | OUT ty_cJSON ** | result | ) |
Retrieve location info
| [out] | result | Json encoded result |
| 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
| [in] | lastFetchTime | Last fetch time returned |
| OPERATE_RET http_gw_property_save | ( | IN CONST CHAR_T * | data | ) |
Save property to TUYA cloud
| [in] | data | Private data to upload |
| OPERATE_RET http_gw_register_V41 | ( | OUT ty_cJSON ** | result | ) |
Register a device on TUYA cloud
| [out] | result | Json encoded result |
| OPERATE_RET http_gw_reset | ( | IN CONST GW_WORK_STAT_T | stat | ) |
Reset device
| OPERATE_RET http_gw_update_version_v41 | ( | VOID | ) |
Update versions of device on TUYA cloud
| [out] | result | Json encoded result |
| 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_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 later on
| [in] | env | Device runtime env |
| 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
| [in] | domain | Domain name |
| [out] | result | Json encoded result |
| OPERATE_RET http_pskkey_get | ( | OUT ty_cJSON ** | result | ) |
Retrieve PSK key
| [out] | result | Json encoded result |
| OPERATE_RET http_put_cloud_config | ( | IN CONST CHAR_T * | data | ) |
Upload config to TUYA cloud
| [in] | data | Private data to upload |
| OPERATE_RET http_put_rst_log | ( | VOID | ) |
Upload information of device reset to TUYA cloud
| CHAR_T * http_url | ( | VOID | ) |
Retrieve active HTTP url of TUYA cloud
| OPERATE_RET httpc_active_shorturl_get | ( | char * | uuid, |
| char * | appid, | ||
| ty_cJSON ** | result | ||
| ) |
Retrieve short url of QR active
| [in] | uuid | UUID of device |
| [in] | appid | ID of app |
| [out] | result | Json encoded result |
| 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
| [in] | api_name | Name of API |
| [in] | api_ver | Version of API |
| [in] | uuid | UUID of device |
| [in] | devid | ID of device |
| [in] | post_data | Pointer to data |
| [in] | p_head_other | Additional header to send |
| [out] | pp_result | Json encoded result |
| 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
| [in] | api_name | Name of API |
| [in] | api_ver | Version of API |
| [in] | uuid | UUID of device |
| [in] | devid | ID of device |
| [in] | post_data | Pointer to data |
| [in] | data_total_len | Length of data |
| [in] | p_head_other | Additional header to send |
| [out] | pp_result | Json encoded result |
| 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
| [in] | url | URL of the file to download |
| [in] | mlk_buf_len | block size of dowload buffer |
| [in] | gfd_cb | Hander when download file |
| [in] | priv_data | Private data |
| [in] | total_len | Total length of file |
| [in] | p_key | HTTP decode key |
| [in] | key_len | Lenght od decode key |
| [in,out] | file_hmac | HMAC of download file |
| OPERATE_RET httpc_gw_extra_erro_code_tranfer | ( | char * | ErroValu | ) |
Transfer HTTP error string to error code
| [in] | ErroValu | HTTP error state |
| OPERATE_RET httpc_iot_certificate_get_v10 | ( | OUT ty_cJSON ** | result, |
| IN CONST CHAR_T * | url_msg | ||
| ) |
Retrieve certs of special domain
| [in] | url_msg | Domain name to get certs |
| [out] | result | Json encoded result |
| OPERATE_RET httpc_iot_cloud_storage_encrypt_key_get | ( | OUT ty_cJSON ** | result | ) |
Retrieve encrypt key of cloud storage
| [out] | result | Json encoded result |
| OPERATE_RET httpc_raw_close | ( | IN RAW_HTTP_S | p_raw_http | ) |
Close raw HTTP request
| [in] | pp_raw_http | Pointer to RAW_HTTP_S |
| 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
| [in] | p_url | URL to request |
| [in,out] | pp_raw_http | Pointer to RAW_HTTP_S |
| [in] | offset | Offset of buffer |
| [in] | total_len | Total length of buffer |
| [in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
| [in] | add_head_data | Header data of add_head_cb |
| 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
| [in] | p_url | URL to request |
| [in] | data_total_len | Total length of raw request |
| [in,out] | pp_raw_http | Pointer to RAW_HTTP_S |
| 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
| [in] | p_url | URL to request |
| [in] | data_total_len | Total length of raw request |
| [in,out] | pp_raw_http | Pointer to RAW_HTTP_S |
| 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
| [in] | pp_raw_http | Pointer to RAW_HTTP_S |
| [in] | buf | Pointer of data to write |
| [in] | buf_len | Length of buffer |
| 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
| [in,out] | pp_raw_http | Pointer to RAW_HTTP_S |
| [out] | p_status_code | Status code from HTTP response |
| [out] | p_chunked | Data is chunk or not |
| [out] | p_content_len | Total length of response content |
| 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
| [in] | pp_raw_http | Pointer to RAW_HTTP_S |
| [in] | buf | Pointer of data to write |
| [in] | buf_len | Length of buffer |
| [in] | chunked | Is chunk enabled |
| VOID httpc_update_localtime_set | ( | BOOL_T | is_auto_update | ) |
Enable or disable time update from httpc (enable by default)
| [in] | is_auto_update | Auto update from httpc or not |
| OPERATE_RET tuya_set_atop_access | ( | ATOP_TYPE_E | type, |
| ATOP_ACCESS_E | access | ||
| ) |
set atop access enable or disable
| [in] | atop | type |
| [in] | atop | access |