Skip to content
Open
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
13 changes: 9 additions & 4 deletions ShimmerBLE/BLE.Client/BLE.Client/Pages/DeviceListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,16 @@
-->
<ScrollView Orientation="Horizontal">
<StackLayout Orientation="Horizontal">
<Button Text="Start Scan"
<Button Text="Start Scan"
IsEnabled="{Binding IsScanPairAndConnectEnabled}"
Command="{Binding RefreshCommand}"
HorizontalOptions="End" />
<Button Text="Stop Scan"
<Button Text="Stop Scan"
IsEnabled="{Binding IsScanPairAndConnectEnabled}"
Command="{Binding StopScanCommand}"
HorizontalOptions="End" />
<Button Text="Pair"
<Button Text="Pair"
IsEnabled="{Binding IsScanPairAndConnectEnabled}"
Command="{Binding PairCommand}"
HorizontalOptions="End" />
</StackLayout>
Expand Down Expand Up @@ -411,7 +414,8 @@

<ScrollView Orientation="Horizontal">
<StackLayout Orientation="Horizontal">
<Button Text="Connect"
<Button Text="Connect"
IsEnabled="{Binding IsScanPairAndConnectEnabled}"
Command="{Binding ConnectCommand}"/>
<Button Text="Disconnect"
Command="{Binding DisconnectVRECommand}"
Expand Down Expand Up @@ -456,6 +460,7 @@
Command="{Binding SoftResetCommand}"
HorizontalOptions="End"/>
<Button Text="Connect Without Initialize"
IsEnabled="{Binding IsScanPairAndConnectEnabled}"
Command="{Binding ConnectWithoutInitializeCommand}"
HorizontalOptions="End" />
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using ShimmerAdvanceBLEAPI;
using ShimmerBLEAPI.Communications;
using shimmer.DTO;
using Acr.Collections;

namespace BLE.Client.ViewModels
{
Expand Down Expand Up @@ -131,6 +132,7 @@ public String PairingStatus
public MvxCommand ConnectWithoutInitializeCommand => new MvxCommand(() => Connect(false));

public ObservableCollection<DeviceListItemViewModel> Devices { get; set; } = new ObservableCollection<DeviceListItemViewModel>();
public ObservableCollection<DeviceListItemViewModel> ListOfScannedDevicesTemp { get; set; } = new ObservableCollection<DeviceListItemViewModel>();
public ObservableCollection<VerisenseSerialDevice> SerialDevices { get; set; } = new ObservableCollection<VerisenseSerialDevice>();
public bool IsRefreshing => (Adapter != null) ? Adapter.IsScanning : false;
public bool IsStateOn => _bluetoothLe.IsOn;
Expand Down Expand Up @@ -1890,7 +1892,10 @@ private void AddOrUpdateDevice(VerisenseBLEScannedDevice device)
}
else
{
Devices.Add(new DeviceListItemViewModel(device));
if(IsScanPairAndConnectEnabled)
{
Devices.Add(new DeviceListItemViewModel(device));
}
}
});
}
Expand Down Expand Up @@ -2406,6 +2411,25 @@ private void ShimmerDevice_BLEEvent(object sender, ShimmerBLEEventData e)

ShimmerDeviceBluetoothState previousState = CurrentState;
CurrentState = VerisenseBLEDevice.GetVerisenseBLEState();

if (previousState.Equals(ShimmerDeviceBluetoothState.Connecting)
&& CurrentState.Equals(ShimmerDeviceBluetoothState.Connected))
{
IsScanPairAndConnectEnabled = false;
foreach (DeviceListItemViewModel device in Devices)
{
ListOfScannedDevicesTemp.Add(device);
}
Devices.Clear();
foreach (DeviceListItemViewModel device in ListOfScannedDevicesTemp)
{
if (device.Id.Equals(VerisenseBLEDevice.Asm_uuid) && Devices.IsEmpty())
{
Devices.Add(device);
}
}
}

if ((previousState.Equals(ShimmerDeviceBluetoothState.StreamingLoggedData) || previousState.Equals(ShimmerDeviceBluetoothState.Streaming))
&& CurrentState.Equals(ShimmerDeviceBluetoothState.Disconnected)) //if it went from a streaming state to disconnect, we want to remember what the previous state was so can execute it upon reconnect
{
Expand All @@ -2418,6 +2442,10 @@ private void ShimmerDevice_BLEEvent(object sender, ShimmerBLEEventData e)
ReconnectTimer = new System.Threading.Timer(Reconnect, null, 5000, Timeout.Infinite);
}

if (VerisenseBLEDevice.GetVerisenseBLEState().Equals(ShimmerDeviceBluetoothState.Disconnected))
{
IsScanPairAndConnectEnabled = true;
}
DisconnectPressed = false;
}
else if (e.CurrentEvent == VerisenseBLEEvent.SyncLoggedDataNewPayload)
Expand Down Expand Up @@ -3347,6 +3375,19 @@ protected set
}
get { return deviceState; }
}
bool isScanPairAndConnectEnabled = true;
public bool IsScanPairAndConnectEnabled
{
protected set
{
if (isScanPairAndConnectEnabled != value)
{
isScanPairAndConnectEnabled = value;
RaisePropertyChanged();
}
}
get { return isScanPairAndConnectEnabled; }
}
public void OnCompleted()
{
throw new NotImplementedException();
Expand Down