-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from cslrfid/release-2.0.18
Updates for 8K Block Read/Write
- Loading branch information
Showing
34 changed files
with
1,727 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:pages="clr-namespace:BLE.Client.Pages;assembly=BLE.Client" | ||
x:Class="BLE.Client.Pages.PageBlockWrite" | ||
Title="Block Write"> | ||
|
||
<ScrollView> | ||
|
||
<StackLayout Padding="5, 3, 5, 0"> | ||
|
||
<Label Text="Selected EPC"/> | ||
<Editor x:Name="editorSelectedEPC" HorizontalOptions="FillAndExpand"/> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Bank " WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonBank" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonBankClicked" /> | ||
</StackLayout> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Block Write Size" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonSize" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonSizeClicked" /> | ||
</StackLayout> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Select data padding" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonPadding" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonPaddingClicked" /> | ||
</StackLayout> | ||
|
||
<Button Text="Block Write" Font="Large" BackgroundColor="#C3C3C3" Clicked="buttonBlockWriteClicked" /> | ||
<Button Text="Read Verify" Font="Large" BackgroundColor="#C3C3C3" Clicked="buttonReadVerifyClicked" /> | ||
|
||
<Label Text="Last result" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonResult" HorizontalOptions="FillAndExpand" BorderWidth ="1" /> | ||
|
||
</StackLayout> | ||
</ScrollView> | ||
</pages:BasePage> | ||
|
122 changes: 122 additions & 0 deletions
122
CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
namespace BLE.Client.Pages | ||
{ | ||
public partial class PageBlockWrite | ||
{ | ||
string[] _bankOptions = new string []{ "Bank3 (User Bank)", "Bank1 (EPC Bank)" }; | ||
string[] _sizeOptions = new string[] { "4K bit", "8K bit" }; | ||
string[] _paddingOptions = new string[] { "repeart 55AA ", "repeart AA55", "repeart 0000", "repeart FFFF", "repeart 0001", "repeart 0002", "repeart 0004", "repeart 0008", "repeart 0010", "repeart 0020", "repeart 0040", "repeart 0080", "repeart 0100", "repeart 0200", "repeart 0400", "repeart 0800", "repeart 1000", "repeart 2000", "repeart 4000", "repeart 8000" }; | ||
|
||
public PageBlockWrite() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnAppearing() | ||
{ | ||
base.OnAppearing(); | ||
|
||
editorSelectedEPC.Text = BleMvxApplication._SELECT_EPC; | ||
buttonBank.Text = _bankOptions[0]; | ||
buttonSize.Text = _sizeOptions[0]; | ||
buttonPadding.Text = _paddingOptions[0]; | ||
} | ||
|
||
protected override void OnDisappearing() | ||
{ | ||
base.OnDisappearing(); | ||
} | ||
|
||
public async void buttonBankClicked(object sender, EventArgs args) | ||
{ | ||
var answer = await DisplayActionSheet("Bank", "Cancel", null, _bankOptions); | ||
|
||
if (answer != "Cancel") | ||
{ | ||
buttonBank.Text = answer; | ||
} | ||
} | ||
|
||
public async void buttonSizeClicked(object sender, EventArgs args) | ||
{ | ||
var answer = await DisplayActionSheet("Data Size", "Cancel", null, _sizeOptions); | ||
|
||
if (answer != "Cancel") | ||
{ | ||
buttonSize.Text = answer; | ||
} | ||
} | ||
|
||
public async void buttonPaddingClicked(object sender, EventArgs args) | ||
{ | ||
var answer = await DisplayActionSheet("Sensor Type", "Cancel", null, _paddingOptions); | ||
|
||
if (answer != "Cancel") | ||
{ | ||
buttonPadding.Text = answer; | ||
} | ||
} | ||
|
||
void SelectTag() | ||
{ | ||
BleMvxApplication._reader.rfid.Options.TagSelected.epcMask = new CSLibrary.Structures.S_MASK(/*m_record.pc.ToString() + */editorSelectedEPC.Text); | ||
|
||
BleMvxApplication._reader.rfid.Options.TagSelected.flags = CSLibrary.Constants.SelectMaskFlags.ENABLE_TOGGLE; | ||
BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskOffset = 0; | ||
BleMvxApplication._reader.rfid.Options.TagSelected.epcMaskLength = (uint)BleMvxApplication._reader.rfid.Options.TagSelected.epcMask.Length * 8; | ||
BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_SELECTED); | ||
} | ||
|
||
void buttonBlockWriteClicked(object sender, EventArgs args) | ||
{ | ||
int dataWordSize = (Array.IndexOf(_sizeOptions, buttonSize.Text) == 0 ? 256 : 512); | ||
UInt16[] data = new UInt16[dataWordSize]; | ||
int paddingType = Array.IndexOf(_paddingOptions, buttonPadding.Text); | ||
UInt16 padding = 0; | ||
|
||
switch (paddingType) | ||
{ | ||
case 0: | ||
padding = 0x55AA; | ||
break; | ||
} | ||
|
||
for (int i = 0; i < dataWordSize; i++) | ||
data [i] = padding; | ||
|
||
SelectTag(); | ||
|
||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.flags = CSLibrary.Constants.SelectFlags.SELECT; | ||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.accessPassword = 0; | ||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.bank = CSLibrary.Constants.MemoryBank.USER; | ||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset = 0; | ||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.count = 256; // max 256 | ||
BleMvxApplication._reader.rfid.Options.TagBlockWrite.data = data; | ||
|
||
CSLibrary.Debug.WriteLine("4K Block Write Test Start"); | ||
BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_BLOCK_WRITE); | ||
} | ||
|
||
DateTime _startingTime; | ||
void buttonReadVerifyClicked(object sender, EventArgs args) | ||
{ | ||
SelectTag(); | ||
|
||
BleMvxApplication._reader.rfid.Options.TagReadUser.accessPassword = 0; | ||
BleMvxApplication._reader.rfid.Options.TagReadUser.offset = 0; // 0 | ||
BleMvxApplication._reader.rfid.Options.TagReadUser.count = 32; // 32 word = 64 byte = 512 bit | ||
|
||
_startingTime = DateTime.Now; | ||
BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ_USER); | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:pages="clr-namespace:BLE.Client.Pages;assembly=BLE.Client" | ||
x:Class="BLE.Client.Pages.PageBlockWrite" | ||
Title="Block Write"> | ||
|
||
<ScrollView> | ||
|
||
<StackLayout Padding="5, 3, 5, 0"> | ||
|
||
<Label Text="Selected EPC"/> | ||
<Editor x:Name="editorSelectedEPC" Text="{Binding editorSelectedEPCText, Mode=TwoWay}" HorizontalOptions="FillAndExpand"/> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Bank " WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonBank" Text="{Binding buttonBankText, Mode=TwoWay}" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonBankClicked" /> | ||
</StackLayout> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Block Write Size" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonSize" Text="{Binding buttonSizeText, Mode=TwoWay}" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonSizeClicked" /> | ||
</StackLayout> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Select data padding" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonPadding" Text="{Binding buttonPaddingText, Mode=TwoWay}" HorizontalOptions="FillAndExpand" BorderWidth ="1" Clicked="buttonPaddingClicked" /> | ||
</StackLayout> | ||
|
||
<Button Text="Block Write 4K/8K" Font="Large" BackgroundColor="#C3C3C3" Command="{Binding buttonBlockWriteCommand}" /> | ||
<Button Text="Read Verify 4K/8K" Font="Large" BackgroundColor="#C3C3C3" Command="{Binding buttonReadVerifyCommand}" /> | ||
|
||
<BoxView HorizontalOptions="FillAndExpand" HeightRequest="5" Color="Black"/> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Offset" WidthRequest="85" VerticalOptions="Center" /> | ||
<Entry x:Name="entryOffset" Text="{Binding entryOffsetText, Mode=TwoWay}" WidthRequest="110" HorizontalOptions="FillAndExpand" /> | ||
</StackLayout> | ||
|
||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="Length (word)" WidthRequest="85" VerticalOptions="Center" /> | ||
<Entry x:Name="entryLength" Text="{Binding entryLengthText, Mode=TwoWay}" WidthRequest="110" HorizontalOptions="FillAndExpand" /> | ||
</StackLayout> | ||
|
||
<Button Text="Block Write Offset n Length" Font="Large" BackgroundColor="#C3C3C3" Command="{Binding buttonBlockWritewOffsetnCountCommand}" /> | ||
|
||
<BoxView HorizontalOptions="FillAndExpand" HeightRequest="5" Color="Black"/> | ||
|
||
<Label Text="Message" WidthRequest="100" VerticalOptions="Center"/> | ||
<Button x:Name="buttonResult" Text="{Binding buttonResultText, Mode=OneWay}" HorizontalOptions="FillAndExpand" BorderWidth ="1" /> | ||
|
||
</StackLayout> | ||
</ScrollView> | ||
</pages:BasePage> | ||
|
Oops, something went wrong.