TuyaOS
tuya_iot_internal_api.h
浏览该文件的文档.
1
10#ifndef _TUYA_IOT_INTERNAL_API_H
11#define _TUYA_IOT_INTERNAL_API_H
12
13#include "tuya_cloud_types.h"
14#include "ty_cJSON.h"
15#include "tuya_cloud_com_defs.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/* cloud-storage api */
22//TODO
23
39OPERATE_RET iot_httpc_common_post_no_remalloc(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
40 IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid,
41 IN CHAR_T *post_data, IN UINT_T data_total_len,
42 IN CONST CHAR_T *p_head_other,
43 OUT ty_cJSON **pp_result);
44
58OPERATE_RET iot_httpc_common_post(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
59 IN CONST CHAR_T *uuid, IN CONST CHAR_T *devid,
60 IN CHAR_T *post_data,
61 IN CONST CHAR_T *p_head_other,
62 OUT ty_cJSON **pp_result);
63
75OPERATE_RET iot_httpc_common_post_simple(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver,
76 IN CHAR_T *post_data, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result);
77
78typedef OPERATE_RET(*IOT_HTTP_GET_FILE_DATA_CB)(IN PVOID_T priv_data, IN CONST UINT_T total_len, IN CONST UINT_T offset, \
79 IN CONST BYTE_T *data, IN CONST UINT_T len, OUT UINT_T *remain_len);
80
93OPERATE_RET iot_httpc_download_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len, \
94 IN CONST IOT_HTTP_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data, \
95 IN CONST UINT_T total_len, INOUT BYTE_T file_hmac[32]);
96
97/* mqtt api */
98typedef OPERATE_RET(*iot_mqc_protocol_handler_cb)(IN ty_cJSON *root_json);
99
109OPERATE_RET iot_mqc_app_register_cb(UINT_T mq_pro, iot_mqc_protocol_handler_cb handler);
110
111typedef VOID (*iot_mqc_publish_result_cb)(IN CONST OPERATE_RET op_ret, IN CONST VOID *prv_data);
124OPERATE_RET iot_mqc_send_custom_msg(IN CONST UINT_T protocol, IN CONST CHAR_T *data, IN CONST BYTE_T qos,
125 IN CONST UINT_T to_lmt, IN CONST iot_mqc_publish_result_cb cb, IN VOID *prv_data);
126
137OPERATE_RET iot_wd_common_write(IN CONST CHAR_T *key, IN CONST BYTE_T *value, IN CONST UINT_T len);
138
149OPERATE_RET iot_wd_common_read(IN CONST CHAR_T *key, OUT BYTE_T **value, OUT UINT_T *p_len);
150
159OPERATE_RET iot_wd_common_free_data(IN BYTE_T *data);
160
169OPERATE_RET iot_wd_common_delete(IN CONST CHAR_T *key);
170
179OPERATE_RET iot_wd_gw_desc_if_read(OUT VOID *di);
180
189OPERATE_RET iot_wd_gw_write_country_code(CHAR_T *country_code);
190
191typedef BYTE_T IOT_VAR_TP_T;
192#define VT_CHAR 0
193#define VT_BYTE 1
194#define VT_SHORT 2
195#define VT_USHORT 3
196#define VT_INT 4
197#define VT_BOOL 5
198#define VT_STRING 6
199#define VT_RAW 7
200
201typedef struct {
202 CHAR_T *key;
203 IOT_VAR_TP_T vt;
204 VOID *val;
205 USHORT_T len;
207
218OPERATE_RET iot_wd_utils_serialize(IN CONST IOT_TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt, \
219 OUT CHAR_T **out, OUT UINT_T *out_len);
220
228OPERATE_RET iot_wd_utils_free_outbuf(IN CHAR_T *out_buf);
229
239OPERATE_RET iot_wd_utils_deserialize(IN CONST CHAR_T *in, INOUT IOT_TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt);
240
248OPERATE_RET iot_gw_user_token_bind(IN CHAR_T *token);
249
258OPERATE_RET iot_put_cloud_config(IN CONST CHAR_T *data);
259
260/***********************************************************
261网关升级时增加的前置过滤处理函数
262如果*handled返回为TRUE,那么就不在通过正常的用户回调通知用户升级
263如果*handled返回为FALSE,那么仍然通过正常的用户回调通知用户升级
264***********************************************************/
265typedef VOID (*PRE_GW_UG_INFORM_CB)(INOUT BOOL_T *handled, IN CONST FW_UG_S *fw);
266
274VOID iot_register_pre_gw_ug_cb(IN PRE_GW_UG_INFORM_CB pre_ug_cb);
275
276/*
277#define MBEDTLS_SSL_VERIFY_NONE 0
278#define MBEDTLS_SSL_VERIFY_OPTIONAL 1
279#define MBEDTLS_SSL_VERIFY_REQUIRED 2
280*/
281
292INT_T iot_tls_register_x509_crt_der(VOID *p_ctx, UCHAR_T *p_der, UINT_T der_len);
293
299OPERATE_RET iot_gw_update_versions(VOID);
300
301/* RAW HTTP API */
302
303typedef PVOID_T IOT_RAW_HTTP_S;
304
314OPERATE_RET iot_httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT IOT_RAW_HTTP_S *pp_raw_http);
315
326OPERATE_RET iot_httpc_raw_get(IN CONST CHAR_T *p_url, INOUT IOT_RAW_HTTP_S *pp_raw_http, IN UINT_T offset, IN UINT_T total_len);
327
337OPERATE_RET iot_httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT IOT_RAW_HTTP_S *pp_raw_http);
338
349INT_T iot_httpc_raw_write_content(IN IOT_RAW_HTTP_S p_raw_http, IN CONST BYTE_T *buf, IN CONST UINT_T buf_len, BOOL_T chunked);
350
361OPERATE_RET iot_httpc_raw_read_resp_header(INOUT IOT_RAW_HTTP_S p_raw_http, OUT INT_T *p_status_code, OUT BOOL_T *p_chunked, OUT UINT_T *p_content_len);
362
372INT_T iot_httpc_raw_read_content(IN IOT_RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len);
373
381OPERATE_RET iot_httpc_raw_close(IN IOT_RAW_HTTP_S p_raw_http);
382
390OPERATE_RET tuya_iot_put_cloud_config(IN CONST CHAR_T *data);
391
400BOOL_T tuya_iot_compare_two_string(IN CONST CHAR_T *cString1, IN CONST CHAR_T *cString2);
401
402typedef OPERATE_RET(*iot_special_dp_cb)(IN CONST UINT16_T dpid, IN CONST ty_cJSON *dp_obj);
403
411OPERATE_RET iot_special_dp_register_cb(IN iot_special_dp_cb handler);
412
421BOOL_T tuya_iot_compare_two_string(IN CONST CHAR_T *cString1, IN CONST CHAR_T *cString2);
422
433CHAR_T* tuya_iot_get_json_safety_string(IN CONST CHAR_T *json);
434
435#ifdef __cplusplus
436}
437#endif
438#endif /*_TUYA_IOT_INTERNAL_API_H*/
439
tuya sdk ota firmware info
Definition: tuya_cloud_com_defs.h:663
Definition: tuya_iot_internal_api.h:201
Definition: ty_cJSON.h:104
CHAR_T * tuya_iot_get_json_safety_string(IN CONST CHAR_T *json)
tuya_iot_get_json_safety_string @desc will change the (") to the (\") in json file
OPERATE_RET iot_wd_utils_serialize(IN CONST IOT_TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt, OUT CHAR_T **out, OUT UINT_T *out_len)
iot_wd_utils_serialize
OPERATE_RET iot_httpc_raw_post(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT IOT_RAW_HTTP_S *pp_raw_http)
iot_httpc_raw_post
OPERATE_RET iot_special_dp_register_cb(IN iot_special_dp_cb handler)
iot_special_dp_register_cb
OPERATE_RET iot_httpc_raw_close(IN IOT_RAW_HTTP_S p_raw_http)
iot_httpc_raw_close
OPERATE_RET iot_wd_common_delete(IN CONST CHAR_T *key)
iot_wd_common_delete @desc wd delete
OPERATE_RET iot_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)
iot_httpc_common_post
OPERATE_RET iot_httpc_raw_read_resp_header(INOUT IOT_RAW_HTTP_S p_raw_http, OUT INT_T *p_status_code, OUT BOOL_T *p_chunked, OUT UINT_T *p_content_len)
iot_httpc_raw_read_resp_header
OPERATE_RET iot_httpc_download_file(IN CONST CHAR_T *url, IN CONST UINT_T mlk_buf_len, IN CONST IOT_HTTP_GET_FILE_DATA_CB gfd_cb, IN PVOID_T priv_data, IN CONST UINT_T total_len, INOUT BYTE_T file_hmac[32])
iot_httpc_download_file
OPERATE_RET iot_wd_common_read(IN CONST CHAR_T *key, OUT BYTE_T **value, OUT UINT_T *p_len)
iot_wd_common_read @desc wd read
OPERATE_RET iot_mqc_send_custom_msg(IN CONST UINT_T protocol, IN CONST CHAR_T *data, IN CONST BYTE_T qos, IN CONST UINT_T to_lmt, IN CONST iot_mqc_publish_result_cb cb, IN VOID *prv_data)
iot_mqc_send_custom_msg
INT_T iot_tls_register_x509_crt_der(VOID *p_ctx, UCHAR_T *p_der, UINT_T der_len)
iot_tls_register_x509_crt_der @desc Parse one or more PEM certificates from a buffer and add them to ...
OPERATE_RET iot_httpc_common_post_simple(IN CONST CHAR_T *api_name, IN CONST CHAR_T *api_ver, IN CHAR_T *post_data, IN CONST CHAR_T *p_head_other, OUT ty_cJSON **pp_result)
iot_httpc_common_post_simple
VOID iot_register_pre_gw_ug_cb(IN PRE_GW_UG_INFORM_CB pre_ug_cb)
iot_register_pre_gw_ug_cb
INT_T iot_httpc_raw_read_content(IN IOT_RAW_HTTP_S p_raw_http, IN BYTE_T *buf, IN CONST UINT_T buf_len)
iot_httpc_raw_read_content
OPERATE_RET iot_httpc_raw_put(IN CONST CHAR_T *p_url, IN CONST UINT_T data_total_len, INOUT IOT_RAW_HTTP_S *pp_raw_http)
iot_httpc_raw_put
OPERATE_RET iot_wd_gw_write_country_code(CHAR_T *country_code)
iot_wd_gw_write_country_code @desc wd write country code
OPERATE_RET tuya_iot_put_cloud_config(IN CONST CHAR_T *data)
tuya_iot_put_cloud_config
OPERATE_RET iot_put_cloud_config(IN CONST CHAR_T *data)
iot_put_cloud_config @desc the project switches to the release, reporting configuration
OPERATE_RET iot_mqc_app_register_cb(UINT_T mq_pro, iot_mqc_protocol_handler_cb handler)
iot_mqc_app_register_cb @desc 注册mqtt事件回调函数
OPERATE_RET iot_gw_update_versions(VOID)
iot_gw_update_versions
OPERATE_RET iot_gw_user_token_bind(IN CHAR_T *token)
iot_gw_user_token_bind
OPERATE_RET iot_wd_common_write(IN CONST CHAR_T *key, IN CONST BYTE_T *value, IN CONST UINT_T len)
iot_wd_common_write @desc wd write
OPERATE_RET iot_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)
iot_httpc_common_post_no_remalloc @desc http api
OPERATE_RET iot_wd_common_free_data(IN BYTE_T *data)
iot_wd_common_free_data @desc wd free
OPERATE_RET iot_wd_gw_desc_if_read(OUT VOID *di)
iot_wd_gw_desc_if_read @desc wd read gateway information
OPERATE_RET iot_wd_utils_free_outbuf(IN CHAR_T *out_buf)
iot_wd_utils_free_outbuf
INT_T iot_httpc_raw_write_content(IN IOT_RAW_HTTP_S p_raw_http, IN CONST BYTE_T *buf, IN CONST UINT_T buf_len, BOOL_T chunked)
iot_httpc_raw_write_content
OPERATE_RET iot_httpc_raw_get(IN CONST CHAR_T *p_url, INOUT IOT_RAW_HTTP_S *pp_raw_http, IN UINT_T offset, IN UINT_T total_len)
iot_httpc_raw_get
BOOL_T tuya_iot_compare_two_string(IN CONST CHAR_T *cString1, IN CONST CHAR_T *cString2)
tuya_iot_compare_two_string
OPERATE_RET iot_wd_utils_deserialize(IN CONST CHAR_T *in, INOUT IOT_TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt)
iot_wd_utils_deserialize