Skip to content

Commit

Permalink
Changes to BLE Blugiga library to allow kisok/keyboard wedge mode. Sl…
Browse files Browse the repository at this point in the history
…ightly better handling of the Bluegiga COM port connection.
  • Loading branch information
dshalaby committed Jul 1, 2017
1 parent b6675d7 commit 8916f74
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 179 deletions.
5 changes: 3 additions & 2 deletions Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="Tappy Demo 2.2" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
Title="Tappy Demo 2.3" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
<Grid Background="{StaticResource LightBackground}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
Expand All @@ -21,7 +21,8 @@
</WrapPanel>
<WrapPanel Grid.Row="0" HorizontalAlignment="Right" >
<Button Margin="10" Height="15" Padding="0" Background="White" BorderBrush="{x:Null}" Style="{StaticResource StopButton}" Click="StopButton_Click"/>
<Button Name="autoDetectButton" Margin="10" Height="25" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" Style="{StaticResource USBButton}" Click="AutoDetectButton_Click"/>
<Button Name="autoDetectButton" Margin="10" Height="25" Padding="0" Background="{x:Null}"
BorderBrush="{x:Null}" Style="{StaticResource USBButton}" Click="AutoDetectButton_Click"/>
<Button Margin="10" Height="25" Style="{StaticResource DisconnectButton}" Click="disconnectButton_Click" Content="Disconnect"/>
<Button Margin="10" Height="25" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" Style="{StaticResource SettingsButton}" Click="SettingsButton_Click"/>
</WrapPanel>
Expand Down
68 changes: 43 additions & 25 deletions Example/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,37 +464,54 @@ private void AutoDetectButton_Click(object sender, RoutedEventArgs e)
else if (window.Protocol == CommunicationProtocol.Bluetooth)
{
batteryTab.Visibility = Visibility.Visible;
if (GetBluegigaDevice() == null)
{
ShowFailStatus("Please insert BLED112 dongle");
return;
}
}
if (GetBluegigaDevice() == null)
{
ShowFailStatus("Please insert BLED112 dongle");
return;
}

}

tappy.SwitchProtocol(window.Protocol);

ShowPendingStatus("Searching for a Tappy");
ShowPendingStatus("Searching for a Tappy");

Task.Run(() =>
{
if (tappy.AutoDetect())
{
ShowSuccessStatus($"Connected to {tappy.DeviceName}");
if (window.Protocol == CommunicationProtocol.Bluetooth)
{
try
{
Command cmd = new EnableDataThrottling(10, 5);
tappy.SendCommand(cmd);
}
catch
{
}
}
}
else
ShowFailStatus("No Tappy found");
if (tappy.AutoDetect())
{
ShowSuccessStatus($"Connected to {tappy.DeviceName}");
if (window.Protocol == CommunicationProtocol.Bluetooth)
{
try
{
Command cmd = new EnableDataThrottling(10, 5);
tappy.SendCommand(cmd);
}
catch
{
}
}
}
else
{
ShowFailStatus("No Tappy found");
if (window.Protocol == CommunicationProtocol.Bluetooth)
{
try
{
tappy.DisconnectBlueGiga();
}
catch
{
return;
}
}
}
});
}
}
Expand Down Expand Up @@ -709,6 +726,7 @@ private void disconnectButton_Click(object sender, RoutedEventArgs e)
try
{
tappy.Disconnect();
tappy.DisconnectBlueGiga();
ShowSuccessStatus("Disconnect was successful");
}
catch
Expand Down
6 changes: 5 additions & 1 deletion Example/Simple Styles.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<!-- SimpleStyles.XAML defines a set of control styles which are simplified starting points for creating your own controls -->

Expand Down
6 changes: 3 additions & 3 deletions Example/Tappy Tcmp Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TapTrack.Demo</RootNamespace>
<AssemblyName>Tappy Demo 2.2</AssemblyName>
<AssemblyName>Tappy Demo 2.3</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -49,7 +49,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Tappy Demo 2.2.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Tappy Demo 2.3.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -59,7 +59,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Tappy Demo 2.2.xml</DocumentationFile>
<DocumentationFile>bin\Release\Tappy Demo 2.3.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>DA55EDA3D657C041EF308F9D8CDF1B5A4950F2E4</ManifestCertificateThumbprint>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace TapTrack.Tcmp.CommandFamilies.System
{
/// <summary>
/// Command to configure thee Tappy when in keyboard wedge/ kiosk mode
/// </summary>
public class ConfigureKioskKeyboardWedgeMode : SystemCommand
{
public const byte commandCode = 0x06;

public override byte CommandCode
{
get
{
return commandCode;
}
}
public ConfigureKioskKeyboardWedgeMode(byte dualTagDetection, byte ndefReading, byte hearbeatPeriod, byte enableScanErrMsgs)
{
this.parameters.Add(dualTagDetection);
this.parameters.Add(ndefReading);
this.parameters.Add(hearbeatPeriod);
this.parameters.Add(enableScanErrMsgs);

}

}
}
2 changes: 1 addition & 1 deletion Tcmp-SDK/Tcmp/CommandFamilies/System/Ping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public class Ping : SystemCommand
{
private const byte commandCode = 0xFD;
public const byte commandCode = 0xFD;

public override byte CommandCode
{
Expand Down
31 changes: 27 additions & 4 deletions Tcmp-SDK/Tcmp/Communication/Bluetooth/BGLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3793,10 +3793,33 @@ BGAPI packet structure (as of 2012-11-07):

public UInt16 SendCommand(System.IO.Ports.SerialPort port, Byte[] cmd)
{
SetBusy(true);
if (bgapiPacketMode) port.Write(new Byte[] { (Byte)cmd.Length }, 0, 1);
port.Write(cmd, 0, cmd.Length);
return 0; // no error handling yet
if (port == null) //needed now that port is nullable (better than having it set to a random invalid port name on instantiation)
{
return 1;
}
else
{
SetBusy(true);
if (bgapiPacketMode) port.Write(new Byte[] { (Byte)cmd.Length }, 0, 1);
if (port != null)
{
try
{
port.Write(cmd, 0, cmd.Length);
return 0; // no error handling yet
}
catch
{
return 1;
}

}
else
{
return 1;
}
}

}

}
Expand Down
Loading

0 comments on commit 8916f74

Please sign in to comment.