|
@@ -210,7 +210,8 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
private val mSearchResponse: SearchResponse = object : SearchResponse {
|
|
|
override fun onSearchStarted() {
|
|
|
BluetoothLog.w("MainActivity.onSearchStarted")
|
|
|
- sing_pbar.visibility = View.VISIBLE
|
|
|
+ //sing_pbar.visibility = View.VISIBLE
|
|
|
+ updateConnectState("正在搜索...", true)
|
|
|
}
|
|
|
|
|
|
override fun onDeviceFounded(device: SearchResult) {
|
|
@@ -228,12 +229,13 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
.build()
|
|
|
ClientManager.getClient().connect(device.getAddress(), options) { code, profile ->
|
|
|
BluetoothLog.v(TAG + String.format("profile:\n%s", profile))
|
|
|
+ updateConnectState("", false)
|
|
|
if (code == Constants.REQUEST_SUCCESS) {
|
|
|
//连接成功
|
|
|
if(dv_type==1){
|
|
|
ClientManager.getClient().notify(bt_mac, xy_mService, xy_mCharacter1, xy_mNotifyRsp)
|
|
|
ClientManager.getClient().registerConnectStatusListener(bt_mac, mBleConnectStatusListener)
|
|
|
- sing_pbar.visibility = View.VISIBLE
|
|
|
+ //sing_pbar.visibility = View.VISIBLE
|
|
|
WifiSetDialogHelper.showDialog(activity, 7)
|
|
|
}else if (dv_type==2){
|
|
|
ClientManager.getClient().notify(bt_mac, xy_mService, xy_mCharacter2, xya_mNotifyRsp)
|
|
@@ -266,7 +268,8 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
|
|
|
override fun onSearchStopped() {
|
|
|
BluetoothLog.w("MainActivity.onSearchStopped")
|
|
|
- sing_pbar.visibility = View.GONE
|
|
|
+ //sing_pbar.visibility = View.GONE
|
|
|
+ updateConnectState("", false)
|
|
|
if (isbtopen){
|
|
|
isbtopen =false
|
|
|
}else{
|
|
@@ -278,7 +281,8 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
|
|
|
override fun onSearchCanceled() {
|
|
|
BluetoothLog.w("MainActivity.onSearchCanceled")
|
|
|
- sing_pbar.visibility = View.GONE
|
|
|
+ //sing_pbar.visibility = View.GONE
|
|
|
+ updateConnectState("", false)
|
|
|
if (isbtopen){
|
|
|
isbtopen =false
|
|
|
}else{
|
|
@@ -330,6 +334,16 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ fun updateConnectState(text: String, show: Boolean) {
|
|
|
+ if (show) {
|
|
|
+ tv_connect_state.text = text
|
|
|
+ ll_ble_connect.visibility = View.VISIBLE
|
|
|
+ } else {
|
|
|
+ tv_connect_state.text = ""
|
|
|
+ ll_ble_connect.visibility = View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
fun onMoonEvent(messageEvent: MessageEvent) {
|
|
|
when (messageEvent.getType()) {
|
|
@@ -349,11 +363,12 @@ class MainFragment: BaseFragment<BedMainFragmentPresenter, MainViewLayoutBindin
|
|
|
var substring2 = String.format("%s", ByteUtils.byteToString(value)).substring(6, 8)
|
|
|
var substring3 = String.format("%s", ByteUtils.byteToString(value)).substring(8, 10)
|
|
|
BluetoothLog.v(TAG + "收到血氧数据"+substring+substring3)
|
|
|
- if (substring.equals("FF") && !substring3.equals("0")){
|
|
|
+ if (substring.equals("FF") && !substring2.equals("0")){
|
|
|
if (!xy_number.equals("")){
|
|
|
xy_number = BluetoothUtil.hexToDecimal(substring3).toString()
|
|
|
}
|
|
|
- sing_pbar.visibility = View.GONE
|
|
|
+ //sing_pbar.visibility = View.GONE
|
|
|
+ updateConnectState("", false)
|
|
|
isbtopen =false
|
|
|
WifiSetDialogHelper.showDialog(activity,5)
|
|
|
ClientManager.getClient().disconnect(bt_mac)
|