update 2016-11-07 b1
1. resolved TV and AC decoding process for main function
This commit is contained in:
@@ -7,8 +7,8 @@ add_definitions(-DBOARD_PC)
|
||||
set(SOURCE_FILES_EXECUTABLE
|
||||
irda_decode.c
|
||||
include/irda_decode.h
|
||||
irda_lib.c
|
||||
include/irda_lib.h
|
||||
irda_tv_parse.c
|
||||
include/irda_tv_parse.h
|
||||
irda_apply.c
|
||||
include/irda_apply.h
|
||||
include/irda_defs.h
|
||||
@@ -28,8 +28,8 @@ set(SOURCE_FILES_EXECUTABLE
|
||||
set(SOURCE_FILES_SHARED_LIB
|
||||
irda_decode.c
|
||||
include/irda_decode.h
|
||||
irda_lib.c
|
||||
include/irda_lib.h
|
||||
irda_tv_parse.c
|
||||
include/irda_tv_parse.h
|
||||
irda_apply.c
|
||||
include/irda_apply.h
|
||||
include/irda_defs.h
|
||||
|
||||
@@ -17,20 +17,8 @@ Revision log:
|
||||
#define TAG_COUNT_FOR_PROTOCOL 29
|
||||
#define TAG_COUNT_FOR_BC_PROTOCOL 20
|
||||
|
||||
#if defined BOARD_EMBEDDED
|
||||
|
||||
#define KEY_COUNT 15
|
||||
|
||||
#elif (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
#define KEY_COUNT 15
|
||||
|
||||
#else
|
||||
|
||||
#define KEY_COUNT 15
|
||||
|
||||
#endif
|
||||
|
||||
#define EXPECTED_MEM_SIZE 1024
|
||||
|
||||
#define TAG_INVALID 0xffff
|
||||
@@ -43,11 +31,6 @@ Revision log:
|
||||
#define AC_PARAMETER_TYPE_1 0
|
||||
#define AC_PARAMETER_TYPE_2 1
|
||||
|
||||
#define BLE_GAP_MTU 20
|
||||
#define BLE_UUID_SIZE 16
|
||||
#define BLE_UUID_STRING_SIZE 32
|
||||
#define BLE_UUID_STRING_SIZE_MAX 36
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AC_POWER_ON = 0,
|
||||
@@ -371,41 +354,6 @@ typedef struct ac_protocol
|
||||
UINT8 solo_function_mark;
|
||||
} protocol;
|
||||
|
||||
#if defined BOARD_FREE_RTOS
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
typedef struct bc_command
|
||||
{
|
||||
UINT8 length;
|
||||
UINT16 handle;
|
||||
UINT8 command[BLE_GAP_MTU];
|
||||
} t_bc_command;
|
||||
#if defined BOARD_FREE_RTOS
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
typedef struct bc_commands
|
||||
{
|
||||
UINT8 seg_count;
|
||||
t_bc_command *commands;
|
||||
} t_bc_commands;
|
||||
|
||||
typedef struct bc_protocol
|
||||
{
|
||||
// would save device_name within 20 bytes to flash
|
||||
char *device_name;
|
||||
// would save need_connection_ack of 1 byte to flash
|
||||
UINT8 need_connection_ack;
|
||||
// would save name essential length of 1 bytes to flash
|
||||
UINT8 name_essential_length;
|
||||
// would save name length of 2 byte to flash
|
||||
UINT8 name_length;
|
||||
|
||||
// would save generic_command of 4 x 20 bytes to flash with segment length tag
|
||||
t_bc_commands conn_ack;
|
||||
t_bc_commands generic_command[KEY_COUNT];
|
||||
} t_bc_protocol;
|
||||
|
||||
typedef struct tag_head
|
||||
{
|
||||
UINT16 tag;
|
||||
@@ -414,21 +362,12 @@ typedef struct tag_head
|
||||
UINT8 *pdata;
|
||||
} t_tag_head;
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
struct ir_bin_buffer
|
||||
{
|
||||
UINT8 data[EXPECTED_MEM_SIZE];
|
||||
UINT16 len;
|
||||
UINT16 offset;
|
||||
};
|
||||
#else
|
||||
struct ir_bin_buffer
|
||||
{
|
||||
UINT8 *data;
|
||||
UINT16 len;
|
||||
UINT16 offset;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct REMOTE_AC_STATUS
|
||||
{
|
||||
@@ -442,7 +381,7 @@ typedef struct REMOTE_AC_STATUS
|
||||
UINT8 acTimer;
|
||||
} remote_ac_status_t;
|
||||
|
||||
// function polymorhism
|
||||
// function polymorphism
|
||||
typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 function_code);
|
||||
|
||||
#define TAG_AC_POWER_1 1001
|
||||
@@ -483,30 +422,6 @@ typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 funct
|
||||
#define TAG_AC_BAN_FUNCTION_IN_FAN_MODE 1504
|
||||
#define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 1505
|
||||
|
||||
//////////////// TAGS FOR BLE CENTRAL //////////////////
|
||||
#define TAG_BC_BLE_NAME 100
|
||||
#define TAG_BC_NEED_CONN_ACK 101
|
||||
#define TAG_BC_NAME_LENGTH 102
|
||||
#define TAG_BC_NAME_ESS_LENGTH 103
|
||||
|
||||
#define TAG_BC_CONN_ACK_CMD 300
|
||||
|
||||
#define TAG_BC_KEY_0_CMD 200
|
||||
#define TAG_BC_KEY_1_CMD 201
|
||||
#define TAG_BC_KEY_2_CMD 202
|
||||
#define TAG_BC_KEY_3_CMD 203
|
||||
#define TAG_BC_KEY_4_CMD 204
|
||||
#define TAG_BC_KEY_5_CMD 205
|
||||
#define TAG_BC_KEY_6_CMD 206
|
||||
#define TAG_BC_KEY_7_CMD 207
|
||||
#define TAG_BC_KEY_8_CMD 208
|
||||
#define TAG_BC_KEY_9_CMD 209
|
||||
#define TAG_BC_KEY_10_CMD 210
|
||||
#define TAG_BC_KEY_11_CMD 211
|
||||
#define TAG_BC_KEY_12_CMD 212
|
||||
#define TAG_BC_KEY_13_CMD 213
|
||||
#define TAG_BC_KEY_14_CMD 214
|
||||
|
||||
// definition about size
|
||||
|
||||
#define PROTOCOL_SIZE (sizeof(protocol))
|
||||
@@ -515,8 +430,8 @@ typedef INT8 (*lp_apply_ac_parameter) (remote_ac_status_t ac_status, UINT8 funct
|
||||
extern UINT8* ir_hex_code;
|
||||
extern UINT8 ir_hex_len;
|
||||
extern protocol* context;
|
||||
extern t_bc_protocol* context_bc;
|
||||
extern remote_ac_status_t ac_status;
|
||||
extern UINT16 user_data[];
|
||||
|
||||
/* exported functions */
|
||||
///////////////////////////////////////////////// AC Begin /////////////////////////////////////////////////
|
||||
@@ -532,18 +447,12 @@ extern INT8 irda_context_init();
|
||||
/*
|
||||
* function irda_ac_lib_open
|
||||
*
|
||||
* parameters: file_name (in, for PC and MT6580) specified bin file path
|
||||
* binary_file (in, for CC2541 and MC200) specified file content of bin
|
||||
* binary_length (in, for CC2541 and MC200) length of binary file content
|
||||
* parameters: binary (in) binary content
|
||||
* binary_length (in) length of binary content
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
extern UINT16 user_data[];
|
||||
extern INT8 irda_ac_lib_open(const char *file_name);
|
||||
#else
|
||||
extern INT8 irda_ac_lib_open(UINT8 *binary_file, UINT16 binary_length);
|
||||
#endif
|
||||
extern INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length);
|
||||
|
||||
/*
|
||||
* function irda_ac_lib_parse
|
||||
@@ -578,15 +487,15 @@ extern void irda_ac_lib_close();
|
||||
///////////////////////////////////////////////// AC End /////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
/*
|
||||
* function irda_tv_lib_open
|
||||
*
|
||||
* parameters: file_name (in, for PC and MT6580) specified bin file path
|
||||
* parameters: binary (in) binary content
|
||||
* binary_length (in) length of binary content
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 irda_tv_lib_open(const char *file_name);
|
||||
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length);
|
||||
|
||||
/*
|
||||
* function irda_tv_lib_parse
|
||||
@@ -615,71 +524,8 @@ extern UINT16 irda_tv_lib_control(UINT8 key_code, UINT16 * l_user_data);
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern UINT16 irda_tv_lib_close();
|
||||
#endif
|
||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////// BLE Central Begin /////////////////////////////////////////////////
|
||||
/*
|
||||
* function bc_context_init
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 bc_context_init();
|
||||
|
||||
/*
|
||||
* function bc_lib_open
|
||||
*
|
||||
* parameters: file_name (in, for PC and MT6580) specified bin file path
|
||||
* binary_file (in, for CC2541 and MC200) specified file content of bin
|
||||
* binary_length (in, for CC2541 and MC200) length of binary file content
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
extern INT8 bc_lib_open(const char *file_name);
|
||||
#else
|
||||
extern INT8 bc_lib_open(UINT8 *binary_file, UINT16 binary_length);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* function bc_lib_parse
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 bc_lib_parse();
|
||||
|
||||
/*
|
||||
* function bc_lib_parse
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
|
||||
/*
|
||||
* function bc_lib_control
|
||||
*
|
||||
* parameters: key_code (in) indicates the number of pressed key
|
||||
* bc_commands (out) command information
|
||||
*
|
||||
* return: length of commands
|
||||
*/
|
||||
extern UINT16 bc_lib_control(int key_code, t_bc_commands* bc_commands);
|
||||
|
||||
/*
|
||||
* function bc_lib_close
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return:
|
||||
*/
|
||||
extern void bc_lib_close();
|
||||
///////////////////////////////////////////////// BLE Central End /////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////// Utils Begin /////////////////////////////////////////////////
|
||||
/*
|
||||
* function get_temperature_range
|
||||
@@ -730,33 +576,6 @@ extern INT8 get_supported_swing(UINT8 ac_mode, UINT8* supported_swing);
|
||||
*/
|
||||
INT8 get_supported_wind_direction(UINT8* supported_wind_direction);
|
||||
|
||||
/*
|
||||
* function get_bc_need_conn_ack
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return: boolean status indicating if bc connection need ACK
|
||||
*/
|
||||
extern UINT8 get_bc_need_conn_ack();
|
||||
|
||||
/*
|
||||
* function get_bc_device_name
|
||||
*
|
||||
* parameters:
|
||||
*
|
||||
* return: name of BLE Peripheral device
|
||||
*/
|
||||
extern char* get_bc_device_name();
|
||||
|
||||
/*
|
||||
* function get_valid_keys
|
||||
*
|
||||
* parameters: valid_keys (out)
|
||||
*
|
||||
* return: name of BLE Peripheral device
|
||||
*/
|
||||
extern int get_valid_keys(int *valid_keys);
|
||||
|
||||
///////////////////////////////////////////////// Utils End /////////////////////////////////////////////////
|
||||
|
||||
#endif // _IRDA_DECODE_H_
|
||||
|
||||
@@ -30,49 +30,13 @@ typedef unsigned short UINT16;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned char BOOL;
|
||||
|
||||
#if defined BOARD_EMBEDDED
|
||||
#define irda_malloc(A) malloc(A)
|
||||
#define irda_free(A) free(A)
|
||||
#define irda_memcpy(A, B, C) memcpy(A, B, C)
|
||||
#define irda_memset(A, B, C) memcpy(A, B, C)
|
||||
#define irda_strlen(A) strlen(A)
|
||||
#define IR_PRINTF(...)
|
||||
#define USER_DATA_SIZE 1536
|
||||
#elif defined BOARD_FREE_RTOS
|
||||
#define irda_malloc(A) os_mem_alloc(A)
|
||||
#define irda_free(A) os_mem_free(A)
|
||||
#define irda_memcpy(A, B, C) memcpy(A, B, C)
|
||||
#define irda_memset(A, B, C) memset(A, B, C)
|
||||
#define irda_strlen(A) strlen(A)
|
||||
#define IR_PRINTF(A)
|
||||
// temporarily define USER_DATA_SIZE as 1536 for BOARD_FREE_RTOS
|
||||
#define USER_DATA_SIZE 1536
|
||||
#elif defined BOARD_PC
|
||||
#define irda_malloc(A) malloc(A)
|
||||
#define irda_free(A) free(A)
|
||||
#define irda_memcpy(A, B, C) memcpy(A, B, C)
|
||||
#define irda_memset(A, B, C) memset(A, B, C)
|
||||
#define irda_strlen(A) strlen(A)
|
||||
#define IR_PRINTF printf
|
||||
// temporarily define USER_DATA_SIZE as 2048 for BOARD_PC
|
||||
#define USER_DATA_SIZE 2048
|
||||
#elif defined BOARD_ANDROID
|
||||
#define irda_malloc(A) malloc(A)
|
||||
#define irda_free(A) free(A)
|
||||
#define irda_memcpy(A, B, C) memcpy(A, B, C)
|
||||
#define irda_memset(A, B, C) memset(A, B, C)
|
||||
#define irda_strlen(A) strlen(A)
|
||||
#define IR_PRINTF(...)
|
||||
#define USER_DATA_SIZE 2048
|
||||
#else
|
||||
#define irda_malloc(A) malloc(A)
|
||||
#define irda_free(A) free(A)
|
||||
#define irda_memcpy(A, B, C) memcpy(A, B, C)
|
||||
#define irda_memset(A, B, C) memset(A, B, C)
|
||||
#define irda_strlen(A) strlen(A)
|
||||
#define IR_PRINTF(A)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -16,6 +16,26 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern struct ir_bin_buffer *pirda_buffer;
|
||||
|
||||
/*
|
||||
* function irda_ac_file_open
|
||||
*
|
||||
* parameters: file_name (in) specified bin file path
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 irda_ac_file_open(const char *file_name);
|
||||
|
||||
/*
|
||||
* function irda_tv_lib_open
|
||||
*
|
||||
* parameters: file_name (in, for PC and MT6580) specified bin file path
|
||||
*
|
||||
* return: IR_DECODE_SUCCEEDED / IR_DECODE_FAILED
|
||||
*/
|
||||
extern INT8 irda_tv_file_open(const char *file_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,40 +38,28 @@ extern INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT
|
||||
|
||||
extern INT8 parse_defaultcode_1002(struct tag_head *tag, ac_hex *default_code);
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
extern INT8 parse_power_1_1001(struct tag_head *tag, power_1 *power1);
|
||||
|
||||
#endif
|
||||
|
||||
extern INT8 parse_temp_1_1003(struct tag_head *tag, temp_1 *temp1);
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
extern INT8 parse_mode_1_1004(struct tag_head *tag, mode_1 *mode1);
|
||||
|
||||
extern INT8 parse_speed_1_1005(struct tag_head *tag, speed_1 *speed1);
|
||||
|
||||
extern INT8 parse_swing_1_1007(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count);
|
||||
|
||||
#endif
|
||||
|
||||
extern INT8 parse_checksum_1008(struct tag_head *tag, tchecksum *checksum);
|
||||
|
||||
extern INT8 parse_function_1_1010(struct tag_head *tag, function_1 *function1);
|
||||
|
||||
extern INT8 parse_temp_2_1011(struct tag_head *tag, temp_2 *temp2);
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
extern INT8 parse_mode_2_1012(struct tag_head *tag, mode_2 *mode2);
|
||||
|
||||
extern INT8 parse_speed_2_1013(struct tag_head *tag, speed_2 *speed2);
|
||||
|
||||
extern INT8 parse_swing_2_1015(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count);
|
||||
|
||||
#endif
|
||||
|
||||
extern INT8 parse_function_2_1016(struct tag_head *tag, function_2 *function2);
|
||||
|
||||
extern INT8 parse_swing_info_1506(struct tag_head *tag, swing_info *si);
|
||||
|
||||
@@ -85,18 +85,14 @@ typedef struct irda_data
|
||||
UINT8 index;
|
||||
} irda_data_t;
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_FREE_RTOS) || (defined BOARD_ANDROID)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
typedef struct irda_cycles
|
||||
{
|
||||
UINT8 flag;
|
||||
UINT16 mask;
|
||||
UINT16 space;
|
||||
} irda_cycles_t;
|
||||
#if (defined BOARD_PC) || (defined BOARD_FREE_RTOS) || (defined BOARD_ANDROID)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//================================== TV ==================================
|
||||
typedef enum tv_key_value
|
||||
@@ -248,9 +244,9 @@ typedef struct irda_data_tv
|
||||
/**************************************************************************************************
|
||||
* GLOBAL FUNCTION PROTOTYPES
|
||||
**************************************************************************************************/
|
||||
extern void irda_lib_open(UINT8 *binary_file, UINT16 binary_length);
|
||||
extern BOOL irda_lib_parse(UINT8 encode_type);
|
||||
extern UINT16 irda_lib_control(UINT8 key, UINT16 *user_data);
|
||||
extern INT8 tv_lib_open(UINT8* binary, UINT16 binary_length);
|
||||
extern BOOL tv_lib_parse(UINT8 encode_type);
|
||||
extern UINT16 tv_lib_control(UINT8 key, UINT16 *user_data);
|
||||
|
||||
|
||||
#endif /* _IRDA_H_ */
|
||||
@@ -421,11 +421,9 @@ INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse)
|
||||
// apply checksum
|
||||
ac_code[cs.checksum_byte_pos] = checksum;
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
IR_PRINTF("checksum value = %02X\n", checksum);
|
||||
IR_PRINTF("checksum byte pos = %d\n", cs.checksum_byte_pos);
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
@@ -455,11 +453,9 @@ INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse)
|
||||
// apply checksum
|
||||
ac_code[cs.checksum_byte_pos] = checksum;
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
IR_PRINTF("checksum value = %02X\n", checksum & 0x0F);
|
||||
IR_PRINTF("checksum byte pos = %d\n", cs.checksum_byte_pos);
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
@@ -512,10 +508,8 @@ INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse
|
||||
ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F);
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
IR_PRINTF("checksum value = %02X\n", checksum & 0x0F);
|
||||
IR_PRINTF("checksum byte pos = %d\n", apply_byte_pos);
|
||||
#endif
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
@@ -559,10 +553,8 @@ INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, tag_checksum_data cs, BOOL
|
||||
apply_byte_pos = cs.checksum_byte_pos >> 1;
|
||||
ac_code[apply_byte_pos] = checksum;
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
IR_PRINTF("checksum value = %02X\n", checksum);
|
||||
IR_PRINTF("checksum byte pos = %d\n", apply_byte_pos);
|
||||
#endif
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
@@ -576,19 +568,15 @@ INT8 apply_checksum(struct ac_protocol *protocol)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
// have some debug
|
||||
IR_PRINTF("\napply checksum :\n");
|
||||
IR_PRINTF("checksum num = %d\n", protocol->checksum.count);
|
||||
#endif
|
||||
|
||||
for(i = 0; i < protocol->checksum.count; i++)
|
||||
{
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
// have some debug
|
||||
IR_PRINTF("num : %d\n", i + 1);
|
||||
IR_PRINTF("checksum type = %02X\n", protocol->checksum.checksum_data[i].type);
|
||||
#endif
|
||||
|
||||
switch (protocol->checksum.checksum_data[i].type)
|
||||
{
|
||||
|
||||
@@ -11,12 +11,6 @@ Revision log:
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "./include/irda_decode.h"
|
||||
@@ -26,7 +20,7 @@ Revision log:
|
||||
#include "./include/irda_parse_forbidden_info.h"
|
||||
#include "./include/irda_irframe.h"
|
||||
#include "./include/irda_apply.h"
|
||||
#include "./include/irda_lib.h"
|
||||
#include "include/irda_tv_parse.h"
|
||||
|
||||
struct ir_bin_buffer binaryfile;
|
||||
struct ir_bin_buffer *pirda_buffer = &binaryfile;
|
||||
@@ -66,9 +60,6 @@ const UINT16 bc_tag_index[TAG_COUNT_FOR_BC_PROTOCOL] =
|
||||
// 2016-10-09 updated by strawmanbobi, change global data context to array pointer
|
||||
protocol *context = (protocol *) byteArray;
|
||||
|
||||
// BLE decode structure, share with a same byteArray to save memory
|
||||
t_bc_protocol *context_bc = (t_bc_protocol *) byteArray;
|
||||
|
||||
// ban function table
|
||||
// fixed swing should not be counted in case of AC
|
||||
INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code);
|
||||
@@ -90,27 +81,6 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] =
|
||||
|
||||
///////////////////////////////////////////////// Air Conditioner Begin /////////////////////////////////////////////////
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
INT8 binary_open(const char *file)
|
||||
{
|
||||
FILE *stream = fopen(file, "rb");
|
||||
if (stream == NULL)
|
||||
{
|
||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_END);
|
||||
pirda_buffer->len = ftell(stream);
|
||||
|
||||
fseek(stream, 0, SEEK_SET);
|
||||
fread(pirda_buffer->data, pirda_buffer->len, 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
#endif
|
||||
|
||||
INT8 binary_parse_offset()
|
||||
{
|
||||
int i = 0;
|
||||
@@ -177,7 +147,6 @@ INT8 binary_parse_len()
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
void binary_tags_info()
|
||||
{
|
||||
UINT16 i = 0;
|
||||
@@ -190,7 +159,6 @@ void binary_tags_info()
|
||||
IR_PRINTF("tag(%d).len = %d\n", tags[i].tag, tags[i].len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
INT8 binary_parse_data()
|
||||
{
|
||||
@@ -343,22 +311,15 @@ INT8 free_ac_context()
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
INT8 irda_ac_lib_open(const char *file_name)
|
||||
INT8 irda_ac_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||
{
|
||||
IR_PRINTF("\nirda_ac_lib_open: %s\n", file_name);
|
||||
return binary_open(file_name);
|
||||
}
|
||||
#else
|
||||
INT8 irda_ac_lib_open(UINT8 *binary_file, UINT16 binary_length)
|
||||
{
|
||||
// load bin to buffer
|
||||
pirda_buffer->data = binary_file;
|
||||
// it is recommended that the parameter binary pointing to
|
||||
// a global memory block in embedded platform environment
|
||||
pirda_buffer->data = binary;
|
||||
pirda_buffer->len = binary_length;
|
||||
pirda_buffer->offset = 0;
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
#endif
|
||||
|
||||
INT8 irda_context_init()
|
||||
{
|
||||
@@ -370,9 +331,8 @@ INT8 irda_ac_lib_parse()
|
||||
{
|
||||
UINT16 i = 0;
|
||||
// suggest not to call init function here for de-couple purpose
|
||||
#if defined BOARD_EMBEDDED
|
||||
irda_context_init();
|
||||
#endif
|
||||
|
||||
if (IR_DECODE_FAILED == binary_parse_offset())
|
||||
{
|
||||
return IR_DECODE_FAILED;
|
||||
@@ -388,9 +348,8 @@ INT8 irda_ac_lib_parse()
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
binary_tags_info();
|
||||
#endif
|
||||
|
||||
context->endian = 0;
|
||||
context->lastbit = 0;
|
||||
context->repeat_times = 1;
|
||||
@@ -926,22 +885,7 @@ UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT
|
||||
UINT8 change_wind_direction)
|
||||
{
|
||||
UINT16 time_length = 0;
|
||||
#if (defined BOARD_PC)|| (defined BOARD_ANDROID)
|
||||
UINT8 i = 0;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// prepare ac status to parameter array
|
||||
UINT8 parameter_array[AC_APPLY_MAX] =
|
||||
{
|
||||
ac_status.acPower,
|
||||
ac_status.acMode,
|
||||
ac_status.acWindSpeed,
|
||||
ac_status.acWindDir,
|
||||
ac_status.acTemp,
|
||||
function_code
|
||||
};
|
||||
#endif
|
||||
|
||||
if (0 == context->default_code.len)
|
||||
{
|
||||
@@ -1034,23 +978,12 @@ UINT16 irda_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT
|
||||
apply_checksum(context);
|
||||
|
||||
// have some debug
|
||||
#if (defined BOARD_PC)|| (defined BOARD_ANDROID)
|
||||
IR_PRINTF("==============================\n");
|
||||
for(i = 0; i < ir_hex_len; i++)
|
||||
{
|
||||
IR_PRINTF("[%02X] ", ir_hex_code[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
#if (defined BOARD_EMBEDDED) && (PRINT_IRDA_DATA == TRUE)
|
||||
NPI_PrintString("hex:\r\n");
|
||||
|
||||
for (UINT16 i = 0; i < context->default_code.len; i++)
|
||||
{
|
||||
NPI_PrintValue("", ir_hex_code[i], 16);
|
||||
}
|
||||
NPI_PrintString("\r\n");
|
||||
#endif
|
||||
|
||||
time_length = create_ir_frame();
|
||||
|
||||
@@ -1214,60 +1147,14 @@ INT8 get_supported_wind_direction(UINT8* supported_wind_direction)
|
||||
///////////////////////////////////////////////// Air Conditioner End /////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////// TV Begin /////////////////////////////////////////////////
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
INT8 binary_tv_open(const char *file)
|
||||
INT8 irda_tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||
{
|
||||
int print_index = 0;
|
||||
FILE *stream = fopen(file, "rb");
|
||||
|
||||
IR_PRINTF("file name = %s\n", file);
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_END);
|
||||
tv_bin_length = ftell(stream);
|
||||
|
||||
IR_PRINTF("length of binary = %d\n", tv_bin_length);
|
||||
|
||||
fseek(stream, 0, SEEK_SET);
|
||||
fread(tv_bin, tv_bin_length, 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
// have some debug
|
||||
IR_PRINTF("=============================\n");
|
||||
// IR_PRINTF("length of binary = %d\n", tv_bin_length);
|
||||
for(print_index = 0; print_index < tv_bin_length; print_index++)
|
||||
{
|
||||
IR_PRINTF("%02X ", tv_bin[print_index]);
|
||||
}
|
||||
IR_PRINTF("\n=============================\n");
|
||||
irda_lib_open(tv_bin, tv_bin_length);
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
return tv_lib_open(binary, binary_length);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
INT8 irda_tv_lib_open(const char *file_name)
|
||||
{
|
||||
return binary_tv_open(file_name);
|
||||
}
|
||||
#else
|
||||
INT8 irda_tv_lib_open(UINT8 *binary_file, UINT16 binary_length)
|
||||
{
|
||||
irda_lib_open(binary_file, binary_length);
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined BOARD_PC)|| (defined BOARD_ANDROID)
|
||||
INT8 irda_tv_lib_parse(UINT8 irda_hex_encode)
|
||||
{
|
||||
if (FALSE == irda_lib_parse(irda_hex_encode))
|
||||
if (FALSE == tv_lib_parse(irda_hex_encode))
|
||||
{
|
||||
IR_PRINTF("parse irda binary failed\n");
|
||||
memset(tv_bin, 0x00, EXPECTED_MEM_SIZE);
|
||||
@@ -1283,7 +1170,7 @@ UINT16 irda_tv_lib_control(UINT8 key, UINT16* l_user_data)
|
||||
UINT16 print_index = 0;
|
||||
UINT16 irda_code_length = 0;
|
||||
memset(user_data, 0x00, USER_DATA_SIZE);
|
||||
irda_code_length = irda_lib_control(key, l_user_data);
|
||||
irda_code_length = tv_lib_control(key, l_user_data);
|
||||
|
||||
// have some debug
|
||||
IR_PRINTF("=============================\n");
|
||||
@@ -1301,5 +1188,4 @@ UINT16 irda_tv_lib_close()
|
||||
{
|
||||
// no need to close tv binary
|
||||
}
|
||||
#endif
|
||||
///////////////////////////////////////////////// TV End /////////////////////////////////////////////////
|
||||
@@ -212,176 +212,3 @@ JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibClos
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_bcLibOpen
|
||||
(JNIEnv *env, jobject this_obj, jstring file_name)
|
||||
{
|
||||
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
||||
if (IR_DECODE_FAILED == bc_lib_open(n_file_name))
|
||||
{
|
||||
bc_lib_close();
|
||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
// no need to verify return value
|
||||
bc_context_init();
|
||||
|
||||
if (IR_DECODE_FAILED == bc_lib_parse())
|
||||
{
|
||||
bc_lib_close();
|
||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_bcGetNeedConnAck
|
||||
(JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
return context_bc->need_connection_ack;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_net_irext_remote_service_DecodeService_bcGetDeviceName
|
||||
(JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
jstring ret_name;
|
||||
const char* device_name = context_bc->device_name;
|
||||
ret_name = (*env)->NewStringUTF(env, device_name);
|
||||
return ret_name;
|
||||
}
|
||||
|
||||
JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_bcGetValidKeys
|
||||
(JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
jintArray result;
|
||||
int valid_keys[KEY_COUNT] = {0};
|
||||
int valid_keys_length = get_valid_keys(valid_keys);
|
||||
|
||||
result = (*env)->NewIntArray(env, valid_keys_length);
|
||||
if (result == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetIntArrayRegion(env, result, 0, valid_keys_length, valid_keys);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_bcLibClose
|
||||
(JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
bc_lib_close();
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_bcGetConnAck
|
||||
(JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
int segment_count = 0;
|
||||
int i = 0;
|
||||
jobject bc_commands = NULL;
|
||||
|
||||
jclass bccommands_class = (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNIBCCommands");
|
||||
jclass bccommand_class = (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNIBCCommand");
|
||||
|
||||
jmethodID bccommands_mid = (*env)->GetMethodID(env, bccommands_class, "<init>", "()V");
|
||||
jmethodID bccommand_mid = (*env)->GetMethodID(env, bccommand_class, "<init>", "()V");
|
||||
|
||||
bc_commands = (*env)->NewObject(env, bccommands_class, bccommands_mid);
|
||||
|
||||
// get connection ACK info
|
||||
segment_count = context_bc->conn_ack.seg_count;
|
||||
// set segment count for result data-structure
|
||||
jfieldID segment_count_fid = (*env)->GetFieldID(env, bccommands_class, "segmentCount", "I");
|
||||
jfieldID commands_fid = (*env)->GetFieldID(env,
|
||||
bccommands_class,
|
||||
"commands",
|
||||
"[com/irext/remote/bean/jnibean/JNIBCCommand");
|
||||
|
||||
(*env)->SetIntField(env, bc_commands, segment_count_fid, segment_count);
|
||||
|
||||
// fill bc_command array for bc_commands
|
||||
jobjectArray j_bc_command_array = (*env)->NewObjectArray(env, segment_count, bccommand_class, NULL);
|
||||
|
||||
for (i = 0; i < segment_count; i++)
|
||||
{
|
||||
jobject bc_command = (*env)->NewObject(env, bccommand_class, bccommand_mid);
|
||||
FillBCCommandValuesToJni(env, bc_command, bccommand_class, context_bc->conn_ack.commands[i]);
|
||||
(*env)->SetObjectArrayElement(env, j_bc_command_array,
|
||||
i, bc_command);
|
||||
}
|
||||
(*env)->SetObjectField(env, bc_commands, commands_fid, j_bc_command_array);
|
||||
|
||||
return bc_commands;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_bcGetCommand
|
||||
(JNIEnv *env, jobject this_obj, jint key_number)
|
||||
{
|
||||
int segment_count = 0;
|
||||
int i = 0;
|
||||
jobject bc_commands = NULL;
|
||||
|
||||
jclass bccommands_class = (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNIBCCommands");
|
||||
jclass bccommand_class = (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNIBCCommand");
|
||||
|
||||
jmethodID bccommands_mid = (*env)->GetMethodID(env, bccommands_class, "<init>", "()V");
|
||||
jmethodID bccommand_mid = (*env)->GetMethodID(env, bccommand_class, "<init>", "()V");
|
||||
|
||||
bc_commands = (*env)->NewObject(env, bccommands_class, bccommands_mid);
|
||||
|
||||
// get connection ACK info
|
||||
segment_count = context_bc->conn_ack.seg_count;
|
||||
// set segment count for result data-structure
|
||||
jfieldID segment_count_fid = (*env)->GetFieldID(env, bccommands_class, "segmentCount", "I");
|
||||
jfieldID commands_fid = (*env)->GetFieldID(env,
|
||||
bccommands_class,
|
||||
"commands",
|
||||
"[com/irext/remote/bean/jnibean/JNIBCCommand");
|
||||
|
||||
(*env)->SetIntField(env, bc_commands, segment_count_fid, segment_count);
|
||||
|
||||
// fill bc_command array for bc_commands
|
||||
jobjectArray j_bc_command_array = (*env)->NewObjectArray(env, segment_count, bccommand_class, NULL);
|
||||
|
||||
for (i = 0; i < segment_count; i++)
|
||||
{
|
||||
jobject bc_command = (*env)->NewObject(env, bccommand_class, bccommand_mid);
|
||||
FillBCCommandValuesToJni(env, bc_command, bccommand_class, context_bc->generic_command[key_number].commands[i]);
|
||||
(*env)->SetObjectArrayElement(env, j_bc_command_array,
|
||||
i, bc_command);
|
||||
}
|
||||
(*env)->SetObjectField(env, bc_commands, commands_fid, j_bc_command_array);
|
||||
|
||||
return bc_commands;
|
||||
}
|
||||
|
||||
// utils
|
||||
void FillBCCommandValuesToJni(JNIEnv* env, jobject j_bc_command, jclass bccommand_class, t_bc_command n_bc_command)
|
||||
{
|
||||
int copy_array[BLE_GAP_MTU] = {0};
|
||||
jintArray ble_command_array = NULL;
|
||||
int i = 0;
|
||||
|
||||
jfieldID length_fid = (*env)->GetFieldID(env, bccommand_class, "length", "I");
|
||||
jfieldID handle_fid = (*env)->GetFieldID(env, bccommand_class, "handle", "I");
|
||||
jfieldID command_fid = (*env)->GetFieldID(env, bccommand_class, "command", "[I");
|
||||
|
||||
IR_PRINTF("Set int field [length] for bc_command : %d\n", n_bc_command.length);
|
||||
(*env)->SetIntField(env, j_bc_command, length_fid, n_bc_command.length);
|
||||
IR_PRINTF("Set int field [handle] for bc_command : 0x%02X\n", n_bc_command.handle);
|
||||
(*env)->SetIntField(env, j_bc_command, handle_fid, n_bc_command.handle);
|
||||
|
||||
ble_command_array = (*env)->NewIntArray(env, BLE_GAP_MTU);
|
||||
|
||||
// prepare BLE command as int32 for java
|
||||
for(i = 0; i < BLE_GAP_MTU; i++)
|
||||
{
|
||||
copy_array[i] = n_bc_command.command[i];
|
||||
IR_PRINTF("command %d origin_value = %02X, converted_value = %02X ", i, n_bc_command.command[i], copy_array[i]);
|
||||
}
|
||||
(*env)->SetIntArrayRegion(env, ble_command_array, 0, BLE_GAP_MTU, copy_array);
|
||||
(*env)->SetObjectField(env, j_bc_command, command_fid, ble_command_array);
|
||||
}
|
||||
@@ -144,13 +144,11 @@ UINT16 create_ir_frame()
|
||||
}
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
for (i = 0; i < context->code_cnt; i++)
|
||||
{
|
||||
IR_PRINTF("%d,", context->time[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
return context->code_cnt;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,56 @@ Revision log:
|
||||
* 2016-11-05: created by strawmanbobi
|
||||
**************************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "./include/irda_defs.h"
|
||||
#include "./include/irda_decode.h"
|
||||
#include "./include/irda_main.h"
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
// global variable definition
|
||||
UINT16 binary_length = 0;
|
||||
UINT8 *binary_content = NULL;
|
||||
|
||||
UINT8 decode_as_ac(char *file_name)
|
||||
INT8 irda_ac_file_open(const char* file_name);
|
||||
INT8 irda_tv_file_open(const char* file_name);
|
||||
|
||||
INT8 irda_ac_file_open(const char* file_name)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
UINT8 decode_as_ac(const char* file_name)
|
||||
{
|
||||
// keyboard input
|
||||
int in_char = 0;
|
||||
@@ -40,7 +85,7 @@ UINT8 decode_as_ac(char *file_name)
|
||||
ac_status.acWindDir = AC_SWING_ON;
|
||||
ac_status.acWindSpeed = AC_WS_AUTO;
|
||||
|
||||
if (IR_DECODE_FAILED == irda_ac_lib_open(file_name))
|
||||
if (IR_DECODE_FAILED == irda_ac_file_open(file_name))
|
||||
{
|
||||
irda_ac_lib_close();
|
||||
return IR_DECODE_FAILED;
|
||||
@@ -156,6 +201,43 @@ UINT8 decode_as_ac(char *file_name)
|
||||
|
||||
irda_ac_lib_close();
|
||||
|
||||
// free binary buffer
|
||||
irda_free(binary_content);
|
||||
binary_length = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -166,7 +248,7 @@ UINT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
||||
int key_code = -1;
|
||||
int count = 0;
|
||||
|
||||
if (IR_DECODE_FAILED == irda_tv_lib_open(file_name))
|
||||
if (IR_DECODE_FAILED == irda_tv_file_open(file_name))
|
||||
{
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
@@ -198,13 +280,13 @@ UINT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
||||
}
|
||||
} while('Q' != in_char);
|
||||
|
||||
// free binary buffer
|
||||
irda_free(binary_content);
|
||||
binary_length = 0;
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined BOARD_PC
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char function = '0';
|
||||
@@ -237,5 +319,3 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -89,9 +89,7 @@ INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp)
|
||||
INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type)
|
||||
{
|
||||
UINT16 hex_len = 0;
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
UINT16 i = 0;
|
||||
#endif
|
||||
UINT16 trav_offset = 0;
|
||||
UINT16 seg_index = 0;
|
||||
UINT8 *hex_data = NULL;
|
||||
@@ -128,7 +126,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_
|
||||
hex_data = NULL;
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
// have some debug
|
||||
IR_PRINTF("seg[%d].len = %d : \n", seg_index, comp_data[seg_index].seg_len);
|
||||
for(i = 0; i < comp_data[seg_index].seg_len; i++)
|
||||
@@ -136,7 +134,6 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_
|
||||
IR_PRINTF("[%02X] ", comp_data[seg_index].segment[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
if (trav_offset >= hex_len)
|
||||
{
|
||||
@@ -154,7 +151,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_
|
||||
hex_data = NULL;
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
// have some debug
|
||||
IR_PRINTF("seg[%d].len = %d : \n", seg_index, comp_data[seg_index].seg_len);
|
||||
for(i = 0; i < comp_data[seg_index].seg_len; i++)
|
||||
@@ -162,7 +159,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_
|
||||
IR_PRINTF("[%02X] ", comp_data[seg_index].segment[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
if (trav_offset >= hex_len)
|
||||
{
|
||||
break;
|
||||
@@ -191,8 +188,6 @@ INT8 parse_defaultcode_1002(struct tag_head *tag, ac_hex *default_code)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
INT8 parse_power_1_1001(struct tag_head *tag, power_1 *power1)
|
||||
{
|
||||
UINT16 hex_len = 0;
|
||||
@@ -250,8 +245,6 @@ INT8 parse_power_1_1001(struct tag_head *tag, power_1 *power1)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
INT8 parse_temp_1_1003(struct tag_head *tag, temp_1 *temp1)
|
||||
{
|
||||
UINT16 hex_len = 0;
|
||||
@@ -318,7 +311,6 @@ INT8 parse_temp_1_1003(struct tag_head *tag, temp_1 *temp1)
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
// have some debug
|
||||
IR_PRINTF("seg[%d].len = %d : \n", seg_index, temp1->comp_data[seg_index].seg_len);
|
||||
for(i = 0; i < temp1->comp_data[seg_index].seg_len; i++)
|
||||
@@ -326,7 +318,6 @@ INT8 parse_temp_1_1003(struct tag_head *tag, temp_1 *temp1)
|
||||
IR_PRINTF("[%02X] ", temp1->comp_data[seg_index].segment[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
if (trav_offset >= hex_len)
|
||||
{
|
||||
@@ -340,8 +331,6 @@ INT8 parse_temp_1_1003(struct tag_head *tag, temp_1 *temp1)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
INT8 parse_mode_1_1004(struct tag_head *tag, mode_1 *mode1)
|
||||
{
|
||||
UINT16 hex_len = 0;
|
||||
@@ -503,8 +492,6 @@ INT8 parse_swing_1_1007(struct tag_head *tag, swing_1 *swing1, UINT16 swing_coun
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len)
|
||||
{
|
||||
checksum->start_byte_pos = csdata[2];
|
||||
@@ -619,7 +606,6 @@ INT8 parse_checksum_1008_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 len
|
||||
|
||||
string_to_hex_common(buf, hex_data, hex_len);
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
UINT8 i = 0;
|
||||
IR_PRINTF("hex len = %d\n", hex_len);
|
||||
for(i = 0; i < hex_len; i++)
|
||||
@@ -627,7 +613,6 @@ INT8 parse_checksum_1008_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 len
|
||||
IR_PRINTF("[%02X] ", hex_data[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
|
||||
if (length != hex_data[0] + 1)
|
||||
{
|
||||
@@ -724,7 +709,6 @@ INT8 parse_checksum_1008(struct tag_head *tag, tchecksum *checksum)
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
UINT8 j = 0;
|
||||
for(i = 0; i < checksum->count; i++)
|
||||
{
|
||||
@@ -739,7 +723,7 @@ INT8 parse_checksum_1008(struct tag_head *tag, tchecksum *checksum)
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
@@ -922,7 +906,6 @@ INT8 parse_temp_2_1011(struct tag_head *tag, temp_2 *temp2)
|
||||
temp2->comp_data[seg_index].segment[i] = hex_data[i + 1] * seg_index;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
// have some debug
|
||||
IR_PRINTF("seg[%d].len = %d : \n", seg_index, temp2->comp_data[seg_index].seg_len);
|
||||
for(i = 0; i < temp2->comp_data[seg_index].seg_len; i++)
|
||||
@@ -930,7 +913,6 @@ INT8 parse_temp_2_1011(struct tag_head *tag, temp_2 *temp2)
|
||||
IR_PRINTF("[%02X] ", temp2->comp_data[seg_index].segment[i]);
|
||||
}
|
||||
IR_PRINTF("\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -959,8 +941,6 @@ INT8 parse_temp_2_1011(struct tag_head *tag, temp_2 *temp2)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#if (defined BOARD_PC) || (defined BOARD_ANDROID)
|
||||
|
||||
INT8 parse_mode_2_1012(struct tag_head *tag, mode_2 *mode2)
|
||||
{
|
||||
UINT16 hex_len = 0;
|
||||
@@ -1137,8 +1117,6 @@ INT8 parse_swing_2_1015(struct tag_head *tag, swing_2 *swing2, UINT16 swing_coun
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg)
|
||||
{
|
||||
UINT8 seg_len = 0;
|
||||
|
||||
@@ -17,8 +17,8 @@ Revision log:
|
||||
#include <string.h>
|
||||
|
||||
#include "./include/irda_defs.h"
|
||||
#include "./include/irda_lib.h"
|
||||
|
||||
#include "./include/irda_tv_parse.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
* MACROS
|
||||
@@ -74,13 +74,13 @@ struct buffer
|
||||
/**************************************************************************************************
|
||||
* LOCAL VARIABLES
|
||||
**************************************************************************************************/
|
||||
static struct buffer *pbuffer = &irda_file; /* Store irda library data */
|
||||
static struct buffer *pbuffer = &irda_file;
|
||||
|
||||
//static UINT8 *prot_name = NULL; //irda protocol name
|
||||
static UINT8 *prot_cycles_num = NULL; //irda protocol cycles num
|
||||
//static UINT8 *prot_name = NULL;
|
||||
static UINT8 *prot_cycles_num = NULL;
|
||||
static irda_cycles_t *prot_cycles_data[IRDA_MAX];
|
||||
static UINT8 prot_items_cnt = 0;
|
||||
static irda_data_t *prot_items_data = NULL; //irda protocol frame data
|
||||
static irda_data_t *prot_items_data = NULL;
|
||||
static irda_data_tv_t *remote_p;
|
||||
static UINT8 *remote_pdata = NULL;
|
||||
|
||||
@@ -90,8 +90,6 @@ static UINT8 irda_toggle_bit = FALSE;
|
||||
static UINT8 irda_decode_flag = IRDA_DECODE_1_BIT;
|
||||
static UINT8 cycles_num_size = 0;
|
||||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
* LOCAL TABLES
|
||||
**************************************************************************************************/
|
||||
@@ -100,7 +98,6 @@ static UINT8 cycles_num_size = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
* LOCAL FUNCTION PROTOTYPES
|
||||
**************************************************************************************************/
|
||||
@@ -111,20 +108,18 @@ static void process_decode_number(UINT8 keycode, irda_data_t *data, UINT8 valid_
|
||||
static void convert_to_irda_time(UINT8 value, UINT16 *irda_time);
|
||||
static void replace_with(irda_cycles_t *pcycles_num, UINT16 *irda_time);
|
||||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
* GLOBAL FUNCTIONS
|
||||
**************************************************************************************************/
|
||||
void irda_lib_open(UINT8 *binary_file, UINT16 binary_length)
|
||||
INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length)
|
||||
{
|
||||
// load binary to buffer
|
||||
pbuffer->data = binary_file;
|
||||
pbuffer->data = binary;
|
||||
pbuffer->len = binary_length;
|
||||
pbuffer->offset = 0;
|
||||
}
|
||||
|
||||
BOOL irda_lib_parse(UINT8 encode_type)
|
||||
BOOL tv_lib_parse(UINT8 encode_type)
|
||||
{
|
||||
if (FALSE == get_irda_protocol(encode_type))
|
||||
{
|
||||
@@ -134,7 +129,7 @@ BOOL irda_lib_parse(UINT8 encode_type)
|
||||
return get_irda_keymap();
|
||||
}
|
||||
|
||||
UINT16 irda_lib_control(UINT8 key, UINT16 *user_data)
|
||||
UINT16 tv_lib_control(UINT8 key, UINT16 *user_data)
|
||||
{
|
||||
UINT16 i = 0;
|
||||
|
||||
@@ -529,4 +524,3 @@ static void replace_with(irda_cycles_t *pcycles_num, UINT16 *irda_time)
|
||||
irda_level = IRDA_LEVEL_HIGH;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user