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
62057b49
Commit
62057b49
authored
2 years ago
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
計測1回ごとにBLEを切断する。長押しで接続する時に、一部の機種の為3000msのWaitを入れた。
parent
ad32ff5f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
80 deletions
+23
-80
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
+2
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+17
-13
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtilListener.java
+1
-1
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
+3
-66
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtil.java
View file @
62057b49
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/AlcoholCheckerUtilListener.java
View file @
62057b49
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
android.bluetooth.BluetoothGatt
;
public
interface
AlcoholCheckerUtilListener
{
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
void
onMeasurementError
(
String
txt
);
// 吹付エラー
...
...
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
62057b49
...
...
@@ -133,7 +133,7 @@ public class BleManagerUtil {
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
@Override
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
final
int
status
)
{
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
int
status
)
{
try
{
Logger
.
i
(
TAG
,
"onServicesDiscovered status = %s"
,
status
);
...
...
@@ -141,15 +141,14 @@ public class BleManagerUtil {
return
;
}
//mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
if
(
mBluetoothGatt
==
null
)
{
mBluetoothGatt
=
gatt
;
for
(
BluetoothGattService
svc
:
gatt
.
getServices
()){
Logger
.
d
(
TAG
,
svc
.
getUuid
().
toString
());
}
mBluetoothGatt
.
requestConnectionPriority
(
BluetoothGatt
.
CONNECTION_PRIORITY_HIGH
);
//mBluetoothGatt = gatt;
//mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
if
(
mListener
!=
null
)
{
// アルコールチェッカー
mListener
.
onServicesDiscovered
(
status
);
mListener
.
onServicesDiscovered
(
gatt
,
status
);
}
}
catch
(
Exception
e
)
{
Logger
.
d
(
TAG
,
e
);
...
...
@@ -182,12 +181,8 @@ public class BleManagerUtil {
@Override
public
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
){
Logger
.
d
(
TAG
,
"onDescriptorWrite"
);
try
{
if
(
mListener
!=
null
)
{
mListener
.
onDescriptorWrite
(
gatt
,
descriptor
,
status
);
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
if
(
mListener
!=
null
)
{
mListener
.
onDescriptorWrite
(
gatt
,
descriptor
,
status
);
}
}
};
...
...
@@ -318,7 +313,9 @@ public class BleManagerUtil {
// ②「接続可能範囲から外れた切断」は、内部処理でmBluetoothGatt.disconnect()処理が実施される。
// 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。
mBluetoothGatt
.
disconnect
();
mBluetoothGatt
.
close
();
mBluetoothGatt
=
null
;
mListener
=
null
;
}
...
...
@@ -435,6 +432,13 @@ public class BleManagerUtil {
return
true
;
}
public
BluetoothGatt
getBluetoothGatt
()
{
return
mBluetoothGatt
;
}
public
void
setBluetoothGatt
(
BluetoothGatt
gatt
)
{
mBluetoothGatt
=
gatt
;
}
/**
* リスナー設定
* @param listener リスナー
...
...
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtilListener.java
View file @
62057b49
...
...
@@ -11,7 +11,7 @@ public interface BleManagerUtilListener {
void
onDisConnectionState
();
// ディバイスと切断時
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
// アルコールチェッカーで追加
void
onServicesDiscovered
(
int
status
);
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
int
status
);
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
);
void
onDescriptorWrite
(
BluetoothGatt
gatt
,
BluetoothGattDescriptor
descriptor
,
int
status
);
}
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
62057b49
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/BlePairingSettingActivity.java
View file @
62057b49
...
...
@@ -3,17 +3,12 @@ package jp.agentec.abook.abv.ui.home.activity;
import
android.app.Activity
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothDevice
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattCallback
;
import
android.bluetooth.BluetoothManager
;
import
android.bluetooth.BluetoothProfile
;
import
android.bluetooth.le.BluetoothLeScanner
;
import
android.bluetooth.le.ScanCallback
;
import
android.bluetooth.le.ScanResult
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.location.LocationManager
;
import
android.os.Build
;
import
android.os.Bundle
;
...
...
@@ -24,7 +19,6 @@ import android.widget.AdapterView;
import
android.widget.Button
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -32,10 +26,8 @@ import java.util.List;
import
jp.agentec.abook.abv.bl.common.Constant
;
import
jp.agentec.abook.abv.bl.common.Constant.DeviceType
;
import
jp.agentec.abook.abv.bl.common.constant.ABookKeys
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto
;
import
jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil
;
import
jp.agentec.abook.abv.cl.util.BleManagerUtil
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.common.activity.ABVUIActivity
;
...
...
@@ -45,8 +37,6 @@ import jp.agentec.abook.abv.ui.home.adapter.common.SectionHeaderData;
import
jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper
;
import
jp.agentec.adf.util.CollectionUtil
;
import
static
android
.
bluetooth
.
BluetoothDevice
.
TRANSPORT_LE
;
public
class
BlePairingSettingActivity
extends
ABVUIActivity
{
private
static
final
String
TAG
=
"BlePairingSettingActivity"
;
...
...
@@ -160,6 +150,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
Logger
.
d
(
TAG
,
"position = "
+
position
);
stopScan
();
BleListRowData
bleListRowData
=
(
BleListRowData
)
parent
.
getItemAtPosition
(
position
);
// 既に保存されてる場合は何もしない
if
(!
bleListRowData
.
isSaved
)
{
...
...
@@ -239,7 +230,7 @@ public class BlePairingSettingActivity extends ABVUIActivity {
//端末側の位置情報許可チェック
if
(!(
gpsEnabled
||
secureLocationGpsEnabled
))
{
//showSimpleAlertDialog(R.string.chino_machine
, R.string.msg_location_device_no_allow);
showSimpleAlertDialog
(
R
.
string
.
alcohol_checker
,
R
.
string
.
msg_location_device_no_allow
);
return
;
}
...
...
@@ -429,29 +420,8 @@ public class BlePairingSettingActivity extends ABVUIActivity {
return
false
;
}
////////////////////////////////////////////////////////////////////////
private
BluetoothGatt
bluetoothGatt
=
null
;
private
BluetoothAdapter
bluetoothAdapter
=
null
;
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
//unregisterReceiver(PairingRequest);
if
(
bluetoothGatt
!=
null
)
{
bluetoothGatt
.
close
();
bluetoothGatt
=
null
;
}
}
BroadcastReceiver
PairingRequest
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
BluetoothDevice
.
ACTION_PAIRING_REQUEST
))
{
Logger
.
d
(
TAG
,
"PEAR"
);
}
}
};
//private BluetoothDevice device = null;
private
void
PairingDevice
(
String
deviceAddress
)
{
BluetoothManager
bleMgr
=
(
BluetoothManager
)
this
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
...
...
@@ -462,39 +432,6 @@ public class BlePairingSettingActivity extends ABVUIActivity {
}
}
BluetoothDevice
device
=
bluetoothAdapter
.
getRemoteDevice
(
deviceAddress
);
//bluetoothGatt = device.connectGatt(this, false, gattcallback, TRANSPORT_LE);
device
.
createBond
();
//IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
//registerReceiver(PairingRequest, filter);
}
private
final
BluetoothGattCallback
gattcallback
=
new
BluetoothGattCallback
()
{
@Override
public
void
onConnectionStateChange
(
BluetoothGatt
gatt
,
int
status
,
int
newState
)
{
super
.
onConnectionStateChange
(
gatt
,
status
,
newState
);
if
(
newState
==
BluetoothProfile
.
STATE_CONNECTED
)
{
//
Logger
.
d
(
TAG
,
"STATE_CONNECTED"
);
gatt
.
discoverServices
();
}
else
if
(
newState
==
BluetoothProfile
.
STATE_DISCONNECTED
)
{
//
Logger
.
d
(
TAG
,
"STATE_DISCONNECTED"
);
if
(
bluetoothGatt
!=
null
)
{
bluetoothGatt
.
close
();
bluetoothGatt
=
null
;
}
}
}
@Override
public
void
onServicesDiscovered
(
BluetoothGatt
gatt
,
int
status
)
{
super
.
onServicesDiscovered
(
gatt
,
status
);
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
)
{
bluetoothGatt
=
gatt
;
Logger
.
d
(
TAG
,
"BluetoothGatt.GATT_SUCCESS"
);
}
}
};
}
This diff is collapsed.
Click to expand it.
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