Commit 932da70f by onuma

計測終了後にRDY状態に戻るように修正

parent 6d3a69d6
...@@ -26,7 +26,7 @@ public class AlcoholCheckerTimerTask extends TimerTask { ...@@ -26,7 +26,7 @@ public class AlcoholCheckerTimerTask extends TimerTask {
@Override @Override
public void run() { public void run() {
alcoholCheckerUtil.gi_rxlength = 0; //alcoholCheckerUtil.gi_rxlength = 0;
switch (alcoholCheckerUtil.gi_status) { switch (alcoholCheckerUtil.gi_status) {
case F_BLE_COM_INIT: case F_BLE_COM_INIT:
...@@ -34,18 +34,23 @@ public class AlcoholCheckerTimerTask extends TimerTask { ...@@ -34,18 +34,23 @@ public class AlcoholCheckerTimerTask extends TimerTask {
break; break;
case F_BLE_COM_RP_START: case F_BLE_COM_RP_START:
// RP Command Send // RP Command Send
Logger.d(TAG,"F_BLE_COM_RP_START"); //Logger.d(TAG,"F_BLE_COM_RP_START");
alcoholCheckerUtil.sendMessage(F_BLE_COM_RP_COMMAND); //alcoholCheckerUtil.sendMessage(F_BLE_COM_RP_COMMAND);
break; break;
case AlcoholCheckerUtil.F_BLE_COM_RD_START: case AlcoholCheckerUtil.F_BLE_COM_RD_START:
// RD Command Send // RD Command Send
Logger.d(TAG,"F_BLE_COM_RD_START"); //Logger.d(TAG,"F_BLE_COM_RD_START");
alcoholCheckerUtil.sendMessage(F_BLE_COM_RD_COMMAND); //alcoholCheckerUtil.sendMessage(F_BLE_COM_RD_COMMAND);
break; break;
case AlcoholCheckerUtil.F_BLE_COM_FC_START: case AlcoholCheckerUtil.F_BLE_COM_FC_START:
// Fc Command Send // Fc Command Send
Logger.d(TAG,"F_BLE_COM_FC_START"); //Logger.d(TAG,"F_BLE_COM_FC_START");
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11); //alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
break;
case AlcoholCheckerUtil.F_BLE_COM_FC_START22:
// Fc Command Send
//Logger.d(TAG,"F_BLE_COM_FC_START22");
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F22);
break; break;
// case F_BLE_COM_RECONNECT1: // case F_BLE_COM_RECONNECT1:
// // ReConecting(NOTIFICATION Disable) // @@@ // // ReConecting(NOTIFICATION Disable) // @@@
......
...@@ -12,6 +12,7 @@ import android.bluetooth.BluetoothProfile; ...@@ -12,6 +12,7 @@ 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;
...@@ -59,7 +60,9 @@ public class BleManagerUtil { ...@@ -59,7 +60,9 @@ public class BleManagerUtil {
@Override @Override
public void onConnectionStateChange(BluetoothGatt gatt, final int status, final int newState ) { public void onConnectionStateChange(BluetoothGatt gatt, final int status, final int newState ) {
Logger.i("onConnectionStateChange status = " + status + " newState = " + newState); Logger.i("onConnectionStateChange status = " + status + " newState = " + newState);
if (newState == BluetoothProfile.STATE_CONNECTED) {
gatt.discoverServices();
}
// デバイスと接続されていない場合のメッセージコード:133, 62 // デバイスと接続されていない場合のメッセージコード:133, 62
// デバイスと離れて応答がなく、タイムアウトになる場合:8 // デバイスと離れて応答がなく、タイムアウトになる場合:8
// デバイスと接続が切れた場合のメッセージコード:19 // デバイスと接続が切れた場合のメッセージコード:19
...@@ -73,6 +76,13 @@ public class BleManagerUtil { ...@@ -73,6 +76,13 @@ 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;
} }
...@@ -116,25 +126,36 @@ public class BleManagerUtil { ...@@ -116,25 +126,36 @@ public class BleManagerUtil {
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。) // サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
@Override @Override
public void onServicesDiscovered(BluetoothGatt gatt, final int status) { public void onServicesDiscovered(BluetoothGatt gatt, final int status) {
Logger.i(TAG,"onServicesDiscovered status = %s", status); try {
Logger.i(TAG, "onServicesDiscovered status = %s", status);
if( BluetoothGatt.GATT_SUCCESS != status ) { if (BluetoothGatt.GATT_SUCCESS != status) {
return; return;
} }
mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
// アルコールチェッカー mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
mListener.onServicesDiscovered(status);
if (mListener != null)
{
// アルコールチェッカー
mListener.onServicesDiscovered(status);
}
} catch (Exception e) {
Logger.d(TAG,e);
}
} }
// キャラクタリスティックが読み込まれたときの処理 // キャラクタリスティックが読み込まれたときの処理
@Override @Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) { public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) {
Logger.d(TAG, "onCharacteristicRead"); try {
if (BluetoothGatt.GATT_SUCCESS != status) { Logger.d(TAG, "onCharacteristicRead");
return; if (BluetoothGatt.GATT_SUCCESS != status)
{
return;
}
} catch (Exception e) {
Logger.d(TAG,"null");
} }
} }
...@@ -142,14 +163,24 @@ public class BleManagerUtil { ...@@ -142,14 +163,24 @@ public class BleManagerUtil {
@Override @Override
public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) { public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) {
Logger.d(TAG,"onCharacteristicChanged"); Logger.d(TAG,"onCharacteristicChanged");
if (mListener != null) { try {
mListener.onCharacteristicChanged(gatt, characteristic); //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");
mListener.onDescriptorWrite(gatt, descriptor, status); try {
mListener.onDescriptorWrite(gatt, descriptor, status);
} catch ( Exception e) {
Logger.e(TAG,e);
}
} }
}; };
......
...@@ -187,6 +187,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -187,6 +187,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 二重起動防止フラグ(アルコールチェッカー) // 二重起動防止フラグ(アルコールチェッカー)
private boolean isAlcBlock = false; private boolean isAlcBlock = false;
// 終了フラグ
private boolean isFinish = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -280,9 +282,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -280,9 +282,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} else { } else {
return; return;
} }
runOnUiThread(new Runnable() { // runOnUiThread(new Runnable() {
@Override // @Override
public void run() { // public void run() {
if (mWaitingDialog != null) { if (mWaitingDialog != null) {
mWaitingDialog.dismiss(); mWaitingDialog.dismiss();
mWaitingDialog = null; mWaitingDialog = null;
...@@ -290,18 +292,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -290,18 +292,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
alcoholCheckerUtil.isConnected = true; alcoholCheckerUtil.isConnected = true;
// 測定開始ボタン押し待ち // 測定開始ボタン押し待ち
showWaitMeasureDialog(getString(R.string.alcohol_checker), getString(R.string.connection_completed)); showWaitMeasureDialog(getString(R.string.alcohol_checker), getString(R.string.connection_completed));
} // }
}); // });
} }
@Override @Override
public void onGetDeviceInfo(String alcohol) { public void onGetDeviceInfo(final String alcohol) {
Logger.d(TAG, "測定完了 = " + alcohol); // runOnUiThread(new Runnable() {
if (!alcohol.equals("")) { // @Override
successAfterAbookCheckApi(alcohol, false); // public void run() {
} else { Logger.d(TAG, "測定完了 = " + alcohol);
if (!alcohol.equals("")) {
successAfterAbookCheckApi(alcohol, false);
} else {
} }
// }
// });
} }
@Override @Override
...@@ -312,16 +319,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -312,16 +319,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} else { } else {
return; return;
} }
runOnUiThread(new Runnable() { // runOnUiThread(new Runnable() {
@Override // @Override
public void run() { // public void run() {
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));
} // }
}); // });
} }
@Override @Override
...@@ -399,7 +406,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -399,7 +406,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* 各デバイスから値を正常に取得された場合、HTML側にコールする * 各デバイスから値を正常に取得された場合、HTML側にコールする
* @param value 各種デバイスから取得した値 * @param value 各種デバイスから取得した値
*/ */
private void successAfterAbookCheckApi(final String value, final boolean isFinish) { private void successAfterAbookCheckApi(final String value, boolean isFinish) {
this.isFinish = isFinish;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -407,7 +415,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -407,7 +415,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
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);
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11); // alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F22);
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START22;
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());
} }
...@@ -419,11 +429,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -419,11 +429,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param errorMessage 各種デバイスから取得した値 * @param errorMessage 各種デバイスから取得した値
*/ */
private void errorAfterAbookCheckApi(final String errorMessage) { private void errorAfterAbookCheckApi(final String errorMessage) {
// エラーの時は終了
isFinish = true;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
dismissAllDialog(); dismissAllDialog();
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11); //alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
afterABookCheckApi(mCmd, "", 1, errorMessage, null); afterABookCheckApi(mCmd, "", 1, errorMessage, null);
Logger.e(TAG,errorMessage); Logger.e(TAG,errorMessage);
} }
...@@ -444,6 +457,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -444,6 +457,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
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");
successAfterAbookCheckApi("", true); successAfterAbookCheckApi("", true);
//errorAfterAbookCheckApi("");
} }
}); });
mWaitingDialog.show(); mWaitingDialog.show();
...@@ -462,7 +476,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -462,7 +476,8 @@ 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");
successAfterAbookCheckApi("", true); successAfterAbookCheckApi("", false);
//errorAfterAbookCheckApi("");
} }
}); });
mWaitMeasureDialog.show(); mWaitMeasureDialog.show();
...@@ -481,7 +496,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -481,7 +496,8 @@ 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");
successAfterAbookCheckApi("", true); successAfterAbookCheckApi("", false);
//errorAfterAbookCheckApi("");
} }
}); });
mMeasureDialog.show(); mMeasureDialog.show();
...@@ -627,12 +643,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -627,12 +643,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// タイマーにFCコマンド // タイマーにFCコマンド
if (alcoholCheckerUtil != null) { if (alcoholCheckerUtil != null) {
isAlcBlock = false; // false にしないと2回目押せない isAlcBlock = false; // false にしないと2回目押せない
alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START; //alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
// チェッカーも終了 // チェッカーも終了
alcoholCheckerUtil.finish(); //alcoholCheckerUtil.finish();
} }
}, 1000); }, 1000);
...@@ -644,7 +660,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -644,7 +660,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.d(TAG,"-------------------------------------------------"); Logger.d(TAG,"-------------------------------------------------");
Logger.d(TAG,"onDestroy"); Logger.d(TAG,"onDestroy");
Logger.d(TAG,"-------------------------------------------------"); Logger.d(TAG,"-------------------------------------------------");
//Logger.d(TAG, "onDestroy");
if (readingLogFlg) { if (readingLogFlg) {
ContentReadingLogLogic logic = AbstractLogic.getLogic(ContentReadingLogLogic.class); ContentReadingLogLogic logic = AbstractLogic.getLogic(ContentReadingLogLogic.class);
logic.endContentReadLog(contentId); logic.endContentReadLog(contentId);
...@@ -1372,12 +1387,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1372,12 +1387,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mCmd, mTaskKey, mEnableReportHistory, abookCheckParam, mOperationId, mContentPath, getContentId(), mCmd, mTaskKey, mEnableReportHistory, abookCheckParam, mOperationId, mContentPath, getContentId(),
operationDto.reportType, finishCallback, taskReportLevel); operationDto.reportType, finishCallback, taskReportLevel);
// if (StringUtil.equalsAny(mCmd,ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT, if (StringUtil.equalsAny(mCmd,ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT,
// ABookKeys.CMD_DELETE_TASK_REPORT , ABookKeys.CMD_CANCEL_TASK_REPORT, ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT) ABookKeys.CMD_DELETE_TASK_REPORT , ABookKeys.CMD_CANCEL_TASK_REPORT, ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT)
// ){ ){
// // 作業一覧に戻る時,bluetoothを切断する。 // 作業一覧に戻る時,bluetoothを切断する。
// disconnectBluetoothDevice(); //disconnectBluetoothDevice();
// } }
} catch(Exception e) { } catch(Exception e) {
Logger.e(TAG, "doABookCheckParam error", e); Logger.e(TAG, "doABookCheckParam error", e);
...@@ -1683,13 +1698,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1683,13 +1698,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
webViewLoadUrl(String.format("javascript:%sCHK.afterABookCheckApi('%s', '%s', '%s', '%s')", finalParent, cmd, taskKey, result, message)); webViewLoadUrl(String.format("javascript:%sCHK.afterABookCheckApi('%s', '%s', '%s', '%s')", finalParent, cmd, taskKey, result, message));
} }
if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) { if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
if (alcoholCheckerUtil != null) {
alcoholCheckerUtil.finish();
alcoholCheckerUtil = null;
}
// アルコールチェッカー終了 // アルコールチェッカー終了
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;
// }
} }
}); });
} }
...@@ -1941,4 +1968,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1941,4 +1968,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
this.mPhotoEditDialog.show(); this.mPhotoEditDialog.show();
} }
} }
private void disconnectBluetoothDevice() {
Logger.d(TAG, "disconnectBluetoothDevice");
// if (alcoholCheckerUtil != null) {
// alcoholCheckerUtil.finish();
// alcoholCheckerUtil = null;
// }
}
} }
\ 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