Commit 578660c4 by onuma

単体試験終了まで2

parent fceb90af
......@@ -22,6 +22,9 @@ public class AlcoholCheckerTimerTask extends TimerTask {
this.alcoholCheckerUtil = alcoholCheckerUtil;
this.listener = listener;
}
public boolean notimeout = false;
@Override
public void run() {
......@@ -34,38 +37,43 @@ public class AlcoholCheckerTimerTask extends TimerTask {
case F_BLE_COM_RP_START:
// RP Command Send
listener.onUpdateSendMessage("TIMER F_BLE_COM_RP_COMMAND");
alcoholCheckerUtil.sendMessage(" " + F_BLE_COM_RP_COMMAND);
alcoholCheckerUtil.sendMessage(F_BLE_COM_RP_COMMAND);
break;
case AlcoholCheckerUtil.F_BLE_COM_RD_START:
// RD Command Send
listener.onUpdateSendMessage("TIMER F_BLE_COM_RD_COMMAND");
alcoholCheckerUtil.sendMessage(" " + F_BLE_COM_RD_COMMAND);
break;
case F_BLE_COM_RECONNECT1:
// ReConecting(NOTIFICATION Disable) // @@@
alcoholCheckerUtil.NotificationDisable(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT2;
listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT2");
alcoholCheckerUtil.sendMessage(F_BLE_COM_RD_COMMAND);
break;
case F_BLE_COM_RECONNECT2:
// ReConecting(Wait) // @@@
alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT3;
listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT3");
break;
case F_BLE_COM_RECONNECT3:
// ReConecting(NOTIFICATION Enable) // @@@
alcoholCheckerUtil.DescriptorDevice(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
alcoholCheckerUtil.gi_status = F_BLE_COM_RP_START;
listener.onUpdateStatus("TIMER F_BLE_COM_RP_START");
case AlcoholCheckerUtil.F_BLE_COM_FC_START:
listener.onUpdateSendMessage("TIMER F_BLE_COM_FC_COMMAND");
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
break;
// case F_BLE_COM_RECONNECT1:
// // ReConecting(NOTIFICATION Disable) // @@@
// alcoholCheckerUtil.NotificationDisable(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT2;
// listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT2");
// break;
// case F_BLE_COM_RECONNECT2:
// // ReConecting(Wait) // @@@
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT3;
// listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT3");
// break;
// case F_BLE_COM_RECONNECT3:
// // ReConecting(NOTIFICATION Enable) // @@@
// alcoholCheckerUtil.DescriptorDevice(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
// alcoholCheckerUtil.gi_status = F_BLE_COM_RP_START;
// listener.onUpdateStatus("TIMER F_BLE_COM_RP_START");
// break;
default:
Logger.i(TAG,"AlcohlCheckerTimerTask Timeout");
if (alcoholCheckerUtil.gi_rxretry_cnt < 100) {
alcoholCheckerUtil.gi_rxretry_cnt++;
}
alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT1;
listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT1");
// Logger.i(TAG,"AlcohlCheckerTimerTask Timeout");
//
// if (alcoholCheckerUtil.gi_rxretry_cnt < 100) {
// alcoholCheckerUtil.gi_rxretry_cnt++;
// } else {
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT1;
// //listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT1");
// }
break;
}
}
......
......@@ -60,15 +60,17 @@ public class AlcoholCheckerUtil {
// @BLE Tx State
public int gi_status; // BLE Tx Status
public boolean gf_result_flg; // Conc Data Get
public boolean gf_result_flg; // Conc Data Get // RD RPを切り替えるフラグ
public static final int F_BLE_COM_INIT = 0; // BLE Init
public static final int F_BLE_COM_RP_START = 1; // RP Command Send
public static final int F_BLE_COM_RP_WAIT = 2; // RP Command Send Wait
public static final int F_BLE_COM_RD_START = 3; // RD Command Send
public static final int F_BLE_COM_RD_WAIT = 4; // RD Command Send Wait
public static final int F_BLE_COM_RECONNECT1 = 5; // ReConecting(NOTIFICATION Disable)
public static final int F_BLE_COM_RECONNECT2 = 6; // ReConecting(Wait)
public static final int F_BLE_COM_RECONNECT3 = 7; // ReConecting(NOTIFICATION Enable)
public static final int F_BLE_COM_RP_START = 1; // RP Command Send
public static final int F_BLE_COM_RP_WAIT = 2; // RP Command Send Wait
public static final int F_BLE_COM_RD_START = 3; // RD Command Send
public static final int F_BLE_COM_RD_WAIT = 4; // RD Command Send Wait
public static final int F_BLE_COM_RECONNECT1 = 5; // ReConecting(NOTIFICATION Disable)
public static final int F_BLE_COM_RECONNECT2 = 6; // ReConecting(Wait)
public static final int F_BLE_COM_RECONNECT3 = 7; // ReConecting(NOTIFICATION Enable)
public static final int F_BLE_COM_FC_START = 8; // FC Command Sned
public static final int F_BLE_COM_FC_WAIT = 9; // FC Command Wait
// @BLE Command
public static final String F_BLE_COM_RP_COMMAND = "01525000A304"; // 01 52 50 00 A3 04 // RP 送信
......@@ -144,10 +146,10 @@ public class AlcoholCheckerUtil {
disconnect(true);
}
public void dispose() {
bleManagerUtil = null;
listener = null;
}
// public void dispose() {
// bleManagerUtil = null;
// listener = null;
// }
// Bluetoothアダプタの取得処理
public boolean startGetDeviceInfo() {
......@@ -196,8 +198,8 @@ public class AlcoholCheckerUtil {
listener.onConnectionError(status);
isConnected = false;
stopAlcTimer();
disconnect(true);
//stopAlcTimer();
//disconnect(true);
}
@Override
......@@ -389,6 +391,9 @@ public class AlcoholCheckerUtil {
TxChar.setValue(chunk);
s_mBluetoothGatt = bleManagerUtil.mBluetoothGatt;
if (s_mBluetoothGatt == null) {
throw new Exception(new Throwable());
}
if (!s_mBluetoothGatt.writeCharacteristic(TxChar)) {
throw new Exception(new Throwable());
}
......@@ -408,6 +413,10 @@ public class AlcoholCheckerUtil {
listener.onUpdateStatus("sendMessage = F_BLE_COM_RD_WAIT");
gi_status = F_BLE_COM_RD_WAIT;
break;
case F_BLE_COM_FC_START:
listener.onUpdateStatus("sendMessage = F_BLE_COM_FC_WAIT");
gi_status = F_BLE_COM_FC_WAIT;
break;
default:
// None
break;
......@@ -485,6 +494,8 @@ public class AlcoholCheckerUtil {
return out;
}
private int fcWaitMode = 0;
/**
* Checks if a character is a valid hexadecimal character
*
......@@ -506,6 +517,7 @@ public class AlcoholCheckerUtil {
sub_rx_data_gen(rxdata);
// Mode
Logger.i(TAG,"---------------------------------gi_status = " + gi_status);
switch (gi_status) {
case F_BLE_COM_INIT:
// BLE Init
......@@ -518,6 +530,9 @@ public class AlcoholCheckerUtil {
// RD Command Send Wait
gi_status = fn_rx_rd_chk(rxdata);
break;
case F_BLE_COM_FC_WAIT:
gi_status = fn_rx_fc_chk(rxdata);
break;
default:
// Others(Include Error)
gi_status = F_BLE_COM_RP_START;
......@@ -598,14 +613,9 @@ public class AlcoholCheckerUtil {
} else {
si_ret = F_BLE_COM_RP_START;
}
//mListener.onUpdateTBVCalc("測定結果表示状態 0x0C");
Logger.i(TAG,"測定結果表示状態 0x0c");
if (si_ret == F_BLE_COM_RD_START) {
Logger.i(TAG, "si_ret = F_BLE_COM_RD_START");
} else {
Logger.i(TAG, "si_ret = F_BLE_COM_RP_START");
}
// 01 46 43 01 F1 7C 04
// リザルトが出たら、FCでRDYに戻す
// si_ret = F_BLE_COM_FC_START;
break;
case (byte) 0x0D:
// Wait
......@@ -621,15 +631,13 @@ public class AlcoholCheckerUtil {
// Error
if (gf_result_flg == false) {
si_ret = F_BLE_COM_RD_START;
} else {
si_ret = F_BLE_COM_RP_START;
}
if (si_ret == F_BLE_COM_RD_START) {
Logger.i(TAG, "ERROR 0x11 si_ret = F_BLE_COM_RD_START");
} else {
si_ret = F_BLE_COM_RP_START;
Logger.i(TAG, "ERROR 0x11 si_ret = F_BLE_COM_RP_START");
}
// "エラー 0x11"
// 呼気エラー
listener.onMeasurementError("エラー 0x11");
break;
case (byte) 0x12:
......@@ -698,15 +706,57 @@ public class AlcoholCheckerUtil {
}
private int fn_rx_fc_chk(byte[] rxdata) {
int si_ret;
int si_ret = F_BLE_COM_FC_WAIT;
byte sb_data;
short ss_data;
String str_msg;
String str_msg = "";
si_ret = F_BLE_COM_RD_WAIT;
//str_msg = hex2string(rxdata);
byte[] res = hex2string(rxdata);
for (byte b: rxdata) {
str_msg += Byte.toString(b);
}
Logger.i(TAG, "fn_rx_fc_chk = " + str_msg);
// 01 72 70 02 rp 上位
// 01 114 112 02
// 2 14 -11 4 rp 下部
// 2 E F5 4
// 動作モード、進行状況、チェックサム
// 01 102 99 3 fc
//
if (fcWaitMode == 0) {
if (rxdata[0] == 1 && rxdata[1] == 102 && rxdata[2] == 99 && rxdata[3] == 3) {
Logger.i(TAG, "fc-----あああああああああああああああ---------------");
//Logger.i(TAG, "fc--------------------------------------------------------------------------------");
//Logger.i(TAG, "fc--------------------------------------------------------------------------------");
fcWaitMode = 1;
}
} else if (fcWaitMode == 1) {
if (rxdata.length == 5) {
// 0x31 49
// 2 2
// E 14
// E 14 チェックサム
// 4 4
if (rxdata[0] != 0x31) {
Logger.i(TAG, "------FC失敗");
}
Logger.i(TAG, "fc=" + fcWaitMode);
listener.onGetDeviceInfo(alcol);
fcWaitMode = 0;
si_ret = F_BLE_COM_RP_START;
}
}
return si_ret;
}
private String alcol = "";
/* @RD Command Check */
private int fn_rx_rd_chk(byte[] rxdata) {
int si_ret;
......@@ -740,15 +790,17 @@ public class AlcoholCheckerUtil {
//str_msg += "[mg/L]";
//listener.onUpdateTBVCalc(str_msg + " 0x0C 測定結果表示状態");
listener.onGetDeviceInfo(str_msg);
//listener.onGetDeviceInfo(str_msg);
alcol = str_msg;
si_ret = F_BLE_COM_FC_START;
//alcoholCheckerUtil.
//sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
return si_ret;
} else {
// Error
//listener.onError("Error");
gf_result_flg = true;
si_ret = F_BLE_COM_RP_START;
}
gf_result_flg = true;
si_ret = F_BLE_COM_RP_START;
} else {
Logger.e(TAG,"RD Error");
si_ret = F_BLE_COM_RP_START;
......
......@@ -273,10 +273,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
*/
private void initAlcoholCheckerUtil() {
// if (alcoholCheckerUtil != null) {
// alcoholCheckerUtil.dispose();
// }
alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() {
@Override
......@@ -427,22 +423,19 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
JSONObject responseJson = new JSONObject();
responseJson.put(ABookKeys.TASK_QUESTION_ID, mQid);
responseJson.put("value", value);
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
// }
// });
afterABookCheckApi(mCmd, "", 0, "", responseJson.toString());
Logger.i(TAG, "successAfterAbookCheckAip JSON [%s]", responseJson.toString());
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (isFinish) {
// BLE接続を解除して接続方法選択状態に戻る(基本中止(キャンセルは切断)
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
alcoholCheckerUtil.finish();
} else {
// BLEは切断しないが測定中断、測定開始状態に戻す(測定完了した場合は、RDYに戻す
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F22);
}
}
}, 1000);
// if (isFinish) {
// alcoholCheckerUtil.finish();
// } else {
//
// }
}
});
}
......@@ -457,11 +450,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public void run() {
closeAllDialog();
// BLE接続を解除して接続方法選択状態に戻る(基本中止(キャンセルは切断)
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
alcoholCheckerUtil.finish();
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
// }
// });
afterABookCheckApi(mCmd, "", 1, errorMessage, null);
Logger.e(TAG,errorMessage);
alcoholCheckerUtil = null;
}
});
}
......@@ -1691,6 +1687,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
webViewLoadUrl(String.format("javascript:%sCHK.afterABookCheckApi('%s', '%s', '%s', '%s')", finalParent, cmd, taskKey, result, message));
}
if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
if (alcoholCheckerUtil != null) {
alcoholCheckerUtil.finish();
alcoholCheckerUtil = null;
}
// アルコールチェッカー終了
isAlcBlock = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment