Commit 3e48ada3 by onuma

#47941 HW連携 アルコールチェッカーから値を取得する処理を追加中6

iOSとふるまいを同じにした。
parent 32a57b15
...@@ -139,10 +139,9 @@ public class AlcoholCheckerUtil { ...@@ -139,10 +139,9 @@ public class AlcoholCheckerUtil {
} }
public void finish() { public void finish() {
sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
isConnected = false; isConnected = false;
//stopAlcTimer(); stopAlcTimer();
//disconnect(true); disconnect(true);
} }
// Bluetoothアダプタの取得処理 // Bluetoothアダプタの取得処理
...@@ -174,8 +173,6 @@ public class AlcoholCheckerUtil { ...@@ -174,8 +173,6 @@ public class AlcoholCheckerUtil {
Logger.i(TAG, "Disconnected from GATT server."); Logger.i(TAG, "Disconnected from GATT server.");
listener.onConnectionError(19); listener.onConnectionError(19);
} }
//finish();
} else { } else {
Logger.i(TAG,"UNKNOW STATE = " + status); Logger.i(TAG,"UNKNOW STATE = " + status);
} }
...@@ -193,6 +190,7 @@ public class AlcoholCheckerUtil { ...@@ -193,6 +190,7 @@ public class AlcoholCheckerUtil {
Logger.i(TAG,"onConnectionError = %s", status); Logger.i(TAG,"onConnectionError = %s", status);
listener.onConnectionError(status); listener.onConnectionError(status);
isConnected = false; isConnected = false;
stopAlcTimer(); stopAlcTimer();
disconnect(true); disconnect(true);
} }
......
...@@ -79,8 +79,17 @@ public class BleManagerUtil { ...@@ -79,8 +79,17 @@ public class BleManagerUtil {
@Override @Override
public void run() { public void run() {
// 接続完了 // 接続完了
if (mBluetoothGatt == null || !mBluetoothGatt.discoverServices()) { // サービス検索 boolean isGattaNull = false;
boolean isNotDiscoverService = false;
if (mBluetoothGatt != null) {
if (!mBluetoothGatt.discoverServices()) {
isNotDiscoverService = true;
}
}
if (mBluetoothGatt == null) {
isGattaNull = true;
}
if (isGattaNull || isNotDiscoverService) {
runOnUiThread( new Runnable() { // 接続失敗 runOnUiThread( new Runnable() { // 接続失敗
@Override @Override
public void run() { public void run() {
...@@ -99,8 +108,6 @@ public class BleManagerUtil { ...@@ -99,8 +108,6 @@ public class BleManagerUtil {
disconnect(true); disconnect(true);
return; return;
} }
mListener.onConnectionState(status);
} }
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。) // サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
......
...@@ -418,19 +418,26 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -418,19 +418,26 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void run() { public void run() {
closeAllDialog(); closeAllDialog();
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);
}
JSONObject responseJson = new JSONObject(); JSONObject responseJson = new JSONObject();
responseJson.put(ABookKeys.TASK_QUESTION_ID, mQid); responseJson.put(ABookKeys.TASK_QUESTION_ID, mQid);
responseJson.put("value", value); responseJson.put("value", value);
afterABookCheckApi(mCmd, "", 0, "", responseJson.toString()); afterABookCheckApi(mCmd, "", 0, "", responseJson.toString());
Logger.i(TAG, "successAfterAbookCheckAip JSON [%s]", 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);
} }
}); });
} }
...@@ -445,9 +452,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -445,9 +452,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public void run() { public void run() {
closeAllDialog(); closeAllDialog();
// BLE接続を解除して接続方法選択状態に戻る(基本中止(キャンセルは切断) // BLE接続を解除して接続方法選択状態に戻る(基本中止(キャンセルは切断)
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11); alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
alcoholCheckerUtil.finish(); alcoholCheckerUtil.finish();
//afterABookCheckApi(mCmd, "", 1, errorMessage, null); afterABookCheckApi(mCmd, "", 1, errorMessage, null);
Logger.e(TAG,errorMessage); Logger.e(TAG,errorMessage);
} }
}); });
......
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