Last Updated on : 2024-11-20 08:51:47
This topic describes the APIs used to implement the functionality of data points (DPs).
typedef struct {
DP_CMD_TYPE_E cmd_tp;
DP_TRANS_TYPE_T dtt_tp;
CHAR_T *cid;
BYTE_T dpid;
CHAR_T *mb_id;
UINT_T len;
BYTE_T data[0];
} TY_RECV_RAW_DP_S;
Functional specification
The commands of the raw type.
Member description
Parameter name | Description |
---|---|
cmd_tp | The types of commands:
|
dtt_tp | The types of transmission:
|
cid | The unique identifier of the device.
|
dpid | The ID of the data point. |
mb_id | The ID of the group. This parameter is valid when dtt_tp is DTT_SCT_MNC . |
len | The length of raw data. |
data | The raw data. |
typedef struct {
DP_CMD_TYPE_E cmd_tp;
DP_TRANS_TYPE_T dtt_tp;
CHAR_T *cid;
CHAR_T *mb_id;
UINT_T dps_cnt;
TY_OBJ_DP_S dps[0];
} TY_RECV_OBJ_DP_S;
Functional specification
The commands of the object type.
Member description
Member | Description |
---|---|
cmd_tp | The types of commands:
|
dtt_tp | The types of transmission:
|
cid | The unique identifier of the device.
|
mb_id | The ID of the group. This parameter is valid when dtt_tp is DTT_SCT_MNC . |
dps_cnt | The number of DPs. |
dps | An array of DPs. For more information, see TY_OBJ_DP_S. |
typedef struct {
BYTE_T dpid;
DP_PROP_TP_E type;
TY_OBJ_DP_VALUE_U value;
UINT_T time_stamp;
} TY_OBJ_DP_S;
Functional specification
The DP of the object type.
Member description
Member | Description |
---|---|
dpid | The ID of the data point. |
type | The data types of DP:
|
value | The value of a DP, in union type. For more information, see TY_OBJ_DP_VALUE_U. |
time_stamp | The timestamp. |
typedef union {
INT_T dp_value;
UINT_T dp_enum;
CHAR_T *dp_str;
BOOL_T dp_bool;
UINT_T dp_bitmap;
} TY_OBJ_DP_VALUE_U;
Functional specification
A union of DP values of the object type.
Member description
Member | Description |
---|---|
dp_value | This parameter is valid when the data type of a DP is PROP_VALUE . |
dp_enum | This parameter is valid when the data type of a DP is PROP_ENUM . |
dp_str | This parameter is valid when the data type of a DP is PROP_STR . |
dp_bool | This parameter is valid when the data type of a DP is PROP_BOOL . |
dp_bitmap | This parameter is valid when the data type of a DP is PROP_BITMAP . |
typedef struct {
CHAR_T *cid;
UINT_T cnt;
BYTE_T dpid[0];
} TY_DP_QUERY_S;
Functional specification
Queries the DP information.
Member description
Parameter name | Description |
---|---|
cid | The unique identifier of the device.
|
cnt | The number of DPs. If cnt is 0, it means to query all the DPs defined for a device. |
dpid | The list of DP IDs to query. |
typedef struct {
DEV_OBJ_DP_CMD_CB obj;
DEV_RAW_DP_CMD_CB raw;
DEV_DP_QUERY_CB query;
} TY_IOT_DP_CBS_S;
Functional specification
The DP callbacks.
Member description
Member | Description |
---|---|
obj | For more information, see dev_obj_dp_cb. |
raw | For more information, see dev_raw_dp_cb. |
query | For more information, see dev_dp_query_cb. |
typedef struct {
VOID (*obj_dp_rept_cb)(CONST CHAR_T *dev_id, CONST TY_OBJ_DP_S *dps, CONST UINT_T dp_cnt);
VOID (*raw_dp_rept_cb)(CONST CHAR_T *dev_id, BYTE_T dpid, CONST BYTE_T *data, UINT_T len);
} TY_DP_REPORT_CBS_S;
Functional description
The DP reporting callbacks.
Member description
Member | Description |
---|---|
obj_dp_rept_cb | The callback for DPs of the object type. Its parameters are the same as those of dev_report_dp_json_async. |
raw_dp_rept_cb | The callback for DPs of the raw type. Its parameters are the same as those of dev_report_dp_raw_sync. |
OPERATE_RET tuya_iot_reg_dp_cb(IN CONST DP_DEV_TYPE_T subcribe_dev_type,
IN GW_PERMIT_DEV_TP_T tp,
TY_IOT_DP_CBS_S *cb)
Functional description
Registers the DP event handler callback.
Parameter description
Parameter name | Description |
---|---|
sub_dev_type | The types of DP event handlers:
|
tp | The types of the sub-device:
|
cb | The DP callbacks. |
Return value
Return value | Description |
---|---|
OPRT_OK | Success |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET dev_report_dp_json_async(IN CONST CHAR_T *dev_id,
IN CONST TY_OBJ_DP_S *dp_data,
IN CONST UINT_T cnt)
Functional description
Reports the status of DPs of the object type asynchronously.
Parameter description
Parameter name | Description |
---|---|
dev_id | The device ID. |
dp_data | The DP data. For more information, see TY_OBJ_DP_S. |
cnt | The number of DPs. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET dev_report_dp_raw_sync (IN CONST CHAR_T *dev_id,
IN CONST BYTE_T dpid,
IN CONST BYTE_T *data,
IN CONST UINT_T len,
IN CONST UINT_T timeout)
Functional description
Reports the status of DPs of the raw type synchronously. Make sure that the data delivery is reliable.
Parameter description
Parameter name | Description |
---|---|
dev_id | The device ID. |
dpid | The ID of the data point. |
data | The raw data. |
len | The length of raw data. |
timeout | The timeout period for interface blocking. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
#define dev_report_dp_stat_sync(dev_id, dp_data, cnt, timeout) \
dev_report_dp_stat_sync_extend(dev_id, dp_data, cnt, timeout, TRUE)
OPERATE_RET dev_report_dp_stat_sync_extend(IN CONST CHAR_T *dev_id,
IN CONST TY_OBJ_DP_S *dp_data,
IN CONST UINT_T cnt,
IN CONST UINT_T timeout,
IN CONST BOOL_T enable_auto_retrans)
Functional description
Reports the status of DPs of the object type synchronously. Make sure that the data delivery is reliable.
Parameter description
Parameter name | Description |
---|---|
dev_id | The device ID. |
dp_data | The DP data. For more information, see TY_OBJ_DP_S. |
cnt | The number of DPs. |
timeout | The timeout period for interface blocking. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_iot_dev_obj_cmd_send(CONST TY_RECV_OBJ_DP_S *cmd)
Functional description
Sends DP commands of the object type locally.
Parameter description
Parameter name | Description |
---|---|
cmd | For more information, see TY_RECV_OBJ_DP_S. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_iot_dev_raw_cmd_send(CONST TY_RECV_RAW_DP_S *cmd)
Functional description
Sends DP commands of the raw type locally.
Parameter description
Parameter name | Description |
---|---|
cmd | For more information, see TY_RECV_RAW_DP_S. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_iot_reg_dp_report_cb(TY_DP_REPORT_CBS_S *cbs)
Functional description
Registers the DP status reporting callback, which is used to get the data reported.
Parameter description
Parameter name | Description |
---|---|
cbs | For more information, see TY_DP_REPORT_CBS_S. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
VOID dev_obj_dp_cb(IN CONST TY_RECV_OBJ_DP_S *dp)
Functional description
A callback processes the DP command of the object type.
Parameter description
Parameter name | Description |
---|---|
dp | The commands of the object type. For more information, see TY_RECV_OBJ_DP_S. |
Return value
Return value | Description |
---|---|
VOID | / |
VOID dev_raw_dp_cb(IN CONST TY_RECV_RAW_DP_S *dp)
Functional description
A callback processes the DP command of the raw type.
Parameter description
Parameter name | Description |
---|---|
dp | The commands of the raw type. For more information, see TY_RECV_RAW_DP_S. |
Return value
Return value | Description |
---|---|
VOID | / |
VOID dev_dp_query_cb(IN CONST TY_DP_QUERY_S *dp_qry)
Functional description
A callback queries the status of DP.
Parameter description
Parameter name | Description |
---|---|
dp_qry | The query for DP information. For more information, see TY_DP_QUERY_S. |
Return value
Return value | Description |
---|---|
VOID | / |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback