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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async void ScanDevices()

public void PasskeySettings_SelectedIndexChanged(object sender, EventArgs e)
{
writePasskeyConfigurationButton.IsEnabled = true;
switch (passkeySettings.SelectedIndex)
{
// no passkey
Expand All @@ -76,6 +77,7 @@ public void PasskeySettings_SelectedIndexChanged(object sender, EventArgs e)
break;
// custom
case 3:
writePasskeyConfigurationButton.IsEnabled = false;
deviceAdvertisingNamePrefix.Text = "";
passkeyId.Text = "";
passkey.Text = "";
Expand Down Expand Up @@ -146,6 +148,14 @@ private void ShimmerDevice_BLEEvent(object sender, ShimmerBLEEventData e)
{
deviceState.Text = device.GetVerisenseBLEState().ToString();
});
if(device.GetVerisenseBLEState() == ShimmerDeviceBluetoothState.Connected)
{
if (!device.MeetsMinimumFWRequirement(1,2,99)) // check if meets minimum requirement of 1.2.99
{
DisconnectDevices();
DisplayAlert("Error!", "Firmware below 1.02.99 is not supported\nYour device will now be disconnect", "OK");
}
}
}
}

Expand Down Expand Up @@ -222,7 +232,7 @@ public async void WritePasskeyConfigurationButton()
break;
// custom
case 3:
break;
return;
default: break;
}
}
Expand Down
13 changes: 13 additions & 0 deletions ShimmerBLE/ShimmerBLEAPI/Devices/VerisenseBLEDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,19 @@ public async Task<IBasePayload> ExecuteRequest(params Object[] reqObjects)
case RequestType.WriteProductionConfig:
if (additionalBytesToWrite != null)
{
if (additionalBytesToWrite.Length >= 55)
{
byte[] passkeyBytes = new byte[ProdConfig.PasskeyLength];
Array.Copy(additionalBytesToWrite, (int)ProdConfigPayload.ConfigurationBytesIndexName.PASSKEY, passkeyBytes, 0, passkeyBytes.Length);
for (int i = 0; i < passkeyBytes.Length; i++)
{
if (passkeyBytes[i] != 0xFF && !int.TryParse(Encoding.UTF8.GetString(passkeyBytes, i, 1), out _))
{
throw new Exception("Passkey Must Be Numeric Values");
}
}
}

//needs a header
request = new byte[additionalBytesToWrite.Length + 3];
Array.Copy(additionalBytesToWrite, 0, request, 3, additionalBytesToWrite.Length);
Expand Down
24 changes: 24 additions & 0 deletions ShimmerBLE/ShimmerBLEAPI/Devices/VerisenseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,30 @@ public DeviceByteArraySettings(string displayName, byte[] operationalConfigurati
public string GetDescription() { return Description; }
}

/// <summary>
/// Returns true if the input version is smaller or equal
/// </summary>
/// <param name="compMajor"></param>
/// <param name="compMinor"></param>
/// <param name="compInternal"></param>
/// <returns></returns>
public bool MeetsMinimumFWRequirement(int compMajor, int compMinor, int compInternal)
{
if (ProdConfig != null)
{
if ((compMajor < ProdConfig.REV_FW_MAJOR)
|| (ProdConfig.REV_FW_MAJOR == compMajor && compMinor < ProdConfig.REV_FW_MINOR)
|| (ProdConfig.REV_FW_MAJOR == compMajor && ProdConfig.REV_FW_MINOR == compMinor && compInternal <= ProdConfig.REV_FW_INTERNAL))
{
return true; // if the version is smaller or equal
}
} else
{
throw new Exception("Production Config Unknown");
}
return false; // if less
}

public static DeviceByteSetting GetDeviceSettingFromConfigurationValue(DeviceByteSetting[] settings, int value)
{
foreach (DeviceByteSetting setting in settings)
Expand Down
13 changes: 8 additions & 5 deletions ShimmerBLE/ShimmerBLEAPI/Models/ProdConfigPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public enum ConfigurationBytesIndexName
ADVERTISING_NAME_PREFIX = 23
}

readonly int PasskeyIDLength = 2;
readonly int PasskeyLength = 6;
readonly int AdvertisingNameLength = 32;
public readonly int PasskeyIDLength = 2;
public readonly int PasskeyLength = 6;
public readonly int AdvertisingNameLength = 32;

public ProdConfigPayload(string payload)
{
Expand Down Expand Up @@ -137,9 +137,12 @@ protected void SetPasskey(string passkey)
}
else if (passkey.Length == PasskeyLength)
{
if (!int.TryParse(passkey, out _))
for (int i = 0; i < PasskeyLength; i++)
{
throw new Exception("Passkey Must Be Numeric Values");
if (!int.TryParse(passkey[i].ToString(), out _))
{
throw new Exception("Passkey Must Be Numeric Values");
}
}

byte[] passkeyArray = Encoding.UTF8.GetBytes(passkey);
Expand Down