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
c074517c
Commit
c074517c
authored
Jul 29, 2020
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RT41 温度計の情報を格納するクラスを追加
parent
0e7bcc1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
25 deletions
+136
-25
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/RT41DeviceDto.java
+54
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/TR41BluetoothUtil.java
+82
-25
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/RT41DeviceDto.java
0 → 100644
View file @
c074517c
package
jp
.
agentec
.
abook
.
abv
.
bl
.
dto
;
/**
* RT41 bluetooth 温度計デバイスの名前とアドレスを持つクラス
* @author onuma
*/
public
class
RT41DeviceDto
{
public
long
serial
;
public
String
name
;
public
String
address
;
//private BluetoothDevice bltDevice ;
public
int
ch1Data
;
public
long
dataTime
;
public
long
rssi
;
// private DeviceInfo(long serial, String name, String address, BluetoothDevice bltDevice,
// int ch1Data, long dataTime, long rssi)
public
RT41DeviceDto
(
long
serial
,
String
name
,
String
address
,
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
;
}
/**
public long getSerial() {
return serial ;
}
public String getName() {
return (name) + " " + rssi ;
}
public String getAddress() {
return address ;
}
private BluetoothDevice getBluetoothDevice() {
return bltDevice ;
}
public int getCh1Data() {
return ch1Data ;
}
public long getDataTime() {
return dataTime ;
}
*/
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/TR41BluetoothUtil.java
View file @
c074517c
...
@@ -41,6 +41,7 @@ import java.util.TimerTask;
...
@@ -41,6 +41,7 @@ import java.util.TimerTask;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
static
android
.
bluetooth
.
le
.
ScanSettings
.
SCAN_MODE_LOW_LATENCY
;
import
static
android
.
bluetooth
.
le
.
ScanSettings
.
SCAN_MODE_LOW_LATENCY
;
import
static
org
.
chromium
.
base
.
ThreadUtils
.
runOnUiThread
;
public
class
TR41BluetoothUtil
{
public
class
TR41BluetoothUtil
{
...
@@ -61,11 +62,11 @@ public class TR41BluetoothUtil {
...
@@ -61,11 +62,11 @@ public class TR41BluetoothUtil {
*
*
*/
*/
public
interface
TR41BluetoothUtilLeScanner
{
public
interface
TR41BluetoothUtilLeScanner
{
void
onGetDeviceInfo
(
String
strTemperature
);
// ディバイスから渡す情報
//
void onGetDeviceInfo(String strTemperature); // ディバイスから渡す情報
void
onGetDeviceInfoFailed
(
int
status
);
// ディバイスと接続失敗時の情報渡す。
//
void onGetDeviceInfoFailed(int status); // ディバイスと接続失敗時の情報渡す。
void
onConnectionState
();
// ディバイスと接続された時情報渡す。
//
void onConnectionState(); // ディバイスと接続された時情報渡す。
void
onDisConnectionState
();
// ディバイスと切断時
//
void onDisConnectionState(); // ディバイスと切断時
void
onConnectionError
(
int
status
);
// ディバイス接続エラー
//
void onConnectionError(int status); // ディバイス接続エラー
void
onBatchScanResults
(
List
<
ScanResult
>
results
);
void
onBatchScanResults
(
List
<
ScanResult
>
results
);
void
onScanFailed
(
int
errorCode
);
void
onScanFailed
(
int
errorCode
);
...
@@ -87,30 +88,19 @@ public class TR41BluetoothUtil {
...
@@ -87,30 +88,19 @@ public class TR41BluetoothUtil {
// ************************************************************************
// ************************************************************************
private
void
Sb_Init_Ble_Scan
()
private
void
Sb_Init_Ble_Scan
()
{
{
if
(
mBluetoothAdapter
!=
null
)
if
(
mBluetoothAdapter
!=
null
)
{
return
;
return
;
}
//BluetoothAdapter取得
//BluetoothAdapter取得
BluetoothAdapter
btAdpt
=
BluetoothAdapter
.
getDefaultAdapter
()
;
BluetoothAdapter
btAdpt
=
BluetoothAdapter
.
getDefaultAdapter
()
;
if
(!
btAdpt
.
equals
(
null
))
{
// Bluetooth対応端末の場合
}
else
{
// Bluetooth非対応端末の場合
//finish() ;
}
boolean
btEnable
=
btAdpt
.
isEnabled
()
;
//
boolean btEnable = btAdpt.isEnabled() ;
if
(
btEnable
==
true
)
{
//
if(btEnable == true) {
// Bluetoothアダプタ作成
// Bluetoothアダプタ作成
mBluetoothManager
=
(
BluetoothManager
)
mContext
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
mBluetoothManager
=
(
BluetoothManager
)
mContext
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
mBluetoothAdapter
=
mBluetoothManager
.
getAdapter
()
;
mBluetoothAdapter
=
mBluetoothManager
.
getAdapter
()
;
mBluetoothLeScanner
=
mBluetoothAdapter
.
getBluetoothLeScanner
()
;
mBluetoothLeScanner
=
mBluetoothAdapter
.
getBluetoothLeScanner
()
;
}
// }
else
{
// BluetoothがOFFだった場合、ONにすることを促すダイアログを表示
//Intent btOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE) ;
//startActivityForResult(btOn, 1) ;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
...
@@ -148,16 +138,29 @@ public class TR41BluetoothUtil {
...
@@ -148,16 +138,29 @@ public class TR41BluetoothUtil {
return
super
.
clone
();
return
super
.
clone
();
}
}
@Override
@Override
public
void
onBatchScanResults
(
List
<
ScanResult
>
results
)
{
public
void
onBatchScanResults
(
final
List
<
ScanResult
>
results
)
{
Logger
.
d
(
TAG
,
"onBatchScanResults"
);
Logger
.
d
(
TAG
,
"onBatchScanResults"
);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mListener
.
onBatchScanResults
(
results
);
}
});
};
};
@Override
@Override
public
void
onScanFailed
(
int
errorCode
)
{
public
void
onScanFailed
(
final
int
errorCode
)
{
Logger
.
d
(
TAG
,
"onScanFailed"
);
Logger
.
d
(
TAG
,
"onScanFailed"
);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mListener
.
onScanFailed
(
errorCode
);
}
});
};
};
@Override
@Override
public
void
onScanResult
(
int
callbackType
,
ScanResult
result
)
{
public
void
onScanResult
(
final
int
callbackType
,
final
ScanResult
result
)
{
Logger
.
d
(
TAG
,
"onScanResult"
);
Logger
.
d
(
TAG
,
"onScanResult"
);
BluetoothDevice
device
=
result
.
getDevice
()
;
BluetoothDevice
device
=
result
.
getDevice
()
;
byte
[]
scanRecord
=
result
.
getScanRecord
().
getBytes
()
;
byte
[]
scanRecord
=
result
.
getScanRecord
().
getBytes
()
;
...
@@ -209,6 +212,12 @@ public class TR41BluetoothUtil {
...
@@ -209,6 +212,12 @@ public class TR41BluetoothUtil {
//mBluetoothLeScanner.stopScan(mScanCallback) ;
//mBluetoothLeScanner.stopScan(mScanCallback) ;
}
}
*/
*/
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mListener
.
onScanResult
(
callbackType
,
result
);
}
});
mBluetoothLeScanner
.
stopScan
(
mScanCallback
)
;
mBluetoothLeScanner
.
stopScan
(
mScanCallback
)
;
}
}
}
}
...
@@ -417,4 +426,51 @@ public class TR41BluetoothUtil {
...
@@ -417,4 +426,51 @@ public class TR41BluetoothUtil {
return
retStr
;
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
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