updated all example references
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -37,6 +37,8 @@ typedef signed int INT;
|
|||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
|
|
||||||
|
void noprint(const char *fmt, ...);
|
||||||
|
|
||||||
#if !defined BOARD_CC26XX
|
#if !defined BOARD_CC26XX
|
||||||
#define ir_malloc(A) malloc(A)
|
#define ir_malloc(A) malloc(A)
|
||||||
#define ir_free(A) free(A)
|
#define ir_free(A) free(A)
|
||||||
@@ -48,7 +50,11 @@ typedef int BOOL;
|
|||||||
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
||||||
#define ir_memset(A, B, C) memset(A, B, C)
|
#define ir_memset(A, B, C) memset(A, B, C)
|
||||||
#define ir_strlen(A) strlen(A)
|
#define ir_strlen(A) strlen(A)
|
||||||
|
#if (defined BOARD_PC) && (!defined BOARD_PC_JNI)
|
||||||
#define ir_printf printf
|
#define ir_printf printf
|
||||||
|
#else
|
||||||
|
#define ir_printf noprint
|
||||||
|
#endif
|
||||||
#define USER_DATA_SIZE 1636
|
#define USER_DATA_SIZE 1636
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ Description: This file links to java layer for Android application
|
|||||||
Revision log:
|
Revision log:
|
||||||
* 2016-03-21: created by strawmanbobi
|
* 2016-03-21: created by strawmanbobi
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include <jni.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "ir_decode_jni.h"
|
#include "ir_decode_jni.h"
|
||||||
#include "../include/ir_defs.h"
|
#include "../include/ir_defs.h"
|
||||||
#include "../include/ir_decode.h"
|
#include "../include/ir_decode.h"
|
||||||
@@ -49,24 +48,22 @@ JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpenBinary
|
|||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*env)->ReleaseByteArrayElements(env, binaries, j_buffer, JNI_ABORT);
|
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
||||||
(JNIEnv *env, jobject this_obj, jint key_code, jobject jni_ac_status, jint change_wind_direction)
|
(JNIEnv *env, jobject this_obj, jint key_code, jobject jni_ac_status, jint change_wind_direction)
|
||||||
{
|
{
|
||||||
UINT16 user_data[USER_DATA_SIZE];
|
UINT16 user_data[USER_DATA_SIZE];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int copy_array[USER_DATA_SIZE] = {0};
|
jint copy_array[USER_DATA_SIZE] = {0};
|
||||||
remote_ac_status_t ac_status;
|
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);
|
||||||
|
|
||||||
if (NULL != n_ac_status)
|
if (NULL != n_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");
|
||||||
jint i_ac_power = (*env)->GetIntField(env, jni_ac_status, ac_power_fid);
|
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");
|
jfieldID ac_mode_fid = (*env)->GetFieldID(env, n_ac_status, "acMode", "I");
|
||||||
@@ -80,7 +77,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
|||||||
|
|
||||||
jfieldID ac_wind_speed_fid = (*env)->GetFieldID(env, n_ac_status, "acWindSpeed", "I");
|
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);
|
jint i_ac_wind_speed = (*env)->GetIntField(env, jni_ac_status, ac_wind_speed_fid);
|
||||||
|
|
||||||
ac_status.acDisplay = 0;
|
ac_status.acDisplay = 0;
|
||||||
ac_status.acSleep = 0;
|
ac_status.acSleep = 0;
|
||||||
ac_status.acTimer = 0;
|
ac_status.acTimer = 0;
|
||||||
@@ -89,7 +86,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
|||||||
ac_status.acTemp = i_ac_temp;
|
ac_status.acTemp = i_ac_temp;
|
||||||
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 = ir_decode(key_code, user_data, &ac_status, change_wind_direction);
|
int wave_code_length = ir_decode(key_code, user_data, &ac_status, change_wind_direction);
|
||||||
|
|
||||||
@@ -103,7 +100,7 @@ JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
|||||||
copy_array[i] = (int)user_data[i];
|
copy_array[i] = (int)user_data[i];
|
||||||
}
|
}
|
||||||
(*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array);
|
(*env)->SetIntArrayRegion(env, result, 0, wave_code_length, copy_array);
|
||||||
(*env)->DeleteLocalRef(env, n_ac_status);
|
(*env)->DeleteLocalRef(env, n_ac_status);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#if defined BOARD_ANDROID
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
#elif (defined BOARD_PC) && (defined BOARD_PC_JNI)
|
||||||
|
#include "./include/jni.h"
|
||||||
|
#endif
|
||||||
/* Header for class net_irext_decodesdk_IRDecode */
|
/* Header for class net_irext_decodesdk_IRDecode */
|
||||||
|
|
||||||
#ifndef _Included_net_irext_decodesdk_IRDecode
|
#ifndef _Included_net_irext_decodesdk_IRDecode
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data);
|
|||||||
static INT8 ir_tv_lib_close();
|
static INT8 ir_tv_lib_close();
|
||||||
|
|
||||||
|
|
||||||
|
void noprint(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// pubic function definitions
|
// pubic function definitions
|
||||||
|
|
||||||
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
|
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
|
||||||
@@ -111,7 +116,8 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
|
|||||||
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
|
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
INT8 ret = IR_DECODE_SUCCEEDED;
|
INT8 ret = IR_DECODE_SUCCEEDED;
|
||||||
if (category == IR_TYPE_STATUS)
|
|
||||||
|
if (category == IR_CATEGORY_AC)
|
||||||
{
|
{
|
||||||
ir_binary_type = IR_TYPE_STATUS;
|
ir_binary_type = IR_TYPE_STATUS;
|
||||||
ret = ir_ac_lib_open(binary, binary_length);
|
ret = ir_ac_lib_open(binary, binary_length);
|
||||||
@@ -352,11 +358,15 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data,
|
|||||||
|
|
||||||
time_length = create_ir_frame();
|
time_length = create_ir_frame();
|
||||||
|
|
||||||
#if defined BOARD_PC
|
#if (defined BOARD_PC)
|
||||||
|
#if (defined BOARD_PC_JNI)
|
||||||
|
ir_printf("code count = %d\n", context->code_cnt);
|
||||||
|
#else
|
||||||
for (i = 0; i < context->code_cnt; i++)
|
for (i = 0; i < context->code_cnt; i++)
|
||||||
{
|
{
|
||||||
ir_printf("%d,", context->time[i]);
|
ir_printf("%d,", context->time[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ir_printf("\n");
|
ir_printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -70,22 +70,22 @@ INT8 decode_as_ac(char *file_name)
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
case 'S':
|
||||||
|
// temperature minus
|
||||||
ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1));
|
ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1));
|
||||||
function_code = AC_FUNCTION_TEMPERATURE_DOWN;
|
function_code = AC_FUNCTION_TEMPERATURE_DOWN;
|
||||||
// temperature minus
|
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
|
// wind speed loop
|
||||||
++ac_status.acWindSpeed;
|
++ac_status.acWindSpeed;
|
||||||
ac_status.acWindSpeed = ac_status.acWindSpeed % AC_WS_MAX;
|
ac_status.acWindSpeed = ac_status.acWindSpeed % AC_WS_MAX;
|
||||||
function_code = AC_FUNCTION_WIND_SPEED;
|
function_code = AC_FUNCTION_WIND_SPEED;
|
||||||
// wind speed loop
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
|
// wind swing loop
|
||||||
ac_status.acWindDir = ((ac_status.acWindDir == 0) ? AC_SWING_OFF : AC_SWING_ON);
|
ac_status.acWindDir = ((ac_status.acWindDir == 0) ? AC_SWING_OFF : AC_SWING_ON);
|
||||||
function_code = AC_FUNCTION_WIND_SWING;
|
function_code = AC_FUNCTION_WIND_SWING;
|
||||||
// wind swing loop
|
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
case 'Q':
|
case 'Q':
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ static BOOL get_ir_protocol(UINT8 encode_type)
|
|||||||
|
|
||||||
/* cycles number */
|
/* cycles number */
|
||||||
prot_cycles_num = pbuffer->data + pbuffer->offset;
|
prot_cycles_num = pbuffer->data + pbuffer->offset;
|
||||||
|
|
||||||
if (encode_type == 0)
|
if (encode_type == 0)
|
||||||
{
|
{
|
||||||
cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
||||||
@@ -190,6 +191,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
|
|
||||||
if (NULL == data || NULL == ir_time)
|
if (NULL == data || NULL == ir_time)
|
||||||
{
|
{
|
||||||
|
ir_printf("data or ir_time is null\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,11 +200,13 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
|
|
||||||
if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1)
|
if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1)
|
||||||
{
|
{
|
||||||
|
ir_printf("logical 1 or 0 is invalid\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_index >= USER_DATA_SIZE)
|
if (time_index >= USER_DATA_SIZE)
|
||||||
{
|
{
|
||||||
|
ir_printf("time index exceeded\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,12 +214,14 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
{
|
{
|
||||||
if (pcycles == NULL)
|
if (pcycles == NULL)
|
||||||
{
|
{
|
||||||
|
ir_printf("pcycles is null\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycles_num = prot_cycles_num[data->index];
|
cycles_num = prot_cycles_num[data->index];
|
||||||
if (cycles_num > 5)
|
if (cycles_num > 5)
|
||||||
{
|
{
|
||||||
|
ir_printf("cycles number exceeded\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ typedef signed int INT;
|
|||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
|
|
||||||
|
void noprint(const char *fmt, ...);
|
||||||
|
|
||||||
#if !defined BOARD_CC26XX
|
#if !defined BOARD_CC26XX
|
||||||
#define ir_malloc(A) malloc(A)
|
#define ir_malloc(A) malloc(A)
|
||||||
#define ir_free(A) free(A)
|
#define ir_free(A) free(A)
|
||||||
@@ -48,7 +50,11 @@ typedef int BOOL;
|
|||||||
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
||||||
#define ir_memset(A, B, C) memset(A, B, C)
|
#define ir_memset(A, B, C) memset(A, B, C)
|
||||||
#define ir_strlen(A) strlen(A)
|
#define ir_strlen(A) strlen(A)
|
||||||
|
#if (defined BOARD_PC) && (!defined BOARD_PC_JNI)
|
||||||
#define ir_printf printf
|
#define ir_printf printf
|
||||||
|
#else
|
||||||
|
#define ir_printf noprint
|
||||||
|
#endif
|
||||||
#define USER_DATA_SIZE 1636
|
#define USER_DATA_SIZE 1636
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ static UINT16 ir_tv_lib_control(UINT8 key, UINT16 *l_user_data);
|
|||||||
static INT8 ir_tv_lib_close();
|
static INT8 ir_tv_lib_close();
|
||||||
|
|
||||||
|
|
||||||
|
void noprint(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// pubic function definitions
|
// pubic function definitions
|
||||||
|
|
||||||
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
|
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
|
||||||
@@ -111,6 +116,7 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
|
|||||||
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
|
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
|
||||||
{
|
{
|
||||||
INT8 ret = IR_DECODE_SUCCEEDED;
|
INT8 ret = IR_DECODE_SUCCEEDED;
|
||||||
|
|
||||||
if (category == IR_CATEGORY_AC)
|
if (category == IR_CATEGORY_AC)
|
||||||
{
|
{
|
||||||
ir_binary_type = IR_TYPE_STATUS;
|
ir_binary_type = IR_TYPE_STATUS;
|
||||||
@@ -352,11 +358,15 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data,
|
|||||||
|
|
||||||
time_length = create_ir_frame();
|
time_length = create_ir_frame();
|
||||||
|
|
||||||
#if defined BOARD_PC
|
#if (defined BOARD_PC)
|
||||||
|
#if (defined BOARD_PC_JNI)
|
||||||
|
ir_printf("code count = %d\n", context->code_cnt);
|
||||||
|
#else
|
||||||
for (i = 0; i < context->code_cnt; i++)
|
for (i = 0; i < context->code_cnt; i++)
|
||||||
{
|
{
|
||||||
ir_printf("%d,", context->time[i]);
|
ir_printf("%d,", context->time[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ir_printf("\n");
|
ir_printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ static BOOL get_ir_protocol(UINT8 encode_type)
|
|||||||
|
|
||||||
/* cycles number */
|
/* cycles number */
|
||||||
prot_cycles_num = pbuffer->data + pbuffer->offset;
|
prot_cycles_num = pbuffer->data + pbuffer->offset;
|
||||||
|
|
||||||
if (encode_type == 0)
|
if (encode_type == 0)
|
||||||
{
|
{
|
||||||
cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
cycles_num_size = 8; /* "BOOT", "STOP", "SEP", "ONE", "ZERO", "FLIP", "TWO", "THREE" */
|
||||||
@@ -190,6 +191,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
|
|
||||||
if (NULL == data || NULL == ir_time)
|
if (NULL == data || NULL == ir_time)
|
||||||
{
|
{
|
||||||
|
ir_printf("data or ir_time is null\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,11 +200,13 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
|
|
||||||
if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1)
|
if (prot_cycles_num[IRDA_ONE] != 1 || prot_cycles_num[IRDA_ZERO] != 1)
|
||||||
{
|
{
|
||||||
|
ir_printf("logical 1 or 0 is invalid\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_index >= USER_DATA_SIZE)
|
if (time_index >= USER_DATA_SIZE)
|
||||||
{
|
{
|
||||||
|
ir_printf("time index exceeded\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,12 +214,14 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time)
|
|||||||
{
|
{
|
||||||
if (pcycles == NULL)
|
if (pcycles == NULL)
|
||||||
{
|
{
|
||||||
|
ir_printf("pcycles is null\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycles_num = prot_cycles_num[data->index];
|
cycles_num = prot_cycles_num[data->index];
|
||||||
if (cycles_num > 5)
|
if (cycles_num > 5)
|
||||||
{
|
{
|
||||||
|
ir_printf("cycles number exceeded\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user