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
39e4fbdc
Commit
39e4fbdc
authored
Jul 29, 2020
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bluetooth未接続時に、フォームから作業一覧に戻る時にスキャンを停止するように修正した
parent
c074517c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
85 deletions
+39
-85
ABVJE_Res_Default_Android/res/values/strings.xml
+2
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+14
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/TR41BluetoothUtil.java
+22
-85
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVCheckContentViewActivity.java
+0
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+1
-0
No files found.
ABVJE_Res_Default_Android/res/values/strings.xml
View file @
39e4fbdc
...
...
@@ -1438,5 +1438,6 @@
<string
name=
"msg_no_nfc_setting"
>
端末の設定からNFCを有効にする必要があります。\n端末の設定画面へ遷移しますか?
</string>
<string
name=
"select_spp_device_title"
>
シリアル通信機器選択
</string>
<string
name=
"msg_bluetooth_connect_timeout_error"
>
%1$s with the central thermometer has been lost. Check the power and distance of %1$s and try again.(%2$s)
</string>
<string
name=
"tr41_thermometer"
>
TR41温度センサー
</string>
</resources>
\ No newline at end of file
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
39e4fbdc
...
...
@@ -326,6 +326,18 @@ public class BleManagerUtil {
// 切断
public
void
disconnect
(
boolean
listenerFlg
)
{
// 接続されていない。検索中の場合はスキャン停止
if
(
listenerFlg
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// スキャン停止
mHandler
.
removeCallbacksAndMessages
(
null
);
mBluetoothAdapter
.
getBluetoothLeScanner
().
stopScan
(
mScanCallback
);
}
});
}
if
(
mBluetoothGatt
==
null
)
{
return
;
}
...
...
@@ -339,6 +351,7 @@ public class BleManagerUtil {
mBluetoothGatt
.
disconnect
();
// mBluetoothGatt.close();
mBluetoothGatt
=
null
;
/**
if (listenerFlg) {
runOnUiThread( new Runnable() {
@Override
...
...
@@ -348,6 +361,7 @@ public class BleManagerUtil {
}
});
}
*/
}
// キャラクタリスティックの読み込み
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/TR41BluetoothUtil.java
View file @
39e4fbdc
...
...
@@ -62,15 +62,10 @@ public class TR41BluetoothUtil {
*
*/
public
interface
TR41BluetoothUtilLeScanner
{
//void onGetDeviceInfo(String strTemperature); // ディバイスから渡す情報
//void onGetDeviceInfoFailed(int status); // ディバイスと接続失敗時の情報渡す。
//void onConnectionState(); // ディバイスと接続された時情報渡す。
//void onDisConnectionState(); // ディバイスと切断時
//void onConnectionError(int status); // ディバイス接続エラー
void
onBatchScanResults
(
List
<
ScanResult
>
results
);
//void onBatchScanResults(List<ScanResult> results);
void
onScanFailed
(
int
errorCode
);
void
onScanResult
(
int
callbackType
,
ScanResult
result
);
//void onScanResult(int callbackType, ScanResult result);
void
onScanResult
(
String
strTemperature
);
// デバイスから温度を渡す
}
public
TR41BluetoothUtil
(
Context
context
,
TR41BluetoothUtilLeScanner
listener
)
...
...
@@ -108,7 +103,7 @@ public class TR41BluetoothUtil {
///////////////////////////////////////////////////////////////////////////////////////////////
/** BLE機器を検索する */
p
rivate
void
Sb_
Scan
()
p
ublic
void
Sb_Start
Scan
()
{
Sb_Init_Ble_Scan
()
;
...
...
@@ -131,6 +126,11 @@ public class TR41BluetoothUtil {
},
SCAN_PERIOD
);
}
public
void
Sb_StopScan
()
{
mBluetoothLeScanner
.
stopScan
(
mScanCallback
)
;
}
private
ScanCallback
mScanCallback
=
new
ScanCallback
()
{
@Override
...
...
@@ -140,12 +140,14 @@ public class TR41BluetoothUtil {
@Override
public
void
onBatchScanResults
(
final
List
<
ScanResult
>
results
)
{
Logger
.
d
(
TAG
,
"onBatchScanResults"
);
/**
runOnUiThread( new Runnable() {
@Override
public void run() {
mListener.onBatchScanResults(results);
}
});
*/
};
@Override
...
...
@@ -160,12 +162,10 @@ public class TR41BluetoothUtil {
};
@Override
public
void
onScanResult
(
final
int
callbackType
,
final
ScanResult
result
)
{
Logger
.
d
(
TAG
,
"onScanResult"
);
public
void
onScanResult
(
int
callbackType
,
ScanResult
result
)
{
BluetoothDevice
device
=
result
.
getDevice
()
;
byte
[]
scanRecord
=
result
.
getScanRecord
().
getBytes
()
;
Logger
.
d
(
""
,
"getBoundState = "
+
device
.
getBondState
());
if
(
device
.
getBondState
()
!=
BluetoothDevice
.
BOND_BONDED
)
{
long
serial
[]
=
new
long
[
1
]
;
int
security
[]
=
new
int
[
1
]
;
...
...
@@ -173,7 +173,6 @@ public class TR41BluetoothUtil {
int
ch2Data
[]
=
new
int
[
1
]
;
int
batLevel
[]
=
new
int
[
1
]
;
StringBuffer
localName
=
new
StringBuffer
()
;
//int found ;
int
rtn
;
String
devName
=
device
.
getName
()
;
...
...
@@ -182,43 +181,29 @@ public class TR41BluetoothUtil {
return
;
}
// 近くにあるTR4だけを検索したい場合
// 近くにあるTR4だけを検索したい場合
( getRssiは、電波強度を返す。dBm マイナスが小さいほど電波が強い)
//if(result.getRssi() < -50)
// return ;
rtn
=
Sb_Parse_ScanRecord
(
scanRecord
,
serial
,
localName
,
security
,
ch1Data
,
ch2Data
,
batLevel
)
;
if
(
rtn
==
0
)
{
devName
=
localName
.
toString
().
trim
()
;
// すでに登録されたシリアル番号を調べる
//found = 0 ;
/**
for(int i=0; i< mDeviceList.getCount(); i++) {
Logger.d("","" + mDeviceList.infoList.get(i).getSerial());
if(mDeviceList.infoList.get(i).getSerial() == serial[0]) {
found = 1 ;
break ;
}
}
if(found == 0) {
mDeviceList.addDeviceInfo(serial[0], devName, device.getAddress(),
device, ch1Data[0], mScanTime/1000);
mListView.setAdapter(mDeviceList) ;
mDeviceList.notifyDataSetChanged() ;
final
String
ch1Str
;
if
(
ch1Data
[
0
]
==
0xEEEE
)
ch1Str
=
"----"
;
else
if
(
ch1Data
[
0
]
==
0xEEE0
)
ch1Str
=
""
;
else
ch1Str
=
String
.
format
(
"%.1f"
,
(
double
)(
ch1Data
[
0
]-
1000
)/
10.0
)
;
//mScanStop.cancel();
//mScanStop = null;
//mBluetoothLeScanner.stopScan(mScanCallback) ;
}
*/
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mListener
.
onScanResult
(
c
allbackType
,
result
);
mListener
.
onScanResult
(
c
h1Str
);
}
});
mBluetoothLeScanner
.
stopScan
(
mScanCallback
)
;
//
mBluetoothLeScanner.stopScan(mScanCallback) ;
}
}
};
...
...
@@ -426,51 +411,4 @@ public class TR41BluetoothUtil {
return
retStr
;
}
//デバイスの名前とアドレスを持つクラス
private
class
DeviceInfo
{
private
long
serial
;
private
String
name
;
private
String
address
;
private
BluetoothDevice
bltDevice
;
private
int
ch1Data
;
private
long
dataTime
;
private
long
rssi
;
private
DeviceInfo
(
long
serial
,
String
name
,
String
address
,
BluetoothDevice
bltDevice
,
int
ch1Data
,
long
dataTime
,
long
rssi
)
{
this
.
serial
=
serial
;
this
.
name
=
name
;
this
.
address
=
address
;
this
.
bltDevice
=
bltDevice
;
this
.
ch1Data
=
ch1Data
;
this
.
dataTime
=
dataTime
;
this
.
rssi
=
rssi
;
}
private
long
getSerial
()
{
return
serial
;
}
private
String
getName
()
{
return
(
name
)
+
" "
+
rssi
;
}
private
String
getAddress
()
{
return
address
;
}
private
BluetoothDevice
getBluetoothDevice
()
{
return
bltDevice
;
}
private
int
getCh1Data
()
{
return
ch1Data
;
}
private
long
getDataTime
()
{
return
dataTime
;
}
}
}
\ No newline at end of file
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVCheckContentViewActivity.java
View file @
39e4fbdc
This diff is collapsed.
Click to expand it.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
39e4fbdc
...
...
@@ -991,6 +991,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
if
(
StringUtil
.
equalsAny
(
mCmd
,
ABookKeys
.
CMD_INSERT_TASK_REPORT
,
ABookKeys
.
CMD_UPDATE_TASK_REPORT
,
ABookKeys
.
CMD_DELETE_TASK_REPORT
,
ABookKeys
.
CMD_CANCEL_TASK_REPORT
)
){
// 作業一覧に戻る時
disconnectBluetoothDevice
();
}
...
...
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