Skip to content

Commit

Permalink
Merge pull request #13 from cslrfid/release-2.0.18
Browse files Browse the repository at this point in the history
Updates for 8K Block Read/Write
  • Loading branch information
ksclam authored May 17, 2019
2 parents 8ff3610 + c268638 commit f7acda9
Show file tree
Hide file tree
Showing 34 changed files with 1,727 additions and 346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
<Debugger>Xamarin</Debugger>
<AndroidTlsProvider>btls</AndroidTlsProvider>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -61,9 +58,6 @@
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<Debugger>Xamarin</Debugger>
<DebugSymbols>False</DebugSymbols>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="FormsViewGroup, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="csl.cs108fulldemo.demo" android:installLocation="auto" android:versionCode="163" android:versionName="2.0.15">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="csl.cs108fulldemo.demo" android:installLocation="auto" android:versionCode="174" android:versionName="2.0.18">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" />
<application android:label="CS108 C# Demo" android:icon="@drawable/icon" android:theme="@style/MyTheme"></application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/window_background</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:textAllCaps">false</item>
</style>
</resources>
6 changes: 4 additions & 2 deletions CS108 Demo/Source/BLE.Client/BLE.Client.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleShortVersionString</key>
<string>2.0.15</string>
<string>2.0.18</string>
<key>NSCalendarsUsageDescription</key>
<string>Only for testing, we don&apos;t need the data to do anything</string>
<key>UIApplicationExitsOnSuspend</key>
Expand Down Expand Up @@ -54,6 +54,8 @@
<true/>
</dict>
<key>CFBundleVersion</key>
<string>163</string>
<string>174</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>The Program reads the RFID tag ID and couples that with the location of the reader and then send this to the cloud server so that the location of the RFID tag ID is de facto reported and saved in Cloud Server</string>
</dict>
</plist>
20 changes: 20 additions & 0 deletions CS108 Demo/Source/BLE.Client/BLE.Client/BLE.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@
<Compile Include="Pages\PageBarcodeScan.xaml.cs">
<DependentUpon>PageBarcodeScan.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PageBlockWrite.xaml.cs">
<DependentUpon>PageBlockWrite.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PageFilter.xaml.cs">
<DependentUpon>PageFilter.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PageRFMicronNickName.xaml.cs">
<DependentUpon>PageRFMicronNickname.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PageRFMicroReadTemp.xaml.cs">
<DependentUpon>PageRFMicroReadTemp.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -120,6 +126,7 @@
<Compile Include="Pages\DeviceListPage.xaml.cs">
<DependentUpon>DeviceListPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\ViewModelBlockWrite.cs" />
<Compile Include="ViewModels\ViewModelFilter.cs" />
<Compile Include="ViewModels\ViewModelGeiger.cs" />
<Compile Include="ViewModels\ViewModelRFMicroInventory.cs" />
Expand All @@ -128,6 +135,7 @@
<Compile Include="ViewModels\ViewModelMultiBankInventory.cs" />
<Compile Include="ViewModels\ViewModelInventorynScan.cs" />
<Compile Include="ViewModels\ViewModelMainMenu.cs" />
<Compile Include="ViewModels\ViewModelRFMicroNickname.cs" />
<Compile Include="ViewModels\ViewModelRFMicroReadTemp.cs" />
<Compile Include="ViewModels\ViewModelRFMicroSetting .cs" />
<Compile Include="ViewModels\ViewModelUCODEDNA.cs" />
Expand Down Expand Up @@ -395,6 +403,18 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\PageRFMicronNickname.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\PageBlockWrite.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.4.247\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.4.247\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
Expand Down
24 changes: 21 additions & 3 deletions CS108 Demo/Source/BLE.Client/BLE.Client/BleMvxApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,32 @@ public class BleMvxApplication : MvxApplication
public static bool _batteryLow = false;

// for RFMicro
public static int _sensorValueType = 0; // 0 = Temp, 1 = Sensor Code
public static uint _minOCRSSI = 0;
public static uint _maxOCRSSI = 0;
public static int _rfMicro_Power; // 0 ~ 4
public static int _rfMicro_SensorType; // 0=Sensor code, 1=Temperature
public static int _rfMicro_SensorUnit; // 0=code, 1=f, 2=c, 3=%
public static int _rfMicro_minOCRSSI;
public static int _rfMicro_maxOCRSSI;
public static int _rfMicro_thresholdComparison; // 0 ~ 1
public static int _rfMicro_thresholdValue;
public static string _rfMicro_thresholdColor;

public override void Initialize()
{
RFMicroTagNicknameViewModel item;
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000417"; item.Nickname = "Test Tag 1"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000001"; item.Nickname = "Motor 1"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000002"; item.Nickname = "Motor 2"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000003"; item.Nickname = "Motor 3"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000004"; item.Nickname = "Milk 1"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000005"; item.Nickname = "Milk 2"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000006"; item.Nickname = "Milk 3"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000007"; item.Nickname = "Diaper 1"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000008"; item.Nickname = "Diaper 2"; ViewModelRFMicroNickname._TagNicknameList.Add(item);
item = new RFMicroTagNicknameViewModel(); item.EPC = "000000000000000000000009"; item.Nickname = "Diaper 3"; ViewModelRFMicroNickname._TagNicknameList.Add(item);

RegisterAppStart<ViewModelMainMenu>();
//RegisterAppStart<DeviceListViewModel>();

}

//static async public void LoadConfig(string readerID)
Expand Down
39 changes: 39 additions & 0 deletions CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml
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 CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs
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);
}

}
}
10 changes: 0 additions & 10 deletions CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml

This file was deleted.

20 changes: 0 additions & 20 deletions CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs

This file was deleted.

55 changes: 55 additions & 0 deletions CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml
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>

Loading

0 comments on commit f7acda9

Please sign in to comment.