├── .gitignore ├── src ├── ir_decoder │ ├── stdafx.c │ ├── Application.mk │ ├── targetver.h │ ├── jni │ │ ├── Readme.md │ │ ├── include │ │ │ ├── win32 │ │ │ │ ├── jni_md.h │ │ │ │ ├── jawt_md.h │ │ │ │ └── bridge │ │ │ │ │ └── AccessBridgeCallbacks.h │ │ │ ├── linux │ │ │ │ ├── jni_md.h │ │ │ │ └── jawt_md.h │ │ │ ├── jvmticmlr.h │ │ │ ├── jdwpTransport.h │ │ │ ├── jawt.h │ │ │ └── classfile_constants.h │ │ ├── ir_decode_jni.h │ │ └── ir_decode_jni.c │ ├── stdafx.h │ ├── ir_decode.def │ ├── .gitignore │ ├── dllmain.c │ ├── include │ │ ├── ir_ac_build_frame.h │ │ ├── ir_ac_parse_forbidden_info.h │ │ ├── ir_ac_binary_parse.h │ │ ├── ir_utils.h │ │ ├── ir_ac_apply.h │ │ ├── ir_ac_parse_frame_info.h │ │ ├── ir_defs.h │ │ ├── ir_ac_parse_parameter.h │ │ ├── ir_tv_control.h │ │ ├── ir_decode.h │ │ └── ir_ac_control.h │ ├── Android.mk │ ├── ir_decoder.sln │ ├── src │ │ ├── ir_utils.c │ │ ├── ir_ac_binary_parse.c │ │ ├── ir_ac_parse_forbidden_info.c │ │ ├── ir_ac_build_frame.c │ │ ├── ir_test_main.c │ │ ├── ir_ac_parse_frame_info.c │ │ ├── ir_tv_control.c │ │ ├── ir_decode.c │ │ └── ir_ac_control.c │ ├── CMakeLists.txt │ └── ir_decoder.vcxproj └── ir_encoder │ ├── .gitignore │ ├── irda_tv_merge.py │ ├── irda_ac_encode.py │ ├── irda_tv_protocol.py │ ├── irda_tv_protocol_hex.py │ └── irda_tv_encode.py ├── LICENSE.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.bin 3 | */output/ -------------------------------------------------------------------------------- /src/ir_decoder/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" -------------------------------------------------------------------------------- /src/ir_encoder/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | source/ 3 | .DS_Store -------------------------------------------------------------------------------- /src/ir_decoder/Application.mk: -------------------------------------------------------------------------------- 1 | APP_BUILD_SCRIPT := Android.mk -------------------------------------------------------------------------------- /src/ir_decoder/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/Readme.md: -------------------------------------------------------------------------------- 1 | ndk-build NDK_PROJECT_PATH=./ NDK_APPLICATION_MK=./Application.mk -------------------------------------------------------------------------------- /src/ir_decoder/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targetver.h" 4 | 5 | #define WIN32_LEAN_AND_MEAN 6 | 7 | #include 8 | -------------------------------------------------------------------------------- /src/ir_decoder/ir_decode.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | 3 | EXPORTS 4 | 5 | ir_file_open @1 6 | ir_binary_open @2 7 | ir_decode @3 8 | ir_close @4 9 | 10 | get_temperature_range @5 11 | get_supported_mode @6 12 | get_supported_wind_speed @7 13 | get_supported_swing @8 14 | get_supported_wind_direction @9 -------------------------------------------------------------------------------- /src/ir_decoder/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | libs/ 3 | obj/ 4 | .idea/ 5 | ipch/ 6 | x64/ 7 | cmake-build-debug/ 8 | cmake-build-release/ 9 | Debug/ 10 | Release/ 11 | *.sdf 12 | *.opensdf 13 | .DS_Store 14 | .vs 15 | ir_decoder.vcxproj.user 16 | irda_decoder.exe.stackdump 17 | ir_decoder.VC.db 18 | ir_decoder.VC.VC.opendb -------------------------------------------------------------------------------- /src/ir_decoder/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL APIENTRY DllMain( HMODULE hModule, 4 | DWORD ul_reason_for_call, 5 | LPVOID lpReserved 6 | ) 7 | { 8 | switch (ul_reason_for_call) 9 | { 10 | case DLL_PROCESS_ATTACH: 11 | case DLL_THREAD_ATTACH: 12 | case DLL_THREAD_DETACH: 13 | case DLL_PROCESS_DETACH: 14 | break; 15 | } 16 | return TRUE; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/win32/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | #ifndef _JAVASOFT_JNI_MD_H_ 27 | #define _JAVASOFT_JNI_MD_H_ 28 | 29 | #define JNIEXPORT __declspec(dllexport) 30 | #define JNIIMPORT __declspec(dllimport) 31 | #define JNICALL __stdcall 32 | 33 | typedef long jint; 34 | typedef long long jlong; 35 | typedef signed char jbyte; 36 | 37 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 38 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_build_frame.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_utils.c 3 | Revised: Date: 2016-10-26 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides generic utils for IR frame build 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_IRFRAME_H_ 13 | #define _IRDA_IRFRAME_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_defs.h" 21 | 22 | extern UINT16 create_ir_frame(); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // _IRDA_IRFRAME_H_ -------------------------------------------------------------------------------- /src/ir_decoder/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_CFLAGS := -DBOARD_ANDROID 6 | LOCAL_MODULE := libirdecode 7 | LOCAL_SRC_FILES := ./jni/ir_decode_jni.c \ 8 | ./src/ir_decode.c \ 9 | ./src/ir_tv_control.c \ 10 | ./src/ir_ac_apply.c \ 11 | ./src/ir_ac_build_frame.c \ 12 | ./src/ir_ac_parse_parameter.c \ 13 | ./src/ir_ac_parse_forbidden_info.c \ 14 | ./src/ir_ac_parse_frame_info.c \ 15 | ./src/ir_ac_binary_parse.c \ 16 | ./src/ir_ac_control.c \ 17 | ./src/ir_utils.c \ 18 | 19 | LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog 20 | 21 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_parse_forbidden_info.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_parse_forbidden_info.h 3 | Revised: Date: 2016-10-05 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for forbidden area of AC code 7 | 8 | Revision log: 9 | * 2016-10-05: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_PARSE_PARSE_H_ 13 | #define _IRDA_PARSE_PARSE_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_decode.h" 21 | 22 | extern INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // _IRDA_PARSE_PARSE_H_ 29 | 30 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_binary_parse.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_ac_binary_parse.h 3 | Revised: Date: 2017-01-03 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides methods for AC binary parse 7 | 8 | Revision log: 9 | * 2017-01-03: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef IRDA_DECODER_IR_AC_BINARY_PARSE_H 13 | #define IRDA_DECODER_IR_AC_BINARY_PARSE_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_defs.h" 21 | 22 | extern INT8 binary_parse_offset(); 23 | 24 | extern INT8 binary_parse_len(); 25 | 26 | extern void binary_tags_info(); 27 | 28 | extern INT8 binary_parse_data(); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | 35 | #endif //IRDA_DECODER_IR_AC_BINARY_PARSE_H 36 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_utils.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_utils.c 3 | Revised: Date: 2016-10-26 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides generic utils for IRDA algorithms 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_UTILS_H_ 13 | #define _IRDA_UTILS_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_defs.h" 21 | #include "ir_decode.h" 22 | 23 | #include 24 | 25 | extern void string_to_hex(UINT8 *p, t_ac_hex *pac_hex); 26 | 27 | extern void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len); 28 | 29 | extern BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif // _IRDA_UTILS_H_ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 IRext 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/win32/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | #ifndef _JAVASOFT_JAWT_MD_H_ 27 | #define _JAVASOFT_JAWT_MD_H_ 28 | 29 | #include 30 | #include "jawt.h" 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* 37 | * Win32-specific declarations for AWT native interface. 38 | * See notes in jawt.h for an example of use. 39 | */ 40 | typedef struct jawt_Win32DrawingSurfaceInfo { 41 | /* Native window, DDB, or DIB handle */ 42 | union { 43 | HWND hwnd; 44 | HBITMAP hbitmap; 45 | void* pbits; 46 | }; 47 | /* 48 | * This HDC should always be used instead of the HDC returned from 49 | * BeginPaint() or any calls to GetDC(). 50 | */ 51 | HDC hdc; 52 | HPALETTE hpalette; 53 | } JAWT_Win32DrawingSurfaceInfo; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 60 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_apply.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_ac_apply.h 3 | Revised: Date: 2016-10-12 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides methods for AC IR applying functionalities 7 | 8 | Revision log: 9 | * 2016-10-12: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_APPLY_H_ 13 | #define _IRDA_APPLY_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_decode.h" 21 | 22 | INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code); 23 | 24 | INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code); 25 | 26 | INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code); 27 | 28 | INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code); 29 | 30 | INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code); 31 | 32 | INT8 apply_function(struct ac_protocol *protocol, UINT8 function); 33 | 34 | INT8 apply_checksum(struct ac_protocol *protocol); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif //_IRDA_APPLY_H_ -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_parse_frame_info.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_parse_frame_parameter.h 3 | Revised: Date: 2016-10-11 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode for AC frame parameters 7 | 8 | Revision log: 9 | * 2016-10-11: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_PARSE_FRAME_PARAMETER_H_ 13 | #define _IRDA_PARSE_FRAME_PARAMETER_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_decode.h" 21 | 22 | extern INT8 parse_boot_code(struct tag_head *tag); 23 | 24 | extern INT8 parse_zero(struct tag_head *tag); 25 | 26 | extern INT8 parse_one(struct tag_head *tag); 27 | 28 | extern INT8 parse_delay_code(struct tag_head *tag); 29 | 30 | extern INT8 parse_frame_len(struct tag_head *tag, UINT16 len); 31 | 32 | extern INT8 parse_endian(struct tag_head *tag); 33 | 34 | extern INT8 parse_lastbit(struct tag_head *tag); 35 | 36 | extern INT8 parse_repeat_times(struct tag_head *tag); 37 | 38 | extern INT8 parse_bit_num(struct tag_head *tag); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif // _IRDA_PARSE_FRAME_PARAMETER_H_ -------------------------------------------------------------------------------- /src/ir_encoder/irda_tv_merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | # 4 | # created by strawmanbobi 2016-11-10 5 | 6 | import sys 7 | import os 8 | 9 | for root, dirs, files in os.walk(sys.argv[1]): 10 | for i in files: 11 | fileType = i.split('.') 12 | if cmp(fileType[1], 'bin') == 0: 13 | print root + i 14 | 15 | print "========================list===========================" 16 | 17 | remotePath = sys.argv[2] 18 | fileType2 = remotePath.split('.') 19 | if cmp(fileType2[-1], 'bin') == 0: 20 | protocolType = fileType2[0].split('#') 21 | print(protocolType[0]) 22 | print(fileType[0]) 23 | if cmp(protocolType[0].split('/')[-1], fileType[0]) == 0: 24 | outName = remotePath.split('#') 25 | binary = open(sys.argv[3] + "/irda_" + outName[0].split('/')[-1] + "_" + outName[1], 'wb') 26 | prot_file = open(root + i, "rb") 27 | remote_file = open(remotePath, "rb") 28 | binary.write(prot_file.read()) 29 | binary.write(remote_file.read()) 30 | binary.close() 31 | prot_file.close() 32 | remote_file.close() 33 | print remotePath 34 | -------------------------------------------------------------------------------- /src/ir_decoder/ir_decoder.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ir_decoder", "ir_decoder.vcxproj", "{8ACC347D-023C-4939-B371-C193EEA210F8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Debug|x64.ActiveCfg = Debug|x64 17 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Debug|x64.Build.0 = Debug|x64 18 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Debug|x86.ActiveCfg = Debug|Win32 19 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Debug|x86.Build.0 = Debug|Win32 20 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Release|x64.ActiveCfg = Release|x64 21 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Release|x64.Build.0 = Release|x64 22 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Release|x86.ActiveCfg = Release|Win32 23 | {8ACC347D-023C-4939-B371-C193EEA210F8}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### For users out of China, please refer to the official website https://irext.net for documentations. 2 | 3 | # IRext (revision 0.1.4) 4 | #### 开源家用电器红外的编解码和免费码库方案 5 | 6 | IRext 提供数以万计的红外设备遥控编码, 并以独特的编、解码算法为任何嵌入式设备、移动设备以及服务器提供红外设备遥控功能 7 | 8 | 9 | #### 官方站点: https://irext.net 10 | 11 | 12 | #### IRext 具有的功能: 13 | - 从简易的XML文件开始对红外遥控码进行二进制压缩编码 14 | - 使用通用的解码算法,将编码成的二进制文件解码成 38KHz 红外波形码 15 | - 提供基于公有云和私有云的码库索引及维护控制台 16 | - 直接通过控制台上传、压缩、存储并管理编码及索引 17 | - 极限的编码格式,LIRC或者其它万能红外厂商需要使用数 KB 甚至上 MB 空间进行存储的单个电器码库,IRext 只需要使用几百字节的空间就可以存储 (已申请专利) 18 | - 极其节省资源的解码算法,整个万能红外码解码算法最多只消耗 1.5 KB 物理 RAM (已申请专利) 19 | - 支持 13 类家用电器 (空调、电视机、机顶盒、网络盒子、IPTV、音响、投影仪、风扇、扫地机器人、空气净化器、灯、DVD以及部分品牌机顶盒) 20 | - 支持数万种型号的家电 21 | - 支持不同平台 (51单片机、Linux、Windows、Java Web、Android、树莓派、Arduino等) 22 | - 提供不同平台解码程序样例 23 | - 支持在线解码以及在线板载解码 24 | 25 | ------ 26 | 27 | #### 红外码原理简介: https://irext.net/doc/ 28 | 29 | #### 码库品牌索引RestAPI: https://irext.net/doc/#services 30 | 31 | #### 解码算法使用方法: https://irext.net/doc/#decode 32 | 33 | ------ 34 | 35 | #### IRext 的子项目: 36 | - 编码/解码算法: https://github.com/irext/irext-core 37 | - 红外码管理控制台私有云版本: https://github.com/irext/irext-console 38 | - 各种平台的解码示例: https://github.com/irext/irext-examples 39 | - Java Web索引API: https://github.com/irext/irext-web-api 40 | 41 | ------ 42 | 43 | #### 联系作者: 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_defs.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_defs.h 3 | Revised: Date: 2016-10-26 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef PARSE_IR_DEFS_H 13 | #define PARSE_IR_DEFS_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #if defined BOARD_ANDROID 21 | #include 22 | #define LOG_TAG "ir_decode" 23 | #endif 24 | 25 | #if defined BOARD_CC26XX 26 | #include "OSAL.h" 27 | #endif 28 | 29 | #define TRUE 1 30 | #define FALSE 0 31 | 32 | typedef unsigned char UINT8; 33 | typedef signed char INT8; 34 | typedef unsigned short UINT16; 35 | typedef signed short INT16; 36 | typedef signed int INT; 37 | typedef unsigned int UINT; 38 | typedef int BOOL; 39 | 40 | void noprint(const char *fmt, ...); 41 | 42 | #if !defined BOARD_CC26XX 43 | #define ir_malloc(A) malloc(A) 44 | #define ir_free(A) free(A) 45 | #else 46 | #define ir_malloc(A) ICall_malloc(A) 47 | #define ir_free(A) ICall_free(A) 48 | #endif 49 | 50 | #define ir_memcpy(A, B, C) memcpy(A, B, C) 51 | #define ir_memset(A, B, C) memset(A, B, C) 52 | #define ir_strlen(A) strlen(A) 53 | #if (defined BOARD_PC) && (!defined BOARD_PC_JNI) 54 | #define ir_printf printf 55 | #else 56 | #define ir_printf noprint 57 | #endif 58 | #define USER_DATA_SIZE 1636 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif //PARSE_IR_DEFS_H 64 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_utils.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_utils.c 3 | Revised: Date: 2016-10-26 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides generic utils for IRDA algorithms 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include "../include/ir_utils.h" 13 | 14 | UINT8 char_to_hex(char chr) 15 | { 16 | UINT8 value = 0; 17 | if (chr >= '0' && chr <= '9') 18 | value = (UINT8) (chr - '0'); 19 | if (chr >= 'a' && chr <= 'f') 20 | value = (UINT8) (chr - 'a' + 10); 21 | if (chr >= 'A' && chr <= 'F') 22 | value = (UINT8) (chr - 'A' + 10); 23 | return value; 24 | } 25 | 26 | UINT8 chars_to_hex(const UINT8 *p) 27 | { 28 | return (char_to_hex(*p) << 4) + char_to_hex(*(p + 1)); 29 | } 30 | 31 | void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len) 32 | { 33 | // in condition of hex_code is already assigned 34 | UINT16 i = 0; 35 | 36 | for (i = 0; i < len; i++) 37 | { 38 | hex_data[i] = chars_to_hex(p); 39 | p = p + 2; 40 | } 41 | } 42 | 43 | void string_to_hex(UINT8 *p, t_ac_hex *pac_hex) 44 | { 45 | UINT8 i = 0; 46 | 47 | pac_hex->len = chars_to_hex(p); 48 | p = p + 2; 49 | for (i = 0; i < pac_hex->len; i++) 50 | { 51 | pac_hex->data[i] = chars_to_hex(p); 52 | p = p + 2; 53 | } 54 | } 55 | 56 | BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len) 57 | { 58 | UINT16 i = 0; 59 | for (i = 0; i < len; i++) 60 | { 61 | if (array[i] == value) 62 | { 63 | return TRUE; 64 | } 65 | } 66 | return FALSE; 67 | } -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/linux/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JNI_MD_H_ 27 | #define _JAVASOFT_JNI_MD_H_ 28 | 29 | #ifndef __has_attribute 30 | #define __has_attribute(x) 0 31 | #endif 32 | #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) 33 | #define JNIEXPORT __attribute__((visibility("default"))) 34 | #define JNIIMPORT __attribute__((visibility("default"))) 35 | #else 36 | #define JNIEXPORT 37 | #define JNIIMPORT 38 | #endif 39 | 40 | #define JNICALL 41 | 42 | typedef int jint; 43 | #ifdef _LP64 /* 64-bit Solaris */ 44 | typedef long jlong; 45 | #else 46 | typedef long long jlong; 47 | #endif 48 | 49 | typedef signed char jbyte; 50 | 51 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 52 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_parse_parameter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_parse_ac_parameter.h 3 | Revised: Date: 2016-10-12 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode for AC functionality parameters 7 | 8 | Revision log: 9 | * 2016-10-12: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_PARSE_AC_PARAMETER_H_ 13 | #define _IRDA_PARSE_AC_PARAMETER_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_decode.h" 21 | 22 | extern INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type); 23 | 24 | extern INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code); 25 | 26 | extern INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1); 27 | 28 | extern INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1); 29 | 30 | extern INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1); 31 | 32 | extern INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1); 33 | 34 | extern INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count); 35 | 36 | extern INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum); 37 | 38 | extern INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1); 39 | 40 | extern INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2); 41 | 42 | extern INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2); 43 | 44 | extern INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2); 45 | 46 | extern INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count); 47 | 48 | extern INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2); 49 | 50 | extern INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si); 51 | 52 | extern INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif // _IRDA_PARSE_AC_PARAMETER_H_ -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/linux/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JAWT_MD_H_ 27 | #define _JAVASOFT_JAWT_MD_H_ 28 | 29 | #include 30 | #include 31 | #include 32 | #include "jawt.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* 39 | * X11-specific declarations for AWT native interface. 40 | * See notes in jawt.h for an example of use. 41 | */ 42 | typedef struct jawt_X11DrawingSurfaceInfo { 43 | Drawable drawable; 44 | Display* display; 45 | VisualID visualID; 46 | Colormap colormapID; 47 | int depth; 48 | /* 49 | * Since 1.4 50 | * Returns a pixel value from a set of RGB values. 51 | * This is useful for paletted color (256 color) modes. 52 | */ 53 | int (JNICALL *GetAWTColor)(JAWT_DrawingSurface* ds, 54 | int r, int g, int b); 55 | } JAWT_X11DrawingSurfaceInfo; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 62 | -------------------------------------------------------------------------------- /src/ir_decoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | 3 | ######################################################## 4 | project(irda_decoder) 5 | # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 6 | add_definitions(-DBOARD_PC) 7 | # add_definitions(-DBOARD_PC -DBOARD_PC_JNI) 8 | 9 | IF (CMAKE_SYSTEM_NAME MATCHES "Linux") 10 | MESSAGE("compile platform : Linux") 11 | add_definitions(-DPLATFORM_LINUX) 12 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows") 13 | MESSAGE("compile platform : win32") 14 | add_definitions(-DPLATFORM_WIN32) 15 | ELSE () 16 | MESSAGE("invalid compile platform") 17 | add_definitions(-DPLATFORM_WIN32) 18 | ENDIF () 19 | 20 | set(SOURCE_FILES_EXECUTABLE 21 | include/ir_defs.h 22 | src/ir_utils.c 23 | include/ir_utils.h 24 | src/ir_tv_control.c 25 | include/ir_tv_control.h 26 | src/ir_ac_apply.c 27 | include/ir_ac_apply.h 28 | src/ir_ac_build_frame.c 29 | include/ir_ac_build_frame.h 30 | src/ir_ac_parse_parameter.c 31 | include/ir_ac_parse_parameter.h 32 | src/ir_ac_parse_forbidden_info.c 33 | include/ir_ac_parse_forbidden_info.h 34 | src/ir_ac_parse_frame_info.c 35 | include/ir_ac_parse_frame_info.h 36 | src/ir_ac_control.c 37 | include/ir_ac_control.h 38 | src/ir_ac_binary_parse.c 39 | include/ir_ac_binary_parse.h 40 | src/ir_decode.c 41 | include/ir_decode.h 42 | src/ir_test_main.c) 43 | 44 | set(SOURCE_FILES_SHARED_LIB 45 | include/ir_defs.h 46 | src/ir_utils.c 47 | include/ir_utils.h 48 | src/ir_tv_control.c 49 | include/ir_tv_control.h 50 | src/ir_ac_apply.c 51 | include/ir_ac_apply.h 52 | src/ir_ac_build_frame.c 53 | include/ir_ac_build_frame.h 54 | src/ir_ac_parse_parameter.c 55 | include/ir_ac_parse_parameter.h 56 | src/ir_ac_parse_forbidden_info.c 57 | include/ir_ac_parse_forbidden_info.h 58 | src/ir_ac_parse_frame_info.c 59 | include/ir_ac_parse_frame_info.h 60 | src/ir_ac_control.c 61 | include/ir_ac_control.h 62 | src/ir_ac_binary_parse.c 63 | include/ir_ac_binary_parse.h 64 | src/ir_decode.c 65 | include/ir_decode.h) 66 | 67 | set(SOURCE_FILES_JNI_SHARED_LIB 68 | jni/ir_decode_jni.h 69 | jni/ir_decode_jni.c 70 | include/ir_defs.h 71 | src/ir_utils.c 72 | include/ir_utils.h 73 | src/ir_tv_control.c 74 | include/ir_tv_control.h 75 | src/ir_ac_apply.c 76 | include/ir_ac_apply.h 77 | src/ir_ac_build_frame.c 78 | include/ir_ac_build_frame.h 79 | src/ir_ac_parse_parameter.c 80 | include/ir_ac_parse_parameter.h 81 | src/ir_ac_parse_forbidden_info.c 82 | include/ir_ac_parse_forbidden_info.h 83 | src/ir_ac_parse_frame_info.c 84 | include/ir_ac_parse_frame_info.h 85 | src/ir_ac_control.c 86 | include/ir_ac_control.h 87 | src/ir_ac_binary_parse.c 88 | include/ir_ac_binary_parse.h 89 | src/ir_decode.c 90 | include/ir_decode.h) 91 | 92 | # add_library(irda_decoder SHARED ${SOURCE_FILES_SHARED_LIB}) 93 | add_executable(irda_decoder ${SOURCE_FILES_EXECUTABLE}) 94 | # add_library(irda_decoder SHARED ${SOURCE_FILES_JNI_SHARED_LIB}) 95 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_ac_binary_parse.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_ac_binary_parse.c 3 | Revised: Date: 2017-01-03 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides methods for AC binary parse 7 | 8 | Revision log: 9 | * 2017-01-03: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | 14 | #include "../include/ir_ac_binary_parse.h" 15 | #include "../include/ir_decode.h" 16 | 17 | UINT16 tag_head_offset = 0; 18 | 19 | extern struct ir_bin_buffer *p_ir_buffer; 20 | extern struct tag_head *tags; 21 | 22 | UINT8 tag_count = 0; 23 | const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] = 24 | { 25 | 1, 2, 3, 4, 5, 6, 7, 26 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 27 | 41, 42, 43, 44, 45, 46, 47, 48 28 | }; 29 | 30 | INT8 binary_parse_offset() 31 | { 32 | int i = 0; 33 | UINT16 *phead = (UINT16 *) &p_ir_buffer->data[1]; 34 | 35 | tag_count = p_ir_buffer->data[0]; 36 | if (TAG_COUNT_FOR_PROTOCOL != tag_count) 37 | { 38 | return IR_DECODE_FAILED; 39 | } 40 | 41 | tag_head_offset = (UINT16) ((tag_count << 1) + 1); 42 | 43 | tags = (t_tag_head *) ir_malloc(tag_count * sizeof(t_tag_head)); 44 | if (NULL == tags) 45 | { 46 | return IR_DECODE_FAILED; 47 | } 48 | 49 | for (i = 0; i < tag_count; i++) 50 | { 51 | tags[i].tag = tag_index[i]; 52 | tags[i].offset = *(phead + i); 53 | 54 | if (tags[i].offset == TAG_INVALID) 55 | { 56 | tags[i].len = 0; 57 | } 58 | } 59 | return IR_DECODE_SUCCEEDED; 60 | } 61 | 62 | INT8 binary_parse_len() 63 | { 64 | UINT16 i = 0, j = 0; 65 | for (i = 0; i < (tag_count - 1); i++) 66 | { 67 | if (tags[i].offset == TAG_INVALID) 68 | { 69 | continue; 70 | } 71 | 72 | for (j = (UINT16) (i + 1); j < tag_count; j++) 73 | { 74 | if (tags[j].offset != TAG_INVALID) 75 | { 76 | break; 77 | } 78 | } 79 | if (j < tag_count) 80 | { 81 | tags[i].len = tags[j].offset - tags[i].offset; 82 | } 83 | else 84 | { 85 | tags[i].len = p_ir_buffer->len - tags[i].offset - tag_head_offset; 86 | return IR_DECODE_SUCCEEDED; 87 | } 88 | } 89 | if (tags[tag_count - 1].offset != TAG_INVALID) 90 | { 91 | tags[tag_count - 1].len = p_ir_buffer->len - tag_head_offset - tags[tag_count - 1].offset; 92 | } 93 | 94 | return IR_DECODE_SUCCEEDED; 95 | } 96 | 97 | void binary_tags_info() 98 | { 99 | #if defined BOARD_PC 100 | UINT16 i = 0; 101 | for (i = 0; i < tag_count; i++) 102 | { 103 | if (tags[i].len == 0) 104 | { 105 | continue; 106 | } 107 | ir_printf("tag(%d).len = %d\n", tags[i].tag, tags[i].len); 108 | } 109 | #endif 110 | } 111 | 112 | INT8 binary_parse_data() 113 | { 114 | UINT16 i = 0; 115 | for (i = 0; i < tag_count; i++) 116 | { 117 | tags[i].p_data = p_ir_buffer->data + tags[i].offset + tag_head_offset; 118 | } 119 | 120 | return IR_DECODE_SUCCEEDED; 121 | } -------------------------------------------------------------------------------- /src/ir_encoder/irda_ac_encode.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env python 2 | # coding=utf-8 3 | # for protocol version V1.0 4 | # 29 tags are supported 5 | # 6 | # created by strawmanbobi 2016-11-10 7 | 8 | import sys 9 | import xml.dom.minidom 10 | import struct 11 | 12 | 13 | alltags = [1, 2, 3, 4, 5, 6, 7, 14 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 15 | 41, 42, 43, 44, 45, 46, 47, 48] 16 | 17 | tags_max_size = [0 for x in range(0, len(alltags))] 18 | 19 | # Definition of ac tag class 20 | # (tag:value) 21 | 22 | 23 | class ACTag: 24 | def __init__(self, tag, value): 25 | self.tag = tag 26 | self.value = value 27 | self.len = len(self.value) 28 | 29 | def __lt__(self, other): 30 | return self.tag < other.tag 31 | 32 | def printf(self): 33 | print "[%d] %s len:%d" % (self.tag, self.value, len(self.value)) 34 | 35 | # Definition of Remote_control class 36 | # device id:(tag:value)...(tag:value) 37 | 38 | 39 | class ACRemoteControl: 40 | def __init__(self, device_id): 41 | self.device_id = device_id 42 | self.tags = [] 43 | 44 | def add(self, tag): 45 | self.tags.append(tag) 46 | 47 | def sort(self): 48 | self.tags.sort() 49 | 50 | def printf(self): 51 | print "==========Device id:%d===========" % self.device_id 52 | for j in range(len(self.tags)): 53 | self.tags[j].printf() 54 | 55 | 56 | def create_binary(ac_device): 57 | find = 0 58 | offset = 0 59 | 60 | f_content = open(sys.argv[2] + str(ac_device.device_id) + "_tmp.bin", "wb") 61 | f_head = open(sys.argv[2] + "irda_new_ac_" + str(ac_device.device_id) + ".bin", "wb") 62 | f_head.write(struct.pack("B", 29)) 63 | for i in range(len(alltags)): 64 | find = 0 65 | for j in range(len(ac_device.tags)): 66 | if alltags[i] == ac_device.tags[j].tag: 67 | f_content.write(ac_device.tags[j].value) 68 | 69 | f_head.write(struct.pack("H", offset)) 70 | offset = offset + ac_device.tags[j].len 71 | 72 | # Find Max length 73 | if tags_max_size[i] < ac_device.tags[j].len: 74 | tags_max_size[i] = ac_device.tags[j].len; 75 | find = 1 76 | break 77 | 78 | if find == 0: 79 | f_head.write(struct.pack("H", 0xffff)) 80 | # f.write(ac_device) 81 | f_content.close() 82 | f_tmp = open(sys.argv[2] + str(ac_device.device_id) + "_tmp.bin", "rb") 83 | f_head.write(f_tmp.read()) 84 | f_tmp.close() 85 | f_head.close() 86 | 87 | dom = xml.dom.minidom.parse(sys.argv[1]) 88 | device = dom.documentElement 89 | # devices = root.getElementsByTagName('remote_controller') 90 | 91 | print "============================" 92 | print "AC data:" 93 | print "============================" 94 | ac_device_arrary=[] 95 | id = device.getElementsByTagName('id') 96 | idnum = int(id[0].firstChild.data.encode('ascii'), 10) 97 | 98 | g_ac_device = ACRemoteControl(idnum) 99 | print "------------AC Device ID: %d-------------" % idnum 100 | exts = device.getElementsByTagName('exts') 101 | for n in range(len(exts)): 102 | ext = exts[n].getElementsByTagName('ext') 103 | for j in range(len(ext)): 104 | tag_index=ext[j].getElementsByTagName('tag') 105 | tag_index_data = int(tag_index[0].firstChild.data.encode('ascii'), 10) 106 | tag_value=ext[j].getElementsByTagName('value') 107 | tag_value_data = tag_value[0].firstChild.data.encode('ascii') 108 | g_ac_device.add(ACTag(tag_index_data, tag_value_data)) 109 | g_ac_device.sort() 110 | g_ac_device.printf() 111 | create_binary(g_ac_device) 112 | ac_device_arrary.append(g_ac_device) 113 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_ac_parse_forbidden_info.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_parse_forbidden_info.c 3 | Revised: Date: 2016-10-05 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for forbidden area of AC code 7 | 8 | Revision log: 9 | * 2016-10-05: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../include/ir_decode.h" 17 | #include "../include/ir_ac_parse_forbidden_info.h" 18 | 19 | 20 | extern t_ac_protocol *context; 21 | 22 | 23 | INT8 parse_nmode_data_speed(char *pdata, t_ac_n_mode seq) 24 | { 25 | char buf[16] = {0}; 26 | char *p = pdata; 27 | UINT16 pos = 0; 28 | UINT16 cnt = 0, index = 0; 29 | 30 | while (index <= ir_strlen(pdata)) 31 | { 32 | while ((index != ir_strlen(pdata)) && (*(p++) != ',')) 33 | { 34 | index++; 35 | } 36 | ir_memcpy(buf, pdata + pos, index - pos); 37 | pos = (UINT16) (index + 1); 38 | index = pos; 39 | context->n_mode[seq].speed[cnt++] = (UINT8) atoi(buf); 40 | context->n_mode[seq].speed_cnt = (UINT8) cnt; 41 | ir_memset(buf, 0, 16); 42 | } 43 | 44 | return IR_DECODE_SUCCEEDED; 45 | } 46 | 47 | INT8 parse_nmode_data_temp(char *pdata, t_ac_n_mode seq) 48 | { 49 | 50 | char buf[16] = {0}; 51 | char *p = pdata; 52 | UINT16 pos = 0; 53 | UINT16 cnt = 0, index = 0; 54 | 55 | while (index <= ir_strlen(pdata)) 56 | { 57 | while ((index != ir_strlen(pdata)) && (*(p++) != ',')) 58 | { 59 | index++; 60 | } 61 | ir_memcpy(buf, pdata + pos, index - pos); 62 | pos = (UINT16) (index + 1); 63 | index = pos; 64 | context->n_mode[seq].temp[cnt++] = (UINT8) (atoi(buf) - 16); 65 | context->n_mode[seq].temp_cnt = (UINT8) cnt; 66 | ir_memset(buf, 0, 16); 67 | } 68 | return IR_DECODE_SUCCEEDED; 69 | } 70 | 71 | INT8 parse_nmode_pos(char *buf, t_ac_n_mode index) 72 | { 73 | UINT16 i = 0; 74 | char data[64] = {0}; 75 | // char start[8] = {0}; 76 | if (ir_strlen(buf) == 1) 77 | { 78 | if (buf[0] == 'S' || buf[0] == 's') 79 | { 80 | context->n_mode[index].all_speed = 1; 81 | } 82 | else if (buf[0] == 'T' || buf[0] == 't') 83 | { 84 | context->n_mode[index].all_temp = 1; 85 | } 86 | return IR_DECODE_SUCCEEDED; 87 | } 88 | 89 | for (i = 0; i < ir_strlen(buf); i++) 90 | { 91 | if (buf[i] == '&') 92 | { 93 | ir_memcpy(data, buf + i + 1, ir_strlen(buf) - i - 1); 94 | break; 95 | } 96 | } 97 | if (buf[0] == 'S') 98 | { 99 | parse_nmode_data_speed(data, index); 100 | } 101 | else 102 | { 103 | parse_nmode_data_temp(data, index); 104 | } 105 | 106 | return IR_DECODE_SUCCEEDED; 107 | } 108 | 109 | INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index) 110 | { 111 | UINT16 i = 0; 112 | UINT16 preindex = 0; 113 | 114 | char buf[64] = {0}; 115 | 116 | if (tag->p_data[0] == 'N' && tag->p_data[1] == 'A') 117 | { 118 | // ban this function directly 119 | context->n_mode[index].enable = 0; 120 | return IR_DECODE_SUCCEEDED; 121 | } 122 | else 123 | { 124 | context->n_mode[index].enable = 1; 125 | } 126 | 127 | preindex = 0; 128 | for (i = 0; i < tag->len; i++) 129 | { 130 | if (tag->p_data[i] == '|') 131 | { 132 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 133 | preindex = (UINT16) (i + 1); 134 | parse_nmode_pos(buf, index); 135 | ir_memset(buf, 0, 64); 136 | } 137 | 138 | } 139 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 140 | parse_nmode_pos(buf, index); 141 | ir_memset(buf, 0, 64); 142 | return IR_DECODE_SUCCEEDED; 143 | } 144 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/jvmticmlr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /* 27 | * This header file defines the data structures sent by the VM 28 | * through the JVMTI CompiledMethodLoad callback function via the 29 | * "void * compile_info" parameter. The memory pointed to by the 30 | * compile_info parameter may not be referenced after returning from 31 | * the CompiledMethodLoad callback. These are VM implementation 32 | * specific data structures that may evolve in future releases. A 33 | * JVMTI agent should interpret a non-NULL compile_info as a pointer 34 | * to a region of memory containing a list of records. In a typical 35 | * usage scenario, a JVMTI agent would cast each record to a 36 | * jvmtiCompiledMethodLoadRecordHeader, a struct that represents 37 | * arbitrary information. This struct contains a kind field to indicate 38 | * the kind of information being passed, and a pointer to the next 39 | * record. If the kind field indicates inlining information, then the 40 | * agent would cast the record to a jvmtiCompiledMethodLoadInlineRecord. 41 | * This record contains an array of PCStackInfo structs, which indicate 42 | * for every pc address what are the methods on the invocation stack. 43 | * The "methods" and "bcis" fields in each PCStackInfo struct specify a 44 | * 1-1 mapping between these inlined methods and their bytecode indices. 45 | * This can be used to derive the proper source lines of the inlined 46 | * methods. 47 | */ 48 | 49 | #ifndef _JVMTI_CMLR_H_ 50 | #define _JVMTI_CMLR_H_ 51 | 52 | enum { 53 | JVMTI_CMLR_MAJOR_VERSION_1 = 0x00000001, 54 | JVMTI_CMLR_MINOR_VERSION_0 = 0x00000000, 55 | 56 | JVMTI_CMLR_MAJOR_VERSION = 0x00000001, 57 | JVMTI_CMLR_MINOR_VERSION = 0x00000000 58 | 59 | /* 60 | * This comment is for the "JDK import from HotSpot" sanity check: 61 | * version: 1.0.0 62 | */ 63 | }; 64 | 65 | typedef enum { 66 | JVMTI_CMLR_DUMMY = 1, 67 | JVMTI_CMLR_INLINE_INFO = 2 68 | } jvmtiCMLRKind; 69 | 70 | /* 71 | * Record that represents arbitrary information passed through JVMTI 72 | * CompiledMethodLoadEvent void pointer. 73 | */ 74 | typedef struct _jvmtiCompiledMethodLoadRecordHeader { 75 | jvmtiCMLRKind kind; /* id for the kind of info passed in the record */ 76 | jint majorinfoversion; /* major and minor info version values. Init'ed */ 77 | jint minorinfoversion; /* to current version value in jvmtiExport.cpp. */ 78 | 79 | struct _jvmtiCompiledMethodLoadRecordHeader* next; 80 | } jvmtiCompiledMethodLoadRecordHeader; 81 | 82 | /* 83 | * Record that gives information about the methods on the compile-time 84 | * stack at a specific pc address of a compiled method. Each element in 85 | * the methods array maps to same element in the bcis array. 86 | */ 87 | typedef struct _PCStackInfo { 88 | void* pc; /* the pc address for this compiled method */ 89 | jint numstackframes; /* number of methods on the stack */ 90 | jmethodID* methods; /* array of numstackframes method ids */ 91 | jint* bcis; /* array of numstackframes bytecode indices */ 92 | } PCStackInfo; 93 | 94 | /* 95 | * Record that contains inlining information for each pc address of 96 | * an nmethod. 97 | */ 98 | typedef struct _jvmtiCompiledMethodLoadInlineRecord { 99 | jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */ 100 | jint numpcs; /* number of pc descriptors in this nmethod */ 101 | PCStackInfo* pcinfo; /* array of numpcs pc descriptors */ 102 | } jvmtiCompiledMethodLoadInlineRecord; 103 | 104 | /* 105 | * Dummy record used to test that we can pass records with different 106 | * information through the void pointer provided that they can be cast 107 | * to a jvmtiCompiledMethodLoadRecordHeader. 108 | */ 109 | 110 | typedef struct _jvmtiCompiledMethodLoadDummyRecord { 111 | jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */ 112 | char message[50]; 113 | } jvmtiCompiledMethodLoadDummyRecord; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_tv_control.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_lib.h 3 | Revised: Date: 2016-02-23 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode (compressed command type) 7 | 8 | Revision log: 9 | * 2016-10-21: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_LIB_H_ 13 | #define _IRDA_LIB_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include "ir_defs.h" 21 | 22 | #define STB_CHANNEL_OFFSET 14 23 | 24 | #define IRDA_FLAG_NORMAL 0 25 | #define IRDA_FLAG_INVERSE 1 26 | 27 | #define IRDA_LEVEL_LOW 0 28 | #define IRDA_LEVEL_HIGH 1 29 | 30 | #define IRDA_LSB 0 31 | #define IRDA_MSB 1 32 | 33 | enum 34 | { 35 | IRDA_DECODE_1_BIT = 0, 36 | IRDA_DECODE_2_BITS, 37 | IRDA_DECODE_4_BITS, 38 | }; 39 | 40 | /* 41 | * global type definitions 42 | */ 43 | typedef enum ir_flags 44 | { 45 | IRDA_BOOT = 0, 46 | IRDA_STOP, 47 | IRDA_SEP, 48 | IRDA_ONE, 49 | IRDA_ZERO, 50 | IRDA_FLIP, 51 | IRDA_TWO, 52 | IRDA_THREE = 7, 53 | IRDA_FOUR, 54 | IRDA_FIVE, 55 | IRDA_SIX, 56 | IRDA_SEVEN, 57 | IRDA_EIGHT, 58 | IRDA_NINE, 59 | IRDA_A, 60 | IRDA_B, 61 | IRDA_C, 62 | IRDA_D, 63 | IRDA_E, 64 | IRDA_F, 65 | IRDA_MAX = 20, 66 | } t_ir_flags; 67 | 68 | typedef struct ir_data 69 | { 70 | UINT8 bits; 71 | UINT8 lsb; 72 | UINT8 mode; 73 | UINT8 index; 74 | } t_ir_data; 75 | 76 | #if !defined BOARD_51 77 | #pragma pack(1) 78 | #endif 79 | typedef struct ir_cycles 80 | { 81 | UINT8 flag; 82 | UINT16 mask; 83 | UINT16 space; 84 | } t_ir_cycles; 85 | 86 | #if !defined BOARD_51 87 | #pragma pack() 88 | #endif 89 | 90 | typedef enum tv_key_value 91 | { 92 | TV_POWER = 0, 93 | TV_MUTE, 94 | TV_UP, 95 | TV_DOWN, 96 | TV_LEFT, 97 | TV_RIGHT, 98 | TV_OK, 99 | TV_VOL_UP, 100 | TV_VOL_DOWN, 101 | TV_BACK, 102 | TV_INPUT, 103 | TV_MENU, 104 | TV_HOME, 105 | TV_SET, 106 | TV_0, 107 | TV_1, 108 | TV_2, 109 | TV_3, 110 | TV_4, 111 | TV_5, 112 | TV_6, 113 | TV_7, 114 | TV_8, 115 | TV_9, 116 | TV_KEY_MAX, 117 | } t_tv_key_value; 118 | 119 | 120 | typedef enum stb_key_value 121 | { 122 | STB_POWER = 0, 123 | STB_MUTE, 124 | STB_UP, 125 | STB_DOWN, 126 | STB_LEFT, 127 | STB_RIGHT, 128 | STB_OK, 129 | STB_VOL_UP, 130 | STB_VOL_DOWN, 131 | STB_BACK, 132 | STB_INPUT, 133 | STB_MENU, 134 | STB_PAGE_UP, 135 | STB_PAGE_DOWN, 136 | STB_0, 137 | STB_1, 138 | STB_2, 139 | STB_3, 140 | STB_4, 141 | STB_5, 142 | STB_6, 143 | STB_7, 144 | STB_8, 145 | STB_9, 146 | STB_KEY_MAX, 147 | } t_stb_key_value; 148 | 149 | typedef enum nw_key_value 150 | { 151 | NW_POWER = 0, 152 | NW_UP, 153 | NW_DOWN, 154 | NW_LEFT, 155 | NW_RIGHT, 156 | NW_OK, 157 | NW_VOL_UP, 158 | NW_VOL_DOWN, 159 | NW_BACK, 160 | NW_MENU, 161 | NW_HOME, 162 | NW_0, 163 | NW_1, 164 | NW_2, 165 | NW_3, 166 | NW_4, 167 | NW_5, 168 | NW_6, 169 | NW_7, 170 | NW_8, 171 | NW_9, 172 | NW_KEY_MAX, 173 | } t_nw_key_value; 174 | 175 | typedef enum cm_key_value 176 | { 177 | CM_POWER = 0, 178 | CM_UP, 179 | CM_DOWN, 180 | CM_LEFT, 181 | CM_RIGHT, 182 | CM_OK, 183 | CM_VOL_UP, 184 | CM_VOL_DOWN, 185 | CM_FUNC_1, 186 | CM_FUNC_2, 187 | CM_FUNC_3, 188 | CM_BACK, 189 | CM_HOME, 190 | CM_MENU, 191 | CM_MODE, 192 | CM_KEY_MAX, 193 | } t_cm_key_value; 194 | 195 | typedef struct ir_data_tv 196 | { 197 | char magic[4]; 198 | UINT8 per_keycode_bytes; 199 | } t_ir_data_tv; 200 | 201 | 202 | extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); 203 | 204 | extern BOOL tv_lib_parse(UINT8 encode_type); 205 | 206 | extern UINT16 tv_lib_control(UINT8 key, UINT16 *user_data); 207 | 208 | extern UINT8 tv_lib_close(); 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | #endif /* _IRDA_LIB_H_ */ 215 | 216 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_ac_build_frame.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_irframe.c 3 | Revised: Date: 2016-10-01 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR frame build 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include "../include/ir_ac_build_frame.h" 13 | #include "../include/ir_decode.h" 14 | 15 | extern t_ac_protocol *context; 16 | 17 | 18 | //return bit number per byte,default value is 8 19 | UINT8 bits_per_byte(UINT8 index) 20 | { 21 | UINT8 i = 0; 22 | UINT8 size = 0; 23 | 24 | if (context->bit_num_cnt == 0) 25 | return 8; //defaut value 26 | 27 | if (context->bit_num_cnt >= MAX_BITNUM) 28 | size = MAX_BITNUM; 29 | else 30 | size = (UINT8) context->bit_num_cnt; 31 | 32 | for (i = 0; i < size; i++) 33 | { 34 | if (context->bit_num[i].pos == index) 35 | return (UINT8) context->bit_num[i].bits; 36 | if (context->bit_num[i].pos > index) 37 | return 8; 38 | } 39 | return 8; 40 | } 41 | 42 | UINT16 add_delaycode(UINT8 index) 43 | { 44 | UINT8 i = 0, j = 0; 45 | UINT8 size = 0; 46 | UINT8 tail_delaycode = 0; 47 | UINT16 tail_pos = 0; 48 | 49 | if (context->dc_cnt != 0) 50 | { 51 | size = (UINT8) context->dc_cnt; 52 | 53 | for (i = 0; i < size; i++) 54 | { 55 | if (context->dc[i].pos == index) 56 | { 57 | for (j = 0; j < context->dc[i].time_cnt; j++) 58 | { 59 | context->time[context->code_cnt++] = context->dc[i].time[j]; 60 | } 61 | } 62 | else if (context->dc[i].pos == -1) 63 | { 64 | tail_delaycode = 1; 65 | tail_pos = i; 66 | } 67 | } 68 | } 69 | 70 | if ((context->last_bit == 0) && (index == (ir_hex_len - 1))) 71 | { 72 | context->time[context->code_cnt++] = context->one.low; //high 73 | } 74 | 75 | if (context->dc_cnt != 0) 76 | { 77 | if ((index == (ir_hex_len - 1)) && (tail_delaycode == 1)) 78 | { 79 | for (i = 0; i < context->dc[tail_pos].time_cnt; i++) 80 | { 81 | context->time[context->code_cnt++] = context->dc[tail_pos].time[i]; 82 | } 83 | } 84 | } 85 | 86 | return context->dc[i].time_cnt; 87 | } 88 | 89 | UINT16 create_ir_frame() 90 | { 91 | UINT16 i = 0, j = 0; 92 | UINT8 bitnum = 0; 93 | UINT8 *irdata = ir_hex_code; 94 | UINT8 mask = 1; 95 | UINT16 framelen = 0; 96 | 97 | context->code_cnt = 0; 98 | 99 | // boot code 100 | for (i = 0; i < context->boot_code.len; i++) 101 | { 102 | context->time[context->code_cnt++] = context->boot_code.data[i]; 103 | } 104 | //code_cnt += context->boot_code.len; 105 | 106 | for (i = 0; i < ir_hex_len; i++) 107 | { 108 | bitnum = bits_per_byte((UINT8) i); 109 | for (j = 0; j < bitnum; j++) 110 | { 111 | if (context->endian == 0) 112 | mask = (UINT8) ((1 << (bitnum - 1)) >> j); 113 | else 114 | mask = (UINT8) (1 << j); 115 | 116 | if (irdata[i] & mask) 117 | { 118 | //ir_printf("%d,%d,", context->one.low, context->one.high); 119 | context->time[context->code_cnt++] = context->one.low; 120 | context->time[context->code_cnt++] = context->one.high; 121 | } 122 | else 123 | { 124 | //ir_printf("%d,%d,", context->zero.low, context->zero.high); 125 | context->time[context->code_cnt++] = context->zero.low; 126 | context->time[context->code_cnt++] = context->zero.high; 127 | } 128 | } 129 | add_delaycode((UINT8) i); 130 | } 131 | 132 | framelen = context->code_cnt; 133 | 134 | for (i = 0; i < (context->repeat_times - 1); i++) 135 | { 136 | for (j = 0; j < framelen; j++) 137 | { 138 | context->time[context->code_cnt++] = context->time[j]; 139 | } 140 | } 141 | 142 | return context->code_cnt; 143 | } 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/win32/bridge/AccessBridgeCallbacks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /* 27 | * AccessBridgeCallbacks.h 1.17 05/03/21 28 | */ 29 | 30 | /* 31 | * Header file defining callback typedefs for Windows routines 32 | * which are called from Java (responding to events, etc.). 33 | */ 34 | 35 | #ifndef __AccessBridgeCallbacks_H__ 36 | #define __AccessBridgeCallbacks_H__ 37 | 38 | #include 39 | #include "AccessBridgePackages.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | typedef void (*AccessBridge_PropertyChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 46 | wchar_t *property, wchar_t *oldValue, wchar_t *newValue); 47 | 48 | typedef void (*AccessBridge_JavaShutdownFP) (long vmID); 49 | typedef void (*AccessBridge_JavaShutdownFP) (long vmID); 50 | 51 | typedef void (*AccessBridge_FocusGainedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 52 | typedef void (*AccessBridge_FocusLostFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 53 | 54 | typedef void (*AccessBridge_CaretUpdateFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 55 | 56 | typedef void (*AccessBridge_MouseClickedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 57 | typedef void (*AccessBridge_MouseEnteredFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 58 | typedef void (*AccessBridge_MouseExitedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 59 | typedef void (*AccessBridge_MousePressedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 60 | typedef void (*AccessBridge_MouseReleasedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 61 | 62 | typedef void (*AccessBridge_MenuCanceledFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 63 | typedef void (*AccessBridge_MenuDeselectedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 64 | typedef void (*AccessBridge_MenuSelectedFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 65 | typedef void (*AccessBridge_PopupMenuCanceledFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 66 | typedef void (*AccessBridge_PopupMenuWillBecomeInvisibleFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 67 | typedef void (*AccessBridge_PopupMenuWillBecomeVisibleFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 68 | 69 | typedef void (*AccessBridge_PropertyNameChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 70 | wchar_t *oldName, wchar_t *newName); 71 | typedef void (*AccessBridge_PropertyDescriptionChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 72 | wchar_t *oldDescription, wchar_t *newDescription); 73 | typedef void (*AccessBridge_PropertyStateChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 74 | wchar_t *oldState, wchar_t *newState); 75 | typedef void (*AccessBridge_PropertyValueChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 76 | wchar_t *oldValue, wchar_t *newValue); 77 | typedef void (*AccessBridge_PropertySelectionChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 78 | typedef void (*AccessBridge_PropertyTextChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 79 | typedef void (*AccessBridge_PropertyCaretChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 80 | int oldPosition, int newPosition); 81 | typedef void (*AccessBridge_PropertyVisibleDataChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source); 82 | typedef void (*AccessBridge_PropertyChildChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 source, 83 | JOBJECT64 oldChild, JOBJECT64 newChild); 84 | typedef void (*AccessBridge_PropertyActiveDescendentChangeFP) (long vmID, JOBJECT64 event, 85 | JOBJECT64 source, 86 | JOBJECT64 oldActiveDescendent, 87 | JOBJECT64 newActiveDescendent); 88 | 89 | typedef void (*AccessBridge_PropertyTableModelChangeFP) (long vmID, JOBJECT64 event, JOBJECT64 src, 90 | wchar_t *oldValue, wchar_t *newValue); 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/ir_encoder/irda_tv_protocol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | # 4 | # created by strawmanbobi 2016-11-10 5 | 6 | import struct 7 | import sys 8 | import xml.dom.minidom 9 | 10 | flag_tab = ("boot", "stop", "separator", "one", "zero", "flip", "two", "three") 11 | 12 | class IRDAData: 13 | def __init__(self, bits, lsb, mode, index): 14 | self.bits = bits 15 | self.lsb = lsb 16 | self.mode = mode 17 | self.index = index 18 | 19 | def printf(self): 20 | print "%d %d %d %d" % (self.bits, self.lsb, self.mode, self.index) 21 | 22 | def packIRData(self): 23 | return struct.pack("BBBB", self.bits, self.lsb, self.mode, self.index) 24 | 25 | class IRDAFlag: 26 | def __init__(self, name, mask, space): 27 | self.name = name 28 | self.mask = mask 29 | self.space = space 30 | 31 | def printf(self): 32 | print "%s %d %d" % (self.name, self.mask, self.space) 33 | 34 | def packFlag(self): 35 | return struct.pack("HH", self.mask, self.space) 36 | 37 | 38 | def printProtocol(file): 39 | print file 40 | dom = xml.dom.minidom.parse(file) 41 | root = dom.documentElement 42 | freqnode = root.getElementsByTagName('frequency') 43 | freq = freqnode[0].firstChild.data 44 | inverseflag = 0 45 | 46 | protnode = root.getAttribute('name') 47 | 48 | print protnode 49 | protname = protnode.split('_') 50 | 51 | binary = open(sys.argv[2], 'wb') 52 | 53 | bytes = struct.pack('20s', protnode.encode("ascii")) 54 | binary.write(bytes) 55 | 56 | bit = root.getElementsByTagName('bit') 57 | for n in range(len(flag_tab)): 58 | for b in range(len(bit)): 59 | name = bit[b].getAttribute('name') 60 | cycles = bit[b].getAttribute('cycles') 61 | if name and cycles: 62 | if cmp(flag_tab[n], name) == 0: 63 | bytes = struct.pack('B', int(cycles)) 64 | binary.write(bytes) 65 | break 66 | if b == (len(bit) - 1): 67 | bytes = struct.pack('B', 0) 68 | binary.write(bytes) 69 | for m in range(len(flag_tab)): 70 | found = 0 71 | for i in range(len(bit)): 72 | name = bit[i].getAttribute('name') 73 | cycles = bit[i].getAttribute('cycles') 74 | if name and cycles and cmp(flag_tab[m], name) == 0: 75 | found = 1 76 | cycle = bit[i].getElementsByTagName('cycle') 77 | for c in range(len(cycle)): 78 | normal = cycle[c].getAttribute('flag') 79 | mask = cycle[c].getAttribute('mask') 80 | space = cycle[c].getAttribute('space') 81 | if cmp(normal, "normal") == 0: 82 | inverseflag = 0 83 | else: 84 | inverseflag = 1 85 | print "{\"%s\", \"cycle:%s\", 0x%04x, 0x%04x, 0x%02x}" % ( 86 | name, c, int(mask), int(space), int(cycles)) 87 | bytes = struct.pack('B', inverseflag) 88 | binary.write(bytes) 89 | bytes = struct.pack('HH', int(mask), int(space)) 90 | binary.write(bytes) 91 | 92 | frame = root.getElementsByTagName('frame') 93 | 94 | index = 0 95 | lsb = 0 96 | mode = 0 97 | flag = 0 98 | irda_frame = [] 99 | flag_tab_dict = {"boot": 0, "stop": 1, "separator": 2, "one": 3, "zero": 4, "flip": 5, "two": 6, "three": 7} 100 | for i in frame[0].childNodes: 101 | if i.nodeType == i.ELEMENT_NODE: 102 | index += 1 103 | if i.getAttribute('type'): 104 | print "{%d, \"%s\", 0, 0, 0}" % (index, i.getAttribute('type')) 105 | flag = IRDAData(1, 0, 0, flag_tab_dict[i.getAttribute('type').encode("ascii")]) 106 | irda_frame.append(flag) 107 | if i.getAttribute('bits'): 108 | if cmp(i.getAttribute('ending'), "lsb") == 0: 109 | lsb = 0 110 | else: 111 | lsb = 1 112 | 113 | if cmp(i.getAttribute('mode'), "normal") == 0: 114 | mode = 0 115 | else: 116 | mode = 1 117 | 118 | print "{%d, \"%s\", %d, %d, %s}" % (index, i.getAttribute('bits'), 119 | lsb, mode, i.firstChild.data) 120 | flag = IRDAData(int(i.getAttribute('bits')), lsb, mode, int(i.firstChild.data)) 121 | irda_frame.append(flag) 122 | 123 | binary.write(struct.pack("B", len(irda_frame))) 124 | 125 | for i in range(len(irda_frame)): 126 | irda_frame[i].printf() 127 | binary.write(irda_frame[i].packIRData()) 128 | binary.close() 129 | 130 | printProtocol(sys.argv[1]) 131 | -------------------------------------------------------------------------------- /src/ir_encoder/irda_tv_protocol_hex.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | # 4 | # created by strawmanbobi 2016-11-10 5 | 6 | import struct 7 | import sys 8 | import xml.dom.minidom 9 | 10 | flag_tab = ("boot", "stop", "separator", "one", "zero", "flip", "two", "three", "four", "five", "six", "seven", 11 | "eight", "nine", "A", "B", "C", "D", "E", "F") 12 | 13 | class IRDAData: 14 | def __init__(self, bits, lsb, mode, index): 15 | self.bits = bits 16 | self.lsb = lsb 17 | self.mode = mode 18 | self.index = index 19 | 20 | def printf(self): 21 | print "%d %d %d %d" % (self.bits, self.lsb, self.mode, self.index) 22 | 23 | def packIRData(self): 24 | return struct.pack("BBBB", self.bits, self.lsb, self.mode, self.index) 25 | 26 | class IRDAFlag: 27 | def __init__(self, name, mask, space): 28 | self.name = name 29 | self.mask = mask 30 | self.space = space 31 | 32 | def printf(self): 33 | print "%s %d %d" % (self.name, self.mask, self.space) 34 | 35 | def packFlag(self): 36 | return struct.pack("HH", self.mask, self.space) 37 | 38 | 39 | def printProtocol(file): 40 | print file 41 | dom = xml.dom.minidom.parse(file) 42 | root = dom.documentElement 43 | freqnode = root.getElementsByTagName('frequency') 44 | freq = freqnode[0].firstChild.data 45 | inverseflag = 0 46 | 47 | protnode = root.getAttribute('name') 48 | 49 | print protnode 50 | protname = protnode.split('_') 51 | 52 | binary = open(sys.argv[2], 'wb') 53 | 54 | bytes = struct.pack('20s', protnode.encode("ascii")) 55 | binary.write(bytes) 56 | 57 | bit = root.getElementsByTagName('bit') 58 | for n in range(len(flag_tab)): 59 | for b in range(len(bit)): 60 | name = bit[b].getAttribute('name') 61 | cycles = bit[b].getAttribute('cycles') 62 | if name and cycles: 63 | if cmp(flag_tab[n], name) == 0: 64 | bytes = struct.pack('B', int(cycles)) 65 | binary.write(bytes) 66 | break 67 | if b == (len(bit) - 1): 68 | bytes = struct.pack('B', 0) 69 | binary.write(bytes) 70 | for m in range(len(flag_tab)): 71 | found = 0 72 | for i in range(len(bit)): 73 | name = bit[i].getAttribute('name') 74 | cycles = bit[i].getAttribute('cycles') 75 | if name and cycles and cmp(flag_tab[m], name) == 0: 76 | found = 1 77 | cycle = bit[i].getElementsByTagName('cycle') 78 | for c in range(len(cycle)): 79 | normal = cycle[c].getAttribute('flag') 80 | mask = cycle[c].getAttribute('mask') 81 | space = cycle[c].getAttribute('space') 82 | if cmp(normal, "normal") == 0: 83 | inverseflag = 0 84 | else: 85 | inverseflag = 1 86 | print "{\"%s\", \"cycle:%s\", 0x%04x, 0x%04x, 0x%02x}" % ( 87 | name, c, int(mask), int(space), int(cycles)) 88 | bytes = struct.pack('B', inverseflag) 89 | binary.write(bytes) 90 | bytes = struct.pack('HH', int(mask), int(space)) 91 | binary.write(bytes) 92 | 93 | frame = root.getElementsByTagName('frame') 94 | 95 | index = 0 96 | lsb = 0 97 | mode = 0 98 | flag = 0 99 | irda_frame = [] 100 | flag_tab_dict = {"boot": 0, "stop": 1, "separator": 2, "one": 3, "zero": 4, "flip": 5, "two": 6, "three": 7, 101 | "four": 8, "five": 9, "six": 10, "seven": 11, "eight": 12, "nine": 13, 102 | "A": 14, "B": 15, "C": 16, "D": 17, "E": 18, "F": 19} 103 | for i in frame[0].childNodes: 104 | if i.nodeType == i.ELEMENT_NODE: 105 | index += 1 106 | if i.getAttribute('type'): 107 | print "{%d, \"%s\", 0, 0, 0}" % (index, i.getAttribute('type')) 108 | flag = IRDAData(1, 0, 0, flag_tab_dict[i.getAttribute('type').encode("ascii")]) 109 | irda_frame.append(flag) 110 | if i.getAttribute('bits'): 111 | if cmp(i.getAttribute('ending'), "lsb") == 0: 112 | lsb = 0 113 | else: 114 | lsb = 1 115 | 116 | if cmp(i.getAttribute('mode'), "normal") == 0: 117 | mode = 0 118 | else: 119 | mode = 1 120 | 121 | print "{%d, \"%s\", %d, %d, %s}" % (index, i.getAttribute('bits'),\ 122 | lsb, mode, i.firstChild.data) 123 | flag = IRDAData(int(i.getAttribute('bits')), lsb, mode, int(i.firstChild.data)) 124 | irda_frame.append(flag) 125 | 126 | binary.write(struct.pack("B", len(irda_frame))) 127 | 128 | for i in range(len(irda_frame)): 129 | irda_frame[i].printf() 130 | binary.write(irda_frame[i].packIRData()) 131 | binary.close() 132 | 133 | printProtocol(sys.argv[1]) 134 | -------------------------------------------------------------------------------- /src/ir_encoder/irda_tv_encode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding = utf-8 3 | # 4 | # created by strawmanbobi 2016-11-10 5 | 6 | import sys 7 | import xml.dom.minidom 8 | import struct 9 | 10 | keymap_dict_empty = () 11 | 12 | keymap_dict_ac = () 13 | 14 | keymap_dict_tv = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", "HOME", 15 | "SET", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") 16 | 17 | keymap_dict_stb = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", 18 | "UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") 19 | 20 | keymap_dict_nw = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "MENU", "HOME", "0", "1", "2", 21 | "3", "4", "5", "6", "7", "8", "9") 22 | 23 | keymap_dict_iptv = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", 24 | "UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") 25 | 26 | keymap_dict_dvd = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "PLAY", "PAUSE", "EJECT", "BACK", 27 | "FOR", "MENU", "SWITCH") 28 | 29 | keymap_dict_fan = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "SPEED+", "SPEED-", "SWING", "SPEED", "MODE", "BACK", 30 | "HOME", "MENU", "SWITCH") 31 | 32 | keymap_dict_stereo = ("POWER1", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "MUTE", "MENU1", "POWER2", "BACK", 33 | "HOME", "MENU2", "SWITCH") 34 | 35 | keymap_dict_projector = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "ZOOM+", "MENU1", "ZOOM-", 36 | "BACK", "HOME", "MENU2", "SWITCH") 37 | 38 | keymap_dict_light = ("POWER", "COLOR_1", "COLOR_2", "COLOR_3", "COLOR_4", "COLOR_0", "BRIGHT", "DARK", "POWER_ON", 39 | "RAINBOW", "POWER_OFF", "BACK", "HOME", "MENU", "SWITCH") 40 | 41 | keymap_dict_bstb = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", 42 | "UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9") 43 | 44 | keymap_dict_clean_robot = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "START", "PLUS", "MINUS", "AUTO", "SPOT", "SPEED", 45 | "TIMING", "CHARGE", "PLAN", "SWITCH") 46 | 47 | keymap_dict_air_cleaner = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "ION", "PLUS", "MINUS", "AUTO", "SPEED", "MODE", 48 | "TIMING", "LIGHT", "FORCE", "SWITCH") 49 | 50 | keymap_dicts = [keymap_dict_empty, 51 | keymap_dict_ac, keymap_dict_tv, keymap_dict_stb, keymap_dict_nw, keymap_dict_iptv, keymap_dict_dvd, 52 | keymap_dict_fan, keymap_dict_stereo, keymap_dict_projector, keymap_dict_light, keymap_dict_bstb, 53 | keymap_dict_clean_robot, keymap_dict_ac] 54 | 55 | class CKeyMap: 56 | def __init__(self, name, value): 57 | self.name = name 58 | self.value = value 59 | 60 | def print_info(self): 61 | print self.name, self.value 62 | 63 | def pack_key(self, output_file): 64 | for i in range(len(self.value)): 65 | output_file.write(struct.pack('B', self.value[i])) 66 | 67 | def pack_null(self, output_file): 68 | for i in range(len(self.value)): 69 | output_file.write(struct.pack('B', 0)) 70 | 71 | def pack_length(self, output_file): 72 | output_file.write(struct.pack('B', len(self.value))) 73 | print len(self.value) 74 | 75 | 76 | def print_remote(input_file, real_path, real_name, category): 77 | print input_file 78 | dom = xml.dom.minidom.parse(input_file) 79 | root = dom.documentElement 80 | protocol_node = root.getElementsByTagName('protocol') 81 | protocol = protocol_node[0].firstChild.data 82 | 83 | filename = real_name.split('.') 84 | 85 | binary = open(real_path + "/" + protocol + "#" + filename[0] + ".bin", 'wb') 86 | tag = struct.pack('4s', 'irda') 87 | binary.write(tag) 88 | 89 | print protocol 90 | keymap = root.getElementsByTagName('key-map') 91 | key = [] 92 | empty_value = [] 93 | for i in keymap[0].childNodes: 94 | if i.nodeType == i.ELEMENT_NODE: 95 | key_map_str = i.firstChild.data.encode('ascii').split(' ') 96 | value = [] 97 | empty_value = [] 98 | for m in range(len(key_map_str)): 99 | value.append(int(key_map_str[m], 16)) 100 | empty_value.append(int('0', 16)) 101 | name = i.getAttribute('name').encode('ascii') 102 | data = CKeyMap(name, value) 103 | key.append(data) 104 | 105 | key[0].pack_length(binary) 106 | for j in range(len(keymap_dicts[int(category)])): 107 | empty_key = CKeyMap(keymap_dicts[int(category)][j], empty_value) 108 | find = 0 109 | for n in range(len(key)): 110 | if cmp(keymap_dicts[int(category)][j], key[n].name) == 0: 111 | key[n].print_info() 112 | key[n].pack_key(binary) 113 | find = 1 114 | break 115 | if find == 0: 116 | print "Don't file this key %s" % (keymap_dicts[int(category)][j]) 117 | empty_key.pack_key(binary) 118 | 119 | fileName = sys.argv[1] 120 | realName = sys.argv[2] 121 | realPath = sys.argv[3] 122 | inCategory = sys.argv[4] 123 | fileType = fileName.split('.') 124 | if cmp(fileType[1], "xml") == 0: 125 | print_remote(fileName, realPath, realName, inCategory) 126 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/ir_decode_jni.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #if defined BOARD_ANDROID 3 | #include 4 | #elif (defined BOARD_PC) && (defined BOARD_PC_JNI) 5 | #include "./include/jni.h" 6 | #endif 7 | /* Header for class net_irext_decodesdk_IRDecode */ 8 | 9 | #ifndef _Included_net_irext_decodesdk_IRDecode 10 | #define _Included_net_irext_decodesdk_IRDecode 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | #undef net_irext_decodesdk_IRDecode_BIND_ABOVE_CLIENT 15 | #define net_irext_decodesdk_IRDecode_BIND_ABOVE_CLIENT 8L 16 | #undef net_irext_decodesdk_IRDecode_BIND_ADJUST_WITH_ACTIVITY 17 | #define net_irext_decodesdk_IRDecode_BIND_ADJUST_WITH_ACTIVITY 128L 18 | #undef net_irext_decodesdk_IRDecode_BIND_ALLOW_OOM_MANAGEMENT 19 | #define net_irext_decodesdk_IRDecode_BIND_ALLOW_OOM_MANAGEMENT 16L 20 | #undef net_irext_decodesdk_IRDecode_BIND_AUTO_CREATE 21 | #define net_irext_decodesdk_IRDecode_BIND_AUTO_CREATE 1L 22 | #undef net_irext_decodesdk_IRDecode_BIND_DEBUG_UNBIND 23 | #define net_irext_decodesdk_IRDecode_BIND_DEBUG_UNBIND 2L 24 | #undef net_irext_decodesdk_IRDecode_BIND_IMPORTANT 25 | #define net_irext_decodesdk_IRDecode_BIND_IMPORTANT 64L 26 | #undef net_irext_decodesdk_IRDecode_BIND_NOT_FOREGROUND 27 | #define net_irext_decodesdk_IRDecode_BIND_NOT_FOREGROUND 4L 28 | #undef net_irext_decodesdk_IRDecode_BIND_WAIVE_PRIORITY 29 | #define net_irext_decodesdk_IRDecode_BIND_WAIVE_PRIORITY 32L 30 | #undef net_irext_decodesdk_IRDecode_CONTEXT_IGNORE_SECURITY 31 | #define net_irext_decodesdk_IRDecode_CONTEXT_IGNORE_SECURITY 2L 32 | #undef net_irext_decodesdk_IRDecode_CONTEXT_INCLUDE_CODE 33 | #define net_irext_decodesdk_IRDecode_CONTEXT_INCLUDE_CODE 1L 34 | #undef net_irext_decodesdk_IRDecode_CONTEXT_RESTRICTED 35 | #define net_irext_decodesdk_IRDecode_CONTEXT_RESTRICTED 4L 36 | #undef net_irext_decodesdk_IRDecode_MODE_APPEND 37 | #define net_irext_decodesdk_IRDecode_MODE_APPEND 32768L 38 | #undef net_irext_decodesdk_IRDecode_MODE_ENABLE_WRITE_AHEAD_LOGGING 39 | #define net_irext_decodesdk_IRDecode_MODE_ENABLE_WRITE_AHEAD_LOGGING 8L 40 | #undef net_irext_decodesdk_IRDecode_MODE_MULTI_PROCESS 41 | #define net_irext_decodesdk_IRDecode_MODE_MULTI_PROCESS 4L 42 | #undef net_irext_decodesdk_IRDecode_MODE_PRIVATE 43 | #define net_irext_decodesdk_IRDecode_MODE_PRIVATE 0L 44 | #undef net_irext_decodesdk_IRDecode_MODE_WORLD_READABLE 45 | #define net_irext_decodesdk_IRDecode_MODE_WORLD_READABLE 1L 46 | #undef net_irext_decodesdk_IRDecode_MODE_WORLD_WRITEABLE 47 | #define net_irext_decodesdk_IRDecode_MODE_WORLD_WRITEABLE 2L 48 | #undef net_irext_decodesdk_IRDecode_START_CONTINUATION_MASK 49 | #define net_irext_decodesdk_IRDecode_START_CONTINUATION_MASK 15L 50 | #undef net_irext_decodesdk_IRDecode_START_FLAG_REDELIVERY 51 | #define net_irext_decodesdk_IRDecode_START_FLAG_REDELIVERY 1L 52 | #undef net_irext_decodesdk_IRDecode_START_FLAG_RETRY 53 | #define net_irext_decodesdk_IRDecode_START_FLAG_RETRY 2L 54 | #undef net_irext_decodesdk_IRDecode_START_NOT_STICKY 55 | #define net_irext_decodesdk_IRDecode_START_NOT_STICKY 2L 56 | #undef net_irext_decodesdk_IRDecode_START_REDELIVER_INTENT 57 | #define net_irext_decodesdk_IRDecode_START_REDELIVER_INTENT 3L 58 | #undef net_irext_decodesdk_IRDecode_START_STICKY 59 | #define net_irext_decodesdk_IRDecode_START_STICKY 1L 60 | #undef net_irext_decodesdk_IRDecode_START_STICKY_COMPATIBILITY 61 | #define net_irext_decodesdk_IRDecode_START_STICKY_COMPATIBILITY 0L 62 | /* 63 | * Class: net_irext_decodesdk_IRDecode 64 | * Method: irOpen 65 | * Signature: II(Ljava/lang/String;) 66 | */ 67 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpen 68 | (JNIEnv *, jobject, jint, jint, jstring); 69 | 70 | /* 71 | * Class: net_irext_decodesdk_IRDecode 72 | * Method: irOpenBinary 73 | * Signature: II(Ljava/lang/String;) 74 | */ 75 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpenBinary 76 | (JNIEnv *, jobject, jint, jint, jbyteArray, jint); 77 | 78 | /* 79 | * Class: net_irext_decodesdk_IRDecode 80 | * Method: irDecode 81 | * Signature: I(Lnet/irext/decodesdk/bean/ACStatus;I)[I 82 | */ 83 | JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode 84 | (JNIEnv *, jobject, jint, jobject, jint); 85 | 86 | /* 87 | * Class: net_irext_decodesdk_IRDecode 88 | * Method: irClose 89 | * Signature: ()V 90 | */ 91 | JNIEXPORT void JNICALL Java_net_irext_decodesdk_IRDecode_irClose 92 | (JNIEnv *, jobject); 93 | 94 | /* 95 | * Class: net_irext_decodesdk_IRDecode 96 | * Method: irACGetTemperatureRange 97 | * Signature: (I)Lcom/irext/remote/bean/jnibean/TemperatureRange; 98 | */ 99 | JNIEXPORT jobject JNICALL Java_net_irext_decodesdk_IRDecode_irACGetTemperatureRange 100 | (JNIEnv *, jobject, jint); 101 | 102 | /* 103 | * Class: net_irext_decodesdk_IRDecode 104 | * Method: irACGetSupportedMode 105 | * Signature: ()I 106 | */ 107 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedMode 108 | (JNIEnv *, jobject); 109 | 110 | /* 111 | * Class: net_irext_decodesdk_IRDecode 112 | * Method: irACGetSupportedWindSpeed 113 | * Signature: (I)I 114 | */ 115 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedWindSpeed 116 | (JNIEnv *, jobject, jint); 117 | 118 | /* 119 | * Class: net_irext_decodesdk_IRDecode 120 | * Method: irACGetSupportedSwing 121 | * Signature: (I)I 122 | */ 123 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedSwing 124 | (JNIEnv *, jobject, jint); 125 | 126 | /* 127 | * Class: net_irext_decodesdk_IRDecode 128 | * Method: irACGetSupportedWindDirection 129 | * Signature: ()I 130 | */ 131 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedWindDirection 132 | (JNIEnv *, jobject); 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | #endif 138 | /* Header for class net_irext_decodesdk_IRDecode_LocalBinder */ 139 | 140 | #ifndef _Included_net_irext_decodesdk_IRDecode_LocalBinder 141 | #define _Included_net_irext_decodesdk_IRDecode_LocalBinder 142 | #ifdef __cplusplus 143 | extern "C" { 144 | #endif 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | #endif 149 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_decode.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_decode.h 3 | Revised: Date: 2016-10-01 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #ifndef _IRDA_DECODE_H_ 13 | #define _IRDA_DECODE_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | #include 21 | #include "ir_defs.h" 22 | #include "ir_ac_control.h" 23 | #include "ir_tv_control.h" 24 | 25 | #define IR_DECODE_FAILED (-1) 26 | #define IR_DECODE_SUCCEEDED (0) 27 | 28 | #define IR_CATEGORY_AC 1 29 | #define IR_CATEGORY_TV 2 30 | 31 | #define IR_TYPE_STATUS 0 32 | #define IR_TYPE_COMMANDS 1 33 | 34 | #define SUB_CATEGORY_QUATERNARY 0 35 | #define SUB_CATEGORY_HEXADECIMAL 1 36 | 37 | // exported functions 38 | /** 39 | * function ir_file_open 40 | * 41 | * description: open IR binary code from file 42 | * 43 | * parameters: category (in) - category ID get from indexing API 44 | * sub_category (in) - subcategory ID get from indexing API 45 | * file_name (in) - file name of IR binary 46 | * 47 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 48 | * 49 | */ 50 | extern INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name); 51 | 52 | /** 53 | * function ir_binary_open 54 | * 55 | * description: open IR binary code from buffer 56 | * 57 | * parameters: category (in) - category ID get from indexing API 58 | * sub_category (in) - subcategory ID get from indexing API 59 | * binary (in) - pointer to binary buffer 60 | * binary_length (in) - binary buffer size 61 | * 62 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 63 | */ 64 | extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length); 65 | 66 | /** 67 | * function ir_decode 68 | * 69 | * description: decode IR binary into INT16 array which indicates the IR levels 70 | * 71 | * parameters: key_code (in) - the code of pressed key 72 | * user_data (out) - output decoded data in INT16 array format 73 | * ac_status(in) - pointer to AC status (optional) 74 | * change_wind_direction (in) - if control changes wind direction for AC (for AC only) 75 | * 76 | * returns: length of decoded data (0 indicates decode failure) 77 | */ 78 | extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction); 79 | 80 | /** 81 | * function ir_decode_d 82 | * 83 | * description: decode IR binary into digital NEC code 84 | * 85 | * parameters: key_code (in) - the code of pressed key 86 | * user_data (out) - output decoded data in INT16 array format 87 | * ac_status(in) - pointer to AC status (optional) 88 | * change_wind_direction (in) - if control changes wind direction for AC (for AC only) 89 | * 90 | * returns: length of decoded data (0 indicates decode failure) 91 | */ 92 | extern UINT16 ir_decode_d(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction); 93 | 94 | /** 95 | * function ir_close 96 | * 97 | * description: close IR binary code 98 | * 99 | * parameters: N/A 100 | * 101 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 102 | */ 103 | extern INT8 ir_close(); 104 | 105 | /** 106 | * function get_temperature_range 107 | * 108 | * description: get the supported temperature range [min, max] for the opened AC IR binary 109 | * 110 | * parameters: ac_mode (in) specify in which AC mode the application need to get temperature info 111 | * temp_min (out) the min temperature supported in a specified AC mode 112 | * temp_max (out) the max temperature supported in a specified AC mode 113 | * 114 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 115 | */ 116 | extern INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max); 117 | 118 | /** 119 | * function get_supported_mode 120 | * 121 | * description: get supported mode for the opened AC IR binary 122 | * 123 | * parameters: supported_mode (out) mode supported by the remote in lower 5 bits 124 | * 125 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 126 | */ 127 | extern INT8 get_supported_mode(UINT8 *supported_mode); 128 | 129 | /** 130 | * function get_supported_wind_speed 131 | * 132 | * description: get supported wind speed levels for the opened AC IR binary in certain mode 133 | * 134 | * parameters: ac_mode (in) specify in which AC mode the application need to get wind speed info 135 | * supported_wind_speed (out) wind speed supported by the remote in lower 4 bits 136 | * 137 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 138 | */ 139 | extern INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed); 140 | 141 | /** 142 | * function get_supported_swing 143 | * 144 | * description: get supported swing functions for the opened AC IR binary in certain mode 145 | * 146 | * parameters: ac_mode (in) specify in which AC mode the application need to get swing info 147 | * supported_swing (out) swing supported by the remote in lower 2 bits 148 | * 149 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 150 | */ 151 | extern INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing); 152 | 153 | /** 154 | * function get_supported_wind_direction 155 | * 156 | * description: get supported wind directions for the opened AC IR binary in certain mode 157 | * 158 | * parameters: supported_wind_direction (out) swing supported by the remote in lower 2 bits 159 | * 160 | * returns: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED 161 | */ 162 | extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction); 163 | 164 | 165 | // private extern function 166 | #if (defined BOARD_PC || defined BOARD_PC_DLL) 167 | extern void ir_lib_free_inner_buffer(); 168 | #endif 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | 174 | #endif // _IRDA_DECODE_H_ 175 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/ir_decode_jni.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | Filename: ir_decode_jni.c 3 | Revised: Date: 2016-03-21 4 | Revision: Revision: 1.0 5 | 6 | Description: This file links to java layer for Android application 7 | 8 | Revision log: 9 | * 2016-03-21: created by strawmanbobi 10 | **************************************************************************************************/ 11 | #include 12 | #include 13 | 14 | #include "ir_decode_jni.h" 15 | #include "../include/ir_defs.h" 16 | #include "../include/ir_decode.h" 17 | 18 | // global variable definition 19 | extern size_t binary_length; 20 | extern UINT8 *binary_content; 21 | 22 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpen 23 | (JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate, jstring file_name) 24 | { 25 | const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0); 26 | if (IR_DECODE_FAILED == ir_file_open(category_id, sub_cate, n_file_name)) 27 | { 28 | ir_close(); 29 | (*env)->ReleaseStringUTFChars(env, file_name, n_file_name); 30 | return IR_DECODE_FAILED; 31 | } 32 | 33 | (*env)->ReleaseStringUTFChars(env, file_name, n_file_name); 34 | return IR_DECODE_SUCCEEDED; 35 | } 36 | 37 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpenBinary 38 | (JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate, 39 | jbyteArray binaries, jint bin_length) 40 | { 41 | jbyte* j_buffer = (*env)->GetByteArrayElements(env, binaries, 0); 42 | unsigned char* buffer = (unsigned char*)j_buffer; 43 | 44 | if (IR_DECODE_FAILED == ir_binary_open(category_id, sub_cate, buffer, bin_length)) 45 | { 46 | ir_close(); 47 | (*env)->ReleaseByteArrayElements(env, binaries, j_buffer, JNI_ABORT); 48 | return IR_DECODE_FAILED; 49 | } 50 | 51 | return IR_DECODE_SUCCEEDED; 52 | } 53 | 54 | JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode 55 | (JNIEnv *env, jobject this_obj, jint key_code, jobject jni_ac_status, jint change_wind_direction) 56 | { 57 | UINT16 user_data[USER_DATA_SIZE]; 58 | int i = 0; 59 | jint copy_array[USER_DATA_SIZE] = {0}; 60 | remote_ac_status_t ac_status; 61 | 62 | jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status); 63 | 64 | if (NULL != n_ac_status) 65 | { 66 | jfieldID ac_power_fid = (*env)->GetFieldID(env, n_ac_status, "acPower", "I"); 67 | jint i_ac_power = (*env)->GetIntField(env, jni_ac_status, ac_power_fid); 68 | 69 | jfieldID ac_mode_fid = (*env)->GetFieldID(env, n_ac_status, "acMode", "I"); 70 | jint i_ac_mode = (*env)->GetIntField(env, jni_ac_status, ac_mode_fid); 71 | 72 | jfieldID ac_temp_fid = (*env)->GetFieldID(env, n_ac_status, "acTemp", "I"); 73 | jint i_ac_temp = (*env)->GetIntField(env, jni_ac_status, ac_temp_fid); 74 | 75 | jfieldID ac_wind_dir_fid = (*env)->GetFieldID(env, n_ac_status, "acWindDir", "I"); 76 | jint i_ac_wind_dir = (*env)->GetIntField(env, jni_ac_status, ac_wind_dir_fid); 77 | 78 | jfieldID ac_wind_speed_fid = (*env)->GetFieldID(env, n_ac_status, "acWindSpeed", "I"); 79 | jint i_ac_wind_speed = (*env)->GetIntField(env, jni_ac_status, ac_wind_speed_fid); 80 | 81 | ac_status.acDisplay = 0; 82 | ac_status.acSleep = 0; 83 | ac_status.acTimer = 0; 84 | ac_status.acPower = i_ac_power; 85 | ac_status.acMode = i_ac_mode; 86 | ac_status.acTemp = i_ac_temp; 87 | ac_status.acWindDir = i_ac_wind_dir; 88 | ac_status.acWindSpeed = i_ac_wind_speed; 89 | } 90 | 91 | int wave_code_length = ir_decode(key_code, user_data, &ac_status, change_wind_direction); 92 | 93 | jintArray result = (*env)->NewIntArray(env, wave_code_length); 94 | if (result == NULL) 95 | { 96 | return NULL; /* out of memory error thrown */ 97 | } 98 | for (i = 0; i < wave_code_length; i++) 99 | { 100 | copy_array[i] = (int)user_data[i]; 101 | } 102 | (*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array); 103 | (*env)->DeleteLocalRef(env, n_ac_status); 104 | 105 | return result; 106 | } 107 | 108 | JNIEXPORT void JNICALL Java_net_irext_decodesdk_IRDecode_irClose 109 | (JNIEnv *env, jobject this_obj) 110 | { 111 | ir_close(); 112 | } 113 | 114 | JNIEXPORT jobject JNICALL Java_net_irext_decodesdk_IRDecode_irACGetTemperatureRange 115 | (JNIEnv *env, jobject this_obj, jint ac_mode) 116 | { 117 | int tempMin = 0; 118 | int tempMax = 0; 119 | 120 | jobject temperature_range = NULL; 121 | jclass temperature_range_class = 122 | (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNITemperatureRange"); 123 | 124 | jmethodID temperature_range_mid = 125 | (*env)->GetMethodID(env, temperature_range_class, "", "()V"); 126 | 127 | jfieldID min_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMin", "I"); 128 | jfieldID max_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMax", "I"); 129 | 130 | temperature_range = (*env)->NewObject(env, temperature_range_class, temperature_range_mid); 131 | 132 | get_temperature_range((UINT8)ac_mode, (INT8*)&tempMin, (INT8*)&tempMax); 133 | 134 | (*env)->SetIntField(env, temperature_range, min_temp_fid, tempMin); 135 | (*env)->SetIntField(env, temperature_range, max_temp_fid, tempMax); 136 | 137 | return temperature_range; 138 | } 139 | 140 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedMode 141 | (JNIEnv *env, jobject this_obj) 142 | { 143 | int supported_mode = 0; 144 | get_supported_mode((UINT8*)&supported_mode); 145 | return supported_mode; 146 | } 147 | 148 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedWindSpeed 149 | (JNIEnv *env, jobject this_obj, jint ac_mode) 150 | { 151 | int supported_wind_speed = 0; 152 | get_supported_wind_speed((UINT8)ac_mode, (UINT8*)&supported_wind_speed); 153 | return supported_wind_speed; 154 | } 155 | 156 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedSwing 157 | (JNIEnv *env, jobject this_obj, jint ac_mode) 158 | { 159 | int supported_swing = 0; 160 | get_supported_swing((UINT8)ac_mode, (UINT8*)&supported_swing); 161 | return supported_swing; 162 | } 163 | 164 | JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irACGetSupportedWindDirection 165 | (JNIEnv *env, jobject this_obj) 166 | { 167 | int supported_wind_direction = 0; 168 | get_supported_wind_direction((UINT8*)&supported_wind_direction); 169 | return supported_wind_direction; 170 | } -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/jdwpTransport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /* 27 | * Java Debug Wire Protocol Transport Service Provider Interface. 28 | */ 29 | 30 | #ifndef JDWPTRANSPORT_H 31 | #define JDWPTRANSPORT_H 32 | 33 | #include "jni.h" 34 | 35 | enum { 36 | JDWPTRANSPORT_VERSION_1_0 = 0x00010000 37 | }; 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | struct jdwpTransportNativeInterface_; 44 | 45 | struct _jdwpTransportEnv; 46 | 47 | #ifdef __cplusplus 48 | typedef _jdwpTransportEnv jdwpTransportEnv; 49 | #else 50 | typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; 51 | #endif /* __cplusplus */ 52 | 53 | /* 54 | * Errors. Universal errors with JVMTI/JVMDI equivalents keep the 55 | * values the same. 56 | */ 57 | typedef enum { 58 | JDWPTRANSPORT_ERROR_NONE = 0, 59 | JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, 60 | JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, 61 | JDWPTRANSPORT_ERROR_INTERNAL = 113, 62 | JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, 63 | JDWPTRANSPORT_ERROR_IO_ERROR = 202, 64 | JDWPTRANSPORT_ERROR_TIMEOUT = 203, 65 | JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 66 | } jdwpTransportError; 67 | 68 | 69 | /* 70 | * Structure to define capabilities 71 | */ 72 | typedef struct { 73 | unsigned int can_timeout_attach :1; 74 | unsigned int can_timeout_accept :1; 75 | unsigned int can_timeout_handshake :1; 76 | unsigned int reserved3 :1; 77 | unsigned int reserved4 :1; 78 | unsigned int reserved5 :1; 79 | unsigned int reserved6 :1; 80 | unsigned int reserved7 :1; 81 | unsigned int reserved8 :1; 82 | unsigned int reserved9 :1; 83 | unsigned int reserved10 :1; 84 | unsigned int reserved11 :1; 85 | unsigned int reserved12 :1; 86 | unsigned int reserved13 :1; 87 | unsigned int reserved14 :1; 88 | unsigned int reserved15 :1; 89 | } JDWPTransportCapabilities; 90 | 91 | 92 | /* 93 | * Structures to define packet layout. 94 | * 95 | * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html 96 | */ 97 | 98 | enum { 99 | /* 100 | * If additional flags are added that apply to jdwpCmdPacket, 101 | * then debugLoop.c: reader() will need to be updated to 102 | * accept more than JDWPTRANSPORT_FLAGS_NONE. 103 | */ 104 | JDWPTRANSPORT_FLAGS_NONE = 0x0, 105 | JDWPTRANSPORT_FLAGS_REPLY = 0x80 106 | }; 107 | 108 | typedef struct { 109 | jint len; 110 | jint id; 111 | jbyte flags; 112 | jbyte cmdSet; 113 | jbyte cmd; 114 | jbyte *data; 115 | } jdwpCmdPacket; 116 | 117 | typedef struct { 118 | jint len; 119 | jint id; 120 | jbyte flags; 121 | jshort errorCode; 122 | jbyte *data; 123 | } jdwpReplyPacket; 124 | 125 | typedef struct { 126 | union { 127 | jdwpCmdPacket cmd; 128 | jdwpReplyPacket reply; 129 | } type; 130 | } jdwpPacket; 131 | 132 | /* 133 | * JDWP functions called by the transport. 134 | */ 135 | typedef struct jdwpTransportCallback { 136 | void *(*alloc)(jint numBytes); /* Call this for all allocations */ 137 | void (*free)(void *buffer); /* Call this for all deallocations */ 138 | } jdwpTransportCallback; 139 | 140 | typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, 141 | jdwpTransportCallback *callback, 142 | jint version, 143 | jdwpTransportEnv** env); 144 | 145 | 146 | 147 | /* Function Interface */ 148 | 149 | struct jdwpTransportNativeInterface_ { 150 | /* 1 : RESERVED */ 151 | void *reserved1; 152 | 153 | /* 2 : Get Capabilities */ 154 | jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, 155 | JDWPTransportCapabilities *capabilities_ptr); 156 | 157 | /* 3 : Attach */ 158 | jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, 159 | const char* address, 160 | jlong attach_timeout, 161 | jlong handshake_timeout); 162 | 163 | /* 4: StartListening */ 164 | jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, 165 | const char* address, 166 | char** actual_address); 167 | 168 | /* 5: StopListening */ 169 | jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); 170 | 171 | /* 6: Accept */ 172 | jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, 173 | jlong accept_timeout, 174 | jlong handshake_timeout); 175 | 176 | /* 7: IsOpen */ 177 | jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); 178 | 179 | /* 8: Close */ 180 | jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); 181 | 182 | /* 9: ReadPacket */ 183 | jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, 184 | jdwpPacket *pkt); 185 | 186 | /* 10: Write Packet */ 187 | jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, 188 | const jdwpPacket* pkt); 189 | 190 | /* 11: GetLastError */ 191 | jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, 192 | char** error); 193 | 194 | }; 195 | 196 | 197 | /* 198 | * Use inlined functions so that C++ code can use syntax such as 199 | * env->Attach("mymachine:5000", 10*1000, 0); 200 | * 201 | * rather than using C's :- 202 | * 203 | * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); 204 | */ 205 | struct _jdwpTransportEnv { 206 | const struct jdwpTransportNativeInterface_ *functions; 207 | #ifdef __cplusplus 208 | 209 | jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { 210 | return functions->GetCapabilities(this, capabilities_ptr); 211 | } 212 | 213 | jdwpTransportError Attach(const char* address, jlong attach_timeout, 214 | jlong handshake_timeout) { 215 | return functions->Attach(this, address, attach_timeout, handshake_timeout); 216 | } 217 | 218 | jdwpTransportError StartListening(const char* address, 219 | char** actual_address) { 220 | return functions->StartListening(this, address, actual_address); 221 | } 222 | 223 | jdwpTransportError StopListening(void) { 224 | return functions->StopListening(this); 225 | } 226 | 227 | jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { 228 | return functions->Accept(this, accept_timeout, handshake_timeout); 229 | } 230 | 231 | jboolean IsOpen(void) { 232 | return functions->IsOpen(this); 233 | } 234 | 235 | jdwpTransportError Close(void) { 236 | return functions->Close(this); 237 | } 238 | 239 | jdwpTransportError ReadPacket(jdwpPacket *pkt) { 240 | return functions->ReadPacket(this, pkt); 241 | } 242 | 243 | jdwpTransportError WritePacket(const jdwpPacket* pkt) { 244 | return functions->WritePacket(this, pkt); 245 | } 246 | 247 | jdwpTransportError GetLastError(char** error) { 248 | return functions->GetLastError(this, error); 249 | } 250 | 251 | 252 | #endif /* __cplusplus */ 253 | }; 254 | 255 | #ifdef __cplusplus 256 | } /* extern "C" */ 257 | #endif /* __cplusplus */ 258 | 259 | #endif /* JDWPTRANSPORT_H */ 260 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_test_main.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_main.c 3 | Revised: Date: 2016-11-05 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides main entry for irda decoder 7 | 8 | Revision log: 9 | * 2016-11-05: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | 14 | #include "../include/ir_defs.h" 15 | #include "../include/ir_decode.h" 16 | 17 | // global variable definition 18 | t_remote_ac_status ac_status; 19 | UINT16 user_data[USER_DATA_SIZE]; 20 | 21 | 22 | INT8 ir_tv_file_open(const char *file_name); 23 | 24 | 25 | INT8 decode_as_ac(char *file_name) 26 | { 27 | // keyboard input 28 | int in_char = 0; 29 | BOOL op_match; 30 | UINT8 function_code = AC_FUNCTION_MAX; 31 | 32 | // get status 33 | UINT8 supported_mode = 0x00; 34 | INT8 min_temperature = 0; 35 | INT8 max_temperature = 0; 36 | UINT8 supported_speed = 0x00; 37 | UINT8 supported_swing = 0x00; 38 | UINT8 supported_wind_direction = 0x00; 39 | 40 | BOOL need_control; 41 | 42 | // init air conditioner status 43 | ac_status.ac_display = 0; 44 | ac_status.ac_sleep = 0; 45 | ac_status.ac_timer = 0; 46 | ac_status.ac_power = AC_POWER_OFF; 47 | ac_status.ac_mode = AC_MODE_COOL; 48 | ac_status.ac_temp = AC_TEMP_20; 49 | ac_status.ac_wind_dir = AC_SWING_ON; 50 | ac_status.ac_wind_speed = AC_WS_AUTO; 51 | 52 | if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_AC, 0, file_name)) 53 | { 54 | ir_close(); 55 | return IR_DECODE_FAILED; 56 | } 57 | 58 | do 59 | { 60 | in_char = getchar(); 61 | op_match = TRUE; 62 | need_control = TRUE; 63 | switch (in_char) 64 | { 65 | case 'w': 66 | case 'W': 67 | // temperature plus 68 | ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.ac_temp + 1)); 69 | function_code = AC_FUNCTION_TEMPERATURE_UP; 70 | break; 71 | case 's': 72 | case 'S': 73 | // temperature minus 74 | ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.ac_temp - 1)); 75 | function_code = AC_FUNCTION_TEMPERATURE_DOWN; 76 | break; 77 | case 'a': 78 | case 'A': 79 | // wind speed loop 80 | ++ac_status.ac_wind_speed; 81 | ac_status.ac_wind_speed = ac_status.ac_wind_speed % AC_WS_MAX; 82 | function_code = AC_FUNCTION_WIND_SPEED; 83 | break; 84 | case 'd': 85 | case 'D': 86 | // wind swing loop 87 | ac_status.ac_wind_dir = ((ac_status.ac_wind_dir == 0) ? AC_SWING_OFF : AC_SWING_ON); 88 | function_code = AC_FUNCTION_WIND_SWING; 89 | break; 90 | case 'q': 91 | case 'Q': 92 | ++ac_status.ac_mode; 93 | ac_status.ac_mode = ac_status.ac_mode % AC_MODE_MAX; 94 | function_code = AC_FUNCTION_MODE; 95 | break; 96 | case '1': 97 | // turn on 98 | ac_status.ac_power = AC_POWER_ON; 99 | function_code = AC_FUNCTION_POWER; 100 | break; 101 | case '2': 102 | // turn off 103 | ac_status.ac_power = AC_POWER_OFF; 104 | // FUNCTION MAX refers to power off 105 | // function_code = AC_FUNCTION_POWER; 106 | break; 107 | case '3': 108 | if (IR_DECODE_SUCCEEDED == get_supported_mode(&supported_mode)) 109 | { 110 | ir_printf("\nsupported mode = %02X\n", supported_mode); 111 | } 112 | need_control = FALSE; 113 | break; 114 | 115 | case '4': 116 | if (IR_DECODE_SUCCEEDED == get_supported_swing(ac_status.ac_mode, &supported_swing)) 117 | { 118 | ir_printf("\nsupported swing in %d = %02X\n", ac_status.ac_mode, supported_swing); 119 | } 120 | need_control = FALSE; 121 | break; 122 | case '5': 123 | if (IR_DECODE_SUCCEEDED == get_supported_wind_speed(ac_status.ac_mode, &supported_speed)) 124 | { 125 | ir_printf("\nsupported wind speed in %d = %02X\n", ac_status.ac_mode, supported_speed); 126 | } 127 | need_control = FALSE; 128 | break; 129 | 130 | case '6': 131 | if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.ac_mode, &min_temperature, &max_temperature)) 132 | { 133 | ir_printf("\nsupported temperature range in mode %d = %d, %d\n", 134 | ac_status.ac_mode, min_temperature, max_temperature); 135 | } 136 | need_control = FALSE; 137 | break; 138 | 139 | case '7': 140 | if (IR_DECODE_SUCCEEDED == get_supported_wind_direction(&supported_wind_direction)) 141 | { 142 | ir_printf("\nsupported wind direction = %02X\n", supported_wind_direction); 143 | } 144 | need_control = FALSE; 145 | break; 146 | 147 | default: 148 | op_match = FALSE; 149 | break; 150 | } 151 | 152 | if (TRUE == op_match && TRUE == need_control) 153 | { 154 | ir_printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d\n", 155 | ac_status.ac_power, 156 | ac_status.ac_mode, 157 | ac_status.ac_temp, 158 | ac_status.ac_wind_speed, 159 | ac_status.ac_wind_dir 160 | ); 161 | 162 | ir_decode(function_code, user_data, &ac_status, TRUE); 163 | } 164 | } while ('0' != in_char); 165 | 166 | ir_close(); 167 | 168 | return IR_DECODE_SUCCEEDED; 169 | } 170 | 171 | INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode) 172 | { 173 | // keyboard input 174 | int in_char = 0; 175 | int key_code = 0; 176 | 177 | if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_TV, ir_hex_encode, file_name)) 178 | { 179 | ir_close(); 180 | return IR_DECODE_FAILED; 181 | } 182 | 183 | do 184 | { 185 | in_char = getchar(); 186 | if (in_char >= '0' && in_char <= '9') 187 | { 188 | key_code = in_char - '0'; 189 | ir_decode((UINT8)key_code, user_data, NULL, 0); 190 | } 191 | else if (in_char >= 'a' && in_char <= 'f') 192 | { 193 | key_code = 10 + (in_char - 'a'); 194 | ir_decode((UINT8) key_code, user_data, NULL, 0); 195 | } 196 | else if (in_char == 'q') 197 | { 198 | ir_close(); 199 | } 200 | else 201 | { 202 | // do nothing 203 | } 204 | } while ('Q' != in_char); 205 | 206 | return IR_DECODE_SUCCEEDED; 207 | } 208 | 209 | int main(int argc, char *argv[]) 210 | { 211 | char function = '0'; 212 | UINT8 ir_hex_encode = 0; 213 | 214 | if (4 != argc) 215 | { 216 | ir_printf("number of args error !\n"); 217 | return -1; 218 | } 219 | 220 | function = argv[1][0]; 221 | ir_hex_encode = (UINT8) (argv[3][0] - '0'); 222 | ir_printf("decode functionality = %c\n", function); 223 | 224 | switch (function) 225 | { 226 | case '0': 227 | ir_printf("decode binary file as AC\n"); 228 | decode_as_ac(argv[2]); 229 | break; 230 | 231 | case '1': 232 | ir_printf("decode binary file as TV : %d\n", ir_hex_encode); 233 | decode_as_tv(argv[2], ir_hex_encode); 234 | break; 235 | 236 | default: 237 | ir_printf("decode functionality error !\n"); 238 | break; 239 | } 240 | } -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_ac_parse_frame_info.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_parse_frame_parameter.c 3 | Revised: Date: 2016-10-11 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode for AC frame parameters 7 | 8 | Revision log: 9 | * 2016-10-11: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../include/ir_utils.h" 17 | #include "../include/ir_ac_parse_frame_info.h" 18 | 19 | 20 | INT8 parse_boot_code(struct tag_head *tag) 21 | { 22 | UINT8 buf[16] = {0}; 23 | UINT8 *p = NULL; 24 | UINT16 pos = 0; 25 | UINT16 cnt = 0, index = 0; 26 | 27 | if (NULL == tag) 28 | { 29 | return IR_DECODE_FAILED; 30 | } 31 | p = tag->p_data; 32 | 33 | if (NULL == p) 34 | { 35 | return IR_DECODE_FAILED; 36 | } 37 | 38 | while (index <= tag->len) 39 | { 40 | while ((index != (tag->len)) && (*(p++) != ',')) 41 | { 42 | index++; 43 | } 44 | ir_memcpy(buf, tag->p_data + pos, index - pos); 45 | pos = (UINT16) (index + 1); 46 | index = pos; 47 | context->boot_code.data[cnt++] = (UINT16) (atoi((char *) buf)); 48 | ir_memset(buf, 0, 16); 49 | } 50 | context->boot_code.len = cnt; 51 | return IR_DECODE_SUCCEEDED; 52 | } 53 | 54 | INT8 parse_zero(struct tag_head *tag) 55 | { 56 | UINT8 low[16] = {0}; 57 | UINT8 high[16] = {0}; 58 | UINT16 index = 0; 59 | UINT8 *p = NULL; 60 | 61 | if (NULL == tag) 62 | { 63 | return IR_DECODE_FAILED; 64 | } 65 | p = tag->p_data; 66 | 67 | if (NULL == p) 68 | { 69 | return IR_DECODE_FAILED; 70 | } 71 | 72 | while (*(p++) != ',') 73 | { 74 | index++; 75 | } 76 | 77 | ir_memcpy(low, tag->p_data, index); 78 | ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); 79 | 80 | context->zero.low = (UINT16) (atoi((char *) low)); 81 | context->zero.high = (UINT16) (atoi((char *) high)); 82 | return IR_DECODE_SUCCEEDED; 83 | } 84 | 85 | INT8 parse_one(struct tag_head *tag) 86 | { 87 | UINT8 low[16] = {0}; 88 | UINT8 high[16] = {0}; 89 | UINT16 index = 0; 90 | UINT8 *p = NULL; 91 | 92 | if (NULL == tag) 93 | { 94 | return IR_DECODE_FAILED; 95 | } 96 | p = tag->p_data; 97 | 98 | if (NULL == p) 99 | { 100 | return IR_DECODE_FAILED; 101 | } 102 | 103 | while (*(p++) != ',') 104 | { 105 | index++; 106 | } 107 | ir_memcpy(low, tag->p_data, index); 108 | ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); 109 | 110 | context->one.low = (UINT16) (atoi((char *) low)); 111 | context->one.high = (UINT16) (atoi((char *) high)); 112 | 113 | return IR_DECODE_SUCCEEDED; 114 | } 115 | 116 | INT8 parse_delay_code_data(UINT8 *pdata) 117 | { 118 | UINT8 buf[16] = {0}; 119 | UINT8 *p = NULL; 120 | UINT16 pos = 0; 121 | UINT16 cnt = 0, index = 0; 122 | 123 | if (NULL == pdata) 124 | { 125 | return IR_DECODE_FAILED; 126 | } 127 | p = pdata; 128 | 129 | while (index <= ir_strlen((char *) pdata)) 130 | { 131 | while ((index != ir_strlen((char *) pdata)) && (*(p++) != ',')) 132 | { 133 | index++; 134 | } 135 | ir_memcpy(buf, pdata + pos, index - pos); 136 | pos = (UINT16) (index + 1); 137 | index = pos; 138 | context->dc[context->dc_cnt].time[cnt++] = (UINT16) (atoi((char *) buf)); 139 | context->dc[context->dc_cnt].time_cnt = cnt; 140 | ir_memset(buf, 0, 16); 141 | } 142 | 143 | return IR_DECODE_SUCCEEDED; 144 | } 145 | 146 | INT8 parse_delay_code_pos(UINT8 *buf) 147 | { 148 | UINT16 i = 0; 149 | UINT8 data[64] = {0}, start[8] = {0}; 150 | 151 | if (NULL == buf) 152 | { 153 | return IR_DECODE_FAILED; 154 | } 155 | 156 | for (i = 0; i < ir_strlen((char *) buf); i++) 157 | { 158 | if (buf[i] == '&') 159 | { 160 | ir_memcpy(start, buf, i); 161 | ir_memcpy(data, buf + i + 1, ir_strlen((char *) buf) - i - 1); 162 | break; 163 | } 164 | } 165 | parse_delay_code_data(data); 166 | context->dc[context->dc_cnt].pos = (UINT16) (atoi((char *) start)); 167 | 168 | context->dc_cnt++; 169 | return IR_DECODE_SUCCEEDED; 170 | } 171 | 172 | INT8 parse_delay_code(struct tag_head *tag) 173 | { 174 | UINT8 buf[64] = {0}; 175 | UINT16 i = 0; 176 | UINT16 preindex = 0; 177 | preindex = 0; 178 | 179 | if (NULL == tag) 180 | { 181 | return IR_DECODE_FAILED; 182 | } 183 | 184 | for (i = 0; i < tag->len; i++) 185 | { 186 | if (tag->p_data[i] == '|') 187 | { 188 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 189 | preindex = (UINT16) (i + 1); 190 | parse_delay_code_pos(buf); 191 | ir_memset(buf, 0, 64); 192 | } 193 | 194 | } 195 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 196 | parse_delay_code_pos(buf); 197 | ir_memset(buf, 0, 64); 198 | 199 | return IR_DECODE_SUCCEEDED; 200 | } 201 | 202 | INT8 parse_frame_len(struct tag_head *tag, UINT16 len) 203 | { 204 | UINT8 *temp = NULL; 205 | 206 | if (NULL == tag) 207 | { 208 | return IR_DECODE_FAILED; 209 | } 210 | 211 | temp = (UINT8 *) ir_malloc(len + 1); 212 | 213 | if (NULL == temp) 214 | { 215 | return IR_DECODE_FAILED; 216 | } 217 | 218 | ir_memset(temp, 0x00, len + 1); 219 | 220 | ir_memcpy(temp, tag->p_data, len); 221 | temp[len] = '\0'; 222 | 223 | context->frame_length = (UINT16) (atoi((char *) temp)); 224 | 225 | ir_free(temp); 226 | return IR_DECODE_SUCCEEDED; 227 | } 228 | 229 | INT8 parse_endian(struct tag_head *tag) 230 | { 231 | UINT8 buf[8] = {0}; 232 | 233 | if (NULL == tag) 234 | { 235 | return IR_DECODE_FAILED; 236 | } 237 | ir_memcpy(buf, tag->p_data, tag->len); 238 | context->endian = (UINT8) (atoi((char *) buf)); 239 | return IR_DECODE_SUCCEEDED; 240 | } 241 | 242 | INT8 parse_lastbit(struct tag_head *tag) 243 | { 244 | UINT8 buf[8] = {0}; 245 | 246 | if (NULL == tag) 247 | { 248 | return IR_DECODE_FAILED; 249 | } 250 | ir_memcpy(buf, tag->p_data, tag->len); 251 | context->last_bit = (UINT8) (atoi((char *) buf)); 252 | return IR_DECODE_SUCCEEDED; 253 | } 254 | 255 | INT8 parse_repeat_times(struct tag_head *tag) 256 | { 257 | char asc_code[8] = {0}; 258 | if (NULL == tag) 259 | { 260 | return IR_DECODE_FAILED; 261 | } 262 | 263 | ir_memcpy(asc_code, tag->p_data, tag->len); 264 | 265 | context->repeat_times = (UINT16) (atoi((char *) asc_code)); 266 | 267 | return IR_DECODE_SUCCEEDED; 268 | } 269 | 270 | INT8 parse_delay_code_tag48_pos(UINT8 *buf) 271 | { 272 | UINT16 i = 0; 273 | UINT8 data[64] = {0}, start[8] = {0}; 274 | 275 | if (NULL == buf) 276 | { 277 | return IR_DECODE_FAILED; 278 | } 279 | 280 | for (i = 0; i < ir_strlen((char *) buf); i++) 281 | { 282 | if (buf[i] == '&') 283 | { 284 | ir_memcpy(start, buf, i); 285 | ir_memcpy(data, buf + i + 1, ir_strlen((char *) buf) - i - 1); 286 | break; 287 | } 288 | } 289 | 290 | context->bit_num[context->bit_num_cnt].pos = (UINT16) (atoi((char *) start)); 291 | context->bit_num[context->bit_num_cnt].bits = (UINT16) (atoi((char *) data)); 292 | context->bit_num_cnt++; 293 | return IR_DECODE_SUCCEEDED; 294 | } 295 | 296 | INT8 parse_bit_num(struct tag_head *tag) 297 | { 298 | UINT16 i = 0; 299 | UINT16 preindex = 0; 300 | UINT8 buf[64] = {0}; 301 | 302 | if (NULL == tag) 303 | { 304 | return IR_DECODE_FAILED; 305 | } 306 | 307 | preindex = 0; 308 | for (i = 0; i < tag->len; i++) 309 | { 310 | if (tag->p_data[i] == '|') 311 | { 312 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 313 | preindex = (UINT16) (i + 1); 314 | parse_delay_code_tag48_pos(buf); 315 | ir_memset(buf, 0, 64); 316 | } 317 | 318 | } 319 | ir_memcpy(buf, tag->p_data + preindex, i - preindex); 320 | parse_delay_code_tag48_pos(buf); 321 | ir_memset(buf, 0, 64); 322 | 323 | for (i = 0; i < context->bit_num_cnt; i++) 324 | { 325 | if (context->bit_num[i].pos == -1) 326 | context->bit_num[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos 327 | } 328 | return IR_DECODE_SUCCEEDED; 329 | } 330 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/jawt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | #ifndef _JAVASOFT_JAWT_H_ 27 | #define _JAVASOFT_JAWT_H_ 28 | 29 | #include "jni.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | * AWT native interface (new in JDK 1.3) 37 | * 38 | * The AWT native interface allows a native C or C++ application a means 39 | * by which to access native structures in AWT. This is to facilitate moving 40 | * legacy C and C++ applications to Java and to target the needs of the 41 | * community who, at present, wish to do their own native rendering to canvases 42 | * for performance reasons. Standard extensions such as Java3D also require a 43 | * means to access the underlying native data structures of AWT. 44 | * 45 | * There may be future extensions to this API depending on demand. 46 | * 47 | * A VM does not have to implement this API in order to pass the JCK. 48 | * It is recommended, however, that this API is implemented on VMs that support 49 | * standard extensions, such as Java3D. 50 | * 51 | * Since this is a native API, any program which uses it cannot be considered 52 | * 100% pure java. 53 | */ 54 | 55 | /* 56 | * AWT Native Drawing Surface (JAWT_DrawingSurface). 57 | * 58 | * For each platform, there is a native drawing surface structure. This 59 | * platform-specific structure can be found in jawt_md.h. It is recommended 60 | * that additional platforms follow the same model. It is also recommended 61 | * that VMs on Win32 and Solaris support the existing structures in jawt_md.h. 62 | * 63 | ******************* 64 | * EXAMPLE OF USAGE: 65 | ******************* 66 | * 67 | * In Win32, a programmer wishes to access the HWND of a canvas to perform 68 | * native rendering into it. The programmer has declared the paint() method 69 | * for their canvas subclass to be native: 70 | * 71 | * 72 | * MyCanvas.java: 73 | * 74 | * import java.awt.*; 75 | * 76 | * public class MyCanvas extends Canvas { 77 | * 78 | * static { 79 | * System.loadLibrary("mylib"); 80 | * } 81 | * 82 | * public native void paint(Graphics g); 83 | * } 84 | * 85 | * 86 | * myfile.c: 87 | * 88 | * #include "jawt_md.h" 89 | * #include 90 | * 91 | * JNIEXPORT void JNICALL 92 | * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) 93 | * { 94 | * JAWT awt; 95 | * JAWT_DrawingSurface* ds; 96 | * JAWT_DrawingSurfaceInfo* dsi; 97 | * JAWT_Win32DrawingSurfaceInfo* dsi_win; 98 | * jboolean result; 99 | * jint lock; 100 | * 101 | * // Get the AWT 102 | * awt.version = JAWT_VERSION_1_3; 103 | * result = JAWT_GetAWT(env, &awt); 104 | * assert(result != JNI_FALSE); 105 | * 106 | * // Get the drawing surface 107 | * ds = awt.GetDrawingSurface(env, canvas); 108 | * assert(ds != NULL); 109 | * 110 | * // Lock the drawing surface 111 | * lock = ds->Lock(ds); 112 | * assert((lock & JAWT_LOCK_ERROR) == 0); 113 | * 114 | * // Get the drawing surface info 115 | * dsi = ds->GetDrawingSurfaceInfo(ds); 116 | * 117 | * // Get the platform-specific drawing info 118 | * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; 119 | * 120 | * ////////////////////////////// 121 | * // !!! DO PAINTING HERE !!! // 122 | * ////////////////////////////// 123 | * 124 | * // Free the drawing surface info 125 | * ds->FreeDrawingSurfaceInfo(dsi); 126 | * 127 | * // Unlock the drawing surface 128 | * ds->Unlock(ds); 129 | * 130 | * // Free the drawing surface 131 | * awt.FreeDrawingSurface(ds); 132 | * } 133 | * 134 | */ 135 | 136 | /* 137 | * JAWT_Rectangle 138 | * Structure for a native rectangle. 139 | */ 140 | typedef struct jawt_Rectangle { 141 | jint x; 142 | jint y; 143 | jint width; 144 | jint height; 145 | } JAWT_Rectangle; 146 | 147 | struct jawt_DrawingSurface; 148 | 149 | /* 150 | * JAWT_DrawingSurfaceInfo 151 | * Structure for containing the underlying drawing information of a component. 152 | */ 153 | typedef struct jawt_DrawingSurfaceInfo { 154 | /* 155 | * Pointer to the platform-specific information. This can be safely 156 | * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a 157 | * JAWT_X11DrawingSurfaceInfo on Solaris. On Mac OS X this is a 158 | * pointer to a NSObject that conforms to the JAWT_SurfaceLayers 159 | * protocol. See jawt_md.h for details. 160 | */ 161 | void* platformInfo; 162 | /* Cached pointer to the underlying drawing surface */ 163 | struct jawt_DrawingSurface* ds; 164 | /* Bounding rectangle of the drawing surface */ 165 | JAWT_Rectangle bounds; 166 | /* Number of rectangles in the clip */ 167 | jint clipSize; 168 | /* Clip rectangle array */ 169 | JAWT_Rectangle* clip; 170 | } JAWT_DrawingSurfaceInfo; 171 | 172 | #define JAWT_LOCK_ERROR 0x00000001 173 | #define JAWT_LOCK_CLIP_CHANGED 0x00000002 174 | #define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 175 | #define JAWT_LOCK_SURFACE_CHANGED 0x00000008 176 | 177 | /* 178 | * JAWT_DrawingSurface 179 | * Structure for containing the underlying drawing information of a component. 180 | * All operations on a JAWT_DrawingSurface MUST be performed from the same 181 | * thread as the call to GetDrawingSurface. 182 | */ 183 | typedef struct jawt_DrawingSurface { 184 | /* 185 | * Cached reference to the Java environment of the calling thread. 186 | * If Lock(), Unlock(), GetDrawingSurfaceInfo() or 187 | * FreeDrawingSurfaceInfo() are called from a different thread, 188 | * this data member should be set before calling those functions. 189 | */ 190 | JNIEnv* env; 191 | /* Cached reference to the target object */ 192 | jobject target; 193 | /* 194 | * Lock the surface of the target component for native rendering. 195 | * When finished drawing, the surface must be unlocked with 196 | * Unlock(). This function returns a bitmask with one or more of the 197 | * following values: 198 | * 199 | * JAWT_LOCK_ERROR - When an error has occurred and the surface could not 200 | * be locked. 201 | * 202 | * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. 203 | * 204 | * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. 205 | * 206 | * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed 207 | */ 208 | jint (JNICALL *Lock) 209 | (struct jawt_DrawingSurface* ds); 210 | /* 211 | * Get the drawing surface info. 212 | * The value returned may be cached, but the values may change if 213 | * additional calls to Lock() or Unlock() are made. 214 | * Lock() must be called before this can return a valid value. 215 | * Returns NULL if an error has occurred. 216 | * When finished with the returned value, FreeDrawingSurfaceInfo must be 217 | * called. 218 | */ 219 | JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) 220 | (struct jawt_DrawingSurface* ds); 221 | /* 222 | * Free the drawing surface info. 223 | */ 224 | void (JNICALL *FreeDrawingSurfaceInfo) 225 | (JAWT_DrawingSurfaceInfo* dsi); 226 | /* 227 | * Unlock the drawing surface of the target component for native rendering. 228 | */ 229 | void (JNICALL *Unlock) 230 | (struct jawt_DrawingSurface* ds); 231 | } JAWT_DrawingSurface; 232 | 233 | /* 234 | * JAWT 235 | * Structure for containing native AWT functions. 236 | */ 237 | typedef struct jawt { 238 | /* 239 | * Version of this structure. This must always be set before 240 | * calling JAWT_GetAWT() 241 | */ 242 | jint version; 243 | /* 244 | * Return a drawing surface from a target jobject. This value 245 | * may be cached. 246 | * Returns NULL if an error has occurred. 247 | * Target must be a java.awt.Component (should be a Canvas 248 | * or Window for native rendering). 249 | * FreeDrawingSurface() must be called when finished with the 250 | * returned JAWT_DrawingSurface. 251 | */ 252 | JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) 253 | (JNIEnv* env, jobject target); 254 | /* 255 | * Free the drawing surface allocated in GetDrawingSurface. 256 | */ 257 | void (JNICALL *FreeDrawingSurface) 258 | (JAWT_DrawingSurface* ds); 259 | /* 260 | * Since 1.4 261 | * Locks the entire AWT for synchronization purposes 262 | */ 263 | void (JNICALL *Lock)(JNIEnv* env); 264 | /* 265 | * Since 1.4 266 | * Unlocks the entire AWT for synchronization purposes 267 | */ 268 | void (JNICALL *Unlock)(JNIEnv* env); 269 | /* 270 | * Since 1.4 271 | * Returns a reference to a java.awt.Component from a native 272 | * platform handle. On Windows, this corresponds to an HWND; 273 | * on Solaris and Linux, this is a Drawable. For other platforms, 274 | * see the appropriate machine-dependent header file for a description. 275 | * The reference returned by this function is a local 276 | * reference that is only valid in this environment. 277 | * This function returns a NULL reference if no component could be 278 | * found with matching platform information. 279 | */ 280 | jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); 281 | 282 | } JAWT; 283 | 284 | /* 285 | * Get the AWT native structure. This function returns JNI_FALSE if 286 | * an error occurs. 287 | */ 288 | _JNI_IMPORT_OR_EXPORT_ 289 | jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); 290 | 291 | #define JAWT_VERSION_1_3 0x00010003 292 | #define JAWT_VERSION_1_4 0x00010004 293 | #define JAWT_VERSION_1_7 0x00010007 294 | 295 | #ifdef __cplusplus 296 | } /* extern "C" */ 297 | #endif 298 | 299 | #endif /* !_JAVASOFT_JAWT_H_ */ 300 | -------------------------------------------------------------------------------- /src/ir_decoder/include/ir_ac_control.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_ac_control.h 3 | Revised: Date: 2016-12-31 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides methods for AC IR control 7 | 8 | Revision log: 9 | * 2016-10-12: created by strawmanbobi 10 | **************************************************************************************/ 11 | #ifndef IRDA_DECODER_IR_AC_CONTROL_H 12 | #define IRDA_DECODER_IR_AC_CONTROL_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | #include "ir_defs.h" 20 | 21 | 22 | #define TAG_COUNT_FOR_PROTOCOL 29 23 | 24 | #define TAG_INVALID 0xffff 25 | 26 | #define MAX_DELAYCODE_NUM 16 27 | #define MAX_BITNUM 16 28 | 29 | #define AC_PARAMETER_TYPE_1 0 30 | #define AC_PARAMETER_TYPE_2 1 31 | 32 | typedef enum 33 | { 34 | AC_POWER_ON = 0, 35 | AC_POWER_OFF, 36 | AC_POWER_MAX 37 | } t_ac_power; 38 | 39 | typedef enum 40 | { 41 | AC_TEMP_16 = 0, 42 | AC_TEMP_17, 43 | AC_TEMP_18, 44 | AC_TEMP_19, 45 | AC_TEMP_20, 46 | AC_TEMP_21, 47 | AC_TEMP_22, 48 | AC_TEMP_23, 49 | AC_TEMP_24, 50 | AC_TEMP_25, 51 | AC_TEMP_26, 52 | AC_TEMP_27, 53 | AC_TEMP_28, 54 | AC_TEMP_29, 55 | AC_TEMP_30, 56 | AC_TEMP_MAX 57 | } t_ac_temperature; 58 | 59 | typedef enum 60 | { 61 | AC_MODE_COOL = 0, 62 | AC_MODE_HEAT, 63 | AC_MODE_AUTO, 64 | AC_MODE_FAN, 65 | AC_MODE_DRY, 66 | AC_MODE_MAX 67 | } t_ac_mode; 68 | 69 | typedef enum 70 | { 71 | AC_FUNCTION_POWER = 1, 72 | AC_FUNCTION_MODE, 73 | AC_FUNCTION_TEMPERATURE_UP, 74 | AC_FUNCTION_TEMPERATURE_DOWN, 75 | AC_FUNCTION_WIND_SPEED, 76 | AC_FUNCTION_WIND_SWING, 77 | AC_FUNCTION_WIND_FIX, 78 | AC_FUNCTION_MAX, 79 | } t_ac_function; 80 | 81 | typedef enum 82 | { 83 | AC_WS_AUTO = 0, 84 | AC_WS_LOW, 85 | AC_WS_MEDIUM, 86 | AC_WS_HIGH, 87 | AC_WS_MAX 88 | } t_ac_wind_speed; 89 | 90 | typedef enum 91 | { 92 | AC_SWING_ON = 0, 93 | AC_SWING_OFF, 94 | AC_SWING_MAX 95 | } t_ac_swing; 96 | 97 | typedef enum 98 | { 99 | SWING_TYPE_SWING_ONLY = 0, 100 | SWING_TYPE_NORMAL, 101 | SWING_TYPE_NOT_SPECIFIED, 102 | SWING_TYPE_MAX 103 | } swing_type; 104 | 105 | typedef enum 106 | { 107 | TEMP_TYPE_DYNAMIC = 0, 108 | TEMP_TYPE_STATIC, 109 | TEMP_TYPE_MAX, 110 | } t_temp_type; 111 | 112 | // enumeration for application polymorphism 113 | typedef enum 114 | { 115 | AC_APPLY_POWER = 0, 116 | AC_APPLY_MODE, 117 | AC_APPLY_TEMPERATURE_UP, 118 | AC_APPLY_TEMPERATURE_DOWN, 119 | AC_APPLY_WIND_SPEED, 120 | AC_APPLY_WIND_SWING, 121 | AC_APPLY_WIND_FIX, 122 | AC_APPLY_MAX 123 | } t_ac_apply; 124 | 125 | typedef struct _ac_hex 126 | { 127 | UINT8 len; 128 | UINT8 *data; 129 | } t_ac_hex; 130 | 131 | typedef struct _ac_level 132 | { 133 | UINT16 low; 134 | UINT16 high; 135 | } t_ac_level; 136 | 137 | typedef struct _ac_bootcode 138 | { 139 | UINT16 len; 140 | UINT16 data[16]; 141 | } t_ac_bootcode; 142 | 143 | typedef struct _ac_delaycode 144 | { 145 | INT16 pos; 146 | UINT16 time[8]; 147 | UINT16 time_cnt; 148 | } t_ac_delaycode; 149 | 150 | /* 151 | * the array of tag_100X application data 152 | * seg_len : length for each segment 153 | * byte_pos : the position of update byte 154 | * byte_value : the value to be updated to position 155 | */ 156 | typedef struct _tag_comp_type_1 157 | { 158 | UINT8 seg_len; 159 | UINT8 *segment; 160 | } t_tag_comp; 161 | 162 | typedef struct _tag_swing_info 163 | { 164 | swing_type type; 165 | UINT8 mode_count; 166 | UINT8 dir_index; 167 | } t_swing_info; 168 | 169 | typedef struct _tag_power_1 170 | { 171 | UINT8 len; 172 | t_tag_comp comp_data[AC_POWER_MAX]; 173 | } t_power_1; 174 | 175 | typedef struct _tag_temp_1 176 | { 177 | UINT8 len; 178 | UINT8 type; 179 | t_tag_comp comp_data[AC_TEMP_MAX]; 180 | } t_temp_1; 181 | 182 | typedef struct tag_mode_1 183 | { 184 | UINT8 len; 185 | t_tag_comp comp_data[AC_MODE_MAX]; 186 | } t_mode_1; 187 | 188 | typedef struct tag_speed_1 189 | { 190 | UINT8 len; 191 | t_tag_comp comp_data[AC_WS_MAX]; 192 | } t_speed_1; 193 | 194 | typedef struct tag_swing_1 195 | { 196 | UINT8 len; 197 | UINT16 count; 198 | t_tag_comp *comp_data; 199 | } t_swing_1; 200 | 201 | typedef struct tag_temp_2 202 | { 203 | UINT8 len; 204 | UINT8 type; 205 | t_tag_comp comp_data[AC_TEMP_MAX]; 206 | } t_temp_2; 207 | 208 | typedef struct tag_mode_2 209 | { 210 | UINT8 len; 211 | t_tag_comp comp_data[AC_MODE_MAX]; 212 | } t_mode_2; 213 | 214 | typedef struct tag_speed_2 215 | { 216 | UINT8 len; 217 | t_tag_comp comp_data[AC_WS_MAX]; 218 | } t_speed_2; 219 | 220 | typedef struct tag_swing_2 221 | { 222 | UINT8 len; 223 | UINT16 count; 224 | t_tag_comp *comp_data; 225 | } t_swing_2; 226 | 227 | #if defined SUPPORT_HORIZONTAL_SWING 228 | typedef struct tag_horiswing_1 229 | { 230 | UINT16 len; 231 | t_tag_comp comp_data[AC_HORI_SWING_MAX]; 232 | } hori_swing_1; 233 | #endif 234 | 235 | typedef struct _tag_checksum_data 236 | { 237 | UINT8 len; 238 | UINT8 type; 239 | UINT8 start_byte_pos; 240 | UINT8 end_byte_pos; 241 | UINT8 checksum_byte_pos; 242 | UINT8 checksum_plus; 243 | UINT8 *spec_pos; 244 | } t_tag_checksum_data; 245 | 246 | typedef struct tag_checksum 247 | { 248 | UINT8 len; 249 | UINT16 count; 250 | t_tag_checksum_data *checksum_data; 251 | } t_checksum; 252 | 253 | typedef struct tag_function_1 254 | { 255 | UINT8 len; 256 | t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; 257 | } t_function_1; 258 | 259 | typedef struct tag_function_2 260 | { 261 | UINT8 len; 262 | t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; 263 | } t_function_2; 264 | 265 | typedef struct tag_solo_code 266 | { 267 | UINT8 len; 268 | UINT8 solo_func_count; 269 | UINT8 solo_function_codes[AC_FUNCTION_MAX - 1]; 270 | } t_solo_code; 271 | 272 | typedef struct _ac_bitnum 273 | { 274 | INT16 pos; 275 | UINT16 bits; 276 | } t_ac_bit_num; 277 | 278 | typedef enum 279 | { 280 | N_COOL = 0, 281 | N_HEAT, 282 | N_AUTO, 283 | N_FAN, 284 | N_DRY, 285 | N_MODE_MAX, 286 | } t_ac_n_mode; 287 | 288 | typedef enum 289 | { 290 | CHECKSUM_TYPE_BYTE = 1, 291 | CHECKSUM_TYPE_BYTE_INVERSE, 292 | CHECKSUM_TYPE_HALF_BYTE, 293 | CHECKSUM_TYPE_HALF_BYTE_INVERSE, 294 | CHECKSUM_TYPE_SPEC_HALF_BYTE, 295 | CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE, 296 | CHECKSUM_TYPE_SPEC_HALF_BYTE_ONE_BYTE, 297 | CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE_ONE_BYTE, 298 | CHECKSUM_TYPE_MAX, 299 | } t_checksum_type; 300 | 301 | typedef struct _ac_n_mode_info 302 | { 303 | UINT8 enable; 304 | UINT8 all_speed; 305 | UINT8 all_temp; 306 | UINT8 temp[AC_TEMP_MAX]; 307 | UINT8 temp_cnt; 308 | UINT8 speed[AC_WS_MAX]; 309 | UINT8 speed_cnt; 310 | } t_ac_n_mode_info; 311 | 312 | typedef struct ac_protocol 313 | { 314 | UINT8 endian; 315 | // t_ac_hex default_code; 316 | t_ac_hex default_code; 317 | t_ac_level zero; 318 | t_ac_level one; 319 | t_ac_bootcode boot_code; 320 | t_ac_delaycode dc[MAX_DELAYCODE_NUM]; 321 | t_power_1 power1; 322 | t_temp_1 temp1; 323 | t_mode_1 mode1; 324 | t_speed_1 speed1; 325 | t_swing_1 swing1; 326 | t_checksum checksum; 327 | 328 | t_function_1 function1; 329 | t_function_2 function2; 330 | 331 | t_temp_2 temp2; 332 | t_mode_2 mode2; 333 | t_speed_2 speed2; 334 | t_swing_2 swing2; 335 | 336 | t_swing_info si; 337 | t_solo_code sc; 338 | 339 | UINT8 swing_status; 340 | 341 | BOOL change_wind_direction; 342 | 343 | UINT16 dc_cnt; 344 | t_ac_bit_num bit_num[MAX_BITNUM]; 345 | UINT16 bit_num_cnt; 346 | UINT16 repeat_times; 347 | t_ac_n_mode_info n_mode[N_MODE_MAX]; 348 | UINT16 code_cnt; 349 | UINT8 last_bit; 350 | UINT16 *time; 351 | UINT8 solo_function_mark; 352 | 353 | UINT16 frame_length; 354 | } t_ac_protocol; 355 | 356 | typedef struct tag_head 357 | { 358 | UINT16 tag; 359 | UINT16 len; 360 | unsigned short offset; 361 | UINT8 *p_data; 362 | } t_tag_head; 363 | 364 | struct ir_bin_buffer 365 | { 366 | UINT8 *data; 367 | UINT16 len; 368 | UINT16 offset; 369 | }; 370 | 371 | typedef struct REMOTE_AC_STATUS 372 | { 373 | t_ac_power ac_power; 374 | t_ac_temperature ac_temp; 375 | t_ac_mode ac_mode; 376 | t_ac_swing ac_wind_dir; 377 | t_ac_wind_speed ac_wind_speed; 378 | UINT8 ac_display; 379 | UINT8 ac_sleep; 380 | UINT8 ac_timer; 381 | } t_remote_ac_status; 382 | 383 | // function polymorphism 384 | typedef INT8 (*lp_apply_ac_parameter)(t_remote_ac_status ac_status, UINT8 function_code); 385 | 386 | #define TAG_AC_BOOT_CODE 1 387 | #define TAG_AC_ZERO 2 388 | #define TAG_AC_ONE 3 389 | #define TAG_AC_DELAY_CODE 4 390 | #define TAG_AC_FRAME_LENGTH 5 391 | #define TAG_AC_ENDIAN 6 392 | #define TAG_AC_LAST_BIT 7 393 | 394 | #define TAG_AC_POWER_1 21 395 | #define TAG_AC_DEFAULT_CODE 22 396 | #define TAG_AC_TEMP_1 23 397 | #define TAG_AC_MODE_1 24 398 | #define TAG_AC_SPEED_1 25 399 | #define TAG_AC_SWING_1 26 400 | #define TAG_AC_CHECKSUM_TYPE 27 401 | #define TAG_AC_SOLO_FUNCTION 28 402 | #define TAG_AC_FUNCTION_1 29 403 | #define TAG_AC_TEMP_2 30 404 | #define TAG_AC_MODE_2 31 405 | #define TAG_AC_SPEED_2 32 406 | #define TAG_AC_SWING_2 33 407 | #define TAG_AC_FUNCTION_2 34 408 | 409 | #define TAG_AC_BAN_FUNCTION_IN_COOL_MODE 41 410 | #define TAG_AC_BAN_FUNCTION_IN_HEAT_MODE 42 411 | #define TAG_AC_BAN_FUNCTION_IN_AUTO_MODE 43 412 | #define TAG_AC_BAN_FUNCTION_IN_FAN_MODE 44 413 | #define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 45 414 | #define TAG_AC_SWING_INFO 46 415 | #define TAG_AC_REPEAT_TIMES 47 416 | #define TAG_AC_BIT_NUM 48 417 | 418 | 419 | // definition about size 420 | 421 | #define PROTOCOL_SIZE (sizeof(t_ac_protocol)) 422 | 423 | /* exported variables */ 424 | extern UINT8 *ir_hex_code; 425 | extern UINT8 ir_hex_len; 426 | extern t_ac_protocol *context; 427 | 428 | 429 | extern INT8 ir_ac_lib_parse(); 430 | 431 | extern INT8 free_ac_context(); 432 | 433 | extern BOOL is_solo_function(UINT8 function_code); 434 | 435 | #ifdef __cplusplus 436 | } 437 | #endif 438 | 439 | #endif //IRDA_DECODER_IR_AC_CONTROL_H 440 | -------------------------------------------------------------------------------- /src/ir_decoder/ir_decoder.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {8ACC347D-023C-4939-B371-C193EEA210F8} 23 | Win32Proj 24 | ir_decoder 25 | 10.0.15063.0 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | v140_xp 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v141 38 | true 39 | Unicode 40 | 41 | 42 | DynamicLibrary 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | DynamicLibrary 49 | false 50 | v140_xp 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | NotUsing 87 | Level3 88 | Disabled 89 | WIN32;_DEBUG;_WINDOWS;_USRDLL;IR_DECODER_EXPORTS;BOARD_PC;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Windows 94 | true 95 | .\ir_decode.def 96 | 97 | 98 | 99 | 100 | Use 101 | Level3 102 | Disabled 103 | _DEBUG;_WINDOWS;_USRDLL;IR_DECODER_EXPORTS;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Windows 108 | true 109 | 110 | 111 | 112 | 113 | Level3 114 | NotUsing 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;IR_DECODER_EXPORTS;%(PreprocessorDefinitions) 119 | true 120 | 121 | 122 | Windows 123 | true 124 | true 125 | true 126 | .\ir_decode.def 127 | 128 | 129 | 130 | 131 | Level3 132 | NotUsing 133 | MaxSpeed 134 | true 135 | true 136 | NDEBUG;_WINDOWS;_USRDLL;IR_DECODER_EXPORTS;%(PreprocessorDefinitions) 137 | true 138 | 139 | 140 | Windows 141 | true 142 | true 143 | true 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | false 167 | 168 | 169 | false 170 | 171 | 172 | false 173 | 174 | 175 | false 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | Create 192 | Create 193 | Create 194 | Create 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_tv_control.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_lib.c 3 | Revised: Date: 2016-10-21 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode (compressed command type) 7 | 8 | Revision log: 9 | * 2016-10-21: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | 14 | #include "../include/ir_defs.h" 15 | #include "../include/ir_decode.h" 16 | 17 | struct buffer 18 | { 19 | UINT8 *data; 20 | UINT16 len; 21 | UINT16 offset; 22 | } ir_file; 23 | 24 | 25 | static struct buffer *pbuffer = &ir_file; 26 | 27 | static UINT8 *prot_cycles_num = NULL; 28 | static t_ir_cycles *prot_cycles_data[IRDA_MAX]; 29 | static UINT8 prot_items_cnt = 0; 30 | static t_ir_data *prot_items_data = NULL; 31 | static t_ir_data_tv *remote_p; 32 | static UINT8 *remote_pdata = NULL; 33 | 34 | static UINT16 time_index = 0; 35 | static UINT8 ir_level = IRDA_LEVEL_LOW; 36 | static UINT8 ir_toggle_bit = FALSE; 37 | static UINT8 ir_decode_flag = IRDA_DECODE_1_BIT; 38 | static UINT8 cycles_num_size = 0; 39 | 40 | 41 | static BOOL get_ir_protocol(UINT8 encode_type); 42 | 43 | static BOOL get_ir_keymap(void); 44 | 45 | static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time); 46 | 47 | static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time); 48 | 49 | static void convert_to_ir_time(UINT8 value, UINT16 *ir_time); 50 | 51 | static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time); 52 | 53 | 54 | INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length) 55 | { 56 | // load binary to buffer 57 | pbuffer->data = binary; 58 | pbuffer->len = binary_length; 59 | pbuffer->offset = 0; 60 | return IR_DECODE_SUCCEEDED; 61 | } 62 | 63 | BOOL tv_lib_parse(UINT8 encode_type) 64 | { 65 | if (FALSE == get_ir_protocol(encode_type)) 66 | { 67 | return FALSE; 68 | } 69 | 70 | return get_ir_keymap(); 71 | } 72 | 73 | UINT16 tv_lib_control(UINT8 key, UINT16 *user_data) 74 | { 75 | UINT16 i = 0; 76 | 77 | time_index = 0; 78 | ir_level = IRDA_LEVEL_LOW; 79 | 80 | for (i = 0; i < prot_items_cnt; i++) 81 | { 82 | print_ir_time(&prot_items_data[i], key, user_data); 83 | } 84 | 85 | // next flip 86 | if (2 == prot_cycles_num[IRDA_FLIP]) 87 | { 88 | ir_toggle_bit = (ir_toggle_bit == FALSE) ? TRUE : FALSE; 89 | } 90 | 91 | return time_index; 92 | } 93 | 94 | 95 | static BOOL get_ir_protocol(UINT8 encode_type) 96 | { 97 | UINT8 i = 0; 98 | UINT8 name_size = 20; 99 | UINT8 *prot_cycles = NULL; 100 | UINT8 cycles_sum = 0; 101 | 102 | if (pbuffer->data == NULL) 103 | { 104 | return FALSE; 105 | } 106 | 107 | pbuffer->offset = 0; 108 | 109 | /* t_ac_protocol name */ 110 | pbuffer->offset += name_size; 111 | 112 | /* cycles number */ 113 | prot_cycles_num = pbuffer->data + pbuffer->offset; 114 | 115 | if (encode_type == 0) 116 | { 117 | cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */ 118 | if (prot_cycles_num[IRDA_TWO] == 0 && prot_cycles_num[IRDA_THREE] == 0) 119 | { 120 | ir_decode_flag = IRDA_DECODE_1_BIT; 121 | } 122 | else 123 | { 124 | ir_decode_flag = IRDA_DECODE_2_BITS; 125 | } 126 | } 127 | else if (encode_type == 1) 128 | { 129 | cycles_num_size = IRDA_MAX; 130 | ir_decode_flag = IRDA_DECODE_4_BITS; 131 | } 132 | else 133 | { 134 | return FALSE; 135 | } 136 | pbuffer->offset += cycles_num_size; 137 | 138 | /* cycles data */ 139 | prot_cycles = pbuffer->data + pbuffer->offset; 140 | for (i = 0; i < cycles_num_size; i++) 141 | { 142 | if (0 != prot_cycles_num[i]) 143 | { 144 | prot_cycles_data[i] = (t_ir_cycles *) (&prot_cycles[sizeof(t_ir_cycles) * cycles_sum]); 145 | } 146 | else 147 | { 148 | prot_cycles_data[i] = NULL; 149 | } 150 | cycles_sum += prot_cycles_num[i]; 151 | } 152 | pbuffer->offset += sizeof(t_ir_cycles) * cycles_sum; 153 | 154 | /* items count */ 155 | prot_items_cnt = pbuffer->data[pbuffer->offset]; 156 | pbuffer->offset += sizeof(UINT8); 157 | 158 | /* items data */ 159 | prot_items_data = (t_ir_data *) (pbuffer->data + pbuffer->offset); 160 | pbuffer->offset += prot_items_cnt * sizeof(t_ir_data); 161 | 162 | ir_toggle_bit = FALSE; 163 | 164 | return TRUE; 165 | } 166 | 167 | static BOOL get_ir_keymap(void) 168 | { 169 | remote_p = (t_ir_data_tv *) (pbuffer->data + pbuffer->offset); 170 | pbuffer->offset += sizeof(t_ir_data_tv); 171 | 172 | if (strncmp(remote_p->magic, "irda", 4) == 0) 173 | { 174 | remote_pdata = pbuffer->data + pbuffer->offset; 175 | return TRUE; 176 | } 177 | 178 | return FALSE; 179 | } 180 | 181 | static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time) 182 | { 183 | UINT8 i = 0; 184 | UINT8 cycles_num = 0; 185 | t_ir_cycles *pcycles = NULL; 186 | UINT8 key_code = 0; 187 | 188 | if (NULL == data || NULL == ir_time) 189 | { 190 | ir_printf("data or ir_time is null\n"); 191 | return; 192 | } 193 | 194 | pcycles = prot_cycles_data[data->index]; 195 | key_code = remote_pdata[remote_p->per_keycode_bytes * key_index + data->index - 1]; 196 | 197 | if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1) 198 | { 199 | ir_printf("logical 1 or 0 is invalid\n"); 200 | return; 201 | } 202 | 203 | if (time_index >= USER_DATA_SIZE) 204 | { 205 | ir_printf("time index exceeded\n"); 206 | return; 207 | } 208 | 209 | if (data->bits == 1) 210 | { 211 | if (pcycles == NULL) 212 | { 213 | ir_printf("pcycles is null\n"); 214 | return; 215 | } 216 | 217 | cycles_num = prot_cycles_num[data->index]; 218 | if (cycles_num > 5) 219 | { 220 | ir_printf("cycles number exceeded\n"); 221 | return; 222 | } 223 | 224 | for (i = cycles_num; i > 0; i--) 225 | { 226 | if (cycles_num == 2 && data->index == IRDA_FLIP) 227 | { 228 | if (ir_toggle_bit == TRUE) 229 | { 230 | pcycles += 1; 231 | } 232 | } 233 | 234 | if (pcycles->mask && pcycles->space) 235 | { 236 | if (pcycles->flag == IRDA_FLAG_NORMAL) 237 | { 238 | if (ir_level == IRDA_LEVEL_HIGH && time_index != 0) 239 | { 240 | time_index--; 241 | ir_time[time_index++] += pcycles->mask; 242 | } 243 | else if (ir_level == IRDA_LEVEL_LOW) 244 | { 245 | ir_time[time_index++] = pcycles->mask; 246 | } 247 | ir_time[time_index++] = pcycles->space; 248 | ir_level = IRDA_LEVEL_LOW; 249 | } 250 | else if (pcycles->flag == IRDA_FLAG_INVERSE) 251 | { 252 | if (ir_level == IRDA_LEVEL_LOW && time_index != 0) 253 | { 254 | time_index--; 255 | ir_time[time_index++] += pcycles->space; 256 | } 257 | else if (ir_level == IRDA_LEVEL_HIGH) 258 | { 259 | ir_time[time_index++] = pcycles->space; 260 | } 261 | ir_time[time_index++] = pcycles->mask; 262 | ir_level = IRDA_LEVEL_HIGH; 263 | } 264 | } 265 | else if (0 == pcycles->mask && 0 != pcycles->space) 266 | { 267 | if (ir_level == IRDA_LEVEL_LOW && time_index != 0) 268 | { 269 | time_index--; 270 | ir_time[time_index++] += pcycles->space; 271 | } 272 | else if (ir_level == IRDA_LEVEL_HIGH) 273 | { 274 | ir_time[time_index++] = pcycles->space; 275 | } 276 | ir_level = IRDA_LEVEL_LOW; 277 | } 278 | else if (0 == pcycles->space && 0 != pcycles->mask) 279 | { 280 | if (ir_level == IRDA_LEVEL_HIGH && time_index != 0) 281 | { 282 | time_index--; 283 | ir_time[time_index++] += pcycles->mask; 284 | } 285 | else if (ir_level == IRDA_LEVEL_LOW) 286 | { 287 | ir_time[time_index++] = pcycles->mask; 288 | } 289 | ir_level = IRDA_LEVEL_HIGH; 290 | } 291 | else 292 | { 293 | // do nothing 294 | } 295 | 296 | if (cycles_num == 2 && data->index == IRDA_FLIP) 297 | { 298 | break; 299 | } 300 | pcycles++; 301 | } 302 | } 303 | else 304 | { 305 | // mode: inverse 306 | if (data->mode == 1) 307 | key_code = ~key_code; 308 | 309 | if (ir_decode_flag == IRDA_DECODE_1_BIT) 310 | { 311 | // for binary formatted code 312 | process_decode_number(key_code, data, 1, ir_time); 313 | } 314 | else if (ir_decode_flag == IRDA_DECODE_2_BITS) 315 | { 316 | // for quanternary formatted code 317 | process_decode_number(key_code, data, 2, ir_time); 318 | } 319 | else if (ir_decode_flag == IRDA_DECODE_4_BITS) 320 | { 321 | // for hexadecimal formatted code 322 | process_decode_number(key_code, data, 4, ir_time); 323 | } 324 | } 325 | } 326 | 327 | static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time) 328 | { 329 | UINT8 i = 0; 330 | UINT8 value = 0; 331 | UINT8 bit_num = data->bits / valid_bits; 332 | UINT8 valid_value = 0; 333 | 334 | valid_value = (UINT8) ((valid_bits == 1) ? 1 : (valid_bits * valid_bits - 1)); 335 | 336 | if (data->lsb == IRDA_LSB) 337 | { 338 | for (i = 0; i < bit_num; i++) 339 | { 340 | value = (keycode >> (valid_bits * i)) & valid_value; 341 | convert_to_ir_time(value, ir_time); 342 | } 343 | } 344 | else if (data->lsb == IRDA_MSB) 345 | { 346 | for (i = 0; i < bit_num; i++) 347 | { 348 | value = (keycode >> (data->bits - valid_bits * (i + 1))) & valid_value; 349 | convert_to_ir_time(value, ir_time); 350 | } 351 | } 352 | } 353 | 354 | static void convert_to_ir_time(UINT8 value, UINT16 *ir_time) 355 | { 356 | switch (value) 357 | { 358 | case 0: 359 | replace_with(prot_cycles_data[IRDA_ZERO], ir_time); 360 | break; 361 | case 1: 362 | replace_with(prot_cycles_data[IRDA_ONE], ir_time); 363 | break; 364 | case 2: 365 | replace_with(prot_cycles_data[IRDA_TWO], ir_time); 366 | break; 367 | case 3: 368 | replace_with(prot_cycles_data[IRDA_THREE], ir_time); 369 | break; 370 | case 4: 371 | replace_with(prot_cycles_data[IRDA_FOUR], ir_time); 372 | break; 373 | case 5: 374 | replace_with(prot_cycles_data[IRDA_FIVE], ir_time); 375 | break; 376 | case 6: 377 | replace_with(prot_cycles_data[IRDA_SIX], ir_time); 378 | break; 379 | case 7: 380 | replace_with(prot_cycles_data[IRDA_SEVEN], ir_time); 381 | break; 382 | case 8: 383 | replace_with(prot_cycles_data[IRDA_EIGHT], ir_time); 384 | break; 385 | case 9: 386 | replace_with(prot_cycles_data[IRDA_NINE], ir_time); 387 | break; 388 | case 0x0A: 389 | replace_with(prot_cycles_data[IRDA_A], ir_time); 390 | break; 391 | case 0x0B: 392 | replace_with(prot_cycles_data[IRDA_B], ir_time); 393 | break; 394 | case 0x0C: 395 | replace_with(prot_cycles_data[IRDA_C], ir_time); 396 | break; 397 | case 0x0D: 398 | replace_with(prot_cycles_data[IRDA_D], ir_time); 399 | break; 400 | case 0x0E: 401 | replace_with(prot_cycles_data[IRDA_E], ir_time); 402 | break; 403 | case 0x0F: 404 | replace_with(prot_cycles_data[IRDA_F], ir_time); 405 | break; 406 | default: 407 | break; 408 | } 409 | } 410 | 411 | static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time) 412 | { 413 | if (NULL == pcycles_num || NULL == ir_time) 414 | { 415 | return; 416 | } 417 | 418 | if (pcycles_num->flag == IRDA_FLAG_NORMAL) 419 | { 420 | if (ir_level == IRDA_LEVEL_HIGH && time_index != 0) 421 | { 422 | time_index--; 423 | ir_time[time_index++] += pcycles_num->mask; 424 | } 425 | else if (ir_level == IRDA_LEVEL_LOW) 426 | { 427 | ir_time[time_index++] = pcycles_num->mask; 428 | } 429 | ir_time[time_index++] = pcycles_num->space; 430 | ir_level = IRDA_LEVEL_LOW; 431 | } 432 | else if (pcycles_num->flag == IRDA_FLAG_INVERSE) 433 | { 434 | if (ir_level == IRDA_LEVEL_LOW && time_index != 0) 435 | { 436 | time_index--; 437 | ir_time[time_index++] += pcycles_num->space; 438 | } 439 | else if (ir_level == IRDA_LEVEL_HIGH) 440 | { 441 | ir_time[time_index++] = pcycles_num->space; 442 | } 443 | ir_time[time_index++] = pcycles_num->mask; 444 | ir_level = IRDA_LEVEL_HIGH; 445 | } 446 | } -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_decode.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_decode.c 3 | Revised: Date: 2016-10-01 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides algorithms for IR decode (status type) 7 | 8 | Revision log: 9 | * 2016-10-01: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "../include/ir_decode.h" 18 | #include "../include/ir_utils.h" 19 | #include "../include/ir_ac_build_frame.h" 20 | #include "../include/ir_ac_apply.h" 21 | 22 | struct ir_bin_buffer binary_file; 23 | struct ir_bin_buffer *p_ir_buffer = &binary_file; 24 | struct tag_head *tags; 25 | 26 | 27 | UINT8 *ir_hex_code = NULL; 28 | UINT8 ir_hex_len = 0; 29 | 30 | UINT8 byteArray[PROTOCOL_SIZE] = {0}; 31 | 32 | size_t binary_length = 0; 33 | UINT8 *binary_content = NULL; 34 | 35 | UINT8 ir_binary_type = IR_TYPE_STATUS; 36 | UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY; 37 | 38 | t_ac_protocol *context = (t_ac_protocol *) byteArray; 39 | 40 | lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = 41 | { 42 | apply_power, 43 | apply_mode, 44 | apply_temperature, 45 | apply_temperature, 46 | apply_wind_speed, 47 | apply_swing, 48 | apply_swing 49 | }; 50 | 51 | // static functions declarations 52 | static INT8 ir_ac_file_open(const char *file_name); 53 | static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length); 54 | static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, 55 | BOOL change_wind_direction); 56 | static INT8 ir_ac_lib_close(); 57 | static INT8 ir_tv_file_open(const char *file_name); 58 | static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length); 59 | static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode); 60 | static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data); 61 | static INT8 ir_tv_lib_close(); 62 | 63 | 64 | void noprint(const char *fmt, ...) 65 | { 66 | return; 67 | } 68 | 69 | // pubic function definitions 70 | 71 | INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name) 72 | { 73 | INT8 ret = IR_DECODE_SUCCEEDED; 74 | if (category == IR_CATEGORY_AC) 75 | { 76 | ir_binary_type = IR_TYPE_STATUS; 77 | ret = ir_ac_file_open(file_name); 78 | if (IR_DECODE_SUCCEEDED == ret) 79 | { 80 | return ir_ac_lib_parse(); 81 | } 82 | else 83 | { 84 | return ret; 85 | } 86 | } 87 | else 88 | { 89 | ir_binary_type = IR_TYPE_COMMANDS; 90 | if (1 == sub_category) 91 | { 92 | ir_hexadecimal = SUB_CATEGORY_QUATERNARY; 93 | } 94 | else if (2 == sub_category) 95 | { 96 | ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL; 97 | } 98 | else 99 | { 100 | return IR_DECODE_FAILED; 101 | } 102 | 103 | ret = ir_tv_file_open(file_name); 104 | if (IR_DECODE_SUCCEEDED == ret) 105 | { 106 | return ir_tv_lib_parse(ir_hexadecimal); 107 | } 108 | else 109 | { 110 | return ret; 111 | } 112 | } 113 | } 114 | 115 | 116 | INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length) 117 | { 118 | INT8 ret = IR_DECODE_SUCCEEDED; 119 | 120 | if (category == IR_CATEGORY_AC) 121 | { 122 | ir_binary_type = IR_TYPE_STATUS; 123 | ret = ir_ac_lib_open(binary, binary_length); 124 | if (IR_DECODE_SUCCEEDED == ret) 125 | { 126 | return ir_ac_lib_parse(); 127 | } 128 | else 129 | { 130 | return ret; 131 | } 132 | } 133 | else 134 | { 135 | ir_binary_type = IR_TYPE_COMMANDS; 136 | if (1 == sub_category) 137 | { 138 | ir_hexadecimal = SUB_CATEGORY_QUATERNARY; 139 | } 140 | else if (2 == sub_category) 141 | { 142 | ir_hexadecimal = SUB_CATEGORY_HEXADECIMAL; 143 | } 144 | else 145 | { 146 | return IR_DECODE_FAILED; 147 | } 148 | 149 | ret = ir_tv_lib_open(binary, binary_length); 150 | if (IR_DECODE_SUCCEEDED == ret) 151 | { 152 | return ir_tv_lib_parse(ir_hexadecimal); 153 | } 154 | else 155 | { 156 | return ret; 157 | } 158 | } 159 | } 160 | 161 | 162 | UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction) 163 | { 164 | if (IR_TYPE_COMMANDS == ir_binary_type) 165 | { 166 | return ir_tv_lib_control(key_code, user_data); 167 | } 168 | else 169 | { 170 | if (NULL == ac_status) 171 | { 172 | return 0; 173 | } 174 | return ir_ac_lib_control(*ac_status, user_data, key_code, change_wind_direction); 175 | } 176 | } 177 | 178 | 179 | INT8 ir_close() 180 | { 181 | if (IR_TYPE_COMMANDS == ir_binary_type) 182 | { 183 | return ir_tv_lib_close(); 184 | } 185 | else 186 | { 187 | return ir_ac_lib_close(); 188 | } 189 | } 190 | 191 | 192 | #if (defined BOARD_PC || defined BOARD_PC_DLL) 193 | void ir_lib_free_inner_buffer(); 194 | #endif 195 | 196 | 197 | // static function definitions 198 | 199 | //////// AC Begin //////// 200 | static INT8 ir_ac_file_open(const char *file_name) 201 | { 202 | #if !defined NO_FS 203 | size_t ret = 0; 204 | #if !defined WIN32 205 | FILE *stream = fopen(file_name, "rb"); 206 | #else 207 | FILE *stream; 208 | fopen_s(&stream, file_name, "rb"); 209 | #endif 210 | if (NULL == stream) 211 | { 212 | ir_printf("\nfile open failed\n"); 213 | return IR_DECODE_FAILED; 214 | } 215 | 216 | fseek(stream, 0, SEEK_END); 217 | binary_length = (size_t) ftell(stream); 218 | binary_content = (UINT8 *) ir_malloc(binary_length); 219 | 220 | if (NULL == binary_content) 221 | { 222 | ir_printf("\nfailed to alloc memory for binary\n"); 223 | fclose(stream); 224 | return IR_DECODE_FAILED; 225 | } 226 | 227 | fseek(stream, 0, SEEK_SET); 228 | ret = fread(binary_content, binary_length, 1, stream); 229 | 230 | if (ret <= 0) 231 | { 232 | fclose(stream); 233 | ir_free(binary_content); 234 | binary_length = 0; 235 | return IR_DECODE_FAILED; 236 | } 237 | 238 | fclose(stream); 239 | 240 | if (IR_DECODE_FAILED == ir_ac_lib_open(binary_content, (UINT16) binary_length)) 241 | { 242 | ir_free(binary_content); 243 | binary_length = 0; 244 | return IR_DECODE_FAILED; 245 | } 246 | #endif 247 | return IR_DECODE_SUCCEEDED; 248 | } 249 | 250 | static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length) 251 | { 252 | // it is recommended that the parameter binary pointing to 253 | // a global memory block in embedded platform environment 254 | p_ir_buffer->data = binary; 255 | p_ir_buffer->len = binary_length; 256 | p_ir_buffer->offset = 0; 257 | return IR_DECODE_SUCCEEDED; 258 | } 259 | 260 | static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, 261 | BOOL change_wind_direction) 262 | { 263 | UINT16 time_length = 0; 264 | 265 | #if defined BOARD_PC 266 | UINT8 i = 0; 267 | #endif 268 | 269 | if (0 == context->default_code.len) 270 | { 271 | ir_printf("\ndefault code is empty\n"); 272 | return 0; 273 | } 274 | 275 | // pre-set change wind direction flag here 276 | context->change_wind_direction = change_wind_direction; 277 | 278 | context->time = user_data; 279 | 280 | // generate temp buffer for frame calculation 281 | ir_memcpy(ir_hex_code, context->default_code.data, context->default_code.len); 282 | 283 | #if defined USE_APPLY_TABLE 284 | if(ac_status.ac_power != AC_POWER_OFF) 285 | { 286 | for (i = AC_APPLY_POWER; i < AC_APPLY_MAX; i++) 287 | { 288 | apply_table[i](context, parameter_array[i]); 289 | } 290 | } 291 | #else 292 | if (ac_status.ac_power == AC_POWER_OFF) 293 | { 294 | // otherwise, power should always be applied 295 | apply_power(ac_status, function_code); 296 | } 297 | else 298 | { 299 | // check the mode as the first priority, despite any other status 300 | if (TRUE == context->n_mode[ac_status.ac_mode].enable) 301 | { 302 | if (is_solo_function(function_code)) 303 | { 304 | // this key press function needs to send solo code 305 | apply_table[function_code - 1](ac_status, function_code); 306 | } 307 | else 308 | { 309 | if (!is_solo_function(AC_FUNCTION_POWER)) 310 | { 311 | apply_power(ac_status, function_code); 312 | } 313 | 314 | if (!is_solo_function(AC_FUNCTION_MODE)) 315 | { 316 | if (IR_DECODE_FAILED == apply_mode(ac_status, function_code)) 317 | { 318 | return 0; 319 | } 320 | } 321 | 322 | if (!is_solo_function(AC_FUNCTION_WIND_SPEED)) 323 | { 324 | if (IR_DECODE_FAILED == apply_wind_speed(ac_status, function_code)) 325 | { 326 | return 0; 327 | } 328 | } 329 | 330 | if (!is_solo_function(AC_FUNCTION_WIND_SWING) && 331 | !is_solo_function(AC_FUNCTION_WIND_FIX)) 332 | { 333 | if (IR_DECODE_FAILED == apply_swing(ac_status, function_code)) 334 | { 335 | return 0; 336 | } 337 | } 338 | 339 | if (!is_solo_function(AC_FUNCTION_TEMPERATURE_UP) && 340 | !is_solo_function(AC_FUNCTION_TEMPERATURE_DOWN)) 341 | { 342 | if (IR_DECODE_FAILED == apply_temperature(ac_status, function_code)) 343 | { 344 | return 0; 345 | } 346 | } 347 | } 348 | } 349 | else 350 | { 351 | return 0; 352 | } 353 | } 354 | #endif 355 | apply_function(context, function_code); 356 | // checksum should always be applied 357 | apply_checksum(context); 358 | 359 | time_length = create_ir_frame(); 360 | 361 | #if (defined BOARD_PC) 362 | #if (defined BOARD_PC_JNI) 363 | ir_printf("code count = %d\n", context->code_cnt); 364 | #else 365 | for (i = 0; i < context->code_cnt; i++) 366 | { 367 | ir_printf("%d,", context->time[i]); 368 | } 369 | #endif 370 | ir_printf("\n"); 371 | #endif 372 | 373 | return time_length; 374 | } 375 | 376 | static INT8 ir_ac_lib_close() 377 | { 378 | // free context 379 | if (NULL != tags) 380 | { 381 | ir_free(tags); 382 | tags = NULL; 383 | } 384 | free_ac_context(); 385 | 386 | return IR_DECODE_SUCCEEDED; 387 | } 388 | 389 | // utils 390 | INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) 391 | { 392 | UINT8 i = 0; 393 | 394 | if (ac_mode >= AC_MODE_MAX) 395 | { 396 | return IR_DECODE_FAILED; 397 | } 398 | if (NULL == temp_min || NULL == temp_max) 399 | { 400 | return IR_DECODE_FAILED; 401 | } 402 | 403 | if (1 == context->n_mode[ac_mode].all_temp) 404 | { 405 | *temp_min = *temp_max = -1; 406 | return IR_DECODE_SUCCEEDED; 407 | } 408 | 409 | *temp_min = -1; 410 | *temp_max = -1; 411 | for (i = 0; i < AC_TEMP_MAX; i++) 412 | { 413 | if (is_in(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || 414 | (context->temp1.len != 0 && 0 == context->temp1.comp_data[i].seg_len) || 415 | (context->temp2.len != 0 && 0 == context->temp2.comp_data[i].seg_len)) 416 | { 417 | continue; 418 | } 419 | if (-1 == *temp_min) 420 | { 421 | *temp_min = i; 422 | } 423 | if (-1 == *temp_max || i > *temp_max) 424 | { 425 | *temp_max = i; 426 | } 427 | } 428 | return IR_DECODE_SUCCEEDED; 429 | } 430 | 431 | INT8 get_supported_mode(UINT8 *supported_mode) 432 | { 433 | UINT8 i = 0; 434 | if (NULL == supported_mode) 435 | { 436 | return IR_DECODE_FAILED; 437 | } 438 | *supported_mode = 0x1F; 439 | 440 | for (i = 0; i < AC_MODE_MAX; i++) 441 | { 442 | if (0 == context->n_mode[i].enable || 443 | (context->mode1.len != 0 && 0 == context->mode1.comp_data[i].seg_len) || 444 | (context->mode2.len != 0 && 0 == context->mode2.comp_data[i].seg_len)) 445 | { 446 | *supported_mode &= ~(1 << i); 447 | } 448 | } 449 | 450 | return IR_DECODE_SUCCEEDED; 451 | } 452 | 453 | INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) 454 | { 455 | UINT8 i = 0; 456 | if (ac_mode >= AC_MODE_MAX) 457 | { 458 | return IR_DECODE_FAILED; 459 | } 460 | 461 | if (NULL == supported_wind_speed) 462 | { 463 | return IR_DECODE_FAILED; 464 | } 465 | 466 | if (1 == context->n_mode[ac_mode].all_speed) 467 | { 468 | *supported_wind_speed = 0; 469 | return IR_DECODE_SUCCEEDED; 470 | } 471 | 472 | *supported_wind_speed = 0x0F; 473 | 474 | for (i = 0; i < AC_WS_MAX; i++) 475 | { 476 | if (is_in(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || 477 | (context->speed1.len != 0 && 0 == context->speed1.comp_data[i].seg_len) || 478 | (context->speed2.len != 0 && 0 == context->speed2.comp_data[i].seg_len)) 479 | { 480 | *supported_wind_speed &= ~(1 << i); 481 | } 482 | } 483 | 484 | return IR_DECODE_SUCCEEDED; 485 | } 486 | 487 | INT8 get_supported_swing(UINT8 ac_mode, UINT8 *supported_swing) 488 | { 489 | if (ac_mode >= AC_MODE_MAX) 490 | { 491 | return IR_DECODE_FAILED; 492 | } 493 | 494 | if (NULL == supported_swing) 495 | { 496 | return IR_DECODE_FAILED; 497 | } 498 | 499 | if (context->si.type == SWING_TYPE_NORMAL) 500 | { 501 | *supported_swing = 0x03; 502 | } 503 | else if (context->si.type == SWING_TYPE_SWING_ONLY) 504 | { 505 | *supported_swing = 0x02; 506 | } 507 | else if (context->si.type == SWING_TYPE_NOT_SPECIFIED) 508 | { 509 | *supported_swing = 0x00; 510 | } 511 | else 512 | { 513 | *supported_swing = 0x01; 514 | } 515 | return IR_DECODE_SUCCEEDED; 516 | } 517 | 518 | INT8 get_supported_wind_direction(UINT8 *supported_wind_direction) 519 | { 520 | if (NULL != context) 521 | { 522 | *supported_wind_direction = (UINT8) (context->si.mode_count - 1); 523 | return IR_DECODE_SUCCEEDED; 524 | } 525 | else 526 | { 527 | return IR_DECODE_FAILED; 528 | } 529 | } 530 | 531 | //////// AC End //////// 532 | 533 | //////// TV Begin //////// 534 | static INT8 ir_tv_file_open(const char *file_name) 535 | { 536 | #if !defined NO_FS 537 | size_t ret = 0; 538 | 539 | #if !defined WIN32 540 | FILE *stream = fopen(file_name, "rb"); 541 | #else 542 | FILE *stream; 543 | fopen_s(&stream, file_name, "rb"); 544 | #endif 545 | 546 | if (stream == NULL) 547 | { 548 | ir_printf("\nfile open failed\n"); 549 | return IR_DECODE_FAILED; 550 | } 551 | 552 | fseek(stream, 0, SEEK_END); 553 | binary_length = (size_t) ftell(stream); 554 | 555 | binary_content = (UINT8 *) ir_malloc(binary_length); 556 | if (NULL == binary_content) 557 | { 558 | ir_printf("\nfailed to alloc memory for binary\n"); 559 | fclose(stream); 560 | return IR_DECODE_FAILED; 561 | } 562 | 563 | fseek(stream, 0, SEEK_SET); 564 | ret = fread(binary_content, binary_length, 1, stream); 565 | if (ret <= 0) 566 | { 567 | fclose(stream); 568 | ir_free(binary_content); 569 | binary_length = 0; 570 | return IR_DECODE_FAILED; 571 | } 572 | 573 | fclose(stream); 574 | 575 | if (IR_DECODE_FAILED == ir_tv_lib_open(binary_content, (UINT16) binary_length)) 576 | { 577 | ir_free(binary_content); 578 | binary_length = 0; 579 | return IR_DECODE_FAILED; 580 | } 581 | #endif 582 | return IR_DECODE_SUCCEEDED; 583 | } 584 | 585 | static INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length) 586 | { 587 | return tv_lib_open(binary, binary_length); 588 | } 589 | 590 | static INT8 ir_tv_lib_parse(UINT8 ir_hex_encode) 591 | { 592 | if (FALSE == tv_lib_parse(ir_hex_encode)) 593 | { 594 | ir_printf("parse irda binary failed\n"); 595 | return IR_DECODE_FAILED; 596 | } 597 | return IR_DECODE_SUCCEEDED; 598 | } 599 | 600 | static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data) 601 | { 602 | #if defined BOARD_PC 603 | UINT16 print_index = 0; 604 | #endif 605 | UINT16 ir_code_length = 0; 606 | memset(l_user_data, 0x00, USER_DATA_SIZE); 607 | ir_code_length = tv_lib_control(key, l_user_data); 608 | 609 | #if defined BOARD_PC 610 | // have some debug 611 | ir_printf("length of IR code = %d\n", ir_code_length); 612 | for (print_index = 0; print_index < ir_code_length; print_index++) 613 | { 614 | ir_printf("%d ", l_user_data[print_index]); 615 | } 616 | #endif 617 | 618 | return ir_code_length; 619 | } 620 | 621 | static INT8 ir_tv_lib_close() 622 | { 623 | #if (defined BOARD_PC || defined BOARD_PC_DLL) 624 | ir_lib_free_inner_buffer(); 625 | #endif 626 | return IR_DECODE_SUCCEEDED; 627 | } 628 | //////// TV End //////// 629 | 630 | 631 | #if (defined BOARD_PC || defined BOARD_PC_DLL) 632 | void ir_lib_free_inner_buffer() 633 | { 634 | if (NULL != binary_content) 635 | { 636 | ir_free(binary_content); 637 | binary_content = NULL; 638 | } 639 | } 640 | #endif -------------------------------------------------------------------------------- /src/ir_decoder/src/ir_ac_control.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************** 2 | Filename: ir_ac_control.c 3 | Revised: Date: 2017-01-02 4 | Revision: Revision: 1.0 5 | 6 | Description: This file provides methods for AC IR control 7 | 8 | Revision log: 9 | * 2016-10-12: created by strawmanbobi 10 | **************************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../include/ir_ac_control.h" 17 | #include "../include/ir_ac_binary_parse.h" 18 | #include "../include/ir_decode.h" 19 | #include "../include/ir_ac_parse_parameter.h" 20 | #include "../include/ir_ac_parse_forbidden_info.h" 21 | #include "../include/ir_ac_parse_frame_info.h" 22 | #include "../include/ir_utils.h" 23 | 24 | 25 | extern struct tag_head *tags; 26 | extern UINT8 tag_count; 27 | 28 | static INT8 ir_context_init(); 29 | 30 | 31 | static INT8 ir_context_init() 32 | { 33 | ir_memset(context, 0, sizeof(t_ac_protocol)); 34 | return IR_DECODE_SUCCEEDED; 35 | } 36 | 37 | 38 | INT8 ir_ac_lib_parse() 39 | { 40 | UINT8 i = 0; 41 | // suggest not to call init function here for de-couple purpose 42 | ir_context_init(); 43 | 44 | if (IR_DECODE_FAILED == binary_parse_offset()) 45 | { 46 | return IR_DECODE_FAILED; 47 | } 48 | 49 | if (IR_DECODE_FAILED == binary_parse_len()) 50 | { 51 | return IR_DECODE_FAILED; 52 | } 53 | 54 | if (IR_DECODE_FAILED == binary_parse_data()) 55 | { 56 | return IR_DECODE_FAILED; 57 | } 58 | 59 | binary_tags_info(); 60 | 61 | context->endian = 0; 62 | context->last_bit = 0; 63 | context->repeat_times = 1; 64 | 65 | for (i = 0; i < N_MODE_MAX; i++) 66 | { 67 | context->n_mode[i].enable = TRUE; 68 | context->n_mode[i].all_speed = FALSE; 69 | context->n_mode[i].all_temp = FALSE; 70 | ir_memset(context->n_mode[i].speed, 0x00, AC_WS_MAX); 71 | context->n_mode[i].speed_cnt = 0; 72 | ir_memset(context->n_mode[i].temp, 0x00, AC_TEMP_MAX); 73 | context->n_mode[i].temp_cnt = 0; 74 | } 75 | 76 | // parse TAG 46 in first priority 77 | for (i = 0; i < tag_count; i++) 78 | { 79 | if (tags[i].tag == TAG_AC_SWING_INFO) 80 | { 81 | if (tags[i].len != 0) 82 | { 83 | parse_swing_info(&tags[i], &(context->si)); 84 | } 85 | else 86 | { 87 | context->si.type = SWING_TYPE_NORMAL; 88 | context->si.mode_count = 2; 89 | } 90 | context->si.dir_index = 0; 91 | } 92 | } 93 | 94 | for (i = 0; i < tag_count; i++) 95 | { 96 | if (tags[i].len == 0) 97 | { 98 | continue; 99 | } 100 | // then parse TAG 26 or 33 101 | if (context->si.type == SWING_TYPE_NORMAL) 102 | { 103 | UINT16 swing_space_size = 0; 104 | if (tags[i].tag == TAG_AC_SWING_1) 105 | { 106 | context->swing1.count = context->si.mode_count; 107 | context->swing1.len = (UINT8) tags[i].len >> 1; 108 | swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; 109 | context->swing1.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); 110 | if (NULL == context->swing1.comp_data) 111 | { 112 | return IR_DECODE_FAILED; 113 | } 114 | 115 | ir_memset(context->swing1.comp_data, 0x00, swing_space_size); 116 | if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], 117 | context->swing1.comp_data, 118 | context->si.mode_count, 119 | AC_PARAMETER_TYPE_1)) 120 | { 121 | return IR_DECODE_FAILED; 122 | } 123 | } 124 | else if (tags[i].tag == TAG_AC_SWING_2) 125 | { 126 | context->swing2.count = context->si.mode_count; 127 | context->swing2.len = (UINT8) tags[i].len >> 1; 128 | swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; 129 | context->swing2.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); 130 | if (NULL == context->swing2.comp_data) 131 | { 132 | return IR_DECODE_FAILED; 133 | } 134 | ir_memset(context->swing2.comp_data, 0x00, swing_space_size); 135 | if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], 136 | context->swing2.comp_data, 137 | context->si.mode_count, 138 | AC_PARAMETER_TYPE_2)) 139 | { 140 | return IR_DECODE_FAILED; 141 | } 142 | } 143 | } 144 | 145 | if (tags[i].tag == TAG_AC_DEFAULT_CODE) // default code TAG 146 | { 147 | context->default_code.data = (UINT8 *) ir_malloc(((size_t) tags[i].len - 2) >> 1); 148 | if (NULL == context->default_code.data) 149 | { 150 | return IR_DECODE_FAILED; 151 | } 152 | if (IR_DECODE_FAILED == parse_default_code(&tags[i], &(context->default_code))) 153 | { 154 | return IR_DECODE_FAILED; 155 | } 156 | } 157 | else if (tags[i].tag == TAG_AC_POWER_1) // power tag 158 | { 159 | context->power1.len = (UINT8) tags[i].len >> 1; 160 | if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], 161 | context->power1.comp_data, 162 | AC_POWER_MAX, 163 | AC_PARAMETER_TYPE_1)) 164 | { 165 | return IR_DECODE_FAILED; 166 | } 167 | } 168 | else if (tags[i].tag == TAG_AC_TEMP_1) // temperature tag type 1 169 | { 170 | if (IR_DECODE_FAILED == parse_temp_1(&tags[i], &(context->temp1))) 171 | { 172 | return IR_DECODE_FAILED; 173 | } 174 | } 175 | else if (tags[i].tag == TAG_AC_MODE_1) // mode tag 176 | { 177 | context->mode1.len = (UINT8) tags[i].len >> 1; 178 | if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], 179 | context->mode1.comp_data, 180 | AC_MODE_MAX, 181 | AC_PARAMETER_TYPE_1)) 182 | { 183 | return IR_DECODE_FAILED; 184 | } 185 | } 186 | else if (tags[i].tag == TAG_AC_SPEED_1) // wind speed tag 187 | { 188 | context->speed1.len = (UINT8) tags[i].len >> 1; 189 | if (IR_DECODE_FAILED == parse_common_ac_parameter(&tags[i], 190 | context->speed1.comp_data, 191 | AC_WS_MAX, 192 | AC_PARAMETER_TYPE_1)) 193 | { 194 | return IR_DECODE_FAILED; 195 | } 196 | } 197 | else if (tags[i].tag == TAG_AC_CHECKSUM_TYPE) 198 | { 199 | if (IR_DECODE_FAILED == parse_checksum(&tags[i], &(context->checksum))) 200 | { 201 | return IR_DECODE_FAILED; 202 | } 203 | } 204 | else if (tags[i].tag == TAG_AC_MODE_2) 205 | { 206 | context->mode2.len = (UINT8) tags[i].len >> 1; 207 | if (IR_DECODE_FAILED == 208 | parse_common_ac_parameter(&tags[i], 209 | context->mode2.comp_data, AC_MODE_MAX, AC_PARAMETER_TYPE_1)) 210 | { 211 | return IR_DECODE_FAILED; 212 | } 213 | } 214 | else if (tags[i].tag == TAG_AC_SPEED_2) 215 | { 216 | context->speed2.len = (UINT8) tags[i].len >> 1; 217 | if (IR_DECODE_FAILED == 218 | parse_common_ac_parameter(&tags[i], 219 | context->speed2.comp_data, AC_WS_MAX, AC_PARAMETER_TYPE_1)) 220 | { 221 | return IR_DECODE_FAILED; 222 | } 223 | } 224 | else if (tags[i].tag == TAG_AC_TEMP_2) 225 | { 226 | if (IR_DECODE_FAILED == parse_temp_2(&tags[i], &(context->temp2))) 227 | { 228 | return IR_DECODE_FAILED; 229 | } 230 | } 231 | else if (tags[i].tag == TAG_AC_SOLO_FUNCTION) 232 | { 233 | if (IR_DECODE_FAILED == parse_solo_code(&tags[i], &(context->sc))) 234 | { 235 | return IR_DECODE_FAILED; 236 | } 237 | context->solo_function_mark = 1; 238 | } 239 | else if (tags[i].tag == TAG_AC_FUNCTION_1) 240 | { 241 | if (IR_DECODE_FAILED == parse_function_1_tag29(&tags[i], &(context->function1))) 242 | { 243 | ir_printf("\nfunction code parse error\n"); 244 | return IR_DECODE_FAILED; 245 | } 246 | } 247 | else if (tags[i].tag == TAG_AC_FUNCTION_2) 248 | { 249 | if (IR_DECODE_FAILED == parse_function_2_tag34(&tags[i], &(context->function2))) 250 | { 251 | return IR_DECODE_FAILED; 252 | } 253 | } 254 | else if (tags[i].tag == TAG_AC_FRAME_LENGTH) 255 | { 256 | if (IR_DECODE_FAILED == parse_frame_len(&tags[i], tags[i].len)) 257 | { 258 | return IR_DECODE_FAILED; 259 | } 260 | } 261 | else if (tags[i].tag == TAG_AC_ZERO) 262 | { 263 | if (IR_DECODE_FAILED == parse_zero(&tags[i])) 264 | { 265 | return IR_DECODE_FAILED; 266 | } 267 | } 268 | else if (tags[i].tag == TAG_AC_ONE) 269 | { 270 | if (IR_DECODE_FAILED == parse_one(&tags[i])) 271 | { 272 | return IR_DECODE_FAILED; 273 | } 274 | } 275 | else if (tags[i].tag == TAG_AC_BOOT_CODE) 276 | { 277 | if (IR_DECODE_FAILED == parse_boot_code(&tags[i])) 278 | { 279 | return IR_DECODE_FAILED; 280 | } 281 | } 282 | else if (tags[i].tag == TAG_AC_REPEAT_TIMES) 283 | { 284 | if (IR_DECODE_FAILED == parse_repeat_times(&tags[i])) 285 | { 286 | return IR_DECODE_FAILED; 287 | } 288 | } 289 | else if (tags[i].tag == TAG_AC_BIT_NUM) 290 | { 291 | if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) 292 | { 293 | return IR_DECODE_FAILED; 294 | } 295 | } 296 | else if (tags[i].tag == TAG_AC_ENDIAN) 297 | { 298 | if (IR_DECODE_FAILED == parse_endian(&tags[i])) 299 | { 300 | return IR_DECODE_FAILED; 301 | } 302 | } 303 | else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_COOL_MODE) 304 | { 305 | if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_COOL)) 306 | { 307 | return IR_DECODE_FAILED; 308 | } 309 | } 310 | else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_HEAT_MODE) 311 | { 312 | if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_HEAT)) 313 | { 314 | return IR_DECODE_FAILED; 315 | } 316 | } 317 | else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_AUTO_MODE) 318 | { 319 | if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_AUTO)) 320 | { 321 | return IR_DECODE_FAILED; 322 | } 323 | } 324 | else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_FAN_MODE) 325 | { 326 | if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_FAN)) 327 | { 328 | return IR_DECODE_FAILED; 329 | } 330 | } 331 | else if (tags[i].tag == TAG_AC_BAN_FUNCTION_IN_DRY_MODE) 332 | { 333 | if (IR_DECODE_FAILED == parse_nmode(&tags[i], N_DRY)) 334 | { 335 | return IR_DECODE_FAILED; 336 | } 337 | } 338 | } 339 | 340 | for (i = 0; i < tag_count; i++) 341 | { 342 | if (tags[i].len == 0) 343 | { 344 | continue; 345 | } 346 | if (tags[i].tag == TAG_AC_DELAY_CODE) 347 | { 348 | if (IR_DECODE_FAILED == parse_delay_code(&tags[i])) 349 | { 350 | return IR_DECODE_FAILED; 351 | } 352 | } 353 | if (tags[i].tag == TAG_AC_LAST_BIT) 354 | { 355 | if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) 356 | { 357 | return IR_DECODE_FAILED; 358 | } 359 | } 360 | } 361 | 362 | if (NULL != tags) 363 | { 364 | ir_free(tags); 365 | tags = NULL; 366 | } 367 | 368 | ir_hex_code = (UINT8 *) ir_malloc(context->default_code.len); 369 | if (NULL == ir_hex_code) 370 | { 371 | // warning: this AC bin contains no default code 372 | return IR_DECODE_FAILED; 373 | } 374 | 375 | ir_hex_len = context->default_code.len; 376 | ir_memset(ir_hex_code, 0x00, ir_hex_len); 377 | 378 | // pre-calculate solo function status after parse phase 379 | if (1 == context->solo_function_mark) 380 | { 381 | context->solo_function_mark = 0x00; 382 | // bit order from right to left : power, mode, temp+, temp-, wind_speed, swing, fix 383 | for (i = AC_FUNCTION_POWER; i < AC_FUNCTION_MAX; i++) 384 | { 385 | if (is_in(context->sc.solo_function_codes, i, context->sc.solo_func_count)) 386 | { 387 | context->solo_function_mark |= (1 << (i - 1)); 388 | } 389 | } 390 | } 391 | 392 | // it is strongly recommended that we free p_ir_buffer 393 | // or make global buffer shared in extreme memory case 394 | /* in case of running with test - begin */ 395 | #if (defined BOARD_PC || defined BOARD_PC_DLL) 396 | ir_lib_free_inner_buffer(); 397 | ir_printf("AC parse done\n"); 398 | #endif 399 | /* in case of running with test - end */ 400 | 401 | return IR_DECODE_SUCCEEDED; 402 | } 403 | 404 | 405 | INT8 free_ac_context() 406 | { 407 | UINT16 i = 0; 408 | 409 | if (ir_hex_code != NULL) 410 | { 411 | ir_free(ir_hex_code); 412 | ir_hex_code = NULL; 413 | } 414 | ir_hex_len = 0; 415 | 416 | if (context->default_code.data != NULL) 417 | { 418 | ir_free(context->default_code.data); 419 | context->default_code.data = NULL; 420 | context->default_code.len = 0; 421 | } 422 | 423 | for (i = 0; i < AC_POWER_MAX; i++) 424 | { 425 | if (context->power1.comp_data[i].segment != NULL) 426 | { 427 | ir_free(context->power1.comp_data[i].segment); 428 | context->power1.comp_data[i].segment = NULL; 429 | context->power1.comp_data[i].seg_len = 0; 430 | } 431 | } 432 | 433 | for (i = 0; i < AC_TEMP_MAX; i++) 434 | { 435 | if (context->temp1.comp_data[i].segment != NULL) 436 | { 437 | ir_free(context->temp1.comp_data[i].segment); 438 | context->temp1.comp_data[i].segment = NULL; 439 | context->temp1.comp_data[i].seg_len = 0; 440 | } 441 | if (context->temp2.comp_data[i].segment != NULL) 442 | { 443 | ir_free(context->temp2.comp_data[i].segment); 444 | context->temp2.comp_data[i].segment = NULL; 445 | context->temp2.comp_data[i].seg_len = 0; 446 | } 447 | } 448 | 449 | for (i = 0; i < AC_MODE_MAX; i++) 450 | { 451 | if (context->mode1.comp_data[i].segment != NULL) 452 | { 453 | ir_free(context->mode1.comp_data[i].segment); 454 | context->mode1.comp_data[i].segment = NULL; 455 | context->mode1.comp_data[i].seg_len = 0; 456 | } 457 | if (context->mode2.comp_data[i].segment != NULL) 458 | { 459 | ir_free(context->mode2.comp_data[i].segment); 460 | context->mode2.comp_data[i].segment = NULL; 461 | context->mode2.comp_data[i].seg_len = 0; 462 | } 463 | } 464 | for (i = 0; i < AC_WS_MAX; i++) 465 | { 466 | if (context->speed1.comp_data[i].segment != NULL) 467 | { 468 | ir_free(context->speed1.comp_data[i].segment); 469 | context->speed1.comp_data[i].segment = NULL; 470 | context->speed1.comp_data[i].seg_len = 0; 471 | } 472 | if (context->speed2.comp_data[i].segment != NULL) 473 | { 474 | ir_free(context->speed2.comp_data[i].segment); 475 | context->speed2.comp_data[i].segment = NULL; 476 | context->speed2.comp_data[i].seg_len = 0; 477 | } 478 | } 479 | 480 | for (i = 0; i < context->si.mode_count; i++) 481 | { 482 | if (context->swing1.comp_data != NULL && 483 | context->swing1.comp_data[i].segment != NULL) 484 | { 485 | ir_free(context->swing1.comp_data[i].segment); 486 | context->swing1.comp_data[i].segment = NULL; 487 | context->swing1.comp_data[i].seg_len = 0; 488 | } 489 | if (context->swing2.comp_data != NULL && 490 | context->swing2.comp_data[i].segment != NULL) 491 | { 492 | ir_free(context->swing2.comp_data[i].segment); 493 | context->swing2.comp_data[i].segment = NULL; 494 | context->swing2.comp_data[i].seg_len = 0; 495 | } 496 | } 497 | 498 | for (i = 0; i < AC_FUNCTION_MAX - 1; i++) 499 | { 500 | if (context->function1.comp_data[i].segment != NULL) 501 | { 502 | ir_free(context->function1.comp_data[i].segment); 503 | context->function1.comp_data[i].segment = NULL; 504 | context->function1.comp_data[i].seg_len = 0; 505 | } 506 | if (context->function2.comp_data[i].segment != NULL) 507 | { 508 | ir_free(context->function2.comp_data[i].segment); 509 | context->function2.comp_data[i].segment = NULL; 510 | context->function2.comp_data[i].seg_len = 0; 511 | } 512 | } 513 | 514 | // free composite data for swing1 and swing 2 515 | if (context->swing1.comp_data != NULL) 516 | { 517 | ir_free(context->swing1.comp_data); 518 | context->swing1.comp_data = NULL; 519 | } 520 | if (context->swing2.comp_data != NULL) 521 | { 522 | ir_free(context->swing2.comp_data); 523 | context->swing2.comp_data = NULL; 524 | } 525 | 526 | for (i = 0; i < context->checksum.count; i++) 527 | { 528 | if (context->checksum.checksum_data != NULL && 529 | context->checksum.checksum_data[i].spec_pos != NULL) 530 | { 531 | ir_free(context->checksum.checksum_data[i].spec_pos); 532 | context->checksum.checksum_data[i].len = 0; 533 | context->checksum.checksum_data[i].spec_pos = NULL; 534 | } 535 | } 536 | if (context->checksum.checksum_data != NULL) 537 | { 538 | ir_free(context->checksum.checksum_data); 539 | context->checksum.checksum_data = NULL; 540 | } 541 | 542 | return IR_DECODE_SUCCEEDED; 543 | } 544 | 545 | BOOL is_solo_function(UINT8 function_code) 546 | { 547 | return (((context->solo_function_mark >> (function_code - 1)) & 0x01) == 0x01) ? TRUE : FALSE; 548 | } 549 | -------------------------------------------------------------------------------- /src/ir_decoder/jni/include/classfile_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | #ifndef CLASSFILE_CONSTANTS_H 27 | #define CLASSFILE_CONSTANTS_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* Classfile version number for this information */ 34 | #define JVM_CLASSFILE_MAJOR_VERSION 52 35 | #define JVM_CLASSFILE_MINOR_VERSION 0 36 | 37 | /* Flags */ 38 | 39 | enum { 40 | JVM_ACC_PUBLIC = 0x0001, 41 | JVM_ACC_PRIVATE = 0x0002, 42 | JVM_ACC_PROTECTED = 0x0004, 43 | JVM_ACC_STATIC = 0x0008, 44 | JVM_ACC_FINAL = 0x0010, 45 | JVM_ACC_SYNCHRONIZED = 0x0020, 46 | JVM_ACC_SUPER = 0x0020, 47 | JVM_ACC_VOLATILE = 0x0040, 48 | JVM_ACC_BRIDGE = 0x0040, 49 | JVM_ACC_TRANSIENT = 0x0080, 50 | JVM_ACC_VARARGS = 0x0080, 51 | JVM_ACC_NATIVE = 0x0100, 52 | JVM_ACC_INTERFACE = 0x0200, 53 | JVM_ACC_ABSTRACT = 0x0400, 54 | JVM_ACC_STRICT = 0x0800, 55 | JVM_ACC_SYNTHETIC = 0x1000, 56 | JVM_ACC_ANNOTATION = 0x2000, 57 | JVM_ACC_ENUM = 0x4000 58 | }; 59 | 60 | /* Used in newarray instruction. */ 61 | 62 | enum { 63 | JVM_T_BOOLEAN = 4, 64 | JVM_T_CHAR = 5, 65 | JVM_T_FLOAT = 6, 66 | JVM_T_DOUBLE = 7, 67 | JVM_T_BYTE = 8, 68 | JVM_T_SHORT = 9, 69 | JVM_T_INT = 10, 70 | JVM_T_LONG = 11 71 | }; 72 | 73 | /* Constant Pool Entries */ 74 | 75 | enum { 76 | JVM_CONSTANT_Utf8 = 1, 77 | JVM_CONSTANT_Unicode = 2, /* unused */ 78 | JVM_CONSTANT_Integer = 3, 79 | JVM_CONSTANT_Float = 4, 80 | JVM_CONSTANT_Long = 5, 81 | JVM_CONSTANT_Double = 6, 82 | JVM_CONSTANT_Class = 7, 83 | JVM_CONSTANT_String = 8, 84 | JVM_CONSTANT_Fieldref = 9, 85 | JVM_CONSTANT_Methodref = 10, 86 | JVM_CONSTANT_InterfaceMethodref = 11, 87 | JVM_CONSTANT_NameAndType = 12, 88 | JVM_CONSTANT_MethodHandle = 15, // JSR 292 89 | JVM_CONSTANT_MethodType = 16, // JSR 292 90 | JVM_CONSTANT_InvokeDynamic = 18 91 | }; 92 | 93 | /* JVM_CONSTANT_MethodHandle subtypes */ 94 | enum { 95 | JVM_REF_getField = 1, 96 | JVM_REF_getStatic = 2, 97 | JVM_REF_putField = 3, 98 | JVM_REF_putStatic = 4, 99 | JVM_REF_invokeVirtual = 5, 100 | JVM_REF_invokeStatic = 6, 101 | JVM_REF_invokeSpecial = 7, 102 | JVM_REF_newInvokeSpecial = 8, 103 | JVM_REF_invokeInterface = 9 104 | }; 105 | 106 | /* StackMapTable type item numbers */ 107 | 108 | enum { 109 | JVM_ITEM_Top = 0, 110 | JVM_ITEM_Integer = 1, 111 | JVM_ITEM_Float = 2, 112 | JVM_ITEM_Double = 3, 113 | JVM_ITEM_Long = 4, 114 | JVM_ITEM_Null = 5, 115 | JVM_ITEM_UninitializedThis = 6, 116 | JVM_ITEM_Object = 7, 117 | JVM_ITEM_Uninitialized = 8 118 | }; 119 | 120 | /* Type signatures */ 121 | 122 | enum { 123 | JVM_SIGNATURE_ARRAY = '[', 124 | JVM_SIGNATURE_BYTE = 'B', 125 | JVM_SIGNATURE_CHAR = 'C', 126 | JVM_SIGNATURE_CLASS = 'L', 127 | JVM_SIGNATURE_ENDCLASS = ';', 128 | JVM_SIGNATURE_ENUM = 'E', 129 | JVM_SIGNATURE_FLOAT = 'F', 130 | JVM_SIGNATURE_DOUBLE = 'D', 131 | JVM_SIGNATURE_FUNC = '(', 132 | JVM_SIGNATURE_ENDFUNC = ')', 133 | JVM_SIGNATURE_INT = 'I', 134 | JVM_SIGNATURE_LONG = 'J', 135 | JVM_SIGNATURE_SHORT = 'S', 136 | JVM_SIGNATURE_VOID = 'V', 137 | JVM_SIGNATURE_BOOLEAN = 'Z' 138 | }; 139 | 140 | /* Opcodes */ 141 | 142 | enum { 143 | JVM_OPC_nop = 0, 144 | JVM_OPC_aconst_null = 1, 145 | JVM_OPC_iconst_m1 = 2, 146 | JVM_OPC_iconst_0 = 3, 147 | JVM_OPC_iconst_1 = 4, 148 | JVM_OPC_iconst_2 = 5, 149 | JVM_OPC_iconst_3 = 6, 150 | JVM_OPC_iconst_4 = 7, 151 | JVM_OPC_iconst_5 = 8, 152 | JVM_OPC_lconst_0 = 9, 153 | JVM_OPC_lconst_1 = 10, 154 | JVM_OPC_fconst_0 = 11, 155 | JVM_OPC_fconst_1 = 12, 156 | JVM_OPC_fconst_2 = 13, 157 | JVM_OPC_dconst_0 = 14, 158 | JVM_OPC_dconst_1 = 15, 159 | JVM_OPC_bipush = 16, 160 | JVM_OPC_sipush = 17, 161 | JVM_OPC_ldc = 18, 162 | JVM_OPC_ldc_w = 19, 163 | JVM_OPC_ldc2_w = 20, 164 | JVM_OPC_iload = 21, 165 | JVM_OPC_lload = 22, 166 | JVM_OPC_fload = 23, 167 | JVM_OPC_dload = 24, 168 | JVM_OPC_aload = 25, 169 | JVM_OPC_iload_0 = 26, 170 | JVM_OPC_iload_1 = 27, 171 | JVM_OPC_iload_2 = 28, 172 | JVM_OPC_iload_3 = 29, 173 | JVM_OPC_lload_0 = 30, 174 | JVM_OPC_lload_1 = 31, 175 | JVM_OPC_lload_2 = 32, 176 | JVM_OPC_lload_3 = 33, 177 | JVM_OPC_fload_0 = 34, 178 | JVM_OPC_fload_1 = 35, 179 | JVM_OPC_fload_2 = 36, 180 | JVM_OPC_fload_3 = 37, 181 | JVM_OPC_dload_0 = 38, 182 | JVM_OPC_dload_1 = 39, 183 | JVM_OPC_dload_2 = 40, 184 | JVM_OPC_dload_3 = 41, 185 | JVM_OPC_aload_0 = 42, 186 | JVM_OPC_aload_1 = 43, 187 | JVM_OPC_aload_2 = 44, 188 | JVM_OPC_aload_3 = 45, 189 | JVM_OPC_iaload = 46, 190 | JVM_OPC_laload = 47, 191 | JVM_OPC_faload = 48, 192 | JVM_OPC_daload = 49, 193 | JVM_OPC_aaload = 50, 194 | JVM_OPC_baload = 51, 195 | JVM_OPC_caload = 52, 196 | JVM_OPC_saload = 53, 197 | JVM_OPC_istore = 54, 198 | JVM_OPC_lstore = 55, 199 | JVM_OPC_fstore = 56, 200 | JVM_OPC_dstore = 57, 201 | JVM_OPC_astore = 58, 202 | JVM_OPC_istore_0 = 59, 203 | JVM_OPC_istore_1 = 60, 204 | JVM_OPC_istore_2 = 61, 205 | JVM_OPC_istore_3 = 62, 206 | JVM_OPC_lstore_0 = 63, 207 | JVM_OPC_lstore_1 = 64, 208 | JVM_OPC_lstore_2 = 65, 209 | JVM_OPC_lstore_3 = 66, 210 | JVM_OPC_fstore_0 = 67, 211 | JVM_OPC_fstore_1 = 68, 212 | JVM_OPC_fstore_2 = 69, 213 | JVM_OPC_fstore_3 = 70, 214 | JVM_OPC_dstore_0 = 71, 215 | JVM_OPC_dstore_1 = 72, 216 | JVM_OPC_dstore_2 = 73, 217 | JVM_OPC_dstore_3 = 74, 218 | JVM_OPC_astore_0 = 75, 219 | JVM_OPC_astore_1 = 76, 220 | JVM_OPC_astore_2 = 77, 221 | JVM_OPC_astore_3 = 78, 222 | JVM_OPC_iastore = 79, 223 | JVM_OPC_lastore = 80, 224 | JVM_OPC_fastore = 81, 225 | JVM_OPC_dastore = 82, 226 | JVM_OPC_aastore = 83, 227 | JVM_OPC_bastore = 84, 228 | JVM_OPC_castore = 85, 229 | JVM_OPC_sastore = 86, 230 | JVM_OPC_pop = 87, 231 | JVM_OPC_pop2 = 88, 232 | JVM_OPC_dup = 89, 233 | JVM_OPC_dup_x1 = 90, 234 | JVM_OPC_dup_x2 = 91, 235 | JVM_OPC_dup2 = 92, 236 | JVM_OPC_dup2_x1 = 93, 237 | JVM_OPC_dup2_x2 = 94, 238 | JVM_OPC_swap = 95, 239 | JVM_OPC_iadd = 96, 240 | JVM_OPC_ladd = 97, 241 | JVM_OPC_fadd = 98, 242 | JVM_OPC_dadd = 99, 243 | JVM_OPC_isub = 100, 244 | JVM_OPC_lsub = 101, 245 | JVM_OPC_fsub = 102, 246 | JVM_OPC_dsub = 103, 247 | JVM_OPC_imul = 104, 248 | JVM_OPC_lmul = 105, 249 | JVM_OPC_fmul = 106, 250 | JVM_OPC_dmul = 107, 251 | JVM_OPC_idiv = 108, 252 | JVM_OPC_ldiv = 109, 253 | JVM_OPC_fdiv = 110, 254 | JVM_OPC_ddiv = 111, 255 | JVM_OPC_irem = 112, 256 | JVM_OPC_lrem = 113, 257 | JVM_OPC_frem = 114, 258 | JVM_OPC_drem = 115, 259 | JVM_OPC_ineg = 116, 260 | JVM_OPC_lneg = 117, 261 | JVM_OPC_fneg = 118, 262 | JVM_OPC_dneg = 119, 263 | JVM_OPC_ishl = 120, 264 | JVM_OPC_lshl = 121, 265 | JVM_OPC_ishr = 122, 266 | JVM_OPC_lshr = 123, 267 | JVM_OPC_iushr = 124, 268 | JVM_OPC_lushr = 125, 269 | JVM_OPC_iand = 126, 270 | JVM_OPC_land = 127, 271 | JVM_OPC_ior = 128, 272 | JVM_OPC_lor = 129, 273 | JVM_OPC_ixor = 130, 274 | JVM_OPC_lxor = 131, 275 | JVM_OPC_iinc = 132, 276 | JVM_OPC_i2l = 133, 277 | JVM_OPC_i2f = 134, 278 | JVM_OPC_i2d = 135, 279 | JVM_OPC_l2i = 136, 280 | JVM_OPC_l2f = 137, 281 | JVM_OPC_l2d = 138, 282 | JVM_OPC_f2i = 139, 283 | JVM_OPC_f2l = 140, 284 | JVM_OPC_f2d = 141, 285 | JVM_OPC_d2i = 142, 286 | JVM_OPC_d2l = 143, 287 | JVM_OPC_d2f = 144, 288 | JVM_OPC_i2b = 145, 289 | JVM_OPC_i2c = 146, 290 | JVM_OPC_i2s = 147, 291 | JVM_OPC_lcmp = 148, 292 | JVM_OPC_fcmpl = 149, 293 | JVM_OPC_fcmpg = 150, 294 | JVM_OPC_dcmpl = 151, 295 | JVM_OPC_dcmpg = 152, 296 | JVM_OPC_ifeq = 153, 297 | JVM_OPC_ifne = 154, 298 | JVM_OPC_iflt = 155, 299 | JVM_OPC_ifge = 156, 300 | JVM_OPC_ifgt = 157, 301 | JVM_OPC_ifle = 158, 302 | JVM_OPC_if_icmpeq = 159, 303 | JVM_OPC_if_icmpne = 160, 304 | JVM_OPC_if_icmplt = 161, 305 | JVM_OPC_if_icmpge = 162, 306 | JVM_OPC_if_icmpgt = 163, 307 | JVM_OPC_if_icmple = 164, 308 | JVM_OPC_if_acmpeq = 165, 309 | JVM_OPC_if_acmpne = 166, 310 | JVM_OPC_goto = 167, 311 | JVM_OPC_jsr = 168, 312 | JVM_OPC_ret = 169, 313 | JVM_OPC_tableswitch = 170, 314 | JVM_OPC_lookupswitch = 171, 315 | JVM_OPC_ireturn = 172, 316 | JVM_OPC_lreturn = 173, 317 | JVM_OPC_freturn = 174, 318 | JVM_OPC_dreturn = 175, 319 | JVM_OPC_areturn = 176, 320 | JVM_OPC_return = 177, 321 | JVM_OPC_getstatic = 178, 322 | JVM_OPC_putstatic = 179, 323 | JVM_OPC_getfield = 180, 324 | JVM_OPC_putfield = 181, 325 | JVM_OPC_invokevirtual = 182, 326 | JVM_OPC_invokespecial = 183, 327 | JVM_OPC_invokestatic = 184, 328 | JVM_OPC_invokeinterface = 185, 329 | JVM_OPC_invokedynamic = 186, 330 | JVM_OPC_new = 187, 331 | JVM_OPC_newarray = 188, 332 | JVM_OPC_anewarray = 189, 333 | JVM_OPC_arraylength = 190, 334 | JVM_OPC_athrow = 191, 335 | JVM_OPC_checkcast = 192, 336 | JVM_OPC_instanceof = 193, 337 | JVM_OPC_monitorenter = 194, 338 | JVM_OPC_monitorexit = 195, 339 | JVM_OPC_wide = 196, 340 | JVM_OPC_multianewarray = 197, 341 | JVM_OPC_ifnull = 198, 342 | JVM_OPC_ifnonnull = 199, 343 | JVM_OPC_goto_w = 200, 344 | JVM_OPC_jsr_w = 201, 345 | JVM_OPC_MAX = 201 346 | }; 347 | 348 | /* Opcode length initializer, use with something like: 349 | * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER; 350 | */ 351 | #define JVM_OPCODE_LENGTH_INITIALIZER { \ 352 | 1, /* nop */ \ 353 | 1, /* aconst_null */ \ 354 | 1, /* iconst_m1 */ \ 355 | 1, /* iconst_0 */ \ 356 | 1, /* iconst_1 */ \ 357 | 1, /* iconst_2 */ \ 358 | 1, /* iconst_3 */ \ 359 | 1, /* iconst_4 */ \ 360 | 1, /* iconst_5 */ \ 361 | 1, /* lconst_0 */ \ 362 | 1, /* lconst_1 */ \ 363 | 1, /* fconst_0 */ \ 364 | 1, /* fconst_1 */ \ 365 | 1, /* fconst_2 */ \ 366 | 1, /* dconst_0 */ \ 367 | 1, /* dconst_1 */ \ 368 | 2, /* bipush */ \ 369 | 3, /* sipush */ \ 370 | 2, /* ldc */ \ 371 | 3, /* ldc_w */ \ 372 | 3, /* ldc2_w */ \ 373 | 2, /* iload */ \ 374 | 2, /* lload */ \ 375 | 2, /* fload */ \ 376 | 2, /* dload */ \ 377 | 2, /* aload */ \ 378 | 1, /* iload_0 */ \ 379 | 1, /* iload_1 */ \ 380 | 1, /* iload_2 */ \ 381 | 1, /* iload_3 */ \ 382 | 1, /* lload_0 */ \ 383 | 1, /* lload_1 */ \ 384 | 1, /* lload_2 */ \ 385 | 1, /* lload_3 */ \ 386 | 1, /* fload_0 */ \ 387 | 1, /* fload_1 */ \ 388 | 1, /* fload_2 */ \ 389 | 1, /* fload_3 */ \ 390 | 1, /* dload_0 */ \ 391 | 1, /* dload_1 */ \ 392 | 1, /* dload_2 */ \ 393 | 1, /* dload_3 */ \ 394 | 1, /* aload_0 */ \ 395 | 1, /* aload_1 */ \ 396 | 1, /* aload_2 */ \ 397 | 1, /* aload_3 */ \ 398 | 1, /* iaload */ \ 399 | 1, /* laload */ \ 400 | 1, /* faload */ \ 401 | 1, /* daload */ \ 402 | 1, /* aaload */ \ 403 | 1, /* baload */ \ 404 | 1, /* caload */ \ 405 | 1, /* saload */ \ 406 | 2, /* istore */ \ 407 | 2, /* lstore */ \ 408 | 2, /* fstore */ \ 409 | 2, /* dstore */ \ 410 | 2, /* astore */ \ 411 | 1, /* istore_0 */ \ 412 | 1, /* istore_1 */ \ 413 | 1, /* istore_2 */ \ 414 | 1, /* istore_3 */ \ 415 | 1, /* lstore_0 */ \ 416 | 1, /* lstore_1 */ \ 417 | 1, /* lstore_2 */ \ 418 | 1, /* lstore_3 */ \ 419 | 1, /* fstore_0 */ \ 420 | 1, /* fstore_1 */ \ 421 | 1, /* fstore_2 */ \ 422 | 1, /* fstore_3 */ \ 423 | 1, /* dstore_0 */ \ 424 | 1, /* dstore_1 */ \ 425 | 1, /* dstore_2 */ \ 426 | 1, /* dstore_3 */ \ 427 | 1, /* astore_0 */ \ 428 | 1, /* astore_1 */ \ 429 | 1, /* astore_2 */ \ 430 | 1, /* astore_3 */ \ 431 | 1, /* iastore */ \ 432 | 1, /* lastore */ \ 433 | 1, /* fastore */ \ 434 | 1, /* dastore */ \ 435 | 1, /* aastore */ \ 436 | 1, /* bastore */ \ 437 | 1, /* castore */ \ 438 | 1, /* sastore */ \ 439 | 1, /* pop */ \ 440 | 1, /* pop2 */ \ 441 | 1, /* dup */ \ 442 | 1, /* dup_x1 */ \ 443 | 1, /* dup_x2 */ \ 444 | 1, /* dup2 */ \ 445 | 1, /* dup2_x1 */ \ 446 | 1, /* dup2_x2 */ \ 447 | 1, /* swap */ \ 448 | 1, /* iadd */ \ 449 | 1, /* ladd */ \ 450 | 1, /* fadd */ \ 451 | 1, /* dadd */ \ 452 | 1, /* isub */ \ 453 | 1, /* lsub */ \ 454 | 1, /* fsub */ \ 455 | 1, /* dsub */ \ 456 | 1, /* imul */ \ 457 | 1, /* lmul */ \ 458 | 1, /* fmul */ \ 459 | 1, /* dmul */ \ 460 | 1, /* idiv */ \ 461 | 1, /* ldiv */ \ 462 | 1, /* fdiv */ \ 463 | 1, /* ddiv */ \ 464 | 1, /* irem */ \ 465 | 1, /* lrem */ \ 466 | 1, /* frem */ \ 467 | 1, /* drem */ \ 468 | 1, /* ineg */ \ 469 | 1, /* lneg */ \ 470 | 1, /* fneg */ \ 471 | 1, /* dneg */ \ 472 | 1, /* ishl */ \ 473 | 1, /* lshl */ \ 474 | 1, /* ishr */ \ 475 | 1, /* lshr */ \ 476 | 1, /* iushr */ \ 477 | 1, /* lushr */ \ 478 | 1, /* iand */ \ 479 | 1, /* land */ \ 480 | 1, /* ior */ \ 481 | 1, /* lor */ \ 482 | 1, /* ixor */ \ 483 | 1, /* lxor */ \ 484 | 3, /* iinc */ \ 485 | 1, /* i2l */ \ 486 | 1, /* i2f */ \ 487 | 1, /* i2d */ \ 488 | 1, /* l2i */ \ 489 | 1, /* l2f */ \ 490 | 1, /* l2d */ \ 491 | 1, /* f2i */ \ 492 | 1, /* f2l */ \ 493 | 1, /* f2d */ \ 494 | 1, /* d2i */ \ 495 | 1, /* d2l */ \ 496 | 1, /* d2f */ \ 497 | 1, /* i2b */ \ 498 | 1, /* i2c */ \ 499 | 1, /* i2s */ \ 500 | 1, /* lcmp */ \ 501 | 1, /* fcmpl */ \ 502 | 1, /* fcmpg */ \ 503 | 1, /* dcmpl */ \ 504 | 1, /* dcmpg */ \ 505 | 3, /* ifeq */ \ 506 | 3, /* ifne */ \ 507 | 3, /* iflt */ \ 508 | 3, /* ifge */ \ 509 | 3, /* ifgt */ \ 510 | 3, /* ifle */ \ 511 | 3, /* if_icmpeq */ \ 512 | 3, /* if_icmpne */ \ 513 | 3, /* if_icmplt */ \ 514 | 3, /* if_icmpge */ \ 515 | 3, /* if_icmpgt */ \ 516 | 3, /* if_icmple */ \ 517 | 3, /* if_acmpeq */ \ 518 | 3, /* if_acmpne */ \ 519 | 3, /* goto */ \ 520 | 3, /* jsr */ \ 521 | 2, /* ret */ \ 522 | 99, /* tableswitch */ \ 523 | 99, /* lookupswitch */ \ 524 | 1, /* ireturn */ \ 525 | 1, /* lreturn */ \ 526 | 1, /* freturn */ \ 527 | 1, /* dreturn */ \ 528 | 1, /* areturn */ \ 529 | 1, /* return */ \ 530 | 3, /* getstatic */ \ 531 | 3, /* putstatic */ \ 532 | 3, /* getfield */ \ 533 | 3, /* putfield */ \ 534 | 3, /* invokevirtual */ \ 535 | 3, /* invokespecial */ \ 536 | 3, /* invokestatic */ \ 537 | 5, /* invokeinterface */ \ 538 | 5, /* invokedynamic */ \ 539 | 3, /* new */ \ 540 | 2, /* newarray */ \ 541 | 3, /* anewarray */ \ 542 | 1, /* arraylength */ \ 543 | 1, /* athrow */ \ 544 | 3, /* checkcast */ \ 545 | 3, /* instanceof */ \ 546 | 1, /* monitorenter */ \ 547 | 1, /* monitorexit */ \ 548 | 0, /* wide */ \ 549 | 4, /* multianewarray */ \ 550 | 3, /* ifnull */ \ 551 | 3, /* ifnonnull */ \ 552 | 5, /* goto_w */ \ 553 | 5 /* jsr_w */ \ 554 | } 555 | 556 | #ifdef __cplusplus 557 | } /* extern "C" */ 558 | #endif /* __cplusplus */ 559 | 560 | #endif /* CLASSFILE_CONSTANTS */ 561 | --------------------------------------------------------------------------------