Commit 88fdc1ad by onuma

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

parent b71b72a9
...@@ -174,5 +174,11 @@ public interface ServiceOption { ...@@ -174,5 +174,11 @@ public interface ServiceOption {
* 利用しない:N(通常)、利用する:Y * 利用しない:N(通常)、利用する:Y
*/ */
int UsableRFIDBarcodeScan = 190; int UsableRFIDBarcodeScan = 190;
/**
* アルコールチェッカーHW
* 利用しない:N(通常)、利用する:Y
*/
int AlcoholCheckerHw = 202;
} }
} }
\ No newline at end of file
...@@ -186,12 +186,12 @@ public class Constant { ...@@ -186,12 +186,12 @@ public class Constant {
// 連携機器の区分 // 連携機器の区分
public interface DeviceType { public interface DeviceType {
int centerThermomete = 1; // 中心温度計 // int centerThermomete = 1; // 中心温度計
int sensor = 2; // 置くだけセンサー // int sensor = 2; // 置くだけセンサー
int barcode = 3; // バーコード // int barcode = 3; // バーコード
int radiationThermomete = 4; // 放射温度計 // int radiationThermomete = 4; // 放射温度計
int sppBluetoothMachine = 5; // SPP通信機器 // int sppBluetoothMachine = 5; // SPP通信機器
int nfc = 6; // nfc機器 // int nfc = 6; // nfc機器
int alcoholChecker = 7; // アルコールチェッカー int alcoholChecker = 0; // アルコールチェッカー
} }
} }
...@@ -347,6 +347,10 @@ public class ABVDataCache { ...@@ -347,6 +347,10 @@ public class ABVDataCache {
return isServiceOptionEnable(ServiceOptionId.UsableRFIDBarcodeScan); return isServiceOptionEnable(ServiceOptionId.UsableRFIDBarcodeScan);
} }
public boolean isAlcoholCheckerHw() {
return isServiceOptionEnable(ServiceOptionId.AlcoholCheckerHw);
}
/** /**
* @version 1.2.300 * @version 1.2.300
* サービスオプション(ユーザパスワードソルト付加)返す * サービスオプション(ユーザパスワードソルト付加)返す
......
...@@ -1522,10 +1522,15 @@ ...@@ -1522,10 +1522,15 @@
<string name="chino_machine">CHINO機器</string> <string name="chino_machine">CHINO機器</string>
<string name="spp_machine">シリアル通信機器</string> <string name="spp_machine">シリアル通信機器</string>
<string name="center_thermometer">中心温度計</string> <string name="center_thermometer">中心温度計</string>
<string name="pairing_save_machine">接続機器名</string>
<string name="connection_completed">接続しました。\n機器のボタンを押してください。</string>
<string name="pairing_other_machine_searching">その他の %s(検索中...)</string>
<string name="bluetooth_is_not_supported">Bluetooth機能が利用できない端末です。</string> <string name="bluetooth_is_not_supported">Bluetooth機能が利用できない端末です。</string>
<string name="msg_scan_bluetooth_no_allow">BlueToothの利用を「許可」しないと、%1$sのスキャンができません。</string> <string name="msg_scan_bluetooth_no_allow">BlueToothの利用を「許可」しないと、%1$sのスキャンができません。</string>
<string name="msg_location_device_no_allow">端末の設定から位置情報をONにしてください。</string> <string name="msg_location_device_no_allow">端末の設定から位置情報をONにしてください。</string>
<string name="alc_checker_setting">アルコールチェッカー設定</string> <string name="alc_checker_setting">アルコールチェッカー設定</string>
<string name="alcohl_checker">アルコールチェッカー</string> <string name="alcohl_checker">アルコールチェッカー</string>
<string name="ble_connecting">の電源を入れて、電源ボタンを押してください</string> <string name="msg_ble_connect_success">%1$sと接続になりました。%1$sを操作してください。</string>
<string name="ble_connecting">%1$sの電源を入れて、電源ボタンを押してください</string>
<string name="start_measurement">測定開始</string>
</resources> </resources>
...@@ -1527,14 +1527,17 @@ ...@@ -1527,14 +1527,17 @@
<string name="bluetooth_is_not_supported">Bluetooth is not supported.</string> <string name="bluetooth_is_not_supported">Bluetooth is not supported.</string>
<string name="msg_scan_bluetooth_no_allow">If Bluetooth is not allow, %1$s scan is disabled.</string> <string name="msg_scan_bluetooth_no_allow">If Bluetooth is not allow, %1$s scan is disabled.</string>
<string name="msg_location_device_no_allow">Please set the location information to ON in the device setting.</string> <string name="msg_location_device_no_allow">Please set the location information to ON in the device setting.</string>
<string name="pairing_save_machine">Saved %s</string> <string name="pairing_save_machine">接続機器名</string>
<string name="pairing_other_machine">Other %s</string> <string name="pairing_other_machine">Other %s</string>
<string name="pairing_other_machine_searching">Other %s(Searching...)</string> <string name="pairing_other_machine_searching">Other %s(Searching...)</string>
<string name="connection_completed">接続しました。\n機器のボタンを押してください。</string>
<string name="select_spp_device_title">シリアル通信機器選択</string> <string name="select_spp_device_title">シリアル通信機器選択</string>
<string name="alc_checker_setting">アルコールチェッカー設定</string> <string name="alc_checker_setting">アルコールチェッカー設定</string>
<string name="alcohl_checker">アルコールチェッカー</string> <string name="alcohl_checker">アルコールチェッカー</string>
<string name="pairing_other_alcohl_checker_searching">アルコールチェッカー(Searching...)</string> <string name="pairing_other_alcohl_checker_searching">アルコールチェッカー(Searching...)</string>
<string name="msg_pairing_device_no_info">登録されたアルコールチェッカー情報がありません。\n設定画面のアルコールチェッカー設定から登録できます。</string> <string name="msg_pairing_device_no_info">登録されたアルコールチェッカー情報がありません。\n設定画面のアルコールチェッカーHW設定から登録できます。</string>
<string name="msg_ble_connect_success">%1$sと接続になりました。%1$sを操作してください。</string> <string name="msg_ble_connect_success">%1$sと接続になりました。%1$sを操作してください。</string>
<string name="ble_connecting">Connection...</string> <string name="ble_connecting">%1$sの電源を入れて、電源ボタンを押してください。</string>
<string name="wait_breathe">息を吹きかけてください。</string>
<string name="start_measurement">測定開始</string>
</resources> </resources>
...@@ -28,9 +28,9 @@ public class AlcoholCheckerTimerTask extends TimerTask { ...@@ -28,9 +28,9 @@ public class AlcoholCheckerTimerTask extends TimerTask {
} }
@Override @Override
public void run() { public void run() {
Logger.i(TAG,"--------------------------------------------------------------"); //Logger.i(TAG,"--------------------------------------------------------------");
Logger.i(TAG,"AlcohlCheckerTimerTask"); Logger.i(TAG,"AlcohlCheckerTimerTask");
Logger.i(TAG,"--------------------------------------------------------------"); //Logger.i(TAG,"--------------------------------------------------------------");
alcoholCheckerUtil.gi_rxlength = 0; alcoholCheckerUtil.gi_rxlength = 0;
...@@ -66,9 +66,9 @@ public class AlcoholCheckerTimerTask extends TimerTask { ...@@ -66,9 +66,9 @@ public class AlcoholCheckerTimerTask extends TimerTask {
listener.onUpdateStatus("F_BLE_COM_RP_START"); listener.onUpdateStatus("F_BLE_COM_RP_START");
break; break;
default: default:
Logger.i(TAG,"--------------------------------------------------------------"); //Logger.i(TAG,"--------------------------------------------------------------");
Logger.i(TAG,"AlcohlCheckerTimerTask Timeout"); Logger.i(TAG,"AlcohlCheckerTimerTask Timeout");
Logger.i(TAG,"--------------------------------------------------------------"); //Logger.i(TAG,"--------------------------------------------------------------");
if (alcoholCheckerUtil.gi_rxretry_cnt < 100) { if (alcoholCheckerUtil.gi_rxretry_cnt < 100) {
alcoholCheckerUtil.gi_rxretry_cnt++; alcoholCheckerUtil.gi_rxretry_cnt++;
......
...@@ -16,6 +16,7 @@ import java.util.ArrayList; ...@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Timer; import java.util.Timer;
import java.util.UUID; import java.util.UUID;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
public class AlcoholCheckerUtil { public class AlcoholCheckerUtil {
...@@ -105,7 +106,6 @@ public class AlcoholCheckerUtil { ...@@ -105,7 +106,6 @@ public class AlcoholCheckerUtil {
public static final UUID TX_CHARACTERISTIC_UUID = UUID.fromString("442F1572-8A00-9A28-CBE1-E1D4212D53EB"); // Taiyo Yuden Tx Characteristic public static final UUID TX_CHARACTERISTIC_UUID = UUID.fromString("442F1572-8A00-9A28-CBE1-E1D4212D53EB"); // Taiyo Yuden Tx Characteristic
private final int MAX_MESSAGE_COUNT = 20; // Number of messages to show in UI private final int MAX_MESSAGE_COUNT = 20; // Number of messages to show in UI
// private String rxMessage;
public static final String ACTION_TX_FINISHED = "com.taiyoyuden.tyapp_terminal.ACTION_TX_FINISHED"; public static final String ACTION_TX_FINISHED = "com.taiyoyuden.tyapp_terminal.ACTION_TX_FINISHED";
public static final String ACTION_TX_ERROR = "com.taiyoyuden.tyapp_terminal.ACTION_TX_ERROR"; public static final String ACTION_TX_ERROR = "com.taiyoyuden.tyapp_terminal.ACTION_TX_ERROR";
...@@ -127,29 +127,36 @@ public class AlcoholCheckerUtil { ...@@ -127,29 +127,36 @@ public class AlcoholCheckerUtil {
private AlcoholCheckerUtilListener listener; private AlcoholCheckerUtilListener listener;
// @Timer // @Timer
private AlcoholCheckerTimerTask alcoholCheckerTimerTask = null; private AlcoholCheckerTimerTask alcoholCheckerTimerTask = null;
public boolean isConnected = false;
public AlcoholCheckerUtil(Context context, AlcoholCheckerUtilListener listener) { public AlcoholCheckerUtil(Context context, AlcoholCheckerUtilListener listener) {
this.context = context; this.context = context;
this.listener = listener; this.listener = listener;
} }
// public void initAlcoholChecker() {
// stopAlcTimer();
// disconnect(true);
// }
public void finish() {
stopAlcTimer();
//disconnect(true);
//listener = null;
}
// Bluetoothアダプタの取得処理 // Bluetoothアダプタの取得処理
public boolean startGetDeviceInfo() { public boolean startGetDeviceInfo() {
// BLE管理 // BLE管理
bleManagerUtil = new BleManagerUtil(context, new BleManagerUtilListener() { bleManagerUtil = new BleManagerUtil(context, new BleManagerUtilListener() {
// @Override
// public void onGetDeviceInfo(String strTemperature) {
// Logger.i(TAG,"------------------------------------");
// Logger.i(TAG,"onGetDeviceInfo = %s", strTemperature);
// Logger.i(TAG,"------------------------------------");
// }
@Override @Override
public void onGetDeviceInfoFailed(int status) { public void onGetDeviceInfoFailed(int status) {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onGetDeviceInfoFailed = %s", status); Logger.i(TAG,"onGetDeviceInfoFailed = %s", status);
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
listener.onGetDeviceInfoFailed(status);
} }
@Override @Override
...@@ -159,28 +166,23 @@ public class AlcoholCheckerUtil { ...@@ -159,28 +166,23 @@ public class AlcoholCheckerUtil {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
if (status == BluetoothProfile.STATE_CONNECTED) { if (status == BluetoothProfile.STATE_CONNECTED) {
// Alert application that we have connected to a device // *2
// Begin service discovery on device
Log.i(TAG, "Connected to GATT server."); Log.i(TAG, "Connected to GATT server.");
listener.onFugoAction(ACTION_GATT_CONNECTED, null, null, null, null); listener.onFugoAction(ACTION_GATT_CONNECTED, null, null, null, null);
//sendBroadcast(new Intent(ACTION_GATT_CONNECTED));
// mBluetoothGatt.discoverServices(); // @@@@@
// @@@@@ // @@@@@
if (bleManagerUtil.mBluetoothGatt.discoverServices()) { if (bleManagerUtil.mBluetoothGatt.discoverServices()) {
Logger.i(TAG, "Started discovering services"); // *3 Logger.i(TAG, "Started discovering services");
} else { } else {
Logger.i(TAG, "Failed to start discovering services"); Logger.i(TAG, "Failed to start discovering services");
} }
// @@@@@
} else if (status == BluetoothProfile.STATE_DISCONNECTED) { } else if (status == BluetoothProfile.STATE_DISCONNECTED) {
// Alert application that we disconnected from a device
if (bleManagerUtil.mBluetoothGatt == null) { if (bleManagerUtil.mBluetoothGatt == null) {
return; return;
} else { } else {
Logger.i(TAG, "Disconnected from GATT server."); Logger.i(TAG, "Disconnected from GATT server.");
listener.onFugoAction(ACTION_GATT_DISCONNECTED, null, null, null, null); listener.onFugoAction(ACTION_GATT_DISCONNECTED, null, null, null, null);
//bmBluetoothGatt.close();
//mBluetoothGatt=null;
bleManagerUtil.disconnect(true); bleManagerUtil.disconnect(true);
} }
} else { } else {
...@@ -193,6 +195,8 @@ public class AlcoholCheckerUtil { ...@@ -193,6 +195,8 @@ public class AlcoholCheckerUtil {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onDisConnectionState"); Logger.i(TAG,"onDisConnectionState");
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
isConnected = false;
listener.onConnectionError(0);
} }
@Override @Override
...@@ -200,6 +204,8 @@ public class AlcoholCheckerUtil { ...@@ -200,6 +204,8 @@ public class AlcoholCheckerUtil {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onConnectionError = %s", status); Logger.i(TAG,"onConnectionError = %s", status);
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
isConnected = false;
listener.onConnectionError(status);
} }
@Override @Override
...@@ -249,7 +255,7 @@ public class AlcoholCheckerUtil { ...@@ -249,7 +255,7 @@ public class AlcoholCheckerUtil {
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
timerStart(); startAlcTimer();
} }
}); });
thread.start(); thread.start();
...@@ -273,18 +279,7 @@ public class AlcoholCheckerUtil { ...@@ -273,18 +279,7 @@ public class AlcoholCheckerUtil {
rxStr += rx1 + " ,"; rxStr += rx1 + " ,";
} }
} }
final String printText = rxStr;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
sub_rx_chk(rx); sub_rx_chk(rx);
//printMessageToScreen(new String(rx));
} }
}); });
...@@ -292,7 +287,6 @@ public class AlcoholCheckerUtil { ...@@ -292,7 +287,6 @@ public class AlcoholCheckerUtil {
if (!bleManagerUtil.startDeviceInfo()) { if (!bleManagerUtil.startDeviceInfo()) {
return false; return false;
} }
//timerStart();
return true; return true;
} }
...@@ -300,7 +294,7 @@ public class AlcoholCheckerUtil { ...@@ -300,7 +294,7 @@ public class AlcoholCheckerUtil {
/** /**
* アルコールチェッカーを監視するタイマーを開始する * アルコールチェッカーを監視するタイマーを開始する
*/ */
private void timerStart() { private void startAlcTimer() {
if (alcoholCheckerTimerTask != null) { if (alcoholCheckerTimerTask != null) {
alcoholCheckerTimerTask.cancel(); alcoholCheckerTimerTask.cancel();
alcoholCheckerTimerTask = null; alcoholCheckerTimerTask = null;
...@@ -310,6 +304,17 @@ public class AlcoholCheckerUtil { ...@@ -310,6 +304,17 @@ public class AlcoholCheckerUtil {
timer.schedule(alcoholCheckerTimerTask, 0, 1000); timer.schedule(alcoholCheckerTimerTask, 0, 1000);
} }
/**
* タイマー停止
*/
public void stopAlcTimer() {
if (alcoholCheckerTimerTask != null) {
alcoholCheckerTimerTask.cancel();
alcoholCheckerTimerTask = null;
}
}
private void init() { private void init() {
//rxMessage = ""; //rxMessage = "";
...@@ -327,11 +332,9 @@ public class AlcoholCheckerUtil { ...@@ -327,11 +332,9 @@ public class AlcoholCheckerUtil {
// 切断 // 切断
public void disconnect(boolean listenerFlg) { public void disconnect(boolean listenerFlg) {
stopAlcTimer();
isConnected = false;
bleManagerUtil.disconnect(listenerFlg); bleManagerUtil.disconnect(listenerFlg);
if (alcoholCheckerTimerTask != null) {
alcoholCheckerTimerTask.cancel();
alcoholCheckerTimerTask = null;
}
} }
...@@ -363,16 +366,12 @@ public class AlcoholCheckerUtil { ...@@ -363,16 +366,12 @@ public class AlcoholCheckerUtil {
String error_msg = ""; String error_msg = "";
try { try {
// Convert our message to byte array in selected format // Convert our message to byte array in selected format
byte[] bMessage = message.getBytes("UTF-8"); byte[] bMessage = message.getBytes("UTF-8");
bMessage = hex2string(bMessage); // Requires NumberFormatException bMessage = hex2string(bMessage); // Requires NumberFormatException
if (bMessage == null) { if (bMessage == null) {
// Invalid message // Invalid message
Toast.makeText(context, "Invalid characters", Toast.LENGTH_SHORT).show(); //Toast.makeText(context, "Invalid characters", Toast.LENGTH_SHORT).show();
throw new NumberFormatException(); throw new NumberFormatException();
} }
...@@ -400,8 +399,7 @@ public class AlcoholCheckerUtil { ...@@ -400,8 +399,7 @@ public class AlcoholCheckerUtil {
Thread.sleep(10); // Requires InterruptedException Thread.sleep(10); // Requires InterruptedException
} }
Logger.d(TAG,"Tx:" + message);
//System.out.println("Tx: " + message);
// @Mode Change // @Mode Change
switch (gi_status) { switch (gi_status) {
...@@ -419,9 +417,9 @@ public class AlcoholCheckerUtil { ...@@ -419,9 +417,9 @@ public class AlcoholCheckerUtil {
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
System.out.println("Unsupported encoding exception"); Logger.w(TAG,e);
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println("Interrupted exception"); Logger.w(TAG,e);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
error_msg = "Invalid message format"; error_msg = "Invalid message format";
} catch (Exception e) { } catch (Exception e) {
...@@ -430,12 +428,9 @@ public class AlcoholCheckerUtil { ...@@ -430,12 +428,9 @@ public class AlcoholCheckerUtil {
//Intent intent; //Intent intent;
if (!error_msg.equals("")) { if (!error_msg.equals("")) {
//intent = new Intent(ACTION_TX_ERROR);
//intent.putExtra("MESSAGE", error_msg);
listener.onFugoAction(ACTION_TX_ERROR, null, null, error_msg, null); listener.onFugoAction(ACTION_TX_ERROR, null, null, error_msg, null);
} else { } else {
//intent = new Intent(ACTION_TX_FINISHED);
//intent.putExtra("MESSAGE", message);
listener.onFugoAction(ACTION_TX_FINISHED, null, null, message, null); listener.onFugoAction(ACTION_TX_FINISHED, null, null, message, null);
} }
} }
...@@ -519,10 +514,8 @@ public class AlcoholCheckerUtil { ...@@ -519,10 +514,8 @@ public class AlcoholCheckerUtil {
try { try {
// Append to current stream output // Append to current stream output
sub_rx_data_gen(rxdata); sub_rx_data_gen(rxdata);
// Mode // Mode
switch (gi_status) { switch (gi_status) {
case F_BLE_COM_INIT: case F_BLE_COM_INIT:
...@@ -541,33 +534,9 @@ public class AlcoholCheckerUtil { ...@@ -541,33 +534,9 @@ public class AlcoholCheckerUtil {
gi_status = F_BLE_COM_RP_START; gi_status = F_BLE_COM_RP_START;
break; break;
} }
// System.out.println("after status");
switch (gi_status) {
case F_BLE_COM_INIT:
// System.out.println("F_BLE_COM_INIT");
listener.onUpdateStatus("F_BLE_COM_INIT");
break;
case F_BLE_COM_RP_WAIT:
// System.out.println("F_BLE_COM_RP_WAIT");
listener.onUpdateStatus("F_BLE_COM_RP_WAIT");
break;
case F_BLE_COM_RD_WAIT:
// System.out.println("F_BLE_COM_RD_WAIT");
listener.onUpdateStatus("F_BLE_COM_RD_WAIT");
break;
default:
// System.out.println("F_BLE_COM_RP_START");
listener.onUpdateStatus("F_BLE_COM_RP_START");
break;
}
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
// This is a new message Logger.e(TAG,e);
// messageLog.add(message);
} }
//messageAdapter.notifyDataSetChanged();
} }
/* @Read Flame Generation */ /* @Read Flame Generation */
...@@ -607,32 +576,28 @@ public class AlcoholCheckerUtil { ...@@ -607,32 +576,28 @@ public class AlcoholCheckerUtil {
case (byte) 0x07: case (byte) 0x07:
// Rest 3 // Rest 3
listener.onUpdateTBVCalc("3"); listener.onUpdateTBVCalc("3");
//((TextView) findViewById(R.id.TBV_Calc)).setText("3"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x08: case (byte) 0x08:
// Rest 2 // Rest 2
// ((TextView)findViewById(R.id.TBV_Calc)).setText("2"); // @
listener.onUpdateTBVCalc("2"); listener.onUpdateTBVCalc("2");
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x09: case (byte) 0x09:
// Rest 1 // Rest 1
listener.onUpdateTBVCalc("1"); listener.onUpdateTBVCalc("1");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("1"); // @
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
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Go"); // @
gf_result_flg = false; gf_result_flg = false;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
listener.onStartMeasurement();
break; break;
case (byte) 0x0B: case (byte) 0x0B:
// Blow After // Blow After
listener.onUpdateTBVCalc("Blow..."); listener.onUpdateTBVCalc("Blow...");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Blow..."); // @
gf_result_flg = false; gf_result_flg = false;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
...@@ -648,13 +613,11 @@ public class AlcoholCheckerUtil { ...@@ -648,13 +613,11 @@ public class AlcoholCheckerUtil {
case (byte) 0x0D: case (byte) 0x0D:
// Wait // Wait
listener.onUpdateTBVCalc("Wait"); listener.onUpdateTBVCalc("Wait");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Wait"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x0E: case (byte) 0x0E:
// Ready // Ready
listener.onUpdateTBVCalc("Ready? 測定開始待ち状態 0x0E"); listener.onUpdateTBVCalc("Ready? 測定開始待ち状態 0x0E");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Ready?"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x11: case (byte) 0x11:
...@@ -664,44 +627,39 @@ public class AlcoholCheckerUtil { ...@@ -664,44 +627,39 @@ public class AlcoholCheckerUtil {
} else { } else {
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} }
listener.onUpdateTBVCalc("エラー 0x11"); // "エラー 0x11"
listener.onMeasurementError("エラー 0x11");
break; break;
case (byte) 0x12: case (byte) 0x12:
// Failed // Failed
listener.onUpdateTBVCalc("BreakDown"); listener.onBreakDownError("BreakDown");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Break Down"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x14: case (byte) 0x14:
listener.onUpdateTBVCalc("Low Battery"); listener.onLowBatteryError("Low Battery");
// Low Battery // Low Battery
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Low Battery"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x15: case (byte) 0x15:
// Calc // Calc
listener.onUpdateTBVCalc("Calculationg"); listener.onUpdateTBVCalc("Calculationg");
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Calculating"); // @
gf_result_flg = false; gf_result_flg = false;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x1F: case (byte) 0x1F:
listener.onUpdateTBVCalc("Over Used"); listener.onOverUsedError("Over Used");
// Excess usage count // Excess usage count
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Over Used"); // @
gf_result_flg = false; gf_result_flg = false;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x20: case (byte) 0x20:
listener.onUpdateTBVCalc("OFF"); listener.onPowerOff("OFF");
// Power Down // Power Down
// ((TextView)findViewById(R.id.TBV_Calc)).setText("OFF"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
case (byte) 0x21: case (byte) 0x21:
listener.onUpdateTBVCalc("Data"); listener.onUpdateTBVCalc("Data");
// Result Data Screen // Result Data Screen
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Data"); // @
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
break; break;
default: default:
...@@ -710,7 +668,7 @@ public class AlcoholCheckerUtil { ...@@ -710,7 +668,7 @@ public class AlcoholCheckerUtil {
break; break;
} }
} else { } else {
System.out.println("RP Error"); Logger.e(TAG,"RP Error");
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} }
} else { } else {
...@@ -718,7 +676,7 @@ public class AlcoholCheckerUtil { ...@@ -718,7 +676,7 @@ public class AlcoholCheckerUtil {
/* Receiving */ /* Receiving */
si_ret = F_BLE_COM_RP_WAIT; si_ret = F_BLE_COM_RP_WAIT;
} else { } else {
System.out.println("RP Length Error"); Logger.e(TAG,"RP Length Error");
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} }
} }
...@@ -767,21 +725,19 @@ public class AlcoholCheckerUtil { ...@@ -767,21 +725,19 @@ public class AlcoholCheckerUtil {
str_msg += String.format("%1$02d", ss_data); str_msg += String.format("%1$02d", ss_data);
} }
str_msg += "[mg/L]"; //str_msg += "[mg/L]";
//((TextView)findViewById(R.id.TBV_Calc)).setText(str_msg); // @
//listener.onUpdateTBVCalc(str_msg + " 0x0C 測定結果表示状態"); //listener.onUpdateTBVCalc(str_msg + " 0x0C 測定結果表示状態");
listener.onGetDeviceInfo(str_msg); listener.onGetDeviceInfo(str_msg);
} else { } else {
// Error // Error
//((TextView)findViewById(R.id.TBV_Calc)).setText("Error"); // @ //listener.onError("Error");
listener.onUpdateTBVCalc("Error");
} }
gf_result_flg = true; gf_result_flg = true;
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} else { } else {
System.out.println("RD Error"); Logger.e(TAG,"RD Error");
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} }
} else { } else {
...@@ -789,7 +745,7 @@ public class AlcoholCheckerUtil { ...@@ -789,7 +745,7 @@ public class AlcoholCheckerUtil {
/* Receiving */ /* Receiving */
si_ret = F_BLE_COM_RD_WAIT; si_ret = F_BLE_COM_RD_WAIT;
} else { } else {
System.out.println("RD Length Error"); Logger.e(TAG,"RD Length Error");
si_ret = F_BLE_COM_RP_START; si_ret = F_BLE_COM_RP_START;
} }
} }
......
...@@ -7,6 +7,18 @@ import java.util.UUID; ...@@ -7,6 +7,18 @@ import java.util.UUID;
public interface AlcoholCheckerUtilListener { public interface AlcoholCheckerUtilListener {
void onFugoAction(String action, UUID CHAR, byte[] data, String MESSAGE, String Type); void onFugoAction(String action, UUID CHAR, byte[] data, String MESSAGE, String Type);
void onGetDeviceInfoFailed(int status);
void onConnectionError(int status); // ディバイス接続エラー
void onMeasurementError(String txt); // 吹付エラー
void onBreakDownError(String txt); // 機器の故障
void onLowBatteryError(String txt); // バッテリー不足
void onOverUsedError(String txt); // 使用回数超過
void onPowerOff(String txt); // 機器の電源がOFF
void onError(String txt); // 機器のエラー
void onStartMeasurement();
void onUpdateTBVCalc(String text); void onUpdateTBVCalc(String text);
void onUpdateStatus(String text); void onUpdateStatus(String text);
void onUpdateSendMessage(String text); void onUpdateSendMessage(String text);
......
...@@ -78,6 +78,7 @@ public class BleManagerUtil { ...@@ -78,6 +78,7 @@ public class BleManagerUtil {
@Override @Override
public void run() { public void run() {
mListener.onConnectionError(status); mListener.onConnectionError(status);
disconnect(true);
} }
}); });
return; return;
...@@ -94,7 +95,7 @@ public class BleManagerUtil { ...@@ -94,7 +95,7 @@ public class BleManagerUtil {
@Override @Override
public void run() { public void run() {
mListener.onGetDeviceInfoFailed(status); mListener.onGetDeviceInfoFailed(status);
Logger.e("onConnectionStateChange2 status = " + status); Logger.e("onConnectionStateChange status = " + status);
} }
}); });
} }
...@@ -134,20 +135,20 @@ public class BleManagerUtil { ...@@ -134,20 +135,20 @@ public class BleManagerUtil {
} }
// 発見されたサービスのループ // 発見されたサービスのループ
for(BluetoothGattService service : gatt.getServices()) { // for(BluetoothGattService service : gatt.getServices()) {
// サービスごとに個別の処理 // // サービスごとに個別の処理
if((service == null) || (service.getUuid() == null)) { // if((service == null) || (service.getUuid() == null)) {
continue; // continue;
} // }
//
// GATTサービスのキャラクタリスティックを列挙 // // GATTサービスのキャラクタリスティックを列挙
List<BluetoothGattCharacteristic> listCharacteristic = service.getCharacteristics(); // List<BluetoothGattCharacteristic> listCharacteristic = service.getCharacteristics();
for (BluetoothGattCharacteristic characteristic : listCharacteristic) { // for (BluetoothGattCharacteristic characteristic : listCharacteristic) {
// 利用したいものがあるはず! // // 利用したいものがあるはず!
Logger.d(TAG, "characteristic : [ " + characteristic ); // //Logger.d(TAG, "characteristic : [ " + characteristic );
} // }
//
// プライベートサービス // // プライベートサービス
// if(UUID_SERVICE_PRIVATE.equals(service.getUuid())) { // if(UUID_SERVICE_PRIVATE.equals(service.getUuid())) {
// // 最初の読み取り // // 最初の読み取り
// readCharacteristic(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE); // readCharacteristic(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE);
...@@ -161,16 +162,16 @@ public class BleManagerUtil { ...@@ -161,16 +162,16 @@ public class BleManagerUtil {
// }); // });
// continue; // continue;
// } // }
} // }
} }
// キャラクタリスティックが読み込まれたときの処理 // キャラクタリスティックが読み込まれたときの処理
// @Override @Override
// public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) { public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) {
// Logger.i(TAG,"onCharacteristicChanged"); Logger.i(TAG,"onCharacteristicChanged");
// if( BluetoothGatt.GATT_SUCCESS != status ) { if( BluetoothGatt.GATT_SUCCESS != status ) {
// return; return;
// } }
// if( UUID_CHARACTERISTIC_PRIVATE.equals(characteristic.getUuid())) { // if( UUID_CHARACTERISTIC_PRIVATE.equals(characteristic.getUuid())) {
// final String strTemperature = byteToString(characteristic.getValue()); // final String strTemperature = byteToString(characteristic.getValue());
// runOnUiThread( new Runnable() { // runOnUiThread( new Runnable() {
...@@ -185,12 +186,12 @@ public class BleManagerUtil { ...@@ -185,12 +186,12 @@ public class BleManagerUtil {
// setCharacteristicNotification(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE, true); // setCharacteristicNotification(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE, true);
// return; // return;
// } // }
// } }
// キャラクタリスティック変更が通知されたときの処理 // キャラクタリスティック変更が通知されたときの処理
@Override @Override
public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) { public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic ) {
Logger.i(TAG,"------------------------------------------------------ onCharacteristicChanged"); Logger.i(TAG,"onCharacteristicChanged");
if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) { if (mBleConnectDeviceType == Constant.DeviceType.alcoholChecker) {
mListener.onCharacteristicChanged(gatt, characteristic); mListener.onCharacteristicChanged(gatt, characteristic);
return; return;
...@@ -282,7 +283,7 @@ public class BleManagerUtil { ...@@ -282,7 +283,7 @@ public class BleManagerUtil {
mDeviceAddress = deviceAddress; mDeviceAddress = deviceAddress;
// デバイスタイプセット // デバイスタイプセット
mBleConnectDeviceType = connectTargetDeviceType; mBleConnectDeviceType = connectTargetDeviceType;
setUUID(); //setUUID();
if(StringUtil.isNullOrEmpty(mDeviceAddress)) { // DeviceAddressが空の場合は処理しない if(StringUtil.isNullOrEmpty(mDeviceAddress)) { // DeviceAddressが空の場合は処理しない
return; return;
} }
...@@ -339,18 +340,17 @@ public class BleManagerUtil { ...@@ -339,18 +340,17 @@ public class BleManagerUtil {
// ②「接続可能範囲から外れた切断」は、内部処理でmBluetoothGatt.disconnect()処理が実施される。 // ②「接続可能範囲から外れた切断」は、内部処理でmBluetoothGatt.disconnect()処理が実施される。
// 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。 // 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。
mBluetoothGatt.disconnect(); mBluetoothGatt.disconnect();
// mBluetoothGatt.close();
mBluetoothGatt = null; mBluetoothGatt = null;
if (listenerFlg) { // if (listenerFlg) {
runOnUiThread( new Runnable() { // runOnUiThread( new Runnable() {
@Override // @Override
public void run() { // public void run() {
// 切断トーストメッセージを表示する。 // // 切断トーストメッセージを表示する。
mListener.onDisConnectionState(); // mListener.onDisConnectionState();
} // }
}); // });
} // }
} }
// キャラクタリスティックの読み込み // キャラクタリスティックの読み込み
......
...@@ -194,15 +194,16 @@ public class ABVUIDataCache { ...@@ -194,15 +194,16 @@ public class ABVUIDataCache {
BluetoothPairingDeviceInfoDto dto = new BluetoothPairingDeviceInfoDto(); BluetoothPairingDeviceInfoDto dto = new BluetoothPairingDeviceInfoDto();
String deviceName = null; String deviceName = null;
String deviceAddress = null; String deviceAddress = null;
if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) { // if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) {
// 中心温度計 // // 中心温度計
deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, ""); // deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, "");
deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, ""); // deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, "");
} else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) { // } else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) {
// 放射温度計 // // 放射温度計
deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, ""); // deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, "");
deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, ""); // deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, "");
} else if (bluetoothDeviceType == Constant.DeviceType.alcoholChecker) { // } else
if (bluetoothDeviceType == Constant.DeviceType.alcoholChecker) {
// アルコールチェッカー // アルコールチェッカー
deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME, ""); deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME, "");
deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS, ""); deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS, "");
...@@ -226,11 +227,12 @@ public class ABVUIDataCache { ...@@ -226,11 +227,12 @@ public class ABVUIDataCache {
*/ */
public String getPairingBluetoothDeviceAddress(int bluetoothDeviceType) { public String getPairingBluetoothDeviceAddress(int bluetoothDeviceType) {
String deviceAddressKey = null; String deviceAddressKey = null;
if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) { // if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) {
deviceAddressKey = UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS; // deviceAddressKey = UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS;
} else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) { // } else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) {
deviceAddressKey = UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS; // deviceAddressKey = UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS;
} else if (bluetoothDeviceType == Constant.DeviceType.alcoholChecker) { // } else
if (bluetoothDeviceType == Constant.DeviceType.alcoholChecker) {
deviceAddressKey = UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS; deviceAddressKey = UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS;
} }
if (deviceAddressKey == null) { if (deviceAddressKey == null) {
...@@ -266,15 +268,16 @@ public class ABVUIDataCache { ...@@ -266,15 +268,16 @@ public class ABVUIDataCache {
* @param pairingDeviceInfoDto * @param pairingDeviceInfoDto
*/ */
public void setPairingBluetoothDeviceInfo(BluetoothPairingDeviceInfoDto pairingDeviceInfoDto) { public void setPairingBluetoothDeviceInfo(BluetoothPairingDeviceInfoDto pairingDeviceInfoDto) {
if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.centerThermomete)) { // if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.centerThermomete)) {
// 中心温度計 // // 中心温度計
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName); // PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName);
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress); // PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress);
} else if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.radiationThermomete)) { // } else if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.radiationThermomete)) {
// 放射温度計 // // 放射温度計
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName); // PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName);
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress); // PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress);
} else if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.alcoholChecker)) { // } else
if (pairingDeviceInfoDto.deviceType.equals(Constant.DeviceType.alcoholChecker)) {
// アルコールチェッカー // アルコールチェッカー
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME, pairingDeviceInfoDto.deviceName); PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME, pairingDeviceInfoDto.deviceName);
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS, pairingDeviceInfoDto.deviceAddress); PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS, pairingDeviceInfoDto.deviceAddress);
...@@ -287,15 +290,16 @@ public class ABVUIDataCache { ...@@ -287,15 +290,16 @@ public class ABVUIDataCache {
* @param deviceType * @param deviceType
*/ */
public void removePairingBluetoothDeviceInfo(int deviceType) { public void removePairingBluetoothDeviceInfo(int deviceType) {
if (deviceType == Constant.DeviceType.centerThermomete) { // if (deviceType == Constant.DeviceType.centerThermomete) {
// 中心温度計 // // 中心温度計
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME); // PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME);
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS); // PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS);
} else if (deviceType == Constant.DeviceType.radiationThermomete) { // } else if (deviceType == Constant.DeviceType.radiationThermomete) {
// 放射温度計 // // 放射温度計
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME); // PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME);
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS); // PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS);
} else if (deviceType == Constant.DeviceType.alcoholChecker) { // } else
if (deviceType == Constant.DeviceType.alcoholChecker) {
// 放射温度計 // 放射温度計
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME); PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_NAME);
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS); PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_ALCOHO_CHECKER_ADDRESS);
......
package jp.agentec.abook.abv.ui.common.activity; package jp.agentec.abook.abv.ui.common.activity;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -21,7 +19,6 @@ import android.view.View; ...@@ -21,7 +19,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
...@@ -44,11 +41,9 @@ import java.util.HashMap; ...@@ -44,11 +41,9 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Timer;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.type.OperationType; import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback; import jp.agentec.abook.abv.bl.common.Callback;
...@@ -58,6 +53,7 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys; ...@@ -58,6 +53,7 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache; import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor; import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.MydataDto; import jp.agentec.abook.abv.bl.dto.MydataDto;
import jp.agentec.abook.abv.bl.dto.OperationDto; import jp.agentec.abook.abv.bl.dto.OperationDto;
...@@ -72,7 +68,6 @@ import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper; ...@@ -72,7 +68,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;
...@@ -103,7 +98,6 @@ import jp.agentec.adf.util.FileUtil; ...@@ -103,7 +98,6 @@ import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.common.Constant.ReportType.RoutineTask; import static jp.agentec.abook.abv.bl.common.Constant.ReportType.RoutineTask;
import static jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil.INDICATION_CHARACTERISTIC_UUID;
public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...@@ -181,18 +175,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -181,18 +175,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// アルコールチェッカー // アルコールチェッカー
private AlcoholCheckerUtil alcoholCheckerUtil; private AlcoholCheckerUtil alcoholCheckerUtil;
// Bluetoothの接続状態 // Bluetoothの接続状態
private boolean mIsConnection; //private boolean mIsConnection;
//待ち状態の時画面に表示するダイアログ //待ち状態の時画面に表示するダイアログ
protected ABookAlertDialog mWaitingDialog; protected ABookAlertDialog mWaitingDialog = null;
// 計測用ダイアログ // 計測用ダイアログ
private ABookAlertDialog mWaitMeasureDialog; private ABookAlertDialog mWaitMeasureDialog = null;
// 息を吹きかけてください // 息を吹きかけてください
private ABookAlertDialog mMeasureDialog; private ABookAlertDialog mMeasureDialog = null;
// デバイスタイプ 0 アルコールチェッカー // デバイスタイプ 0 アルコールチェッカー
private int mDeviceType; private int mDeviceType;
// 設問ID // 設問ID
private String mQid; private String mQid = "";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -243,6 +237,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -243,6 +237,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} }
} }
// アルコールチェッカースタート // アルコールチェッカースタート
alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() { alcoholCheckerUtil = new AlcoholCheckerUtil(this, new AlcoholCheckerUtilListener() {
...@@ -251,15 +246,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -251,15 +246,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onFugoAction = %s", action); Logger.i(TAG,"onFugoAction = %s", action);
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
if (action.equals(AlcoholCheckerUtil.ACTION_GATT_CONNECTED)) { if (action.equals(AlcoholCheckerUtil.ACTION_GATT_CONNECTED)) {
Logger.i(TAG,"ACTION_GATT_CONNECTED"); Logger.i(TAG,"ACTION_GATT_CONNECTED");
} else if (action.equals(AlcoholCheckerUtil.ACTION_GATT_DISCONNECTED)) { } else if (action.equals(AlcoholCheckerUtil.ACTION_GATT_DISCONNECTED)) {
Logger.i(TAG,"ACTION_GATT_DISCONNECTED"); Logger.i(TAG,"ACTION_GATT_DISCONNECTED");
errorAfterAbookCheckApi("");
} else if (action.equals(AlcoholCheckerUtil.ACTION_DATA_RECEIVED)) { } else if (action.equals(AlcoholCheckerUtil.ACTION_DATA_RECEIVED)) {
Logger.i(TAG,"ACTION_DATA_RECEIVED"); Logger.i(TAG,"ACTION_DATA_RECEIVED");
// if (messageAdapter.getCurrentDirection() != 'R'){
// messageAdapter.newMessage('R');
// }
byte[] rx = data; byte[] rx = data;
String rxStr = " "; String rxStr = " ";
...@@ -268,42 +262,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -268,42 +262,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
rxStr += rx1 + " ,"; rxStr += rx1 + " ,";
} }
} }
final String printText = rxStr;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
alcoholCheckerUtil.sub_rx_chk(rx); alcoholCheckerUtil.sub_rx_chk(rx);
//printMessageToScreen(new String(rx)); // } else if (action.equals(AlcoholCheckerUtil.ACTION_TX_FINISHED)) {
} else if (action.equals(AlcoholCheckerUtil.ACTION_TX_FINISHED)) { // Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"------------------------------------"); // Logger.i(TAG,"ACTION_TX_FINISHED = %s", action);
Logger.i(TAG,"ACTION_TX_FINISHED = %s", action); // Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"------------------------------------"); // } else if (action.equals(AlcoholCheckerUtil.ACTION_TX_ERROR)) {
// Finished transmitting, display to screen and clear message // Logger.i(TAG,"------------------------------------");
// if (messageAdapter.getCurrentDirection() != 'T'){ // Logger.i(TAG,"ACTION_TX_ERROR", action);
// messageAdapter.newMessage('T'); // Logger.i(TAG,"------------------------------------");
// }
//printMessageToScreen(MESSAGE);
// ((EditText) findViewById(com.taiyoyuden.tyapp_terminal.R.id.txt_txmessage)).setText("");
} else if (action.equals(AlcoholCheckerUtil.ACTION_TX_ERROR)) {
Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"ACTION_TX_ERROR", action);
Logger.i(TAG,"------------------------------------");
// An error occurred during sending, display the message (don't clear text - allow user to edit)
// Toast.makeText(getApplicationContext(),intent.getStringExtra("MESSAGE"),Toast.LENGTH_SHORT).show();
} else if (action.equals(AlcoholCheckerUtil.ACTION_DESCRIPTOR_WROTE)) { } else if (action.equals(AlcoholCheckerUtil.ACTION_DESCRIPTOR_WROTE)) {
Logger.i(TAG, "------------------------------------"); Logger.i(TAG, "------------------------------------");
Logger.i(TAG, "ACTION_DESCRIPTOR_WROTE", action); Logger.i(TAG, "ACTION_DESCRIPTOR_WROTE", action);
Logger.i(TAG, "------------------------------------"); Logger.i(TAG, "------------------------------------");
if (alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.getService(AlcoholCheckerUtil.TY_SERVICE_UUID).getCharacteristic(AlcoholCheckerUtil.INDICATION_CHARACTERISTIC_UUID) == null) { if (alcoholCheckerUtil.bleManagerUtil.mBluetoothGatt.getService(AlcoholCheckerUtil.TY_SERVICE_UUID).getCharacteristic(AlcoholCheckerUtil.INDICATION_CHARACTERISTIC_UUID) == null) {
Logger.i(TAG, "Old Version."); Logger.i(TAG, "Old Version.");
// This version doesn't support latest characteristics
return; return;
} }
if (Type.equals("Notification")) { if (Type.equals("Notification")) {
...@@ -327,8 +302,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -327,8 +302,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onUpdateTBVCalc = %s", text); Logger.i(TAG,"onUpdateTBVCalc = %s", text);
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND);
} }
@Override @Override
...@@ -357,40 +330,98 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -357,40 +330,98 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"onServicesDiscovered = %s", status); Logger.i(TAG,"onServicesDiscovered = %s", status);
Logger.i(TAG,"------------------------------------"); Logger.i(TAG,"------------------------------------");
Logger.i(TAG,"ACTION_GATT_SERVICES"); alcoholCheckerUtil.isConnected = true;
mIsConnection = true;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
//mWaitingDialog.setMessage("接続しましたボタンをおしてください");
//Button btn = mWaitingDialog.getButton(DialogInterface.BUTTON_POSITIVE);
//btn.setText("うんこ");
if (mWaitingDialog != null) { if (mWaitingDialog != null) {
mWaitingDialog.dismiss(); mWaitingDialog.dismiss();
mWaitingDialog = null; mWaitingDialog = null;
} }
showWaitMeasureDialog("aaaaaa","aaaaaaaaaaaaaaaaaaaaaaaaaaa"); // 測定開始ボタン押し待ち
showWaitMeasureDialog(getString(R.string.alcohl_checker), getString(R.string.connection_completed));
} }
}); });
} }
@Override @Override
public void onGetDeviceInfo(String alcohol) { public void onGetDeviceInfo(String alcohol) {
/// 測定値 // 測定完了
if (mWaitingDialog != null) { successAfterAbookCheckApi(alcohol);
mWaitingDialog.dismiss(); //alcoholCheckerUtil.finish();
mWaitingDialog = null; }
}
if (mWaitMeasureDialog != null) { @Override
mWaitMeasureDialog.dismiss(); public void onStartMeasurement() {
mWaitMeasureDialog = null; if (mMeasureDialog != null) {
return;
} }
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mWaitMeasureDialog != null) {
mWaitMeasureDialog.dismiss();
mWaitMeasureDialog = null;
}
showMeasureDialog(getString(R.string.alcohl_checker), getString(R.string.wait_breathe));
}
});
}
@Override
public void onConnectionError(int status) {
errorAfterAbookCheckApi("");
//alcoholCheckerUtil.finish();
}
@Override
public void onMeasurementError(String text) {
if (mMeasureDialog != null) { if (mMeasureDialog != null) {
mMeasureDialog.dismiss(); runOnUiThread(new Runnable() {
mMeasureDialog = null; @Override
public void run() {
mMeasureDialog.setMessage("正しく呼気が吹き込まれませんでした。機器のボタンを押して再計測してください。");
}
});
} }
} }
@Override
public void onGetDeviceInfoFailed(int status) {
errorAfterAbookCheckApi("");
//alcoholCheckerUtil.finish();
}
@Override
public void onBreakDownError(String text) {
errorAfterAbookCheckApi("機器が故障している可能性があります。購入元へご連絡ください。");
//alcoholCheckerUtil.finish();
}
@Override
public void onLowBatteryError(String text) {
errorAfterAbookCheckApi("バッテリー不足です。機器の電池を交換してください。");
//alcoholCheckerUtil.finish();
}
@Override
public void onOverUsedError(String text) {
errorAfterAbookCheckApi("使用回数が上限を超えました。他の機器を使用してください。");
//alcoholCheckerUtil.finish();
}
@Override
public void onPowerOff(String text) {
errorAfterAbookCheckApi("機器の電源がOFFになりました。電源を入れて再接続してください。");
//alcoholCheckerUtil.finish();
}
@Override
public void onError(String txt) {
alcoholCheckerUtil.finish();
errorAfterAbookCheckApi("不明なエラーです");
}
}); });
...@@ -1117,40 +1148,52 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1117,40 +1148,52 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// showHelpViewDialog(helpViewType); // showHelpViewDialog(helpViewType);
// } // }
/** private void closeAllDialog() {
* 中心温度計の接続を切る runOnUiThread(new Runnable() {
* #39006 【@Form】(要望)中心温度計 放射温度計の連続計測対応 @Override
*/ public void run() {
protected void bleManagerDisconnect() { // 後始末
// onuma ここでは切らない if (mWaitingDialog != null) {
//bleManagerUtil.disconnect(true); mWaitingDialog.dismiss();
} mWaitingDialog = null;
}
// private void alcoholCheckerUtilbleManagerDisconnect(boolean disconnect) { if (mWaitMeasureDialog != null) {
// Logger.d(TAG,"-------------------------------------------------"); mWaitMeasureDialog.dismiss();
// Logger.d(TAG, "bleManagerDisconnect = " + disconnect); mWaitMeasureDialog = null;
// Logger.d(TAG,"-------------------------------------------------"); }
// if (disconnect){ if (mMeasureDialog !=null) {
// mIsConnection = false; mMeasureDialog.dismiss();
// alcoholCheckerUtil.disconnect(true); mMeasureDialog = null;
// } else { }
// // 何もしない }
// } });
// } }
/** /**
* 各デバイスから値を正常に取得された場合、HTML側にコールする * 各デバイスから値を正常に取得された場合、HTML側にコールする
* @param value 各種デバイスから取得した値 * @param value 各種デバイスから取得した値
*/ */
private void successAfterAbookCheckAip(String value) { private void successAfterAbookCheckApi(String value) {
closeAllDialog();
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());
isAlcLock = false;
} }
private int status = 0; /**
* 各デバイスからエラー(接続不能など)発生した場合、HTML側にコールする
* @param errorMessage 各種デバイスから取得した値
*/
private void errorAfterAbookCheckApi(String errorMessage) {
closeAllDialog();
afterABookCheckApi(mCmd, "", 1, errorMessage, null);
isAlcLock = false;
}
/** /**
* 接続待ち * 接続待ち
...@@ -1167,15 +1210,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1167,15 +1210,10 @@ 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 : " + mDeviceType); Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType);
if (mDeviceType == Constant.DeviceType.alcoholChecker) { //mWaitingDialog.dismiss();
Logger.i(TAG, "-------------------------------------------------");
Logger.i(TAG, "アルコールチェッカー接続待中止");
Logger.i(TAG, "-------------------------------------------------");
alcoholCheckerUtil.disconnect(true);
}
successAfterAbookCheckAip("");
mWaitingDialog.dismiss();
mWaitingDialog = null; mWaitingDialog = null;
//alcoholCheckerUtil.disconnect(true);
successAfterAbookCheckApi("");
} }
}); });
mWaitingDialog.show(); mWaitingDialog.show();
...@@ -1191,41 +1229,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1191,41 +1229,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.i(TAG,"showWaitMeasureDialog"); Logger.i(TAG,"showWaitMeasureDialog");
Logger.i(TAG,"-------------------------------------------------"); Logger.i(TAG,"-------------------------------------------------");
mWaitMeasureDialog = AlertDialogUtil.createAlertDialog(this, title); mWaitMeasureDialog = AlertDialogUtil.createAlertDialog(this, title);
mWaitMeasureDialog.setMessage("接続しました。ボタンをおしてください"); mWaitMeasureDialog.setMessage(getString(R.string.connection_completed));
mWaitMeasureDialog.setButton(DialogInterface.BUTTON_POSITIVE, "測定開始", new DialogInterface.OnClickListener() { mWaitMeasureDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting mWaitMeasureDialog stop click : " + mDeviceType); Logger.i(TAG, "waiting mWaitMeasureDialog stop click : " + mDeviceType);
runOnUiThread(new Runnable() { //mWaitMeasureDialog.dismiss();
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
//showMeasureDialog("banban","banban");
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND);
}
});
showMeasureDialog("banban","banban");
alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND);
mWaitMeasureDialog.dismiss();
mWaitMeasureDialog = null;
}
});
}
});
mWaitMeasureDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "キャンセル", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting mWaitMeasureDialog stop click : " + mDeviceType);
alcoholCheckerUtil.disconnect(true);
successAfterAbookCheckAip("");
mWaitMeasureDialog.dismiss();
mWaitMeasureDialog = null; mWaitMeasureDialog = null;
//alcoholCheckerUtil.disconnect(true);
errorAfterAbookCheckApi("");
} }
}); });
mWaitMeasureDialog.show(); mWaitMeasureDialog.show();
...@@ -1237,67 +1249,45 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1237,67 +1249,45 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param message 内容 * @param message 内容
*/ */
private void showMeasureDialog(String title, String message) { private void showMeasureDialog(String title, String message) {
Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG,"showMeasureDialog"); Logger.i(TAG,"showMeasureDialog");
Logger.i(TAG,"-------------------------------------------------");
mMeasureDialog = AlertDialogUtil.createAlertDialog(this, title); mMeasureDialog = AlertDialogUtil.createAlertDialog(this, title);
mMeasureDialog.setMessage("息を吹きかけてください"); mMeasureDialog.setMessage(message);
mMeasureDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "測定中止", new DialogInterface.OnClickListener() { mMeasureDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType); Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType);
if (mDeviceType == Constant.DeviceType.alcoholChecker) { //alcoholCheckerUtil.disconnect(true);
Logger.i(TAG, "-------------------------------------------------"); //mMeasureDialog.dismiss();
Logger.i(TAG, "測定中止");
Logger.i(TAG, "-------------------------------------------------");
}
alcoholCheckerUtil.disconnect(true);
successAfterAbookCheckAip("");
mMeasureDialog.dismiss();
mMeasureDialog = null; mMeasureDialog = null;
errorAfterAbookCheckApi("");
} }
}); });
// mMeasureDialog.setButton(DialogInterface.BUTTON_POSITIVE, "測定中止", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// Logger.i(TAG, "waiting Dialog stop click : " + mDeviceType);
// if (mDeviceType == Constant.DeviceType.alcoholChecker) {
//
// alcoholCheckerUtil.disconnect(true);
// }
// successAfterAbookCheckAip("");
// mMeasureDialog.dismiss();
// mMeasureDialog = null;
// }
// });
mMeasureDialog.show(); mMeasureDialog.show();
} }
/** /**
* 各デバイスからエラー(接続不能など)発生した場合、HTML側にコールする
* @param errorMessage 各種デバイスから取得した値
*/
private void errorAfterAbookCheckAip(String errorMessage) {
afterABookCheckApi(mCmd, "", 1, errorMessage, null);
}
/**
* アルコールチェッカー処理 * アルコールチェッカー処理
* @param abookCheckParam * @param abookCheckParam
*/ */
private void getDeviceInfo(Map<String, String> abookCheckParam) { private void getDeviceInfo(Map<String, String> abookCheckParam) {
Logger.d(TAG,"-------------------------------------------------"); Logger.i(TAG,"-------------------------------------------------");
Logger.d(TAG,"getDeviceInfo"); Logger.i(TAG,"getDeviceInfo");
Logger.d(TAG,"-------------------------------------------------"); Logger.i(TAG,"-------------------------------------------------");
mDeviceType = Constant.DeviceType.alcoholChecker; mDeviceType = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_DEVICE_TYPE));
mQid = "1"; mQid = abookCheckParam.get(ABookKeys.TASK_QUESTION_ID);
if (isAlcLock) {
return;
}
isAlcLock = true;
// アルコールチェッカー接続
connectToAlcholChecker(); connectToAlcholChecker();
} }
private boolean isAlcLock = false;
/** /**
* BLEディバイスのアルコールチェッカーの情報取得 * BLEディバイスのアルコールチェッカーの情報取得
*/ */
...@@ -1307,21 +1297,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1307,21 +1297,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
String deviceAddress = getABVUIDataCache().getPairingBluetoothDeviceAddress(Constant.DeviceType.alcoholChecker); String deviceAddress = getABVUIDataCache().getPairingBluetoothDeviceAddress(Constant.DeviceType.alcoholChecker);
if (StringUtil.isNullOrEmpty(deviceAddress)) { if (StringUtil.isNullOrEmpty(deviceAddress)) {
// 登録されているアルコールチェッカーが無い場合はエラー // 登録されているアルコールチェッカーが無い場合はエラー
errorAfterAbookCheckAip(getString(R.string.msg_pairing_device_no_info)); errorAfterAbookCheckApi(getString(R.string.msg_pairing_device_no_info));
return; return;
} }
if (mIsConnection) {
Logger.d(TAG,"-------------------------------------------------"); BluetoothPairingDeviceInfoDto dto = getABVUIDataCache().getPairingBluetoothDeviceInfo(Constant.DeviceType.alcoholChecker);
Logger.d(TAG, "isConnection = true");
Logger.d(TAG,"-------------------------------------------------"); if (alcoholCheckerUtil.isConnected) {
String message = String.format(getString(R.string.msg_ble_connect_success), getString(R.string.alcohl_checker)); Logger.i(TAG,"-------------------------------------------------");
Logger.i(TAG, "isConnection = true");
Logger.i(TAG,"-------------------------------------------------");
String message = String.format(getString(R.string.msg_ble_connect_success), dto.deviceName);
showWaitingDialog(getString(R.string.alcohl_checker),message); showWaitingDialog(getString(R.string.alcohl_checker),message);
} else { } else {
Logger.d(TAG,"-------------------------------------------------"); Logger.i(TAG,"-------------------------------------------------");
Logger.d(TAG, "isConnection = false"); Logger.i(TAG, "isConnection = false");
Logger.d(TAG,"-------------------------------------------------"); Logger.i(TAG,"-------------------------------------------------");
// 登録されているアルコールチェッカーがある // 登録されているアルコールチェッカーがある
showWaitingDialog(getString(R.string.alcohl_checker), getString(R.string.ble_connecting)); String message = String.format(getString(R.string.ble_connecting), dto.deviceName);
showWaitingDialog(getString(R.string.alcohl_checker), message);
// 接続 // 接続
alcoholCheckerUtil.connect(Constant.DeviceType.alcoholChecker, deviceAddress); alcoholCheckerUtil.connect(Constant.DeviceType.alcoholChecker, deviceAddress);
} }
...@@ -1624,12 +1618,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1624,12 +1618,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} }
} else if (mCmd.equals(ABookKeys.CMD_LOAD_USER_DATA)) { } else if (mCmd.equals(ABookKeys.CMD_LOAD_USER_DATA)) {
// 前回の入力内容を読み込む // 前回の入力内容を読み込む
Logger.i(TAG,"load taskKey = " + abookCheckParam.get(ABookKeys.TASK_KEY)); Logger.d(TAG,"load taskKey = " + abookCheckParam.get(ABookKeys.TASK_KEY));
loadUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY)); loadUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY));
} else if (mCmd.equals(ABookKeys.CMD_SAVE_USER_DATA)) { } else if (mCmd.equals(ABookKeys.CMD_SAVE_USER_DATA)) {
// 入力内容を保存する // 入力内容を保存する
Logger.i(TAG,"save taskKey = " + abookCheckParam.get(ABookKeys.TASK_KEY)); Logger.d(TAG,"save taskKey = " + abookCheckParam.get(ABookKeys.TASK_KEY));
Logger.i(TAG,"save userData = " + abookCheckParam.get(ABookKeys.USER_DATA)); Logger.d(TAG,"save userData = " + abookCheckParam.get(ABookKeys.USER_DATA));
saveUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY), abookCheckParam.get(ABookKeys.USER_DATA)); saveUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY), abookCheckParam.get(ABookKeys.USER_DATA));
} else if (mCmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) { } else if (mCmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
Logger.i(TAG,"getDeviceInfo"); Logger.i(TAG,"getDeviceInfo");
......
...@@ -35,6 +35,7 @@ import java.io.File; ...@@ -35,6 +35,7 @@ import java.io.File;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppLastVersionParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AppLastVersionParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis; import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.ServiceOptionId;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor; import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
...@@ -69,6 +70,7 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -69,6 +70,7 @@ public class ABookSettingFragment extends PreferenceFragment {
private static final String ACCOUNT_SET = "account_set"; private static final String ACCOUNT_SET = "account_set";
private static final String LOG_INFO = "log_info"; private static final String LOG_INFO = "log_info";
private static final String APP_INFO = "app_info"; private static final String APP_INFO = "app_info";
private static final String SET_PAIRING = "set_pairing";
// アカウント // アカウント
private static final String ACCOUNT_PATH = "accountPath"; private static final String ACCOUNT_PATH = "accountPath";
...@@ -88,8 +90,6 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -88,8 +90,6 @@ public class ABookSettingFragment extends PreferenceFragment {
private static final String PRIVACY_POLICY = "privacyPolicy"; private static final String PRIVACY_POLICY = "privacyPolicy";
// 機器連携(ペアリング) // 機器連携(ペアリング)
//private static final String SET_CHINO_PAIRING = "setChinoPairing"; // CHINO機器
//private static final String SET_SPP_PAIRING = "setSppPairing"; // SPP通信機器
private static final String SET_ALC_PAIRING = "setAlcPairing"; private static final String SET_ALC_PAIRING = "setAlcPairing";
protected Handler handler = new Handler(); protected Handler handler = new Handler();
...@@ -482,10 +482,15 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -482,10 +482,15 @@ public class ABookSettingFragment extends PreferenceFragment {
// 機器連携のペアリング設定 // 機器連携のペアリング設定
private void setPairingSetting() { private void setPairingSetting() {
// CHINO機器
PreferenceGroup chinoDevicePairing = (PreferenceGroup) findPreference(SET_ALC_PAIRING);
chinoDevicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() { PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_ALC_PAIRING);
if (!ABVDataCache.getInstance().serviceOption.isAlcoholCheckerHw()) {
// Preference alcoholChecker = (Preference) findPreference(SET_ALC_PAIRING);
// devicePairing.removePreference(alcoholChecker);
return;
}
//PreferenceUtil ppp = devicePairing.findPreference(SET_ALC_PAIRING);
devicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
try { try {
......
...@@ -44,8 +44,8 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -44,8 +44,8 @@ public class BlePairingSettingActivity extends ABVUIActivity {
private static final int REQUEST_ENABLEBLUETOOTH = 1; // Bluetooth機能の有効化要求時の識別コード private static final int REQUEST_ENABLEBLUETOOTH = 1; // Bluetooth機能の有効化要求時の識別コード
private static final long SCAN_PERIOD = 20000; // スキャン時間。単位はミリ秒。 private static final long SCAN_PERIOD = 20000; // スキャン時間。単位はミリ秒。
private static final String CENTER_THERMOMETE_DEVICE_NAME = "MF500"; // 中心温度計のデバイス名 //private static final String CENTER_THERMOMETE_DEVICE_NAME = "MF500"; // 中心温度計のデバイス名
private static final String RADIATION_THERMOMETE_DEVICE_NAME = "IR-TB"; // 放射温度計のデバイス名 //private static final String RADIATION_THERMOMETE_DEVICE_NAME = "IR-TB"; // 放射温度計のデバイス名
private static final String ALCOHOL_CHECKER_DEVICE_NAME = "FALC-31"; // アルコールチェッカーデバイス名 private static final String ALCOHOL_CHECKER_DEVICE_NAME = "FALC-31"; // アルコールチェッカーデバイス名
...@@ -73,10 +73,10 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -73,10 +73,10 @@ public class BlePairingSettingActivity extends ABVUIActivity {
Logger.d("mScanCallback device.getName() = " + device.getName()); Logger.d("mScanCallback device.getName() = " + device.getName());
} }
// 識別商品名に絞る ALC_DEVICE_NAME // 識別商品名に絞る ALC_DEVICE_NAME
if(device.getName() != null && (device.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME) // if(device.getName() != null && (device.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME)
|| device.getName().startsWith(RADIATION_THERMOMETE_DEVICE_NAME) // || device.getName().startsWith(RADIATION_THERMOMETE_DEVICE_NAME)
|| (device.getName().startsWith(ALCOHOL_CHECKER_DEVICE_NAME) ))) // || (device.getName().startsWith(ALCOHOL_CHECKER_DEVICE_NAME) )))
{ if(device.getName() != null && (device.getName().startsWith(ALCOHOL_CHECKER_DEVICE_NAME) )) {
if (!mSavedDeviceAddressList.contains(device.getAddress())) { //登録されたデバイスの場合、スキャン情報から除外する。 if (!mSavedDeviceAddressList.contains(device.getAddress())) { //登録されたデバイスの場合、スキャン情報から除外する。
boolean isAdd = true; boolean isAdd = true;
for (BluetoothDevice savedDevice : mScanDeviceInfoList) { for (BluetoothDevice savedDevice : mScanDeviceInfoList) {
...@@ -123,11 +123,12 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -123,11 +123,12 @@ public class BlePairingSettingActivity extends ABVUIActivity {
public void onDeleteConnectInfo(BleListRowData rowData) { // 登録されたデバイス情報削除 public void onDeleteConnectInfo(BleListRowData rowData) { // 登録されたデバイス情報削除
Logger.i(rowData.deviceAddress); Logger.i(rowData.deviceAddress);
Integer deviceType = null; Integer deviceType = null;
if (rowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) { // if (rowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
deviceType = DeviceType.centerThermomete; // deviceType = DeviceType.centerThermomete;
} else if (rowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) { // } else if (rowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
deviceType = DeviceType.radiationThermomete; // deviceType = DeviceType.radiationThermomete;
} else if (rowData.title.startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) { // } else
if (rowData.title.startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) {
deviceType = DeviceType.alcoholChecker; deviceType = DeviceType.alcoholChecker;
} }
...@@ -305,13 +306,14 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -305,13 +306,14 @@ public class BlePairingSettingActivity extends ABVUIActivity {
mSavedDeviceAddressList.add(bleListRowData.deviceAddress); mSavedDeviceAddressList.add(bleListRowData.deviceAddress);
BluetoothPairingDeviceInfoDto pairingDeviceInfo = new BluetoothPairingDeviceInfoDto(); BluetoothPairingDeviceInfoDto pairingDeviceInfo = new BluetoothPairingDeviceInfoDto();
if (bleListRowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) { // if (bleListRowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
// デバイス名がMF500から始まると中心温度計と見做す。 // // デバイス名がMF500から始まると中心温度計と見做す。
pairingDeviceInfo.deviceType = DeviceType.centerThermomete; // pairingDeviceInfo.deviceType = DeviceType.centerThermomete;
} else if (bleListRowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) { // } else if (bleListRowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
// デバイス名がIR-TBから始まると放射温度計と見做す。 // // デバイス名がIR-TBから始まると放射温度計と見做す。
pairingDeviceInfo.deviceType = DeviceType.radiationThermomete; // pairingDeviceInfo.deviceType = DeviceType.radiationThermomete;
} else if (bleListRowData.title.startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) { // } else
if (bleListRowData.title.startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) {
// デバイス名がMF500から始まるとアルコールチェッカーとみなす // デバイス名がMF500から始まるとアルコールチェッカーとみなす
pairingDeviceInfo.deviceType = DeviceType.alcoholChecker; pairingDeviceInfo.deviceType = DeviceType.alcoholChecker;
} }
...@@ -350,15 +352,16 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -350,15 +352,16 @@ public class BlePairingSettingActivity extends ABVUIActivity {
List<SectionHeaderData> sectionList = new ArrayList<>(); List<SectionHeaderData> sectionList = new ArrayList<>();
List<BluetoothPairingDeviceInfoDto> bluetoothPairingInfoDtoList = List<BluetoothPairingDeviceInfoDto> bluetoothPairingInfoDtoList =
getABVUIDataCache().getPairingBluetoothDeviceInfoList(Arrays.asList(DeviceType.centerThermomete, DeviceType.radiationThermomete, DeviceType.alcoholChecker)); getABVUIDataCache().getPairingBluetoothDeviceInfoList(Arrays.asList(DeviceType.alcoholChecker));
if (CollectionUtil.isNotEmpty(bluetoothPairingInfoDtoList)) { if (CollectionUtil.isNotEmpty(bluetoothPairingInfoDtoList)) {
for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) { for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) {
// ペアリング情報が既に保存されてる場合はヘッダー情報を各機器毎に追加する // ペアリング情報が既に保存されてる場合はヘッダー情報を各機器毎に追加する
if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.centerThermomete)) { // if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.centerThermomete)) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.center_thermometer)))); // sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.center_thermometer))));
} else if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.radiationThermomete)) { // } else if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.radiationThermomete)) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.radiation_thermometer)))); // sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.radiation_thermometer))));
} else if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.alcoholChecker)) { // } else
if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.alcoholChecker)) {
sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.alcohl_checker)))); sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.alcohl_checker))));
} }
} }
...@@ -380,7 +383,7 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -380,7 +383,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
List<List<BleListRowData>> rowList = new ArrayList<List<BleListRowData>>(); List<List<BleListRowData>> rowList = new ArrayList<List<BleListRowData>>();
// 引数で指定したタイプリストのペアリング情報を取得 // 引数で指定したタイプリストのペアリング情報を取得
List<BluetoothPairingDeviceInfoDto> bluetoothPairingInfoDtoList = List<BluetoothPairingDeviceInfoDto> bluetoothPairingInfoDtoList =
getABVUIDataCache().getPairingBluetoothDeviceInfoList(Arrays.asList(DeviceType.centerThermomete, DeviceType.radiationThermomete, DeviceType.alcoholChecker)); getABVUIDataCache().getPairingBluetoothDeviceInfoList(Arrays.asList(DeviceType.alcoholChecker));
if (CollectionUtil.isNotEmpty(bluetoothPairingInfoDtoList)) { if (CollectionUtil.isNotEmpty(bluetoothPairingInfoDtoList)) {
for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) { for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) {
...@@ -405,11 +408,12 @@ public class BlePairingSettingActivity extends ABVUIActivity { ...@@ -405,11 +408,12 @@ public class BlePairingSettingActivity extends ABVUIActivity {
List<BleListRowData> scanRowDataList = new ArrayList<BleListRowData>(); List<BleListRowData> scanRowDataList = new ArrayList<BleListRowData>();
for (BluetoothDevice bleDevice : mScanDeviceInfoList) { for (BluetoothDevice bleDevice : mScanDeviceInfoList) {
String labelDeviceName = ""; String labelDeviceName = "";
if (bleDevice.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME)) { // if (bleDevice.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
labelDeviceName = getString(R.string.center_thermometer); // labelDeviceName = getString(R.string.center_thermometer);
} else if (bleDevice.getName().startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) { // } else if (bleDevice.getName().startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
labelDeviceName = getString(R.string.radiation_thermometer); // labelDeviceName = getString(R.string.radiation_thermometer);
} else if (bleDevice.getName().startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) { // } else
if (bleDevice.getName().startsWith(ALCOHOL_CHECKER_DEVICE_NAME)) {
labelDeviceName = "アルコールチェッカー"; labelDeviceName = "アルコールチェッカー";
} }
BleListRowData scanRowData = new BleListRowData(bleDevice.getName(), labelDeviceName, bleDevice.getAddress(), false); BleListRowData scanRowData = new BleListRowData(bleDevice.getName(), labelDeviceName, bleDevice.getAddress(), 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