Commit 97554d16 by onuma

2回目計測可能。キャンセル時は必ず切断するように修正した。

parent 25e12974
...@@ -130,11 +130,8 @@ public class AlcoholCheckerUtil { ...@@ -130,11 +130,8 @@ public class AlcoholCheckerUtil {
private Context context; private Context context;
public BleManagerUtil bleManagerUtil; public BleManagerUtil bleManagerUtil;
private AlcoholCheckerUtilListener listener; private AlcoholCheckerUtilListener listener;
// @Timer
//private AlcoholCheckerTimerTask alcoholCheckerTimerTask = null;
public static boolean isConnected = false; public static boolean isConnected = false;
// アルコール濃度 // アルコール濃度
private String strAlcoholValue = ""; private String strAlcoholValue = "";
...@@ -145,7 +142,9 @@ public class AlcoholCheckerUtil { ...@@ -145,7 +142,9 @@ public class AlcoholCheckerUtil {
public static final int fugo_wait_go = 3; public static final int fugo_wait_go = 3;
public static final int fugo_fu_error = 4; public static final int fugo_fu_error = 4;
public static final int fugo_restart = 5; public static final int fugo_restart = 5;
//public int alcStatus = 0;
// mutex
private Object lockObj = new Object();
public AlcoholCheckerUtil(Context context, AlcoholCheckerUtilListener listener) { public AlcoholCheckerUtil(Context context, AlcoholCheckerUtilListener listener) {
this.context = context; this.context = context;
...@@ -155,15 +154,27 @@ public class AlcoholCheckerUtil { ...@@ -155,15 +154,27 @@ public class AlcoholCheckerUtil {
public void finish() { public void finish() {
isConnected = false; isConnected = false;
disconnect(true); disconnect();
} }
// Bluetoothアダプタの取得処理 // Bluetoothアダプタの取得処理
public boolean startGetDeviceInfo() { public boolean startGetDeviceInfo() {
// BLE管理 // BLE管理
bleManagerUtil = new BleManagerUtil(context, new BleManagerUtilListener() { bleManagerUtil = new BleManagerUtil(context, new BleManagerUtilListener() {
@Override @Override
public void onGetDeviceInfoFailed(int status) {
}
@Override
public void onGetDeviceInfo(String strTemperature) {
}
@Override
public void onConnectionState(int status) { public void onConnectionState(int status) {
// Logger.i(TAG,"-------------------------------------------------------------- = %s", status); // Logger.i(TAG,"-------------------------------------------------------------- = %s", status);
// Logger.i(TAG,"onConnectionState = %s", status); // Logger.i(TAG,"onConnectionState = %s", status);
...@@ -249,13 +260,9 @@ public class AlcoholCheckerUtil { ...@@ -249,13 +260,9 @@ public class AlcoholCheckerUtil {
gi_status = F_BLE_COM_RP_START; gi_status = F_BLE_COM_RP_START;
//startAlcTimer();
SendMessageFromApp(gi_status); SendMessageFromApp(gi_status);
listener.onServicesDiscovered(status); listener.onServicesDiscovered(status);
//Logger.i(TAG,"iiiiiiiiiiiiiiiiiiiiiii");
} }
} }
} else { } else {
...@@ -265,17 +272,19 @@ public class AlcoholCheckerUtil { ...@@ -265,17 +272,19 @@ public class AlcoholCheckerUtil {
@Override @Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
//Logger.d(TAG,"onCharacteristicChanged"); synchronized (lockObj) {
Logger.d(TAG, "onCharacteristicChanged");
byte[] rx = characteristic.getValue(); byte[] rx = characteristic.getValue();
String rxStr = " "; String rxStr = " ";
if (rx != null && rx.length > 0) { if (rx != null && rx.length > 0) {
for ( byte rx1 : rx) { for (byte rx1 : rx) {
rxStr += rx1 + " ,"; rxStr += rx1 + " ,";
} }
} }
sub_rx_chk(rx); sub_rx_chk(rx);
} }
}
@Override @Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
...@@ -337,10 +346,11 @@ public class AlcoholCheckerUtil { ...@@ -337,10 +346,11 @@ public class AlcoholCheckerUtil {
// public int lastSendCmd; // public int lastSendCmd;
public void SendMessageFromApp(final int giStatus) { public void SendMessageFromApp(final int giStatus) {
synchronized (lockObj) {
if (giStatus == F_BLE_COM_RP_START || giStatus == F_BLE_COM_RD_START || giStatus == F_BLE_COM_FC_START || giStatus == F_BLE_COM_FC_START22) { if (giStatus == F_BLE_COM_RP_START || giStatus == F_BLE_COM_RD_START || giStatus == F_BLE_COM_FC_START || giStatus == F_BLE_COM_FC_START22) {
Logger.d(TAG, "giStatus = " + giStatus); Logger.d(TAG, "gi_status = " + giStatus);
} else { } else {
Logger.w(TAG,"UNKOWN COMMAND"); Logger.w(TAG, "UNKOWN COMMAND");
} }
//lastSendCmd = giStatus; //lastSendCmd = giStatus;
...@@ -366,15 +376,16 @@ public class AlcoholCheckerUtil { ...@@ -366,15 +376,16 @@ public class AlcoholCheckerUtil {
}); });
thread.start(); thread.start();
} }
}
public void connect(int connectTargetDeviceType, String deviceAddress) { public void connect(int connectTargetDeviceType, String deviceAddress) {
bleManagerUtil.connect(connectTargetDeviceType, deviceAddress); bleManagerUtil.connect(connectTargetDeviceType, deviceAddress);
} }
// 切断 // 切断
public void disconnect(boolean listenerFlg) { public void disconnect() {
isConnected = false; isConnected = false;
bleManagerUtil.disconnect(listenerFlg); bleManagerUtil.disconnect();
} }
...@@ -672,6 +683,7 @@ public class AlcoholCheckerUtil { ...@@ -672,6 +683,7 @@ public class AlcoholCheckerUtil {
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x0A: case (byte) 0x0A:
// 計測
listener.onUpdateTBVCalc("Go"); listener.onUpdateTBVCalc("Go");
// Blow // Blow
gf_result_flg = false; gf_result_flg = false;
...@@ -815,6 +827,7 @@ public class AlcoholCheckerUtil { ...@@ -815,6 +827,7 @@ public class AlcoholCheckerUtil {
if(!StringUtil.isNullOrEmpty(strAlcoholValue)) { if(!StringUtil.isNullOrEmpty(strAlcoholValue)) {
// 測定値あれば成功 // 測定値あれば成功
listener.onGetDeviceInfo(strAlcoholValue); listener.onGetDeviceInfo(strAlcoholValue);
strAlcoholValue = "";
} }
fcWaitMode = 0; fcWaitMode = 0;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
...@@ -848,6 +861,7 @@ public class AlcoholCheckerUtil { ...@@ -848,6 +861,7 @@ public class AlcoholCheckerUtil {
if (!StringUtil.isNullOrEmpty(strAlcoholValue)) { if (!StringUtil.isNullOrEmpty(strAlcoholValue)) {
// 測定値あれば成功 // 測定値あれば成功
listener.onGetDeviceInfo(strAlcoholValue); listener.onGetDeviceInfo(strAlcoholValue);
strAlcoholValue = "";
} }
fcWaitMode = 0; fcWaitMode = 0;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
......
...@@ -12,11 +12,9 @@ import android.bluetooth.BluetoothProfile; ...@@ -12,11 +12,9 @@ import android.bluetooth.BluetoothProfile;
import android.bluetooth.le.ScanCallback; import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanResult;
import android.content.Context; import android.content.Context;
import android.graphics.RenderNode;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.widget.Toast;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -24,7 +22,6 @@ import java.nio.ByteOrder; ...@@ -24,7 +22,6 @@ import java.nio.ByteOrder;
import java.util.UUID; import java.util.UUID;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static android.bluetooth.BluetoothDevice.TRANSPORT_LE; import static android.bluetooth.BluetoothDevice.TRANSPORT_LE;
...@@ -76,13 +73,6 @@ public class BleManagerUtil { ...@@ -76,13 +73,6 @@ public class BleManagerUtil {
Logger.e(TAG,"onConnectionStateChange status = " + status); Logger.e(TAG,"onConnectionStateChange status = " + status);
} }
}); });
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// //mBluetoothGatt = device.connectGatt(mContext, false, mGattcallback, TRANSPORT_LE);
// bleGattReconnect();
// }
// });
return; return;
} }
...@@ -105,7 +95,9 @@ public class BleManagerUtil { ...@@ -105,7 +95,9 @@ public class BleManagerUtil {
runOnUiThread( new Runnable() { // 接続失敗 runOnUiThread( new Runnable() { // 接続失敗
@Override @Override
public void run() { public void run() {
//mListener.onGetDeviceInfoFailed(status); if (mListener != null) {
mListener.onGetDeviceInfoFailed(status);
}
Logger.e("onConnectionStateChange status = " + status); Logger.e("onConnectionStateChange status = " + status);
} }
}); });
...@@ -116,10 +108,12 @@ public class BleManagerUtil { ...@@ -116,10 +108,12 @@ public class BleManagerUtil {
} }
if( BluetoothProfile.STATE_DISCONNECTED == newState ) { // 切断完了(接続可能範囲から外れて切断された) if( BluetoothProfile.STATE_DISCONNECTED == newState ) { // 切断完了(接続可能範囲から外れて切断された)
Logger.e(TAG,"out of range"); Logger.w(TAG,"BluetoothProfile.STATE_DISCONNECTED");
//Logger.e(TAG,"out of range");
// 切断が発生する場合、Bluetoothと接続を切断する。 // 切断が発生する場合、Bluetoothと接続を切断する。
disconnect(true); if (mListener != null) {
return; mListener.onConnectionError(status);
}
} }
} }
...@@ -133,10 +127,13 @@ public class BleManagerUtil { ...@@ -133,10 +127,13 @@ public class BleManagerUtil {
return; return;
} }
//mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
if (mBluetoothGatt == null) {
mBluetoothGatt = gatt;
}
mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH); mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
if (mListener != null) if (mListener != null) {
{
// アルコールチェッカー // アルコールチェッカー
mListener.onServicesDiscovered(status); mListener.onServicesDiscovered(status);
} }
...@@ -163,26 +160,18 @@ public class BleManagerUtil { ...@@ -163,26 +160,18 @@ public class BleManagerUtil {
@Override @Override
public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic ) { public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic ) {
Logger.d(TAG,"onCharacteristicChanged"); Logger.d(TAG,"onCharacteristicChanged");
if (mListener != null) {
mListener.onCharacteristicChanged(gatt, characteristic); mListener.onCharacteristicChanged(gatt, characteristic);
// runOnUiThread(new Runnable() { }
// @Override
// public void run() {
// try {
// if (mListener != null) {
// mListener.onCharacteristicChanged(gatt, characteristic);
// }
// } catch (Exception e) {
// Logger.e(TAG,e);
// }
// }
// });
} }
@Override @Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){ public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){
Logger.d(TAG,"onDescriptorWrite"); Logger.d(TAG,"onDescriptorWrite");
try { try {
if (mListener != null) {
mListener.onDescriptorWrite(gatt, descriptor, status); mListener.onDescriptorWrite(gatt, descriptor, status);
}
} catch ( Exception e) { } catch ( Exception e) {
Logger.e(TAG,e); Logger.e(TAG,e);
} }
...@@ -223,8 +212,10 @@ public class BleManagerUtil { ...@@ -223,8 +212,10 @@ public class BleManagerUtil {
runOnUiThread( new Runnable() { runOnUiThread( new Runnable() {
@Override @Override
public void run() { public void run() {
if (mListener != null) {
mListener.onConnectionError(errorCode); mListener.onConnectionError(errorCode);
} }
}
}); });
} }
}; };
...@@ -300,7 +291,7 @@ public class BleManagerUtil { ...@@ -300,7 +291,7 @@ public class BleManagerUtil {
} }
// 切断 // 切断
public void disconnect(boolean listenerFlg) { public void disconnect() {
if(mBluetoothGatt == null) { if(mBluetoothGatt == null) {
return; return;
...@@ -397,7 +388,7 @@ public class BleManagerUtil { ...@@ -397,7 +388,7 @@ public class BleManagerUtil {
* 再接続処理 * 再接続処理
*/ */
private void bleGattReconnect() { private void bleGattReconnect() {
disconnect(false); disconnect();
connect(mBleConnectDeviceType, mDeviceAddress); connect(mBleConnectDeviceType, mDeviceAddress);
} }
......
...@@ -5,9 +5,12 @@ import android.bluetooth.BluetoothGattCharacteristic; ...@@ -5,9 +5,12 @@ import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattDescriptor;
public interface BleManagerUtilListener { public interface BleManagerUtilListener {
void onGetDeviceInfo(String strTemperature); // ディバイスから渡す情報
void onGetDeviceInfoFailed(int status); // ディバイスと接続失敗時の情報渡す。
void onConnectionState(int status); // ディバイスと接続された時情報渡す。 void onConnectionState(int status); // ディバイスと接続された時情報渡す。
void onDisConnectionState(); // ディバイスと切断時 void onDisConnectionState(); // ディバイスと切断時
void onConnectionError(int status); // ディバイス接続エラー void onConnectionError(int status); // ディバイス接続エラー
// アルコールチェッカーで追加
void onServicesDiscovered(int status); void onServicesDiscovered(int status);
void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic); void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic);
void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status); void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status);
......
...@@ -66,7 +66,6 @@ import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper; ...@@ -66,7 +66,6 @@ import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper;
import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil; import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil;
import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtilListener; import jp.agentec.abook.abv.cl.util.AlcoholCheckerUtilListener;
import jp.agentec.abook.abv.cl.util.AndroidStringUtil; import jp.agentec.abook.abv.cl.util.AndroidStringUtil;
import jp.agentec.abook.abv.cl.util.BleManagerUtil;
import jp.agentec.abook.abv.cl.util.ContentLogUtil; import jp.agentec.abook.abv.cl.util.ContentLogUtil;
import jp.agentec.abook.abv.cl.util.LocationManagerUtil; import jp.agentec.abook.abv.cl.util.LocationManagerUtil;
import jp.agentec.abook.abv.cl.util.PreferenceUtil; import jp.agentec.abook.abv.cl.util.PreferenceUtil;
...@@ -184,13 +183,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -184,13 +183,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private int mDeviceType; private int mDeviceType;
// 設問ID // 設問ID
private String mQid = ""; private String mQid = "";
// アルコールチェッカー二重初期化防止フラグ
private boolean isInitAlcChecker = false;
private boolean isInitBLE = false;
// 二重起動防止フラグ(アルコールチェッカー) // 二重起動防止フラグ(アルコールチェッカー)
private boolean isAlcBlock = false; private boolean isAlcBlock = false;
// 終了フラグ // ステータス
//private boolean isFinish = false;
private int checkerStatus = AlcoholCheckerUtil.fugo_init; private int checkerStatus = AlcoholCheckerUtil.fugo_init;
// BLE接続中にonStopしたら、再接続からやりなおし
//private boolean isReconnect = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -262,12 +263,20 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -262,12 +263,20 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
contentDownloader.pauseAll(); contentDownloader.pauseAll();
showUpdateContentAlert(contentId); showUpdateContentAlert(contentId);
isInitAlcChecker = false;
isInitBLE = false;
} }
/** /**
* アルコールチェッカー、ユーティリティ初期化 * アルコールチェッカー、ユーティリティ初期化
*/ */
private void initAlcoholCheckerUtil() { private void initAlcoholCheckerUtil() {
Logger.i(TAG,"initAlcoholCheckerUtil");
if (alcoholCheckerUtil != null) {
checkerStatus = AlcoholCheckerUtil.fugo_init;
return;
}
alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() { alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() {
...@@ -317,7 +326,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -317,7 +326,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void onStartMeasurement() { public void onStartMeasurement() {
Logger.d(TAG, "onStartMeasurement"); Logger.d(TAG, "onStartMeasurement");
final boolean isFromError;
if (checkerStatus == AlcoholCheckerUtil.fugo_conntected) { if (checkerStatus == AlcoholCheckerUtil.fugo_conntected) {
isFromError = false;
checkerStatus = AlcoholCheckerUtil.fugo_wait_go;
} else if (checkerStatus == AlcoholCheckerUtil.fugo_fu_error) {
isFromError = true;
checkerStatus = AlcoholCheckerUtil.fugo_wait_go; checkerStatus = AlcoholCheckerUtil.fugo_wait_go;
} else { } else {
return; return;
...@@ -325,12 +339,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -325,12 +339,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (isFromError) {
if (mMeasureDialog != null) {
mMeasureDialog.setMessage(getString(R.string.msg_breath_error));
}
} else {
if (mWaitMeasureDialog != null) { if (mWaitMeasureDialog != null) {
mWaitMeasureDialog.dismiss(); mWaitMeasureDialog.dismiss();
mWaitMeasureDialog = null; mWaitMeasureDialog = null;
} }
showMeasureDialog(getString(R.string.alcohol_checker), getString(R.string.wait_breathe)); showMeasureDialog(getString(R.string.alcohol_checker), getString(R.string.wait_breathe));
} }
}
}); });
} }
...@@ -436,10 +456,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -436,10 +456,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void run() { public void run() {
dismissAllDialog(); dismissAllDialog();
if (AlcoholCheckerUtil.isConnected) {
alcoholCheckerUtil.SendMessageFromApp(AlcoholCheckerUtil.F_BLE_COM_FC_START); alcoholCheckerUtil.SendMessageFromApp(AlcoholCheckerUtil.F_BLE_COM_FC_START);
}
if (isSendResult) { if (isSendResult) {
afterABookCheckApi(mCmd, "", 1, errorMessage, null); afterABookCheckApi(mCmd, "", 1, errorMessage, null);
} }
if(alcoholCheckerUtil != null) {
alcoholCheckerUtil.finish();
alcoholCheckerUtil = null;
}
isInitAlcChecker = false;
isInitBLE = false;
Logger.e(TAG,errorMessage); Logger.e(TAG,errorMessage);
isAlcBlock = false; isAlcBlock = false;
} }
...@@ -459,7 +487,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -459,7 +487,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting Dialog stop click"); Logger.i(TAG, "waiting Dialog stop click");
//AlcoholCheckerUtil.isConnected = false;
errorAfterAbookCheckApi("", false); errorAfterAbookCheckApi("", false);
//alcoholCheckerUtil.disconnect();
} }
}); });
mWaitingDialog.show(); mWaitingDialog.show();
...@@ -478,7 +508,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -478,7 +508,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting mWaitMeasureDialog stop clickf"); Logger.i(TAG, "waiting mWaitMeasureDialog stop clickf");
//AlcoholCheckerUtil.isConnected = false;
errorAfterAbookCheckApi("", false); errorAfterAbookCheckApi("", false);
//alcoholCheckerUtil.disconnect();
} }
}); });
mWaitMeasureDialog.show(); mWaitMeasureDialog.show();
...@@ -497,32 +529,60 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -497,32 +529,60 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "wait mMeasureDialog stop click"); Logger.i(TAG, "wait mMeasureDialog stop click");
//AlcoholCheckerUtil.isConnected = false;
errorAfterAbookCheckApi("", false); errorAfterAbookCheckApi("", false);
//alcoholCheckerUtil.disconnect();
} }
}); });
mMeasureDialog.show(); mMeasureDialog.show();
} }
/** /**
* アルコールチェッカー処理 * アルコールチェッカー処理
* @param abookCheckParam * @param abookCheckParam
*/ */
private void getDeviceInfo(Map<String, String> abookCheckParam) { private void getDeviceInfo(Map<String, String> abookCheckParam) {
Logger.i(TAG,"getDeviceInfo start."); Logger.i(TAG, "getDeviceInfo start.");
mDeviceType = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_DEVICE_TYPE)); mDeviceType = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_DEVICE_TYPE));
mQid = abookCheckParam.get(ABookKeys.TASK_QUESTION_ID); mQid = abookCheckParam.get(ABookKeys.TASK_QUESTION_ID);
if (!isInitAlcChecker) {
// アルコールチェッカー初期化 // アルコールチェッカー初期化
initAlcoholCheckerUtil(); initAlcoholCheckerUtil();
}
if (isInitBLE == false) {
if (!alcoholCheckerUtil.startGetDeviceInfo()) { if (!alcoholCheckerUtil.startGetDeviceInfo()) {
// 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない // 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない
Logger.e(TAG,"bluetooth not support."); Logger.e(TAG, "bluetooth not support.");
afterABookCheckApi(mCmd, "", 1, getString(R.string.bluetooth_is_not_supported), null);
return;
} else {
isInitBLE = true;
} }
}
if (!isInitAlcChecker) {
// アルコールチェッカー接続 // アルコールチェッカー接続
connectToAlcholChecker(); connectToAlcholChecker();
isInitAlcChecker = true;
} else {
BluetoothPairingDeviceInfoDto dto = getABVUIDataCache().getPairingBluetoothDeviceInfo(Constant.DeviceType.alcoholChecker);
checkerStatus = AlcoholCheckerUtil.fugo_wait_connect;
if (AlcoholCheckerUtil.isConnected) {
Logger.d(TAG, "isConnection = true");
checkerStatus = AlcoholCheckerUtil.fugo_conntected;
showWaitMeasureDialog(getString(R.string.alcohol_checker), getString(R.string.connection_completed));
} else {
Logger.d(TAG, "isConnection = false");
// 登録されているアルコールチェッカーがある
String message = String.format(getString(R.string.ble_connecting), dto.deviceName);
showWaitingDialog(getString(R.string.alcohol_checker), message);
// 接続まち
alcoholCheckerUtil.connect(Constant.DeviceType.alcoholChecker, dto.deviceAddress);
}
}
} }
/** /**
...@@ -626,23 +686,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -626,23 +686,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
Logger.d(TAG,"-------------------------------------------------");
Logger.i(TAG,"onPause"); Logger.i(TAG,"onPause");
Logger.d(TAG,"-------------------------------------------------"); if (mCmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
errorAfterAbookCheckApi("", false);
// ダイアログ閉じる
dismissAllDialog();
// タイマーにFCコマンド
if (alcoholCheckerUtil != null) {
alcoholCheckerUtil.SendMessageFromApp(AlcoholCheckerUtil.F_BLE_COM_FC_START);
isAlcBlock = false;
handler.postDelayed(new Runnable() {
@Override
public void run() {
// チェッカーも終了
alcoholCheckerUtil.finish();
}
}, 1000);
} }
} }
...@@ -1700,23 +1746,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1700,23 +1746,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) { if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
// アルコールチェッカー終了 // アルコールチェッカー終了
isAlcBlock = false; isAlcBlock = false;
// if (alcoholCheckerUtil != null) {
// if (!isFinish) {
// alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START22;
// } else {
// alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
// }
// }
} }
// if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
//// if (alcoholCheckerUtil != null) {
//// alcoholCheckerUtil.finish();
//// alcoholCheckerUtil = null;
//// }
// // アルコールチェッカー終了
// isAlcBlock = false;
// }
} }
}); });
} }
...@@ -1969,11 +1999,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1969,11 +1999,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} }
} }
/**
* 全Bluetoothデバイスとの接続を切る
*/
private void disconnectBluetoothDevice() { private void disconnectBluetoothDevice() {
Logger.d(TAG, "disconnectBluetoothDevice"); Logger.d(TAG, "disconnectBluetoothDevice");
if (alcoholCheckerUtil != null) { if (alcoholCheckerUtil != null) {
alcoholCheckerUtil.finish(); alcoholCheckerUtil.finish();
alcoholCheckerUtil = null; alcoholCheckerUtil = null;
} }
isInitAlcChecker = false;
isInitBLE = false;
} }
} }
\ No newline at end of file
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