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
932da70f
Commit
932da70f
authored
Jun 24, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
計測終了後にRDY状態に戻るように修正
parent
6d3a69d6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
337 additions
and
120 deletions
+337
-120
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
+12
-7
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+223
-78
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+37
-6
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+65
-29
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
View file @
932da70f
...
...
@@ -26,7 +26,7 @@ public class AlcoholCheckerTimerTask extends TimerTask {
@Override
public
void
run
()
{
alcoholCheckerUtil
.
gi_rxlength
=
0
;
//
alcoholCheckerUtil.gi_rxlength = 0;
switch
(
alcoholCheckerUtil
.
gi_status
)
{
case
F_BLE_COM_INIT:
...
...
@@ -34,18 +34,23 @@ public class AlcoholCheckerTimerTask extends TimerTask {
break
;
case
F_BLE_COM_RP_START:
// RP Command Send
Logger
.
d
(
TAG
,
"F_BLE_COM_RP_START"
);
alcoholCheckerUtil
.
sendMessage
(
F_BLE_COM_RP_COMMAND
);
//
Logger.d(TAG,"F_BLE_COM_RP_START");
//
alcoholCheckerUtil.sendMessage(F_BLE_COM_RP_COMMAND);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_RD_START
:
// RD Command Send
Logger
.
d
(
TAG
,
"F_BLE_COM_RD_START"
);
alcoholCheckerUtil
.
sendMessage
(
F_BLE_COM_RD_COMMAND
);
//
Logger.d(TAG,"F_BLE_COM_RD_START");
//
alcoholCheckerUtil.sendMessage(F_BLE_COM_RD_COMMAND);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
:
// Fc Command Send
Logger
.
d
(
TAG
,
"F_BLE_COM_FC_START"
);
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND_F11
);
//Logger.d(TAG,"F_BLE_COM_FC_START");
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_FC_START22
:
// Fc Command Send
//Logger.d(TAG,"F_BLE_COM_FC_START22");
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F22);
break
;
// case F_BLE_COM_RECONNECT1:
// // ReConecting(NOTIFICATION Disable) // @@@
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
932da70f
...
...
@@ -12,6 +12,8 @@ import java.io.UnsupportedEncodingException;
import
java.util.ArrayList
;
import
java.util.Timer
;
import
java.util.UUID
;
import
java.util.logging.Handler
;
import
java.util.logging.LogRecord
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.adf.util.StringUtil
;
...
...
@@ -72,6 +74,8 @@ public class AlcoholCheckerUtil {
public
static
final
int
F_BLE_COM_RECONNECT3
=
7
;
// ReConecting(NOTIFICATION Enable)
public
static
final
int
F_BLE_COM_FC_START
=
8
;
// FC Command Sned
public
static
final
int
F_BLE_COM_FC_WAIT
=
9
;
// FC Command Wait
public
static
final
int
F_BLE_COM_FC_START22
=
10
;
// RDYに戻す FC Command Send
public
static
final
int
F_BLE_COM_FC_WAIT22
=
11
;
// RDYに戻す FC Command Wait
// @BLE Command
public
static
final
String
F_BLE_COM_RP_COMMAND
=
"01525000A304"
;
// 01 52 50 00 A3 04 // RP 送信
...
...
@@ -157,58 +161,56 @@ public class AlcoholCheckerUtil {
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
()
{
// BLE管理
bleManagerUtil
=
new
BleManagerUtil
(
context
,
new
BleManagerUtilListener
()
{
@Override
public
void
onConnectionState
(
int
status
)
{
Logger
.
i
(
TAG
,
"onConnectionState = %s"
+
status
);
if
(
status
==
BluetoothProfile
.
STATE_CONNECTED
)
{
Log
.
d
(
TAG
,
"Connected to GATT server."
);
// ペリフェラルとの接続に成功した時点でサービスを検索する
if
(
bleManagerUtil
.
mBluetoothGatt
.
discoverServices
())
{
Logger
.
d
(
TAG
,
"Started discovering services"
);
}
else
{
Logger
.
d
(
TAG
,
"Failed to start discovering services"
);
}
isConnected
=
true
;
}
else
if
(
status
==
BluetoothProfile
.
STATE_DISCONNECTED
)
{
if
(
bleManagerUtil
.
mBluetoothGatt
==
null
)
{
return
;
}
else
{
Logger
.
i
(
TAG
,
"Disconnected from GATT server."
);
listener
.
onConnectionError
(
19
);
}
}
else
{
Logger
.
i
(
TAG
,
"UNKNOW STATE = "
+
status
);
}
// Logger.i(TAG,"-------------------------------------------------------------- = %s", status);
// Logger.i(TAG,"onConnectionState = %s", status);
// Logger.i(TAG,"-------------------------------------------------------------- = %s", status);
// if (status == BluetoothProfile.STATE_CONNECTED) {
// Log.d(TAG, "Connected to GATT server.");
//
// // ペリフェラルとの接続に成功した時点でサービスを検索する
// if (bleManagerUtil.mBluetoothGatt.discoverServices()) {
// Logger.d(TAG, "Started discovering services");
// } else {
// Logger.d(TAG, "Failed to start discovering services");
// }
// isConnected = true;
//
// } else if (status == BluetoothProfile.STATE_DISCONNECTED) {
//
// if (bleManagerUtil.mBluetoothGatt == null) {
// return;
// } else {
// Logger.i(TAG, "Disconnected from GATT server.");
// listener.onConnectionError(19);
// }
// } else {
// Logger.i(TAG,"UNKNOW STATE = " + status);
// }
}
@Override
public
void
onDisConnectionState
()
{
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
listener
.
onConnectionError
(
0
);
//isConnected = false;
//
Logger.d(TAG,"onDisConnectionState");
//
listener.onConnectionError(0);
//
//isConnected = false;
}
@Override
public
void
onConnectionError
(
int
status
)
{
Logger
.
d
(
TAG
,
"onConnectionError = %s"
,
status
);
listener
.
onConnectionError
(
status
);
//isConnected = false;
//stopAlcTimer();
//disconnect(true);
}
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
d
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"-------------------------------------------------------------- = %s"
,
status
);
Logger
.
i
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"-------------------------------------------------------------- = %s"
,
status
);
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
)
{
Logger
.
i
(
TAG
,
"BluetoothGatt.GATT_SUCCESS"
);
...
...
@@ -219,10 +221,11 @@ public class AlcoholCheckerUtil {
// Check TX and RX UUIDs
RxChar
=
TaiyoYudenService
.
getCharacteristic
(
RX_CHARACTERISTIC_UUID
);
TxChar
=
TaiyoYudenService
.
getCharacteristic
(
TX_CHARACTERISTIC_UUID
);
//Logger.i(TAG,"iiiiiiiiiiiiiiiiiiiiiii");
if
(
RxChar
==
null
||
TxChar
==
null
)
{
Logger
.
e
(
TAG
,
"No Tx/Rx"
);
}
else
{
//Logger.i(TAG,"iiiiiiiiiiiiiiiiiiiiiii");
gi_status
=
F_BLE_COM_INIT
;
gi_rxlength
=
0
;
...
...
@@ -247,9 +250,13 @@ public class AlcoholCheckerUtil {
gi_status
=
F_BLE_COM_RP_START
;
startAlcTimer
();
//startAlcTimer();
SendMessage
(
gi_status
);
listener
.
onServicesDiscovered
(
status
);
Logger
.
i
(
TAG
,
"iiiiiiiiiiiiiiiiiiiiiii"
);
}
}
}
else
{
...
...
@@ -259,7 +266,7 @@ public class AlcoholCheckerUtil {
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
d
(
TAG
,
"onCharacteristicChanged"
);
//
Logger.d(TAG,"onCharacteristicChanged");
byte
[]
rx
=
characteristic
.
getValue
();
String
rxStr
=
" "
;
...
...
@@ -270,14 +277,14 @@ public class AlcoholCheckerUtil {
}
sub_rx_chk
(
rx
);
if
(
gi_status
==
F_BLE_COM_FC_WAIT
)
{
Logger
.
d
(
TAG
,
"FC_WAIT"
);
}
//
if (gi_status == F_BLE_COM_FC_WAIT) {
//
Logger.d(TAG,"FC_WAIT");
//
}
}
@Override
public
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
)
{
Logger
.
d
(
TAG
,
"onDescriptorWrite"
);
//
Logger.d(TAG,"onDescriptorWrite");
if
(
bleManagerUtil
.
mBluetoothGatt
!=
null
)
{
if
(
bleManagerUtil
.
mBluetoothGatt
.
getService
(
TY_SERVICE_UUID
).
getCharacteristic
(
INDICATION_CHARACTERISTIC_UUID
)
==
null
)
{
Logger
.
d
(
TAG
,
"Old version"
);
...
...
@@ -287,19 +294,38 @@ public class AlcoholCheckerUtil {
}
else
{
return
;
}
gatt
=
bleManagerUtil
.
mBluetoothGatt
;
TaiyoYudenService
=
gatt
.
getService
(
TY_SERVICE_UUID
);
BatteryService
=
gatt
.
getService
(
BATTERY_SERVICE_UUID
);
NotificationChar
=
TaiyoYudenService
.
getCharacteristic
(
NOTIFICATION_CHARACTERISTIC_UUID
);
IndicationChar
=
TaiyoYudenService
.
getCharacteristic
(
INDICATION_CHARACTERISTIC_UUID
);
WriteChar
=
TaiyoYudenService
.
getCharacteristic
(
WRITE_NO_RESPONSE_CHARACTERISTIC_UUID
);
batteryLevelChar
=
BatteryService
.
getCharacteristic
(
BATTERY_LEVEL_UUID
);
connectionPHY
=
0
;
bleManagerUtil
.
readPhyConnection
();
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
NotificationChar
,
true
);
BluetoothGattDescriptor
notification_descriptor
=
NotificationChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
notification_descriptor
);
UUID
characteristic_uuid
=
descriptor
.
getCharacteristic
().
getUuid
();
if
(
characteristic_uuid
.
equals
(
NOTIFICATION_CHARACTERISTIC_UUID
)){
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
IndicationChar
,
true
);
if
(
IndicationChar
==
null
)
{
IndicationChar
=
TaiyoYudenService
.
getCharacteristic
(
INDICATION_CHARACTERISTIC_UUID
);
}
gatt
.
setCharacteristicNotification
(
IndicationChar
,
true
);
BluetoothGattDescriptor
indication_descriptor
=
IndicationChar
.
getDescriptor
(
CCCD
);
indication_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_INDICATION_VALUE
);
bleManagerUtil
.
mBluetoothG
att
.
writeDescriptor
(
indication_descriptor
);
g
att
.
writeDescriptor
(
indication_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
INDICATION_CHARACTERISTIC_UUID
)){
// Enable notification on receiving data
bleManagerUtil
.
mBluetoothG
att
.
setCharacteristicNotification
(
batteryLevelChar
,
true
);
BluetoothGattDescriptor
notification_descriptor
=
batteryLevelChar
.
getDescriptor
(
CCCD
);
g
att
.
setCharacteristicNotification
(
batteryLevelChar
,
true
);
notification_descriptor
=
batteryLevelChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
bleManagerUtil
.
mBluetoothG
att
.
writeDescriptor
(
notification_descriptor
);
g
att
.
writeDescriptor
(
notification_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
BATTERY_LEVEL_UUID
)){
Logger
.
d
(
TAG
,
"Wrote descriptor: "
+
BATTERY_LEVEL_UUID
);
}
...
...
@@ -313,6 +339,39 @@ public class AlcoholCheckerUtil {
return
true
;
}
public
int
lastSendCmd
;
public
void
SendMessage
(
final
int
statusa
)
{
// if (statusa == 1 || statusa == 3 || statusa ==8) {
// Logger.d(TAG, "SendMessage = " + statusa);
// }
// if (lastSendCmd == statusa) {
// return;
// }
lastSendCmd
=
statusa
;
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
//gi_rxlength = 0;
if
(
statusa
==
F_BLE_COM_RP_START
)
{
sendMessage
(
F_BLE_COM_RP_COMMAND
);
}
else
if
(
statusa
==
F_BLE_COM_RD_START
)
{
sendMessage
(
F_BLE_COM_RD_COMMAND
);
}
else
if
(
statusa
==
F_BLE_COM_FC_START
)
{
sendMessage
(
F_BLE_COM_FC_COMMAND_F11
);
}
else
if
(
statusa
==
F_BLE_COM_FC_START22
)
{
sendMessage
(
F_BLE_COM_FC_COMMAND_F22
);
}
}
});
thread
.
start
();
}
/**
* アルコールチェッカーを監視するタイマーを開始する
*/
...
...
@@ -370,6 +429,7 @@ public class AlcoholCheckerUtil {
@Override
public
void
run
()
{
gi_rxlength
=
0
;
final
int
PACKET_SIZE
=
20
;
BluetoothGatt
s_mBluetoothGatt
;
// @@@
String
error_msg
=
""
;
...
...
@@ -411,28 +471,35 @@ public class AlcoholCheckerUtil {
}
Logger
.
i
(
TAG
,
"Tx:"
+
message
);
if
(
message
.
equals
(
"01464301F27D04"
))
{
Logger
.
d
(
TAG
,
"aaaaaaaaaaa"
);
}
// @Mode Change
switch
(
gi_status
)
{
case
F_BLE_COM_RP_START:
//listener.onUpdateStatus("sendMessage = F_BLE_COM_RP_WAIT");
gi_status
=
F_BLE_COM_RP_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_RP_WAIT:"
+
gi_status
);
break
;
case
F_BLE_COM_RD_START:
//listener.onUpdateStatus("sendMessage = F_BLE_COM_RD_WAIT");
gi_status
=
F_BLE_COM_RD_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_RD_WAIT:"
+
gi_status
);
break
;
case
F_BLE_COM_FC_START:
//listener.onUpdateStatus("sendMessage = F_BLE_COM_FC_WAIT");
gi_status
=
F_BLE_COM_FC_WAIT
;
Logger
.
d
(
TAG
,
"F_BLE_COM_FC_WAIT:"
+
gi_status
);
break
;
case
F_BLE_COM_FC_START22:
gi_status
=
F_BLE_COM_FC_WAIT22
;
Logger
.
d
(
TAG
,
"F_BLE_COM_FC_WAIT22:"
+
gi_status
);
break
;
default
:
// None
break
;
}
//SendMessage(gi_status);
}
catch
(
UnsupportedEncodingException
e
)
{
Logger
.
w
(
TAG
,
e
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -528,7 +595,8 @@ public class AlcoholCheckerUtil {
sub_rx_data_gen
(
rxdata
);
// Mode
Logger
.
i
(
TAG
,
"sub_rx_chk gi_status = "
+
gi_status
);
int
gi
=
gi_status
;
//Logger.i(TAG,"sub_rx_chk gi_status = " + gi_status);
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
// BLE Init
...
...
@@ -544,16 +612,27 @@ public class AlcoholCheckerUtil {
case
F_BLE_COM_FC_WAIT:
gi_status
=
fn_rx_fc_chk
(
rxdata
);
break
;
case
F_BLE_COM_FC_WAIT22:
gi_status
=
fn_rx_fc_chk2
(
rxdata
);
break
;
default
:
// Others(Include Error)
gi_status
=
F_BLE_COM_RP_START
;
break
;
}
//if (gi!=gi_status)
{
SendMessage
(
gi_status
);
}
}
catch
(
IndexOutOfBoundsException
e
)
{
Logger
.
e
(
TAG
,
e
);
}
}
public
void
SendResponse
()
{
}
/* @Read Flame Generation */
private
void
sub_rx_data_gen
(
byte
[]
rxdata
)
{
int
si_length
;
...
...
@@ -578,14 +657,26 @@ public class AlcoholCheckerUtil {
/* @RP Command Check */
private
int
fn_rx_rp_chk
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_rp_chk"
);
int
si_ret
;
byte
sb_mode
;
for
(
byte
b:
rxdata
)
{
Logger
.
d
(
TAG
,
"%s, "
,
Byte
.
toString
(
b
));
}
si_ret
=
F_BLE_COM_RP_WAIT
;
// 01 72 70 02
//
boolean
go
=
false
;
if
(
rxdata
[
0
]
==
2
&&
rxdata
[
1
]
==
14
&&
rxdata
[
2
]
==
-
11
&&
rxdata
[
3
]
==
4
)
{
go
=
true
;
}
// Command Check
Logger
.
d
(
TAG
,
"RP_RENGTH="
+
gi_rxlength
);
if
(
gi_rxlength
==
F_RX_RP_LENGTH
)
{
if
(
gi_rxlength
==
F_RX_RP_LENGTH
||
go
)
{
if
((
gb_rxdat
[
F_RX_COMMAND_POS
]
==
F_RP_COMMAND_MSB
)
&&
(
gb_rxdat
[(
F_RX_COMMAND_POS
+
1
)]
==
F_RP_COMMAND_LSB
))
{
sb_mode
=
gb_rxdat
[
F_RX_RP_MODE_POS
];
switch
(
sb_mode
)
{
...
...
@@ -627,6 +718,7 @@ public class AlcoholCheckerUtil {
// リザルトが出たら、FCでRDYに戻す
// si_ret = F_BLE_COM_FC_START;
break
;
case
(
byte
)
0x0D
:
// Wait
...
...
@@ -714,20 +806,59 @@ public class AlcoholCheckerUtil {
return
si_ret
;
}
private
int
fn_rx_fc_chk2
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_fc_chk2"
);
int
si_ret
=
F_BLE_COM_FC_WAIT22
;
if
(
fcWaitMode
==
0
)
{
if
(
rxdata
[
0
]
==
1
&&
rxdata
[
1
]
==
102
&&
rxdata
[
2
]
==
99
&&
rxdata
[
3
]
==
3
)
{
fcWaitMode
=
1
;
}
}
else
if
(
fcWaitMode
==
1
)
{
if
(
rxdata
.
length
==
5
)
{
// 49 05 32 35 4
// 0x31 05 20 23 4 実行完了 本体動作モード リアルタイム測定進行状況 チェックサム 4
if
(
rxdata
[
0
]
==
49
&&
rxdata
[
1
]
==
2
)
{
Logger
.
i
(
TAG
,
"------FC2成功"
);
si_ret
=
F_BLE_COM_RP_START
;
}
//if (rxdata[1] == 0x05)
listener
.
onGetDeviceInfo
(
alcol
);
// if (StringUtil.isNullOrEmpty(alcol)) {
// // 空文字の時は BLEに戻す
// si_ret = F_BLE_COM_FC_START;
// } else {
// if (status == F_BLE_COM_FC_WAIT22) {
// // RDY戻し待ちの場合は
// //si_ret = F_BLE_COM_FC_START22;
// si_ret = F_BLE_COM_RP_START;
// } else {
// //si_ret = F_BLE_COM_FC_START22;
// }
// si_ret = F_BLE_COM_RP_START;
// }
fcWaitMode
=
0
;
//si_ret = F_BLE_COM_FC_START22;
//SendMessage(si_ret);
//listener.onGetDeviceInfo(alcol);
}
}
return
si_ret
;
}
private
int
fn_rx_fc_chk
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_fc_chk"
);
int
si_ret
=
F_BLE_COM_FC_WAIT
;
byte
sb_data
;
short
ss_data
;
String
str_msg
=
""
;
//str_msg = hex2string(rxdata);
byte
[]
res
=
hex2string
(
rxdata
);
for
(
byte
b:
rxdata
)
{
//str_msg += Byte.toString(b);
Logger
.
d
(
TAG
,
"%s, "
+
Byte
.
toString
(
b
));
Logger
.
d
(
TAG
,
"%s, "
,
Byte
.
toString
(
b
));
}
//Logger.i(TAG, "fn_rx_fc_chk = " + str_msg);
// 01 72 70 02 rp 上位
// 01 114 112 02
...
...
@@ -740,27 +871,39 @@ public class AlcoholCheckerUtil {
//
if
(
fcWaitMode
==
0
)
{
if
(
rxdata
[
0
]
==
1
&&
rxdata
[
1
]
==
102
&&
rxdata
[
2
]
==
99
&&
rxdata
[
3
]
==
3
)
{
//Logger.i(TAG, "fc--------------------");
fcWaitMode
=
1
;
}
}
else
if
(
fcWaitMode
==
1
)
{
if
(
rxdata
.
length
==
5
)
{
// 0x31 49
// 2 2
// E 14
// E 14 チェックサム
// 4 4
if
(
rxdata
[
0
]
!=
0x31
)
{
// 49 05 32 35 4
// 0x31 05 20 23 4 実行完了 本体動作モード リアルタイム測定進行状況 チェックサム 4
if
(
rxdata
[
0
]
==
49
&&
rxdata
[
1
]
==
2
)
{
//Logger.i(TAG, "------FC失敗");
//si_ret = F_BLE_COM_RP_START;
//return si_ret;
}
//Logger.i(TAG, "fc=" + fcWaitMode);
listener
.
onGetDeviceInfo
(
alcol
);
if
(
StringUtil
.
isNullOrEmpty
(
alcol
))
{
si_ret
=
F_BLE_COM_FC_START
;
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
//listener.onGetDeviceInfo(alcol);
// if (StringUtil.isNullOrEmpty(alcol)) {
// // 空文字の時は BLEに戻す
// si_ret = F_BLE_COM_FC_START;
// //} else {
//// if (status == F_BLE_COM_FC_WAIT22) {
//// // RDY戻し待ちの場合は
//// //si_ret = F_BLE_COM_FC_START22;
//// si_ret = F_BLE_COM_RP_START;
//// } else {
//// //si_ret = F_BLE_COM_FC_START22;
//// }
// //si_ret = F_BLE_COM_RP_START;
// }
fcWaitMode
=
0
;
//si_ret = F_BLE_COM_FC_START22;
//SendMessage(si_ret);
//listener.onGetDeviceInfo(alcol);
}
}
return
si_ret
;
...
...
@@ -770,6 +913,7 @@ public class AlcoholCheckerUtil {
/* @RD Command Check */
private
int
fn_rx_rd_chk
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_rd_chk"
);
int
si_ret
;
byte
sb_data
;
short
ss_data
;
...
...
@@ -778,7 +922,9 @@ public class AlcoholCheckerUtil {
si_ret
=
F_BLE_COM_RD_WAIT
;
// Command Check
Logger
.
d
(
TAG
,
"RD_LENGTH="
+
gi_rxlength
);
if
(
gi_rxlength
==
F_RX_RD_LENGTH
)
{
// 0x72, 0x64
if
((
gb_rxdat
[
F_RX_COMMAND_POS
]
==
F_RD_COMMAND_MSB
)
&&
(
gb_rxdat
[(
F_RX_COMMAND_POS
+
1
)]
==
F_RD_COMMAND_LSB
))
{
sb_data
=
gb_rxdat
[
F_RX_RD_DATA_POS
];
str_msg
=
""
;
...
...
@@ -799,13 +945,12 @@ public class AlcoholCheckerUtil {
str_msg
+=
String
.
format
(
"%1$02d"
,
ss_data
);
}
Logger
.
d
(
TAG
,
"測定結果表示"
);
//str_msg += "[mg/L]";
//listener.onUpdateTBVCalc(str_msg + " 0x0C 測定結果表示状態");
//listener.onGetDeviceInfo(str_msg);
// 0x0C 測定結果表示状態");
alcol
=
str_msg
;
si_ret
=
F_BLE_COM_FC_START
;
//alcoholCheckerUtil.
//sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
si_ret
=
F_BLE_COM_FC_START22
;
return
si_ret
;
}
else
{
// Error
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
932da70f
...
...
@@ -12,6 +12,7 @@ import android.bluetooth.BluetoothProfile;
import
android.bluetooth.le.ScanCallback
;
import
android.bluetooth.le.ScanResult
;
import
android.content.Context
;
import
android.graphics.RenderNode
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Looper
;
...
...
@@ -59,7 +60,9 @@ public class BleManagerUtil {
@Override
public
void
onConnectionStateChange
(
BluetoothGatt
gatt
,
final
int
status
,
final
int
newState
)
{
Logger
.
i
(
"onConnectionStateChange status = "
+
status
+
" newState = "
+
newState
);
if
(
newState
==
BluetoothProfile
.
STATE_CONNECTED
)
{
gatt
.
discoverServices
();
}
// デバイスと接続されていない場合のメッセージコード:133, 62
// デバイスと離れて応答がなく、タイムアウトになる場合:8
// デバイスと接続が切れた場合のメッセージコード:19
...
...
@@ -73,6 +76,13 @@ public class BleManagerUtil {
Logger
.
e
(
TAG
,
"onConnectionStateChange status = "
+
status
);
}
});
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// //mBluetoothGatt = device.connectGatt(mContext, false, mGattcallback, TRANSPORT_LE);
// bleGattReconnect();
// }
// });
return
;
}
...
...
@@ -116,40 +126,61 @@ public class BleManagerUtil {
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
@Override
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
final
int
status
)
{
Logger
.
i
(
TAG
,
"onServicesDiscovered status = %s"
,
status
);
try
{
Logger
.
i
(
TAG
,
"onServicesDiscovered status = %s"
,
status
);
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
return
;
}
mBluetoothGatt
.
requestConnectionPriority
(
BluetoothGatt
.
CONNECTION_PRIORITY_HIGH
);
if
(
mListener
!=
null
)
{
// アルコールチェッカー
mListener
.
onServicesDiscovered
(
status
);
}
}
catch
(
Exception
e
)
{
Logger
.
d
(
TAG
,
e
);
}
}
// キャラクタリスティックが読み込まれたときの処理
@Override
public
void
onCharacteristicRead
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
,
int
status
)
{
try
{
Logger
.
d
(
TAG
,
"onCharacteristicRead"
);
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
return
;
}
}
catch
(
Exception
e
)
{
Logger
.
d
(
TAG
,
"null"
);
}
}
// キャラクタリスティック変更が通知されたときの処理
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
d
(
TAG
,
"onCharacteristicChanged"
);
if
(
mListener
!=
null
)
{
try
{
//if (mListener != null)
{
mListener
.
onCharacteristicChanged
(
gatt
,
characteristic
);
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
}
}
@Override
public
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
){
Logger
.
d
(
TAG
,
"onDescriptorWrite"
);
try
{
mListener
.
onDescriptorWrite
(
gatt
,
descriptor
,
status
);
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
}
}
};
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
932da70f
...
...
@@ -187,6 +187,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 二重起動防止フラグ(アルコールチェッカー)
private
boolean
isAlcBlock
=
false
;
// 終了フラグ
private
boolean
isFinish
=
false
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -280,9 +282,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
else
{
return
;
}
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
//
runOnUiThread(new Runnable() {
//
@Override
//
public void run() {
if
(
mWaitingDialog
!=
null
)
{
mWaitingDialog
.
dismiss
();
mWaitingDialog
=
null
;
...
...
@@ -290,18 +292,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
alcoholCheckerUtil
.
isConnected
=
true
;
// 測定開始ボタン押し待ち
showWaitMeasureDialog
(
getString
(
R
.
string
.
alcohol_checker
),
getString
(
R
.
string
.
connection_completed
));
}
});
//
}
//
});
}
@Override
public
void
onGetDeviceInfo
(
String
alcohol
)
{
public
void
onGetDeviceInfo
(
final
String
alcohol
)
{
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
Logger
.
d
(
TAG
,
"測定完了 = "
+
alcohol
);
if
(!
alcohol
.
equals
(
""
))
{
successAfterAbookCheckApi
(
alcohol
,
false
);
}
else
{
}
// }
// });
}
@Override
...
...
@@ -312,16 +319,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
else
{
return
;
}
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
//
runOnUiThread(new Runnable() {
//
@Override
//
public void run() {
if
(
mWaitMeasureDialog
!=
null
)
{
mWaitMeasureDialog
.
dismiss
();
mWaitMeasureDialog
=
null
;
}
showMeasureDialog
(
getString
(
R
.
string
.
alcohol_checker
),
getString
(
R
.
string
.
wait_breathe
));
}
});
//
}
//
});
}
@Override
...
...
@@ -399,7 +406,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* 各デバイスから値を正常に取得された場合、HTML側にコールする
* @param value 各種デバイスから取得した値
*/
private
void
successAfterAbookCheckApi
(
final
String
value
,
final
boolean
isFinish
)
{
private
void
successAfterAbookCheckApi
(
final
String
value
,
boolean
isFinish
)
{
this
.
isFinish
=
isFinish
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -407,7 +415,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
JSONObject
responseJson
=
new
JSONObject
();
responseJson
.
put
(
ABookKeys
.
TASK_QUESTION_ID
,
mQid
);
responseJson
.
put
(
"value"
,
value
);
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND_F11
);
// alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F22);
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START22;
afterABookCheckApi
(
mCmd
,
""
,
0
,
""
,
responseJson
.
toString
());
Logger
.
i
(
TAG
,
"successAfterAbookCheckAip JSON [%s]"
,
responseJson
.
toString
());
}
...
...
@@ -419,11 +429,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param errorMessage 各種デバイスから取得した値
*/
private
void
errorAfterAbookCheckApi
(
final
String
errorMessage
)
{
// エラーの時は終了
isFinish
=
true
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dismissAllDialog
();
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND_F11
);
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
afterABookCheckApi
(
mCmd
,
""
,
1
,
errorMessage
,
null
);
Logger
.
e
(
TAG
,
errorMessage
);
}
...
...
@@ -444,6 +457,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting Dialog stop click"
);
successAfterAbookCheckApi
(
""
,
true
);
//errorAfterAbookCheckApi("");
}
});
mWaitingDialog
.
show
();
...
...
@@ -462,7 +476,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting mWaitMeasureDialog stop clickf"
);
successAfterAbookCheckApi
(
""
,
true
);
successAfterAbookCheckApi
(
""
,
false
);
//errorAfterAbookCheckApi("");
}
});
mWaitMeasureDialog
.
show
();
...
...
@@ -481,7 +496,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"wait mMeasureDialog stop click"
);
successAfterAbookCheckApi
(
""
,
true
);
successAfterAbookCheckApi
(
""
,
false
);
//errorAfterAbookCheckApi("");
}
});
mMeasureDialog
.
show
();
...
...
@@ -627,12 +643,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// タイマーにFCコマンド
if
(
alcoholCheckerUtil
!=
null
)
{
isAlcBlock
=
false
;
// false にしないと2回目押せない
alcoholCheckerUtil
.
gi_status
=
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
;
//
alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
// チェッカーも終了
alcoholCheckerUtil
.
finish
();
//
alcoholCheckerUtil.finish();
}
},
1000
);
...
...
@@ -644,7 +660,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"onDestroy"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
//Logger.d(TAG, "onDestroy");
if
(
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
endContentReadLog
(
contentId
);
...
...
@@ -1372,12 +1387,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mCmd
,
mTaskKey
,
mEnableReportHistory
,
abookCheckParam
,
mOperationId
,
mContentPath
,
getContentId
(),
operationDto
.
reportType
,
finishCallback
,
taskReportLevel
);
//
if (StringUtil.equalsAny(mCmd,ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT,
//
ABookKeys.CMD_DELETE_TASK_REPORT , ABookKeys.CMD_CANCEL_TASK_REPORT, ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT)
//
){
//
// 作業一覧に戻る時,bluetoothを切断する。
//
disconnectBluetoothDevice();
//
}
if
(
StringUtil
.
equalsAny
(
mCmd
,
ABookKeys
.
CMD_INSERT_TASK_REPORT
,
ABookKeys
.
CMD_UPDATE_TASK_REPORT
,
ABookKeys
.
CMD_DELETE_TASK_REPORT
,
ABookKeys
.
CMD_CANCEL_TASK_REPORT
,
ABookKeys
.
CMD_LOCAL_SAVE_TASK_REPORT
)
){
// 作業一覧に戻る時,bluetoothを切断する。
//
disconnectBluetoothDevice();
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
"doABookCheckParam error"
,
e
);
...
...
@@ -1683,13 +1698,25 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
webViewLoadUrl
(
String
.
format
(
"javascript:%sCHK.afterABookCheckApi('%s', '%s', '%s', '%s')"
,
finalParent
,
cmd
,
taskKey
,
result
,
message
));
}
if
(
cmd
.
equals
(
ABookKeys
.
CMD_GET_DEVICE_INFO
))
{
if
(
alcoholCheckerUtil
!=
null
)
{
alcoholCheckerUtil
.
finish
();
alcoholCheckerUtil
=
null
;
}
// アルコールチェッカー終了
isAlcBlock
=
false
;
// if (alcoholCheckerUtil != null) {
// if (!isFinish) {
// alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START22;
// } else {
// alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START;
// }
// }
}
// if (cmd.equals(ABookKeys.CMD_GET_DEVICE_INFO)) {
//// if (alcoholCheckerUtil != null) {
//// alcoholCheckerUtil.finish();
//// alcoholCheckerUtil = null;
//// }
// // アルコールチェッカー終了
// isAlcBlock = false;
// }
}
});
}
...
...
@@ -1941,4 +1968,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
this
.
mPhotoEditDialog
.
show
();
}
}
private
void
disconnectBluetoothDevice
()
{
Logger
.
d
(
TAG
,
"disconnectBluetoothDevice"
);
// if (alcoholCheckerUtil != null) {
// alcoholCheckerUtil.finish();
// alcoholCheckerUtil = null;
// }
}
}
\ No newline at end of file
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