updated decoder jni component
This commit is contained in:
@@ -4,15 +4,17 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_CFLAGS := -DBOARD_ANDROID
|
LOCAL_CFLAGS := -DBOARD_ANDROID
|
||||||
LOCAL_MODULE := libirdecode
|
LOCAL_MODULE := libirdecode
|
||||||
LOCAL_SRC_FILES := irda_decode_jni.c \
|
LOCAL_SRC_FILES := ./jni/ir_decode_jni.c \
|
||||||
irda_decode.c \
|
./src/ir_decode.c \
|
||||||
irda_tv_parse_protocol.c \
|
./src/ir_tv_control.c \
|
||||||
irda_ac_apply.c \
|
./src/ir_ac_apply.c \
|
||||||
irda_ac_build_frame.c \
|
./src/ir_ac_build_frame.c \
|
||||||
irda_ac_parse_parameter.c \
|
./src/ir_ac_parse_parameter.c \
|
||||||
irda_ac_parse_forbidden_info.c \
|
./src/ir_ac_parse_forbidden_info.c \
|
||||||
irda_ac_parse_frame_parameter.c \
|
./src/ir_ac_parse_frame_info.c \
|
||||||
irda_utils.c \
|
./src/ir_ac_binary_parse.c \
|
||||||
|
./src/ir_ac_control.c \
|
||||||
|
./src/ir_utils.c \
|
||||||
|
|
||||||
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
|
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ extern "C"
|
|||||||
|
|
||||||
#include "ir_defs.h"
|
#include "ir_defs.h"
|
||||||
|
|
||||||
extern INT8 irda_ac_lib_parse();
|
extern INT8 ir_ac_lib_parse();
|
||||||
|
|
||||||
extern INT8 free_ac_context();
|
extern INT8 free_ac_context();
|
||||||
|
|
||||||
|
|||||||
@@ -431,42 +431,40 @@ typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 funct
|
|||||||
extern UINT8* ir_hex_code;
|
extern UINT8* ir_hex_code;
|
||||||
extern UINT8 ir_hex_len;
|
extern UINT8 ir_hex_len;
|
||||||
extern protocol* context;
|
extern protocol* context;
|
||||||
extern remote_ac_status_t ac_status;
|
|
||||||
extern UINT16 user_data[];
|
|
||||||
|
|
||||||
|
|
||||||
/* exported functions */
|
/* exported functions */
|
||||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
||||||
/*
|
/*
|
||||||
* function irda_ac_file_open
|
* function ir_ac_file_open
|
||||||
*
|
*
|
||||||
* parameters: file name of remote binary
|
* parameters: file name of remote binary
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 irda_ac_file_open(const char* file_name);
|
extern INT8 ir_ac_file_open(const char *file_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_ac_lib_open
|
* function ir_ac_lib_open
|
||||||
*
|
*
|
||||||
* parameters: binary (in) binary content
|
* parameters: binary (in) binary content
|
||||||
* binary_length (in) length of binary content
|
* binary_length (in) length of binary content
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length);
|
extern INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_ac_lib_parse
|
* function ir_ac_lib_parse
|
||||||
*
|
*
|
||||||
* parameters:
|
* parameters:
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 irda_ac_lib_parse();
|
extern INT8 ir_ac_lib_parse();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_ac_lib_control
|
* function ir_ac_lib_control
|
||||||
*
|
*
|
||||||
* parameters: ac_status (in) indicates the current status of air conditioner to be controlled
|
* parameters: ac_status (in) indicates the current status of air conditioner to be controlled
|
||||||
* user_data (out) wave code array to be transmitted
|
* user_data (out) wave code array to be transmitted
|
||||||
@@ -475,66 +473,66 @@ extern INT8 irda_ac_lib_parse();
|
|||||||
*
|
*
|
||||||
* return: length of wave code array
|
* return: length of wave code array
|
||||||
*/
|
*/
|
||||||
extern UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
extern UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
||||||
BOOL change_wind_direction);
|
BOOL change_wind_direction);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_ac_lib_close
|
* function ir_ac_lib_close
|
||||||
*
|
*
|
||||||
* parameters:
|
* parameters:
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern void irda_ac_lib_close();
|
extern void ir_ac_lib_close();
|
||||||
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
|
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
||||||
/*
|
/*
|
||||||
* function irda_tv_file_open
|
* function ir_tv_file_open
|
||||||
*
|
*
|
||||||
* parameters: file name of remote binary
|
* parameters: file name of remote binary
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
INT8 irda_tv_file_open(const char* file_name);
|
INT8 ir_tv_file_open(const char *file_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_tv_lib_open
|
* function ir_tv_lib_open
|
||||||
*
|
*
|
||||||
* parameters: binary (in) binary content
|
* parameters: binary (in) binary content
|
||||||
* binary_length (in) length of binary content
|
* binary_length (in) length of binary content
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length);
|
INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_tv_lib_parse
|
* function ir_tv_lib_parse
|
||||||
*
|
*
|
||||||
* parameters:
|
* parameters:
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 irda_tv_lib_parse(UINT8 irda_hex_encode);
|
extern INT8 ir_tv_lib_parse(UINT8 irda_hex_encode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_tv_lib_control
|
* function ir_tv_lib_control
|
||||||
*
|
*
|
||||||
* parameters: key_code (in) indicates the number of pressed key
|
* parameters: key_code (in) indicates the number of pressed key
|
||||||
* user_data (out) wave code array to be transmitted
|
* user_data (out) wave code array to be transmitted
|
||||||
*
|
*
|
||||||
* return: length of wave code array
|
* return: length of wave code array
|
||||||
*/
|
*/
|
||||||
extern UINT16 irda_tv_lib_control(UINT8 key_code, UINT16* user_data);
|
extern UINT16 ir_tv_lib_control(UINT8 key_code, UINT16 *user_data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function irda_tv_lib_close
|
* function ir_tv_lib_close
|
||||||
*
|
*
|
||||||
* parameters:
|
* parameters:
|
||||||
*
|
*
|
||||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||||
*/
|
*/
|
||||||
extern INT8 irda_tv_lib_close();
|
extern INT8 ir_tv_lib_close();
|
||||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
|
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
|
||||||
|
|||||||
1
src/ir_decoder/jni/Readme.md
Normal file
1
src/ir_decoder/jni/Readme.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ndk-build NDK_PROJECT_PATH=./ NDK_APPLICATION_MK=./Application.mk
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**************************************************************************************************
|
/**************************************************************************************************
|
||||||
Filename: irda_decode_jni.c
|
Filename: ir_decode_jni.c
|
||||||
Revised: Date: 2016-03-21
|
Revised: Date: 2016-03-21
|
||||||
Revision: Revision: 1.0
|
Revision: Revision: 1.0
|
||||||
|
|
||||||
@@ -12,97 +12,28 @@ Revision log:
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "../include/irda_decode_jni.h"
|
#include "ir_decode_jni.h"
|
||||||
#include "../include/irda_defs.h"
|
#include "../include/ir_defs.h"
|
||||||
#include "../include/irda_decode.h"
|
#include "../include/ir_decode.h"
|
||||||
|
|
||||||
// global variable definition
|
// global variable definition
|
||||||
UINT16 binary_length = 0;
|
extern size_t binary_length;
|
||||||
UINT8 *binary_content = NULL;
|
extern UINT8 *binary_content;
|
||||||
|
|
||||||
INT8 irda_ac_file_open(const char* file_name)
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACLibOpen
|
||||||
{
|
|
||||||
FILE *stream = fopen(file_name, "rb");
|
|
||||||
if (NULL == stream)
|
|
||||||
{
|
|
||||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(stream, 0, SEEK_END);
|
|
||||||
binary_length = ftell(stream);
|
|
||||||
binary_content = (UINT8*) irda_malloc(binary_length);
|
|
||||||
|
|
||||||
if (NULL == binary_content)
|
|
||||||
{
|
|
||||||
IR_PRINTF("\nfailed to alloc memory for binary\n");
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(stream, 0, SEEK_SET);
|
|
||||||
fread(binary_content, binary_length, 1, stream);
|
|
||||||
fclose(stream);
|
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_ac_lib_open(binary_content, binary_length))
|
|
||||||
{
|
|
||||||
irda_free(binary_content);
|
|
||||||
binary_length = 0;
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT8 irda_tv_file_open(const char* file_name)
|
|
||||||
{
|
|
||||||
int print_index = 0;
|
|
||||||
FILE *stream = fopen(file_name, "rb");
|
|
||||||
|
|
||||||
IR_PRINTF("file name = %s\n", file_name);
|
|
||||||
|
|
||||||
if (stream == NULL)
|
|
||||||
{
|
|
||||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(stream, 0, SEEK_END);
|
|
||||||
binary_length = ftell(stream);
|
|
||||||
IR_PRINTF("length of binary = %d\n", binary_length);
|
|
||||||
|
|
||||||
binary_content = (UINT8*) irda_malloc(binary_length);
|
|
||||||
|
|
||||||
fseek(stream, 0, SEEK_SET);
|
|
||||||
fread(binary_content, binary_length, 1, stream);
|
|
||||||
fclose(stream);
|
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_lib_open(binary_content, binary_length))
|
|
||||||
{
|
|
||||||
irda_free(binary_content);
|
|
||||||
binary_length = 0;
|
|
||||||
return IR_DECODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibOpen
|
|
||||||
(JNIEnv *env, jobject this_obj, jstring file_name)
|
(JNIEnv *env, jobject this_obj, jstring file_name)
|
||||||
{
|
{
|
||||||
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
||||||
if (IR_DECODE_FAILED == irda_ac_file_open(n_file_name))
|
if (IR_DECODE_FAILED == ir_ac_file_open(n_file_name))
|
||||||
{
|
{
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to verify return value
|
if (IR_DECODE_FAILED == ir_ac_lib_parse())
|
||||||
irda_context_init();
|
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_ac_lib_parse())
|
|
||||||
{
|
{
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
@@ -111,11 +42,13 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibOpen
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaACControl
|
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irACControl
|
||||||
(JNIEnv *env, jobject this_obj, jobject jni_ac_status, jint function_code, jint change_wind_direction)
|
(JNIEnv *env, jobject this_obj, jobject jni_ac_status, jint function_code, jint change_wind_direction)
|
||||||
{
|
{
|
||||||
|
UINT16 user_data[USER_DATA_SIZE];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int copy_array[USER_DATA_SIZE] = {0};
|
int copy_array[USER_DATA_SIZE] = {0};
|
||||||
|
remote_ac_status_t ac_status;
|
||||||
|
|
||||||
jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status);
|
jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status);
|
||||||
jfieldID ac_power_fid = (*env)->GetFieldID(env, n_ac_status, "acPower", "I");
|
jfieldID ac_power_fid = (*env)->GetFieldID(env, n_ac_status, "acPower", "I");
|
||||||
@@ -150,7 +83,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaACCo
|
|||||||
ac_status.acWindDir = i_ac_wind_dir;
|
ac_status.acWindDir = i_ac_wind_dir;
|
||||||
ac_status.acWindSpeed = i_ac_wind_speed;
|
ac_status.acWindSpeed = i_ac_wind_speed;
|
||||||
|
|
||||||
int wave_code_length = irda_ac_lib_control(ac_status, user_data, function_code, change_wind_direction);
|
int wave_code_length = ir_ac_lib_control(ac_status, user_data, function_code, change_wind_direction);
|
||||||
|
|
||||||
IR_PRINTF("\nsize of wave code = %d\n", wave_code_length);
|
IR_PRINTF("\nsize of wave code = %d\n", wave_code_length);
|
||||||
|
|
||||||
@@ -166,18 +99,18 @@ JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaACCo
|
|||||||
(*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array);
|
(*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array);
|
||||||
|
|
||||||
// temporary solution, close ac lib here in order to release memory
|
// temporary solution, close ac lib here in order to release memory
|
||||||
// irda_ac_lib_close();
|
// ir_ac_lib_close();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibClose
|
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irACLibClose
|
||||||
(JNIEnv *env, jobject this_obj)
|
(JNIEnv *env, jobject this_obj)
|
||||||
{
|
{
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetTemperatureRange
|
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_irACGetTemperatureRange
|
||||||
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
||||||
{
|
{
|
||||||
int tempMin = 0;
|
int tempMin = 0;
|
||||||
@@ -199,7 +132,7 @@ JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetT
|
|||||||
return temperature_range;
|
return temperature_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedMode
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedMode
|
||||||
(JNIEnv *env, jobject this_obj)
|
(JNIEnv *env, jobject this_obj)
|
||||||
{
|
{
|
||||||
int supported_mode = 0;
|
int supported_mode = 0;
|
||||||
@@ -207,7 +140,7 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupp
|
|||||||
return supported_mode;
|
return supported_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedWindSpeed
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedWindSpeed
|
||||||
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
||||||
{
|
{
|
||||||
int supported_wind_speed = 0;
|
int supported_wind_speed = 0;
|
||||||
@@ -215,7 +148,7 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupp
|
|||||||
return supported_wind_speed;
|
return supported_wind_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedSwing
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedSwing
|
||||||
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
||||||
{
|
{
|
||||||
int supported_swing = 0;
|
int supported_swing = 0;
|
||||||
@@ -223,7 +156,7 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupp
|
|||||||
return supported_swing;
|
return supported_swing;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedWindDirection
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedWindDirection
|
||||||
(JNIEnv *env, jobject this_obj)
|
(JNIEnv *env, jobject this_obj)
|
||||||
{
|
{
|
||||||
int supported_wind_direction = 0;
|
int supported_wind_direction = 0;
|
||||||
@@ -231,18 +164,18 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupp
|
|||||||
return supported_wind_direction;
|
return supported_wind_direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibOpen
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irTVLibOpen
|
||||||
(JNIEnv *env, jobject this_obj, jstring file_name, jint j_irda_hex_encode)
|
(JNIEnv *env, jobject this_obj, jstring file_name, jint j_ir_hex_encode)
|
||||||
{
|
{
|
||||||
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_file_open(n_file_name))
|
if (IR_DECODE_FAILED == ir_tv_file_open(n_file_name))
|
||||||
{
|
{
|
||||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_lib_parse(j_irda_hex_encode))
|
if (IR_DECODE_FAILED == ir_tv_lib_parse(j_ir_hex_encode))
|
||||||
{
|
{
|
||||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
@@ -252,12 +185,13 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibOpen
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaTVControl
|
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irTVControl
|
||||||
(JNIEnv *env, jobject this_obj, jint key_number)
|
(JNIEnv *env, jobject this_obj, jint key_number)
|
||||||
{
|
{
|
||||||
|
UINT16 user_data[USER_DATA_SIZE];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int copy_array[USER_DATA_SIZE] = {0};
|
int copy_array[USER_DATA_SIZE] = {0};
|
||||||
int wave_code_length = irda_tv_lib_control(key_number, user_data);
|
int wave_code_length = ir_tv_lib_control(key_number, user_data);
|
||||||
|
|
||||||
IR_PRINTF("\nsize of wave code = %d\n", wave_code_length);
|
IR_PRINTF("\nsize of wave code = %d\n", wave_code_length);
|
||||||
|
|
||||||
@@ -275,7 +209,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaTVCo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibClose
|
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irTVLibClose
|
||||||
(JNIEnv *env, jobject this_obj)
|
(JNIEnv *env, jobject this_obj)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
@@ -57,90 +57,90 @@ extern "C" {
|
|||||||
#define net_irext_remote_service_DecodeService_START_STICKY_COMPATIBILITY 0L
|
#define net_irext_remote_service_DecodeService_START_STICKY_COMPATIBILITY 0L
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACLibOpen
|
* Method: irACLibOpen
|
||||||
* Signature: (Ljava/lang/String;)I
|
* Signature: (Ljava/lang/String;)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibOpen
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACLibOpen
|
||||||
(JNIEnv *, jobject, jstring);
|
(JNIEnv *, jobject, jstring);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACControl
|
* Method: irACControl
|
||||||
* Signature: (Lcom/irext/remote/bean/jnibean/JNIACStatus;II)[I
|
* Signature: (Lcom/irext/remote/bean/jnibean/JNIACStatus;II)[I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaACControl
|
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irACControl
|
||||||
(JNIEnv *, jobject, jobject, jint, jint);
|
(JNIEnv *, jobject, jobject, jint, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACLibClose
|
* Method: irACLibClose
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibClose
|
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irACLibClose
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACGetTemperatureRange
|
* Method: irACGetTemperatureRange
|
||||||
* Signature: (I)Lcom/irext/remote/bean/jnibean/JNITemperatureRange;
|
* Signature: (I)Lcom/irext/remote/bean/jnibean/JNITemperatureRange;
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetTemperatureRange
|
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_irACGetTemperatureRange
|
||||||
(JNIEnv *, jobject, jint);
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACGetSupportedMode
|
* Method: irACGetSupportedMode
|
||||||
* Signature: ()I
|
* Signature: ()I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedMode
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedMode
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACGetSupportedWindSpeed
|
* Method: irACGetSupportedWindSpeed
|
||||||
* Signature: (I)I
|
* Signature: (I)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedWindSpeed
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedWindSpeed
|
||||||
(JNIEnv *, jobject, jint);
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACGetSupportedSwing
|
* Method: irACGetSupportedSwing
|
||||||
* Signature: (I)I
|
* Signature: (I)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedSwing
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedSwing
|
||||||
(JNIEnv *, jobject, jint);
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaACGetSupportedWindDirection
|
* Method: irACGetSupportedWindDirection
|
||||||
* Signature: ()I
|
* Signature: ()I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACGetSupportedWindDirection
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irACGetSupportedWindDirection
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaTVLibOpen
|
* Method: irTVLibOpen
|
||||||
* Signature: (Ljava/lang/String;I)I
|
* Signature: (Ljava/lang/String;I)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibOpen
|
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irTVLibOpen
|
||||||
(JNIEnv *, jobject, jstring, jint);
|
(JNIEnv *, jobject, jstring, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaTVControl
|
* Method: irTVControl
|
||||||
* Signature: (I)[I
|
* Signature: (I)[I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaTVControl
|
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irTVControl
|
||||||
(JNIEnv *, jobject, jint);
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_remote_service_DecodeService
|
* Class: net_irext_remote_service_DecodeService
|
||||||
* Method: irdaTVLibClose
|
* Method: irTVLibClose
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibClose
|
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irTVLibClose
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -25,20 +25,20 @@ Revision log:
|
|||||||
extern struct tag_head *tags;
|
extern struct tag_head *tags;
|
||||||
extern INT tag_count;
|
extern INT tag_count;
|
||||||
|
|
||||||
static INT8 irda_context_init();
|
static INT8 ir_context_init();
|
||||||
|
|
||||||
|
|
||||||
static INT8 irda_context_init()
|
static INT8 ir_context_init()
|
||||||
{
|
{
|
||||||
irda_memset(context, 0, sizeof(protocol));
|
irda_memset(context, 0, sizeof(protocol));
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INT8 irda_ac_lib_parse() {
|
INT8 ir_ac_lib_parse() {
|
||||||
UINT8 i = 0;
|
UINT8 i = 0;
|
||||||
// suggest not to call init function here for de-couple purpose
|
// suggest not to call init function here for de-couple purpose
|
||||||
irda_context_init();
|
ir_context_init();
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == binary_parse_offset()) {
|
if (IR_DECODE_FAILED == binary_parse_offset()) {
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void irda_lib_free_inner_buffer();
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
||||||
INT8 irda_ac_file_open(const char* file_name)
|
INT8 ir_ac_file_open(const char *file_name)
|
||||||
{
|
{
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
#if !defined WIN32
|
#if !defined WIN32
|
||||||
@@ -107,7 +107,7 @@ INT8 irda_ac_file_open(const char* file_name)
|
|||||||
|
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_ac_lib_open(binary_content, (UINT16)binary_length))
|
if (IR_DECODE_FAILED == ir_ac_lib_open(binary_content, (UINT16) binary_length))
|
||||||
{
|
{
|
||||||
irda_free(binary_content);
|
irda_free(binary_content);
|
||||||
binary_length = 0;
|
binary_length = 0;
|
||||||
@@ -117,7 +117,7 @@ INT8 irda_ac_file_open(const char* file_name)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
// it is recommended that the parameter binary pointing to
|
// it is recommended that the parameter binary pointing to
|
||||||
// a global memory block in embedded platform environment
|
// a global memory block in embedded platform environment
|
||||||
@@ -127,8 +127,8 @@ INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code,
|
||||||
BOOL change_wind_direction)
|
BOOL change_wind_direction)
|
||||||
{
|
{
|
||||||
UINT16 time_length = 0;
|
UINT16 time_length = 0;
|
||||||
UINT8 i = 0;
|
UINT8 i = 0;
|
||||||
@@ -236,7 +236,7 @@ UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT
|
|||||||
return time_length;
|
return time_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void irda_ac_lib_close()
|
void ir_ac_lib_close()
|
||||||
{
|
{
|
||||||
// free context
|
// free context
|
||||||
if (NULL != tags)
|
if (NULL != tags)
|
||||||
@@ -394,7 +394,7 @@ INT8 get_supported_wind_direction(UINT8* supported_wind_direction)
|
|||||||
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
|
///////////////////////////////////////////////// AC End //////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
||||||
INT8 irda_tv_file_open(const char* file_name)
|
INT8 ir_tv_file_open(const char *file_name)
|
||||||
{
|
{
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ INT8 irda_tv_file_open(const char* file_name)
|
|||||||
|
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_lib_open(binary_content, (UINT16)binary_length))
|
if (IR_DECODE_FAILED == ir_tv_lib_open(binary_content, (UINT16) binary_length))
|
||||||
{
|
{
|
||||||
irda_free(binary_content);
|
irda_free(binary_content);
|
||||||
binary_length = 0;
|
binary_length = 0;
|
||||||
@@ -444,12 +444,12 @@ INT8 irda_tv_file_open(const char* file_name)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
INT8 ir_tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
return tv_lib_open(binary, binary_length);
|
return tv_lib_open(binary, binary_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 irda_tv_lib_parse(UINT8 irda_hex_encode)
|
INT8 ir_tv_lib_parse(UINT8 irda_hex_encode)
|
||||||
{
|
{
|
||||||
if (FALSE == tv_lib_parse(irda_hex_encode))
|
if (FALSE == tv_lib_parse(irda_hex_encode))
|
||||||
{
|
{
|
||||||
@@ -460,7 +460,7 @@ INT8 irda_tv_lib_parse(UINT8 irda_hex_encode)
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT16 irda_tv_lib_control(UINT8 key, UINT16* l_user_data)
|
UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data)
|
||||||
{
|
{
|
||||||
UINT16 print_index = 0;
|
UINT16 print_index = 0;
|
||||||
UINT16 irda_code_length = 0;
|
UINT16 irda_code_length = 0;
|
||||||
@@ -481,7 +481,7 @@ UINT16 irda_tv_lib_control(UINT8 key, UINT16* l_user_data)
|
|||||||
return irda_code_length;
|
return irda_code_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT8 irda_tv_lib_close()
|
INT8 ir_tv_lib_close()
|
||||||
{
|
{
|
||||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||||
irda_lib_free_inner_buffer();
|
irda_lib_free_inner_buffer();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ remote_ac_status_t ac_status;
|
|||||||
UINT16 user_data[USER_DATA_SIZE];
|
UINT16 user_data[USER_DATA_SIZE];
|
||||||
|
|
||||||
|
|
||||||
INT8 irda_tv_file_open(const char* file_name);
|
INT8 ir_tv_file_open(const char *file_name);
|
||||||
|
|
||||||
|
|
||||||
INT8 decode_as_ac(char* file_name)
|
INT8 decode_as_ac(char* file_name)
|
||||||
@@ -57,16 +57,16 @@ INT8 decode_as_ac(char* file_name)
|
|||||||
ac_status.acWindDir = AC_SWING_ON;
|
ac_status.acWindDir = AC_SWING_ON;
|
||||||
ac_status.acWindSpeed = AC_WS_AUTO;
|
ac_status.acWindSpeed = AC_WS_AUTO;
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_ac_file_open(file_name))
|
if (IR_DECODE_FAILED == ir_ac_file_open(file_name))
|
||||||
{
|
{
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_ac_lib_parse())
|
if (IR_DECODE_FAILED == ir_ac_lib_parse())
|
||||||
{
|
{
|
||||||
IR_PRINTF("\nac lib parse failed\n");
|
IR_PRINTF("\nac lib parse failed\n");
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
@@ -173,11 +173,11 @@ INT8 decode_as_ac(char* file_name)
|
|||||||
ac_status.acWindDir
|
ac_status.acWindDir
|
||||||
);
|
);
|
||||||
|
|
||||||
irda_ac_lib_control(ac_status, user_data, function_code, TRUE);
|
ir_ac_lib_control(ac_status, user_data, function_code, TRUE);
|
||||||
}
|
}
|
||||||
} while('0' != in_char);
|
} while('0' != in_char);
|
||||||
|
|
||||||
irda_ac_lib_close();
|
ir_ac_lib_close();
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
@@ -188,12 +188,12 @@ INT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
|||||||
int in_char = 0;
|
int in_char = 0;
|
||||||
int key_code = 0;
|
int key_code = 0;
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_file_open(file_name))
|
if (IR_DECODE_FAILED == ir_tv_file_open(file_name))
|
||||||
{
|
{
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IR_DECODE_FAILED == irda_tv_lib_parse(irda_hex_encode))
|
if (IR_DECODE_FAILED == ir_tv_lib_parse(irda_hex_encode))
|
||||||
{
|
{
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
@@ -203,16 +203,16 @@ INT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
|||||||
if (in_char >= '0' && in_char <= '9')
|
if (in_char >= '0' && in_char <= '9')
|
||||||
{
|
{
|
||||||
key_code = in_char - '0';
|
key_code = in_char - '0';
|
||||||
irda_tv_lib_control((UINT8)key_code, user_data);
|
ir_tv_lib_control((UINT8) key_code, user_data);
|
||||||
}
|
}
|
||||||
else if (in_char >= 'a' && in_char <= 'f')
|
else if (in_char >= 'a' && in_char <= 'f')
|
||||||
{
|
{
|
||||||
key_code = 10 + (in_char - 'a');
|
key_code = 10 + (in_char - 'a');
|
||||||
irda_tv_lib_control((UINT8)key_code, user_data);
|
ir_tv_lib_control((UINT8) key_code, user_data);
|
||||||
}
|
}
|
||||||
else if (in_char == 'q')
|
else if (in_char == 'q')
|
||||||
{
|
{
|
||||||
irda_tv_lib_close();
|
ir_tv_lib_close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user