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
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1163 additions
and
59 deletions
+1163
-59
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
+826
-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
+68
-27
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
+157
-31
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
package
jp
.
agentec
.
abook
.
abv
.
cl
.
util
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattCharacteristic
;
import
android.bluetooth.BluetoothGattDescriptor
;
import
android.bluetooth.BluetoothGattService
;
import
android.bluetooth.BluetoothProfile
;
import
android.content.Context
;
import
android.util.Log
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.Timer
;
import
java.util.UUID
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
public
class
AlcoholCheckerUtil
{
public
static
final
String
TAG
=
"AlcoholCheckerUtil"
;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BLEService
public
static
final
String
ACTION_GATT_CONNECTED
=
"com.taiyoyuden.tysab_terminal.ACTION_GATT_CONNECTED"
;
/**
* @brief Intent broadcast when remote GATT server is no longer connected
* \hideinitializer
*/
public
static
final
String
ACTION_GATT_DISCONNECTED
=
"com.taiyoyuden.tysab_terminal.ACTION_GATT_DISCONNECTED"
;
/**
* @brief Intent broadcast when remote device service discovery is finished
* \hideinitializer
*/
public
static
final
String
ACTION_GATT_SERVICES
=
"com.taiyoyuden.tysab_terminal.ACTION_GATT_SERVICES"
;
/**
* @brief Intent broadcast on data received from remote device
* \hideinitializer
*/
public
static
final
String
ACTION_DATA_RECEIVED
=
"com.taiyoyuden.tysab_terminal.ACTION_DATA_RECEIVED"
;
// @PERIPHERAL_NAME
private
static
final
String
PERIPHERAL_NAME
=
"FALC-31"
;
public
static
final
UUID
CCCD
=
UUID
.
fromString
(
"00002902-0000-1000-8000-00805f9b34fb"
);
public
static
final
UUID
TY_SERVICE_UUID
=
UUID
.
fromString
(
"442F1570-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Service UUID
public
static
final
UUID
NOTIFICATION_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1571-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Read Notification Characteristic
public
static
final
UUID
WRITE_NO_RESPONSE_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1572-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Write No Response Characteristic
public
static
final
UUID
INDICATION_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1573-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Read Indication Characteristic
public
static
final
UUID
WRITE_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1574-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Write Characteristic
public
static
final
UUID
BATTERY_SERVICE_UUID
=
UUID
.
fromString
(
"0000180f-0000-1000-8000-00805f9b34fb"
);
public
static
final
UUID
BATTERY_LEVEL_UUID
=
UUID
.
fromString
(
"00002a19-0000-1000-8000-00805f9b34fb"
);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BLEService
// @
private
boolean
mIsBluetoothEnable
=
false
;
public
static
final
String
ACTION_PHY_READ
=
"com.taiyoyuden.tysab_terminal.ACTION_PHY_READ"
;
public
static
final
String
ACTION_DESCRIPTOR_WROTE
=
"com.taiyoyuden.tysab_terminal.ACTION_DESCRIPTOR_WROTE"
;
// @BLE Tx State
public
int
gi_status
;
// BLE Tx Status
public
boolean
gf_result_flg
;
// Conc Data Get
public
static
final
int
F_BLE_COM_INIT
=
0
;
// BLE Init
public
static
final
int
F_BLE_COM_RP_START
=
1
;
// RP Command Send
public
static
final
int
F_BLE_COM_RP_WAIT
=
2
;
// RP Command Send Wait
public
static
final
int
F_BLE_COM_RD_START
=
3
;
// RD Command Send
public
static
final
int
F_BLE_COM_RD_WAIT
=
4
;
// RD Command Send Wait
public
static
final
int
F_BLE_COM_RECONNECT1
=
5
;
// ReConecting(NOTIFICATION Disable)
public
static
final
int
F_BLE_COM_RECONNECT2
=
6
;
// ReConecting(Wait)
public
static
final
int
F_BLE_COM_RECONNECT3
=
7
;
// ReConecting(NOTIFICATION Enable)
// @BLE Command
public
static
final
String
F_BLE_COM_RP_COMMAND
=
"01525000A304"
;
public
static
final
String
F_BLE_COM_RD_COMMAND
=
"015244009704"
;
public
static
final
String
F_BLE_COM_FC_COMMAND
=
"01464301F37E04"
;
// 測定開始
public
static
final
String
F_BLE_COM_FC_COMMAND_F1
=
"01464301F17E04"
;
// BLE接続解除
public
static
final
String
F_BLE_COM_FC_COMMAND_F2
=
"01464301F27E04"
;
// 測定中断
// @BLE Rx
private
final
int
F_RX_BUFSIZE
=
32
;
private
byte
gb_rxdat
[]
=
new
byte
[
F_RX_BUFSIZE
];
public
int
gi_rxlength
;
public
final
int
F_RX_COMMAND_POS
=
1
;
// Command Position
private
final
int
F_RX_RP_LENGTH
=
8
;
private
final
byte
F_RP_COMMAND_MSB
=
(
byte
)
0x72
;
private
final
byte
F_RP_COMMAND_LSB
=
(
byte
)
0x70
;
private
final
int
F_RX_RP_MODE_POS
=
5
;
// RP MODE Position
private
final
int
F_RX_RD_LENGTH
=
28
;
private
final
byte
F_RD_COMMAND_MSB
=
(
byte
)
0x72
;
private
final
byte
F_RD_COMMAND_LSB
=
(
byte
)
0x64
;
private
final
int
F_RX_RD_DATA_POS
=
9
;
// Conc Data Position
public
int
gi_rxretry_cnt
;
// BLE Connect Error Retry Counter // @@@
private
enum
FORMAT
{
Ascii
,
Hex
};
private
enum
EOL_TYPE
{
None
,
CR
,
LF
,
CRLF
};
private
static
FORMAT
input_format
=
FORMAT
.
Ascii
;
private
static
EOL_TYPE
eol_type
=
EOL_TYPE
.
None
;
public
static
final
UUID
RX_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1571-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Rx Characteristic
public
static
final
UUID
TX_CHARACTERISTIC_UUID
=
UUID
.
fromString
(
"442F1572-8A00-9A28-CBE1-E1D4212D53EB"
);
// Taiyo Yuden Tx Characteristic
private
final
int
MAX_MESSAGE_COUNT
=
20
;
// Number of messages to show in UI
private
String
rxMessage
;
public
static
final
String
ACTION_TX_FINISHED
=
"com.taiyoyuden.tyapp_terminal.ACTION_TX_FINISHED"
;
public
static
final
String
ACTION_TX_ERROR
=
"com.taiyoyuden.tyapp_terminal.ACTION_TX_ERROR"
;
public
static
BluetoothGattCharacteristic
RxChar
;
// @@@
public
static
BluetoothGattCharacteristic
TxChar
;
// @@@
private
BluetoothGattService
TaiyoYudenService
;
private
BluetoothGattService
BatteryService
;
private
BluetoothGattCharacteristic
NotificationChar
;
private
BluetoothGattCharacteristic
WriteChar
;
public
BluetoothGattCharacteristic
IndicationChar
;
public
BluetoothGattCharacteristic
batteryLevelChar
;
private
int
connectionPHY
=
0
;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
private
Context
context
;
public
BleManagerUtil
bleManagerUtil
;
private
AlcoholCheckerUtilListener
listener
;
// @Timer
private
AlcoholCheckerTimerTask
alcoholCheckerTimerTask
=
null
;
public
AlcoholCheckerUtil
(
Context
context
,
AlcoholCheckerUtilListener
listener
)
{
this
.
context
=
context
;
this
.
listener
=
listener
;
}
// Bluetoothアダプタの取得処理
public
boolean
startGetDeviceInfo
()
{
// BLE管理
bleManagerUtil
=
new
BleManagerUtil
(
context
,
new
BleManagerUtilListener
()
{
@Override
public
void
onGetDeviceInfo
(
String
strTemperature
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onGetDeviceInfo = %s"
,
strTemperature
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onGetDeviceInfoFailed
(
int
status
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onGetDeviceInfoFailed = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onConnectionState
(
int
status
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onConnectionState = %s"
+
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
status
==
BluetoothProfile
.
STATE_CONNECTED
)
{
// Alert application that we have connected to a device // *2
// Begin service discovery on device
Log
.
i
(
TAG
,
"Connected to GATT server."
);
listener
.
onFugoAction
(
ACTION_GATT_CONNECTED
,
null
,
null
,
null
,
null
);
//sendBroadcast(new Intent(ACTION_GATT_CONNECTED));
// mBluetoothGatt.discoverServices(); // @@@@@
// @@@@@
if
(
bleManagerUtil
.
mBluetoothGatt
.
discoverServices
())
{
Logger
.
i
(
TAG
,
"Started discovering services"
);
// *3
}
else
{
Logger
.
i
(
TAG
,
"Failed to start discovering services"
);
}
// @@@@@
}
else
if
(
status
==
BluetoothProfile
.
STATE_DISCONNECTED
)
{
// Alert application that we disconnected from a device
if
(
bleManagerUtil
.
mBluetoothGatt
==
null
)
{
return
;
}
else
{
Logger
.
i
(
TAG
,
"Disconnected from GATT server."
);
listener
.
onFugoAction
(
ACTION_GATT_DISCONNECTED
,
null
,
null
,
null
,
null
);
//bmBluetoothGatt.close();
//mBluetoothGatt=null;
bleManagerUtil
.
disconnect
(
true
);
}
}
else
{
}
}
@Override
public
void
onDisConnectionState
()
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onDisConnectionState"
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onConnectionError
(
int
status
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onConnectionError = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onServicesDiscovered
(
int
status
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
)
{
Logger
.
i
(
TAG
,
"------------------------------------------------------ BluetoothGatt.GATT_SUCCESS"
);
Logger
.
i
(
TAG
,
"BluetoothGatt.GATT_SUCCESS"
);
// for (BluetoothGattService svc : gatt.getServices()){
// //Log.d(TAG,svc.getUuid().toString());
// System.out.println("" + svc.getUuid().toString());
// }
//listener.onFugoAction(ACTION_GATT_SERVICES,null, null, null, null);
Logger
.
i
(
TAG
,
"ACTION_GATT_SERVICES"
);
// Check if the required services are available
// Check if this is a Taiyo Yuden device
TaiyoYudenService
=
bleManagerUtil
.
mBluetoothGatt
.
getService
(
TY_SERVICE_UUID
);
if
(
TaiyoYudenService
==
null
)
{
Logger
.
i
(
TAG
,
"Not a TaiyoYuden device"
);
//Toast.makeText(getApplicationContext(), "Not a TaiyoYuden device", Toast.LENGTH_SHORT).show();
//mService.disconnectDevice();
}
else
{
// Check TX and RX UUIDs
// BluetoothGattCharacteristic RxChar = TaiyoYudenService.getCharacteristic(RX_CHARACTERISTIC_UUID);
// BluetoothGattCharacteristic TxChar = TaiyoYudenService.getCharacteristic(TX_CHARACTERISTIC_UUID);
RxChar
=
TaiyoYudenService
.
getCharacteristic
(
RX_CHARACTERISTIC_UUID
);
TxChar
=
TaiyoYudenService
.
getCharacteristic
(
TX_CHARACTERISTIC_UUID
);
// if (RxChar == null || TxChar == null) {
if
(
RxChar
==
null
||
TxChar
==
null
)
{
// TaiyoYuden device doesn't support Tx/Rx communication
System
.
out
.
println
(
"No Tx/Rx"
);
//Toast.makeText(getApplicationContext(), "Device is not running terminal service", Toast.LENGTH_SHORT).show();
}
else
{
System
.
out
.
println
(
"Terminal Start..............................."
);
// @Info
//mListener.onStartFugo();
//Intent fugosmartdemo = new Intent(getApplicationContext(), FugoSmartDemo.class);
// Stop Bluetooth scanning while the terminal activity is open
//mService.stopScan(mLeScanCallback);
// Start terminal application
//startActivityForResult(fugosmartdemo, REQUEST_OPEN_TERMINAL);
gi_status
=
F_BLE_COM_INIT
;
//((TextView)findViewById(R.id.txtStatus)).setText("F_BLE_COM_INIT");
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
;
bleManagerUtil
.
readPhyConnection
();
rxMessage
=
""
;
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
;
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
timer
();
}
});
thread
.
start
();
}
}
listener
.
onServicesDiscovered
(
status
);
//mIsBluetoothEnable = true;
}
else
{
//System.out.println("onServicesDiscovered received: " + status);
}
}
@Override
public
void
onCharacteristicChanged
(
BluetoothGatt
gatt
,
BluetoothGattCharacteristic
characteristic
)
{
Logger
.
i
(
TAG
,
"onCharacteristicChanged"
);
byte
[]
rx
=
characteristic
.
getValue
();
String
rxStr
=
" "
;
if
(
rx
!=
null
&&
rx
.
length
>
0
)
{
for
(
byte
rx1
:
rx
)
{
rxStr
+=
rx1
+
" ,"
;
}
}
final
String
printText
=
rxStr
;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
sub_rx_chk
(
rx
);
//printMessageToScreen(new String(rx));
}
});
if
(!
bleManagerUtil
.
startDeviceInfo
())
{
return
false
;
}
// 状態管理タイマースタート
// alcoholCheckerTimerTask = new AlcoholCheckerTimerTask(context, listener);
// Timer timer = new Timer(true);
// timer.schedule(alcoholCheckerTimerTask, 0, 1000);
return
true
;
}
private
void
timer
()
{
alcoholCheckerTimerTask
=
new
AlcoholCheckerTimerTask
(
this
,
listener
);
Timer
timer
=
new
Timer
(
true
);
timer
.
schedule
(
alcoholCheckerTimerTask
,
0
,
1000
);
}
private
void
init
()
{
rxMessage
=
""
;
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
;
}
public
void
connect
(
int
connectTargetDeviceType
,
String
deviceAddress
)
{
bleManagerUtil
.
connect
(
connectTargetDeviceType
,
deviceAddress
);
}
// 切断
public
void
disconnect
(
boolean
listenerFlg
)
{
bleManagerUtil
.
disconnect
(
listenerFlg
);
}
/**
* @param message Message to transmit
* <p>
* Message is converted to specified format (if non-Ascii) and transmitted to remote device using
* TxChar characteristic. As BLE can only handle 20 byte data payloads, this function handles delivery
* of sequential packets until entire message is successfully transmitted. The selected line endings
* will be appended prior to transmission
* @brief Handles delivery of message to connected device.
* @note This function is called on a non-UI thread to avoid blocking user interaction.
*/
public
void
sendMessage
(
String
message
)
{
// Send message on a separate thread so we don't hold up the UI
class
MessageSender
implements
Runnable
{
String
message
;
private
MessageSender
(
String
string
)
{
this
.
message
=
string
;
}
@Override
public
void
run
()
{
final
int
PACKET_SIZE
=
20
;
BluetoothGatt
s_mBluetoothGatt
;
// @@@
String
error_msg
=
""
;
try
{
// Convert our message to byte array in selected format
byte
[]
bMessage
=
message
.
getBytes
(
"UTF-8"
);
bMessage
=
hex2string
(
bMessage
);
// Requires NumberFormatException
if
(
bMessage
==
null
)
{
// Invalid message
Toast
.
makeText
(
context
,
"Invalid characters"
,
Toast
.
LENGTH_SHORT
).
show
();
throw
new
NumberFormatException
();
}
// We can only transmit in packets of 20 bytes
int
packet_start
=
0
;
while
(
packet_start
<
bMessage
.
length
)
{
// Trim the packet length if we have less than 20 to send
int
packet_end
=
(
bMessage
.
length
<
packet_start
+
PACKET_SIZE
)
?
bMessage
.
length
:
packet_start
+
PACKET_SIZE
;
// Construct and send this packet
byte
[]
chunk
=
new
byte
[
packet_end
-
packet_start
];
for
(
int
i
=
0
;
i
<
chunk
.
length
;
i
++)
{
chunk
[
i
]
=
bMessage
[
i
+
packet_start
];
}
TxChar
.
setValue
(
chunk
);
//if (!mBluetoothGatt.writeCharacteristic(TxChar))
s_mBluetoothGatt
=
bleManagerUtil
.
mBluetoothGatt
;
if
(!
s_mBluetoothGatt
.
writeCharacteristic
(
TxChar
))
{
throw
new
Exception
(
new
Throwable
());
}
packet_start
+=
PACKET_SIZE
;
Thread
.
sleep
(
10
);
// Requires InterruptedException
}
//System.out.println("Tx: " + message);
// @Mode Change
switch
(
gi_status
)
{
case
F_BLE_COM_RP_START:
listener
.
onUpdateStatus
(
"F_BLE_COM_RP_WAIT"
);
gi_status
=
F_BLE_COM_RP_WAIT
;
break
;
case
F_BLE_COM_RD_START:
listener
.
onUpdateStatus
(
"F_BLE_COM_RD_WAIT"
);
gi_status
=
F_BLE_COM_RD_WAIT
;
break
;
default
:
// None
break
;
}
}
catch
(
UnsupportedEncodingException
e
)
{
System
.
out
.
println
(
"Unsupported encoding exception"
);
}
catch
(
InterruptedException
e
)
{
System
.
out
.
println
(
"Interrupted exception"
);
}
catch
(
NumberFormatException
e
)
{
error_msg
=
"Invalid message format"
;
}
catch
(
Exception
e
)
{
error_msg
=
"Failed to send data"
;
}
//Intent intent;
if
(!
error_msg
.
equals
(
""
))
{
//intent = new Intent(ACTION_TX_ERROR);
//intent.putExtra("MESSAGE", error_msg);
listener
.
onFugoAction
(
ACTION_TX_ERROR
,
null
,
null
,
error_msg
,
null
);
}
else
{
//intent = new Intent(ACTION_TX_FINISHED);
//intent.putExtra("MESSAGE", message);
listener
.
onFugoAction
(
ACTION_TX_FINISHED
,
null
,
null
,
message
,
null
);
}
}
}
Thread
thread
=
new
Thread
(
new
MessageSender
(
message
));
thread
.
start
();
}
/**
* @return Hex formatted string
* @brief Converts a byte array of ascii to hexadecimal
*/
public
byte
[]
ascii2hex
(
byte
[]
bytes
)
{
byte
[]
result
=
new
byte
[
3
*
bytes
.
length
];
int
i
=
0
;
for
(
byte
b
:
bytes
)
{
// Upper nibble
byte
un
=
(
byte
)
((
b
>>
4
)
&
0xF
);
result
[
i
]
=
(
byte
)
(
un
>
9
?
un
+
0x37
:
un
+
0x30
);
// Lower nibble
byte
ln
=
(
byte
)
(
b
&
0xF
);
result
[
i
+
1
]
=
(
byte
)
(
ln
>
9
?
ln
+
0x37
:
ln
+
0x30
);
result
[
i
+
2
]
=
(
byte
)
' '
;
i
+=
3
;
}
return
null
;
//result; ;
}
/**
* @return Ascii formatted string
* @brief Converts a byte array of hexadecimal values to characters
*/
private
byte
[]
hex2string
(
byte
[]
bytes
)
{
ArrayList
<
Byte
>
in
=
new
ArrayList
<>(
bytes
.
length
+
1
);
byte
b
;
// Validate input
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
b
=
getValidHex
(
bytes
[
i
]);
switch
(
b
)
{
case
(
byte
)
0xFF
:
// Invalid character
return
null
;
case
(
byte
)
0xFE
:
// Ignore character
break
;
default
:
// Valid
in
.
add
(
Byte
.
valueOf
(
b
));
}
}
if
((
in
.
size
()
&
1
)
==
1
)
in
.
add
(
0
,
Byte
.
valueOf
(
"0"
));
// Construct bytes
byte
[]
out
=
new
byte
[
in
.
size
()
/
2
];
for
(
int
i
=
0
;
i
<
out
.
length
;
i
++)
{
byte
u
=
(
byte
)
(
in
.
get
(
i
*
2
)
<<
4
);
byte
l
=
in
.
get
(
2
*
i
+
1
);
out
[
i
]
=
(
byte
)
(
u
+
l
);
}
return
out
;
}
/**
* Checks if a character is a valid hexadecimal character
*
* @param b Hexadecimal value
* @return Ascii value of character, 0xFE if special character, 0xFF if invalid
*/
private
byte
getValidHex
(
byte
b
)
{
if
(
b
<
'0'
)
return
(
byte
)
0xFE
;
if
((
b
-
'0'
)
<=
'9'
-
'0'
)
return
(
byte
)
(
b
-
'0'
);
if
((
b
-
'A'
)
<=
'F'
-
'A'
)
return
(
byte
)
(
b
-
'A'
+
10
);
if
((
b
-
'a'
)
<=
'f'
-
'a'
)
return
(
byte
)
(
b
-
'a'
+
10
);
return
(
byte
)
0xFF
;
}
/* @Rx Command Check */
public
void
sub_rx_chk
(
byte
[]
rxdata
)
{
try
{
// Append to current stream output
sub_rx_data_gen
(
rxdata
);
// Mode
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
// BLE Init
break
;
case
F_BLE_COM_RP_WAIT:
// RP Command Send Wait
gi_status
=
fn_rx_rp_chk
(
rxdata
);
break
;
case
F_BLE_COM_RD_WAIT:
// RD Command Send Wait
gi_status
=
fn_rx_rd_chk
(
rxdata
);
break
;
default
:
// Others(Include Error)
gi_status
=
F_BLE_COM_RP_START
;
break
;
}
// System.out.println("after status");
switch
(
gi_status
)
{
case
F_BLE_COM_INIT:
// System.out.println("F_BLE_COM_INIT");
listener
.
onUpdateStatus
(
"F_BLE_COM_INIT"
);
break
;
case
F_BLE_COM_RP_WAIT:
// System.out.println("F_BLE_COM_RP_WAIT");
listener
.
onUpdateStatus
(
"F_BLE_COM_RP_WAIT"
);
break
;
case
F_BLE_COM_RD_WAIT:
// System.out.println("F_BLE_COM_RD_WAIT");
listener
.
onUpdateStatus
(
"F_BLE_COM_RD_WAIT"
);
break
;
default
:
// System.out.println("F_BLE_COM_RP_START");
listener
.
onUpdateStatus
(
"F_BLE_COM_RP_START"
);
break
;
}
}
catch
(
IndexOutOfBoundsException
e
)
{
// This is a new message
// messageLog.add(message);
}
//messageAdapter.notifyDataSetChanged();
}
/* @Read Flame Generation */
private
void
sub_rx_data_gen
(
byte
[]
rxdata
)
{
int
si_length
;
int
si_iloop
;
si_length
=
rxdata
.
length
;
// Buffer Size Check
if
((
gi_rxlength
+
si_length
)
<=
F_RX_BUFSIZE
)
{
// None
}
else
{
si_length
=
F_RX_BUFSIZE
-
gi_rxlength
;
}
if
(
si_length
>
0
)
{
for
(
si_iloop
=
0
;
si_iloop
<
si_length
;
si_iloop
++)
{
gb_rxdat
[
si_iloop
+
gi_rxlength
]
=
rxdata
[
si_iloop
];
}
gi_rxlength
+=
si_length
;
}
}
/* @RP Command Check */
private
int
fn_rx_rp_chk
(
byte
[]
rxdata
)
{
int
si_ret
;
byte
sb_mode
;
si_ret
=
F_BLE_COM_RP_WAIT
;
// Command Check
if
(
gi_rxlength
==
F_RX_RP_LENGTH
)
{
if
((
gb_rxdat
[
F_RX_COMMAND_POS
]
==
F_RP_COMMAND_MSB
)
&&
(
gb_rxdat
[(
F_RX_COMMAND_POS
+
1
)]
==
F_RP_COMMAND_LSB
))
{
sb_mode
=
gb_rxdat
[
F_RX_RP_MODE_POS
];
switch
(
sb_mode
)
{
case
(
byte
)
0x07
:
// Rest 3
listener
.
onUpdateTBVCalc
(
"3"
);
//((TextView) findViewById(R.id.TBV_Calc)).setText("3"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x08
:
// Rest 2
// ((TextView)findViewById(R.id.TBV_Calc)).setText("2"); // @
listener
.
onUpdateTBVCalc
(
"2"
);
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x09
:
// Rest 1
listener
.
onUpdateTBVCalc
(
"1"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("1"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0A
:
listener
.
onUpdateTBVCalc
(
"Go"
);
// Blow
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Go"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0B
:
// Blow After
listener
.
onUpdateTBVCalc
(
"Blow..."
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Blow..."); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0C
:
// Result
if
(
gf_result_flg
==
false
)
{
si_ret
=
F_BLE_COM_RD_START
;
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
//mListener.onUpdateTBVCalc("測定結果表示状態 0x0C");
break
;
case
(
byte
)
0x0D
:
// Wait
listener
.
onUpdateTBVCalc
(
"Wait"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Wait"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x0E
:
// Ready
listener
.
onUpdateTBVCalc
(
"Ready? 測定開始待ち状態 0x0E"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Ready?"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x11
:
// Error
if
(
gf_result_flg
==
false
)
{
si_ret
=
F_BLE_COM_RD_START
;
}
else
{
si_ret
=
F_BLE_COM_RP_START
;
}
listener
.
onUpdateTBVCalc
(
"エラー 0x11"
);
break
;
case
(
byte
)
0x12
:
// Failed
listener
.
onUpdateTBVCalc
(
"BreakDown"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Break Down"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x14
:
listener
.
onUpdateTBVCalc
(
"Low Battery"
);
// Low Battery
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Low Battery"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x15
:
// Calc
listener
.
onUpdateTBVCalc
(
"Calculationg"
);
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Calculating"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x1F
:
listener
.
onUpdateTBVCalc
(
"Over Used"
);
// Excess usage count
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Over Used"); // @
gf_result_flg
=
false
;
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x20
:
listener
.
onUpdateTBVCalc
(
"OFF"
);
// Power Down
// ((TextView)findViewById(R.id.TBV_Calc)).setText("OFF"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
case
(
byte
)
0x21
:
listener
.
onUpdateTBVCalc
(
"Data"
);
// Result Data Screen
// ((TextView)findViewById(R.id.TBV_Calc)).setText("Data"); // @
si_ret
=
F_BLE_COM_RP_START
;
break
;
default
:
// Others
si_ret
=
F_BLE_COM_RP_START
;
break
;
}
}
else
{
System
.
out
.
println
(
"RP Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
else
{
if
(
gi_rxlength
<
F_RX_RP_LENGTH
)
{
/* Receiving */
si_ret
=
F_BLE_COM_RP_WAIT
;
}
else
{
System
.
out
.
println
(
"RP Length Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
return
si_ret
;
}
private
int
fn_rx_fc_chk
(
byte
[]
rxdata
)
{
int
si_ret
;
byte
sb_data
;
short
ss_data
;
String
str_msg
;
si_ret
=
F_BLE_COM_RD_WAIT
;
return
si_ret
;
}
/* @RD Command Check */
private
int
fn_rx_rd_chk
(
byte
[]
rxdata
)
{
int
si_ret
;
byte
sb_data
;
short
ss_data
;
String
str_msg
;
si_ret
=
F_BLE_COM_RD_WAIT
;
// Command Check
if
(
gi_rxlength
==
F_RX_RD_LENGTH
)
{
if
((
gb_rxdat
[
F_RX_COMMAND_POS
]
==
F_RD_COMMAND_MSB
)
&&
(
gb_rxdat
[(
F_RX_COMMAND_POS
+
1
)]
==
F_RD_COMMAND_LSB
))
{
sb_data
=
gb_rxdat
[
F_RX_RD_DATA_POS
];
str_msg
=
""
;
// Change Range from (-128 to 127) to (0 to 255)
if
(
sb_data
>=
0
)
{
ss_data
=
(
short
)
sb_data
;
}
else
{
ss_data
=
(
short
)
(
256
+
(
short
)
sb_data
);
}
// Message
if
((
ss_data
>=
0
)
&&
(
ss_data
<
(
short
)
0xE0
))
{
if
(
ss_data
>=
(
short
)
100
)
{
str_msg
=
"1.00"
;
}
else
{
str_msg
=
"0."
;
str_msg
+=
String
.
format
(
"%1$02d"
,
ss_data
);
}
str_msg
+=
"[mg/L]"
;
//((TextView)findViewById(R.id.TBV_Calc)).setText(str_msg); // @
listener
.
onUpdateTBVCalc
(
str_msg
+
" 0x0C 測定結果表示状態"
);
}
else
{
// Error
//((TextView)findViewById(R.id.TBV_Calc)).setText("Error"); // @
listener
.
onUpdateTBVCalc
(
"Error"
);
}
gf_result_flg
=
true
;
si_ret
=
F_BLE_COM_RP_START
;
}
else
{
System
.
out
.
println
(
"RD Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
else
{
if
(
gi_rxlength
<
F_RX_RD_LENGTH
)
{
/* Receiving */
si_ret
=
F_BLE_COM_RD_WAIT
;
}
else
{
System
.
out
.
println
(
"RD Length Error"
);
si_ret
=
F_BLE_COM_RP_START
;
}
}
return
si_ret
;
}
// @@@@@
public
void
DescriptorDevice
(
BluetoothGattCharacteristic
uRxChar
,
UUID
ucccd
)
{
bleManagerUtil
.
DescriptorDevice
(
uRxChar
,
ucccd
);
}
// @@@@@
public
void
NotificationDisable
(
BluetoothGattCharacteristic
uRxChar
,
UUID
ucccd
)
{
bleManagerUtil
.
NotificationDisable
(
uRxChar
,
ucccd
);
}
}
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
;
...
...
@@ -53,6 +56,7 @@ public class BleManagerUtil {
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
package
jp
.
agentec
.
abook
.
abv
.
ui
.
common
.
activity
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothGatt
;
import
android.bluetooth.BluetoothGattDescriptor
;
import
android.bluetooth.BluetoothGattService
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
...
...
@@ -40,8 +43,11 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Timer
;
import
java.util.UUID
;
import
java.util.concurrent.ConcurrentHashMap
;
import
jp.agentec.abook.abv.bl.acms.client.AcmsClient
;
import
jp.agentec.abook.abv.bl.acms.type.OperationType
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.Callback
;
...
...
@@ -62,6 +68,8 @@ import jp.agentec.abook.abv.bl.logic.OperationLogic;
import
jp.agentec.abook.abv.bl.websocket.MeetingManager
;
import
jp.agentec.abook.abv.cl.environment.DeviceInfo
;
import
jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper
;
import
jp.agentec.abook.abv.cl.util.AlcoholCheckerUtil
;
import
jp.agentec.abook.abv.cl.util.AlcoholCheckerUtilListener
;
import
jp.agentec.abook.abv.cl.util.AndroidStringUtil
;
import
jp.agentec.abook.abv.cl.util.BleManagerUtil
;
import
jp.agentec.abook.abv.cl.util.ContentLogUtil
;
...
...
@@ -94,6 +102,7 @@ import jp.agentec.adf.util.FileUtil;
import
jp.agentec.adf.util.StringUtil
;
import
static
jp
.
agentec
.
abook
.
abv
.
bl
.
common
.
Constant
.
ReportType
.
RoutineTask
;
import
static
jp
.
agentec
.
abook
.
abv
.
cl
.
util
.
AlcoholCheckerUtil
.
INDICATION_CHARACTERISTIC_UUID
;
public
abstract
class
ABVContentViewActivity
extends
ABVAuthenticatedActivity
{
...
...
@@ -167,12 +176,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private
static
final
int
REQUEST_CODE_ENABLEBLUETOOTH_SPP_MACHINE
=
2005
;
// Bluetooth機能の有効化要求時の識別コード(SPP通信機器)
private
static
final
int
REQUEST_CODE_ENABLEBLUETOOTH_TR41
=
2006
;
// Bluetooth機能の有効化要求時の識別コード(TR41温度センサー)
private
static
final
int
REQUEST_CODE_ENABLEBLUETOOTH_ALCOHL_CHECKER
=
2007
;
// Bluetooth機能の有効化要求時の識別コード(TR41温度センサー)
// Bluetooth機器連携
private
BleManagerUtil
bleManagerUtil
;
// Bluetoothの接続
// アルコールチェッカー
private
AlcoholCheckerUtil
alcoholCheckerUtil
;
// Bluetoothの接続状態
private
boolean
mIsConnection
;
//待ち状態の時画面に表示するダイアログ
protected
ABookAlertDialog
mWaitingDialog
;
// 計測用ダイアログ
private
ABookAlertDialog
mMeasureDialog
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -223,35 +235,130 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
/
** アルコールチェッカー関連 開始 **/
bleManagerUtil
=
new
BleManagerUtil
(
this
,
new
BleManagerUtil
.
BleManag
erUtilListener
()
{
/
/ アルコールチェッカースタート
alcoholCheckerUtil
=
new
AlcoholCheckerUtil
(
this
,
new
AlcoholCheck
erUtilListener
()
{
@Override
public
void
onGetDeviceInfo
(
String
strTemperature
)
{
public
void
onFugoAction
(
String
action
,
UUID
CHAR
,
byte
[]
data
,
String
MESSAGE
,
String
Type
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onFugoAction = %s"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_GATT_CONNECTED
))
{
Logger
.
i
(
TAG
,
"ACTION_GATT_CONNECTED"
);
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_GATT_DISCONNECTED
))
{
Logger
.
i
(
TAG
,
"ACTION_GATT_DISCONNECTED"
);
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_DATA_RECEIVED
))
{
Logger
.
i
(
TAG
,
"ACTION_DATA_RECEIVED"
);
// if (messageAdapter.getCurrentDirection() != 'R'){
// messageAdapter.newMessage('R');
// }
byte
[]
rx
=
data
;
String
rxStr
=
" "
;
if
(
rx
!=
null
&&
rx
.
length
>
0
)
{
for
(
byte
rx1
:
rx
)
{
rxStr
+=
rx1
+
" ,"
;
}
}
final
String
printText
=
rxStr
;
@Override
public
void
onGetDeviceInfoFailed
(
int
status
)
{
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// ViewRecieved.setText(printText);
// }
// });
alcoholCheckerUtil
.
sub_rx_chk
(
rx
);
//printMessageToScreen(new String(rx));
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_TX_FINISHED
))
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_TX_FINISHED = %s"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
// Finished transmitting, display to screen and clear message
// if (messageAdapter.getCurrentDirection() != 'T'){
// messageAdapter.newMessage('T');
// }
//printMessageToScreen(MESSAGE);
// ((EditText) findViewById(com.taiyoyuden.tyapp_terminal.R.id.txt_txmessage)).setText("");
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_TX_ERROR
))
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_TX_ERROR"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
// An error occurred during sending, display the message (don't clear text - allow user to edit)
// Toast.makeText(getApplicationContext(),intent.getStringExtra("MESSAGE"),Toast.LENGTH_SHORT).show();
}
else
if
(
action
.
equals
(
AlcoholCheckerUtil
.
ACTION_DESCRIPTOR_WROTE
))
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_DESCRIPTOR_WROTE"
,
action
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
if
(
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
getService
(
AlcoholCheckerUtil
.
TY_SERVICE_UUID
).
getCharacteristic
(
AlcoholCheckerUtil
.
INDICATION_CHARACTERISTIC_UUID
)
==
null
)
{
Logger
.
i
(
TAG
,
"Old Version."
);
// This version doesn't support latest characteristics
return
;
}
if
(
Type
.
equals
(
"Notification"
))
{
// Enable indication on receiving data
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
alcoholCheckerUtil
.
IndicationChar
,
true
);
BluetoothGattDescriptor
indication_descriptor
=
alcoholCheckerUtil
.
IndicationChar
.
getDescriptor
(
AlcoholCheckerUtil
.
CCCD
);
indication_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_INDICATION_VALUE
);
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
indication_descriptor
);
}
else
if
(
Type
.
equals
(
"Indication"
))
{
// Enable notification on receiving data
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
setCharacteristicNotification
(
alcoholCheckerUtil
.
batteryLevelChar
,
true
);
BluetoothGattDescriptor
notification_descriptor
=
alcoholCheckerUtil
.
batteryLevelChar
.
getDescriptor
(
AlcoholCheckerUtil
.
CCCD
);
notification_descriptor
.
setValue
(
BluetoothGattDescriptor
.
ENABLE_NOTIFICATION_VALUE
);
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothGatt
.
writeDescriptor
(
notification_descriptor
);
}
}
}
@Override
public
void
onConnectionState
()
{
public
void
onUpdateTBVCalc
(
String
text
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onUpdateTBVCalc = %s"
,
text
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
alcoholCheckerUtil
.
sendMessage
(
AlcoholCheckerUtil
.
F_BLE_COM_FC_COMMAND
);
}
@Override
public
void
onDisConnectionState
()
{
public
void
onUpdateStatus
(
String
text
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onUpdateStatus = %s"
,
text
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onUpdateSendMessage
(
String
text
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onFugoActonUpdateSendMessageion = %s"
,
text
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onConnectionError
(
int
status
)
{
public
void
onUpdateReceivedData
(
String
text
)
{
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onUpdateReceivedData = %s"
,
text
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
}
@Override
public
void
onServicesDiscovered
(
int
status
){
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"onServicesDiscovered = %s"
,
status
);
Logger
.
i
(
TAG
,
"------------------------------------"
);
Logger
.
i
(
TAG
,
"ACTION_GATT_SERVICES"
);
}
});
if
(!
alcoholCheckerUtil
.
startGetDeviceInfo
())
{
// 端末がBluetoothをサポートしていないなどの理由で、アルコールチェッカーが使えない
Logger
.
e
(
TAG
,
"bluetooth damedame."
);
}
// 遠隔連動
meetingManager
=
MeetingManager
.
getInstance
();
isCollaboration
=
meetingManager
.
isCollaboration
();
...
...
@@ -968,14 +1075,22 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// showHelpViewDialog(helpViewType);
// }
private
void
bleManagerDisconnect
(
boolean
disconnect
)
{
/**
* 中心温度計の接続を切る
* #39006 【@Form】(要望)中心温度計 放射温度計の連続計測対応
*/
protected
void
bleManagerDisconnect
()
{
// onuma ここでは切らない
//bleManagerUtil.disconnect(true);
}
private
void
alcoholCheckerUtilbleManagerDisconnect
(
boolean
disconnect
)
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"bleManagerDisconnect = "
+
disconnect
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
if
(
disconnect
){
mIsConnection
=
false
;
bleManag
erUtil
.
disconnect
(
true
);
alcoholCheck
erUtil
.
disconnect
(
true
);
}
else
{
// 何もしない
}
...
...
@@ -990,7 +1105,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
responseJson
.
put
(
ABookKeys
.
TASK_QUESTION_ID
,
mQid
);
responseJson
.
put
(
"value"
,
value
);
afterABookCheckApi
(
mCmd
,
""
,
0
,
""
,
responseJson
.
toString
());
Logger
.
d
(
TAG
,
"successAfterAbookCheckAip JSON [%s]"
,
responseJson
.
toString
());
Logger
.
i
(
TAG
,
"successAfterAbookCheckAip JSON [%s]"
,
responseJson
.
toString
());
}
/**
...
...
@@ -999,24 +1114,29 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @param message 内容
*/
private
void
showWaitingDialog
(
String
title
,
String
message
)
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"showWaitingDialog"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"showWaitingDialog"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
//待機状態のダイヤログ表示
mWaitingDialog
=
AlertDialogUtil
.
createAlertDialog
(
this
,
title
);
mWaitingDialog
.
setMessage
(
message
);
mWaitingDialog
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getResources
().
getString
(
R
.
string
.
pairing_search_stop
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Logger
.
d
(
TAG
,
"waiting Dialog stop click : "
+
mDeviceType
);
Logger
.
i
(
TAG
,
"waiting Dialog stop click : "
+
mDeviceType
);
switch
(
mDeviceType
)
{
case
Constant
.
DeviceType
.
centerThermomete
:
case
Constant
.
DeviceType
.
radiationThermomete
:
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"放射・中心温度計 アルコールチェッカー接続待中止"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
alcoholCheckerUtilbleManagerDisconnect
(
true
);
// 放射温度計、中心温度計接続切断
break
;
case
Constant
.
DeviceType
.
alcoholChecker
:
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"放射・中心温度計
接続待中止"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
bleManagerDisconnect
(
true
);
// 放射温度計、中心温度計接続切断
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
Logger
.
i
(
TAG
,
"アルコールチェッカー
接続待中止"
);
Logger
.
i
(
TAG
,
"-------------------------------------------------"
);
alcoholCheckerUtilbleManagerDisconnect
(
true
);
break
;
// case Constant.DeviceType.sensor:
// stopOkudakeBeaconScan(); // 置くだけセンサースキャン中止
...
...
@@ -1063,7 +1183,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
* @return true:bluetooth ON, false:bluetooth OFF
*/
private
boolean
requestBluetoothFeature
(
int
requestCode
)
{
if
(
bleManagerUtil
.
mBluetoothAdapter
.
isEnabled
())
{
if
(
alcoholCheckerUtil
.
bleManagerUtil
.
mBluetoothAdapter
.
isEnabled
())
{
return
true
;
}
// デバイスのBluetooth機能が有効になっていないときは、有効化要求(ダイアログ表示)
...
...
@@ -1073,9 +1193,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
/**
* BLEディバイスの
中心温度計
の情報取得
* BLEディバイスの
アルコールチェッカー
の情報取得
*/
private
void
setCenterThermometer
DeviceInfo
()
{
private
void
initGet
DeviceInfo
()
{
if
(
requestBluetoothFeature
(
REQUEST_CODE_ENABLEBLUETOOTH_ALCOHL_CHECKER
))
{
//端末のBluetooth設定を確認
String
deviceAddress
=
getABVUIDataCache
().
getPairingBluetoothDeviceAddress
(
Constant
.
DeviceType
.
alcoholChecker
);
...
...
@@ -1090,13 +1210,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger
.
d
(
TAG
,
"isConnection = true"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
String
message
=
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_success
),
getString
(
R
.
string
.
alcohl_checker
));
showWaitingDialog
(
getString
(
R
.
string
.
center_thermomet
er
),
message
);
showWaitingDialog
(
getString
(
R
.
string
.
alcohl_check
er
),
message
);
}
else
{
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
Logger
.
d
(
TAG
,
"isConnection = false"
);
Logger
.
d
(
TAG
,
"-------------------------------------------------"
);
// 登録されている中心温度計がある
showWaitingDialog
(
getString
(
R
.
string
.
center_thermomet
er
),
getString
(
R
.
string
.
ble_connecting
));
showWaitingDialog
(
getString
(
R
.
string
.
alcohl_check
er
),
getString
(
R
.
string
.
ble_connecting
));
// 接続
bleManagerUtil
.
connect
(
Constant
.
DeviceType
.
centerThermomete
,
deviceAddress
);
alcoholCheckerUtil
.
connect
(
Constant
.
DeviceType
.
alcoholChecker
,
deviceAddress
);
}
}
}
...
...
@@ -1110,6 +1233,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mDeviceType
=
Constant
.
DeviceType
.
alcoholChecker
;
mQid
=
"1"
;
initGetDeviceInfo
();
}
/**
...
...
@@ -1130,9 +1255,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mTaskKey
=
abookCheckParam
.
get
(
ABookKeys
.
TASK_KEY
);
}
// アルコールチェッカーテスト
if
(
mCmd
.
equals
(
ABookKeys
.
CMD_
INSERT_TASK_REPORT
)
||
mCmd
.
equals
(
ABookKeys
.
CMD_
CANCEL_TASK_REPORT
))
{
mCmd
=
ABookKeys
.
CMD_GET_DEVICE_INFO
;
if
(
mCmd
.
equals
(
ABookKeys
.
CMD_CANCEL_TASK_REPORT
))
{
//
mCmd = ABookKeys.CMD_GET_DEVICE_INFO;
getDeviceInfo
(
abookCheckParam
);
return
;
}
int
taskReportLevel
=
0
;
// 作業報告レベル(0:報告、1:報告(回答)、2:報告(回答))
...
...
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