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
78b23091
Commit
78b23091
authored
Jun 28, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
吹付エラーの後、10秒経過後に「息を吹きかけてください」が表示されなかったのを修正した。
parent
97554d16
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
163 deletions
+139
-163
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+129
-158
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+8
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+2
-5
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
78b23091
...
...
@@ -146,195 +146,166 @@ public class AlcoholCheckerUtil {
// mutex
private
Object
lockObj
=
new
Object
();
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
isConnected
=
false
;
this
.
listener
=
listener
;
}
public
void
finish
()
{
isConnected
=
false
;
disconnect
();
}
public
BleManagerUtilListener
bleManagerUtilListener
=
new
BleManagerUtilListener
()
{
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
(
)
{
@Override
public
void
onGetDeviceInfoFailed
(
int
status
)
{
}
// BLE管理
bleManagerUtil
=
new
BleManagerUtil
(
context
,
new
BleManagerUtilListener
()
{
@Override
public
void
onGetDeviceInfoFailed
(
int
status
)
{
@Override
public
void
onGetDeviceInfo
(
String
strTemperature
)
{
}
}
@Override
public
void
onGetDeviceInfo
(
String
strTemperature
)
{
@Override
public
void
onConnectionState
(
int
status
)
{
Logger
.
d
(
TAG
,
"onConnectionState = %s"
,
status
);
}
}
@Override
public
void
onConnectionState
(
int
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
()
{
}
@Override
public
void
onDisConnectionState
()
{
// Logger.d(TAG,"onDisConnectionState");
// listener.onConnectionError(0);
// //isConnected = false;
}
@Override
public
void
onConnectionError
(
int
status
)
{
Logger
.
d
(
TAG
,
"onConnectionError = %s"
,
status
);
listener
.
onConnectionError
(
status
);
}
@Override
public
void
onConnectionError
(
int
status
)
{
Logger
.
d
(
TAG
,
"onConnectionError
= %s"
,
status
);
listener
.
onConnectionError
(
status
);
}
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
i
(
TAG
,
"onServicesDiscovered
= %s"
,
status
);
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
)
{
Logger
.
i
(
TAG
,
"BluetoothGatt.GATT_SUCCESS"
);
@Override
public
void
onServicesDiscovered
(
int
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"
);
TaiyoYudenService
=
bleManagerUtil
.
mBluetoothGatt
.
getService
(
TY_SERVICE_UUID
);
if
(
TaiyoYudenService
==
null
)
{
Logger
.
e
(
TAG
,
"Not a TaiyoYuden device"
);
TaiyoYudenService
=
bleManagerUtil
.
mBluetoothGatt
.
getService
(
TY_SERVICE_UUID
);
if
(
TaiyoYudenService
==
null
)
{
Logger
.
e
(
TAG
,
"Not a TaiyoYuden device"
);
}
else
{
// Check TX and RX UUIDs
RxChar
=
TaiyoYudenService
.
getCharacteristic
(
RX_CHARACTERISTIC_UUID
);
TxChar
=
TaiyoYudenService
.
getCharacteristic
(
TX_CHARACTERISTIC_UUID
);
if
(
RxChar
==
null
||
TxChar
==
null
)
{
Logger
.
e
(
TAG
,
"No Tx/Rx"
);
}
else
{
// 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_status
=
F_BLE_COM_INIT
;
gi_rxlength
=
0
;
gf_result_flg
=
false
;
gi_rxretry_cnt
=
0
;
gi_rxlength
=
0
;
gf_result_flg
=
false
;
gi_rxretry_cnt
=
0
;
BluetoothGatt
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
;
BluetoothGatt
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
.
readPhyConnection
();
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
NotificationChar
,
true
);
BluetoothGattDescriptor
notification_descriptor
=
NotificationChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
notification_descriptor
);
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
NotificationChar
,
true
);
BluetoothGattDescriptor
notification_descriptor
=
NotificationChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
notification_descriptor
);
gi_status
=
F_BLE_COM_RP_START
;
gi_status
=
F_BLE_COM_RP_START
;
SendMessageFromApp
(
gi_status
);
SendMessageFromApp
(
gi_status
);
listener
.
onServicesDiscovered
(
status
);
}
listener
.
onServicesDiscovered
(
status
);
}
}
else
{
}
}
else
{
}
}
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
synchronized
(
lockObj
)
{
Logger
.
d
(
TAG
,
"onCharacteristicChanged"
);
byte
[]
rx
=
characteristic
.
getValue
();
String
rxStr
=
" "
;
if
(
rx
!=
null
&&
rx
.
length
>
0
)
{
for
(
byte
rx1
:
rx
)
{
rxStr
+=
rx1
+
" ,"
;
}
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
synchronized
(
lockObj
)
{
Logger
.
d
(
TAG
,
"onCharacteristicChanged"
);
byte
[]
rx
=
characteristic
.
getValue
();
String
rxStr
=
" "
;
if
(
rx
!=
null
&&
rx
.
length
>
0
)
{
for
(
byte
rx1
:
rx
)
{
rxStr
+=
rx1
+
" ,"
;
}
sub_rx_chk
(
rx
);
}
sub_rx_chk
(
rx
);
}
}
@Override
public
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
)
{
//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"
);
// This version doesn't support latest characteristics
return
;
}
}
else
{
@Override
public
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
)
{
//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"
);
// This version doesn't support latest characteristics
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
);
}
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
)){
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
);
gatt
.
writeDescriptor
(
indication_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
INDICATION_CHARACTERISTIC_UUID
)){
// Enable notification on receiving data
gatt
.
setCharacteristicNotification
(
batteryLevelChar
,
true
);
notification_descriptor
=
batteryLevelChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
notification_descriptor
);
gatt
.
writeDescriptor
(
notification_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
BATTERY_LEVEL_UUID
)){
Logger
.
d
(
TAG
,
"Wrote descriptor: "
+
BATTERY_LEVEL_UUID
);
}
}
};
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
isConnected
=
false
;
this
.
listener
=
listener
;
}
UUID
characteristic_uuid
=
descriptor
.
getCharacteristic
().
getUuid
();
if
(
characteristic_uuid
.
equals
(
NOTIFICATION_CHARACTERISTIC_UUID
)){
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
);
gatt
.
writeDescriptor
(
indication_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
INDICATION_CHARACTERISTIC_UUID
)){
// Enable notification on receiving data
gatt
.
setCharacteristicNotification
(
batteryLevelChar
,
true
);
notification_descriptor
=
batteryLevelChar
.
getDescriptor
(
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
gatt
.
writeDescriptor
(
notification_descriptor
);
}
else
if
(
characteristic_uuid
.
equals
(
BATTERY_LEVEL_UUID
)){
Logger
.
d
(
TAG
,
"Wrote descriptor: "
+
BATTERY_LEVEL_UUID
);
}
}
});
public
void
finish
()
{
isConnected
=
false
;
disconnect
();
}
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
()
{
// BLE管理
bleManagerUtil
=
new
BleManagerUtil
(
context
,
bleManagerUtilListener
);
if
(!
bleManagerUtil
.
startDeviceInfo
())
{
return
false
;
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
78b23091
...
...
@@ -420,4 +420,12 @@ public class BleManagerUtil {
mBluetoothGatt
.
readPhy
();
return
true
;
}
/**
* リスナー設定
* @param listener リスナー
*/
public
void
setListener
(
BleManagerUtilListener
listener
)
{
mListener
=
listener
;
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
78b23091
...
...
@@ -273,10 +273,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
*/
private
void
initAlcoholCheckerUtil
()
{
Logger
.
i
(
TAG
,
"initAlcoholCheckerUtil"
);
if
(
alcoholCheckerUtil
!=
null
)
{
checkerStatus
=
AlcoholCheckerUtil
.
fugo_init
;
return
;
}
alcoholCheckerUtil
=
new
AlcoholCheckerUtil
(
this
,
new
AlcoholCheckerUtilListener
()
{
...
...
@@ -341,7 +337,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public
void
run
()
{
if
(
isFromError
)
{
if
(
mMeasureDialog
!=
null
)
{
mMeasureDialog
.
setMessage
(
getString
(
R
.
string
.
msg_breath_error
));
mMeasureDialog
.
setMessage
(
getString
(
R
.
string
.
wait_breathe
));
}
}
else
{
if
(
mWaitMeasureDialog
!=
null
)
{
...
...
@@ -563,6 +559,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
isInitBLE
=
true
;
}
}
alcoholCheckerUtil
.
bleManagerUtil
.
setListener
(
alcoholCheckerUtil
.
bleManagerUtilListener
);
if
(!
isInitAlcChecker
)
{
// アルコールチェッカー接続
connectToAlcholChecker
();
...
...
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