diff --git a/Source/BLE.Client/BLE.Client/ViewModels/DeviceListViewModel.cs b/Source/BLE.Client/BLE.Client/ViewModels/DeviceListViewModel.cs index 44b10cf5..37f16d29 100644 --- a/Source/BLE.Client/BLE.Client/ViewModels/DeviceListViewModel.cs +++ b/Source/BLE.Client/BLE.Client/ViewModels/DeviceListViewModel.cs @@ -456,6 +456,9 @@ private async void ConnectAndDisposeDevice(DeviceListItemViewModel item) var resultMTU = await item.Device.RequestMtuAsync(60); System.Diagnostics.Debug.WriteLine($"Requested MTU. Result is {resultMTU}"); + var resultInterval = await item.Device.UpdateConnectionIntervalAsync(ConnectionInterval.High); + System.Diagnostics.Debug.WriteLine($"Set Connection Interval. Result is {resultInterval}"); + item.Update(); _userDialogs.ShowSuccess($"Connected {item.Device.Name}"); diff --git a/Source/Plugin.BLE.Abstractions/ConnectionInterval.cs b/Source/Plugin.BLE.Abstractions/ConnectionInterval.cs new file mode 100644 index 00000000..83fbfbe1 --- /dev/null +++ b/Source/Plugin.BLE.Abstractions/ConnectionInterval.cs @@ -0,0 +1,10 @@ +using System; +namespace Plugin.BLE.Abstractions +{ + public enum ConnectionInterval + { + Normal = 0, + High = 1, + Low = 2 + } +} diff --git a/Source/Plugin.BLE.Abstractions/Contracts/IDevice.cs b/Source/Plugin.BLE.Abstractions/Contracts/IDevice.cs index b3c057d8..e0b75468 100644 --- a/Source/Plugin.BLE.Abstractions/Contracts/IDevice.cs +++ b/Source/Plugin.BLE.Abstractions/Contracts/IDevice.cs @@ -89,5 +89,18 @@ public interface IDevice : IDisposable /// A task that represents the asynchronous operation. The result contains the negotiated MTU size between master and slave /// The requested MTU Task RequestMtuAsync(int requestValue); + + /// + /// Requests a bluetooth-le connection update request. Be aware that this is only implemented on Android (>= API 21). + /// You can choose between a high, low and a normal mode which will requests the following connection intervals: HIGH (11-15ms). NORMAL (30-50ms). LOW (100-125ms). + /// Its not possible to request a specific connection interval. + /// + /// Important: + /// On Android: This function will only work with API level 21 and higher. Other API level will return false as function result. + /// On iOS: Updating the connection interval is not supported by iOS. The function simply returns true. + /// + /// True if the update request was sucessfull. On iOS it will always return true. + /// The requested interval (High/Low/Normal) + Task UpdateConnectionIntervalAsync(ConnectionInterval interval); } } \ No newline at end of file diff --git a/Source/Plugin.BLE.Abstractions/DeviceBase.cs b/Source/Plugin.BLE.Abstractions/DeviceBase.cs index 1474ead0..785791e5 100644 --- a/Source/Plugin.BLE.Abstractions/DeviceBase.cs +++ b/Source/Plugin.BLE.Abstractions/DeviceBase.cs @@ -75,10 +75,16 @@ public async Task RequestMtuAsync(int requestValue) return await RequestMtuNativeAsync(requestValue); } + public async Task UpdateConnectionIntervalAsync(ConnectionInterval interval) + { + return await UpdateConnectionIntervalNativeAsync(interval); + } + public abstract Task UpdateRssiAsync(); protected abstract DeviceState GetState(); protected abstract Task> GetServicesNativeAsync(); protected abstract Task RequestMtuNativeAsync(int requestValue); + protected abstract Task UpdateConnectionIntervalNativeAsync(ConnectionInterval interval); public override string ToString() { diff --git a/Source/Plugin.BLE.Abstractions/Plugin.BLE.Abstractions.csproj b/Source/Plugin.BLE.Abstractions/Plugin.BLE.Abstractions.csproj index 50c540d4..5a273c88 100644 --- a/Source/Plugin.BLE.Abstractions/Plugin.BLE.Abstractions.csproj +++ b/Source/Plugin.BLE.Abstractions/Plugin.BLE.Abstractions.csproj @@ -77,6 +77,7 @@ +