added decode combo function for jni call
This commit is contained in:
@@ -153,6 +153,12 @@ extern INT8 get_supported_wind_direction(UINT8 *supported_wind_direction);
|
||||
extern void ir_lib_free_inner_buffer();
|
||||
#endif
|
||||
|
||||
// this function is preferred being called by JNI only
|
||||
UINT16 ir_decode_combo(const UINT8 category, const UINT8 sub_category,
|
||||
UINT8* binary, UINT16 binary_length,
|
||||
UINT8 key_code, UINT16* user_data,
|
||||
t_remote_ac_status* ac_status, BOOL change_wind_direction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,11 @@ extern "C"
|
||||
#define FORMAT_HEX 16
|
||||
#define FORMAT_DECIMAL 10
|
||||
|
||||
// #define USE_DYNAMIC_TAG 1
|
||||
|
||||
#if defined USE_DYNAMIC_TAG
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned char UINT8;
|
||||
typedef signed char INT8;
|
||||
@@ -60,6 +65,7 @@ void noprint(const char *fmt, ...);
|
||||
#define ir_printf noprint
|
||||
#endif
|
||||
#define USER_DATA_SIZE 1636
|
||||
// #define USER_DATA_SIZE 4096
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -86,6 +86,16 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decode_sdk_IRDecode_irDecode
|
||||
ac_status.ac_temp = i_ac_temp;
|
||||
ac_status.ac_wind_dir = i_ac_wind_dir;
|
||||
ac_status.ac_wind_speed = i_ac_wind_speed;
|
||||
|
||||
ir_printf("ac status is not null : power = %d, mode = %d, "
|
||||
"temp = %d, wind_dir = %d, wind_speed = %d\n",
|
||||
ac_status.ac_power, ac_status.ac_mode,
|
||||
ac_status.ac_temp, ac_status.ac_wind_dir,
|
||||
ac_status.ac_wind_speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
ir_printf("ac status is null, error!\n");
|
||||
}
|
||||
|
||||
int wave_code_length = ir_decode(key_code, user_data, &ac_status, change_wind_direction);
|
||||
@@ -111,6 +121,70 @@ JNIEXPORT void JNICALL Java_net_irext_decode_sdk_IRDecode_irClose
|
||||
ir_close();
|
||||
}
|
||||
|
||||
JNIEXPORT jintArray JNICALL Java_net_irext_decode_sdk_IRDecode_irDecodeCombo
|
||||
(JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate,
|
||||
jbyteArray binaries, jint bin_length,
|
||||
jint key_code, jobject jni_ac_status, jint change_wind_direction) {
|
||||
UINT16 user_data[USER_DATA_SIZE] = { 0 };
|
||||
int i = 0;
|
||||
jint copy_array[USER_DATA_SIZE] = { 0 };
|
||||
t_remote_ac_status ac_status;
|
||||
|
||||
jbyte* j_buffer = (*env)->GetByteArrayElements(env, binaries, 0);
|
||||
unsigned char* buffer = (unsigned char*)j_buffer;
|
||||
|
||||
jclass n_ac_status = (*env)->GetObjectClass(env, jni_ac_status);
|
||||
|
||||
if (NULL != n_ac_status) {
|
||||
jfieldID ac_power_fid = (*env)->GetFieldID(env, n_ac_status, "acPower", "I");
|
||||
jint
|
||||
i_ac_power = (*env)->GetIntField(env, jni_ac_status, ac_power_fid);
|
||||
|
||||
jfieldID ac_mode_fid = (*env)->GetFieldID(env, n_ac_status, "acMode", "I");
|
||||
jint
|
||||
i_ac_mode = (*env)->GetIntField(env, jni_ac_status, ac_mode_fid);
|
||||
|
||||
jfieldID ac_temp_fid = (*env)->GetFieldID(env, n_ac_status, "acTemp", "I");
|
||||
jint
|
||||
i_ac_temp = (*env)->GetIntField(env, jni_ac_status, ac_temp_fid);
|
||||
|
||||
jfieldID ac_wind_dir_fid = (*env)->GetFieldID(env, n_ac_status, "acWindDir", "I");
|
||||
jint
|
||||
i_ac_wind_dir = (*env)->GetIntField(env, jni_ac_status, ac_wind_dir_fid);
|
||||
|
||||
jfieldID ac_wind_speed_fid =
|
||||
(*env)->GetFieldID(env, n_ac_status, "acWindSpeed", "I");
|
||||
jint
|
||||
i_ac_wind_speed = (*env)->GetIntField(env, jni_ac_status, ac_wind_speed_fid);
|
||||
|
||||
ac_status.ac_display = 0;
|
||||
ac_status.ac_sleep = 0;
|
||||
ac_status.ac_timer = 0;
|
||||
ac_status.ac_power = i_ac_power;
|
||||
ac_status.ac_mode = i_ac_mode;
|
||||
ac_status.ac_temp = i_ac_temp;
|
||||
ac_status.ac_wind_dir = i_ac_wind_dir;
|
||||
ac_status.ac_wind_speed = i_ac_wind_speed;
|
||||
}
|
||||
|
||||
int wave_code_length = ir_decode_combo(category_id, sub_cate,
|
||||
buffer, bin_length,
|
||||
key_code, user_data,
|
||||
&ac_status, change_wind_direction);
|
||||
|
||||
jintArray result = (*env)->NewIntArray(env, wave_code_length);
|
||||
if (result == NULL) {
|
||||
return NULL; /* out of memory error thrown */
|
||||
}
|
||||
for (i = 0; i < wave_code_length; i++) {
|
||||
copy_array[i] = (int) user_data[i];
|
||||
}
|
||||
(*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array);
|
||||
(*env)->DeleteLocalRef(env, n_ac_status);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_net_irext_decode_sdk_IRDecode_irACGetTemperatureRange
|
||||
(JNIEnv *env, jobject this_obj, jint ac_mode)
|
||||
{
|
||||
|
||||
@@ -131,6 +131,12 @@ JNIEXPORT jint JNICALL Java_net_irext_decode_sdk_IRDecode_irACGetSupportedSwing
|
||||
JNIEXPORT jint JNICALL Java_net_irext_decode_sdk_IRDecode_irACGetSupportedWindDirection
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
|
||||
JNIEXPORT jintArray JNICALL Java_net_irext_decode_sdk_IRDecode_irDecodeCombo
|
||||
(JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate,
|
||||
jbyteArray binaries, jint bin_length,
|
||||
jint key_code, jobject jni_ac_status, jint change_wind_direction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -170,7 +170,8 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar
|
||||
}
|
||||
|
||||
|
||||
UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction)
|
||||
UINT16 ir_decode(UINT8 key_code, UINT16* user_data,
|
||||
t_remote_ac_status* ac_status, BOOL change_wind_direction)
|
||||
{
|
||||
if (IR_TYPE_COMMANDS == ir_binary_type)
|
||||
{
|
||||
@@ -198,10 +199,12 @@ INT8 ir_close()
|
||||
{
|
||||
if (IR_TYPE_COMMANDS == ir_binary_type)
|
||||
{
|
||||
ir_printf("tv binary close\n");
|
||||
return ir_tv_binary_close();
|
||||
}
|
||||
else
|
||||
{
|
||||
ir_printf("ac binary close\n");
|
||||
return ir_ac_binary_close();
|
||||
}
|
||||
}
|
||||
@@ -648,6 +651,25 @@ static INT8 ir_tv_binary_close()
|
||||
}
|
||||
//////// TV End ////////
|
||||
|
||||
// combo decode for JNI which means call open, decode and then close in one JNI call
|
||||
UINT16 ir_decode_combo(const UINT8 category, const UINT8 sub_category,
|
||||
UINT8* binary, UINT16 binary_length,
|
||||
UINT8 key_code, UINT16* user_data,
|
||||
t_remote_ac_status* ac_status, BOOL change_wind_direction)
|
||||
{
|
||||
UINT16 decoded_length = 0;
|
||||
if (IR_DECODE_SUCCEEDED ==
|
||||
ir_binary_open(category, sub_category, binary, binary_length))
|
||||
{
|
||||
decoded_length = ir_decode(key_code, user_data, ac_status, change_wind_direction);
|
||||
ir_close();
|
||||
return decoded_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC || defined BOARD_PC_DLL)
|
||||
void ir_lib_free_inner_buffer()
|
||||
|
||||
Reference in New Issue
Block a user