added decode combo function for jni call
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user