Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
88fdc1ad
Commit
88fdc1ad
authored
Jun 17, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#47941 HW連携 アルコールチェッカーから値を取得する処理を追加中4
parent
b71b72a9
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
385 additions
and
391 deletions
+385
-391
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/type/ServiceOption.java
+7
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/common/Constant.java
+7
-7
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/ABVDataCache.java
+4
-0
ABVJE_Res_Default_Android/res/values-ja/strings.xml
+6
-1
ABVJE_Res_Default_Android/res/values/strings.xml
+6
-3
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
+4
-4
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+56
-100
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
+12
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+35
-35
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/ABVUIDataCache.java
+36
-32
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+168
-174
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ABookSettingFragment.java
+10
-5
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
+34
-30
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/type/ServiceOption.java
View file @
88fdc1ad
...
...
@@ -174,5 +174,11 @@ public interface ServiceOption {
* 利用しない:N(通常)、利用する:Y
*/
int
UsableRFIDBarcodeScan
=
190
;
/**
* アルコールチェッカーHW
* 利用しない:N(通常)、利用する:Y
*/
int
AlcoholCheckerHw
=
202
;
}
}
\ No newline at end of file
ABVJE_BL/src/jp/agentec/abook/abv/bl/common/Constant.java
View file @
88fdc1ad
...
...
@@ -186,12 +186,12 @@ public class Constant {
// 連携機器の区分
public
interface
DeviceType
{
int
centerThermomete
=
1
;
// 中心温度計
int
sensor
=
2
;
// 置くだけセンサー
int
barcode
=
3
;
// バーコード
int
radiationThermomete
=
4
;
// 放射温度計
int
sppBluetoothMachine
=
5
;
// SPP通信機器
int
nfc
=
6
;
// nfc機器
int
alcoholChecker
=
7
;
// アルコールチェッカー
//
int centerThermomete = 1; // 中心温度計
//
int sensor = 2; // 置くだけセンサー
//
int barcode = 3; // バーコード
//
int radiationThermomete = 4; // 放射温度計
//
int sppBluetoothMachine = 5; // SPP通信機器
//
int nfc = 6; // nfc機器
int
alcoholChecker
=
0
;
// アルコールチェッカー
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/ABVDataCache.java
View file @
88fdc1ad
...
...
@@ -347,6 +347,10 @@ public class ABVDataCache {
return
isServiceOptionEnable
(
ServiceOptionId
.
UsableRFIDBarcodeScan
);
}
public
boolean
isAlcoholCheckerHw
()
{
return
isServiceOptionEnable
(
ServiceOptionId
.
AlcoholCheckerHw
);
}
/**
* @version 1.2.300
* サービスオプション(ユーザパスワードソルト付加)返す
...
...
ABVJE_Res_Default_Android/res/values-ja/strings.xml
View file @
88fdc1ad
...
...
@@ -1522,10 +1522,15 @@
<string
name=
"chino_machine"
>
CHINO機器
</string>
<string
name=
"spp_machine"
>
シリアル通信機器
</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=
"msg_scan_bluetooth_no_allow"
>
BlueToothの利用を「許可」しないと、%1$sのスキャンができません。
</string>
<string
name=
"msg_location_device_no_allow"
>
端末の設定から位置情報をONにしてください。
</string>
<string
name=
"alc_checker_setting"
>
アルコールチェッカー設定
</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>
ABVJE_Res_Default_Android/res/values/strings.xml
View file @
88fdc1ad
...
...
@@ -1527,14 +1527,17 @@
<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_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_searching"
>
Other %s(Searching...)
</string>
<string
name=
"connection_completed"
>
接続しました。\n機器のボタンを押してください。
</string>
<string
name=
"select_spp_device_title"
>
シリアル通信機器選択
</string>
<string
name=
"alc_checker_setting"
>
アルコールチェッカー設定
</string>
<string
name=
"alcohl_checker"
>
アルコールチェッカー
</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=
"ble_connecting"
>
Connection...
</string>
<string
name=
"ble_connecting"
>
%1$sの電源を入れて、電源ボタンを押してください。
</string>
<string
name=
"wait_breathe"
>
息を吹きかけてください。
</string>
<string
name=
"start_measurement"
>
測定開始
</string>
</resources>
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
View file @
88fdc1ad
...
...
@@ -28,9 +28,9 @@ public class AlcoholCheckerTimerTask extends TimerTask {
}
@Override
public
void
run
()
{
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
//
Logger.i(TAG,"--------------------------------------------------------------");
Logger
.
i
(
TAG
,
"AlcohlCheckerTimerTask"
);
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
//
Logger.i(TAG,"--------------------------------------------------------------");
alcoholCheckerUtil
.
gi_rxlength
=
0
;
...
...
@@ -66,9 +66,9 @@ public class AlcoholCheckerTimerTask extends TimerTask {
listener
.
onUpdateStatus
(
"F_BLE_COM_RP_START"
);
break
;
default
:
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
//
Logger.i(TAG,"--------------------------------------------------------------");
Logger
.
i
(
TAG
,
"AlcohlCheckerTimerTask Timeout"
);
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
//
Logger.i(TAG,"--------------------------------------------------------------");
if
(
alcoholCheckerUtil
.
gi_rxretry_cnt
<
100
)
{
alcoholCheckerUtil
.
gi_rxretry_cnt
++;
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
88fdc1ad
...
...
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import
java.util.Timer
;
import
java.util.UUID
;
import
jp.agentec.abook.abv.bl.common.constant.ABookKeys
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
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
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_ERROR
=
"com.taiyoyuden.tyapp_terminal.ACTION_TX_ERROR"
;
...
...
@@ -127,29 +127,36 @@ public class AlcoholCheckerUtil {
private
AlcoholCheckerUtilListener
listener
;
// @Timer
private
AlcoholCheckerTimerTask
alcoholCheckerTimerTask
=
null
;
public
boolean
isConnected
=
false
;
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
this
.
listener
=
listener
;
}
// public void initAlcoholChecker() {
// stopAlcTimer();
// disconnect(true);
// }
public
void
finish
()
{
stopAlcTimer
();
//disconnect(true);
//listener = null;
}
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
()
{
// BLE管理
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
public
void
onGetDeviceInfoFailed
(
int
status
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onGetDeviceInfoFailed = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
listener
.
onGetDeviceInfoFailed
(
status
);
}
@Override
...
...
@@ -159,28 +166,23 @@ public class AlcoholCheckerUtil {
Logger
.
i
(
TAG
,
"------------------------------------"
);
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."
);
listener
.
onFugoAction
(
ACTION_GATT_CONNECTED
,
null
,
null
,
null
,
null
);
//sendBroadcast(new Intent(ACTION_GATT_CONNECTED));
// mBluetoothGatt.discoverServices(); // @@@@@
// @@@@@
if
(
bleManagerUtil
.
mBluetoothGatt
.
discoverServices
())
{
Logger
.
i
(
TAG
,
"Started discovering services"
);
// *3
Logger
.
i
(
TAG
,
"Started discovering services"
);
}
else
{
Logger
.
i
(
TAG
,
"Failed to start discovering services"
);
}
// @@@@@
}
else
if
(
status
==
BluetoothProfile
.
STATE_DISCONNECTED
)
{
// Alert application that we disconnected from a device
if
(
bleManagerUtil
.
mBluetoothGatt
==
null
)
{
return
;
}
else
{
Logger
.
i
(
TAG
,
"Disconnected from GATT server."
);
listener
.
onFugoAction
(
ACTION_GATT_DISCONNECTED
,
null
,
null
,
null
,
null
);
//bmBluetoothGatt.close();
//mBluetoothGatt=null;
bleManagerUtil
.
disconnect
(
true
);
}
}
else
{
...
...
@@ -193,6 +195,8 @@ public class AlcoholCheckerUtil {
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onDisConnectionState"
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
isConnected
=
false
;
listener
.
onConnectionError
(
0
);
}
@Override
...
...
@@ -200,6 +204,8 @@ public class AlcoholCheckerUtil {
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onConnectionError = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
isConnected
=
false
;
listener
.
onConnectionError
(
status
);
}
@Override
...
...
@@ -249,7 +255,7 @@ public class AlcoholCheckerUtil {
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
timerStart
();
startAlcTimer
();
}
});
thread
.
start
();
...
...
@@ -273,18 +279,7 @@ public class AlcoholCheckerUtil {
rxStr
+=
rx1
+
" ,"
;
}
}
final
String
printText
=
rxStr
;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
sub_rx_chk
(
rx
);
//printMessageToScreen(new String(rx));
}
});
...
...
@@ -292,7 +287,6 @@ public class AlcoholCheckerUtil {
if
(!
bleManagerUtil
.
startDeviceInfo
())
{
return
false
;
}
//timerStart();
return
true
;
}
...
...
@@ -300,7 +294,7 @@ public class AlcoholCheckerUtil {
/**
* アルコールチェッカーを監視するタイマーを開始する
*/
private
void
timerStart
()
{
private
void
startAlcTimer
()
{
if
(
alcoholCheckerTimerTask
!=
null
)
{
alcoholCheckerTimerTask
.
cancel
();
alcoholCheckerTimerTask
=
null
;
...
...
@@ -310,6 +304,17 @@ public class AlcoholCheckerUtil {
timer
.
schedule
(
alcoholCheckerTimerTask
,
0
,
1000
);
}
/**
* タイマー停止
*/
public
void
stopAlcTimer
()
{
if
(
alcoholCheckerTimerTask
!=
null
)
{
alcoholCheckerTimerTask
.
cancel
();
alcoholCheckerTimerTask
=
null
;
}
}
private
void
init
()
{
//rxMessage = "";
...
...
@@ -327,11 +332,9 @@ public class AlcoholCheckerUtil {
// 切断
public
void
disconnect
(
boolean
listenerFlg
)
{
stopAlcTimer
();
isConnected
=
false
;
bleManagerUtil
.
disconnect
(
listenerFlg
);
if
(
alcoholCheckerTimerTask
!=
null
)
{
alcoholCheckerTimerTask
.
cancel
();
alcoholCheckerTimerTask
=
null
;
}
}
...
...
@@ -363,16 +366,12 @@ public class AlcoholCheckerUtil {
String
error_msg
=
""
;
try
{
// Convert our message to byte array in selected format
byte
[]
bMessage
=
message
.
getBytes
(
"UTF-8"
);
bMessage
=
hex2string
(
bMessage
);
// Requires NumberFormatException
if
(
bMessage
==
null
)
{
// Invalid message
Toast
.
makeText
(
context
,
"Invalid characters"
,
Toast
.
LENGTH_SHORT
).
show
();
//
Toast.makeText(context, "Invalid characters", Toast.LENGTH_SHORT).show();
throw
new
NumberFormatException
();
}
...
...
@@ -400,8 +399,7 @@ public class AlcoholCheckerUtil {
Thread
.
sleep
(
10
);
// Requires InterruptedException
}
//System.out.println("Tx: " + message);
Logger
.
d
(
TAG
,
"Tx:"
+
message
);
// @Mode Change
switch
(
gi_status
)
{
...
...
@@ -419,9 +417,9 @@ public class AlcoholCheckerUtil {
}
}
catch
(
UnsupportedEncodingException
e
)
{
System
.
out
.
println
(
"Unsupported encoding exception"
);
Logger
.
w
(
TAG
,
e
);
}
catch
(
InterruptedException
e
)
{
System
.
out
.
println
(
"Interrupted exception"
);
Logger
.
w
(
TAG
,
e
);
}
catch
(
NumberFormatException
e
)
{
error_msg
=
"Invalid message format"
;
}
catch
(
Exception
e
)
{
...
...
@@ -430,12 +428,9 @@ public class AlcoholCheckerUtil {
//Intent intent;
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
);
}
else
{
//intent = new Intent(ACTION_TX_FINISHED);
//intent.putExtra("MESSAGE", message);
listener
.
onFugoAction
(
ACTION_TX_FINISHED
,
null
,
null
,
message
,
null
);
}
}
...
...
@@ -519,10 +514,8 @@ public class AlcoholCheckerUtil {
try
{
// Append to current stream output
sub_rx_data_gen
(
rxdata
);
// Mode
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
...
...
@@ -541,33 +534,9 @@ public class AlcoholCheckerUtil {
gi_status
=
F_BLE_COM_RP_START
;
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
)
{
// This is a new message
// messageLog.add(message);
Logger
.
e
(
TAG
,
e
);
}
//messageAdapter.notifyDataSetChanged();
}
/* @Read Flame Generation */
...
...
@@ -607,32 +576,28 @@ public class AlcoholCheckerUtil {
case
(
byte
)
0x07
:
// Rest 3
listener
.
onUpdateTBVCalc
(
"3"
);
//((TextView) findViewById(R.id.TBV_Calc)).setText("3"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x08
:
// Rest 2
// ((TextView)findViewById(R.id.TBV_Calc)).setText("2"); // @
listener
.
onUpdateTBVCalc
(
"2"
);
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x09
:
// Rest 1
listener
.
onUpdateTBVCalc
(
"1"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("1"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0A
:
listener
.
onUpdateTBVCalc
(
"Go"
);
// Blow
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Go"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
listener
.
onStartMeasurement
();
break
;
case
(
byte
)
0x0B
:
// Blow After
listener
.
onUpdateTBVCalc
(
"Blow..."
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Blow..."); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
...
...
@@ -648,13 +613,11 @@ public class AlcoholCheckerUtil {
case
(
byte
)
0x0D
:
// Wait
listener
.
onUpdateTBVCalc
(
"Wait"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Wait"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0E
:
// Ready
listener
.
onUpdateTBVCalc
(
"Ready? 測定開始待ち状態 0x0E"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Ready?"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x11
:
...
...
@@ -664,44 +627,39 @@ public class AlcoholCheckerUtil {
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
listener
.
onUpdateTBVCalc
(
"エラー 0x11"
);
// "エラー 0x11"
listener
.
onMeasurementError
(
"エラー 0x11"
);
break
;
case
(
byte
)
0x12
:
// Failed
listener
.
onUpdateTBVCalc
(
"BreakDown"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Break Down"); // @
listener
.
onBreakDownError
(
"BreakDown"
);
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x14
:
listener
.
on
UpdateTBVCalc
(
"Low Battery"
);
listener
.
on
LowBatteryError
(
"Low Battery"
);
// Low Battery
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Low Battery"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x15
:
// Calc
listener
.
onUpdateTBVCalc
(
"Calculationg"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Calculating"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x1F
:
listener
.
on
UpdateTBVCalc
(
"Over Used"
);
listener
.
on
OverUsedError
(
"Over Used"
);
// Excess usage count
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Over Used"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x20
:
listener
.
on
UpdateTBVCalc
(
"OFF"
);
listener
.
on
PowerOff
(
"OFF"
);
// Power Down
// ((TextView)findViewById(R.id.TBV_Calc)).setText("OFF"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x21
:
listener
.
onUpdateTBVCalc
(
"Data"
);
// Result Data Screen
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Data"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
default
:
...
...
@@ -710,7 +668,7 @@ public class AlcoholCheckerUtil {
break
;
}
}
else
{
System
.
out
.
println
(
"RP Error"
);
Logger
.
e
(
TAG
,
"RP Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
else
{
...
...
@@ -718,7 +676,7 @@ public class AlcoholCheckerUtil {
/* Receiving */
si_ret
=
F_BLE_COM_RP_WAIT
;
}
else
{
System
.
out
.
println
(
"RP Length Error"
);
Logger
.
e
(
TAG
,
"RP Length Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
...
...
@@ -767,21 +725,19 @@ public class AlcoholCheckerUtil {
str_msg
+=
String
.
format
(
"%1$02d"
,
ss_data
);
}
str_msg
+=
"[mg/L]"
;
//((TextView)findViewById(R.id.TBV_Calc)).setText(str_msg); // @
//str_msg += "[mg/L]";
//listener.onUpdateTBVCalc(str_msg + " 0x0C 測定結果表示状態");
listener
.
onGetDeviceInfo
(
str_msg
);
}
else
{
// Error
//((TextView)findViewById(R.id.TBV_Calc)).setText("Error"); // @
listener
.
onUpdateTBVCalc
(
"Error"
);
//listener.onError("Error");
}
gf_result_flg
=
true
;
si_ret
=
F_BLE_COM_RP_START
;
}
else
{
System
.
out
.
println
(
"RD Error"
);
Logger
.
e
(
TAG
,
"RD Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
else
{
...
...
@@ -789,7 +745,7 @@ public class AlcoholCheckerUtil {
/* Receiving */
si_ret
=
F_BLE_COM_RD_WAIT
;
}
else
{
System
.
out
.
println
(
"RD Length Error"
);
Logger
.
e
(
TAG
,
"RD Length Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
View file @
88fdc1ad
...
...
@@ -7,6 +7,18 @@ import java.util.UUID;
public
interface
AlcoholCheckerUtilListener
{
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
onUpdateStatus
(
String
text
);
void
onUpdateSendMessage
(
String
text
);
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
88fdc1ad
...
...
@@ -78,6 +78,7 @@ public class BleManagerUtil {
@Override
public
void
run
()
{
mListener
.
onConnectionError
(
status
);
disconnect
(
true
);
}
});
return
;
...
...
@@ -94,7 +95,7 @@ public class BleManagerUtil {
@Override
public
void
run
()
{
mListener
.
onGetDeviceInfoFailed
(
status
);
Logger
.
e
(
"onConnectionStateChange
2
status = "
+
status
);
Logger
.
e
(
"onConnectionStateChange status = "
+
status
);
}
});
}
...
...
@@ -134,20 +135,20 @@ public class BleManagerUtil {
}
// 発見されたサービスのループ
for
(
BluetoothGattService
service
:
gatt
.
getServices
())
{
// サービスごとに個別の処理
if
((
service
==
null
)
||
(
service
.
getUuid
()
==
null
))
{
continue
;
}
// GATTサービスのキャラクタリスティックを列挙
List
<
BluetoothGattCharacteristic
>
listCharacteristic
=
service
.
getCharacteristics
();
for
(
BluetoothGattCharacteristic
characteristic
:
listCharacteristic
)
{
// 利用したいものがあるはず!
Logger
.
d
(
TAG
,
"characteristic : [ "
+
characteristic
);
}
// プライベートサービス
//
for(BluetoothGattService service : gatt.getServices()) {
//
// サービスごとに個別の処理
//
if((service == null) || (service.getUuid() == null)) {
//
continue;
//
}
//
//
// GATTサービスのキャラクタリスティックを列挙
//
List<BluetoothGattCharacteristic> listCharacteristic = service.getCharacteristics();
//
for (BluetoothGattCharacteristic characteristic : listCharacteristic) {
//
// 利用したいものがあるはず!
// //
Logger.d(TAG, "characteristic : [ " + characteristic );
//
}
//
//
// プライベートサービス
// if(UUID_SERVICE_PRIVATE.equals(service.getUuid())) {
// // 最初の読み取り
// readCharacteristic(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE);
...
...
@@ -161,16 +162,16 @@ public class BleManagerUtil {
// });
// continue;
// }
}
//
}
}
// キャラクタリスティックが読み込まれたときの処理
//
@Override
//
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status ) {
//
Logger.i(TAG,"onCharacteristicChanged");
//
if( BluetoothGatt.GATT_SUCCESS != status ) {
//
return;
//
}
@Override
public
void
onCharacteristicRead
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
,
int
status
)
{
Logger
.
i
(
TAG
,
"onCharacteristicChanged"
);
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
return
;
}
// if( UUID_CHARACTERISTIC_PRIVATE.equals(characteristic.getUuid())) {
// final String strTemperature = byteToString(characteristic.getValue());
// runOnUiThread( new Runnable() {
...
...
@@ -185,12 +186,12 @@ public class BleManagerUtil {
// setCharacteristicNotification(UUID_SERVICE_PRIVATE, UUID_CHARACTERISTIC_PRIVATE, true);
// return;
// }
//
}
}
// キャラクタリスティック変更が通知されたときの処理
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
i
(
TAG
,
"
------------------------------------------------------
onCharacteristicChanged"
);
Logger
.
i
(
TAG
,
"onCharacteristicChanged"
);
if
(
mBleConnectDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
mListener
.
onCharacteristicChanged
(
gatt
,
characteristic
);
return
;
...
...
@@ -282,7 +283,7 @@ public class BleManagerUtil {
mDeviceAddress
=
deviceAddress
;
// デバイスタイプセット
mBleConnectDeviceType
=
connectTargetDeviceType
;
setUUID
();
//
setUUID();
if
(
StringUtil
.
isNullOrEmpty
(
mDeviceAddress
))
{
// DeviceAddressが空の場合は処理しない
return
;
}
...
...
@@ -339,18 +340,17 @@ public class BleManagerUtil {
// ②「接続可能範囲から外れた切断」は、内部処理でmBluetoothGatt.disconnect()処理が実施される。
// 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。
mBluetoothGatt
.
disconnect
();
// mBluetoothGatt.close();
mBluetoothGatt
=
null
;
if
(
listenerFlg
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// 切断トーストメッセージを表示する。
mListener
.
onDisConnectionState
();
}
});
}
//
if (listenerFlg) {
//
runOnUiThread( new Runnable() {
//
@Override
//
public void run() {
//
// 切断トーストメッセージを表示する。
//
mListener.onDisConnectionState();
//
}
//
});
//
}
}
// キャラクタリスティックの読み込み
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/ABVUIDataCache.java
View file @
88fdc1ad
...
...
@@ -194,15 +194,16 @@ public class ABVUIDataCache {
BluetoothPairingDeviceInfoDto
dto
=
new
BluetoothPairingDeviceInfoDto
();
String
deviceName
=
null
;
String
deviceAddress
=
null
;
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
centerThermomete
)
{
// 中心温度計
deviceName
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_CENTER_TEMPERATURE_NAME
,
""
);
deviceAddress
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS
,
""
);
}
else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
radiationThermomete
)
{
// 放射温度計
deviceName
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_RADIATION_TEMPERATURE_NAME
,
""
);
deviceAddress
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS
,
""
);
}
else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
// if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) {
// // 中心温度計
// deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, "");
// deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, "");
// } else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) {
// // 放射温度計
// deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, "");
// deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, "");
// } else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
// アルコールチェッカー
deviceName
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_ALCOHO_CHECKER_NAME
,
""
);
deviceAddress
=
PreferenceUtil
.
getUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_ALCOHO_CHECKER_ADDRESS
,
""
);
...
...
@@ -226,11 +227,12 @@ public class ABVUIDataCache {
*/
public
String
getPairingBluetoothDeviceAddress
(
int
bluetoothDeviceType
)
{
String
deviceAddressKey
=
null
;
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
centerThermomete
)
{
deviceAddressKey
=
UserPrefKey
.
BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS
;
}
else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
radiationThermomete
)
{
deviceAddressKey
=
UserPrefKey
.
BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS
;
}
else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
// if (bluetoothDeviceType == Constant.DeviceType.centerThermomete) {
// deviceAddressKey = UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS;
// } else if (bluetoothDeviceType == Constant.DeviceType.radiationThermomete) {
// deviceAddressKey = UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS;
// } else
if
(
bluetoothDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
deviceAddressKey
=
UserPrefKey
.
BLE_DEVICE_ALCOHO_CHECKER_ADDRESS
;
}
if
(
deviceAddressKey
==
null
)
{
...
...
@@ -266,15 +268,16 @@ public class ABVUIDataCache {
* @param pairingDeviceInfoDto
*/
public
void
setPairingBluetoothDeviceInfo
(
BluetoothPairingDeviceInfoDto
pairingDeviceInfoDto
)
{
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_ADDRESS
,
pairingDeviceInfoDto
.
deviceAddress
);
}
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_ADDRESS
,
pairingDeviceInfoDto
.
deviceAddress
);
}
else
if
(
pairingDeviceInfoDto
.
deviceType
.
equals
(
Constant
.
DeviceType
.
alcoholChecker
))
{
// 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_ADDRESS, pairingDeviceInfoDto.deviceAddress);
// } 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_ADDRESS, pairingDeviceInfoDto.deviceAddress);
// } 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_ADDRESS
,
pairingDeviceInfoDto
.
deviceAddress
);
...
...
@@ -287,15 +290,16 @@ public class ABVUIDataCache {
* @param deviceType
*/
public
void
removePairingBluetoothDeviceInfo
(
int
deviceType
)
{
if
(
deviceType
==
Constant
.
DeviceType
.
centerThermomete
)
{
// 中心温度計
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_CENTER_TEMPERATURE_NAME
);
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS
);
}
else
if
(
deviceType
==
Constant
.
DeviceType
.
radiationThermomete
)
{
// 放射温度計
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_RADIATION_TEMPERATURE_NAME
);
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS
);
}
else
if
(
deviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
// if (deviceType == Constant.DeviceType.centerThermomete) {
// // 中心温度計
// PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME);
// PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS);
// } else if (deviceType == Constant.DeviceType.radiationThermomete) {
// // 放射温度計
// PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME);
// PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS);
// } else
if
(
deviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
// 放射温度計
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_ALCOHO_CHECKER_NAME
);
PreferenceUtil
.
removeUserPref
(
context
,
UserPrefKey
.
BLE_DEVICE_ALCOHO_CHECKER_ADDRESS
);
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
88fdc1ad
package
jp
.
agentec
.
abook
.
abv
.
ui
.
common
.
activity
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattDescriptor
;
import
android.bluetooth.BluetoothGattService
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
...
...
@@ -21,7 +19,6 @@ import android.view.View;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.Button
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
...
...
@@ -44,11 +41,9 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Timer
;
import
java.util.UUID
;
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.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.Callback
;
...
...
@@ -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.data.ABVDataCache
;
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.MydataDto
;
import
jp.agentec.abook.abv.bl.dto.OperationDto
;
...
...
@@ -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.AlcoholCheckerUtilListener
;
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.LocationManagerUtil
;
import
jp.agentec.abook.abv.cl.util.PreferenceUtil
;
...
...
@@ -103,7 +98,6 @@ import jp.agentec.adf.util.FileUtil;
import
jp.agentec.adf.util.StringUtil
;
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
{
...
...
@@ -181,18 +175,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// アルコールチェッカー
private
AlcoholCheckerUtil
alcoholCheckerUtil
;
// 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 アルコールチェッカー
private
int
mDeviceType
;
// 設問ID
private
String
mQid
;
private
String
mQid
=
""
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -243,6 +237,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
// アルコールチェッカースタート
alcoholCheckerUtil
=
new
AlcoholCheckerUtil
(
this
,
new
AlcoholCheckerUtilListener
()
{
...
...
@@ -251,15 +246,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onFugoAction = %s"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_GATT_CONNECTED
))
{
Logger
.
i
(
TAG
,
"ACTION_GATT_CONNECTED"
);
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_GATT_DISCONNECTED
))
{
Logger
.
i
(
TAG
,
"ACTION_GATT_DISCONNECTED"
);
errorAfterAbookCheckApi
(
""
);
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_DATA_RECEIVED
))
{
Logger
.
i
(
TAG
,
"ACTION_DATA_RECEIVED"
);
// if (messageAdapter.getCurrentDirection() != 'R'){
// messageAdapter.newMessage('R');
// }
byte
[]
rx
=
data
;
String
rxStr
=
" "
;
...
...
@@ -268,42 +262,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
rxStr
+=
rx1
+
" ,"
;
}
}
final
String
printText
=
rxStr
;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
alcoholCheckerUtil
.
sub_rx_chk
(
rx
);
//printMessageToScreen(new String(rx));
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_TX_FINISHED
))
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_TX_FINISHED = %s"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
// Finished transmitting, display to screen and clear message
// if (messageAdapter.getCurrentDirection() != 'T'){
// messageAdapter.newMessage('T');
// }
//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_TX_FINISHED)) {
// Logger.i(TAG,"------------------------------------");
// Logger.i(TAG,"ACTION_TX_FINISHED = %s", action);
// Logger.i(TAG,"------------------------------------");
// } else if (action.equals(AlcoholCheckerUtil.ACTION_TX_ERROR)) {
// Logger.i(TAG,"------------------------------------");
// Logger.i(TAG,"ACTION_TX_ERROR", action);
// Logger.i(TAG,"------------------------------------");
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_DESCRIPTOR_WROTE
))
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_DESCRIPTOR_WROTE"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
getService
(
AlcoholCheckerUtil
.
TY_SERVICE_UUID
).
getCharacteristic
(
AlcoholCheckerUtil
.
INDICATION_CHARACTERISTIC_UUID
)
==
null
)
{
Logger
.
i
(
TAG
,
"Old Version."
);
// This version doesn't support latest characteristics
return
;
}
if
(
Type
.
equals
(
"Notification"
))
{
...
...
@@ -327,8 +302,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onUpdateTBVCalc = %s"
,
text
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND);
}
@Override
...
...
@@ -357,40 +330,98 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_GATT_SERVICES"
);
mIsConnection
=
true
;
alcoholCheckerUtil
.
isConnected
=
true
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
//mWaitingDialog.setMessage("接続しましたボタンをおしてください");
//Button btn = mWaitingDialog.getButton(DialogInterface.BUTTON_POSITIVE);
//btn.setText("うんこ");
if
(
mWaitingDialog
!=
null
)
{
mWaitingDialog
.
dismiss
();
mWaitingDialog
=
null
;
}
showWaitMeasureDialog
(
"aaaaaa"
,
"aaaaaaaaaaaaaaaaaaaaaaaaaaa"
);
// 測定開始ボタン押し待ち
showWaitMeasureDialog
(
getString
(
R
.
string
.
alcohl_checker
),
getString
(
R
.
string
.
connection_completed
));
}
});
}
@Override
public
void
onGetDeviceInfo
(
String
alcohol
)
{
/// 測定値
if
(
mWaitingDialog
!=
null
)
{
mWaitingDialog
.
dismiss
();
mWaitingDialog
=
null
;
}
if
(
mWaitMeasureDialog
!=
null
)
{
mWaitMeasureDialog
.
dismiss
();
mWaitMeasureDialog
=
null
;
// 測定完了
successAfterAbookCheckApi
(
alcohol
);
//alcoholCheckerUtil.finish();
}
@Override
public
void
onStartMeasurement
()
{
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
)
{
mMeasureDialog
.
dismiss
();
mMeasureDialog
=
null
;
runOnUiThread
(
new
Runnable
()
{
@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 {
// showHelpViewDialog(helpViewType);
// }
/**
* 中心温度計の接続を切る
* #39006 【@Form】(要望)中心温度計 放射温度計の連続計測対応
*/
protected
void
bleManagerDisconnect
()
{
// onuma ここでは切らない
//bleManagerUtil.disconnect(true);
}
// private void alcoholCheckerUtilbleManagerDisconnect(boolean disconnect) {
// Logger.d(TAG,"-------------------------------------------------");
// Logger.d(TAG, "bleManagerDisconnect = " + disconnect);
// Logger.d(TAG,"-------------------------------------------------");
// if (disconnect){
// mIsConnection = false;
// alcoholCheckerUtil.disconnect(true);
// } else {
// // 何もしない
// }
// }
private
void
closeAllDialog
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// 後始末
if
(
mWaitingDialog
!=
null
)
{
mWaitingDialog
.
dismiss
();
mWaitingDialog
=
null
;
}
if
(
mWaitMeasureDialog
!=
null
)
{
mWaitMeasureDialog
.
dismiss
();
mWaitMeasureDialog
=
null
;
}
if
(
mMeasureDialog
!=
null
)
{
mMeasureDialog
.
dismiss
();
mMeasureDialog
=
null
;
}
}
});
}
/**
* 各デバイスから値を正常に取得された場合、HTML側にコールする
* @param value 各種デバイスから取得した値
*/
private
void
successAfterAbookCheckAip
(
String
value
)
{
private
void
successAfterAbookCheckApi
(
String
value
)
{
closeAllDialog
();
JSONObject
responseJson
=
new
JSONObject
();
responseJson
.
put
(
ABookKeys
.
TASK_QUESTION_ID
,
mQid
);
responseJson
.
put
(
"value"
,
value
);
afterABookCheckApi
(
mCmd
,
""
,
0
,
""
,
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 {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting Dialog stop click : "
+
mDeviceType
);
if
(
mDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"アルコールチェッカー接続待中止"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
alcoholCheckerUtil
.
disconnect
(
true
);
}
successAfterAbookCheckAip
(
""
);
mWaitingDialog
.
dismiss
();
//mWaitingDialog.dismiss();
mWaitingDialog
=
null
;
//alcoholCheckerUtil.disconnect(true);
successAfterAbookCheckApi
(
""
);
}
});
mWaitingDialog
.
show
();
...
...
@@ -1191,41 +1229,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
i
(
TAG
,
"showWaitMeasureDialog"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
mWaitMeasureDialog
=
AlertDialogUtil
.
createAlertDialog
(
this
,
title
);
mWaitMeasureDialog
.
setMessage
(
"接続しました。ボタンをおしてください"
);
mWaitMeasureDialog
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
"測定開始"
,
new
DialogInterface
.
OnClickListener
()
{
mWaitMeasureDialog
.
setMessage
(
getString
(
R
.
string
.
connection_completed
)
);
mWaitMeasureDialog
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
cancel
)
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting mWaitMeasureDialog stop click : "
+
mDeviceType
);
runOnUiThread
(
new
Runnable
()
{
@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.dismiss();
mWaitMeasureDialog
=
null
;
//alcoholCheckerUtil.disconnect(true);
errorAfterAbookCheckApi
(
""
);
}
});
mWaitMeasureDialog
.
show
();
...
...
@@ -1237,67 +1249,45 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param message 内容
*/
private
void
showMeasureDialog
(
String
title
,
String
message
)
{
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"showMeasureDialog"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
mMeasureDialog
=
AlertDialogUtil
.
createAlertDialog
(
this
,
title
);
mMeasureDialog
.
setMessage
(
"息を吹きかけてください"
);
mMeasureDialog
.
setButton
(
DialogInterface
.
BUTTON_NEGATIVE
,
"測定中止"
,
new
DialogInterface
.
OnClickListener
()
{
mMeasureDialog
.
setMessage
(
message
);
mMeasureDialog
.
setButton
(
DialogInterface
.
BUTTON_NEGATIVE
,
getString
(
R
.
string
.
cancel
)
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting Dialog stop click : "
+
mDeviceType
);
if
(
mDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"測定中止"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
}
alcoholCheckerUtil
.
disconnect
(
true
);
successAfterAbookCheckAip
(
""
);
mMeasureDialog
.
dismiss
();
//alcoholCheckerUtil.disconnect(true);
//mMeasureDialog.dismiss();
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
();
}
/**
* 各デバイスからエラー(接続不能など)発生した場合、HTML側にコールする
* @param errorMessage 各種デバイスから取得した値
*/
private
void
errorAfterAbookCheckAip
(
String
errorMessage
)
{
afterABookCheckApi
(
mCmd
,
""
,
1
,
errorMessage
,
null
);
}
/**
* アルコールチェッカー処理
* @param abookCheckParam
*/
private
void
getDeviceInfo
(
Map
<
String
,
String
>
abookCheckParam
)
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"getDeviceInfo"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"getDeviceInfo"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
mDeviceType
=
Constant
.
DeviceType
.
alcoholChecker
;
mQid
=
"1"
;
mDeviceType
=
Integer
.
parseInt
(
abookCheckParam
.
get
(
ABookKeys
.
TASK_DEVICE_TYPE
))
;
mQid
=
abookCheckParam
.
get
(
ABookKeys
.
TASK_QUESTION_ID
)
;
if
(
isAlcLock
)
{
return
;
}
isAlcLock
=
true
;
// アルコールチェッカー接続
connectToAlcholChecker
();
}
private
boolean
isAlcLock
=
false
;
/**
* BLEディバイスのアルコールチェッカーの情報取得
*/
...
...
@@ -1307,21 +1297,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
String
deviceAddress
=
getABVUIDataCache
().
getPairingBluetoothDeviceAddress
(
Constant
.
DeviceType
.
alcoholChecker
);
if
(
StringUtil
.
isNullOrEmpty
(
deviceAddress
))
{
// 登録されているアルコールチェッカーが無い場合はエラー
errorAfterAbookCheckA
ip
(
getString
(
R
.
string
.
msg_pairing_device_no_info
));
errorAfterAbookCheckA
pi
(
getString
(
R
.
string
.
msg_pairing_device_no_info
));
return
;
}
if
(
mIsConnection
)
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"isConnection = true"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
String
message
=
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_success
),
getString
(
R
.
string
.
alcohl_checker
));
BluetoothPairingDeviceInfoDto
dto
=
getABVUIDataCache
().
getPairingBluetoothDeviceInfo
(
Constant
.
DeviceType
.
alcoholChecker
);
if
(
alcoholCheckerUtil
.
isConnected
)
{
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
);
}
else
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"isConnection = false"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"isConnection = false"
);
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
);
}
...
...
@@ -1624,12 +1618,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
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
));
}
else
if
(
mCmd
.
equals
(
ABookKeys
.
CMD_SAVE_USER_DATA
))
{
// 入力内容を保存する
Logger
.
i
(
TAG
,
"save taskKey = "
+
abookCheckParam
.
get
(
ABookKeys
.
TASK_KEY
));
Logger
.
i
(
TAG
,
"save userData = "
+
abookCheckParam
.
get
(
ABookKeys
.
USER_DATA
));
Logger
.
d
(
TAG
,
"save taskKey = "
+
abookCheckParam
.
get
(
ABookKeys
.
TASK_KEY
));
Logger
.
d
(
TAG
,
"save userData = "
+
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
))
{
Logger
.
i
(
TAG
,
"getDeviceInfo"
);
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ABookSettingFragment.java
View file @
88fdc1ad
...
...
@@ -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.parameters.AppLastVersionParameters
;
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.CommonExecutor
;
import
jp.agentec.abook.abv.bl.common.Constant
;
...
...
@@ -69,6 +70,7 @@ public class ABookSettingFragment extends PreferenceFragment {
private
static
final
String
ACCOUNT_SET
=
"account_set"
;
private
static
final
String
LOG_INFO
=
"log_info"
;
private
static
final
String
APP_INFO
=
"app_info"
;
private
static
final
String
SET_PAIRING
=
"set_pairing"
;
// アカウント
private
static
final
String
ACCOUNT_PATH
=
"accountPath"
;
...
...
@@ -88,8 +90,6 @@ public class ABookSettingFragment extends PreferenceFragment {
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"
;
protected
Handler
handler
=
new
Handler
();
...
...
@@ -482,10 +482,15 @@ public class ABookSettingFragment extends PreferenceFragment {
// 機器連携のペアリング設定
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
public
boolean
onPreferenceClick
(
Preference
preference
)
{
try
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
View file @
88fdc1ad
...
...
@@ -44,8 +44,8 @@ public class BlePairingSettingActivity extends ABVUIActivity {
private
static
final
int
REQUEST_ENABLEBLUETOOTH
=
1
;
// Bluetooth機能の有効化要求時の識別コード
private
static
final
long
SCAN_PERIOD
=
20000
;
// スキャン時間。単位はミリ秒。
private
static
final
String
CENTER_THERMOMETE_DEVICE_NAME
=
"MF500"
;
// 中心温度計のデバイス名
private
static
final
String
RADIATION_THERMOMETE_DEVICE_NAME
=
"IR-TB"
;
// 放射温度計のデバイス名
//
private static final String CENTER_THERMOMETE_DEVICE_NAME = "MF500"; // 中心温度計のデバイス名
//
private static final String RADIATION_THERMOMETE_DEVICE_NAME = "IR-TB"; // 放射温度計のデバイス名
private
static
final
String
ALCOHOL_CHECKER_DEVICE_NAME
=
"FALC-31"
;
// アルコールチェッカーデバイス名
...
...
@@ -73,10 +73,10 @@ public class BlePairingSettingActivity extends ABVUIActivity {
Logger
.
d
(
"mScanCallback device.getName() = "
+
device
.
getName
());
}
// 識別商品名に絞る ALC_DEVICE_NAME
if
(
device
.
getName
()
!=
null
&&
(
device
.
getName
().
startsWith
(
CENTER_THERMOMETE_DEVICE_NAME
)
||
device
.
getName
().
startsWith
(
RADIATION_THERMOMETE_DEVICE_NAME
)
||
(
device
.
getName
().
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
)
)))
{
//
if(device.getName() != null && (device.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME)
//
|| device.getName().startsWith(RADIATION_THERMOMETE_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
()))
{
//登録されたデバイスの場合、スキャン情報から除外する。
boolean
isAdd
=
true
;
for
(
BluetoothDevice
savedDevice
:
mScanDeviceInfoList
)
{
...
...
@@ -123,11 +123,12 @@ public class BlePairingSettingActivity extends ABVUIActivity {
public
void
onDeleteConnectInfo
(
BleListRowData
rowData
)
{
// 登録されたデバイス情報削除
Logger
.
i
(
rowData
.
deviceAddress
);
Integer
deviceType
=
null
;
if
(
rowData
.
title
.
startsWith
(
CENTER_THERMOMETE_DEVICE_NAME
))
{
deviceType
=
DeviceType
.
centerThermomete
;
}
else
if
(
rowData
.
title
.
startsWith
(
RADIATION_THERMOMETE_DEVICE_NAME
))
{
deviceType
=
DeviceType
.
radiationThermomete
;
}
else
if
(
rowData
.
title
.
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
// if (rowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
// deviceType = DeviceType.centerThermomete;
// } else if (rowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
// deviceType = DeviceType.radiationThermomete;
// } else
if
(
rowData
.
title
.
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
deviceType
=
DeviceType
.
alcoholChecker
;
}
...
...
@@ -305,13 +306,14 @@ public class BlePairingSettingActivity extends ABVUIActivity {
mSavedDeviceAddressList
.
add
(
bleListRowData
.
deviceAddress
);
BluetoothPairingDeviceInfoDto
pairingDeviceInfo
=
new
BluetoothPairingDeviceInfoDto
();
if
(
bleListRowData
.
title
.
startsWith
(
CENTER_THERMOMETE_DEVICE_NAME
))
{
// デバイス名がMF500から始まると中心温度計と見做す。
pairingDeviceInfo
.
deviceType
=
DeviceType
.
centerThermomete
;
}
else
if
(
bleListRowData
.
title
.
startsWith
(
RADIATION_THERMOMETE_DEVICE_NAME
))
{
// デバイス名がIR-TBから始まると放射温度計と見做す。
pairingDeviceInfo
.
deviceType
=
DeviceType
.
radiationThermomete
;
}
else
if
(
bleListRowData
.
title
.
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
// if (bleListRowData.title.startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
// // デバイス名がMF500から始まると中心温度計と見做す。
// pairingDeviceInfo.deviceType = DeviceType.centerThermomete;
// } else if (bleListRowData.title.startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
// // デバイス名がIR-TBから始まると放射温度計と見做す。
// pairingDeviceInfo.deviceType = DeviceType.radiationThermomete;
// } else
if
(
bleListRowData
.
title
.
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
// デバイス名がMF500から始まるとアルコールチェッカーとみなす
pairingDeviceInfo
.
deviceType
=
DeviceType
.
alcoholChecker
;
}
...
...
@@ -350,15 +352,16 @@ public class BlePairingSettingActivity extends ABVUIActivity {
List
<
SectionHeaderData
>
sectionList
=
new
ArrayList
<>();
List
<
BluetoothPairingDeviceInfoDto
>
bluetoothPairingInfoDtoList
=
getABVUIDataCache
().
getPairingBluetoothDeviceInfoList
(
Arrays
.
asList
(
DeviceType
.
centerThermomete
,
DeviceType
.
radiationThermomete
,
DeviceType
.
alcoholChecker
));
getABVUIDataCache
().
getPairingBluetoothDeviceInfoList
(
Arrays
.
asList
(
DeviceType
.
alcoholChecker
));
if
(
CollectionUtil
.
isNotEmpty
(
bluetoothPairingInfoDtoList
))
{
for
(
BluetoothPairingDeviceInfoDto
bluetoothPairingDeviceInfoDto
:
bluetoothPairingInfoDtoList
)
{
// ペアリング情報が既に保存されてる場合はヘッダー情報を各機器毎に追加する
if
(
bluetoothPairingDeviceInfoDto
.
deviceType
.
equals
(
DeviceType
.
centerThermomete
))
{
sectionList
.
add
(
new
SectionHeaderData
(
String
.
format
(
getString
(
R
.
string
.
pairing_save_machine
),
getString
(
R
.
string
.
center_thermometer
))));
}
else
if
(
bluetoothPairingDeviceInfoDto
.
deviceType
.
equals
(
DeviceType
.
radiationThermomete
))
{
sectionList
.
add
(
new
SectionHeaderData
(
String
.
format
(
getString
(
R
.
string
.
pairing_save_machine
),
getString
(
R
.
string
.
radiation_thermometer
))));
}
else
if
(
bluetoothPairingDeviceInfoDto
.
deviceType
.
equals
(
DeviceType
.
alcoholChecker
))
{
// if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.centerThermomete)) {
// sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.center_thermometer))));
// } else if (bluetoothPairingDeviceInfoDto.deviceType.equals(DeviceType.radiationThermomete)) {
// sectionList.add(new SectionHeaderData(String.format(getString(R.string.pairing_save_machine), getString(R.string.radiation_thermometer))));
// } else
if
(
bluetoothPairingDeviceInfoDto
.
deviceType
.
equals
(
DeviceType
.
alcoholChecker
))
{
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 {
List
<
List
<
BleListRowData
>>
rowList
=
new
ArrayList
<
List
<
BleListRowData
>>();
// 引数で指定したタイプリストのペアリング情報を取得
List
<
BluetoothPairingDeviceInfoDto
>
bluetoothPairingInfoDtoList
=
getABVUIDataCache
().
getPairingBluetoothDeviceInfoList
(
Arrays
.
asList
(
DeviceType
.
centerThermomete
,
DeviceType
.
radiationThermomete
,
DeviceType
.
alcoholChecker
));
getABVUIDataCache
().
getPairingBluetoothDeviceInfoList
(
Arrays
.
asList
(
DeviceType
.
alcoholChecker
));
if
(
CollectionUtil
.
isNotEmpty
(
bluetoothPairingInfoDtoList
))
{
for
(
BluetoothPairingDeviceInfoDto
bluetoothPairingDeviceInfoDto
:
bluetoothPairingInfoDtoList
)
{
...
...
@@ -405,11 +408,12 @@ public class BlePairingSettingActivity extends ABVUIActivity {
List
<
BleListRowData
>
scanRowDataList
=
new
ArrayList
<
BleListRowData
>();
for
(
BluetoothDevice
bleDevice
:
mScanDeviceInfoList
)
{
String
labelDeviceName
=
""
;
if
(
bleDevice
.
getName
().
startsWith
(
CENTER_THERMOMETE_DEVICE_NAME
))
{
labelDeviceName
=
getString
(
R
.
string
.
center_thermometer
);
}
else
if
(
bleDevice
.
getName
().
startsWith
(
RADIATION_THERMOMETE_DEVICE_NAME
))
{
labelDeviceName
=
getString
(
R
.
string
.
radiation_thermometer
);
}
else
if
(
bleDevice
.
getName
().
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
// if (bleDevice.getName().startsWith(CENTER_THERMOMETE_DEVICE_NAME)) {
// labelDeviceName = getString(R.string.center_thermometer);
// } else if (bleDevice.getName().startsWith(RADIATION_THERMOMETE_DEVICE_NAME)) {
// labelDeviceName = getString(R.string.radiation_thermometer);
// } else
if
(
bleDevice
.
getName
().
startsWith
(
ALCOHOL_CHECKER_DEVICE_NAME
))
{
labelDeviceName
=
"アルコールチェッカー"
;
}
BleListRowData
scanRowData
=
new
BleListRowData
(
bleDevice
.
getName
(),
labelDeviceName
,
bleDevice
.
getAddress
(),
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment