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
25e12974
Commit
25e12974
authored
Jun 28, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
まだ2回目が計測できない
parent
932da70f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
185 additions
and
303 deletions
+185
-303
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
+0
-84
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+105
-145
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+13
-8
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+67
-66
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
deleted
100644 → 0
View file @
932da70f
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
java.util.TimerTask
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_INIT
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RD_COMMAND
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RECONNECT1
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RECONNECT2
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RECONNECT3
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RP_COMMAND
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
F_BLE_COM_RP_START
;
public
class
AlcoholCheckerTimerTask
extends
TimerTask
{
public
static
final
String
TAG
=
"AlcoholCheckerTimerTask"
;
private
AlcoholCheckerUtil
alcoholCheckerUtil
;
private
AlcoholCheckerUtilListener
listener
;
public
AlcoholCheckerTimerTask
(
AlcoholCheckerUtil
alcoholCheckerUtil
,
AlcoholCheckerUtilListener
listener
)
{
this
.
alcoholCheckerUtil
=
alcoholCheckerUtil
;
this
.
listener
=
listener
;
}
@Override
public
void
run
()
{
//alcoholCheckerUtil.gi_rxlength = 0;
switch
(
alcoholCheckerUtil
.
gi_status
)
{
case
F_BLE_COM_INIT:
// BLE Init
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);
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);
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);
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) // @@@
// alcoholCheckerUtil.NotificationDisable(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT2;
// listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT2");
// break;
// case F_BLE_COM_RECONNECT2:
// // ReConecting(Wait) // @@@
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT3;
// listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT3");
// break;
// case F_BLE_COM_RECONNECT3:
// // ReConecting(NOTIFICATION Enable) // @@@
// alcoholCheckerUtil.DescriptorDevice(AlcoholCheckerUtil.RxChar, AlcoholCheckerUtil.CCCD);
// alcoholCheckerUtil.gi_status = F_BLE_COM_RP_START;
// listener.onUpdateStatus("TIMER F_BLE_COM_RP_START");
// break;
default
:
// Logger.i(TAG,"AlcohlCheckerTimerTask Timeout");
//
// if (alcoholCheckerUtil.gi_rxretry_cnt < 100) {
// alcoholCheckerUtil.gi_rxretry_cnt++;
// } else {
// alcoholCheckerUtil.gi_status = F_BLE_COM_RECONNECT1;
// //listener.onUpdateStatus("TIMER F_BLE_COM_RECONNECT1");
// }
break
;
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
25e12974
...
...
@@ -4,16 +4,11 @@ import android.bluetooth.BluetoothGatt;
import
android.bluetooth.BluetoothGattCharacteristic
;
import
android.bluetooth.BluetoothGattDescriptor
;
import
android.bluetooth.BluetoothGattService
;
import
android.bluetooth.BluetoothProfile
;
import
android.content.Context
;
import
android.util.Log
;
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
;
...
...
@@ -136,16 +131,21 @@ public class AlcoholCheckerUtil {
public
BleManagerUtil
bleManagerUtil
;
private
AlcoholCheckerUtilListener
listener
;
// @Timer
private
AlcoholCheckerTimerTask
alcoholCheckerTimerTask
=
null
;
public
boolean
isConnected
=
false
;
//private AlcoholCheckerTimerTask alcoholCheckerTimerTask = null;
public
static
boolean
isConnected
=
false
;
// アルコール濃度
private
String
strAlcoholValue
=
""
;
// ステータス
public
static
final
int
fugo_wait_connect
=
0
;
public
static
final
int
fugo_conntected
=
1
;
public
static
final
int
fugo_wait_go
=
2
;
public
static
final
int
fugo_fu_error
=
3
;
public
static
final
int
fugo_restart
=
4
;
public
int
alcStatus
=
0
;
public
static
final
int
fugo_init
=
0
;
public
static
final
int
fugo_wait_connect
=
1
;
public
static
final
int
fugo_conntected
=
2
;
public
static
final
int
fugo_wait_go
=
3
;
public
static
final
int
fugo_fu_error
=
4
;
public
static
final
int
fugo_restart
=
5
;
//public int alcStatus = 0;
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
...
...
@@ -155,7 +155,6 @@ public class AlcoholCheckerUtil {
public
void
finish
()
{
isConnected
=
false
;
stopAlcTimer
();
disconnect
(
true
);
}
...
...
@@ -208,9 +207,9 @@ public class AlcoholCheckerUtil {
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
i
(
TAG
,
"-------------------------------------------------------------- = %s"
,
status
);
//
Logger.i(TAG,"-------------------------------------------------------------- = %s", status);
Logger
.
i
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"-------------------------------------------------------------- = %s"
,
status
);
//
Logger.i(TAG,"-------------------------------------------------------------- = %s", status);
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
)
{
Logger
.
i
(
TAG
,
"BluetoothGatt.GATT_SUCCESS"
);
...
...
@@ -252,11 +251,11 @@ public class AlcoholCheckerUtil {
//startAlcTimer();
SendMessage
(
gi_status
);
SendMessage
FromApp
(
gi_status
);
listener
.
onServicesDiscovered
(
status
);
Logger
.
i
(
TAG
,
"iiiiiiiiiiiiiiiiiiiiiii"
);
//
Logger.i(TAG,"iiiiiiiiiiiiiiiiiiiiiii");
}
}
}
else
{
...
...
@@ -276,10 +275,6 @@ public class AlcoholCheckerUtil {
}
}
sub_rx_chk
(
rx
);
// if (gi_status == F_BLE_COM_FC_WAIT) {
// Logger.d(TAG,"FC_WAIT");
// }
}
@Override
...
...
@@ -339,16 +334,16 @@ public class AlcoholCheckerUtil {
return
true
;
}
public
int
lastSendCmd
;
//
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
;
public
void
SendMessage
FromApp
(
final
int
giStatus
)
{
if
(
giStatus
==
F_BLE_COM_RP_START
||
giStatus
==
F_BLE_COM_RD_START
||
giStatus
==
F_BLE_COM_FC_START
||
giStatus
==
F_BLE_COM_FC_START22
)
{
Logger
.
d
(
TAG
,
"giStatus = "
+
giStatus
);
}
else
{
Logger
.
w
(
TAG
,
"UNKOWN COMMAND"
);
}
//lastSendCmd = giStatus
;
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -357,14 +352,14 @@ public class AlcoholCheckerUtil {
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
//gi_rxlength = 0;
if
(
statusa
==
F_BLE_COM_RP_START
)
{
if
(
giStatus
==
F_BLE_COM_RP_START
)
{
sendMessage
(
F_BLE_COM_RP_COMMAND
);
}
else
if
(
statusa
==
F_BLE_COM_RD_START
)
{
}
else
if
(
giStatus
==
F_BLE_COM_RD_START
)
{
sendMessage
(
F_BLE_COM_RD_COMMAND
);
}
else
if
(
statusa
==
F_BLE_COM_FC_START
)
{
}
else
if
(
giStatus
==
F_BLE_COM_FC_START
)
{
sendMessage
(
F_BLE_COM_FC_COMMAND_F11
);
}
else
if
(
statusa
==
F_BLE_COM_FC_START22
)
{
}
else
if
(
giStatus
==
F_BLE_COM_FC_START22
)
{
sendMessage
(
F_BLE_COM_FC_COMMAND_F22
);
}
}
...
...
@@ -372,29 +367,6 @@ public class AlcoholCheckerUtil {
thread
.
start
();
}
/**
* アルコールチェッカーを監視するタイマーを開始する
*/
public
void
startAlcTimer
()
{
if
(
alcoholCheckerTimerTask
!=
null
)
{
alcoholCheckerTimerTask
.
cancel
();
alcoholCheckerTimerTask
=
null
;
}
alcoholCheckerTimerTask
=
new
AlcoholCheckerTimerTask
(
this
,
listener
);
Timer
timer
=
new
Timer
(
true
);
timer
.
schedule
(
alcoholCheckerTimerTask
,
0
,
500
);
}
/**
* タイマー停止
*/
public
void
stopAlcTimer
()
{
if
(
alcoholCheckerTimerTask
!=
null
)
{
alcoholCheckerTimerTask
.
cancel
();
alcoholCheckerTimerTask
=
null
;
}
}
public
void
connect
(
int
connectTargetDeviceType
,
String
deviceAddress
)
{
bleManagerUtil
.
connect
(
connectTargetDeviceType
,
deviceAddress
);
}
...
...
@@ -471,10 +443,6 @@ 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:
...
...
@@ -498,8 +466,6 @@ public class AlcoholCheckerUtil {
break
;
}
//SendMessage(gi_status);
}
catch
(
UnsupportedEncodingException
e
)
{
Logger
.
w
(
TAG
,
e
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -595,8 +561,7 @@ public class AlcoholCheckerUtil {
sub_rx_data_gen
(
rxdata
);
// Mode
int
gi
=
gi_status
;
//Logger.i(TAG,"sub_rx_chk gi_status = " + gi_status);
int
oldgiStatus
=
gi_status
;
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
// BLE Init
...
...
@@ -620,9 +585,13 @@ public class AlcoholCheckerUtil {
gi_status
=
F_BLE_COM_RP_START
;
break
;
}
//if (gi!=gi_status)
{
SendMessage
(
gi_status
);
if
(
oldgiStatus
==
F_BLE_COM_RP_WAIT
&&
gi_status
==
F_BLE_COM_FC_WAIT
&&
fcWaitMode
==
1
)
{
return
;
}
if
(
oldgiStatus
!=
gi_status
)
{
Logger
.
i
(
TAG
,
"chageStatus:"
+
gi_status
);
SendMessageFromApp
(
gi_status
);
}
}
catch
(
IndexOutOfBoundsException
e
)
{
Logger
.
e
(
TAG
,
e
);
...
...
@@ -669,10 +638,17 @@ public class AlcoholCheckerUtil {
// 01 72 70 02
//
// 01 72 70 02
//
boolean
go
=
false
;
if
(
rxdata
[
0
]
==
2
&&
rxdata
[
1
]
==
14
&&
rxdata
[
2
]
==
-
11
&&
rxdata
[
3
]
==
4
)
{
go
=
true
;
}
if
(
rxdata
[
0
]
==
1
&&
rxdata
[
1
]
==
102
&&
rxdata
[
2
]
==
99
&&
rxdata
[
3
]
==
3
)
{
// nor rp FC command
fcWaitMode
=
1
;
return
si_ret
=
F_BLE_COM_FC_WAIT
;
}
// Command Check
Logger
.
d
(
TAG
,
"RP_RENGTH="
+
gi_rxlength
);
...
...
@@ -715,10 +691,6 @@ public class AlcoholCheckerUtil {
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
// リザルトが出たら、FCでRDYに戻す
// si_ret = F_BLE_COM_FC_START;
break
;
case
(
byte
)
0x0D
:
// Wait
...
...
@@ -806,111 +778,85 @@ public class AlcoholCheckerUtil {
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
;
for
(
byte
b:
rxdata
)
{
Logger
.
d
(
TAG
,
"%s, "
,
Byte
.
toString
(
b
));
}
private
int
fn_rx_fc_chk2
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_fc_chk2"
);
int
si_ret
=
F_BLE_COM_FC_WAIT22
;
// 01 72 70 02 rp 上位
// 01 114 112 02
// 2 14 -11 4 rp 下部
// 2 E F5 4
// 動作モード、進行状況、チェックサム
// 01 102 99 3 fc
//
if
(
fcWaitMode
==
0
)
{
if
(
rxdata
[
0
]
==
1
&&
rxdata
[
1
]
==
102
&&
rxdata
[
2
]
==
99
&&
rxdata
[
3
]
==
3
)
{
fcWaitMode
=
1
;
}
if
(
rxdata
[
0
]
==
1
&&
rxdata
[
1
]
==
114
&&
rxdata
[
2
]
==
112
&&
rxdata
[
3
]
==
2
)
{
si_ret
=
F_BLE_COM_RP_WAIT
;
return
si_ret
;
}
}
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
[
0
]
==
49
&&
rxdata
[
1
]
==
2
)
{
//Logger.i(TAG, "------FC失敗");
}
//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;
// }
if
(!
StringUtil
.
isNullOrEmpty
(
strAlcoholValue
))
{
// 測定値あれば成功
listener
.
onGetDeviceInfo
(
strAlcoholValue
);
}
fcWaitMode
=
0
;
//si_ret = F_BLE_COM_FC_START22;
//SendMessage(si_ret);
//listener.onGetDeviceInfo(alcol);
si_ret
=
F_BLE_COM_RP_START
;
}
}
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
;
private
int
fn_rx_fc_chk2
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_fc_chk2"
);
for
(
byte
b:
rxdata
)
{
Logger
.
d
(
TAG
,
"%s, "
,
Byte
.
toString
(
b
));
}
// 01 72 70 02 rp 上位
// 01 114 112 02
// 2 14 -11 4 rp 下部
// 2 E F5 4
// 動作モード、進行状況、チェックサム
// 01 102 99 3 fc
//
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
)
{
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, "------FC失敗");
//si_ret = F_BLE_COM_RP_START;
//return si_ret;
}
//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
;
if
(
rxdata
[
0
]
==
49
&&
rxdata
[
1
]
==
2
)
{
Logger
.
i
(
TAG
,
"RDYに戻る"
);
si_ret
=
F_BLE_COM_RP_START
;
}
//si_ret = F_BLE_COM_FC_START22;
//SendMessage(si_ret);
//listener.onGetDeviceInfo(alcol);
if
(!
StringUtil
.
isNullOrEmpty
(
strAlcoholValue
))
{
// 測定値あれば成功
listener
.
onGetDeviceInfo
(
strAlcoholValue
);
}
fcWaitMode
=
0
;
si_ret
=
F_BLE_COM_RP_START
;
}
}
}
return
si_ret
;
}
private
String
alcol
=
""
;
/* @RD Command Check */
private
int
fn_rx_rd_chk
(
byte
[]
rxdata
)
{
Logger
.
d
(
TAG
,
"fn_rx_rd_chk"
);
...
...
@@ -920,10 +866,23 @@ public class AlcoholCheckerUtil {
String
str_msg
;
si_ret
=
F_BLE_COM_RD_WAIT
;
for
(
byte
b:
rxdata
)
{
Logger
.
d
(
TAG
,
"%s, "
,
Byte
.
toString
(
b
));
}
// 1 114 100 22
// 0x01 0x72 0x64, 0x16
// 1, 114, 100, 22, -1, -1, 0, -1, -1, 5, 3, 74, -1, -1, -1, -1, -1, -1, 45, 4
// 1, 114, 100, 22, -1, -1, 0, 5, 3, 75, -1, -1, -1, -1, -1, -1, 46 4
boolean
go
=
false
;
if
(
gi_rxlength
>=
24
&&
rxdata
[
rxdata
.
length
-
1
]
==
4
)
{
go
=
true
;
}
// Command Check
Logger
.
d
(
TAG
,
"RD_LENGTH="
+
gi_rxlength
);
if
(
gi_rxlength
==
F_RX_RD_LENGTH
)
{
if
(
gi_rxlength
==
F_RX_RD_LENGTH
||
go
)
{
// 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
];
...
...
@@ -948,7 +907,7 @@ public class AlcoholCheckerUtil {
Logger
.
d
(
TAG
,
"測定結果表示"
);
//str_msg += "[mg/L]";
// 0x0C 測定結果表示状態");
alcol
=
str_msg
;
strAlcoholValue
=
str_msg
;
si_ret
=
F_BLE_COM_FC_START22
;
return
si_ret
;
...
...
@@ -958,8 +917,9 @@ public class AlcoholCheckerUtil {
si_ret
=
F_BLE_COM_RP_START
;
}
}
else
{
Logger
.
e
(
TAG
,
"RD Error"
);
si_ret
=
F_BLE_COM_RP_START
;
//Logger.e(TAG,"RD Error");
//si_ret = F_BLE_COM_RP_START;
// 失敗の場合もエラーに戻す
}
}
else
{
if
(
gi_rxlength
<
F_RX_RD_LENGTH
)
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
25e12974
...
...
@@ -161,16 +161,21 @@ public class BleManagerUtil {
// キャラクタリスティック変更が通知されたときの処理
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
public
void
onCharacteristicChanged
(
final
BluetoothGatt
gatt
,
final
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
d
(
TAG
,
"onCharacteristicChanged"
);
try
{
//if (mListener != null)
{
mListener
.
onCharacteristicChanged
(
gatt
,
characteristic
);
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
}
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// try {
// if (mListener != null) {
// mListener.onCharacteristicChanged(gatt, characteristic);
// }
// } catch (Exception e) {
// Logger.e(TAG,e);
// }
// }
// });
}
@Override
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
25e12974
...
...
@@ -188,7 +188,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 二重起動防止フラグ(アルコールチェッカー)
private
boolean
isAlcBlock
=
false
;
// 終了フラグ
private
boolean
isFinish
=
false
;
//private boolean isFinish = false;
private
int
checkerStatus
=
AlcoholCheckerUtil
.
fugo_init
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -277,58 +279,59 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
d
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
if
(
alcoholCheckerUtil
.
alcStatus
==
AlcoholCheckerUtil
.
fugo_wait_connect
)
{
alcoholCheckerUtil
.
alcStatus
=
AlcoholCheckerUtil
.
fugo_conntected
;
if
(
checkerStatus
==
AlcoholCheckerUtil
.
fugo_wait_connect
)
{
checkerStatus
=
AlcoholCheckerUtil
.
fugo_conntected
;
}
else
{
return
;
}
//
runOnUiThread(new Runnable() {
//
@Override
//
public void run() {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
mWaitingDialog
!=
null
)
{
mWaitingDialog
.
dismiss
();
mWaitingDialog
=
null
;
}
a
lcoholCheckerUtil
.
isConnected
=
true
;
A
lcoholCheckerUtil
.
isConnected
=
true
;
// 測定開始ボタン押し待ち
showWaitMeasureDialog
(
getString
(
R
.
string
.
alcohol_checker
),
getString
(
R
.
string
.
connection_completed
));
//
}
//
});
}
});
}
@Override
public
void
onGetDeviceInfo
(
final
String
alcohol
)
{
//
runOnUiThread(new Runnable() {
//
@Override
//
public void run() {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Logger
.
d
(
TAG
,
"測定完了 = "
+
alcohol
);
if
(!
alcohol
.
equals
(
""
))
{
successAfterAbookCheckApi
(
alcohol
,
false
);
}
else
{
}
//
}
//
});
}
});
}
@Override
public
void
onStartMeasurement
()
{
Logger
.
d
(
TAG
,
"onStartMeasurement"
);
if
(
alcoholCheckerUtil
.
alc
Status
==
AlcoholCheckerUtil
.
fugo_conntected
)
{
alcoholCheckerUtil
.
alc
Status
=
AlcoholCheckerUtil
.
fugo_wait_go
;
if
(
checker
Status
==
AlcoholCheckerUtil
.
fugo_conntected
)
{
checker
Status
=
AlcoholCheckerUtil
.
fugo_wait_go
;
}
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
...
...
@@ -340,15 +343,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
else
if
(
status
==
19
)
{
message
=
getString
(
R
.
string
.
msg_disconnected_device
);
}
if
(
alcoholCheckerUtil
!=
null
)
{
alcoholCheckerUtil
.
isConnected
=
false
;
errorAfterAbookCheckApi
(
message
);
}
errorAfterAbookCheckApi
(
message
,
true
);
}
@Override
public
void
onMeasurementError
(
String
text
)
{
Logger
.
d
(
TAG
,
"onMeasurementError = "
+
text
);
if
(
mMeasureDialog
!=
null
)
{
alcoholCheckerUtil
.
alc
Status
=
AlcoholCheckerUtil
.
fugo_fu_error
;
checker
Status
=
AlcoholCheckerUtil
.
fugo_fu_error
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -360,22 +365,22 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onBreakDownError
(
String
text
)
{
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_break_down_device
));
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_break_down_device
)
,
true
);
}
@Override
public
void
onLowBatteryError
(
String
text
)
{
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_low_battery
));
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_low_battery
)
,
true
);
}
@Override
public
void
onOverUsedError
(
String
text
)
{
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_over_used
));
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_over_used
)
,
true
);
}
@Override
public
void
onPowerOff
(
String
text
)
{
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_power_off
));
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_power_off
)
,
true
);
}
});
}
...
...
@@ -407,7 +412,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param value 各種デバイスから取得した値
*/
private
void
successAfterAbookCheckApi
(
final
String
value
,
boolean
isFinish
)
{
this
.
isFinish
=
isFinish
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -415,11 +419,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_F22);
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START22;
afterABookCheckApi
(
mCmd
,
""
,
0
,
""
,
responseJson
.
toString
());
Logger
.
i
(
TAG
,
"successAfterAbookCheckAip JSON [%s]"
,
responseJson
.
toString
());
isAlcBlock
=
false
;
}
});
}
...
...
@@ -428,17 +430,18 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* 各デバイスからエラー(接続不能など)発生した場合、HTML側にコールする
* @param errorMessage 各種デバイスから取得した値
*/
private
void
errorAfterAbookCheckApi
(
final
String
errorMessage
)
{
private
void
errorAfterAbookCheckApi
(
final
String
errorMessage
,
final
boolean
isSendResult
)
{
// エラーの時は終了
isFinish
=
true
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dismissAllDialog
();
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START
;
//alcoholCheckerUtil.sendMessage(AlcoholCheckerUtil.F_BLE_COM_FC_COMMAND_F11);
alcoholCheckerUtil
.
SendMessageFromApp
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
)
;
if
(
isSendResult
)
{
afterABookCheckApi
(
mCmd
,
""
,
1
,
errorMessage
,
null
);
}
Logger
.
e
(
TAG
,
errorMessage
);
isAlcBlock
=
false
;
}
});
}
...
...
@@ -456,8 +459,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting Dialog stop click"
);
successAfterAbookCheckApi
(
""
,
true
);
//errorAfterAbookCheckApi("");
errorAfterAbookCheckApi
(
""
,
false
);
}
});
mWaitingDialog
.
show
();
...
...
@@ -476,8 +478,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"waiting mWaitMeasureDialog stop clickf"
);
successAfterAbookCheckApi
(
""
,
false
);
//errorAfterAbookCheckApi("");
errorAfterAbookCheckApi
(
""
,
false
);
}
});
mWaitMeasureDialog
.
show
();
...
...
@@ -496,8 +497,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
i
(
TAG
,
"wait mMeasureDialog stop click"
);
successAfterAbookCheckApi
(
""
,
false
);
//errorAfterAbookCheckApi("");
errorAfterAbookCheckApi
(
""
,
false
);
}
});
mMeasureDialog
.
show
();
...
...
@@ -548,14 +548,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
String
deviceAddress
=
getABVUIDataCache
().
getPairingBluetoothDeviceAddress
(
Constant
.
DeviceType
.
alcoholChecker
);
if
(
StringUtil
.
isNullOrEmpty
(
deviceAddress
))
{
// 登録されているアルコールチェッカーが無い場合はエラー
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_pairing_device_no_info
));
errorAfterAbookCheckApi
(
getString
(
R
.
string
.
msg_pairing_device_no_info
)
,
true
);
return
;
}
BluetoothPairingDeviceInfoDto
dto
=
getABVUIDataCache
().
getPairingBluetoothDeviceInfo
(
Constant
.
DeviceType
.
alcoholChecker
);
alcoholCheckerUtil
.
alc
Status
=
AlcoholCheckerUtil
.
fugo_wait_connect
;
if
(
a
lcoholCheckerUtil
.
isConnected
)
{
checker
Status
=
AlcoholCheckerUtil
.
fugo_wait_connect
;
if
(
A
lcoholCheckerUtil
.
isConnected
)
{
Logger
.
d
(
TAG
,
"isConnection = true"
);
alcoholCheckerUtil
.
alc
Status
=
AlcoholCheckerUtil
.
fugo_conntected
;
checker
Status
=
AlcoholCheckerUtil
.
fugo_conntected
;
showWaitMeasureDialog
(
getString
(
R
.
string
.
alcohol_checker
),
getString
(
R
.
string
.
connection_completed
));
}
else
{
Logger
.
d
(
TAG
,
"isConnection = false"
);
...
...
@@ -593,6 +593,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
protected
void
onResume
()
{
Logger
.
i
(
TAG
,
"onResume"
);
super
.
onResume
();
try
{
if
(
readingLogFlg
)
{
...
...
@@ -625,41 +626,40 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
protected
void
onPause
()
{
super
.
onPause
();
}
@Override
protected
void
onStop
()
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"onStop
"
);
Logger
.
i
(
TAG
,
"onPause
"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
super
.
onStop
();
if
(!
DeviceInfo
.
isForegrdound
(
getApplicationContext
())
&&
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
pauseContentReadLog
(
contentId
);
}
// ダイアログ閉じる
dismissAllDialog
();
// タイマーにFCコマンド
if
(
alcoholCheckerUtil
!=
null
)
{
isAlcBlock
=
false
;
// false にしないと2回目押せない
//alcoholCheckerUtil.gi_status = AlcoholCheckerUtil.F_BLE_COM_FC_START
;
alcoholCheckerUtil
.
SendMessageFromApp
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_START
);
isAlcBlock
=
false
;
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
// チェッカーも終了
//alcoholCheckerUtil.finish();
alcoholCheckerUtil
.
finish
();
}
},
1000
);
}
}
@Override
protected
void
onStop
()
{
super
.
onStop
();
Logger
.
d
(
TAG
,
"onStop"
);
if
(!
DeviceInfo
.
isForegrdound
(
getApplicationContext
())
&&
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
pauseContentReadLog
(
contentId
);
}
}
@Override
protected
void
onDestroy
()
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"onDestroy"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
if
(
readingLogFlg
)
{
ContentReadingLogLogic
logic
=
AbstractLogic
.
getLogic
(
ContentReadingLogLogic
.
class
);
logic
.
endContentReadLog
(
contentId
);
...
...
@@ -1391,7 +1391,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
ABookKeys
.
CMD_DELETE_TASK_REPORT
,
ABookKeys
.
CMD_CANCEL_TASK_REPORT
,
ABookKeys
.
CMD_LOCAL_SAVE_TASK_REPORT
)
){
// 作業一覧に戻る時,bluetoothを切断する。
//
disconnectBluetoothDevice();
disconnectBluetoothDevice
();
}
}
catch
(
Exception
e
)
{
...
...
@@ -1971,9 +1971,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private
void
disconnectBluetoothDevice
()
{
Logger
.
d
(
TAG
,
"disconnectBluetoothDevice"
);
//
if (alcoholCheckerUtil != null) {
//
alcoholCheckerUtil.finish();
//
alcoholCheckerUtil = null;
//
}
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