made progress on remote implementation
This commit is contained in:
@@ -81,7 +81,7 @@ public class ArduinoSocket {
|
|||||||
callback.onResponse(response);
|
callback.onResponse(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onDisconnected();
|
callback.onDisconnected();
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ public class ArduinoSocket {
|
|||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onDisconnected();
|
callback.onDisconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionStatus = EMITTER_DISCONNECTED;
|
connectionStatus = EMITTER_DISCONNECTED;
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|||||||
@@ -1,25 +1,38 @@
|
|||||||
package net.irext.ircontrol.controller;
|
package net.irext.ircontrol.controller;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import net.irext.decode.sdk.IRDecode;
|
import net.irext.decode.sdk.IRDecode;
|
||||||
import net.irext.decode.sdk.bean.ACStatus;
|
import net.irext.decode.sdk.bean.ACStatus;
|
||||||
import net.irext.ircontrol.controller.implementable.IRemote;
|
import net.irext.ircontrol.controller.implementable.IRemote;
|
||||||
|
|
||||||
public class PhoneRemote implements IRemote {
|
public class PhoneRemote implements IRemote {
|
||||||
|
|
||||||
|
private static final String TAG = PhoneRemote.class.getSimpleName();
|
||||||
|
|
||||||
IRDecode mIRDecode;
|
IRDecode mIRDecode;
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
public PhoneRemote(Context context) {
|
public PhoneRemote(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mIRDecode = new IRDecode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int irControl(int category, int subCategory, int keyCode) {
|
public int irControl(int category, int subCategory, int keyCode) {
|
||||||
int []decoded;
|
int []decoded;
|
||||||
|
StringBuilder debugStr = new StringBuilder();
|
||||||
ACStatus acStatus = new ACStatus();
|
ACStatus acStatus = new ACStatus();
|
||||||
int inputKeyCode = ControlUtils.translateKeyCode(category, keyCode, acStatus);
|
int inputKeyCode = ControlUtils.translateKeyCode(category, keyCode, acStatus);
|
||||||
decoded = mIRDecode.decodeBinary(inputKeyCode, 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);
|
ControlUtils.transmitIr(mContext, decoded);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,12 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
|||||||
String binFileName = FileUtils.binDir + FileUtils.FILE_NAME_PREFIX +
|
String binFileName = FileUtils.binDir + FileUtils.FILE_NAME_PREFIX +
|
||||||
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
|
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
|
||||||
byte []binContent = FileUtils.getByteArrayFromFile(binFileName);
|
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) {
|
private void processECtrl(String response) {
|
||||||
@@ -248,7 +253,7 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
|||||||
keyCode = IRemote.KEY_MENU;
|
keyCode = IRemote.KEY_MENU;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mArduinoSocket.isConnected()) {
|
if (mArduinoSocket.isConnected() && mArduinoSocket.getConnectionStatus() == ArduinoSocket.EMITTER_BIN_RECEIVED) {
|
||||||
remote = new ArduinoRemote(mParent, mArduinoSocket);
|
remote = new ArduinoRemote(mParent, mArduinoSocket);
|
||||||
} else {
|
} else {
|
||||||
remote = new PhoneRemote(mParent);
|
remote = new PhoneRemote(mParent);
|
||||||
|
|||||||
@@ -30,15 +30,20 @@
|
|||||||
<string name="button_ok">确定</string>
|
<string name="button_ok">确定</string>
|
||||||
<string name="button_plus">+</string>
|
<string name="button_plus">+</string>
|
||||||
<string name="button_minus">-</string>
|
<string name="button_minus">-</string>
|
||||||
<string name="ir_not_supported">该设备不支持红外发射, 请连接外部模块进行发射</string>
|
|
||||||
|
|
||||||
|
<!-- Emitter panel -->
|
||||||
<string name="emitter_ip">发射端 IP</string>
|
<string name="emitter_ip">发射端 IP</string>
|
||||||
<string name="default_ip">192.168.1.40</string>
|
<string name="default_ip">192.168.1.40</string>
|
||||||
<string name="connect">连接</string>
|
<string name="connect">连接</string>
|
||||||
<string name="decode_on_board">在单片机上解码</string>
|
<string name="decode_on_board">在单片机上解码</string>
|
||||||
|
|
||||||
|
<!-- Error messages -->
|
||||||
|
<string name="ir_not_supported">该设备不支持红外发射, 请连接外部模块进行发射</string>
|
||||||
<string name="input_emitter_ip_address">请输入接收器的 IP 地址</string>
|
<string name="input_emitter_ip_address">请输入接收器的 IP 地址</string>
|
||||||
<string name="connect_failed">连接失败</string>
|
<string name="connect_failed">连接失败</string>
|
||||||
<string name="connect_disconnected">连接已断开</string>
|
<string name="connect_disconnected">连接已断开</string>
|
||||||
<string name="status_not_connected">未连接</string>
|
<string name="status_not_connected">未连接</string>
|
||||||
<string name="status_connected">已连接</string>
|
<string name="status_connected">已连接</string>
|
||||||
|
<string name="file_could_not_open">编码文件无法打开</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -30,16 +30,20 @@
|
|||||||
<string name="button_ok">OK</string>
|
<string name="button_ok">OK</string>
|
||||||
<string name="button_plus">+</string>
|
<string name="button_plus">+</string>
|
||||||
<string name="button_minus">-</string>
|
<string name="button_minus">-</string>
|
||||||
<string name="ir_not_supported">IR emitter is not supported in this device, please try with external emitters</string>
|
|
||||||
|
|
||||||
|
<!-- Emitter panel -->
|
||||||
<string name="emitter_ip">Emitter IP</string>
|
<string name="emitter_ip">Emitter IP</string>
|
||||||
<string name="default_ip">192.168.1.40</string>
|
<string name="default_ip">192.168.1.40</string>
|
||||||
<string name="connect">connect</string>
|
<string name="connect">Connect</string>
|
||||||
<string name="decode_on_board">Decode On Board</string>
|
<string name="decode_on_board">Decode On Board</string>
|
||||||
|
|
||||||
|
<!-- Error messages -->
|
||||||
|
<string name="ir_not_supported">IR emitter is not supported in this device, please try with external emitters</string>
|
||||||
<string name="input_emitter_ip_address">Please input IP address of emitter</string>
|
<string name="input_emitter_ip_address">Please input IP address of emitter</string>
|
||||||
<string name="connect_failed">Connect failed</string>
|
<string name="connect_failed">Connect failed</string>
|
||||||
<string name="connect_disconnected">The connection has lost</string>
|
<string name="connect_disconnected">The connection has lost</string>
|
||||||
<string name="status_not_connected">Disconnected</string>
|
<string name="status_not_connected">Disconnected</string>
|
||||||
<string name="status_connected">Connected</string>
|
<string name="status_connected">Connected</string>
|
||||||
|
<string name="file_could_not_open">The IR binary file could not be opened</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user