diff --git a/android-example/app/src/main/java/net/irext/ircontrol/controller/ArduinoSocket.java b/android-example/app/src/main/java/net/irext/ircontrol/controller/ArduinoSocket.java
index 4fb6b1b..506a334 100644
--- a/android-example/app/src/main/java/net/irext/ircontrol/controller/ArduinoSocket.java
+++ b/android-example/app/src/main/java/net/irext/ircontrol/controller/ArduinoSocket.java
@@ -81,7 +81,7 @@ public class ArduinoSocket {
callback.onResponse(response);
}
}
-
+
if (callback != null) {
callback.onDisconnected();
}
@@ -93,7 +93,7 @@ public class ArduinoSocket {
if (callback != null) {
callback.onDisconnected();
}
-
+
connectionStatus = EMITTER_DISCONNECTED;
}
}).start();
diff --git a/android-example/app/src/main/java/net/irext/ircontrol/controller/PhoneRemote.java b/android-example/app/src/main/java/net/irext/ircontrol/controller/PhoneRemote.java
index 91808f0..5ae308a 100644
--- a/android-example/app/src/main/java/net/irext/ircontrol/controller/PhoneRemote.java
+++ b/android-example/app/src/main/java/net/irext/ircontrol/controller/PhoneRemote.java
@@ -1,25 +1,38 @@
package net.irext.ircontrol.controller;
import android.content.Context;
+import android.util.Log;
import net.irext.decode.sdk.IRDecode;
import net.irext.decode.sdk.bean.ACStatus;
import net.irext.ircontrol.controller.implementable.IRemote;
public class PhoneRemote implements IRemote {
+ private static final String TAG = PhoneRemote.class.getSimpleName();
+
IRDecode mIRDecode;
Context mContext;
public PhoneRemote(Context context) {
mContext = context;
+ mIRDecode = new IRDecode();
}
@Override
public int irControl(int category, int subCategory, int keyCode) {
int []decoded;
+ StringBuilder debugStr = new StringBuilder();
ACStatus acStatus = new ACStatus();
int inputKeyCode = ControlUtils.translateKeyCode(category, keyCode, acStatus);
decoded = mIRDecode.decodeBinary(inputKeyCode, acStatus);
+
+ for (int i = 0; i < decoded.length; i++) {
+ debugStr.append(decoded[i]);
+ if (i != decoded.length - 1) {
+ debugStr.append(",");
+ }
+ }
+ Log.d(TAG, "IR control decoded: " + debugStr);
ControlUtils.transmitIr(mContext, decoded);
return 0;
}
diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/ControlFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/ControlFragment.java
index 22352e9..5810693 100644
--- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/ControlFragment.java
+++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/ControlFragment.java
@@ -197,7 +197,12 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
String binFileName = FileUtils.binDir + FileUtils.FILE_NAME_PREFIX +
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
byte []binContent = FileUtils.getByteArrayFromFile(binFileName);
- mArduinoSocket.sendBinToEmitter(binContent, mCurrentRemoteControl.getCategoryId(), mCurrentRemoteControl.getSubCategory());
+ if (null != binContent) {
+ mArduinoSocket.sendBinToEmitter(binContent, mCurrentRemoteControl.getCategoryId(), mCurrentRemoteControl.getSubCategory());
+ } else {
+ Log.e(TAG, "emitter sender could not open the binary file");
+ ToastUtils.showToast(mParent, mParent.getString(R.string.file_could_not_open), Toast.LENGTH_SHORT);
+ }
}
private void processECtrl(String response) {
@@ -248,7 +253,7 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
keyCode = IRemote.KEY_MENU;
}
- if (mArduinoSocket.isConnected()) {
+ if (mArduinoSocket.isConnected() && mArduinoSocket.getConnectionStatus() == ArduinoSocket.EMITTER_BIN_RECEIVED) {
remote = new ArduinoRemote(mParent, mArduinoSocket);
} else {
remote = new PhoneRemote(mParent);
diff --git a/android-example/app/src/main/res/values-zh-rCN/strings.xml b/android-example/app/src/main/res/values-zh-rCN/strings.xml
index c10e265..1d31e08 100644
--- a/android-example/app/src/main/res/values-zh-rCN/strings.xml
+++ b/android-example/app/src/main/res/values-zh-rCN/strings.xml
@@ -30,15 +30,20 @@
确定
+
-
- 该设备不支持红外发射, 请连接外部模块进行发射
+
发射端 IP
192.168.1.40
连接
在单片机上解码
+
+
+ 该设备不支持红外发射, 请连接外部模块进行发射
请输入接收器的 IP 地址
连接失败
连接已断开
未连接
已连接
+ 编码文件无法打开
+
diff --git a/android-example/app/src/main/res/values/strings.xml b/android-example/app/src/main/res/values/strings.xml
index e824098..29afde5 100644
--- a/android-example/app/src/main/res/values/strings.xml
+++ b/android-example/app/src/main/res/values/strings.xml
@@ -30,16 +30,20 @@
OK
+
-
- IR emitter is not supported in this device, please try with external emitters
+
Emitter IP
192.168.1.40
- connect
+ Connect
Decode On Board
+
+
+ IR emitter is not supported in this device, please try with external emitters
Please input IP address of emitter
Connect failed
The connection has lost
Disconnected
Connected
+ The IR binary file could not be opened