Compare commits

...

10 Commits

Author SHA1 Message Date
strawmanbobi
ce1c8e8fc8 Merge branch 'master' of https://opensource.irext.net/irext/core 2026-02-02 11:15:50 +08:00
77943c1d9c typo fix 2026-02-02 03:10:43 +00:00
strawmanbobi
5f8200f4dc enabled debug 2026-01-27 19:54:38 +08:00
strawmanbobi
225b30018a corrected memory leak issue and added some boundary check 2026-01-13 16:31:37 +08:00
strawmanbobi
2cad5e71a2 added change wind dir debug 2026-01-13 09:18:16 +08:00
strawmanbobi
16855d26a3 code format tweak 2026-01-11 19:20:45 +08:00
strawmanbobi
0eb3005976 set default cross-compile to x86_64 2026-01-06 21:22:56 +08:00
strawmanbobi
3f720f0e6c fixed Android.mk 2026-01-06 21:16:46 +08:00
strawmanbobi
4f250d97ab adjusted jni source structure 2026-01-06 21:11:13 +08:00
strawmanbobi
0c1353bd39 updated decode lib version 2026-01-06 12:24:48 +08:00
28 changed files with 76 additions and 68 deletions

View File

@@ -2,7 +2,7 @@
This project contains IRext core encode algorithm and decode algorithm.
### Summary
### Overview
IR code is base on 38000Hz or 56000Hz carrier waves, it is identified by the time interval of carrier waves.
@@ -28,7 +28,7 @@ Following are some specifications:
- Command code: The receiver receives IR code as commands from emitter, and then adjusts status of itself, eg. control code of TV, DVD.
- Status code: The receiver receives IR code as status, and applies itself to this status, eg. control code of air conditioner.
### Encoder
### The IR Encoder
The encoder composes compressed remote control IR binaries from plain text in XML format. Different kind of remote control code are differently composed.
@@ -40,7 +40,7 @@ __Status code__
Status code is defined by various kinds of tags, indication each essential part in one status control frame. It is especially used for air conditioners.
### Decoder
### The IR Decoder
The decoder decodes IR remote control binaries into IR control frame which is composed by time series illustrated above.

View File

@@ -2,14 +2,13 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libirdecode
LOCAL_MODULE := libirdecode
LOCAL_CFLAGS := -DBOARD_ANDROID
LOCAL_CFLAGS := -DBOARD_ANDROID
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/jni/include \
$(LOCAL_PATH)/src/include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/include
LOCAL_SRC_FILES := ./src/jni/src/ir_decode_jni.c \
LOCAL_SRC_FILES := ./src/ir_decode_jni.c \
./src/ir_decode.c \
./src/ir_tv_control.c \
./src/ir_ac_apply.c \
@@ -19,7 +18,7 @@ LOCAL_SRC_FILES := ./src/jni/src/ir_decode_jni.c \
./src/ir_ac_parse_frame_info.c \
./src/ir_ac_binary_parse.c \
./src/ir_ac_control.c \
./src/ir_utils.c \
./src/ir_utils.c
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog

View File

@@ -31,16 +31,19 @@ set(LIB_IRDECODE_SRC
src/ir_decode.c
src/ir_decode_test.c)
set(LIB_JNI_SRC
src/ir_decode_jni.c)
set(BIN_TEST_SRC
src/ir_decode.c)
# SET(CMAKE_SYSTEM_NAME Linux)
## ARMv7hf cross compile
# SET(CMAKE_C_COMPILER "/usr/bin/arm-linux-gnueabihf-gcc")
# SET(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabihf-g++")
# SET(CMAKE_FIND_ROOT_PATH "/usr/bin")
# SET(CMAKE_SYSTEM_NAME Linux)
## ARMv7el cross compile
# SET(CMAKE_C_COMPILER "/usr/bin/arm-linux-gnueabi-gcc")
# SET(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabi-g++")
@@ -60,16 +63,26 @@ target_compile_options(irdecode PRIVATE
add_library(irdecode_s STATIC
${LIB_IRDECODE_SRC})
target_compile_options(irdecode_s PRIVATE
target_compile_definitions(irdecode_s PRIVATE
-DBOARD_PC)
target_compile_options(irdecode_s PRIVATE
-fPIC)
add_library(irdecode_jni SHARED
${LIB_IRDECODE_SRC}
${LIB_JNI_SRC})
target_include_directories(irdecode_jni PRIVATE
"${CMAKE_SOURCE_DIR}/src/jni")
target_compile_definitions(irdecode_jni PRIVATE
-DBOARD_PC
-DBOARD_PC_JNI)
add_executable(irdecode_test
${LIB_IRDECODE_SRC}
${BIN_TEST_SRC})
target_link_libraries(irdecode_test PRIVATE
irdecode)
add_subdirectory("src/jni")
target_compile_definitions(irdecode_test PRIVATE
-DBOARD_PC)

View File

@@ -2,7 +2,7 @@
#if defined BOARD_ANDROID
#include <jni.h>
#elif (defined BOARD_PC) && (defined BOARD_PC_JNI)
#include "./include/jni.h"
#include "include/jni.h"
#endif
/* Header for class net_irext_decode_sdk_IRDecode */

View File

@@ -12,7 +12,9 @@ Revision log:
#ifndef _IR_DEFS_H
#define _IR_DEFS_H
#define IR_DECODE_LIB_VER "1.5.1"
#define IR_DECODE_LIB_VER "1.5.2"
#define DEBUG (1)
#if defined (BOARD_PC)
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
@@ -62,7 +64,7 @@ void noprint(const char *fmt, ...);
#else
#define ir_printf noprint
#endif
#define USER_DATA_SIZE 1636
#define USER_DATA_SIZE 2048
// #define USER_DATA_SIZE 4096
#ifdef __cplusplus

View File

@@ -791,6 +791,13 @@ UINT16 ir_decode_combo(const UINT8 category, const UINT8 sub_category,
return IR_DECODE_FAILED;
}
if (sub_category < SUB_CATEGORY_QUATERNARY ||
sub_category >= SUB_CATEGORY_NEXT)
{
ir_printf("wrong remote sub category : %d\n", sub_category);
return IR_DECODE_FAILED;
}
remote_category = (t_remote_category) category;
if (key_code < 0 || key_code >= KEY_CODE_MAX[remote_category])

View File

@@ -69,6 +69,7 @@ static INT8 decode_as_ac(char *file_name)
int first_time = 1;
int length = 0;
int index = 0;
INT8 ret_val = IR_DECODE_SUCCEEDED;
// get status
UINT8 supported_mode = 0x00;
@@ -101,8 +102,8 @@ static INT8 decode_as_ac(char *file_name)
if (IR_DECODE_FAILED == ir_file_open(REMOTE_CATEGORY_AC, 0, file_name))
{
ir_close();
return IR_DECODE_FAILED;
ret_val = IR_DECODE_FAILED;
goto _exit;
}
do
@@ -215,7 +216,6 @@ static INT8 decode_as_ac(char *file_name)
case 11:
if (ac_status->ac_wind_dir == AC_SWING_OFF) {
ac_status->change_wind_direction = 1;
}
need_control = TRUE;
break;
@@ -227,12 +227,14 @@ static INT8 decode_as_ac(char *file_name)
if (TRUE == op_match && TRUE == need_control)
{
printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d with key_code = %d\n",
printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d, change_wind_dir = %d,"
" with key_code = %d\n",
ac_status->ac_power,
ac_status->ac_mode,
ac_status->ac_temp,
ac_status->ac_wind_speed,
ac_status->ac_wind_dir,
ac_status->change_wind_direction,
key_code);
length = ir_decode(key_code, user_data, ac_status);
printf("\n === binary decoded : %d\n", length);
@@ -245,9 +247,14 @@ static INT8 decode_as_ac(char *file_name)
}
} while (TRUE);
_exit:
ir_close();
return IR_DECODE_SUCCEEDED;
if (NULL != ac_status) {
free(ac_status);
}
return ret_val;
}
static INT8 decode_as_tv(char *file_name, UINT8 ir_hex_encode)

View File

@@ -249,8 +249,16 @@ static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time)
}
else if (ir_level == IRDA_LEVEL_LOW)
{
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->mask;
}
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->space;
ir_level = IRDA_LEVEL_LOW;
}
@@ -263,8 +271,16 @@ static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time)
}
else if (ir_level == IRDA_LEVEL_HIGH)
{
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->space;
}
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->mask;
ir_level = IRDA_LEVEL_HIGH;
}
@@ -278,6 +294,10 @@ static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time)
}
else if (ir_level == IRDA_LEVEL_HIGH)
{
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->space;
}
ir_level = IRDA_LEVEL_LOW;
@@ -291,6 +311,10 @@ static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time)
}
else if (ir_level == IRDA_LEVEL_LOW)
{
if (time_index + 1 > USER_DATA_SIZE) {
ir_printf("time index exceeded\n");
return;
}
ir_time[time_index++] = pcycles->mask;
}
ir_level = IRDA_LEVEL_HIGH;

View File

@@ -1,33 +0,0 @@
cmake_minimum_required(VERSION 3.10)
########################################################
project(ir_decode_jni)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE("compile platform : Linux")
add_definitions(-DPLATFORM_LINUX)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
MESSAGE("compile platform : win32")
add_definitions(-DPLATFORM_WIN32)
ELSE ()
MESSAGE("invalid compile platform")
add_definitions(-DPLATFORM_WIN32)
ENDIF ()
include_directories(
"${CMAKE_SOURCE_DIR}/src/include"
"src/include")
set(LIB_IRDECODE_JNI_SRC
src/ir_decode_jni.c)
add_library(irdecode_jni SHARED
${LIB_IRDECODE_JNI_SRC})
target_compile_definitions(irdecode_jni PRIVATE
-DBOARD_PC
-DBOARD_PC_JNI)
target_link_libraries(irdecode_jni PRIVATE
irdecode_s)

View File

@@ -51,6 +51,7 @@ public class IRDecode {
System.out.println("loading decode library " + libPath);
System.load(libPath);
}
public String getVersion() {
return irGetVersion();
}

View File

@@ -1,4 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)

View File

@@ -1,4 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

View File

@@ -1,4 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7el)
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)