Last Updated on : 2024-11-20 08:51:48download
This topic describes the APIs used to implement the infrared (IR) features.
typedef struct
{
TY_IR_STUDY_CTL_CB study_ctl_cb;
TY_IR_SEND_CB send_cb;
}TY_IR_CONTROL_CBS_S;
Functional specification
Registers IR specific callbacks.
Member description
Member | Description |
---|---|
study_ctl_cb | For more information, see TY_IR_STUDY_CTL_CB. |
send_cb | For more information, see TY_IR_SEND_CB. |
typedef struct
{
USHORT_T *code;
USHORT_T code_len;
BYTE_T send_count; //repeat send count, don't need delay
UINT_T feq;
USHORT_T delay; //ms
}TY_IR_CODE_S;
Functional specification
The array of IR code structure.
Member description
Member | Description |
---|---|
code | The IR code. |
code_len | The number of IR codes. |
send_count | The repetitions of IR code transmission after the first round. There is no delay between repetitions. |
feq | The frequency of IR code transmission. |
delay | The time delay (in milliseconds) after the IR code transmission is finished. |
typedef struct
{
TY_RF_STUDY_STATE_CB rf_study_state_cb; // A callback is sent in the RF learning state
TY_RF_SEND_CB rf_lib_send_cb; // A callback is sent in the RF data
} TY_RF_CONTROL_CBS_S;
Functional specification
The radio frequency (RF) specific callbacks.
Member description
Member | Description |
---|---|
rf_study_state_cb | For more information, see TY_RF_STUDY_STATE_CB. |
rf_lib_send_cb | For more information, see TY_RF_SEND_CB. |
OPERATE_RET tuya_ir_control_register(IN CONST TY_IR_CONTROL_CBS_S *p_ir_cbs);
Functional description
Enables the IR services and registers callbacks.
Parameter description
Parameter name | Description |
---|---|
p_ir_cbs | IR control callbacks. For more information, see TY_IR_CONTROL_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 . |
OPERATE_RET tuya_ir_study_code_report(IN CONST USHORT_T *p_code, IN CONST UINT_T code_len);
Functional description
Reports the learned IR codes.
Parameter description
Parameter name | Description |
---|---|
p_code | The learned code. |
code_len | The length of the learned code. |
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_ir_code_free(IN TY_IR_CODE_S *ir_code, IN UCHAR_T code_num);
Functional description
Frees resources after the learned IR code is sent to the cloud.
Parameter description
Parameter name | Description |
---|---|
ir_code | The array of IR codes. For more information, see TY_IR_CODE_S. |
code_num | The number of IR codes. |
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_ir_study_stat_report(IN TY_IR_STUDY_CTL_E mode);
Functional description
Reports the status of the IR code learning.
Parameter description
Parameter name | Description |
---|---|
mode | The learning status:
|
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_rf_control_register(IN CONST TY_RF_CONTROL_CBS_S *p_ir_cbs);
Functional description
Starts the RF services and registers callbacks.
Parameter description
Parameter name | Description |
---|---|
p_ir_cbs | The RF control callbacks. For more information, see TY_RF_CONTROL_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 . |
OPERATE_RET tuya_rf_study_code_report(IN CONST UCHAR_T *p_code,IN CONST UINT_T code_len,IN CONST UINT_T max_len);
Functional description
Reports the learned RF codes.
Parameter description
Parameter name | Description |
---|---|
p_code | The learned code. |
code_len | The length of the learned code. |
max_len | The maximum length of the learned code. |
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_rf_study_stat_report(IN TY_RF_STUDY_CTL_E mode);
Functional description
Reports the status of the RF code learning.
Parameter description
Parameter name | Description |
---|---|
mode | The learning status:
|
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
VOID (*TY_IR_STUDY_CTL_CB)(TY_IR_STUDY_CTL_E mode);
Functional description
The callback to invoke when an alarm is triggered.
Parameter description
Parameter name | Description |
---|---|
mode | The learning status:
|
Return value
Return value | Description |
---|---|
VOID | / |
VOID (*TY_IR_SEND_CB)(TY_IR_CODE_S *ir_code, UCHAR_T code_num_type);
Functional description
The callback to invoke when the alarm sound is muted.
Parameter description
Parameter name | Description |
---|---|
ir_code | The array of IR codes. For more information, see TY_IR_CODE_S. |
code_num_type | The number of arrays of IR codes. |
Return value
Return value | Description |
---|---|
VOID | / |
VOID (*TY_RF_STUDY_STATE_CB)(TY_RF_STUDY_CTL_E mode);
Functional description
The callback to invoke when an alarm is canceled.
Parameter description
Parameter name | Description |
---|---|
mode | The learning status:
|
Return value
Return value | Description |
---|---|
VOID | / |
VOID (*TY_RF_SEND_CB)(UCHAR_T *rf_data,UCHAR_T rf_data_len,TY_RF_SEND_CTL_E type);
Functional description
The callback to invoke when the system is disarmed.
Parameter description
Parameter name | Description |
---|---|
rf_data | The data to be sent. |
rf_data_len | The length of the data to be sent. |
type | The defined data types:
|
Return value
Return value | Description |
---|---|
VOID | / |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback