TuyaOS
smart_frame.h
浏览该文件的文档.
1
11#ifndef _SMART_FRAME_H
12#define _SMART_FRAME_H
13
14#include "tuya_cloud_types.h"
15#include "gw_intf.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
24typedef struct {
25 DP_CMD_TYPE_E tp; //command source
26 ty_cJSON *cmd_js; //command content
28
32typedef struct msg_data_s {
33 UINT_T serno; //serial number
34 UINT_T len; //message data lenth
35 BYTE_T data[0];//message data
37
47OPERATE_RET smart_frame_init(VOID);
48
58OPERATE_RET sf_send_gw_dev_cmd(IN SF_GW_DEV_CMD_S *gd_cmd);
59
70
85CHAR_T *sf_pack_local_obj_dp_data(IN DEV_CNTL_N_S *dev_cntl, IN CONST UINT_T max_len, IN CONST BOOL_T addDevId, OUT BOOL_T *p_all_data_packed, BOOL_T reset_flow_ctl, IN CONST BOOL_T is_lan, OUT CHAR_T** time_str);
86
96UINT_T sf_get_serial_no(VOID);
97
108OPERATE_RET sf_respone_obj_dp_query(IN UINT_T cmd_tp, IN CONST ty_cJSON *pCidArr, IN CONST ty_cJSON *pDpIdArr);
109
120DP_CNTL_S * sf_dp_data_get(IN CHAR_T *id, IN CONST uint8_t dp_id);
121
131BOOL_T sf_dp_data_is_equl(IN ty_cJSON *dp_cmd);
132
133//special dp callback function
134typedef OPERATE_RET(*sf_special_dp_cb)(IN CONST UINT16_T dpid, IN CONST ty_cJSON *dp_obj);
135
145OPERATE_RET sf_special_dp_register_cb(IN sf_special_dp_cb handler);
146
159OPERATE_RET sf_dp_low_power_query(IN CONST UCHAR_T *dps, IN CONST UINT_T cnt,
160 OUT TY_RECV_OBJ_DP_S **obj_dps, OUT TY_RECV_MULTI_RAW_DP_S **raw_dps);
161
162//callback function by different kind of transport type
163typedef OPERATE_RET(*sf_trans_type_cb)(IN CONST UINT16_T dpid, IN CONST ty_cJSON *data_js);
164
175OPERATE_RET sf_trans_type_register_cb(IN CONST DP_TRANS_TYPE_T trans, IN sf_trans_type_cb handler);
176
186OPERATE_RET sf_dp_set_delete_null_dp(BOOL_T enable);
187
195OPERATE_RET sf_dp_set_report_timeout(UINT_T timeout_s);
196
197
198//callback function for subdevice
199typedef OPERATE_RET(*subdev_dev_cntl_cb)(IN DEV_CNTL_N_S *subdev_cntl, VOID *param);
200//callback function for traversal subdevice
201typedef OPERATE_RET(*sf_subdev_dev_cntl_traversal_cb)(subdev_dev_cntl_cb, VOID *param);
202
203//callback function for checking whether the subdevice needs to execute the reliable trasmission
204typedef BOOL_T(*sf_subdev_reliable_transfer_check_cb)(IN CHAR_T *id);
205
206//callback function for getting the time of subdevice's reliable trasmission
207typedef UINT_T(*sf_subdev_reliable_transfer_time_get_cb)(IN CHAR_T *id);
208
209//callback function for checking whether the subdevice nedds report
210typedef BOOL_T(*sf_subdev_report_check_cb)(IN CHAR_T *id);
211
215typedef struct {
217 sf_subdev_dev_cntl_traversal_cb traversal_cb;
219 sf_subdev_reliable_transfer_check_cb rt_check_cb;
221 sf_subdev_reliable_transfer_time_get_cb rt_time_get_cb;
223 sf_subdev_report_check_cb rpt_check_cb;
225
236
240typedef struct {
241 CHAR_T* dev_id; // device id
242 TY_OBJ_DP_S* data; // dp data
243 UINT_T cnt; // dp count
245
249typedef struct {
250 TY_OBJ_DP_DATA_S obj_dp; // dp data information
251 BOOL_T force_send; // if report dp forcely or not
252 DP_REPT_FORM_T rept_form; // report form, 0:active, 1:query, 2:sync
253 BYTE_T is_ble_roam; // ble roam flag, 0: no, 1:yes
254 UINT_T rept_seq; // report sequence for ble roam
255 //TY_DP_REPT_PARAM_ASYNC rept_param; // report param
257
261typedef struct {
262 TY_OBJ_DP_DATA_S obj_dp; // dp data information
263 UINT_T timeout; // report timeout
264 BOOL_T auto_retrans; // if re-report or not
265 BYTE_T is_ble_roam; // ble roam flag, 0: no, 1:yes
266 UINT_T rept_seq; // report sequence for ble roam
267 //TY_DP_REPT_PARAM_SYNC rept_param; // report param
269
273typedef struct {
274 CHAR_T* dev_id; // device id
275 BYTE_T dpid; // dp id
276 BYTE_T* data; // dp data
277 UINT_T len; // dp data lenth
278 CHAR_T* time_str; // dp report time
279 UINT_T timeout; // report timeout
280 BOOL_T auto_retrans; // if re-report or not
281 BYTE_T is_ble_roam; // ble roam flag, 0: no, 1:yes
282 UINT_T rept_seq; // report sequence for ble roam
283 BOOL_T is_async; // report async
284 //TY_DP_REPT_PARAM_SYNC rept_param; // report param
286
296VOID_T ty_print_dp_time(VOID_T);
297
307OPERATE_RET sf_regist_dp_rept_cb(IN DP_REPT_HADLE_CB_S* dp_rept_cbs);
308
319OPERATE_RET ty_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN VOID_T* dp_rept);
320
336OPERATE_RET ty_get_obj_dp_from_json(IN CHAR_T *dev_id, IN CONST CHAR_T *json_str, OUT TY_OBJ_DP_S **dp_data, OUT UINT_T *cnt);
337
349VOID_T ty_free_obj_dp_data(TY_OBJ_DP_S* dp_data, UINT_T cnt);
350
360VOID ty_set_dpid_rept_rule(UINT8_T rept_rule);
361
367UINT8_T ty_get_dpid_rept_rule(VOID_T);
368
381BOOL_T ty_check_dpid_need_rept(CHAR_T *dev_id, BYTE_T dpid, DP_CMD_TYPE_E type, DP_DESC_IF_S *dp_desc);
382
383#if defined(ENABLE_COMMUNICATE_PRIORITY) && (ENABLE_COMMUNICATE_PRIORITY==1)
395OPERATE_RET ty_set_dp_rept_chan(IN UINT8_T chan[], UINT8_T cnt, BOOL_T only);
396
406UINT8_T* ty_get_dp_rept_chan(UINT8_T* cnt);
407#endif
408
409#ifdef __cplusplus
410}
411#endif
412#endif
413
Facility of DevOS definitions
OPERATE_RET ty_get_obj_dp_from_json(IN CHAR_T *dev_id, IN CONST CHAR_T *json_str, OUT TY_OBJ_DP_S **dp_data, OUT UINT_T *cnt)
ty_dp_json_to_obj @desc transfer json format dp to object
UINT8_T ty_get_dpid_rept_rule(VOID_T)
get dp id report rule
UINT_T sf_get_serial_no(VOID)
Get serial number for dp report
CHAR_T * sf_pack_local_obj_dp_data(IN DEV_CNTL_N_S *dev_cntl, IN CONST UINT_T max_len, IN CONST BOOL_T addDevId, OUT BOOL_T *p_all_data_packed, BOOL_T reset_flow_ctl, IN CONST BOOL_T is_lan, OUT CHAR_T **time_str)
Packed the local dp data as string in json format
OPERATE_RET sf_dp_set_delete_null_dp(BOOL_T enable)
Set enable switch for deleting null dp
OPERATE_RET sf_trans_type_register_cb(IN CONST DP_TRANS_TYPE_T trans, IN sf_trans_type_cb handler)
Register callback function for different kind of transport type
VOID ty_set_dpid_rept_rule(UINT8_T rept_rule)
set dp id report rule
OPERATE_RET sf_dp_set_report_timeout(UINT_T timeout_s)
Set default dp report timeout
struct msg_data_s MSG_DATA_S
info of dp message data
OPERATE_RET sf_regist_dp_rept_cb(IN DP_REPT_HADLE_CB_S *dp_rept_cbs)
Register callback function for dp report
VOID_T ty_free_obj_dp_data(TY_OBJ_DP_S *dp_data, UINT_T cnt)
ty_free_obj_dp_data @desc free memory of object dp
OPERATE_RET sf_special_dp_register_cb(IN sf_special_dp_cb handler)
Register special dp callback function
OPERATE_RET smart_frame_init(VOID)
Smart frame init
DP_CNTL_S * sf_dp_data_get(IN CHAR_T *id, IN CONST uint8_t dp_id)
Get dp control information
VOID sf_start_sync_obj_dp(VOID)
Start to synchronize dp data
OPERATE_RET ty_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN VOID_T *dp_rept)
Report dp data
OPERATE_RET sf_send_gw_dev_cmd(IN SF_GW_DEV_CMD_S *gd_cmd)
Send dp command
OPERATE_RET sf_dp_low_power_query(IN CONST UCHAR_T *dps, IN CONST UINT_T cnt, OUT TY_RECV_OBJ_DP_S **obj_dps, OUT TY_RECV_MULTI_RAW_DP_S **raw_dps)
Query dp for low power
BOOL_T ty_check_dpid_need_rept(CHAR_T *dev_id, BYTE_T dpid, DP_CMD_TYPE_E type, DP_DESC_IF_S *dp_desc)
check dp id need report
BOOL_T sf_dp_data_is_equl(IN ty_cJSON *dp_cmd)
Check the dp data is same
OPERATE_RET sf_subdev_register_cb(IN SF_SUBDEV_HANDLE_CB_S *cbs)
Register callback function for subdevice
OPERATE_RET sf_respone_obj_dp_query(IN UINT_T cmd_tp, IN CONST ty_cJSON *pCidArr, IN CONST ty_cJSON *pDpIdArr)
Response for dp query
VOID_T ty_print_dp_time(VOID_T)
Print the key time for dp report
Definition of dp control
Definition: gw_intf.h:293
Definition of dp description
Definition: tuya_cloud_com_defs.h:392
Definition of DP handlers
Definition: tuya_cloud_com_defs.h:644
info of dp command
Definition: smart_frame.h:24
callback function of subdevice handle
Definition: smart_frame.h:215
dp data information
Definition: smart_frame.h:240
dp data report information for object type
Definition: smart_frame.h:249
Definition of structured dp
Definition: tuya_cloud_com_defs.h:448
dp data report information for raw type
Definition: smart_frame.h:273
Definition of recved raw dp
Definition: tuya_cloud_com_defs.h:544
Definition of recved structured dp
Definition: tuya_cloud_com_defs.h:494
dp data report information for statistic type
Definition: smart_frame.h:261
Definition of device control info
Definition: gw_intf.h:385
info of dp message data
Definition: smart_frame.h:32
Definition: ty_cJSON.h:104