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
efcda418
Commit
efcda418
authored
Jun 14, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#47941 HW連携 アルコールチェッカーから値を取得する処理を追加中2
parent
a257e52f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
181 additions
and
29 deletions
+181
-29
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
+81
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
+0
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
+16
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+69
-28
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtilListener.java
+14
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+0
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
+1
-1
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerTimerTask.java
0 → 100644
View file @
efcda418
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
android.bluetooth.BluetoothGattCharacteristic
;
import
android.bluetooth.BluetoothGattDescriptor
;
import
java.util.TimerTask
;
import
java.util.UUID
;
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
()
{
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
Logger
.
i
(
TAG
,
"AlcohlCheckerTimerTask"
);
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
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
listener
.
onUpdateSendMessage
(
"F_BLE_COM_RP_COMMAND"
);
alcoholCheckerUtil
.
sendMessage
(
" "
+
F_BLE_COM_RP_COMMAND
);
break
;
case
AlcoholCheckerUtil
.
F_BLE_COM_RD_START
:
// RD Command Send
listener
.
onUpdateSendMessage
(
"F_BLE_COM_RD_COMMAND"
);
alcoholCheckerUtil
.
sendMessage
(
" "
+
F_BLE_COM_RD_COMMAND
);
break
;
case
F_BLE_COM_RECONNECT1:
// ReConecting(NOTIFICATION Disable) // @@@
alcoholCheckerUtil
.
NotificationDisable
(
AlcoholCheckerUtil
.
RxChar
,
AlcoholCheckerUtil
.
CCCD
);
alcoholCheckerUtil
.
gi_status
=
F_BLE_COM_RECONNECT2
;
listener
.
onUpdateStatus
(
"F_BLE_COM_RECONNECT2"
);
break
;
case
F_BLE_COM_RECONNECT2:
// ReConecting(Wait) // @@@
alcoholCheckerUtil
.
gi_status
=
F_BLE_COM_RECONNECT3
;
listener
.
onUpdateStatus
(
"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
(
"F_BLE_COM_RP_START"
);
break
;
default
:
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
Logger
.
i
(
TAG
,
"AlcohlCheckerTimerTask Timeout"
);
Logger
.
i
(
TAG
,
"--------------------------------------------------------------"
);
if
(
alcoholCheckerUtil
.
gi_rxretry_cnt
<
100
)
{
alcoholCheckerUtil
.
gi_rxretry_cnt
++;
}
alcoholCheckerUtil
.
gi_status
=
F_BLE_COM_RECONNECT1
;
listener
.
onUpdateStatus
(
"F_BLE_COM_RECONNECT1"
);
break
;
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
0 → 100644
View file @
efcda418
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
0 → 100644
View file @
efcda418
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattCharacteristic
;
import
java.util.UUID
;
public
interface
AlcoholCheckerUtilListener
{
void
onFugoAction
(
String
action
,
UUID
CHAR
,
byte
[]
data
,
String
MESSAGE
,
String
Type
);
void
onUpdateTBVCalc
(
String
text
);
void
onUpdateStatus
(
String
text
);
void
onUpdateSendMessage
(
String
text
);
void
onUpdateReceivedData
(
String
text
);
void
onServicesDiscovered
(
int
status
);
void
onGetDeviceInfo
(
String
alcohol
);
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
efcda418
...
...
@@ -15,6 +15,7 @@ import android.content.Context;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.widget.Toast
;
import
java.lang.reflect.Method
;
...
...
@@ -23,9 +24,11 @@ import java.nio.ByteOrder;
import
java.util.List
;
import
java.util.UUID
;
import
jp.agentec.abook.abv.bl.common.Constant
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.adf.util.StringUtil
;
import
oz.lottie.animation.content.Content
;
import
static
android
.
bluetooth
.
BluetoothDevice
.
TRANSPORT_LE
;
import
static
org
.
chromium
.
base
.
ThreadUtils
.
runOnUiThread
;
...
...
@@ -48,11 +51,12 @@ public class BleManagerUtil {
// メンバー変数
public
BluetoothAdapter
mBluetoothAdapter
;
// BluetoothAdapter : Bluetooth処理で必要
private
String
mDeviceAddress
=
""
;
// デバイスアドレス
private
String
mDeviceAddress
=
""
;
// デバイスアドレス
public
BluetoothGatt
mBluetoothGatt
=
null
;
// Gattサービスの検索、キャラスタリスティックの読み書き
private
int
mBleConnectDeviceType
;
//public BleManagerUtil(Context context, BleManagerUtilListener listener) {
public
BleManagerUtil
(
Context
context
,
BleManagerUtilListener
listener
)
{
mContext
=
context
;
mListener
=
listener
;
...
...
@@ -64,7 +68,7 @@ public class BleManagerUtil {
// 接続状態変更(connectGatt()の結果として呼ばれる。)
@Override
public
void
onConnectionStateChange
(
BluetoothGatt
gatt
,
final
int
status
,
final
int
newState
)
{
Logger
.
d
(
"onConnectionStateChange status = "
+
status
+
" newState = "
+
newState
);
Logger
.
i
(
"onConnectionStateChange status = "
+
status
+
" newState = "
+
newState
);
// デバイスと接続されていない場合のメッセージコード:133, 62
// デバイスと離れて応答がなく、タイムアウトになる場合:8
...
...
@@ -108,7 +112,9 @@ public class BleManagerUtil {
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
@Override
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
int
status
)
{
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
final
int
status
)
{
Logger
.
i
(
TAG
,
"onServicesDiscovered status = %s"
,
status
);
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
return
;
}
...
...
@@ -121,6 +127,11 @@ public class BleManagerUtil {
}
mBluetoothGatt
.
requestConnectionPriority
(
BluetoothGatt
.
CONNECTION_PRIORITY_HIGH
);
if
(
mBleConnectDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
mListener
.
onServicesDiscovered
(
status
);
return
;
}
// 発見されたサービスのループ
for
(
BluetoothGattService
service
:
gatt
.
getServices
())
{
// サービスごとに個別の処理
...
...
@@ -144,7 +155,7 @@ public class BleManagerUtil {
@Override
public
void
run
()
{
// 操作可能
mListener
.
onConnectionState
();
mListener
.
onConnectionState
(
status
);
}
});
continue
;
...
...
@@ -155,6 +166,7 @@ public class BleManagerUtil {
// キャラクタリスティックが読み込まれたときの処理
@Override
public
void
onCharacteristicRead
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
,
int
status
)
{
Logger
.
i
(
TAG
,
"onCharacteristicChanged"
);
if
(
BluetoothGatt
.
GATT_SUCCESS
!=
status
)
{
return
;
}
...
...
@@ -179,6 +191,11 @@ public class BleManagerUtil {
// キャラクタリスティック変更が通知されたときの処理
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
i
(
TAG
,
"------------------------------------------------------ onCharacteristicChanged"
);
if
(
mBleConnectDeviceType
==
Constant
.
DeviceType
.
alcoholChecker
)
{
mListener
.
onCharacteristicChanged
(
gatt
,
characteristic
);
return
;
}
if
(
UUID_CHARACTERISTIC_PRIVATE
.
equals
(
characteristic
.
getUuid
()
)
)
{
final
String
strTemperature
=
byteToString
(
characteristic
.
getValue
());
...
...
@@ -197,6 +214,7 @@ public class BleManagerUtil {
}
}
};
/**
* 接続してるデバイスタイプを取得
* @return
...
...
@@ -260,18 +278,6 @@ public class BleManagerUtil {
bleGattConnect
(
device
);
}
/**
* ディバイス情報の取得を開始します<br>
* 成功時にlistenerのonGetDeviceInfo、失敗時にlistenerのonGetDeviceInfoFailedが呼び出されます。
*
*/
public
interface
BleManagerUtilListener
{
void
onGetDeviceInfo
(
String
strTemperature
);
// ディバイスから渡す情報
void
onGetDeviceInfoFailed
(
int
status
);
// ディバイスと接続失敗時の情報渡す。
void
onConnectionState
();
// ディバイスと接続された時情報渡す。
void
onDisConnectionState
();
// ディバイスと切断時
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
}
// 接続
public
void
connect
(
int
connectTargetDeviceType
,
String
deviceAddress
)
{
mDeviceAddress
=
deviceAddress
;
...
...
@@ -384,32 +390,37 @@ public class BleManagerUtil {
return
String
.
valueOf
(
flt
);
}
// Bluetoothアダプタの取得処理
public
void
startDeviceInfo
()
{
/**
* Bluetoothアダプタの取得処理
* @return Android端末がBluetooth端末をサポートしていない場合 false
*/
public
boolean
startDeviceInfo
()
{
// Bluetoothアダプタの取得
BluetoothManager
bluetoothManager
=
(
BluetoothManager
)
mContext
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
if
(
bluetoothManager
!=
null
)
{
mBluetoothAdapter
=
bluetoothManager
.
getAdapter
();
if
(
mBluetoothAdapter
==
null
)
{
// Android端末がBluetoothをサポートしていない
Toast
.
makeText
(
mContext
,
R
.
string
.
bluetooth_is_not_supported
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
return
false
;
}
}
else
{
Logger
.
e
(
TAG
,
"bluetoothManager is null"
);
return
false
;
}
return
true
;
}
// UUIDセット
private
void
setUUID
()
{
// if (mBleConnectDeviceType ==
DeviceType.centerThermomete) {
//
// 中心温度計のUUIDセット
//
UUID_SERVICE_PRIVATE = UUID.fromString("05fd8c58-9d23-11e7-abc4-cec278b6b50a");
//
UUID_CHARACTERISTIC_PRIVATE = UUID.fromString("05fd8f5a-9d23-11e7-abc4-cec278b6b50a");
// } else if (mBleConnectDeviceType ==
DeviceType.radiationThermomete) {
//
// 放射温度計のUUIDセット
//
UUID_SERVICE_PRIVATE = UUID.fromString("462026f6-cfe1-11e7-abc4-cec278b6b50a");
//
UUID_CHARACTERISTIC_PRIVATE = UUID.fromString("46202b74-cfe1-11e7-abc4-cec278b6b50a");
//
}
if
(
mBleConnectDeviceType
==
Constant
.
DeviceType
.
centerThermomete
)
{
// 中心温度計のUUIDセット
UUID_SERVICE_PRIVATE
=
UUID
.
fromString
(
"05fd8c58-9d23-11e7-abc4-cec278b6b50a"
);
UUID_CHARACTERISTIC_PRIVATE
=
UUID
.
fromString
(
"05fd8f5a-9d23-11e7-abc4-cec278b6b50a"
);
}
else
if
(
mBleConnectDeviceType
==
Constant
.
DeviceType
.
radiationThermomete
)
{
// 放射温度計のUUIDセット
UUID_SERVICE_PRIVATE
=
UUID
.
fromString
(
"462026f6-cfe1-11e7-abc4-cec278b6b50a"
);
UUID_CHARACTERISTIC_PRIVATE
=
UUID
.
fromString
(
"46202b74-cfe1-11e7-abc4-cec278b6b50a"
);
}
}
/**
...
...
@@ -439,4 +450,34 @@ public class BleManagerUtil {
disconnect
(
false
);
connect
(
mBleConnectDeviceType
,
mDeviceAddress
);
}
// @@@@@
public
void
DescriptorDevice
(
BluetoothGattCharacteristic
uRxChar
,
UUID
ucccd
)
{
if
(
mBluetoothGatt
!=
null
){
mBluetoothGatt
.
setCharacteristicNotification
(
uRxChar
,
true
);
BluetoothGattDescriptor
descriptor
=
uRxChar
.
getDescriptor
(
ucccd
);
descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
mBluetoothGatt
.
writeDescriptor
(
descriptor
);
}
}
// @@@@@
public
void
NotificationDisable
(
BluetoothGattCharacteristic
uRxChar
,
UUID
ucccd
)
{
if
(
mBluetoothGatt
!=
null
){
mBluetoothGatt
.
setCharacteristicNotification
(
uRxChar
,
true
);
BluetoothGattDescriptor
descriptor
=
uRxChar
.
getDescriptor
(
ucccd
);
descriptor
.
setValue
(
BluetoothGattDescriptor
.
DISABLE_NOTIFICATION_VALUE
);
mBluetoothGatt
.
writeDescriptor
(
descriptor
);
}
}
public
boolean
readPhyConnection
(){
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
O
){
return
false
;
}
if
(
mBluetoothGatt
==
null
){
return
false
;
}
mBluetoothGatt
.
readPhy
();
return
true
;
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtilListener.java
0 → 100644
View file @
efcda418
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattCharacteristic
;
public
interface
BleManagerUtilListener
{
void
onGetDeviceInfo
(
String
strTemperature
);
// ディバイスから渡す情報
void
onGetDeviceInfoFailed
(
int
status
);
// ディバイスと接続失敗時の情報渡す。
void
onConnectionState
(
int
status
);
// ディバイスと接続された時情報渡す。
void
onDisConnectionState
();
// ディバイスと切断時
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
void
onServicesDiscovered
(
int
status
);
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
);
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
efcda418
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
View file @
efcda418
...
...
@@ -47,7 +47,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
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"
;
// アルコールチェッカーデバイス名
private
static
final
String
ALCOHOL_CHECKER_DEVICE_NAME
=
"FALC
-31
"
;
// アルコールチェッカーデバイス名
// メンバー変数
private
Handler
mHandler
;
// UIスレッド操作ハンドラ : 「一定時間後にスキャンをやめる処理」で必要
...
...
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