Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public DeviceInfo(string uuid)
//"00000000-0000-0000-0000-c96117537402",
//"def7b570-bb64-5167-aa2c-76f634454258",
"7b3eba6c-026c-0861-bb0d-45d23d4dad64",
"00000000-0000-0000-0000-daa619f04ad7",
//"00000000-0000-0000-0000-daa619f04ad7",
//"00000000-0000-0000-0000-d02b463da2bb",
//"00000000-0000-0000-0000-e7ec37a0d234",
//"04514419-5ab1-6eee-a83d-334220dade3d",
Expand Down Expand Up @@ -103,6 +103,7 @@ public async void ConnectDevices()
{
Devices.Add(uuid, device);
}

device.ShimmerBLEEvent += ShimmerDevice_BLEEvent;
bool result = await device.Connect(true);
if (result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task<bool> StartScanForDevices()
{
BLEManagerEvent += BLEManager_BLEEvent;

RequestTCS = new TaskCompletionSource<bool>();
//RequestTCS = new TaskCompletionSource<bool>();
ListOfScannedKnownDevices = new List<VerisenseBLEScannedDevice>();

adapter.ScanMode = Plugin.BLE.Abstractions.Contracts.ScanMode.LowLatency;
Expand All @@ -81,7 +81,8 @@ public async Task<bool> StartScanForDevices()
adapter.DeviceAdvertised -= Adapter_DeviceAdvertised;
if (BLEManagerEvent != null)
BLEManagerEvent.Invoke(null, new BLEManagerEvent { CurrentEvent = shimmer.Communications.BLEManagerEvent.BLEAdapterEvent.ScanCompleted });
return RequestTCS.TrySetResult(true);
//return RequestTCS.TrySetResult(true); //commented out as currently this does nothing
return true;

}
catch (Exception ex)
Expand Down
124 changes: 124 additions & 0 deletions ShimmerBLE/ShimmerBLEAPI.iOS/Communications/VerisenseBLEManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using Plugin.BLE;
using Plugin.BLE.Abstractions.Contracts;
using shimmer.Communications;
using ShimmerBLEAPI.Communications;
using ShimmerBLEAPI.Devices;
using ShimmerBLEAPI.iOS.Communications;
using ShimmerBLEAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

[assembly: Dependency(typeof(VerisenseBLEManager))]
namespace ShimmerBLEAPI.iOS.Communications
{
public class VerisenseBLEManager : IVerisenseBLEManager
{
public event EventHandler<BLEManagerEvent> BLEManagerEvent;
static List<VerisenseBLEScannedDevice> ListOfScannedKnownDevices { get; set; }
static List<IDevice> deviceList { get; set; }
public static TaskCompletionSource<bool> RequestTCS { get; set; }
static IAdapter Adapter { get { return CrossBluetoothLE.Current.Adapter; } }

public EventHandler<BLEManagerEvent> GetBLEManagerEvent()
{
return BLEManagerEvent;
}
private void BLEManager_BLEEvent(object sender, BLEManagerEvent e)
{
if (e.CurrentEvent == shimmer.Communications.BLEManagerEvent.BLEAdapterEvent.ScanCompleted)
{
Console.WriteLine("Scan is completed.");
}
else if (e.CurrentEvent == shimmer.Communications.BLEManagerEvent.BLEAdapterEvent.DevicePaired)
{
Console.WriteLine(((VerisenseBLEScannedDevice)e.objMsg).Uuid.ToString() + " is paired.");
}
}
public List<VerisenseBLEScannedDevice> GetListOfScannedDevices()
{
return ListOfScannedKnownDevices;
}

public async Task<bool> StartScanForDevices()
{
try
{
BLEManagerEvent += BLEManager_BLEEvent;

//RequestTCS = new TaskCompletionSource<bool>();
ListOfScannedKnownDevices = new List<VerisenseBLEScannedDevice>();
Adapter.ScanMode = ScanMode.LowLatency;
Adapter.DeviceAdvertised += Adapter_DeviceAdvertised;

//Adapter.DeviceDiscovered += (s, a) => deviceList.Add(a.Device);
await Adapter.StartScanningForDevicesAsync();
Adapter.DeviceAdvertised -= Adapter_DeviceAdvertised;

if (BLEManagerEvent != null)
BLEManagerEvent.Invoke(null, new BLEManagerEvent { CurrentEvent = shimmer.Communications.BLEManagerEvent.BLEAdapterEvent.ScanCompleted });
//return RequestTCS.TrySetResult(true); //commented out as currently this does nothing
return true;
} catch (Exception e)
{
return false;
}
}

private static void Adapter_DeviceAdvertised(object sender, Plugin.BLE.Abstractions.EventArgs.DeviceEventArgs e)
{
string uuid = e.Device.Id.ToString();
var entry = ListOfScannedKnownDevices.FirstOrDefault(x => x.ID.Equals(uuid));

if (entry != null)
{
return;
}

if (e.Device.Name != null)
{
ListOfScannedKnownDevices.Add(new VerisenseBLEScannedDevice
{
Name = e.Device.Name,
ID = uuid,
RSSI = e.Device.Rssi,
Uuid = e.Device.Id,
IsConnectable = e.Device.Name.Contains("Verisense") ? true : false,
//IsPaired = GetBondingStatus(uuid), //unable to get bonding status in ios
IsPaired = false,
DeviceInfo = e.Device
}); ;
}

}

public static bool GetBondingStatus(string id)
{
var devices = Adapter.GetSystemConnectedOrPairedDevices();

var isBonded = devices.FirstOrDefault(x => x.Id.Equals(Guid.Parse(id))) != null;

return isBonded;
}
public async Task<bool> PairVerisenseDevice(object Device, IBLEPairingKeyGenerator generator)
{
VerisenseBLEDeviceIOS verisenseBLEDevice = new VerisenseBLEDeviceIOS(((VerisenseBLEScannedDevice)Device).Uuid.ToString(), "");
var pairingResult = await verisenseBLEDevice.PairDeviceAsync();
if (pairingResult)
{
if (BLEManagerEvent != null)
BLEManagerEvent.Invoke(null, new BLEManagerEvent { CurrentEvent = shimmer.Communications.BLEManagerEvent.BLEAdapterEvent.DevicePaired, objMsg = (VerisenseBLEScannedDevice)Device, message = "Device Is Successfully Paired" });
}
return pairingResult;
}

public void StopScanForDevices()
{
throw new NotImplementedException();
}

}
}
20 changes: 20 additions & 0 deletions ShimmerBLE/ShimmerBLEAPI.iOS/Communications/VerisenseBLEPairing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using shimmer.Models;
using ShimmerBLEAPI.Communications;
using ShimmerBLEAPI.iOS.Communications;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

[assembly: Dependency(typeof(VerisenseBLEPairing))]
namespace ShimmerBLEAPI.iOS.Communications
{
public class VerisenseBLEPairing : IVerisenseBLEPairing
{
public Task<BondingStatus> BondASMAutomatically(string deviceID)
{
throw new NotImplementedException();
}
}
}
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions ShimmerBLE/ShimmerBLEAPI.iOS/ShimmerBLEAPI.iOS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ShimmerBLEAPI\ShimmerBLEAPI.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Libs\" />
</ItemGroup>

<ItemGroup>
<Reference Include="Plugin.BLE" />
<Reference Include="Plugin.BLE.Abstractions" />
</ItemGroup>

<ItemGroup>
<Reference Update="Plugin.BLE">
<HintPath>Libs\Plugin.BLE.dll</HintPath>
</Reference>
<Reference Update="Plugin.BLE.Abstractions">
<HintPath>Libs\Plugin.BLE.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
90 changes: 88 additions & 2 deletions ShimmerBLE/ShimmerBLEAPI.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31829.152
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShimmerBLEAPI.UWP", "ShimmerBLEAPI.UWP\ShimmerBLEAPI.UWP.csproj", "{76908925-02BB-433B-A9E5-BB07EDFCB9C9}"
EndProject
Expand All @@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shimmer32FeetBLEAPIConsoleA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShimmerAPI", "..\ShimmerAPI\ShimmerAPI\ShimmerAPI.csproj", "{2230CC85-32B9-441C-A3C2-0DB4CC1D8CE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShimmerBLEAPI.iOS", "ShimmerBLEAPI.iOS\ShimmerBLEAPI.iOS.csproj", "{7384146A-CBDD-4E65-A20F-CB9597378B26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down Expand Up @@ -1060,6 +1062,90 @@ Global
{2230CC85-32B9-441C-A3C2-0DB4CC1D8CE9}.ShimmerAPIBasic|x64.Build.0 = Debug|Any CPU
{2230CC85-32B9-441C-A3C2-0DB4CC1D8CE9}.ShimmerAPIBasic|x86.ActiveCfg = Debug|Any CPU
{2230CC85-32B9-441C-A3C2-0DB4CC1D8CE9}.ShimmerAPIBasic|x86.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|ARM64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|ARM64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|ARM.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|ARM64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|ARM64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|iPhone.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|x64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|x64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|x86.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.AppStore|x86.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|ARM.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|ARM64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|iPhone.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|x64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|x64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|x86.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Debug|x86.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|Any CPU.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|ARM.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|ARM.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|ARM64.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|ARM64.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|iPhone.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|iPhone.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|x64.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|x64.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|x86.ActiveCfg = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.Release|x86.Build.0 = Release|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|Any CPU.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|Any CPU.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|ARM.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|ARM.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|ARM64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|ARM64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|iPhone.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|iPhone.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|iPhoneSimulator.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|x64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|x64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|x86.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPI|x86.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|Any CPU.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|Any CPU.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|ARM.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|ARM.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|ARM64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|ARM64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|iPhone.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|iPhone.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|iPhoneSimulator.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|x64.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|x64.Build.0 = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|x86.ActiveCfg = Debug|Any CPU
{7384146A-CBDD-4E65-A20F-CB9597378B26}.ShimmerAPIBasic|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 6 additions & 4 deletions ShimmerBLE/ShimmerBLEAPI/Communications/RadioPluginBLE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ public async Task<ConnectivityState> Disconnect()

if (ConnectedASM != null)
{
var timeout = 5000; //might need a longer period for windows
var timeout = 10000; //might need a longer period for windows
var task = adapter.DisconnectDeviceAsync(ConnectedASM);

AdvanceLog(nameof(RadioPluginBLE), "Disconnect Device", ConnectedASM.GetHashCode(), Asm_uuid.ToString());

if (await Task.WhenAny(task, Task.Delay(timeout)) == task)
{
// task completed within timeout
Expand All @@ -207,10 +210,9 @@ public async Task<ConnectivityState> Disconnect()
{
state = ConnectivityState.Limited;
}
//state = GetConnectivityStateFromDevice(ConnectedASM);

AdvanceLog(nameof(RadioPluginBLE), "Disconnect Device", ConnectedASM.GetHashCode(), Asm_uuid.ToString());
AdvanceLog(nameof(RadioPluginBLE), "ASM Connection Status", ConnectedASM.State.ToString(), Asm_uuid.ToString());
AdvanceLog(nameof(RadioPluginBLE), "ASM Connection Status", state.ToString(), Asm_uuid.ToString());
//state = GetConnectivityStateFromDevice(ConnectedASM);
}
//StateChange(ShimmerDeviceBluetoothState.Disconnected);
AdvanceLog(nameof(RadioPluginBLE), "Disconnect", "Success", Asm_uuid.ToString());
Expand Down
Loading