diff --git a/src/ir_decoder/src/ir_ac_apply.c b/src/ir_decoder/src/ir_ac_apply.c index 905ddc8..267df48 100644 --- a/src/ir_decoder/src/ir_ac_apply.c +++ b/src/ir_decoder/src/ir_ac_apply.c @@ -495,6 +495,11 @@ static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, t_tag_checksum_data static UINT8 has_function(struct ac_protocol *protocol, UINT8 function) { + if (function < AC_FUNCTION_POWER || function > AC_FUNCTION_WIND_FIX) + { + return FALSE; + } + if (0 != protocol->function1.len) { if (0 != protocol->function1.comp_data[function - 1].seg_len) @@ -518,6 +523,11 @@ INT8 apply_function(struct ac_protocol *protocol, UINT8 function) { UINT16 i = 0; + if (function < AC_FUNCTION_POWER || function > AC_FUNCTION_WIND_FIX) + { + return IR_DECODE_FAILED; + } + // function index starts from 1 (AC_FUNCTION_POWER), do -1 operation at first if (0 == protocol->function1.len) { diff --git a/src/ir_decoder/src/ir_decode.c b/src/ir_decoder/src/ir_decode.c index de5a057..6ee5859 100644 --- a/src/ir_decoder/src/ir_decode.c +++ b/src/ir_decoder/src/ir_decode.c @@ -22,7 +22,7 @@ Revision log: struct ir_bin_buffer binary_file; struct ir_bin_buffer *p_ir_buffer = &binary_file; -const char* release = "0.2.0"; +const char* release = "0.2.1"; #if defined USE_DYNAMIC_TAG struct tag_head *tags; @@ -278,7 +278,7 @@ static INT8 ir_ac_binary_open(UINT8 *binary, UINT16 binary_length) return IR_DECODE_SUCCEEDED; } -static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 key_code, BOOL change_wind_direction) { UINT16 time_length = 0; @@ -287,6 +287,36 @@ static UINT16 ir_ac_control(t_remote_ac_status ac_status, UINT16 *user_data, UIN UINT16 i = 0; #endif + UINT8 function_code = 0; + + switch(key_code) + { + case 0: + function_code = AC_FUNCTION_POWER; + break; + case 1: + function_code = AC_FUNCTION_MODE; + break; + case 2: + function_code = AC_FUNCTION_TEMPERATURE_UP; + break; + case 3: + function_code = AC_FUNCTION_TEMPERATURE_DOWN; + break; + case 7: + function_code = AC_FUNCTION_TEMPERATURE_UP; + break; + case 8: + function_code = AC_FUNCTION_TEMPERATURE_DOWN; + break; + case 9: + function_code = AC_FUNCTION_WIND_SPEED; + break; + case 10: + function_code = AC_FUNCTION_WIND_SWING; + break; + } + if (0 == context->default_code.len) { ir_printf("\ndefault code is empty\n");