解决io设备连接&android卡顿问题

This commit is contained in:
lishuo 2022-07-14 13:37:33 +08:00
parent 342740b740
commit a588716b30
8 changed files with 13 additions and 41 deletions

1
.gitignore vendored
View File

@ -107,3 +107,4 @@ Assets/AVProVideo.meta
Packages Packages
Assets/Tree_Textures.meta Assets/Tree_Textures.meta
Packages Packages
Assets/FacebookSDK/SDK/Resources.meta

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 43702c51e269ba844b251a6b0dc2c3ee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,7 +3,7 @@
<queries> <queries>
<package android:name="com.tencent.mm" /> <package android:name="com.tencent.mm" />
<package android:name="com.zhixingpai.powerfun" /> <package android:name="com.zhixingpai.powerfun" />
<package android:name="com.facebook.katana" /> <package android:name="com.facebook.katana" />
</queries> </queries>
<application android:requestLegacyExternalStorage="true"> <application android:requestLegacyExternalStorage="true">
<activity android:name="com.unityplugins.imageselector.TestMainActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false"> <activity android:name="com.unityplugins.imageselector.TestMainActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">

View File

@ -477,7 +477,7 @@ public class BluetoothLEHardwareInterface
#endif #endif
} }
public static void ScanForPeripheralsWithServices (string[] serviceUUIDs, Action<string, string> action = null, Action<string, string, int, string[]> actionAdvertisingInfo = null, bool rssiOnly = false, bool clearPeripheralList = true, int recordType = 0xFF) public static void ScanForPeripheralsWithServices (string[] serviceUUIDs, Action<string, string> action = null, Action<string, string, int, string[]> actionAdvertisingInfo = null, bool rssiOnly = false, bool clearPeripheralList = false, int recordType = 0xFF)
{ {
#if !UNITY_EDITOR_OSX || !EXPERIMENTAL_MACOS_EDITOR #if !UNITY_EDITOR_OSX || !EXPERIMENTAL_MACOS_EDITOR
if (!Application.isEditor) if (!Application.isEditor)

View File

@ -126,15 +126,8 @@ namespace Assets.Scripts.Devices.Ble
if (this.State != DeviceState.Disconnected) if (this.State != DeviceState.Disconnected)
{ {
Debug.Log("断开设备" + this.Name); Debug.Log("断开设备" + this.Name);
//App.MainDeviceAdapter.PrintStatus();
//this.State = DeviceState.Disconnected;
this.hwInterface.DisconnectPeripheral(this.peripheralInfo, () => { this.hwInterface.DisconnectPeripheral(this.peripheralInfo, () => {
//App.MainDeviceAdapter.PrintStatus();
this.State = DeviceState.Disconnected; this.State = DeviceState.Disconnected;
}); });
} }
} }
@ -247,8 +240,6 @@ namespace Assets.Scripts.Devices.Ble
public override void Disconnect(bool save = true) public override void Disconnect(bool save = true)
{ {
//throw new NotImplementedException();
//this.hwInterface.DisconnectPeripheral(this.peripheralInfo, null);
this.Disconnect(); this.Disconnect();
} }

View File

@ -30,7 +30,6 @@ namespace Assets.Scripts.Devices.Ble
private void HwInterface_BluetoothStateChangedEvent(IBleWinHwInterface hwInterface, BleState bleState) private void HwInterface_BluetoothStateChangedEvent(IBleWinHwInterface hwInterface, BleState bleState)
{ {
//Debug.Log("22222222222222" + bleState);
if(bleState == BleState.Off) if(bleState == BleState.Off)
{ {
discoveredDevices.Clear(); discoveredDevices.Clear();
@ -136,20 +135,7 @@ namespace Assets.Scripts.Devices.Ble
//TODO:取消注释,自动连接设备 //TODO:取消注释,自动连接设备
//Debug.Log("自动连接" + device111.Id); //Debug.Log("自动连接" + device111.Id);
if (App.IsRowerMode == true) device111.Connect();
{
if (device111.Sensor == Ant.SensorType.Rower || device111.Sensor == Ant.SensorType.HeartRate)
{
device111.Connect();
}
}
else if(App.IsRowerMode == false)
{
if (device111.Sensor != Ant.SensorType.Rower)
{
device111.Connect();
}
}
} }
} }

View File

@ -146,23 +146,25 @@ namespace Assets.Scenes.Ride.Scripts.Network
return Encoding.UTF8.GetString(buffer); return Encoding.UTF8.GetString(buffer);
} }
private string temp = ""; private StringBuilder temp = new StringBuilder();
protected override void OnReceived(byte[] buffer, long offset, long size) protected override void OnReceived(byte[] buffer, long offset, long size)
{ {
//base.OnReceived(buffer, offset, size); //base.OnReceived(buffer, offset, size);
var returnData = Encoding.UTF8.GetString(buffer, (int)offset, (int)size); var returnData = Encoding.UTF8.GetString(buffer, (int)offset, (int)size);
//*sdfsd#*sdfsd#*sdfsd#*sdfsd# //*sdfsd#*sdfsd#*sdfsd#*sdfsd#
foreach (var item in returnData) foreach (var item in returnData)
{ {
if (item != '*' && item != '#') if (item != '*' && item != '#')
{ {
temp += item; temp.Append(item);
} }
if (item == '#') if (item == '#')
{ {
//解压 temp //解压 temp
var uncompressStr = Decompress(Convert.FromBase64String(temp)); var uncompressStr = Decompress(Convert.FromBase64String(temp.ToString()));
#if UNITY_EDITOR #if UNITY_EDITOR
Console.WriteLine(uncompressStr); Console.WriteLine(uncompressStr);
#endif #endif
@ -176,7 +178,7 @@ namespace Assets.Scenes.Ride.Scripts.Network
{ {
var l = t.Replace("l{", "").Replace("}", ""); var l = t.Replace("l{", "").Replace("}", "");
var itemList = l.Split('|'); var itemList = l.Split('|');
temp = ""; temp.Clear();
foreach (var obj in itemList) foreach (var obj in itemList)
{ {

View File

@ -61,9 +61,9 @@ namespace Assets.Scenes.Ride.Scripts
cadance = mainController.UpdateCadence(); cadance = mainController.UpdateCadence();
weight = App.CurrentUser.Weight; weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight; bicycleWeight = App.CurrentUser.BicycleWeight;
#if UNITY_EDITOR //#if UNITY_EDITOR
power = 300; power = 300;
#endif //#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100); mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
} }
catch (Exception ex) catch (Exception ex)