|
@@ -1,5 +1,6 @@
|
|
|
package kr.co.icontrols.callengine.subwallpad;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.app.ActivityManager;
|
|
|
import android.app.Service;
|
|
|
import android.content.BroadcastReceiver;
|
|
@@ -19,6 +20,8 @@ import com.artncore.WallPadDataMgr.WallpadDeviceSet;
|
|
|
import com.artncore.WallPadDataMgr.WallpadStatusData;
|
|
|
import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
|
|
|
import com.artncore.commons.define;
|
|
|
+import com.artncore.wallpadapi.IGW200dAPI;
|
|
|
+import com.artncore.wallpadapi.IGW300API;
|
|
|
import com.artncore.wallpadapi.WallPadAPI;
|
|
|
import com.util.LogUtil;
|
|
|
|
|
@@ -74,6 +77,9 @@ public class SubWallPadSerialManager extends Service {
|
|
|
private SerialDataReceiver mSerialDataReceiver;
|
|
|
private SubWallPadServiceBRReceiver mSubWallPadServiceBRReceiver;
|
|
|
|
|
|
+ //서브 월패드 1010GL로 실행하기 위해 필요
|
|
|
+ private IGW300API mIGW300;
|
|
|
+
|
|
|
@Override
|
|
|
public void onCreate() {
|
|
|
try {
|
|
@@ -83,6 +89,11 @@ public class SubWallPadSerialManager extends Service {
|
|
|
|
|
|
mWallPadAPI = new WallPadAPI(this);
|
|
|
|
|
|
+ //2022.10.26 6410 현산향 사용 시, GW를 사용해야 하기 때문에 필요함
|
|
|
+ if (Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
|
|
|
+ IGW300APICheckHandler.sendEmptyMessage(0);
|
|
|
+ }
|
|
|
+
|
|
|
registerBRReceiver();
|
|
|
|
|
|
if (startSerialPort()) {
|
|
@@ -100,6 +111,43 @@ public class SubWallPadSerialManager extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
|
|
|
+ * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
|
|
|
+ * 본 딜레이 코드를 임시로 적용한다.
|
|
|
+ */
|
|
|
+ @SuppressLint("HandlerLeak")
|
|
|
+ protected Handler IGW300APICheckHandler = new Handler() {
|
|
|
+ @SuppressLint("HandlerLeak")
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ if (msg.what == 0) {
|
|
|
+ if (mWallPadAPI != null) {
|
|
|
+ if (mWallPadAPI.Check_Connect()) IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
|
|
|
+ else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(msg.what == 1) {
|
|
|
+ setIGE300Interface();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public void setIGE300Interface() {
|
|
|
+ try {
|
|
|
+ mIGW300 = mWallPadAPI.Get_IGW300Controller();
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ Log.e(TAG, "[Exception] setIGE300Interface()");
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void onDestroy() {
|
|
|
try {
|
|
@@ -272,6 +320,13 @@ public class SubWallPadSerialManager extends Service {
|
|
|
// Read serial port parameters
|
|
|
String[] aSerialInfo = strSerialInfo.split("_");
|
|
|
int nBaudrate = Integer.parseInt(getSubPhoneBaudrate());
|
|
|
+
|
|
|
+ //jglee - 통신 속도에 따라 WaitTime이 달라질 필요 있음
|
|
|
+ //jglee - 9600bps 인 경우는 데이터 손실이 없음(80bit - 10byte) ->0.008s=>0.8ms
|
|
|
+ //1200bps 인 경우는 데이터 손실 발생(80bit - 10byte) ->0.0666s => 66ms
|
|
|
+ if(nBaudrate == 9600) SERIAL_RECEIVE_TIMEOUT = 100;
|
|
|
+ else SERIAL_RECEIVE_TIMEOUT = 200;
|
|
|
+
|
|
|
String strPath = "/dev/" + aSerialInfo[1];
|
|
|
Log.d(TAG, "[openSerialPort] nBaudrate [" + nBaudrate + "], strPath [" + strPath + "]");
|
|
|
|
|
@@ -578,6 +633,12 @@ public class SubWallPadSerialManager extends Service {
|
|
|
// 통화어플을 실행시킨다.
|
|
|
sendLCDBacklightStatus(true);
|
|
|
|
|
|
+ //여기서 GW사용할 떄
|
|
|
+ if ( Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
|
|
|
+ GW300ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
|
|
|
+ GW300ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
|
|
|
+ }
|
|
|
+
|
|
|
ComponentName mComponentName = new ComponentName(strWallPadCallPackageName, "kr.co.icontrols.wallpadcall.MainActivity");
|
|
|
Intent mIntent = new Intent(Intent.ACTION_MAIN);
|
|
|
mIntent.putExtra(Declare.CALLTRIGGER.CALLOWNER, eCallOwner.toString());
|
|
@@ -601,6 +662,43 @@ public class SubWallPadSerialManager extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //jglee 6410 GL을 서브폰으로 사용하기 위해 추가
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 서브폰(GW사용) 사용 시, 명령을 내려보내기 위해 사용
|
|
|
+ * @param kind
|
|
|
+ * @param OnOff
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int GW300ctrlDeviceIO(byte kind, boolean OnOff) {
|
|
|
+ try {
|
|
|
+ Log.d(TAG, "[ctrlDeviceIO] kind :" + kind + " , OnOff :" + OnOff );
|
|
|
+ if (mIGW300 == null) {
|
|
|
+ Log.e(TAG, "[ctrlDeviceIO] - mIGW300API unload !!!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ int ret = mIGW300.ControlOutput(kind, OnOff);
|
|
|
+ if (ret < 0) {
|
|
|
+ Log.e(TAG, "[ctrlDeviceIO] - mIGW300API.ControlOutput() ret = " + ret + " / ErrorCode = " + mIGW300.ErrorCode.ErrStr());
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ LogUtil.errorLogInfo("", TAG, re);
|
|
|
+ return -102;
|
|
|
+ }catch(Exception e) {
|
|
|
+ Log.e(TAG, "[ctrlDeviceIO] - [Exception Error] mIGW300API.ControlOutput()");
|
|
|
+ Log.e(TAG, "[ctrlDeviceIO] - " + e.toString());
|
|
|
+ //e.printStackTrace();
|
|
|
+ LogUtil.errorLogInfo("", TAG, e);
|
|
|
+ return -102;
|
|
|
+ }
|
|
|
+ //DebugLogOutput("[ctrlDeviceIO] - OK");
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Edited by jeff (2020.06.22)
|
|
|
* LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
|
|
@@ -1646,14 +1744,16 @@ public class SubWallPadSerialManager extends Service {
|
|
|
}
|
|
|
|
|
|
if (mInputStream.available() > 0) {
|
|
|
+ //jglee - 9600bps 인 경우는 데이터 손실이 없음(80bit - 10byte) ->0.008s=>0.8ms
|
|
|
+ //1200bps 인 경우는 데이터 손실 발생(80bit - 10byte) ->0.0666s => 66ms
|
|
|
lRcvTimeLimit = System.currentTimeMillis() + SERIAL_RECEIVE_TIMEOUT; // Time limit for receiving data
|
|
|
nRcvDataCnt = 0;
|
|
|
while (lRcvTimeLimit > System.currentTimeMillis()) {
|
|
|
if (mInputStream.available() > 0) {
|
|
|
hRcvBuffer = new byte[mInputStream.available()];
|
|
|
mInputStream.read(hRcvBuffer);
|
|
|
-// Log.d(TAG, "[SerialDataReceiver.run()] hRcvBuffer.length [" + hRcvBuffer.length + "]");
|
|
|
-// Log.d(TAG, "[SerialDataReceiver.run()] hRcvBuffer [" + Global.printHexs(hRcvBuffer) + "]");
|
|
|
+ Log.d(TAG, "[SerialDataReceiver.run()] hRcvBuffer.length [" + hRcvBuffer.length + "]");
|
|
|
+ Log.d(TAG, "[SerialDataReceiver.run()] hRcvBuffer [" + Global.printHexs(hRcvBuffer) + "]");
|
|
|
for (int i = 0; i < hRcvBuffer.length; i++) {
|
|
|
if (nRcvDataCnt == 0) {
|
|
|
if (hRcvBuffer[i] == SubWallPadCmds.STX) {
|