From 833284ca48ee9b80aa1c0207df4aa140428b7ac0 Mon Sep 17 00:00:00 2001 From: strawmanbobi Date: Sun, 29 Apr 2018 13:36:03 +0800 Subject: [PATCH] fixed examples for 0.1.4 --- android-example/app/build.gradle | 8 +- .../net/irext/ircontrol/IRApplication.java | 10 +- android-example/build.gradle | 3 +- android-example/decodesdk/build.gradle | 2 +- .../irextdecode/include/ir_ac_apply.h | 10 +- .../irextdecode/include/ir_ac_control.h | 192 +++++++++--------- .../include/ir_ac_parse_forbidden_info.h | 2 +- .../include/ir_ac_parse_parameter.h | 32 +-- .../decodesdk/irextdecode/include/ir_decode.h | 2 +- .../decodesdk/irextdecode/include/ir_defs.h | 12 +- .../irextdecode/include/ir_tv_control.h | 21 +- .../decodesdk/irextdecode/include/ir_utils.h | 6 +- .../decodesdk/irextdecode/src/ir_ac_apply.c | 88 ++++---- .../irextdecode/src/ir_ac_binary_parse.c | 22 +- .../irextdecode/src/ir_ac_build_frame.c | 22 +- .../decodesdk/irextdecode/src/ir_ac_control.c | 30 ++- .../src/ir_ac_parse_forbidden_info.c | 22 +- .../irextdecode/src/ir_ac_parse_frame_info.c | 54 ++--- .../irextdecode/src/ir_ac_parse_parameter.c | 102 +++++----- .../decodesdk/irextdecode/src/ir_decode.c | 31 +-- .../decodesdk/irextdecode/src/ir_test_main.c | 65 +++--- .../decodesdk/irextdecode/src/ir_tv_control.c | 41 ++-- .../decodesdk/irextdecode/src/ir_utils.c | 6 +- .../net/irext/webapi/WebAPICallbacks.java | 2 +- .../main/java/net/irext/webapi/WebAPIs.java | 32 +-- .../net/irext/webapi/request/BaseRequest.java | 14 +- .../irext/webapi/response/LoginResponse.java | 1 - 27 files changed, 431 insertions(+), 401 deletions(-) diff --git a/android-example/app/build.gradle b/android-example/app/build.gradle index c4c2436..d0cd6e9 100644 --- a/android-example/app/build.gradle +++ b/android-example/app/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion "25.0.2" + buildToolsVersion '27.0.3' defaultConfig { applicationId "net.irext.ircontrol" minSdkVersion 19 targetSdkVersion 25 - versionCode 2 - versionName '1.1' + versionCode 3 + versionName '0.1.4' } buildTypes { release { @@ -24,8 +24,6 @@ android { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 } productFlavors { } diff --git a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java index 74c1097..01f7d91 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java @@ -22,7 +22,7 @@ public class IRApplication extends com.activeandroid.app.Application { private static final String TAG = IRApplication.class.getSimpleName(); - private static final String ADDRESS = "http://irext.net"; + private static final String ADDRESS = "https://irext.net"; private static final String APP_NAME = "/irext-server"; public WebAPIs mWeAPIs = WebAPIs.getInstance(ADDRESS, APP_NAME); @@ -31,8 +31,8 @@ public class IRApplication extends com.activeandroid.app.Application { private SignInCallback mSignInCallback = new SignInCallback() { @Override - public void onSignInSuccess(UserApp admin) { - mUserApp = admin; + public void onSignInSuccess(UserApp userApp) { + mUserApp = userApp; } @Override @@ -46,7 +46,7 @@ public class IRApplication extends com.activeandroid.app.Application { } }; - public UserApp getAdmin() { + public UserApp getUserApp() { return mUserApp; } @@ -64,6 +64,8 @@ public class IRApplication extends com.activeandroid.app.Application { mWeAPIs.signIn(IRApplication.this, mSignInCallback); if (null != mUserApp) { Log.d(TAG, "signIn response : " + mUserApp.getId() + ", " + mUserApp.getToken()); + } else { + Log.w(TAG, "signIn failed"); } } }.start(); diff --git a/android-example/build.gradle b/android-example/build.gradle index a533a1b..a2ff042 100644 --- a/android-example/build.gradle +++ b/android-example/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -15,6 +15,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/android-example/decodesdk/build.gradle b/android-example/decodesdk/build.gradle index 383615e..4e38204 100644 --- a/android-example/decodesdk/build.gradle +++ b/android-example/decodesdk/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 25 - buildToolsVersion "25.0.2" + buildToolsVersion '27.0.3' defaultConfig { minSdkVersion 19 diff --git a/android-example/decodesdk/irextdecode/include/ir_ac_apply.h b/android-example/decodesdk/irextdecode/include/ir_ac_apply.h index 4c3db32..a9dc4d2 100644 --- a/android-example/decodesdk/irextdecode/include/ir_ac_apply.h +++ b/android-example/decodesdk/irextdecode/include/ir_ac_apply.h @@ -22,15 +22,15 @@ extern "C" #define MIN_TAG_LENGTH_TYPE_1 4 #define MIN_TAG_LENGTH_TYPE_2 6 -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code); INT8 apply_function(struct ac_protocol *protocol, UINT8 function); diff --git a/android-example/decodesdk/irextdecode/include/ir_ac_control.h b/android-example/decodesdk/irextdecode/include/ir_ac_control.h index 6d297c0..1ce4882 100644 --- a/android-example/decodesdk/irextdecode/include/ir_ac_control.h +++ b/android-example/decodesdk/irextdecode/include/ir_ac_control.h @@ -19,22 +19,22 @@ extern "C" #include "ir_defs.h" -#define TAG_COUNT_FOR_PROTOCOL 29 +#define TAG_COUNT_FOR_PROTOCOL 29 -#define TAG_INVALID 0xffff +#define TAG_INVALID 0xffff -#define MAX_DELAYCODE_NUM 16 -#define MAX_BITNUM 16 +#define MAX_DELAYCODE_NUM 16 +#define MAX_BITNUM 16 -#define AC_PARAMETER_TYPE_1 0 -#define AC_PARAMETER_TYPE_2 1 +#define AC_PARAMETER_TYPE_1 0 +#define AC_PARAMETER_TYPE_2 1 typedef enum { AC_POWER_ON = 0, AC_POWER_OFF, AC_POWER_MAX -} ac_power; +} t_ac_power; typedef enum { @@ -54,7 +54,7 @@ typedef enum AC_TEMP_29, AC_TEMP_30, AC_TEMP_MAX -} ac_temperature; +} t_ac_temperature; typedef enum { @@ -64,7 +64,7 @@ typedef enum AC_MODE_FAN, AC_MODE_DRY, AC_MODE_MAX -} ac_mode; +} t_ac_mode; typedef enum { @@ -76,7 +76,7 @@ typedef enum AC_FUNCTION_WIND_SWING, AC_FUNCTION_WIND_FIX, AC_FUNCTION_MAX, -} ac_function; +} t_ac_function; typedef enum { @@ -85,14 +85,14 @@ typedef enum AC_WS_MEDIUM, AC_WS_HIGH, AC_WS_MAX -} ac_wind_speed; +} t_ac_wind_speed; typedef enum { AC_SWING_ON = 0, AC_SWING_OFF, AC_SWING_MAX -} ac_swing; +} t_ac_swing; typedef enum { @@ -107,7 +107,7 @@ typedef enum TEMP_TYPE_DYNAMIC = 0, TEMP_TYPE_STATIC, TEMP_TYPE_MAX, -} temp_type; +} t_temp_type; // enumeration for application polymorphism typedef enum @@ -120,32 +120,32 @@ typedef enum AC_APPLY_WIND_SWING, AC_APPLY_WIND_FIX, AC_APPLY_MAX -} ac_apply; +} t_ac_apply; typedef struct _ac_hex { UINT8 len; UINT8 *data; -} ac_hex; +} t_ac_hex; typedef struct _ac_level { UINT16 low; UINT16 high; -} ac_level; +} t_ac_level; typedef struct _ac_bootcode { UINT16 len; UINT16 data[16]; -} ac_bootcode; +} t_ac_bootcode; typedef struct _ac_delaycode { INT16 pos; UINT16 time[8]; UINT16 time_cnt; -} ac_delaycode; +} t_ac_delaycode; /* * the array of tag_100X application data @@ -157,78 +157,78 @@ typedef struct _tag_comp_type_1 { UINT8 seg_len; UINT8 *segment; -} tag_comp; +} t_tag_comp; typedef struct _tag_swing_info { swing_type type; UINT8 mode_count; UINT8 dir_index; -} swing_info; +} t_swing_info; typedef struct _tag_power_1 { UINT8 len; - tag_comp comp_data[AC_POWER_MAX]; -} power_1; + t_tag_comp comp_data[AC_POWER_MAX]; +} t_power_1; typedef struct _tag_temp_1 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_1; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_1; typedef struct tag_mode_1 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_1; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_1; typedef struct tag_speed_1 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_1; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_1; typedef struct tag_swing_1 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_1; + t_tag_comp *comp_data; +} t_swing_1; typedef struct tag_temp_2 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_2; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_2; typedef struct tag_mode_2 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_2; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_2; typedef struct tag_speed_2 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_2; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_2; typedef struct tag_swing_2 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_2; + t_tag_comp *comp_data; +} t_swing_2; #if defined SUPPORT_HORIZONTAL_SWING typedef struct tag_horiswing_1 { UINT16 len; - tag_comp comp_data[AC_HORI_SWING_MAX]; + t_tag_comp comp_data[AC_HORI_SWING_MAX]; } hori_swing_1; #endif @@ -241,39 +241,39 @@ typedef struct _tag_checksum_data UINT8 checksum_byte_pos; UINT8 checksum_plus; UINT8 *spec_pos; -} tag_checksum_data; +} t_tag_checksum_data; typedef struct tag_checksum { UINT8 len; UINT16 count; - tag_checksum_data *checksum_data; -} tchecksum; + t_tag_checksum_data *checksum_data; +} t_checksum; typedef struct tag_function_1 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_1; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_1; typedef struct tag_function_2 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_2; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_2; typedef struct tag_solo_code { UINT8 len; UINT8 solo_func_count; UINT8 solo_function_codes[AC_FUNCTION_MAX - 1]; -} solo_code; +} t_solo_code; typedef struct _ac_bitnum { INT16 pos; UINT16 bits; -} ac_bitnum; +} t_ac_bit_num; typedef enum { @@ -283,7 +283,7 @@ typedef enum N_FAN, N_DRY, N_MODE_MAX, -} ac_n_mode; +} t_ac_n_mode; typedef enum { @@ -296,68 +296,69 @@ typedef enum CHECKSUM_TYPE_SPEC_HALF_BYTE_ONE_BYTE, CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE_ONE_BYTE, CHECKSUM_TYPE_MAX, -} checksum_type; +} t_checksum_type; typedef struct _ac_n_mode_info { UINT8 enable; - UINT8 allspeed; - UINT8 alltemp; + UINT8 all_speed; + UINT8 all_temp; UINT8 temp[AC_TEMP_MAX]; UINT8 temp_cnt; UINT8 speed[AC_WS_MAX]; UINT8 speed_cnt; -} ac_n_mode_info; +} t_ac_n_mode_info; typedef struct ac_protocol { UINT8 endian; - // ac_hex default_code; - ac_hex default_code; - ac_level zero; - ac_level one; - ac_bootcode bootcode; - ac_delaycode dc[MAX_DELAYCODE_NUM]; - power_1 power1; - temp_1 temp1; - mode_1 mode1; - speed_1 speed1; - swing_1 swing1; - tchecksum checksum; + // t_ac_hex default_code; + t_ac_hex default_code; + t_ac_level zero; + t_ac_level one; + t_ac_bootcode boot_code; + t_ac_delaycode dc[MAX_DELAYCODE_NUM]; + t_power_1 power1; + t_temp_1 temp1; + t_mode_1 mode1; + t_speed_1 speed1; + t_swing_1 swing1; + t_checksum checksum; - function_1 function1; - function_2 function2; + t_function_1 function1; + t_function_2 function2; - temp_2 temp2; - mode_2 mode2; - speed_2 speed2; - swing_2 swing2; + t_temp_2 temp2; + t_mode_2 mode2; + t_speed_2 speed2; + t_swing_2 swing2; - swing_info si; - solo_code sc; + t_swing_info si; + t_solo_code sc; UINT8 swing_status; BOOL change_wind_direction; UINT16 dc_cnt; - ac_bitnum bitnum[MAX_BITNUM]; - UINT16 bitnum_cnt; + t_ac_bit_num bit_num[MAX_BITNUM]; + UINT16 bit_num_cnt; UINT16 repeat_times; - UINT16 frame_length; - ac_n_mode_info n_mode[N_MODE_MAX]; + t_ac_n_mode_info n_mode[N_MODE_MAX]; UINT16 code_cnt; - UINT8 lastbit; + UINT8 last_bit; UINT16 *time; UINT8 solo_function_mark; -} protocol; + + UINT16 frame_length; +} t_ac_protocol; typedef struct tag_head { UINT16 tag; UINT16 len; - unsigned short offset; - UINT8 *pdata; + UINT16 offset; + UINT8 *p_data; } t_tag_head; struct ir_bin_buffer @@ -369,19 +370,18 @@ struct ir_bin_buffer typedef struct REMOTE_AC_STATUS { - ac_power acPower; - ac_temperature acTemp; - ac_mode acMode; - ac_swing acWindDir; - ac_wind_speed acWindSpeed; - UINT8 acDisplay; - UINT8 acSleep; - UINT8 acTimer; -} remote_ac_status_t; + t_ac_power ac_power; + t_ac_temperature ac_temp; + t_ac_mode ac_mode; + t_ac_swing ac_wind_dir; + t_ac_wind_speed ac_wind_speed; + UINT8 ac_display; + UINT8 ac_sleep; + UINT8 ac_timer; +} t_remote_ac_status; // function polymorphism -typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 function_code); - +typedef INT8 (*lp_apply_ac_parameter)(t_remote_ac_status ac_status, UINT8 function_code); #define TAG_AC_BOOT_CODE 1 #define TAG_AC_ZERO 2 @@ -389,7 +389,7 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_DELAY_CODE 4 #define TAG_AC_FRAME_LENGTH 5 #define TAG_AC_ENDIAN 6 -#define TAG_AC_LASTBIT 7 +#define TAG_AC_LAST_BIT 7 #define TAG_AC_POWER_1 21 #define TAG_AC_DEFAULT_CODE 22 @@ -413,17 +413,17 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 45 #define TAG_AC_SWING_INFO 46 #define TAG_AC_REPEAT_TIMES 47 -#define TAG_AC_BITNUM 48 +#define TAG_AC_BIT_NUM 48 // definition about size -#define PROTOCOL_SIZE (sizeof(protocol)) +#define PROTOCOL_SIZE (sizeof(t_ac_protocol)) /* exported variables */ extern UINT8 *ir_hex_code; extern UINT8 ir_hex_len; -extern protocol *context; +extern t_ac_protocol *context; extern INT8 ir_ac_lib_parse(); diff --git a/android-example/decodesdk/irextdecode/include/ir_ac_parse_forbidden_info.h b/android-example/decodesdk/irextdecode/include/ir_ac_parse_forbidden_info.h index c0cce82..8f0f5b1 100644 --- a/android-example/decodesdk/irextdecode/include/ir_ac_parse_forbidden_info.h +++ b/android-example/decodesdk/irextdecode/include/ir_ac_parse_forbidden_info.h @@ -19,7 +19,7 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_nmode(struct tag_head *tag, ac_n_mode index); +extern INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index); #ifdef __cplusplus } diff --git a/android-example/decodesdk/irextdecode/include/ir_ac_parse_parameter.h b/android-example/decodesdk/irextdecode/include/ir_ac_parse_parameter.h index 1da7132..6d53e89 100644 --- a/android-example/decodesdk/irextdecode/include/ir_ac_parse_parameter.h +++ b/android-example/decodesdk/irextdecode/include/ir_ac_parse_parameter.h @@ -19,37 +19,37 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type); +extern INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type); -extern INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code); +extern INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code); -extern INT8 parse_power_1(struct tag_head *tag, power_1 *power1); +extern INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1); -extern INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1); +extern INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1); -extern INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1); +extern INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1); -extern INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1); +extern INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1); -extern INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count); +extern INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count); -extern INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum); +extern INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum); -extern INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1); +extern INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1); -extern INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2); +extern INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2); -extern INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2); +extern INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2); -extern INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2); +extern INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2); -extern INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count); +extern INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count); -extern INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2); +extern INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2); -extern INT8 parse_swing_info(struct tag_head *tag, swing_info *si); +extern INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si); -extern INT8 parse_solo_code(struct tag_head *tag, solo_code *sc); +extern INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc); #ifdef __cplusplus } diff --git a/android-example/decodesdk/irextdecode/include/ir_decode.h b/android-example/decodesdk/irextdecode/include/ir_decode.h index 5ae4b17..b2fff07 100644 --- a/android-example/decodesdk/irextdecode/include/ir_decode.h +++ b/android-example/decodesdk/irextdecode/include/ir_decode.h @@ -75,7 +75,7 @@ extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8 * * returns: length of decoded data (0 indicates decode failure) */ -extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction); +extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction); /** * function ir_close diff --git a/android-example/decodesdk/irextdecode/include/ir_defs.h b/android-example/decodesdk/irextdecode/include/ir_defs.h index 7b60e53..b16e660 100644 --- a/android-example/decodesdk/irextdecode/include/ir_defs.h +++ b/android-example/decodesdk/irextdecode/include/ir_defs.h @@ -29,6 +29,10 @@ extern "C" #define TRUE 1 #define FALSE 0 +#define FORMAT_HEX 16 +#define FORMAT_DECIMAL 10 + + typedef unsigned char UINT8; typedef signed char INT8; typedef unsigned short UINT16; @@ -39,12 +43,12 @@ typedef int BOOL; void noprint(const char *fmt, ...); -#if !defined BOARD_CC26XX -#define ir_malloc(A) malloc(A) -#define ir_free(A) free(A) -#else +#if defined BOARD_CC26XX #define ir_malloc(A) ICall_malloc(A) #define ir_free(A) ICall_free(A) +#else +#define ir_malloc(A) malloc(A) +#define ir_free(A) free(A) #endif #define ir_memcpy(A, B, C) memcpy(A, B, C) diff --git a/android-example/decodesdk/irextdecode/include/ir_tv_control.h b/android-example/decodesdk/irextdecode/include/ir_tv_control.h index a4e1661..50dfaf4 100644 --- a/android-example/decodesdk/irextdecode/include/ir_tv_control.h +++ b/android-example/decodesdk/irextdecode/include/ir_tv_control.h @@ -63,7 +63,7 @@ typedef enum ir_flags IRDA_E, IRDA_F, IRDA_MAX = 20, -} ir_flags_t; +} t_ir_flags; typedef struct ir_data { @@ -71,9 +71,9 @@ typedef struct ir_data UINT8 lsb; UINT8 mode; UINT8 index; -} ir_data_t; +} t_ir_data; -#if !defined BOARD_51 +#if !defined BOARD_51 && !defined BOARD_STM8 #pragma pack(1) #endif typedef struct ir_cycles @@ -81,8 +81,9 @@ typedef struct ir_cycles UINT8 flag; UINT16 mask; UINT16 space; -} ir_cycles_t; -#if !defined BOARD_51 +} t_ir_cycles; + +#if !defined BOARD_51 && !defined BOARD_STM8 #pragma pack() #endif @@ -113,7 +114,7 @@ typedef enum tv_key_value TV_8, TV_9, TV_KEY_MAX, -} tv_key_value_t; +} t_tv_key_value; typedef enum stb_key_value @@ -143,7 +144,7 @@ typedef enum stb_key_value STB_8, STB_9, STB_KEY_MAX, -} stb_key_value_t; +} t_stb_key_value; typedef enum nw_key_value { @@ -169,7 +170,7 @@ typedef enum nw_key_value NW_8, NW_9, NW_KEY_MAX, -} nw_key_value_t; +} t_nw_key_value; typedef enum cm_key_value { @@ -189,13 +190,13 @@ typedef enum cm_key_value CM_MENU, CM_MODE, CM_KEY_MAX, -} cm_key_value_t; +} t_cm_key_value; typedef struct ir_data_tv { char magic[4]; UINT8 per_keycode_bytes; -} ir_data_tv_t; +} t_ir_data_tv; extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); diff --git a/android-example/decodesdk/irextdecode/include/ir_utils.h b/android-example/decodesdk/irextdecode/include/ir_utils.h index 2f036ae..667bdf1 100644 --- a/android-example/decodesdk/irextdecode/include/ir_utils.h +++ b/android-example/decodesdk/irextdecode/include/ir_utils.h @@ -22,13 +22,11 @@ extern "C" #include -extern void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len); - -extern void string_to_intArray(UINT8 *p, UINT8 *binary_code, UINT16 len); +extern void string_to_hex(UINT8 *p, t_ac_hex *pac_hex); extern void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len); -extern BOOL isin(UINT8 array[], UINT8 value, UINT8 len); +extern BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len); extern void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src); diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_apply.c b/android-example/decodesdk/irextdecode/src/ir_ac_apply.c index 7206bcc..905ddc8 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_apply.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_apply.c @@ -17,16 +17,16 @@ static INT8 apply_ac_power(struct ac_protocol *protocol, UINT8 power_status); static INT8 apply_ac_mode(struct ac_protocol *protocol, UINT8 mode_status); -static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temperature); +static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temp_diff); static INT8 apply_ac_wind_speed(struct ac_protocol *protocol, UINT8 wind_speed); -static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_status); +static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode); static UINT8 has_function(struct ac_protocol *protocol, UINT8 function); -INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_1(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { if (0 != (comp_data->seg_len & 0x01)) { @@ -45,7 +45,7 @@ INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_SUCCEEDED; } -INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_2(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { UINT8 start_bit = 0; UINT8 end_bit = 0; @@ -59,11 +59,10 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_FAILED; } - // TODO: to be validated start_bit = comp_data->segment[current_seg]; end_bit = comp_data->segment[current_seg + 1]; cover_byte_pos_hi = start_bit >> 3; - cover_byte_pos_lo = (end_bit - 1) >> 3; + cover_byte_pos_lo = (UINT8) (end_bit - 1) >> 3; if (cover_byte_pos_hi == cover_byte_pos_lo) { // cover_byte_pos_hi or cover_bytes_pos_lo is target byte to be applied with AC parameter @@ -72,12 +71,12 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren UINT8 int_start_bit = start_bit - (cover_byte_pos_hi << 3); UINT8 int_end_bit = end_bit - (cover_byte_pos_lo << 3); UINT8 bit_range = end_bit - start_bit; - UINT8 mask = (0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit); + UINT8 mask = (UINT8) ((0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit)); UINT8 origin = dc_data[cover_byte_pos_lo]; if (TRUE == is_temp) { - move_bit = 8 - int_end_bit; + move_bit = (UINT8) (8 - int_end_bit); value = (origin & mask) | (((((origin & ~mask) >> move_bit) + raw_value) << move_bit) & ~mask); } else @@ -88,14 +87,13 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren } else { - UINT8 value = 0x00; - UINT8 origin_hi = 0x00; - UINT8 origin_lo = 0x00; - UINT8 mask_hi = 0x00; - UINT8 mask_lo = 0x00; - UINT8 raw_value = 0x00; - UINT8 int_start_bit = 0x00; - UINT8 int_end_bit = 0x00; + UINT8 origin_hi = 0; + UINT8 origin_lo = 0; + UINT8 mask_hi = 0; + UINT8 mask_lo = 0; + UINT8 raw_value = 0; + UINT8 int_start_bit = 0; + UINT8 int_end_bit = 0; if (cover_byte_pos_hi > cover_byte_pos_lo) { @@ -111,8 +109,8 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren int_start_bit = start_bit - (cover_byte_pos_hi << 3); int_end_bit = end_bit - (cover_byte_pos_lo << 3); - mask_hi = 0xFF << (8 - int_start_bit); - mask_lo = 0xFF >> int_end_bit; + mask_hi = (UINT8) 0xFF << (8 - int_start_bit); + mask_lo = (UINT8) 0xFF >> int_end_bit; value = ((origin_hi & ~mask_hi) << int_end_bit) | ((origin_lo & ~mask_lo) >> (8 - int_end_bit)); @@ -121,11 +119,11 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren raw_value += value; } - dc_data[cover_byte_pos_hi] = (origin_hi & mask_hi) | - (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit); + dc_data[cover_byte_pos_hi] = (UINT8) ((origin_hi & mask_hi) | + (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit)); - dc_data[cover_byte_pos_lo] = (origin_lo & mask_lo) | - (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit)); + dc_data[cover_byte_pos_lo] = (UINT8) ((origin_lo & mask_lo) | + (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit))); } return IR_DECODE_SUCCEEDED; @@ -346,7 +344,7 @@ static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode) return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -374,7 +372,7 @@ static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inver return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_halfbyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -402,7 +400,7 @@ static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL i return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -442,18 +440,18 @@ static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL if (0 == (cs.checksum_byte_pos & 0x01)) { // save low bits and add checksum as high bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0x0F) | (checksum << 4); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0x0F) | (checksum << 4)); } else { // save high bits and add checksum as low bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F)); } return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -605,15 +603,15 @@ INT8 apply_checksum(struct ac_protocol *protocol) return IR_DECODE_SUCCEEDED; } -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code) { - apply_ac_power(context, ac_status.acPower); + apply_ac_power(context, ac_status.ac_power); return IR_DECODE_SUCCEEDED; } -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code) { - if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.acMode)) + if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.ac_mode)) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -626,16 +624,16 @@ INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].allspeed) + if (FALSE == context->n_mode[ac_status.ac_mode].all_speed) { // if this level is not in black list - if (!isin(context->n_mode[ac_status.acMode].speed, - ac_status.acWindSpeed, - context->n_mode[ac_status.acMode].speed_cnt)) + if (!is_in(context->n_mode[ac_status.ac_mode].speed, + ac_status.ac_wind_speed, + context->n_mode[ac_status.ac_mode].speed_cnt)) { - if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.acWindSpeed) && + if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.ac_wind_speed) && function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind @@ -676,7 +674,7 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code) { if (function_code == AC_FUNCTION_WIND_FIX) { @@ -719,15 +717,15 @@ INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].alltemp) + if (FALSE == context->n_mode[ac_status.ac_mode].all_temp) { - if (!isin(context->n_mode[ac_status.acMode].temp, - ac_status.acTemp, - context->n_mode[ac_status.acMode].temp_cnt)) + if (!is_in(context->n_mode[ac_status.ac_mode].temp, + ac_status.ac_temp, + context->n_mode[ac_status.ac_mode].temp_cnt)) { - if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp)) + if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.ac_temp)) { if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_binary_parse.c b/android-example/decodesdk/irextdecode/src/ir_ac_binary_parse.c index cf07677..b3360a4 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_binary_parse.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_binary_parse.c @@ -9,15 +9,18 @@ Revision log: * 2017-01-03: created by strawmanbobi **************************************************************************************/ -#include - #include "../include/ir_ac_binary_parse.h" #include "../include/ir_decode.h" UINT16 tag_head_offset = 0; extern struct ir_bin_buffer *p_ir_buffer; -extern struct tag_head *tags; + +#if defined USE_DYNAMIC_TAG +extern struct tag_head* tags; +#else +extern struct tag_head tags[]; +#endif UINT8 tag_count = 0; const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] = @@ -40,16 +43,25 @@ INT8 binary_parse_offset() tag_head_offset = (UINT16) ((tag_count << 1) + 1); +#if defined USE_DYNAMIC_TAG tags = (t_tag_head *) ir_malloc(tag_count * sizeof(t_tag_head)); + if (NULL == tags) { return IR_DECODE_FAILED; } +#endif for (i = 0; i < tag_count; i++) { tags[i].tag = tag_index[i]; + +#if defined BOARD_STM8 && defined COMPILER_IAR + UINT16 offset = *(phead + i); + tags[i].offset = (offset >> 8) | (offset << 8); +#else tags[i].offset = *(phead + i); +#endif if (tags[i].offset == TAG_INVALID) { @@ -96,7 +108,7 @@ INT8 binary_parse_len() void binary_tags_info() { -#if defined BOARD_PC +#if defined BOARD_PC && defined DEBUG UINT16 i = 0; for (i = 0; i < tag_count; i++) { @@ -114,7 +126,7 @@ INT8 binary_parse_data() UINT16 i = 0; for (i = 0; i < tag_count; i++) { - tags[i].pdata = p_ir_buffer->data + tags[i].offset + tag_head_offset; + tags[i].p_data = p_ir_buffer->data + tags[i].offset + tag_head_offset; } return IR_DECODE_SUCCEEDED; diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_build_frame.c b/android-example/decodesdk/irextdecode/src/ir_ac_build_frame.c index 1cf2b75..f3f767d 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_build_frame.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_build_frame.c @@ -12,7 +12,7 @@ Revision log: #include "../include/ir_ac_build_frame.h" #include "../include/ir_decode.h" -extern protocol *context; +extern t_ac_protocol *context; //return bit number per byte,default value is 8 @@ -21,19 +21,19 @@ UINT8 bits_per_byte(UINT8 index) UINT8 i = 0; UINT8 size = 0; - if (context->bitnum_cnt == 0) + if (context->bit_num_cnt == 0) return 8; //defaut value - if (context->bitnum_cnt >= MAX_BITNUM) + if (context->bit_num_cnt >= MAX_BITNUM) size = MAX_BITNUM; else - size = (UINT8) context->bitnum_cnt; + size = (UINT8) context->bit_num_cnt; for (i = 0; i < size; i++) { - if (context->bitnum[i].pos == index) - return (UINT8) context->bitnum[i].bits; - if (context->bitnum[i].pos > index) + if (context->bit_num[i].pos == index) + return (UINT8) context->bit_num[i].bits; + if (context->bit_num[i].pos > index) return 8; } return 8; @@ -67,7 +67,7 @@ UINT16 add_delaycode(UINT8 index) } } - if ((context->lastbit == 0) && (index == (ir_hex_len - 1))) + if ((context->last_bit == 0) && (index == (ir_hex_len - 1))) { context->time[context->code_cnt++] = context->one.low; //high } @@ -97,11 +97,11 @@ UINT16 create_ir_frame() context->code_cnt = 0; // boot code - for (i = 0; i < context->bootcode.len; i++) + for (i = 0; i < context->boot_code.len; i++) { - context->time[context->code_cnt++] = context->bootcode.data[i]; + context->time[context->code_cnt++] = context->boot_code.data[i]; } - //code_cnt += context->bootcode.len; + //code_cnt += context->boot_code.len; for (i = 0; i < ir_hex_len; i++) { diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_control.c b/android-example/decodesdk/irextdecode/src/ir_ac_control.c index b84d882..3d07dc0 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_control.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_control.c @@ -22,7 +22,12 @@ Revision log: #include "../include/ir_utils.h" +#if defined USE_DYNAMIC_TAG extern struct tag_head *tags; +#else +extern struct tag_head tags[]; +#endif + extern UINT8 tag_count; static INT8 ir_context_init(); @@ -30,7 +35,7 @@ static INT8 ir_context_init(); static INT8 ir_context_init() { - ir_memset(context, 0, sizeof(protocol)); + ir_memset(context, 0, sizeof(t_ac_protocol)); return IR_DECODE_SUCCEEDED; } @@ -59,14 +64,14 @@ INT8 ir_ac_lib_parse() binary_tags_info(); context->endian = 0; - context->lastbit = 0; + context->last_bit = 0; context->repeat_times = 1; for (i = 0; i < N_MODE_MAX; i++) { context->n_mode[i].enable = TRUE; - context->n_mode[i].allspeed = FALSE; - context->n_mode[i].alltemp = FALSE; + context->n_mode[i].all_speed = FALSE; + context->n_mode[i].all_temp = FALSE; ir_memset(context->n_mode[i].speed, 0x00, AC_WS_MAX); context->n_mode[i].speed_cnt = 0; ir_memset(context->n_mode[i].temp, 0x00, AC_TEMP_MAX); @@ -88,6 +93,7 @@ INT8 ir_ac_lib_parse() context->si.mode_count = 2; } context->si.dir_index = 0; + break; } } @@ -105,8 +111,8 @@ INT8 ir_ac_lib_parse() { context->swing1.count = context->si.mode_count; context->swing1.len = (UINT8) tags[i].len >> 1; - swing_space_size = sizeof(tag_comp) * context->si.mode_count; - context->swing1.comp_data = (tag_comp *) ir_malloc(swing_space_size); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing1.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing1.comp_data) { return IR_DECODE_FAILED; @@ -125,8 +131,8 @@ INT8 ir_ac_lib_parse() { context->swing2.count = context->si.mode_count; context->swing2.len = (UINT8) tags[i].len >> 1; - swing_space_size = sizeof(tag_comp) * context->si.mode_count; - context->swing2.comp_data = (tag_comp *) ir_malloc(swing_space_size); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing2.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing2.comp_data) { return IR_DECODE_FAILED; @@ -286,7 +292,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - else if (tags[i].tag == TAG_AC_BITNUM) + else if (tags[i].tag == TAG_AC_BIT_NUM) { if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) { @@ -350,7 +356,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - if (tags[i].tag == TAG_AC_LASTBIT) + if (tags[i].tag == TAG_AC_LAST_BIT) { if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) { @@ -359,11 +365,13 @@ INT8 ir_ac_lib_parse() } } +#if defined USE_DYNAMIC_TAG if (NULL != tags) { ir_free(tags); tags = NULL; } +#endif ir_hex_code = (UINT8 *) ir_malloc(context->default_code.len); if (NULL == ir_hex_code) @@ -382,7 +390,7 @@ INT8 ir_ac_lib_parse() // bit order from right to left : power, mode, temp+, temp-, wind_speed, swing, fix for (i = AC_FUNCTION_POWER; i < AC_FUNCTION_MAX; i++) { - if (isin(context->sc.solo_function_codes, i, context->sc.solo_func_count)) + if (is_in(context->sc.solo_function_codes, i, context->sc.solo_func_count)) { context->solo_function_mark |= (1 << (i - 1)); } diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_parse_forbidden_info.c b/android-example/decodesdk/irextdecode/src/ir_ac_parse_forbidden_info.c index d7c8c3a..0ea1c47 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_parse_forbidden_info.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_parse_forbidden_info.c @@ -17,10 +17,10 @@ Revision log: #include "../include/ir_ac_parse_forbidden_info.h" -extern protocol *context; +extern t_ac_protocol *context; -INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_speed(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; char *p = pdata; @@ -44,7 +44,7 @@ INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_temp(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; @@ -68,7 +68,7 @@ INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_pos(char *buf, ac_n_mode index) +INT8 parse_nmode_pos(char *buf, t_ac_n_mode index) { UINT16 i = 0; char data[64] = {0}; @@ -77,11 +77,11 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) { if (buf[0] == 'S' || buf[0] == 's') { - context->n_mode[index].allspeed = 1; + context->n_mode[index].all_speed = 1; } else if (buf[0] == 'T' || buf[0] == 't') { - context->n_mode[index].alltemp = 1; + context->n_mode[index].all_temp = 1; } return IR_DECODE_SUCCEEDED; } @@ -106,14 +106,14 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) +INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index) { UINT16 i = 0; UINT16 preindex = 0; char buf[64] = {0}; - if (tag->pdata[0] == 'N' && tag->pdata[1] == 'A') + if (tag->p_data[0] == 'N' && tag->p_data[1] == 'A') { // ban this function directly context->n_mode[index].enable = 0; @@ -127,16 +127,16 @@ INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); return IR_DECODE_SUCCEEDED; diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_parse_frame_info.c b/android-example/decodesdk/irextdecode/src/ir_ac_parse_frame_info.c index 5a20932..b96bca1 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_parse_frame_info.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_parse_frame_info.c @@ -28,7 +28,7 @@ INT8 parse_boot_code(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -41,13 +41,13 @@ INT8 parse_boot_code(struct tag_head *tag) { index++; } - ir_memcpy(buf, tag->pdata + pos, index - pos); + ir_memcpy(buf, tag->p_data + pos, index - pos); pos = (UINT16) (index + 1); index = pos; - context->bootcode.data[cnt++] = (UINT16) (atoi((char *) buf)); + context->boot_code.data[cnt++] = (UINT16) (atoi((char *) buf)); ir_memset(buf, 0, 16); } - context->bootcode.len = cnt; + context->boot_code.len = cnt; return IR_DECODE_SUCCEEDED; } @@ -62,7 +62,7 @@ INT8 parse_zero(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -74,8 +74,8 @@ INT8 parse_zero(struct tag_head *tag) index++; } - ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); + ir_memcpy(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->zero.low = (UINT16) (atoi((char *) low)); context->zero.high = (UINT16) (atoi((char *) high)); @@ -93,7 +93,7 @@ INT8 parse_one(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -104,8 +104,8 @@ INT8 parse_one(struct tag_head *tag) { index++; } - ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); + ir_memcpy(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->one.low = (UINT16) (atoi((char *) low)); context->one.high = (UINT16) (atoi((char *) high)); @@ -183,16 +183,16 @@ INT8 parse_delay_code(struct tag_head *tag) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); @@ -217,7 +217,7 @@ INT8 parse_frame_len(struct tag_head *tag, UINT16 len) ir_memset(temp, 0x00, len + 1); - ir_memcpy(temp, tag->pdata, len); + ir_memcpy(temp, tag->p_data, len); temp[len] = '\0'; context->frame_length = (UINT16) (atoi((char *) temp)); @@ -234,7 +234,7 @@ INT8 parse_endian(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); + ir_memcpy(buf, tag->p_data, tag->len); context->endian = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -247,8 +247,8 @@ INT8 parse_lastbit(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); - context->lastbit = (UINT8) (atoi((char *) buf)); + ir_memcpy(buf, tag->p_data, tag->len); + context->last_bit = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -260,7 +260,7 @@ INT8 parse_repeat_times(struct tag_head *tag) return IR_DECODE_FAILED; } - ir_memcpy(asc_code, tag->pdata, tag->len); + ir_memcpy(asc_code, tag->p_data, tag->len); context->repeat_times = (UINT16) (atoi((char *) asc_code)); @@ -287,9 +287,9 @@ INT8 parse_delay_code_tag48_pos(UINT8 *buf) } } - context->bitnum[context->bitnum_cnt].pos = (UINT16) (atoi((char *) start)); - context->bitnum[context->bitnum_cnt].bits = (UINT16) (atoi((char *) data)); - context->bitnum_cnt++; + context->bit_num[context->bit_num_cnt].pos = (UINT16) (atoi((char *) start)); + context->bit_num[context->bit_num_cnt].bits = (UINT16) (atoi((char *) data)); + context->bit_num_cnt++; return IR_DECODE_SUCCEEDED; } @@ -307,23 +307,23 @@ INT8 parse_bit_num(struct tag_head *tag) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); - for (i = 0; i < context->bitnum_cnt; i++) + for (i = 0; i < context->bit_num_cnt; i++) { - if (context->bitnum[i].pos == -1) - context->bitnum[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos + if (context->bit_num[i].pos == -1) + context->bit_num[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos } return IR_DECODE_SUCCEEDED; } diff --git a/android-example/decodesdk/irextdecode/src/ir_ac_parse_parameter.c b/android-example/decodesdk/irextdecode/src/ir_ac_parse_parameter.c index 39b03b7..e5c8cea 100644 --- a/android-example/decodesdk/irextdecode/src/ir_ac_parse_parameter.c +++ b/android-example/decodesdk/irextdecode/src/ir_ac_parse_parameter.c @@ -17,7 +17,7 @@ Revision log: #include "../include/ir_ac_parse_parameter.h" -INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -43,7 +43,7 @@ INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -69,7 +69,7 @@ INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type) +INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -93,10 +93,9 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to AC data structure - //*comp_len = hex_len; if (AC_PARAMETER_TYPE_1 == type) { @@ -136,22 +135,19 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_SUCCEEDED; } -INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code) +INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code) { - UINT16 byteLen = 0; - if (NULL == tag) { return IR_DECODE_FAILED; } - byteLen = tag->len >> 1; - string_to_hex(tag->pdata, default_code, byteLen); + string_to_hex(tag->p_data, default_code); return IR_DECODE_SUCCEEDED; } -INT8 parse_power_1(struct tag_head *tag, power_1 *power1) +INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -176,7 +172,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to power1 data structure power1->len = (UINT8) hex_len; @@ -201,7 +197,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) +INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1) { UINT16 hex_len = 0; UINT16 i = 0; @@ -222,7 +218,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -276,7 +272,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) +INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -296,7 +292,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode1->len = (UINT8) hex_len; @@ -320,7 +316,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) +INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -340,7 +336,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed1->len = (UINT8) hex_len; @@ -364,7 +360,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) +INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -384,12 +380,12 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing1 data structure swing1->count = swing_count; swing1->len = (UINT8) hex_len; - swing1->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing1->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing1->comp_data) { ir_free(hex_data); @@ -415,7 +411,7 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -434,7 +430,7 @@ INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT1 return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -452,7 +448,7 @@ INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { /* * note: @@ -478,14 +474,14 @@ INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *check return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum_malloc(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 cnt = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { cnt++; } @@ -493,18 +489,18 @@ INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) checksum->len = (UINT8) ((tag->len - cnt) >> 1); checksum->count = (UINT16) (cnt + 1); - checksum->checksum_data = (tag_checksum_data *) ir_malloc(sizeof(tag_checksum_data) * checksum->count); + checksum->checksum_data = (t_tag_checksum_data *) ir_malloc(sizeof(t_tag_checksum_data) * checksum->count); if (NULL == checksum->checksum_data) { return IR_DECODE_FAILED; } - ir_memset(checksum->checksum_data, 0x00, sizeof(tag_checksum_data) * checksum->count); + ir_memset(checksum->checksum_data, 0x00, sizeof(t_tag_checksum_data) * checksum->count); return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) +INT8 parse_checksum_data(UINT8 *buf, t_tag_checksum_data *checksum, UINT8 length) { UINT8 *hex_data = NULL; UINT16 hex_len = 0; @@ -574,7 +570,7 @@ INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 num = 0; @@ -597,9 +593,9 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -610,7 +606,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) } } - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -620,7 +616,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -687,7 +683,7 @@ INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) +INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -712,7 +708,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function1->len = (UINT8) hex_len; @@ -743,7 +739,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) +INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2) { UINT16 hex_len = 0; UINT16 i = 0; @@ -769,7 +765,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -823,7 +819,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) +INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -848,7 +844,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode2->len = (UINT8) hex_len; @@ -872,7 +868,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) +INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -897,7 +893,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed2->len = (UINT8) hex_len; @@ -921,7 +917,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) +INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -946,12 +942,12 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing2 data structure swing2->count = swing_count; swing2->len = (UINT8) hex_len; - swing2->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing2->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing2->comp_data) { ir_free(hex_data); @@ -977,7 +973,7 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -1045,7 +1041,7 @@ INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) +INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -1070,7 +1066,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function2->len = (UINT8) hex_len; @@ -1101,7 +1097,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_info(struct tag_head *tag, swing_info *si) +INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si) { if (NULL == tag) { @@ -1117,13 +1113,13 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) */ if (1 == tag->len) { - if ('0' == tag->pdata[0]) + if ('0' == tag->p_data[0]) { // to identify if there is only 1 status in TAG 26 OR 33 si->type = SWING_TYPE_NOT_SPECIFIED; si->mode_count = 0; } - else if ('1' == tag->pdata[0]) + else if ('1' == tag->p_data[0]) { si->type = SWING_TYPE_SWING_ONLY; si->mode_count = 1; @@ -1145,7 +1141,7 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) return IR_DECODE_SUCCEEDED; } -INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) +INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc) { UINT16 hex_len = 0; UINT8 *hex_data = NULL; @@ -1175,7 +1171,7 @@ INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) { return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure sc->len = (UINT8) hex_len; diff --git a/android-example/decodesdk/irextdecode/src/ir_decode.c b/android-example/decodesdk/irextdecode/src/ir_decode.c index cfc7b5b..5391b2b 100644 --- a/android-example/decodesdk/irextdecode/src/ir_decode.c +++ b/android-example/decodesdk/irextdecode/src/ir_decode.c @@ -21,8 +21,12 @@ Revision log: struct ir_bin_buffer binary_file; struct ir_bin_buffer *p_ir_buffer = &binary_file; -struct tag_head *tags; +#if defined USE_DYNAMIC_TAG +struct tag_head *tags; +#else +struct tag_head tags[TAG_COUNT_FOR_PROTOCOL]; +#endif UINT8 *ir_hex_code = NULL; UINT8 ir_hex_len = 0; @@ -35,7 +39,7 @@ UINT8 *binary_content = NULL; UINT8 ir_binary_type = IR_TYPE_STATUS; UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY; -protocol *context = (protocol *) byteArray; +t_ac_protocol *context = (t_ac_protocol *) byteArray; lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = { @@ -51,7 +55,7 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = // static functions declarations static INT8 ir_ac_file_open(const char *file_name); static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length); -static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction); static INT8 ir_ac_lib_close(); static INT8 ir_tv_file_open(const char *file_name); @@ -159,7 +163,7 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar } -UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* 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) { @@ -257,7 +261,7 @@ static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length) return IR_DECODE_SUCCEEDED; } -static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction) { UINT16 time_length = 0; @@ -281,7 +285,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, ir_memcpy(ir_hex_code, context->default_code.data, context->default_code.len); #if defined USE_APPLY_TABLE - if(ac_status.acPower != AC_POWER_OFF) + if(ac_status.ac_power != AC_POWER_OFF) { for (i = AC_APPLY_POWER; i < AC_APPLY_MAX; i++) { @@ -289,7 +293,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, } } #else - if (ac_status.acPower == AC_POWER_OFF) + if (ac_status.ac_power == AC_POWER_OFF) { // otherwise, power should always be applied apply_power(ac_status, function_code); @@ -297,7 +301,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, else { // check the mode as the first priority, despite any other status - if (TRUE == context->n_mode[ac_status.acMode].enable) + if (TRUE == context->n_mode[ac_status.ac_mode].enable) { if (is_solo_function(function_code)) { @@ -375,12 +379,15 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, static INT8 ir_ac_lib_close() { +#if defined USE_DYNAMIC_TAG // free context if (NULL != tags) { ir_free(tags); tags = NULL; } +#endif + free_ac_context(); return IR_DECODE_SUCCEEDED; @@ -400,7 +407,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].alltemp) + if (1 == context->n_mode[ac_mode].all_temp) { *temp_min = *temp_max = -1; return IR_DECODE_SUCCEEDED; @@ -410,7 +417,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) *temp_max = -1; for (i = 0; i < AC_TEMP_MAX; i++) { - if (isin(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || + if (is_in(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || (context->temp1.len != 0 && 0 == context->temp1.comp_data[i].seg_len) || (context->temp2.len != 0 && 0 == context->temp2.comp_data[i].seg_len)) { @@ -463,7 +470,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].allspeed) + if (1 == context->n_mode[ac_mode].all_speed) { *supported_wind_speed = 0; return IR_DECODE_SUCCEEDED; @@ -473,7 +480,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) for (i = 0; i < AC_WS_MAX; i++) { - if (isin(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || + if (is_in(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || (context->speed1.len != 0 && 0 == context->speed1.comp_data[i].seg_len) || (context->speed2.len != 0 && 0 == context->speed2.comp_data[i].seg_len)) { diff --git a/android-example/decodesdk/irextdecode/src/ir_test_main.c b/android-example/decodesdk/irextdecode/src/ir_test_main.c index 10db3de..c77f608 100644 --- a/android-example/decodesdk/irextdecode/src/ir_test_main.c +++ b/android-example/decodesdk/irextdecode/src/ir_test_main.c @@ -15,7 +15,7 @@ Revision log: #include "../include/ir_decode.h" // global variable definition -remote_ac_status_t ac_status; +t_remote_ac_status ac_status; UINT16 user_data[USER_DATA_SIZE]; @@ -40,14 +40,14 @@ INT8 decode_as_ac(char *file_name) BOOL need_control; // init air conditioner status - ac_status.acDisplay = 0; - ac_status.acSleep = 0; - ac_status.acTimer = 0; - ac_status.acPower = AC_POWER_OFF; - ac_status.acMode = AC_MODE_COOL; - ac_status.acTemp = AC_TEMP_20; - ac_status.acWindDir = AC_SWING_ON; - ac_status.acWindSpeed = AC_WS_AUTO; + ac_status.ac_display = 0; + ac_status.ac_sleep = 0; + ac_status.ac_timer = 0; + ac_status.ac_power = AC_POWER_OFF; + ac_status.ac_mode = AC_MODE_COOL; + ac_status.ac_temp = AC_TEMP_20; + ac_status.ac_wind_dir = AC_SWING_ON; + ac_status.ac_wind_speed = AC_WS_AUTO; if (IR_DECODE_FAILED == ir_file_open(IR_CATEGORY_AC, 0, file_name)) { @@ -65,45 +65,52 @@ INT8 decode_as_ac(char *file_name) case 'w': case 'W': // temperature plus - ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.acTemp + 1)); + ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_30) ? AC_TEMP_30 : (ac_status.ac_temp + 1)); function_code = AC_FUNCTION_TEMPERATURE_UP; break; + case 's': case 'S': // temperature minus - ac_status.acTemp = ((ac_status.acTemp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.acTemp - 1)); + ac_status.ac_temp = ((ac_status.ac_temp == AC_TEMP_16) ? AC_TEMP_16 : (ac_status.ac_temp - 1)); function_code = AC_FUNCTION_TEMPERATURE_DOWN; break; + case 'a': case 'A': // wind speed loop - ++ac_status.acWindSpeed; - ac_status.acWindSpeed = ac_status.acWindSpeed % AC_WS_MAX; + ++ac_status.ac_wind_speed; + ac_status.ac_wind_speed = ac_status.ac_wind_speed % AC_WS_MAX; function_code = AC_FUNCTION_WIND_SPEED; break; + case 'd': case 'D': // wind swing loop - ac_status.acWindDir = ((ac_status.acWindDir == 0) ? AC_SWING_OFF : AC_SWING_ON); + ac_status.ac_wind_dir = ((ac_status.ac_wind_dir == 0) ? AC_SWING_OFF : AC_SWING_ON); function_code = AC_FUNCTION_WIND_SWING; break; + case 'q': case 'Q': - ++ac_status.acMode; - ac_status.acMode = ac_status.acMode % AC_MODE_MAX; + ++ac_status.ac_mode; + ac_status.ac_mode = ac_status.ac_mode % AC_MODE_MAX; function_code = AC_FUNCTION_MODE; break; + case '1': // turn on - ac_status.acPower = AC_POWER_ON; + ac_status.ac_power = AC_POWER_ON; function_code = AC_FUNCTION_POWER; break; + case '2': // turn off - ac_status.acPower = AC_POWER_OFF; + ac_status.ac_power = AC_POWER_OFF; // FUNCTION MAX refers to power off // function_code = AC_FUNCTION_POWER; break; + case '3': if (IR_DECODE_SUCCEEDED == get_supported_mode(&supported_mode)) { @@ -113,25 +120,25 @@ INT8 decode_as_ac(char *file_name) break; case '4': - if (IR_DECODE_SUCCEEDED == get_supported_swing(ac_status.acMode, &supported_swing)) + if (IR_DECODE_SUCCEEDED == get_supported_swing(ac_status.ac_mode, &supported_swing)) { - ir_printf("\nsupported swing in %d = %02X\n", ac_status.acMode, supported_swing); + ir_printf("\nsupported swing in %d = %02X\n", ac_status.ac_mode, supported_swing); } need_control = FALSE; break; case '5': - if (IR_DECODE_SUCCEEDED == get_supported_wind_speed(ac_status.acMode, &supported_speed)) + if (IR_DECODE_SUCCEEDED == get_supported_wind_speed(ac_status.ac_mode, &supported_speed)) { - ir_printf("\nsupported wind speed in %d = %02X\n", ac_status.acMode, supported_speed); + ir_printf("\nsupported wind speed in %d = %02X\n", ac_status.ac_mode, supported_speed); } need_control = FALSE; break; case '6': - if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.acMode, &min_temperature, &max_temperature)) + if (IR_DECODE_SUCCEEDED == get_temperature_range(ac_status.ac_mode, &min_temperature, &max_temperature)) { ir_printf("\nsupported temperature range in mode %d = %d, %d\n", - ac_status.acMode, min_temperature, max_temperature); + ac_status.ac_mode, min_temperature, max_temperature); } need_control = FALSE; break; @@ -152,11 +159,11 @@ INT8 decode_as_ac(char *file_name) if (TRUE == op_match && TRUE == need_control) { ir_printf("switch AC to power = %d, mode = %d, temp = %d, speed = %d, swing = %d\n", - ac_status.acPower, - ac_status.acMode, - ac_status.acTemp, - ac_status.acWindSpeed, - ac_status.acWindDir + ac_status.ac_power, + ac_status.ac_mode, + ac_status.ac_temp, + ac_status.ac_wind_speed, + ac_status.ac_wind_dir ); ir_decode(function_code, user_data, &ac_status, TRUE); diff --git a/android-example/decodesdk/irextdecode/src/ir_tv_control.c b/android-example/decodesdk/irextdecode/src/ir_tv_control.c index e4b04ba..78cb9b9 100644 --- a/android-example/decodesdk/irextdecode/src/ir_tv_control.c +++ b/android-example/decodesdk/irextdecode/src/ir_tv_control.c @@ -26,12 +26,11 @@ struct buffer static struct buffer *pbuffer = &ir_file; -//static UINT8 *prot_name = NULL; static UINT8 *prot_cycles_num = NULL; -static ir_cycles_t *prot_cycles_data[IRDA_MAX]; +static t_ir_cycles *prot_cycles_data[IRDA_MAX]; static UINT8 prot_items_cnt = 0; -static ir_data_t *prot_items_data = NULL; -static ir_data_tv_t *remote_p; +static t_ir_data *prot_items_data = NULL; +static t_ir_data_tv *remote_p; static UINT8 *remote_pdata = NULL; static UINT16 time_index = 0; @@ -45,13 +44,13 @@ static BOOL get_ir_protocol(UINT8 encode_type); static BOOL get_ir_keymap(void); -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time); +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time); -static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time); +static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time); static void convert_to_ir_time(UINT8 value, UINT16 *ir_time); -static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time); +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time); INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length) @@ -109,8 +108,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) pbuffer->offset = 0; - /* protocol name */ - // prot_name = pbuffer->data + pbuffer->offset; + /* t_ac_protocol name */ pbuffer->offset += name_size; /* cycles number */ @@ -145,7 +143,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) { if (0 != prot_cycles_num[i]) { - prot_cycles_data[i] = (ir_cycles_t *) (&prot_cycles[sizeof(ir_cycles_t) * cycles_sum]); + prot_cycles_data[i] = (t_ir_cycles *) (&prot_cycles[sizeof(t_ir_cycles) * cycles_sum]); } else { @@ -153,15 +151,15 @@ static BOOL get_ir_protocol(UINT8 encode_type) } cycles_sum += prot_cycles_num[i]; } - pbuffer->offset += sizeof(ir_cycles_t) * cycles_sum; + pbuffer->offset += sizeof(t_ir_cycles) * cycles_sum; /* items count */ prot_items_cnt = pbuffer->data[pbuffer->offset]; pbuffer->offset += sizeof(UINT8); /* items data */ - prot_items_data = (ir_data_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += prot_items_cnt * sizeof(ir_data_t); + prot_items_data = (t_ir_data *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += prot_items_cnt * sizeof(t_ir_data); ir_toggle_bit = FALSE; @@ -170,8 +168,8 @@ static BOOL get_ir_protocol(UINT8 encode_type) static BOOL get_ir_keymap(void) { - remote_p = (ir_data_tv_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += sizeof(ir_data_tv_t); + remote_p = (t_ir_data_tv *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += sizeof(t_ir_data_tv); if (strncmp(remote_p->magic, "irda", 4) == 0) { @@ -182,11 +180,11 @@ static BOOL get_ir_keymap(void) return FALSE; } -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time) { UINT8 i = 0; UINT8 cycles_num = 0; - ir_cycles_t *pcycles = NULL; + t_ir_cycles *pcycles = NULL; UINT8 key_code = 0; if (NULL == data || NULL == ir_time) @@ -301,10 +299,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) { break; } - else - { - pcycles++; - } + pcycles++; } } else @@ -331,7 +326,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) } } -static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time) +static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time) { UINT8 i = 0; UINT8 value = 0; @@ -415,7 +410,7 @@ static void convert_to_ir_time(UINT8 value, UINT16 *ir_time) } } -static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time) +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time) { if (NULL == pcycles_num || NULL == ir_time) { diff --git a/android-example/decodesdk/irextdecode/src/ir_utils.c b/android-example/decodesdk/irextdecode/src/ir_utils.c index bbe78c6..6867df7 100644 --- a/android-example/decodesdk/irextdecode/src/ir_utils.c +++ b/android-example/decodesdk/irextdecode/src/ir_utils.c @@ -23,7 +23,7 @@ UINT8 char_to_hex(char chr) return value; } -UINT8 chars_to_hex(UINT8 *p) +UINT8 chars_to_hex(const UINT8 *p) { return (char_to_hex(*p) << 4) + char_to_hex(*(p + 1)); } @@ -40,7 +40,7 @@ void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len) } } -void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len) +void string_to_hex(UINT8 *p, t_ac_hex *pac_hex) { UINT8 i = 0; @@ -84,7 +84,7 @@ void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src) dest[1] = hex_half_byte_to_single_char(1, lo_num); } -BOOL isin(UINT8 array[], UINT8 value, UINT8 len) +BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len) { UINT16 i = 0; for (i = 0; i < len; i++) diff --git a/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java b/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java index bdac629..0a1a52c 100644 --- a/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java +++ b/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java @@ -23,7 +23,7 @@ import java.util.List; public class WebAPICallbacks { public interface SignInCallback { - void onSignInSuccess(UserApp admin); + void onSignInSuccess(UserApp userApp); void onSignInFailed(); void onSignInError(); } diff --git a/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java index 7f4c92a..3b03d0f 100644 --- a/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java +++ b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java @@ -3,6 +3,7 @@ package net.irext.webapi; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.util.Log; import com.google.gson.Gson; import net.irext.webapi.model.*; @@ -48,7 +49,7 @@ public class WebAPIs { private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin"; private static final String SERVICE_ONLINE_DECODE = "/operation/decode"; - private int adminId; + private int id; private String token; private OkHttpClient mHttpClient; @@ -123,14 +124,17 @@ public class WebAPIs { appSignInRequest.setAndroidSignature(signature); String bodyJson = appSignInRequest.toJson(); + Log.d(TAG, "Android APP example sign-in request data : " + bodyJson); String response = postToServer(signInURL, bodyJson); + + Log.d(TAG, "Android APP example sign-in response data : " + response); LoginResponse loginResponse = new Gson().fromJson(response, LoginResponse.class); if (loginResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { - UserApp admin = loginResponse.getEntity(); - if (0 != admin.getId() && null != admin.getToken()) { - adminId = admin.getId(); - token = admin.getToken(); - signInCallback.onSignInSuccess(admin); + UserApp userApp = loginResponse.getEntity(); + if (0 != userApp.getId() && null != userApp.getToken()) { + id = userApp.getId(); + token = userApp.getToken(); + signInCallback.onSignInSuccess(userApp); } else { signInCallback.onSignInFailed(); } @@ -145,7 +149,7 @@ public class WebAPIs { public void listCategories(int from, int count, ListCategoriesCallback listCategoriesCallback) { String listCategoriesURL = URL_PREFIX + SERVICE_LIST_CATEGORIES; ListCategoriesRequest listCategoriesRequest = new ListCategoriesRequest(); - listCategoriesRequest.setAdminId(adminId); + listCategoriesRequest.setId(id); listCategoriesRequest.setToken(token); listCategoriesRequest.setFrom(from); listCategoriesRequest.setCount(count); @@ -171,7 +175,7 @@ public class WebAPIs { ListBrandsCallback listBrandsCallback) { String listBrandsURL = URL_PREFIX + SERVICE_LIST_BRANDS; ListBrandsRequest listBrandsRequest = new ListBrandsRequest(); - listBrandsRequest.setAdminId(adminId); + listBrandsRequest.setId(id); listBrandsRequest.setToken(token); listBrandsRequest.setCategoryId(categoryId); listBrandsRequest.setFrom(from); @@ -197,7 +201,7 @@ public class WebAPIs { public void listProvinces(ListProvincesCallback listProvincesCallback) { String listProvincesURL = URL_PREFIX + SERVICE_LIST_PROVINCES; ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); - listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setId(id); listCitiesRequest.setToken(token); String bodyJson = listCitiesRequest.toJson(); @@ -220,7 +224,7 @@ public class WebAPIs { public void listCities(String prefix, ListCitiesCallback listCitiesCallback) { String listCitiesURL = URL_PREFIX + SERVICE_LIST_CITIES; ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); - listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setId(id); listCitiesRequest.setToken(token); listCitiesRequest.setProvincePrefix(prefix); String bodyJson = listCitiesRequest.toJson(); @@ -245,7 +249,7 @@ public class WebAPIs { ListOperatersCallback listOperatersCallback) { String listOperatorsURL = URL_PREFIX + SERVICE_LIST_OPERATORS; ListOperatorsRequest listOperatorsRequest = new ListOperatorsRequest(); - listOperatorsRequest.setAdminId(adminId); + listOperatorsRequest.setId(id); listOperatorsRequest.setToken(token); listOperatorsRequest.setCityCode(cityCode); listOperatorsRequest.setFrom(0); @@ -275,7 +279,7 @@ public class WebAPIs { ListIndexesCallback onListIndexCallback) { String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES; ListIndexesRequest listIndexesRequest = new ListIndexesRequest(); - listIndexesRequest.setAdminId(adminId); + listIndexesRequest.setId(id); listIndexesRequest.setToken(token); listIndexesRequest.setCategoryId(categoryId); listIndexesRequest.setBrandId(brandId); @@ -306,7 +310,7 @@ public class WebAPIs { DownloadBinCallback downloadBinCallback) { String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN; DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest(); - downloadBinaryRequest.setAdminId(adminId); + downloadBinaryRequest.setId(id); downloadBinaryRequest.setToken(token); downloadBinaryRequest.setIndexId(indexId); @@ -333,7 +337,7 @@ public class WebAPIs { public int[] decodeIR(int indexId) { String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE; DecodeRequest decodeRequest = new DecodeRequest(); - decodeRequest.setAdminId(adminId); + decodeRequest.setId(id); decodeRequest.setToken(token); decodeRequest.setIndexId(indexId); diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java index 93777aa..ef4ba78 100644 --- a/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java @@ -14,11 +14,11 @@ import com.google.gson.Gson; */ public class BaseRequest { - private int adminId; + private int id; private String token; - public BaseRequest(int adminId, String token) { - this.adminId = adminId; + public BaseRequest(int id, String token) { + this.id = id; this.token = token; } @@ -26,12 +26,12 @@ public class BaseRequest { } - public int getAdminId() { - return adminId; + public int getId() { + return id; } - public void setAdminId(int adminId) { - this.adminId = adminId; + public void setId(int id) { + this.id = id; } public String getToken() { diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java index 9f06381..d5e51d7 100644 --- a/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java @@ -1,7 +1,6 @@ package net.irext.webapi.response; import net.irext.webapi.model.UserApp; - /** * Filename: LoginResponse.java * Revised: Date: 2017-03-31