updated Android example according to 0.2.1

This commit is contained in:
strawmanbobi
2019-06-16 21:10:58 +08:00
parent 2eabc65df6
commit fd0c2cc620
16 changed files with 70 additions and 44 deletions

View File

@@ -2,7 +2,7 @@ package net.irext.decode.sdk;
import net.irext.decode.sdk.bean.ACStatus;
import net.irext.decode.sdk.bean.TemperatureRange;
import net.irext.sdk.utils.Constants;
import net.irext.decode.sdk.utils.Constants;
/**
* Filename: IRDecode.java
@@ -18,9 +18,7 @@ public class IRDecode {
private static final String TAG = IRDecode.class.getSimpleName();
static {
System.loadLibrary("irdecode");
}
private static Object mSync = new Object();
private native int irOpen(int category, int subCate, String fileName);
@@ -38,6 +36,8 @@ public class IRDecode {
private native int irACGetSupportedSwing(int acMode);
private native int irACGetSupportedWindDirection(int acMode);
private static IRDecode mInstance;
public static IRDecode getInstance() {
@@ -48,7 +48,9 @@ public class IRDecode {
}
private IRDecode() {
String libPath = "/data/irext/libirda_decoder.so";
System.out.println("loading decode library " + libPath);
System.load(libPath);
}
public int openFile(int category, int subCate, String fileName) {
@@ -60,10 +62,14 @@ public class IRDecode {
}
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
if (null == acStatus) {
acStatus = new ACStatus();
int[] decoded;
synchronized (mSync) {
if (null == acStatus) {
acStatus = new ACStatus();
}
decoded = irDecode(keyCode, acStatus, changeWindDir);
}
return irDecode(keyCode, acStatus, changeWindDir);
return decoded;
}
public void closeBinary() {
@@ -76,7 +82,7 @@ public class IRDecode {
public int[] getACSupportedMode() {
// cool, heat, auto, fan, de-humidification
int []retSupportedMode = {0, 0, 0, 0, 0};
int[] retSupportedMode = {0, 0, 0, 0, 0};
int supportedMode = irACGetSupportedMode();
for (int i = Constants.ACMode.MODE_COOL.getValue(); i <=
Constants.ACMode.MODE_DEHUMIDITY.getValue(); i++) {
@@ -87,7 +93,7 @@ public class IRDecode {
public int[] getACSupportedWindSpeed(int acMode) {
// auto, low, medium, high
int []retSupportedWindSpeed = {0, 0, 0, 0};
int[] retSupportedWindSpeed = {0, 0, 0, 0};
int supportedWindSpeed = irACGetSupportedWindSpeed(acMode);
for (int i = Constants.ACWindSpeed.SPEED_AUTO.getValue();
i <= Constants.ACWindSpeed.SPEED_HIGH.getValue();
@@ -99,7 +105,7 @@ public class IRDecode {
public int[] getACSupportedSwing(int acMode) {
// swing-on, swing-off
int []retSupportedSwing= {0, 0};
int[] retSupportedSwing = {0, 0};
int supportedSwing = irACGetSupportedSwing(acMode);
for (int i = Constants.ACSwing.SWING_ON.getValue();
i <= Constants.ACSwing.SWING_OFF.getValue();
@@ -108,4 +114,9 @@ public class IRDecode {
}
return retSupportedSwing;
}
public int getACSupportedWindDirection(int acMode) {
// how many directions supported by specific AC
return irACGetSupportedWindDirection(acMode);
}
}

View File

@@ -1,6 +1,6 @@
package net.irext.decode.sdk.bean;
import net.irext.sdk.utils.Constants;
import net.irext.decode.sdk.utils.Constants;
/**
* Filename: ACStatus.java
@@ -48,67 +48,67 @@ public class ACStatus {
this.acTimer = acTimer;
}
public int getACPower() {
public int getAcPower() {
return acPower;
}
public void setACPower(int acPower) {
public void setAcPower(int acPower) {
this.acPower = acPower;
}
public int getACTemp() {
public int getAcTemp() {
return acTemp;
}
public void setACTemp(int acTemp) {
public void setAcTemp(int acTemp) {
this.acTemp = acTemp;
}
public int getACMode() {
public int getAcMode() {
return acMode;
}
public void setACMode(int acMode) {
public void setAcMode(int acMode) {
this.acMode = acMode;
}
public int getACWindDir() {
public int getAcWindDir() {
return acWindDir;
}
public void setACWindDir(int acWindDir) {
public void setAcWindDir(int acWindDir) {
this.acWindDir = acWindDir;
}
public int getACWindSpeed() {
public int getAcWindSpeed() {
return acWindSpeed;
}
public void setACWindSpeed(int acWindSpeed) {
public void setAcWindSpeed(int acWindSpeed) {
this.acWindSpeed = acWindSpeed;
}
public int getACDisplay() {
public int getAcDisplay() {
return acDisplay;
}
public void setACDisplay(int acDisplay) {
public void setAcDisplay(int acDisplay) {
this.acDisplay = acDisplay;
}
public int getACSleep() {
public int getAcSleep() {
return acSleep;
}
public void setACSleep(int acSleep) {
public void setAcSleep(int acSleep) {
this.acSleep = acSleep;
}
public int getACTimer() {
public int getAcTimer() {
return acTimer;
}
public void setACTimer(int acTimer) {
public void setAcTimer(int acTimer) {
this.acTimer = acTimer;
}

View File

@@ -1,4 +1,4 @@
package net.irext.sdk.utils;
package net.irext.decode.sdk.utils;
/**
* Filename: Constants.java
@@ -14,10 +14,24 @@ public class Constants {
public static final int ERROR_CODE_SUCCESS = 0;
public static final int ERROR_CODE_NETWORK_ERROR = -1;
public static final int ERROR_CODE_AUTH_FAILURE = 1;
public static final int ERROR_CODE_INVALID_CATEGORY = 2;
public static final int ERROR_CODE_INVALID_BRAND = 3;
public static final int ERROR_CODE_INVALID_PARAMETER = 4;
public static final int ERROR_CODE_INVALID_CITY = 5;
public static final int ERROR_CODE_INVALID_OPERATOR = 6;
public static final int ERROR_CODE_INVALID_SESSION = 20;
public static final String ERROR_CODE_SUCESS_TEXT = "success";
public static final String ERROR_CODE_NETWORK_ERROR_TEXT = "network error";
public static final String ERROR_CODE_AUTH_FAILUTRE_TEXT = "auth failure";
public static final String ERROR_CODE_INVALID_CATEGORY_TEXT = "invalid category";
public static final String ERROR_CODE_INVALID_BRAND_TEXT = "invalid brand";
public static final String ERROR_CODE_INVALID_PARAMETER_TEXT = "invalid parameter";
public static final String ERROR_CODE_INVALID_SESSION_TEXT = "invalid decode session";
public enum CategoryID {
AIR_CONDITIONER(1),