added jni example (undone)
This commit is contained in:
121
jni-example/decodesdk/IRDecode.java
Normal file
121
jni-example/decodesdk/IRDecode.java
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package net.irext.decodesdk;
|
||||||
|
|
||||||
|
import net.irext.decodesdk.bean.ACStatus;
|
||||||
|
import net.irext.decodesdk.bean.TemperatureRange;
|
||||||
|
import net.irext.decodesdk.utils.Constants;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: IRDecode.java
|
||||||
|
* Revised: Date: 2017-04-22
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: Wrapper-sdk of IR decode
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2017-04-23: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class IRDecode {
|
||||||
|
|
||||||
|
private static final String TAG = IRDecode.class.getSimpleName();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private static ServletContext context;
|
||||||
|
|
||||||
|
private static Object mSync = new Object();
|
||||||
|
|
||||||
|
private native int irOpen(int category, int subCate, String fileName);
|
||||||
|
|
||||||
|
private native int irOpenBinary(int category, int subCate, byte[] binaries, int binLength);
|
||||||
|
|
||||||
|
private native int[] irDecode(int keyCode, ACStatus acStatus, int changeWindDirection);
|
||||||
|
|
||||||
|
private native void irClose();
|
||||||
|
|
||||||
|
private native TemperatureRange irACGetTemperatureRange(int acMode);
|
||||||
|
|
||||||
|
private native int irACGetSupportedMode();
|
||||||
|
|
||||||
|
private native int irACGetSupportedWindSpeed(int acMode);
|
||||||
|
|
||||||
|
private native int irACGetSupportedSwing(int acMode);
|
||||||
|
|
||||||
|
private static IRDecode mInstance;
|
||||||
|
|
||||||
|
public static IRDecode getInstance() {
|
||||||
|
if (null == mInstance) {
|
||||||
|
mInstance = new IRDecode();
|
||||||
|
}
|
||||||
|
return mInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return irOpen(category, subCate, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int openBinary(int category, int subCate, byte[] binaries, int binLength) {
|
||||||
|
return irOpenBinary(category, subCate, binaries, binLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
|
||||||
|
int []decoded;
|
||||||
|
synchronized (mSync) {
|
||||||
|
if (null == acStatus) {
|
||||||
|
acStatus = new ACStatus();
|
||||||
|
}
|
||||||
|
decoded = irDecode(keyCode, acStatus, changeWindDir);
|
||||||
|
}
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeBinary() {
|
||||||
|
irClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemperatureRange getTemperatureRange(int acMode) {
|
||||||
|
return irACGetTemperatureRange(acMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getACSupportedMode() {
|
||||||
|
// cool, heat, auto, fan, de-humidification
|
||||||
|
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++) {
|
||||||
|
retSupportedMode[i] = (supportedMode >>> 1) & 1;
|
||||||
|
}
|
||||||
|
return retSupportedMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getACSupportedWindSpeed(int acMode) {
|
||||||
|
// auto, low, medium, high
|
||||||
|
int []retSupportedWindSpeed = {0, 0, 0, 0};
|
||||||
|
int supportedWindSpeed = irACGetSupportedWindSpeed(acMode);
|
||||||
|
for (int i = Constants.ACWindSpeed.SPEED_AUTO.getValue();
|
||||||
|
i <= Constants.ACWindSpeed.SPEED_HIGH.getValue();
|
||||||
|
i++) {
|
||||||
|
retSupportedWindSpeed[i] = (supportedWindSpeed >>> 1) & 1;
|
||||||
|
}
|
||||||
|
return retSupportedWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getACSupportedSwing(int acMode) {
|
||||||
|
// swing-on, swing-off
|
||||||
|
int []retSupportedSwing= {0, 0};
|
||||||
|
int supportedSwing = irACGetSupportedSwing(acMode);
|
||||||
|
for (int i = Constants.ACSwing.SWING_ON.getValue();
|
||||||
|
i <= Constants.ACSwing.SWING_OFF.getValue();
|
||||||
|
i++) {
|
||||||
|
retSupportedSwing[i] = (supportedSwing >>> 1) & 1;
|
||||||
|
}
|
||||||
|
return retSupportedSwing;
|
||||||
|
}
|
||||||
|
}
|
||||||
115
jni-example/decodesdk/bean/ACStatus.java
Normal file
115
jni-example/decodesdk/bean/ACStatus.java
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package net.irext.decodesdk.bean;
|
||||||
|
|
||||||
|
import net.irext.decodesdk.utils.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: ACStatus.java
|
||||||
|
* Revised: Date: 2017-03-28
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: Status descriptor for air-conditioner
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2017-03-28: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class ACStatus {
|
||||||
|
|
||||||
|
private static final String TAG = ACStatus.class.getSimpleName();
|
||||||
|
|
||||||
|
private int acPower;
|
||||||
|
private int acTemp;
|
||||||
|
private int acMode;
|
||||||
|
private int acWindDir;
|
||||||
|
private int acWindSpeed;
|
||||||
|
private int acDisplay;
|
||||||
|
private int acSleep;
|
||||||
|
private int acTimer;
|
||||||
|
|
||||||
|
public ACStatus() {
|
||||||
|
this.acPower = Constants.ACPower.POWER_OFF.getValue();
|
||||||
|
this.acMode = Constants.ACMode.MODE_AUTO.getValue();
|
||||||
|
this.acTemp = Constants.ACTemperature.TEMP_24.getValue();
|
||||||
|
this.acWindSpeed = Constants.ACWindSpeed.SPEED_AUTO.getValue();
|
||||||
|
this.acWindDir = Constants.ACSwing.SWING_ON.getValue();
|
||||||
|
this.acTimer = 0;
|
||||||
|
this.acDisplay = 0;
|
||||||
|
this.acSleep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ACStatus(int acPower, int acMode, int acTemp, int acWindSpeed, int acWindDir,
|
||||||
|
int acDisplay, int acSleep, int acTimer) {
|
||||||
|
this.acPower = acPower;
|
||||||
|
this.acTemp = acTemp;
|
||||||
|
this.acMode = acMode;
|
||||||
|
this.acWindDir = acWindDir;
|
||||||
|
this.acWindSpeed = acWindSpeed;
|
||||||
|
this.acDisplay = acDisplay;
|
||||||
|
this.acSleep = acSleep;
|
||||||
|
this.acTimer = acTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcPower() {
|
||||||
|
return acPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcPower(int acPower) {
|
||||||
|
this.acPower = acPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcTemp() {
|
||||||
|
return acTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcTemp(int acTemp) {
|
||||||
|
this.acTemp = acTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcMode() {
|
||||||
|
return acMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcMode(int acMode) {
|
||||||
|
this.acMode = acMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcWindDir() {
|
||||||
|
return acWindDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcWindDir(int acWindDir) {
|
||||||
|
this.acWindDir = acWindDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcWindSpeed() {
|
||||||
|
return acWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcWindSpeed(int acWindSpeed) {
|
||||||
|
this.acWindSpeed = acWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcDisplay() {
|
||||||
|
return acDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcDisplay(int acDisplay) {
|
||||||
|
this.acDisplay = acDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcSleep() {
|
||||||
|
return acSleep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcSleep(int acSleep) {
|
||||||
|
this.acSleep = acSleep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAcTimer() {
|
||||||
|
return acTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcTimer(int acTimer) {
|
||||||
|
this.acTimer = acTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
jni-example/decodesdk/bean/TemperatureRange.java
Normal file
43
jni-example/decodesdk/bean/TemperatureRange.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package net.irext.decodesdk.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: TemperatureRange.java
|
||||||
|
* Revised: Date: 2017-03-28
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: Temperature range for air-conditioner
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2017-03-28: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class TemperatureRange {
|
||||||
|
|
||||||
|
private static final String TAG = TemperatureRange.class.getSimpleName();
|
||||||
|
|
||||||
|
private int tempMin;
|
||||||
|
private int tempMax;
|
||||||
|
|
||||||
|
public TemperatureRange() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemperatureRange(int tempMin, int tempMax) {
|
||||||
|
this.tempMin = tempMin;
|
||||||
|
this.tempMax = tempMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTempMin() {
|
||||||
|
return tempMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTempMin(int tempMin) {
|
||||||
|
this.tempMin = tempMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTempMax() {
|
||||||
|
return tempMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTempMax(int tempMax) {
|
||||||
|
this.tempMax = tempMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
jni-example/decodesdk/libs/libirda_decoder.so
Normal file
BIN
jni-example/decodesdk/libs/libirda_decoder.so
Normal file
Binary file not shown.
175
jni-example/decodesdk/utils/Constants.java
Normal file
175
jni-example/decodesdk/utils/Constants.java
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
package net.irext.decodesdk.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: Constants.java
|
||||||
|
* Revised: Date: 2017-04-03
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: SDK Constants
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2017-04-03: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
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 enum CategoryID {
|
||||||
|
AIR_CONDITIONER(1),
|
||||||
|
TV(2),
|
||||||
|
STB(3),
|
||||||
|
NET_BOX(4),
|
||||||
|
IPTV(5),
|
||||||
|
DVD(6),
|
||||||
|
FAN(7),
|
||||||
|
PROJECTOR(8),
|
||||||
|
STEREO(9),
|
||||||
|
LIGHT(10),
|
||||||
|
BSTB(11),
|
||||||
|
CLEANING_ROBOT(12),
|
||||||
|
AIR_CLEANER(13);
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
CategoryID(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BinaryType {
|
||||||
|
TYPE_BINARY(0),
|
||||||
|
TYPE_HEXDECIMAL(1);
|
||||||
|
|
||||||
|
private final int type;
|
||||||
|
|
||||||
|
BinaryType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACPower {
|
||||||
|
POWER_ON(0),
|
||||||
|
POWER_OFF(1);
|
||||||
|
|
||||||
|
private final int power;
|
||||||
|
|
||||||
|
ACPower(int power) {
|
||||||
|
this.power = power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return power;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACMode {
|
||||||
|
MODE_COOL(0),
|
||||||
|
MODE_HEAT(1),
|
||||||
|
MODE_AUTO(2),
|
||||||
|
MODE_FAN(3),
|
||||||
|
MODE_DEHUMIDITY(4);
|
||||||
|
|
||||||
|
private final int mode;
|
||||||
|
|
||||||
|
ACMode(int mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACTemperature {
|
||||||
|
TEMP_16(0),
|
||||||
|
TEMP_17(1),
|
||||||
|
TEMP_18(2),
|
||||||
|
TEMP_19(3),
|
||||||
|
TEMP_20(4),
|
||||||
|
TEMP_21(5),
|
||||||
|
TEMP_22(6),
|
||||||
|
TEMP_23(7),
|
||||||
|
TEMP_24(8),
|
||||||
|
TEMP_25(9),
|
||||||
|
TEMP_26(10),
|
||||||
|
TEMP_27(11),
|
||||||
|
TEMP_28(12),
|
||||||
|
TEMP_29(13),
|
||||||
|
TEMP_30(14);
|
||||||
|
|
||||||
|
private final int temp;
|
||||||
|
|
||||||
|
ACTemperature(int temp) {
|
||||||
|
this.temp = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACWindSpeed {
|
||||||
|
SPEED_AUTO(0),
|
||||||
|
SPEED_LOW(1),
|
||||||
|
SPEED_MEDIUM(2),
|
||||||
|
SPEED_HIGH(3);
|
||||||
|
|
||||||
|
private final int speed;
|
||||||
|
|
||||||
|
ACWindSpeed(int speed) {
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACSwing {
|
||||||
|
SWING_ON(0),
|
||||||
|
SWING_OFF(1);
|
||||||
|
|
||||||
|
private final int swing;
|
||||||
|
|
||||||
|
ACSwing(int swing) {
|
||||||
|
this.swing = swing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return swing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ACFunction {
|
||||||
|
FUNCTION_SWITCH_POWER(1),
|
||||||
|
FUNCTION_CHANGE_MODE(2),
|
||||||
|
FUNCTION_TEMPERATURE_UP(3),
|
||||||
|
FUNCTION_TEMPERATURE_DOWN(4),
|
||||||
|
FUNCTION_SWITCH_WIND_SPEED(5),
|
||||||
|
FUNCTION_SWITCH_WIND_DIR(6),
|
||||||
|
FUNCTION_SWITCH_SWING(7);
|
||||||
|
|
||||||
|
private final int function;
|
||||||
|
|
||||||
|
ACFunction(int function) {
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user