设备连接微调
This commit is contained in:
1 parent
afb8c358f5
commit
ad26419654
7 files changed
+55
-21
No files matched your search
@@ -211,6 +211,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
this.callbacks.Add(info, callback);
|
||||
}
|
||||
Debug.Log("try connect device" + info.Name + this.callbacks.Count.ToString());
|
||||
if (this.callbacks.Count == 1)
|
||||
{
|
||||
BleResponse s = new BleResponse();
|
||||
@@ -221,6 +222,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
callback?.Invoke(self, info, s);
|
||||
this.callbacks.Remove(info);
|
||||
Debug.Log("连接成功!");
|
||||
if (this.callbacks.Any())
|
||||
{
|
||||
this.ConnectPeripheral(this.callbacks.First().Key, this.callbacks.First().Value);
|
||||
@@ -233,6 +235,7 @@ namespace Assets.Scripts.Ble
|
||||
CharacteristicsDiscovered(address, service, characteristic);
|
||||
}, (address) =>
|
||||
{
|
||||
Debug.Log("disconnect device:" + address);
|
||||
PeripheralDisconnected(address, info);
|
||||
});
|
||||
}
|
||||
@@ -311,6 +314,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
BluetoothLEHardwareInterface.DisconnectPeripheral(peripheral.Address, (address) =>
|
||||
{
|
||||
Debug.Log("断开回调"+ address);
|
||||
peripheralDisconnectedEvent(this, peripheral, null, true);
|
||||
callback?.Invoke();
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MainController : BaseScene
|
||||
//rect1.offsetMax = Vector2.zero;
|
||||
//transform.Find("ModalPanel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
|
||||
#endif
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
//App.MainDeviceAdapter.StartScan();
|
||||
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ public class MainController : BaseScene
|
||||
scanTicks++;
|
||||
if (scanTicks == 10)
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
Debug.Log("StopScan");
|
||||
//App.MainDeviceAdapter.StopScan();
|
||||
//Debug.Log("StopScan");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
{
|
||||
if (item.Value.DeviceInfo.Sensor == SensorType.SpeedCadence || item.Value.DeviceInfo.Sensor == SensorType.Cadence)
|
||||
{
|
||||
//Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
|
||||
Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
DeviceCache.Remove(item.Value.DeviceInfo);
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class DeviceView : MonoBehaviour
|
||||
mSearchButton.SetActive(false);
|
||||
mPairButton.SetActive(true);
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
searchState.gameObject.SetActive(false);
|
||||
//searchState.gameObject.SetActive(false);
|
||||
#endif
|
||||
logo.sprite = sprite1;
|
||||
|
||||
@@ -275,8 +275,13 @@ public class DeviceView : MonoBehaviour
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
#if (UNITY_IOS || UNITY_ANDROID)
|
||||
mPairButton.SetActive(true);
|
||||
searchState.gameObject.SetActive(true);
|
||||
#endif
|
||||
searchState.text = "Connecting...";
|
||||
|
||||
|
||||
}
|
||||
else if (connectedDevice.State == DeviceState.Connected)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user