TuyaOS
tuya_matop.h
1#ifndef _TUYA_MATOP_H_
2#define _TUYA_MATOP_H_
3
4#include "tuya_cloud_types.h"
6#include "ty_cJSON.h"
7
8#if defined(ENABLE_MATOP) && (ENABLE_MATOP==1)
9
10typedef struct {
11 BOOL_T success; // response status
12 ty_cJSON *result; // json formatted result if json parse success, need release manually
13 UINT_T t; // uni-timestamp
14 VOID *user_data; // custom user data
15 UINT8_T *raw_data; // raw data reulst, if json parse failed
16 SIZE_T raw_data_len; // raw data length
17} mqtt_atop_response_t;
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
28typedef OPERATE_RET(*MQTT_ATOP_RESPONSE_CB)(mqtt_atop_response_t *response, VOID *user_data);
29
34VOID tuya_matop_init();
35
41BOOL_T tuya_matop_is_ready();
42
55OPERATE_RET tuya_matop_request_async(CONST CHAR_T *api_name,
56 CONST CHAR_T *api_ver,
57 CONST CHAR_T *data,
58 CONST CHAR_T *data_other,
59 UINT_T timeout,
60 MQTT_ATOP_RESPONSE_CB notify_cb,
61 VOID *user_data);
62
75OPERATE_RET tuya_matop_request_sync(CONST CHAR_T *api_name,
76 CONST CHAR_T *api_ver,
77 CONST CHAR_T *data,
78 CONST CHAR_T *data_other,
79 UINT_T timeout,
80 MQTT_ATOP_RESPONSE_CB notify_cb,
81 VOID *user_data);
82
94OPERATE_RET tuya_matop_request_sync_simple(CONST CHAR_T *api_name,
95 CONST CHAR_T *api_ver,
96 CONST CHAR_T *data,
97 CONST CHAR_T *data_other,
98 UINT_T timeout,
99 ty_cJSON **pp_result);
100
101#if 0
114#define matop_service_request_legacy(api_name, api_ver, uuid, devid, post_data, p_head_other, pp_result) \
115 ((void)uuid, (void)devid, \
116 tuya_matop_request_sync_simple(api_name, api_ver, post_data, p_head_other, 0, pp_result))
117
128#define matop_service_request_legacy_simple(api_name, api_ver, post_data, p_head_other, pp_result) \
129 tuya_matop_request_sync_simple(api_name, api_ver, post_data, p_head_other, 0, pp_result)
130
131
144OPERATE_RET matop_service_file_download_range(CONST CHAR_T* url,
145 UINT_T range_start,
146 UINT_T range_end,
147 UINT_T timeout,
148 CONST CHAR_T *data_other,
149 MQTT_ATOP_RESPONSE_CB notify_cb,
150 VOID* user_data);
151
164OPERATE_RET matop_service_file_download_simple(CONST CHAR_T* url,
165 UINT_T file_offset,
166 UINT_T dl_size,
167 UINT_T timeout,
168 CONST CHAR_T *data_other,
169 BYTE_T *buf,
170 UINT_T buf_len);
171#endif
172#ifdef __cplusplus
173}
174#endif
175#endif
176#endif
Definition: ty_cJSON.h:104