Commit 932da70f by onuma

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

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